CRIU (Checkpoint/Restore in Userspace) mailing list
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
To: criu@lists.linux.dev
Cc: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>,
	David Francis <David.Francis@amd.com>
Subject: [PATCH v2 06/23] plugins/amdgpu: Propagate failure to save buffer object content
Date: Fri, 10 Apr 2026 19:54:57 +0100	[thread overview]
Message-ID: <20260410185514.51153-7-tvrtko.ursulin@igalia.com> (raw)
In-Reply-To: <20260410185514.51153-1-tvrtko.ursulin@igalia.com>

Currently the failure to save content of a buffer object is only logged,
while the checkpointing will continue unaware due the error code being
"eaten" inside sdma_copy_bo() cleanup path, together with the caller not
checking the return value to begin with.

Fix it by preserving and returning the original error code inside
sdma_copy_bo(), and abort the checkpointing process in case of a failure.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Reviewed-By: David Francis <David.Francis@amd.com>
---
 plugins/amdgpu/amdgpu_plugin.c     | 31 +++++++++++++++---------------
 plugins/amdgpu/amdgpu_plugin_drm.c |  2 ++
 2 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/plugins/amdgpu/amdgpu_plugin.c b/plugins/amdgpu/amdgpu_plugin.c
index a55e6cef96c4..c875df060eed 100644
--- a/plugins/amdgpu/amdgpu_plugin.c
+++ b/plugins/amdgpu/amdgpu_plugin.c
@@ -563,7 +563,7 @@ int sdma_copy_bo(int shared_fd, uint64_t size, FILE *storage_fp,
 	uint32_t expired;
 	amdgpu_context_handle h_ctx;
 	uint32_t *ib = NULL;
-	int j, err, packets_per_buffer;
+	int j, err, err2, packets_per_buffer;
 
 	buffer_bo_size = min(size, buffer_size);
 	packets_per_buffer = ((buffer_bo_size - 1) / max_copy_size) + 1;
@@ -767,29 +767,30 @@ err_ctx:
 err_bo_list:
 	free_and_unmap(packets_per_buffer * 28, h_bo_ib, h_va_ib, gpu_addr_ib, ib);
 err_ib_gpu_alloc:
-	err = amdgpu_bo_va_op(h_bo_dst, 0, size, gpu_addr_dst, 0, AMDGPU_VA_OP_UNMAP);
-	if (err)
+	err2 = amdgpu_bo_va_op(h_bo_dst, 0, size, gpu_addr_dst, 0, AMDGPU_VA_OP_UNMAP);
+	if (err2)
 		pr_perror("failed to GPU unmap the dest BO %lx, size = %lx", gpu_addr_dst, size);
 err_dst_bo_map:
-	err = amdgpu_va_range_free(h_va_dst);
-	if (err)
+	err2 = amdgpu_va_range_free(h_va_dst);
+	if (err2)
 		pr_perror("dest range free failed");
 err_dst_va:
-	if (!do_not_free)
-		err = amdgpu_bo_free(h_bo_dst);
-	if (err)
-		pr_perror("dest bo free failed");
+	if (!do_not_free) {
+		err2 = amdgpu_bo_free(h_bo_dst);
+		if (err2)
+			pr_perror("dest bo free failed");
+	}
 err_dst_bo_prep:
-	err = amdgpu_bo_va_op(h_bo_src, 0, size, gpu_addr_src, 0, AMDGPU_VA_OP_UNMAP);
-	if (err)
+	err2 = amdgpu_bo_va_op(h_bo_src, 0, size, gpu_addr_src, 0, AMDGPU_VA_OP_UNMAP);
+	if (err2)
 		pr_perror("failed to GPU unmap the src BO %lx, size = %lx", gpu_addr_src, size);
 err_src_bo_map:
-	err = amdgpu_va_range_free(h_va_src);
-	if (err)
+	err2 = amdgpu_va_range_free(h_va_src);
+	if (err2)
 		pr_perror("src range free failed");
 err_src_va:
-	err = amdgpu_bo_free(h_bo_src);
-	if (err)
+	err2 = amdgpu_bo_free(h_bo_src);
+	if (err2)
 		pr_perror("src bo free failed");
 	plugin_log_msg("Leaving sdma_copy_bo, err = %d\n", err);
 	return err;
diff --git a/plugins/amdgpu/amdgpu_plugin_drm.c b/plugins/amdgpu/amdgpu_plugin_drm.c
index 487c2a1e2a6d..a5ab3adffa6c 100644
--- a/plugins/amdgpu/amdgpu_plugin_drm.c
+++ b/plugins/amdgpu/amdgpu_plugin_drm.c
@@ -438,6 +438,8 @@ int amdgpu_plugin_drm_dump_file(int fd, int id, struct stat *drm)
 
 		ret = sdma_copy_bo(dmabuf_fd, handle_entry.size, bo_contents_fp, buffer, handle_entry.size, h_dev, 0x1000,
 				   SDMA_OP_VRAM_READ, false);
+		if (ret)
+			goto exit;
 
 		xfree(buffer);
 
-- 
2.52.0


  parent reply	other threads:[~2026-04-10 18:55 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-10 18:54 [PATCH v2 00/23] Amdgpu plugin cleanups and fixes Tvrtko Ursulin
2026-04-10 18:54 ` [PATCH v2 01/23] plugins/amgdpu: Fix one error message Tvrtko Ursulin
2026-04-10 18:54 ` [PATCH v2 02/23] plugins/amdgpu: Remove unused current_pid global variable Tvrtko Ursulin
2026-04-10 18:54 ` [PATCH v2 03/23] plugins/amdgpu: Remove unused new_minor from struct vma_metadata Tvrtko Ursulin
2026-04-10 18:54 ` [PATCH v2 04/23] plugins/amdgpu: Fix drm pages size header Tvrtko Ursulin
2026-04-10 18:54 ` [PATCH v2 05/23] plugins/amdgpu: Fix logging of failures to open files during restore init Tvrtko Ursulin
2026-04-10 18:54 ` Tvrtko Ursulin [this message]
2026-04-10 18:54 ` [PATCH v2 07/23] plugins/amdgpu: Close the directory when image probing fails Tvrtko Ursulin
2026-04-10 18:54 ` [PATCH v2 08/23] plugins/amdgpu: Close dma-buf image file if the read fails Tvrtko Ursulin
2026-04-10 18:55 ` [PATCH v2 09/23] plugins/amdgpu: Flatten amdgpu_restore_init a bit Tvrtko Ursulin
2026-04-10 18:55 ` [PATCH v2 10/23] plugins/amdgpu: Add error handling for seek operations Tvrtko Ursulin
2026-04-10 18:55 ` [PATCH v2 11/23] plugins/amdgpu: Consolidate vm_info collection Tvrtko Ursulin
2026-04-10 18:55 ` [PATCH v2 12/23] plugins/amdgpu: Remove plugin_log_msg() Tvrtko Ursulin
2026-04-10 18:55 ` [PATCH v2 13/23] plugins/amdgpu: Reduce amount of debug logging a little bit Tvrtko Ursulin
2026-04-10 18:55 ` [PATCH v2 14/23] plugins/amdgpu: Do not eat the errno in kmtIoctl Tvrtko Ursulin
2026-04-10 18:55 ` [PATCH v2 15/23] plugins/amdgpu: Fix open_drm_render_device() Tvrtko Ursulin
2026-04-10 18:55 ` [PATCH v2 16/23] plugins/amdgpu: Check sdma operation type early and once Tvrtko Ursulin
2026-04-10 18:55 ` [PATCH v2 17/23] plugins/amdgpu: Add plugin to inventory even if process has no vmas Tvrtko Ursulin
2026-04-10 18:55 ` [PATCH v2 18/23] plugins/amdgpu: Move drm file dump and restore into helpers Tvrtko Ursulin
2026-04-10 18:55 ` [PATCH v2 19/23] plugins/amdgpu: Use the load_img helper in drm file restore Tvrtko Ursulin
2026-04-10 18:55 ` [PATCH v2 20/23] plugins/amdgpu: Convert away from libc buffered file IO Tvrtko Ursulin
2026-04-10 18:55 ` [PATCH v2 21/23] plugins/amdgpu: Use save_vma_updates for all call sites Tvrtko Ursulin
2026-04-10 18:55 ` [PATCH v2 22/23] plugins/amdgpu: amdgpu_plugin_drm_restore_file() does not need to use libdrm Tvrtko Ursulin
2026-04-10 18:55 ` [PATCH v2 23/23] plugins/amdgpu: Fix remaining wrong usages of pr_perror Tvrtko Ursulin
2026-04-13 18:23 ` [PATCH v2 00/23] Amdgpu plugin cleanups and fixes Andrei Vagin
2026-04-13 19:47   ` Tvrtko Ursulin
2026-04-13 20:03     ` Andrei Vagin

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=20260410185514.51153-7-tvrtko.ursulin@igalia.com \
    --to=tvrtko.ursulin@igalia.com \
    --cc=David.Francis@amd.com \
    --cc=criu@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