All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t 1/4] lib/igt_pm: Make exit handlers signal safe
@ 2018-07-23 11:46 ` Tvrtko Ursulin
  0 siblings, 0 replies; 33+ messages in thread
From: Tvrtko Ursulin @ 2018-07-23 11:46 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

IGT logging helpers are not signal safe so avoid calling them from exit
handlers.

At the same time refactor the code a bit to enable following patches.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 lib/igt_pm.c | 77 ++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 53 insertions(+), 24 deletions(-)

diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 8ac132269d79..6f3b0a2d897d 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -66,33 +66,47 @@ enum {
 static char __igt_pm_audio_runtime_power_save[64];
 static char __igt_pm_audio_runtime_control[64];
 
-static void __igt_pm_audio_runtime_exit_handler(int sig)
+static int __igt_pm_audio_restore_runtime_pm(void)
 {
 	int fd;
 
-	igt_debug("Restoring audio power management to '%s' and '%s'\n",
-		  __igt_pm_audio_runtime_power_save,
-		  __igt_pm_audio_runtime_control);
+	if (!__igt_pm_audio_runtime_power_save[0])
+		return 0;
 
 	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_WRONLY);
 	if (fd < 0)
-		return;
+		return errno;
+
 	if (write(fd, __igt_pm_audio_runtime_power_save,
 		  strlen(__igt_pm_audio_runtime_power_save)) !=
-	    strlen(__igt_pm_audio_runtime_power_save))
-		igt_warn("Failed to restore audio power_save to '%s'\n",
-			 __igt_pm_audio_runtime_power_save);
+	    strlen(__igt_pm_audio_runtime_power_save)) {
+		close(fd);
+		return errno;
+	}
+
 	close(fd);
 
 	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_WRONLY);
 	if (fd < 0)
-		return;
+		return errno;
+
 	if (write(fd, __igt_pm_audio_runtime_control,
 		  strlen(__igt_pm_audio_runtime_control)) !=
-	    strlen(__igt_pm_audio_runtime_control))
-		igt_warn("Failed to restore audio control to '%s'\n",
-			 __igt_pm_audio_runtime_control);
+	    strlen(__igt_pm_audio_runtime_control)) {
+		close(fd);
+		return errno;
+	}
+
 	close(fd);
+
+	__igt_pm_audio_runtime_power_save[0] = 0;
+
+	return 0;
+}
+
+static void __igt_pm_audio_runtime_exit_handler(int sig)
+{
+	__igt_pm_audio_restore_runtime_pm();
 }
 
 static void strchomp(char *str)
@@ -297,33 +311,48 @@ int pm_status_fd = -1;
 static char __igt_pm_runtime_autosuspend[64];
 static char __igt_pm_runtime_control[64];
 
-static void __igt_pm_runtime_exit_handler(int sig)
+static int __igt_restore_runtime_pm(void)
 {
 	int fd;
 
-	igt_debug("Restoring runtime management to '%s' and '%s'\n",
-		  __igt_pm_runtime_autosuspend,
-		  __igt_pm_runtime_control);
+	if (pm_status_fd < 0)
+		return 0;
 
 	fd = open(POWER_DIR "/autosuspend_delay_ms", O_WRONLY);
 	if (fd < 0)
-		return;
+		return errno;
+
 	if (write(fd, __igt_pm_runtime_autosuspend,
 		  strlen(__igt_pm_runtime_autosuspend)) !=
-	    strlen(__igt_pm_runtime_autosuspend))
-		igt_warn("Failed to restore runtime pm autosuspend delay to '%s'\n",
-			 __igt_pm_runtime_autosuspend);
+	    strlen(__igt_pm_runtime_autosuspend)) {
+		close(fd);
+		return errno;
+	}
+
 	close(fd);
 
 	fd = open(POWER_DIR "/control", O_WRONLY);
 	if (fd < 0)
-		return;
+		return errno;
+
 	if (write(fd, __igt_pm_runtime_control,
 		  strlen(__igt_pm_runtime_control)) !=
-	    strlen(__igt_pm_runtime_control))
-		igt_warn("Failed to restore runtime pm control to '%s'\n",
-			 __igt_pm_runtime_control);
+	    strlen(__igt_pm_runtime_control)) {
+		close(fd);
+		return errno;
+	}
+
 	close(fd);
+
+	close(pm_status_fd);
+	pm_status_fd = -1;
+
+	return 0;
+}
+
+static void __igt_pm_runtime_exit_handler(int sig)
+{
+	__igt_restore_runtime_pm();
 }
 
 /**
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [igt-dev] [PATCH i-g-t 1/4] lib/igt_pm: Make exit handlers signal safe
@ 2018-07-23 11:46 ` Tvrtko Ursulin
  0 siblings, 0 replies; 33+ messages in thread
From: Tvrtko Ursulin @ 2018-07-23 11:46 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx, Tvrtko Ursulin

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

IGT logging helpers are not signal safe so avoid calling them from exit
handlers.

At the same time refactor the code a bit to enable following patches.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 lib/igt_pm.c | 77 ++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 53 insertions(+), 24 deletions(-)

diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 8ac132269d79..6f3b0a2d897d 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -66,33 +66,47 @@ enum {
 static char __igt_pm_audio_runtime_power_save[64];
 static char __igt_pm_audio_runtime_control[64];
 
-static void __igt_pm_audio_runtime_exit_handler(int sig)
+static int __igt_pm_audio_restore_runtime_pm(void)
 {
 	int fd;
 
-	igt_debug("Restoring audio power management to '%s' and '%s'\n",
-		  __igt_pm_audio_runtime_power_save,
-		  __igt_pm_audio_runtime_control);
+	if (!__igt_pm_audio_runtime_power_save[0])
+		return 0;
 
 	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_WRONLY);
 	if (fd < 0)
-		return;
+		return errno;
+
 	if (write(fd, __igt_pm_audio_runtime_power_save,
 		  strlen(__igt_pm_audio_runtime_power_save)) !=
-	    strlen(__igt_pm_audio_runtime_power_save))
-		igt_warn("Failed to restore audio power_save to '%s'\n",
-			 __igt_pm_audio_runtime_power_save);
+	    strlen(__igt_pm_audio_runtime_power_save)) {
+		close(fd);
+		return errno;
+	}
+
 	close(fd);
 
 	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_WRONLY);
 	if (fd < 0)
-		return;
+		return errno;
+
 	if (write(fd, __igt_pm_audio_runtime_control,
 		  strlen(__igt_pm_audio_runtime_control)) !=
-	    strlen(__igt_pm_audio_runtime_control))
-		igt_warn("Failed to restore audio control to '%s'\n",
-			 __igt_pm_audio_runtime_control);
+	    strlen(__igt_pm_audio_runtime_control)) {
+		close(fd);
+		return errno;
+	}
+
 	close(fd);
+
+	__igt_pm_audio_runtime_power_save[0] = 0;
+
+	return 0;
+}
+
+static void __igt_pm_audio_runtime_exit_handler(int sig)
+{
+	__igt_pm_audio_restore_runtime_pm();
 }
 
 static void strchomp(char *str)
@@ -297,33 +311,48 @@ int pm_status_fd = -1;
 static char __igt_pm_runtime_autosuspend[64];
 static char __igt_pm_runtime_control[64];
 
-static void __igt_pm_runtime_exit_handler(int sig)
+static int __igt_restore_runtime_pm(void)
 {
 	int fd;
 
-	igt_debug("Restoring runtime management to '%s' and '%s'\n",
-		  __igt_pm_runtime_autosuspend,
-		  __igt_pm_runtime_control);
+	if (pm_status_fd < 0)
+		return 0;
 
 	fd = open(POWER_DIR "/autosuspend_delay_ms", O_WRONLY);
 	if (fd < 0)
-		return;
+		return errno;
+
 	if (write(fd, __igt_pm_runtime_autosuspend,
 		  strlen(__igt_pm_runtime_autosuspend)) !=
-	    strlen(__igt_pm_runtime_autosuspend))
-		igt_warn("Failed to restore runtime pm autosuspend delay to '%s'\n",
-			 __igt_pm_runtime_autosuspend);
+	    strlen(__igt_pm_runtime_autosuspend)) {
+		close(fd);
+		return errno;
+	}
+
 	close(fd);
 
 	fd = open(POWER_DIR "/control", O_WRONLY);
 	if (fd < 0)
-		return;
+		return errno;
+
 	if (write(fd, __igt_pm_runtime_control,
 		  strlen(__igt_pm_runtime_control)) !=
-	    strlen(__igt_pm_runtime_control))
-		igt_warn("Failed to restore runtime pm control to '%s'\n",
-			 __igt_pm_runtime_control);
+	    strlen(__igt_pm_runtime_control)) {
+		close(fd);
+		return errno;
+	}
+
 	close(fd);
+
+	close(pm_status_fd);
+	pm_status_fd = -1;
+
+	return 0;
+}
+
+static void __igt_pm_runtime_exit_handler(int sig)
+{
+	__igt_restore_runtime_pm();
 }
 
 /**
-- 
2.17.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH i-g-t 2/4] lib/igt_pm: Find HDA device when attempting to enable runtime PM
  2018-07-23 11:46 ` [igt-dev] " Tvrtko Ursulin
@ 2018-07-23 11:46   ` Tvrtko Ursulin
  -1 siblings, 0 replies; 33+ messages in thread
From: Tvrtko Ursulin @ 2018-07-23 11:46 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

HDA audio device can be present at various PCI paths on different systems
which the existing code did not account for.

Furthermore the failure to enable runtime PM was silent leaving callers
in the dark.

Improve it by auto-locating the PCI path and logging a warning when
something is not as expected.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 lib/igt_pm.c | 77 ++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 60 insertions(+), 17 deletions(-)

diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 6f3b0a2d897d..a4c0cf335f6d 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -33,6 +33,7 @@
 #include <unistd.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <dirent.h>
 
 #include "drmtest.h"
 #include "igt_pm.h"
@@ -64,6 +65,7 @@ enum {
 #define MAX_POLICY_STRLEN	strlen(MAX_PERFORMANCE_STR)
 
 static char __igt_pm_audio_runtime_power_save[64];
+static const char * __igt_pm_audio_runtime_control_path;
 static char __igt_pm_audio_runtime_control[64];
 
 static int __igt_pm_audio_restore_runtime_pm(void)
@@ -86,7 +88,7 @@ static int __igt_pm_audio_restore_runtime_pm(void)
 
 	close(fd);
 
-	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_WRONLY);
+	fd = open(__igt_pm_audio_runtime_control_path, O_WRONLY);
 	if (fd < 0)
 		return errno;
 
@@ -130,36 +132,77 @@ static void strchomp(char *str)
  */
 void igt_pm_enable_audio_runtime_pm(void)
 {
+	char *path = NULL;
+	struct dirent *de;
+	DIR *dir;
 	int fd;
 
 	/* Check if already enabled. */
 	if (__igt_pm_audio_runtime_power_save[0])
 		return;
 
-	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
-	if (fd >= 0) {
-		igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
-				sizeof(__igt_pm_audio_runtime_power_save)) > 0);
-		strchomp(__igt_pm_audio_runtime_power_save);
-		igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
-		igt_assert_eq(write(fd, "1\n", 2), 2);
-		close(fd);
-	}
-	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_RDWR);
-	if (fd >= 0) {
-		igt_assert(read(fd, __igt_pm_audio_runtime_control,
-				sizeof(__igt_pm_audio_runtime_control)) > 0);
-		strchomp(__igt_pm_audio_runtime_control);
-		igt_assert_eq(write(fd, "auto\n", 5), 5);
-		close(fd);
+	dir = opendir("/sys/bus/pci/drivers/snd_hda_intel");
+	if (!dir)
+		goto err;
+
+	while ((de = readdir(dir))) {
+		const char *prefix = "/sys/bus/pci/devices/";
+		const char *suffix = "/power/control";
+		const char *match = "0000:00:";
+
+		if (strncmp(de->d_name, match, strlen(match)))
+			continue;
+
+		path = malloc(strlen(prefix) +
+			      strlen(de->d_name) +
+			      strlen(suffix) +
+			      1);
+		if (!path)
+			goto err;
+
+		strcpy(path, prefix);
+		strcat(path, de->d_name);
+		strcat(path, suffix);
+
+		igt_debug("Audio device PCI path is %s\n", path);
 	}
 
+	if (!path)
+		goto err;
+
+	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
+	if (fd < 0)
+		goto err;
+
+	igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
+			sizeof(__igt_pm_audio_runtime_power_save)) > 0);
+	strchomp(__igt_pm_audio_runtime_power_save);
+	igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
+	igt_assert_eq(write(fd, "1\n", 2), 2);
+	close(fd);
+
+	fd = open(path, O_RDWR);
+	if (fd < 0)
+		goto err;
+
+	igt_assert(read(fd, __igt_pm_audio_runtime_control,
+			sizeof(__igt_pm_audio_runtime_control)) > 0);
+	strchomp(__igt_pm_audio_runtime_control);
+	igt_assert_eq(write(fd, "auto\n", 5), 5);
+	close(fd);
+	__igt_pm_audio_runtime_control_path = path;
+
 	igt_debug("Saved audio power management as '%s' and '%s'\n",
 		  __igt_pm_audio_runtime_power_save,
 		  __igt_pm_audio_runtime_control);
 
 	/* Give some time for it to react. */
 	sleep(1);
+
+	return;
+
+err:
+	igt_warn("Failed to enable audio runtime PM! (%d)", errno);
 }
 
 /**
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [Intel-gfx] [PATCH i-g-t 2/4] lib/igt_pm: Find HDA device when attempting to enable runtime PM
@ 2018-07-23 11:46   ` Tvrtko Ursulin
  0 siblings, 0 replies; 33+ messages in thread
From: Tvrtko Ursulin @ 2018-07-23 11:46 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

HDA audio device can be present at various PCI paths on different systems
which the existing code did not account for.

Furthermore the failure to enable runtime PM was silent leaving callers
in the dark.

Improve it by auto-locating the PCI path and logging a warning when
something is not as expected.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 lib/igt_pm.c | 77 ++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 60 insertions(+), 17 deletions(-)

diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 6f3b0a2d897d..a4c0cf335f6d 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -33,6 +33,7 @@
 #include <unistd.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <dirent.h>
 
 #include "drmtest.h"
 #include "igt_pm.h"
@@ -64,6 +65,7 @@ enum {
 #define MAX_POLICY_STRLEN	strlen(MAX_PERFORMANCE_STR)
 
 static char __igt_pm_audio_runtime_power_save[64];
+static const char * __igt_pm_audio_runtime_control_path;
 static char __igt_pm_audio_runtime_control[64];
 
 static int __igt_pm_audio_restore_runtime_pm(void)
@@ -86,7 +88,7 @@ static int __igt_pm_audio_restore_runtime_pm(void)
 
 	close(fd);
 
-	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_WRONLY);
+	fd = open(__igt_pm_audio_runtime_control_path, O_WRONLY);
 	if (fd < 0)
 		return errno;
 
@@ -130,36 +132,77 @@ static void strchomp(char *str)
  */
 void igt_pm_enable_audio_runtime_pm(void)
 {
+	char *path = NULL;
+	struct dirent *de;
+	DIR *dir;
 	int fd;
 
 	/* Check if already enabled. */
 	if (__igt_pm_audio_runtime_power_save[0])
 		return;
 
-	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
-	if (fd >= 0) {
-		igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
-				sizeof(__igt_pm_audio_runtime_power_save)) > 0);
-		strchomp(__igt_pm_audio_runtime_power_save);
-		igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
-		igt_assert_eq(write(fd, "1\n", 2), 2);
-		close(fd);
-	}
-	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_RDWR);
-	if (fd >= 0) {
-		igt_assert(read(fd, __igt_pm_audio_runtime_control,
-				sizeof(__igt_pm_audio_runtime_control)) > 0);
-		strchomp(__igt_pm_audio_runtime_control);
-		igt_assert_eq(write(fd, "auto\n", 5), 5);
-		close(fd);
+	dir = opendir("/sys/bus/pci/drivers/snd_hda_intel");
+	if (!dir)
+		goto err;
+
+	while ((de = readdir(dir))) {
+		const char *prefix = "/sys/bus/pci/devices/";
+		const char *suffix = "/power/control";
+		const char *match = "0000:00:";
+
+		if (strncmp(de->d_name, match, strlen(match)))
+			continue;
+
+		path = malloc(strlen(prefix) +
+			      strlen(de->d_name) +
+			      strlen(suffix) +
+			      1);
+		if (!path)
+			goto err;
+
+		strcpy(path, prefix);
+		strcat(path, de->d_name);
+		strcat(path, suffix);
+
+		igt_debug("Audio device PCI path is %s\n", path);
 	}
 
+	if (!path)
+		goto err;
+
+	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
+	if (fd < 0)
+		goto err;
+
+	igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
+			sizeof(__igt_pm_audio_runtime_power_save)) > 0);
+	strchomp(__igt_pm_audio_runtime_power_save);
+	igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
+	igt_assert_eq(write(fd, "1\n", 2), 2);
+	close(fd);
+
+	fd = open(path, O_RDWR);
+	if (fd < 0)
+		goto err;
+
+	igt_assert(read(fd, __igt_pm_audio_runtime_control,
+			sizeof(__igt_pm_audio_runtime_control)) > 0);
+	strchomp(__igt_pm_audio_runtime_control);
+	igt_assert_eq(write(fd, "auto\n", 5), 5);
+	close(fd);
+	__igt_pm_audio_runtime_control_path = path;
+
 	igt_debug("Saved audio power management as '%s' and '%s'\n",
 		  __igt_pm_audio_runtime_power_save,
 		  __igt_pm_audio_runtime_control);
 
 	/* Give some time for it to react. */
 	sleep(1);
