<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/drivers/rtc/rtc-mc146818-lib.c, branch linux-6.9.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.</subtitle>
<id>https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-6.9.y</id>
<link rel='self' href='https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-6.9.y'/>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/'/>
<updated>2023-12-17T21:33:55Z</updated>
<entry>
<title>rtc: Extend timeout for waiting for UIP to clear to 1s</title>
<updated>2023-12-17T21:33:55Z</updated>
<author>
<name>Mario Limonciello</name>
<email>mario.limonciello@amd.com</email>
</author>
<published>2023-11-28T05:36:53Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=cef9ecc8e938dd48a560f7dd9be1246359248d20'/>
<id>urn:sha1:cef9ecc8e938dd48a560f7dd9be1246359248d20</id>
<content type='text'>
Specs don't say anything about UIP being cleared within 10ms. They
only say that UIP won't occur for another 244uS. If a long NMI occurs
while UIP is still updating it might not be possible to get valid
data in 10ms.

This has been observed in the wild that around s2idle some calls can
take up to 480ms before UIP is clear.

Adjust callers from outside an interrupt context to wait for up to a
1s instead of 10ms.

Cc:  &lt;stable@vger.kernel.org&gt; # 6.1.y
Fixes: ec5895c0f2d8 ("rtc: mc146818-lib: extract mc146818_avoid_UIP")
Reported-by: Carsten Hatger &lt;xmb8dsv4@gmail.com&gt;
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217626
Tested-by: Mateusz Jończyk &lt;mat.jonczyk@o2.pl&gt;
Reviewed-by: Mateusz Jończyk &lt;mat.jonczyk@o2.pl&gt;
Acked-by: Mateusz Jończyk &lt;mat.jonczyk@o2.pl&gt;
Signed-off-by: Mario Limonciello &lt;mario.limonciello@amd.com&gt;
Link: https://lore.kernel.org/r/20231128053653.101798-5-mario.limonciello@amd.com
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
</content>
</entry>
<entry>
<title>rtc: Add support for configuring the UIP timeout for RTC reads</title>
<updated>2023-12-17T21:33:55Z</updated>
<author>
<name>Mario Limonciello</name>
<email>mario.limonciello@amd.com</email>
</author>
<published>2023-11-28T05:36:52Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=120931db07b49252aba2073096b595482d71857c'/>
<id>urn:sha1:120931db07b49252aba2073096b595482d71857c</id>
<content type='text'>
The UIP timeout is hardcoded to 10ms for all RTC reads, but in some
contexts this might not be enough time. Add a timeout parameter to
mc146818_get_time() and mc146818_get_time_callback().

If UIP timeout is configured by caller to be &gt;=100 ms and a call
takes this long, log a warning.

Make all callers use 10ms to ensure no functional changes.

Cc:  &lt;stable@vger.kernel.org&gt; # 6.1.y
Fixes: ec5895c0f2d8 ("rtc: mc146818-lib: extract mc146818_avoid_UIP")
Signed-off-by: Mario Limonciello &lt;mario.limonciello@amd.com&gt;
Tested-by: Mateusz Jończyk &lt;mat.jonczyk@o2.pl&gt;
Reviewed-by: Mateusz Jończyk &lt;mat.jonczyk@o2.pl&gt;
Acked-by: Mateusz Jończyk &lt;mat.jonczyk@o2.pl&gt;
Link: https://lore.kernel.org/r/20231128053653.101798-4-mario.limonciello@amd.com
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
</content>
</entry>
<entry>
<title>rtc: mc146818-lib: Adjust failure return code for mc146818_get_time()</title>
<updated>2023-12-17T21:33:54Z</updated>
<author>
<name>Mario Limonciello</name>
<email>mario.limonciello@amd.com</email>
</author>
<published>2023-11-28T05:36:50Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=af838635a3eb9b1bc0d98599c101ebca98f31311'/>
<id>urn:sha1:af838635a3eb9b1bc0d98599c101ebca98f31311</id>
<content type='text'>
mc146818_get_time() calls mc146818_avoid_UIP() to avoid fetching the
time while RTC update is in progress (UIP). When this fails, the return
code is -EIO, but actually there was no IO failure.

The reason for the return from mc146818_avoid_UIP() is that the UIP
wasn't cleared in the time period. Adjust the return code to -ETIMEDOUT
to match the behavior.

