Skip to content
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

intel_adsp: ace: clock gating in idle #64468

Conversation

tmleman
Copy link
Collaborator

@tmleman tmleman commented Oct 26, 2023

This patch enables DSP clock gating for ACE platforms. By default, clock gating is blocked by the firmware in the hardware configuration. If CONFIG_ADSP_IDLE_CLOCK_GATING is enabled, this prevent is not active and clock can be gated when core is in idle state. WIth this option disabled clock gating will only be enabled in hardware during power gating.

@ceolin
Copy link
Member

ceolin commented Oct 26, 2023

Why don't you have shallow sleep states, then in pm_state_set you do what you are doing in pm_idle_entry and calls k_cpu_idle. Then in the post ops you do what you are doing in pm_idle_exit ? The question is if that was considered

@tmleman tmleman force-pushed the topic/upstream/dev/intel/adsp/clock_optimizations branch 2 times, most recently from a066641 to 9a3ed36 Compare October 27, 2023 10:17
@tmleman
Copy link
Collaborator Author

tmleman commented Oct 27, 2023

Why don't you have shallow sleep states, then in pm_state_set you do what you are doing in pm_idle_entry and calls k_cpu_idle. Then in the post ops you do what you are doing in pm_idle_exit ? The question is if that was considered

If I add this as a sub-state for PM_STATE_RUNTIME_IDLE for example, PM_STATE_ACTIVE would become a state that we would probably end up in less than 5% of the time.

I also think it wouldn't be very efficient. We gain the most when we switch the clock and wait for the next interrupt as long as possible.

@tmleman tmleman requested a review from ceolin October 27, 2023 14:07
@tmleman
Copy link
Collaborator Author

tmleman commented Nov 7, 2023

Update ww45: I will rewrite it using the changes made in #64760. After that ACE will have its own idle implementation, so I dont need to add anything to the kernel idle.

@tmleman tmleman force-pushed the topic/upstream/dev/intel/adsp/clock_optimizations branch 3 times, most recently from b6517f8 to 8d300df Compare November 13, 2023 10:50
Copy link
Member

@ceolin ceolin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take a look in individual comments.

@tmleman
Copy link
Collaborator Author

tmleman commented Dec 6, 2023

@ceolin is the use for substates for PM_STATE_ACTIVE a blocker for you?

@tmleman tmleman requested a review from ceolin December 6, 2023 14:47
@ceolin
Copy link
Member

ceolin commented Dec 7, 2023

@ceolin is the use for substates for PM_STATE_ACTIVE a blocker for you?

I think that is the wrong way to do this, that is not the PM_STATE_ACTIVE semantic. In the end what we need is a way to set a CPU property to when it gets idle decides how to set its clock. Right ?

@tmleman tmleman force-pushed the topic/upstream/dev/intel/adsp/clock_optimizations branch 2 times, most recently from b4e47b9 to f27bbfa Compare December 7, 2023 15:29
Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first part looks ok to enabling gating based on Kconfig. The adsp-specific interface to get/put a lock, that I'm less sure about and wonder whether this could be done in a separate PR (unless this lock capability is a must-have and we cannot enable anything without it). Comments inline.

soc/xtensa/intel_adsp/ace/power.c Outdated Show resolved Hide resolved
soc/xtensa/intel_adsp/ace/power.c Outdated Show resolved Hide resolved
soc/xtensa/intel_adsp/ace/power.c Outdated Show resolved Hide resolved
soc/xtensa/intel_adsp/ace/power.c Outdated Show resolved Hide resolved
@tmleman tmleman force-pushed the topic/upstream/dev/intel/adsp/clock_optimizations branch from f27bbfa to 6dda1f4 Compare December 7, 2023 22:53
@tmleman tmleman changed the title intel_adsp: ace: clock usage optimizations in idle intel_adsp: ace: clock gating in idle Dec 7, 2023
Copy link
Contributor

@andyross andyross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpicks

soc/xtensa/intel_adsp/common/include/adsp_clk.h Outdated Show resolved Hide resolved
soc/xtensa/intel_adsp/ace/power.c Outdated Show resolved Hide resolved
soc/xtensa/intel_adsp/ace/power.c Outdated Show resolved Hide resolved
This patch enables DSP clock gating for ACE platforms. By default, clock
gating is blocked by the firmware in the hardware configuration. If
CONFIG_ADSP_IDLE_CLOCK_GATING is enabled, this prevent is not active and
clock can be gated when core is in idle state. WIth this option disabled
clock gating will only be enabled in hardware during power gating.

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
@tmleman tmleman force-pushed the topic/upstream/dev/intel/adsp/clock_optimizations branch from 6dda1f4 to 0c584de Compare December 8, 2023 12:44
@tmleman
Copy link
Collaborator Author

tmleman commented Dec 8, 2023

I abandoned the desire to add an API that allows you to change clock gating settings in the runtime. Currently, the option to permanently enable this in the hardware is sufficient.

Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tmleman , looks good! We can build on top of this to add runtime control later if/when needed (and have more time to discuss what is the proper interface to expose this).

@carlescufi carlescufi merged commit 3732aae into zephyrproject-rtos:main Dec 12, 2023
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.