<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/drivers/rtc/rtc-snvs.c, branch v5.4</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v5.4</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v5.4'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2019-09-01T06:48:23Z</updated>
<entry>
<title>rtc: snvs: switch to rtc_time64_to_tm/rtc_tm_to_time64</title>
<updated>2019-09-01T06:48:23Z</updated>
<author>
<name>Alexandre Belloni</name>
<email>alexandre.belloni@bootlin.com</email>
</author>
<published>2019-08-28T20:50:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=c59a9fc7272e56ba0575b9fcc346c5e4bf16b39d'/>
<id>urn:sha1:c59a9fc7272e56ba0575b9fcc346c5e4bf16b39d</id>
<content type='text'>
Call the 64bit versions of rtc_tm time conversion now that the range is
enforced by the core.

Link: https://lore.kernel.org/r/20190828205056.31321-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
</content>
</entry>
<entry>
<title>rtc: snvs: set range</title>
<updated>2019-09-01T06:48:15Z</updated>
<author>
<name>Alexandre Belloni</name>
<email>alexandre.belloni@bootlin.com</email>
</author>
<published>2019-08-28T20:50:55Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=79610340cac8840ad67572ca13afae03265edae6'/>
<id>urn:sha1:79610340cac8840ad67572ca13afae03265edae6</id>
<content type='text'>
The SNVS is a 47-bit counter incremented at 32768Hz, it is then a 32-bit
second counter.

Link: https://lore.kernel.org/r/20190828205056.31321-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
</content>
</entry>
<entry>
<title>rtc: snvs: fix possible race condition</title>
<updated>2019-08-29T15:53:12Z</updated>
<author>
<name>Anson Huang</name>
<email>Anson.Huang@nxp.com</email>
</author>
<published>2019-07-16T07:18:58Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=6fd4fe9b496d9ba3382992ff4fde3871d1b6f63d'/>
<id>urn:sha1:6fd4fe9b496d9ba3382992ff4fde3871d1b6f63d</id>
<content type='text'>
The RTC IRQ is requested before the struct rtc_device is allocated,
this may lead to a NULL pointer dereference in IRQ handler.

To fix this issue, allocating the rtc_device struct before requesting
the RTC IRQ using devm_rtc_allocate_device, and use rtc_register_device
to register the RTC device.

Signed-off-by: Anson Huang &lt;Anson.Huang@nxp.com&gt;
Reviewed-by: Dong Aisheng &lt;aisheng.dong@nxp.com&gt;
Link: https://lore.kernel.org/r/20190716071858.36750-1-Anson.Huang@nxp.com
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
</content>
</entry>
<entry>
<title>rtc: snvs: Use __maybe_unused instead of #if CONFIG_PM_SLEEP</title>
<updated>2019-05-08T20:14:36Z</updated>
<author>
<name>Anson Huang</name>
<email>anson.huang@nxp.com</email>
</author>
<published>2019-04-30T01:07:08Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=dacb6a4035a010e41abaf81c1cfe2beadfb05ec8'/>
<id>urn:sha1:dacb6a4035a010e41abaf81c1cfe2beadfb05ec8</id>
<content type='text'>
Use __maybe_unused for power management related functions
instead of #if CONFIG_PM_SLEEP to simply the code.

Signed-off-by: Anson Huang &lt;Anson.Huang@nxp.com&gt;
Reviewed-by: Dong Aisheng &lt;aisheng.dong@nxp.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
</content>
</entry>
<entry>
<title>rtc: snvs: use devm_platform_ioremap_resource() to simplify code</title>
<updated>2019-04-04T08:07:11Z</updated>
<author>
<name>Anson Huang</name>
<email>anson.huang@nxp.com</email>
</author>
<published>2019-04-01T05:29:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=0c46b07ce4d5000855d810d61bb18fb4b0c4cc3b'/>
<id>urn:sha1:0c46b07ce4d5000855d810d61bb18fb4b0c4cc3b</id>
<content type='text'>
Use the new helper devm_platform_ioremap_resource() which wraps the
platform_get_resource() and devm_ioremap_resource() together, to
simplify the code.

