Skip to content

Commit 12f325b

Browse files
ChristianKoenigAMDalexdeucher
authored andcommitted
drm/amdgpu: fix UVD contiguous CS mapping problem
When starting the mpv player, Radeon R9 users are observing the below error in dmesg. [drm:amdgpu_uvd_cs_pass2 [amdgpu]] *ERROR* msg/fb buffer ff00f7c000-ff00f7e000 out of 256MB segment! The patch tries to set the TTM_PL_FLAG_CONTIGUOUS for both user flag(AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS) set and not set cases. v2: Make the TTM_PL_FLAG_CONTIGUOUS mandatory for user BO's. v3: revert back to v1, but fix the check instead (chk). Closes:https://gitlab.freedesktop.org/drm/amd/-/issues/3599 Closes:https://gitlab.freedesktop.org/drm/amd/-/issues/3501 Signed-off-by: Arunpravin Paneer Selvam <[email protected]> Signed-off-by: Christian König <[email protected]> Reviewed-by: Arunpravin Paneer Selvam <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Cc: [email protected] # 6.10+
1 parent 9a4ab40 commit 12f325b

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,13 +1801,18 @@ int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,
18011801
if (dma_resv_locking_ctx((*bo)->tbo.base.resv) != &parser->exec.ticket)
18021802
return -EINVAL;
18031803

1804+
/* Make sure VRAM is allocated contigiously */
18041805
(*bo)->flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
1805-
amdgpu_bo_placement_from_domain(*bo, (*bo)->allowed_domains);
1806-
for (i = 0; i < (*bo)->placement.num_placement; i++)
1807-
(*bo)->placements[i].flags |= TTM_PL_FLAG_CONTIGUOUS;
1808-
r = ttm_bo_validate(&(*bo)->tbo, &(*bo)->placement, &ctx);
1809-
if (r)
1810-
return r;
1806+
if ((*bo)->tbo.resource->mem_type == TTM_PL_VRAM &&
1807+
!((*bo)->tbo.resource->placement & TTM_PL_FLAG_CONTIGUOUS)) {
1808+
1809+
amdgpu_bo_placement_from_domain(*bo, (*bo)->allowed_domains);
1810+
for (i = 0; i < (*bo)->placement.num_placement; i++)
1811+
(*bo)->placements[i].flags |= TTM_PL_FLAG_CONTIGUOUS;
1812+
r = ttm_bo_validate(&(*bo)->tbo, &(*bo)->placement, &ctx);
1813+
if (r)
1814+
return r;
1815+
}
18111816

18121817
return amdgpu_ttm_alloc_gart(&(*bo)->tbo);
18131818
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,8 @@ static void amdgpu_uvd_force_into_uvd_segment(struct amdgpu_bo *abo)
551551
for (i = 0; i < abo->placement.num_placement; ++i) {
552552
abo->placements[i].fpfn = 0 >> PAGE_SHIFT;
553553
abo->placements[i].lpfn = (256 * 1024 * 1024) >> PAGE_SHIFT;
554+
if (abo->placements[i].mem_type == TTM_PL_VRAM)
555+
abo->placements[i].flags |= TTM_PL_FLAG_CONTIGUOUS;
554556
}
555557
}
556558

0 commit comments

Comments
 (0)