Linux virtualization list
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Honglei Huang" <honghuan@amd.com>
Cc: dri-devel@lists.freedesktop.org, virtualization@lists.linux.dev,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [RFC PATCH v10 4/4] drm/virtio: wire blob ioctl creation to userptr objects
Date: Fri, 06 Nov 2026 08:42:28 +0000	[thread overview]
Message-ID: <sashiko-outbox-201084@kernel.org> (raw)
In-Reply-To: <20261106082625.812860-5-honghuan@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/virtio: unnotified ctrlq strands blob on handle creation
  failure
--

commit f8b823e6be2332eb525d4e0d0576cd0869cd03e1
Author: Honglei Huang <honghuan@amd.com>

drm/virtio: wire blob ioctl creation to userptr objects

This commit integrates userptr creation and read-only blob support into
the blob resource creation and getparam ioctls, and switches the error
paths in virtio_gpu_resource_create_blob_ioctl() from
drm_gem_object_release() to drm_gem_object_put().

> diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> index 3d8e4ccdb7c1f..e57750588df01 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
[ ... ]
> @@ -557,14 +586,14 @@ static int virtio_gpu_resource_create_blob_ioctl(struct drm_device *dev,
>  	if (params.blob_flags & VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE) {
>  		ret = virtio_gpu_resource_assign_uuid(vgdev, bo);
>  		if (ret) {
> -			drm_gem_object_release(obj);
> +			drm_gem_object_put(obj);
>  			return ret;
>  		}
>  	}
>  
>  	ret = drm_gem_handle_create(file, obj, &handle);
>  	if (ret) {
> -		drm_gem_object_release(obj);
> +		drm_gem_object_put(obj);
>  		return ret;
>  	}

[Severity: Medium]
Can this leave obj stranded in vgdev->ctrlq when drm_gem_handle_create()
fails after virtio_gpu_resource_assign_uuid() succeeds?

Neither the blob creation helpers nor virtio_gpu_resource_assign_uuid()
call virtio_gpu_notify(vgdev); notification normally happens at the end
of virtio_gpu_gem_object_open() inside drm_gem_handle_create().  However,
virtio_gpu_resource_assign_uuid() takes an extra reference on obj via
virtio_gpu_array_add_obj() for the queued command buffer:

drivers/gpu/drm/virtio/virtgpu_prime.c:virtio_gpu_resource_assign_uuid() {
	objs = virtio_gpu_array_alloc(1);
	if (!objs)
		return -ENOMEM;

	virtio_gpu_array_add_obj(objs, &bo->base.base);

	return virtio_gpu_cmd_resource_assign_uuid(vgdev, objs);
}

If drm_gem_handle_create() fails before virtio_gpu_gem_object_open()
reaches virtio_gpu_notify(vgdev), drm_gem_object_put(obj) only drops
obj->refcount from 2 to 1.  Because the refcount does not reach 0,
obj->funcs->free() is not called, leaving the queued commands un-kicked
and keeping userptr pages pinned and charged to mm->pinned_vm until an
unrelated command notifies ctrlq.  Calling virtio_gpu_notify(vgdev) on
the drm_gem_handle_create() failure path would ensure the queued command
completes and drops its reference.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261106082625.812860-1-honghuan@amd.com?part=4

      reply	other threads:[~2026-11-06  8:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06  8:26 [RFC PATCH v10 0/4] drm/virtio: userptr blobs for native-context compute Honglei Huang
2026-11-06  8:26 ` [RFC PATCH v10 1/4] drm/virtio: add VIRTIO_GPU_CAPSET_ROCM capability Honglei Huang
2026-11-06  8:30   ` sashiko-bot
2026-11-06  8:26 ` [RFC PATCH v10 2/4] drm/virtio: add userptr blob resource to the UAPI Honglei Huang
2026-11-06  8:34   ` sashiko-bot
2026-11-06  8:26 ` [RFC PATCH v10 3/4] drm/virtio: implement userptr resource support Honglei Huang
2026-11-06  8:45   ` sashiko-bot
2026-11-06  8:26 ` [RFC PATCH v10 4/4] drm/virtio: wire blob ioctl creation to userptr objects Honglei Huang
2026-11-06  8:42   ` sashiko-bot [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=sashiko-outbox-201084@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=eperezma@redhat.com \
    --cc=honghuan@amd.com \
    --cc=mst@redhat.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --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