<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-stable.git/drivers/rtc/rtc-snvs.c, branch linux-5.10.y</title>
<subtitle>Linux kernel stable tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/'/>
<entry>
<title>rtc: snvs: Allow a time difference on clock register read</title>
<updated>2023-01-14T09:16:05+00:00</updated>
<author>
<name>Stefan Eichenberger</name>
<email>stefan.eichenberger@toradex.com</email>
</author>
<published>2022-11-06T11:59:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=aaed333e2237da8a391cdc0e675da1993347c4e4'/>
<id>aaed333e2237da8a391cdc0e675da1993347c4e4</id>
<content type='text'>
[ Upstream commit 0462681e207ccc44778a77b3297af728b1cf5b9f ]

On an iMX6ULL the following message appears when a wakealarm is set:

echo 0 &gt; /sys/class/rtc/rtc1/wakealarm
rtc rtc1: Timeout trying to get valid LPSRT Counter read

This does not always happen but is reproducible quite often (7 out of 10
times). The problem appears because the iMX6ULL is not able to read the
registers within one 32kHz clock cycle which is the base clock of the
RTC. Therefore, this patch allows a difference of up to 320 cycles
(10ms). 10ms was chosen to be big enough even on systems with less cpu
power (e.g. iMX6ULL). According to the reference manual a difference is
fine:
- If the two consecutive reads are similar, the value is correct.
The values have to be similar, not equal.

Fixes: cd7f3a249dbe ("rtc: snvs: Add timeouts to avoid kernel lockups")
Reviewed-by: Francesco Dolcini &lt;francesco.dolcini@toradex.com&gt;
Signed-off-by: Stefan Eichenberger &lt;stefan.eichenberger@toradex.com&gt;
Signed-off-by: Francesco Dolcini &lt;francesco@dolcini.it&gt;
Link: https://lore.kernel.org/r/20221106115915.7930-1-francesco@dolcini.it
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 0462681e207ccc44778a77b3297af728b1cf5b9f ]

On an iMX6ULL the following message appears when a wakealarm is set:

echo 0 &gt; /sys/class/rtc/rtc1/wakealarm
rtc rtc1: Timeout trying to get valid LPSRT Counter read

This does not always happen but is reproducible quite often (7 out of 10
times). The problem appears because the iMX6ULL is not able to read the
registers within one 32kHz clock cycle which is the base clock of the
RTC. Therefore, this patch allows a difference of up to 320 cycles
(10ms). 10ms was chosen to be big enough even on systems with less cpu
power (e.g. iMX6ULL). According to the reference manual a difference is
fine:
- If the two consecutive reads are similar, the value is correct.
The values have to be similar, not equal.

Fixes: cd7f3a249dbe ("rtc: snvs: Add timeouts to avoid kernel lockups")
Reviewed-by: Francesco Dolcini &lt;francesco.dolcini@toradex.com&gt;
Signed-off-by: Stefan Eichenberger &lt;stefan.eichenberger@toradex.com&gt;
Signed-off-by: Francesco Dolcini &lt;francesco@dolcini.it&gt;
Link: https://lore.kernel.org/r/20221106115915.7930-1-francesco@dolcini.it
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>rtc: snvs: Add necessary clock operations for RTC APIs</title>
<updated>2020-05-30T01:17:48+00:00</updated>
<author>
<name>Anson Huang</name>
<email>Anson.Huang@nxp.com</email>
</author>
<published>2020-05-22T02:19:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=4b957bde561f3a56865395be06f1be2c196b0b5e'/>
<id>4b957bde561f3a56865395be06f1be2c196b0b5e</id>
<content type='text'>
There could be still RTC registers access after RTC suspend
with clock disabled, need to add clock operations for each
RTC API to make sure accessing RTC registers is successfully.

Signed-off-by: Anson Huang &lt;Anson.Huang@nxp.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/1590113996-31845-2-git-send-email-Anson.Huang@nxp.com
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
There could be still RTC registers access after RTC suspend
with clock disabled, need to add clock operations for each
RTC API to make sure accessing RTC registers is successfully.

Signed-off-by: Anson Huang &lt;Anson.Huang@nxp.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/1590113996-31845-2-git-send-email-Anson.Huang@nxp.com
</pre>
</div>
</content>
</entry>
<entry>
<title>rtc: snvs: Make SNVS clock always prepared</title>
<updated>2020-05-30T01:17:48+00:00</updated>
<author>
<name>Anson Huang</name>
<email>Anson.Huang@nxp.com</email>
</author>
<published>2020-05-22T02:19:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=20af67700bc39bccd838414128f63a72965de6e7'/>
<id>20af67700bc39bccd838414128f63a72965de6e7</id>
<content type='text'>
In IRQ handler, ONLY clock enable/disable is called due to
clock prepare can NOT be called in interrupt context, but
clock enable/disable will return failure if prepare count
is 0, to fix this issue, just make SNVS clock always prepared
there, the SNVS clock has no prepare function implemented,
so it won't impact anything.

