<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-stable.git/drivers/rtc/rtc-cmos.c, branch v5.15.78</title>
<subtitle>Linux kernel stable tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/'/>
<entry>
<title>rtc: mc146818-lib: fix RTC presence check</title>
<updated>2022-04-13T18:59:14+00:00</updated>
<author>
<name>Mateusz Jończyk</name>
<email>mat.jonczyk@o2.pl</email>
</author>
<published>2021-12-10T20:01:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=985d87e6a36551b292443c52a4ae9b82296d1f51'/>
<id>985d87e6a36551b292443c52a4ae9b82296d1f51</id>
<content type='text'>
[ Upstream commit ea6fa4961aab8f90a8aa03575a98b4bda368d4b6 ]

To prevent an infinite loop in mc146818_get_time(),
commit 211e5db19d15 ("rtc: mc146818: Detect and handle broken RTCs")
added a check for RTC availability. Together with a later fix, it
checked if bit 6 in register 0x0d is cleared.

This, however, caused a false negative on a motherboard with an AMD
SB710 southbridge; according to the specification [1], bit 6 of register
0x0d of this chipset is a scratchbit. This caused a regression in Linux
5.11 - the RTC was determined broken by the kernel and not used by
rtc-cmos.c [3]. This problem was also reported in Fedora [4].

As a better alternative, check whether the UIP ("Update-in-progress")
bit is set for longer then 10ms. If that is the case, then apparently
the RTC is either absent (and all register reads return 0xff) or broken.
Also limit the number of loop iterations in mc146818_get_time() to 10 to
prevent an infinite loop there.

The functions mc146818_get_time() and mc146818_does_rtc_work() will be
refactored later in this patch series, in order to fix a separate
problem with reading / setting the RTC alarm time. This is done so to
avoid a confusion about what is being fixed when.

In a previous approach to this problem, I implemented a check whether
the RTC_HOURS register contains a value &lt;= 24. This, however, sometimes
did not work correctly on my Intel Kaby Lake laptop. According to
Intel's documentation [2], "the time and date RAM locations (0-9) are
disconnected from the external bus" during the update cycle so reading
this register without checking the UIP bit is incorrect.

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

[2] 7th Generation Intel ® Processor Family I/O for U/Y Platforms [...] Datasheet
Volume 1 of 2, page 209
Intel's Document Number: 334658-006,
https://www.intel.com/content/dam/www/public/us/en/documents/datasheets/7th-and-8th-gen-core-family-mobile-u-y-processor-lines-i-o-datasheet-vol-1.pdf

[3] Functions in arch/x86/kernel/rtc.c apparently were using it.

[4] https://bugzilla.redhat.com/show_bug.cgi?id=1936688

Fixes: 211e5db19d15 ("rtc: mc146818: Detect and handle broken RTCs")
Fixes: ebb22a059436 ("rtc: mc146818: Dont test for bit 0-5 in Register D")
Signed-off-by: Mateusz Jończyk &lt;mat.jonczyk@o2.pl&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&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-5-mat.jonczyk@o2.pl
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 ea6fa4961aab8f90a8aa03575a98b4bda368d4b6 ]

To prevent an infinite loop in mc146818_get_time(),
commit 211e5db19d15 ("rtc: mc146818: Detect and handle broken RTCs")
added a check for RTC availability. Together with a later fix, it
checked if bit 6 in register 0x0d is cleared.

This, however, caused a false negative on a motherboard with an AMD
SB710 southbridge; according to the specification [1], bit 6 of register
0x0d of this chipset is a scratchbit. This caused a regression in Linux
5.11 - the RTC was determined broken by the kernel and not used by
rtc-cmos.c [3]. This problem was also reported in Fedora [4].

As a better alternative, check whether the UIP ("Update-in-progress")
bit is set for longer then 10ms. If that is the case, then apparently
the RTC is either absent (and all register reads return 0xff) or broken.
Also limit the number of loop iterations in mc146818_get_time() to 10 to
prevent an infinite loop there.

The functions mc146818_get_time() and mc146818_does_rtc_work() will be
refactored later in this patch series, in order to fix a separate
problem with reading / setting the RTC alarm time. This is done so to
avoid a confusion about what is being fixed when.

In a previous approach to this problem, I implemented a check whether
the RTC_HOURS register contains a value &lt;= 24. This, however, sometimes
did not work correctly on my Intel Kaby Lake laptop. According to
Intel's documentation [2], "the time and date RAM locations (0-9) are
disconnected from the external bus" during the update cycle so reading
this register without checking the UIP bit is incorrect.

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

[2] 7th Generation Intel ® Processor Family I/O for U/Y Platforms [...] Datasheet
Volume 1 of 2, page 209
Intel's Document Number: 334658-006,
https://www.intel.com/content/dam/www/public/us/en/documents/datasheets/7th-and-8th-gen-core-family-mobile-u-y-processor-lines-i-o-datasheet-vol-1.pdf

[3] Functions in arch/x86/kernel/rtc.c apparently were using it.

[4] https://bugzilla.redhat.com/show_bug.cgi?id=1936688

Fixes: 211e5db19d15 ("rtc: mc146818: Detect and handle broken RTCs")
Fixes: ebb22a059436 ("rtc: mc146818: Dont test for bit 0-5 in Register D")
Signed-off-by: Mateusz Jończyk &lt;mat.jonczyk@o2.pl&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&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-5-mat.jonczyk@o2.pl
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>rtc: Check return value from mc146818_get_time()</title>
<updated>2022-04-13T18:59:14+00:00</updated>
<author>
<name>Mateusz Jończyk</name>
<email>mat.jonczyk@o2.pl</email>
</author>
<published>2021-12-10T20:01:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=be6c3152d6f6d9c4a72eeb7126b762b413b1030c'/>
<id>be6c3152d6f6d9c4a72eeb7126b762b413b1030c</id>
<content type='text'>
[ Upstream commit 0dd8d6cb9eddfe637bcd821bbfd40ebd5a0737b9 ]

There are 4 users of mc146818_get_time() and none of them was checking
the return value from this function. Change this.

Print the appropriate warnings in callers of mc146818_get_time() instead
of in the function mc146818_get_time() itself, in order not to add
strings to rtc-mc146818-lib.c, which is kind of a library.

The callers of alpha_rtc_read_time() and cmos_read_time() may use the
contents of (struct rtc_time *) even when the functions return a failure
code. Therefore, set the contents of (struct rtc_time *) to 0x00,
which looks more sensible then 0xff and aligns with the (possibly
stale?) comment in cmos_read_time:

	/*
	 * If pm_trace abused the RTC for storage, set the timespec to 0,
	 * which tells the caller that this RTC value is unusable.
	 */

For consistency, do this in mc146818_get_time().

Note: hpet_rtc_interrupt() may call mc146818_get_time() many times a
second. It is very unlikely, though, that the RTC suddenly stops
working and mc146818_get_time() would consistently fail.

Only compile-tested on alpha.

Signed-off-by: Mateusz Jończyk &lt;mat.jonczyk@o2.pl&gt;
Cc: Richard Henderson &lt;rth@twiddle.net&gt;
Cc: Ivan Kokshaysky &lt;ink@jurassic.park.msu.ru&gt;
Cc: Matt Turner &lt;mattst88@gmail.com&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: Alessandro Zummo &lt;a.zummo@towertech.it&gt;
Cc: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Cc: linux-alpha@vger.kernel.org
Cc: x86@kernel.org
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/20211210200131.153887-4-mat.jonczyk@o2.pl
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 0dd8d6cb9eddfe637bcd821bbfd40ebd5a0737b9 ]

There are 4 users of mc146818_get_time() and none of them was checking
the return value from this function. Change this.

Print the appropriate warnings in callers of mc146818_get_time() instead
of in the function mc146818_get_time() itself, in order not to add
strings to rtc-mc146818-lib.c, which is kind of a library.

The callers of alpha_rtc_read_time() and cmos_read_time() may use the
contents of (struct rtc_time *) even when the functions return a failure
code. Therefore, set the contents of (struct rtc_time *) to 0x00,
which looks more sensible then 0xff and aligns with the (possibly
stale?) comment in cmos_read_time:

	/*
	 * If pm_trace abused the RTC for storage, set the timespec to 0,
	 * which tells the caller that this RTC value is unusable.
	 */

For consistency, do this in mc146818_get_time().

Note: hpet_rtc_interrupt() may call mc146818_get_time() many times a
second. It is very unlikely, though, that the RTC suddenly stops
working and mc146818_get_time() would consistently fail.

Only compile-tested on alpha.

Signed-off-by: Mateusz Jończyk &lt;mat.jonczyk@o2.pl&gt;
Cc: Richard Henderson &lt;rth@twiddle.net&gt;
Cc: Ivan Kokshaysky &lt;ink@jurassic.park.msu.ru&gt;
Cc: Matt Turner &lt;mattst88@gmail.com&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: Alessandro Zummo &lt;a.zummo@towertech.it&gt;
Cc: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Cc: linux-alpha@vger.kernel.org
Cc: x86@kernel.org
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/20211210200131.153887-4-mat.jonczyk@o2.pl
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>rtc: cmos: take rtc_lock while reading from CMOS</title>
<updated>2022-01-27T10:02:52+00:00</updated>
<author>
<name>Mateusz Jończyk</name>
<email>mat.jonczyk@o2.pl</email>
</author>
<published>2021-12-10T20:01:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=e428c89717ff941ac7486523160845561295ec82'/>
<id>e428c89717ff941ac7486523160845561295ec82</id>
<content type='text'>
commit 454f47ff464325223129b9b5b8d0b61946ec704d upstream.

Reading from the CMOS involves writing to the index register and then
reading from the data register. Therefore access to the CMOS has to be
serialized with rtc_lock. This invocation of CMOS_READ was not
serialized, which could cause trouble when other code is accessing CMOS
at the same time.

Use spin_lock_irq() like the rest of the function.

Nothing in kernel modifies the RTC_DM_BINARY bit, so there could be a
separate pair of spin_lock_irq() / spin_unlock_irq() before doing the
math.

Signed-off-by: Mateusz Jończyk &lt;mat.jonczyk@o2.pl&gt;
Reviewed-by: Nobuhiro Iwamatsu &lt;iwamatsu@nigauri.org&gt;
Cc: Alessandro Zummo &lt;a.zummo@towertech.it&gt;
Cc: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/20211210200131.153887-2-mat.jonczyk@o2.pl
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 454f47ff464325223129b9b5b8d0b61946ec704d upstream.

Reading from the CMOS involves writing to the index register and then
reading from the data register. Therefore access to the CMOS has to be
serialized with rtc_lock. This invocation of CMOS_READ was not
serialized, which could cause trouble when other code is accessing CMOS
at the same time.

Use spin_lock_irq() like the rest of the function.

Nothing in kernel modifies the RTC_DM_BINARY bit, so there could be a
separate pair of spin_lock_irq() / spin_unlock_irq() before doing the
math.

