[PATCH 2/4] drm/virtio: factor out context create cmd
Chia-I Wu
olvaffe at gmail.com
Wed Feb 12 18:46:02 UTC 2020
On Tue, Feb 11, 2020 at 3:56 PM Gurchetan Singh
<gurchetansingh at chromium.org> wrote:
>
> We currently do it when open the DRM fd, let's delay it. First step,
> remove the hyercall from initialization.
>
> Signed-off-by: Gurchetan Singh <gurchetansingh at chromium.org>
> ---
> drivers/gpu/drm/virtio/virtgpu_drv.h | 2 ++
> drivers/gpu/drm/virtio/virtgpu_ioctl.c | 16 ++++++++++++++++
> drivers/gpu/drm/virtio/virtgpu_kms.c | 10 ++++------
> 3 files changed, 22 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h
> index 28aeac8717e1..edaa7b8224a8 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_drv.h
> +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
> @@ -214,6 +214,8 @@ struct virtio_gpu_fpriv {
> /* virtio_ioctl.c */
> #define DRM_VIRTIO_NUM_IOCTLS 10
> extern 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);
> diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> index 89d90e95900f..f1afabaa3a08 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> @@ -33,6 +33,22 @@
>
> #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);
> +}
> +
> static int virtio_gpu_map_ioctl(struct drm_device *dev, void *data,
> struct drm_file *file)
> {
> diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c
> index 44e4c07d0162..e1e1c0821a35 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_kms.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c
> @@ -52,15 +52,13 @@ 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)
> +static int virtio_gpu_context_handle(struct virtio_gpu_device *vgdev)
virtio_gpu_context_id_get, to mirror virtio_gpu_resource_id_get?
> {
> 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);
> return handle;
> }
>
> @@ -256,7 +254,6 @@ 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];
>
> /* can't create contexts without 3d renderer */
> if (!vgdev->has_virgl_3d)
> @@ -267,8 +264,7 @@ 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);
> + id = virtio_gpu_context_handle(vgdev);
> if (id < 0) {
> kfree(vfpriv);
> return id;
> @@ -276,6 +272,8 @@ int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file)
>
> vfpriv->ctx_id = id;
> file->driver_priv = vfpriv;
> + virtio_gpu_create_context(dev, file);
> +
> return 0;
> }
>
> --
> 2.25.0.225.g125e21ebc7-goog
>
More information about the dri-devel
mailing list