All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t] lib: Poll for snd_hda_intel discovery
@ 2018-08-16 18:01 ` Chris Wilson
  0 siblings, 0 replies; 16+ messages in thread
From: Chris Wilson @ 2018-08-16 18:01 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

Loading the sounds modules is asynchronous with the sysfs device
hierarchy being instantiated sometime after modprobe returns. As such
while we are probing for the sound device, poll a few times to
accommodate the async discovery.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Imre Deak <imre.deak@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
---
 lib/igt_pm.c | 65 +++++++++++++++++++++++++++++++++-------------------
 1 file changed, 41 insertions(+), 24 deletions(-)

diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 6e96db22b..f82707231 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -138,31 +138,17 @@ static void strchomp(char *str)
 		str[len - 1] = 0;
 }
 
-/**
- * igt_pm_enable_audio_runtime_pm:
- *
- * We know that if we don't enable audio runtime PM, snd_hda_intel will never
- * release its power well refcount, and we'll never reach the LPSP state.
- * There's no guarantee that it will release the power well if we enable
- * runtime PM, but at least we can try.
- *
- * We don't have any assertions on open since the user may not even have
- * snd_hda_intel loaded, which is not a problem.
- */
-void igt_pm_enable_audio_runtime_pm(void)
+static int __igt_pm_enable_audio_runtime_pm(void)
 {
 	char *path = NULL;
 	struct dirent *de;
 	DIR *dir;
+	int err;
 	int fd;
 
-	/* Check if already enabled. */
-	if (__igt_pm_audio_runtime_power_save[0])
-		return;
-
 	dir = opendir("/sys/class/sound");
 	if (!dir)
-		return;
+		return 0;
 
 	/* Find PCI device claimed by snd_hda_intel and tied to i915. */
 	while ((de = readdir(dir))) {
@@ -196,18 +182,17 @@ void igt_pm_enable_audio_runtime_pm(void)
 				    de->d_name));
 
 		igt_debug("Audio device path is %s\n", path);
-
 		break;
 	}
 
 	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
 	if (fd < 0)
-		return;
+		return 0;
 
 	/* snd_hda_intel loaded but no path found is an error. */
 	if (!path) {
 		close(fd);
-		errno = ESRCH;
+		err = -ESRCH;
 		goto err;
 	}
 
@@ -219,8 +204,10 @@ void igt_pm_enable_audio_runtime_pm(void)
 	close(fd);
 
 	fd = open(path, O_RDWR);
-	if (fd < 0)
+	if (fd < 0) {
+		err = -errno;
 		goto err;
+	}
 
 	igt_assert(read(fd, __igt_pm_audio_runtime_control,
 			sizeof(__igt_pm_audio_runtime_control)) > 0);
@@ -236,12 +223,42 @@ void igt_pm_enable_audio_runtime_pm(void)
 
 	/* Give some time for it to react. */
 	sleep(1);
-
-	return;
+	return 0;
 
 err:
-	igt_warn("Failed to enable audio runtime PM! (%d)", errno);
 	free(path);
+	return err;
+}
+
+/**
+ * igt_pm_enable_audio_runtime_pm:
+ *
+ * We know that if we don't enable audio runtime PM, snd_hda_intel will never
+ * release its power well refcount, and we'll never reach the LPSP state.
+ * There's no guarantee that it will release the power well if we enable
+ * runtime PM, but at least we can try.
+ *
+ * We don't have any assertions on open since the user may not even have
+ * snd_hda_intel loaded, which is not a problem.
+ */
+void igt_pm_enable_audio_runtime_pm(void)
+{
+	int err;
+
+	/* Check if already enabled. */
+	if (__igt_pm_audio_runtime_power_save[0])
+		return;
+
+	for (int count = 0; count < 5; count++) {
+		err = __igt_pm_enable_audio_runtime_pm();
+		if (!err)
+			return;
+
+		/* modprobe(sna-hda-intel) is async so poll for sysfs */
+		sleep(1);
+	}
+
+	igt_warn("Failed to enable audio runtime PM! (%d)\n", -err);
 }
 
 /**
-- 
2.18.0

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

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

* [igt-dev] [PATCH i-g-t] lib: Poll for snd_hda_intel discovery
@ 2018-08-16 18:01 ` Chris Wilson
  0 siblings, 0 replies; 16+ messages in thread
From: Chris Wilson @ 2018-08-16 18:01 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

Loading the sounds modules is asynchronous with the sysfs device
hierarchy being instantiated sometime after modprobe returns. As such
while we are probing for the sound device, poll a few times to
accommodate the async discovery.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Imre Deak <imre.deak@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
---
 lib/igt_pm.c | 65 +++++++++++++++++++++++++++++++++-------------------
 1 file changed, 41 insertions(+), 24 deletions(-)

diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 6e96db22b..f82707231 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -138,31 +138,17 @@ static void strchomp(char *str)
 		str[len - 1] = 0;
 }
 
-/**
- * igt_pm_enable_audio_runtime_pm:
- *
- * We know that if we don't enable audio runtime PM, snd_hda_intel will never
- * release its power well refcount, and we'll never reach the LPSP state.
- * There's no guarantee that it will release the power well if we enable
- * runtime PM, but at least we can try.
- *
- * We don't have any assertions on open since the user may not even have
- * snd_hda_intel loaded, which is not a problem.
- */
-void igt_pm_enable_audio_runtime_pm(void)
+static int __igt_pm_enable_audio_runtime_pm(void)
 {
 	char *path = NULL;
 	struct dirent *de;
 	DIR *dir;
+	int err;
 	int fd;
 
-	/* Check if already enabled. */
-	if (__igt_pm_audio_runtime_power_save[0])
-		return;
-
 	dir = opendir("/sys/class/sound");
 	if (!dir)
-		return;
+		return 0;
 
 	/* Find PCI device claimed by snd_hda_intel and tied to i915. */
 	while ((de = readdir(dir))) {
@@ -196,18 +182,17 @@ void igt_pm_enable_audio_runtime_pm(void)
 				    de->d_name));
 
 		igt_debug("Audio device path is %s\n", path);
-
 		break;
 	}
 
 	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
 	if (fd < 0)
-		return;
+		return 0;
 
 	/* snd_hda_intel loaded but no path found is an error. */
 	if (!path) {
 		close(fd);
-		errno = ESRCH;
+		err = -ESRCH;
 		goto err;
 	}
 
@@ -219,8 +204,10 @@ void igt_pm_enable_audio_runtime_pm(void)
 	close(fd);
 
 	fd = open(path, O_RDWR);
-	if (fd < 0)
+	if (fd < 0) {
+		err = -errno;
 		goto err;
+	}
 
 	igt_assert(read(fd, __igt_pm_audio_runtime_control,
 			sizeof(__igt_pm_audio_runtime_control)) > 0);
@@ -236,12 +223,42 @@ void igt_pm_enable_audio_runtime_pm(void)
 
 	/* Give some time for it to react. */
 	sleep(1);
-
-	return;
+	return 0;
 
 err:
-	igt_warn("Failed to enable audio runtime PM! (%d)", errno);
 	free(path);
+	return err;
+}
+
+/**
+ * igt_pm_enable_audio_runtime_pm:
+ *
+ * We know that if we don't enable audio runtime PM, snd_hda_intel will never
+ * release its power well refcount, and we'll never reach the LPSP state.
+ * There's no guarantee that it will release the power well if we enable
+ * runtime PM, but at least we can try.
+ *
+ * We don't have any assertions on open since the user may not even have
+ * snd_hda_intel loaded, which is not a problem.
+ */
+void igt_pm_enable_audio_runtime_pm(void)
+{
+	int err;
+
+	/* Check if already enabled. */
+	if (__igt_pm_audio_runtime_power_save[0])
+		return;
+
+	for (int count = 0; count < 5; count++) {
+		err = __igt_pm_enable_audio_runtime_pm();
+		if (!err)
+			return;
+
+		/* modprobe(sna-hda-intel) is async so poll for sysfs */
+		sleep(1);
+	}
+
+	igt_warn("Failed to enable audio runtime PM! (%d)\n", -err);
 }
 
 /**
-- 
2.18.0

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

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

* [igt-dev] ✓ Fi.CI.BAT: success for lib: Poll for snd_hda_intel discovery
  2018-08-16 18:01 ` [igt-dev] " Chris Wilson
  (?)
@ 2018-08-16 18:19 ` Patchwork
  -1 siblings, 0 replies; 16+ messages in thread
From: Patchwork @ 2018-08-16 18:19 UTC (permalink / raw)
  To: Chris Wilson; +Cc: igt-dev

== Series Details ==

Series: lib: Poll for snd_hda_intel discovery
URL   : https://patchwork.freedesktop.org/series/48349/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4680 -> IGTPW_1724 =

== Summary - SUCCESS ==

  No regressions found.

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

== Possible new issues ==

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

  === IGT changes ===

    ==== Possible regressions ====

    {igt@pm_rpm@module-reload}:
      {fi-bsw-kefka}:     SKIP -> WARN
      fi-bdw-5557u:       SKIP -> WARN
      fi-glk-dsi:         SKIP -> WARN
      fi-skl-6600u:       SKIP -> WARN
      fi-kbl-guc:         SKIP -> WARN
      {fi-cfl-8109u}:     SKIP -> WARN
      {fi-byt-clapper}:   SKIP -> WARN
      fi-cfl-s3:          SKIP -> WARN
      fi-kbl-7500u:       SKIP -> WARN
      fi-bxt-dsi:         SKIP -> WARN
      fi-hsw-4770:        SKIP -> WARN
      fi-skl-6700hq:      SKIP -> WARN
      fi-cfl-guc:         SKIP -> WARN
      fi-skl-guc:         SKIP -> WARN
      fi-bsw-n3050:       SKIP -> WARN
      fi-hsw-peppy:       SKIP -> DMESG-FAIL
      fi-cfl-8700k:       SKIP -> WARN
      fi-kbl-x1275:       SKIP -> WARN
      fi-skl-6770hq:      SKIP -> WARN
      {fi-kbl-8809g}:     SKIP -> WARN
      fi-cnl-psr:         SKIP -> WARN
      fi-byt-j1900:       SKIP -> WARN
      fi-kbl-r:           SKIP -> WARN
      fi-skl-6260u:       SKIP -> WARN
      fi-bxt-j4205:       SKIP -> WARN
      fi-byt-n2820:       SKIP -> WARN
      fi-whl-u:           SKIP -> WARN
      fi-kbl-7567u:       SKIP -> WARN
      fi-kbl-7560u:       SKIP -> WARN
      {fi-skl-iommu}:     SKIP -> WARN
      fi-glk-j4005:       SKIP -> WARN
      fi-skl-6700k2:      SKIP -> WARN

    
== Known issues ==

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

  === IGT changes ===

    ==== Issues hit ====

    igt@drv_module_reload@basic-reload-inject:
      fi-hsw-4770r:       PASS -> DMESG-WARN (fdo#107425)

    igt@kms_frontbuffer_tracking@basic:
      {fi-byt-clapper}:   PASS -> FAIL (fdo#103167)

    igt@kms_pipe_crc_basic@nonblocking-crc-pipe-b-frame-sequence:
      {fi-byt-clapper}:   PASS -> FAIL (fdo#107362, fdo#103191)

    
    ==== Possible fixes ====

    igt@drv_selftest@live_hangcheck:
      fi-kbl-guc:         DMESG-FAIL (fdo#106947) -> PASS

    igt@kms_busy@basic-flip-a:
      fi-kbl-r:           DMESG-WARN (fdo#105602) -> PASS

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

  fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
  fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
  fdo#105602 https://bugs.freedesktop.org/show_bug.cgi?id=105602
  fdo#106947 https://bugs.freedesktop.org/show_bug.cgi?id=106947
  fdo#107362 https://bugs.freedesktop.org/show_bug.cgi?id=107362
  fdo#107425 https://bugs.freedesktop.org/show_bug.cgi?id=107425


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

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


== Build changes ==

    * IGT: IGT_4603 -> IGTPW_1724

  CI_DRM_4680: c0adc75a6340ba5a3f9cf07c5064627ee73b9ba9 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1724: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1724/
  IGT_4603: 1598fdb717546e25e8077935daa8e97768ad245d @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

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

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

* [igt-dev] ✓ Fi.CI.IGT: success for lib: Poll for snd_hda_intel discovery
  2018-08-16 18:01 ` [igt-dev] " Chris Wilson
  (?)
  (?)
@ 2018-08-16 22:15 ` Patchwork
  -1 siblings, 0 replies; 16+ messages in thread
From: Patchwork @ 2018-08-16 22:15 UTC (permalink / raw)
  To: Chris Wilson; +Cc: igt-dev

== Series Details ==

Series: lib: Poll for snd_hda_intel discovery
URL   : https://patchwork.freedesktop.org/series/48349/
State : success

== Summary ==

= CI Bug Log - changes from IGT_4603_full -> IGTPW_1724_full =

== Summary - SUCCESS ==

  No regressions found.

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

== Known issues ==

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

  === IGT changes ===

    ==== Issues hit ====

    igt@gem_caching@read-writes:
      shard-snb:          PASS -> INCOMPLETE (fdo#105411)

    igt@gem_exec_schedule@pi-ringfull-bsd2:
      shard-kbl:          NOTRUN -> FAIL (fdo#103158) +1

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

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

    
    ==== Possible fixes ====

    igt@drv_selftest@live_hangcheck:
      shard-kbl:          DMESG-FAIL (fdo#106560, fdo#106947) -> PASS

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

    igt@perf_pmu@semaphore-wait-idle-bcs0:
      shard-snb:          INCOMPLETE (fdo#105411) -> SKIP

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

    
  fdo#103158 https://bugs.freedesktop.org/show_bug.cgi?id=103158
  fdo#103359 https://bugs.freedesktop.org/show_bug.cgi?id=103359
  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#106023 https://bugs.freedesktop.org/show_bug.cgi?id=106023
  fdo#106560 https://bugs.freedesktop.org/show_bug.cgi?id=106560
  fdo#106947 https://bugs.freedesktop.org/show_bug.cgi?id=106947
  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_4603 -> IGTPW_1724
    * Linux: CI_DRM_4677 -> CI_DRM_4680

  CI_DRM_4677: 1af9e170b6469a64c82f5a4961a2be2f0fc1ff0a @ git://anongit.freedesktop.org/gfx-ci/linux
  CI_DRM_4680: c0adc75a6340ba5a3f9cf07c5064627ee73b9ba9 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1724: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1724/
  IGT_4603: 1598fdb717546e25e8077935daa8e97768ad245d @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

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

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

* Re: [PATCH i-g-t] lib: Poll for snd_hda_intel discovery
  2018-08-16 18:01 ` [igt-dev] " Chris Wilson
@ 2018-08-17  9:14   ` Imre Deak
  -1 siblings, 0 replies; 16+ messages in thread
From: Imre Deak @ 2018-08-17  9:14 UTC (permalink / raw)
  To: Chris Wilson; +Cc: igt-dev, intel-gfx

On Thu, Aug 16, 2018 at 07:01:36PM +0100, Chris Wilson wrote:
> Loading the sounds modules is asynchronous with the sysfs device
> hierarchy being instantiated sometime after modprobe returns. As such
> while we are probing for the sound device, poll a few times to
> accommodate the async discovery.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Imre Deak <imre.deak@intel.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>

> ---
>  lib/igt_pm.c | 65 +++++++++++++++++++++++++++++++++-------------------
>  1 file changed, 41 insertions(+), 24 deletions(-)
> 
> diff --git a/lib/igt_pm.c b/lib/igt_pm.c
> index 6e96db22b..f82707231 100644
> --- a/lib/igt_pm.c
> +++ b/lib/igt_pm.c
> @@ -138,31 +138,17 @@ static void strchomp(char *str)
>  		str[len - 1] = 0;
>  }
>  
> -/**
> - * igt_pm_enable_audio_runtime_pm:
> - *
> - * We know that if we don't enable audio runtime PM, snd_hda_intel will never
> - * release its power well refcount, and we'll never reach the LPSP state.
> - * There's no guarantee that it will release the power well if we enable
> - * runtime PM, but at least we can try.
> - *
> - * We don't have any assertions on open since the user may not even have
> - * snd_hda_intel loaded, which is not a problem.
> - */
> -void igt_pm_enable_audio_runtime_pm(void)
> +static int __igt_pm_enable_audio_runtime_pm(void)
>  {
>  	char *path = NULL;
>  	struct dirent *de;
>  	DIR *dir;
> +	int err;
>  	int fd;
>  
> -	/* Check if already enabled. */
> -	if (__igt_pm_audio_runtime_power_save[0])
> -		return;
> -
>  	dir = opendir("/sys/class/sound");
>  	if (!dir)
> -		return;
> +		return 0;
>  
>  	/* Find PCI device claimed by snd_hda_intel and tied to i915. */
>  	while ((de = readdir(dir))) {
> @@ -196,18 +182,17 @@ void igt_pm_enable_audio_runtime_pm(void)
>  				    de->d_name));
>  
>  		igt_debug("Audio device path is %s\n", path);
> -
>  		break;
>  	}

Could close dir while at it.

Reviewed-by: Imre Deak <imre.deak@intel.com>

This time the catch was that snd_hda_intel's second half of probe is run
from a scheduled work. (even though the first half returns synchronously
due to modprobe being synchronous as you found last time)

