Re: rtc ds3232 call trace in kernel

From: Akinobu Mita
Date: Mon Apr 18 2016 - 09:02:16 EST


2016-04-18 15:15 GMT+09:00 Qianyu Gong <qianyu.gong@xxxxxxx>:
> 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@xxxxxxxxx>
>
> 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@xxxxxxxxx>
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@xxxxxxxxxxxxxxxxxx
>
>
>
> 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âm 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?