Signed-off-by: Mateusz Jończyk &lt;mat.jonczyk@o2.pl&gt;
Reviewed-by: Nobuhiro Iwamatsu &lt;iwamatsu@nigauri.org&gt;
Cc: Alessandro Zummo &lt;a.zummo@towertech.it&gt;
Cc: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/20211210200131.153887-2-mat.jonczyk@o2.pl
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>rtc: cmos: Disable irq around direct invocation of cmos_interrupt()</title>
<updated>2021-09-14T08:20:19+00:00</updated>
<author>
<name>Chris Wilson</name>
<email>chris@chris-wilson.co.uk</email>
</author>
<published>2021-03-05T12:21:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=13be2efc390acd2a46a69a359f6efc00ca434599'/>
<id>13be2efc390acd2a46a69a359f6efc00ca434599</id>
<content type='text'>
As previously noted in commit 66e4f4a9cc38 ("rtc: cmos: Use
spin_lock_irqsave() in cmos_interrupt()"):

&lt;4&gt;[  254.192378] WARNING: inconsistent lock state
&lt;4&gt;[  254.192384] 5.12.0-rc1-CI-CI_DRM_9834+ #1 Not tainted
&lt;4&gt;[  254.192396] --------------------------------
&lt;4&gt;[  254.192400] inconsistent {IN-HARDIRQ-W} -&gt; {HARDIRQ-ON-W} usage.
&lt;4&gt;[  254.192409] rtcwake/5309 [HC0[0]:SC0[0]:HE1:SE1] takes:
&lt;4&gt;[  254.192429] ffffffff8263c5f8 (rtc_lock){?...}-{2:2}, at: cmos_interrupt+0x18/0x100
&lt;4&gt;[  254.192481] {IN-HARDIRQ-W} state was registered at:
&lt;4&gt;[  254.192488]   lock_acquire+0xd1/0x3d0
&lt;4&gt;[  254.192504]   _raw_spin_lock+0x2a/0x40
&lt;4&gt;[  254.192519]   cmos_interrupt+0x18/0x100
&lt;4&gt;[  254.192536]   rtc_handler+0x1f/0xc0
&lt;4&gt;[  254.192553]   acpi_ev_fixed_event_detect+0x109/0x13c
&lt;4&gt;[  254.192574]   acpi_ev_sci_xrupt_handler+0xb/0x28
&lt;4&gt;[  254.192596]   acpi_irq+0x13/0x30
&lt;4&gt;[  254.192620]   __handle_irq_event_percpu+0x43/0x2c0
&lt;4&gt;[  254.192641]   handle_irq_event_percpu+0x2b/0x70
&lt;4&gt;[  254.192661]   handle_irq_event+0x2f/0x50
&lt;4&gt;[  254.192680]   handle_fasteoi_irq+0x9e/0x150
&lt;4&gt;[  254.192693]   __common_interrupt+0x76/0x140
&lt;4&gt;[  254.192715]   common_interrupt+0x96/0xc0
&lt;4&gt;[  254.192732]   asm_common_interrupt+0x1e/0x40
&lt;4&gt;[  254.192750]   _raw_spin_unlock_irqrestore+0x38/0x60
&lt;4&gt;[  254.192767]   resume_irqs+0xba/0xf0
&lt;4&gt;[  254.192786]   dpm_resume_noirq+0x245/0x3d0
&lt;4&gt;[  254.192811]   suspend_devices_and_enter+0x230/0xaa0
&lt;4&gt;[  254.192835]   pm_suspend.cold.8+0x301/0x34a
&lt;4&gt;[  254.192859]   state_store+0x7b/0xe0
&lt;4&gt;[  254.192879]   kernfs_fop_write_iter+0x11d/0x1c0
&lt;4&gt;[  254.192899]   new_sync_write+0x11d/0x1b0
&lt;4&gt;[  254.192916]   vfs_write+0x265/0x390
&lt;4&gt;[  254.192933]   ksys_write+0x5a/0xd0
&lt;4&gt;[  254.192949]   do_syscall_64+0x33/0x80
&lt;4&gt;[  254.192965]   entry_SYSCALL_64_after_hwframe+0x44/0xae
&lt;4&gt;[  254.192986] irq event stamp: 43775
&lt;4&gt;[  254.192994] hardirqs last  enabled at (43775): [&lt;ffffffff81c00c42&gt;] asm_sysvec_apic_timer_interrupt+0x12/0x20
&lt;4&gt;[  254.193023] hardirqs last disabled at (43774): [&lt;ffffffff81aa691a&gt;] sysvec_apic_timer_interrupt+0xa/0xb0
&lt;4&gt;[  254.193049] softirqs last  enabled at (42548): [&lt;ffffffff81e00342&gt;] __do_softirq+0x342/0x48e
&lt;4&gt;[  254.193074] softirqs last disabled at (42543): [&lt;ffffffff810b45fd&gt;] irq_exit_rcu+0xad/0xd0
&lt;4&gt;[  254.193101]
                  other info that might help us debug this:
&lt;4&gt;[  254.193107]  Possible unsafe locking scenario:

&lt;4&gt;[  254.193112]        CPU0
&lt;4&gt;[  254.193117]        ----
&lt;4&gt;[  254.193121]   lock(rtc_lock);
&lt;4&gt;[  254.193137]   &lt;Interrupt&gt;
&lt;4&gt;[  254.193142]     lock(rtc_lock);
&lt;4&gt;[  254.193156]
                   *** DEADLOCK ***

&lt;4&gt;[  254.193161] 6 locks held by rtcwake/5309:
&lt;4&gt;[  254.193174]  #0: ffff888104861430 (sb_writers#5){.+.+}-{0:0}, at: ksys_write+0x5a/0xd0
&lt;4&gt;[  254.193232]  #1: ffff88810f823288 (&amp;of-&gt;mutex){+.+.}-{3:3}, at: kernfs_fop_write_iter+0xe7/0x1c0
&lt;4&gt;[  254.193282]  #2: ffff888100cef3c0 (kn-&gt;active#285
&lt;7&gt;[  254.192706] i915 0000:00:02.0: [drm:intel_modeset_setup_hw_state [i915]] [CRTC:51:pipe A] hw state readout: disabled
&lt;4&gt;[  254.193307] ){.+.+}-{0:0}, at: kernfs_fop_write_iter+0xf0/0x1c0
&lt;4&gt;[  254.193333]  #3: ffffffff82649fa8 (system_transition_mutex){+.+.}-{3:3}, at: pm_suspend.cold.8+0xce/0x34a
&lt;4&gt;[  254.193387]  #4: ffffffff827a2108 (acpi_scan_lock){+.+.}-{3:3}, at: acpi_suspend_begin+0x47/0x70
&lt;4&gt;[  254.193433]  #5: ffff8881019ea178 (&amp;dev-&gt;mutex){....}-{3:3}, at: device_resume+0x68/0x1e0
&lt;4&gt;[  254.193485]
                  stack backtrace:
