igt-dev.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: igt-dev@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org, Imre Deak <imre.deak@linux.com>
Subject: [Intel-gfx] [PATCH i-g-t v2] lib/pm: Wait a little for sound module load to complete
Date: Mon,  3 Sep 2018 14:02:00 +0100	[thread overview]
Message-ID: <20180903130200.30736-1-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <20180903125110.26306-1-chris@chris-wilson.co.uk>

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@chris-wilson.co.uk>
Cc: Imre Deak <imre.deak@linux.com>
---
 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

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

  parent reply	other threads:[~2018-09-03 13:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-03 12:51 [Intel-gfx] [PATCH i-g-t] lib/pm: Wait a little for sound module load to complete Chris Wilson
2018-09-03 13:01 ` [igt-dev] " Chris Wilson
2018-09-03 13:02 ` Chris Wilson [this message]
2018-09-04 10:00   ` [igt-dev] [PATCH i-g-t v2] " Imre Deak
2018-09-04 10:06     ` Chris Wilson
2018-09-03 13:11 ` [igt-dev] ✗ Fi.CI.BAT: failure for " Patchwork
2018-09-03 13:27 ` [igt-dev] ✓ Fi.CI.BAT: success for lib/pm: Wait a little for sound module load to complete (rev2) Patchwork
2018-09-03 13:32 ` [igt-dev] [PATCH i-g-t v3] lib/pm: Wait a little for sound module load to complete Chris Wilson
2018-09-03 14:10 ` [igt-dev] ✓ Fi.CI.BAT: success for lib/pm: Wait a little for sound module load to complete (rev3) Patchwork
2018-09-03 18:16 ` [igt-dev] ✗ Fi.CI.IGT: failure for lib/pm: Wait a little for sound module load to complete Patchwork
2018-09-03 19:00 ` [igt-dev] ✗ Fi.CI.IGT: failure for lib/pm: Wait a little for sound module load to complete (rev2) Patchwork
2018-09-03 20:32 ` [igt-dev] ✓ Fi.CI.IGT: success for lib/pm: Wait a little for sound module load to complete (rev3) Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180903130200.30736-1-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=imre.deak@linux.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).