Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 367
ace: power policy management#6489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kv2019i
merged 5 commits into
thesofproject:main
from
tmleman:topic/upstream/zephyr/pm/pm_policyNov 4, 2022
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2a8c798
ace: power: add custom power policy
tmleman ddfe1b8
ace: power: handling d0i3 prevent
tmleman e97ceec
zephyr: power: preventing lower power states
tmleman 1d90bf8
ace: cpu: compilation error fix
tmleman aac1777
mtl: power: enabling zephyr power manager
tmleman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -9,12 +9,82 @@ | ||
| #include <sof_versions.h> | ||
| #include <stdint.h> | ||
| #include <ace_v1x-regs.h> | ||
| #include <zephyr/pm/policy.h> | ||
| /* 76cc9773-440c-4df9-95a8-72defe7796fc */ | ||
| DECLARE_SOF_UUID("power", power_uuid, 0x76cc9773, 0x440c, 0x4df9, | ||
| 0x95, 0xa8, 0x72, 0xde, 0xfe, 0x77, 0x96, 0xfc); | ||
| DECLARE_TR_CTX(power_tr, SOF_UUID(power_uuid), LOG_LEVEL_INFO); | ||
| #if defined(CONFIG_PM_POLICY_CUSTOM) | ||
| const struct pm_state_info *pm_policy_next_state(uint8_t cpu, int32_t ticks) | ||
tmleman marked this conversation as resolved.
Outdated
Uh oh!There was an error while loading. Please reload this page. | ||
| { | ||
| unsigned int num_cpu_states; | ||
| const struct pm_state_info *cpu_states; | ||
| num_cpu_states = pm_state_cpu_get_all(cpu, &cpu_states); | ||
| for (int i = num_cpu_states - 1; i >= 0; i--) { | ||
| const struct pm_state_info *state = &cpu_states[i]; | ||
| uint32_t min_residency, exit_latency; | ||
| /* policy cannot lead to D3 */ | ||
| if (state->state == PM_STATE_SOFT_OFF) | ||
| continue; | ||
| /* check if there is a lock on state + substate */ | ||
| if (pm_policy_state_lock_is_active(state->state, state->substate_id)) | ||
| continue; | ||
| if (state->state == PM_STATE_RUNTIME_IDLE) { | ||
| /* No D0i3 when secondary cores are active! */ | ||
| if (cpu_enabled_cores() & ~BIT(PLATFORM_PRIMARY_CORE_ID)) | ||
| continue; | ||
| } | ||
| min_residency = k_us_to_ticks_ceil32(state->min_residency_us); | ||
| exit_latency = k_us_to_ticks_ceil32(state->exit_latency_us); | ||
| if (ticks == K_TICKS_FOREVER || | ||
| (ticks >= (min_residency + exit_latency))) { | ||
| /* TODO: PM_STATE_RUNTIME_IDLE requires substates to be defined | ||
| * to handle case with enabled PG andf disabled CG. | ||
| */ | ||
| return state; | ||
| } | ||
| } | ||
| return NULL; | ||
| } | ||
| #endif /* CONFIG_PM_POLICY_CUSTOM */ | ||
| void platform_pm_runtime_enable(uint32_t context, uint32_t index) | ||
| { | ||
| switch (context) { | ||
| case PM_RUNTIME_DSP: | ||
| pm_policy_state_lock_put(PM_STATE_RUNTIME_IDLE, PM_ALL_SUBSTATES); | ||
| break; | ||
| default: | ||
| break; | ||
| } | ||
| } | ||
| void platform_pm_runtime_disable(uint32_t context, uint32_t index) | ||
| { | ||
| switch (context) { | ||
| case PM_RUNTIME_DSP: | ||
| pm_policy_state_lock_get(PM_STATE_RUNTIME_IDLE, PM_ALL_SUBSTATES); | ||
| /* Disable power gating when preventing */ | ||
| DFDSPBRCP.bootctl[PLATFORM_PRIMARY_CORE_ID].bctl |= | ||
| DFDSPBRCP_BCTL_WAITIPCG | DFDSPBRCP_BCTL_WAITIPPG; | ||
| break; | ||
| default: | ||
| break; | ||
| } | ||
| } | ||
| void platform_pm_runtime_init(struct pm_runtime_data *prd) | ||
| { } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -25,6 +25,7 @@ | ||
| /* Zephyr includes */ | ||
| #include <zephyr/device.h> | ||
kv2019i marked this conversation as resolved.
Outdated
Uh oh!There was an error while loading. Please reload this page. | ||
| #include <zephyr/kernel.h> | ||
| #include <zephyr/pm/policy.h> | ||
| #include <version.h> | ||
| #include <zephyr/sys/__assert.h> | ||
| #include <soc.h> | ||
| @@ -624,7 +625,10 @@ int task_main_start(struct sof *sof) | ||
| * (only called from single core, no RMW lock) | ||
| */ | ||
| __ASSERT_NO_MSG(cpu_get_id() == PLATFORM_PRIMARY_CORE_ID); | ||
| #if defined(CONFIG_PM) | ||
tmleman marked this conversation as resolved.
Outdated
Uh oh!There was an error while loading. Please reload this page. | ||
| pm_policy_state_lock_get(PM_STATE_RUNTIME_IDLE, PM_ALL_SUBSTATES); | ||
| pm_policy_state_lock_get(PM_STATE_SOFT_OFF, PM_ALL_SUBSTATES); | ||
| #endif | ||
| /* let host know DSP boot is complete */ | ||
| ret = platform_boot_complete(0); | ||
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.
Uh oh!
There was an error while loading. Please reload this page.