pm_idle.c add support for smp case. #13541
Draft
+461
−11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
The current pm_idle is only support for not smp case, and we are now start facing the chip & board & project with both smp and power consume limit. These patchs will take smp support for PM.
We do a spinlock_irqsave and cpuset bit clear to ensure there is no running cpu. then the pm_handle can do cross-core relative operations with locked.
PM_IDLE_DOMAIN now only action as system domain, and only update when last core enter sleep, or first core leave sleep.
If want to get notification from specific core should register callback by specific cpu domain.
system domain will not deeper than cpudomain cur state.
this behavior is realized by stay/relax when cpudomain state change.
We exposed the lock/unlock behavior in pm_handler, so need manually unlock->WFI->lock in pm_handler, to make possible minium the cpus lock time. if not cross core relative required, operations can also do after unlock, and before WFI.
As it always run in idle threads. Need to sched_lock, so sched lock by tcb/core is required.
Before this feature ready will keep in draft status.
Impact
This method is optional, and will no impact if did not face the use case open COFIG_PM and CONFIG_SMP at the same time.
When open CONFIG_PM and CONFIG_SMP at the same time, the pm_idle function will replaced with smp version, and require the chip/board to implement pm handler, to take care of the cpu domain & system domain state changed.
Testing
CI-test & qemu-v8a manually open CONFIG_PM & cortex-A7 SMP board.