Skip to contentSkip to conversation

lib/igt_aux: move audio RPM code to igt_setup_runtime_pm()

PATCH In review Paulo Zanoni 2 participants 2 messages Oct 21, 2014 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/igt_aux: move audio RPM code to igt_setup_runtime_pm()

From: Paulo Zanoni <[email protected]>

If we don't enable audio runtime PM, the audio driver won't release its reference, the refcount won't ever become zero, so we will never actually runtime suspend. So move this code from pm_rpm.c to igt_aux.c, so kms_flip - and any other IGT test case using RPM - can benefit from it.

Previously, if you ran pm_rpm before running the other tests - or if you just didn't have snd_hda_intel loaded - you wouldn't notice this bug.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=78893

---
 lib/igt_aux.c  | 14 ++++++++++++++
 tests/pm_rpm.c | 12 ------------
 2 files changed, 14 insertions(+), 12 deletions(-)
lib/igt_aux.c +14 -0
index 01654f0..0e1eeea 100644
@@ -431,6 +431,20 @@ bool igt_setup_runtime_pm(void)
 	if (pm_status_fd >= 0)
 		return true;
 
+	/* The Audio driver can get runtime PM references, so we need to make
+	 * sure its runtime PM is enabled, so it can release the refs and
+	 * actually enable us to runtime suspend. */
+	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_WRONLY);
+	if (fd >= 0) {
+		igt_assert(write(fd, "1\n", 2) == 2);
+		close(fd);
+	}
+	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_WRONLY);
+	if (fd >= 0) {
+		igt_assert(write(fd, "auto\n", 5) == 5);
+		close(fd);
+	}
+
 	/* Our implementation uses autosuspend. Try to set it to 0ms so the test
 	 * suite goes faster and we have a higher probability of triggering race
 	 * conditions. */
tests/pm_rpm.c +0 -12
index 4ee3ca7..25c9900 100644
@@ -697,18 +697,6 @@ static void setup_non_graphics_runtime_pm(void)
 		close(fd);
 	}
 	free(file_name);
-
-	/* Audio runtime PM policies. */
-	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_WRONLY);
-	if (fd >= 0) {
-		igt_assert(write(fd, "1\n", 2) == 2);
-		close(fd);
-	}
-	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_WRONLY);
-	if (fd >= 0) {
-		igt_assert(write(fd, "auto\n", 5) == 5);
-		close(fd);
-	}
 }
 
 static void setup_environment(void)
Signature · 1 line
1.9.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Paulo Zanoni

From: Paulo Zanoni <[email protected]>

If we don't enable audio runtime PM, the audio driver won't release its reference, the refcount won't ever become zero, so we will never actually runtime suspend. So move this code from pm_rpm.c to igt_aux.c, so kms_flip - and any other IGT test case using RPM - can benefit from it.

Quoted 7 lines

Previously, if you ran pm_rpm before running the other tests - or if you just didn't have snd_hda_intel loaded - you wouldn't notice this bug.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=78893

Yeah, somehow missed that in my extraction - with all the trouble I've stopped building with audio enabled.

Cheers, Daniel

Quoted 56 lines
---
 lib/igt_aux.c  | 14 ++++++++++++++
 tests/pm_rpm.c | 12 ------------
 2 files changed, 14 insertions(+), 12 deletions(-)
lib/igt_aux.c +14 -0
index 01654f0..0e1eeea 100644
@@ -431,6 +431,20 @@ bool igt_setup_runtime_pm(void)
 	if (pm_status_fd >= 0)
 		return true;
 
+	/* The Audio driver can get runtime PM references, so we need to make
+	 * sure its runtime PM is enabled, so it can release the refs and
+	 * actually enable us to runtime suspend. */
+	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_WRONLY);
+	if (fd >= 0) {
+		igt_assert(write(fd, "1\n", 2) == 2);
+		close(fd);
+	}
+	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_WRONLY);
+	if (fd >= 0) {
+		igt_assert(write(fd, "auto\n", 5) == 5);
+		close(fd);
+	}
+
 	/* Our implementation uses autosuspend. Try to set it to 0ms so the test
 	 * suite goes faster and we have a higher probability of triggering race
 	 * conditions. */
tests/pm_rpm.c +0 -12
index 4ee3ca7..25c9900 100644
@@ -697,18 +697,6 @@ static void setup_non_graphics_runtime_pm(void)
 		close(fd);
 	}
 	free(file_name);
-
-	/* Audio runtime PM policies. */
-	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_WRONLY);
-	if (fd >= 0) {
-		igt_assert(write(fd, "1\n", 2) == 2);
-		close(fd);
-	}
-	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_WRONLY);
-	if (fd >= 0) {
-		igt_assert(write(fd, "auto\n", 5) == 5);
-		close(fd);
-	}
 }
 
 static void setup_environment(void)
Signature · 1 line
1.9.1
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch