Skip to content

Commit 0e5ac88

Browse files
ChristianKoenigAMDalexdeucher
authored andcommitted
drm/amdgpu: fix check in gmc_v9_0_get_vm_pte()
The coherency flags can only be determined when the BO is locked and that in turn is only guaranteed when the mapping is validated. Fix the check, move the resource check into the function and add an assert that the BO is locked. Signed-off-by: Christian König <[email protected]> Fixes: d1a372a ("drm/amdgpu: Set MTYPE in PTE based on BO flags") Acked-by: Alex Deucher <[email protected]> Signed-off-by: Alex Deucher <[email protected]> (cherry picked from commit 1b4ca85) Cc: [email protected]
1 parent df0279e commit 0e5ac88

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,15 +1124,19 @@ static void gmc_v9_0_get_coherence_flags(struct amdgpu_device *adev,
11241124
uint64_t *flags)
11251125
{
11261126
struct amdgpu_device *bo_adev = amdgpu_ttm_adev(bo->tbo.bdev);
1127-
bool is_vram = bo->tbo.resource->mem_type == TTM_PL_VRAM;
1128-
bool coherent = bo->flags & (AMDGPU_GEM_CREATE_COHERENT | AMDGPU_GEM_CREATE_EXT_COHERENT);
1127+
bool is_vram = bo->tbo.resource &&
1128+
bo->tbo.resource->mem_type == TTM_PL_VRAM;
1129+
bool coherent = bo->flags & (AMDGPU_GEM_CREATE_COHERENT |
1130+
AMDGPU_GEM_CREATE_EXT_COHERENT);
11291131
bool ext_coherent = bo->flags & AMDGPU_GEM_CREATE_EXT_COHERENT;
11301132
bool uncached = bo->flags & AMDGPU_GEM_CREATE_UNCACHED;
11311133
struct amdgpu_vm *vm = mapping->bo_va->base.vm;
11321134
unsigned int mtype_local, mtype;
11331135
bool snoop = false;
11341136
bool is_local;
11351137

1138+
dma_resv_assert_held(bo->tbo.base.resv);
1139+
11361140
switch (amdgpu_ip_version(adev, GC_HWIP, 0)) {
11371141
case IP_VERSION(9, 4, 1):
11381142
case IP_VERSION(9, 4, 2):
@@ -1251,9 +1255,8 @@ static void gmc_v9_0_get_vm_pte(struct amdgpu_device *adev,
12511255
*flags &= ~AMDGPU_PTE_VALID;
12521256
}
12531257

1254-
if (bo && bo->tbo.resource)
1255-
gmc_v9_0_get_coherence_flags(adev, mapping->bo_va->base.bo,
1256-
mapping, flags);
1258+
if ((*flags & AMDGPU_PTE_VALID) && bo)
1259+
gmc_v9_0_get_coherence_flags(adev, bo, mapping, flags);
12571260
}
12581261

12591262
static void gmc_v9_0_override_vm_pte_flags(struct amdgpu_device *adev,

0 commit comments

Comments
 (0)