Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Much more flexible cpu frequency selection is available for the deck #21

Closed
JDGBOLT opened this issue Jul 28, 2022 · 4 comments
Closed
Assignees
Labels
enhancement New feature or request indev Selected for development; coming soon
Milestone

Comments

@JDGBOLT
Copy link

JDGBOLT commented Jul 28, 2022

Within the Deck's Van Gogh APU there is actually a much more flexible interface available to us for selecting a maximum/minimum clock speed. It's a little obscure and Phawx pointed me in the direction of what to do. Within /sys/class/drm/card0/device/pp_od_clk_voltage is actually controls you can use to control the minimum/max clocks for both the gpu and cpu of the deck. The deck actually uses this interface for it's manual gpu clock speed controls, it just turns out there is an additional setting specifically for Van Gogh that also controls cpu core clocks.

The required steps are as follows:
write "manual" to /sys/class/drm/card0/device/power_dpm_force_performance_level
This gives you access to the relevant controls in pp_od_clk_voltage.

Then you have to write a string in the form of: "p C M F" with:
C is the core number, from 0 to 3 to control individual cores, or you can use one not one of the numbers like 4 to control all of them at once.
M is for controlling the minimum or max core frequency, minimum is 0 maximum is 1.
F is the frequency, minimum has a minimum of 1400 and maximum has a maximum of 3500, but maximum can go below minimum to lock the deck at say 400 mhz is "p 4 1 400" as an example.
Then after you modify whatever clocks you want you write "c" to pp_od_clk_voltage which will commit the changes.

There are a few caveats with this, it's not necessarily useful for setting an absolute static clock on the deck's hardware as if the max is above 1.4 ghz it won't necessarily try to go all the way to that, it just controls the maximum, and setting the minimum does seem to get it to clock up at least one core, but it can depend with the others, when it gets pushed enough it will go at that frequency though. The other thing is it seems there is a bug with the deck where it will lock the cores at a wrong value when you put it to sleep and wake it again, but this can be fixed by writing the speed again to pp_od_clk_voltage and committing it. This exhibits even a little more subtly when having just a manual gpu clock will cause the first core to run at about half speed when waking up.

For reference how the deck controls the gpu clocks is setting the minimum and maximum to the set frequency, writing "s 0 400" "s 1 400" "c" to pp_od_clk_voltage in order to lock the frequency. This could potentially be used to have the minimum and maximum frequency of the gpu be settable in Power Tools.

There is one other thing I discovered which is mostly useful for doing ultra low power gaming with things such as 2d indies or the like. With power_dpm_force_performance_level at manual, it is possible to change the deck's memory clock from the max 687mhz to it's minimum 400mhz which it mostly just uses when idle by writing 1 to /sys/class/drm/card/device/pp_dpm_fclk . This does have an effect on performance in things that are too demanding such as most 3d games, but it can be used with lighter stuff to save between 0.5 and 1 watt of total power. For Hades I had 1 watt, Pillars of Eternity was more like 0.5 watts. In 2d gaming with the deck not being pushed very hard, it is possible to get a fair amount of more battery life by shaving that watt or so of power. It would be great to have this available as a toggle too that we can save as a profile, will make doing low intensity gaming on the deck for long periods even better.

Thanks for your consideration.

@JDGBOLT JDGBOLT added the enhancement New feature or request label Jul 28, 2022
@NGnius NGnius added this to the The upgrade milestone Jul 30, 2022
@NGnius NGnius self-assigned this Jul 30, 2022
@NGnius NGnius added the indev Selected for development; coming soon label Jul 30, 2022
@NGnius
Copy link
Owner

NGnius commented Jul 30, 2022

This is some really great info, many thanks! I'm going to get this working for the next version of PowerTools, since I've already planned out a major overhaul.

@vazmiguel
Copy link

Great find. Thank you. I have tried this and it did help to set a static clock on all cores at 2.8G. Tested for both cpu and gpu at 1600 with success. But for some reason, power_dpm_force_performance_level seems to revert to auto automatically, and then your settings are reset. So it seems you have a small time window to adjust settings after you set it to manual. Or maybe i did something wrong. Emulators not optimized for steam deck i think may benefit from this the most if the settings stick in gaming mode.

@NGnius
Copy link
Owner

NGnius commented Sep 5, 2022

Just to note, in case anyone wants to implement this on something else in the future: when writing to /sys/class/drm/card0/device/pp_od_clk_voltage, always end your string with a page return (\n). For some reason failing to do so crashes the kernel.

@NGnius
Copy link
Owner

NGnius commented Sep 5, 2022

This is working as of db3f4a8 and will be available in the next release

@NGnius NGnius closed this as completed Sep 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request indev Selected for development; coming soon
Projects
None yet
Development

No branches or pull requests

3 participants