From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38D31606A322 for ; Wed, 2 Dec 2026 10:29:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lCQVTcZi Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9F31810E5C6; Wed, 2 Dec 2026 10:29:24 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5B7F510E5C6 for ; Wed, 2 Dec 2026 10:29:18 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 1631842D9E; Wed, 2 Dec 2026 10:29:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B787A1F0089C; Wed, 2 Dec 2026 10:29:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796207357; bh=JevainWcomTflpYCQvsYgk1Hc7fP+74AVU3CqCod9+s=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=lCQVTcZiqMlJPOjGwlEqIXrQivfKQ85UP7d5XFZZKvWhjSpSSDQsNS8C/kSVzPISz ma3T9XcjvHKtWFxPqQv+9HsUuthH5vgQqAAivv08FD4Bms51XIInlCZ3V1DLhVtdgK VAyenUWfbv9gMQqd1x5UZdi4QpbelFpL0DjDeRsOpK+/Tja2e4iopyP7dD81s7PYDz yU4mcjnYTMDkIp2uySopbB3ZruUiWCj4wDd7QZhXJIDm4TNAr5MyGNHoQEXMKzPzMQ dJfqmw/izNtyO/0PvwEaQZ8un9C/By6C30o2Ii2mdQCmU6OmvQzXBUwuEv2YaCY8me S9LsPXu8PLiQg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v11 3/4] drm/virtio: implement userptr resource support To: "Honglei Huang" Cc: dri-devel@lists.freedesktop.org, virtualization@lists.linux.dev, "Michael S. Tsirkin" , "Eugenio Perez" In-Reply-To: <20261202101658.1209083-4-honghuan@amd.com> References: <20261202101658.1209083-1-honghuan@amd.com> <20261202101658.1209083-4-honghuan@amd.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 10:29:17 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "dri-devel" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: 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 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/virti= o/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; > }; > =20 > +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/v= irtio/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 =3D gem_to_virtio_gpu_obj(obj); > + struct virtio_gpu_device *vgdev =3D 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. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202101658.1209= 083-1-honghuan@amd.com?part=3D3