[igt-dev] [PATCH i-g-t v2] lib/pm: Wait a little for sound module load to complete

Imre Deak imre.deak at intel.com
Tue Sep 4 10:00:26 UTC 2018


On Mon, Sep 03, 2018 at 02:02:00PM +0100, Chris Wilson wrote:
> Sometimes we may probe the sound module as it is still being registered
> and its debugfs not yet fully populated. If we do not find a file we
> expect to exist, sleep a little and check again.
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107801
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Imre Deak <imre.deak at linux.com>

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

A different delay is when the snd_hda_intel's probing takes more than 5
sec (as you noticed in [1]), should we increase the timeout in
igt_pm_enable_audio_runtime_pm() for that as well?

[1] https://intel-gfx-ci.01.org/tree/drm-tip/IGT_4618/fi-cnl-psr/igt@pm_rpm@module-reload.html

> ---
>  lib/igt_pm.c | 22 +++++++++++++++-------
>  1 file changed, 15 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/igt_pm.c b/lib/igt_pm.c
> index 339a51e6f..c18bb87c6 100644
> --- a/lib/igt_pm.c
> +++ b/lib/igt_pm.c
> @@ -154,20 +154,28 @@ static int __igt_pm_enable_audio_runtime_pm(void)
>  	while ((de = readdir(dir))) {
>  		const char *match = "hwC";
>  		char buf[32] = { }; /* for Valgrind */
> -		char *tmp;
> +		int loops = 500;
> +		int base;
>  		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));
> +		base = openat(dirfd(dir), de->d_name, O_RDONLY);
> +		igt_assert_fd(base);
> +
> +		do {
> +			fd = open(base, "vendor_name", O_RDONLY);
> +			if (fd < 0) /* module is still loading? */
> +				usleep(1000);
> +			else
> +				break;
> +		} while (--loops);
> +		close(base);
> +		if (fd < 0)
> +			continue;
>  
> -		fd = open(tmp, O_RDONLY);
> -		free(tmp);
> -		igt_assert_fd(fd);
>  		ret = read(fd, buf, sizeof(buf));
>  		close(fd);
>  		igt_assert(ret > 0);
> -- 
> 2.19.0.rc1
> 
> _______________________________________________
> igt-dev mailing list
> igt-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev


More information about the igt-dev mailing list