From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755534Ab1FFEe2 (ORCPT ); Mon, 6 Jun 2011 00:34:28 -0400 Received: from smtp-out.google.com ([74.125.121.67]:27605 "EHLO smtp-out.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751202Ab1FFEe1 (ORCPT ); Mon, 6 Jun 2011 00:34:27 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=google.com; s=beta; h=date:from:x-x-sender:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version:content-type; b=CiN6wdhT8dBN+s2dVjk0BYtJQin5aGBaahSouMleZOHkZScLUXbRh2SeZWPSNLlMQF lbq6E9v2WYoOincCYcQA== Date: Sun, 5 Jun 2011 21:34:25 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@sister.anvils To: Andrew Morton cc: Chris Wilson , Keith Packard , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 8/14] drm/i915: more struct_mutex locking In-Reply-To: Message-ID: References: User-Agent: Alpine 2.00 (LSU 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-System-Of-Record: true Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When auditing the locking in i915_gem.c (for a prospective change which I then abandoned), I noticed two places where struct_mutex is not held across GEM object manipulations that would usually require it. Since one is in initial setup and the other in driver unload, I'm guessing the mutex is not required for either; but post a patch in case it is. Signed-off-by: Hugh Dickins Cc: Chris Wilson Cc: Keith Packard --- drivers/gpu/drm/i915/i915_dma.c | 3 +-- drivers/gpu/drm/i915/intel_overlay.c | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) --- linux.orig/drivers/gpu/drm/i915/i915_dma.c 2011-05-29 18:42:31.781854594 -0700 +++ linux/drivers/gpu/drm/i915/i915_dma.c 2011-06-05 18:49:14.757317293 -0700 @@ -2182,9 +2182,8 @@ int i915_driver_unload(struct drm_device /* Flush any outstanding unpin_work. */ flush_workqueue(dev_priv->wq); - i915_gem_free_all_phys_object(dev); - mutex_lock(&dev->struct_mutex); + i915_gem_free_all_phys_object(dev); i915_gem_cleanup_ringbuffer(dev); mutex_unlock(&dev->struct_mutex); if (I915_HAS_FBC(dev) && i915_powersave) --- linux.orig/drivers/gpu/drm/i915/intel_overlay.c 2011-05-18 21:06:34.000000000 -0700 +++ linux/drivers/gpu/drm/i915/intel_overlay.c 2011-06-05 18:49:14.761317509 -0700 @@ -1416,6 +1416,8 @@ void intel_setup_overlay(struct drm_devi goto out_free; overlay->reg_bo = reg_bo; + mutex_lock(&dev->struct_mutex); + if (OVERLAY_NEEDS_PHYSICAL(dev)) { ret = i915_gem_attach_phys_object(dev, reg_bo, I915_GEM_PHYS_OVERLAY_REGS, @@ -1440,6 +1442,8 @@ void intel_setup_overlay(struct drm_devi } } + mutex_unlock(&dev->struct_mutex); + /* init all values */ overlay->color_key = 0x0101fe; overlay->brightness = -19; @@ -1463,6 +1467,7 @@ void intel_setup_overlay(struct drm_devi out_unpin_bo: i915_gem_object_unpin(reg_bo); out_free_bo: + mutex_unlock(&dev->struct_mutex); drm_gem_object_unreference(®_bo->base); out_free: kfree(overlay);