Conversation
cpu/cortexm_common/periph/pm.c
Outdated
| #include "periph/pm.h" | ||
|
|
||
| #ifndef FEATURE_PERIPH_PM | ||
| #ifndef MODULE_PM_LAYERED |
There was a problem hiding this comment.
Shouldn't this be #ifndef PROVIDES_PM_SET_LOWEST? Because any other CPU could in theory define pm_set_lowest
There was a problem hiding this comment.
The problem with using PROVIDES_PM_SET_LOWEST here is, that it does not clearly differentiate from the fallback implementation in drivers/periph_common/pm.c (which uses the that guard).
But true, this line needs to be changed, how about
#if !defined(MODULE_PM_LAYERED) && !defined(PROVIDES_PM_SET_LOWEST_CORTEXM)
So we have 4 possible cases:
- CPU branch uses
pm_set_lowest()fromperiph_common-> do nothing - CPU uses 'set_lowest()
defined by architecture -> definePROVIDES_PM_SET_LOWEST` by CPU architecture, do nothing else - CPU uses
pm_layered-> simply use that module, it definesPROVIDES_PM_SET_LOWESTin any case (if not done already by the CPU architecture config) - CPU wants to use its own implementation -> CPU defines
PROVIDES_PM_SET_LOWEST_CORTEXM', and do not usepm_layered`
| * @name Power management configuration | ||
| * @{ | ||
| */ | ||
| #if defined(CPU_FAM_STM32F1) || defined(CPU_FAM_STM32F2) || defined(CPU_FAM_STM32F4) |
There was a problem hiding this comment.
Should be #define PROVIDES_PM_OFF in my opinion. As the function is still called pm_off().
There was a problem hiding this comment.
nope, as we want to explicitly override the pm_off function provided by the pm_layered module.
Rationale: for the 3 CPU families specified above, we know that we use the pm_layered module. So if we want to use a custom pm_off function, we need to explicitly override the one provided by pm_layered (which in turn overrides the default one from periph_common).
| extern "C" { | ||
| #endif | ||
|
|
||
| #ifndef PROVIDES_PM_OFF |
There was a problem hiding this comment.
I personally don't like mixing PROVIDED_PM_OFF and PROVIDES_PM_LAYERED_OFF. Can we get rid of this? Or is this required?
There was a problem hiding this comment.
IMHO this is required, as each of those defines overrides a specific function in the 'fallback hierarchy'. As I see it, this is the price to pay for having multiple tiers of fallback functions.
But maybe we come up with an even better idea?
|
Very nice idea: provide instead of need... Also re-using the existing config headers. @roberthartung what do you think? |
|
fixed all boards but the MIPS, need to install the toolchain locally to debug this... fix follows asap. |
|
|
done, at least locally they should be all set. |
|
@roberthartung @kaspar030: what is your verdict? And how to proceed? Would be nice to get one of the fixes merged today, so we have it for sure in the release! |
|
@haukepetersen I'd vote for merging your PR as it is (if all tests are passing ofc). The solution is good and I want to make progress with my own atmega PM implementations. |
|
I agree with @roberthartung. I prefer this solution. Also I did a quick measurement on samr21-xpro and can confirm the low power modes actually work as intended. This is already an improvement compared to the broken weak implementation. |
|
@MichelRottleuthner thanks for checking on the board! That's great. I think it's far more than an improvement. This might be a very good, clean solution while keeping flexibility. |
|
Very cool. Then I will fix this PR now and let's merge it! |
046eeae to
b3cbd29
Compare
|
rebased and fixed missing doc for pic32. Will wait for Murdock to do one more run and then squash. |
|
Murdock seems ok, so I will squash now. |
|
yes, please squash! |
9665a8b to
09ec992
Compare
|
squashed. |
|
|
||
| /** | ||
| * @brief All Cortex-m-based CPUs provide pm_set_lowest | ||
| * |
There was a problem hiding this comment.
minor: I think there's a "by" missing in this sentence.
There was a problem hiding this comment.
jupp. Fixed and squashed
09ec992 to
2e12239
Compare
|
Murdock is happy -> feel free to ACK and press the green button :-) |
|
should we set PM_BLOCKER_INITIAL to a safe default? |
possibly. But how about a quick follow-up PR for this? |
I'll make a commit that you can cherry-pick. IMO it belongs in here. |
|
done. |
Instead of using `weak` function definitions, this PR handles default implementations using `PROVIDES_x` defines, allowing for cpus/pm realted modules to use their own implementations.
8e92517 to
829271d
Compare
|
rebased. |
829271d to
416ac62
Compare
|
Let's go and start this release! |
|
@kaspar030 @haukepetersen I just tried to rebase my pm implementation for the atmega_common/atmega1284p and I am stuck at a point, where I select pm_layered im Makefile.include of my CPU. pm_layered is compiled correctly. However both pm.c from periph_common and pm_layered provide pm_set_lowest. Shouldn't we add #ifndef PROVIDES_PM_SET_LOWEST
#define PROVIDES_PM_SET_LOWEST
#endifto sys/include/pm_layered.h - at least until the default pm.c module is not build any more by accident? |
|
sorry for the delayed reply. Just trying to get my head around this: in the case a CPU is using |
|
@haukepetersen Just finished rebasing my atmega_common pm stuff on the latest master ... hooray! Will create a PR tomorrow. |
|
Awesome, looking forward to it! |
|
@haukepetersen I just wonder why this isn't conflicting at the moment as well, as some CPUs also use pm_layered already? |
|
Confirmed. Does not happen with other boards. But why? Maybe it has something todo with _common. Will investigate. |
|
@haukepetersen ping #7863 |
Created this PR just to illustrate my ideas for #7648 and I'd rather have the changes merged in #7648 instead of merging this PR...
But anyhow, I think this approach simplifies matters compared to #7648 and could be the way to go? This approach does not depend on any
weaksymbols, nor on the order of theincludepaths, so it should be pretty dependable. What do you think?66 additions and 15 deletionsvs.531 additions and 13 deletions