>  
>  	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
>  	if (fd < 0)
> -		return;
> +		return 0;
>  
>  	/* snd_hda_intel loaded but no path found is an error. */
>  	if (!path) {
>  		close(fd);
> -		errno = ESRCH;
> +		err = -ESRCH;
>  		goto err;
>  	}
>  
> @@ -219,8 +204,10 @@ void igt_pm_enable_audio_runtime_pm(void)
>  	close(fd);
>  
>  	fd = open(path, O_RDWR);
> -	if (fd < 0)
> +	if (fd < 0) {
> +		err = -errno;
>  		goto err;
> +	}
>  
>  	igt_assert(read(fd, __igt_pm_audio_runtime_control,
>  			sizeof(__igt_pm_audio_runtime_control)) > 0);
> @@ -236,12 +223,42 @@ void igt_pm_enable_audio_runtime_pm(void)
>  
>  	/* Give some time for it to react. */
>  	sleep(1);
> -
> -	return;
> +	return 0;
>  
>  err:
> -	igt_warn("Failed to enable audio runtime PM! (%d)", errno);
>  	free(path);
> +	return err;
> +}
> +
> +/**
> + * igt_pm_enable_audio_runtime_pm:
> + *
> + * We know that if we don't enable audio runtime PM, snd_hda_intel will never
> + * release its power well refcount, and we'll never reach the LPSP state.
> + * There's no guarantee that it will release the power well if we enable
> + * runtime PM, but at least we can try.
> + *
> + * We don't have any assertions on open since the user may not even have
> + * snd_hda_intel loaded, which is not a problem.
> + */
> +void igt_pm_enable_audio_runtime_pm(void)
> +{
> +	int err;
> +
> +	/* Check if already enabled. */
> +	if (__igt_pm_audio_runtime_power_save[0])
> +		return;
> +
> +	for (int count = 0; count < 5; count++) {
> +		err = __igt_pm_enable_audio_runtime_pm();
> +		if (!err)
> +			return;
> +
> +		/* modprobe(sna-hda-intel) is async so poll for sysfs */
> +		sleep(1);
> +	}
> +
> +	igt_warn("Failed to enable audio runtime PM! (%d)\n", -err);
>  }
>  
>  /**
> -- 
> 2.18.0
> 
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [igt-dev] [PATCH i-g-t] lib: Poll for snd_hda_intel discovery
@ 2018-08-17  9:14   ` Imre Deak
  0 siblings, 0 replies; 16+ messages in thread
From: Imre Deak @ 2018-08-17  9:14 UTC (permalink / raw)
  To: Chris Wilson; +Cc: igt-dev, intel-gfx

On Thu, Aug 16, 2018 at 07:01:36PM +0100, Chris Wilson wrote:
> Loading the sounds modules is asynchronous with the sysfs device
> hierarchy being instantiated sometime after modprobe returns. As such
> while we are probing for the sound device, poll a few times to
> accommodate the async discovery.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Imre Deak <imre.deak@intel.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>

> ---
>  lib/igt_pm.c | 65 +++++++++++++++++++++++++++++++++-------------------
>  1 file changed, 41 insertions(+), 24 deletions(-)
> 
> diff --git a/lib/igt_pm.c b/lib/igt_pm.c
> index 6e96db22b..f82707231 100644
> --- a/lib/igt_pm.c
> +++ b/lib/igt_pm.c
> @@ -138,31 +138,17 @@ static void strchomp(char *str)
>  		str[len - 1] = 0;
>  }
>  
> -/**
> - * igt_pm_enable_audio_runtime_pm:
> - *
> - * We know that if we don't enable audio runtime PM, snd_hda_intel will never
> - * release its power well refcount, and we'll never reach the LPSP state.
> - * There's no guarantee that it will release the power well if we enable
> - * runtime PM, but at least we can try.
> - *
> - * We don't have any assertions on open since the user may not even have
> - * snd_hda_intel loaded, which is not a problem.
> - */
> -void igt_pm_enable_audio_runtime_pm(void)
> +static int __igt_pm_enable_audio_runtime_pm(void)
>  {
>  	char *path = NULL;
>  	struct dirent *de;
>  	DIR *dir;
> +	int err;
>  	int fd;
>  
> -	/* Check if already enabled. */
> -	if (__igt_pm_audio_runtime_power_save[0])
> -		return;
> -
>  	dir = opendir("/sys/class/sound");
>  	if (!dir)
> -		return;
> +		return 0;
>  
>  	/* Find PCI device claimed by snd_hda_intel and tied to i915. */
>  	while ((de = readdir(dir))) {
> @@ -196,18 +182,17 @@ void igt_pm_enable_audio_runtime_pm(void)
>  				    de->d_name));
>  
>  		igt_debug("Audio device path is %s\n", path);
> -
>  		break;
>  	}

Could close dir while at it.

Reviewed-by: Imre Deak <imre.deak@intel.com>

This time the catch was that snd_hda_intel's second half of probe is run
from a scheduled work. (even though the first half returns synchronously
due to modprobe being synchronous as you found last time)

>  
>  	fd = open("/sys/module/snd_hda_intel/parameters/power_save", O_RDWR);
>  	if (fd < 0)
> -		return;
> +		return 0;
>  
>  	/* snd_hda_intel loaded but no path found is an error. */
>  	if (!path) {
>  		close(fd);
> -		errno = ESRCH;
> +		err = -ESRCH;
>  		goto err;
>  	}
>  
> @@ -219,8 +204,10 @@ void igt_pm_enable_audio_runtime_pm(void)
>  	close(fd);
>  
>  	fd = open(path, O_RDWR);
> -	if (fd < 0)
> +	if (fd < 0) {
> +		err = -errno;
>  		goto err;
> +	}
>  
>  	igt_assert(read(fd, __igt_pm_audio_runtime_control,
>  			sizeof(__igt_pm_audio_runtime_control)) > 0);
> @@ -236,12 +223,42 @@ void igt_pm_enable_audio_runtime_pm(void)
>  
>  	/* Give some time for it to react. */
>  	sleep(1);
> -
> -	return;
> +	return 0;
>  
>  err:
> -	igt_warn("Failed to enable audio runtime PM! (%d)", errno);
>  	free(path);
> +	return err;
> +}
> +
> +/**
> + * igt_pm_enable_audio_runtime_pm:
> + *
> + * We know that if we don't enable audio runtime PM, snd_hda_intel will never
> + * release its power well refcount, and we'll never reach the LPSP state.
> + * There's no guarantee that it will release the power well if we enable
> + * runtime PM, but at least we can try.
> + *
> + * We don't have any assertions on open since the user may not even have
> + * snd_hda_intel loaded, which is not a problem.
> + */
> +void igt_pm_enable_audio_runtime_pm(void)
> +{
> +	int err;
> +
> +	/* Check if already enabled. */
> +	if (__igt_pm_audio_runtime_power_save[0])
> +		return;
> +
> +	for (int count = 0; count < 5; count++) {
> +		err = __igt_pm_enable_audio_runtime_pm();
> +		if (!err)
> +			return;
> +
> +		/* modprobe(sna-hda-intel) is async so poll for sysfs */
> +		sleep(1);
> +	}
> +
> +	igt_warn("Failed to enable audio runtime PM! (%d)\n", -err);
>  }
>  
>  /**
> -- 
> 2.18.0
> 
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [PATCH i-g-t] lib: Poll for snd_hda_intel discovery
  2018-08-17  9:14   ` [igt-dev] " Imre Deak
@ 2018-08-17  9:24     ` Chris Wilson
  -1 siblings, 0 replies; 16+ messages in thread
From: Chris Wilson @ 2018-08-17  9:24 UTC (permalink / raw)
  To: Imre Deak; +Cc: igt-dev, intel-gfx

Quoting Imre Deak (2018-08-17 10:14:51)
> On Thu, Aug 16, 2018 at 07:01:36PM +0100, Chris Wilson wrote:
> > Loading the sounds modules is asynchronous with the sysfs device
> > hierarchy being instantiated sometime after modprobe returns. As such
> > while we are probing for the sound device, poll a few times to
> > accommodate the async discovery.
> > 
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Imre Deak <imre.deak@intel.com>
> > Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
> 
> > ---
> >  lib/igt_pm.c | 65 +++++++++++++++++++++++++++++++++-------------------
> >  1 file changed, 41 insertions(+), 24 deletions(-)
> > 
> > diff --git a/lib/igt_pm.c b/lib/igt_pm.c
> > index 6e96db22b..f82707231 100644
> > --- a/lib/igt_pm.c
> > +++ b/lib/igt_pm.c
> > @@ -138,31 +138,17 @@ static void strchomp(char *str)
> >               str[len - 1] = 0;
> >  }
> >  
> > -/**
> > - * igt_pm_enable_audio_runtime_pm:
> > - *
> > - * We know that if we don't enable audio runtime PM, snd_hda_intel will never
> > - * release its power well refcount, and we'll never reach the LPSP state.
> > - * There's no guarantee that it will release the power well if we enable
> > - * runtime PM, but at least we can try.
> > - *
> > - * We don't have any assertions on open since the user may not even have
> > - * snd_hda_intel loaded, which is not a problem.
> > - */
> > -void igt_pm_enable_audio_runtime_pm(void)
> > +static int __igt_pm_enable_audio_runtime_pm(void)
> >  {
> >       char *path = NULL;
> >       struct dirent *de;
> >       DIR *dir;
> > +     int err;
> >       int fd;
> >  
> > -     /* Check if already enabled. */
> > -     if (__igt_pm_audio_runtime_power_save[0])
> > -             return;
> > -
> >       dir = opendir("/sys/class/sound");
> >       if (!dir)
> > -             return;
> > +             return 0;
> >  
> >       /* Find PCI device claimed by snd_hda_intel and tied to i915. */
> >       while ((de = readdir(dir))) {
> > @@ -196,18 +182,17 @@ void igt_pm_enable_audio_runtime_pm(void)
> >                                   de->d_name));
> >  
> >               igt_debug("Audio device path is %s\n", path);
> > -
> >               break;
> >       }
> 
> Could close dir while at it.