&lt;4&gt;[  254.193492] CPU: 1 PID: 5309 Comm: rtcwake Not tainted 5.12.0-rc1-CI-CI_DRM_9834+ #1
&lt;4&gt;[  254.193514] Hardware name: Google Soraka/Soraka, BIOS MrChromebox-4.10 08/25/2019
&lt;4&gt;[  254.193524] Call Trace:
&lt;4&gt;[  254.193536]  dump_stack+0x7f/0xad
&lt;4&gt;[  254.193567]  mark_lock.part.47+0x8ca/0xce0
&lt;4&gt;[  254.193604]  __lock_acquire+0x39b/0x2590
&lt;4&gt;[  254.193626]  ? asm_sysvec_apic_timer_interrupt+0x12/0x20
&lt;4&gt;[  254.193660]  lock_acquire+0xd1/0x3d0
&lt;4&gt;[  254.193677]  ? cmos_interrupt+0x18/0x100
&lt;4&gt;[  254.193716]  _raw_spin_lock+0x2a/0x40
&lt;4&gt;[  254.193735]  ? cmos_interrupt+0x18/0x100
&lt;4&gt;[  254.193758]  cmos_interrupt+0x18/0x100
&lt;4&gt;[  254.193785]  cmos_resume+0x2ac/0x2d0
&lt;4&gt;[  254.193813]  ? acpi_pm_set_device_wakeup+0x1f/0x110
&lt;4&gt;[  254.193842]  ? pnp_bus_suspend+0x10/0x10
&lt;4&gt;[  254.193864]  pnp_bus_resume+0x5e/0x90
&lt;4&gt;[  254.193885]  dpm_run_callback+0x5f/0x240
&lt;4&gt;[  254.193914]  device_resume+0xb2/0x1e0
&lt;4&gt;[  254.193942]  ? pm_dev_err+0x25/0x25
&lt;4&gt;[  254.193974]  dpm_resume+0xea/0x3f0
&lt;4&gt;[  254.194005]  dpm_resume_end+0x8/0x10
&lt;4&gt;[  254.194030]  suspend_devices_and_enter+0x29b/0xaa0
&lt;4&gt;[  254.194066]  pm_suspend.cold.8+0x301/0x34a
&lt;4&gt;[  254.194094]  state_store+0x7b/0xe0
&lt;4&gt;[  254.194124]  kernfs_fop_write_iter+0x11d/0x1c0
&lt;4&gt;[  254.194151]  new_sync_write+0x11d/0x1b0
&lt;4&gt;[  254.194183]  vfs_write+0x265/0x390
&lt;4&gt;[  254.194207]  ksys_write+0x5a/0xd0
&lt;4&gt;[  254.194232]  do_syscall_64+0x33/0x80
&lt;4&gt;[  254.194251]  entry_SYSCALL_64_after_hwframe+0x44/0xae
&lt;4&gt;[  254.194274] RIP: 0033:0x7f07d79691e7
&lt;4&gt;[  254.194293] Code: 64 89 02 48 c7 c0 ff ff ff ff eb bb 0f 1f 80 00 00 00 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 01 00 00 00 0f 05 &lt;48&gt; 3d 00 f0 ff ff 77 51 c3 48 83 ec 28 48 89 54 24 18 48 89 74 24
&lt;4&gt;[  254.194312] RSP: 002b:00007ffd9cc2c768 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
&lt;4&gt;[  254.194337] RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 00007f07d79691e7
&lt;4&gt;[  254.194352] RDX: 0000000000000004 RSI: 0000556ebfc63590 RDI: 000000000000000b
&lt;4&gt;[  254.194366] RBP: 0000556ebfc63590 R08: 0000000000000000 R09: 0000000000000004
&lt;4&gt;[  254.194379] R10: 0000556ebf0ec2a6 R11: 0000000000000246 R12: 0000000000000004

which breaks S3-resume on fi-kbl-soraka presumably as that's slow enough
to trigger the alarm during the suspend.

