Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F8F633E379 for ; Fri, 20 Feb 2026 12:05:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771589142; cv=none; b=gmuSjqrt3etPy2GHZwBsS8Kqck9DNvTE/g7kXTKPxEHK+DZbDMBn6NlNT6zKrD9G/nRENTdePLOKpKlnj9ifr+xMSv3IF7kTLpn/UChupSd3bJPhwLzUj1UnyWMk9Nkw4qPmC01UXTgpnuRquT1Y9+zF9I8Nk8mDEYFYq4WmmcQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771589142; c=relaxed/simple; bh=hWdCrzZgVvqhMX8insComZi1b22nOTTHtbTwmPwJEDM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o1c7XBKKn686vqPGrTIdXWs98M1+FffL4fzQS9uMPYx07ClNjlUZoQ3BQV/mXgsm9iy8W1iKTVgIjj5udDvd7rW99S+pUZhYXYuBAj9zRymxpAF4aORJLBSrcKYwSnEHx3ZgLn8uv0P5liprbdcN+6NjLeOUJsj/fVVdBw/zJRU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=l/luVObn; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="l/luVObn" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=LoG63rHTPy/xDy7RXCVqtEASsTlB7ITDR/kxw6j9CaQ=; b=l/luVObne0HzDZ4/4N78VxqfdN yZSe6s3ftxB5sAhpw3oaHLHKAMNMcmocS3Nl9uUgnwo9Ar3D/h+jJ+/Tk+4TrCnO5TjRULxyCT2dr 7npIqal58xsKc39FTww5klpu/G5keynhoGviEIoxdj0hyY3ogrmOFX+t5a5P9NfLax0s7nlDKbNQx LuzNBzNkTr3i1+38vET1u3aop3TYKYQzz/q2C4urPs/ZKMiNbjcP6ux0SOX/L8b2KgItY+4VNP+aL 5WJ+T+J/tsxuRHd9HfasZNl2lJSxr2WwKptNQ02+ORrYg24K/Ad564RnNnsiNpylIGJzybQM3/c7J 6NxHq5mg==; Received: from [90.240.106.137] (helo=localhost) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1vtPGN-002v19-Es; Fri, 20 Feb 2026 13:05:39 +0100 From: Tvrtko Ursulin To: criu@lists.linux.dev Cc: David Francis , Tvrtko Ursulin Subject: [RFC 20/26] plugins/amdgpu: amdgpu_plugin_drm_restore_file() does not need to use libdrm Date: Fri, 20 Feb 2026 12:05:08 +0000 Message-ID: <20260220120514.4540-21-tvrtko.ursulin@igalia.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260220120514.4540-1-tvrtko.ursulin@igalia.com> References: <20260220120514.4540-1-tvrtko.ursulin@igalia.com> Precedence: bulk X-Mailing-List: criu@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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