Good point.
 
> Reviewed-by: Imre Deak <imre.deak@intel.com>
> 
> This time the catch was that snd_hda_intel's second half of probe is run
> from a scheduled work. (even though the first half returns synchronously
> due to modprobe being synchronous as you found last time)

The results from the CI didn't look too promising, but I'm a bit dubious
as to what exactly was tested and so pushed anyway ;)

What next if it still doesn't discover an audio device?

Hmm, is the /sys/class/sound construction async? I was assuming it was
constructed by the parent snd module long before sna_hda_intel does it
thing.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [igt-dev] [PATCH i-g-t] lib: Poll for snd_hda_intel discovery
@ 2018-08-17  9:24     ` Chris Wilson
  0 siblings, 0 replies; 16+ messages in thread
From: Chris Wilson @ 2018-08-17  9:24 UTC (permalink / raw)
  To: Imre Deak; +Cc: igt-dev, intel-gfx

Quoting Imre Deak (2018-08-17 10:14:51)
> On Thu, Aug 16, 2018 at 07:01:36PM +0100, Chris Wilson wrote:
> > Loading the sounds modules is asynchronous with the sysfs device
> > hierarchy being instantiated sometime after modprobe returns. As such
> > while we are probing for the sound device, poll a few times to
> > accommodate the async discovery.
> > 
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Imre Deak <imre.deak@intel.com>
> > Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
> 
> > ---
> >  lib/igt_pm.c | 65 +++++++++++++++++++++++++++++++++-------------------
> >  1 file changed, 41 insertions(+), 24 deletions(-)
> > 
> > diff --git a/lib/igt_pm.c b/lib/igt_pm.c
> > index 6e96db22b..f82707231 100644
> > --- a/lib/igt_pm.c
> > +++ b/lib/igt_pm.c
> > @@ -138,31 +138,17 @@ static void strchomp(char *str)
> >               str[len - 1] = 0;
> >  }
> >  
> > -/**
> > - * igt_pm_enable_audio_runtime_pm:
> > - *
> > - * We know that if we don't enable audio runtime PM, snd_hda_intel will never
> > - * release its power well refcount, and we'll never reach the LPSP state.
> > - * There's no guarantee that it will release the power well if we enable
> > - * runtime PM, but at least we can try.
> > - *
> > - * We don't have any assertions on open since the user may not even have
> > - * snd_hda_intel loaded, which is not a problem.
> > - */
> > -void igt_pm_enable_audio_runtime_pm(void)
> > +static int __igt_pm_enable_audio_runtime_pm(void)
> >  {
> >       char *path = NULL;
> >       struct dirent *de;
> >       DIR *dir;
> > +     int err;
> >       int fd;
> >  
> > -     /* Check if already enabled. */
> > -     if (__igt_pm_audio_runtime_power_save[0])
> > -             return;
> > -
> >       dir = opendir("/sys/class/sound");
> >       if (!dir)
> > -             return;
> > +             return 0;
> >  
> >       /* Find PCI device claimed by snd_hda_intel and tied to i915. */
> >       while ((de = readdir(dir))) {
> > @@ -196,18 +182,17 @@ void igt_pm_enable_audio_runtime_pm(void)
> >                                   de->d_name));
> >  
> >               igt_debug("Audio device path is %s\n", path);
> > -
> >               break;
> >       }
> 
> Could close dir while at it.

Good point.
 
> Reviewed-by: Imre Deak <imre.deak@intel.com>
> 
> This time the catch was that snd_hda_intel's second half of probe is run
> from a scheduled work. (even though the first half returns synchronously
> due to modprobe being synchronous as you found last time)

The results from the CI didn't look too promising, but I'm a bit dubious
as to what exactly was tested and so pushed anyway ;)

What next if it still doesn't discover an audio device?

Hmm, is the /sys/class/sound construction async? I was assuming it was
constructed by the parent snd module long before sna_hda_intel does it
thing.
-Chris
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [PATCH i-g-t] lib: Poll for snd_hda_intel discovery
  2018-08-17  9:24     ` [igt-dev] " Chris Wilson
@ 2018-08-17  9:38       ` Imre Deak
  -1 siblings, 0 replies; 16+ messages in thread
From: Imre Deak @ 2018-08-17  9:38 UTC (permalink / raw)
  To: Chris Wilson; +Cc: igt-dev, intel-gfx, Takashi Iwai

On Fri, Aug 17, 2018 at 10:24:30AM +0100, Chris Wilson wrote:
> Quoting Imre Deak (2018-08-17 10:14:51)
> > On Thu, Aug 16, 2018 at 07:01:36PM +0100, Chris Wilson wrote:
> > > Loading the sounds modules is asynchronous with the sysfs device
> > > hierarchy being instantiated sometime after modprobe returns. As such
> > > while we are probing for the sound device, poll a few times to
> > > accommodate the async discovery.
> > > 
> > > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > > Cc: Imre Deak <imre.deak@intel.com>
> > > Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
> > 
> > > ---
> > >  lib/igt_pm.c | 65 +++++++++++++++++++++++++++++++++-------------------
> > >  1 file changed, 41 insertions(+), 24 deletions(-)
> > > 
> > > diff --git a/lib/igt_pm.c b/lib/igt_pm.c
> > > index 6e96db22b..f82707231 100644
> > > --- a/lib/igt_pm.c
> > > +++ b/lib/igt_pm.c
> > > @@ -138,31 +138,17 @@ static void strchomp(char *str)
> > >               str[len - 1] = 0;
> > >  }
> > >  
> > > -/**
> > > - * igt_pm_enable_audio_runtime_pm:
> > > - *
> > > - * We know that if we don't enable audio runtime PM, snd_hda_intel will never
> > > - * release its power well refcount, and we'll never reach the LPSP state.
> > > - * There's no guarantee that it will release the power well if we enable
> > > - * runtime PM, but at least we can try.
> > > - *
> > > - * We don't have any assertions on open since the user may not even have
> > > - * snd_hda_intel loaded, which is not a problem.
> > > - */
> > > -void igt_pm_enable_audio_runtime_pm(void)
> > > +static int __igt_pm_enable_audio_runtime_pm(void)
> > >  {
> > >       char *path = NULL;
> > >       struct dirent *de;
> > >       DIR *dir;
> > > +     int err;
> > >       int fd;
> > >  
> > > -     /* Check if already enabled. */
> > > -     if (__igt_pm_audio_runtime_power_save[0])
> > > -             return;
> > > -
> > >       dir = opendir("/sys/class/sound");
> > >       if (!dir)
> > > -             return;
> > > +             return 0;
> > >  
> > >       /* Find PCI device claimed by snd_hda_intel and tied to i915. */
> > >       while ((de = readdir(dir))) {
> > > @@ -196,18 +182,17 @@ void igt_pm_enable_audio_runtime_pm(void)
> > >                                   de->d_name));
> > >  
> > >               igt_debug("Audio device path is %s\n", path);
> > > -
> > >               break;
> > >       }
> > 
> > Could close dir while at it.
> 
> Good point.
>  
> > Reviewed-by: Imre Deak <imre.deak@intel.com>
> > 
> > This time the catch was that snd_hda_intel's second half of probe is run
> > from a scheduled work. (even though the first half returns synchronously
> > due to modprobe being synchronous as you found last time)
> 
> The results from the CI didn't look too promising, but I'm a bit dubious
> as to what exactly was tested and so pushed anyway ;)
> 
> What next if it still doesn't discover an audio device?

We need to register the i915 audio component (in its current form or
just a stub version) even with disable_display=1, so that the audio
driver can continue its own probing (before timing out on the 10sec
wait for the audio component). Atm the

if (INTEL_INFO(dev_priv)->num_pipes == 0)
	return;

in i915_audio_component_init() prevents the registration.

> Hmm, is the /sys/class/sound construction async? I was assuming it was
> constructed by the parent snd module long before sna_hda_intel does it
> thing.

AFAICS, azx_probe_continue() is the scheduled work and it will do
snd_card_register()->device_add() which will add the sysfs entries.

Adding Takashi to confirm.

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

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

* Re: [igt-dev] [PATCH i-g-t] lib: Poll for snd_hda_intel discovery
@ 2018-08-17  9:38       ` Imre Deak
  0 siblings, 0 replies; 16+ messages in thread
