summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaulo Zanoni <paulo.r.zanoni@intel.com>2013-11-21 17:32:42 -0200
committerPaulo Zanoni <paulo.r.zanoni@intel.com>2013-11-21 17:36:57 -0200
commit78227101e27471b81af69b54e2de203678243338 (patch)
tree56bd193f29fe966bd95b74955ee1b132f36cdebf
parente9363973b1fd973f562c101a58354e05ea2b48e4 (diff)
tests/pm_pc8: try harder to reach PC8+ residencies
If we want to actually reach PC8+ states, we need to properly configure all the devices on the system to allow this. This function will try to setup the things we know we need, but won't scream in case anything fails: we don't know which devices are present on your machine, so we can't really expect anything, just try to help with the more common problems. Another reason for this commit is that I got tired of having to readjust the runtime PM policies every time I reboot my machine. Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
-rw-r--r--tests/pm_pc8.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/pm_pc8.c b/tests/pm_pc8.c
index 19298842..cabf005b 100644
--- a/tests/pm_pc8.c
+++ b/tests/pm_pc8.c
@@ -659,6 +659,51 @@ static void setup_pc8(void)
has_pc8 = true;
}
+/* If we want to actually reach PC8+ states, we need to properly configure all
+ * the devices on the system to allow this. This function will try to setup the
+ * things we know we need, but won't scream in case anything fails: we don't
+ * know which devices are present on your machine, so we can't really expect
+ * anything, just try to help with the more common problems. */
+static void setup_non_graphics_runtime_pm(void)
+{
+ int fd, i;
+ char *file_name;
+
+ /* Disk runtime PM policies. */
+ file_name = malloc(PATH_MAX);
+ for (i = 0; ; i++) {
+
+ snprintf(file_name, PATH_MAX,
+ "/sys/class/scsi_host/host%d/link_power_management_policy",
+ i);
+
+ fd = open(file_name, O_WRONLY);
+ if (fd < 0)
+ break;
+
+ write(fd, "min_power\n", 10);
+ close(fd);
+ }
+ free(file_name);
+
+ /* Audio runtime PM policies. */
+ fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_WRONLY);
+ if (fd >= 0) {
+ write(fd, "1\n", 2);
+ close(fd);
+ }
+ fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_WRONLY);
+ if (fd >= 0) {
+ write(fd, "auto\n", 5);
+ close(fd);
+ }
+
+ /* For some yet unknown reason, it takes some time for the machine to
+ * reach PC8+ residencies after we do this. I don't really know how much
+ * we should wait, but this value seems to be working for me. */
+ sleep(10);
+}
+
static void setup_environment(void)
{
drm_fd = drm_open_any();
@@ -666,6 +711,8 @@ static void setup_environment(void)
init_mode_set_data(&ms_data);
+ setup_non_graphics_runtime_pm();
+
setup_runtime_pm();
setup_pc8();