Fixes: 6950d046eb6e ("rtc: cmos: Replace spin_lock_irqsave with spin_lock in hard IRQ")
References: 66e4f4a9cc38 ("rtc: cmos: Use spin_lock_irqsave() in cmos_interrupt()"):
Signed-off-by: Chris Wilson &lt;chris@chris-wilson.co.uk&gt;
Cc: Xiaofei Tan &lt;tanxiaofei@huawei.com&gt;
Cc: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Cc: Alessandro Zummo &lt;a.zummo@towertech.it&gt;
Cc: Ville Syrjälä &lt;ville.syrjala@linux.intel.com&gt;
Reviewed-by: Ville Syrjälä &lt;ville.syrjala@linux.intel.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/20210305122140.28774-1-chris@chris-wilson.co.uk
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
As previously noted in commit 66e4f4a9cc38 ("rtc: cmos: Use
spin_lock_irqsave() in cmos_interrupt()"):

&lt;4&gt;[  254.192378] WARNING: inconsistent lock state
&lt;4&gt;[  254.192384] 5.12.0-rc1-CI-CI_DRM_9834+ #1 Not tainted
&lt;4&gt;[  254.192396] --------------------------------
&lt;4&gt;[  254.192400] inconsistent {IN-HARDIRQ-W} -&gt; {HARDIRQ-ON-W} usage.
&lt;4&gt;[  254.192409] rtcwake/5309 [HC0[0]:SC0[0]:HE1:SE1] takes:
&lt;4&gt;[  254.192429] ffffffff8263c5f8 (rtc_lock){?...}-{2:2}, at: cmos_interrupt+0x18/0x100
&lt;4&gt;[  254.192481] {IN-HARDIRQ-W} state was registered at:
&lt;4&gt;[  254.192488]   lock_acquire+0xd1/0x3d0
&lt;4&gt;[  254.192504]   _raw_spin_lock+0x2a/0x40
&lt;4&gt;[  254.192519]   cmos_interrupt+0x18/0x100
&lt;4&gt;[  254.192536]   rtc_handler+0x1f/0xc0
&lt;4&gt;[  254.192553]   acpi_ev_fixed_event_detect+0x109/0x13c
&lt;4&gt;[  254.192574]   acpi_ev_sci_xrupt_handler+0xb/0x28
&lt;4&gt;[  254.192596]   acpi_irq+0x13/0x30
&lt;4&gt;[  254.192620]   __handle_irq_event_percpu+0x43/0x2c0
&lt;4&gt;[  254.192641]   handle_irq_event_percpu+0x2b/0x70
&lt;4&gt;[  254.192661]   handle_irq_event+0x2f/0x50
&lt;4&gt;[  254.192680]   handle_fasteoi_irq+0x9e/0x150
&lt;4&gt;[  254.192693]   __common_interrupt+0x76/0x140
&lt;4&gt;[  254.192715]   common_interrupt+0x96/0xc0
&lt;4&gt;[  254.192732]   asm_common_interrupt+0x1e/0x40
&lt;4&gt;[  254.192750]   _raw_spin_unlock_irqrestore+0x38/0x60
&lt;4&gt;[  254.192767]   resume_irqs+0xba/0xf0
&lt;4&gt;[  254.192786]   dpm_resume_noirq+0x245/0x3d0
&lt;4&gt;[  254.192811]   suspend_devices_and_enter+0x230/0xaa0
&lt;4&gt;[  254.192835]   pm_suspend.cold.8+0x301/0x34a
&lt;4&gt;[  254.192859]   state_store+0x7b/0xe0
&lt;4&gt;[  254.192879]   kernfs_fop_write_iter+0x11d/0x1c0
&lt;4&gt;[  254.192899]   new_sync_write+0x11d/0x1b0
&lt;4&gt;[  254.192916]   vfs_write+0x265/0x390
&lt;4&gt;[  254.192933]   ksys_write+0x5a/0xd0
&lt;4&gt;[  254.192949]   do_syscall_64+0x33/0x80
&lt;4&gt;[  254.192965]   entry_SYSCALL_64_after_hwframe+0x44/0xae
&lt;4&gt;[  254.192986] irq event stamp: 43775
&lt;4&gt;[  254.192994] hardirqs last  enabled at (43775): [&lt;ffffffff81c00c42&gt;] asm_sysvec_apic_timer_interrupt+0x12/0x20
&lt;4&gt;[  254.193023] hardirqs last disabled at (43774): [&lt;ffffffff81aa691a&gt;] sysvec_apic_timer_interrupt+0xa/0xb0
&lt;4&gt;[  254.193049] softirqs last  enabled at (42548): [&lt;ffffffff81e00342&gt;] __do_softirq+0x342/0x48e
&lt;4&gt;[  254.193074] softirqs last disabled at (42543): [&lt;ffffffff810b45fd&gt;] irq_exit_rcu+0xad/0xd0
&lt;4&gt;[  254.193101]
                  other info that might help us debug this:
&lt;4&gt;[  254.193107]  Possible unsafe locking scenario:

&lt;4&gt;[  254.193112]        CPU0
&lt;4&gt;[  254.193117]        ----
&lt;4&gt;[  254.193121]   lock(rtc_lock);
&lt;4&gt;[  254.193137]   &lt;Interrupt&gt;
&lt;4&gt;[  254.193142]     lock(rtc_lock);
&lt;4&gt;[  254.193156]
                   *** DEADLOCK ***

&lt;4&gt;[  254.193161] 6 locks held by rtcwake/5309:
&lt;4&gt;[  254.193174]  #0: ffff888104861430 (sb_writers#5){.+.+}-{0:0}, at: ksys_write+0x5a/0xd0
&lt;4&gt;[  254.193232]  #1: ffff88810f823288 (&amp;of-&gt;mutex){+.+.}-{3:3}, at: kernfs_fop_write_iter+0xe7/0x1c0
&lt;4&gt;[  254.193282]  #2: ffff888100cef3c0 (kn-&gt;active#285
&lt;7&gt;[  254.192706] i915 0000:00:02.0: [drm:intel_modeset_setup_hw_state [i915]] [CRTC:51:pipe A] hw state readout: disabled
&lt;4&gt;[  254.193307] ){.+.+}-{0:0}, at: kernfs_fop_write_iter+0xf0/0x1c0
&lt;4&gt;[  254.193333]  #3: ffffffff82649fa8 (system_transition_mutex){+.+.}-{3:3}, at: pm_suspend.cold.8+0xce/0x34a
&lt;4&gt;[  254.193387]  #4: ffffffff827a2108 (acpi_scan_lock){+.+.}-{3:3}, at: acpi_suspend_begin+0x47/0x70
&lt;4&gt;[  254.193433]  #5: ffff8881019ea178 (&amp;dev-&gt;mutex){....}-{3:3}, at: device_resume+0x68/0x1e0
&lt;4&gt;[  254.193485]
                  stack backtrace:
&lt;4&gt;[  254.193492] CPU: 1 PID: 5309 Comm: rtcwake Not tainted 5.12.0-rc1-CI-CI_DRM_9834+ #1
&lt;4&gt;[  254.193514] Hardware name: Google Soraka/Soraka, BIOS MrChromebox-4.10 08/25/2019
&lt;4&gt;[  254.193524] Call Trace:
&lt;4&gt;[  254.193536]  dump_stack+0x7f/0xad
&lt;4&gt;[  254.193567]  mark_lock.part.47+0x8ca/0xce0
&lt;4&gt;[  254.193604]  __lock_acquire+0x39b/0x2590
&lt;4&gt;[  254.193626]  ? asm_sysvec_apic_timer_interrupt+0x12/0x20
&lt;4&gt;[  254.193660]  lock_acquire+0xd1/0x3d0
&lt;4&gt;[  254.193677]  ? cmos_interrupt+0x18/0x100
&lt;4&gt;[  254.193716]  _raw_spin_lock+0x2a/0x40
&lt;4&gt;[  254.193735]  ? cmos_interrupt+0x18/0x100
&lt;4&gt;[  254.193758]  cmos_interrupt+0x18/0x100
&lt;4&gt;[  254.193785]  cmos_resume+0x2ac/0x2d0
&lt;4&gt;[  254.193813]  ? acpi_pm_set_device_wakeup+0x1f/0x110
&lt;4&gt;[  254.193842]  ? pnp_bus_suspend+0x10/0x10
&lt;4&gt;[  254.193864]  pnp_bus_resume+0x5e/0x90
&lt;4&gt;[  254.193885]  dpm_run_callback+0x5f/0x240
&lt;4&gt;[  254.193914]  device_resume+0xb2/0x1e0
&lt;4&gt;[  254.193942]  ? pm_dev_err+0x25/0x25
&lt;4&gt;[  254.193974]  dpm_resume+0xea/0x3f0
&lt;4&gt;[  254.194005]  dpm_resume_end+0x8/0x10
&lt;4&gt;[  254.194030]  suspend_devices_and_enter+0x29b/0xaa0
&lt;4&gt;[  254.194066]  pm_suspend.cold.8+0x301/0x34a
&lt;4&gt;[  254.194094]  state_store+0x7b/0xe0
&lt;4&gt;[  254.194124]  kernfs_fop_write_iter+0x11d/0x1c0
&lt;4&gt;[  254.194151]  new_sync_write+0x11d/0x1b0
&lt;4&gt;[  254.194183]  vfs_write+0x265/0x390
&lt;4&gt;[  254.194207]  ksys_write+0x5a/0xd0
&lt;4&gt;[  254.194232]  do_syscall_64+0x33/0x80
&lt;4&gt;[  254.194251]  entry_SYSCALL_64_after_hwframe+0x44/0xae
&lt;4&gt;[  254.194274] RIP: 0033:0x7f07d79691e7
&lt;4&gt;[  254.194293] Code: 64 89 02 48 c7 c0 ff ff ff ff eb bb 0f 1f 80 00 00 00 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 01 00 00 00 0f 05 &lt;48&gt; 3d 00 f0 ff ff 77 51 c3 48 83 ec 28 48 89 54 24 18 48 89 74 24
&lt;4&gt;[  254.194312] RSP: 002b:00007ffd9cc2c768 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
&lt;4&gt;[  254.194337] RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 00007f07d79691e7
&lt;4&gt;[  254.194352] RDX: 0000000000000004 RSI: 0000556ebfc63590 RDI: 000000000000000b
&lt;4&gt;[  254.194366] RBP: 0000556ebfc63590 R08: 0000000000000000 R09: 0000000000000004
&lt;4&gt;[  254.194379] R10: 0000556ebf0ec2a6 R11: 0000000000000246 R12: 0000000000000004

which breaks S3-resume on fi-kbl-soraka presumably as that's slow enough
to trigger the alarm during the suspend.

Fixes: 6950d046eb6e ("rtc: cmos: Replace spin_lock_irqsave with spin_lock in hard IRQ")
References: 66e4f4a9cc38 ("rtc: cmos: Use spin_lock_irqsave() in cmos_interrupt()"):
Signed-off-by: Chris Wilson &lt;chris@chris-wilson.co.uk&gt;
Cc: Xiaofei Tan &lt;tanxiaofei@huawei.com&gt;
Cc: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Cc: Alessandro Zummo &lt;a.zummo@towertech.it&gt;
Cc: Ville Syrjälä &lt;ville.syrjala@linux.intel.com&gt;
Reviewed-by: Ville Syrjälä &lt;ville.syrjala@linux.intel.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/20210305122140.28774-1-chris@chris-wilson.co.uk
</pre>
</div>
</content>
</entry>
<entry>
<title>rtc: cmos: remove stale REVISIT comments</title>
<updated>2021-08-17T21:39:20+00:00</updated>
<author>
<name>Mateusz Jończyk</name>
<email>mat.jonczyk@o2.pl</email>
</author>
<published>2021-07-16T21:04:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=e1aba37569f0aa9c993f740828871e48eea79f98'/>
<id>e1aba37569f0aa9c993f740828871e48eea79f98</id>
<content type='text'>
It appears mc146818_get_time() and mc146818_set_time() now correctly
use the century register as specified in the ACPI FADT table. It is not
clear what else could be done here.

