<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/drivers/rtc/rtc-snvs.c, branch v4.14.151</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v4.14.151</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v4.14.151'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2019-10-07T16:55:10Z</updated>
<entry>
<title>rtc: snvs: fix possible race condition</title>
<updated>2019-10-07T16:55:10Z</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.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=dc93018d455f22adfb64643053b0630903dc1a72'/>
<id>urn:sha1:dc93018d455f22adfb64643053b0630903dc1a72</id>
<content type='text'>
[ Upstream commit 6fd4fe9b496d9ba3382992ff4fde3871d1b6f63d ]

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;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>rtc: snvs: Add timeouts to avoid kernel lockups</title>
<updated>2018-12-21T13:13:18Z</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.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=f1e1eb5c90b6b6a359e584e01468ce0c05801f4d'/>
<id>urn:sha1:f1e1eb5c90b6b6a359e584e01468ce0c05801f4d</id>
<content type='text'>
[ Upstream commit cd7f3a249dbed2858e6c2f30e5be7f1f7a709ee2 ]

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;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>rtc: snvs: Fix usage of snvs_rtc_enable</title>
<updated>2018-05-25T14:18:00Z</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.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=731d965a587c96ebd319bca7e09448482e01d7b1'/>
<id>urn:sha1:731d965a587c96ebd319bca7e09448482e01d7b1</id>
<content type='text'>
[ Upstream commit 1485991c024603b2fb4ae77beb7a0d741128a48e ]

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;
Signed-off-by: Sasha Levin &lt;alexander.levin@microsoft.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>rtc: snvs: fix an incorrect check of return value</title>
<updated>2017-05-04T22:43:50Z</updated>
<author>
<name>Pan Bian</name>
<email>bianpan2016@163.com</email>
</author>
<published>2017-04-23T05:43:24Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=758929005f06f954b7e1c87a1c9fdb44157b228f'/>
<id>urn:sha1:758929005f06f954b7e1c87a1c9fdb44157b228f</id>
<content type='text'>
Function devm_regmap_init_mmio() returns an ERR_PTR on error. However,
in function snvs_rtc_probe() its return value is checked against NULL.
This patch fixes it by checking the return value with IS_ERR().

Signed-off-by: Pan Bian &lt;bianpan2016@163.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
</content>
</entry>
<entry>
<title>rtc: snvs: add a missing write sync</title>
<updated>2017-02-01T11:44:24Z</updated>
<author>
<name>Guy Shapiro</name>
<email>guy.shapiro@mobi-wize.com</email>
</author>
<published>2017-01-29T09:57:19Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=7bb633b1a9812a6b9f3e49d0cf17f60a633914e5'/>
<id>urn:sha1:7bb633b1a9812a6b9f3e49d0cf17f60a633914e5</id>
<content type='text'>
The clear of the LPTA_EN flag should be synced before writing to the
alarm register. Omitting this synchronization creates a race when
trying to change existing alarm.

Signed-off-by: Guy Shapiro &lt;guy.shapiro@mobi-wize.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
</content>
</entry>
<entry>
<title>rtc: snvs: return error in case enable_irq_wake fails</title>
<updated>2016-05-20T10:33:51Z</updated>
<author>
<name>Stefan Agner</name>
<email>stefan@agner.ch</email>
</author>
<published>2016-04-20T23:09:57Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=a350259da4b0556fcf276c506a14f406d608c2b3'/>
<id>urn:sha1:a350259da4b0556fcf276c506a14f406d608c2b3</id>
<content type='text'>
If enable_irq_wake fails, we should return that error code so that
entering suspend fails. Otherwise we will get a WARNING along with
the hint of a unbalanced wake disable:
Unbalanced IRQ 37 wake disable

Signed-off-by: Stefan Agner &lt;stefan@agner.ch&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
</content>
</entry>
<entry>
<title>rtc: snvs: use syscon to access register</title>
<updated>2015-07-15T02:15:10Z</updated>
<author>
<name>Frank Li</name>
<email>Frank.Li@freescale.com</email>
</author>
<published>2015-05-26T16:25:57Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=d482893b1caa5345b066c9721bab6636059e2a61'/>
<id>urn:sha1:d482893b1caa5345b066c9721bab6636059e2a61</id>
<content type='text'>
snvs included rtc, on/off key, power-off module
change to syscon to access register

Signed-off-by: Frank Li &lt;Frank.Li@freescale.com&gt;
Acked-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
Signed-off-by: Shawn Guo &lt;shawn.guo@linaro.org&gt;
</content>
</entry>
<entry>
<title>rtc: snvs: fix wakealarm by call enable_irq_wake earlier</title>
<updated>2015-06-24T23:13:38Z</updated>
<author>
<name>Stefan Agner</name>
<email>stefan@agner.ch</email>
</author>
<published>2015-05-21T15:29:35Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=119434f44c78df8c4b6d67f835448542a4bd7e91'/>
<id>urn:sha1:119434f44c78df8c4b6d67f835448542a4bd7e91</id>
<content type='text'>
When entering suspend while an wakeup alarm is set, enable_set_wake
should make sure that the RTC interrupt keep being enabled and the
.irq_set_wake for the RTC interrupt get called. However, since the
driver uses the suspend_noirq callback, the call to enable_irq_wake
has been made after disabling the interrupts. While .irq_set_wake
has been called properly, the interrupt remained disabled.

Use the suspend callback to call enable_irq_wake early enough to
ensure the RTC interrupt remains enabled.

Fixes: 7654e9d4fd8f ("drivers/rtc/rtc-snvs: fix suspend/resume")
Cc:  &lt;stable@vger.kernel.org&gt; # 3.19
Signed-off-by: Stefan Agner &lt;stefan@agner.ch&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
</content>
</entry>
<entry>
<title>Merge tag 'driver-core-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core</title>
<updated>2014-12-15T00:10:09Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2014-12-15T00:10:09Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=e6b5be2be4e30037eb551e0ed09dd97bd00d85d3'/>
<id>urn:sha1:e6b5be2be4e30037eb551e0ed09dd97bd00d85d3</id>
<content type='text'>
Pull driver core update from Greg KH:
 "Here's the set of driver core patches for 3.19-rc1.

  They are dominated by the removal of the .owner field in platform
  drivers.  They touch a lot of files, but they are "simple" changes,
  just removing a line in a structure.

  Other than that, a few minor driver core and debugfs changes.  There
  are some ath9k patches coming in through this tree that have been
  acked by the wireless maintainers as they relied on the debugfs
  changes.

  Everything has been in linux-next for a while"

* tag 'driver-core-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (324 commits)
  Revert "ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries"
  fs: debugfs: add forward declaration for struct device type
  firmware class: Deletion of an unnecessary check before the function call "vunmap"
  firmware loader: fix hung task warning dump
  devcoredump: provide a one-way disable function
  device: Add dev_&lt;level&gt;_once variants
  ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries
  ath: use seq_file api for ath9k debugfs files
  debugfs: add helper function to create device related seq_file
  drivers/base: cacheinfo: remove noisy error boot message
  Revert "core: platform: add warning if driver has no owner"
  drivers: base: support cpu cache information interface to userspace via sysfs
  drivers: base: add cpu_device_create to support per-cpu devices
  topology: replace custom attribute macros with standard DEVICE_ATTR*
  cpumask: factor out show_cpumap into separate helper function
  driver core: Fix unbalanced device reference in drivers_probe
  driver core: fix race with userland in device_add()
  sysfs/kernfs: make read requests on pre-alloc files use the buffer.
  sysfs/kernfs: allow attributes to request write buffer be pre-allocated.
  fs: sysfs: return EGBIG on write if offset is larger than file size
  ...
</content>
</entry>
<entry>
<title>rtc: snvs: fix build with CONFIG_PM_SLEEP disabled</title>
<updated>2014-12-13T20:42:45Z</updated>
<author>
<name>Guenter Roeck</name>
<email>linux@roeck-us.net</email>
</author>
<published>2014-12-13T00:54:12Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=88221c32f98551727cd4b8137fcc857a5294b97f'/>
<id>urn:sha1:88221c32f98551727cd4b8137fcc857a5294b97f</id>
<content type='text'>
Commit 7654e9d4fd8f ("drivers/rtc/rtc-snvs: fix suspend/resume")
replaces SIMPLE_DEV_PM_OPS with direct declaration of snvs_rtc_pm_ops,
but does so outside #ifdef CONFIG_PM_SLEEP.  This causes the driver
build to fail if CONFIG_PM_SLEEP is not configured.

Fixes: 7654e9d4fd8f ("drivers/rtc/rtc-snvs: fix suspend/resume")
Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Cc: Sanchayan Maity &lt;maitysanchayan@gmail.com&gt;
Cc: Alessandro Zummo &lt;a.zummo@towertech.it&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
</feed>
