drm/amdgpu: cache in more vm fault information
Subsystems (2)
PATCH 1/1 drm/amdgpu: cache in more vm fault information
When an page fault interrupt is raised there is a lot more information that is useful for developers to analyse the pagefault.
Add all such information in the last cached pagefault from an interrupt handler.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 9 +++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 7 ++++++- drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 2 +- 7 files changed, 18 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +7 -2
@@ -2905,7 +2905,7 @@ void amdgpu_debugfs_vm_bo_info(struct amdgpu_vm *vm, struct seq_file *m)* Cache the fault info for later use by userspace in debugging. */ void amdgpu_vm_update_fault_cache (struct amdgpu_device *adev, -unsigned int pasid, +struct amdgpu_iv_entry *entry,uint64_t addr,uint32_t status,unsigned int vmhub)
@@ -2915,7 +2915,7 @@ void amdgpu_vm_update_fault_cache(struct amdgpu_device *adev,xa_lock_irqsave (&adev->vm_manager.pasids, flags); - vm =xa_load (&adev->vm_manager.pasids, pasid); + vm =xa_load (&adev->vm_manager.pasids, entry->pasid);/* Don't update the fault cache if status is 0. In the multiple * fault case, subsequent faults will return a 0 status which is * useless for userspace and replaces the useful fault status, so
@@ -2924,6 +2924,11 @@ void amdgpu_vm_update_fault_cache(struct amdgpu_device *adev,if (vm && status) { vm->fault_info.addr = addr; vm->fault_info.status = status; + vm->fault_info.client_id = entry->client_id; + vm->fault_info.src_id = entry->src_id; + vm->fault_info.vmid = entry->vmid; + vm->fault_info.pasid = entry->pasid; + vm->fault_info.ring_id = entry->ring_id;if (AMDGPU_IS_GFXHUB (vmhub)) { vm->fault_info.vmhub =AMDGPU_VMHUB_TYPE_GFX ; vm->fault_info.vmhub |=
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +6 -1
@@ -286,6 +286,11 @@ struct amdgpu_vm_fault_info {uint32_t status;/* which vmhub? gfxhub, mmhub, etc. */ unsigned int vmhub; +unsigned int client_id; +unsigned int src_id; +unsigned int ring_id; +unsigned int pasid; +unsigned int vmid; };struct amdgpu_vm {
@@ -605,7 +610,7 @@ static inline void amdgpu_vm_eviction_unlock(struct amdgpu_vm *vm) }void amdgpu_vm_update_fault_cache (struct amdgpu_device *adev, -unsigned int pasid, +struct amdgpu_iv_entry *entry,uint64_t addr,uint32_t status,unsigned int vmhub);
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -1
@@ -150,7 +150,7 @@ static int gmc_v10_0_process_interrupt(struct amdgpu_device *adev, status =RREG32 (hub->vm_l2_pro_fault_status);WREG32_P (hub->vm_l2_pro_fault_cntl,1 , ~1 ); -amdgpu_vm_update_fault_cache (adev, entry->pasid, addr, status, +amdgpu_vm_update_fault_cache (adev, entry, addr, status, entry->vmid_src ?AMDGPU_MMHUB0 (0 ) :AMDGPU_GFXHUB (0 )); }
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +1 -1
@@ -121,7 +121,7 @@ static int gmc_v11_0_process_interrupt(struct amdgpu_device *adev, status =RREG32 (hub->vm_l2_pro_fault_status);WREG32_P (hub->vm_l2_pro_fault_cntl,1 , ~1 ); -amdgpu_vm_update_fault_cache (adev, entry->pasid, addr, status, +amdgpu_vm_update_fault_cache (adev, entry, addr, status, entry->vmid_src ?AMDGPU_MMHUB0 (0 ) :AMDGPU_GFXHUB (0 )); }
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +1 -1
@@ -1270,7 +1270,7 @@ static int gmc_v7_0_process_interrupt(struct amdgpu_device *adev,if (!addr && !status)return 0 ; -amdgpu_vm_update_fault_cache (adev, entry->pasid, +amdgpu_vm_update_fault_cache (adev, entry, ((u64 )addr) <<AMDGPU_GPU_PAGE_SHIFT , status,AMDGPU_GFXHUB (0 ));if (amdgpu_vm_fault_stop ==AMDGPU_VM_FAULT_STOP_FIRST )
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +1 -1
@@ -1438,7 +1438,7 @@ static int gmc_v8_0_process_interrupt(struct amdgpu_device *adev,if (!addr && !status)return 0 ; -amdgpu_vm_update_fault_cache (adev, entry->pasid, +amdgpu_vm_update_fault_cache (adev, entry, ((u64 )addr) <<AMDGPU_GPU_PAGE_SHIFT , status,AMDGPU_GFXHUB (0 ));if (amdgpu_vm_fault_stop ==AMDGPU_VM_FAULT_STOP_FIRST )
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -1
@@ -666,7 +666,7 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev, rw =REG_GET_FIELD (status,VM_L2_PROTECTION_FAULT_STATUS ,RW );WREG32_P (hub->vm_l2_pro_fault_cntl,1 , ~1 ); -amdgpu_vm_update_fault_cache (adev, entry->pasid, addr, status, vmhub); +amdgpu_vm_update_fault_cache (adev, entry, addr, status, vmhub); dev_err(adev->dev, "VM_L2_PROTECTION_FAULT_STATUS:0x%08X\n",
Signature · 1 line
2.34.1
PATCH 1/1 drm/amdgpu: add vm fault information to devcoredump
Add page fault information to the devcoredump.
Output of devcoredump:
**** AMDGPU Device Coredump ****
version: 1
kernel: 6.7.0-amd-staging-drm-next
module: amdgpu
time: 29.725011811process_name: soft_recovery_p PID: 1720
Ring timed out details
IP Type: 0 Ring Name: gfx_0.0.0
[gfxhub] Page fault observed for GPU family:143 Faulty page starting at address 0x0000000000000000 Protection fault status register:0x301031
VRAM is lost due to GPU reset!
--- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 15 ++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +14 -1
@@ -203,8 +203,20 @@ amdgpu_devcoredump_read(char *buffer, loff_t offset, size_t count, coredump->ring->name); } +if (coredump->fault_info.status) { +struct amdgpu_vm_fault_info *fault_info = &coredump->fault_info; + +drm_printf (&p,"\n[%s] Page fault observed for GPU family:%d\n" , + fault_info->vmhub ?"mmhub" :"gfxhub" , + coredump->adev->family); +drm_printf (&p,"Faulty page starting at address 0x%016llx\n" , + fault_info->addr); +drm_printf (&p,"Protection fault status register:0x%x\n" , + fault_info->status); + } +if (coredump->reset_vram_lost) -drm_printf (&p,"VRAM is lost due to GPU reset!\n" ); +drm_printf (&p,"\nVRAM is lost due to GPU reset!\n" );if (coredump->adev->reset_info.num_regs) {drm_printf (&p,"AMDGPU register dumps:\nOffset: Value:\n" );
@@ -253,6 +265,7 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool vram_lost,if (job) { s_job = &job->base; coredump->ring =to_amdgpu_ring (s_job->sched); + coredump->fault_info = job->vm->fault_info; } coredump->adev = adev;
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +1 -0
@@ -98,6 +98,7 @@ struct amdgpu_coredump_info {struct timespec64 reset_time;bool reset_vram_lost;struct amdgpu_ring *ring; + struct amdgpu_vm_fault_info fault_info; };#endif
Signature · 1 line
2.34.1
Deucher, Alexander
maintainerRE: [PATCH] drm/amdgpu: add vm fault information to devcoredump
[Public]
Quoted 22 lines
-----Original Message-----
From: Sunil Khatri <[email protected]>
Sent: Wednesday, March 6, 2024 1:20 PM
To: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Sharma, Shashank <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; Joshi, Mukul <[email protected]>; Paneer Selvam, Arunpravin <[email protected]>; Khatri, Sunil <[email protected]>
Subject: [PATCH] drm/amdgpu: add vm fault information to devcoredumpAdd page fault information to the devcoredump.
Output of devcoredump:
**** AMDGPU Device Coredump ****
version: 1
kernel: 6.7.0-amd-staging-drm-next
module: amdgpu
time: 29.725011811process_name:soft_recovery_pPID: 1720
Quoted 4 lines
Ring timed out details
IP Type: 0 Ring Name: gfx_0.0.0[gfxhub] Page fault observed for GPU family:143 Faulty page starting at
I think we should add a separate section for the GPU identification information (family, PCI ids, IP versions, etc.). For this patch, I think fine to just print the fault address and status.
Alex
Quoted 65 lines
address
0x0000000000000000Protection fault status register:0x301031VRAM is lost due to GPU reset!
Signed-off-by Sunil Khatri <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 15 ++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +13
-1@@ -203,8 +203,20 @@ amdgpu_devcoredump_read(char *buffer, loff_t offset, size_t count, coredump->ring->name); } +if (coredump->fault_info.status) { +struct amdgpu_vm_fault_info *fault_info = &coredump- >fault_info; + +drm_printf (&p,"\n[%s] Page fault observed for GPU family:%d\n", + fault_info->vmhub ?"mmhub" :"gfxhub" , + coredump->adev->family); +drm_printf (&p,"Faulty page starting at address 0x%016llx\n" , + fault_info->addr); +drm_printf (&p,"Protection fault status register:0x%x\n" , + fault_info->status); + } +if (coredump->reset_vram_lost) -drm_printf (&p,"VRAM is lost due to GPU reset!\n" ); +drm_printf (&p,"\nVRAM is lost due to GPU reset!\n" );if (
coredump->adev->reset_info.num_regs) {
drm_printf(&p, "AMDGPU register dumps:\nOffset:
Value:\n");drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +1
-0@@ -253,6 +265,7 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool vram_lost, if (job) { s_job = &job->base; coredump->ring =to_amdgpu_ring (s_job->sched); + coredump->fault_info = job->vm->fault_info; }coredump->adev = adev;drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +1
-1@@ -98,6 +98,7 @@ struct amdgpu_coredump_info {struct timespec64 reset_time;bool reset_vram_lost;struct amdgpu_ring *ring; + struct amdgpu_vm_fault_info fault_info; };#endif --2.34.1
Re: [PATCH] drm/amdgpu: add vm fault information to devcoredump
Quoted 24 lines · Alexander
[Public]
Quoted 22 lines
-----Original Message-----
From: Sunil Khatri <[email protected]>
Sent: Wednesday, March 6, 2024 1:20 PM
To: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Sharma, Shashank <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; Joshi, Mukul <[email protected]>; Paneer Selvam, Arunpravin <[email protected]>; Khatri, Sunil <[email protected]>
Subject: [PATCH] drm/amdgpu: add vm fault information to devcoredumpAdd page fault information to the devcoredump.
Output of devcoredump:
**** AMDGPU Device Coredump ****
version: 1
kernel: 6.7.0-amd-staging-drm-next
module: amdgpu
time: 29.725011811process_name:soft_recovery_pPID: 1720
Quoted 5 lines
Quoted 4 lines
Ring timed out details
IP Type: 0 Ring Name: gfx_0.0.0[gfxhub] Page fault observed for GPU family:143 Faulty page starting at
I think we should add a separate section for the GPU identification information (family, PCI ids, IP versions, etc.). For this patch, I think fine to just print the fault address and status.
Noted
Regards
Sunil
Quoted 67 lines
Alex
Quoted 65 lines
address
0x0000000000000000Protection fault status register:0x301031VRAM is lost due to GPU reset!
Signed-off-by Sunil Khatri <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 15 ++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +13
-1@@ -203,8 +203,20 @@ amdgpu_devcoredump_read(char *buffer, loff_t offset, size_t count, coredump->ring->name); } +if (coredump->fault_info.status) { +struct amdgpu_vm_fault_info *fault_info = &coredump- > fault_info; + +drm_printf (&p,"\n[%s] Page fault observed for GPU family:%d\n", + fault_info->vmhub ?"mmhub" :"gfxhub" , + coredump->adev->family); +drm_printf (&p,"Faulty page starting at address 0x%016llx\n" , + fault_info->addr); +drm_printf (&p,"Protection fault status register:0x%x\n" , + fault_info->status); + } +if (coredump->reset_vram_lost) -drm_printf (&p,"VRAM is lost due to GPU reset!\n" ); +drm_printf (&p,"\nVRAM is lost due to GPU reset!\n" );if (
coredump->adev->reset_info.num_regs) {
drm_printf(&p, "AMDGPU register dumps:\nOffset:
Value:\n");drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +1
-0@@ -253,6 +265,7 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool vram_lost, if (job) { s_job = &job->base; coredump->ring =to_amdgpu_ring (s_job->sched); + coredump->fault_info = job->vm->fault_info; }coredump->adev = adev;drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +1
-1@@ -98,6 +98,7 @@ struct amdgpu_coredump_info {struct timespec64 reset_time;bool reset_vram_lost;struct amdgpu_ring *ring; + struct amdgpu_vm_fault_info fault_info; };#endif --2.34.1
Christian König
maintainerRe: [PATCH] drm/amdgpu: add vm fault information to devcoredump
In reply to Sunil KhatriAm 06.03.24 um 19:19 schrieb Sunil Khatri:
Quoted 52 lines
Add page fault information to the devcoredump.
Output of devcoredump:
**** AMDGPU Device Coredump ****
version: 1
kernel: 6.7.0-amd-staging-drm-next
module: amdgpu
time: 29.725011811process_name:soft_recovery_pPID: 1720Ring timed out details
IP Type: 0 Ring Name: gfx_0.0.0[gfxhub] Page fault observed for GPU family:143 Faulty page starting at address
0x0000000000000000Protection fault status register:0x301031VRAM is lost due to GPU reset!
Signed-off-by Sunil Khatri <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 15 ++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +13
-1@@ -203,8 +203,20 @@ amdgpu_devcoredump_read(char *buffer, loff_t offset, size_t count, coredump->ring->name); } +if (coredump->fault_info.status) { +struct amdgpu_vm_fault_info *fault_info = &coredump->fault_info; + +drm_printf (&p,"\n[%s] Page fault observed for GPU family:%d\n" , + fault_info->vmhub ?"mmhub" :"gfxhub" , + coredump->adev->family); +drm_printf (&p,"Faulty page starting at address 0x%016llx\n" , + fault_info->addr); +drm_printf (&p,"Protection fault status register:0x%x\n" , + fault_info->status); + } +if (coredump->reset_vram_lost) -drm_printf (&p,"VRAM is lost due to GPU reset!\n" ); +drm_printf (&p,"\nVRAM is lost due to GPU reset!\n" );if (coredump->adev->reset_info.num_regs) {drm_printf (&p,"AMDGPU register dumps:\nOffset: Value:\n" );
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c void amdgpu_coredump(struct amdgpu_device *adev, bool vram_lost, · line 268
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +1
-0@@ -253,6 +265,7 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool vram_lost,if (job) { s_job = &job->base; coredump->ring =to_amdgpu_ring (s_job->sched); + coredump->fault_info = job->vm->fault_info;
That's illegal. The VM pointer might already be stale at this point.
I think you need to add the fault info of the last fault globally in the VRAM manager or move this to the process info Shashank is working on.
Regards,
Christian.
Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +0
-0} coredump->adev = adev;drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +1
-0@@ -98,6 +98,7 @@ struct amdgpu_coredump_info {struct timespec64 reset_time;bool reset_vram_lost;struct amdgpu_ring *ring; + struct amdgpu_vm_fault_info fault_info; };#endif
Re: [PATCH] drm/amdgpu: add vm fault information to devcoredump
Quoted 83 lines · Christian König
Am 06.03.24 um 19:19 schrieb Sunil Khatri:
Quoted 50 lines
Add page fault information to the devcoredump.
Output of devcoredump:
**** AMDGPU Device Coredump ****
version: 1
kernel: 6.7.0-amd-staging-drm-next
module: amdgpu
time: 29.725011811process_name:soft_recovery_pPID: 1720Ring timed out details
IP Type: 0 Ring Name: gfx_0.0.0[gfxhub] Page fault observed for GPU family:143 Faulty page starting at address
0x0000000000000000Protection fault status register:0x301031VRAM is lost due to GPU reset!
Signed-off-by Sunil Khatri <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c| 15 ++++++++++++++-drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h| 1 +2 files changed, 15 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +12
-1@@ -203,8 +203,20 @@ amdgpu_devcoredump_read(char *buffer, loff_t offset, size_t count, coredump->ring->name); } + if (coredump->fault_info.status) { + struct amdgpu_vm_fault_info *fault_info = &coredump->fault_info; + + drm_printf(&p, "\n[%s] Page fault observed for GPU family:%d\n", + fault_info->vmhub ? "mmhub" : "gfxhub", + coredump->adev->family); + drm_printf(&p, "Faulty page starting at address 0x%016llx\n", + fault_info->addr); + drm_printf(&p, "Protection fault status register:0x%x\n", + fault_info->status); + } + if (coredump->reset_vram_lost) - drm_printf(&p, "VRAM is lost due to GPU reset!\n"); + drm_printf(&p, "\nVRAM is lost due to GPU reset!\n");Quoted 7 lines
if (
coredump->adev->reset_info.num_regs) {
drm_printf(&p, "AMDGPU register dumps:\nOffset: Value:\n"); @@ -253,6 +265,7 @@ void amdgpu_coredump(structamdgpu_device*adev, boolvram_lost, if (job) {
s_job=&job->base;
coredump->ring=to_amdgpu_ring(s_job->sched);
+coredump->fault_info=job->vm->fault_info;That's illegal. The VM pointer might already be stale at this point.
I think you need to add the fault info of the last fault globally in the VRAM manager or move this to the process info Shashank is working on.
Are you saying that during the reset or otherwise a vm which is part of this job could have been freed and we might have a NULL dereference or invalid reference? Till now based on the resets and pagefaults that i have created till now using the same app which we are using for IH overflow i am able to get the valid vm only.Assuming
amdgpu_vmis freed for this job or stale, are you suggesting to update this information in adev->vm_manageralong with existing per vmfault_infoor only invm_manager?Regards,
Christian.Quoted 13 lines
}
coredump->adev= adev;drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +1
-0@@ -98,6 +98,7 @@ struct amdgpu_coredump_info { struct timespec64 reset_time; bool reset_vram_lost; struct amdgpu_ring *ring; + struct amdgpu_vm_fault_info fault_info; }; #endif
Christian König
maintainerRe: [PATCH] drm/amdgpu: add vm fault information to devcoredump
Am 07.03.24 um 09:37 schrieb Khatri, Sunil:
Quoted 63 lines · Christian König
Quoted 61 lines
Am 06.03.24 um 19:19 schrieb Sunil Khatri:
Quoted 50 lines
Add page fault information to the devcoredump.
Output of devcoredump:
**** AMDGPU Device Coredump ****
version: 1
kernel: 6.7.0-amd-staging-drm-next
module: amdgpu
time: 29.725011811process_name:soft_recovery_pPID: 1720Ring timed out details
IP Type: 0 Ring Name: gfx_0.0.0[gfxhub] Page fault observed for GPU family:143 Faulty page starting at address
0x0000000000000000Protection fault status register:0x301031VRAM is lost due to GPU reset!
Signed-off-by Sunil Khatri <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c| 15 ++++++++++++++-drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h| 1 +2 files changed, 15 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +12
-1@@ -203,8 +203,20 @@ amdgpu_devcoredump_read(char *buffer, loff_t offset, size_t count, coredump->ring->name); } + if (coredump->fault_info.status) { + struct amdgpu_vm_fault_info *fault_info = &coredump->fault_info; + + drm_printf(&p, "\n[%s] Page fault observed for GPU family:%d\n", + fault_info->vmhub ? "mmhub" : "gfxhub", + coredump->adev->family); + drm_printf(&p, "Faulty page starting at address 0x%016llx\n", + fault_info->addr); + drm_printf(&p, "Protection fault status register:0x%x\n", + fault_info->status); + } + if (coredump->reset_vram_lost) - drm_printf(&p, "VRAM is lost due to GPU reset!\n"); + drm_printf(&p, "\nVRAM is lost due to GPU reset!\n");Quoted 7 lines
if (
coredump->adev->reset_info.num_regs) {
drm_printf(&p, "AMDGPU register dumps:\nOffset: Value:\n"); @@ -253,6 +265,7 @@ void amdgpu_coredump(structamdgpu_device*adev, boolvram_lost, if (job) {
s_job=&job->base;
coredump->ring=to_amdgpu_ring(s_job->sched);
+coredump->fault_info=job->vm->fault_info;That's illegal. The VM pointer might already be stale at this point.
Quoted 4 lines
Quoted 4 lines
I think you need to add the fault info of the last fault globally in the VRAM manager or move this to the process info Shashank is working on.
Are you saying that during the reset or otherwise a vm which is part of this job could have been freed and we might have a NULL dereference or invalid reference? Till now based on the resets and pagefaults that i have created till now using the same app which we are using for IH overflow i am able to get the valid vm only.Assuming
amdgpu_vmis freed for this job or stale, are you suggesting to update this information in adev->vm_manageralong with existing per vmfault_infoor only invm_manager?
Good question. having it both in the VM as well as the VM manager sounds like the simplest option for now.
Regards,
Christian.
Quoted 18 lines
Quoted 18 lines
Regards,
Christian.Quoted 13 lines
}
coredump->adev= adev;drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +1
-0@@ -98,6 +98,7 @@ struct amdgpu_coredump_info { struct timespec64 reset_time; bool reset_vram_lost; struct amdgpu_ring *ring; + struct amdgpu_vm_fault_info fault_info; }; #endif
Re: [PATCH] drm/amdgpu: add vm fault information to devcoredump
Quoted 64 lines · Christian König
Am 07.03.24 um 09:37 schrieb Khatri, Sunil:
Quoted 63 lines · Christian König
Quoted 61 lines
Am 06.03.24 um 19:19 schrieb Sunil Khatri:
Quoted 50 lines
Add page fault information to the devcoredump.
Output of devcoredump:
**** AMDGPU Device Coredump ****
version: 1
kernel: 6.7.0-amd-staging-drm-next
module: amdgpu
time: 29.725011811process_name:soft_recovery_pPID: 1720Ring timed out details
IP Type: 0 Ring Name: gfx_0.0.0[gfxhub] Page fault observed for GPU family:143 Faulty page starting at address
0x0000000000000000Protection fault status register:0x301031VRAM is lost due to GPU reset!
Signed-off-by Sunil Khatri <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c| 15 ++++++++++++++-drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h| 1 +2 files changed, 15 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +12
-1@@ -203,8 +203,20 @@ amdgpu_devcoredump_read(char *buffer, loff_t offset, size_t count, coredump->ring->name); } + if (coredump->fault_info.status) { + struct amdgpu_vm_fault_info *fault_info = &coredump->fault_info; + + drm_printf(&p, "\n[%s] Page fault observed for GPU family:%d\n", + fault_info->vmhub ? "mmhub" : "gfxhub", + coredump->adev->family); + drm_printf(&p, "Faulty page starting at address 0x%016llx\n", + fault_info->addr); + drm_printf(&p, "Protection fault status register:0x%x\n", + fault_info->status); + } + if (coredump->reset_vram_lost) - drm_printf(&p, "VRAM is lost due to GPU reset!\n"); + drm_printf(&p, "\nVRAM is lost due to GPU reset!\n");Quoted 7 lines
if (
coredump->adev->reset_info.num_regs) {
drm_printf(&p, "AMDGPU register dumps:\nOffset: Value:\n"); @@ -253,6 +265,7 @@ void amdgpu_coredump(structamdgpu_device*adev, boolvram_lost, if (job) {
s_job=&job->base;
coredump->ring=to_amdgpu_ring(s_job->sched);
+coredump->fault_info=job->vm->fault_info;That's illegal. The VM pointer might already be stale at this point.
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
I think you need to add the fault info of the last fault globally in the VRAM manager or move this to the process info Shashank is working on.
Are you saying that during the reset or otherwise a vm which is part of this job could have been freed and we might have a NULL dereference or invalid reference? Till now based on the resets and pagefaults that i have created till now using the same app which we are using for IH overflow i am able to get the valid vm only.Assuming
amdgpu_vmis freed for this job or stale, are you suggesting to update this information in adev->vm_manageralong with existing per vmfault_infoor only invm_manager?Good question. having it both in the VM as well as the VM manager sounds like the simplest option for now.
Let me update the patch then with information in VM manager.
Regards
Sunil
Quoted 23 lines
Regards,
Christian.Quoted 18 lines
Quoted 18 lines
Regards,
Christian.Quoted 13 lines
}
coredump->adev= adev;drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +1
-0@@ -98,6 +98,7 @@ struct amdgpu_coredump_info { struct timespec64 reset_time; bool reset_vram_lost; struct amdgpu_ring *ring; + struct amdgpu_vm_fault_info fault_info; }; #endif
[AMD Official Use Only - General]
Ignore this. Triggered wrongly.
-----Original Message-----
From: Sunil Khatri <[email protected]>
Sent: Wednesday, March 6, 2024 11:50 PM
To: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Sharma, Shashank <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Joshi, Mukul <[email protected]>; Paneer Selvam, Arunpravin <[email protected]>; Khatri, Sunil <[email protected]>
Subject: [PATCH] drm/amdgpu: cache in more vm fault information
When an page fault interrupt is raised there is a lot more information that is useful for developers to analyse the pagefault.
Add all such information in the last cached pagefault from an interrupt handler.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 9 +++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 7 ++++++- drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 2 +- 7 files changed, 18 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -2
@@ -2905,7 +2905,7 @@ void amdgpu_debugfs_vm_bo_info(struct amdgpu_vm *vm, struct seq_file *m)* Cache the fault info for later use by userspace in debugging. */ void amdgpu_vm_update_fault_cache (struct amdgpu_device *adev, -unsigned int pasid, +struct amdgpu_iv_entry *entry,uint64_t addr,uint32_t status,unsigned int vmhub)
@@ -2915,7 +2915,7 @@ void amdgpu_vm_update_fault_cache(struct amdgpu_device *adev,xa_lock_irqsave (&adev->vm_manager.pasids, flags); - vm =xa_load (&adev->vm_manager.pasids, pasid); + vm =xa_load (&adev->vm_manager.pasids, entry->pasid);/* Don't update the fault cache if status is 0. In the multiple * fault case, subsequent faults will return a 0 status which is * useless for userspace and replaces the useful fault status, so @@ -2924,6 +2924,11 @@ void amdgpu_vm_update_fault_cache(struct amdgpu_device *adev,
if (vm && status) {
vm->fault_info.addr = addr;
vm->fault_info.status = status;
+ vm->fault_info.client_id = entry->client_id;
+ vm->fault_info.src_id = entry->src_id;
+ vm->fault_info.vmid = entry->vmid;
+ vm->fault_info.pasid = entry->pasid;
+ vm->fault_info.ring_id = entry->ring_id;
if (AMDGPU_IS_GFXHUB(vmhub)) {
vm->fault_info.vmhub = AMDGPU_VMHUB_TYPE_GFX;
vm->fault_info.vmhub |=drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +6 -1
@@ -286,6 +286,11 @@ struct amdgpu_vm_fault_info {uint32_t status;/* which vmhub? gfxhub, mmhub, etc. */ unsigned int vmhub; +unsigned int client_id; +unsigned int src_id; +unsigned int ring_id; +unsigned int pasid; +unsigned int vmid; };struct amdgpu_vm {
@@ -605,7 +610,7 @@ static inline void amdgpu_vm_eviction_unlock(struct amdgpu_vm *vm) }void amdgpu_vm_update_fault_cache (struct amdgpu_device *adev, -unsigned int pasid, +struct amdgpu_iv_entry *entry,uint64_t addr,uint32_t status,unsigned int vmhub);
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -1
@@ -150,7 +150,7 @@ static int gmc_v10_0_process_interrupt(struct amdgpu_device *adev, status =RREG32 (hub->vm_l2_pro_fault_status);WREG32_P (hub->vm_l2_pro_fault_cntl,1 , ~1 ); -amdgpu_vm_update_fault_cache (adev, entry->pasid, addr, status, +amdgpu_vm_update_fault_cache (adev, entry, addr, status, entry->vmid_src ?AMDGPU_MMHUB0 (0 ) :AMDGPU_GFXHUB (0 )); }
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +1 -1
@@ -121,7 +121,7 @@ static int gmc_v11_0_process_interrupt(struct amdgpu_device *adev, status =RREG32 (hub->vm_l2_pro_fault_status);WREG32_P (hub->vm_l2_pro_fault_cntl,1 , ~1 ); -amdgpu_vm_update_fault_cache (adev, entry->pasid, addr, status, +amdgpu_vm_update_fault_cache (adev, entry, addr, status, entry->vmid_src ?AMDGPU_MMHUB0 (0 ) :AMDGPU_GFXHUB (0 )); }
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +1 -1
@@ -1270,7 +1270,7 @@ static int gmc_v7_0_process_interrupt(struct amdgpu_device *adev,if (!addr && !status)return 0 ; -amdgpu_vm_update_fault_cache (adev, entry->pasid, +amdgpu_vm_update_fault_cache (adev, entry, ((u64 )addr) <<AMDGPU_GPU_PAGE_SHIFT , status,AMDGPU_GFXHUB (0 )); if (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_FIRST) diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
index d20e5f20ee31..a271bf832312 100644
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +1 -1
@@ -1438,7 +1438,7 @@ static int gmc_v8_0_process_interrupt(struct amdgpu_device *adev,if (!addr && !status)return 0 ; -amdgpu_vm_update_fault_cache (adev, entry->pasid, +amdgpu_vm_update_fault_cache (adev, entry, ((u64 )addr) <<AMDGPU_GPU_PAGE_SHIFT , status,AMDGPU_GFXHUB (0 )); if (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_FIRST) diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
index 47b63a4ce68b..dc9fb1fb9540 100644
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -1
@@ -666,7 +666,7 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev, rw =REG_GET_FIELD (status,VM_L2_PROTECTION_FAULT_STATUS ,RW );WREG32_P (hub->vm_l2_pro_fault_cntl,1 , ~1 ); -amdgpu_vm_update_fault_cache (adev, entry->pasid, addr, status, vmhub); +amdgpu_vm_update_fault_cache (adev, entry, addr, status, vmhub); dev_err(adev->dev, "VM_L2_PROTECTION_FAULT_STATUS:0x%08X\n",
--
2.34.1