[Intel-gfx] [PATCH i-g-t] amdgpu: Exporting a dmabuf from amdgpu waits for outstanding fences
Chris Wilson
chris at chris-wilson.co.uk
Mon Aug 6 12:43:36 UTC 2018
Since amdgpu is synchronous for exporting a dmabuf, exercise both paths
to highlight the issue.
References: https://bugs.freedesktop.org/show_bug.cgi?id=107341
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
tests/amdgpu/amd_prime.c | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/tests/amdgpu/amd_prime.c b/tests/amdgpu/amd_prime.c
index 9bf298a41..7be7a04ac 100644
--- a/tests/amdgpu/amd_prime.c
+++ b/tests/amdgpu/amd_prime.c
@@ -286,7 +286,9 @@ static void i915_to_amd(int i915, int amd, amdgpu_device_handle device)
gem_close(i915, obj[1].handle);
}
-static void amd_to_i915(int i915, int amd, amdgpu_device_handle device)
+static void amd_to_i915(int i915, int amd, amdgpu_device_handle device,
+ unsigned int flags)
+#define EXPORT_BEFORE 0x1
{
const uint32_t bbe = MI_BATCH_BUFFER_END;
struct drm_i915_gem_exec_object2 obj[2];
@@ -300,7 +302,7 @@ static void amd_to_i915(int i915, int amd, amdgpu_device_handle device)
struct amdgpu_cs_ib_info ib_info;
uint32_t *ptr;
amdgpu_context_handle *contexts;
- int i, r, dmabuf;
+ int i, r, dmabuf = -1;
amdgpu_bo_list_handle bo_list;
amdgpu_va_handle va_handle;
unsigned long count, size;
@@ -320,6 +322,13 @@ static void amd_to_i915(int i915, int amd, amdgpu_device_handle device)
&ib_result_mc_address, &va_handle);
igt_assert_eq(r, 0);
+ if (flags & EXPORT_BEFORE) {
+ amdgpu_bo_export(ib_result_handle,
+ amdgpu_bo_handle_type_dma_buf_fd,
+ (uint32_t *)&dmabuf);
+ igt_assert(dmabuf != -1);
+ }
+
ptr = ib_result_cpu;
for (i = 0; i < 16; ++i)
ptr[i] = GFX_COMPUTE_NOP;
@@ -365,9 +374,12 @@ static void amd_to_i915(int i915, int amd, amdgpu_device_handle device)
igt_info("Reservation width = %ld\n", count);
- amdgpu_bo_export(ib_result_handle,
- amdgpu_bo_handle_type_dma_buf_fd,
- (uint32_t *)&dmabuf);
+ if (dmabuf == -1) {
+ amdgpu_bo_export(ib_result_handle,
+ amdgpu_bo_handle_type_dma_buf_fd,
+ (uint32_t *)&dmabuf);
+ igt_assert(dmabuf != -1);
+ }
igt_assert_eq(poll(&(struct pollfd){dmabuf, POLLOUT}, 1, 0), 0);
obj[0].handle = prime_fd_to_handle(i915, dmabuf);
obj[0].flags = EXEC_OBJECT_WRITE;
@@ -418,7 +430,10 @@ igt_main
}
igt_subtest("amd-to-i915")
- amd_to_i915(i915, amd, device);
+ amd_to_i915(i915, amd, device, EXPORT_BEFORE);
+
+ igt_subtest("inflight-amd-to-i915")
+ amd_to_i915(i915, amd, device, 0);
igt_fixture {
amdgpu_device_deinitialize(device);
--
2.18.0
More information about the Intel-gfx
mailing list