mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dmitry Osipenko <dmitry.osipenko@collabora.com>
To: Peter Shkenev <mustela@erminea.space>,
	David Airlie <airlied@redhat.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Gurchetan Singh <gurchetansingh@chromium.org>,
	Chia-I Wu <olvaffe@gmail.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Simona Vetter <simona@ffwll.ch>,
	dri-devel@lists.freedesktop.org, virtualization@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/virtio: use generic dumb_map_offset implementation
Date: Mon, 21 Oct 2024 07:17:07 +0300	[thread overview]
Message-ID: <d81b181b-ef81-4533-aa9d-1084e2b26da2@collabora.com> (raw)
In-Reply-To: <20241014170801.71231-1-mustela@erminea.space>

On 10/14/24 20:07, Peter Shkenev wrote:
> Currently, virtio uses its own dumb_map_offset implementation,
> virtio_gpu_mode_dumb_mmap. It works similarly to generic implementation,
> drm_gem_dumb_map_offset, and using the generic implementation is
> preferable (and making drivers to do so is a task stated on the DRM
> subsystem's TODO list).
> 
> Thus, make driver use the generic implementation. This includes
> VIRTGPU_MAP ioctl so it cannot be used to circumvent rules imposed by
> drm_gem_dumb_map_offset (imported objects cannot be mapped).
> 
> Signed-off-by: Peter Shkenev <mustela@erminea.space>
> ---
>  drivers/gpu/drm/virtio/virtgpu_drv.c   |  1 -
>  drivers/gpu/drm/virtio/virtgpu_gem.c   | 15 ---------------
>  drivers/gpu/drm/virtio/virtgpu_ioctl.c |  3 ++-
>  3 files changed, 2 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c b/drivers/gpu/drm/virtio/virtgpu_drv.c
> index ffca6e2e1c9a..909808398d66 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_drv.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_drv.c
> @@ -184,7 +184,6 @@ static const struct drm_driver driver = {
>  	.postclose = virtio_gpu_driver_postclose,
>  
>  	.dumb_create = virtio_gpu_mode_dumb_create,
> -	.dumb_map_offset = virtio_gpu_mode_dumb_mmap,
>  
>  	DRM_FBDEV_SHMEM_DRIVER_OPS,
>  
> diff --git a/drivers/gpu/drm/virtio/virtgpu_gem.c b/drivers/gpu/drm/virtio/virtgpu_gem.c
> index 7db48d17ee3a..aefbb49481f1 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_gem.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_gem.c
> @@ -99,21 +99,6 @@ int virtio_gpu_mode_dumb_create(struct drm_file *file_priv,
>  	return ret;
>  }
>  
> -int virtio_gpu_mode_dumb_mmap(struct drm_file *file_priv,
> -			      struct drm_device *dev,
> -			      uint32_t handle, uint64_t *offset_p)
> -{
> -	struct drm_gem_object *gobj;
> -
> -	BUG_ON(!offset_p);
> -	gobj = drm_gem_object_lookup(file_priv, handle);
> -	if (gobj == NULL)
> -		return -ENOENT;
> -	*offset_p = drm_vma_node_offset_addr(&gobj->vma_node);
> -	drm_gem_object_put(gobj);
> -	return 0;
> -}
> -
>  int virtio_gpu_gem_object_open(struct drm_gem_object *obj,
>  			       struct drm_file *file)
>  {
> diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> index e4f76f315550..13f3ed60a0e5 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> @@ -30,6 +30,7 @@
>  #include <linux/uaccess.h>
>  
>  #include <drm/drm_file.h>
> +#include <drm/drm_gem.h>

This include shouldn't be needed as drm_gem.h is included by virtgpu_drv.h

>  #include <drm/virtgpu_drm.h>
>  
>  #include "virtgpu_drv.h"
> @@ -80,7 +81,7 @@ static int virtio_gpu_map_ioctl(struct drm_device *dev, void *data,
>  	struct virtio_gpu_device *vgdev = dev->dev_private;
>  	struct drm_virtgpu_map *virtio_gpu_map = data;
>  
> -	return virtio_gpu_mode_dumb_mmap(file, vgdev->ddev,
> +	return drm_gem_dumb_map_offset(file, vgdev->ddev,
>  					 virtio_gpu_map->handle,
>  					 &virtio_gpu_map->offset);
>  }

Please remove obsoleted virtio_gpu_mode_dumb_mmap() prototype from
virtgpu_drv.h

Otherwise patch looks good.

-- 
Best regards,
Dmitry


      reply	other threads:[~2024-10-21  4:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-14 17:07 Peter Shkenev
2024-10-21  4:17 ` Dmitry Osipenko [this message]

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=d81b181b-ef81-4533-aa9d-1084e2b26da2@collabora.com \
    --to=dmitry.osipenko@collabora.com \
    --cc=airlied@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gurchetansingh@chromium.org \
    --cc=kraxel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=mustela@erminea.space \
    --cc=olvaffe@gmail.com \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    --cc=virtualization@lists.linux.dev \
    /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

all inboxes | Powered by JetHome®