All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Thomas Zimmermann <tzimmermann@suse.de>
Cc: feng.tang@intel.com, dave@stgolabs.net, rong.a.chen@intel.com,
	airlied@linux.ie, dri-devel@lists.freedesktop.org,
	maxime.ripard@bootlin.com, kraxel@redhat.com,
	ying.huang@intel.com, sean@poorly.run
Subject: Re: [PATCH v3 2/3] drm/vram: Add infrastructure for move_notify()
Date: Fri, 6 Sep 2019 11:28:22 +0200	[thread overview]
Message-ID: <20190906092822.GD3958@phenom.ffwll.local> (raw)
In-Reply-To: <20190906085214.11677-3-tzimmermann@suse.de>

On Fri, Sep 06, 2019 at 10:52:13AM +0200, Thomas Zimmermann wrote:
> This patch prepares VRAM helpers for lazy unmapping of buffer objects.
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
>  drivers/gpu/drm/drm_vram_mm_helper.c | 12 ++++++++++++
>  include/drm/drm_vram_mm_helper.h     |  4 ++++
>  2 files changed, 16 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_vram_mm_helper.c b/drivers/gpu/drm/drm_vram_mm_helper.c
> index c911781d6728..31984690d5f3 100644
> --- a/drivers/gpu/drm/drm_vram_mm_helper.c
> +++ b/drivers/gpu/drm/drm_vram_mm_helper.c
> @@ -98,6 +98,17 @@ static int bo_driver_verify_access(struct ttm_buffer_object *bo,
>  	return vmm->funcs->verify_access(bo, filp);
>  }
>  
> +static void bo_driver_move_notify(struct ttm_buffer_object *bo,
> +				  bool evict,
> +				  struct ttm_mem_reg *new_mem)
> +{
> +	struct drm_vram_mm *vmm = drm_vram_mm_of_bdev(bo->bdev);
> +
> +	if (!vmm->funcs || !vmm->funcs->move_notify)
> +		return;
> +	vmm->funcs->move_notify(bo, evict, new_mem);
> +}
> +
>  static int bo_driver_io_mem_reserve(struct ttm_bo_device *bdev,
>  				    struct ttm_mem_reg *mem)
>  {
> @@ -140,6 +151,7 @@ static struct ttm_bo_driver bo_driver = {
>  	.eviction_valuable = ttm_bo_eviction_valuable,
>  	.evict_flags = bo_driver_evict_flags,
>  	.verify_access = bo_driver_verify_access,
> +	.move_notify = bo_driver_move_notify,
>  	.io_mem_reserve = bo_driver_io_mem_reserve,
>  	.io_mem_free = bo_driver_io_mem_free,
>  };
> diff --git a/include/drm/drm_vram_mm_helper.h b/include/drm/drm_vram_mm_helper.h
> index 2aacfb1ccfae..7fb8700f45fe 100644
> --- a/include/drm/drm_vram_mm_helper.h
> +++ b/include/drm/drm_vram_mm_helper.h
> @@ -15,6 +15,8 @@ struct drm_device;
>  	&ttm_bo_driver.evict_flags
>   * @verify_access:	Provides an implementation for \
>  	struct &ttm_bo_driver.verify_access
> + * @move_notify:	Provides an implementation for
> + *			struct &ttm_bo_driver.move_notify
>   *
>   * These callback function integrate VRAM MM with TTM buffer objects. New
>   * functions can be added if necessary.
> @@ -23,6 +25,8 @@ struct drm_vram_mm_funcs {
>  	void (*evict_flags)(struct ttm_buffer_object *bo,
>  			    struct ttm_placement *placement);
>  	int (*verify_access)(struct ttm_buffer_object *bo, struct file *filp);
> +	void (*move_notify)(struct ttm_buffer_object *bo, bool evict,
> +			    struct ttm_mem_reg *new_mem);

Is this indirection really worth it? We have a grand total of 1 driver
which isn't using gem (vmwgfx), and I don't think that one will ever
switch over to vram helpers.

I'd fold that all in. Helpers don't need to be flexible enough to support
every possible use-case (that's just the job of the core), they can be
opinionated to get cleaner code for most cases.

For this case here if you fold this in you can unexport 3 EXPORT_SYMBOLs
(4 with this patch here), which I think is a neat simplification of the
complexity exposed to driver writers. Just put the necessary declarations
into a drm_vram_helper_internal.h so that drivers don't get at it by
accident (like the other drm*internal.h helpers we have).
-Daniel

>  };
>  
>  /**
> -- 
> 2.23.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-09-06  9:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-06  8:52 [PATCH v3 0/3] Implement lazy unmapping for GEM VRAM buffers Thomas Zimmermann
2019-09-06  8:52 ` [PATCH v3 1/3] drm/vram: Add kmap ref-counting to GEM VRAM objects Thomas Zimmermann
2019-09-06  9:09   ` Daniel Vetter
2019-09-06  8:52 ` [PATCH v3 2/3] drm/vram: Add infrastructure for move_notify() Thomas Zimmermann
2019-09-06  9:28   ` Daniel Vetter [this message]
2019-09-06 10:24     ` Thomas Zimmermann
2019-09-06 13:05       ` Daniel Vetter
2019-09-06 14:01         ` Thomas Zimmermann
2019-09-06  8:52 ` [PATCH v3 3/3] drm/vram: Implement lazy unmapping for GEM VRAM buffers Thomas Zimmermann
2019-09-06  9:39   ` Gerd Hoffmann
2019-09-06 10:37     ` Thomas Zimmermann
2019-09-06 11:18       ` 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=20190906092822.GD3958@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=airlied@linux.ie \
    --cc=dave@stgolabs.net \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=feng.tang@intel.com \
    --cc=kraxel@redhat.com \
    --cc=maxime.ripard@bootlin.com \
    --cc=rong.a.chen@intel.com \
    --cc=sean@poorly.run \
    --cc=tzimmermann@suse.de \
    --cc=ying.huang@intel.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.