From patchwork Fri Mar 2 08:49:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 10253635 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 0209C60211 for ; Fri, 2 Mar 2018 08:50:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E942C288B8 for ; Fri, 2 Mar 2018 08:50:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD86E288D0; Fri, 2 Mar 2018 08:50: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=-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 60CBD288B8 for ; Fri, 2 Mar 2018 08:50:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 282626EE06; Fri, 2 Mar 2018 08:50:09 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4D8E36EE06 for ; Fri, 2 Mar 2018 08:50:08 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id t6so1613573wmt.5 for ; Fri, 02 Mar 2018 00:50:08 -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:in-reply-to:references; bh=mI/iJJcnnF2RIpkdYFtE15DUUtAMzISg0273gLH5L0E=; b=w6zeHjTjNyrUCsjCQIwGkVGetHLDQbuV2bzMZvd/SEi3JwG5r//SYyLJIWjwmxFUp7 Ql20ZzmMA8c//qbeyc7N5uY7JLQHPT1HhEMLJ2AP369XrHFyB9i+2T1AtrIcXA2RZ2rE jimqcenK3S9aVx28JAVQyz/lKSk1kscp3gvImYBXn/clHvdB2T9uElD5ICk7gfnzBAov JtNo1VnoOvTZVsIVVWJ1S0kFKabPzgmhs10b0++JpGLe+YM2fkW7o2qpepcIH1VrduLQ yItXT9Cxa7O8lTWHi1XIfI/GbWSKdLibYCfZgqa4dr8dvD6RUj7rYbBaNgv/cF+nrH9f 6xug== 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:in-reply-to :references; bh=mI/iJJcnnF2RIpkdYFtE15DUUtAMzISg0273gLH5L0E=; b=NWiKYpXk6Zc7u3LvQPwZ6jLBAmBErjApjZVrrUn8ANEhw64uBiejf5tCr69Oo/KnGf mtlgzDS3v8Z/X5K20E/NegA3ZhyrxIOqfkGBv1EPkDfDSjC5gyQ+xItqTDA6rVSrwCUd aIvois1+jVKiR+KGG8hlKpnQQ6l1DHpklNKvitSRa7jRSOHeWM0xdbyTI9h7FcdAXJCs KpK7BBcDTQSAoILWzJqzeQuiP/8mc193yHcm5IWUMvCfzp6SkiLqz1c1gOIPHHow5+lZ W1Zb75El5bzyHi5h5Ipu+ZFtjgfmzU03qdGjk2XG+VmMdKub+dwScrUYr7KlpCQQ3JWV FT6w== X-Gm-Message-State: AElRT7HVgcbyxpkBwNaequ34eJKZ1LtcpfRRZOF+9ASx20zgKobYJ/53 wDbgRpy4t0TidkRZ+A+yZ5AcVw== X-Google-Smtp-Source: AG47ELuOECbCewQ90yXWDWF/a3Bdcu7Nppsv8iwesDHqPSxe5fpXW7PaYQVCq4YjL+KaCSQba2ODBA== X-Received: by 10.28.228.197 with SMTP id b188mr912809wmh.65.1519980606806; Fri, 02 Mar 2018 00:50:06 -0800 (PST) Received: from localhost.localdomain ([95.146.144.186]) by smtp.gmail.com with ESMTPSA id l11sm4775314wrg.71.2018.03.02.00.50.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Mar 2018 00:50:06 -0800 (PST) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Fri, 2 Mar 2018 08:49:58 +0000 Message-Id: <20180302084958.23566-1-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180301164849.21430-1-tvrtko.ursulin@linux.intel.com> References: <20180301164849.21430-1-tvrtko.ursulin@linux.intel.com> Subject: [Intel-gfx] [CI i-g-t v3] 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: Do not assert from the threads. v3: HACK Signed-off-by: Tvrtko Ursulin --- tests/gen7_forcewake_mt.c | 69 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 64 insertions(+), 5 deletions(-) diff --git a/tests/gen7_forcewake_mt.c b/tests/gen7_forcewake_mt.c index 07320ef9e8ac..d8a369b0e6ff 100644 --- a/tests/gen7_forcewake_mt.c +++ b/tests/gen7_forcewake_mt.c @@ -29,6 +29,7 @@ * Testcase: Exercise a suspect workaround required for FORCEWAKE_MT * */ +#pragma GCC optimize ("O0") #include "igt.h" #include @@ -44,6 +45,7 @@ IGT_TEST_DESCRIPTION("Exercise a suspect workaround required for" struct thread { pthread_t thread; + bool run; void *mmio; int fd; int bit; @@ -106,14 +108,26 @@ 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) { + uint32_t reg; + *forcewake_mt = bit << 16 | bit; - igt_assert(*forcewake_mt & bit); + reg = *forcewake_mt; + if (!(reg & bit)) { + igt_warn("Bit %u did not set! (val=%x)\n", t->bit, reg); + return (void *)-1; + } *forcewake_mt = bit << 16; - igt_assert((*forcewake_mt & bit) == 0); + reg = *forcewake_mt; + if (reg & bit) { + igt_warn("Bit %u did not clear! (val=%x)\n", + t->bit, reg); + return (void *)-1; + } } return NULL; @@ -121,13 +135,39 @@ 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++) { + uint32_t val = 1 << bit; + uint32_t reg; + + *forcewake_mt = val << 16; + reg = *forcewake_mt; + if (reg & val) + igt_warn("Failed to restore bit %u! (val=%x)\n", + bit, reg); + } +} + igt_simple_main { struct thread t[16]; + bool success = true; 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 +241,23 @@ igt_simple_main usleep(1000); } + + for (i = 2; i < 16; i++) + t[i].run = false; + + for (i = 2; i < 16; i++) { + void *threadret = NULL; + int ret; + + ret = pthread_join(t[i].thread, &threadret); + if (ret) { + igt_warn("failed to join thread%u! (%d)\n", i, ret); + success = false; + } else if (threadret) { + igt_warn("thread%u failed! (%p)\n", i, threadret); + success = false; + } + } + + igt_assert(success); }