+
+	return;
+
+err:
+	igt_warn("Failed to enable audio runtime PM! (%d)", errno);
 }
 
 /**
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH i-g-t 3/4] lib/igt_pm: Export function to restore runtime PM status
  2018-07-23 11:46 ` [igt-dev] " Tvrtko Ursulin
@ 2018-07-23 11:46   ` Tvrtko Ursulin
  -1 siblings, 0 replies; 33+ messages in thread
From: Tvrtko Ursulin @ 2018-07-23 11:46 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

In cases when runtime PM is enabled only from individual subtests and not
whole tests it is usable to be able to restore the old runtime PM config
and so avoid running subsequent subtests in an unexpected environment.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 lib/igt_pm.c | 41 +++++++++++++++++++++++++++++++++++++++++
 lib/igt_pm.h |  1 +
 2 files changed, 42 insertions(+)

diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index a4c0cf335f6d..a861055d382b 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -106,6 +106,23 @@ static int __igt_pm_audio_restore_runtime_pm(void)
 	return 0;
 }
 
+static void igt_pm_audio_restore_runtime_pm(void)
+{
+	int ret;
+
+	if (!__igt_pm_audio_runtime_power_save[0])
+		return;
+
+	igt_debug("Restoring audio power management to '%s' and '%s'\n",
+		  __igt_pm_audio_runtime_power_save,
+		  __igt_pm_audio_runtime_control);
+
+	ret = __igt_pm_audio_restore_runtime_pm();
+	if (ret)
+		igt_warn("Failed to restore runtime audio PM! (errno=%d)\n",
+			 ret);
+}
+
 static void __igt_pm_audio_runtime_exit_handler(int sig)
 {
 	__igt_pm_audio_restore_runtime_pm();
@@ -393,6 +410,30 @@ static int __igt_restore_runtime_pm(void)
 	return 0;
 }
 
+/**
+ * igt_restore_runtime_pm:
+ *
+ * Restores the runtime PM configuration as it was before the call to
+ * igt_setup_runtime_pm.
+ */
+void igt_restore_runtime_pm(void)
+{
+	int ret;
+
+	if (pm_status_fd < 0)
+		return;
+
+	igt_debug("Restoring runtime PM management to '%s' and '%s'\n",
+		  __igt_pm_runtime_autosuspend,
+		  __igt_pm_runtime_control);
+
+	ret = __igt_restore_runtime_pm();
+	if (ret)
+		igt_warn("Failed to restore runtime PM! (errno=%d)\n", ret);
+
+	igt_pm_audio_restore_runtime_pm();
+}
+
 static void __igt_pm_runtime_exit_handler(int sig)
 {
 	__igt_restore_runtime_pm();
diff --git a/lib/igt_pm.h b/lib/igt_pm.h
index eced39f8801a..10cc6794e4e7 100644
--- a/lib/igt_pm.h
+++ b/lib/igt_pm.h
@@ -47,6 +47,7 @@ enum igt_runtime_pm_status {
 };
 
 bool igt_setup_runtime_pm(void);
+void igt_restore_runtime_pm(void);
 enum igt_runtime_pm_status igt_get_runtime_pm_status(void);
 bool igt_wait_for_pm_status(enum igt_runtime_pm_status status);
 
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [igt-dev] [PATCH i-g-t 3/4] lib/igt_pm: Export function to restore runtime PM status
@ 2018-07-23 11:46   ` Tvrtko Ursulin
  0 siblings, 0 replies; 33+ messages in thread
From: Tvrtko Ursulin @ 2018-07-23 11:46 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx, Tvrtko Ursulin

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

In cases when runtime PM is enabled only from individual subtests and not
whole tests it is usable to be able to restore the old runtime PM config
and so avoid running subsequent subtests in an unexpected environment.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 lib/igt_pm.c | 41 +++++++++++++++++++++++++++++++++++++++++
 lib/igt_pm.h |  1 +
 2 files changed, 42 insertions(+)

diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index a4c0cf335f6d..a861055d382b 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -106,6 +106,23 @@ static int __igt_pm_audio_restore_runtime_pm(void)
 	return 0;
 }
 
+static void igt_pm_audio_restore_runtime_pm(void)
+{
+	int ret;
+
+	if (!__igt_pm_audio_runtime_power_save[0])
+		return;
+
+	igt_debug("Restoring audio power management to '%s' and '%s'\n",
+		  __igt_pm_audio_runtime_power_save,
+		  __igt_pm_audio_runtime_control);
+
+	ret = __igt_pm_audio_restore_runtime_pm();
+	if (ret)
+		igt_warn("Failed to restore runtime audio PM! (errno=%d)\n",
+			 ret);
+}
+
 static void __igt_pm_audio_runtime_exit_handler(int sig)
 {
 	__igt_pm_audio_restore_runtime_pm();
@@ -393,6 +410,30 @@ static int __igt_restore_runtime_pm(void)
 	return 0;
 }
 
+/**
+ * igt_restore_runtime_pm:
+ *
+ * Restores the runtime PM configuration as it was before the call to
+ * igt_setup_runtime_pm.
+ */
+void igt_restore_runtime_pm(void)
+{
+	int ret;
+
+	if (pm_status_fd < 0)
+		return;
+
+	igt_debug("Restoring runtime PM management to '%s' and '%s'\n",
+		  __igt_pm_runtime_autosuspend,
+		  __igt_pm_runtime_control);
+
+	ret = __igt_restore_runtime_pm();
+	if (ret)
+		igt_warn("Failed to restore runtime PM! (errno=%d)\n", ret);
+
+	igt_pm_audio_restore_runtime_pm();
+}
+
 static void __igt_pm_runtime_exit_handler(int sig)
 {
 	__igt_restore_runtime_pm();
diff --git a/lib/igt_pm.h b/lib/igt_pm.h
index eced39f8801a..10cc6794e4e7 100644
--- a/lib/igt_pm.h
+++ b/lib/igt_pm.h
@@ -47,6 +47,7 @@ enum igt_runtime_pm_status {
 };
 
 bool igt_setup_runtime_pm(void);
+void igt_restore_runtime_pm(void);
 enum igt_runtime_pm_status igt_get_runtime_pm_status(void);
 bool igt_wait_for_pm_status(enum igt_runtime_pm_status status);
 
-- 
2.17.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH i-g-t 4/4] tests/perf_pmu: Restore runtime PM status at rc6 test exit
  2018-07-23 11:46 ` [igt-dev] " Tvrtko Ursulin
@ 2018-07-23 11:46   ` Tvrtko Ursulin
  -1 siblings, 0 replies; 33+ messages in thread
From: Tvrtko Ursulin @ 2018-07-23 11:46 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Avoid running subsequent subtests in non-default setup by restoring the
runtime PM config in one particular subtest.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 tests/perf_pmu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c
index a1d36ac4fa9d..9a20abb6b95c 100644
--- a/tests/perf_pmu.c
+++ b/tests/perf_pmu.c
@@ -1441,6 +1441,9 @@ test_rc6(int gem_fd, unsigned int flags)
 	close(fw);
 	close(fd);
 
+	if (flags & TEST_RUNTIME_PM)
+		igt_restore_runtime_pm();
+
 	assert_within_epsilon(busy - prev, 0.0, tolerance);
 }
 
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [igt-dev] [PATCH i-g-t 4/4] tests/perf_pmu: Restore runtime PM status at rc6 test exit
@ 2018-07-23 11:46   ` Tvrtko Ursulin
  0 siblings, 0 replies; 33+ messages in thread
From: Tvrtko Ursulin @ 2018-07-23 11:46 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx, Tvrtko Ursulin

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Avoid running subsequent subtests in non-default setup by restoring the
runtime PM config in one particular subtest.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 tests/perf_pmu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c
index a1d36ac4fa9d..9a20abb6b95c 100644
--- a/tests/perf_pmu.c
+++ b/tests/perf_pmu.c
@@ -1441,6 +1441,9 @@ test_rc6(int gem_fd, unsigned int flags)
 	close(fw);
 	close(fd);
 
+	if (flags & TEST_RUNTIME_PM)
+		igt_restore_runtime_pm();
+
 	assert_within_epsilon(busy - prev, 0.0, tolerance);
 }
 
-- 
2.17.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe
  2018-07-23 11:46 ` [igt-dev] " Tvrtko Ursulin
                   ` (3 preceding siblings ...)
  (?)
@ 2018-07-23 12:37 ` Patchwork
  -1 siblings, 0 replies; 33+ messages in thread
From: Patchwork @ 2018-07-23 12:37 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: igt-dev

== Series Details ==

Series: series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe
URL   : https://patchwork.freedesktop.org/series/47052/
State : failure

== Summary ==

= CI Bug Log - changes from CI_DRM_4521 -> IGTPW_1627 =

== Summary - FAILURE ==

  Serious unknown changes coming with IGTPW_1627 absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in IGTPW_1627, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/47052/revisions/1/mbox/

== Possible new issues ==

  Here are the unknown changes that may have been introduced in IGTPW_1627:

  === IGT changes ===

    ==== Possible regressions ====

    igt@pm_rpm@basic-rte:
      fi-cfl-s3:          PASS -> WARN +1

    
== Known issues ==

  Here are the changes found in IGTPW_1627 that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    igt@drv_module_reload@basic-no-display:
      fi-glk-j4005:       PASS -> DMESG-WARN (fdo#106725)

    igt@drv_module_reload@basic-reload:
      fi-glk-j4005:       PASS -> DMESG-WARN (fdo#106248, fdo#106725)

    igt@kms_chamelium@hdmi-hpd-fast:
      fi-kbl-7500u:       SKIP -> FAIL (fdo#103841, fdo#102672)

    igt@kms_flip@basic-flip-vs-wf_vblank:
      fi-glk-j4005:       PASS -> FAIL (fdo#100368)

    
    ==== Possible fixes ====

    igt@prime_vgem@basic-fence-flip:
      fi-ilk-650:         FAIL (fdo#104008) -> PASS

    
  fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
  fdo#102672 https://bugs.freedesktop.org/show_bug.cgi?id=102672
  fdo#103841 https://bugs.freedesktop.org/show_bug.cgi?id=103841
  fdo#104008 https://bugs.freedesktop.org/show_bug.cgi?id=104008
  fdo#106248 https://bugs.freedesktop.org/show_bug.cgi?id=106248
  fdo#106725 https://bugs.freedesktop.org/show_bug.cgi?id=106725


== Participating hosts (47 -> 43) ==

  Additional (1): fi-bsw-kefka 
  Missing    (5): fi-ctg-p8600 fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-hsw-4200u 


== Build changes ==

    * IGT: IGT_4570 -> IGTPW_1627

  CI_DRM_4521: a4ebbd84c682fd30edbde6ac0e48d150d4c5c066 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1627: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1627/
  IGT_4570: 65cdccdc7bcbb791d791aeeeecb784a382110a3c @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1627/issues.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH i-g-t v2 2/4] lib/igt_pm: Find HDA device when attempting to enable runtime PM
  2018-07-23 11:46   ` [Intel-gfx] " Tvrtko Ursulin
@ 2018-07-23 12:46     ` Tvrtko Ursulin
  -1 siblings, 0 replies; 33+ messages in thread
From: Tvrtko Ursulin @ 2018-07-23 12:46 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

HDA audio device can be present at various PCI paths on different systems
which the existing code did not account for.

Furthermore the failure to enable runtime PM was silent leaving callers
in the dark.

Improve it by auto-locating the PCI path and logging a warning when
something is not as expected.

v2:
 * If there is no audio hw/driver there is no failure.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 lib/igt_pm.c | 77 ++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 60 insertions(+), 17 deletions(-)

diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 6f3b0a2d897d..26150fdfedf5 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -33,6 +33,7 @@
 #include <unistd.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <dirent.h>
 
 #include "drmtest.h"
 #include "igt_pm.h"
@@ -64,6 +65,7 @@ enum {
 #define MAX_POLICY_STRLEN	strlen(MAX_PERFORMANCE_STR)
 
 static char __igt_pm_audio_runtime_power_save[64];
+static const char * __igt_pm_audio_runtime_control_path;
 static char __igt_pm_audio_runtime_control[64];
 
 static int __igt_pm_audio_restore_runtime_pm(void)
@@ -86,7 +88,7 @@ static int __igt_pm_audio_restore_runtime_pm(void)
 
 	close(fd);
 
-	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_WRONLY);
+	fd = open(__igt_pm_audio_runtime_control_path, O_WRONLY);
 	if (fd < 0)
 		return errno;
 
@@ -130,36 +132,77 @@ static void strchomp(char *str)
  */
 void igt_pm_enable_audio_runtime_pm(void)
 {
+	char *path = NULL;
+	struct dirent *de;
+	DIR *dir;
 	int fd;
 
 	/* Check if already enabled. */
 	if (__igt_pm_audio_runtime_power_save[0])
 		return;
 
-	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
-	if (fd >= 0) {
-		igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
-				sizeof(__igt_pm_audio_runtime_power_save)) > 0);
-		strchomp(__igt_pm_audio_runtime_power_save);
-		igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
-		igt_assert_eq(write(fd, "1\n", 2), 2);
-		close(fd);
-	}
-	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_RDWR);
-	if (fd >= 0) {
-		igt_assert(read(fd, __igt_pm_audio_runtime_control,
-				sizeof(__igt_pm_audio_runtime_control)) > 0);
-		strchomp(__igt_pm_audio_runtime_control);
-		igt_assert_eq(write(fd, "auto\n", 5), 5);
-		close(fd);
+	dir = opendir("/sys/bus/pci/drivers/snd_hda_intel");
+	if (!dir)
+		return;
+
+	while ((de = readdir(dir))) {
+		const char *prefix = "/sys/bus/pci/devices/";
+		const char *suffix = "/power/control";
+		const char *match = "0000:00:";
+
+		if (strncmp(de->d_name, match, strlen(match)))
+			continue;
+
+		path = malloc(strlen(prefix) +
+			      strlen(de->d_name) +
+			      strlen(suffix) +
+			      1);
+		if (!path)
+			goto err;
+
+		strcpy(path, prefix);
+		strcat(path, de->d_name);
+		strcat(path, suffix);
+
+		igt_debug("Audio device PCI path is %s\n", path);
 	}
 
+	if (!path)
+		goto err;
+
+	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
+	if (fd < 0)
+		goto err;
+
+	igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
+			sizeof(__igt_pm_audio_runtime_power_save)) > 0);
+	strchomp(__igt_pm_audio_runtime_power_save);
+	igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
+	igt_assert_eq(write(fd, "1\n", 2), 2);
+	close(fd);
+
+	fd = open(path, O_RDWR);
+	if (fd < 0)
+		goto err;
+
+	igt_assert(read(fd, __igt_pm_audio_runtime_control,
+			sizeof(__igt_pm_audio_runtime_control)) > 0);
+	strchomp(__igt_pm_audio_runtime_control);
+	igt_assert_eq(write(fd, "auto\n", 5), 5);
+	close(fd);
+	__igt_pm_audio_runtime_control_path = path;
+
 	igt_debug("Saved audio power management as '%s' and '%s'\n",
 		  __igt_pm_audio_runtime_power_save,
 		  __igt_pm_audio_runtime_control);
 
 	/* Give some time for it to react. */
 	sleep(1);
+
+	return;
+
+err:
+	igt_warn("Failed to enable audio runtime PM! (%d)", errno);
 }
 
 /**
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [Intel-gfx] [PATCH i-g-t v2 2/4] lib/igt_pm: Find HDA device when attempting to enable runtime PM
@ 2018-07-23 12:46     ` Tvrtko Ursulin
  0 siblings, 0 replies; 33+ messages in thread
