aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2019-01-22 15:44:54 -0500
committerAlex Deucher <alexander.deucher@amd.com>2019-02-01 00:33:00 -0500
commitfe57085a36de5813ab63a8d178ccfb5f257f028e (patch)
treea33d93e816327e2344ca02715ee25f2bf88efd19 /drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
parenta5c8e0524dbbe1107d81a1604da3d191b66ead6b (diff)
drm/amdgpu: clean up memory/GDS/GWS/OA alignment code
- move all adjustments into one place - specify GDS/GWS/OA alignment in basic units of the heaps - it looks like GDS alignment was 1 instead of 4 Signed-off-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_object.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_object.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 728e15e5d68a..fd9c4beeaaa4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -426,12 +426,20 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
426 size_t acc_size; 426 size_t acc_size;
427 int r; 427 int r;
428 428
429 page_align = roundup(bp->byte_align, PAGE_SIZE) >> PAGE_SHIFT; 429 /* Note that GDS/GWS/OA allocates 1 page per byte/resource. */
430 if (bp->domain & (AMDGPU_GEM_DOMAIN_GDS | AMDGPU_GEM_DOMAIN_GWS | 430 if (bp->domain & (AMDGPU_GEM_DOMAIN_GWS | AMDGPU_GEM_DOMAIN_OA)) {
431 AMDGPU_GEM_DOMAIN_OA)) 431 /* GWS and OA don't need any alignment. */
432 page_align = bp->byte_align;
432 size <<= PAGE_SHIFT; 433 size <<= PAGE_SHIFT;
433 else 434 } else if (bp->domain & AMDGPU_GEM_DOMAIN_GDS) {
435 /* Both size and alignment must be a multiple of 4. */
436 page_align = ALIGN(bp->byte_align, 4);
437 size = ALIGN(size, 4) << PAGE_SHIFT;
438 } else {
439 /* Memory should be aligned at least to a page size. */
440 page_align = ALIGN(bp->byte_align, PAGE_SIZE) >> PAGE_SHIFT;
434 size = ALIGN(size, PAGE_SIZE); 441 size = ALIGN(size, PAGE_SIZE);
442 }
435 443
436 if (!amdgpu_bo_validate_size(adev, size, bp->domain)) 444 if (!amdgpu_bo_validate_size(adev, size, bp->domain))
437 return -ENOMEM; 445 return -ENOMEM;