From patchwork Fri Sep 7 08:41:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10591893 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 341FD112B for ; Fri, 7 Sep 2018 08:42:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21F312AC99 for ; Fri, 7 Sep 2018 08:42:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 14CDB2AD8A; Fri, 7 Sep 2018 08:42:08 +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 BBFD82AC99 for ; Fri, 7 Sep 2018 08:42:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AEE7E6E861; Fri, 7 Sep 2018 08:42:06 +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 ED3F56E861; Fri, 7 Sep 2018 08:42:04 +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 13633257-1500050 for multiple; Fri, 07 Sep 2018 09:41:49 +0100 From: Chris Wilson To: igt-dev@lists.freedesktop.org Date: Fri, 7 Sep 2018 09:41:51 +0100 Message-Id: <20180907084151.10085-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.19.0.rc2 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t] lib: Cancel all outstanding requests at the end of a test 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 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Quite often on catastrophic failure the test leaves a long queue of unterminated batches pending execution. Each runs until hangcheck fires and skips onto the next, leaving us waiting for a very long time at test exit. On older kernels, this gracefully degrades into the existing mechanism. Signed-off-by: Chris Wilson Reviewed-by: Antonio Argenziano --- lib/drmtest.c | 25 +++++++++++++++++++------ lib/igt_debugfs.h | 12 ++++++++++++ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/lib/drmtest.c b/lib/drmtest.c index bfa2e0f0a..fee9d33ad 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -302,22 +302,35 @@ static int __drm_open_driver_render(int chipset) static int at_exit_drm_fd = -1; static int at_exit_drm_render_fd = -1; -static void quiescent_gpu_at_exit(int sig) +static void __cancel_work_at_exit(int fd) +{ + igt_terminate_spin_batches(); /* for older kernels */ + + igt_drop_caches_set(fd, + /* cancel everything */ + DROP_RESET_ACTIVE | DROP_RESET_SEQNO | + /* cleanup */ + DROP_ACTIVE | DROP_RETIRE | DROP_IDLE | DROP_FREED); +} + +static void cancel_work_at_exit(int sig) { if (at_exit_drm_fd < 0) return; - gem_quiescent_gpu(at_exit_drm_fd); + __cancel_work_at_exit(at_exit_drm_fd); + close(at_exit_drm_fd); at_exit_drm_fd = -1; } -static void quiescent_gpu_at_exit_render(int sig) +static void cancel_work_at_exit_render(int sig) { if (at_exit_drm_render_fd < 0) return; - gem_quiescent_gpu(at_exit_drm_render_fd); + __cancel_work_at_exit(at_exit_drm_render_fd); + close(at_exit_drm_render_fd); at_exit_drm_render_fd = -1; } @@ -369,7 +382,7 @@ int drm_open_driver(int chipset) gem_quiescent_gpu(fd); at_exit_drm_fd = __drm_open_driver(chipset); - igt_install_exit_handler(quiescent_gpu_at_exit); + igt_install_exit_handler(cancel_work_at_exit); } } @@ -418,7 +431,7 @@ int drm_open_driver_render(int chipset) at_exit_drm_render_fd = __drm_open_driver(chipset); if(chipset & DRIVER_INTEL){ gem_quiescent_gpu(fd); - igt_install_exit_handler(quiescent_gpu_at_exit_render); + igt_install_exit_handler(cancel_work_at_exit_render); } return fd; diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h index ff8612dc6..9f81be0a2 100644 --- a/lib/igt_debugfs.h +++ b/lib/igt_debugfs.h @@ -190,6 +190,18 @@ void igt_require_hpd_storm_ctl(int fd); * Flush the driver's idle_worker, releasing internal caches and wakerefs. */ #define DROP_IDLE 0x40 +/** + * DROP_RESET_ACTIVE: + * + * Cancel all outstanding requests by forcing a gpu reset + */ +#define DROP_RESET_ACTIVE 0x80 +/** + * DROP_RESET_SEQNO: + * + * Reset the global request seqno counter back to 0 + */ +#define DROP_RESET_SEQNO 0x100 /** * DROP_ALL: *