The AMD P-states driver has added support for active mode in kernel 6.3,
which exposes a similar interface for controlling energy performance
preference as the Intel P-state driver, with the same presets present,
so make use of it.
See:
https://www.kernel.org/doc/html/v6.3/admin-guide/pm/amd-pstate.htmlCloses: #108
src/powerprofilesctl:137:0: C0325: Unnecessary parens after '=' keyword (superfluous-parens)
src/powerprofilesctl:126:4: R1720: Unnecessary "else" after "raise", remove the "else" and de-indent the code inside it (no-else-raise)
src/powerprofilesctl:134:4: R1720: Unnecessary "else" after "raise", remove the "else" and de-indent the code inside it (no-else-raise)
src/powerprofilesctl:154:4: R1720: Unnecessary "else" after "raise", remove the "else" and de-indent the code inside it (no-else-raise)
The "cool" profile isn't a low-power mode, but a mode where the fans are
always running to reduce the temperature, presumably to allow it to run
faster.
At the same time, we need to handle the lack of low-power profile on HP
machines as they only had a cool mode and no low-power mode.
Closes: #89
Otherwise energy_performance_preference might not be writable. This can
happen on systems where the default cpufreq scaling governor has been
changed.
See https://bugzilla.redhat.com/show_bug.cgi?id=2079898Closes: #90
Before:
Traceback (most recent call last):
File "/usr/bin/powerprofilesctl", line 262, in <module>
main()
File "/usr/bin/powerprofilesctl", line 216, in main
_set(args[0])
File "/usr/bin/powerprofilesctl", line 111, in _set
proxy.Set('(ssv)',
File "/usr/lib/python3.10/site-packages/gi/overrides/Gio.py", line 349, in __call__
result = self.dbus_proxy.call_sync(self.method_name, arg_variant,
gi.repository.GLib.GError: g-io-error-quark: GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._g_2dio_2derror_2dquark.Code26: Error writing '/sys/devices/system/cpu/cpufreq/policy1/energy_performance_preference': Device or resource busy (26)
After:
Failed to communicate with power-profiles-daemon: g-io-error-quark: GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._g_2dio_2derror_2dquark.Code26: Error writing '/sys/devices/system/cpu/cpufreq/policy1/energy_performance_preference': Device or resource busy (26)
Because fprintf() is buffered unless disabled and we weren't checking
for the fclose() return value, we were returning without errors when
there should have been some.
WARNING: You should add the boolean check kwarg to the run_command call.
It currently defaults to false,
but it will default to true in future releases of meson.
See also: https://github.com/mesonbuild/meson/issues/9300