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

Closed
opened 2022-07-28 04:22:21 +01:00 by JDGBOLT · 4 comments
JDGBOLT commented 2022-07-28 04:22:21 +01:00 (Migrated from github.com)

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.

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.
NGnius commented 2022-07-30 05:35:32 +01:00 (Migrated from github.com)

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.

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 commented 2022-08-08 20:09:09 +01:00 (Migrated from github.com)

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.

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 commented 2022-09-05 19:27:50 +01:00 (Migrated from github.com)

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.

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 commented 2022-09-05 22:21:51 +01:00 (Migrated from github.com)

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

This is working as of db3f4a85c0a77f7a39dc595ed82d0b3f46105121 and will be available in the next release
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: NG-SD-Plugins/PowerTools#21
No description provided.