From patchwork Thu Mar 1 16:48:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 10251991 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 81547602B5 for ; Thu, 1 Mar 2018 16:49:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 712FC2853A for ; Thu, 1 Mar 2018 16:49:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 659B128688; Thu, 1 Mar 2018 16:49:04 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 6AF5828643 for ; Thu, 1 Mar 2018 16:49:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A7FEC6ED02; Thu, 1 Mar 2018 16:49:02 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 58B1D6ED00 for ; Thu, 1 Mar 2018 16:49:00 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id t74so13454419wme.3 for ; Thu, 01 Mar 2018 08:49:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ursulin-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=AXwYYWgaFk2WIP6WuBuPXk2AqbFQHmKon3Dzg0M/xwk=; b=In1mAVxM2IANfST11FIIgjKgo/3O5TdqPZYObCmZpIl9pyccRlkPoAcj3XZ2WcQfKe mUtfdvGNgY9/y96QIdzfyRHty9jGlQSNz8mc9nxHPOVf2lIKYwLcNVXVroL6/W0CU+pk ASXGHqDOiwHL+oSqPnEU8mwBd+oeCK9bikdvgSTpNX+cMTzTgSh54duWjejhAU5RuJmM NhCDy3qFAso6zRCgJK3qEK2lLfO126Pa5ss6zn5aVEQPsxGhCMwNfmC+ZYv7Gev1tCZn hx/0pxMO8F2xSr27toLdk5EVl0MRM5fnyHZHC2M5B8Ffi2BFltCuy8sqJbYCnQi2cGNH d59w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=AXwYYWgaFk2WIP6WuBuPXk2AqbFQHmKon3Dzg0M/xwk=; b=pPBxzhbjDag/BWTd4uZXppytuwPi5DnqY65Mj93DSvxilvtIrzh9G787jXnfWkSxvC Y5dIUa88CzNFzmpsSVHxVXFkZXFBmNInHpbJ8A/PXj8YE7t74oM7HBlAAhHzLoR6BuHv CTnKei4N4AXNQ5jS9Rb/YwV3wGEwx34gTbO5wAvKwpwAopM8vHxwGlUUrSDaEm2MAA3C GfW38Hv1moeCKZaMROBSYGJeLWjV2rTjU5E8BvlTn+EqPu0q/uLa7rewZ+VsQtGe2YTE ZKkFwD0tyYz4iIUPXr1WtrR/u0UI8HTSvQCl/+mq3zD57/14yMiLO3mJD57PVPuWS4zQ k8cA== X-Gm-Message-State: AElRT7HzrTS/dTrSZDknIFPt1UvP95E3xnaZ7rQjKYbt8uA5cA5yp9Ib 3qohbBi6IXIA5i3vvS+/8jZhJgRI X-Google-Smtp-Source: AG47ELv9YczlDITNjXwhVHXIASsLHxzKMdSEA9Qr6vdrz1kvgWi7ZYitRbkbAaActcVCs5KZxjAydA== X-Received: by 10.28.180.132 with SMTP id d126mr2548660wmf.93.1519922938989; Thu, 01 Mar 2018 08:48:58 -0800 (PST) Received: from localhost.localdomain ([95.146.144.186]) by smtp.gmail.com with ESMTPSA id s2sm20259185wmf.0.2018.03.01.08.48.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Mar 2018 08:48:58 -0800 (PST) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Thu, 1 Mar 2018 16:48:49 +0000 Message-Id: <20180301164849.21430-1-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.14.1 Subject: [Intel-gfx] [CI i-g-t] don't look 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 MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Tvrtko Ursulin 1. We need to tell the compiler mmio access cannot be optimized away (volatile). 2. We need to ensure we don't exit with forcewake left on. Signal threads to exit in a controlled fashion and install atexit handler just in case. v2: HACK Signed-off-by: Tvrtko Ursulin --- tests/gen7_forcewake_mt.c | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/tests/gen7_forcewake_mt.c b/tests/gen7_forcewake_mt.c index 07320ef9e8ac..04a93afc839f 100644 --- a/tests/gen7_forcewake_mt.c +++ b/tests/gen7_forcewake_mt.c @@ -30,6 +30,8 @@ * */ +#pragma GCC optimize ("O0") + #include "igt.h" #include #include @@ -44,6 +46,7 @@ IGT_TEST_DESCRIPTION("Exercise a suspect workaround required for" struct thread { pthread_t thread; + bool run; void *mmio; int fd; int bit; @@ -106,10 +109,11 @@ static void *igfx_get_mmio(void) static void *thread(void *arg) { struct thread *t = arg; - uint32_t *forcewake_mt = (uint32_t *)((char *)t->mmio + FORCEWAKE_MT); + volatile uint32_t *forcewake_mt = + (uint32_t *)((char *)t->mmio + FORCEWAKE_MT); uint32_t bit = 1 << t->bit; - while (1) { + while (t->run) { *forcewake_mt = bit << 16 | bit; igt_assert(*forcewake_mt & bit); *forcewake_mt = bit << 16; @@ -121,13 +125,33 @@ static void *thread(void *arg) #define MI_STORE_REGISTER_MEM (0x24<<23) +static void *mmio_base; + +static void cleanup(int sig) +{ + volatile uint32_t *forcewake_mt = + (uint32_t *)((char *)mmio_base + FORCEWAKE_MT); + unsigned int bit; + + for (bit = 2; bit < 16; bit++) { + *forcewake_mt = (1 << bit) << 16; + if (*forcewake_mt & (1 << bit)) + igt_warn("Failed to restore bit %u!\n", bit); + } +} + igt_simple_main { struct thread t[16]; int i; + mmio_base = igfx_get_mmio(); + t[0].fd = drm_open_driver(DRIVER_INTEL); - t[0].mmio = igfx_get_mmio(); + t[0].run = true; + t[0].mmio = mmio_base; + + igt_install_exit_handler(cleanup); for (i = 2; i < 16; i++) { t[i] = t[0]; @@ -201,4 +225,10 @@ igt_simple_main usleep(1000); } + + for (i = 2; i < 16; i++) + t[i].run = false; + + for (i = 2; i < 16; i++) + pthread_join(t[i].thread, NULL); }