Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: Remove TTM resource->start visible VRAM condition v2

Use amdgpu_bo_in_cpu_visible_vram() instead.

v2 (chk): fix test inversion

Signed-off-by: Somalapuram Amaranath <Amaranath.Somalapuram@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230208090106.9659-2-Amaranath.Somalapuram@amd.com

authored by

Somalapuram Amaranath and committed by
Christian König
aed01a68 e3ea1806

+3 -6
+3 -6
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
··· 600 600 601 601 if (!amdgpu_gmc_vram_full_visible(&adev->gmc) && 602 602 bo->tbo.resource->mem_type == TTM_PL_VRAM && 603 - bo->tbo.resource->start < adev->gmc.visible_vram_size >> PAGE_SHIFT) 603 + amdgpu_bo_in_cpu_visible_vram(bo)) 604 604 amdgpu_cs_report_moved_bytes(adev, ctx.bytes_moved, 605 605 ctx.bytes_moved); 606 606 else ··· 1346 1346 struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev); 1347 1347 struct ttm_operation_ctx ctx = { false, false }; 1348 1348 struct amdgpu_bo *abo = ttm_to_amdgpu_bo(bo); 1349 - unsigned long offset; 1350 1349 int r; 1351 1350 1352 1351 /* Remember that this BO was accessed by the CPU */ ··· 1354 1355 if (bo->resource->mem_type != TTM_PL_VRAM) 1355 1356 return 0; 1356 1357 1357 - offset = bo->resource->start << PAGE_SHIFT; 1358 - if ((offset + bo->base.size) <= adev->gmc.visible_vram_size) 1358 + if (amdgpu_bo_in_cpu_visible_vram(abo)) 1359 1359 return 0; 1360 1360 1361 1361 /* Can't move a pinned BO to visible VRAM */ ··· 1376 1378 else if (unlikely(r)) 1377 1379 return VM_FAULT_SIGBUS; 1378 1380 1379 - offset = bo->resource->start << PAGE_SHIFT; 1380 1381 /* this should never happen */ 1381 1382 if (bo->resource->mem_type == TTM_PL_VRAM && 1382 - (offset + bo->base.size) > adev->gmc.visible_vram_size) 1383 + !amdgpu_bo_in_cpu_visible_vram(abo)) 1383 1384 return VM_FAULT_SIGBUS; 1384 1385 1385 1386 ttm_bo_move_to_lru_tail_unlocked(bo);