Signed-off-by: Anson Huang &lt;Anson.Huang@nxp.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
</content>
</entry>
<entry>
<title>rtc: snvs: use dev_pm_set_wake_irq() to simplify code</title>
<updated>2019-04-04T08:07:11Z</updated>
<author>
<name>Anson Huang</name>
<email>anson.huang@nxp.com</email>
</author>
<published>2019-03-27T06:18:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=e7afddb2b4d24fba318f5e74216bae06dcb36a10'/>
<id>urn:sha1:e7afddb2b4d24fba318f5e74216bae06dcb36a10</id>
<content type='text'>
With calling dev_pm_set_wake_irq() to set SNVS RTC as wakeup
source for suspend, generic wake irq mechanism will automatically
enable it as wakeup source when suspend, then the suspend/resume
callback which are ONLY for enabling/disabling irq wake can be
removed, it simplifies the code.

Signed-off-by: Anson Huang &lt;Anson.Huang@nxp.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
</content>
</entry>
<entry>
<title>rtc: snvs: make sure clock is enabled for interrupt handle</title>
<updated>2019-02-05T22:11:31Z</updated>
<author>
<name>Anson Huang</name>
<email>anson.huang@nxp.com</email>
</author>
<published>2019-01-11T07:09:02Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=edb190cb173416b9d7f59b3887ecc43f6d94a9ad'/>
<id>urn:sha1:edb190cb173416b9d7f59b3887ecc43f6d94a9ad</id>
<content type='text'>
During system suspend, the SNVS RTC's clock will be disabled in
noirq suspend phase, but SNVS RTC's alarm interrupt could still
arrive, system will hang if SNVS RTC driver tries to access register
without clock enabled, this patch fixes the issue of this scenario.

Signed-off-by: Anson Huang &lt;Anson.Huang@nxp.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
</content>
</entry>
<entry>
<title>rtc: snvs: Add timeouts to avoid kernel lockups</title>
<updated>2018-07-11T18:41:09Z</updated>
<author>
<name>Trent Piepho</name>
<email>tpiepho@impinj.com</email>
</author>
<published>2018-05-16T23:45:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=cd7f3a249dbed2858e6c2f30e5be7f1f7a709ee2'/>
<id>urn:sha1:cd7f3a249dbed2858e6c2f30e5be7f1f7a709ee2</id>
<content type='text'>
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 &lt;alexandre.belloni@free-electrons.com&gt;
Cc: Alessandro Zummo &lt;a.zummo@towertech.it&gt;
Cc: Fabio Estevam &lt;fabio.estevam@nxp.com&gt;
Cc: Shawn Guo &lt;shawn.guo@linaro.org&gt;
Cc: Bryan O'Donoghue &lt;pure.logic@nexus-software.ie&gt;
Signed-off-by: Trent Piepho &lt;tpiepho@impinj.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
</content>
</entry>
<entry>
<title>rtc: snvs: Switch to SPDX identifier</title>
<updated>2018-05-22T07:47:15Z</updated>
<author>
<name>Fabio Estevam</name>
<email>fabio.estevam@nxp.com</email>
</author>
<published>2018-05-22T02:45:58Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5874c7f16a10acba0db1658f24c3a7206c12ab14'/>
<id>urn:sha1:5874c7f16a10acba0db1658f24c3a7206c12ab14</id>
<content type='text'>
Adopt the SPDX license identifier headers to ease license compliance
management.

