summaryrefslogtreecommitdiff
path: root/examples/usercmodule/cexample/examplemodule.c
diff options
context:
space:
mode:
authorAngus Gratton <angus@redyak.com.au>2024-07-05 15:44:45 +1000
committerDamien George <damien@micropython.org>2024-07-23 16:01:42 +1000
commiteced9d86a709f3f267edc7bc08e52115d0c0c9df (patch)
treeaa3ee9e28a5f2d061907b3a7718ab133567b3370 /examples/usercmodule/cexample/examplemodule.c
parent44527ada5f120f5f131bcd759e86e4e5323555aa (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