From patchwork Tue Sep 4 08:06:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10586947 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 5C1F8920 for ; Tue, 4 Sep 2018 08:07:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40A6928F28 for ; Tue, 4 Sep 2018 08:07:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3519328FE6; Tue, 4 Sep 2018 08:07:10 +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 CC73028F28 for ; Tue, 4 Sep 2018 08:07:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0C23F6E343; Tue, 4 Sep 2018 08:07:09 +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 CB18D89CA8; Tue, 4 Sep 2018 08:07:07 +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 13537473-1500050 for multiple; Tue, 04 Sep 2018 09:06:59 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Tue, 4 Sep 2018 09:06:59 +0100 Message-Id: <20180904080659.10547-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.19.0.rc1 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t] igt/pm_rps: Wait for the load-helper to signal receipt of command 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: igt-dev@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Actually wait for the load-helper to complete it switch over to the new load by using a pipe() between the two. References: https://bugs.freedesktop.org/show_bug.cgi?id=102250 Signed-off-by: Chris Wilson Reviewed-by: Katarzyna Dec --- tests/pm_rps.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/pm_rps.c b/tests/pm_rps.c index 202132b1c..8dff5bbc5 100644 --- a/tests/pm_rps.c +++ b/tests/pm_rps.c @@ -181,8 +181,10 @@ enum load { }; static struct load_helper { + int link; enum load load; bool exit; + bool signal; struct igt_helper_process igt_proc; } lh; @@ -190,6 +192,7 @@ static void load_helper_signal_handler(int sig) { if (sig == SIGUSR2) { lh.load = !lh.load; + lh.signal = true; igt_debug("Switching background load to %s\n", lh.load ? "high" : "low"); } else lh.exit = true; @@ -199,6 +202,8 @@ static void load_helper_signal_handler(int sig) #define LOAD_HELPER_BO_SIZE (16*1024*1024) static void load_helper_set_load(enum load load) { + bool dummy; + igt_assert(lh.igt_proc.running); if (lh.load == load) @@ -207,11 +212,14 @@ static void load_helper_set_load(enum load load) lh.load = load; kill(lh.igt_proc.pid, SIGUSR2); - usleep(1000); /* wait for load-helper to switch */ + /* wait for load-helper to switch */ + igt_assert_eq(read(lh.link, &dummy, sizeof(dummy)), sizeof(dummy)); } static void load_helper_run(enum load load) { + int link[2]; + /* * FIXME fork helpers won't get cleaned up when started from within a * subtest, so handle the case where it sticks around a bit too long. @@ -225,6 +233,10 @@ static void load_helper_run(enum load load) lh.exit = false; lh.load = load; + lh.signal = false; + + pipe(link); + lh.link = link[1]; igt_fork_helper(&lh.igt_proc) { igt_spin_t *spin[2] = {}; @@ -249,6 +261,11 @@ static void load_helper_run(enum load load) spin[0] = spin[1]; spin[lh.load == HIGH] = __igt_spin_batch_new(drm_fd); + + if (lh.signal) { + write(lh.link, &lh.signal, sizeof(lh.signal)); + lh.signal = false; + } } handle = spin[0]->handle; @@ -274,6 +291,8 @@ static void load_helper_run(enum load load) igt_spin_batch_free(drm_fd, spin[1]); igt_spin_batch_free(drm_fd, spin[0]); } + + lh.link = link[0]; } static void load_helper_stop(void)