From mboxrd@z Thu Jan 1 00:00:00 1970 From: Maarten Lankhorst Subject: Re: [PATCH] drm/gem: add mutex lock when using drm_gem_mmap_obj Date: Wed, 26 Jun 2013 09:12:08 +0200 Message-ID: <51CA9448.5040907@canonical.com> References: <1372212882-19082-1-git-send-email-sw0312.kim@samsung.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by gabe.freedesktop.org (Postfix) with ESMTP id 1B357E616E for ; Wed, 26 Jun 2013 00:12:12 -0700 (PDT) In-Reply-To: <1372212882-19082-1-git-send-email-sw0312.kim@samsung.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: Seung-Woo Kim Cc: kyungmin.park@samsung.com, laurent.pinchart+renesas@ideasonboard.com, yj44.cho@samsung.com, dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org Op 26-06-13 04:14, Seung-Woo Kim schreef: > From: YoungJun Cho > > The drm_gem_mmap_obj() has to be protected with dev->struct_mutex, > but some caller functions do not. So it adds mutex lock to missing > callers and adds WARN_ON assertion whether drm_gem_mmap_obj() is > called with mutex lock or not. > > Signed-off-by: YoungJun Cho > Signed-off-by: Seung-Woo Kim > Signed-off-by: Kyungmin Park > CC: Laurent Pinchart > CC: Rob Clark > --- > This patch is based on drm-next branch. > > drivers/gpu/drm/drm_gem.c | 4 ++++ > drivers/gpu/drm/drm_gem_cma_helper.c | 3 +++ > drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c | 3 +++ > 3 files changed, 10 insertions(+), 0 deletions(-) > > diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c > index 4321713..b19bba0 100644 > --- a/drivers/gpu/drm/drm_gem.c > +++ b/drivers/gpu/drm/drm_gem.c > @@ -661,6 +661,8 @@ EXPORT_SYMBOL(drm_gem_vm_close); > * the GEM object is not looked up based on its fake offset. To implement the > * DRM mmap operation, drivers should use the drm_gem_mmap() function. > * > + * NOTE: This function has to be protected with dev->struct_mutex > + * > * Return 0 or success or -EINVAL if the object size is smaller than the VMA > * size, or if no gem_vm_ops are provided. > */ > @@ -669,6 +671,8 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size, > { > struct drm_device *dev = obj->dev; > > + WARN_ON(!mutex_is_locked(&dev->struct_mutex)); > Please don't use mutex_is_locked, use lockdep_assert_held, so the cost only exists when PROVE_LOCKING is used.. I know some current code does it wrong, but that is the correct function to use. ~Maarten