<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Calibri;font-size:10pt;color:#0000FF;margin:5pt;font-style:normal;font-weight:normal;text-decoration:none;" align="Left">
[AMD Official Use Only - AMD Internal Distribution Only]<br>
</p>
<br>
<div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Acked-by: Vitaly Prosyak <vitaly.prosyak@amd.com></div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
The entire series of patches for gfx 7, 8, 9, 11 and compute gfx 10, 12</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
 for queue_reset was tested using the new IGT test, amd_queue_reset, which has been merged upstream.</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Prosyak, Vitaly <Vitaly.Prosyak@amd.com><br>
<b>Sent:</b> Thursday, August 8, 2024 1:01 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Deucher, Alexander <Alexander.Deucher@amd.com><br>
<b>Subject:</b> Re: amd-gfx Digest, Vol 98, Issue 218</font>
<div> </div>
</div>
<style type="text/css" style="display:none">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div dir="ltr">
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Acked-by: Vitaly Prosyak <vitaly.prosyak@amd.com></div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
The entire series of patches for gfx 7, 8, 9, 11 and compute gfx 10, 12</div>
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
 for queue_reset was tested using the new IGT test, amd_queue_reset, which has been merged upstream.</div>
<div id="x_appendonsend"></div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of amd-gfx-request@lists.freedesktop.org <amd-gfx-request@lists.freedesktop.org><br>
<b>Sent:</b> Wednesday, July 17, 2024 4:40 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Subject:</b> amd-gfx Digest, Vol 98, Issue 218</font>
<div> </div>
</div>
<div class="x_BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="x_PlainText">Send amd-gfx mailing list submissions to<br>
        amd-gfx@lists.freedesktop.org<br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
        <a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
or, via email, send a message with subject or body 'help' to<br>
        amd-gfx-request@lists.freedesktop.org<br>
<br>
You can reach the person managing the list at<br>
        amd-gfx-owner@lists.freedesktop.org<br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of amd-gfx digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
   1. [PATCH 6/6] drm/amdgpu/gfx9.4.3: Enable bad opcode interrupt<br>
      (Alex Deucher)<br>
   2. [PATCH 2/6] drm/amdgpu/gfx11: Enable bad opcode interrupt<br>
      (Alex Deucher)<br>
   3. [PATCH 4/6] drm/amdgpu/gfx12: Enable bad opcode interrupt<br>
      (Alex Deucher)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Wed, 17 Jul 2024 16:40:11 -0400<br>
From: Alex Deucher <alexander.deucher@amd.com><br>
To: <amd-gfx@lists.freedesktop.org><br>
Cc: Alex Deucher <alexander.deucher@amd.com><br>
Subject: [PATCH 6/6] drm/amdgpu/gfx9.4.3: Enable bad opcode interrupt<br>
Message-ID: <20240717204011.15342-6-alexander.deucher@amd.com><br>
Content-Type: text/plain<br>
<br>
For the bad opcode case, it will cause CP/ME hang.<br>
The firmware will prevent the ME side from hanging by raising a bad opcode interrupt.<br>
And the driver needs to perform a vmid reset when receiving the interrupt.<br>
<br>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com><br>
---<br>
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 69 +++++++++++++++++++++++++<br>
 1 file changed, 69 insertions(+)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c<br>
index 43a3ef276b5f..98fe6c40da64 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c<br>
@@ -901,6 +901,13 @@ static int gfx_v9_4_3_sw_init(void *handle)<br>
         if (r)<br>
                 return r;<br>
 <br>
+       /* Bad opcode Event */<br>
+       r = amdgpu_irq_add_id(adev, SOC15_IH_CLIENTID_GRBM_CP,<br>
+                             GFX_9_0__SRCID__CP_BAD_OPCODE_ERROR,<br>
+                             &adev->gfx.bad_op_irq);<br>
+       if (r)<br>
+               return r;<br>
+<br>
         /* Privileged reg */<br>
         r = amdgpu_irq_add_id(adev, SOC15_IH_CLIENTID_GRBM_CP, GFX_9_0__SRCID__CP_PRIV_REG_FAULT,<br>
                               &adev->gfx.priv_reg_irq);<br>
