From patchwork Thu Jul 24 13:23:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 4618171 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3047AC0514 for ; Thu, 24 Jul 2014 13:23:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 43D7A2010C for ; Thu, 24 Jul 2014 13:23:24 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 59E8A20142 for ; Thu, 24 Jul 2014 13:23:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6368C6E6FB; Thu, 24 Jul 2014 06:23:22 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [87.106.93.118]) by gabe.freedesktop.org (Postfix) with ESMTP id 41C8E6E6F7; Thu, 24 Jul 2014 06:23:20 -0700 (PDT) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from nuc-i3427.intel.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 28152196-1500048 for multiple; Thu, 24 Jul 2014 14:24:25 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH] drm: Unlink dead file_priv from list of active files first Date: Thu, 24 Jul 2014 14:23:10 +0100 Message-Id: <1406208190-918-1-git-send-email-chris@chris-wilson.co.uk> X-Mailer: git-send-email 1.9.1 X-Originating-IP: 78.156.65.138 X-Country: code=GB country="United Kingdom" ip=78.156.65.138 Cc: "Ursulin, Tvrtko" X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In order to prevent external observers walking the list of open DRM files from seeing an invalid drm_file_private in the process of being torndown, the first operation we need to take is to unlink the drm_file_private from that list. general protection fault: 0000 [#1] PREEMPT SMP Modules linked in: i915 i2c_algo_bit drm_kms_helper drm lpc_ich mfd_core nls_iso8859_1 i2c_hid video hid_generic usbhid hid e1000e ahci ptp libahci pps_core CPU: 3 PID: 8220 Comm: cat Not tainted 3.16.0-rc6+ #4 Hardware name: Intel Corporation Shark Bay Client platform/WhiteTip Mountain 1, BIOS HSWLPTU1.86C.0119.R00.1303230105 03/23/2013 task: ffff8800219642c0 ti: ffff880047024000 task.ti: ffff880047024000 RIP: 0010:[] [] per_file_stats+0x110/0x160 [i915] RSP: 0018:ffff880047027d48 EFLAGS: 00010246 RAX: 6b6b6b6b6b6b6b6b RBX: ffff880047027e30 RCX: 0000000000000000 RDX: 0000000000000001 RSI: 0000000000000000 RDI: ffff88003a05cd00 RBP: ffff880047027d58 R08: 0000000000000001 R09: 0000000000000000 R10: ffff8800219642c0 R11: 0000000000000000 R12: ffff88003a05cd00 R13: 0000000000000000 R14: ffff88003a05cd00 R15: ffff880047027d88 FS: 00007f5f73a13740(0000) GS:ffff88014e380000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00000000023ff038 CR3: 0000000021a4b000 CR4: 00000000001407e0 Stack: 0000000000000001 000000000000ffff ffff880047027dc8 ffffffff813438e4 ffff880047027e30 ffffffffa0137b60 ffff880021a8af58 ffff880021a8f1a0 ffff8800a2061fb0 ffff8800a2062048 ffff8800a2061fb0 ffff8800a1e23478 Call Trace: [] idr_for_each+0xf4/0x180 [] ? i915_gem_stolen_list_info+0x1f0/0x1f0 [i915] [] i915_gem_object_info+0x5ca/0x6a0 [i915] [] seq_read+0xf5/0x3a0 [] vfs_read+0x90/0x150 [] SyS_read+0x49/0xb0 [] tracesys+0xd0/0xd5 Code: 01 00 00 49 39 84 24 08 01 00 00 74 55 49 8b 84 24 b8 00 00 00 48 01 43 18 31 c0 5b 41 5c 5d c3 0f 1f 00 49 8b 44 24 08 4c 89 e7 <48> 8b 70 28 48 81 c6 48 80 00 00 e8 80 14 01 00 84 c0 74 bc 49 RIP [] per_file_stats+0x110/0x160 [i915] RSP Reported-by: "Ursulin, Tvrtko" Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=81712 Signed-off-by: Chris Wilson Cc: "Ursulin, Tvrtko" Reviewed-by: David Herrmann --- drivers/gpu/drm/drm_fops.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c index a0c63cf..aff8217 100644 --- a/drivers/gpu/drm/drm_fops.c +++ b/drivers/gpu/drm/drm_fops.c @@ -416,6 +416,10 @@ int drm_release(struct inode *inode, struct file *filp) DRM_DEBUG("open_count = %d\n", dev->open_count); + mutex_lock(&dev->struct_mutex); + list_del(&file_priv->lhead); + mutex_unlock(&dev->struct_mutex); + if (dev->driver->preclose) dev->driver->preclose(dev, file_priv); @@ -509,10 +513,6 @@ int drm_release(struct inode *inode, struct file *filp) file_priv->is_master = 0; mutex_unlock(&dev->master_mutex); - mutex_lock(&dev->struct_mutex); - list_del(&file_priv->lhead); - mutex_unlock(&dev->struct_mutex); - if (dev->driver->postclose) dev->driver->postclose(dev, file_priv);