rtc: brcmstb-waketimer: compensate for lack of wktmr disable
authorDoug Berger <opendmb@gmail.com>
Fri, 20 Jan 2023 19:01:44 +0000 (11:01 -0800)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Mon, 23 Jan 2023 23:07:21 +0000 (00:07 +0100)
commit516ae02c38ff3ae867f9b19fa050f78157e2bdae
treebea712527a9eecbcdf41728b6abdcf6c8a8a3bc0
parent2cd98b22c1443d1f2921a371baee658da184868e
rtc: brcmstb-waketimer: compensate for lack of wktmr disable

Since the WKTMR hardware block cannot be disabled it is necessary
for the driver to accommodate for associated timing hazards. This
commit targets the following possibilities:

A possible race between clearing a wktmr event and the alarm expiring
is made one-sided by setting the alarm to its maximum value before
clearing the event.

Programming alarm values close to the current time may not trigger
events if the counter advances while the alarm is being programmed.
After programming an alarm, a check is made to ensure that it is
either in the future or an expiration event is pending.

Signed-off-by: Doug Berger <opendmb@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20230120190147.718976-4-opendmb@gmail.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/rtc/rtc-brcmstb-waketimer.c