From patchwork Fri Oct 22 11:52:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francisco Jerez X-Patchwork-Id: 273801 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9MBr0CA011494 for ; Fri, 22 Oct 2010 11:53:20 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 978019E96B for ; Fri, 22 Oct 2010 04:53:00 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx1.riseup.net (mx1.riseup.net [204.13.164.18]) by gabe.freedesktop.org (Postfix) with ESMTP id DDDB59E7D1 for ; Fri, 22 Oct 2010 04:52:21 -0700 (PDT) Received: from auk.riseup.net (auk-pn.riseup.net [10.0.1.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "*.riseup.net", Issuer "Gandi Standard SSL CA" (verified OK)) by mx1.riseup.net (Postfix) with ESMTPS id C456D25E96E; Fri, 22 Oct 2010 04:52:21 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: currojerez@auk.riseup.net) with ESMTPSA id A043F4943 From: Francisco Jerez To: Dave Airlie Subject: [PATCH 2/2] drm/kms: Fix missing locking in some fb helpers. Date: Fri, 22 Oct 2010 13:52:13 +0200 Message-Id: <1287748333-4990-2-git-send-email-currojerez@riseup.net> X-Mailer: git-send-email 1.6.4.4 In-Reply-To: <1287748333-4990-1-git-send-email-currojerez@riseup.net> References: <1287748333-4990-1-git-send-email-currojerez@riseup.net> X-Virus-Scanned: clamav-milter 0.96.3 at mx1 X-Virus-Status: Clean Cc: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 22 Oct 2010 11:53:20 +0000 (UTC) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 6a5e403..4d608b7 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -1449,6 +1449,8 @@ bool drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int bpp_sel) struct drm_device *dev = fb_helper->dev; int count = 0; + mutex_lock(&dev->mode_config.mutex); + /* disable all the possible outputs/crtcs before entering KMS mode */ drm_helper_disable_unused_functions(fb_helper->dev); @@ -1465,19 +1467,23 @@ bool drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int bpp_sel) } drm_setup_crtcs(fb_helper); + mutex_unlock(&dev->mode_config.mutex); + return drm_fb_helper_single_fb_probe(fb_helper, bpp_sel); } EXPORT_SYMBOL(drm_fb_helper_initial_config); bool drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper) { + struct drm_device *dev = fb_helper->dev; int count = 0; u32 max_width, max_height, bpp_sel; bool bound = false, crtcs_bound = false; struct drm_crtc *crtc; + mutex_lock(&dev->mode_config.mutex); if (!fb_helper->fb) - return false; + goto fail; list_for_each_entry(crtc, &fb_helper->dev->mode_config.crtc_list, head) { if (crtc->fb) @@ -1488,7 +1494,7 @@ bool drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper) if (!bound && crtcs_bound) { fb_helper->delayed_hotplug = true; - return false; + goto fail; } DRM_DEBUG_KMS("\n"); @@ -1500,7 +1506,11 @@ bool drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper) max_height); drm_setup_crtcs(fb_helper); + mutex_unlock(&dev->mode_config.mutex); return drm_fb_helper_single_fb_probe(fb_helper, bpp_sel); +fail: + mutex_unlock(&dev->mode_config.mutex); + return false; } EXPORT_SYMBOL(drm_fb_helper_hotplug_event);