Re: [PATCH v2 01/22] rtc: pm8xxx: fix set-alarm race

From: Johan Hovold
Date: Tue Feb 07 2023 - 10:55:59 EST


On Tue, Feb 07, 2023 at 04:13:36PM +0100, Johan Hovold wrote:
> On Mon, Feb 06, 2023 at 07:12:43PM -0800, David Collins wrote:
> > On 2/2/23 07:54, Johan Hovold wrote:
> > > Make sure to disable the alarm before updating the four alarm time
> > > registers to avoid spurious alarms during the update.
> >
> > What scenario can encounter a spurious alarm triggering upon writing the
> > new alarm time inside of pm8xxx_rtc_set_alarm()?
>
> The alarm is stored in four bytes in little-endian order. Consider
> having had an alarm set and expired at:

This was just supposed to say "Consider having an alarm set at:" as the
alarm must still be enabled. Let me update the example I gave:

Consider having an alarm set at

10 01 00 00

and now you want to set an alarm at

01 02 00 00

Unless the alarm is disabled before the update the alarm could go off at

01 01 00 00

after updating the first byte.

Johan