From: "Christian König" <ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: [PATCH libdrm 2/3] test/amdgpu: add proper error handling
Date: Fri, 14 Sep 2018 15:09:05 +0200 [thread overview]
Message-ID: <20180914130906.3853-2-christian.koenig@amd.com> (raw)
In-Reply-To: <20180914130906.3853-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
Otherwise the calling function won't notice that something is wrong.
Signed-off-by: Christian König <christian.koenig@amd.com>
---
tests/amdgpu/amdgpu_test.h | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/tests/amdgpu/amdgpu_test.h b/tests/amdgpu/amdgpu_test.h
index f2ece3c3..d1e14e23 100644
--- a/tests/amdgpu/amdgpu_test.h
+++ b/tests/amdgpu/amdgpu_test.h
@@ -219,17 +219,31 @@ 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);
CU_ASSERT_EQUAL(r, 0);
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 +253,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
--
2.14.1
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2018-09-14 13:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-14 13:09 [PATCH libdrm 1/3] amdgpu: remove invalid check in amdgpu_bo_alloc Christian König
[not found] ` <20180914130906.3853-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-09-14 13:09 ` Christian König [this message]
[not found] ` <20180914130906.3853-2-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-09-18 6:07 ` [PATCH libdrm 2/3] test/amdgpu: add proper error handling Zhang, Jerry(Junwei)
2018-09-14 13:09 ` [PATCH libdrm 3/3] test/amdgpu: add GDS, GWS and OA tests Christian König
[not found] ` <20180914130906.3853-3-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-09-14 13:54 ` Deucher, Alexander
2018-09-18 6:09 ` Zhang, Jerry(Junwei)
2018-09-18 6:08 ` [PATCH libdrm 1/3] amdgpu: remove invalid check in amdgpu_bo_alloc Zhang, Jerry(Junwei)
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=20180914130906.3853-2-christian.koenig@amd.com \
--to=ckoenig.leichtzumerken-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
/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