-
Notifications
You must be signed in to change notification settings - Fork 2.1k
ztimer and Power Management #16327
Copy link
Copy link
Closed
Labels
Area: pmArea: (Low) power managementArea: (Low) power managementArea: timersArea: timer subsystemsArea: timer subsystemsDiscussion: RFCThe issue/PR is used as a discussion starting point about the item of the issue/PRThe issue/PR is used as a discussion starting point about the item of the issue/PRType: cleanupThe issue proposes a clean-up / The PR cleans-up parts of the codebase / documentationThe issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation
Metadata
Metadata
Assignees
Labels
Area: pmArea: (Low) power managementArea: (Low) power managementArea: timersArea: timer subsystemsArea: timer subsystemsDiscussion: RFCThe issue/PR is used as a discussion starting point about the item of the issue/PRThe issue/PR is used as a discussion starting point about the item of the issue/PRType: cleanupThe issue proposes a clean-up / The PR cleans-up parts of the codebase / documentationThe issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation
Description
I'm the initial author of ztimer's interaction with pm_layered (#13722). Basically, it works like this: For each
ztimer_clock_t, a minimum required PM mode can be defined. If so, that PM mode is blocked, once aztimer_tis added to theztimer_clock_tand unblocked, once allztimer_thave expired. This works in my applications for more than a year, but I came to the conclusion that this approach isn't a clean solution.Long story short: ztimer interacts with pm_layered to ensure that the underlying ztimer_periph_[timer|rtt|rtc|ptp] doesn't stall. In my opinion, this should be done by the timer/rtt/rtc/ptp driver. Instead of blocking and unblocking certain PM modes, ztimer should call
timer_start()/timer_stop(),rtt_poweron()/rtt_poweroff(), ... The respective driver should be in charge of blocking and unblocking PM modes.Would you agree, that this is at least a cleaner solution?
Before any change can happen, we have some homework left to do:
periph_timerimplementation. Some already interact withpm_layered(ESP32), some don't (STM32, SAM0). We need to make sure that everyperiph_timerblocks the right PM mode. The same goes withperiph_rtt,periph_rtcandperiph_ptp.ztimer_clock_t. This means a simpleztimer_now()can't be used for time measurement anymore. For that, we must tell ztimer that the clock must not be turned off. Maybe we'll introduce a ztimer_stopwatch_...? That could be used to measuring time distances or as a wall clock? Dunno ... TBD ;-)I'd love to hear your opinion on this!
Useful links
Original PR: #13722