dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: dri-devel@lists.freedesktop.org
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
	Tomi Valkeinen <tomi.valkeinen@ti.com>
Subject: Re: [PATCH v2 4/6] drm/omap: gem: Replace struct_mutex usage with omap_obj private lock
Date: Sat, 26 May 2018 20:10:32 +0300	[thread overview]
Message-ID: <1816854.LCQKW1FNGA@avalon> (raw)
In-Reply-To: <20180525163925.10736-5-laurent.pinchart@ideasonboard.com>

Hello,

On Friday, 25 May 2018 19:39:23 EEST Laurent Pinchart wrote:
> The DRM device struct_mutex is used to protect against concurrent GEM
> object operations that deal with memory allocation and pinning. All
> those operations are local to a GEM object and don't need to be
> serialized across different GEM objects. Replace the struct_mutex with
> a local omap_obj.lock or drop it altogether where not needed.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
> Changes since v1:
> 
> - Use lockdep_assert_held() to verify locking correctness
> ---
>  drivers/gpu/drm/omapdrm/omap_debugfs.c |   7 --
>  drivers/gpu/drm/omapdrm/omap_fbdev.c   |   8 +--
>  drivers/gpu/drm/omapdrm/omap_gem.c     | 122 ++++++++++++++++++++----------
>  3 files changed, 81 insertions(+), 56 deletions(-)

[snip]

> diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c
> b/drivers/gpu/drm/omapdrm/omap_gem.c index 0a9ba1f711e6..39cbc7273b29
> 100644
> --- a/drivers/gpu/drm/omapdrm/omap_gem.c
> +++ b/drivers/gpu/drm/omapdrm/omap_gem.c

[snip]

> -/** release backing pages */
> +/* Release backing pages. Must be called with the omap_obj.lock held. */
>  static void omap_gem_detach_pages(struct drm_gem_object *obj)
>  {
>  	struct omap_gem_object *omap_obj = to_omap_bo(obj);
>  	unsigned int npages = obj->size >> PAGE_SHIFT;
>  	unsigned int i;
> 
> +	lockdep_assert_held(&omap_obj->lock);
> +
>  	for (i = 0; i < npages; i++) {
>  		if (omap_obj->dma_addrs[i])
>  			dma_unmap_page(obj->dev->dev, omap_obj->dma_addrs[i],

[snip]

> @@ -1056,15 +1091,16 @@ void omap_gem_free_object(struct drm_gem_object
> *obj)
> 
>  	omap_gem_evict(obj);
> 
> -	WARN_ON(!mutex_is_locked(&dev->struct_mutex));
> -
>  	spin_lock(&priv->list_lock);
>  	list_del(&omap_obj->mm_list);
>  	spin_unlock(&priv->list_lock);
> 
> -	/* this means the object is still pinned.. which really should
> -	 * not happen.  I think..
> +	/*
> +	 * No need to take the omap_obj.lock as at this point we own the sole
> +	 * reference to the object.
>  	 */

And this of course causes a lockdep warning, as the function calls 
omap_gem_detach_pages(), and the lockdep_assert_held() call there doesn't know 
we're the sole owner. I've sent a v2.1 to fix this.

> +
> +	/* The object should not be pinned. */
>  	WARN_ON(omap_obj->dma_addr_cnt > 0);
> 
>  	if (omap_obj->pages) {

[snip]

-- 
Regards,

Laurent Pinchart



_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2018-05-26 17:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-25 16:39 [PATCH v2 0/6] omapdrm: struct_mutex removal Laurent Pinchart
2018-05-25 16:39 ` [PATCH v2 1/6] drm/omap: gem: Rename GEM function with omap_gem_* prefix Laurent Pinchart
2018-05-25 16:39 ` [PATCH v2 2/6] drm/omap: gem: Merge __omap_gem_get_pages() and omap_gem_attach_pages() Laurent Pinchart
2018-05-25 16:39 ` [PATCH v2 3/6] drm/omap: gem: Don't take struct_mutex to get GEM object mmap offset Laurent Pinchart
2018-05-25 16:39 ` [PATCH v2 4/6] drm/omap: gem: Replace struct_mutex usage with omap_obj private lock Laurent Pinchart
2018-05-26 16:54   ` [PATCH v2.1 " Laurent Pinchart
2018-05-26 17:10   ` Laurent Pinchart [this message]
2018-05-25 16:39 ` [PATCH v2 5/6] drm/omap: gem: Fix mm_list locking Laurent Pinchart
2018-05-25 16:39 ` [PATCH v2 6/6] drm/omap: gem: Switch to gem_free_object_unlocked() Laurent Pinchart
2018-05-29  9:29 ` [PATCH v2 0/6] omapdrm: struct_mutex removal Tomi Valkeinen

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=1816854.LCQKW1FNGA@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=tomi.valkeinen@ti.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).