From patchwork Wed Jun 3 13:57:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 6538271 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 96EB39F3D1 for ; Wed, 3 Jun 2015 13:57:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C831720612 for ; Wed, 3 Jun 2015 13:57:51 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 86FB02060F for ; Wed, 3 Jun 2015 13:57:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 681B66EA07; Wed, 3 Jun 2015 06:57:49 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [87.106.93.118]) by gabe.freedesktop.org (Postfix) with ESMTP id 27B5D6EA08 for ; Wed, 3 Jun 2015 06:57:47 -0700 (PDT) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from nuc-i3427.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 40660077-1500048 for multiple; Wed, 03 Jun 2015 14:58:25 +0100 Received: by nuc-i3427.alporthouse.com (sSMTP sendmail emulation); Wed, 03 Jun 2015 14:57:41 +0100 Date: Wed, 3 Jun 2015 14:57:41 +0100 From: Chris Wilson To: Lukas Wunner Message-ID: <20150603135741.GB27056@nuc-i3427.alporthouse.com> Mail-Followup-To: Chris Wilson , Lukas Wunner , Ville =?iso-8859-1?Q?Syrj=E4l=E4?= , intel-gfx@lists.freedesktop.org References: <20150603134332.GA5548@wunner.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150603134332.GA5548@wunner.de> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: intel-gfx@lists.freedesktop.org Subject: Re: [Intel-gfx] Deadlock in intel_user_framebuffer_destroy() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 On Wed, Jun 03, 2015 at 03:43:32PM +0200, Lukas Wunner wrote: > Hi, > > a deadlock was introduced by commit 60a5ca015ffd2aacfe5674b5a401cd2a37159e07 > > Author: Ville Syrjälä > Date: Fri Jun 13 11:10:53 2014 +0300 > > drm/i915: Add locking around framebuffer_references-- > > > The commit amended intel_display.c:intel_user_framebuffer_destroy() with > mutex_lock(&dev->struct_mutex). > > A few weeks prior Chris Wilson had amended intel_fbdev.c:intelfb_create() > with a call to drm_framebuffer_unreference() while &dev->struct_mutex is > locked (commit edd586fe705e819bc711b5ed7194a0b6f9f1a7e1, "drm/i915: Discard > BIOS framebuffers too small to accommodate chosen mode"). > Just move the mutex_lock down a step. t a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c index 6372cfc..a9b8c43 100644 --- a/drivers/gpu/drm/i915/intel_fbdev.c +++ b/drivers/gpu/drm/i915/intel_fbdev.c @@ -209,8 +209,6 @@ static int intelfb_create(struct drm_fb_helper *helper, int size, ret; bool prealloc = false; - mutex_lock(&dev->struct_mutex); - if (intel_fb && (sizes->fb_width > intel_fb->base.width || sizes->fb_height > intel_fb->base.height)) { @@ -221,6 +219,9 @@ static int intelfb_create(struct drm_fb_helper *helper, drm_framebuffer_unreference(&intel_fb->base); intel_fb = ifbdev->fb = NULL; } + + mutex_lock(&dev->struct_mutex); + if (!intel_fb || WARN_ON(!intel_fb->obj)) { DRM_DEBUG_KMS("no BIOS fb, allocating a new one\n"); ret = intelfb_alloc(helper, sizes);