diff options
author | Angus Gratton <angus@redyak.com.au> | 2024-07-05 15:44:45 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2024-07-23 16:01:42 +1000 |
commit | eced9d86a709f3f267edc7bc08e52115d0c0c9df (patch) | |
tree | aa3ee9e28a5f2d061907b3a7718ab133567b3370 /examples/usercmodule/cexample/examplemodule.c | |
parent | 44527ada5f120f5f131bcd759e86e4e5323555aa (diff) |
rp2: Fix power consumption when sleeping with a timeout.
Fixes a regression introduced in 3af006efb39ad0b7aa7c0401c93329b654bca617
where WFE never blocked in `mp_wfe_or_timeout()` function and would
busy-wait instead. This increases power consumption measurably.
Root cause is that `mp_wfe_or_timeout()` calls soft timer functions that
(after the regression) call `recursive_mutex_enter()` and
`recursive_mutex_exit()`. The exit calls
`lock_internal_spin_unlock_with_notify()` and the default pico-sdk
implementation of this macro issues a SEV which negates the WFE that
follows it, meaning the CPU never suspends.
See https://forums.raspberrypi.com/viewtopic.php?p=2233908 for more
details.
The fix in this comment adds a custom "nowait" variant mutex that doesn't
do WFE/SEV, and uses this one for PendSV. This will use more power when
there's contention for the PendSV mutex as the other core will spin, but
this shouldn't happen very often.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Diffstat (limited to 'examples/usercmodule/cexample/examplemodule.c')
0 files changed, 0 insertions, 0 deletions