From: Imre Deak @ 2018-08-17  9:38 UTC (permalink / raw)
  To: Chris Wilson; +Cc: igt-dev, intel-gfx, Takashi Iwai

On Fri, Aug 17, 2018 at 10:24:30AM +0100, Chris Wilson wrote:
> Quoting Imre Deak (2018-08-17 10:14:51)
> > On Thu, Aug 16, 2018 at 07:01:36PM +0100, Chris Wilson wrote:
> > > Loading the sounds modules is asynchronous with the sysfs device
> > > hierarchy being instantiated sometime after modprobe returns. As such
> > > while we are probing for the sound device, poll a few times to
> > > accommodate the async discovery.
> > > 
> > > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > > Cc: Imre Deak <imre.deak@intel.com>
> > > Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
> > 
> > > ---
> > >  lib/igt_pm.c | 65 +++++++++++++++++++++++++++++++++-------------------
> > >  1 file changed, 41 insertions(+), 24 deletions(-)
> > > 
> > > diff --git a/lib/igt_pm.c b/lib/igt_pm.c
> > > index 6e96db22b..f82707231 100644
> > > --- a/lib/igt_pm.c
> > > +++ b/lib/igt_pm.c
> > > @@ -138,31 +138,17 @@ static void strchomp(char *str)
> > >               str[len - 1] = 0;
> > >  }
> > >  
> > > -/**
> > > - * igt_pm_enable_audio_runtime_pm:
> > > - *
> > > - * We know that if we don't enable audio runtime PM, snd_hda_intel will never
> > > - * release its power well refcount, and we'll never reach the LPSP state.
> > > - * There's no guarantee that it will release the power well if we enable
> > > - * runtime PM, but at least we can try.
> > > - *
> > > - * We don't have any assertions on open since the user may not even have
> > > - * snd_hda_intel loaded, which is not a problem.
> > > - */
> > > -void igt_pm_enable_audio_runtime_pm(void)
> > > +static int __igt_pm_enable_audio_runtime_pm(void)
> > >  {
> > >       char *path = NULL;
> > >       struct dirent *de;
> > >       DIR *dir;
> > > +     int err;
> > >       int fd;
> > >  
> > > -     /* Check if already enabled. */
> > > -     if (__igt_pm_audio_runtime_power_save[0])
> > > -             return;
> > > -
> > >       dir = opendir("/sys/class/sound");
> > >       if (!dir)
> > > -             return;
> > > +             return 0;
> > >  
> > >       /* Find PCI device claimed by snd_hda_intel and tied to i915. */
> > >       while ((de = readdir(dir))) {
> > > @@ -196,18 +182,17 @@ void igt_pm_enable_audio_runtime_pm(void)
> > >                                   de->d_name));
> > >  
> > >               igt_debug("Audio device path is %s\n", path);
> > > -
> > >               break;
> > >       }
> > 
> > Could close dir while at it.
> 
> Good point.
>  
> > Reviewed-by: Imre Deak <imre.deak@intel.com>
> > 
> > This time the catch was that snd_hda_intel's second half of probe is run
> > from a scheduled work. (even though the first half returns synchronously
> > due to modprobe being synchronous as you found last time)
> 
> The results from the CI didn't look too promising, but I'm a bit dubious
> as to what exactly was tested and so pushed anyway ;)
> 
> What next if it still doesn't discover an audio device?

We need to register the i915 audio component (in its current form or
just a stub version) even with disable_display=1, so that the audio
driver can continue its own probing (before timing out on the 10sec
wait for the audio component). Atm the

if (INTEL_INFO(dev_priv)->num_pipes == 0)
	return;

in i915_audio_component_init() prevents the registration.

> Hmm, is the /sys/class/sound construction async? I was assuming it was
> constructed by the parent snd module long before sna_hda_intel does it
> thing.

AFAICS, azx_probe_continue() is the scheduled work and it will do
snd_card_register()->device_add() which will add the sysfs entries.

Adding Takashi to confirm.

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

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

* Re: [PATCH i-g-t] lib: Poll for snd_hda_intel discovery
  2018-08-17  9:38       ` [igt-dev] " Imre Deak
@ 2018-08-17  9:48         ` Chris Wilson
  -1 siblings, 0 replies; 16+ messages in thread
From: Chris Wilson @ 2018-08-17  9:48 UTC (permalink / raw)
  To: Imre Deak; +Cc: igt-dev, intel-gfx, Takashi Iwai

Quoting Imre Deak (2018-08-17 10:38:01)
> On Fri, Aug 17, 2018 at 10:24:30AM +0100, Chris Wilson wrote:
> > Quoting Imre Deak (2018-08-17 10:14:51)
> > > On Thu, Aug 16, 2018 at 07:01:36PM +0100, Chris Wilson wrote:
> > > > Loading the sounds modules is asynchronous with the sysfs device
> > > > hierarchy being instantiated sometime after modprobe returns. As such
> > > > while we are probing for the sound device, poll a few times to
> > > > accommodate the async discovery.
> > > > 
> > > > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > > > Cc: Imre Deak <imre.deak@intel.com>
> > > > Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
> > > 
> > > > ---
> > > >  lib/igt_pm.c | 65 +++++++++++++++++++++++++++++++++-------------------
> > > >  1 file changed, 41 insertions(+), 24 deletions(-)
> > > > 
> > > > diff --git a/lib/igt_pm.c b/lib/igt_pm.c
> > > > index 6e96db22b..f82707231 100644
> > > > --- a/lib/igt_pm.c
> > > > +++ b/lib/igt_pm.c
> > > > @@ -138,31 +138,17 @@ static void strchomp(char *str)
> > > >               str[len - 1] = 0;
> > > >  }
> > > >  
> > > > -/**
> > > > - * igt_pm_enable_audio_runtime_pm:
> > > > - *
> > > > - * We know that if we don't enable audio runtime PM, snd_hda_intel will never
> > > > - * release its power well refcount, and we'll never reach the LPSP state.
> > > > - * There's no guarantee that it will release the power well if we enable
> > > > - * runtime PM, but at least we can try.
> > > > - *
> > > > - * We don't have any assertions on open since the user may not even have
> > > > - * snd_hda_intel loaded, which is not a problem.
> > > > - */
> > > > -void igt_pm_enable_audio_runtime_pm(void)
> > > > +static int __igt_pm_enable_audio_runtime_pm(void)
> > > >  {
> > > >       char *path = NULL;
> > > >       struct dirent *de;
> > > >       DIR *dir;
> > > > +     int err;
> > > >       int fd;
> > > >  
> > > > -     /* Check if already enabled. */
> > > > -     if (__igt_pm_audio_runtime_power_save[0])
> > > > -             return;
> > > > -
> > > >       dir = opendir("/sys/class/sound");
> > > >       if (!dir)
> > > > -             return;
> > > > +             return 0;
> > > >  
> > > >       /* Find PCI device claimed by snd_hda_intel and tied to i915. */
> > > >       while ((de = readdir(dir))) {
> > > > @@ -196,18 +182,17 @@ void igt_pm_enable_audio_runtime_pm(void)
> > > >                                   de->d_name));
> > > >  
> > > >               igt_debug("Audio device path is %s\n", path);
> > > > -
> > > >               break;
> > > >       }
> > > 
> > > Could close dir while at it.
> > 
> > Good point.
> >  
> > > Reviewed-by: Imre Deak <imre.deak@intel.com>
> > > 
> > > This time the catch was that snd_hda_intel's second half of probe is run
> > > from a scheduled work. (even though the first half returns synchronously
> > > due to modprobe being synchronous as you found last time)
> > 
> > The results from the CI didn't look too promising, but I'm a bit dubious
> > as to what exactly was tested and so pushed anyway ;)
> > 
> > What next if it still doesn't discover an audio device?
> 
> We need to register the i915 audio component (in its current form or
> just a stub version) even with disable_display=1, so that the audio
> driver can continue its own probing (before timing out on the 10sec
> wait for the audio component). Atm the
> 
> if (INTEL_INFO(dev_priv)->num_pipes == 0)
>         return;
> 
> in i915_audio_component_init() prevents the registration.

