drm/amdgpu: fix mqd corruption for gfx12
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 drm/amdgpu: fix mqd corruption for gfx12
[AMD Official Use Only - General]
From: Frank Min <[email protected]>
1. restore mqd from backup while resuming
2. use copy_toio and copy_fromio while mqd in vram
Signed-off-by Frank Min <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +8 -13
@@ -2720,17 +2720,15 @@ static int gfx_v12_0_gfx_init_queue(struct amdgpu_ring *ring)soc24_grbm_select (adev,0 ,0 ,0 ,0 );mutex_unlock (&adev->srbm_mutex);if (adev->gfx.me.mqd_backup[mqd_idx]) -memcpy (adev->gfx.me.mqd_backup[mqd_idx], mqd,sizeof (*mqd)); - }else if (amdgpu_in_reset (adev)) { -/* reset mqd with the backup copy */ +memcpy_fromio (adev->gfx.me.mqd_backup[mqd_idx], mqd,sizeof (*mqd)); + }else { +/* restore mqd with the backup copy */ if (adev->gfx.me.mqd_backup[mqd_idx]) -memcpy (mqd, adev->gfx.me.mqd_backup[mqd_idx],sizeof (*mqd)); +memcpy_toio (mqd, adev->gfx.me.mqd_backup[mqd_idx],sizeof (*mqd));/* reset the ring */ ring->wptr =0 ; *ring->wptr_cpu_addr =0 ;amdgpu_ring_clear_ring (ring); - }else { -amdgpu_ring_clear_ring (ring); }return 0 ;
@@ -3091,18 +3089,15 @@ static int gfx_v12_0_kcq_init_queue(struct amdgpu_ring *ring)mutex_unlock (&adev->srbm_mutex);if (adev->gfx.mec.mqd_backup[mqd_idx]) -memcpy (adev->gfx.mec.mqd_backup[mqd_idx], mqd,sizeof (*mqd)); - }else if (amdgpu_in_reset (adev)) {/* for GPU_RESET case */ -/* reset MQD to a clean status */ +memcpy_fromio (adev->gfx.mec.mqd_backup[mqd_idx], mqd,sizeof (*mqd)); + }else { +/* restore MQD to a clean status */ if (adev->gfx.mec.mqd_backup[mqd_idx]) -memcpy (mqd, adev->gfx.mec.mqd_backup[mqd_idx],sizeof (*mqd)); - +memcpy_toio (mqd, adev->gfx.mec.mqd_backup[mqd_idx],sizeof (*mqd));/* reset ring buffer */ ring->wptr =0 ;atomic64_set ((atomic64_t *)ring->wptr_cpu_addr,0 );amdgpu_ring_clear_ring (ring); - }else { -amdgpu_ring_clear_ring (ring); }return 0 ;
--
2.34.1
Quoted 10 lines · Frank
[AMD Official Use Only - General]
From: Frank Min <[email protected]>
1. restore mqd from backup while resuming
2. use
copy_toioandcopy_fromiowhile mqd in vramSigned-off-by Frank Min <[email protected]>
Reviewed-by Alex Deucher <[email protected]>
Quoted 56 lines
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +8
-14@@ -2720,17 +2720,15 @@ static int gfx_v12_0_gfx_init_queue(struct amdgpu_ring *ring)soc24_grbm_select (adev,0 ,0 ,0 ,0 );mutex_unlock (&adev->srbm_mutex);if (adev->gfx.me.mqd_backup[mqd_idx]) -memcpy (adev->gfx.me.mqd_backup[mqd_idx], mqd,sizeof (*mqd)); - }else if (amdgpu_in_reset (adev)) { -/* reset mqd with the backup copy */ +memcpy_fromio (adev->gfx.me.mqd_backup[mqd_idx], mqd,sizeof (*mqd)); + }else { +/* restore mqd with the backup copy */ if (adev->gfx.me.mqd_backup[mqd_idx]) -memcpy (mqd, adev->gfx.me.mqd_backup[mqd_idx],sizeof (*mqd)); +memcpy_toio (mqd, adev->gfx.me.mqd_backup[mqd_idx],sizeof (*mqd));/* reset the ring */ ring->wptr =0 ; *ring->wptr_cpu_addr =0 ;amdgpu_ring_clear_ring (ring); - }else { -amdgpu_ring_clear_ring (ring); }return 0 ;@@ -3091,18 +3089,15 @@ static int gfx_v12_0_kcq_init_queue(struct amdgpu_ring *ring)mutex_unlock (&adev->srbm_mutex);if (adev->gfx.mec.mqd_backup[mqd_idx]) -memcpy (adev->gfx.mec.mqd_backup[mqd_idx], mqd,sizeof (*mqd)); - }else if (amdgpu_in_reset (adev)) {/* for GPU_RESET case */ -/* reset MQD to a clean status */ +memcpy_fromio (adev->gfx.mec.mqd_backup[mqd_idx], mqd,sizeof (*mqd)); + }else { +/* restore MQD to a clean status */ if (adev->gfx.mec.mqd_backup[mqd_idx]) -memcpy (mqd, adev->gfx.mec.mqd_backup[mqd_idx],sizeof (*mqd)); - +memcpy_toio (mqd, adev->gfx.mec.mqd_backup[mqd_idx],sizeof (*mqd));/* reset ring buffer */ ring->wptr =0 ;atomic64_set ((atomic64_t *)ring->wptr_cpu_addr,0 );amdgpu_ring_clear_ring (ring); - }else { -amdgpu_ring_clear_ring (ring); }return 0 ; --2.34.1