<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/drivers/rtc/rtc-cmos.c, branch v5.16</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<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.toradex.cn/cgit/linux-toradex.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.toradex.cn/cgit/linux-toradex.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.toradex.cn/cgit/linux-toradex.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.toradex.cn/cgit/linux-toradex.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.toradex.cn/cgit/linux-toradex.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.toradex.cn/cgit/linux-toradex.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.toradex.cn/cgit/linux-toradex.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>
<entry>
<title>Merge tag 'rtc-5.11' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux</title>
<updated>2020-12-20T18:12:06+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2020-12-20T18:12:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=f4a2f7866faaf89ea1595b136e01fcb336b46aab'/>
<id>f4a2f7866faaf89ea1595b136e01fcb336b46aab</id>
<content type='text'>
Pull RTC updates from Alexandre Belloni:
 "Subsystem:

   - Remove nvram ABI. There was no complaints about the deprecation for
     the last 3 years.

   - Improve RTC device allocation and registration

   - Now available for ARCH=um

  Drivers:

   - at91rm9200: correction and sam9x60 support

   - ds1307: improve ACPI support

   - mxc: now DT only

   - pcf2127: watchdog support now needs the reset-source property

   - pcf8523: set range

   - rx6110: i2c support"

* tag 'rtc-5.11' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (43 commits)
  rtc: pcf2127: only use watchdog when explicitly available
  dt-bindings: rtc: add reset-source property
  rtc: fix RTC removal
  rtc: s3c: Remove dead code related to periodic tick handling
  rtc: s3c: Disable all enable (RTC, tick) bits in the probe
  rtc: ep93xx: Fix NULL pointer dereference in ep93xx_rtc_read_time
  rtc: test: remove debug message
  rtc: mxc{,_v2}: enable COMPILE_TEST
  rtc: enable RTC framework on ARCH=um
  rtc: pcf8523: use BIT
  rtc: pcf8523: set range
  rtc: pcf8523: switch to devm_rtc_allocate_device
  rtc: destroy mutex when releasing the device
  rtc: shrink devm_rtc_allocate_device()
  rtc: rework rtc_register_device() resource management
  rtc: nvmem: emit an error message when nvmem registration fails
  rtc: add devm_ prefix to rtc_nvmem_register()
  rtc: nvmem: remove nvram ABI
  Documentation: list RTC devres helpers in devres.rst
  rtc: omap: use devm_pinctrl_register()
  ...
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Pull RTC updates from Alexandre Belloni:
 "Subsystem:

   - Remove nvram ABI. There was no complaints about the deprecation for
     the last 3 years.

   - Improve RTC device allocation and registration

   - Now available for ARCH=um

  Drivers:

   - at91rm9200: correction and sam9x60 support

   - ds1307: improve ACPI support

   - mxc: now DT only

   - pcf2127: watchdog support now needs the reset-source property

   - pcf8523: set range

   - rx6110: i2c support"

* tag 'rtc-5.11' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (43 commits)
  rtc: pcf2127: only use watchdog when explicitly available
  dt-bindings: rtc: add reset-source property
  rtc: fix RTC removal
  rtc: s3c: Remove dead code related to periodic tick handling
  rtc: s3c: Disable all enable (RTC, tick) bits in the probe
  rtc: ep93xx: Fix NULL pointer dereference in ep93xx_rtc_read_time
  rtc: test: remove debug message
  rtc: mxc{,_v2}: enable COMPILE_TEST
  rtc: enable RTC framework on ARCH=um
  rtc: pcf8523: use BIT
  rtc: pcf8523: set range
  rtc: pcf8523: switch to devm_rtc_allocate_device
  rtc: destroy mutex when releasing the device
  rtc: shrink devm_rtc_allocate_device()
  rtc: rework rtc_register_device() resource management
  rtc: nvmem: emit an error message when nvmem registration fails
  rtc: add devm_ prefix to rtc_nvmem_register()
  rtc: nvmem: remove nvram ABI
  Documentation: list RTC devres helpers in devres.rst
  rtc: omap: use devm_pinctrl_register()
  ...
</pre>
</div>
</content>
</entry>
<entry>
<title>ntp: Make the RTC sync offset less obscure</title>
<updated>2020-12-11T09:40:53+00:00</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2020-12-06T21:46:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=69eca258c85000564577642ba28335eb4e1df8f0'/>
<id>69eca258c85000564577642ba28335eb4e1df8f0</id>
<content type='text'>
The current RTC set_offset_nsec value is not really intuitive to
understand. 

  tsched       twrite(t2.tv_sec - 1) 	 t2 (seconds increment)