These comments were introduced by
        commit 7be2c7c96aff ("[PATCH] RTC framework driver for CMOS RTCs")
in 2007, which originally referenced function get_rtc_time() in
include/asm-generic/rtc.h .

Signed-off-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/20210716210437.29622-1-mat.jonczyk@o2.pl
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
It appears mc146818_get_time() and mc146818_set_time() now correctly
use the century register as specified in the ACPI FADT table. It is not
clear what else could be done here.

These comments were introduced by
        commit 7be2c7c96aff ("[PATCH] RTC framework driver for CMOS RTCs")
in 2007, which originally referenced function get_rtc_time() in
include/asm-generic/rtc.h .

Signed-off-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/20210716210437.29622-1-mat.jonczyk@o2.pl
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge tag 'rtc-5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux</title>
<updated>2021-02-22T17:54:19+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2021-02-22T17:54:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=0328b5f2ef4af8ba060e64baa928c94037e7308f'/>
<id>0328b5f2ef4af8ba060e64baa928c94037e7308f</id>
<content type='text'>
Pull RTC updates from Alexandre Belloni:
 "Many cleanups and a few drivers removal this cycle.

  Subsystem:
   - Introduce features bitfield and the first feature: RTC_FEATURE_ALARM

  Removed drivers:
   - ab3100
   - coh901331
   - tx4939
   - sirfsoc

  Drivers:
   - use rtc_lock and rtc_unlock instead of opencoding
   - constify all struct rtc_class_ops
   - quiet maybe-unused variable warning
   - replace spin_lock_irqsave with spin_lock in hard IRQ
   - pcf2127: disable Power-On Reset Override and run OTP refresh"

* tag 'rtc-5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (81 commits)
  rtc: abx80x: Add utility function for writing configuration key
  rtc: pcf2127: properly set flag WD_CD for rtc chips(pcf2129, pca2129)
  rtc: pcf8563: Add NXP PCA8565 compatible
  rtc: s3c: quiet maybe-unused variable warning
  rtc: s3c: stop setting bogus time
  rtc: sd3078: quiet maybe-unused variable warning
  rtc: s35390a: quiet maybe-unused variable warning
  rtc: rx8581: quiet maybe-unused variable warning
  rtc: rx8010: quiet maybe-unused variable warning
  rtc: rv8803: quiet maybe-unused variable warning
  rtc: rv3032: quiet maybe-unused variable warning
  rtc: rv3029: quiet maybe-unused variable warning
  rtc: rv3028: quiet maybe-unused variable warning
  rtc: rs5c372: quiet maybe-unused variable warning
  rtc: pcf85363: quiet maybe-unused variable warning
  rtc: pcf85063: quiet maybe-unused variable warnings
  rtc: meson: quiet maybe-unused variable warning
  rtc: m41t80: quiet maybe-unused variable warning
  rtc: isl1208: quiet maybe-unused variable warning
  rtc: ds3232: quiet maybe-unused variable warning
  ...
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Pull RTC updates from Alexandre Belloni:
 "Many cleanups and a few drivers removal this cycle.

  Subsystem:
   - Introduce features bitfield and the first feature: RTC_FEATURE_ALARM

  Removed drivers:
   - ab3100
   - coh901331
   - tx4939
   - sirfsoc

  Drivers:
   - use rtc_lock and rtc_unlock instead of opencoding
   - constify all struct rtc_class_ops
   - quiet maybe-unused variable warning
   - replace spin_lock_irqsave with spin_lock in hard IRQ
   - pcf2127: disable Power-On Reset Override and run OTP refresh"

* tag 'rtc-5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (81 commits)
  rtc: abx80x: Add utility function for writing configuration key
  rtc: pcf2127: properly set flag WD_CD for rtc chips(pcf2129, pca2129)
  rtc: pcf8563: Add NXP PCA8565 compatible
  rtc: s3c: quiet maybe-unused variable warning
  rtc: s3c: stop setting bogus time
  rtc: sd3078: quiet maybe-unused variable warning
  rtc: s35390a: quiet maybe-unused variable warning
  rtc: rx8581: quiet maybe-unused variable warning
  rtc: rx8010: quiet maybe-unused variable warning
  rtc: rv8803: quiet maybe-unused variable warning
  rtc: rv3032: quiet maybe-unused variable warning
  rtc: rv3029: quiet maybe-unused variable warning
  rtc: rv3028: quiet maybe-unused variable warning
  rtc: rs5c372: quiet maybe-unused variable warning
  rtc: pcf85363: quiet maybe-unused variable warning
  rtc: pcf85063: quiet maybe-unused variable warnings
  rtc: meson: quiet maybe-unused variable warning
  rtc: m41t80: quiet maybe-unused variable warning
  rtc: isl1208: quiet maybe-unused variable warning
  rtc: ds3232: quiet maybe-unused variable warning
  ...
</pre>
</div>
</content>
</entry>
<entry>
<title>rtc: cmos: Replace spin_lock_irqsave with spin_lock in hard IRQ</title>
<updated>2021-02-05T23:50:47+00:00</updated>
<author>
<name>Xiaofei Tan</name>
<email>tanxiaofei@huawei.com</email>
</author>
<published>2021-02-03T12:39:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=6950d046eb6eabbc271fda416460c05f7a85698a'/>
<id>6950d046eb6eabbc271fda416460c05f7a85698a</id>
<content type='text'>
It is redundant to do irqsave and irqrestore in hardIRQ context, where
it has been in a irq-disabled context.

