summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2015-06-24 14:13:00 +0200
committerAlex Deucher <alexander.deucher@amd.com>2015-07-30 00:11:12 -0400
commiteba5683e20cfcbbdd2689c99506d8d8796c954ef (patch)
tree1e82239a39a410a4a8f13bb584674f794a15035e
parenta3c1e5207938b8c1cc7595bb9600858aa33b3daa (diff)
amdgpu: remove pointer arithmetic from command submission
Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com>
-rw-r--r--amdgpu/amdgpu_cs.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c
index bf79df35..184f2092 100644
--- a/amdgpu/amdgpu_cs.c
+++ b/amdgpu/amdgpu_cs.c
@@ -182,12 +182,12 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context,
struct amdgpu_cs_request *ibs_request,
uint64_t *fence)
{
- int r = 0;
- uint32_t i, size;
union drm_amdgpu_cs cs;
uint64_t *chunk_array;
struct drm_amdgpu_cs_chunk *chunks;
struct drm_amdgpu_cs_chunk_data *chunk_data;
+ uint32_t i, size;
+ int r = 0;
if (ibs_request->ip_type >= AMDGPU_HW_IP_NUM)
return -EINVAL;
@@ -196,17 +196,11 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context,
if (ibs_request->number_of_ibs > AMDGPU_CS_MAX_IBS_PER_SUBMIT)
return -EINVAL;
- size = (ibs_request->number_of_ibs + 1) * (
- sizeof(uint64_t) +
- sizeof(struct drm_amdgpu_cs_chunk) +
- sizeof(struct drm_amdgpu_cs_chunk_data));
-
- chunk_array = alloca(size);
- if (!chunk_array)
- return -ENOMEM;
+ size = ibs_request->number_of_ibs + 1;
- chunks = (struct drm_amdgpu_cs_chunk *)(chunk_array + ibs_request->number_of_ibs + 1);
- chunk_data = (struct drm_amdgpu_cs_chunk_data *)(chunks + ibs_request->number_of_ibs + 1);
+ chunk_array = alloca(sizeof(uint64_t) * size);
+ chunks = alloca(sizeof(struct drm_amdgpu_cs_chunk) * size);
+ chunk_data = alloca(sizeof(struct drm_amdgpu_cs_chunk_data) * size);
memset(&cs, 0, sizeof(cs));
cs.in.chunks = (uint64_t)(uintptr_t)chunk_array;