Skip to content

Commit e222b36

Browse files
committed
drm/amdgpu: fix AGP addressing when GART is not at 0
This worked by luck if the GART aperture ended up at 0. When we ended up moving GART on some chips, the GART aperture ended up offsetting the AGP address since the resource->start is a GART offset, not an MC address. Fix this by moving the AGP address setup into amdgpu_bo_gpu_offset_no_check(). v2: check mem_type before checking agp v3: check if the ttm bo has a ttm_tt allocated yet Fixes: 67318cb ("drm/amdgpu/gmc11: set gart placement GC11") Tested-by: Mario Limonciello <[email protected]> Reported-by: Jesse Zhang <[email protected]> Reported-by: Yifan Zhang <[email protected]> Reviewed-by: Christian König <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Cc: [email protected] Cc: [email protected]
1 parent c92da04 commit e222b36

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ uint64_t amdgpu_gmc_agp_addr(struct ttm_buffer_object *bo)
181181
{
182182
struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev);
183183

184+
if (!bo->ttm)
185+
return AMDGPU_BO_INVALID_OFFSET;
186+
184187
if (bo->ttm->num_pages != 1 || bo->ttm->caching == ttm_cached)
185188
return AMDGPU_BO_INVALID_OFFSET;
186189

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,10 +1527,14 @@ u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo)
15271527
u64 amdgpu_bo_gpu_offset_no_check(struct amdgpu_bo *bo)
15281528
{
15291529
struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
1530-
uint64_t offset;
1530+
uint64_t offset = AMDGPU_BO_INVALID_OFFSET;
15311531

1532-
offset = (bo->tbo.resource->start << PAGE_SHIFT) +
1533-
amdgpu_ttm_domain_start(adev, bo->tbo.resource->mem_type);
1532+
if (bo->tbo.resource->mem_type == TTM_PL_TT)
1533+
offset = amdgpu_gmc_agp_addr(&bo->tbo);
1534+
1535+
if (offset == AMDGPU_BO_INVALID_OFFSET)
1536+
offset = (bo->tbo.resource->start << PAGE_SHIFT) +
1537+
amdgpu_ttm_domain_start(adev, bo->tbo.resource->mem_type);
15341538

15351539
return amdgpu_gmc_sign_extend(offset);
15361540
}

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -959,10 +959,8 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
959959
return 0;
960960

961961
addr = amdgpu_gmc_agp_addr(bo);
962-
if (addr != AMDGPU_BO_INVALID_OFFSET) {
963-
bo->resource->start = addr >> PAGE_SHIFT;
962+
if (addr != AMDGPU_BO_INVALID_OFFSET)
964963
return 0;
965-
}
966964

967965
/* allocate GART space */
968966
placement.num_placement = 1;

0 commit comments

Comments
 (0)