linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Price <steven.price@arm.com>
To: Gerd Hoffmann <kraxel@redhat.com>, dri-devel@lists.freedesktop.org
Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com>,
	Maxime Ripard <maxime.ripard@bootlin.com>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	open list <linux-kernel@vger.kernel.org>,
	David Airlie <airlied@linux.ie>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	"open list:VIRTIO GPU DRIVER" 
	<virtualization@lists.linux-foundation.org>,
	Sean Paul <sean@poorly.run>,
	Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Subject: Re: [PATCH 2/8] drm/shmem: switch shmem helper to &drm_gem_object_funcs.mmap
Date: Fri, 13 Sep 2019 15:03:35 +0100	[thread overview]
Message-ID: <197fdced-cf4a-c59a-47fd-aa5dbf8e04a2@arm.com> (raw)
In-Reply-To: <20190913122908.784-3-kraxel@redhat.com>

On 13/09/2019 13:29, Gerd Hoffmann wrote:
> Switch gem shmem helper to the new mmap() workflow,
> from &gem_driver.fops.mmap to &drm_gem_object_funcs.mmap.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  include/drm/drm_gem_shmem_helper.h      |  6 ++----
>  drivers/gpu/drm/drm_gem_shmem_helper.c  | 26 ++++++++-----------------
>  drivers/gpu/drm/panfrost/panfrost_gem.c |  2 +-
>  drivers/gpu/drm/v3d/v3d_bo.c            |  2 +-
>  drivers/gpu/drm/virtio/virtgpu_object.c |  2 +-
>  5 files changed, 13 insertions(+), 25 deletions(-)
> 
> diff --git a/include/drm/drm_gem_shmem_helper.h b/include/drm/drm_gem_shmem_helper.h
> index 01f514521687..d89f2116c8ab 100644
> --- a/include/drm/drm_gem_shmem_helper.h
> +++ b/include/drm/drm_gem_shmem_helper.h
> @@ -111,7 +111,7 @@ struct drm_gem_shmem_object {
>  		.poll		= drm_poll,\
>  		.read		= drm_read,\
>  		.llseek		= noop_llseek,\
> -		.mmap		= drm_gem_shmem_mmap, \
> +		.mmap		= drm_gem_mmap, \
>  	}
>  
>  struct drm_gem_shmem_object *drm_gem_shmem_create(struct drm_device *dev, size_t size);
> @@ -143,9 +143,7 @@ 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_mmap(struct file *filp, struct vm_area_struct *vma);
> -
> -extern const struct vm_operations_struct drm_gem_shmem_vm_ops;
> +int drm_gem_shmem_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma);
>  
>  void drm_gem_shmem_print_info(struct drm_printer *p, unsigned int indent,
>  			      const struct drm_gem_object *obj);
> diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
> index f5918707672f..a104140154bb 100644
> --- a/drivers/gpu/drm/drm_gem_shmem_helper.c
> +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
> @@ -32,7 +32,7 @@ static const struct drm_gem_object_funcs drm_gem_shmem_funcs = {
>  	.get_sg_table = drm_gem_shmem_get_sg_table,
>  	.vmap = drm_gem_shmem_vmap,
>  	.vunmap = drm_gem_shmem_vunmap,
> -	.vm_ops = &drm_gem_shmem_vm_ops,
> +	.mmap = drm_gem_shmem_mmap,
>  };
>  
>  /**
> @@ -505,39 +505,30 @@ static void drm_gem_shmem_vm_close(struct vm_area_struct *vma)
>  	drm_gem_vm_close(vma);
>  }
>  
> -const struct vm_operations_struct drm_gem_shmem_vm_ops = {
> +static const struct vm_operations_struct drm_gem_shmem_vm_ops = {
>  	.fault = drm_gem_shmem_fault,
>  	.open = drm_gem_shmem_vm_open,
>  	.close = drm_gem_shmem_vm_close,
>  };
> -EXPORT_SYMBOL_GPL(drm_gem_shmem_vm_ops);
>  
>  /**
>   * drm_gem_shmem_mmap - Memory-map a shmem GEM object
> - * @filp: File object
> + * @obj: gem object
>   * @vma: VMA for the area to be mapped
>   *
>   * This function implements an augmented version of the GEM DRM file mmap
>   * operation for shmem objects. Drivers which employ the shmem helpers should
> - * use this function as their &file_operations.mmap handler in the DRM device file's
> - * file_operations structure.
> - *
> - * Instead of directly referencing this function, drivers should use the
> - * DEFINE_DRM_GEM_SHMEM_FOPS() macro.
> + * use this function as their &drm_gem_object_funcs.mmap handler.
>   *
>   * Returns:
>   * 0 on success or a negative error code on failure.
>   */
> -int drm_gem_shmem_mmap(struct file *filp, struct vm_area_struct *vma)
> +int drm_gem_shmem_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
>  {
>  	struct drm_gem_shmem_object *shmem;
>  	int ret;
>  
> -	ret = drm_gem_mmap(filp, vma);
> -	if (ret)
> -		return ret;
> -
> -	shmem = to_drm_gem_shmem_obj(vma->vm_private_data);
> +	shmem = to_drm_gem_shmem_obj(obj);
>  
>  	ret = drm_gem_shmem_get_pages(shmem);
>  	if (ret) {
> @@ -545,9 +536,8 @@ int drm_gem_shmem_mmap(struct file *filp, struct vm_area_struct *vma)
>  		return ret;
>  	}
>  
> -	/* VM_PFNMAP was set by drm_gem_mmap() */
> -	vma->vm_flags &= ~VM_PFNMAP;
> -	vma->vm_flags |= VM_MIXEDMAP;
> +	vma->vm_flags |= (VM_MIXEDMAP|VM_DONTEXPAND);

I'm finding this a bit hard to follow - but I think here we've lost
VM_IO and VM_DONTDUMP which used to be set by drm_gem_mmap().

Also it looks like nothing is fiddling vma->vm_page_prot anymore.

Steve

> +	vma->vm_ops = &drm_gem_shmem_vm_ops;
>  
>  	/* Remove the fake offset */
>  	vma->vm_pgoff -= drm_vma_node_start(&shmem->base.vma_node);
> diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c
> index acb07fe06580..deca0c30bbd4 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_gem.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_gem.c
> @@ -112,7 +112,7 @@ static const struct drm_gem_object_funcs panfrost_gem_funcs = {
>  	.get_sg_table = drm_gem_shmem_get_sg_table,
>  	.vmap = drm_gem_shmem_vmap,
>  	.vunmap = drm_gem_shmem_vunmap,
> -	.vm_ops = &drm_gem_shmem_vm_ops,
> +	.mmap = drm_gem_shmem_mmap,
>  };
>  
>  /**
> diff --git a/drivers/gpu/drm/v3d/v3d_bo.c b/drivers/gpu/drm/v3d/v3d_bo.c
> index a22b75a3a533..edd299ab53d8 100644
> --- a/drivers/gpu/drm/v3d/v3d_bo.c
> +++ b/drivers/gpu/drm/v3d/v3d_bo.c
> @@ -58,7 +58,7 @@ static const struct drm_gem_object_funcs v3d_gem_funcs = {
>  	.get_sg_table = drm_gem_shmem_get_sg_table,
>  	.vmap = drm_gem_shmem_vmap,
>  	.vunmap = drm_gem_shmem_vunmap,
> -	.vm_ops = &drm_gem_shmem_vm_ops,
> +	.mmap = drm_gem_shmem_mmap,
>  };
>  
>  /* gem_create_object function for allocating a BO struct and doing
> diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c
> index 69a3d310ff70..017a9e0fc3bb 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_object.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_object.c
> @@ -86,7 +86,7 @@ static const struct drm_gem_object_funcs virtio_gpu_gem_funcs = {
>  	.get_sg_table = drm_gem_shmem_get_sg_table,
>  	.vmap = drm_gem_shmem_vmap,
>  	.vunmap = drm_gem_shmem_vunmap,
> -	.vm_ops = &drm_gem_shmem_vm_ops,
> +	.mmap = &drm_gem_shmem_mmap,
>  };
>  
>  struct drm_gem_object *virtio_gpu_create_object(struct drm_device *dev,
> 


  reply	other threads:[~2019-09-13 14:03 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190913122908.784-1-kraxel@redhat.com>
2019-09-13 12:29 ` [PATCH 1/8] drm: add mmap() to drm_gem_object_funcs Gerd Hoffmann
2019-09-17 13:27   ` Daniel Vetter
2019-09-13 12:29 ` [PATCH 2/8] drm/shmem: switch shmem helper to &drm_gem_object_funcs.mmap Gerd Hoffmann
2019-09-13 14:03   ` Steven Price [this message]
2019-09-17  8:14     ` Gerd Hoffmann
2019-09-13 12:29 ` [PATCH 3/8] drm/shmem: drop DEFINE_DRM_GEM_SHMEM_FOPS Gerd Hoffmann
2019-09-16 22:07   ` Rob Herring
2019-09-17  8:18     ` Gerd Hoffmann
2019-09-13 12:29 ` [PATCH 4/8] drm/ttm: factor out ttm_bo_mmap_vma_setup Gerd Hoffmann
2019-09-13 12:56   ` Thomas Zimmermann
2019-09-17  8:26     ` Gerd Hoffmann
2019-09-13 13:05   ` Thomas Zimmermann
2019-09-17  8:34     ` Gerd Hoffmann
2019-09-17  9:38       ` Thomas Zimmermann
2019-09-17  9:54         ` Gerd Hoffmann
2019-09-13 12:29 ` [PATCH 5/8] drm/ttm: add drm_gem_ttm_mmap() Gerd Hoffmann
2019-09-13 13:02   ` Thomas Zimmermann
2019-09-13 12:29 ` [PATCH 6/8] drm/vram: switch vram helper to &drm_gem_object_funcs.mmap() Gerd Hoffmann
2019-09-13 13:10   ` Thomas Zimmermann
2019-09-13 12:29 ` [PATCH 7/8] drm/vram: drop verify_access Gerd Hoffmann
2019-09-13 13:11   ` Thomas Zimmermann
2019-09-13 12:29 ` [PATCH 8/8] drm/vram: drop DRM_VRAM_MM_FILE_OPERATIONS Gerd Hoffmann
2019-09-13 13:18   ` Thomas Zimmermann
2019-09-17  8:39     ` 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=197fdced-cf4a-c59a-47fd-aa5dbf8e04a2@arm.com \
    --to=steven.price@arm.com \
    --cc=airlied@linux.ie \
    --cc=alyssa.rosenzweig@collabora.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kraxel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime.ripard@bootlin.com \
    --cc=sean@poorly.run \
    --cc=tomeu.vizoso@collabora.com \
    --cc=tzimmermann@suse.de \
    --cc=virtualization@lists.linux-foundation.org \
    /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).