From: Tvrtko Ursulin @ 2018-07-23 12:46 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

HDA audio device can be present at various PCI paths on different systems
which the existing code did not account for.

Furthermore the failure to enable runtime PM was silent leaving callers
in the dark.

Improve it by auto-locating the PCI path and logging a warning when
something is not as expected.

v2:
 * If there is no audio hw/driver there is no failure.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 lib/igt_pm.c | 77 ++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 60 insertions(+), 17 deletions(-)

diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 6f3b0a2d897d..26150fdfedf5 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -33,6 +33,7 @@
 #include <unistd.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <dirent.h>
 
 #include "drmtest.h"
 #include "igt_pm.h"
@@ -64,6 +65,7 @@ enum {
 #define MAX_POLICY_STRLEN	strlen(MAX_PERFORMANCE_STR)
 
 static char __igt_pm_audio_runtime_power_save[64];
+static const char * __igt_pm_audio_runtime_control_path;
 static char __igt_pm_audio_runtime_control[64];
 
 static int __igt_pm_audio_restore_runtime_pm(void)
@@ -86,7 +88,7 @@ static int __igt_pm_audio_restore_runtime_pm(void)
 
 	close(fd);
 
-	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_WRONLY);
+	fd = open(__igt_pm_audio_runtime_control_path, O_WRONLY);
 	if (fd < 0)
 		return errno;
 
@@ -130,36 +132,77 @@ static void strchomp(char *str)
  */
 void igt_pm_enable_audio_runtime_pm(void)
 {
+	char *path = NULL;
+	struct dirent *de;
+	DIR *dir;
 	int fd;
 
 	/* Check if already enabled. */
 	if (__igt_pm_audio_runtime_power_save[0])
 		return;
 
-	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
-	if (fd >= 0) {
-		igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
-				sizeof(__igt_pm_audio_runtime_power_save)) > 0);
-		strchomp(__igt_pm_audio_runtime_power_save);
-		igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
-		igt_assert_eq(write(fd, "1\n", 2), 2);
-		close(fd);
-	}
-	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_RDWR);
-	if (fd >= 0) {
-		igt_assert(read(fd, __igt_pm_audio_runtime_control,
-				sizeof(__igt_pm_audio_runtime_control)) > 0);
-		strchomp(__igt_pm_audio_runtime_control);
-		igt_assert_eq(write(fd, "auto\n", 5), 5);
-		close(fd);
+	dir = opendir("/sys/bus/pci/drivers/snd_hda_intel");
+	if (!dir)
+		return;
+
+	while ((de = readdir(dir))) {
+		const char *prefix = "/sys/bus/pci/devices/";
+		const char *suffix = "/power/control";
+		const char *match = "0000:00:";
+
+		if (strncmp(de->d_name, match, strlen(match)))
+			continue;
+
+		path = malloc(strlen(prefix) +
+			      strlen(de->d_name) +
+			      strlen(suffix) +
+			      1);
+		if (!path)
+			goto err;
+
+		strcpy(path, prefix);
+		strcat(path, de->d_name);
+		strcat(path, suffix);
+
+		igt_debug("Audio device PCI path is %s\n", path);
 	}
 
+	if (!path)
+		goto err;
+
+	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
+	if (fd < 0)
+		goto err;
+
+	igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
+			sizeof(__igt_pm_audio_runtime_power_save)) > 0);
+	strchomp(__igt_pm_audio_runtime_power_save);
+	igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
+	igt_assert_eq(write(fd, "1\n", 2), 2);
+	close(fd);
+
+	fd = open(path, O_RDWR);
+	if (fd < 0)
+		goto err;
+
+	igt_assert(read(fd, __igt_pm_audio_runtime_control,
+			sizeof(__igt_pm_audio_runtime_control)) > 0);
+	strchomp(__igt_pm_audio_runtime_control);
+	igt_assert_eq(write(fd, "auto\n", 5), 5);
+	close(fd);
+	__igt_pm_audio_runtime_control_path = path;
+
 	igt_debug("Saved audio power management as '%s' and '%s'\n",
 		  __igt_pm_audio_runtime_power_save,
 		  __igt_pm_audio_runtime_control);
 
 	/* Give some time for it to react. */
 	sleep(1);
