drm/amdgpu/gfx: add bad opcode interrupt
Subsystems (2)
Alex Deucher
maintainerPATCH 1/6 drm/amdgpu/gfx: add bad opcode interrupt
Add the irq source for bad opcodes.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +1 -0
@@ -391,6 +391,7 @@ struct amdgpu_gfx {struct amdgpu_irq_src eop_irq;struct amdgpu_irq_src priv_reg_irq;struct amdgpu_irq_src priv_inst_irq; +struct amdgpu_irq_src bad_op_irq;struct amdgpu_irq_src cp_ecc_error_irq;struct amdgpu_irq_src sq_irq;struct amdgpu_irq_src rlc_gc_fed_irq;
Signature · 1 line
2.45.2
Alex Deucher
maintainerPATCH 2/6 drm/amdgpu/gfx11: Enable bad opcode interrupt
From: Jesse Zhang <[email protected]>
For the bad opcode case, it will cause CP/ME hang.
The firmware will prevent the ME side from hanging by raising a bad opcode interrupt. And the driver needs to perform a vmid reset when receiving the interrupt.
v2: update irq naming (drop priv) (Alex)
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 73 ++++++++++++++++++++++++++ 1 file changed, 73 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +73 -0
@@ -1569,6 +1569,13 @@ static int gfx_v11_0_sw_init(void *handle)if (r)return r; +/* Bad opcode Event */ + r =amdgpu_irq_add_id (adev,SOC21_IH_CLIENTID_GRBM_CP , +GFX_11_0_0__SRCID__CP_BAD_OPCODE_ERROR , + &adev->gfx.bad_op_irq); +if (r) +return r; +/* Privileged reg */ r = amdgpu_irq_add_id(adev, SOC21_IH_CLIENTID_GRBM_CP, GFX_11_0_0__SRCID__CP_PRIV_REG_FAULT,
@@ -4646,6 +4653,7 @@ static int gfx_v11_0_hw_fini(void *handle)amdgpu_irq_put (adev, &adev->gfx.priv_reg_irq,0 );amdgpu_irq_put (adev, &adev->gfx.priv_inst_irq,0 ); +amdgpu_irq_put (adev, &adev->gfx.bad_op_irq,0 );if (!adev->no_hw_access) {if (amdgpu_async_gfx_ring) {
@@ -5002,6 +5010,9 @@ static int gfx_v11_0_late_init(void *handle)if (r)return r; + r =amdgpu_irq_get (adev, &adev->gfx.bad_op_irq,0 ); +if (r) +return r;return 0 ; }
@@ -6293,6 +6304,51 @@ static int gfx_v11_0_set_priv_reg_fault_state(struct amdgpu_device *adev,return 0 ; } +static int gfx_v11_0_set_bad_op_fault_state (struct amdgpu_device *adev, +struct amdgpu_irq_src *source, +unsigned type, +enum amdgpu_interrupt_state state) +{ +u32 cp_int_cntl_reg, cp_int_cntl; +int i , j; + +switch (state) { +case AMDGPU_IRQ_STATE_DISABLE : +case AMDGPU_IRQ_STATE_ENABLE : +for (i =0 ; i < adev->gfx.me.num_me; i++) { +for (j =0 ; j < adev->gfx.me.num_pipe_per_me; j++) { + cp_int_cntl_reg =gfx_v11_0_get_cpg_int_cntl (adev, i, j); + +if (cp_int_cntl_reg) { + cp_int_cntl =RREG32_SOC15_IP (GC , cp_int_cntl_reg); + cp_int_cntl =REG_SET_FIELD (cp_int_cntl,CP_INT_CNTL_RING0 , +OPCODE_ERROR_INT_ENABLE , + state ==AMDGPU_IRQ_STATE_ENABLE ?1 :0 ); +WREG32_SOC15_IP (GC , cp_int_cntl_reg, cp_int_cntl); + } + } + } +for (i =0 ; i < adev->gfx.mec.num_mec; i++) { +for (j =0 ; j < adev->gfx.mec.num_pipe_per_mec; j++) { +/* MECs start at 1 */ + cp_int_cntl_reg =gfx_v11_0_get_cpc_int_cntl (adev, i +1 , j); + +if (cp_int_cntl_reg) { + cp_int_cntl =RREG32_SOC15_IP (GC , cp_int_cntl_reg); + cp_int_cntl =REG_SET_FIELD (cp_int_cntl,CP_ME1_PIPE0_INT_CNTL , +OPCODE_ERROR_INT_ENABLE , + state ==AMDGPU_IRQ_STATE_ENABLE ?1 :0 ); +WREG32_SOC15_IP (GC , cp_int_cntl_reg, cp_int_cntl); + } + } + } +break ; +default : +break ; + } +return 0 ; +} + static int gfx_v11_0_set_priv_inst_fault_state(struct amdgpu_device *adev, struct amdgpu_irq_src *source, unsigned int type,
@@ -6369,6 +6425,15 @@ static int gfx_v11_0_priv_reg_irq(struct amdgpu_device *adev,return 0 ; } +static int gfx_v11_0_bad_op_irq (struct amdgpu_device *adev, +struct amdgpu_irq_src *source, +struct amdgpu_iv_entry *entry) +{ +DRM_ERROR ("Illegal opcode in command stream \n" ); +gfx_v11_0_handle_priv_fault (adev, entry); +return 0 ; +} +static int gfx_v11_0_priv_inst_irq (struct amdgpu_device *adev,struct amdgpu_irq_src *source,struct amdgpu_iv_entry *entry)
@@ -6747,6 +6812,11 @@ static const struct amdgpu_irq_src_funcs gfx_v11_0_priv_reg_irq_funcs = { .process = gfx_v11_0_priv_reg_irq, }; +static const struct amdgpu_irq_src_funcs gfx_v11_0_bad_op_irq_funcs = { + .set = gfx_v11_0_set_bad_op_fault_state, + .process = gfx_v11_0_bad_op_irq, +}; +static const struct amdgpu_irq_src_funcs gfx_v11_0_priv_inst_irq_funcs = { .set = gfx_v11_0_set_priv_inst_fault_state, .process = gfx_v11_0_priv_inst_irq,
@@ -6764,6 +6834,9 @@ static void gfx_v11_0_set_irq_funcs(struct amdgpu_device *adev) adev->gfx.priv_reg_irq.num_types =1 ; adev->gfx.priv_reg_irq.funcs = &gfx_v11_0_priv_reg_irq_funcs; + adev->gfx.bad_op_irq.num_types =1 ; + adev->gfx.bad_op_irq.funcs = &gfx_v11_0_bad_op_irq_funcs; + adev->gfx.priv_inst_irq.num_types =1 ; adev->gfx.priv_inst_irq.funcs = &gfx_v11_0_priv_inst_irq_funcs;
Signature · 1 line
2.45.2
Re: [PATCH 2/6] drm/amdgpu/gfx11: Enable bad opcode interrupt
Am 17.07.24 um 22:40 schrieb Alex Deucher:
Quoted 57 lines
From: Jesse Zhang <[email protected]>
For the bad opcode case, it will cause CP/ME hang.
The firmware will prevent the ME side from hanging by raising a bad opcode interrupt. And the driver needs to perform a vmid reset when receiving the interrupt.v2: update irq naming (drop priv) (Alex)
Signed-off-by Jesse Zhang <[email protected]>Reviewed-by Prike Liang <[email protected]>Reviewed-by Alex Deucher <[email protected]>Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 73 ++++++++++++++++++++++++++ 1 file changed, 73 insertions(+)drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +12
-0@@ -1569,6 +1569,13 @@ static int gfx_v11_0_sw_init(void *handle)if (r)return r; +/* Bad opcode Event */ + r =amdgpu_irq_add_id (adev,SOC21_IH_CLIENTID_GRBM_CP , +GFX_11_0_0__SRCID__CP_BAD_OPCODE_ERROR , + &adev->gfx.bad_op_irq); +if (r) +return r; +/* Privileged reg */ r = amdgpu_irq_add_id(adev, SOC21_IH_CLIENTID_GRBM_CP, GFX_11_0_0__SRCID__CP_PRIV_REG_FAULT,@@ -4646,6 +4653,7 @@ static int gfx_v11_0_hw_fini(void *handle)amdgpu_irq_put (adev, &adev->gfx.priv_reg_irq,0 );amdgpu_irq_put (adev, &adev->gfx.priv_inst_irq,0 ); +amdgpu_irq_put (adev, &adev->gfx.bad_op_irq,0 );if (!adev->no_hw_access) {if (amdgpu_async_gfx_ring) {@@ -5002,6 +5010,9 @@ static int gfx_v11_0_late_init(void *handle)if (r)return r; + r =amdgpu_irq_get (adev, &adev->gfx.bad_op_irq,0 ); +if (r) +return r;return 0 ; }@@ -6293,6 +6304,51 @@ static int gfx_v11_0_set_priv_reg_fault_state(struct amdgpu_device *adev,return 0 ; } +static int gfx_v11_0_set_bad_op_fault_state(struct amdgpu_device *adev,
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static int gfx_v11_0_set_priv_reg_fault_state(struct amdgpu_device *adev, · line 6317
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +10
-0+struct amdgpu_irq_src *source, + unsigned type, + enum amdgpu_interrupt_state state) +{ + u32 cp_int_cntl_reg, cp_int_cntl; +int i , j; + +switch (state) { +case AMDGPU_IRQ_STATE_DISABLE : +case AMDGPU_IRQ_STATE_ENABLE :
That switch is pretty pointless since state can only be disabled or enabled.
Most likely just c&p from an older version of the code and at some point lost it's relevance.
Apart from that the series looks good to me.
Regards,
Christian.
Quoted 75 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +51
-0+for (i =0 ; i < adev->gfx.me.num_me; i++) { +for (j =0 ; j < adev->gfx.me.num_pipe_per_me; j++) { + cp_int_cntl_reg =gfx_v11_0_get_cpg_int_cntl (adev, i, j); + +if (cp_int_cntl_reg) { + cp_int_cntl =RREG32_SOC15_IP (GC , cp_int_cntl_reg); + cp_int_cntl =REG_SET_FIELD (cp_int_cntl,CP_INT_CNTL_RING0 , +OPCODE_ERROR_INT_ENABLE , + state ==AMDGPU_IRQ_STATE_ENABLE ?1 :0 ); +WREG32_SOC15_IP (GC , cp_int_cntl_reg, cp_int_cntl); + } + } + } +for (i =0 ; i < adev->gfx.mec.num_mec; i++) { +for (j =0 ; j < adev->gfx.mec.num_pipe_per_mec; j++) { +/* MECs start at 1 */ + cp_int_cntl_reg =gfx_v11_0_get_cpc_int_cntl (adev, i +1 , j); + +if (cp_int_cntl_reg) { + cp_int_cntl =RREG32_SOC15_IP (GC , cp_int_cntl_reg); + cp_int_cntl =REG_SET_FIELD (cp_int_cntl,CP_ME1_PIPE0_INT_CNTL , +OPCODE_ERROR_INT_ENABLE , + state ==AMDGPU_IRQ_STATE_ENABLE ?1 :0 ); +WREG32_SOC15_IP (GC , cp_int_cntl_reg, cp_int_cntl); + } + } + } +break ; +default : +break ; + } +return 0 ; +} + static int gfx_v11_0_set_priv_inst_fault_state(struct amdgpu_device *adev, struct amdgpu_irq_src *source, unsigned int type,@@ -6369,6 +6425,15 @@ static int gfx_v11_0_priv_reg_irq(struct amdgpu_device *adev,return 0 ; } +static int gfx_v11_0_bad_op_irq (struct amdgpu_device *adev, +struct amdgpu_irq_src *source, +struct amdgpu_iv_entry *entry) +{ +DRM_ERROR ("Illegal opcode in command stream \n" ); +gfx_v11_0_handle_priv_fault (adev, entry); +return 0 ; +} +static int gfx_v11_0_priv_inst_irq (struct amdgpu_device *adev,struct amdgpu_irq_src *source,struct amdgpu_iv_entry *entry)@@ -6747,6 +6812,11 @@ static const struct amdgpu_irq_src_funcs gfx_v11_0_priv_reg_irq_funcs = { .process = gfx_v11_0_priv_reg_irq, }; +static const struct amdgpu_irq_src_funcs gfx_v11_0_bad_op_irq_funcs = { + .set = gfx_v11_0_set_bad_op_fault_state, + .process = gfx_v11_0_bad_op_irq, +}; +static const struct amdgpu_irq_src_funcs gfx_v11_0_priv_inst_irq_funcs = { .set = gfx_v11_0_set_priv_inst_fault_state, .process = gfx_v11_0_priv_inst_irq,@@ -6764,6 +6834,9 @@ static void gfx_v11_0_set_irq_funcs(struct amdgpu_device *adev) adev->gfx.priv_reg_irq.num_types =1 ; adev->gfx.priv_reg_irq.funcs = &gfx_v11_0_priv_reg_irq_funcs; + adev->gfx.bad_op_irq.num_types =1 ; + adev->gfx.bad_op_irq.funcs = &gfx_v11_0_bad_op_irq_funcs; + adev->gfx.priv_inst_irq.num_types =1 ; adev->gfx.priv_inst_irq.funcs = &gfx_v11_0_priv_inst_irq_funcs;
Re: [PATCH 2/6] drm/amdgpu/gfx11: Enable bad opcode interrupt
Quoted 72 lines · Christian König
Am 17.07.24 um 22:40 schrieb Alex Deucher:
Quoted 57 lines
From: Jesse Zhang <[email protected]>
For the bad opcode case, it will cause CP/ME hang.
The firmware will prevent the ME side from hanging by raising a bad opcode interrupt. And the driver needs to perform a vmid reset when receiving the interrupt.v2: update irq naming (drop priv) (Alex)
Signed-off-by Jesse Zhang <[email protected]>Reviewed-by Prike Liang <[email protected]>Reviewed-by Alex Deucher <[email protected]>Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 73 ++++++++++++++++++++++++++ 1 file changed, 73 insertions(+)drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +12
-0@@ -1569,6 +1569,13 @@ static int gfx_v11_0_sw_init(void *handle)if (r)return r; +/* Bad opcode Event */ + r =amdgpu_irq_add_id (adev,SOC21_IH_CLIENTID_GRBM_CP , +GFX_11_0_0__SRCID__CP_BAD_OPCODE_ERROR , + &adev->gfx.bad_op_irq); +if (r) +return r; +/* Privileged reg */ r = amdgpu_irq_add_id(adev, SOC21_IH_CLIENTID_GRBM_CP, GFX_11_0_0__SRCID__CP_PRIV_REG_FAULT,@@ -4646,6 +4653,7 @@ static int gfx_v11_0_hw_fini(void *handle)amdgpu_irq_put (adev, &adev->gfx.priv_reg_irq,0 );amdgpu_irq_put (adev, &adev->gfx.priv_inst_irq,0 ); +amdgpu_irq_put (adev, &adev->gfx.bad_op_irq,0 );if (!adev->no_hw_access) {if (amdgpu_async_gfx_ring) {@@ -5002,6 +5010,9 @@ static int gfx_v11_0_late_init(void *handle)if (r)return r; + r =amdgpu_irq_get (adev, &adev->gfx.bad_op_irq,0 ); +if (r) +return r;return 0 ; }@@ -6293,6 +6304,51 @@ static int gfx_v11_0_set_priv_reg_fault_state(struct amdgpu_device *adev,return 0 ; } +static int gfx_v11_0_set_bad_op_fault_state(struct amdgpu_device *adev,drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static int gfx_v11_0_set_priv_reg_fault_state(struct amdgpu_device *adev, · line 6317
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +10
-0+struct amdgpu_irq_src *source, + unsigned type, + enum amdgpu_interrupt_state state) +{ + u32 cp_int_cntl_reg, cp_int_cntl; +int i , j; + +switch (state) { +case AMDGPU_IRQ_STATE_DISABLE : +case AMDGPU_IRQ_STATE_ENABLE :That switch is pretty pointless since state can only be disabled or enabled.
Quoted 4 lines
Most likely just c&p from an older version of the code and at some point lost it's relevance.
Apart from that the series looks good to me.
Yeah, all of the other irq functions follow that same model. If you feel strongly, I can change it.
Alex
Quoted 80 lines
Regards,
Christian.Quoted 75 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +51
-0+for (i =0 ; i < adev->gfx.me.num_me; i++) { +for (j =0 ; j < adev->gfx.me.num_pipe_per_me; j++) { + cp_int_cntl_reg =gfx_v11_0_get_cpg_int_cntl (adev, i, j); + +if (cp_int_cntl_reg) { + cp_int_cntl =RREG32_SOC15_IP (GC , cp_int_cntl_reg); + cp_int_cntl =REG_SET_FIELD (cp_int_cntl,CP_INT_CNTL_RING0 , +OPCODE_ERROR_INT_ENABLE , + state ==AMDGPU_IRQ_STATE_ENABLE ?1 :0 ); +WREG32_SOC15_IP (GC , cp_int_cntl_reg, cp_int_cntl); + } + } + } +for (i =0 ; i < adev->gfx.mec.num_mec; i++) { +for (j =0 ; j < adev->gfx.mec.num_pipe_per_mec; j++) { +/* MECs start at 1 */ + cp_int_cntl_reg =gfx_v11_0_get_cpc_int_cntl (adev, i +1 , j); + +if (cp_int_cntl_reg) { + cp_int_cntl =RREG32_SOC15_IP (GC , cp_int_cntl_reg); + cp_int_cntl =REG_SET_FIELD (cp_int_cntl,CP_ME1_PIPE0_INT_CNTL , +OPCODE_ERROR_INT_ENABLE , + state ==AMDGPU_IRQ_STATE_ENABLE ?1 :0 ); +WREG32_SOC15_IP (GC , cp_int_cntl_reg, cp_int_cntl); + } + } + } +break ; +default : +break ; + } +return 0 ; +} + static int gfx_v11_0_set_priv_inst_fault_state(struct amdgpu_device *adev, struct amdgpu_irq_src *source, unsigned int type,@@ -6369,6 +6425,15 @@ static int gfx_v11_0_priv_reg_irq(struct amdgpu_device *adev,return 0 ; } +static int gfx_v11_0_bad_op_irq (struct amdgpu_device *adev, +struct amdgpu_irq_src *source, +struct amdgpu_iv_entry *entry) +{ +DRM_ERROR ("Illegal opcode in command stream \n" ); +gfx_v11_0_handle_priv_fault (adev, entry); +return 0 ; +} +static int gfx_v11_0_priv_inst_irq (struct amdgpu_device *adev,struct amdgpu_irq_src *source,struct amdgpu_iv_entry *entry)@@ -6747,6 +6812,11 @@ static const struct amdgpu_irq_src_funcs gfx_v11_0_priv_reg_irq_funcs = { .process = gfx_v11_0_priv_reg_irq, }; +static const struct amdgpu_irq_src_funcs gfx_v11_0_bad_op_irq_funcs = { + .set = gfx_v11_0_set_bad_op_fault_state, + .process = gfx_v11_0_bad_op_irq, +}; +static const struct amdgpu_irq_src_funcs gfx_v11_0_priv_inst_irq_funcs = { .set = gfx_v11_0_set_priv_inst_fault_state, .process = gfx_v11_0_priv_inst_irq,@@ -6764,6 +6834,9 @@ static void gfx_v11_0_set_irq_funcs(struct amdgpu_device *adev) adev->gfx.priv_reg_irq.num_types =1 ; adev->gfx.priv_reg_irq.funcs = &gfx_v11_0_priv_reg_irq_funcs; + adev->gfx.bad_op_irq.num_types =1 ; + adev->gfx.bad_op_irq.funcs = &gfx_v11_0_bad_op_irq_funcs; + adev->gfx.priv_inst_irq.num_types =1 ; adev->gfx.priv_inst_irq.funcs = &gfx_v11_0_priv_inst_irq_funcs;
Alex Deucher
maintainerPATCH 3/6 drm/amdgpu/gfx10: Enable bad opcode interrupt
In reply to Alex DeucherFrom: Jesse Zhang <[email protected]>
For the bad opcode case, it will cause CP/ME hang.
The firmware will prevent the ME side from hanging by raising a bad opcode interrupt. And the driver needs to perform a vmid reset when receiving the interrupt.
v2: update irq naming (drop priv) (Alex)
--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 74 ++++++++++++++++++++++++++ 1 file changed, 74 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +74 -0
@@ -4740,6 +4740,13 @@ static int gfx_v10_0_sw_init(void *handle)if (r)return r; +/* Bad opcode Event */ + r =amdgpu_irq_add_id (adev,SOC15_IH_CLIENTID_GRBM_CP , +GFX_10_1__SRCID__CP_BAD_OPCODE_ERROR , + &adev->gfx.bad_op_irq); +if (r) +return r; +/* Privileged reg */ r =amdgpu_irq_add_id (adev,SOC15_IH_CLIENTID_GRBM_CP ,GFX_10_1__SRCID__CP_PRIV_REG_FAULT , &adev->gfx.priv_reg_irq);
@@ -7416,6 +7423,7 @@ static int gfx_v10_0_hw_fini(void *handle)amdgpu_irq_put (adev, &adev->gfx.priv_reg_irq,0 );amdgpu_irq_put (adev, &adev->gfx.priv_inst_irq,0 ); +amdgpu_irq_put (adev, &adev->gfx.bad_op_irq,0 );/* WA added for Vangogh asic fixing the SMU suspend failure * It needs to set power gating again during gfxoff control
@@ -7726,6 +7734,10 @@ static int gfx_v10_0_late_init(void *handle)if (r)return r; + r =amdgpu_irq_get (adev, &adev->gfx.bad_op_irq,0 ); +if (r) +return r; +return 0 ; }
@@ -9162,6 +9174,51 @@ static int gfx_v10_0_set_priv_reg_fault_state(struct amdgpu_device *adev,return 0 ; } +static int gfx_v10_0_set_bad_op_fault_state (struct amdgpu_device *adev, +struct amdgpu_irq_src *source, +unsigned type, +enum amdgpu_interrupt_state state) +{ +u32 cp_int_cntl_reg, cp_int_cntl; +int i , j; + +switch (state) { +case AMDGPU_IRQ_STATE_DISABLE : +case AMDGPU_IRQ_STATE_ENABLE : +for (i =0 ; i < adev->gfx.me.num_me; i++) { +for (j =0 ; j < adev->gfx.me.num_pipe_per_me; j++) { + cp_int_cntl_reg =gfx_v10_0_get_cpg_int_cntl (adev, i, j); + +if (cp_int_cntl_reg) { + cp_int_cntl =RREG32_SOC15_IP (GC , cp_int_cntl_reg); + cp_int_cntl =REG_SET_FIELD (cp_int_cntl,CP_INT_CNTL_RING0 , +OPCODE_ERROR_INT_ENABLE , + state ==AMDGPU_IRQ_STATE_ENABLE ?1 :0 ); +WREG32_SOC15_IP (GC , cp_int_cntl_reg, cp_int_cntl); + } + } + } +for (i =0 ; i < adev->gfx.mec.num_mec; i++) { +for (j =0 ; j < adev->gfx.mec.num_pipe_per_mec; j++) { +/* MECs start at 1 */ + cp_int_cntl_reg =gfx_v10_0_get_cpc_int_cntl (adev, i +1 , j); + +if (cp_int_cntl_reg) { + cp_int_cntl =RREG32_SOC15_IP (GC , cp_int_cntl_reg); + cp_int_cntl =REG_SET_FIELD (cp_int_cntl,CP_ME1_PIPE0_INT_CNTL , +OPCODE_ERROR_INT_ENABLE , + state ==AMDGPU_IRQ_STATE_ENABLE ?1 :0 ); +WREG32_SOC15_IP (GC , cp_int_cntl_reg, cp_int_cntl); + } + } + } +break ; +default : +break ; + } +return 0 ; +} + static int gfx_v10_0_set_priv_inst_fault_state(struct amdgpu_device *adev, struct amdgpu_irq_src *source, unsigned int type,
@@ -9237,6 +9294,15 @@ static int gfx_v10_0_priv_reg_irq(struct amdgpu_device *adev,return 0 ; } +static int gfx_v10_0_bad_op_irq (struct amdgpu_device *adev, +struct amdgpu_irq_src *source, +struct amdgpu_iv_entry *entry) +{ +DRM_ERROR ("Illegal opcode in command stream \n" ); +gfx_v10_0_handle_priv_fault (adev, entry); +return 0 ; +} +static int gfx_v10_0_priv_inst_irq (struct amdgpu_device *adev,struct amdgpu_irq_src *source,struct amdgpu_iv_entry *entry)
@@ -9624,6 +9690,11 @@ static const struct amdgpu_irq_src_funcs gfx_v10_0_priv_reg_irq_funcs = { .process = gfx_v10_0_priv_reg_irq, }; +static const struct amdgpu_irq_src_funcs gfx_v10_0_bad_op_irq_funcs = { + .set = gfx_v10_0_set_bad_op_fault_state, + .process = gfx_v10_0_bad_op_irq, +}; +static const struct amdgpu_irq_src_funcs gfx_v10_0_priv_inst_irq_funcs = { .set = gfx_v10_0_set_priv_inst_fault_state, .process = gfx_v10_0_priv_inst_irq,
@@ -9645,6 +9716,9 @@ static void gfx_v10_0_set_irq_funcs(struct amdgpu_device *adev) adev->gfx.priv_reg_irq.num_types =1 ; adev->gfx.priv_reg_irq.funcs = &gfx_v10_0_priv_reg_irq_funcs; + adev->gfx.bad_op_irq.num_types =1 ; + adev->gfx.bad_op_irq.funcs = &gfx_v10_0_bad_op_irq_funcs; + adev->gfx.priv_inst_irq.num_types =1 ; adev->gfx.priv_inst_irq.funcs = &gfx_v10_0_priv_inst_irq_funcs; }
Signature · 1 line
2.45.2
Alex Deucher
maintainerPATCH 4/6 drm/amdgpu/gfx12: Enable bad opcode interrupt
In reply to Alex DeucherFrom: Jesse Zhang <[email protected]>
For the bad opcode case, it will cause CP/ME hang.
The firmware will prevent the ME side from hanging by raising a bad opcode interrupt. And the driver needs to perform a vmid reset when receiving the interrupt.
v2: update irq naming (drop priv) (Alex)
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 74 ++++++++++++++++++++++++++ 1 file changed, 74 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +74 -0
@@ -1349,6 +1349,13 @@ static int gfx_v12_0_sw_init(void *handle)if (r)return r; +/* Bad opcode Event */ + r =amdgpu_irq_add_id (adev,SOC21_IH_CLIENTID_GRBM_CP , +GFX_11_0_0__SRCID__CP_BAD_OPCODE_ERROR , + &adev->gfx.bad_op_irq); +if (r) +return r; +/* Privileged reg */ r = amdgpu_irq_add_id(adev, SOC21_IH_CLIENTID_GRBM_CP, GFX_11_0_0__SRCID__CP_PRIV_REG_FAULT,
@@ -3592,6 +3599,7 @@ static int gfx_v12_0_hw_fini(void *handle)amdgpu_irq_put (adev, &adev->gfx.priv_reg_irq,0 );amdgpu_irq_put (adev, &adev->gfx.priv_inst_irq,0 ); +amdgpu_irq_put (adev, &adev->gfx.bad_op_irq,0 );if (!adev->no_hw_access) {if (amdgpu_async_gfx_ring) {
@@ -3712,6 +3720,10 @@ static int gfx_v12_0_late_init(void *handle)if (r)return r; + r =amdgpu_irq_get (adev, &adev->gfx.bad_op_irq,0 ); +if (r) +return r; +return 0 ; }
@@ -4831,6 +4843,51 @@ static int gfx_v12_0_set_priv_reg_fault_state(struct amdgpu_device *adev,return 0 ; } +static int gfx_v12_0_set_bad_op_fault_state (struct amdgpu_device *adev, +struct amdgpu_irq_src *source, +unsigned type, +enum amdgpu_interrupt_state state) +{ +u32 cp_int_cntl_reg, cp_int_cntl; +int i , j; + +switch (state) { +case AMDGPU_IRQ_STATE_DISABLE : +case AMDGPU_IRQ_STATE_ENABLE : +for (i =0 ; i < adev->gfx.me.num_me; i++) { +for (j =0 ; j < adev->gfx.me.num_pipe_per_me; j++) { + cp_int_cntl_reg =gfx_v12_0_get_cpg_int_cntl (adev, i, j); + +if (cp_int_cntl_reg) { + cp_int_cntl =RREG32_SOC15_IP (GC , cp_int_cntl_reg); + cp_int_cntl =REG_SET_FIELD (cp_int_cntl,CP_INT_CNTL_RING0 , +OPCODE_ERROR_INT_ENABLE , + state ==AMDGPU_IRQ_STATE_ENABLE ?1 :0 ); +WREG32_SOC15_IP (GC , cp_int_cntl_reg, cp_int_cntl); + } + } + } +for (i =0 ; i < adev->gfx.mec.num_mec; i++) { +for (j =0 ; j < adev->gfx.mec.num_pipe_per_mec; j++) { +/* MECs start at 1 */ + cp_int_cntl_reg =gfx_v12_0_get_cpc_int_cntl (adev, i +1 , j); + +if (cp_int_cntl_reg) { + cp_int_cntl =RREG32_SOC15_IP (GC , cp_int_cntl_reg); + cp_int_cntl =REG_SET_FIELD (cp_int_cntl,CP_ME1_PIPE0_INT_CNTL , +OPCODE_ERROR_INT_ENABLE , + state ==AMDGPU_IRQ_STATE_ENABLE ?1 :0 ); +WREG32_SOC15_IP (GC , cp_int_cntl_reg, cp_int_cntl); + } + } + } +break ; +default : +break ; + } +return 0 ; +} + static int gfx_v12_0_set_priv_inst_fault_state(struct amdgpu_device *adev, struct amdgpu_irq_src *source, unsigned int type,
@@ -4907,6 +4964,15 @@ static int gfx_v12_0_priv_reg_irq(struct amdgpu_device *adev,return 0 ; } +static int gfx_v12_0_bad_op_irq (struct amdgpu_device *adev, +struct amdgpu_irq_src *source, +struct amdgpu_iv_entry *entry) +{ +DRM_ERROR ("Illegal opcode in command stream \n" ); +gfx_v12_0_handle_priv_fault (adev, entry); +return 0 ; +} +static int gfx_v12_0_priv_inst_irq (struct amdgpu_device *adev,struct amdgpu_irq_src *source,struct amdgpu_iv_entry *entry)
@@ -5219,6 +5285,11 @@ static const struct amdgpu_irq_src_funcs gfx_v12_0_priv_reg_irq_funcs = { .process = gfx_v12_0_priv_reg_irq, }; +static const struct amdgpu_irq_src_funcs gfx_v12_0_bad_op_irq_funcs = { + .set = gfx_v12_0_set_bad_op_fault_state, + .process = gfx_v12_0_bad_op_irq, +}; +static const struct amdgpu_irq_src_funcs gfx_v12_0_priv_inst_irq_funcs = { .set = gfx_v12_0_set_priv_inst_fault_state, .process = gfx_v12_0_priv_inst_irq,
@@ -5232,6 +5303,9 @@ static void gfx_v12_0_set_irq_funcs(struct amdgpu_device *adev) adev->gfx.priv_reg_irq.num_types =1 ; adev->gfx.priv_reg_irq.funcs = &gfx_v12_0_priv_reg_irq_funcs; + adev->gfx.bad_op_irq.num_types =1 ; + adev->gfx.bad_op_irq.funcs = &gfx_v12_0_bad_op_irq_funcs; + adev->gfx.priv_inst_irq.num_types =1 ; adev->gfx.priv_inst_irq.funcs = &gfx_v12_0_priv_inst_irq_funcs; }
Signature · 1 line
2.45.2
Alex Deucher
maintainerPATCH 5/6 drm/amdgpu/gfx9: Enable bad opcode interrupt
In reply to Alex DeucherFor the bad opcode case, it will cause CP/ME hang.
The firmware will prevent the ME side from hanging by raising a bad opcode interrupt. And the driver needs to perform a vmid reset when receiving the interrupt.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 65 +++++++++++++++++++++++++++ 1 file changed, 65 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +65 -0
@@ -2182,6 +2182,13 @@ static int gfx_v9_0_sw_init(void *handle)if (r)return r; +/* Bad opcode Event */ + r =amdgpu_irq_add_id (adev,SOC15_IH_CLIENTID_GRBM_CP , +GFX_9_0__SRCID__CP_BAD_OPCODE_ERROR , + &adev->gfx.bad_op_irq); +if (r) +return r; +/* Privileged reg */ r =amdgpu_irq_add_id (adev,SOC15_IH_CLIENTID_GRBM_CP ,GFX_9_0__SRCID__CP_PRIV_REG_FAULT , &adev->gfx.priv_reg_irq);
@@ -3937,6 +3944,7 @@ static int gfx_v9_0_hw_fini(void *handle)amdgpu_irq_put (adev, &adev->gfx.cp_ecc_error_irq,0 );amdgpu_irq_put (adev, &adev->gfx.priv_reg_irq,0 );amdgpu_irq_put (adev, &adev->gfx.priv_inst_irq,0 ); +amdgpu_irq_put (adev, &adev->gfx.bad_op_irq,0 );/* DF freeze and kcq disable will fail */ if (!amdgpu_ras_intr_triggered ())
@@ -4747,6 +4755,10 @@ static int gfx_v9_0_late_init(void *handle)if (r)return r; + r =amdgpu_irq_get (adev, &adev->gfx.bad_op_irq,0 ); +if (r) +return r; + r =gfx_v9_0_ecc_late_init (handle);if (r)return r;
@@ -5990,6 +6002,42 @@ static int gfx_v9_0_set_priv_reg_fault_state(struct amdgpu_device *adev,return 0 ; } +static int gfx_v9_0_set_bad_op_fault_state (struct amdgpu_device *adev, +struct amdgpu_irq_src *source, +unsigned type, +enum amdgpu_interrupt_state state) +{ +u32 cp_int_cntl_reg, cp_int_cntl; +int i, j; + +switch (state) { +case AMDGPU_IRQ_STATE_DISABLE : +case AMDGPU_IRQ_STATE_ENABLE : +WREG32_FIELD15 (GC ,0 ,CP_INT_CNTL_RING0 , +OPCODE_ERROR_INT_ENABLE , + state ==AMDGPU_IRQ_STATE_ENABLE ?1 :0 ); +for (i =0 ; i < adev->gfx.mec.num_mec; i++) { +for (j =0 ; j < adev->gfx.mec.num_pipe_per_mec; j++) { +/* MECs start at 1 */ + cp_int_cntl_reg =gfx_v9_0_get_cpc_int_cntl (adev, i +1 , j); + +if (cp_int_cntl_reg) { + cp_int_cntl =RREG32_SOC15_IP (GC , cp_int_cntl_reg); + cp_int_cntl =REG_SET_FIELD (cp_int_cntl,CP_ME1_PIPE0_INT_CNTL , +OPCODE_ERROR_INT_ENABLE , + state ==AMDGPU_IRQ_STATE_ENABLE ?1 :0 ); +WREG32_SOC15_IP (GC , cp_int_cntl_reg, cp_int_cntl); + } + } + } +break ; +default : +break ; + } + +return 0 ; +} + static int gfx_v9_0_set_priv_inst_fault_state(struct amdgpu_device *adev, struct amdgpu_irq_src *source, unsigned type,
@@ -6163,6 +6211,15 @@ static int gfx_v9_0_priv_reg_irq(struct amdgpu_device *adev,return 0 ; } +static int gfx_v9_0_bad_op_irq (struct amdgpu_device *adev, +struct amdgpu_irq_src *source, +struct amdgpu_iv_entry *entry) +{ +DRM_ERROR ("Illegal opcode in command stream\n" ); +gfx_v9_0_fault (adev, entry); +return 0 ; +} +static int gfx_v9_0_priv_inst_irq (struct amdgpu_device *adev,struct amdgpu_irq_src *source,struct amdgpu_iv_entry *entry)
@@ -7346,6 +7403,11 @@ static const struct amdgpu_irq_src_funcs gfx_v9_0_priv_reg_irq_funcs = { .process = gfx_v9_0_priv_reg_irq, }; +static const struct amdgpu_irq_src_funcs gfx_v9_0_bad_op_irq_funcs = { + .set = gfx_v9_0_set_bad_op_fault_state, + .process = gfx_v9_0_bad_op_irq, +}; +static const struct amdgpu_irq_src_funcs gfx_v9_0_priv_inst_irq_funcs = { .set = gfx_v9_0_set_priv_inst_fault_state, .process = gfx_v9_0_priv_inst_irq,
@@ -7365,6 +7427,9 @@ static void gfx_v9_0_set_irq_funcs(struct amdgpu_device *adev) adev->gfx.priv_reg_irq.num_types =1 ; adev->gfx.priv_reg_irq.funcs = &gfx_v9_0_priv_reg_irq_funcs; + adev->gfx.bad_op_irq.num_types =1 ; + adev->gfx.bad_op_irq.funcs = &gfx_v9_0_bad_op_irq_funcs; + adev->gfx.priv_inst_irq.num_types =1 ; adev->gfx.priv_inst_irq.funcs = &gfx_v9_0_priv_inst_irq_funcs;
Signature · 1 line
2.45.2
Alex Deucher
maintainerPATCH 6/6 drm/amdgpu/gfx9.4.3: Enable bad opcode interrupt
In reply to Alex DeucherFor the bad opcode case, it will cause CP/ME hang.
The firmware will prevent the ME side from hanging by raising a bad opcode interrupt. And the driver needs to perform a vmid reset when receiving the interrupt.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 69 +++++++++++++++++++++++++ 1 file changed, 69 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +69 -0
@@ -901,6 +901,13 @@ static int gfx_v9_4_3_sw_init(void *handle)if (r)return r; +/* Bad opcode Event */ + r =amdgpu_irq_add_id (adev,SOC15_IH_CLIENTID_GRBM_CP , +GFX_9_0__SRCID__CP_BAD_OPCODE_ERROR , + &adev->gfx.bad_op_irq); +if (r) +return r; +/* Privileged reg */ r =amdgpu_irq_add_id (adev,SOC15_IH_CLIENTID_GRBM_CP ,GFX_9_0__SRCID__CP_PRIV_REG_FAULT , &adev->gfx.priv_reg_irq);
@@ -2162,6 +2169,7 @@ static int gfx_v9_4_3_hw_fini(void *handle)amdgpu_irq_put (adev, &adev->gfx.priv_reg_irq,0 );amdgpu_irq_put (adev, &adev->gfx.priv_inst_irq,0 ); +amdgpu_irq_put (adev, &adev->gfx.bad_op_irq,0 ); num_xcc =NUM_XCC (adev->gfx.xcc_mask);for (i =0 ; i < num_xcc; i++) {
@@ -2327,6 +2335,10 @@ static int gfx_v9_4_3_late_init(void *handle)if (r)return r; + r =amdgpu_irq_get (adev, &adev->gfx.bad_op_irq,0 ); +if (r) +return r; +if (adev->gfx.ras && adev->gfx.ras->enable_watchdog_timer) adev->gfx.ras->enable_watchdog_timer (adev);
@@ -2964,6 +2976,46 @@ static int gfx_v9_4_3_set_priv_reg_fault_state(struct amdgpu_device *adev,return 0 ; } +static int gfx_v9_4_3_set_bad_op_fault_state (struct amdgpu_device *adev, +struct amdgpu_irq_src *source, +unsigned type, +enum amdgpu_interrupt_state state) +{ +u32 mec_int_cntl_reg, mec_int_cntl; +int i, j, k, num_xcc; + + num_xcc =NUM_XCC (adev->gfx.xcc_mask); +switch (state) { +case AMDGPU_IRQ_STATE_DISABLE : +case AMDGPU_IRQ_STATE_ENABLE : +for (i =0 ; i < num_xcc; i++) { +WREG32_FIELD15_PREREG (GC ,GET_INST (GC , i),CP_INT_CNTL_RING0 , +OPCODE_ERROR_INT_ENABLE , + state ==AMDGPU_IRQ_STATE_ENABLE ?1 :0 ); +for (j =0 ; j < adev->gfx.mec.num_mec; j++) { +for (k =0 ; k < adev->gfx.mec.num_pipe_per_mec; k++) { +/* MECs start at 1 */ + mec_int_cntl_reg =gfx_v9_4_3_get_cpc_int_cntl (adev, i, j +1 , k); + +if (mec_int_cntl_reg) { + mec_int_cntl =RREG32_XCC (mec_int_cntl_reg, i); + mec_int_cntl =REG_SET_FIELD (mec_int_cntl,CP_ME1_PIPE0_INT_CNTL , +OPCODE_ERROR_INT_ENABLE , + state ==AMDGPU_IRQ_STATE_ENABLE ? +1 :0 ); +WREG32_XCC (mec_int_cntl_reg, mec_int_cntl, i); + } + } + } + } +break ; +default : +break ; + } + +return 0 ; +} + static int gfx_v9_4_3_set_priv_inst_fault_state(struct amdgpu_device *adev, struct amdgpu_irq_src *source, unsigned type,
@@ -3116,6 +3168,15 @@ static int gfx_v9_4_3_priv_reg_irq(struct amdgpu_device *adev,return 0 ; } +static int gfx_v9_4_3_bad_op_irq (struct amdgpu_device *adev, +struct amdgpu_irq_src *source, +struct amdgpu_iv_entry *entry) +{ +DRM_ERROR ("Illegal opcode in command stream\n" ); +gfx_v9_4_3_fault (adev, entry); +return 0 ; +} +static int gfx_v9_4_3_priv_inst_irq (struct amdgpu_device *adev,struct amdgpu_irq_src *source,struct amdgpu_iv_entry *entry)
@@ -4228,6 +4289,11 @@ static const struct amdgpu_irq_src_funcs gfx_v9_4_3_priv_reg_irq_funcs = { .process = gfx_v9_4_3_priv_reg_irq, }; +static const struct amdgpu_irq_src_funcs gfx_v9_4_3_bad_op_irq_funcs = { + .set = gfx_v9_4_3_set_bad_op_fault_state, + .process = gfx_v9_4_3_bad_op_irq, +}; +static const struct amdgpu_irq_src_funcs gfx_v9_4_3_priv_inst_irq_funcs = { .set = gfx_v9_4_3_set_priv_inst_fault_state, .process = gfx_v9_4_3_priv_inst_irq,
@@ -4241,6 +4307,9 @@ static void gfx_v9_4_3_set_irq_funcs(struct amdgpu_device *adev) adev->gfx.priv_reg_irq.num_types =1 ; adev->gfx.priv_reg_irq.funcs = &gfx_v9_4_3_priv_reg_irq_funcs; + adev->gfx.bad_op_irq.num_types =1 ; + adev->gfx.bad_op_irq.funcs = &gfx_v9_4_3_bad_op_irq_funcs; + adev->gfx.priv_inst_irq.num_types =1 ; adev->gfx.priv_inst_irq.funcs = &gfx_v9_4_3_priv_inst_irq_funcs; }
Signature · 1 line
2.45.2
Quoted 3 lines · Alex Deucher
Add the irq source for bad opcodes.
Signed-off-by Alex Deucher <[email protected]>
Looks like all the error IRQ handlers return 0, which means the interrupts will still get forwarded to KFD (which is good). The series is
Quoted 16 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +1
-0@@ -391,6 +391,7 @@ struct amdgpu_gfx {struct amdgpu_irq_src eop_irq;struct amdgpu_irq_src priv_reg_irq;struct amdgpu_irq_src priv_inst_irq; +struct amdgpu_irq_src bad_op_irq;struct amdgpu_irq_src cp_ecc_error_irq;struct amdgpu_irq_src sq_irq;struct amdgpu_irq_src rlc_gc_fed_irq;