Right, that's the other question: do we need that at all...
 
> > Hmm, is the /sys/class/sound construction async? I was assuming it was
> > constructed by the parent snd module long before sna_hda_intel does it
> > thing.
> 
> AFAICS, azx_probe_continue() is the scheduled work and it will do
> snd_card_register()->device_add() which will add the sysfs entries.

As far as the probe we do here, the key question is whether
opendir("/sys/class/sound") will succeed after modprobe but before the
devices have been constructed. We using that as a predicate as to
whether there are any sound modules to wait for.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [Intel-gfx] [PATCH i-g-t] lib: Poll for snd_hda_intel discovery
@ 2018-08-17  9:48         ` Chris Wilson
  0 siblings, 0 replies; 16+ messages in thread
From: Chris Wilson @ 2018-08-17  9:48 UTC (permalink / raw)
  To: Imre Deak; +Cc: igt-dev, intel-gfx, Takashi Iwai

Quoting Imre Deak (2018-08-17 10:38:01)
> On Fri, Aug 17, 2018 at 10:24:30AM +0100, Chris Wilson wrote:
> > Quoting Imre Deak (2018-08-17 10:14:51)
> > > On Thu, Aug 16, 2018 at 07:01:36PM +0100, Chris Wilson wrote:
> > > > Loading the sounds modules is asynchronous with the sysfs device
> > > > hierarchy being instantiated sometime after modprobe returns. As such
> > > > while we are probing for the sound device, poll a few times to
> > > > accommodate the async discovery.
> > > > 
> > > > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > > > Cc: Imre Deak <imre.deak@intel.com>
> > > > Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
> > > 
> > > > ---
> > > >  lib/igt_pm.c | 65 +++++++++++++++++++++++++++++++++-------------------
> > > >  1 file changed, 41 insertions(+), 24 deletions(-)
> > > > 
> > > > diff --git a/lib/igt_pm.c b/lib/igt_pm.c
> > > > index 6e96db22b..f82707231 100644
> > > > --- a/lib/igt_pm.c
> > > > +++ b/lib/igt_pm.c
> > > > @@ -138,31 +138,17 @@ static void strchomp(char *str)
> > > >               str[len - 1] = 0;
> > > >  }
> > > >  
> > > > -/**
> > > > - * igt_pm_enable_audio_runtime_pm:
> > > > - *
> > > > - * We know that if we don't enable audio runtime PM, snd_hda_intel will never
> > > > - * release its power well refcount, and we'll never reach the LPSP state.
> > > > - * There's no guarantee that it will release the power well if we enable
> > > > - * runtime PM, but at least we can try.
> > > > - *
> > > > - * We don't have any assertions on open since the user may not even have
> > > > - * snd_hda_intel loaded, which is not a problem.
> > > > - */
> > > > -void igt_pm_enable_audio_runtime_pm(void)
> > > > +static int __igt_pm_enable_audio_runtime_pm(void)
> > > >  {
> > > >       char *path = NULL;
> > > >       struct dirent *de;
> > > >       DIR *dir;
> > > > +     int err;
> > > >       int fd;
> > > >  
> > > > -     /* Check if already enabled. */
> > > > -     if (__igt_pm_audio_runtime_power_save[0])
> > > > -             return;
> > > > -
> > > >       dir = opendir("/sys/class/sound");
> > > >       if (!dir)
> > > > -             return;
> > > > +             return 0;
> > > >  
> > > >       /* Find PCI device claimed by snd_hda_intel and tied to i915. */
> > > >       while ((de = readdir(dir))) {
> > > > @@ -196,18 +182,17 @@ void igt_pm_enable_audio_runtime_pm(void)
> > > >                                   de->d_name));
> > > >  
> > > >               igt_debug("Audio device path is %s\n", path);
> > > > -
> > > >               break;
> > > >       }
> > > 
> > > Could close dir while at it.
> > 
> > Good point.
> >  
> > > Reviewed-by: Imre Deak <imre.deak@intel.com>
> > > 
> > > This time the catch was that snd_hda_intel's second half of probe is run
> > > from a scheduled work. (even though the first half returns synchronously
> > > due to modprobe being synchronous as you found last time)
> > 
> > The results from the CI didn't look too promising, but I'm a bit dubious
> > as to what exactly was tested and so pushed anyway ;)
> > 
> > What next if it still doesn't discover an audio device?
> 
> We need to register the i915 audio component (in its current form or
> just a stub version) even with disable_display=1, so that the audio
> driver can continue its own probing (before timing out on the 10sec
> wait for the audio component). Atm the
> 
> if (INTEL_INFO(dev_priv)->num_pipes == 0)
>         return;
> 
> in i915_audio_component_init() prevents the registration.

Right, that's the other question: do we need that at all...
 
> > Hmm, is the /sys/class/sound construction async? I was assuming it was
> > constructed by the parent snd module long before sna_hda_intel does it
> > thing.
> 
> AFAICS, azx_probe_continue() is the scheduled work and it will do
> snd_card_register()->device_add() which will add the sysfs entries.

As far as the probe we do here, the key question is whether
opendir("/sys/class/sound") will succeed after modprobe but before the
devices have been constructed. We using that as a predicate as to
whether there are any sound modules to wait for.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH i-g-t] lib: Poll for snd_hda_intel discovery
  2018-08-17  9:38       ` [igt-dev] " Imre Deak
@ 2018-08-17 10:00         ` Takashi Iwai
  -1 siblings, 0 replies; 16+ messages in thread
From: Takashi Iwai @ 2018-08-17 10:00 UTC (permalink / raw)
  To: imre.deak, Chris Wilson; +Cc: igt-dev, intel-gfx, Takashi Iwai

On Fri, 17 Aug 2018 11:38:01 +0200,
Imre Deak wrote:
> 
> On Fri, Aug 17, 2018 at 10:24:30AM +0100, Chris Wilson wrote:
> > Quoting Imre Deak (2018-08-17 10:14:51)
> > > On Thu, Aug 16, 2018 at 07:01:36PM +0100, Chris Wilson wrote:
> > > > Loading the sounds modules is asynchronous with the sysfs device
> > > > hierarchy being instantiated sometime after modprobe returns. As such
> > > > while we are probing for the sound device, poll a few times to
> > > > accommodate the async discovery.
> > > > 
> > > > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > > > Cc: Imre Deak <imre.deak@intel.com>
> > > > Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
> > > 
> > > > ---
> > > >  lib/igt_pm.c | 65 +++++++++++++++++++++++++++++++++-------------------
> > > >  1 file changed, 41 insertions(+), 24 deletions(-)
> > > > 
> > > > diff --git a/lib/igt_pm.c b/lib/igt_pm.c
> > > > index 6e96db22b..f82707231 100644
> > > > --- a/lib/igt_pm.c
> > > > +++ b/lib/igt_pm.c
> > > > @@ -138,31 +138,17 @@ static void strchomp(char *str)
> > > >               str[len - 1] = 0;
> > > >  }
> > > >  
> > > > -/**
> > > > - * igt_pm_enable_audio_runtime_pm:
> > > > - *
> > > > - * We know that if we don't enable audio runtime PM, snd_hda_intel will never
> > > > - * release its power well refcount, and we'll never reach the LPSP state.
> > > > - * There's no guarantee that it will release the power well if we enable
> > > > - * runtime PM, but at least we can try.
> > > > - *
> > > > - * We don't have any assertions on open since the user may not even have
> > > > - * snd_hda_intel loaded, which is not a problem.
> > > > - */
> > > > -void igt_pm_enable_audio_runtime_pm(void)
> > > > +static int __igt_pm_enable_audio_runtime_pm(void)
> > > >  {
> > > >       char *path = NULL;
> > > >       struct dirent *de;
> > > >       DIR *dir;
> > > > +     int err;
> > > >       int fd;
> > > >  
> > > > -     /* Check if already enabled. */
> > > > -     if (__igt_pm_audio_runtime_power_save[0])
> > > > -             return;
> > > > -
> > > >       dir = opendir("/sys/class/sound");
> > > >       if (!dir)
> > > > -             return;
> > > > +             return 0;
> > > >  
> > > >       /* Find PCI device claimed by snd_hda_intel and tied to i915. */
> > > >       while ((de = readdir(dir))) {
> > > > @@ -196,18 +182,17 @@ void igt_pm_enable_audio_runtime_pm(void)
> > > >                                   de->d_name));
> > > >  
> > > >               igt_debug("Audio device path is %s\n", path);
> > > > -
> > > >               break;
> > > >       }
> > > 
> > > Could close dir while at it.
> > 
> > Good point.
> >  
> > > Reviewed-by: Imre Deak <imre.deak@intel.com>
> > > 
> > > This time the catch was that snd_hda_intel's second half of probe is run
> > > from a scheduled work. (even though the first half returns synchronously
> > > due to modprobe being synchronous as you found last time)
> > 
> > The results from the CI didn't look too promising, but I'm a bit dubious
> > as to what exactly was tested and so pushed anyway ;)
> > 
> > What next if it still doesn't discover an audio device?
> 
> We need to register the i915 audio component (in its current form or
> just a stub version) even with disable_display=1, so that the audio
> driver can continue its own probing (before timing out on the 10sec
> wait for the audio component). Atm the
> 
> if (INTEL_INFO(dev_priv)->num_pipes == 0)
> 	return;
> 
> in i915_audio_component_init() prevents the registration.
> 
> > Hmm, is the /sys/class/sound construction async? I was assuming it was
> > constructed by the parent snd module long before sna_hda_intel does it
> > thing.
> 
> AFAICS, azx_probe_continue() is the scheduled work and it will do
> snd_card_register()->device_add() which will add the sysfs entries.
> 
> Adding Takashi to confirm.

The root /sys/class/sound directory should have been visible at
loading soundcore module, and this one is loaded before snd-hda-intel
due to the dependency.


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

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

* Re: [igt-dev] [PATCH i-g-t] lib: Poll for snd_hda_intel discovery
@ 2018-08-17 10:00         ` Takashi Iwai
  0 siblings, 0 replies; 16+ messages in thread
