The devcoredump prints adev->vm_manager.fault_info from the coredump
worker, which runs concurrently with recovery. A fault taken after the
hang was detected, for example by the next job after a queue reset,
replaces the cached fault, so the dump can report a fault that has
nothing to do with the hang.
Copy it in amdgpu_coredump_dump_ip_state() instead, under the PASID
lock that amdgpu_vm_update_fault_cache() holds while updating it, so
the copy is not torn either, and have amdgpu_coredump() take the copy
into the dump. Every amdgpu_coredump() call is preceded by
amdgpu_coredump_dump_ip_state(), and for a full reset that runs before
the IP blocks are suspended, rather than after the reset and resume
where the coredump is taken.
Fixes: 583681d4a417 ("drm/amdgpu: add vm fault information to devcoredump")
Signed-off-by: Matt Turner <[email protected]>
---
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 13 +++++++++++--
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h | 3 +++
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 7eff62f4cdda..c8ca96ce5bdc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -932,6 +932,8 @@ struct amdgpu_device {
struct work_struct coredump_work;
/* the IP state was dumped for the next coredump */
bool coredump_ip_state_valid;
+ /* the last VM fault when the IP state was dumped */
+ struct amdgpu_vm_fault_info coredump_fault_info;
#endif
struct mutex benchmark_mutex;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
index 0e235096977b..4d1b89527545 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
@@ -446,7 +446,7 @@ amdgpu_devcoredump_format(char *buffer, size_t count,
struct amdgpu_coredump_inf
}
/* Add page fault information */
- fault_info = &coredump->adev->vm_manager.fault_info;
+ fault_info = &coredump->fault_info;
drm_printf(&p, "\n[%s] Page fault observed\n",
fault_info->vmhub ? "mmhub" : "gfxhub");
drm_printf(&p, "Faulty page starting at address: 0x%016llx\n",
fault_info->addr);
@@ -579,7 +579,9 @@ static void amdgpu_devcoredump_deferred_work(struct
work_struct *work)
* @adev: amdgpu device pointer
*
* Run each IP block's dump_ip_state() so that the following amdgpu_coredump()
- * can include the register state at the time of the hang.
+ * can include the register state at the time of the hang. Also copy the last
+ * VM fault, which a fault taken during recovery could replace before
+ * amdgpu_coredump() runs after a full reset.
*
* The coredump worker reads the saved registers while it formats a dump, so
* skip this while the worker is busy. Callers run on the reset domain's
@@ -587,8 +589,14 @@ static void amdgpu_devcoredump_deferred_work(struct
work_struct *work)
*/
void amdgpu_coredump_dump_ip_state(struct amdgpu_device *adev)
{
+ unsigned long flags;
int i;
+ /* amdgpu_vm_update_fault_cache() updates it under the PASID lock. */
+ amdgpu_pasid_lock(&flags);
+ adev->coredump_fault_info = adev->vm_manager.fault_info;
+ amdgpu_pasid_unlock(flags);
+
adev->coredump_ip_state_valid = false;
if (work_busy(&adev->coredump_work))
@@ -634,6 +642,7 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool
skip_vram_check,
coredump->skip_vram_check = skip_vram_check;
coredump->reset_vram_lost = vram_lost;
coredump->ip_state_valid = ip_state_valid;
+ coredump->fault_info = adev->coredump_fault_info;
if (job && job->pasid) {
struct amdgpu_task_info *ti;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
index 54b323b007db..6836f312b3f8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
@@ -54,6 +54,9 @@ struct amdgpu_coredump_info {
/* the IP blocks' dump_ip_state() was run for this hang */
bool ip_state_valid;
+ /* the last VM fault when the hang was detected */
+ struct amdgpu_vm_fault_info fault_info;
+
struct amdgpu_coredump_ring *rings;
u32 num_rings;
--
2.56.1