+
+	return;
+
+err:
+	igt_warn("Failed to enable audio runtime PM! (%d)", errno);
 }
 
 /**
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* Re: [igt-dev] [PATCH i-g-t v2 2/4] lib/igt_pm: Find HDA device when attempting to enable runtime PM
  2018-07-23 12:46     ` [Intel-gfx] " Tvrtko Ursulin
@ 2018-07-23 12:54       ` Chris Wilson
  -1 siblings, 0 replies; 33+ messages in thread
From: Chris Wilson @ 2018-07-23 12:54 UTC (permalink / raw)
  To: Tvrtko Ursulin, igt-dev; +Cc: intel-gfx

Quoting Tvrtko Ursulin (2018-07-23 13:46:49)
> @@ -130,36 +132,77 @@ static void strchomp(char *str)
>   */
>  void igt_pm_enable_audio_runtime_pm(void)
>  {
> +       char *path = NULL;
> +       struct dirent *de;
> +       DIR *dir;
>         int fd;
>  
>         /* Check if already enabled. */
>         if (__igt_pm_audio_runtime_power_save[0])
>                 return;
>  
> -       fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
> -       if (fd >= 0) {
> -               igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
> -                               sizeof(__igt_pm_audio_runtime_power_save)) > 0);
> -               strchomp(__igt_pm_audio_runtime_power_save);
> -               igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
> -               igt_assert_eq(write(fd, "1\n", 2), 2);
> -               close(fd);
> -       }
> -       fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_RDWR);
> -       if (fd >= 0) {
> -               igt_assert(read(fd, __igt_pm_audio_runtime_control,
> -                               sizeof(__igt_pm_audio_runtime_control)) > 0);
> -               strchomp(__igt_pm_audio_runtime_control);
> -               igt_assert_eq(write(fd, "auto\n", 5), 5);
> -               close(fd);
> +       dir = opendir("/sys/bus/pci/drivers/snd_hda_intel");
> +       if (!dir)
> +               return;
> +
> +       while ((de = readdir(dir))) {
> +               const char *prefix = "/sys/bus/pci/devices/";
> +               const char *suffix = "/power/control";
> +               const char *match = "0000:00:";
> +
> +               if (strncmp(de->d_name, match, strlen(match)))
> +                       continue;
> +
> +               path = malloc(strlen(prefix) +
> +                             strlen(de->d_name) +
> +                             strlen(suffix) +
> +                             1);
> +               if (!path)
> +                       goto err;
> +
> +               strcpy(path, prefix);
> +               strcat(path, de->d_name);
> +               strcat(path, suffix);

if (asprintf(&path, "/sys/bus/pci/devices/%s/power/control", de->d_name) < 0)
	goto err;
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [Intel-gfx] [igt-dev] [PATCH i-g-t v2 2/4] lib/igt_pm: Find HDA device when attempting to enable runtime PM
@ 2018-07-23 12:54       ` Chris Wilson
  0 siblings, 0 replies; 33+ messages in thread
From: Chris Wilson @ 2018-07-23 12:54 UTC (permalink / raw)
  To: Tvrtko Ursulin, igt-dev; +Cc: intel-gfx

Quoting Tvrtko Ursulin (2018-07-23 13:46:49)
> @@ -130,36 +132,77 @@ static void strchomp(char *str)
>   */
>  void igt_pm_enable_audio_runtime_pm(void)
>  {
> +       char *path = NULL;
> +       struct dirent *de;
> +       DIR *dir;
>         int fd;
>  
>         /* Check if already enabled. */
>         if (__igt_pm_audio_runtime_power_save[0])
>                 return;
>  
> -       fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
> -       if (fd >= 0) {
> -               igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
> -                               sizeof(__igt_pm_audio_runtime_power_save)) > 0);
> -               strchomp(__igt_pm_audio_runtime_power_save);
> -               igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
> -               igt_assert_eq(write(fd, "1\n", 2), 2);
> -               close(fd);
> -       }
> -       fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_RDWR);
> -       if (fd >= 0) {
> -               igt_assert(read(fd, __igt_pm_audio_runtime_control,
> -                               sizeof(__igt_pm_audio_runtime_control)) > 0);
> -               strchomp(__igt_pm_audio_runtime_control);
> -               igt_assert_eq(write(fd, "auto\n", 5), 5);
> -               close(fd);
> +       dir = opendir("/sys/bus/pci/drivers/snd_hda_intel");
> +       if (!dir)
> +               return;
> +
> +       while ((de = readdir(dir))) {
> +               const char *prefix = "/sys/bus/pci/devices/";
> +               const char *suffix = "/power/control";
> +               const char *match = "0000:00:";
> +
> +               if (strncmp(de->d_name, match, strlen(match)))
> +                       continue;
> +
> +               path = malloc(strlen(prefix) +
> +                             strlen(de->d_name) +
> +                             strlen(suffix) +
> +                             1);
> +               if (!path)
> +                       goto err;
> +
> +               strcpy(path, prefix);
> +               strcat(path, de->d_name);
> +               strcat(path, suffix);

if (asprintf(&path, "/sys/bus/pci/devices/%s/power/control", de->d_name) < 0)
	goto err;
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev2)
  2018-07-23 11:46 ` [igt-dev] " Tvrtko Ursulin
                   ` (4 preceding siblings ...)
  (?)
@ 2018-07-23 13:12 ` Patchwork
  -1 siblings, 0 replies; 33+ messages in thread
From: Patchwork @ 2018-07-23 13:12 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: igt-dev

== Series Details ==

Series: series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev2)
URL   : https://patchwork.freedesktop.org/series/47052/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4521 -> IGTPW_1629 =

== Summary - SUCCESS ==

  No regressions found.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/47052/revisions/2/mbox/

== Possible new issues ==

  Here are the unknown changes that may have been introduced in IGTPW_1629:

  === IGT changes ===

    ==== Possible regressions ====

    igt@gem_workarounds@basic-read:
      {fi-icl-u}:         NOTRUN -> FAIL

    
== Known issues ==

  Here are the changes found in IGTPW_1629 that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    igt@drv_module_reload@basic-reload-inject:
      fi-glk-j4005:       PASS -> DMESG-WARN (fdo#106248, fdo#106725) +1

    igt@kms_flip@basic-flip-vs-dpms:
      fi-glk-j4005:       PASS -> DMESG-WARN (fdo#106000)

    igt@kms_flip@basic-flip-vs-wf_vblank:
      {fi-icl-u}:         NOTRUN -> DMESG-WARN (fdo#107335) +42
      fi-glk-j4005:       PASS -> FAIL (fdo#100368)

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c:
      fi-bxt-dsi:         PASS -> INCOMPLETE (fdo#103927)

    {igt@kms_psr@primary_page_flip}:
      {fi-icl-u}:         NOTRUN -> DMESG-FAIL (fdo#107335) +3

    
    ==== Possible fixes ====

    igt@debugfs_test@read_all_entries:
      fi-snb-2520m:       INCOMPLETE (fdo#103713) -> PASS

    
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
  fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
  fdo#103927 https://bugs.freedesktop.org/show_bug.cgi?id=103927
  fdo#106000 https://bugs.freedesktop.org/show_bug.cgi?id=106000
  fdo#106248 https://bugs.freedesktop.org/show_bug.cgi?id=106248
  fdo#106725 https://bugs.freedesktop.org/show_bug.cgi?id=106725
  fdo#107335 https://bugs.freedesktop.org/show_bug.cgi?id=107335


== Participating hosts (47 -> 44) ==

  Additional (2): fi-bsw-kefka fi-icl-u 
  Missing    (5): fi-ctg-p8600 fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-hsw-4200u 


== Build changes ==

    * IGT: IGT_4570 -> IGTPW_1629

  CI_DRM_4521: a4ebbd84c682fd30edbde6ac0e48d150d4c5c066 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1629: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1629/
  IGT_4570: 65cdccdc7bcbb791d791aeeeecb784a382110a3c @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1629/issues.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [igt-dev] ✓ Fi.CI.IGT: success for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe
  2018-07-23 11:46 ` [igt-dev] " Tvrtko Ursulin
                   ` (5 preceding siblings ...)
  (?)
@ 2018-07-23 13:58 ` Patchwork
  -1 siblings, 0 replies; 33+ messages in thread
From: Patchwork @ 2018-07-23 13:58 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: igt-dev

== Series Details ==

Series: series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe
URL   : https://patchwork.freedesktop.org/series/47052/
State : success

== Summary ==

= CI Bug Log - changes from IGT_4570_full -> IGTPW_1627_full =

== Summary - WARNING ==

  Minor unknown changes coming with IGTPW_1627_full need to be verified
  manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in IGTPW_1627_full, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/47052/revisions/1/mbox/

== Possible new issues ==

  Here are the unknown changes that may have been introduced in IGTPW_1627_full:

  === IGT changes ===

    ==== Warnings ====

    igt@gem_exec_schedule@deep-bsd2:
      shard-kbl:          PASS -> SKIP +3

    igt@gem_mocs_settings@mocs-rc6-bsd1:
      shard-kbl:          SKIP -> PASS

    igt@kms_atomic_interruptible@legacy-pageflip:
      shard-snb:          SKIP -> PASS +2

    
== Known issues ==

  Here are the changes found in IGTPW_1627_full that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    igt@gem_exec_schedule@pi-ringfull-vebox:
      shard-glk:          NOTRUN -> FAIL (fdo#103158)

    igt@kms_cursor_legacy@cursora-vs-flipa-legacy:
      shard-glk:          PASS -> FAIL (fdo#106765)

    igt@kms_flip@2x-plain-flip-ts-check-interruptible:
      shard-glk:          PASS -> FAIL (fdo#100368)

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c:
      shard-glk:          PASS -> FAIL (fdo#103375) +1

    
    ==== Possible fixes ====

    igt@gem_mmap_gtt@coherency:
      shard-glk:          FAIL (fdo#100587) -> SKIP +1

    igt@gem_ppgtt@blt-vs-render-ctxn:
      shard-kbl:          INCOMPLETE (fdo#106023, fdo#103665) -> PASS

    igt@kms_flip@plain-flip-ts-check-interruptible:
      shard-glk:          FAIL (fdo#100368) -> PASS +1

    igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-indfb-draw-pwrite:
      shard-glk:          FAIL (fdo#103167) -> PASS

    igt@perf_pmu@multi-client-vcs1:
      shard-snb:          INCOMPLETE (fdo#105411) -> SKIP

    igt@prime_vgem@coherency-gtt:
      shard-apl:          FAIL (fdo#100587) -> SKIP +1

    igt@testdisplay:
      shard-glk:          INCOMPLETE (fdo#107093, k.org#198133, fdo#103359) -> PASS

    
  fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
  fdo#100587 https://bugs.freedesktop.org/show_bug.cgi?id=100587
  fdo#103158 https://bugs.freedesktop.org/show_bug.cgi?id=103158
  fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
  fdo#103359 https://bugs.freedesktop.org/show_bug.cgi?id=103359
  fdo#103375 https://bugs.freedesktop.org/show_bug.cgi?id=103375
  fdo#103665 https://bugs.freedesktop.org/show_bug.cgi?id=103665
  fdo#105411 https://bugs.freedesktop.org/show_bug.cgi?id=105411
  fdo#106023 https://bugs.freedesktop.org/show_bug.cgi?id=106023
  fdo#106765 https://bugs.freedesktop.org/show_bug.cgi?id=106765
  fdo#107093 https://bugs.freedesktop.org/show_bug.cgi?id=107093
  k.org#198133 https://bugzilla.kernel.org/show_bug.cgi?id=198133


== Participating hosts (5 -> 5) ==

  No changes in participating hosts


== Build changes ==

    * IGT: IGT_4570 -> IGTPW_1627
    * Linux: CI_DRM_4519 -> CI_DRM_4521

  CI_DRM_4519: f14c0ec8fe9acce6fd1be84766f854ab8874eb33 @ git://anongit.freedesktop.org/gfx-ci/linux
  CI_DRM_4521: a4ebbd84c682fd30edbde6ac0e48d150d4c5c066 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1627: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1627/
  IGT_4570: 65cdccdc7bcbb791d791aeeeecb784a382110a3c @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1627/shards.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [igt-dev] ✓ Fi.CI.IGT: success for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev2)
  2018-07-23 11:46 ` [igt-dev] " Tvrtko Ursulin
                   ` (6 preceding siblings ...)
  (?)
@ 2018-07-23 15:20 ` Patchwork
  -1 siblings, 0 replies; 33+ messages in thread
From: Patchwork @ 2018-07-23 15:20 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: igt-dev

== Series Details ==

Series: series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev2)
URL   : https://patchwork.freedesktop.org/series/47052/
State : success

== Summary ==

= CI Bug Log - changes from IGT_4570_full -> IGTPW_1629_full =

== Summary - WARNING ==

  Minor unknown changes coming with IGTPW_1629_full need to be verified
  manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in IGTPW_1629_full, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/47052/revisions/2/mbox/

== Possible new issues ==

  Here are the unknown changes that may have been introduced in IGTPW_1629_full:

  === IGT changes ===

    ==== Warnings ====

    igt@gem_exec_schedule@deep-vebox:
      shard-kbl:          PASS -> SKIP

    igt@kms_atomic_interruptible@legacy-pageflip:
      shard-snb:          SKIP -> PASS +1

    igt@pm_rc6_residency@rc6-accuracy:
      shard-kbl:          SKIP -> PASS +1

    
== Known issues ==

  Here are the changes found in IGTPW_1629_full that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    igt@gem_exec_schedule@pi-ringfull-vebox:
      shard-glk:          NOTRUN -> FAIL (fdo#103158)

    igt@kms_available_modes_crc@available_mode_test_crc:
      shard-snb:          PASS -> FAIL (fdo#106641)

    igt@perf@polling:
      shard-hsw:          PASS -> FAIL (fdo#102252)

    igt@perf_pmu@enable-race-vcs0:
      shard-snb:          SKIP -> INCOMPLETE (fdo#105411)

    
    ==== Possible fixes ====

    igt@gem_mmap_gtt@coherency:
      shard-glk:          FAIL (fdo#100587) -> SKIP +1

    igt@gem_ppgtt@blt-vs-render-ctxn:
      shard-kbl:          INCOMPLETE (fdo#103665, fdo#106023) -> PASS

    igt@kms_flip@plain-flip-ts-check-interruptible:
      shard-glk:          FAIL (fdo#100368) -> PASS +1

    igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-indfb-draw-pwrite:
      shard-glk:          FAIL (fdo#103167) -> PASS

    igt@kms_plane_multiple@atomic-pipe-a-tiling-x:
      shard-snb:          FAIL (fdo#103166) -> PASS

    igt@perf_pmu@multi-client-vcs1:
      shard-snb:          INCOMPLETE (fdo#105411) -> SKIP

    igt@prime_vgem@coherency-gtt:
      shard-apl:          FAIL (fdo#100587) -> SKIP +1

    
  fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
  fdo#100587 https://bugs.freedesktop.org/show_bug.cgi?id=100587
  fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252
  fdo#103158 https://bugs.freedesktop.org/show_bug.cgi?id=103158
  fdo#103166 https://bugs.freedesktop.org/show_bug.cgi?id=103166
  fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
  fdo#103665 https://bugs.freedesktop.org/show_bug.cgi?id=103665
  fdo#105411 https://bugs.freedesktop.org/show_bug.cgi?id=105411
  fdo#106023 https://bugs.freedesktop.org/show_bug.cgi?id=106023
  fdo#106641 https://bugs.freedesktop.org/show_bug.cgi?id=106641


== Participating hosts (5 -> 5) ==

  No changes in participating hosts


== Build changes ==

    * IGT: IGT_4570 -> IGTPW_1629
    * Linux: CI_DRM_4519 -> CI_DRM_4521

  CI_DRM_4519: f14c0ec8fe9acce6fd1be84766f854ab8874eb33 @ git://anongit.freedesktop.org/gfx-ci/linux
  CI_DRM_4521: a4ebbd84c682fd30edbde6ac0e48d150d4c5c066 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1629: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1629/
  IGT_4570: 65cdccdc7bcbb791d791aeeeecb784a382110a3c @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1629/shards.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH i-g-t v3 2/4] lib/igt_pm: Find HDA device when attempting to enable runtime PM
  2018-07-23 12:54       ` [Intel-gfx] " Chris Wilson
@ 2018-07-23 15:31         ` Tvrtko Ursulin
  -1 siblings, 0 replies; 33+ messages in thread
From: Tvrtko Ursulin @ 2018-07-23 15:31 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

HDA audio device can be present at various PCI paths on different systems
which the existing code did not account for.

Furthermore the failure to enable runtime PM was silent leaving callers
in the dark.

Improve it by auto-locating the PCI path and logging a warning when
something is not as expected.

v2:
 * If there is no audio hw/driver there is no failure.

v3
 * Comment.
 * Skip non-symlinks.
 * Free path on failure and restore.
 * Simplify with asprintf. (Chris Wilson)

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 lib/igt_pm.c | 76 ++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 59 insertions(+), 17 deletions(-)

diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 6f3b0a2d897d..fd2880c9df11 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -33,6 +33,7 @@
 #include <unistd.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <dirent.h>
 
 #include "drmtest.h"
 #include "igt_pm.h"
@@ -64,6 +65,7 @@ enum {
 #define MAX_POLICY_STRLEN	strlen(MAX_PERFORMANCE_STR)
 
 static char __igt_pm_audio_runtime_power_save[64];
+static char * __igt_pm_audio_runtime_control_path;
 static char __igt_pm_audio_runtime_control[64];
 
 static int __igt_pm_audio_restore_runtime_pm(void)
@@ -86,7 +88,7 @@ static int __igt_pm_audio_restore_runtime_pm(void)
 
 	close(fd);
 
-	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_WRONLY);
+	fd = open(__igt_pm_audio_runtime_control_path, O_WRONLY);
 	if (fd < 0)
 		return errno;
 
@@ -100,6 +102,8 @@ static int __igt_pm_audio_restore_runtime_pm(void)
 	close(fd);
 
 	__igt_pm_audio_runtime_power_save[0] = 0;
+	free(__igt_pm_audio_runtime_control_path);
+	__igt_pm_audio_runtime_control_path = NULL;
 
 	return 0;
 }
@@ -130,36 +134,74 @@ static void strchomp(char *str)
  */
 void igt_pm_enable_audio_runtime_pm(void)
 {
+	char *path = NULL;
+	struct dirent *de;
+	DIR *dir;
 	int fd;
 
 	/* Check if already enabled. */
 	if (__igt_pm_audio_runtime_power_save[0])
 		return;
 
-	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
-	if (fd >= 0) {
-		igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
-				sizeof(__igt_pm_audio_runtime_power_save)) > 0);
-		strchomp(__igt_pm_audio_runtime_power_save);
-		igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
-		igt_assert_eq(write(fd, "1\n", 2), 2);
-		close(fd);
-	}
-	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_RDWR);
-	if (fd >= 0) {
-		igt_assert(read(fd, __igt_pm_audio_runtime_control,
-				sizeof(__igt_pm_audio_runtime_control)) > 0);
-		strchomp(__igt_pm_audio_runtime_control);
-		igt_assert_eq(write(fd, "auto\n", 5), 5);
-		close(fd);
+	dir = opendir("/sys/bus/pci/drivers/snd_hda_intel");
+	if (!dir)
+		return;
+
+	/* Find PCI device claimed by snd_hda_intel. */
+	while ((de = readdir(dir))) {
+		const char *match = "0000:00:";
+
+		if (de->d_type != DT_LNK ||
+		    strncmp(de->d_name, match, strlen(match)))
+			continue;
+
+		igt_assert(asprintf(&path,
+				    "/sys/bus/pci/devices/%s/power/control",
+				    de->d_name));
+
+		igt_debug("Audio device PCI path is %s\n", path);
+
+		break;
 	}
 
+	if (!path)
+		goto err;
+
+	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
+	if (fd < 0)
+		goto err;
+
+	igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
+			sizeof(__igt_pm_audio_runtime_power_save)) > 0);
+	strchomp(__igt_pm_audio_runtime_power_save);
+	igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
+	igt_assert_eq(write(fd, "1\n", 2), 2);
+	close(fd);
+
+	fd = open(path, O_RDWR);
+	if (fd < 0)
+		goto err;
+
+	igt_assert(read(fd, __igt_pm_audio_runtime_control,
+			sizeof(__igt_pm_audio_runtime_control)) > 0);
+	strchomp(__igt_pm_audio_runtime_control);
+	igt_assert_eq(write(fd, "auto\n", 5), 5);
+	close(fd);
+
+	__igt_pm_audio_runtime_control_path = path;
+
 	igt_debug("Saved audio power management as '%s' and '%s'\n",
 		  __igt_pm_audio_runtime_power_save,
 		  __igt_pm_audio_runtime_control);
 
 	/* Give some time for it to react. */
 	sleep(1);
+
+	return;
+
+err:
+	igt_warn("Failed to enable audio runtime PM! (%d)", errno);
+	free(path);
 }
 
 /**
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [igt-dev] [PATCH i-g-t v3 2/4] lib/igt_pm: Find HDA device when attempting to enable runtime PM
@ 2018-07-23 15:31         ` Tvrtko Ursulin
  0 siblings, 0 replies; 33+ messages in thread
From: Tvrtko Ursulin @ 2018-07-23 15:31 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx, Tvrtko Ursulin

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

HDA audio device can be present at various PCI paths on different systems
which the existing code did not account for.

Furthermore the failure to enable runtime PM was silent leaving callers
in the dark.

Improve it by auto-locating the PCI path and logging a warning when
something is not as expected.

v2:
 * If there is no audio hw/driver there is no failure.

v3
 * Comment.
 * Skip non-symlinks.
 * Free path on failure and restore.
 * Simplify with asprintf. (Chris Wilson)

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 lib/igt_pm.c | 76 ++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 59 insertions(+), 17 deletions(-)

diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 6f3b0a2d897d..fd2880c9df11 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -33,6 +33,7 @@
 #include <unistd.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <dirent.h>
 
 #include "drmtest.h"
 #include "igt_pm.h"
@@ -64,6 +65,7 @@ enum {
 #define MAX_POLICY_STRLEN	strlen(MAX_PERFORMANCE_STR)
 
 static char __igt_pm_audio_runtime_power_save[64];
+static char * __igt_pm_audio_runtime_control_path;
 static char __igt_pm_audio_runtime_control[64];
 
 static int __igt_pm_audio_restore_runtime_pm(void)
@@ -86,7 +88,7 @@ static int __igt_pm_audio_restore_runtime_pm(void)
 
 	close(fd);
 
-	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_WRONLY);
+	fd = open(__igt_pm_audio_runtime_control_path, O_WRONLY);
 	if (fd < 0)
 		return errno;
 
@@ -100,6 +102,8 @@ static int __igt_pm_audio_restore_runtime_pm(void)
 	close(fd);
 
 	__igt_pm_audio_runtime_power_save[0] = 0;
+	free(__igt_pm_audio_runtime_control_path);
+	__igt_pm_audio_runtime_control_path = NULL;
 
 	return 0;
 }
@@ -130,36 +134,74 @@ static void strchomp(char *str)
  */
 void igt_pm_enable_audio_runtime_pm(void)
 {
+	char *path = NULL;
+	struct dirent *de;
+	DIR *dir;
 	int fd;
 
 	/* Check if already enabled. */
 	if (__igt_pm_audio_runtime_power_save[0])
 		return;
 
-	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
-	if (fd >= 0) {
-		igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
-				sizeof(__igt_pm_audio_runtime_power_save)) > 0);
-		strchomp(__igt_pm_audio_runtime_power_save);
-		igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
-		igt_assert_eq(write(fd, "1\n", 2), 2);
-		close(fd);
-	}
-	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_RDWR);
-	if (fd >= 0) {
-		igt_assert(read(fd, __igt_pm_audio_runtime_control,
-				sizeof(__igt_pm_audio_runtime_control)) > 0);
-		strchomp(__igt_pm_audio_runtime_control);
-		igt_assert_eq(write(fd, "auto\n", 5), 5);
-		close(fd);
+	dir = opendir("/sys/bus/pci/drivers/snd_hda_intel");
+	if (!dir)
+		return;
+
+	/* Find PCI device claimed by snd_hda_intel. */
+	while ((de = readdir(dir))) {
+		const char *match = "0000:00:";
+
+		if (de->d_type != DT_LNK ||
+		    strncmp(de->d_name, match, strlen(match)))
+			continue;
+
+		igt_assert(asprintf(&path,
+				    "/sys/bus/pci/devices/%s/power/control",
+				    de->d_name));
+
+		igt_debug("Audio device PCI path is %s\n", path);
+
+		break;
 	}
 
+	if (!path)
+		goto err;
+
+	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
+	if (fd < 0)
+		goto err;
+
+	igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
+			sizeof(__igt_pm_audio_runtime_power_save)) > 0);
+	strchomp(__igt_pm_audio_runtime_power_save);
+	igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
+	igt_assert_eq(write(fd, "1\n", 2), 2);
+	close(fd);
+
+	fd = open(path, O_RDWR);
+	if (fd < 0)
+		goto err;
+
+	igt_assert(read(fd, __igt_pm_audio_runtime_control,
+			sizeof(__igt_pm_audio_runtime_control)) > 0);
+	strchomp(__igt_pm_audio_runtime_control);
+	igt_assert_eq(write(fd, "auto\n", 5), 5);
+	close(fd);
+
+	__igt_pm_audio_runtime_control_path = path;
+
 	igt_debug("Saved audio power management as '%s' and '%s'\n",
 		  __igt_pm_audio_runtime_power_save,
 		  __igt_pm_audio_runtime_control);
 
 	/* Give some time for it to react. */
 	sleep(1);
+
+	return;
+
+err:
+	igt_warn("Failed to enable audio runtime PM! (%d)", errno);
+	free(path);
 }
 
 /**
-- 
2.17.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev3)
  2018-07-23 11:46 ` [igt-dev] " Tvrtko Ursulin
                   ` (7 preceding siblings ...)
  (?)
@ 2018-07-23 15:54 ` Patchwork
  2018-07-23 16:35   ` Tvrtko Ursulin
  -1 siblings, 1 reply; 33+ messages in thread
From: Patchwork @ 2018-07-23 15:54 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: igt-dev

== Series Details ==

Series: series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev3)
URL   : https://patchwork.freedesktop.org/series/47052/
State : failure

== Summary ==

= CI Bug Log - changes from CI_DRM_4521 -> IGTPW_1631 =

== Summary - FAILURE ==

  Serious unknown changes coming with IGTPW_1631 absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in IGTPW_1631, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/47052/revisions/3/mbox/

== Possible new issues ==

  Here are the unknown changes that may have been introduced in IGTPW_1631:

  === IGT changes ===

    ==== Possible regressions ====

    igt@pm_rpm@basic-rte:
      fi-bdw-5557u:       PASS -> FAIL +1

    
== Known issues ==

  Here are the changes found in IGTPW_1631 that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    igt@drv_module_reload@basic-reload:
      fi-glk-j4005:       PASS -> DMESG-WARN (fdo#106725, fdo#106248)

    igt@pm_rpm@basic-rte:
      fi-hsw-peppy:       PASS -> FAIL (fdo#106539) +1
      fi-hsw-4770r:       PASS -> FAIL (fdo#106539) +1
      fi-hsw-4770:        PASS -> FAIL (fdo#106539) +1

    
    ==== Possible fixes ====

    igt@debugfs_test@read_all_entries:
      fi-snb-2520m:       INCOMPLETE (fdo#103713) -> PASS

    igt@prime_vgem@basic-fence-flip:
      fi-ilk-650:         FAIL (fdo#104008) -> PASS

    
  fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
  fdo#104008 https://bugs.freedesktop.org/show_bug.cgi?id=104008
  fdo#106248 https://bugs.freedesktop.org/show_bug.cgi?id=106248
  fdo#106539 https://bugs.freedesktop.org/show_bug.cgi?id=106539
  fdo#106725 https://bugs.freedesktop.org/show_bug.cgi?id=106725


== Participating hosts (47 -> 43) ==

  Additional (1): fi-bsw-kefka 
  Missing    (5): fi-ctg-p8600 fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-hsw-4200u 


== Build changes ==

    * IGT: IGT_4570 -> IGTPW_1631

  CI_DRM_4521: a4ebbd84c682fd30edbde6ac0e48d150d4c5c066 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1631: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1631/
  IGT_4570: 65cdccdc7bcbb791d791aeeeecb784a382110a3c @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1631/issues.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev3)
  2018-07-23 15:54 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev3) Patchwork
@ 2018-07-23 16:35   ` Tvrtko Ursulin
  0 siblings, 0 replies; 33+ messages in thread
From: Tvrtko Ursulin @ 2018-07-23 16:35 UTC (permalink / raw)
  To: igt-dev, Patchwork, Tvrtko Ursulin


On 23/07/2018 16:54, Patchwork wrote:
> == Series Details ==
> 
> Series: series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev3)
> URL   : https://patchwork.freedesktop.org/series/47052/
> State : failure
> 
> == Summary ==
> 
> = CI Bug Log - changes from CI_DRM_4521 -> IGTPW_1631 =
> 
> == Summary - FAILURE ==
> 
>    Serious unknown changes coming with IGTPW_1631 absolutely need to be
>    verified manually.
>    
>    If you think the reported changes have nothing to do with the changes
>    introduced in IGTPW_1631, please notify your bug team to allow them
>    to document this new failure mode, which will reduce false positives in CI.
> 
>    External URL: https://patchwork.freedesktop.org/api/1.0/series/47052/revisions/3/mbox/
> 
> == Possible new issues ==
> 
>    Here are the unknown changes that may have been introduced in IGTPW_1631:
> 
>    === IGT changes ===
> 
>      ==== Possible regressions ====
> 
>      igt@pm_rpm@basic-rte:
>        fi-bdw-5557u:       PASS -> FAIL +1

Okay there seems to be two PCI devices claimed by snd_hda_intel on some 
platforms and this patch apparently picks the wrong one. So it seems I 
would need some logic to figure out which one is which, and which one we 
actually want to touch. The one tied with i915 I guess. Just figuring 
out how to find it.

Tvrtko

>      
> == Known issues ==
> 
>    Here are the changes found in IGTPW_1631 that come from known issues:
> 
>    === IGT changes ===
> 
>      ==== Issues hit ====
> 
>      igt@drv_module_reload@basic-reload:
>        fi-glk-j4005:       PASS -> DMESG-WARN (fdo#106725, fdo#106248)
> 
>      igt@pm_rpm@basic-rte:
>        fi-hsw-peppy:       PASS -> FAIL (fdo#106539) +1
>        fi-hsw-4770r:       PASS -> FAIL (fdo#106539) +1
>        fi-hsw-4770:        PASS -> FAIL (fdo#106539) +1
> 
>      
>      ==== Possible fixes ====
> 
>      igt@debugfs_test@read_all_entries:
>        fi-snb-2520m:       INCOMPLETE (fdo#103713) -> PASS
> 
>      igt@prime_vgem@basic-fence-flip:
>        fi-ilk-650:         FAIL (fdo#104008) -> PASS
> 
>      
>    fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
>    fdo#104008 https://bugs.freedesktop.org/show_bug.cgi?id=104008
>    fdo#106248 https://bugs.freedesktop.org/show_bug.cgi?id=106248
>    fdo#106539 https://bugs.freedesktop.org/show_bug.cgi?id=106539
>    fdo#106725 https://bugs.freedesktop.org/show_bug.cgi?id=106725
> 
> 
> == Participating hosts (47 -> 43) ==
> 
>    Additional (1): fi-bsw-kefka
>    Missing    (5): fi-ctg-p8600 fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-hsw-4200u
> 
> 
> == Build changes ==
> 
>      * IGT: IGT_4570 -> IGTPW_1631
> 
>    CI_DRM_4521: a4ebbd84c682fd30edbde6ac0e48d150d4c5c066 @ git://anongit.freedesktop.org/gfx-ci/linux
>    IGTPW_1631: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1631/
>    IGT_4570: 65cdccdc7bcbb791d791aeeeecb784a382110a3c @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
> 
> == Logs ==
> 
> For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1631/issues.html
> _______________________________________________
> igt-dev mailing list
> igt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev
> 
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH i-g-t v4 2/4] lib/igt_pm: Find HDA device when attempting to enable runtime PM
  2018-07-23 15:31         ` [igt-dev] " Tvrtko Ursulin
@ 2018-07-24  9:59           ` Tvrtko Ursulin
  -1 siblings, 0 replies; 33+ messages in thread
From: Tvrtko Ursulin @ 2018-07-24  9:59 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

HDA audio device can be present at various PCI paths on different systems
which the existing code did not account for.

Furthermore the failure to enable runtime PM was silent leaving callers
in the dark.

Improve it by auto-locating the PCI path and logging a warning when
something is not as expected.

v2:
 * If there is no audio hw/driver there is no failure.

v3:
 * Comment.
 * Skip non-symlinks.
 * Free path on failure and restore.
 * Simplify with asprintf. (Chris Wilson)

v4:
 * Find snd_hda_intel instance tied with an Intel device.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 lib/igt_pm.c | 92 +++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 76 insertions(+), 16 deletions(-)

diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 6f3b0a2d897d..22d8d420c5d7 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -33,6 +33,7 @@
 #include <unistd.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <dirent.h>
 
 #include "drmtest.h"
 #include "igt_pm.h"
@@ -64,6 +65,7 @@ enum {
 #define MAX_POLICY_STRLEN	strlen(MAX_PERFORMANCE_STR)
 
 static char __igt_pm_audio_runtime_power_save[64];
+static char * __igt_pm_audio_runtime_control_path;
 static char __igt_pm_audio_runtime_control[64];
 
 static int __igt_pm_audio_restore_runtime_pm(void)
@@ -86,7 +88,7 @@ static int __igt_pm_audio_restore_runtime_pm(void)
 
 	close(fd);
 
-	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_WRONLY);
+	fd = open(__igt_pm_audio_runtime_control_path, O_WRONLY);
 	if (fd < 0)
 		return errno;
 
@@ -100,6 +102,8 @@ static int __igt_pm_audio_restore_runtime_pm(void)
 	close(fd);
 
 	__igt_pm_audio_runtime_power_save[0] = 0;
+	free(__igt_pm_audio_runtime_control_path);
+	__igt_pm_audio_runtime_control_path = NULL;
 
 	return 0;
 }
@@ -130,36 +134,92 @@ static void strchomp(char *str)
  */
 void igt_pm_enable_audio_runtime_pm(void)
 {
+	char *path = NULL;
+	struct dirent *de;
+	DIR *dir;
 	int fd;
 
 	/* Check if already enabled. */
 	if (__igt_pm_audio_runtime_power_save[0])
 		return;
 
-	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
-	if (fd >= 0) {
-		igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
-				sizeof(__igt_pm_audio_runtime_power_save)) > 0);
-		strchomp(__igt_pm_audio_runtime_power_save);
-		igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
-		igt_assert_eq(write(fd, "1\n", 2), 2);
-		close(fd);
-	}
-	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_RDWR);
-	if (fd >= 0) {
-		igt_assert(read(fd, __igt_pm_audio_runtime_control,
-				sizeof(__igt_pm_audio_runtime_control)) > 0);
-		strchomp(__igt_pm_audio_runtime_control);
-		igt_assert_eq(write(fd, "auto\n", 5), 5);
+	dir = opendir("/sys/class/sound");
+	if (!dir)
+		return;
+
+	/* Find PCI device claimed by snd_hda_intel and tied to i915. */
+	while ((de = readdir(dir))) {
+		const char *match = "hwC";
+		char buf[32];
+		char *tmp;
+		int ret;
+
+		if (de->d_type != DT_LNK ||
+		    strncmp(de->d_name, match, strlen(match)))
+			continue;
+
+		igt_assert(asprintf(&tmp,
+				    "/sys/class/sound/%s/vendor_name",
+				    de->d_name));
+
+		fd = open(tmp, O_RDONLY);
+		igt_assert_fd(fd);
+		ret = read(fd, buf, sizeof(buf));
 		close(fd);
+		igt_assert(ret >= 0);
+		strchomp(buf);
+
+		/* Realtek and similar devices are not what we are after. */
+		if (strcmp(buf, "Intel"))
+			continue;
+
+		igt_assert(asprintf(&path,
+				    "/sys/class/sound/%s/device/device/power/control",
+				    de->d_name));
+
+		igt_debug("Audio device path is %s\n", path);
+
+		break;
 	}
 
+	if (!path)
+		goto err;
+
+	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
+	if (fd < 0)
+		goto err;
+
+	igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
+			sizeof(__igt_pm_audio_runtime_power_save)) > 0);
+	strchomp(__igt_pm_audio_runtime_power_save);
+	igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
+	igt_assert_eq(write(fd, "1\n", 2), 2);
+	close(fd);
+
+	fd = open(path, O_RDWR);
+	if (fd < 0)
+		goto err;
+
+	igt_assert(read(fd, __igt_pm_audio_runtime_control,
+			sizeof(__igt_pm_audio_runtime_control)) > 0);
+	strchomp(__igt_pm_audio_runtime_control);
+	igt_assert_eq(write(fd, "auto\n", 5), 5);
+	close(fd);
+
+	__igt_pm_audio_runtime_control_path = path;
+
 	igt_debug("Saved audio power management as '%s' and '%s'\n",
 		  __igt_pm_audio_runtime_power_save,
 		  __igt_pm_audio_runtime_control);
 
 	/* Give some time for it to react. */
 	sleep(1);
+
+	return;
+
+err:
+	igt_warn("Failed to enable audio runtime PM! (%d)", errno);
+	free(path);
 }
 
 /**
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [igt-dev] [PATCH i-g-t v4 2/4] lib/igt_pm: Find HDA device when attempting to enable runtime PM
@ 2018-07-24  9:59           ` Tvrtko Ursulin
  0 siblings, 0 replies; 33+ messages in thread
From: Tvrtko Ursulin @ 2018-07-24  9:59 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx, Tvrtko Ursulin

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

HDA audio device can be present at various PCI paths on different systems
which the existing code did not account for.

Furthermore the failure to enable runtime PM was silent leaving callers
in the dark.

Improve it by auto-locating the PCI path and logging a warning when
something is not as expected.

v2:
 * If there is no audio hw/driver there is no failure.

v3:
 * Comment.
 * Skip non-symlinks.
 * Free path on failure and restore.
 * Simplify with asprintf. (Chris Wilson)

v4:
 * Find snd_hda_intel instance tied with an Intel device.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 lib/igt_pm.c | 92 +++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 76 insertions(+), 16 deletions(-)

diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 6f3b0a2d897d..22d8d420c5d7 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -33,6 +33,7 @@
 #include <unistd.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <dirent.h>
 
 #include "drmtest.h"
 #include "igt_pm.h"
@@ -64,6 +65,7 @@ enum {
 #define MAX_POLICY_STRLEN	strlen(MAX_PERFORMANCE_STR)
 
 static char __igt_pm_audio_runtime_power_save[64];
+static char * __igt_pm_audio_runtime_control_path;
 static char __igt_pm_audio_runtime_control[64];
 
 static int __igt_pm_audio_restore_runtime_pm(void)
@@ -86,7 +88,7 @@ static int __igt_pm_audio_restore_runtime_pm(void)
 
 	close(fd);
 
-	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_WRONLY);
+	fd = open(__igt_pm_audio_runtime_control_path, O_WRONLY);
 	if (fd < 0)
 		return errno;
 
@@ -100,6 +102,8 @@ static int __igt_pm_audio_restore_runtime_pm(void)
 	close(fd);
 
 	__igt_pm_audio_runtime_power_save[0] = 0;
+	free(__igt_pm_audio_runtime_control_path);
+	__igt_pm_audio_runtime_control_path = NULL;
 
 	return 0;
 }
@@ -130,36 +134,92 @@ static void strchomp(char *str)
  */
 void igt_pm_enable_audio_runtime_pm(void)
 {
+	char *path = NULL;
+	struct dirent *de;
+	DIR *dir;
 	int fd;
 
 	/* Check if already enabled. */
 	if (__igt_pm_audio_runtime_power_save[0])
 		return;
 
-	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
-	if (fd >= 0) {
-		igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
-				sizeof(__igt_pm_audio_runtime_power_save)) > 0);
-		strchomp(__igt_pm_audio_runtime_power_save);
-		igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
-		igt_assert_eq(write(fd, "1\n", 2), 2);
-		close(fd);
-	}
-	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_RDWR);
-	if (fd >= 0) {
-		igt_assert(read(fd, __igt_pm_audio_runtime_control,
-				sizeof(__igt_pm_audio_runtime_control)) > 0);
-		strchomp(__igt_pm_audio_runtime_control);
-		igt_assert_eq(write(fd, "auto\n", 5), 5);
+	dir = opendir("/sys/class/sound");
+	if (!dir)
+		return;
+
+	/* Find PCI device claimed by snd_hda_intel and tied to i915. */
+	while ((de = readdir(dir))) {
+		const char *match = "hwC";
+		char buf[32];
+		char *tmp;
+		int ret;
+
+		if (de->d_type != DT_LNK ||
+		    strncmp(de->d_name, match, strlen(match)))
+			continue;
+
+		igt_assert(asprintf(&tmp,
+				    "/sys/class/sound/%s/vendor_name",
+				    de->d_name));
+
+		fd = open(tmp, O_RDONLY);
+		igt_assert_fd(fd);
+		ret = read(fd, buf, sizeof(buf));
 		close(fd);
+		igt_assert(ret >= 0);
+		strchomp(buf);
+
+		/* Realtek and similar devices are not what we are after. */
+		if (strcmp(buf, "Intel"))
+			continue;
+
+		igt_assert(asprintf(&path,
+				    "/sys/class/sound/%s/device/device/power/control",
+				    de->d_name));
+
+		igt_debug("Audio device path is %s\n", path);
+
+		break;
 	}
 
+	if (!path)
+		goto err;
+
+	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
+	if (fd < 0)
+		goto err;
+
+	igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
+			sizeof(__igt_pm_audio_runtime_power_save)) > 0);
+	strchomp(__igt_pm_audio_runtime_power_save);
+	igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
+	igt_assert_eq(write(fd, "1\n", 2), 2);
+	close(fd);
+
+	fd = open(path, O_RDWR);
+	if (fd < 0)
+		goto err;
+
+	igt_assert(read(fd, __igt_pm_audio_runtime_control,
+			sizeof(__igt_pm_audio_runtime_control)) > 0);
+	strchomp(__igt_pm_audio_runtime_control);
+	igt_assert_eq(write(fd, "auto\n", 5), 5);
+	close(fd);
+
+	__igt_pm_audio_runtime_control_path = path;
+
 	igt_debug("Saved audio power management as '%s' and '%s'\n",
 		  __igt_pm_audio_runtime_power_save,
 		  __igt_pm_audio_runtime_control);
 
 	/* Give some time for it to react. */
 	sleep(1);
+
+	return;
+
+err:
+	igt_warn("Failed to enable audio runtime PM! (%d)", errno);
+	free(path);
 }
 
 /**
-- 
2.17.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH i-g-t v5 2/4] lib/igt_pm: Find HDA device when attempting to enable runtime PM
  2018-07-24  9:59           ` [igt-dev] " Tvrtko Ursulin
@ 2018-07-24 10:08             ` Tvrtko Ursulin
  -1 siblings, 0 replies; 33+ messages in thread
From: Tvrtko Ursulin @ 2018-07-24 10:08 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

HDA audio device can be present at various PCI paths on different systems
which the existing code did not account for.

Furthermore the failure to enable runtime PM was silent leaving callers
in the dark.

Improve it by auto-locating the PCI path and logging a warning when
something is not as expected.

v2:
 * If there is no audio hw/driver there is no failure.

v3:
 * Comment.
 * Skip non-symlinks.
 * Free path on failure and restore.
 * Simplify with asprintf. (Chris Wilson)

v4:
 * Find snd_hda_intel instance tied with an Intel device.

v5:
 * Fix memory leak and silence Valgrind warning.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 lib/igt_pm.c | 93 +++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 77 insertions(+), 16 deletions(-)

diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 6f3b0a2d897d..21eb01e1903e 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -33,6 +33,7 @@
 #include <unistd.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <dirent.h>
 
 #include "drmtest.h"
 #include "igt_pm.h"
@@ -64,6 +65,7 @@ enum {
 #define MAX_POLICY_STRLEN	strlen(MAX_PERFORMANCE_STR)
 
 static char __igt_pm_audio_runtime_power_save[64];
+static char * __igt_pm_audio_runtime_control_path;
 static char __igt_pm_audio_runtime_control[64];
 
 static int __igt_pm_audio_restore_runtime_pm(void)
@@ -86,7 +88,7 @@ static int __igt_pm_audio_restore_runtime_pm(void)
 
 	close(fd);
 
-	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_WRONLY);
+	fd = open(__igt_pm_audio_runtime_control_path, O_WRONLY);
 	if (fd < 0)
 		return errno;
 
@@ -100,6 +102,8 @@ static int __igt_pm_audio_restore_runtime_pm(void)
 	close(fd);
 
 	__igt_pm_audio_runtime_power_save[0] = 0;
+	free(__igt_pm_audio_runtime_control_path);
+	__igt_pm_audio_runtime_control_path = NULL;
 
 	return 0;
 }
@@ -130,36 +134,93 @@ static void strchomp(char *str)
  */
 void igt_pm_enable_audio_runtime_pm(void)
 {
+	char *path = NULL;
+	struct dirent *de;
+	DIR *dir;
 	int fd;
 
 	/* Check if already enabled. */
 	if (__igt_pm_audio_runtime_power_save[0])
 		return;
 
-	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
-	if (fd >= 0) {
-		igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
-				sizeof(__igt_pm_audio_runtime_power_save)) > 0);
-		strchomp(__igt_pm_audio_runtime_power_save);
-		igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
-		igt_assert_eq(write(fd, "1\n", 2), 2);
-		close(fd);
-	}
-	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_RDWR);
-	if (fd >= 0) {
-		igt_assert(read(fd, __igt_pm_audio_runtime_control,
-				sizeof(__igt_pm_audio_runtime_control)) > 0);
-		strchomp(__igt_pm_audio_runtime_control);
-		igt_assert_eq(write(fd, "auto\n", 5), 5);
+	dir = opendir("/sys/class/sound");
+	if (!dir)
+		return;
+
+	/* Find PCI device claimed by snd_hda_intel and tied to i915. */
+	while ((de = readdir(dir))) {
+		const char *match = "hwC";
+		char buf[32] = { }; /* for Valgrind */
+		char *tmp;
+		int ret;
+
+		if (de->d_type != DT_LNK ||
+		    strncmp(de->d_name, match, strlen(match)))
+			continue;
+
+		igt_assert(asprintf(&tmp,
+				    "/sys/class/sound/%s/vendor_name",
+				    de->d_name));
+
+		fd = open(tmp, O_RDONLY);
+		free(tmp);
+		igt_assert_fd(fd);
+		ret = read(fd, buf, sizeof(buf));
 		close(fd);
+		igt_assert(ret > 0);
+		strchomp(buf);
+
+		/* Realtek and similar devices are not what we are after. */
+		if (strcmp(buf, "Intel"))
+			continue;
+
+		igt_assert(asprintf(&path,
+				    "/sys/class/sound/%s/device/device/power/control",
+				    de->d_name));
+
+		igt_debug("Audio device path is %s\n", path);
+
+		break;
 	}
 
+	if (!path)
+		goto err;
+
+	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
+	if (fd < 0)
+		goto err;
+
+	igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
+			sizeof(__igt_pm_audio_runtime_power_save)) > 0);
+	strchomp(__igt_pm_audio_runtime_power_save);
+	igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
+	igt_assert_eq(write(fd, "1\n", 2), 2);
+	close(fd);
+
+	fd = open(path, O_RDWR);
+	if (fd < 0)
+		goto err;
+
+	igt_assert(read(fd, __igt_pm_audio_runtime_control,
+			sizeof(__igt_pm_audio_runtime_control)) > 0);
+	strchomp(__igt_pm_audio_runtime_control);
+	igt_assert_eq(write(fd, "auto\n", 5), 5);
+	close(fd);
+
+	__igt_pm_audio_runtime_control_path = path;
+
 	igt_debug("Saved audio power management as '%s' and '%s'\n",
 		  __igt_pm_audio_runtime_power_save,
 		  __igt_pm_audio_runtime_control);
 
 	/* Give some time for it to react. */
 	sleep(1);
