Skip to content

Commit 1b4ca85

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]>
1 parent d4be16c commit 1b4ca85

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
@@ -1130,15 +1130,19 @@ static void gmc_v9_0_get_coherence_flags(struct amdgpu_device *adev,
11301130
uint64_t *flags)
11311131
{
11321132
struct amdgpu_device *bo_adev = amdgpu_ttm_adev(bo->tbo.bdev);
1133-
bool is_vram = bo->tbo.resource->mem_type == TTM_PL_VRAM;
1134-
bool coherent = bo->flags & (AMDGPU_GEM_CREATE_COHERENT | AMDGPU_GEM_CREATE_EXT_COHERENT);
1133+
bool is_vram = bo->tbo.resource &&
1134+
bo->tbo.resource->mem_type == TTM_PL_VRAM;
1135+
bool coherent = bo->flags & (AMDGPU_GEM_CREATE_COHERENT |
1136+
AMDGPU_GEM_CREATE_EXT_COHERENT);
11351137
bool ext_coherent = bo->flags & AMDGPU_GEM_CREATE_EXT_COHERENT;
11361138
bool uncached = bo->flags & AMDGPU_GEM_CREATE_UNCACHED;
11371139
struct amdgpu_vm *vm = mapping->bo_va->base.vm;
11381140
unsigned int mtype_local, mtype;
11391141
bool snoop = false;
11401142
bool is_local;
11411143

1144+
dma_resv_assert_held(bo->tbo.base.resv);
1145+
11421146
switch (amdgpu_ip_version(adev, GC_HWIP, 0)) {
11431147
case IP_VERSION(9, 4, 1):
11441148
case IP_VERSION(9, 4, 2):
@@ -1257,9 +1261,8 @@ static void gmc_v9_0_get_vm_pte(struct amdgpu_device *adev,
12571261
*flags &= ~AMDGPU_PTE_VALID;
12581262
}
12591263

1260-
if (bo && bo->tbo.resource)
1261-
gmc_v9_0_get_coherence_flags(adev, mapping->bo_va->base.bo,
1262-
mapping, flags);
1264+
if ((*flags & AMDGPU_PTE_VALID) && bo)
1265+
gmc_v9_0_get_coherence_flags(adev, bo, mapping, flags);
12631266
}
12641267

12651268
static void gmc_v9_0_override_vm_pte_flags(struct amdgpu_device *adev,

0 commit comments

Comments
 (0)