dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Thomas Zimmermann <tzimmermann@suse.de>
Cc: maxime.ripard@bootlin.com, sam@ravnborg.org,
	dri-devel@lists.freedesktop.org, kraxel@redhat.com,
	airlied@redhat.com, sean@poorly.run
Subject: Re: [PATCH v3 8/9] drm: Remove lock interfaces from GEM VRAM helpers
Date: Thu, 13 Jun 2019 18:34:42 +0200	[thread overview]
Message-ID: <20190613163442.GQ23020@phenom.ffwll.local> (raw)
In-Reply-To: <20190613073041.29350-9-tzimmermann@suse.de>

On Thu, Jun 13, 2019 at 09:30:40AM +0200, Thomas Zimmermann wrote:
> The lock functions and the locked-pin/unpin functions of GEM VRAM are not
> requried any longer. Remove them.
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>

btw a neat thing we could do for these helpers would be to integrate them
more tighly with the reservation/fence helpers in drm_gem.h. All those
require is that gem_obj->resv is set correctly, which duplicates ttm's own
ttm_buffer_object->resv.

It hink we could also remove ttm_buffer_object->ttm_resv and require that
you always pass one in when calling ttm_bo_init, and gem drivers would
just use the gem_object->resv one.

One complication is that for dma-buf expect we need to make sure we pick
the right one. There's kinda no neat way to solve that, except by just
making ttm_buffer_object a full subclass of drm_gem_object, which probably
wouldn't go down too well I think.

Just an aside, I'm digging around in this area in radeon/amdgpu/nouveau
code right now.
-Daniel

> ---
>  drivers/gpu/drm/drm_gem_vram_helper.c | 109 --------------------------
>  include/drm/drm_gem_vram_helper.h     |   5 --
>  2 files changed, 114 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
> index f3e5803affb0..4cae52054e61 100644
> --- a/drivers/gpu/drm/drm_gem_vram_helper.c
> +++ b/drivers/gpu/drm/drm_gem_vram_helper.c
> @@ -151,36 +151,6 @@ void drm_gem_vram_put(struct drm_gem_vram_object *gbo)
>  }
>  EXPORT_SYMBOL(drm_gem_vram_put);
>  
> -/**
> - * drm_gem_vram_lock() - Locks a VRAM-backed GEM object
> - * @gbo:	the GEM VRAM object
> - * @no_wait:	don't wait for buffer object to become available
> - *
> - * See ttm_bo_reserve() for more information.
> - *
> - * Returns:
> - * 0 on success, or
> - * a negative error code otherwise
> - */
> -int drm_gem_vram_lock(struct drm_gem_vram_object *gbo, bool no_wait)
> -{
> -	return ttm_bo_reserve(&gbo->bo, true, no_wait, NULL);
> -}
> -EXPORT_SYMBOL(drm_gem_vram_lock);
> -
> -/**
> - * drm_gem_vram_unlock() - \
> -	Release a reservation acquired by drm_gem_vram_lock()
> - * @gbo:	the GEM VRAM object
> - *
> - * See ttm_bo_unreserve() for more information.
> - */
> -void drm_gem_vram_unlock(struct drm_gem_vram_object *gbo)
> -{
> -	ttm_bo_unreserve(&gbo->bo);
> -}
> -EXPORT_SYMBOL(drm_gem_vram_unlock);
> -
>  /**
>   * drm_gem_vram_mmap_offset() - Returns a GEM VRAM object's mmap offset
>   * @gbo:	the GEM VRAM object
> @@ -266,49 +236,6 @@ int drm_gem_vram_pin(struct drm_gem_vram_object *gbo, unsigned long pl_flag)
>  }
>  EXPORT_SYMBOL(drm_gem_vram_pin);
>  
> -/**
> - * drm_gem_vram_pin_locked() - Pins a GEM VRAM object in a region.
> - * @gbo:	the GEM VRAM object
> - * @pl_flag:	a bitmask of possible memory regions
> - *
> - * Pinning a buffer object ensures that it is not evicted from
> - * a memory region. A pinned buffer object has to be unpinned before
> - * it can be pinned to another region.
> - *
> - * This function pins a GEM VRAM object that has already been
> - * locked. Use drm_gem_vram_pin() if possible.
> - *
> - * Returns:
> - * 0 on success, or
> - * a negative error code otherwise.
> - */
> -int drm_gem_vram_pin_locked(struct drm_gem_vram_object *gbo,
> -			    unsigned long pl_flag)
> -{
> -	int i, ret;
> -	struct ttm_operation_ctx ctx = { false, false };
> -
> -	lockdep_assert_held(&gbo->bo.resv->lock.base);
> -
> -	if (gbo->pin_count) {
> -		++gbo->pin_count;
> -		return 0;
> -	}
> -
> -	drm_gem_vram_placement(gbo, pl_flag);
> -	for (i = 0; i < gbo->placement.num_placement; ++i)
> -		gbo->placements[i].flags |= TTM_PL_FLAG_NO_EVICT;
> -
> -	ret = ttm_bo_validate(&gbo->bo, &gbo->placement, &ctx);
> -	if (ret < 0)
> -		return ret;
> -
> -	gbo->pin_count = 1;
> -
> -	return 0;
> -}
> -EXPORT_SYMBOL(drm_gem_vram_pin_locked);
> -
>  /**
>   * drm_gem_vram_unpin() - Unpins a GEM VRAM object
>   * @gbo:	the GEM VRAM object
> @@ -351,42 +278,6 @@ int drm_gem_vram_unpin(struct drm_gem_vram_object *gbo)
>  }
>  EXPORT_SYMBOL(drm_gem_vram_unpin);
>  
> -/**
> - * drm_gem_vram_unpin_locked() - Unpins a GEM VRAM object
> - * @gbo:	the GEM VRAM object
> - *
> - * This function unpins a GEM VRAM object that has already been
> - * locked. Use drm_gem_vram_unpin() if possible.
> - *
> - * Returns:
> - * 0 on success, or
> - * a negative error code otherwise.
> - */
> -int drm_gem_vram_unpin_locked(struct drm_gem_vram_object *gbo)
> -{
> -	int i, ret;
> -	struct ttm_operation_ctx ctx = { false, false };
> -
> -	lockdep_assert_held(&gbo->bo.resv->lock.base);
> -
> -	if (WARN_ON_ONCE(!gbo->pin_count))
> -		return 0;
> -
> -	--gbo->pin_count;
> -	if (gbo->pin_count)
> -		return 0;
> -
> -	for (i = 0; i < gbo->placement.num_placement ; ++i)
> -		gbo->placements[i].flags &= ~TTM_PL_FLAG_NO_EVICT;
> -
> -	ret = ttm_bo_validate(&gbo->bo, &gbo->placement, &ctx);
> -	if (ret < 0)
> -		return ret;
> -
> -	return 0;
> -}
> -EXPORT_SYMBOL(drm_gem_vram_unpin_locked);
> -
>  /**
>   * drm_gem_vram_kmap_at() - Maps a GEM VRAM object into kernel address space
>   * @gbo:	the GEM VRAM object
> diff --git a/include/drm/drm_gem_vram_helper.h b/include/drm/drm_gem_vram_helper.h
> index 4d1d2c1bf32b..1d4aa87f8dfa 100644
> --- a/include/drm/drm_gem_vram_helper.h
> +++ b/include/drm/drm_gem_vram_helper.h
> @@ -77,15 +77,10 @@ struct drm_gem_vram_object *drm_gem_vram_create(struct drm_device *dev,
>  						unsigned long pg_align,
>  						bool interruptible);
>  void drm_gem_vram_put(struct drm_gem_vram_object *gbo);
> -int drm_gem_vram_lock(struct drm_gem_vram_object *gbo, bool no_wait);
> -void drm_gem_vram_unlock(struct drm_gem_vram_object *gbo);
>  u64 drm_gem_vram_mmap_offset(struct drm_gem_vram_object *gbo);
>  s64 drm_gem_vram_offset(struct drm_gem_vram_object *gbo);
>  int drm_gem_vram_pin(struct drm_gem_vram_object *gbo, unsigned long pl_flag);
> -int drm_gem_vram_pin_locked(struct drm_gem_vram_object *gbo,
> -			      unsigned long pl_flag);
>  int drm_gem_vram_unpin(struct drm_gem_vram_object *gbo);
> -int drm_gem_vram_unpin_locked(struct drm_gem_vram_object *gbo);
>  void *drm_gem_vram_kmap_at(struct drm_gem_vram_object *gbo, bool map,
>  			   bool *is_iomem, struct ttm_bo_kmap_obj *kmap);
>  void *drm_gem_vram_kmap(struct drm_gem_vram_object *gbo, bool map,
> -- 
> 2.21.0
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2019-06-13 16:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-13  7:30 [PATCH v3 0/9] Remove explicit locking and kmap arguments from GEM VRAM interface Thomas Zimmermann
2019-06-13  7:30 ` [PATCH v3 1/9] drm/gem-vram: Support pinning buffers to current location Thomas Zimmermann
2019-06-13  7:30 ` [PATCH v3 2/9] drm/ast: Unpin cursor BO during cleanup Thomas Zimmermann
2019-06-13  7:30 ` [PATCH v3 3/9] drm/ast: Remove obsolete or unused cursor state Thomas Zimmermann
2019-06-13  7:30 ` [PATCH v3 4/9] drm/ast: Pin and map cursor source BO during update Thomas Zimmermann
2019-06-13  7:30 ` [PATCH v3 5/9] drm/ast: Pin framebuffer BO during dirty update Thomas Zimmermann
2019-06-13  7:30 ` [PATCH v3 6/9] drm/mgag200: " Thomas Zimmermann
2019-06-13  7:30 ` [PATCH v3 7/9] drm/mgag200: Rewrite cursor handling Thomas Zimmermann
2019-06-13  7:30 ` [PATCH v3 8/9] drm: Remove lock interfaces from GEM VRAM helpers Thomas Zimmermann
2019-06-13 16:34   ` Daniel Vetter [this message]
2019-06-13  7:30 ` [PATCH v3 9/9] drm: Remove functions with kmap-object argument " Thomas Zimmermann
2019-06-13  9:44 ` [PATCH v3 0/9] Remove explicit locking and kmap arguments from GEM VRAM interface Gerd Hoffmann

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=20190613163442.GQ23020@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=airlied@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kraxel@redhat.com \
    --cc=maxime.ripard@bootlin.com \
    --cc=sam@ravnborg.org \
    --cc=sean@poorly.run \
    --cc=tzimmermann@suse.de \
    /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