dri-devel Archive on lore.kernel.org
 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: [PATCH v11 3/4] drm/virtio: implement userptr resource support
Date: Wed, 02 Dec 2026 10:29:17 +0000	[thread overview]
Message-ID: <sashiko-outbox-245463@kernel.org> (raw)
In-Reply-To: <20261202101658.1209083-4-honghuan@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] drm/virtio: duplicated virtio_gpu_userptr_free() and dead
  userptr struct fields
--

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

drm/virtio: implement userptr resource support

This commit introduces virtio_gpu_object_userptr to pin userspace memory
pages and create blob resources backed by them, including hibernation
restore support.

> diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h
> index f3bbbe4468bf1..635122c68a29c 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_drv.h
> +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
[ ... ]
> @@ -140,12 +141,42 @@ struct virtio_gpu_object_vram {
>  	struct drm_mm_node vram_node;
>  };
>  
> +struct virtio_gpu_object_userptr;
> +
> +struct virtio_gpu_object_userptr_ops {
> +	int (*get_pages)(struct virtio_gpu_object_userptr *userptr);
> +	void (*put_pages)(struct virtio_gpu_object_userptr *userptr);
> +};
> +
> +struct virtio_gpu_object_userptr {
> +	struct virtio_gpu_object base;
> +	const struct virtio_gpu_object_userptr_ops *ops;
> +	/* Protects @pages, @sgt and @dma_mapped. */
> +	struct mutex lock;
> +
> +	uint64_t start;
> +	uint32_t npages;
> +	uint32_t bo_handle;
> +	uint32_t flags;
> +
> +	struct virtio_gpu_device *vgdev;
> +	struct drm_file *file;
> +	struct page **pages;
> +	struct sg_table *sgt;
> +	bool dma_mapped;
> +	enum dma_data_direction dma_dir;
> +	struct mm_struct *mm;
> +};
[ ... ]
> diff --git a/drivers/gpu/drm/virtio/virtgpu_userptr.c b/drivers/gpu/drm/virtio/virtgpu_userptr.c
> new file mode 100644
> index 0000000000000..eddf29bad0094
> --- /dev/null
> +++ b/drivers/gpu/drm/virtio/virtgpu_userptr.c
> @@ -0,0 +1,352 @@
[ ... ]
> +static void virtio_gpu_userptr_free(struct drm_gem_object *obj)
> +{
> +	struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(obj);
> +	struct virtio_gpu_device *vgdev = obj->dev->dev_private;
> +
> +	/*
> +	 * Pages stay pinned until RESOURCE_UNREF finishes. Its callback
> +	 * calls virtio_gpu_cleanup_object to drop them.
> +	 */
> +	if (bo->created) {
> +		virtio_gpu_remove_from_restore_list(bo);
> +		virtio_gpu_cmd_unref_resource(vgdev, bo, false);
> +		virtio_gpu_notify(vgdev);
> +		return;
> +	}
> +
> +	virtio_gpu_cleanup_object(bo);
> +}

[Severity: Low]
This isn't a bug, but virtio_gpu_userptr_free() is identical to
virtio_gpu_free_object() in drivers/gpu/drm/virtio/virtgpu_object.c, which
could be exported and reused instead.

Also, in struct virtio_gpu_object_userptr, bo_handle is never used, file is
assigned in virtio_gpu_userptr_init() (storing an unreferenced drm_file
pointer on an object that can outlive the file descriptor across
asynchronous RESOURCE_UNREF completion) and never read, and
virtio_gpu_object_userptr_ops has only a single implementation so
virtio_gpu_userptr_get_pages() and virtio_gpu_userptr_put_pages() can be
called directly.

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

  reply	other threads:[~2026-12-02 10:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 10:16 [PATCH v11 0/4] drm/virtio: userptr blobs for native-context compute Honglei Huang
2026-12-02 10:16 ` [PATCH v11 1/4] drm/virtio: add VIRTIO_GPU_CAPSET_ROCM capability Honglei Huang
2026-12-02 10:16 ` [PATCH v11 2/4] drm/virtio: add userptr blob resource to the UAPI Honglei Huang
2026-12-02 10:16 ` [PATCH v11 3/4] drm/virtio: implement userptr resource support Honglei Huang
2026-12-02 10:29   ` sashiko-bot [this message]
2026-12-02 10:16 ` [PATCH v11 4/4] drm/virtio: wire blob ioctl creation to userptr objects Honglei Huang

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-245463@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