summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2018-09-03 13:47:49 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2018-09-04 11:07:24 +0100
commit925fbed79fd71ff998a962f12f7a8bb18c06abd7 (patch)
tree4638be268a2360fc832de577f74f803e359448b7
parent4fea665b29622baf1692e7f949fcfb8ed993fa36 (diff)
lib/pm: Wait a little for sound module load to complete
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@intel.linux.com> Reviewed-by: Imre Deak <imre.deak@intel.linux.com>
-rw-r--r--lib/igt_pm.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index b1f359d8..e86fa4a4 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 = openat(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);