From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To: Trent Piepho <tpiepho@impinj.com>
Cc: linux-rtc@vger.kernel.org,
Alessandro Zummo <a.zummo@towertech.it>,
Fabio Estevam <fabio.estevam@nxp.com>,
Shawn Guo <shawn.guo@linaro.org>,
Bryan O'Donoghue <pure.logic@nexus-software.ie>
Subject: Re: [PATCH v2] rtc-snvs: Add timeouts to avoid kernel lockups
Date: Thu, 12 Jul 2018 11:33:40 +0200 [thread overview]
Message-ID: <20180712093340.GC16084@piout.net> (raw)
In-Reply-To: <20180516234551.24954-1-tpiepho@impinj.com>
On 16/05/2018 16:45:51-0700, Trent Piepho wrote:
> 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>
> ---
> drivers/rtc/rtc-snvs.c | 105 ++++++++++++++++++++++++++++++++-----------------
> 1 file changed, 70 insertions(+), 35 deletions(-)
>
Applied, thanks.
--
Alexandre Belloni, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
prev parent reply other threads:[~2018-07-12 9:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-16 23:45 [PATCH v2] rtc-snvs: Add timeouts to avoid kernel lockups Trent Piepho
2018-07-12 9:33 ` Alexandre Belloni [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180712093340.GC16084@piout.net \
--to=alexandre.belloni@free-electrons.com \
--cc=a.zummo@towertech.it \
--cc=fabio.estevam@nxp.com \
--cc=linux-rtc@vger.kernel.org \
--cc=pure.logic@nexus-software.ie \
--cc=shawn.guo@linaro.org \
--cc=tpiepho@impinj.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).