From: Takashi Iwai @ 2018-08-17 10:00 UTC (permalink / raw)
  To: imre.deak, Chris Wilson; +Cc: igt-dev, intel-gfx, Takashi Iwai

On Fri, 17 Aug 2018 11:38:01 +0200,
Imre Deak wrote:
> 
> On Fri, Aug 17, 2018 at 10:24:30AM +0100, Chris Wilson wrote:
> > Quoting Imre Deak (2018-08-17 10:14:51)
> > > On Thu, Aug 16, 2018 at 07:01:36PM +0100, Chris Wilson wrote:
> > > > Loading the sounds modules is asynchronous with the sysfs device
> > > > hierarchy being instantiated sometime after modprobe returns. As such
> > > > while we are probing for the sound device, poll a few times to
> > > > accommodate the async discovery.
> > > > 
> > > > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > > > Cc: Imre Deak <imre.deak@intel.com>
> > > > Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
> > > 
> > > > ---
> > > >  lib/igt_pm.c | 65 +++++++++++++++++++++++++++++++++-------------------
> > > >  1 file changed, 41 insertions(+), 24 deletions(-)
> > > > 
> > > > diff --git a/lib/igt_pm.c b/lib/igt_pm.c
> > > > index 6e96db22b..f82707231 100644
> > > > --- a/lib/igt_pm.c
> > > > +++ b/lib/igt_pm.c
> > > > @@ -138,31 +138,17 @@ static void strchomp(char *str)
> > > >               str[len - 1] = 0;
> > > >  }
> > > >  
> > > > -/**
> > > > - * igt_pm_enable_audio_runtime_pm:
> > > > - *
> > > > - * We know that if we don't enable audio runtime PM, snd_hda_intel will never
> > > > - * release its power well refcount, and we'll never reach the LPSP state.
> > > > - * There's no guarantee that it will release the power well if we enable
> > > > - * runtime PM, but at least we can try.
> > > > - *
> > > > - * We don't have any assertions on open since the user may not even have
> > > > - * snd_hda_intel loaded, which is not a problem.
> > > > - */
> > > > -void igt_pm_enable_audio_runtime_pm(void)
> > > > +static int __igt_pm_enable_audio_runtime_pm(void)
> > > >  {
> > > >       char *path = NULL;
> > > >       struct dirent *de;
> > > >       DIR *dir;
> > > > +     int err;
> > > >       int fd;
> > > >  
> > > > -     /* Check if already enabled. */
> > > > -     if (__igt_pm_audio_runtime_power_save[0])
> > > > -             return;
> > > > -
> > > >       dir = opendir("/sys/class/sound");
> > > >       if (!dir)
> > > > -             return;
> > > > +             return 0;
> > > >  
> > > >       /* Find PCI device claimed by snd_hda_intel and tied to i915. */
> > > >       while ((de = readdir(dir))) {
> > > > @@ -196,18 +182,17 @@ void igt_pm_enable_audio_runtime_pm(void)
> > > >                                   de->d_name));
> > > >  
> > > >               igt_debug("Audio device path is %s\n", path);
> > > > -
> > > >               break;
> > > >       }
> > > 
> > > Could close dir while at it.
> > 
> > Good point.
> >  
> > > Reviewed-by: Imre Deak <imre.deak@intel.com>
> > > 
> > > This time the catch was that snd_hda_intel's second half of probe is run
> > > from a scheduled work. (even though the first half returns synchronously
> > > due to modprobe being synchronous as you found last time)
> > 
> > The results from the CI didn't look too promising, but I'm a bit dubious
> > as to what exactly was tested and so pushed anyway ;)
> > 
> > What next if it still doesn't discover an audio device?
> 
> We need to register the i915 audio component (in its current form or
> just a stub version) even with disable_display=1, so that the audio
> driver can continue its own probing (before timing out on the 10sec
> wait for the audio component). Atm the
> 
> if (INTEL_INFO(dev_priv)->num_pipes == 0)
> 	return;
> 
> in i915_audio_component_init() prevents the registration.
> 
> > Hmm, is the /sys/class/sound construction async? I was assuming it was
> > constructed by the parent snd module long before sna_hda_intel does it
> > thing.
> 
> AFAICS, azx_probe_continue() is the scheduled work and it will do
> snd_card_register()->device_add() which will add the sysfs entries.
> 
> Adding Takashi to confirm.

The root /sys/class/sound directory should have been visible at
loading soundcore module, and this one is loaded before snd-hda-intel
due to the dependency.


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

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

* Re: [PATCH i-g-t] lib: Poll for snd_hda_intel discovery
  2018-08-17  9:48         ` [Intel-gfx] " Chris Wilson
@ 2018-08-17 12:32           ` Imre Deak
  -1 siblings, 0 replies; 16+ messages in thread
From: Imre Deak @ 2018-08-17 12:32 UTC (permalink / raw)
  To: Chris Wilson; +Cc: igt-dev, intel-gfx, Takashi Iwai

