From patchwork Tue Mar 27 11:02:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10309729 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 EC8D1600F6 for ; Tue, 27 Mar 2018 11:02:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B840C29CAB for ; Tue, 27 Mar 2018 11:02:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B611C29CBF; Tue, 27 Mar 2018 11:02:28 +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.2 required=2.0 tests=BAYES_00, 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 6709429CCF for ; Tue, 27 Mar 2018 11:02:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A68326E49A; Tue, 27 Mar 2018 11:02:18 +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 A407A6E49A for ; Tue, 27 Mar 2018 11:02:17 +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 11172290-1500050 for multiple; Tue, 27 Mar 2018 12:02:05 +0100 Received: by haswell.alporthouse.com (sSMTP sendmail emulation); Tue, 27 Mar 2018 12:02:05 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Tue, 27 Mar 2018 12:02:04 +0100 Message-Id: <20180327110204.21160-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.16.3 X-Originating-IP: 78.156.65.138 X-Country: code=GB country="United Kingdom" ip=78.156.65.138 Subject: [Intel-gfx] [PATCH] drm/i915: Check all requests have been retired on switching to kernel context 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: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP When asserting the switch to the kernel context is complete, we know that the requests should also have been retired. We can assert that this is so in order to give us some more insight into the state of affairs should we ever see a bug along this path, such as: <4>[ 206.836931] WARN_ON(dev_priv->gt.awake) <4>[ 206.836982] WARNING: CPU: 1 PID: 105 at drivers/gpu/drm/i915/i915_gem.c:4966 i915_gem_suspend+0x10b/0x130 [i915] <4>[ 206.836983] Modules linked in: vgem snd_hda_codec_analog snd_hda_codec_generic i915 snd_hda_intel snd_hda_codec snd_hwdep coretemp snd_hda_core snd_pcm lpc_ich mei_me e1000e mei <4>[ 206.836992] CPU: 1 PID: 105 Comm: kworker/u16:7 Tainted: G U 4.16.0-rc6-g94f5d9189e61-nodebug_1+ #1 <4>[ 206.836993] Hardware name: Dell Inc. OptiPlex 755 /0PU052, BIOS A08 02/19/2008 <4>[ 206.836997] Workqueue: events_unbound async_run_entry_fn <4>[ 206.837017] RIP: 0010:i915_gem_suspend+0x10b/0x130 [i915] <4>[ 206.837018] RSP: 0000:ffffada54037fd60 EFLAGS: 00010282 <4>[ 206.837019] RAX: 000000000000001b RBX: ffff9901f361faa8 RCX: 0000000000000001 <4>[ 206.837020] RDX: 0000000080000001 RSI: 0000000000000092 RDI: 00000000ffffffff <4>[ 206.837021] RBP: ffff9901f3618000 R08: 000000000000001b R09: 000000000000001b <4>[ 206.837022] R10: 0000000000000040 R11: 00000000001c8b58 R12: ffff9901f361d648 <4>[ 206.837023] R13: 0000000000000000 R14: 0000000000000002 R15: ffffffffa80c42c9 <4>[ 206.837024] FS: 0000000000000000(0000) GS:ffff9901fd240000(0000) knlGS:0000000000000000 <4>[ 206.837025] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 <4>[ 206.837025] CR2: 00005613fbbfef76 CR3: 0000000078710000 CR4: 00000000000006e0 <4>[ 206.837026] Call Trace: <4>[ 206.837046] i915_drm_suspend+0x62/0x160 [i915] <4>[ 206.837050] pci_pm_suspend+0x7a/0x1d0 <4>[ 206.837052] ? pci_pm_suspend_noirq+0x290/0x290 <4>[ 206.837054] dpm_run_callback+0x4d/0x180 <4>[ 206.837055] __device_suspend+0xf6/0x4b0 <4>[ 206.837057] async_suspend+0x1a/0x90 <4>[ 206.837058] async_run_entry_fn+0x31/0x140 <4>[ 206.837060] process_one_work+0x1c8/0x3d0 <4>[ 206.837062] worker_thread+0x47/0x3f0 <4>[ 206.837064] kthread+0xf5/0x130 <4>[ 206.837066] ? process_one_work+0x3d0/0x3d0 <4>[ 206.837067] ? _kthread_create_on_node+0x40/0x40 <4>[ 206.837069] ret_from_fork+0x35/0x40 <4>[ 206.837071] Code: 89 ef e8 89 fe ff ff 48 89 ef e8 31 e7 fd ff 48 83 c4 08 31 c0 5b 5d c3 48 c7 c6 7f b5 56 c0 48 c7 c7 1c b5 56 c0 e8 b5 1b bc e6 <0f> 0b eb bc 48 c7 c6 a0 85 57 c0 48 c7 c7 1c b5 56 c0 e8 9e 1b <4>[ 206.837115] WARNING: CPU: 1 PID: 105 at drivers/gpu/drm/i915/i915_gem.c:4966 i915_gem_suspend+0x10b/0x130 [i915] Signed-off-by: Chris Wilson --- drivers/gpu/drm/i915/i915_gem.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 9650a7b10c5f..9b6f995b658f 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -4894,6 +4894,8 @@ static void assert_kernel_context_is_current(struct drm_i915_private *i915) GEM_BUG_ON(__i915_gem_active_peek(&engine->timeline->last_request)); GEM_BUG_ON(engine->last_retired_context != kernel_context); } + + GEM_BUG_ON(i915->gt.active_requests); } void i915_gem_sanitize(struct drm_i915_private *i915)