Signed-off-by: Fabio Estevam &lt;fabio.estevam@nxp.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
</content>
</entry>
<entry>
<title>rtc: snvs: Fix usage of snvs_rtc_enable</title>
<updated>2018-04-03T14:43:36Z</updated>
<author>
<name>Bryan O'Donoghue</name>
<email>pure.logic@nexus-software.ie</email>
</author>
<published>2018-03-28T19:14:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=1485991c024603b2fb4ae77beb7a0d741128a48e'/>
<id>urn:sha1:1485991c024603b2fb4ae77beb7a0d741128a48e</id>
<content type='text'>
commit 179a502f8c46 ("rtc: snvs: add Freescale rtc-snvs driver") introduces
the SNVS RTC driver with a function snvs_rtc_enable().

snvs_rtc_enable() can return an error on the enable path however this
driver does not currently trap that failure on the probe() path and
consequently if enabling the RTC fails we encounter a later error spinning
forever in rtc_write_sync_lp().

[   36.093481] [&lt;c010d630&gt;] (__irq_svc) from [&lt;c0c2e9ec&gt;] (_raw_spin_unlock_irqrestore+0x34/0x44)
[   36.102122] [&lt;c0c2e9ec&gt;] (_raw_spin_unlock_irqrestore) from [&lt;c072e32c&gt;] (regmap_read+0x4c/0x5c)
[   36.110938] [&lt;c072e32c&gt;] (regmap_read) from [&lt;c085d0f4&gt;] (rtc_write_sync_lp+0x6c/0x98)
[   36.118881] [&lt;c085d0f4&gt;] (rtc_write_sync_lp) from [&lt;c085d160&gt;] (snvs_rtc_alarm_irq_enable+0x40/0x4c)
[   36.128041] [&lt;c085d160&gt;] (snvs_rtc_alarm_irq_enable) from [&lt;c08567b4&gt;] (rtc_timer_do_work+0xd8/0x1a8)
[   36.137291] [&lt;c08567b4&gt;] (rtc_timer_do_work) from [&lt;c01441b8&gt;] (process_one_work+0x28c/0x76c)
[   36.145840] [&lt;c01441b8&gt;] (process_one_work) from [&lt;c01446cc&gt;] (worker_thread+0x34/0x58c)
[   36.153961] [&lt;c01446cc&gt;] (worker_thread) from [&lt;c014aee4&gt;] (kthread+0x138/0x150)
[   36.161388] [&lt;c014aee4&gt;] (kthread) from [&lt;c0107e14&gt;] (ret_from_fork+0x14/0x20)
[   36.168635] rcu_sched kthread starved for 2602 jiffies! g496 c495 f0x2 RCU_GP_WAIT_FQS(3) -&gt;state=0x0 -&gt;cpu=0
[   36.178564] rcu_sched       R  running task        0     8      2 0x00000000
[   36.185664] [&lt;c0c288b0&gt;] (__schedule) from [&lt;c0c29134&gt;] (schedule+0x3c/0xa0)
[   36.192739] [&lt;c0c29134&gt;] (schedule) from [&lt;c0c2db80&gt;] (schedule_timeout+0x78/0x4e0)
[   36.200422] [&lt;c0c2db80&gt;] (schedule_timeout) from [&lt;c01a7ab0&gt;] (rcu_gp_kthread+0x648/0x1864)
[   36.208800] [&lt;c01a7ab0&gt;] (rcu_gp_kthread) from [&lt;c014aee4&gt;] (kthread+0x138/0x150)
[   36.216309] [&lt;c014aee4&gt;] (kthread) from [&lt;c0107e14&gt;] (ret_from_fork+0x14/0x20)

This patch fixes by parsing the result of rtc_write_sync_lp() and
propagating both in the probe and elsewhere. If the RTC doesn't start we
don't proceed loading the driver and don't get into this loop mess later
on.

Fixes: 179a502f8c46 ("rtc: snvs: add Freescale rtc-snvs driver")
Signed-off-by: Bryan O'Donoghue &lt;pure.logic@nexus-software.ie&gt;
Acked-by: Shawn Guo &lt;shawn.guo@linaro.org&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
</content>
</entry>
</feed>