+
+	return;
+
+err:
+	igt_warn("Failed to enable audio runtime PM! (%d)", errno);
+	free(path);
 }
 
 /**
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [igt-dev] [PATCH i-g-t v5 2/4] lib/igt_pm: Find HDA device when attempting to enable runtime PM
@ 2018-07-24 10:08             ` Tvrtko Ursulin
  0 siblings, 0 replies; 33+ messages in thread
From: Tvrtko Ursulin @ 2018-07-24 10:08 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx, Tvrtko Ursulin

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

HDA audio device can be present at various PCI paths on different systems
which the existing code did not account for.

Furthermore the failure to enable runtime PM was silent leaving callers
in the dark.

Improve it by auto-locating the PCI path and logging a warning when
something is not as expected.

v2:
 * If there is no audio hw/driver there is no failure.

v3:
 * Comment.
 * Skip non-symlinks.
 * Free path on failure and restore.
 * Simplify with asprintf. (Chris Wilson)

v4:
 * Find snd_hda_intel instance tied with an Intel device.

v5:
 * Fix memory leak and silence Valgrind warning.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 lib/igt_pm.c | 93 +++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 77 insertions(+), 16 deletions(-)

diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 6f3b0a2d897d..21eb01e1903e 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -33,6 +33,7 @@
 #include <unistd.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <dirent.h>
 
 #include "drmtest.h"
 #include "igt_pm.h"
@@ -64,6 +65,7 @@ enum {
 #define MAX_POLICY_STRLEN	strlen(MAX_PERFORMANCE_STR)
 
 static char __igt_pm_audio_runtime_power_save[64];
+static char * __igt_pm_audio_runtime_control_path;
 static char __igt_pm_audio_runtime_control[64];
 
 static int __igt_pm_audio_restore_runtime_pm(void)
@@ -86,7 +88,7 @@ static int __igt_pm_audio_restore_runtime_pm(void)
 
 	close(fd);
 
-	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_WRONLY);
+	fd = open(__igt_pm_audio_runtime_control_path, O_WRONLY);
 	if (fd < 0)
 		return errno;
 
@@ -100,6 +102,8 @@ static int __igt_pm_audio_restore_runtime_pm(void)
 	close(fd);
 
 	__igt_pm_audio_runtime_power_save[0] = 0;
+	free(__igt_pm_audio_runtime_control_path);
+	__igt_pm_audio_runtime_control_path = NULL;
 
 	return 0;
 }
@@ -130,36 +134,93 @@ static void strchomp(char *str)
  */
 void igt_pm_enable_audio_runtime_pm(void)
 {
+	char *path = NULL;
+	struct dirent *de;
+	DIR *dir;
 	int fd;
 
 	/* Check if already enabled. */
 	if (__igt_pm_audio_runtime_power_save[0])
 		return;
 
-	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
-	if (fd >= 0) {
-		igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
-				sizeof(__igt_pm_audio_runtime_power_save)) > 0);
-		strchomp(__igt_pm_audio_runtime_power_save);
-		igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
-		igt_assert_eq(write(fd, "1\n", 2), 2);
-		close(fd);
-	}
-	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_RDWR);
-	if (fd >= 0) {
-		igt_assert(read(fd, __igt_pm_audio_runtime_control,
-				sizeof(__igt_pm_audio_runtime_control)) > 0);
-		strchomp(__igt_pm_audio_runtime_control);
-		igt_assert_eq(write(fd, "auto\n", 5), 5);
+	dir = opendir("/sys/class/sound");
+	if (!dir)
+		return;
+
+	/* Find PCI device claimed by snd_hda_intel and tied to i915. */
+	while ((de = readdir(dir))) {
+		const char *match = "hwC";
+		char buf[32] = { }; /* for Valgrind */
+		char *tmp;
+		int ret;
+
+		if (de->d_type != DT_LNK ||
+		    strncmp(de->d_name, match, strlen(match)))
+			continue;
+
+		igt_assert(asprintf(&tmp,
+				    "/sys/class/sound/%s/vendor_name",
+				    de->d_name));
+
+		fd = open(tmp, O_RDONLY);
+		free(tmp);
+		igt_assert_fd(fd);
+		ret = read(fd, buf, sizeof(buf));
 		close(fd);
+		igt_assert(ret > 0);
+		strchomp(buf);
+
+		/* Realtek and similar devices are not what we are after. */
+		if (strcmp(buf, "Intel"))
+			continue;
+
+		igt_assert(asprintf(&path,
+				    "/sys/class/sound/%s/device/device/power/control",
+				    de->d_name));
+
+		igt_debug("Audio device path is %s\n", path);
+
+		break;
 	}
 
+	if (!path)
+		goto err;
+
+	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
+	if (fd < 0)
+		goto err;
+
+	igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
+			sizeof(__igt_pm_audio_runtime_power_save)) > 0);
+	strchomp(__igt_pm_audio_runtime_power_save);
+	igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
+	igt_assert_eq(write(fd, "1\n", 2), 2);
+	close(fd);
+
+	fd = open(path, O_RDWR);
+	if (fd < 0)
+		goto err;
+
+	igt_assert(read(fd, __igt_pm_audio_runtime_control,
+			sizeof(__igt_pm_audio_runtime_control)) > 0);
+	strchomp(__igt_pm_audio_runtime_control);
+	igt_assert_eq(write(fd, "auto\n", 5), 5);
+	close(fd);
+
+	__igt_pm_audio_runtime_control_path = path;
+
 	igt_debug("Saved audio power management as '%s' and '%s'\n",
 		  __igt_pm_audio_runtime_power_save,
 		  __igt_pm_audio_runtime_control);
 
 	/* Give some time for it to react. */
 	sleep(1);
