drm/amdgpu: add new bit definitions for GC 9.0 PROTECTION_FAULT_STATUS
Subsystems (3)
PATCH 1/5 drm/amdgpu: add new bit definitions for GC 9.0 PROTECTION_FAULT_STATUS
Add UCE and FED bit definitions.
--- drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_0_sh_mask.h | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_0_sh_mask.h +4 -0
@@ -6822,6 +6822,8 @@#define VM_L2_PROTECTION_FAULT_STATUS__VMID__SHIFT 0x14#define VM_L2_PROTECTION_FAULT_STATUS__VF__SHIFT 0x18#define VM_L2_PROTECTION_FAULT_STATUS__VFID__SHIFT 0x19 +#define VM_L2_PROTECTION_FAULT_STATUS__UCE__SHIFT 0x1d +#define VM_L2_PROTECTION_FAULT_STATUS__FED__SHIFT 0x1e#define VM_L2_PROTECTION_FAULT_STATUS__MORE_FAULTS_MASK 0x00000001L#define VM_L2_PROTECTION_FAULT_STATUS__WALKER_ERROR_MASK 0x0000000EL#define VM_L2_PROTECTION_FAULT_STATUS__PERMISSION_FAULTS_MASK 0x000000F0L
@@ -6832,6 +6834,8 @@#define VM_L2_PROTECTION_FAULT_STATUS__VMID_MASK 0x00F00000L#define VM_L2_PROTECTION_FAULT_STATUS__VF_MASK 0x01000000L#define VM_L2_PROTECTION_FAULT_STATUS__VFID_MASK 0x1E000000L +#define VM_L2_PROTECTION_FAULT_STATUS__UCE_MASK 0x20000000L +#define VM_L2_PROTECTION_FAULT_STATUS__FED_MASK 0x40000000L//VM_L2_PROTECTION_FAULT_ADDR_LO32 #define VM_L2_PROTECTION_FAULT_ADDR_LO32__LOGICAL_PAGE_ADDR_LO32__SHIFT 0x0#define VM_L2_PROTECTION_FAULT_ADDR_LO32__LOGICAL_PAGE_ADDR_LO32_MASK 0xFFFFFFFFL
Signature · 1 line
2.34.1
PATCH 2/5 drm/amdgpu: add utcl2 poison query for gfxhub
Implement it for gfxhub 1.0 and 1.2.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfxhub.h | 2 ++ drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c | 17 +++++++++++++++++ drivers/gpu/drm/amd/amdgpu/gfxhub_v1_2.c | 15 +++++++++++++++ 3 files changed, 34 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfxhub.h +2 -0
@@ -38,6 +38,8 @@ struct amdgpu_gfxhub_funcs {void (*mode2_save_regs)(struct amdgpu_device *adev);void (*mode2_restore_regs)(struct amdgpu_device *adev);void (*halt)(struct amdgpu_device *adev); +bool (*query_utcl2_poison_status)(struct amdgpu_device *adev, +uint32_t node_id); };struct amdgpu_gfxhub {
drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c +17 -0
@@ -443,6 +443,22 @@ static void gfxhub_v1_0_init(struct amdgpu_device *adev) mmVM_INVALIDATE_ENG0_ADDR_RANGE_LO32; } +static bool gfxhub_v1_0_query_utcl2_poison_status (struct amdgpu_device *adev, +uint32_t node_id) +{ +u32 status =0 ; +struct amdgpu_vmhub *hub; + +if (amdgpu_ip_version (adev,GC_HWIP ,0 ) !=IP_VERSION (9 ,4 ,2 )) +return false; + + hub = &adev->vmhub[AMDGPU_GFXHUB (0 )]; + status =RREG32 (hub->vm_l2_pro_fault_status); +/* reset page fault status */ +WREG32_P (hub->vm_l2_pro_fault_cntl,1 , ~1 ); + +return REG_GET_FIELD (status,VM_L2_PROTECTION_FAULT_STATUS ,FED ); +}const struct amdgpu_gfxhub_funcs gfxhub_v1_0_funcs = { .get_mc_fb_offset = gfxhub_v1_0_get_mc_fb_offset,
@@ -452,4 +468,5 @@ const struct amdgpu_gfxhub_funcs gfxhub_v1_0_funcs = { .set_fault_enable_default = gfxhub_v1_0_set_fault_enable_default, .init = gfxhub_v1_0_init, .get_xgmi_info = gfxhub_v1_1_get_xgmi_info, + .query_utcl2_poison_status = gfxhub_v1_0_query_utcl2_poison_status, };
drivers/gpu/drm/amd/amdgpu/gfxhub_v1_2.c +15 -0
@@ -620,6 +620,20 @@ static int gfxhub_v1_2_get_xgmi_info(struct amdgpu_device *adev)return 0 ; } +static bool gfxhub_v1_2_query_utcl2_poison_status (struct amdgpu_device *adev, +uint32_t node_id) +{ +u32 fed, status; + + status =RREG32_SOC15 (GC , node_id, regVM_L2_PROTECTION_FAULT_STATUS); + fed =REG_GET_FIELD (status,VM_L2_PROTECTION_FAULT_STATUS ,FED ); +/* reset page fault status */ +WREG32_P (SOC15_REG_OFFSET (GC , node_id, + regVM_L2_PROTECTION_FAULT_STATUS),1 , ~1 ); + +return fed; +} +const struct amdgpu_gfxhub_funcs gfxhub_v1_2_funcs = { .get_mc_fb_offset = gfxhub_v1_2_get_mc_fb_offset, .setup_vm_pt_regs = gfxhub_v1_2_setup_vm_pt_regs,
@@ -628,6 +642,7 @@ const struct amdgpu_gfxhub_funcs gfxhub_v1_2_funcs = { .set_fault_enable_default = gfxhub_v1_2_set_fault_enable_default, .init = gfxhub_v1_2_init, .get_xgmi_info = gfxhub_v1_2_get_xgmi_info, + .query_utcl2_poison_status = gfxhub_v1_2_query_utcl2_poison_status, };static int gfxhub_v1_2_xcp_resume (void *handle,uint32_t inst_mask)
Signature · 1 line
2.34.1
PATCH 3/5 drm/amdgpu: retire gfx ras query_utcl2_poison_status
In reply to Tao ZhouReplace it with related interface in gfxhub functions.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 7 ++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 1 - drivers/gpu/drm/amd/amdgpu/gfx_v9_4_2.c | 12 ------------ 4 files changed, 6 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +4 -3
@@ -776,10 +776,11 @@ int amdgpu_amdkfd_send_close_event_drain_irq(struct amdgpu_device *adev,return 0 ; } -bool amdgpu_amdkfd_ras_query_utcl2_poison_status (struct amdgpu_device *adev) +bool amdgpu_amdkfd_ras_query_utcl2_poison_status (struct amdgpu_device *adev, +uint32_t node_id) { -if (adev->gfx.ras && adev->gfx.ras->query_utcl2_poison_status) -return adev->gfx.ras->query_utcl2_poison_status (adev); +if (adev->gfxhub.funcs->query_utcl2_poison_status) +return adev->gfxhub.funcs->query_utcl2_poison_status (adev, node_id);else return false; }
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +2 -1
@@ -404,7 +404,8 @@ void amdgpu_amdkfd_ras_poison_consumption_handler(struct amdgpu_device *adev,bool amdgpu_amdkfd_bo_mapped_to_dev (struct amdgpu_device *adev,struct kgd_mem *mem);void amdgpu_amdkfd_block_mmu_notifications (void *p);int amdgpu_amdkfd_criu_resume (void *p); -bool amdgpu_amdkfd_ras_query_utcl2_poison_status (struct amdgpu_device *adev); +bool amdgpu_amdkfd_ras_query_utcl2_poison_status (struct amdgpu_device *adev, +uint32_t node_id);int amdgpu_amdkfd_reserve_mem_limit (struct amdgpu_device *adev,uint64_t size,u32 alloc_flag,int8_t xcp_id); void amdgpu_amdkfd_unreserve_mem_limit(struct amdgpu_device *adev,
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0 -1
@@ -268,7 +268,6 @@ struct amdgpu_cu_info {struct amdgpu_gfx_ras {struct amdgpu_ras_block_object ras_block;void (*enable_watchdog_timer)(struct amdgpu_device *adev); -bool (*query_utcl2_poison_status)(struct amdgpu_device *adev);int (*rlc_gc_fed_irq)(struct amdgpu_device *adev,struct amdgpu_irq_src *source,struct amdgpu_iv_entry *entry);
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_2.c +0 -12
@@ -1909,18 +1909,7 @@ static void gfx_v9_4_2_reset_sq_timeout_status(struct amdgpu_device *adev)mutex_unlock (&adev->grbm_idx_mutex); } -static bool gfx_v9_4_2_query_uctl2_poison_status (struct amdgpu_device *adev) -{ -u32 status =0 ; -struct amdgpu_vmhub *hub; - - hub = &adev->vmhub[AMDGPU_GFXHUB (0 )]; - status =RREG32 (hub->vm_l2_pro_fault_status); -/* reset page fault status */ -WREG32_P (hub->vm_l2_pro_fault_cntl,1 , ~1 ); -return REG_GET_FIELD (status,VM_L2_PROTECTION_FAULT_STATUS ,FED ); -}struct amdgpu_ras_block_hw_ops gfx_v9_4_2_ras_ops = { .query_ras_error_count = &gfx_v9_4_2_query_ras_error_count,
@@ -1934,5 +1923,4 @@ struct amdgpu_gfx_ras gfx_v9_4_2_ras = { .hw_ops = &gfx_v9_4_2_ras_ops, }, .enable_watchdog_timer = &gfx_v9_4_2_enable_watchdog_timer, - .query_utcl2_poison_status = gfx_v9_4_2_query_uctl2_poison_status, };
Signature · 1 line
2.34.1
PATCH 4/5 amd/amdkfd: get node id for query_utcl2_poison_status
In reply to Tao ZhouObtain it from ring entry.
--- drivers/gpu/drm/amd/amdkfd/kfd_int_process_v10.c | 3 ++- drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_int_process_v10.c +2 -1
@@ -367,10 +367,11 @@ static void event_interrupt_wq_v10(struct kfd_node *dev, client_id == SOC15_IH_CLIENTID_UTCL2) {struct kfd_vm_fault_info info = {0 };uint16_t ring_id =SOC15_RING_ID_FROM_IH_ENTRY (ih_ring_entry); +uint32_t node_id =SOC15_NODEID_FROM_IH_ENTRY (ih_ring_entry);struct kfd_hsa_memory_exception_data exception_data;if (client_id ==SOC15_IH_CLIENTID_UTCL2 && -amdgpu_amdkfd_ras_query_utcl2_poison_status (dev->adev)) { +amdgpu_amdkfd_ras_query_utcl2_poison_status (dev->adev, node_id)) {event_interrupt_poison_consumption (dev, pasid, client_id);return ; }
drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c +2 -1
@@ -413,10 +413,11 @@ static void event_interrupt_wq_v9(struct kfd_node *dev, client_id == SOC15_IH_CLIENTID_UTCL2) {struct kfd_vm_fault_info info = {0 };uint16_t ring_id =SOC15_RING_ID_FROM_IH_ENTRY (ih_ring_entry); +uint32_t node_id =SOC15_NODEID_FROM_IH_ENTRY (ih_ring_entry);struct kfd_hsa_memory_exception_data exception_data;if (client_id ==SOC15_IH_CLIENTID_UTCL2 && -amdgpu_amdkfd_ras_query_utcl2_poison_status (dev->adev)) { +amdgpu_amdkfd_ras_query_utcl2_poison_status (dev->adev, node_id)) {event_interrupt_poison_consumption_v9 (dev, pasid, client_id);return ; }
Signature · 1 line
2.34.1
PATCH 5/5 drm/amdgpu: skip GFX FED error in page fault handling
In reply to Tao ZhouLet kfd interrupt handler process it.
--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +9 -1
@@ -552,7 +552,7 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev, {bool retry_fault = !!(entry->src_data[1 ] &0x80 );bool write_fault = !!(entry->src_data[1 ] &0x20 ); -uint32_t status =0 , cid =0 , rw =0 ; +uint32_t status =0 , cid =0 , rw =0 , fed =0 ;struct amdgpu_task_info task_info;struct amdgpu_vmhub *hub;const char *mmhub_cid;
@@ -663,6 +663,14 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev, status =RREG32 (hub->vm_l2_pro_fault_status); cid =REG_GET_FIELD (status,VM_L2_PROTECTION_FAULT_STATUS ,CID ); rw =REG_GET_FIELD (status,VM_L2_PROTECTION_FAULT_STATUS ,RW ); + fed =REG_GET_FIELD (status,VM_L2_PROTECTION_FAULT_STATUS ,FED ); + +/* for gfx fed error, kfd will handle it, return directly */ +if (fed &&amdgpu_ras_is_poison_mode_supported (adev) && +amdgpu_ip_version (adev,GC_HWIP ,0 ) >=IP_VERSION (9 ,4 ,2 ) && + !strcmp (hub_name,"gfxhub0" )) +return 1 ; +WREG32_P (hub->vm_l2_pro_fault_cntl,1 , ~1 );#ifdef HAVE_STRUCT_XARRAY amdgpu_vm_update_fault_cache (adev, entry->pasid, addr, status, vmhub);
Signature · 1 line
2.34.1
Re: [PATCH 5/5] drm/amdgpu: skip GFX FED error in page fault handling
Quoted 21 lines · Tao Zhou
Let kfd interrupt handler process it.
Signed-off-by Tao Zhou <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1
-1@@ -552,7 +552,7 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev, {bool retry_fault = !!(entry->src_data[1 ] &0x80 );bool write_fault = !!(entry->src_data[1 ] &0x20 ); -uint32_t status =0 , cid =0 , rw =0 ; +uint32_t status =0 , cid =0 , rw =0 , fed =0 ;struct amdgpu_task_info task_info;struct amdgpu_vmhub *hub;const char *mmhub_cid;
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev, · line 672
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +7
-0@@ -663,6 +663,14 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev, status =RREG32 (hub->vm_l2_pro_fault_status); cid =REG_GET_FIELD (status,VM_L2_PROTECTION_FAULT_STATUS ,CID ); rw =REG_GET_FIELD (status,VM_L2_PROTECTION_FAULT_STATUS ,RW ); + fed =REG_GET_FIELD (status,VM_L2_PROTECTION_FAULT_STATUS ,FED ); + +/* for gfx fed error, kfd will handle it, return directly */ +if (fed &&amdgpu_ras_is_poison_mode_supported (adev) && +amdgpu_ip_version (adev,GC_HWIP ,0 ) >=IP_VERSION (9 ,4 ,2 ) && + !strcmp (hub_name,"gfxhub0" )) +return 1 ;
amdgpu_irq_dispatch() gives the impression that return value of 1 is treated as handled, hence won't be passed to kfd. The commit description says it is intended to pass to kfd for handling.
Also, FED status check may be moved up so that it's not misunderstood as a regular page fault with the extra prints coming to dmesg log. Otherwise, poison status also needs to be added to dmesg.
Thanks,
Lijo
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1
-0+WREG32_P (hub->vm_l2_pro_fault_cntl,1 , ~1 );#ifdef HAVE_STRUCT_XARRAY amdgpu_vm_update_fault_cache (adev, entry->pasid, addr, status, vmhub);
RE: [PATCH 5/5] drm/amdgpu: skip GFX FED error in page fault handling
[AMD Official Use Only - General]
Quoted 44 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, February 19, 2024 8:40 PM
To: Zhou1, Tao <[email protected]>; [email protected]
Subject: Re: [PATCH 5/5] drm/amdgpu: skip GFX FED error in page fault handlingdrivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_process_interrupt(struct
Quoted 22 lines · Tao Zhou
Let kfd interrupt handler process it.
Signed-off-by Tao Zhou <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1
-1@@ -552,7 +552,7 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev, { bool retry_fault = !!(entry->src_data[1] & 0x80);bool write_fault = !!(entry->src_data[1 ] &0x20 ); -uint32_t status =0 , cid =0 , rw =0 ; +uint32_t status =0 , cid =0 , rw =0 , fed =0 ;struct amdgpu_task_info task_info;struct amdgpu_vmhub *hub;const char *mmhub_cid;@@ -663,6 +663,14 @@ static int gmc_v9_0_process_interrupt(struct
amdgpu_device*adev,drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev,
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1
-0status =RREG32 (hub->vm_l2_pro_fault_status); cid =REG_GET_FIELD (status,VM_L2_PROTECTION_FAULT_STATUS ,CID ); rw =REG_GET_FIELD (status,VM_L2_PROTECTION_FAULT_STATUS ,RW ); + fed = REG_GET_FIELD(status, VM_L2_PROTECTION_FAULT_STATUS,FED);
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev, · line 672
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +6
-0+ +/* for gfx fed error, kfd will handle it, return directly */ +if (fed &&amdgpu_ras_is_poison_mode_supported (adev) && +amdgpu_ip_version (adev,GC_HWIP ,0 ) >=IP_VERSION (9 ,4 ,2 ) && + !strcmp (hub_name,"gfxhub0" )) +return 1 ;
Quoted 3 lines
amdgpu_irq_dispatch()gives the impression that return value of 1 is treated as handled, hence won't be passed to kfd. The commit description says it is intended to pass to kfd for handling.
[Tao] good catch, it should return 0 here, will update it in v2, thanks.
Quoted 4 lines
Also, FED status check may be moved up so that it's not misunderstood as a regular page fault with the extra prints coming to dmesg log. Otherwise, poison status also needs to be added to dmesg.
[Tao] there is poison consumption dmesg log in kfd interrupt handler, no neeed to add extra print here.
My intention is to skip " WREG32_P(hub->vm_l2_pro_fault_cntl, 1, ~1)", moving up the check will make the change a little bit more and I think the page fault log is acceptable.
Quoted 9 lines
Thanks,
LijoQuoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1
-0+ WREG32_P(hub->vm_l2_pro_fault_cntl, 1, ~1); #ifdef
HAVE_STRUCT_XARRAYamdgpu_vm_update_fault_cache(adev, entry->pasid, addr, status,vmhub);
Christian König
maintainerRe: [PATCH 5/5] drm/amdgpu: skip GFX FED error in page fault handling
In reply to Tao ZhouAm 19.02.24 um 09:15 schrieb Tao Zhou:
Quoted 21 lines
Let kfd interrupt handler process it.
Signed-off-by Tao Zhou <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1
-1@@ -552,7 +552,7 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev, {bool retry_fault = !!(entry->src_data[1 ] &0x80 );bool write_fault = !!(entry->src_data[1 ] &0x20 ); -uint32_t status =0 , cid =0 , rw =0 ; +uint32_t status =0 , cid =0 , rw =0 , fed =0 ;struct amdgpu_task_info task_info;struct amdgpu_vmhub *hub;const char *mmhub_cid;
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev, · line 671
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +6
-0@@ -663,6 +663,14 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev, status =RREG32 (hub->vm_l2_pro_fault_status); cid =REG_GET_FIELD (status,VM_L2_PROTECTION_FAULT_STATUS ,CID ); rw =REG_GET_FIELD (status,VM_L2_PROTECTION_FAULT_STATUS ,RW ); + fed =REG_GET_FIELD (status,VM_L2_PROTECTION_FAULT_STATUS ,FED ); + +/* for gfx fed error, kfd will handle it, return directly */ +if (fed &&amdgpu_ras_is_poison_mode_supported (adev) && +amdgpu_ip_version (adev,GC_HWIP ,0 ) >=IP_VERSION (9 ,4 ,2 ) && + !strcmp (hub_name,"gfxhub0" ))
Please never ever use strcmp() to make a decision like that, *especially* not in an interrupt handler.
Regards,
Christian.
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2
-0+return 1 ; +WREG32_P (hub->vm_l2_pro_fault_cntl,1 , ~1 );#ifdef HAVE_STRUCT_XARRAY amdgpu_vm_update_fault_cache (adev, entry->pasid, addr, status, vmhub);