linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Hugh Dickins <hughd@google.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Chris Wilson <chris@chris-wilson.co.uk>,
	Keith Packard <keithp@keithp.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH 8/14] drm/i915: more struct_mutex locking
Date: Sun, 5 Jun 2011 21:34:25 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LSU.2.00.1106052132390.17116@sister.anvils> (raw)
In-Reply-To: <alpine.LSU.2.00.1106052116350.17116@sister.anvils>

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 <hughd@google.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Keith Packard <keithp@keithp.com>
---
 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(&reg_bo->base);
 out_free:
 	kfree(overlay);

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2011-06-06  4:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-06  4:21 [PATCH 0/14] mm: tmpfs and trunc changes, affecting drm Hugh Dickins
2011-06-06  4:23 ` [PATCH 1/14] mm: move vmtruncate_range to truncate.c Hugh Dickins
2011-06-06  4:24 ` [PATCH 2/14] mm: move shmem prototypes to shmem_fs.h Hugh Dickins
2011-06-06  4:26 ` [PATCH 3/14] tmpfs: take control of its truncate_range Hugh Dickins
2011-06-06  4:27 ` [PATCH 4/14] tmpfs: add shmem_read_mapping_page_gfp Hugh Dickins
2011-06-06  4:29 ` [PATCH 5/14] drm/ttm: use shmem_read_mapping_page Hugh Dickins
2011-06-06  4:31 ` [PATCH 6/14] drm/i915: " Hugh Dickins
2011-06-06  4:32 ` [PATCH 7/14] drm/i915: use shmem_truncate_range Hugh Dickins
2011-06-06  4:34 ` Hugh Dickins [this message]
2011-06-06  4:35 ` [PATCH 9/14] mm: cleanup descriptions of filler arg Hugh Dickins
2011-06-06  4:36 ` [PATCH 10/14] mm: truncate functions are in truncate.c Hugh Dickins
2011-06-06  4:38 ` [PATCH 11/14] mm: tidy vmtruncate_range and related functions Hugh Dickins
2011-06-06  4:39 ` [PATCH 12/14] mm: consistent truncate and invalidate loops Hugh Dickins
2011-06-06  4:40 ` [PATCH 13/14] mm: pincer in truncate_inode_pages_range Hugh Dickins
2011-06-06  4:42 ` [PATCH 14/14] tmpfs: no need to use i_lock Hugh Dickins
  -- strict thread matches above, loose matches on Subject: below --
2011-05-31  0:33 [PATCH 0/14] mm: tmpfs and trunc changes, affecting drm Hugh Dickins
2011-05-31  0:46 ` [PATCH 8/14] drm/i915: more struct_mutex locking Hugh Dickins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LSU.2.00.1106052132390.17116@sister.anvils \
    --to=hughd@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=chris@chris-wilson.co.uk \
    --cc=keithp@keithp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox