summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2015-06-24 14:13:00 +0200
committerChristian König <christian.koenig@amd.com>2015-06-29 16:41:28 +0200
commitf1aa148e7f9c47e415ec8a080f3afc86078cef83 (patch)
tree89bd8db9bbc1d35e14c908940c920292b791279e
parent42e09d0296ed9df5cae649ba2f58010ae61114e3 (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;