[PATCH 3/3] drm/virtio: implement debug name via CONTEXT_INIT
Dmitry Osipenko
dmitry.osipenko at collabora.com
Mon Oct 16 20:39:03 UTC 2023
On 10/16/23 21:42, Gurchetan Singh wrote:
> This allows setting the debug name during CONTEXT_INIT.
>
> Signed-off-by: Gurchetan Singh <gurchetansingh at chromium.org>
> ---
> drivers/gpu/drm/virtio/virtgpu_drv.h | 4 +++
> drivers/gpu/drm/virtio/virtgpu_ioctl.c | 38 ++++++++++++++++++++++----
> 2 files changed, 36 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h
> index 96365a772f77..c0702d630e05 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_drv.h
> +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
> @@ -58,6 +58,8 @@
> #define MAX_CAPSET_ID 63
> #define MAX_RINGS 64
>
> +#define DEBUG_NAME_MAX_LEN 64
> +
> struct virtio_gpu_object_params {
> unsigned long size;
> bool dumb;
> @@ -274,6 +276,8 @@ struct virtio_gpu_fpriv {
> uint64_t base_fence_ctx;
> uint64_t ring_idx_mask;
> struct mutex context_lock;
> + char debug_name[DEBUG_NAME_MAX_LEN];
> + char explicit_debug_name;
bool
> };
>
> /* virtgpu_ioctl.c */
> diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> index 8d13b17c215b..4d6d44a4c899 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> @@ -42,12 +42,19 @@
> static void virtio_gpu_create_context_locked(struct virtio_gpu_device *vgdev,
> struct virtio_gpu_fpriv *vfpriv)
> {
> - char dbgname[TASK_COMM_LEN];
> + if (vfpriv->explicit_debug_name) {
> + virtio_gpu_cmd_context_create(vgdev, vfpriv->ctx_id,
> + vfpriv->context_init,
> + strlen(vfpriv->debug_name),
> + vfpriv->debug_name);
> + } else {
> + char dbgname[TASK_COMM_LEN];
>
> - get_task_comm(dbgname, current);
> - virtio_gpu_cmd_context_create(vgdev, vfpriv->ctx_id,
> - vfpriv->context_init, strlen(dbgname),
> - dbgname);
> + get_task_comm(dbgname, current);
> + virtio_gpu_cmd_context_create(vgdev, vfpriv->ctx_id,
> + vfpriv->context_init, strlen(dbgname),
> + dbgname);
> + }
>
> vfpriv->context_created = true;
> }
> @@ -107,6 +114,9 @@ static int virtio_gpu_getparam_ioctl(struct drm_device *dev, void *data,
> case VIRTGPU_PARAM_SUPPORTED_CAPSET_IDs:
> value = vgdev->capset_id_mask;
> break;
> + case VIRTGPU_PARAM_EXPLICIT_DEBUG_NAME:
> + value = vgdev->has_context_init ? 1 : 0;
> + break;
> default:
> return -EINVAL;
> }
> @@ -580,7 +590,7 @@ static int virtio_gpu_context_init_ioctl(struct drm_device *dev,
> return -EINVAL;
>
> /* Number of unique parameters supported at this time. */
> - if (num_params > 3)
> + if (num_params > 4)
> return -EINVAL;
>
> ctx_set_params = memdup_user(u64_to_user_ptr(args->ctx_set_params),
> @@ -642,6 +652,22 @@ static int virtio_gpu_context_init_ioctl(struct drm_device *dev,
>
> vfpriv->ring_idx_mask = value;
> break;
> + case VIRTGPU_CONTEXT_PARAM_DEBUG_NAME:
> + if (vfpriv->explicit_debug_name) {
> + ret = -EINVAL;
> + goto out_unlock;
> + }
> +
> + ret = strncpy_from_user(vfpriv->debug_name,
> + (const char __user *)u64_to_user_ptr(value),
casting not needed
> + DEBUG_NAME_MAX_LEN);
DEBUG_NAME_MAX_LEN - 1
--
Best regards,
Dmitry
More information about the dri-devel
mailing list