Signed-off-by: Xiaofei Tan &lt;tanxiaofei@huawei.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/1612355981-6764-2-git-send-email-tanxiaofei@huawei.com
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
It is redundant to do irqsave and irqrestore in hardIRQ context, where
it has been in a irq-disabled context.

Signed-off-by: Xiaofei Tan &lt;tanxiaofei@huawei.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/1612355981-6764-2-git-send-email-tanxiaofei@huawei.com
</pre>
</div>
</content>
</entry>
<entry>
<title>rtc: mc146818: Dont test for bit 0-5 in Register D</title>
<updated>2021-02-02T19:35:02+00:00</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2021-02-01T19:24:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=ebb22a05943666155e6da04407cc6e913974c78c'/>
<id>ebb22a05943666155e6da04407cc6e913974c78c</id>
<content type='text'>
The recent change to validate the RTC turned out to be overly tight.

While it cures the problem on the reporters machine it breaks machines
with Intel chipsets which use bit 0-5 of the D register. So check only
for bit 6 being 0 which is the case on these Intel machines as well.

Fixes: 211e5db19d15 ("rtc: mc146818: Detect and handle broken RTCs")
Reported-by: Serge Belyshev &lt;belyshev@depni.sinp.msu.ru&gt;
Reported-by: Dirk Gouders &lt;dirk@gouders.net&gt;
Reported-by: Borislav Petkov &lt;bp@suse.de&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Tested-by: Dirk Gouders &lt;dirk@gouders.net&gt;
Tested-by: Len Brown &lt;len.brown@intel.com&gt;
Tested-by: Borislav Petkov &lt;bp@suse.de&gt;
Acked-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/87zh0nbnha.fsf@nanos.tec.linutronix.de

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The recent change to validate the RTC turned out to be overly tight.

While it cures the problem on the reporters machine it breaks machines
with Intel chipsets which use bit 0-5 of the D register. So check only
for bit 6 being 0 which is the case on these Intel machines as well.

Fixes: 211e5db19d15 ("rtc: mc146818: Detect and handle broken RTCs")
Reported-by: Serge Belyshev &lt;belyshev@depni.sinp.msu.ru&gt;
Reported-by: Dirk Gouders &lt;dirk@gouders.net&gt;
Reported-by: Borislav Petkov &lt;bp@suse.de&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Tested-by: Dirk Gouders &lt;dirk@gouders.net&gt;
Tested-by: Len Brown &lt;len.brown@intel.com&gt;
Tested-by: Borislav Petkov &lt;bp@suse.de&gt;
Acked-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/87zh0nbnha.fsf@nanos.tec.linutronix.de

</pre>
</div>
</content>
</entry>
<entry>
<title>rtc: mc146818: Detect and handle broken RTCs</title>
<updated>2021-01-27T08:36:22+00:00</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2021-01-26T17:02:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=211e5db19d15a721b2953ea54b8f26c2963720eb'/>
<id>211e5db19d15a721b2953ea54b8f26c2963720eb</id>
<content type='text'>
The recent fix for handling the UIP bit unearthed another issue in the RTC
code. If the RTC is advertised but the readout is straight 0xFF because
it's not available, the old code just proceeded with crappy values, but the
new code hangs because it waits for the UIP bit to become low.

Add a sanity check in the RTC CMOS probe function which reads the RTC_VALID
register (Register D) which should have bit 0-6 cleared. If that's not the
case then fail to register the CMOS.

Add the same check to mc146818_get_time(), warn once when the condition
is true and invalidate the rtc_time data.

Reported-by: Mickaël Salaün &lt;mic@digikod.net&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Tested-by: Mickaël Salaün &lt;mic@linux.microsoft.com&gt;
Acked-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/87tur3fx7w.fsf@nanos.tec.linutronix.de

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The recent fix for handling the UIP bit unearthed another issue in the RTC
code. If the RTC is advertised but the readout is straight 0xFF because
it's not available, the old code just proceeded with crappy values, but the
new code hangs because it waits for the UIP bit to become low.

Add a sanity check in the RTC CMOS probe function which reads the RTC_VALID
register (Register D) which should have bit 0-6 cleared. If that's not the
case then fail to register the CMOS.

Add the same check to mc146818_get_time(), warn once when the condition
is true and invalidate the rtc_time data.

Reported-by: Mickaël Salaün &lt;mic@digikod.net&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Tested-by: Mickaël Salaün &lt;mic@linux.microsoft.com&gt;
Acked-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/87tur3fx7w.fsf@nanos.tec.linutronix.de

</pre>
</div>
</content>
</entry>
<entry>
<title>rtc: cmos: remove cmos_rtc_ops_no_alarm</title>
<updated>2021-01-16T22:19:26+00:00</updated>
<author>
<name>Alexandre Belloni</name>
<email>alexandre.belloni@bootlin.com</email>
</author>
<published>2021-01-10T23:17:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=30f5bd537fdb6124b9955858b301577ce4eb8dcd'/>
<id>30f5bd537fdb6124b9955858b301577ce4eb8dcd</id>
<content type='text'>
Clear RTC_FEATURE_ALARM to signal that alarms are not available instead of
having a supplementary struct rtc_class_ops with a NULL .set_alarm.

Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/20210110231752.1418816-5-alexandre.belloni@bootlin.com
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Clear RTC_FEATURE_ALARM to signal that alarms are not available instead of
having a supplementary struct rtc_class_ops with a NULL .set_alarm.

Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/20210110231752.1418816-5-alexandre.belloni@bootlin.com
</pre>
</div>
</content>
</entry>
</feed>