On Fri, Aug 17, 2018 at 10:48:29AM +0100, Chris Wilson wrote:
> Quoting Imre Deak (2018-08-17 10:38:01)
> > On Fri, Aug 17, 2018 at 10:24:30AM +0100, Chris Wilson wrote:
> > > Quoting Imre Deak (2018-08-17 10:14:51)
> > > > On Thu, Aug 16, 2018 at 07:01:36PM +0100, Chris Wilson wrote:
> > > > > Loading the sounds modules is asynchronous with the sysfs device
> > > > > hierarchy being instantiated sometime after modprobe returns. As such
> > > > > while we are probing for the sound device, poll a few times to
> > > > > accommodate the async discovery.
> > > > > 
> > > > > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > > > > Cc: Imre Deak <imre.deak@intel.com>
> > > > > Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
> > > > 
> > > > > ---
> > > > >  lib/igt_pm.c | 65 +++++++++++++++++++++++++++++++++-------------------
> > > > >  1 file changed, 41 insertions(+), 24 deletions(-)
> > > > > 
> > > > > diff --git a/lib/igt_pm.c b/lib/igt_pm.c
> > > > > index 6e96db22b..f82707231 100644
> > > > > --- a/lib/igt_pm.c
> > > > > +++ b/lib/igt_pm.c
> > > > > @@ -138,31 +138,17 @@ static void strchomp(char *str)
> > > > >               str[len - 1] = 0;
> > > > >  }
> > > > >  
> > > > > -/**
> > > > > - * igt_pm_enable_audio_runtime_pm:
> > > > > - *
> > > > > - * We know that if we don't enable audio runtime PM, snd_hda_intel will never
> > > > > - * release its power well refcount, and we'll never reach the LPSP state.
> > > > > - * There's no guarantee that it will release the power well if we enable
> > > > > - * runtime PM, but at least we can try.
> > > > > - *
> > > > > - * We don't have any assertions on open since the user may not even have
> > > > > - * snd_hda_intel loaded, which is not a problem.
> > > > > - */
> > > > > -void igt_pm_enable_audio_runtime_pm(void)
> > > > > +static int __igt_pm_enable_audio_runtime_pm(void)
> > > > >  {
> > > > >       char *path = NULL;
> > > > >       struct dirent *de;
> > > > >       DIR *dir;
> > > > > +     int err;
> > > > >       int fd;
> > > > >  
> > > > > -     /* Check if already enabled. */
> > > > > -     if (__igt_pm_audio_runtime_power_save[0])
> > > > > -             return;
> > > > > -
> > > > >       dir = opendir("/sys/class/sound");
> > > > >       if (!dir)
> > > > > -             return;
> > > > > +             return 0;
> > > > >  
> > > > >       /* Find PCI device claimed by snd_hda_intel and tied to i915. */
> > > > >       while ((de = readdir(dir))) {
> > > > > @@ -196,18 +182,17 @@ void igt_pm_enable_audio_runtime_pm(void)
> > > > >                                   de->d_name));
> > > > >  
> > > > >               igt_debug("Audio device path is %s\n", path);
> > > > > -
> > > > >               break;
> > > > >       }
> > > > 
> > > > Could close dir while at it.
> > > 
> > > Good point.
> > >  
> > > > Reviewed-by: Imre Deak <imre.deak@intel.com>
> > > > 
> > > > This time the catch was that snd_hda_intel's second half of probe is run
> > > > from a scheduled work. (even though the first half returns synchronously
> > > > due to modprobe being synchronous as you found last time)
> > > 
> > > The results from the CI didn't look too promising, but I'm a bit dubious
> > > as to what exactly was tested and so pushed anyway ;)
> > > 
> > > What next if it still doesn't discover an audio device?
> > 
> > We need to register the i915 audio component (in its current form or
> > just a stub version) even with disable_display=1, so that the audio
> > driver can continue its own probing (before timing out on the 10sec
> > wait for the audio component). Atm the
> > 
> > if (INTEL_INFO(dev_priv)->num_pipes == 0)
> >         return;
> > 
> > in i915_audio_component_init() prevents the registration.
> 
> Right, that's the other question: do we need that at all...
>  
> > > Hmm, is the /sys/class/sound construction async? I was assuming it was
> > > constructed by the parent snd module long before sna_hda_intel does it
> > > thing.
> > 
> > AFAICS, azx_probe_continue() is the scheduled work and it will do
> > snd_card_register()->device_add() which will add the sysfs entries.
> 
> As far as the probe we do here, the key question is whether
> opendir("/sys/class/sound") will succeed after modprobe but before the
> devices have been constructed. We using that as a predicate as to
> whether there are any sound modules to wait for.

Ok, /sys/class/sound appears immediately after modprobe, I meant
/sys/class/sound/hwC* which appears only after component binding. In any
case both dirs are polled for after your igt patch so that part is ok
now imo.

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

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

* Re: [igt-dev] [PATCH i-g-t] lib: Poll for snd_hda_intel discovery
@ 2018-08-17 12:32           ` Imre Deak
  0 siblings, 0 replies; 16+ messages in thread
From: Imre Deak @ 2018-08-17 12:32 UTC (permalink / raw)
  To: Chris Wilson; +Cc: igt-dev, intel-gfx, Takashi Iwai

On Fri, Aug 17, 2018 at 10:48:29AM +0100, Chris Wilson wrote:
> Quoting Imre Deak (2018-08-17 10:38:01)
> > On Fri, Aug 17, 2018 at 10:24:30AM +0100, Chris Wilson wrote:
> > > Quoting Imre Deak (2018-08-17 10:14:51)
> > > > On Thu, Aug 16, 2018 at 07:01:36PM +0100, Chris Wilson wrote:
> > > > > Loading the sounds modules is asynchronous with the sysfs device
> > > > > hierarchy being instantiated sometime after modprobe returns. As such
> > > > > while we are probing for the sound device, poll a few times to
> > > > > accommodate the async discovery.
> > > > > 
> > > > > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > > > > Cc: Imre Deak <imre.deak@intel.com>
> > > > > Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
> > > > 
> > > > > ---
> > > > >  lib/igt_pm.c | 65 +++++++++++++++++++++++++++++++++-------------------
> > > > >  1 file changed, 41 insertions(+), 24 deletions(-)
> > > > > 
> > > > > diff --git a/lib/igt_pm.c b/lib/igt_pm.c
> > > > > index 6e96db22b..f82707231 100644
> > > > > --- a/lib/igt_pm.c
> > > > > +++ b/lib/igt_pm.c
> > > > > @@ -138,31 +138,17 @@ static void strchomp(char *str)
> > > > >               str[len - 1] = 0;
> > > > >  }
> > > > >  
> > > > > -/**
> > > > > - * igt_pm_enable_audio_runtime_pm:
> > > > > - *
> > > > > - * We know that if we don't enable audio runtime PM, snd_hda_intel will never
> > > > > - * release its power well refcount, and we'll never reach the LPSP state.
> > > > > - * There's no guarantee that it will release the power well if we enable
> > > > > - * runtime PM, but at least we can try.
> > > > > - *
> > > > > - * We don't have any assertions on open since the user may not even have
> > > > > - * snd_hda_intel loaded, which is not a problem.
> > > > > - */
> > > > > -void igt_pm_enable_audio_runtime_pm(void)
> > > > > +static int __igt_pm_enable_audio_runtime_pm(void)
> > > > >  {
> > > > >       char *path = NULL;
> > > > >       struct dirent *de;
> > > > >       DIR *dir;
> > > > > +     int err;
> > > > >       int fd;
> > > > >  
> > > > > -     /* Check if already enabled. */
> > > > > -     if (__igt_pm_audio_runtime_power_save[0])
> > > > > -             return;
> > > > > -
> > > > >       dir = opendir("/sys/class/sound");
> > > > >       if (!dir)
> > > > > -             return;
> > > > > +             return 0;
> > > > >  
> > > > >       /* Find PCI device claimed by snd_hda_intel and tied to i915. */
> > > > >       while ((de = readdir(dir))) {
> > > > > @@ -196,18 +182,17 @@ void igt_pm_enable_audio_runtime_pm(void)
> > > > >                                   de->d_name));
> > > > >  
> > > > >               igt_debug("Audio device path is %s\n", path);
> > > > > -
> > > > >               break;
> > > > >       }
> > > > 
> > > > Could close dir while at it.
> > > 
> > > Good point.
> > >  
> > > > Reviewed-by: Imre Deak <imre.deak@intel.com>
> > > > 
> > > > This time the catch was that snd_hda_intel's second half of probe is run
> > > > from a scheduled work. (even though the first half returns synchronously
> > > > due to modprobe being synchronous as you found last time)
> > > 
> > > The results from the CI didn't look too promising, but I'm a bit dubious
> > > as to what exactly was tested and so pushed anyway ;)
> > > 
> > > What next if it still doesn't discover an audio device?
> > 
> > We need to register the i915 audio component (in its current form or
> > just a stub version) even with disable_display=1, so that the audio
> > driver can continue its own probing (before timing out on the 10sec
> > wait for the audio component). Atm the
> > 
> > if (INTEL_INFO(dev_priv)->num_pipes == 0)
> >         return;
> > 
> > in i915_audio_component_init() prevents the registration.
> 
> Right, that's the other question: do we need that at all...
>  
> > > Hmm, is the /sys/class/sound construction async? I was assuming it was
> > > constructed by the parent snd module long before sna_hda_intel does it
> > > thing.
> > 
> > AFAICS, azx_probe_continue() is the scheduled work and it will do
> > snd_card_register()->device_add() which will add the sysfs entries.
> 
> As far as the probe we do here, the key question is whether
> opendir("/sys/class/sound") will succeed after modprobe but before the
> devices have been constructed. We using that as a predicate as to
> whether there are any sound modules to wait for.

Ok, /sys/class/sound appears immediately after modprobe, I meant
/sys/class/sound/hwC* which appears only after component binding. In any
case both dirs are polled for after your igt patch so that part is ok
now imo.

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

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

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

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-16 18:01 [PATCH i-g-t] lib: Poll for snd_hda_intel discovery Chris Wilson
2018-08-16 18:01 ` [igt-dev] " Chris Wilson
2018-08-16 18:19 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2018-08-16 22:15 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2018-08-17  9:14 ` [PATCH i-g-t] " Imre Deak
2018-08-17  9:14   ` [igt-dev] " Imre Deak
2018-08-17  9:24   ` Chris Wilson
2018-08-17  9:24     ` [igt-dev] " Chris Wilson
2018-08-17  9:38     ` Imre Deak
2018-08-17  9:38       ` [igt-dev] " Imre Deak
2018-08-17  9:48       ` Chris Wilson
2018-08-17  9:48         ` [Intel-gfx] " Chris Wilson
2018-08-17 12:32         ` Imre Deak
2018-08-17 12:32           ` [igt-dev] " Imre Deak
2018-08-17 10:00       ` Takashi Iwai
2018-08-17 10:00         ` [igt-dev] " Takashi Iwai

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.