[PATCH v3 05/19] lib/amdgpu: add func amdgpu_bo_alloc_and_map_sync

Sunil Khatri sunil.khatri at amd.com
Fri Mar 28 08:24:02 UTC 2025


Add amdgpu_bo_alloc_and_map_sync func which
is synchronised version of amdgpu_bo_alloc_and_map.
It wait till the timeline is signaled and page tables
are updated for the bo.

Signed-off-by: Sunil Khatri <sunil.khatri at amd.com>
---
 lib/amdgpu/amd_memory.c | 19 +++++++++++++++++++
 lib/amdgpu/amd_memory.h |  8 ++++++++
 2 files changed, 27 insertions(+)

diff --git a/lib/amdgpu/amd_memory.c b/lib/amdgpu/amd_memory.c
index 92ddc9fe2..d1ff57085 100644
--- a/lib/amdgpu/amd_memory.c
+++ b/lib/amdgpu/amd_memory.c
@@ -25,6 +25,8 @@
 
 #include "amd_memory.h"
 #include "amd_PM4.h"
+#include "amd_user_queue.h"
+
 /**
  *
  * @param device_handle
@@ -193,6 +195,23 @@ error_va_alloc:
 	return r;
 }
 
+int
+amdgpu_bo_alloc_and_map_sync(amdgpu_device_handle dev, unsigned int size,
+			     unsigned int alignment, unsigned int heap, uint64_t flags,
+			     uint64_t mapping_flags, amdgpu_bo_handle *bo, void **cpu,
+			     uint64_t *mc_address, amdgpu_va_handle *va_handle,
+			     uint32_t timeline_syncobj_handle, uint64_t point, bool sync)
+{
+	if (sync)
+		return amdgpu_bo_alloc_and_map_uq(dev, size, alignment, heap, flags,
+						  mapping_flags, bo, cpu,
+						  mc_address, va_handle,
+						  timeline_syncobj_handle, point);
+	else
+		return amdgpu_bo_alloc_and_map(dev, size, alignment, heap, flags,
+					       bo, cpu, mc_address, va_handle);
+}
+
 int
 amdgpu_bo_alloc_and_map_raw(amdgpu_device_handle dev, unsigned size,
 			unsigned alignment, unsigned heap, uint64_t alloc_flags,
diff --git a/lib/amdgpu/amd_memory.h b/lib/amdgpu/amd_memory.h
index a06f88923..9b0e3f392 100644
--- a/lib/amdgpu/amd_memory.h
+++ b/lib/amdgpu/amd_memory.h
@@ -55,6 +55,14 @@ amdgpu_bo_alloc_and_map(amdgpu_device_handle dev, unsigned size,
 			amdgpu_bo_handle *bo, void **cpu, uint64_t *mc_address,
 			amdgpu_va_handle *va_handle);
 
+int
+amdgpu_bo_alloc_and_map_sync(amdgpu_device_handle dev, unsigned int size,
+			     unsigned int alignment, unsigned int heap, uint64_t flags,
+			     uint64_t mapping_flags, amdgpu_bo_handle *bo, void **cpu,
+			     uint64_t *mc_address, amdgpu_va_handle *va_handle,
+			     uint32_t timeline_syncobj_handle, uint64_t point,
+			     bool sync);
+
 int
 amdgpu_bo_alloc_and_map_raw(amdgpu_device_handle dev, unsigned size,
 			unsigned alignment, unsigned heap, uint64_t alloc_flags,
-- 
2.43.0



More information about the igt-dev mailing list