summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2018-09-14 15:04:38 +0200
committerChristian König <christian.koenig@amd.com>2018-09-18 14:56:22 +0200
commit864d4501b95837d225eeca9b6e3ff3925baef063 (patch)
treec1a3822a1741fa7f3a5db8b3ada9941a37a2a491
parentc40bd3cbf8002edec94ef7d6275db192b4ecc53b (diff)
downloadlibdrm-864d4501b95837d225eeca9b6e3ff3925baef063.tar.gz
libdrm-864d4501b95837d225eeca9b6e3ff3925baef063.tar.bz2
libdrm-864d4501b95837d225eeca9b6e3ff3925baef063.zip
test/amdgpu: add proper error handling v2
Otherwise the calling function won't notice that something is wrong. v2: check map result as well Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--tests/amdgpu/amdgpu_test.h28
1 files changed, 26 insertions, 2 deletions
diff --git a/tests/amdgpu/amdgpu_test.h b/tests/amdgpu/amdgpu_test.h
index f2ece3c3..84ed3cc8 100644
--- a/tests/amdgpu/amdgpu_test.h
+++ b/tests/amdgpu/amdgpu_test.h
@@ -219,17 +219,34 @@ static inline amdgpu_bo_handle gpu_mem_alloc(
r = amdgpu_bo_alloc(device_handle, &req, &buf_handle);
CU_ASSERT_EQUAL(r, 0);
+ if (r)
+ return NULL;
r = amdgpu_va_range_alloc(device_handle,
amdgpu_gpu_va_range_general,
size, alignment, 0, vmc_addr,
va_handle, 0);
CU_ASSERT_EQUAL(r, 0);
+ if (r)
+ goto error_free_bo;
- r = amdgpu_bo_va_op(buf_handle, 0, size, *vmc_addr, 0, AMDGPU_VA_OP_MAP);
+ r = amdgpu_bo_va_op(buf_handle, 0, size, *vmc_addr, 0,
+ AMDGPU_VA_OP_MAP);
CU_ASSERT_EQUAL(r, 0);
+ if (r)
+ goto error_free_va;
return buf_handle;
+
+error_free_va:
+ r = amdgpu_va_range_free(*va_handle);
+ CU_ASSERT_EQUAL(r, 0);
+
+error_free_bo:
+ r = amdgpu_bo_free(buf_handle);
+ CU_ASSERT_EQUAL(r, 0);
+
+ return NULL;
}
static inline int gpu_mem_free(amdgpu_bo_handle bo,
@@ -239,16 +256,23 @@ static inline int gpu_mem_free(amdgpu_bo_handle bo,
{
int r;
+ if (!bo)
+ return 0;
+
r = amdgpu_bo_va_op(bo, 0, size, vmc_addr, 0, AMDGPU_VA_OP_UNMAP);
CU_ASSERT_EQUAL(r, 0);
+ if (r)
+ return r;
r = amdgpu_va_range_free(va_handle);
CU_ASSERT_EQUAL(r, 0);
+ if (r)
+ return r;
r = amdgpu_bo_free(bo);
CU_ASSERT_EQUAL(r, 0);
- return 0;
+ return r;
}
static inline int