drm/virtio: use consistent names for drm_files
Subsystems (3)
Gurchetan Singh
reviewerPATCH v5 1/5 drm/virtio: use consistent names for drm_files
Minor cleanup, change:
- file_priv--> file,
- drm_file --> file.
--- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/gpu/drm/virtio/virtgpu_ioctl.c +10 -10
@@ -34,12 +34,12 @@#include "virtgpu_drv.h" static int virtio_gpu_map_ioctl (struct drm_device *dev,void *data, -struct drm_file *file_priv) +struct drm_file *file) {struct virtio_gpu_device *vgdev = dev->dev_private;struct drm_virtgpu_map *virtio_gpu_map = data; -return virtio_gpu_mode_dumb_mmap (file_priv, vgdev->ddev, +return virtio_gpu_mode_dumb_mmap (file, vgdev->ddev, virtio_gpu_map->handle, &virtio_gpu_map->offset); }
@@ -51,11 +51,11 @@ static int virtio_gpu_map_ioctl(struct drm_device *dev, void *data,* VIRTIO_GPUReleaseInfo struct (first XXX bytes) */ static int virtio_gpu_execbuffer_ioctl (struct drm_device *dev,void *data, -struct drm_file *drm_file) +struct drm_file *file) {struct drm_virtgpu_execbuffer *exbuf = data;struct virtio_gpu_device *vgdev = dev->dev_private; -struct virtio_gpu_fpriv *vfpriv = drm_file->driver_priv; +struct virtio_gpu_fpriv *vfpriv = file->driver_priv;struct virtio_gpu_fence *out_fence;int ret;uint32_t *bo_handles =NULL ;
@@ -116,7 +116,7 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data, goto out_unused_fd; } - buflist =virtio_gpu_array_from_handles (drm_file, bo_handles, + buflist =virtio_gpu_array_from_handles (file, bo_handles, exbuf->num_bo_handles);if (!buflist) { ret = -ENOENT ;
@@ -178,7 +178,7 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data, }static int virtio_gpu_getparam_ioctl (struct drm_device *dev,void *data, -struct drm_file *file_priv) +struct drm_file *file) {struct virtio_gpu_device *vgdev = dev->dev_private;struct drm_virtgpu_getparam *param = data;
@@ -201,7 +201,7 @@ static int virtio_gpu_getparam_ioctl(struct drm_device *dev, void *data, }static int virtio_gpu_resource_create_ioctl (struct drm_device *dev,void *data, -struct drm_file *file_priv) +struct drm_file *file) {struct virtio_gpu_device *vgdev = dev->dev_private;struct drm_virtgpu_resource_create *rc = data;
@@ -252,7 +252,7 @@ static int virtio_gpu_resource_create_ioctl(struct drm_device *dev, void *data,return ret; obj = &qobj->base.base; - ret =drm_gem_handle_create (file_priv, obj, &handle); + ret =drm_gem_handle_create (file, obj, &handle);if (ret) {drm_gem_object_release (obj);return ret;
@@ -265,13 +265,13 @@ static int virtio_gpu_resource_create_ioctl(struct drm_device *dev, void *data, }static int virtio_gpu_resource_info_ioctl (struct drm_device *dev,void *data, -struct drm_file *file_priv) +struct drm_file *file) {struct drm_virtgpu_resource_info *ri = data;struct drm_gem_object *gobj =NULL ;struct virtio_gpu_object *qobj =NULL ; - gobj =drm_gem_object_lookup (file_priv, ri->bo_handle); + gobj =drm_gem_object_lookup (file, ri->bo_handle);if (gobj ==NULL )return -ENOENT ;
Signature · 6 lines
2.25.0.265.gbab2e86ba0-goog _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gurchetan Singh
reviewerPATCH v5 2/5 drm/virtio: factor out context create hyercall
We currently create an OpenGL context when opening the DRM fd if 3D is available.
We may need other context types (VK,..) in the future, and the plan is to have explicit initialization for that.
For explicit initialization to work, we need to factor out virtio_gpu_create_context from driver initialization.
v2: Move context handle initialization too (@olv)
--- drivers/gpu/drm/virtio/virtgpu_drv.h | 2 ++ drivers/gpu/drm/virtio/virtgpu_ioctl.c | 17 +++++++++++++++++ drivers/gpu/drm/virtio/virtgpu_kms.c | 26 ++++++-------------------- 3 files changed, 25 insertions(+), 20 deletions(-)
drivers/gpu/drm/virtio/virtgpu_drv.h +2 -0
@@ -214,6 +214,8 @@ struct virtio_gpu_fpriv {/* virtio_ioctl.c */ #define DRM_VIRTIO_NUM_IOCTLS 10extern struct drm_ioctl_desc virtio_gpu_ioctls[DRM_VIRTIO_NUM_IOCTLS ]; +void virtio_gpu_create_context (struct drm_device *dev, +struct drm_file *file);/* virtio_kms.c */ int virtio_gpu_init (struct drm_device *dev);
drivers/gpu/drm/virtio/virtgpu_ioctl.c +17 -0
@@ -33,6 +33,23 @@#include "virtgpu_drv.h" +void virtio_gpu_create_context (struct drm_device *dev, +struct drm_file *file) +{ +struct virtio_gpu_device *vgdev = dev->dev_private; +struct virtio_gpu_fpriv *vfpriv = file->driver_priv; +char dbgname[TASK_COMM_LEN ]; + +/* can't create contexts without 3d renderer */ +if (!vgdev->has_virgl_3d) +return ; + +get_task_comm (dbgname, current); +virtio_gpu_cmd_context_create (vgdev, vfpriv->ctx_id, +strlen (dbgname), dbgname); +virtio_gpu_notify (vgdev); +} +static int virtio_gpu_map_ioctl (struct drm_device *dev,void *data,struct drm_file *file) {
drivers/gpu/drm/virtio/virtgpu_kms.c +6 -20
@@ -52,19 +52,6 @@ static void virtio_gpu_config_changed_work_func(struct work_struct *work) events_clear, &events_clear); } -static int virtio_gpu_context_create (struct virtio_gpu_device *vgdev, -uint32_t nlen,const char *name) -{ -int handle =ida_alloc (&vgdev->ctx_id_ida,GFP_KERNEL ); - -if (handle <0 ) -return handle; - handle +=1 ; -virtio_gpu_cmd_context_create (vgdev, handle, nlen, name); -virtio_gpu_notify (vgdev); -return handle; -} -static void virtio_gpu_context_destroy (struct virtio_gpu_device *vgdev,uint32_t ctx_id) {
@@ -260,8 +247,7 @@ int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file) {struct virtio_gpu_device *vgdev = dev->dev_private;struct virtio_gpu_fpriv *vfpriv; -int id; -char dbgname[TASK_COMM_LEN ]; +int handle;/* can't create contexts without 3d renderer */ if (!vgdev->has_virgl_3d)
@@ -272,15 +258,15 @@ int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file)if (!vfpriv)return -ENOMEM ; -get_task_comm (dbgname, current); - id =virtio_gpu_context_create (vgdev,strlen (dbgname), dbgname); -if (id <0 ) { + handle =ida_alloc (&vgdev->ctx_id_ida,GFP_KERNEL ); +if (handle <0 ) {kfree (vfpriv); -return id; +return handle; } - vfpriv->ctx_id = id; + vfpriv->ctx_id = handle +1 ; file->driver_priv = vfpriv; +virtio_gpu_create_context (dev, file);return 0 ; }
Signature · 6 lines
2.25.0.265.gbab2e86ba0-goog _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/5 v5] drm/virtio: factor out context create hyercall
Hi Gurchetan,
s/hyercall/hypercall/ in the commit message
drivers/gpu/drm/virtio/virtgpu_ioctl.c line 46
Quoted 11 lines · Gurchetan Singh
drivers/gpu/drm/virtio/virtgpu_ioctl.c +11
-0+void virtio_gpu_create_context (struct drm_device *dev, +struct drm_file *file) +{ +struct virtio_gpu_device *vgdev = dev->dev_private; +struct virtio_gpu_fpriv *vfpriv = file->driver_priv; +char dbgname[TASK_COMM_LEN ]; + +/* can't create contexts without 3d renderer */ +if (!vgdev->has_virgl_3d) +return ; +
This cannot trigger, since we have similar check in the caller virtio_gpu_driver_open().
drivers/gpu/drm/virtio/virtgpu_kms.c int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file) · line 253
Quoted 10 lines
drivers/gpu/drm/virtio/virtgpu_kms.c +1
-2@@ -260,8 +247,7 @@ int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file) {struct virtio_gpu_device *vgdev = dev->dev_private;struct virtio_gpu_fpriv *vfpriv; -int id; -char dbgname[TASK_COMM_LEN ]; +int handle;/* can't create contexts without 3d renderer */ if (!vgdev->has_virgl_3d)
... namely this here.
With either of the two dropped:
-Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gurchetan Singh
reviewerPATCH v5 3/5 drm/virtio: track whether or not a context has been initiated
In reply to Gurchetan SinghUse an atomic variable to track whether a context has been initiated.
v5: Fix possible race and sleep via mutex (@olv)
--- drivers/gpu/drm/virtio/virtgpu_drv.h | 2 ++ drivers/gpu/drm/virtio/virtgpu_ioctl.c | 8 ++++++++ drivers/gpu/drm/virtio/virtgpu_kms.c | 3 +++ 3 files changed, 13 insertions(+)
drivers/gpu/drm/virtio/virtgpu_drv.h +2 -0
@@ -209,6 +209,8 @@ struct virtio_gpu_device {struct virtio_gpu_fpriv {uint32_t ctx_id; +bool context_initiated; +struct mutex context_lock; };/* virtio_ioctl.c */
drivers/gpu/drm/virtio/virtgpu_ioctl.c +8 -0
@@ -44,10 +44,18 @@ void virtio_gpu_create_context(struct drm_device *dev,if (!vgdev->has_virgl_3d)return ; +mutex_lock (&vfpriv->context_lock); +if (vfpriv->context_initiated) + goto out_unlock; +get_task_comm (dbgname, current);virtio_gpu_cmd_context_create (vgdev, vfpriv->ctx_id,strlen (dbgname), dbgname);virtio_gpu_notify (vgdev); + vfpriv->context_initiated = true; + +out_unlock: +mutex_unlock (&vfpriv->context_lock); } static int virtio_gpu_map_ioctl(struct drm_device *dev, void *data,
drivers/gpu/drm/virtio/virtgpu_kms.c +3 -0
@@ -258,6 +258,8 @@ int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file)if (!vfpriv)return -ENOMEM ; +mutex_init (&vfpriv->context_lock); + handle =ida_alloc (&vgdev->ctx_id_ida,GFP_KERNEL );if (handle <0 ) {kfree (vfpriv);
@@ -281,6 +283,7 @@ void virtio_gpu_driver_postclose(struct drm_device *dev, struct drm_file *file) vfpriv = file->driver_priv;virtio_gpu_context_destroy (vgdev, vfpriv->ctx_id); +mutex_destroy (&vfpriv->context_lock);kfree (vfpriv); file->driver_priv =NULL ; }
Signature · 6 lines
2.25.0.265.gbab2e86ba0-goog _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 3/5 v5] drm/virtio: track whether or not a context has been initiated
Quoted 7 lines · Gurchetan Singh
Use an atomic variable to track whether a context has been initiated.
v5: Fix possible race and sleep via mutex (@olv)
Signed-off-by Gurchetan Singh <[email protected]>
-Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 3/5 v5] drm/virtio: track whether or not a context has been initiated
In reply to Gurchetan SinghPatch 1-4 are
I think we can drop patch 5 for now.
Quoted 18 lines · Gurchetan Singh
Use an atomic variable to track whether a context has been initiated.
v5: Fix possible race and sleep via mutex (@olv)
Signed-off-by Gurchetan Singh <[email protected]>--- drivers/gpu/drm/virtio/virtgpu_drv.h | 2 ++ drivers/gpu/drm/virtio/virtgpu_ioctl.c | 8 ++++++++ drivers/gpu/drm/virtio/virtgpu_kms.c | 3 +++ 3 files changed, 13 insertions(+)drivers/gpu/drm/virtio/virtgpu_drv.h +0
-0
drivers/gpu/drm/virtio/virtgpu_drv.h struct virtio_gpu_device { · line 212
Quoted 4 lines
drivers/gpu/drm/virtio/virtgpu_drv.h +1
-0@@ -209,6 +209,8 @@ struct virtio_gpu_device {struct virtio_gpu_fpriv {uint32_t ctx_id; +bool context_initiated;
ctx_id and context_initialized are named hw_res_handle and created respectively in virtio_gpu_object. I think we should use "hw", "id"/"handle", "initialized"/"created" more consistently.
This is just a nitpick, and does not need to be a part of this series.
Quoted 49 lines
drivers/gpu/drm/virtio/virtgpu_drv.h +1
-0+struct mutex context_lock; };/* virtio_ioctl.c */ drivers/gpu/drm/virtio/virtgpu_ioctl.c +8
-0@@ -44,10 +44,18 @@ void virtio_gpu_create_context(struct drm_device *dev,if (!vgdev->has_virgl_3d)return ; +mutex_lock (&vfpriv->context_lock); +if (vfpriv->context_initiated) + goto out_unlock; +get_task_comm (dbgname, current);virtio_gpu_cmd_context_create (vgdev, vfpriv->ctx_id,strlen (dbgname), dbgname);virtio_gpu_notify (vgdev); + vfpriv->context_initiated = true; + +out_unlock: +mutex_unlock (&vfpriv->context_lock); } static int virtio_gpu_map_ioctl(struct drm_device *dev, void *data,drivers/gpu/drm/virtio/virtgpu_kms.c +3
-1@@ -258,6 +258,8 @@ int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file)if (!vfpriv)return -ENOMEM ; +mutex_init (&vfpriv->context_lock); + handle =ida_alloc (&vgdev->ctx_id_ida,GFP_KERNEL );if (handle <0 ) {kfree (vfpriv);@@ -281,6 +283,7 @@ void virtio_gpu_driver_postclose(struct drm_device *dev, struct drm_file *file) vfpriv = file->driver_priv;virtio_gpu_context_destroy (vgdev, vfpriv->ctx_id); +mutex_destroy (&vfpriv->context_lock);kfree (vfpriv); file->driver_priv =NULL ; } --
Quoted 2 lines
2.25.0.265.gbab2e86ba0-goog
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gurchetan Singh
reviewerPATCH v5 4/5 drm/virtio: enqueue virtio_gpu_create_context after the first 3D ioctl
In reply to Gurchetan SinghFor old userspace, initialization will still be implicit.
For backwards compatibility, enqueue virtio_gpu_cmd_context_create after the first 3D ioctl.
v3: staticify virtio_gpu_create_context
remove notify to batch vm-exit
--- drivers/gpu/drm/virtio/virtgpu_drv.h | 2 -- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 10 +++++++--- drivers/gpu/drm/virtio/virtgpu_kms.c | 1 - 3 files changed, 7 insertions(+), 6 deletions(-)
drivers/gpu/drm/virtio/virtgpu_drv.h +0 -2
@@ -216,8 +216,6 @@ struct virtio_gpu_fpriv {/* virtio_ioctl.c */ #define DRM_VIRTIO_NUM_IOCTLS 10extern struct drm_ioctl_desc virtio_gpu_ioctls[DRM_VIRTIO_NUM_IOCTLS ]; -void virtio_gpu_create_context (struct drm_device *dev, -struct drm_file *file);/* virtio_kms.c */ int virtio_gpu_init (struct drm_device *dev);
drivers/gpu/drm/virtio/virtgpu_ioctl.c +7 -3
@@ -33,8 +33,8 @@#include "virtgpu_drv.h" -void virtio_gpu_create_context (struct drm_device *dev, -struct drm_file *file) +static void virtio_gpu_create_context (struct drm_device *dev, +struct drm_file *file) {struct virtio_gpu_device *vgdev = dev->dev_private;struct virtio_gpu_fpriv *vfpriv = file->driver_priv;
@@ -51,7 +51,6 @@ void virtio_gpu_create_context(struct drm_device *dev,get_task_comm (dbgname, current);virtio_gpu_cmd_context_create (vgdev, vfpriv->ctx_id,strlen (dbgname), dbgname); -virtio_gpu_notify (vgdev); vfpriv->context_initiated = true; out_unlock:
@@ -99,6 +98,7 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data, exbuf->fence_fd =-1 ; +virtio_gpu_create_context (dev, file);if (exbuf->flags &VIRTGPU_EXECBUF_FENCE_FD_IN ) {struct dma_fence *in_fence;
@@ -250,6 +250,7 @@ static int virtio_gpu_resource_create_ioctl(struct drm_device *dev, void *data,return -EINVAL ; } +virtio_gpu_create_context (dev, file); params.format = rc->format; params.width = rc->width; params.height = rc->height;
@@ -323,6 +324,7 @@ static int virtio_gpu_transfer_from_host_ioctl(struct drm_device *dev,if (vgdev->has_virgl_3d == false)return -ENOSYS ; +virtio_gpu_create_context (dev, file); objs =virtio_gpu_array_from_handles (file, &args->bo_handle,1 );if (objs ==NULL )return -ENOENT ;
@@ -371,6 +373,7 @@ static int virtio_gpu_transfer_to_host_ioctl(struct drm_device *dev, void *data, args->box.w, args->box.h, args->box.x, args->box.y, objs, NULL); }else { +virtio_gpu_create_context (dev, file); ret =virtio_gpu_array_lock_resv (objs);if (ret !=0 ) goto err_put_free;
@@ -471,6 +474,7 @@ static int virtio_gpu_get_caps_ioctl(struct drm_device *dev,spin_unlock (&vgdev->display_info_lock);/* not in cache - need to talk to hw */ +virtio_gpu_create_context (dev, file);virtio_gpu_cmd_get_capset (vgdev, found_valid, args->cap_set_ver, &cache_ent);virtio_gpu_notify (vgdev);
drivers/gpu/drm/virtio/virtgpu_kms.c +0 -1
@@ -268,7 +268,6 @@ int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file) vfpriv->ctx_id = handle +1 ; file->driver_priv = vfpriv; -virtio_gpu_create_context (dev, file);return 0 ; }
Signature · 6 lines
2.25.0.265.gbab2e86ba0-goog _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 4/5 v5] drm/virtio: enqueue virtio_gpu_create_context after the first 3D ioctl
Quoted 9 lines · Gurchetan Singh
For old userspace, initialization will still be implicit.
For backwards compatibility, enqueue
virtio_gpu_cmd_context_createafter the first 3D ioctl.v3: staticify
virtio_gpu_create_context
remove notify to batch vm-exit
Similar to 2/5 I suspect we have nested has_virgl_3d checking.
Quoted 25 lines
Signed-off-by Gurchetan Singh <[email protected]>--- drivers/gpu/drm/virtio/virtgpu_drv.h | 2 -- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 10 +++++++--- drivers/gpu/drm/virtio/virtgpu_kms.c | 1 - 3 files changed, 7 insertions(+), 6 deletions(-)drivers/gpu/drm/virtio/virtgpu_drv.h +0
-2@@ -216,8 +216,6 @@ struct virtio_gpu_fpriv {/* virtio_ioctl.c */ #define DRM_VIRTIO_NUM_IOCTLS 10extern struct drm_ioctl_desc virtio_gpu_ioctls[DRM_VIRTIO_NUM_IOCTLS ]; -void virtio_gpu_create_context (struct drm_device *dev, -struct drm_file *file);/* virtio_kms.c */ int virtio_gpu_init (struct drm_device *dev);drivers/gpu/drm/virtio/virtgpu_ioctl.c +0
-0
drivers/gpu/drm/virtio/virtgpu_ioctl.c line 38
Quoted 8 lines
drivers/gpu/drm/virtio/virtgpu_ioctl.c +2
-2@@ -33,8 +33,8 @@#include "virtgpu_drv.h" -void virtio_gpu_create_context (struct drm_device *dev, -struct drm_file *file) +static void virtio_gpu_create_context (struct drm_device *dev, +struct drm_file *file) {
In this function...
drivers/gpu/drm/virtio/virtgpu_ioctl.c static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data, · line 98
Quoted 12 lines
drivers/gpu/drm/virtio/virtgpu_ioctl.c +0
-1struct virtio_gpu_device *vgdev = dev->dev_private;struct virtio_gpu_fpriv *vfpriv = file->driver_priv;@@ -51,7 +51,6 @@ void virtio_gpu_create_context(struct drm_device *dev,get_task_comm (dbgname, current);virtio_gpu_cmd_context_create (vgdev, vfpriv->ctx_id,strlen (dbgname), dbgname); -virtio_gpu_notify (vgdev); vfpriv->context_initiated = true; out_unlock:@@ -99,6 +98,7 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data,
... and this caller, just a couple of lines above.
drivers/gpu/drm/virtio/virtgpu_ioctl.c static int virtio_gpu_resource_create_ioctl(struct drm_device *dev, void *data, · line 252
Quoted 10 lines
drivers/gpu/drm/virtio/virtgpu_ioctl.c +1
-0exbuf->fence_fd =-1 ; +virtio_gpu_create_context (dev, file);if (exbuf->flags &VIRTGPU_EXECBUF_FENCE_FD_IN ) {struct dma_fence *in_fence;@@ -250,6 +250,7 @@ static int virtio_gpu_resource_create_ioctl(struct drm_device *dev, void *data,return -EINVAL ; }
Unrelated: might be a good idea to sort the has_virgl_3d == false EINVAL handling like the has_virgl_3d == true hunk just below. Bonus points for a comment explaining we don't check for the bind and flags arguments.
drivers/gpu/drm/virtio/virtgpu_ioctl.c static int virtio_gpu_transfer_from_host_ioctl(struct drm_device *dev, · line 326
Quoted 8 lines
drivers/gpu/drm/virtio/virtgpu_ioctl.c +1
-0+virtio_gpu_create_context (dev, file); params.format = rc->format; params.width = rc->width; params.height = rc->height;@@ -323,6 +324,7 @@ static int virtio_gpu_transfer_from_host_ioctl(struct drm_device *dev,if (vgdev->has_virgl_3d == false)return -ENOSYS ;
... and this caller.
drivers/gpu/drm/virtio/virtgpu_ioctl.c static int virtio_gpu_transfer_to_host_ioctl(struct drm_device *dev, void *data, · line 375
Quoted 8 lines
drivers/gpu/drm/virtio/virtgpu_ioctl.c +1
-0+virtio_gpu_create_context (dev, file); objs =virtio_gpu_array_from_handles (file, &args->bo_handle,1 );if (objs ==NULL )return -ENOENT ;@@ -371,6 +373,7 @@ static int virtio_gpu_transfer_to_host_ioctl(struct drm_device *dev, void *data, args->box.w, args->box.h, args->box.x, args->box.y, objs, NULL); }else {
... and this caller, just a couple of lines above.
With the trivial comments addressed:
-Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gurchetan Singh
reviewerPATCH v5 5/5 drm/virtio: add virtio_gpu_context_type
In reply to Gurchetan SinghWe'll have to do something like this eventually, and this conveys we want a Virgl context by default.
--- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
drivers/gpu/drm/virtio/virtgpu_ioctl.c +17 -6
@@ -33,8 +33,14 @@#include "virtgpu_drv.h" +/* TODO: add more context types */ +enum virtio_gpu_context_type { + virtio_gpu_virgl_context, +}; +static void virtio_gpu_create_context (struct drm_device *dev, -struct drm_file *file) +struct drm_file *file, +enum virtio_gpu_context_type type) {struct virtio_gpu_device *vgdev = dev->dev_private;struct virtio_gpu_fpriv *vfpriv = file->driver_priv;
@@ -44,6 +50,11 @@ static void virtio_gpu_create_context(struct drm_device *dev,if (!vgdev->has_virgl_3d)return ; +if (type != virtio_gpu_virgl_context) { +DRM_ERROR ("Unsupported context type: %u\n" , type); +return ; + } +mutex_lock (&vfpriv->context_lock);if (vfpriv->context_initiated) goto out_unlock;
@@ -98,7 +109,7 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data, exbuf->fence_fd =-1 ; -virtio_gpu_create_context (dev, file); +virtio_gpu_create_context (dev, file, virtio_gpu_virgl_context);if (exbuf->flags &VIRTGPU_EXECBUF_FENCE_FD_IN ) {struct dma_fence *in_fence;
@@ -250,7 +261,7 @@ static int virtio_gpu_resource_create_ioctl(struct drm_device *dev, void *data,return -EINVAL ; } -virtio_gpu_create_context (dev, file); +virtio_gpu_create_context (dev, file, virtio_gpu_virgl_context); params.format = rc->format; params.width = rc->width; params.height = rc->height;
@@ -324,7 +335,7 @@ static int virtio_gpu_transfer_from_host_ioctl(struct drm_device *dev,if (vgdev->has_virgl_3d == false)return -ENOSYS ; -virtio_gpu_create_context (dev, file); +virtio_gpu_create_context (dev, file, virtio_gpu_virgl_context); objs =virtio_gpu_array_from_handles (file, &args->bo_handle,1 );if (objs ==NULL )return -ENOENT ;
@@ -373,7 +384,7 @@ static int virtio_gpu_transfer_to_host_ioctl(struct drm_device *dev, void *data, args->box.w, args->box.h, args->box.x, args->box.y, objs, NULL); }else { -virtio_gpu_create_context (dev, file); +virtio_gpu_create_context (dev, file, virtio_gpu_virgl_context); ret =virtio_gpu_array_lock_resv (objs);if (ret !=0 ) goto err_put_free;
@@ -474,7 +485,7 @@ static int virtio_gpu_get_caps_ioctl(struct drm_device *dev,spin_unlock (&vgdev->display_info_lock);/* not in cache - need to talk to hw */ -virtio_gpu_create_context (dev, file); +virtio_gpu_create_context (dev, file, virtio_gpu_virgl_context);virtio_gpu_cmd_get_capset (vgdev, found_valid, args->cap_set_ver, &cache_ent);virtio_gpu_notify (vgdev);
Signature · 6 lines
2.25.0.265.gbab2e86ba0-goog _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 5/5 v5] drm/virtio: add virtio_gpu_context_type
Quoted 5 lines · Gurchetan Singh
We'll have to do something like this eventually, and this conveys we want a Virgl context by default.
Signed-off-by Gurchetan Singh <[email protected]>
HTH
Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 7 lines · Gurchetan Singh
Minor cleanup, change:
- file_priv--> file,
-drm_file--> file.Signed-off-by Gurchetan Singh <[email protected]>
-Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel