From e63a74266d2fe5899ed22bf3fade0b759c21d8bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Lyson=C4=9Bk?= Date: Fri, 21 Apr 2017 14:39:12 +0200 Subject: [PATCH] plugin_video: Support the 'dpm' power method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Support changing the 'power_dpm_state' parameter of Radeon GPUs. It only works if the 'dpm' power method is enabled. Note that the 'dpm' power method cannot be enabled through the video plugin, but it can be set using the bootloader plugin using 'cmdline = radeon.dpm=1'. The video plugin now recognizes a new 'radeon_dpm_state' option which changes the dpm state. Possible values are 'battery', 'balanced' and 'performance' [1]. [video] radeon_dpm_state=balanced [1] https://wiki.archlinux.org/index.php/ATI#Dynamic_power_management Resolves: rhbz#1417659 Signed-off-by: Ondřej Lysoněk --- tuned/plugins/plugin_video.py | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/tuned/plugins/plugin_video.py b/tuned/plugins/plugin_video.py index cbf3c17..c15e3ee 100644 --- a/tuned/plugins/plugin_video.py +++ b/tuned/plugins/plugin_video.py @@ -29,6 +29,7 @@ class VideoPlugin(base.Plugin): def _get_config_options(self): return { "radeon_powersave" : None, + "radeon_dpm_state" : None, } def _instance_init(self, instance): @@ -44,6 +45,9 @@ class VideoPlugin(base.Plugin): "profile": "/sys/class/drm/%s/device/power_profile" % device, } + def _radeon_dpm_state_file(self, device): + return "/sys/class/drm/%s/device/power_dpm_state" % device + @command_set("radeon_powersave", per_device=True) def _set_radeon_powersave(self, value, device, sim): sys_files = self._radeon_powersave_files(device) @@ -61,6 +65,12 @@ class VideoPlugin(base.Plugin): if not sim: self._cmd.write_to_file(sys_files["method"], "dynpm") return "dynpm" + elif value == "dpm": + if not sim and self._get_radeon_powersave(device) != "dpm": + log.error("Cannot set dpm power method through the video plugin." \ + + "Use the bootloader plugin with the 'cmdline = radeon.dpm=1' option") + return None + return "dpm" else: if not sim: log.warn("Invalid option for radeon_powersave.") @@ -73,7 +83,28 @@ class VideoPlugin(base.Plugin): method = self._cmd.read_file(sys_files["method"]).strip() if method == "profile": return self._cmd.read_file(sys_files["profile"]).strip() - elif method == "dynpm": - return "dynpm" + elif method == "dynpm" or method == "dpm": + return method else: return None + + @command_set("radeon_dpm_state", per_device=True, priority=10) + def _set_radeon_dpm_state(self, value, device, sim): + if self._get_radeon_powersave(device) != "dpm": + log.error("dpm power method is not enabled.") + return None + if not value in ["battery", "balanced", "performance"]: + if not sim: + log.warn("Invalid option for radeon_dpm_state.") + return None + path = self._radeon_dpm_state_file(device) + self._cmd.write_to_file(path, value) + return value + + @command_get("radeon_dpm_state") + def _get_radeon_dpm_state(self, device): + if self._get_radeon_powersave(device) != "dpm": + log.error("dpm power method is not enabled.") + return None + path = self._radeon_dpm_state_file(device) + return self._cmd.read_file(path).strip()