]> asedeno.scripts.mit.edu Git - linux.git/commit
rtc: snvs: Add timeouts to avoid kernel lockups
authorTrent Piepho <tpiepho@impinj.com>
Wed, 16 May 2018 23:45:51 +0000 (16:45 -0700)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Wed, 11 Jul 2018 18:41:09 +0000 (20:41 +0200)
commitcd7f3a249dbed2858e6c2f30e5be7f1f7a709ee2
treefe0e55dcbe6fd38aefb3b39136145cb6a90c655c
parent7874b919866ba91bac253fa219d3d4c82bb944df
rtc: snvs: Add timeouts to avoid kernel lockups

In order to read correctly from asynchronously updated RTC registers,
it's necessary to read repeatedly until their values do not change from
read to read.  It's also necessary to wait for three RTC clock ticks for
certain operations.  There are no timeouts in this code and these
operations could possibly loop forever.

To avoid kernel hangs, put in timeouts.

The iMX7d can be configured to stop the SRTC on a tamper event, which
will lockup the kernel inside this driver as described above.

These hangs can happen when running under qemu, which doesn't emulate
the SNVS RTC, though currently the driver will refuse to load on qemu
due to a timeout in the driver probe method.

It could also happen if the SRTC block where somehow placed into reset
or the slow speed clock that drives the SRTC counter (but not the CPU)
were to stop.

The symptoms on a two core iMX7d are a work queue hang on
rtc_timer_do_work(), which eventually blocks a systemd fsnotify
operation that triggers a work queue flush, causing systemd to hang and
thus causing all services that should be started by systemd, like a
console getty, to fail to start or stop.

Also optimize the wait code to wait less.  It only needs to wait for the
clock to advance three ticks, not to see it change three times.

Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
Cc: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Signed-off-by: Trent Piepho <tpiepho@impinj.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/rtc/rtc-snvs.c