+
+	return;
+
+err:
+	igt_warn("Failed to enable audio runtime PM! (%d)", errno);
+	free(path);
 }
 
 /**
-- 
2.17.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH i-g-t v6 2/4] lib/igt_pm: Find HDA device when attempting to enable runtime PM
  2018-07-24 10:08             ` [igt-dev] " Tvrtko Ursulin
@ 2018-07-24 10:29               ` Tvrtko Ursulin
  -1 siblings, 0 replies; 33+ messages in thread
From: Tvrtko Ursulin @ 2018-07-24 10:29 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

HDA audio device can be present at various PCI paths on different systems
which the existing code did not account for.

Furthermore the failure to enable runtime PM was silent leaving callers
in the dark.

Improve it by auto-locating the PCI path and logging a warning when
something is not as expected.

v2:
 * If there is no audio hw/driver there is no failure.

v3:
 * Comment.
 * Skip non-symlinks.
 * Free path on failure and restore.
 * Simplify with asprintf. (Chris Wilson)

v4:
 * Find snd_hda_intel instance tied with an Intel device.

v5:
 * Fix memory leak and silence Valgrind warning.

v6:
 * Fix error out logic.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 lib/igt_pm.c | 93 ++++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 79 insertions(+), 14 deletions(-)

diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 6f3b0a2d897d..94d4dd2d3c37 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -33,6 +33,7 @@
 #include <unistd.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <dirent.h>
 
 #include "drmtest.h"
 #include "igt_pm.h"
@@ -64,6 +65,7 @@ enum {
 #define MAX_POLICY_STRLEN	strlen(MAX_PERFORMANCE_STR)
 
 static char __igt_pm_audio_runtime_power_save[64];
+static char * __igt_pm_audio_runtime_control_path;
 static char __igt_pm_audio_runtime_control[64];
 
 static int __igt_pm_audio_restore_runtime_pm(void)
@@ -86,7 +88,7 @@ static int __igt_pm_audio_restore_runtime_pm(void)
 
 	close(fd);
 
-	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_WRONLY);
+	fd = open(__igt_pm_audio_runtime_control_path, O_WRONLY);
 	if (fd < 0)
 		return errno;
 
@@ -100,6 +102,8 @@ static int __igt_pm_audio_restore_runtime_pm(void)
 	close(fd);
 
 	__igt_pm_audio_runtime_power_save[0] = 0;
+	free(__igt_pm_audio_runtime_control_path);
+	__igt_pm_audio_runtime_control_path = NULL;
 
 	return 0;
 }
@@ -130,36 +134,97 @@ static void strchomp(char *str)
  */
 void igt_pm_enable_audio_runtime_pm(void)
 {
+	char *path = NULL;
+	struct dirent *de;
+	DIR *dir;
 	int fd;
 
 	/* Check if already enabled. */
 	if (__igt_pm_audio_runtime_power_save[0])
 		return;
 
-	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
-	if (fd >= 0) {
-		igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
-				sizeof(__igt_pm_audio_runtime_power_save)) > 0);
-		strchomp(__igt_pm_audio_runtime_power_save);
-		igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
-		igt_assert_eq(write(fd, "1\n", 2), 2);
+	dir = opendir("/sys/class/sound");
+	if (!dir)
+		return;
+
+	/* Find PCI device claimed by snd_hda_intel and tied to i915. */
+	while ((de = readdir(dir))) {
+		const char *match = "hwC";
+		char buf[32] = { }; /* for Valgrind */
+		char *tmp;
+		int ret;
+
+		if (de->d_type != DT_LNK ||
+		    strncmp(de->d_name, match, strlen(match)))
+			continue;
+
+		igt_assert(asprintf(&tmp,
+				    "/sys/class/sound/%s/vendor_name",
+				    de->d_name));
+
+		fd = open(tmp, O_RDONLY);
+		free(tmp);
+		igt_assert_fd(fd);
+		ret = read(fd, buf, sizeof(buf));
 		close(fd);
+		igt_assert(ret > 0);
+		strchomp(buf);
+
+		/* Realtek and similar devices are not what we are after. */
+		if (strcmp(buf, "Intel"))
+			continue;
+
+		igt_assert(asprintf(&path,
+				    "/sys/class/sound/%s/device/device/power/control",
+				    de->d_name));
+
+		igt_debug("Audio device path is %s\n", path);
+
+		break;
 	}