The offset is calculated from twrite based on the assumption that t2 -
twrite == 1s. That means for the MC146818 RTC the offset needs to be
negative so that the write happens 500ms before t2.

It's easier to understand when the whole calculation is based on t2. That
avoids negative offsets and the meaning is obvious:

 t2 - twrite:     The time defined by the chip when seconds increment
      		  after the write.

 twrite - tsched: The time for the transport to the point where the chip
 	  	  is updated. 

==&gt; set_offset_nsec =  t2 - tsched
    ttransport      =  twrite - tsched
    tRTCinc         =  t2 - twrite
==&gt; set_offset_nsec =  ttransport + tRTCinc

tRTCinc is a chip property and can be obtained from the data sheet.

ttransport depends on how the RTC is connected. It is close to 0 for
directly accessible RTCs. For RTCs behind a slow bus, e.g. i2c, it's the
time required to send the update over the bus. This can be estimated or
even calibrated, but that's a different problem.

Adjust the implementation and update comments accordingly.

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Acked-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/20201206220542.263204937@linutronix.de

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The current RTC set_offset_nsec value is not really intuitive to
understand. 

  tsched       twrite(t2.tv_sec - 1) 	 t2 (seconds increment)

The offset is calculated from twrite based on the assumption that t2 -
twrite == 1s. That means for the MC146818 RTC the offset needs to be
negative so that the write happens 500ms before t2.

It's easier to understand when the whole calculation is based on t2. That
avoids negative offsets and the meaning is obvious:

 t2 - twrite:     The time defined by the chip when seconds increment
      		  after the write.

 twrite - tsched: The time for the transport to the point where the chip
 	  	  is updated. 

==&gt; set_offset_nsec =  t2 - tsched
    ttransport      =  twrite - tsched
    tRTCinc         =  t2 - twrite
==&gt; set_offset_nsec =  ttransport + tRTCinc

tRTCinc is a chip property and can be obtained from the data sheet.

ttransport depends on how the RTC is connected. It is close to 0 for
directly accessible RTCs. For RTCs behind a slow bus, e.g. i2c, it's the
time required to send the update over the bus. This can be estimated or
even calibrated, but that's a different problem.

Adjust the implementation and update comments accordingly.

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Acked-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/20201206220542.263204937@linutronix.de

</pre>
</div>
</content>
</entry>
<entry>
<title>rtc: cmos: Make rtc_cmos sync offset correct</title>
<updated>2020-12-11T09:40:52+00:00</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2020-12-06T21:46:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=b0ecd8e8c5ef376777277c4c2db7de92ac59f23f'/>
<id>b0ecd8e8c5ef376777277c4c2db7de92ac59f23f</id>
<content type='text'>
The offset for rtc_cmos must be -500ms to work correctly with the current
implementation of rtc_set_ntp_time() due to the following:

  tsched       twrite(t2.tv_sec - 1) 	 t2 (seconds increment)

twrite - tsched is the transport time for the write to hit the device,
which is negligible for this chip because it's accessed directly.

t2 - twrite = 500ms according to the datasheet.

But rtc_set_ntp_time() calculation of tsched is:

    tsched = t2 - 1sec - (t2 - twrite)

The default for the sync offset is 500ms which means that the write happens
at t2 - 1.5 seconds which is obviously off by a second for this device.

Make the offset -500ms so it works correct.

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Reviewed-by: Jason Gunthorpe &lt;jgg@nvidia.com&gt;
Acked-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/20201206220541.830517160@linutronix.de

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The offset for rtc_cmos must be -500ms to work correctly with the current
implementation of rtc_set_ntp_time() due to the following:

  tsched       twrite(t2.tv_sec - 1) 	 t2 (seconds increment)

twrite - tsched is the transport time for the write to hit the device,
which is negligible for this chip because it's accessed directly.

t2 - twrite = 500ms according to the datasheet.

But rtc_set_ntp_time() calculation of tsched is:

    tsched = t2 - 1sec - (t2 - twrite)

The default for the sync offset is 500ms which means that the write happens
at t2 - 1.5 seconds which is obviously off by a second for this device.

Make the offset -500ms so it works correct.

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Reviewed-by: Jason Gunthorpe &lt;jgg@nvidia.com&gt;
Acked-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/20201206220541.830517160@linutronix.de

</pre>
</div>
</content>
</entry>
</feed>
