drm/amdgpu: fix amdgpu_coredump
Subsystems (3)
PATCH 1/3 drm/amdgpu: fix amdgpu_coredump
The VM pointer might already be outdated when that function is called. Use the PASID instead to gather the information instead.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c +2 -3
@@ -343,11 +343,10 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check, coredump->skip_vram_check = skip_vram_check; coredump->reset_vram_lost = vram_lost; -if (job && job->vm) { -struct amdgpu_vm *vm = job->vm; +if (job && job->pasid) {struct amdgpu_task_info *ti; - ti =amdgpu_vm_get_task_info_vm (vm); + ti =amdgpu_vm_get_task_info_pasid (adev, job->pasid);if (ti) { coredump->reset_task_info = *ti;amdgpu_vm_put_task_info (ti);
Signature · 1 line
2.34.1
PATCH 2/3 drm/amdgpu: set the VM pointer to NULL in amdgpu_job_prepare
As soon as the prepare phase is completed the VM might be released, better set it to NULL.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +7 -0
@@ -367,6 +367,13 @@ amdgpu_job_prepare_job(struct drm_sched_job *sched_job,dev_err (ring->adev->dev,"Error getting VM ID (%d)\n" , r); goto error; } +/* +* The VM structure might be released after the VMID is +* assigned, we had multiple problems with people trying to use +* the VM pointer so better set it to NULL. +*/ +if (!fence) + job->vm =NULL ; }return fence;
Signature · 1 line
2.34.1
PATCH 3/3 drm/amdgpu: partially revert "reduce reset time"
In reply to Christian KönigThis partially reverts commit 194eb174cbe4fe2b3376ac30acca2dc8c8beca00.
This commit introduced a new state variable into adev without even remotely worrying about CPU barriers.
Since we already have the amdgpu_in_reset() function exactly for this use case partially revert that.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 3 --- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 +- 5 files changed, 4 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -1
@@ -1192,7 +1192,6 @@ struct amdgpu_device {struct work_struct reset_work; -bool job_hang;bool dc_enabled;/* Mask of active clusters */ uint32_t aid_mask;
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +1 -1
@@ -836,7 +836,7 @@ int amdgpu_amdkfd_unmap_hiq(struct amdgpu_device *adev, u32 doorbell_off,if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues)return -EINVAL ; -if (!kiq_ring->sched.ready || adev->job_hang) +if (!kiq_ring->sched.ready ||amdgpu_in_reset (adev))return 0 ; ring_funcs =kzalloc (sizeof (*ring_funcs),GFP_KERNEL );
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +2 -2
@@ -515,7 +515,7 @@ int amdgpu_gfx_disable_kcq(struct amdgpu_device *adev, int xcc_id)if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues)return -EINVAL ; -if (!kiq_ring->sched.ready || adev->job_hang ||amdgpu_in_reset (adev)) +if (!kiq_ring->sched.ready ||amdgpu_in_reset (adev))return 0 ;spin_lock (&kiq->ring_lock);
@@ -567,7 +567,7 @@ int amdgpu_gfx_disable_kgq(struct amdgpu_device *adev, int xcc_id)if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues)return -EINVAL ; -if (!adev->gfx.kiq[0 ].ring.sched.ready || adev->job_hang) +if (!adev->gfx.kiq[0 ].ring.sched.ready ||amdgpu_in_reset (adev))return 0 ;if (amdgpu_gfx_is_master_xcc (adev, xcc_id)) {
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +0 -3
@@ -102,8 +102,6 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job)return DRM_GPU_SCHED_STAT_ENODEV ; } - adev->job_hang = true; -/* * Do the coredump immediately after a job timeout to get a very * close dump/snapshot/representation of GPU's current error status
@@ -181,7 +179,6 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job) } exit: - adev->job_hang = false;drm_dev_exit (idx);return DRM_GPU_SCHED_STAT_NOMINAL ; }
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1 -1
@@ -5957,7 +5957,7 @@ static int gfx_v10_0_cp_gfx_enable(struct amdgpu_device *adev, bool enable)else WREG32_SOC15 (GC ,0 , mmCP_ME_CNTL, tmp); -if (adev->job_hang && !enable) +if (amdgpu_in_reset (adev) && !enable)return 0 ;for (i =0 ; i < adev->usec_timeout; i++) {
Signature · 1 line
2.34.1
Re: [PATCH 3/3] drm/amdgpu: partially revert "reduce reset time"
Quoted 10 lines · Christian König
This partially reverts commit
194eb174cbe4fe2b3376ac30acca2dc8c8beca00.This commit introduced a new state variable into adev without even remotely worrying about CPU barriers.
Since we already have the
amdgpu_in_reset()function exactly for this use case partially revert that.Signed-off-by Christian König <[email protected]>
Series is:
Quoted 92 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 3 --- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 +- 5 files changed, 4 insertions(+), 8 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-1@@ -1192,7 +1192,6 @@ struct amdgpu_device {struct work_struct reset_work; -bool job_hang;bool dc_enabled;/* Mask of active clusters */ uint32_t aid_mask;drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +1
-1@@ -836,7 +836,7 @@ int amdgpu_amdkfd_unmap_hiq(struct amdgpu_device *adev, u32 doorbell_off,if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues)return -EINVAL ; -if (!kiq_ring->sched.ready || adev->job_hang) +if (!kiq_ring->sched.ready ||amdgpu_in_reset (adev))return 0 ; ring_funcs =kzalloc (sizeof (*ring_funcs),GFP_KERNEL );drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +2
-2@@ -515,7 +515,7 @@ int amdgpu_gfx_disable_kcq(struct amdgpu_device *adev, int xcc_id)if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues)return -EINVAL ; -if (!kiq_ring->sched.ready || adev->job_hang ||amdgpu_in_reset (adev)) +if (!kiq_ring->sched.ready ||amdgpu_in_reset (adev))return 0 ;spin_lock (&kiq->ring_lock);@@ -567,7 +567,7 @@ int amdgpu_gfx_disable_kgq(struct amdgpu_device *adev, int xcc_id)if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues)return -EINVAL ; -if (!adev->gfx.kiq[0 ].ring.sched.ready || adev->job_hang) +if (!adev->gfx.kiq[0 ].ring.sched.ready ||amdgpu_in_reset (adev))return 0 ;if (amdgpu_gfx_is_master_xcc (adev, xcc_id)) {drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +0
-3@@ -102,8 +102,6 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job)return DRM_GPU_SCHED_STAT_ENODEV ; } - adev->job_hang = true; -/* * Do the coredump immediately after a job timeout to get a very * close dump/snapshot/representation of GPU's current error status @@ -181,7 +179,6 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job) } exit: - adev->job_hang = false;drm_dev_exit (idx);return DRM_GPU_SCHED_STAT_NOMINAL ; }drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-2@@ -5957,7 +5957,7 @@ static int gfx_v10_0_cp_gfx_enable(struct amdgpu_device *adev, bool enable)else WREG32_SOC15 (GC ,0 , mmCP_ME_CNTL, tmp); -if (adev->job_hang && !enable) +if (amdgpu_in_reset (adev) && !enable)return 0 ;for (i =0 ; i < adev->usec_timeout; i++) { --2.34.1
Sunil please take a look as well.
Thanks,
Christian.
Am 13.12.24 um 09:52 schrieb Christian König:
Quoted 26 lines
The VM pointer might already be outdated when that function is called. Use the PASID instead to gather the information instead.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c +2
-3@@ -343,11 +343,10 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check, coredump->skip_vram_check = skip_vram_check; coredump->reset_vram_lost = vram_lost; -if (job && job->vm) { -struct amdgpu_vm *vm = job->vm; +if (job && job->pasid) {struct amdgpu_task_info *ti; - ti =amdgpu_vm_get_task_info_vm (vm); + ti =amdgpu_vm_get_task_info_pasid (adev, job->pasid);if (ti) { coredump->reset_task_info = *ti;amdgpu_vm_put_task_info (ti);