Signed-off-by: Anson Huang &lt;Anson.Huang@nxp.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/1590113996-31845-1-git-send-email-Anson.Huang@nxp.com
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In IRQ handler, ONLY clock enable/disable is called due to
clock prepare can NOT be called in interrupt context, but
clock enable/disable will return failure if prepare count
is 0, to fix this issue, just make SNVS clock always prepared
there, the SNVS clock has no prepare function implemented,
so it won't impact anything.

Signed-off-by: Anson Huang &lt;Anson.Huang@nxp.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/1590113996-31845-1-git-send-email-Anson.Huang@nxp.com
</pre>
</div>
</content>
</entry>
<entry>
<title>rtc: snvs: Use devm_add_action_or_reset() for calls to clk_disable_unprepare()</title>
<updated>2020-03-16T10:55:55+00:00</updated>
<author>
<name>Anson Huang</name>
<email>Anson.Huang@nxp.com</email>
</author>
<published>2020-03-13T14:30:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=7863bd076b990f57076f2123337b67b5d5ccd190'/>
<id>7863bd076b990f57076f2123337b67b5d5ccd190</id>
<content type='text'>
Use devm_add_action_or_reset() for calls to clk_disable_unprepare(),
which can simplify the error handling.

Signed-off-by: Anson Huang &lt;Anson.Huang@nxp.com&gt;
Link: https://lore.kernel.org/r/1584109849-21402-1-git-send-email-Anson.Huang@nxp.com
Link: https://lore.kernel.org/r/1584233264-26025-1-git-send-email-Anson.Huang@nxp.com
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use devm_add_action_or_reset() for calls to clk_disable_unprepare(),
which can simplify the error handling.

Signed-off-by: Anson Huang &lt;Anson.Huang@nxp.com&gt;
Link: https://lore.kernel.org/r/1584109849-21402-1-git-send-email-Anson.Huang@nxp.com
Link: https://lore.kernel.org/r/1584233264-26025-1-git-send-email-Anson.Huang@nxp.com
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>rtc: snvs: Remove unused include of of_device.h</title>
<updated>2020-02-18T21:39:23+00:00</updated>
<author>
<name>Anson Huang</name>
<email>Anson.Huang@nxp.com</email>
</author>
<published>2020-02-16T03:27:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=a137e9b620bcf3925a8d72dd7ba723910d0bf976'/>
<id>a137e9b620bcf3925a8d72dd7ba723910d0bf976</id>
<content type='text'>
There is nothing in use from of_device.h, remove it.

Signed-off-by: Anson Huang &lt;Anson.Huang@nxp.com&gt;
Link: https://lore.kernel.org/r/1581823666-16944-1-git-send-email-Anson.Huang@nxp.com
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
There is nothing in use from of_device.h, remove it.

Signed-off-by: Anson Huang &lt;Anson.Huang@nxp.com&gt;
Link: https://lore.kernel.org/r/1581823666-16944-1-git-send-email-Anson.Huang@nxp.com
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>rtc: snvs: switch to rtc_time64_to_tm/rtc_tm_to_time64</title>
<updated>2019-09-01T06:48:23+00:00</updated>
<author>
<name>Alexandre Belloni</name>
<email>alexandre.belloni@bootlin.com</email>
</author>
<published>2019-08-28T20:50:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=c59a9fc7272e56ba0575b9fcc346c5e4bf16b39d'/>
<id>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>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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;
</pre>
</div>
</content>
</entry>
<entry>
<title>rtc: snvs: set range</title>
<updated>2019-09-01T06:48:15+00:00</updated>
<author>
<name>Alexandre Belloni</name>
<email>alexandre.belloni@bootlin.com</email>
</author>
<published>2019-08-28T20:50:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=79610340cac8840ad67572ca13afae03265edae6'/>
<id>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>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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;
</pre>
</div>
</content>
</entry>
<entry>
<title>rtc: snvs: fix possible race condition</title>
<updated>2019-08-29T15:53:12+00:00</updated>
<author>
<name>Anson Huang</name>
<email>Anson.Huang@nxp.com</email>
</author>
<published>2019-07-16T07:18:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=6fd4fe9b496d9ba3382992ff4fde3871d1b6f63d'/>
<id>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>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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;
</pre>
</div>
</content>
</entry>
<entry>
<title>rtc: snvs: Use __maybe_unused instead of #if CONFIG_PM_SLEEP</title>
<updated>2019-05-08T20:14:36+00:00</updated>
<author>
<name>Anson Huang</name>
<email>anson.huang@nxp.com</email>
</author>
<published>2019-04-30T01:07:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=dacb6a4035a010e41abaf81c1cfe2beadfb05ec8'/>
<id>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>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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;
</pre>
</div>
</content>
</entry>
<entry>
<title>rtc: snvs: use devm_platform_ioremap_resource() to simplify code</title>
<updated>2019-04-04T08:07:11+00:00</updated>
<author>
<name>Anson Huang</name>
<email>anson.huang@nxp.com</email>
</author>
<published>2019-04-01T05:29:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=0c46b07ce4d5000855d810d61bb18fb4b0c4cc3b'/>
<id>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>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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;
</pre>
</div>
</content>
</entry>
</feed>