@@ -2162,6 +2169,7 @@ static int gfx_v9_4_3_hw_fini(void *handle)<br>
 <br>
         amdgpu_irq_put(adev, &adev->gfx.priv_reg_irq, 0);<br>
         amdgpu_irq_put(adev, &adev->gfx.priv_inst_irq, 0);<br>
+       amdgpu_irq_put(adev, &adev->gfx.bad_op_irq, 0);<br>
 <br>
         num_xcc = NUM_XCC(adev->gfx.xcc_mask);<br>
         for (i = 0; i < num_xcc; i++) {<br>
@@ -2327,6 +2335,10 @@ static int gfx_v9_4_3_late_init(void *handle)<br>
         if (r)<br>
                 return r;<br>
 <br>
+       r = amdgpu_irq_get(adev, &adev->gfx.bad_op_irq, 0);<br>
+       if (r)<br>
+               return r;<br>
+<br>
         if (adev->gfx.ras &&<br>
             adev->gfx.ras->enable_watchdog_timer)<br>
                 adev->gfx.ras->enable_watchdog_timer(adev);<br>
@@ -2964,6 +2976,46 @@ static int gfx_v9_4_3_set_priv_reg_fault_state(struct amdgpu_device *adev,<br>
         return 0;<br>
 }<br>
 <br>
+static int gfx_v9_4_3_set_bad_op_fault_state(struct amdgpu_device *adev,<br>
+                                            struct amdgpu_irq_src *source,<br>
+                                            unsigned type,<br>
+                                            enum amdgpu_interrupt_state state)<br>
+{<br>
+       u32 mec_int_cntl_reg, mec_int_cntl;<br>
+       int i, j, k, num_xcc;<br>
+<br>
+       num_xcc = NUM_XCC(adev->gfx.xcc_mask);<br>
+       switch (state) {<br>
+       case AMDGPU_IRQ_STATE_DISABLE:<br>
+       case AMDGPU_IRQ_STATE_ENABLE:<br>
+               for (i = 0; i < num_xcc; i++) {<br>
+                       WREG32_FIELD15_PREREG(GC, GET_INST(GC, i), CP_INT_CNTL_RING0,<br>
+                                             OPCODE_ERROR_INT_ENABLE,<br>
+                                             state == AMDGPU_IRQ_STATE_ENABLE ? 1 : 0);<br>
+                       for (j = 0; j < adev->gfx.mec.num_mec; j++) {<br>
+                               for (k = 0; k < adev->gfx.mec.num_pipe_per_mec; k++) {<br>
+                                       /* MECs start at 1 */<br>
+                                       mec_int_cntl_reg = gfx_v9_4_3_get_cpc_int_cntl(adev, i, j + 1, k);<br>
+<br>
+                                       if (mec_int_cntl_reg) {<br>
+                                               mec_int_cntl = RREG32_XCC(mec_int_cntl_reg, i);<br>
+                                               mec_int_cntl = REG_SET_FIELD(mec_int_cntl, CP_ME1_PIPE0_INT_CNTL,<br>
+                                                                            OPCODE_ERROR_INT_ENABLE,<br>
+                                                                            state == AMDGPU_IRQ_STATE_ENABLE ?<br>
+                                                                            1 : 0);<br>
+                                               WREG32_XCC(mec_int_cntl_reg, mec_int_cntl, i);<br>
+                                       }<br>
+                               }<br>
+                       }<br>
+               }<br>
+               break;<br>
+       default:<br>
+               break;<br>
+       }<br>
+<br>
+       return 0;<br>
+}<br>
+<br>
 static int gfx_v9_4_3_set_priv_inst_fault_state(struct amdgpu_device *adev,<br>
                                               struct amdgpu_irq_src *source,<br>
                                               unsigned type,<br>
@@ -3116,6 +3168,15 @@ static int gfx_v9_4_3_priv_reg_irq(struct amdgpu_device *adev,<br>
         return 0;<br>
 }<br>
 <br>
+static int gfx_v9_4_3_bad_op_irq(struct amdgpu_device *adev,<br>
+                                struct amdgpu_irq_src *source,<br>
+                                struct amdgpu_iv_entry *entry)<br>
+{<br>
+       DRM_ERROR("Illegal opcode in command stream\n");<br>
+       gfx_v9_4_3_fault(adev, entry);<br>
+       return 0;<br>
+}<br>
+<br>
 static int gfx_v9_4_3_priv_inst_irq(struct amdgpu_device *adev,<br>
                                   struct amdgpu_irq_src *source,<br>
                                   struct amdgpu_iv_entry *entry)<br>
@@ -4228,6 +4289,11 @@ static const struct amdgpu_irq_src_funcs gfx_v9_4_3_priv_reg_irq_funcs = {<br>
         .process = gfx_v9_4_3_priv_reg_irq,<br>
 };<br>
 <br>
+static const struct amdgpu_irq_src_funcs gfx_v9_4_3_bad_op_irq_funcs = {<br>
+       .set = gfx_v9_4_3_set_bad_op_fault_state,<br>
+       .process = gfx_v9_4_3_bad_op_irq,<br>
+};<br>
+<br>
 static const struct amdgpu_irq_src_funcs gfx_v9_4_3_priv_inst_irq_funcs = {<br>
         .set = gfx_v9_4_3_set_priv_inst_fault_state,<br>
         .process = gfx_v9_4_3_priv_inst_irq,<br>
@@ -4241,6 +4307,9 @@ static void gfx_v9_4_3_set_irq_funcs(struct amdgpu_device *adev)<br>
         adev->gfx.priv_reg_irq.num_types = 1;<br>
         adev->gfx.priv_reg_irq.funcs = &gfx_v9_4_3_priv_reg_irq_funcs;<br>
 <br>
+       adev->gfx.bad_op_irq.num_types = 1;<br>
+       adev->gfx.bad_op_irq.funcs = &gfx_v9_4_3_bad_op_irq_funcs;<br>
+<br>
         adev->gfx.priv_inst_irq.num_types = 1;<br>
         adev->gfx.priv_inst_irq.funcs = &gfx_v9_4_3_priv_inst_irq_funcs;<br>
 }<br>
-- <br>
2.45.2<br>
<br>
<br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Wed, 17 Jul 2024 16:40:07 -0400<br>
From: Alex Deucher <alexander.deucher@amd.com><br>
To: <amd-gfx@lists.freedesktop.org><br>
Cc: Jesse Zhang <jesse.zhang@amd.com>, Jesse Zhang<br>
        <Jesse.Zhang@amd.com>, Prike Liang <Prike.Liang@amd.com>, Alex Deucher<br>
        <alexander.deucher@amd.com><br>
Subject: [PATCH 2/6] drm/amdgpu/gfx11: Enable bad opcode interrupt<br>
Message-ID: <20240717204011.15342-2-alexander.deucher@amd.com><br>
Content-Type: text/plain<br>
<br>
From: Jesse Zhang <jesse.zhang@amd.com><br>
<br>
For the bad opcode case, it will cause CP/ME hang.<br>
The firmware will prevent the ME side from hanging by raising a bad opcode interrupt.<br>
And the driver needs to perform a vmid reset when receiving the interrupt.<br>
<br>
v2: update irq naming (drop priv) (Alex)<br>
<br>
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com><br>
Reviewed-by: Prike Liang <Prike.Liang@amd.com><br>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com><br>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com><br>
---<br>
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 73 ++++++++++++++++++++++++++<br>
 1 file changed, 73 insertions(+)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c<br>
index 02efa475eb7e..ce5cb60b8628 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c<br>
@@ -1569,6 +1569,13 @@ static int gfx_v11_0_sw_init(void *handle)<br>
         if (r)<br>
                 return r;<br>
 <br>
+       /* Bad opcode Event */<br>
+       r = amdgpu_irq_add_id(adev, SOC21_IH_CLIENTID_GRBM_CP,<br>
+                             GFX_11_0_0__SRCID__CP_BAD_OPCODE_ERROR,<br>
+                             &adev->gfx.bad_op_irq);<br>
+       if (r)<br>
+               return r;<br>
+<br>
         /* Privileged reg */<br>
         r = amdgpu_irq_add_id(adev, SOC21_IH_CLIENTID_GRBM_CP,<br>
                               GFX_11_0_0__SRCID__CP_PRIV_REG_FAULT,<br>
@@ -4646,6 +4653,7 @@ static int gfx_v11_0_hw_fini(void *handle)<br>
 <br>
         amdgpu_irq_put(adev, &adev->gfx.priv_reg_irq, 0);<br>
         amdgpu_irq_put(adev, &adev->gfx.priv_inst_irq, 0);<br>
+       amdgpu_irq_put(adev, &adev->gfx.bad_op_irq, 0);<br>
 <br>
         if (!adev->no_hw_access) {<br>
                 if (amdgpu_async_gfx_ring) {<br>
@@ -5002,6 +5010,9 @@ static int gfx_v11_0_late_init(void *handle)<br>
         if (r)<br>
                 return r;<br>
 <br>
+       r = amdgpu_irq_get(adev, &adev->gfx.bad_op_irq, 0);<br>
+       if (r)<br>
+               return r;<br>
         return 0;<br>
 }<br>
 <br>
@@ -6293,6 +6304,51 @@ static int gfx_v11_0_set_priv_reg_fault_state(struct amdgpu_device *adev,<br>
         return 0;<br>
 }<br>
 <br>
+static int gfx_v11_0_set_bad_op_fault_state(struct amdgpu_device *adev,<br>
+                                           struct amdgpu_irq_src *source,<br>
+                                           unsigned type,<br>
+                                           enum amdgpu_interrupt_state state)<br>
+{<br>
+       u32 cp_int_cntl_reg, cp_int_cntl;<br>
+       int i , j;<br>
+<br>
+       switch (state) {<br>
+       case AMDGPU_IRQ_STATE_DISABLE:<br>
+       case AMDGPU_IRQ_STATE_ENABLE:<br>
+               for (i = 0; i < adev->gfx.me.num_me; i++) {<br>
+                       for (j = 0; j < adev->gfx.me.num_pipe_per_me; j++) {<br>
+                               cp_int_cntl_reg = gfx_v11_0_get_cpg_int_cntl(adev, i, j);<br>
+<br>
+                               if (cp_int_cntl_reg) {<br>
+                                       cp_int_cntl = RREG32_SOC15_IP(GC, cp_int_cntl_reg);<br>
+                                       cp_int_cntl = REG_SET_FIELD(cp_int_cntl, CP_INT_CNTL_RING0,<br>
+                                                                   OPCODE_ERROR_INT_ENABLE,<br>
+                                                                   state == AMDGPU_IRQ_STATE_ENABLE ? 1 : 0);<br>
+                                       WREG32_SOC15_IP(GC, cp_int_cntl_reg, cp_int_cntl);<br>
+                               }<br>
+                       }<br>
+               }<br>
+               for (i = 0; i < adev->gfx.mec.num_mec; i++) {<br>
+                       for (j = 0; j < adev->gfx.mec.num_pipe_per_mec; j++) {<br>
+                               /* MECs start at 1 */<br>
+                               cp_int_cntl_reg = gfx_v11_0_get_cpc_int_cntl(adev, i + 1, j);<br>
+<br>
+                               if (cp_int_cntl_reg) {<br>
+                                       cp_int_cntl = RREG32_SOC15_IP(GC, cp_int_cntl_reg);<br>
+                                       cp_int_cntl = REG_SET_FIELD(cp_int_cntl, CP_ME1_PIPE0_INT_CNTL,<br>
+                                                                   OPCODE_ERROR_INT_ENABLE,<br>
+                                                                   state == AMDGPU_IRQ_STATE_ENABLE ? 1 : 0);<br>
+                                       WREG32_SOC15_IP(GC, cp_int_cntl_reg, cp_int_cntl);<br>
+                               }<br>
+                       }<br>
+               }<br>
+               break;<br>
+       default:<br>
+               break;<br>
+       }<br>
+       return 0;<br>
+}<br>
+<br>
 static int gfx_v11_0_set_priv_inst_fault_state(struct amdgpu_device *adev,<br>
                                                struct amdgpu_irq_src *source,<br>
                                                unsigned int type,<br>
@@ -6369,6 +6425,15 @@ static int gfx_v11_0_priv_reg_irq(struct amdgpu_device *adev,<br>
         return 0;<br>
 }<br>
 <br>
+static int gfx_v11_0_bad_op_irq(struct amdgpu_device *adev,<br>
+                               struct amdgpu_irq_src *source,<br>
+                               struct amdgpu_iv_entry *entry)<br>
+{<br>
+       DRM_ERROR("Illegal opcode in command stream \n");<br>
+       gfx_v11_0_handle_priv_fault(adev, entry);<br>
+       return 0;<br>
+}<br>
+<br>
 static int gfx_v11_0_priv_inst_irq(struct amdgpu_device *adev,<br>
                                    struct amdgpu_irq_src *source,<br>
                                    struct amdgpu_iv_entry *entry)<br>
@@ -6747,6 +6812,11 @@ static const struct amdgpu_irq_src_funcs gfx_v11_0_priv_reg_irq_funcs = {<br>
         .process = gfx_v11_0_priv_reg_irq,<br>
 };<br>
 <br>
+static const struct amdgpu_irq_src_funcs gfx_v11_0_bad_op_irq_funcs = {<br>
+       .set = gfx_v11_0_set_bad_op_fault_state,<br>
+       .process = gfx_v11_0_bad_op_irq,<br>
+};<br>
+<br>
 static const struct amdgpu_irq_src_funcs gfx_v11_0_priv_inst_irq_funcs = {<br>
         .set = gfx_v11_0_set_priv_inst_fault_state,<br>
         .process = gfx_v11_0_priv_inst_irq,<br>
@@ -6764,6 +6834,9 @@ static void gfx_v11_0_set_irq_funcs(struct amdgpu_device *adev)<br>
         adev->gfx.priv_reg_irq.num_types = 1;<br>
         adev->gfx.priv_reg_irq.funcs = &gfx_v11_0_priv_reg_irq_funcs;<br>
 <br>
+       adev->gfx.bad_op_irq.num_types = 1;<br>
+       adev->gfx.bad_op_irq.funcs = &gfx_v11_0_bad_op_irq_funcs;<br>
+<br>
         adev->gfx.priv_inst_irq.num_types = 1;<br>
         adev->gfx.priv_inst_irq.funcs = &gfx_v11_0_priv_inst_irq_funcs;<br>
 <br>
-- <br>
2.45.2<br>
<br>
<br>
<br>
------------------------------<br>
<br>
Message: 3<br>
Date: Wed, 17 Jul 2024 16:40:09 -0400<br>
From: Alex Deucher <alexander.deucher@amd.com><br>
To: <amd-gfx@lists.freedesktop.org><br>
Cc: Jesse Zhang <jesse.zhang@amd.com>, Alex Deucher<br>
        <alexander.deucher@amd.com><br>
Subject: [PATCH 4/6] drm/amdgpu/gfx12: Enable bad opcode interrupt<br>
Message-ID: <20240717204011.15342-4-alexander.deucher@amd.com><br>
Content-Type: text/plain<br>
<br>
From: Jesse Zhang <jesse.zhang@amd.com><br>
<br>
For the bad opcode case, it will cause CP/ME hang.<br>
The firmware will prevent the ME side from hanging by raising a bad opcode interrupt.<br>
And the driver needs to perform a vmid reset when receiving the interrupt.<br>
<br>
v2: update irq naming (drop priv) (Alex)<br>
<br>
Signed-off-by: Jesse Zhang <jesse.zhang@amd.com><br>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com><br>
---<br>
 drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 74 ++++++++++++++++++++++++++<br>
 1 file changed, 74 insertions(+)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c<br>
index c74c8a60a23a..63b073fd4dc7 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c<br>
@@ -1349,6 +1349,13 @@ static int gfx_v12_0_sw_init(void *handle)<br>
         if (r)<br>
                 return r;<br>
 <br>
+       /* Bad opcode Event */<br>
+       r = amdgpu_irq_add_id(adev, SOC21_IH_CLIENTID_GRBM_CP,<br>
+                             GFX_11_0_0__SRCID__CP_BAD_OPCODE_ERROR,<br>
+                             &adev->gfx.bad_op_irq);<br>
+       if (r)<br>
+               return r;<br>
+<br>
         /* Privileged reg */<br>
         r = amdgpu_irq_add_id(adev, SOC21_IH_CLIENTID_GRBM_CP,<br>
                               GFX_11_0_0__SRCID__CP_PRIV_REG_FAULT,<br>
@@ -3592,6 +3599,7 @@ static int gfx_v12_0_hw_fini(void *handle)<br>
 <br>
         amdgpu_irq_put(adev, &adev->gfx.priv_reg_irq, 0);<br>
         amdgpu_irq_put(adev, &adev->gfx.priv_inst_irq, 0);<br>
+       amdgpu_irq_put(adev, &adev->gfx.bad_op_irq, 0);<br>
 <br>
         if (!adev->no_hw_access) {<br>
                 if (amdgpu_async_gfx_ring) {<br>
@@ -3712,6 +3720,10 @@ static int gfx_v12_0_late_init(void *handle)<br>
         if (r)<br>
                 return r;<br>
 <br>
+       r = amdgpu_irq_get(adev, &adev->gfx.bad_op_irq, 0);<br>
+       if (r)<br>
+               return r;<br>
+<br>
         return 0;<br>
 }<br>
 <br>
@@ -4831,6 +4843,51 @@ static int gfx_v12_0_set_priv_reg_fault_state(struct amdgpu_device *adev,<br>
         return 0;<br>
 }<br>
 <br>
+static int gfx_v12_0_set_bad_op_fault_state(struct amdgpu_device *adev,<br>
+                                           struct amdgpu_irq_src *source,<br>
+                                           unsigned type,<br>
+                                           enum amdgpu_interrupt_state state)<br>
+{<br>
+       u32 cp_int_cntl_reg, cp_int_cntl;<br>
+       int i , j;<br>
+<br>
+       switch (state) {<br>
+       case AMDGPU_IRQ_STATE_DISABLE:<br>
+       case AMDGPU_IRQ_STATE_ENABLE:<br>
+               for (i = 0; i < adev->gfx.me.num_me; i++) {<br>
+                       for (j = 0; j < adev->gfx.me.num_pipe_per_me; j++) {<br>
+                               cp_int_cntl_reg = gfx_v12_0_get_cpg_int_cntl(adev, i, j);<br>
+<br>
+                               if (cp_int_cntl_reg) {<br>
+                                       cp_int_cntl = RREG32_SOC15_IP(GC, cp_int_cntl_reg);<br>
+                                       cp_int_cntl = REG_SET_FIELD(cp_int_cntl, CP_INT_CNTL_RING0,<br>
+                                                                   OPCODE_ERROR_INT_ENABLE,<br>
+                                                                   state == AMDGPU_IRQ_STATE_ENABLE ? 1 : 0);<br>
+                                       WREG32_SOC15_IP(GC, cp_int_cntl_reg, cp_int_cntl);<br>
+                               }<br>
+                       }<br>
+               }<br>
+               for (i = 0; i < adev->gfx.mec.num_mec; i++) {<br>
+                       for (j = 0; j < adev->gfx.mec.num_pipe_per_mec; j++) {<br>
+                               /* MECs start at 1 */<br>
+                               cp_int_cntl_reg = gfx_v12_0_get_cpc_int_cntl(adev, i + 1, j);<br>
+<br>
+                               if (cp_int_cntl_reg) {<br>
+                                       cp_int_cntl = RREG32_SOC15_IP(GC, cp_int_cntl_reg);<br>
+                                       cp_int_cntl = REG_SET_FIELD(cp_int_cntl, CP_ME1_PIPE0_INT_CNTL,<br>
+                                                                   OPCODE_ERROR_INT_ENABLE,<br>
+                                                                   state == AMDGPU_IRQ_STATE_ENABLE ? 1 : 0);<br>
+                                       WREG32_SOC15_IP(GC, cp_int_cntl_reg, cp_int_cntl);<br>
+                               }<br>
+                       }<br>
+               }<br>
+               break;<br>
+       default:<br>
+               break;<br>
+       }<br>
+       return 0;<br>
+}<br>
+<br>
 static int gfx_v12_0_set_priv_inst_fault_state(struct amdgpu_device *adev,<br>
                                                struct amdgpu_irq_src *source,<br>
                                                unsigned int type,<br>
@@ -4907,6 +4964,15 @@ static int gfx_v12_0_priv_reg_irq(struct amdgpu_device *adev,<br>
         return 0;<br>
 }<br>
 <br>
+static int gfx_v12_0_bad_op_irq(struct amdgpu_device *adev,<br>
+                               struct amdgpu_irq_src *source,<br>
+                               struct amdgpu_iv_entry *entry)<br>
+{<br>
+       DRM_ERROR("Illegal opcode in command stream \n");<br>
+       gfx_v12_0_handle_priv_fault(adev, entry);<br>
+       return 0;<br>
+}<br>
+<br>
 static int gfx_v12_0_priv_inst_irq(struct amdgpu_device *adev,<br>
                                    struct amdgpu_irq_src *source,<br>
                                    struct amdgpu_iv_entry *entry)<br>
@@ -5219,6 +5285,11 @@ static const struct amdgpu_irq_src_funcs gfx_v12_0_priv_reg_irq_funcs = {<br>
         .process = gfx_v12_0_priv_reg_irq,<br>
 };<br>
 <br>
+static const struct amdgpu_irq_src_funcs gfx_v12_0_bad_op_irq_funcs = {<br>
+       .set = gfx_v12_0_set_bad_op_fault_state,<br>
+       .process = gfx_v12_0_bad_op_irq,<br>
+};<br>
+<br>
 static const struct amdgpu_irq_src_funcs gfx_v12_0_priv_inst_irq_funcs = {<br>
         .set = gfx_v12_0_set_priv_inst_fault_state,<br>
         .process = gfx_v12_0_priv_inst_irq,<br>
@@ -5232,6 +5303,9 @@ static void gfx_v12_0_set_irq_funcs(struct amdgpu_device *adev)<br>
         adev->gfx.priv_reg_irq.num_types = 1;<br>
         adev->gfx.priv_reg_irq.funcs = &gfx_v12_0_priv_reg_irq_funcs;<br>
 <br>
+       adev->gfx.bad_op_irq.num_types = 1;<br>
+       adev->gfx.bad_op_irq.funcs = &gfx_v12_0_bad_op_irq_funcs;<br>
+<br>
         adev->gfx.priv_inst_irq.num_types = 1;<br>
         adev->gfx.priv_inst_irq.funcs = &gfx_v12_0_priv_inst_irq_funcs;<br>
 }<br>
-- <br>
2.45.2<br>
<br>
<br>
<br>
------------------------------<br>
<br>
Subject: Digest Footer<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
<br>
<br>
------------------------------<br>
<br>
End of amd-gfx Digest, Vol 98, Issue 218<br>
****************************************<br>
</div>
</span></font></div>
</div>
</div>
</body>
</html>