-	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_RDWR);
-	if (fd >= 0) {
-		igt_assert(read(fd, __igt_pm_audio_runtime_control,
-				sizeof(__igt_pm_audio_runtime_control)) > 0);
-		strchomp(__igt_pm_audio_runtime_control);
-		igt_assert_eq(write(fd, "auto\n", 5), 5);
+
+	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
+	if (fd < 0)
+		return;
+
+	/* snd_hda_intel loaded but no path found is an error. */
+	if (!path) {
 		close(fd);
+		errno = ESRCH;
+		goto err;
 	}
 
+	igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
+			sizeof(__igt_pm_audio_runtime_power_save)) > 0);
+	strchomp(__igt_pm_audio_runtime_power_save);
+	igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
+	igt_assert_eq(write(fd, "1\n", 2), 2);
+	close(fd);
+
+	fd = open(path, O_RDWR);
+	if (fd < 0)
+		goto err;
+
+	igt_assert(read(fd, __igt_pm_audio_runtime_control,
+			sizeof(__igt_pm_audio_runtime_control)) > 0);
+	strchomp(__igt_pm_audio_runtime_control);
+	igt_assert_eq(write(fd, "auto\n", 5), 5);
+	close(fd);
+
+	__igt_pm_audio_runtime_control_path = path;
+
 	igt_debug("Saved audio power management as '%s' and '%s'\n",
 		  __igt_pm_audio_runtime_power_save,
 		  __igt_pm_audio_runtime_control);
 
 	/* Give some time for it to react. */
 	sleep(1);
+
+	return;
+
+err:
+	igt_warn("Failed to enable audio runtime PM! (%d)", errno);
+	free(path);
 }
 
 /**
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [Intel-gfx] [PATCH i-g-t v6 2/4] lib/igt_pm: Find HDA device when attempting to enable runtime PM
@ 2018-07-24 10:29               ` Tvrtko Ursulin
  0 siblings, 0 replies; 33+ messages in thread
From: Tvrtko Ursulin @ 2018-07-24 10:29 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

HDA audio device can be present at various PCI paths on different systems
which the existing code did not account for.

Furthermore the failure to enable runtime PM was silent leaving callers
in the dark.

Improve it by auto-locating the PCI path and logging a warning when
something is not as expected.

v2:
 * If there is no audio hw/driver there is no failure.

v3:
 * Comment.
 * Skip non-symlinks.
 * Free path on failure and restore.
 * Simplify with asprintf. (Chris Wilson)

v4:
 * Find snd_hda_intel instance tied with an Intel device.

v5:
 * Fix memory leak and silence Valgrind warning.

v6:
 * Fix error out logic.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 lib/igt_pm.c | 93 ++++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 79 insertions(+), 14 deletions(-)

diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 6f3b0a2d897d..94d4dd2d3c37 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -33,6 +33,7 @@
 #include <unistd.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <dirent.h>
 
 #include "drmtest.h"
 #include "igt_pm.h"
@@ -64,6 +65,7 @@ enum {
 #define MAX_POLICY_STRLEN	strlen(MAX_PERFORMANCE_STR)
 
 static char __igt_pm_audio_runtime_power_save[64];
+static char * __igt_pm_audio_runtime_control_path;
 static char __igt_pm_audio_runtime_control[64];
 
 static int __igt_pm_audio_restore_runtime_pm(void)
@@ -86,7 +88,7 @@ static int __igt_pm_audio_restore_runtime_pm(void)
 
 	close(fd);
 
-	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_WRONLY);
+	fd = open(__igt_pm_audio_runtime_control_path, O_WRONLY);
 	if (fd < 0)
 		return errno;
 
@@ -100,6 +102,8 @@ static int __igt_pm_audio_restore_runtime_pm(void)
 	close(fd);
 
 	__igt_pm_audio_runtime_power_save[0] = 0;
+	free(__igt_pm_audio_runtime_control_path);
+	__igt_pm_audio_runtime_control_path = NULL;
 
 	return 0;
 }
@@ -130,36 +134,97 @@ static void strchomp(char *str)
  */
 void igt_pm_enable_audio_runtime_pm(void)
 {
+	char *path = NULL;
+	struct dirent *de;
+	DIR *dir;
 	int fd;
 
 	/* Check if already enabled. */
 	if (__igt_pm_audio_runtime_power_save[0])
 		return;
 
-	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
-	if (fd >= 0) {
-		igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
-				sizeof(__igt_pm_audio_runtime_power_save)) > 0);
-		strchomp(__igt_pm_audio_runtime_power_save);
-		igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
-		igt_assert_eq(write(fd, "1\n", 2), 2);
+	dir = opendir("/sys/class/sound");
+	if (!dir)
+		return;
+
+	/* Find PCI device claimed by snd_hda_intel and tied to i915. */
+	while ((de = readdir(dir))) {
+		const char *match = "hwC";
+		char buf[32] = { }; /* for Valgrind */
+		char *tmp;
+		int ret;
+
+		if (de->d_type != DT_LNK ||
+		    strncmp(de->d_name, match, strlen(match)))
+			continue;
+
+		igt_assert(asprintf(&tmp,
+				    "/sys/class/sound/%s/vendor_name",
+				    de->d_name));
+
+		fd = open(tmp, O_RDONLY);
+		free(tmp);
+		igt_assert_fd(fd);
+		ret = read(fd, buf, sizeof(buf));
 		close(fd);
+		igt_assert(ret > 0);
+		strchomp(buf);
+
+		/* Realtek and similar devices are not what we are after. */
+		if (strcmp(buf, "Intel"))
+			continue;
+
+		igt_assert(asprintf(&path,
+				    "/sys/class/sound/%s/device/device/power/control",
+				    de->d_name));
+
+		igt_debug("Audio device path is %s\n", path);
+
+		break;
 	}