Tested-by: Mateusz Jończyk &lt;mat.jonczyk@o2.pl&gt;
Reviewed-by: Mateusz Jończyk &lt;mat.jonczyk@o2.pl&gt;
Acked-by: Mateusz Jończyk &lt;mat.jonczyk@o2.pl&gt;
Cc:  &lt;stable@vger.kernel.org&gt;
Fixes: 2a61b0ac5493 ("rtc: mc146818-lib: refactor mc146818_get_time")
Signed-off-by: Mario Limonciello &lt;mario.limonciello@amd.com&gt;
Link: https://lore.kernel.org/r/20231128053653.101798-2-mario.limonciello@amd.com
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
</content>
</entry>
<entry>
<title>rtc: mc146818-lib: reduce RTC_UIP polling period</title>
<updated>2022-06-24T19:23:50Z</updated>
<author>
<name>Mateusz Jończyk</name>
<email>mat.jonczyk@o2.pl</email>
</author>
<published>2022-02-25T21:50:09Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=d2a632a8a11756197deb1341bbb09c09abaf20ce'/>
<id>urn:sha1:d2a632a8a11756197deb1341bbb09c09abaf20ce</id>
<content type='text'>
Waiting 1ms every time is not necessary, for example on some AMD boxes
the RTC_UIP bit is documented as being high for around 270 microseconds
in some cases [1], which agreed with experiments on an SB710
southbridge. So 100us seems optimal.

This in preparation for mach_get_cmos_time() refactoring.
The functions mc146818_get_time() and mach_get_cmos_time() in
arch/x86/kernel/rtc.c perform the same function and the code is
duplicated. mach_get_cmos_time() is busy waiting for the RTC_UIP
bit to clear, so make mc146818_get_time() more similar to it by reducing
the polling period.

[1] AMD SB700/710/750 Register Reference Guide, page 307,
https://developer.amd.com/wordpress/media/2012/10/43009_sb7xx_rrg_pub_1.00.pdf

        "SB700 A12: The UIP high pulse is 270 μS Typical when SS on SRC
        clock is OFF and 100μ min when SRC SS is ON." [sic]

