Linux RTC
 help / color / mirror / Atom feed
* [rtc-linux] rtc ds3232 call trace in kernel
@ 2016-04-18  6:15 Qianyu Gong
  2016-04-18 13:02 ` [rtc-linux] " Akinobu Mita
  2016-04-18 16:21 ` [rtc-linux] " Alexandre Belloni
  0 siblings, 2 replies; 7+ messages in thread
From: Qianyu Gong @ 2016-04-18  6:15 UTC (permalink / raw)
  To: akinobu.mita@gmail.com, alexandre.belloni@free-electrons.com
  Cc: Mingkai Hu, rtc-linux@googlegroups.com,
	linux-kernel@vger.kernel.org

[-- Attachment #1: Type: text/plain, Size: 1596 bytes --]

Hi Akinobu,

I got an rtc call trace when booting 4.6 kernel on our board and I found it
was caused by this patch:

commit fc1dcb0b39dbb10d3290f2fcd6e154670f699166
Author: Akinobu Mita <akinobu.mita@gmail.com>
Date:   Mon Mar 7 00:27:53 2016 +0900

    rtc: ds3232: use rtc->ops_lock to protect alarm operations

    ds3232->mutex is used to protect for alarm operations which
    need to access status and control registers.

    But we can use rtc->ops_lock instead.  rtc->ops_lock is held when most
    of rtc_class_ops methods are called, so we only need to explicitly
    acquire it from irq handler in order to protect form concurrent
    accesses.

    Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com

The problem is that rtc->ops_lock would be accessed in ds3232_irq()
without being initialized as rtc_device_register() is called too late.

As I'm not familiar with rtc things, could I just revert the patch or you already
have a solution to this problem? Thanks in advance.


Regards,
Qianyu

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: Type: text/html, Size: 5465 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [rtc-linux] Re: rtc ds3232 call trace in kernel
  2016-04-18  6:15 [rtc-linux] rtc ds3232 call trace in kernel Qianyu Gong
@ 2016-04-18 13:02 ` Akinobu Mita
  2016-04-19  2:36   ` [rtc-linux] " Qianyu Gong
  2016-04-18 16:21 ` [rtc-linux] " Alexandre Belloni
  1 sibling, 1 reply; 7+ messages in thread
From: Akinobu Mita @ 2016-04-18 13:02 UTC (permalink / raw)
  To: Qianyu Gong
  Cc: alexandre.belloni@free-electrons.com, Mingkai Hu,
	rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org

2016-04-18 15:15 GMT+09:00 Qianyu Gong <qianyu.gong@nxp.com>:
> Hi Akinobu,
>
>
>
> I got an rtc call trace when booting 4.6 kernel on our board and I found =
it
>
> was caused by this patch:
>
>
>
> commit fc1dcb0b39dbb10d3290f2fcd6e154670f699166
>
> Author: Akinobu Mita <akinobu.mita@gmail.com>
>
> Date:   Mon Mar 7 00:27:53 2016 +0900
>
>
>
>     rtc: ds3232: use rtc->ops_lock to protect alarm operations
>
>
>
>     ds3232->mutex is used to protect for alarm operations which
>
>     need to access status and control registers.
>
>
>
>     But we can use rtc->ops_lock instead.  rtc->ops_lock is held when mos=
t
>
>     of rtc_class_ops methods are called, so we only need to explicitly
>
>     acquire it from irq handler in order to protect form concurrent
>
>     accesses.
>
>
>
>     Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com
>
>
>
> The problem is that rtc->ops_lock would be accessed in ds3232_irq()
>
> without being initialized as rtc_device_register() is called too late.

You have already identified the root cause of this issue.

> As I=E2=80=99m not familiar with rtc things, could I just revert the patc=
h or you
> already
>
> have a solution to this problem? Thanks in advance.

Could you check if the problem is resolved by moving the call of
devm_rtc_device_register() from the end of ds3232_probe() to just
before registering irq handler?

--=20
--=20
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---=20
You received this message because you are subscribed to the Google Groups "=
rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [rtc-linux] Re: rtc ds3232 call trace in kernel
  2016-04-18  6:15 [rtc-linux] rtc ds3232 call trace in kernel Qianyu Gong
  2016-04-18 13:02 ` [rtc-linux] " Akinobu Mita
@ 2016-04-18 16:21 ` Alexandre Belloni
  2016-04-19  2:54   ` [rtc-linux] " Qianyu Gong
  1 sibling, 1 reply; 7+ messages in thread
From: Alexandre Belloni @ 2016-04-18 16:21 UTC (permalink / raw)
  To: Qianyu Gong
  Cc: akinobu.mita@gmail.com, Mingkai Hu, rtc-linux@googlegroups.com,
	linux-kernel@vger.kernel.org

On 18/04/2016 at 06:15:40 +0000, Qianyu Gong wrote :
> Hi Akinobu,
> 
> I got an rtc call trace when booting 4.6 kernel on our board and I found it
> was caused by this patch:
> 
> commit fc1dcb0b39dbb10d3290f2fcd6e154670f699166
> Author: Akinobu Mita <akinobu.mita@gmail.com>
> Date:   Mon Mar 7 00:27:53 2016 +0900
> 
>     rtc: ds3232: use rtc->ops_lock to protect alarm operations
> 
>     ds3232->mutex is used to protect for alarm operations which
>     need to access status and control registers.
> 
>     But we can use rtc->ops_lock instead.  rtc->ops_lock is held when most
>     of rtc_class_ops methods are called, so we only need to explicitly
>     acquire it from irq handler in order to protect form concurrent
>     accesses.
> 
>     Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com
> 
> The problem is that rtc->ops_lock would be accessed in ds3232_irq()
> without being initialized as rtc_device_register() is called too late.
> 
> As I'm not familiar with rtc things, could I just revert the patch or you already
> have a solution to this problem? Thanks in advance.
> 
> 

Well, many RTC drivers actually suffer from that. I'm planning to change
the infrastructure to handle this case better.
Meanwhile, this is worth fixing.


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [rtc-linux] RE: rtc ds3232 call trace in kernel
  2016-04-18 13:02 ` [rtc-linux] " Akinobu Mita
@ 2016-04-19  2:36   ` Qianyu Gong
  2016-04-19  3:58     ` [rtc-linux] " Akinobu Mita
  0 siblings, 1 reply; 7+ messages in thread
From: Qianyu Gong @ 2016-04-19  2:36 UTC (permalink / raw)
  To: Akinobu Mita
  Cc: alexandre.belloni@free-electrons.com, Mingkai Hu,
	rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org


> -----Original Message-----
> From: Akinobu Mita [mailto:akinobu.mita@gmail.com]
> Sent: Monday, April 18, 2016 9:02 PM
> To: Qianyu Gong <qianyu.gong@nxp.com>
> Cc: alexandre.belloni@free-electrons.com; Mingkai Hu <mingkai.hu@nxp.com>=
;
> rtc-linux@googlegroups.com; linux-kernel@vger.kernel.org
> Subject: Re: rtc ds3232 call trace in kernel
>=20
> 2016-04-18 15:15 GMT+09:00 Qianyu Gong <qianyu.gong@nxp.com>:
> > Hi Akinobu,
> >
> >
> >
> > I got an rtc call trace when booting 4.6 kernel on our board and I
> > found it
> >
> > was caused by this patch:
> >
> >
> >
> > commit fc1dcb0b39dbb10d3290f2fcd6e154670f699166
> >
> > Author: Akinobu Mita <akinobu.mita@gmail.com>
> >
> > Date:   Mon Mar 7 00:27:53 2016 +0900
> >
> >
> >
> >     rtc: ds3232: use rtc->ops_lock to protect alarm operations
> >
> >
> >
> >     ds3232->mutex is used to protect for alarm operations which
> >
> >     need to access status and control registers.
> >
> >
> >
> >     But we can use rtc->ops_lock instead.  rtc->ops_lock is held when
> > most
> >
> >     of rtc_class_ops methods are called, so we only need to explicitly
> >
> >     acquire it from irq handler in order to protect form concurrent
> >
> >     accesses.
> >
> >
> >
> >     Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> >
> > Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com
> >
> >
> >
> > The problem is that rtc->ops_lock would be accessed in ds3232_irq()
> >
> > without being initialized as rtc_device_register() is called too late.
>=20
> You have already identified the root cause of this issue.
>=20
> > As I=E2=80=99m not familiar with rtc things, could I just revert the pa=
tch or
> > you already
> >
> > have a solution to this problem? Thanks in advance.
>=20
> Could you check if the problem is resolved by moving the call of
> devm_rtc_device_register() from the end of ds3232_probe() to just before
> registering irq handler?

Yes. It works(no call trace now).=20

Regards,
Qianyu

--=20
--=20
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---=20
You received this message because you are subscribed to the Google Groups "=
rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [rtc-linux] RE: rtc ds3232 call trace in kernel
  2016-04-18 16:21 ` [rtc-linux] " Alexandre Belloni
@ 2016-04-19  2:54   ` Qianyu Gong
  0 siblings, 0 replies; 7+ messages in thread
From: Qianyu Gong @ 2016-04-19  2:54 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: akinobu.mita@gmail.com, Mingkai Hu, rtc-linux@googlegroups.com,
	linux-kernel@vger.kernel.org


> -----Original Message-----
> From: Alexandre Belloni [mailto:alexandre.belloni@free-electrons.com]
> Sent: Tuesday, April 19, 2016 12:22 AM
> To: Qianyu Gong <qianyu.gong@nxp.com>
> Cc: akinobu.mita@gmail.com; Mingkai Hu <mingkai.hu@nxp.com>; rtc-
> linux@googlegroups.com; linux-kernel@vger.kernel.org
> Subject: Re: rtc ds3232 call trace in kernel
> 
> On 18/04/2016 at 06:15:40 +0000, Qianyu Gong wrote :
> > Hi Akinobu,
> >
> > I got an rtc call trace when booting 4.6 kernel on our board and I
> > found it was caused by this patch:
> >
> > commit fc1dcb0b39dbb10d3290f2fcd6e154670f699166
> > Author: Akinobu Mita <akinobu.mita@gmail.com>
> > Date:   Mon Mar 7 00:27:53 2016 +0900
> >
> >     rtc: ds3232: use rtc->ops_lock to protect alarm operations
> >
> >     ds3232->mutex is used to protect for alarm operations which
> >     need to access status and control registers.
> >
> >     But we can use rtc->ops_lock instead.  rtc->ops_lock is held when most
> >     of rtc_class_ops methods are called, so we only need to explicitly
> >     acquire it from irq handler in order to protect form concurrent
> >     accesses.
> >
> >     Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> > Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com
> >
> > The problem is that rtc->ops_lock would be accessed in ds3232_irq()
> > without being initialized as rtc_device_register() is called too late.
> >
> > As I'm not familiar with rtc things, could I just revert the patch or
> > you already have a solution to this problem? Thanks in advance.
> >
> >
> 
> Well, many RTC drivers actually suffer from that. I'm planning to change the
> infrastructure to handle this case better.
> Meanwhile, this is worth fixing.
> 
> 
> --
> Alexandre Belloni, Free Electrons
> Embedded Linux, Kernel and Android engineering http://free-electrons.com

Thanks. I followed Akinobu's suggest and put devm_rtc_device_register() just
before registering the irq handler. The call trace disappeared. Looks like it's 
working well.


Regards,
Qianyu

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [rtc-linux] Re: rtc ds3232 call trace in kernel
  2016-04-19  2:36   ` [rtc-linux] " Qianyu Gong
@ 2016-04-19  3:58     ` Akinobu Mita
  2016-04-19  4:11       ` [rtc-linux] " Qianyu Gong
  0 siblings, 1 reply; 7+ messages in thread
From: Akinobu Mita @ 2016-04-19  3:58 UTC (permalink / raw)
  To: Qianyu Gong
  Cc: alexandre.belloni@free-electrons.com, Mingkai Hu,
	rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org

2016-04-19 11:36 GMT+09:00 Qianyu Gong <qianyu.gong@nxp.com>:
>
>> -----Original Message-----
>> From: Akinobu Mita [mailto:akinobu.mita@gmail.com]
>> Sent: Monday, April 18, 2016 9:02 PM
>> To: Qianyu Gong <qianyu.gong@nxp.com>
>> Cc: alexandre.belloni@free-electrons.com; Mingkai Hu <mingkai.hu@nxp.com=
>;
>> rtc-linux@googlegroups.com; linux-kernel@vger.kernel.org
>> Subject: Re: rtc ds3232 call trace in kernel
>>
>> 2016-04-18 15:15 GMT+09:00 Qianyu Gong <qianyu.gong@nxp.com>:
>> > Hi Akinobu,
>> >
>> >
>> >
>> > I got an rtc call trace when booting 4.6 kernel on our board and I
>> > found it
>> >
>> > was caused by this patch:
>> >
>> >
>> >
>> > commit fc1dcb0b39dbb10d3290f2fcd6e154670f699166
>> >
>> > Author: Akinobu Mita <akinobu.mita@gmail.com>
>> >
>> > Date:   Mon Mar 7 00:27:53 2016 +0900
>> >
>> >
>> >
>> >     rtc: ds3232: use rtc->ops_lock to protect alarm operations
>> >
>> >
>> >
>> >     ds3232->mutex is used to protect for alarm operations which
>> >
>> >     need to access status and control registers.
>> >
>> >
>> >
>> >     But we can use rtc->ops_lock instead.  rtc->ops_lock is held when
>> > most
>> >
>> >     of rtc_class_ops methods are called, so we only need to explicitly
>> >
>> >     acquire it from irq handler in order to protect form concurrent
>> >
>> >     accesses.
>> >
>> >
>> >
>> >     Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
>> >
>> > Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com
>> >
>> >
>> >
>> > The problem is that rtc->ops_lock would be accessed in ds3232_irq()
>> >
>> > without being initialized as rtc_device_register() is called too late.
>>
>> You have already identified the root cause of this issue.
>>
>> > As I=E2=80=99m not familiar with rtc things, could I just revert the p=
atch or
>> > you already
>> >
>> > have a solution to this problem? Thanks in advance.
>>
>> Could you check if the problem is resolved by moving the call of
>> devm_rtc_device_register() from the end of ds3232_probe() to just before
>> registering irq handler?
>
> Yes. It works(no call trace now).

Thanks for testing.  Do you mind submitting your patch to
rtc-linux@googlegroups.com ?

--=20
--=20
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---=20
You received this message because you are subscribed to the Google Groups "=
rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [rtc-linux] RE: rtc ds3232 call trace in kernel
  2016-04-19  3:58     ` [rtc-linux] " Akinobu Mita
@ 2016-04-19  4:11       ` Qianyu Gong
  0 siblings, 0 replies; 7+ messages in thread
From: Qianyu Gong @ 2016-04-19  4:11 UTC (permalink / raw)
  To: Akinobu Mita
  Cc: alexandre.belloni@free-electrons.com, Mingkai Hu,
	rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org

> -----Original Message-----
> From: Akinobu Mita [mailto:akinobu.mita@gmail.com]
> Sent: Tuesday, April 19, 2016 11:58 AM
> To: Qianyu Gong <qianyu.gong@nxp.com>
> Cc: alexandre.belloni@free-electrons.com; Mingkai Hu <mingkai.hu@nxp.com>=
;
> rtc-linux@googlegroups.com; linux-kernel@vger.kernel.org
> Subject: Re: rtc ds3232 call trace in kernel
>=20
> 2016-04-19 11:36 GMT+09:00 Qianyu Gong <qianyu.gong@nxp.com>:
> >
> >> -----Original Message-----
> >> From: Akinobu Mita [mailto:akinobu.mita@gmail.com]
> >> Sent: Monday, April 18, 2016 9:02 PM
> >> To: Qianyu Gong <qianyu.gong@nxp.com>
> >> Cc: alexandre.belloni@free-electrons.com; Mingkai Hu
> >> <mingkai.hu@nxp.com>; rtc-linux@googlegroups.com;
> >> linux-kernel@vger.kernel.org
> >> Subject: Re: rtc ds3232 call trace in kernel
> >>
> >> 2016-04-18 15:15 GMT+09:00 Qianyu Gong <qianyu.gong@nxp.com>:
> >> > Hi Akinobu,
> >> >
> >> >
> >> >
> >> > I got an rtc call trace when booting 4.6 kernel on our board and I
> >> > found it
> >> >
> >> > was caused by this patch:
> >> >
> >> >
> >> >
> >> > commit fc1dcb0b39dbb10d3290f2fcd6e154670f699166
> >> >
> >> > Author: Akinobu Mita <akinobu.mita@gmail.com>
> >> >
> >> > Date:   Mon Mar 7 00:27:53 2016 +0900
> >> >
> >> >
> >> >
> >> >     rtc: ds3232: use rtc->ops_lock to protect alarm operations
> >> >
> >> >
> >> >
> >> >     ds3232->mutex is used to protect for alarm operations which
> >> >
> >> >     need to access status and control registers.
> >> >
> >> >
> >> >
> >> >     But we can use rtc->ops_lock instead.  rtc->ops_lock is held
> >> > when most
> >> >
> >> >     of rtc_class_ops methods are called, so we only need to
> >> > explicitly
> >> >
> >> >     acquire it from irq handler in order to protect form concurrent
> >> >
> >> >     accesses.
> >> >
> >> >
> >> >
> >> >     Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> >> >
> >> > Signed-off-by: Alexandre Belloni
> >> > <alexandre.belloni@free-electrons.com
> >> >
> >> >
> >> >
> >> > The problem is that rtc->ops_lock would be accessed in ds3232_irq()
> >> >
> >> > without being initialized as rtc_device_register() is called too lat=
e.
> >>
> >> You have already identified the root cause of this issue.
> >>
> >> > As I=E2=80=99m not familiar with rtc things, could I just revert the=
 patch
> >> > or you already
> >> >
> >> > have a solution to this problem? Thanks in advance.
> >>
> >> Could you check if the problem is resolved by moving the call of
> >> devm_rtc_device_register() from the end of ds3232_probe() to just
> >> before registering irq handler?
> >
> > Yes. It works(no call trace now).
>=20
> Thanks for testing.  Do you mind submitting your patch to rtc-
> linux@googlegroups.com ?

No problem.:)

Regards,
Qianyu

--=20
--=20
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---=20
You received this message because you are subscribed to the Google Groups "=
rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-04-19  4:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-18  6:15 [rtc-linux] rtc ds3232 call trace in kernel Qianyu Gong
2016-04-18 13:02 ` [rtc-linux] " Akinobu Mita
2016-04-19  2:36   ` [rtc-linux] " Qianyu Gong
2016-04-19  3:58     ` [rtc-linux] " Akinobu Mita
2016-04-19  4:11       ` [rtc-linux] " Qianyu Gong
2016-04-18 16:21 ` [rtc-linux] " Alexandre Belloni
2016-04-19  2:54   ` [rtc-linux] " Qianyu Gong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox