Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/virtio: Use generic dumb_map_offset implementation

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>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
[dmitry.osipenko@collabora.com: cosmetic code improvements]
Link: https://patchwork.freedesktop.org/patch/msgid/20241107141133.13624-1-mustela@erminea.space

authored by

Peter Shkenev and committed by
Dmitry Osipenko
c85021f3 7d2faa8d

+3 -22
-1
drivers/gpu/drm/virtio/virtgpu_drv.c
··· 184 184 .postclose = virtio_gpu_driver_postclose, 185 185 186 186 .dumb_create = virtio_gpu_mode_dumb_create, 187 - .dumb_map_offset = virtio_gpu_mode_dumb_mmap, 188 187 189 188 DRM_FBDEV_SHMEM_DRIVER_OPS, 190 189
-3
drivers/gpu/drm/virtio/virtgpu_drv.h
··· 301 301 int virtio_gpu_mode_dumb_create(struct drm_file *file_priv, 302 302 struct drm_device *dev, 303 303 struct drm_mode_create_dumb *args); 304 - int virtio_gpu_mode_dumb_mmap(struct drm_file *file_priv, 305 - struct drm_device *dev, 306 - uint32_t handle, uint64_t *offset_p); 307 304 308 305 struct virtio_gpu_object_array *virtio_gpu_array_alloc(u32 nents); 309 306 struct virtio_gpu_object_array*
-15
drivers/gpu/drm/virtio/virtgpu_gem.c
··· 99 99 return ret; 100 100 } 101 101 102 - int virtio_gpu_mode_dumb_mmap(struct drm_file *file_priv, 103 - struct drm_device *dev, 104 - uint32_t handle, uint64_t *offset_p) 105 - { 106 - struct drm_gem_object *gobj; 107 - 108 - BUG_ON(!offset_p); 109 - gobj = drm_gem_object_lookup(file_priv, handle); 110 - if (gobj == NULL) 111 - return -ENOENT; 112 - *offset_p = drm_vma_node_offset_addr(&gobj->vma_node); 113 - drm_gem_object_put(gobj); 114 - return 0; 115 - } 116 - 117 102 int virtio_gpu_gem_object_open(struct drm_gem_object *obj, 118 103 struct drm_file *file) 119 104 {
+3 -3
drivers/gpu/drm/virtio/virtgpu_ioctl.c
··· 80 80 struct virtio_gpu_device *vgdev = dev->dev_private; 81 81 struct drm_virtgpu_map *virtio_gpu_map = data; 82 82 83 - return virtio_gpu_mode_dumb_mmap(file, vgdev->ddev, 84 - virtio_gpu_map->handle, 85 - &virtio_gpu_map->offset); 83 + return drm_gem_dumb_map_offset(file, vgdev->ddev, 84 + virtio_gpu_map->handle, 85 + &virtio_gpu_map->offset); 86 86 } 87 87 88 88 static int virtio_gpu_getparam_ioctl(struct drm_device *dev, void *data,