Skip to content

Commit 72cda9b

Browse files
Likun Gaoalexdeucher
authored andcommitted
drm/amdgpu: pin the csb buffer on hw init for gfx v8
Without this pin, the csb buffer will be filled with inconsistent data after S3 resume. And that will causes gfx hang on gfxoff exit since this csb will be executed then. Signed-off-by: Likun Gao <[email protected]> Tested-by: Paul Gover <[email protected]> Reviewed-by: Feifei Xu <[email protected]> Reviewed-by: Xiaojie Yuan <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent b887011 commit 72cda9b

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,6 +1321,39 @@ static int gfx_v8_0_rlc_init(struct amdgpu_device *adev)
13211321
return 0;
13221322
}
13231323

1324+
static int gfx_v8_0_csb_vram_pin(struct amdgpu_device *adev)
1325+
{
1326+
int r;
1327+
1328+
r = amdgpu_bo_reserve(adev->gfx.rlc.clear_state_obj, false);
1329+
if (unlikely(r != 0))
1330+
return r;
1331+
1332+
r = amdgpu_bo_pin(adev->gfx.rlc.clear_state_obj,
1333+
AMDGPU_GEM_DOMAIN_VRAM);
1334+
if (!r)
1335+
adev->gfx.rlc.clear_state_gpu_addr =
1336+
amdgpu_bo_gpu_offset(adev->gfx.rlc.clear_state_obj);
1337+
1338+
amdgpu_bo_unreserve(adev->gfx.rlc.clear_state_obj);
1339+
1340+
return r;
1341+
}
1342+
1343+
static void gfx_v8_0_csb_vram_unpin(struct amdgpu_device *adev)
1344+
{
1345+
int r;
1346+
1347+
if (!adev->gfx.rlc.clear_state_obj)
1348+
return;
1349+
1350+
r = amdgpu_bo_reserve(adev->gfx.rlc.clear_state_obj, true);
1351+
if (likely(r == 0)) {
1352+
amdgpu_bo_unpin(adev->gfx.rlc.clear_state_obj);
1353+
amdgpu_bo_unreserve(adev->gfx.rlc.clear_state_obj);
1354+
}
1355+
}
1356+
13241357
static void gfx_v8_0_mec_fini(struct amdgpu_device *adev)
13251358
{
13261359
amdgpu_bo_free_kernel(&adev->gfx.mec.hpd_eop_obj, NULL, NULL);
@@ -4785,6 +4818,10 @@ static int gfx_v8_0_hw_init(void *handle)
47854818
gfx_v8_0_init_golden_registers(adev);
47864819
gfx_v8_0_constants_init(adev);
47874820

4821+
r = gfx_v8_0_csb_vram_pin(adev);
4822+
if (r)
4823+
return r;
4824+
47884825
r = adev->gfx.rlc.funcs->resume(adev);
47894826
if (r)
47904827
return r;
@@ -4901,6 +4938,9 @@ static int gfx_v8_0_hw_fini(void *handle)
49014938
else
49024939
pr_err("rlc is busy, skip halt rlc\n");
49034940
amdgpu_gfx_rlc_exit_safe_mode(adev);
4941+
4942+
gfx_v8_0_csb_vram_unpin(adev);
4943+
49044944
return 0;
49054945
}
49064946

0 commit comments

Comments
 (0)