Re: [RFC 20/26] plugins/amdgpu: amdgpu_plugin_drm_restore_file() does not need to use libdrm
"Francis, David" <[email protected]> Mon, 2 Mar 2026 14:59:28 +0000
| Newsgroups | dev.linux.lists.criu |
|---|---|
| Message-ID | <SA1PR12MB8144F3B341AD399F7640FF8FEF7EA@SA1PR12MB8144.namprd12.prod.outlook.com> |
I think we used those major, minor values somewhere once but now that we don't, this looks sensible This patch is Reviewed-By: David Francis <[email protected]> ________________________________________ From: Tvrtko Ursulin <[email protected]> Sent: Friday, February 20, 2026 7:05 AM To: [email protected] Cc: Francis, David; Tvrtko Ursulin Subject: [RFC 20/26] plugins/amdgpu: amdgpu_plugin_drm_restore_file() does not need to use libdrm There is no need to initialize and de-initialize libdrm only to use the duplicated fd for calls to drmPrimeFDToHandle(). From the kernel's perspective it is exactly the same file so operation is identical to just using the passed in file descriptor. Signed-off-by: Tvrtko Ursulin <[email protected]> --- plugins/amdgpu/amdgpu_plugin_drm.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/plugins/amdgpu/amdgpu_plugin_drm.c b/plugins/amdgpu/amdgpu_plugin_drm.c index de6d6f178d51..99a6804f51eb 100644 --- a/plugins/amdgpu/amdgpu_plugin_drm.c +++ b/plugins/amdgpu/amdgpu_plugin_drm.c @@ -454,9 +454,7 @@ int amdgpu_plugin_drm_restore_file(int fd, CriuRenderNode *rd) { int ret = 0; bool retry_needed = false; - uint32_t major, minor; - amdgpu_device_handle h_dev; - int device_fd, *dmabufs; + int *dmabufs; dmabufs = xzalloc(sizeof(int) * rd->num_of_bos); if (!dmabufs) { @@ -464,14 +462,6 @@ int amdgpu_plugin_drm_restore_file(int fd, CriuRenderNode *rd) return -ENOMEM; } - ret = amdgpu_device_initialize(fd, &major, &minor, &h_dev); - if (ret) { - pr_info("Error in init amdgpu device\n"); - goto exit; - } - - device_fd = amdgpu_device_get_fd(h_dev); - for (int i = 0; i < rd->num_of_bos; i++) { DrmBoEntry *boinfo = rd->bo_entries[i]; int dmabuf_fd = -1; @@ -495,7 +485,7 @@ int amdgpu_plugin_drm_restore_file(int fd, CriuRenderNode *rd) } if (boinfo->is_import) { - drmPrimeFDToHandle(device_fd, dmabuf_fd, &handle); + drmPrimeFDToHandle(fd, dmabuf_fd, &handle); } else { union drm_amdgpu_gem_create create_args = { 0 }; @@ -511,7 +501,7 @@ int amdgpu_plugin_drm_restore_file(int fd, CriuRenderNode *rd) } handle = create_args.out.handle; - drmPrimeHandleToFD(device_fd, handle, 0, &dmabuf_fd); + drmPrimeHandleToFD(fd, handle, 0, &dmabuf_fd); } change_args.handle = handle; @@ -572,8 +562,6 @@ int amdgpu_plugin_drm_restore_file(int fd, CriuRenderNode *rd) if (ret) goto exit; - ret = amdgpu_device_deinitialize(h_dev); - if (rd->num_of_bos > 0) { ret = restore_bo_contents_drm(rd->drm_render_minor, rd, fd, dmabufs); if (ret) -- 2.52.0