Commit fe57085a authored by Marek Olšák's avatar Marek Olšák Committed by Alex Deucher

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: default avatarMarek Olšák <marek.olsak@amd.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent a5c8e052
...@@ -54,10 +54,6 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, ...@@ -54,10 +54,6 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size,
memset(&bp, 0, sizeof(bp)); memset(&bp, 0, sizeof(bp));
*obj = NULL; *obj = NULL;
/* At least align on page size */
if (alignment < PAGE_SIZE) {
alignment = PAGE_SIZE;
}
bp.size = size; bp.size = size;
bp.byte_align = alignment; bp.byte_align = alignment;
...@@ -244,9 +240,6 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data, ...@@ -244,9 +240,6 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
return -EINVAL; return -EINVAL;
} }
flags |= AMDGPU_GEM_CREATE_NO_CPU_ACCESS; flags |= AMDGPU_GEM_CREATE_NO_CPU_ACCESS;
/* GDS allocations must be DW aligned */
if (args->in.domains & AMDGPU_GEM_DOMAIN_GDS)
size = ALIGN(size, 4);
} }
if (flags & AMDGPU_GEM_CREATE_VM_ALWAYS_VALID) { if (flags & AMDGPU_GEM_CREATE_VM_ALWAYS_VALID) {
......
...@@ -426,12 +426,20 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, ...@@ -426,12 +426,20 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
size_t acc_size; size_t acc_size;
int r; int r;
page_align = roundup(bp->byte_align, PAGE_SIZE) >> PAGE_SHIFT; /* Note that GDS/GWS/OA allocates 1 page per byte/resource. */
if (bp->domain & (AMDGPU_GEM_DOMAIN_GDS | AMDGPU_GEM_DOMAIN_GWS | if (bp->domain & (AMDGPU_GEM_DOMAIN_GWS | AMDGPU_GEM_DOMAIN_OA)) {
AMDGPU_GEM_DOMAIN_OA)) /* GWS and OA don't need any alignment. */
page_align = bp->byte_align;
size <<= PAGE_SHIFT; size <<= PAGE_SHIFT;
else } else if (bp->domain & AMDGPU_GEM_DOMAIN_GDS) {
/* Both size and alignment must be a multiple of 4. */
page_align = ALIGN(bp->byte_align, 4);
size = ALIGN(size, 4) << PAGE_SHIFT;
} else {
/* Memory should be aligned at least to a page size. */
page_align = ALIGN(bp->byte_align, PAGE_SIZE) >> PAGE_SHIFT;
size = ALIGN(size, PAGE_SIZE); size = ALIGN(size, PAGE_SIZE);
}
if (!amdgpu_bo_validate_size(adev, size, bp->domain)) if (!amdgpu_bo_validate_size(adev, size, bp->domain))
return -ENOMEM; return -ENOMEM;
......
...@@ -1756,7 +1756,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) ...@@ -1756,7 +1756,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
} }
r = amdgpu_bo_create_kernel(adev, adev->gds.mem.gfx_partition_size, r = amdgpu_bo_create_kernel(adev, adev->gds.mem.gfx_partition_size,
PAGE_SIZE, AMDGPU_GEM_DOMAIN_GDS, 4, AMDGPU_GEM_DOMAIN_GDS,
&adev->gds.gds_gfx_bo, NULL, NULL); &adev->gds.gds_gfx_bo, NULL, NULL);
if (r) if (r)
return r; return r;
...@@ -1769,7 +1769,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) ...@@ -1769,7 +1769,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
} }
r = amdgpu_bo_create_kernel(adev, adev->gds.gws.gfx_partition_size, r = amdgpu_bo_create_kernel(adev, adev->gds.gws.gfx_partition_size,
PAGE_SIZE, AMDGPU_GEM_DOMAIN_GWS, 1, AMDGPU_GEM_DOMAIN_GWS,
&adev->gds.gws_gfx_bo, NULL, NULL); &adev->gds.gws_gfx_bo, NULL, NULL);
if (r) if (r)
return r; return r;
...@@ -1782,7 +1782,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) ...@@ -1782,7 +1782,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
} }
r = amdgpu_bo_create_kernel(adev, adev->gds.oa.gfx_partition_size, r = amdgpu_bo_create_kernel(adev, adev->gds.oa.gfx_partition_size,
PAGE_SIZE, AMDGPU_GEM_DOMAIN_OA, 1, AMDGPU_GEM_DOMAIN_OA,
&adev->gds.oa_gfx_bo, NULL, NULL); &adev->gds.oa_gfx_bo, NULL, NULL);
if (r) if (r)
return r; return r;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment