All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maarten Lankhorst <maarten.lankhorst@canonical.com>
To: Seung-Woo Kim <sw0312.kim@samsung.com>
Cc: kyungmin.park@samsung.com,
	laurent.pinchart+renesas@ideasonboard.com, yj44.cho@samsung.com,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/gem: add mutex lock when using drm_gem_mmap_obj
Date: Wed, 26 Jun 2013 09:12:08 +0200	[thread overview]
Message-ID: <51CA9448.5040907@canonical.com> (raw)
In-Reply-To: <1372212882-19082-1-git-send-email-sw0312.kim@samsung.com>

Op 26-06-13 04:14, Seung-Woo Kim schreef:
> From: YoungJun Cho <yj44.cho@samsung.com>
>
> 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 <yj44.cho@samsung.com>
> Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> CC: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> CC: Rob Clark <robdclark@gmail.com>
> ---
> 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

  reply	other threads:[~2013-06-26  7:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-26  2:14 [PATCH] drm/gem: add mutex lock when using drm_gem_mmap_obj Seung-Woo Kim
2013-06-26  7:12 ` Maarten Lankhorst [this message]
2013-06-26  8:28   ` YoungJun Cho
2013-06-26 23:39   ` [PATCH v2] " Seung-Woo Kim
2013-06-27  4:53     ` Maarten Lankhorst
2013-06-27 13:00     ` Laurent Pinchart
2013-06-27 14:16     ` Rob Clark
2013-06-27 14:20     ` Maarten Lankhorst

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=51CA9448.5040907@canonical.com \
    --to=maarten.lankhorst@canonical.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kyungmin.park@samsung.com \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=sw0312.kim@samsung.com \
    --cc=yj44.cho@samsung.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.