From patchwork Mon Sep 3 13:02:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10585823 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AA014139B for ; Mon, 3 Sep 2018 13:02:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A04D296F2 for ; Mon, 3 Sep 2018 13:02:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E13E29785; Mon, 3 Sep 2018 13:02:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 41DA2296F2 for ; Mon, 3 Sep 2018 13:02:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A8DFC6E218; Mon, 3 Sep 2018 13:02:12 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1BAB66E218; Mon, 3 Sep 2018 13:02:10 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 13516641-1500050 for multiple; Mon, 03 Sep 2018 14:02:00 +0100 From: Chris Wilson To: igt-dev@lists.freedesktop.org Date: Mon, 3 Sep 2018 14:02:00 +0100 Message-Id: <20180903130200.30736-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.19.0.rc1 In-Reply-To: <20180903125110.26306-1-chris@chris-wilson.co.uk> References: <20180903125110.26306-1-chris@chris-wilson.co.uk> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2] lib/pm: Wait a little for sound module load to complete X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org, Imre Deak Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Imre Deak Reviewed-by: Imre Deak --- 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);