-	fd = open("/sys/bus/pci/devices/0000:00:03.0/power/control", O_RDWR);
-	if (fd >= 0) {
-		igt_assert(read(fd, __igt_pm_audio_runtime_control,
-				sizeof(__igt_pm_audio_runtime_control)) > 0);
-		strchomp(__igt_pm_audio_runtime_control);
-		igt_assert_eq(write(fd, "auto\n", 5), 5);
+
+	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
+	if (fd < 0)
+		return;
+
+	/* snd_hda_intel loaded but no path found is an error. */
+	if (!path) {
 		close(fd);
+		errno = ESRCH;
+		goto err;
 	}
 
+	igt_assert(read(fd, __igt_pm_audio_runtime_power_save,
+			sizeof(__igt_pm_audio_runtime_power_save)) > 0);
+	strchomp(__igt_pm_audio_runtime_power_save);
+	igt_install_exit_handler(__igt_pm_audio_runtime_exit_handler);
+	igt_assert_eq(write(fd, "1\n", 2), 2);
+	close(fd);
+
+	fd = open(path, O_RDWR);
+	if (fd < 0)
+		goto err;
+
+	igt_assert(read(fd, __igt_pm_audio_runtime_control,
+			sizeof(__igt_pm_audio_runtime_control)) > 0);
+	strchomp(__igt_pm_audio_runtime_control);
+	igt_assert_eq(write(fd, "auto\n", 5), 5);
+	close(fd);
+
+	__igt_pm_audio_runtime_control_path = path;
+
 	igt_debug("Saved audio power management as '%s' and '%s'\n",
 		  __igt_pm_audio_runtime_power_save,
 		  __igt_pm_audio_runtime_control);
 
 	/* Give some time for it to react. */
 	sleep(1);
+
+	return;
+
+err:
+	igt_warn("Failed to enable audio runtime PM! (%d)", errno);
+	free(path);
 }
 
 /**
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev5)
  2018-07-23 11:46 ` [igt-dev] " Tvrtko Ursulin
                   ` (8 preceding siblings ...)
  (?)
@ 2018-07-24 10:34 ` Patchwork
  -1 siblings, 0 replies; 33+ messages in thread
From: Patchwork @ 2018-07-24 10:34 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: igt-dev

== Series Details ==

Series: series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev5)
URL   : https://patchwork.freedesktop.org/series/47052/
State : failure

== Summary ==

= CI Bug Log - changes from CI_DRM_4521 -> IGTPW_1634 =

== Summary - FAILURE ==

  Serious unknown changes coming with IGTPW_1634 absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in IGTPW_1634, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/47052/revisions/5/mbox/

== Possible new issues ==

  Here are the unknown changes that may have been introduced in IGTPW_1634:

  === IGT changes ===

    ==== Possible regressions ====

    igt@pm_rpm@basic-rte:
      fi-cfl-s3:          PASS -> WARN +1

    
== Known issues ==

  Here are the changes found in IGTPW_1634 that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    igt@drv_module_reload@basic-reload:
      fi-glk-j4005:       PASS -> DMESG-WARN (fdo#106248, fdo#106725)

    igt@gem_workarounds@basic-read:
      {fi-icl-u}:         NOTRUN -> FAIL (fdo#107338)

    igt@kms_flip@basic-flip-vs-dpms:
      fi-glk-j4005:       PASS -> DMESG-WARN (fdo#106000)

    igt@kms_flip@basic-flip-vs-wf_vblank:
      {fi-icl-u}:         NOTRUN -> DMESG-WARN (fdo#107335) +42
      fi-glk-j4005:       PASS -> FAIL (fdo#100368)

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
      fi-snb-2520m:       NOTRUN -> INCOMPLETE (fdo#103713)

    {igt@kms_psr@primary_page_flip}:
      {fi-icl-u}:         NOTRUN -> DMESG-FAIL (fdo#107335) +3

    
    ==== Possible fixes ====

    igt@debugfs_test@read_all_entries:
      fi-snb-2520m:       INCOMPLETE (fdo#103713) -> PASS

    igt@prime_vgem@basic-fence-flip:
      fi-ilk-650:         FAIL (fdo#104008) -> PASS

    
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
  fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
  fdo#104008 https://bugs.freedesktop.org/show_bug.cgi?id=104008
  fdo#106000 https://bugs.freedesktop.org/show_bug.cgi?id=106000
  fdo#106248 https://bugs.freedesktop.org/show_bug.cgi?id=106248
  fdo#106725 https://bugs.freedesktop.org/show_bug.cgi?id=106725
  fdo#107335 https://bugs.freedesktop.org/show_bug.cgi?id=107335
  fdo#107338 https://bugs.freedesktop.org/show_bug.cgi?id=107338


== Participating hosts (47 -> 44) ==

  Additional (2): fi-bsw-kefka fi-icl-u 
  Missing    (5): fi-ctg-p8600 fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-hsw-4200u 


== Build changes ==

    * IGT: IGT_4570 -> IGTPW_1634

  CI_DRM_4521: a4ebbd84c682fd30edbde6ac0e48d150d4c5c066 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1634: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1634/
  IGT_4570: 65cdccdc7bcbb791d791aeeeecb784a382110a3c @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1634/issues.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev6)
  2018-07-23 11:46 ` [igt-dev] " Tvrtko Ursulin
                   ` (9 preceding siblings ...)
  (?)
@ 2018-07-24 10:50 ` Patchwork
  -1 siblings, 0 replies; 33+ messages in thread
From: Patchwork @ 2018-07-24 10:50 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: igt-dev

== Series Details ==

Series: series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev6)
URL   : https://patchwork.freedesktop.org/series/47052/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4521 -> IGTPW_1635 =

== Summary - SUCCESS ==

  No regressions found.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/47052/revisions/6/mbox/

== Known issues ==

  Here are the changes found in IGTPW_1635 that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    igt@drv_module_reload@basic-reload-inject:
      fi-glk-j4005:       PASS -> DMESG-WARN (fdo#106725, fdo#106248) +1

    igt@gem_exec_suspend@basic-s3:
      {fi-cfl-8109u}:     PASS -> INCOMPLETE (fdo#107187)

    igt@gem_workarounds@basic-read:
      {fi-icl-u}:         NOTRUN -> FAIL (fdo#107338)

    igt@kms_flip@basic-flip-vs-dpms:
      fi-glk-j4005:       PASS -> DMESG-WARN (fdo#106000)

    igt@kms_flip@basic-flip-vs-wf_vblank:
      {fi-icl-u}:         NOTRUN -> DMESG-WARN (fdo#107335) +42
      fi-glk-j4005:       PASS -> FAIL (fdo#100368)

    {igt@kms_psr@primary_page_flip}:
      {fi-icl-u}:         NOTRUN -> DMESG-FAIL (fdo#107335) +3

    
    ==== Possible fixes ====

    igt@debugfs_test@read_all_entries:
      fi-snb-2520m:       INCOMPLETE (fdo#103713) -> PASS

    igt@prime_vgem@basic-fence-flip:
      fi-ilk-650:         FAIL (fdo#104008) -> PASS

    
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
  fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
  fdo#104008 https://bugs.freedesktop.org/show_bug.cgi?id=104008
  fdo#106000 https://bugs.freedesktop.org/show_bug.cgi?id=106000
  fdo#106248 https://bugs.freedesktop.org/show_bug.cgi?id=106248
  fdo#106725 https://bugs.freedesktop.org/show_bug.cgi?id=106725
  fdo#107187 https://bugs.freedesktop.org/show_bug.cgi?id=107187
  fdo#107335 https://bugs.freedesktop.org/show_bug.cgi?id=107335
  fdo#107338 https://bugs.freedesktop.org/show_bug.cgi?id=107338


== Participating hosts (47 -> 44) ==

  Additional (2): fi-bsw-kefka fi-icl-u 
  Missing    (5): fi-ctg-p8600 fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-hsw-4200u 


== Build changes ==

    * IGT: IGT_4570 -> IGTPW_1635

  CI_DRM_4521: a4ebbd84c682fd30edbde6ac0e48d150d4c5c066 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1635: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1635/
  IGT_4570: 65cdccdc7bcbb791d791aeeeecb784a382110a3c @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1635/issues.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [igt-dev] ✓ Fi.CI.IGT: success for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev5)
  2018-07-23 11:46 ` [igt-dev] " Tvrtko Ursulin
                   ` (10 preceding siblings ...)
  (?)
@ 2018-07-24 11:27 ` Patchwork
  -1 siblings, 0 replies; 33+ messages in thread
From: Patchwork @ 2018-07-24 11:27 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: igt-dev

== Series Details ==

Series: series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev5)
URL   : https://patchwork.freedesktop.org/series/47052/
State : success

== Summary ==

= CI Bug Log - changes from IGT_4570_full -> IGTPW_1634_full =

== Summary - WARNING ==

  Minor unknown changes coming with IGTPW_1634_full need to be verified
  manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in IGTPW_1634_full, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/47052/revisions/5/mbox/

== Possible new issues ==

  Here are the unknown changes that may have been introduced in IGTPW_1634_full:

  === IGT changes ===

    ==== Warnings ====

    igt@kms_atomic_interruptible@legacy-pageflip:
      shard-snb:          SKIP -> PASS +1

    igt@pm_rc6_residency@rc6-accuracy:
      shard-kbl:          SKIP -> PASS +1

    
== Known issues ==

  Here are the changes found in IGTPW_1634_full that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    igt@gem_ctx_isolation@vcs1-s3:
      shard-kbl:          PASS -> INCOMPLETE (fdo#103665)

    igt@gem_exec_schedule@pi-ringfull-vebox:
      shard-glk:          NOTRUN -> FAIL (fdo#103158)

    igt@gem_softpin@noreloc:
      shard-snb:          PASS -> INCOMPLETE (fdo#105411)

    igt@kms_setmode@basic:
      shard-apl:          PASS -> FAIL (fdo#99912)

    igt@kms_vblank@pipe-c-ts-continuation-suspend:
      shard-hsw:          PASS -> FAIL (fdo#104894)

    
    ==== Possible fixes ====

    igt@gem_mmap_gtt@coherency:
      shard-glk:          FAIL (fdo#100587) -> SKIP +1

    igt@kms_flip@plain-flip-ts-check-interruptible:
      shard-glk:          FAIL (fdo#100368) -> PASS

    igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-indfb-draw-pwrite:
      shard-glk:          FAIL (fdo#103167) -> PASS

    igt@kms_rotation_crc@sprite-rotation-180:
      shard-snb:          FAIL (fdo#103925) -> PASS

    igt@perf_pmu@multi-client-vcs1:
      shard-snb:          INCOMPLETE (fdo#105411) -> SKIP

    igt@prime_vgem@coherency-gtt:
      shard-apl:          FAIL (fdo#100587) -> SKIP +1

    
  fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
  fdo#100587 https://bugs.freedesktop.org/show_bug.cgi?id=100587
  fdo#103158 https://bugs.freedesktop.org/show_bug.cgi?id=103158
  fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
  fdo#103665 https://bugs.freedesktop.org/show_bug.cgi?id=103665
  fdo#103925 https://bugs.freedesktop.org/show_bug.cgi?id=103925
  fdo#104894 https://bugs.freedesktop.org/show_bug.cgi?id=104894
  fdo#105411 https://bugs.freedesktop.org/show_bug.cgi?id=105411
  fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912


== Participating hosts (5 -> 5) ==

  No changes in participating hosts


== Build changes ==

    * IGT: IGT_4570 -> IGTPW_1634
    * Linux: CI_DRM_4519 -> CI_DRM_4521

  CI_DRM_4519: f14c0ec8fe9acce6fd1be84766f854ab8874eb33 @ git://anongit.freedesktop.org/gfx-ci/linux
  CI_DRM_4521: a4ebbd84c682fd30edbde6ac0e48d150d4c5c066 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1634: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1634/
  IGT_4570: 65cdccdc7bcbb791d791aeeeecb784a382110a3c @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1634/shards.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [igt-dev] ✗ Fi.CI.IGT: failure for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev6)
  2018-07-23 11:46 ` [igt-dev] " Tvrtko Ursulin
                   ` (11 preceding siblings ...)
  (?)
@ 2018-07-24 12:07 ` Patchwork
  -1 siblings, 0 replies; 33+ messages in thread
From: Patchwork @ 2018-07-24 12:07 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: igt-dev

== Series Details ==

Series: series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev6)
URL   : https://patchwork.freedesktop.org/series/47052/
State : failure

== Summary ==

= CI Bug Log - changes from IGT_4570_full -> IGTPW_1635_full =

== Summary - FAILURE ==

  Serious unknown changes coming with IGTPW_1635_full absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in IGTPW_1635_full, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/47052/revisions/6/mbox/

== Possible new issues ==

  Here are the unknown changes that may have been introduced in IGTPW_1635_full:

  === IGT changes ===

    ==== Possible regressions ====

    igt@prime_busy@basic-wait-after-default:
      shard-snb:          PASS -> DMESG-FAIL

    
    ==== Warnings ====

    igt@gem_exec_schedule@deep-vebox:
      shard-kbl:          PASS -> SKIP +1

    igt@kms_atomic_interruptible@legacy-pageflip:
      shard-snb:          SKIP -> PASS +1

    igt@pm_rc6_residency@rc6-accuracy:
      shard-kbl:          SKIP -> PASS

    
== Known issues ==

  Here are the changes found in IGTPW_1635_full that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    igt@gem_exec_schedule@pi-ringfull-vebox:
      shard-glk:          NOTRUN -> FAIL (fdo#103158)

    igt@kms_atomic_transition@1x-modeset-transitions-nonblocking:
      shard-glk:          PASS -> FAIL (fdo#105703)

    igt@kms_available_modes_crc@available_mode_test_crc:
      shard-snb:          PASS -> FAIL (fdo#106641)

    igt@kms_frontbuffer_tracking@fbcpsr-rgb565-draw-render:
      shard-snb:          SKIP -> INCOMPLETE (fdo#105411)

    igt@kms_setmode@basic:
      shard-apl:          PASS -> FAIL (fdo#99912)

    igt@kms_vblank@pipe-a-ts-continuation-suspend:
      shard-snb:          PASS -> INCOMPLETE (fdo#105411)

    
    ==== Possible fixes ====

    igt@gem_mmap_gtt@coherency:
      shard-glk:          FAIL (fdo#100587) -> SKIP

    igt@gem_ppgtt@blt-vs-render-ctxn:
      shard-kbl:          INCOMPLETE (fdo#106023, fdo#103665) -> PASS

    igt@kms_flip@plain-flip-ts-check-interruptible:
      shard-glk:          FAIL (fdo#100368) -> PASS +1

    igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-indfb-draw-pwrite:
      shard-glk:          FAIL (fdo#103167) -> PASS

    igt@kms_plane_multiple@atomic-pipe-a-tiling-x:
      shard-snb:          FAIL (fdo#103166) -> PASS

    igt@kms_rotation_crc@sprite-rotation-180:
      shard-snb:          FAIL (fdo#103925) -> PASS

    igt@kms_setmode@basic:
      shard-kbl:          FAIL (fdo#99912) -> PASS

    igt@perf_pmu@multi-client-vcs1:
      shard-snb:          INCOMPLETE (fdo#105411) -> SKIP

    igt@prime_vgem@coherency-gtt:
      shard-apl:          FAIL (fdo#100587) -> SKIP +1

    
  fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
  fdo#100587 https://bugs.freedesktop.org/show_bug.cgi?id=100587
  fdo#103158 https://bugs.freedesktop.org/show_bug.cgi?id=103158
  fdo#103166 https://bugs.freedesktop.org/show_bug.cgi?id=103166
  fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
  fdo#103665 https://bugs.freedesktop.org/show_bug.cgi?id=103665
  fdo#103925 https://bugs.freedesktop.org/show_bug.cgi?id=103925
  fdo#105411 https://bugs.freedesktop.org/show_bug.cgi?id=105411
  fdo#105703 https://bugs.freedesktop.org/show_bug.cgi?id=105703
  fdo#106023 https://bugs.freedesktop.org/show_bug.cgi?id=106023
  fdo#106641 https://bugs.freedesktop.org/show_bug.cgi?id=106641
  fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912


== Participating hosts (5 -> 5) ==

  No changes in participating hosts


== Build changes ==

    * IGT: IGT_4570 -> IGTPW_1635
    * Linux: CI_DRM_4519 -> CI_DRM_4521

  CI_DRM_4519: f14c0ec8fe9acce6fd1be84766f854ab8874eb33 @ git://anongit.freedesktop.org/gfx-ci/linux
  CI_DRM_4521: a4ebbd84c682fd30edbde6ac0e48d150d4c5c066 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1635: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1635/
  IGT_4570: 65cdccdc7bcbb791d791aeeeecb784a382110a3c @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1635/shards.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [igt-dev] [PATCH i-g-t v6 2/4] lib/igt_pm: Find HDA device when attempting to enable runtime PM
  2018-07-24 10:29               ` [Intel-gfx] " Tvrtko Ursulin
@ 2018-07-24 12:27                 ` Chris Wilson
  -1 siblings, 0 replies; 33+ messages in thread
From: Chris Wilson @ 2018-07-24 12:27 UTC (permalink / raw)
  To: Tvrtko Ursulin, igt-dev; +Cc: intel-gfx

Quoting Tvrtko Ursulin (2018-07-24 11:29:31)
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 
> HDA audio device can be present at various PCI paths on different systems
> which the existing code did not account for.
> 
> Furthermore the failure to enable runtime PM was silent leaving callers
> in the dark.
> 
> Improve it by auto-locating the PCI path and logging a warning when
> something is not as expected.
> 
> v2:
>  * If there is no audio hw/driver there is no failure.
> 
> v3:
>  * Comment.
>  * Skip non-symlinks.
>  * Free path on failure and restore.
>  * Simplify with asprintf. (Chris Wilson)
> 
> v4:
>  * Find snd_hda_intel instance tied with an Intel device.
> 
> v5:
>  * Fix memory leak and silence Valgrind warning.
> 
> v6:
>  * Fix error out logic.
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

CI looks promising, as far my knowledge goes (and I am sorry to say
finding the child devices is beyond my sysfs ken), series is
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [Intel-gfx] [igt-dev] [PATCH i-g-t v6 2/4] lib/igt_pm: Find HDA device when attempting to enable runtime PM
@ 2018-07-24 12:27                 ` Chris Wilson
  0 siblings, 0 replies; 33+ messages in thread
From: Chris Wilson @ 2018-07-24 12:27 UTC (permalink / raw)
  To: Tvrtko Ursulin, igt-dev; +Cc: intel-gfx

Quoting Tvrtko Ursulin (2018-07-24 11:29:31)
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 
> HDA audio device can be present at various PCI paths on different systems
> which the existing code did not account for.
> 
> Furthermore the failure to enable runtime PM was silent leaving callers
> in the dark.
> 
> Improve it by auto-locating the PCI path and logging a warning when
> something is not as expected.
> 
> v2:
>  * If there is no audio hw/driver there is no failure.
> 
> v3:
>  * Comment.
>  * Skip non-symlinks.
>  * Free path on failure and restore.
>  * Simplify with asprintf. (Chris Wilson)
> 
> v4:
>  * Find snd_hda_intel instance tied with an Intel device.
> 
> v5:
>  * Fix memory leak and silence Valgrind warning.
> 
> v6:
>  * Fix error out logic.
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

CI looks promising, as far my knowledge goes (and I am sorry to say
finding the child devices is beyond my sysfs ken), series is
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev6)
  2018-07-23 11:46 ` [igt-dev] " Tvrtko Ursulin
                   ` (12 preceding siblings ...)
  (?)
@ 2018-07-26 17:08 ` Patchwork
  -1 siblings, 0 replies; 33+ messages in thread
From: Patchwork @ 2018-07-26 17:08 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: igt-dev

== Series Details ==

Series: series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev6)
URL   : https://patchwork.freedesktop.org/series/47052/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4547 -> IGTPW_1653 =

== Summary - SUCCESS ==

  No regressions found.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/47052/revisions/6/mbox/

== Possible new issues ==

  Here are the unknown changes that may have been introduced in IGTPW_1653:

  === IGT changes ===

    ==== Possible regressions ====

    igt@debugfs_test@read_all_entries:
      {fi-icl-u}:         NOTRUN -> DMESG-WARN

    
== Known issues ==

  Here are the changes found in IGTPW_1653 that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    igt@drv_module_reload@basic-no-display:
      fi-cnl-psr:         NOTRUN -> DMESG-WARN (fdo#105395) +2

    igt@gem_exec_suspend@basic-s3:
      {fi-skl-caroline}:  NOTRUN -> INCOMPLETE (fdo#104108)

    igt@gem_workarounds@basic-read:
      {fi-icl-u}:         NOTRUN -> FAIL (fdo#107338)

    igt@kms_flip@basic-flip-vs-dpms:
      fi-skl-6700hq:      PASS -> DMESG-WARN (fdo#105998)

    igt@kms_frontbuffer_tracking@basic:
      fi-hsw-peppy:       PASS -> DMESG-FAIL (fdo#102614, fdo#106103)

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
      fi-snb-2520m:       PASS -> INCOMPLETE (fdo#103713)

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c:
      {fi-icl-u}:         NOTRUN -> DMESG-WARN (fdo#107382) +4

    {igt@kms_psr@cursor_plane_move}:
      fi-cnl-psr:         NOTRUN -> DMESG-FAIL (fdo#107372)

    {igt@kms_psr@primary_page_flip}:
      {fi-icl-u}:         NOTRUN -> FAIL (fdo#107383) +3
      fi-cnl-psr:         NOTRUN -> DMESG-WARN (fdo#107372)

    
    ==== Possible fixes ====

    igt@drv_module_reload@basic-reload:
      fi-glk-j4005:       DMESG-WARN (fdo#106248, fdo#106725) -> PASS

    igt@gem_exec_create@basic:
      fi-glk-j4005:       DMESG-WARN (fdo#106745) -> PASS

    igt@kms_flip@basic-flip-vs-modeset:
      fi-glk-j4005:       DMESG-WARN (fdo#106000) -> PASS

    igt@kms_flip@basic-flip-vs-wf_vblank:
      fi-glk-j4005:       FAIL (fdo#100368) -> PASS

    
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
  fdo#102614 https://bugs.freedesktop.org/show_bug.cgi?id=102614
  fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
  fdo#104108 https://bugs.freedesktop.org/show_bug.cgi?id=104108
  fdo#105395 https://bugs.freedesktop.org/show_bug.cgi?id=105395
  fdo#105998 https://bugs.freedesktop.org/show_bug.cgi?id=105998
  fdo#106000 https://bugs.freedesktop.org/show_bug.cgi?id=106000
  fdo#106103 https://bugs.freedesktop.org/show_bug.cgi?id=106103
  fdo#106248 https://bugs.freedesktop.org/show_bug.cgi?id=106248
  fdo#106725 https://bugs.freedesktop.org/show_bug.cgi?id=106725
  fdo#106745 https://bugs.freedesktop.org/show_bug.cgi?id=106745
  fdo#107338 https://bugs.freedesktop.org/show_bug.cgi?id=107338
  fdo#107372 https://bugs.freedesktop.org/show_bug.cgi?id=107372
  fdo#107382 https://bugs.freedesktop.org/show_bug.cgi?id=107382
  fdo#107383 https://bugs.freedesktop.org/show_bug.cgi?id=107383


== Participating hosts (48 -> 44) ==

  Additional (4): fi-byt-j1900 fi-skl-caroline fi-icl-u fi-cnl-psr 
  Missing    (8): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-kbl-8809g fi-byt-clapper fi-bdw-samus 


== Build changes ==

    * IGT: IGT_4575 -> IGTPW_1653

  CI_DRM_4547: 0a7ab192a697e951b2404f3c1ce42c5fa74f9ed1 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1653: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1653/
  IGT_4575: fe908a01012c9daafafb3410b9407725ca9d4f21 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1653/issues.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2018-07-26 17:08 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-23 11:46 [PATCH i-g-t 1/4] lib/igt_pm: Make exit handlers signal safe Tvrtko Ursulin
2018-07-23 11:46 ` [igt-dev] " Tvrtko Ursulin
2018-07-23 11:46 ` [PATCH i-g-t 2/4] lib/igt_pm: Find HDA device when attempting to enable runtime PM Tvrtko Ursulin
2018-07-23 11:46   ` [Intel-gfx] " Tvrtko Ursulin
2018-07-23 12:46   ` [PATCH i-g-t v2 " Tvrtko Ursulin
2018-07-23 12:46     ` [Intel-gfx] " Tvrtko Ursulin
2018-07-23 12:54     ` [igt-dev] " Chris Wilson
2018-07-23 12:54       ` [Intel-gfx] " Chris Wilson
2018-07-23 15:31       ` [PATCH i-g-t v3 " Tvrtko Ursulin
2018-07-23 15:31         ` [igt-dev] " Tvrtko Ursulin
2018-07-24  9:59         ` [PATCH i-g-t v4 " Tvrtko Ursulin
2018-07-24  9:59           ` [igt-dev] " Tvrtko Ursulin
2018-07-24 10:08           ` [PATCH i-g-t v5 " Tvrtko Ursulin
2018-07-24 10:08             ` [igt-dev] " Tvrtko Ursulin
2018-07-24 10:29             ` [PATCH i-g-t v6 " Tvrtko Ursulin
2018-07-24 10:29               ` [Intel-gfx] " Tvrtko Ursulin
2018-07-24 12:27               ` [igt-dev] " Chris Wilson
2018-07-24 12:27                 ` [Intel-gfx] " Chris Wilson
2018-07-23 11:46 ` [PATCH i-g-t 3/4] lib/igt_pm: Export function to restore runtime PM status Tvrtko Ursulin
2018-07-23 11:46   ` [igt-dev] " Tvrtko Ursulin
2018-07-23 11:46 ` [PATCH i-g-t 4/4] tests/perf_pmu: Restore runtime PM status at rc6 test exit Tvrtko Ursulin
2018-07-23 11:46   ` [igt-dev] " Tvrtko Ursulin
2018-07-23 12:37 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe Patchwork
2018-07-23 13:12 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev2) Patchwork
2018-07-23 13:58 ` [igt-dev] ✓ Fi.CI.IGT: success for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe Patchwork
2018-07-23 15:20 ` [igt-dev] ✓ Fi.CI.IGT: success for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev2) Patchwork
2018-07-23 15:54 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev3) Patchwork
2018-07-23 16:35   ` Tvrtko Ursulin
2018-07-24 10:34 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev5) Patchwork
2018-07-24 10:50 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev6) Patchwork
2018-07-24 11:27 ` [igt-dev] ✓ Fi.CI.IGT: success for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev5) Patchwork
2018-07-24 12:07 ` [igt-dev] ✗ Fi.CI.IGT: failure for series starting with [i-g-t,1/4] lib/igt_pm: Make exit handlers signal safe (rev6) Patchwork
2018-07-26 17:08 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.