Signed-off-by: Mateusz Jończyk &lt;mat.jonczyk@o2.pl&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Ingo Molnar &lt;mingo@redhat.com&gt;
Cc: Borislav Petkov &lt;bp@alien8.de&gt;
Cc: Dave Hansen &lt;dave.hansen@linux.intel.com&gt;
Cc: x86@kernel.org
Cc: "H. Peter Anvin" &lt;hpa@zytor.com&gt;
Cc: Alessandro Zummo &lt;a.zummo@towertech.it&gt;
Cc: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/20220225215011.861477-2-mat.jonczyk@o2.pl
</content>
</entry>
<entry>
<title>rtc: mc146818-lib: Fix the AltCentury for AMD platforms</title>
<updated>2022-03-29T20:45:31Z</updated>
<author>
<name>Mario Limonciello</name>
<email>mario.limonciello@amd.com</email>
</author>
<published>2022-01-11T22:57:50Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=3ae8fd41573af4fb3a490c9ed947fc936ba87190'/>
<id>urn:sha1:3ae8fd41573af4fb3a490c9ed947fc936ba87190</id>
<content type='text'>
Setting the century forward has been failing on AMD platforms.
There was a previous attempt at fixing this for family 0x17 as part of
commit 7ad295d5196a ("rtc: Fix the AltCentury value on AMD/Hygon
platform") but this was later reverted due to some problems reported
that appeared to stem from an FW bug on a family 0x17 desktop system.

The same comments mentioned in the previous commit continue to apply
to the newer platforms as well.

```
MC146818 driver use function mc146818_set_time() to set register
RTC_FREQ_SELECT(RTC_REG_A)'s bit4-bit6 field which means divider stage
reset value on Intel platform to 0x7.

While AMD/Hygon RTC_REG_A(0Ah)'s bit4 is defined as DV0 [Reference]:
DV0 = 0 selects Bank 0, DV0 = 1 selects Bank 1. Bit5-bit6 is defined
as reserved.

DV0 is set to 1, it will select Bank 1, which will disable AltCentury
register(0x32) access. As UEFI pass acpi_gbl_FADT.century 0x32
(AltCentury), the CMOS write will be failed on code:
CMOS_WRITE(century, acpi_gbl_FADT.century).

Correct RTC_REG_A bank select bit(DV0) to 0 on AMD/Hygon CPUs, it will
enable AltCentury(0x32) register writing and finally setup century as
expected.
```

However in closer examination the change previously submitted was also
modifying bits 5 &amp; 6 which are declared reserved in the AMD documentation.
So instead modify just the DV0 bank selection bit.

Being cognizant that there was a failure reported before, split the code
change out to a static function that can also be used for exclusions if
any regressions such as Mikhail's pop up again.

Cc: Jinke Fan &lt;fanjinke@hygon.cn&gt;
Cc: Mikhail Gavrilov &lt;mikhail.v.gavrilov@gmail.com&gt;
Link: https://lore.kernel.org/all/CABXGCsMLob0DC25JS8wwAYydnDoHBSoMh2_YLPfqm3TTvDE-Zw@mail.gmail.com/
Link: https://www.amd.com/system/files/TechDocs/51192_Bolton_FCH_RRG.pdf
Signed-off-by: Raul E Rangel &lt;rrangel@chromium.org&gt;
Signed-off-by: Mario Limonciello &lt;mario.limonciello@amd.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/20220111225750.1699-1-mario.limonciello@amd.com
</content>
</entry>
<entry>
<title>rtc: mc146818-lib: fix locking in mc146818_set_time</title>
<updated>2022-03-23T18:58:37Z</updated>
<author>
<name>Mateusz Jończyk</name>
<email>mat.jonczyk@o2.pl</email>
</author>
<published>2022-02-20T09:04:03Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=811f5559270f25c34c338d6eaa2ece2544c3d3bd'/>
<id>urn:sha1:811f5559270f25c34c338d6eaa2ece2544c3d3bd</id>
<content type='text'>
In mc146818_set_time(), CMOS_READ(RTC_CONTROL) was performed without the
rtc_lock taken, which is required for CMOS accesses. Fix this.

Nothing in kernel modifies RTC_DM_BINARY, so a separate critical section
is allowed here.

Fixes: dcf257e92622 ("rtc: mc146818: Reduce spinlock section in mc146818_set_time()")
Signed-off-by: Mateusz Jończyk &lt;mat.jonczyk@o2.pl&gt;
Cc: Alessandro Zummo &lt;a.zummo@towertech.it&gt;
Cc: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/20220220090403.153928-1-mat.jonczyk@o2.pl
</content>
</entry>
<entry>
<title>rtc: cmos: Evaluate century appropriate</title>
<updated>2022-01-16T22:50:26Z</updated>
<author>
<name>Riwen Lu</name>
<email>luriwen@kylinos.cn</email>
</author>
<published>2022-01-06T08:46:09Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=ff164ae39b82ee483b24579c8e22a13a8ce5bd04'/>
<id>urn:sha1:ff164ae39b82ee483b24579c8e22a13a8ce5bd04</id>
<content type='text'>
There's limiting the year to 2069. When setting the rtc year to 2070,
reading it returns 1970. Evaluate century starting from 19 to count the
correct year.

$ sudo date -s 20700106
Mon 06 Jan 2070 12:00:00 AM CST
$ sudo hwclock -w
$ sudo hwclock -r
1970-01-06 12:00:49.604968+08:00

Fixes: 2a4daadd4d3e5071 ("rtc: cmos: ignore bogus century byte")

Signed-off-by: Riwen Lu &lt;luriwen@kylinos.cn&gt;
Acked-by: Eric Wong &lt;e@80x24.org&gt;
Reviewed-by: Mateusz Jończyk &lt;mat.jonczyk@o2.pl&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/20220106084609.1223688-1-luriwen@kylinos.cn
</content>
</entry>
<entry>
<title>rtc: mc146818-lib: fix signedness bug in mc146818_get_time()</title>
<updated>2022-01-16T22:34:43Z</updated>
<author>
<name>Dan Carpenter</name>
<email>dan.carpenter@oracle.com</email>
</author>
<published>2022-01-11T07:19:22Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=7372971c1be5b7d4fdd8ad237798bdc1d1d54162'/>
<id>urn:sha1:7372971c1be5b7d4fdd8ad237798bdc1d1d54162</id>
<content type='text'>
The mc146818_get_time() function returns zero on success or negative
a error code on failure.  It needs to be type int.

Fixes: d35786b3a28d ("rtc: mc146818-lib: change return values of mc146818_get_time()")
Signed-off-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Reviewed-by: Mateusz Jończyk &lt;mat.jonczyk@o2.pl&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/20220111071922.GE11243@kili
</content>
</entry>
<entry>
<title>rtc: mc146818-lib: refactor mc146818_does_rtc_work</title>
<updated>2021-12-16T20:50:06Z</updated>
<author>
<name>Mateusz Jończyk</name>
<email>mat.jonczyk@o2.pl</email>
</author>
<published>2021-12-10T20:01:29Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=2c7d47a45b06be3d0a7aa21c3dea2215685a928f'/>
<id>urn:sha1:2c7d47a45b06be3d0a7aa21c3dea2215685a928f</id>
<content type='text'>
Refactor mc146818_does_rtc_work() so that it uses mc146818_avoid_UIP().
It is enough to call mc146818_avoid_UIP() with no callback.

Signed-off-by: Mateusz Jończyk &lt;mat.jonczyk@o2.pl&gt;
Cc: Alessandro Zummo &lt;a.zummo@towertech.it&gt;
Cc: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/20211210200131.153887-8-mat.jonczyk@o2.pl
</content>
</entry>
<entry>
<title>rtc: mc146818-lib: refactor mc146818_get_time</title>
<updated>2021-12-16T20:50:06Z</updated>
<author>
<name>Mateusz Jończyk</name>
<email>mat.jonczyk@o2.pl</email>
</author>
<published>2021-12-10T20:01:28Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=2a61b0ac5493363149f68a2fb80287f314626987'/>
<id>urn:sha1:2a61b0ac5493363149f68a2fb80287f314626987</id>
<content type='text'>
Refactor mc146818_get_time() so that it uses mc146818_avoid_UIP().

Signed-off-by: Mateusz Jończyk &lt;mat.jonczyk@o2.pl&gt;
Cc: Alessandro Zummo &lt;a.zummo@towertech.it&gt;
Cc: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/20211210200131.153887-7-mat.jonczyk@o2.pl
</content>
</entry>
</feed>
