[PATCH RFC 2/3] alarmtimer: Choose the wakeup RTC by sleep state and priority

Thomas Gleixner tglx at kernel.org
Thu Nov 12 02:26:09 PST 2026


On Wed, Nov 11 2026 at 01:50, Igor Velkov wrote:
> On Wed, Nov 11 2026 at 00:14, Thomas Gleixner wrote:
>> So this gets _ONE_ suspend() and _ONE_ resume() call and nothing more
>> and everything falls in place and is comprehensible, no?
>
> Thanks, that is much simpler. v2 will first replace the freezer_delta
> handling as you sketched, then add the per-state wakeup_ctl with one
> pseudo device and no priority, and reject suspend into a state without
> an RTC while an alarm is armed. It will be based on tip timers/core and
> follow the tip style. I'll also check whether user space looks up the
> alarmtimer device.

You want to structure this nicely into $N patches:

    1) Provide and use alarmtimer_has_rtcdev()

       Just check !!READ_ONCE(rtcdev)

       Convert the one lonely user outside of the core code and the core
       code itself. Replace the few users which actually need the
       pointer and do the read directly there.

    2) Move the static variables into struct wakeup_ctl

    3) Replace the freezer delta handling

    4) Switch to the pseudo platform device

    5) Convert the rtcdev storage to an array and implement a stub
       parser which returns STATES_ALL.

    6) Add the actual device tree parser logic, which enables the whole
       thing.

That makes it easy to review and bisect.

For #4 you might think about doing the following:

	for (int state = 0; i < ARRAY_SIZE(state_names); state++) {
        	if (!state_names[state])
                	continue;
         	sysfs_create_link(&wakeup_ctl->pdev->dev.kobj,
                                  &dev->kobj, state_names[state];
        }

which creates symlinks in

/sys/devices/platform/alarmtimer.0.auto/

        freeze -> ../../pci0000:00/0000:00:1f.0/PNP0B00:00/rtc/rtc0
        mem -> ../../pci0000:00/0000:00:1f.0/PNP0B00:00/rtc/rtc0
        standby -> ../../pci0000:00/0000:00:1f.0/PNP0B00:00/rtc/rtc0

and in #5 this becomes:

	for_each_set_bit(state, &states, PM_SUSPEND_MAX) {
		wakeup_ctl.rtcs[state] = dev;
         	sysfs_create_link(&wakeup_ctl->pdev->dev.kobj,
                                  &dev->kobj, state_names[state];
        }

so the symlinks point to the device which is assigned to a state. That
gives at least some insight into the actual assignments on systmes which
need more than one RTC to wake up.

Thanks,

        tglx






More information about the linux-arm-kernel mailing list