LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Steven Price <steven.price@arm.com>
Cc: Daniel Vetter <daniel@ffwll.ch>, Rob Herring <robh@kernel.org>,
	Tomeu Vizoso <tomeu.vizoso@collabora.com>,
	Alyssa Rosenzweig <alyssa@rosenzweig.io>,
	Chris Wilson <chris@chris-wilson.co.uk>,
	David Airlie <airlied@linux.ie>, Inki Dae <inki.dae@samsung.com>,
	Joonyoung Shim <jy0922.shim@samsung.com>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	Kukjin Kim <kgene@kernel.org>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <maxime.ripard@bootlin.com>,
	Sean Paul <sean@poorly.run>,
	Seung-Woo Kim <sw0312.kim@samsung.com>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/3] drm: shmem: Add drm_gem_shmem_map_offset() wrapper
Date: Thu, 16 May 2019 22:26:44 +0200	[thread overview]
Message-ID: <20190516202644.GE3851@phenom.ffwll.local> (raw)
In-Reply-To: <20190516141447.46839-3-steven.price@arm.com>

On Thu, May 16, 2019 at 03:14:46PM +0100, Steven Price wrote:
> Provide a wrapper for drm_gem_map_offset() for clients of shmem. This
> wrapper provides the correct semantics for the drm_gem_shmem_mmap()
> callback.
> 
> Signed-off-by: Steven Price <steven.price@arm.com>
> ---
>  drivers/gpu/drm/drm_gem_shmem_helper.c | 20 ++++++++++++++++++++
>  include/drm/drm_gem_shmem_helper.h     |  2 ++
>  2 files changed, 22 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
> index 1ee208c2c85e..9dbebc4897d1 100644
> --- a/drivers/gpu/drm/drm_gem_shmem_helper.c
> +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
> @@ -400,6 +400,26 @@ int drm_gem_shmem_dumb_create(struct drm_file *file, struct drm_device *dev,
>  }
>  EXPORT_SYMBOL_GPL(drm_gem_shmem_dumb_create);
>  
> +/**
> + * drm_gem_map_offset - return the fake mmap offset for a gem object
> + * @file: drm file-private structure containing the gem object
> + * @dev: corresponding drm_device
> + * @handle: gem object handle
> + * @offset: return location for the fake mmap offset
> + *
> + * This provides an offset suitable for user space to return to the
> + * drm_gem_shmem_mmap() callback via an mmap() call.
> + *
> + * Returns:
> + * 0 on success or a negative error code on failure.
> + */
> +int drm_gem_shmem_map_offset(struct drm_file *file, struct drm_device *dev,
> +			     u32 handle, u64 *offset)
> +{
> +	return drm_gem_map_offset(file, dev, handle, offset);
> +}
> +EXPORT_SYMBOL_GPL(drm_gem_shmem_map_offset);

Not seeing the point of this mapper, since drm_gem_shmem_map_offset isn't
speficic at all. It works for dumb, shmem, cma and private objects all
equally well. I'd drop this and just directly call the underlying thing,
no need to layer helpers.
-Daniel

> +
>  static vm_fault_t drm_gem_shmem_fault(struct vm_fault *vmf)
>  {
>  	struct vm_area_struct *vma = vmf->vma;
> diff --git a/include/drm/drm_gem_shmem_helper.h b/include/drm/drm_gem_shmem_helper.h
> index 038b6d313447..4239ddaaaa4f 100644
> --- a/include/drm/drm_gem_shmem_helper.h
> +++ b/include/drm/drm_gem_shmem_helper.h
> @@ -128,6 +128,8 @@ drm_gem_shmem_create_with_handle(struct drm_file *file_priv,
>  int drm_gem_shmem_dumb_create(struct drm_file *file, struct drm_device *dev,
>  			      struct drm_mode_create_dumb *args);
>  
> +int drm_gem_shmem_map_offset(struct drm_file *file, struct drm_device *dev,
> +			     u32 handle, u64 *offset);
>  int drm_gem_shmem_mmap(struct file *filp, struct vm_area_struct *vma);
>  
>  extern const struct vm_operations_struct drm_gem_shmem_vm_ops;
> -- 
> 2.20.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

  reply	other threads:[~2019-05-16 20:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-16 14:14 [PATCH v2 0/3] drm/panfrost: drm_gem_map_offset() helper Steven Price
2019-05-16 14:14 ` [PATCH v2 1/3] drm/gem: Rename drm_gem_dumb_map_offset() to drm_gem_map_offset() Steven Price
2019-05-16 20:25   ` Daniel Vetter
2019-05-16 14:14 ` [PATCH v2 2/3] drm: shmem: Add drm_gem_shmem_map_offset() wrapper Steven Price
2019-05-16 20:26   ` Daniel Vetter [this message]
2019-05-20  9:21     ` Steven Price
2019-05-16 14:14 ` [PATCH v2 3/3] drm/panfrost: Use drm_gem_shmem_map_offset() Steven Price
2019-05-16 15:36 ` [PATCH v2 0/3] drm/panfrost: drm_gem_map_offset() helper Alyssa Rosenzweig

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=20190516202644.GE3851@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=airlied@linux.ie \
    --cc=alyssa@rosenzweig.io \
    --cc=chris@chris-wilson.co.uk \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=inki.dae@samsung.com \
    --cc=jy0922.shim@samsung.com \
    --cc=kgene@kernel.org \
    --cc=krzk@kernel.org \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=maxime.ripard@bootlin.com \
    --cc=robh@kernel.org \
    --cc=sean@poorly.run \
    --cc=steven.price@arm.com \
    --cc=sw0312.kim@samsung.com \
    --cc=tomeu.vizoso@collabora.com \
    --subject='Re: [PATCH v2 2/3] drm: shmem: Add drm_gem_shmem_map_offset() wrapper' \
    /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

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).