<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 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> 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:39 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 216</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="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 2/4] drm/amdgpu/gfx11: properly handle error ints on<br>
      all pipes (Alex Deucher)<br>
   2. [PATCH 4/4] drm/amdgpu/gfx9: properly handle error ints on<br>
      all pipes (Alex Deucher)<br>
   3. [PATCH 3/4] drm/amdgpu/gfx12: properly handle error ints on<br>
      all pipes (Alex Deucher)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Wed, 17 Jul 2024 16:38:45 -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 2/4] drm/amdgpu/gfx11: properly handle error ints on<br>
        all pipes<br>
Message-ID: <20240717203847.14600-2-alexander.deucher@amd.com><br>
Content-Type: text/plain<br>
<br>
Need to handle the interrupt enables for all pipes.<br>
<br>
v2: fix indexing (Jessie)<br>
<br>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com><br>
---<br>
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 134 ++++++++++++++++++++-----<br>
 1 file changed, 111 insertions(+), 23 deletions(-)<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 554aae995f41..02efa475eb7e 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c<br>
@@ -1953,26 +1953,74 @@ static void gfx_v11_0_constants_init(struct amdgpu_device *adev)<br>
         gfx_v11_0_init_gds_vmid(adev);<br>
 }<br>
 <br>
+static u32 gfx_v11_0_get_cpg_int_cntl(struct amdgpu_device *adev,<br>
+                                     int me, int pipe)<br>
+{<br>
+       if (me != 0)<br>
+               return 0;<br>
+<br>
+       switch (pipe) {<br>
+       case 0:<br>
+               return SOC15_REG_OFFSET(GC, 0, regCP_INT_CNTL_RING0);<br>
+       case 1:<br>
+               return SOC15_REG_OFFSET(GC, 0, regCP_INT_CNTL_RING1);<br>
+       default:<br>
+               return 0;<br>
+       }<br>
+}<br>
+<br>
+static u32 gfx_v11_0_get_cpc_int_cntl(struct amdgpu_device *adev,<br>
+                                     int me, int pipe)<br>
+{<br>
+       /*<br>
+        * amdgpu controls only the first MEC. That's why this function only<br>
+        * handles the setting of interrupts for this specific MEC. All other<br>
+        * pipes' interrupts are set by amdkfd.<br>
+        */<br>
+       if (me != 1)<br>
+               return 0;<br>
+<br>
+       switch (pipe) {<br>
+       case 0:<br>
+               return SOC15_REG_OFFSET(GC, 0, regCP_ME1_PIPE0_INT_CNTL);<br>
+       case 1:<br>
+               return SOC15_REG_OFFSET(GC, 0, regCP_ME1_PIPE1_INT_CNTL);<br>
+       case 2:<br>
+               return SOC15_REG_OFFSET(GC, 0, regCP_ME1_PIPE2_INT_CNTL);<br>
+       case 3:<br>
+               return SOC15_REG_OFFSET(GC, 0, regCP_ME1_PIPE3_INT_CNTL);<br>
+       default:<br>
+               return 0;<br>
+       }<br>
+}<br>
+<br>
 static void gfx_v11_0_enable_gui_idle_interrupt(struct amdgpu_device *adev,<br>
                                                bool enable)<br>
 {<br>
-       u32 tmp;<br>
+       u32 tmp, cp_int_cntl_reg;<br>
+       int i, j;<br>
 <br>
         if (amdgpu_sriov_vf(adev))<br>
                 return;<br>
 <br>
-       tmp = RREG32_SOC15(GC, 0, regCP_INT_CNTL_RING0);<br>
-<br>
-       tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, CNTX_BUSY_INT_ENABLE,<br>
-                           enable ? 1 : 0);<br>
-       tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, CNTX_EMPTY_INT_ENABLE,<br>
-                           enable ? 1 : 0);<br>
-       tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, CMP_BUSY_INT_ENABLE,<br>
-                           enable ? 1 : 0);<br>
-       tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, GFX_IDLE_INT_ENABLE,<br>
-                           enable ? 1 : 0);<br>
-<br>
-       WREG32_SOC15(GC, 0, regCP_INT_CNTL_RING0, tmp);<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>
+                               tmp = RREG32_SOC15_IP(GC, cp_int_cntl_reg);<br>
+                               tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, CNTX_BUSY_INT_ENABLE,<br>
+                                                   enable ? 1 : 0);<br>
+                               tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, CNTX_EMPTY_INT_ENABLE,<br>
+                                                   enable ? 1 : 0);<br>
+                               tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, CMP_BUSY_INT_ENABLE,<br>
+                                                   enable ? 1 : 0);<br>
+                               tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, GFX_IDLE_INT_ENABLE,<br>
+                                                   enable ? 1 : 0);<br>
+                               WREG32_SOC15_IP(GC, cp_int_cntl_reg, tmp);<br>
+                       }<br>
+               }<br>
+       }<br>
 }<br>
 <br>
 static int gfx_v11_0_init_csb(struct amdgpu_device *adev)<br>
@@ -6201,15 +6249,42 @@ static int gfx_v11_0_eop_irq(struct amdgpu_device *adev,<br>
 <br>
 static int gfx_v11_0_set_priv_reg_fault_state(struct amdgpu_device *adev,<br>
                                               struct amdgpu_irq_src *source,<br>
-                                             unsigned type,<br>
+                                             unsigned int 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>
-               WREG32_FIELD15_PREREG(GC, 0, CP_INT_CNTL_RING0,<br>
-                              PRIV_REG_INT_ENABLE,<br>
-                              state == AMDGPU_IRQ_STATE_ENABLE ? 1 : 0);<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>
+                                                                   PRIV_REG_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>
+                                                                   PRIV_REG_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>
@@ -6220,15 +6295,28 @@ static int gfx_v11_0_set_priv_reg_fault_state(struct amdgpu_device *adev,<br>
 <br>
 static int gfx_v11_0_set_priv_inst_fault_state(struct amdgpu_device *adev,<br>
                                                struct amdgpu_irq_src *source,<br>
-                                              unsigned type,<br>
+                                              unsigned int 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>
-               WREG32_FIELD15_PREREG(GC, 0, CP_INT_CNTL_RING0,<br>
-                              PRIV_INSTR_INT_ENABLE,<br>
-                              state == AMDGPU_IRQ_STATE_ENABLE ? 1 : 0);<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>
+                                                                   PRIV_INSTR_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>
@@ -6252,8 +6340,8 @@ static void gfx_v11_0_handle_priv_fault(struct amdgpu_device *adev,<br>
         case 0:<br>
                 for (i = 0; i < adev->gfx.num_gfx_rings; i++) {<br>
                         ring = &adev->gfx.gfx_ring[i];<br>
-                       /* we only enabled 1 gfx queue per pipe for now */<br>
-                       if (ring->me == me_id && ring->pipe == pipe_id)<br>
+                       if (ring->me == me_id && ring->pipe == pipe_id &&<br>
+                           ring->queue == queue_id)<br>
                                 drm_sched_fault(&ring->sched);<br>
                 }<br>
                 break;<br>
-- <br>
2.45.2<br>
<br>
<br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Wed, 17 Jul 2024 16:38:47 -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 4/4] drm/amdgpu/gfx9: properly handle error ints on<br>
        all pipes<br>
Message-ID: <20240717203847.14600-4-alexander.deucher@amd.com><br>
Content-Type: text/plain<br>
<br>
Need to handle the interrupt enables for all pipes.<br>
<br>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com><br>
---<br>
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c   | 44 +++++++++++++++++++++-<br>
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 50 +++++++++++++++++++++++--<br>
 2 files changed, 89 insertions(+), 5 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c<br>
index d4e38edc9353..97476fb2ca40 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c<br>
@@ -2634,7 +2634,7 @@ static void gfx_v9_0_enable_gui_idle_interrupt(struct amdgpu_device *adev,<br>
         tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, CNTX_BUSY_INT_ENABLE, enable ? 1 : 0);<br>
         tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, CNTX_EMPTY_INT_ENABLE, enable ? 1 : 0);<br>
         tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, CMP_BUSY_INT_ENABLE, enable ? 1 : 0);<br>
-       if(adev->gfx.num_gfx_rings)<br>
+       if (adev->gfx.num_gfx_rings)<br>
                 tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, GFX_IDLE_INT_ENABLE, enable ? 1 : 0);<br>
 <br>
         WREG32_SOC15(GC, 0, mmCP_INT_CNTL_RING0, tmp);<br>
@@ -5929,17 +5929,59 @@ static void gfx_v9_0_set_compute_eop_interrupt_state(struct amdgpu_device *adev,<br>
         }<br>
 }<br>
 <br>
+static u32 gfx_v9_0_get_cpc_int_cntl(struct amdgpu_device *adev,<br>
+                                    int me, int pipe)<br>
+{<br>
+       /*<br>
+        * amdgpu controls only the first MEC. That's why this function only<br>
+        * handles the setting of interrupts for this specific MEC. All other<br>
+        * pipes' interrupts are set by amdkfd.<br>
+        */<br>
+       if (me != 1)<br>
+               return 0;<br>
+<br>
+       switch (pipe) {<br>
+       case 0:<br>
+               return SOC15_REG_OFFSET(GC, 0, mmCP_ME1_PIPE0_INT_CNTL);<br>
+       case 1:<br>
+               return SOC15_REG_OFFSET(GC, 0, mmCP_ME1_PIPE1_INT_CNTL);<br>
+       case 2:<br>
+               return SOC15_REG_OFFSET(GC, 0, mmCP_ME1_PIPE2_INT_CNTL);<br>
+       case 3:<br>
+               return SOC15_REG_OFFSET(GC, 0, mmCP_ME1_PIPE3_INT_CNTL);<br>
+       default:<br>
+               return 0;<br>
+       }<br>
+}<br>
+<br>
 static int gfx_v9_0_set_priv_reg_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>
                 WREG32_FIELD15(GC, 0, CP_INT_CNTL_RING0,<br>
                                PRIV_REG_INT_ENABLE,<br>
                                state == AMDGPU_IRQ_STATE_ENABLE ? 1 : 0);<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_v9_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>
+                                                                   PRIV_REG_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>
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 2ac398184e12..43a3ef276b5f 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>
@@ -2899,21 +2899,63 @@ static void gfx_v9_4_3_xcc_set_compute_eop_interrupt_state(<br>
         }<br>
 }<br>
 <br>
+static u32 gfx_v9_4_3_get_cpc_int_cntl(struct amdgpu_device *adev,<br>
+                                    int xcc_id, int me, int pipe)<br>
+{<br>
+       /*<br>
+        * amdgpu controls only the first MEC. That's why this function only<br>
+        * handles the setting of interrupts for this specific MEC. All other<br>
+        * pipes' interrupts are set by amdkfd.<br>
+        */<br>
+       if (me != 1)<br>
+               return 0;<br>
+<br>
+       switch (pipe) {<br>
+       case 0:<br>
+               return SOC15_REG_OFFSET(GC, GET_INST(GC, xcc_id), regCP_ME1_PIPE0_INT_CNTL);<br>
+       case 1:<br>
+               return SOC15_REG_OFFSET(GC, GET_INST(GC, xcc_id), regCP_ME1_PIPE1_INT_CNTL);<br>
+       case 2:<br>
+               return SOC15_REG_OFFSET(GC, GET_INST(GC, xcc_id), regCP_ME1_PIPE2_INT_CNTL);<br>
+       case 3:<br>
+               return SOC15_REG_OFFSET(GC, GET_INST(GC, xcc_id), regCP_ME1_PIPE3_INT_CNTL);<br>
+       default:<br>
+               return 0;<br>
+       }<br>
+}<br>
+<br>
 static int gfx_v9_4_3_set_priv_reg_fault_state(struct amdgpu_device *adev,<br>
                                              struct amdgpu_irq_src *source,<br>
                                              unsigned type,<br>
                                              enum amdgpu_interrupt_state state)<br>
 {<br>
-       int i, num_xcc;<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>
+               for (i = 0; i < num_xcc; i++) {<br>
                         WREG32_FIELD15_PREREG(GC, GET_INST(GC, i), CP_INT_CNTL_RING0,<br>
-                               PRIV_REG_INT_ENABLE,<br>
-                               state == AMDGPU_IRQ_STATE_ENABLE ? 1 : 0);<br>
+                                             PRIV_REG_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>
+                                                                            PRIV_REG_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>
2.45.2<br>
<br>
<br>
<br>
------------------------------<br>
<br>
Message: 3<br>
Date: Wed, 17 Jul 2024 16:38:46 -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 3/4] drm/amdgpu/gfx12: properly handle error ints on<br>
        all pipes<br>
Message-ID: <20240717203847.14600-3-alexander.deucher@amd.com><br>
Content-Type: text/plain<br>
<br>
Need to handle the interrupt enables for all pipes.<br>
<br>
v2: fix indexing (Jessie)<br>
<br>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com><br>
---<br>
 drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 130 ++++++++++++++++++++-----<br>
 1 file changed, 106 insertions(+), 24 deletions(-)<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 567f9196d6a0..c74c8a60a23a 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c<br>
@@ -1680,26 +1680,68 @@ static void gfx_v12_0_constants_init(struct amdgpu_device *adev)<br>
         gfx_v12_0_init_compute_vmid(adev);<br>
 }<br>
 <br>
+static u32 gfx_v12_0_get_cpg_int_cntl(struct amdgpu_device *adev,<br>
+                                     int me, int pipe)<br>
+{<br>
+       if (me != 0)<br>
+               return 0;<br>
+<br>
+       switch (pipe) {<br>
+       case 0:<br>
+               return SOC15_REG_OFFSET(GC, 0, regCP_INT_CNTL_RING0);<br>
+       default:<br>
+               return 0;<br>
+       }<br>
+}<br>
+<br>
+static u32 gfx_v12_0_get_cpc_int_cntl(struct amdgpu_device *adev,<br>
+                                     int me, int pipe)<br>
+{<br>
+       /*<br>
+        * amdgpu controls only the first MEC. That's why this function only<br>
+        * handles the setting of interrupts for this specific MEC. All other<br>
+        * pipes' interrupts are set by amdkfd.<br>
+        */<br>
+       if (me != 1)<br>
+               return 0;<br>
+<br>
+       switch (pipe) {<br>
+       case 0:<br>
+               return SOC15_REG_OFFSET(GC, 0, regCP_ME1_PIPE0_INT_CNTL);<br>
+       case 1:<br>
+               return SOC15_REG_OFFSET(GC, 0, regCP_ME1_PIPE1_INT_CNTL);<br>
+       default:<br>
+               return 0;<br>
+       }<br>
+}<br>
+<br>
 static void gfx_v12_0_enable_gui_idle_interrupt(struct amdgpu_device *adev,<br>
-                                               bool enable)<br>
+                                              bool enable)<br>
 {<br>
-       u32 tmp;<br>
+       u32 tmp, cp_int_cntl_reg;<br>
+       int i, j;<br>
 <br>
         if (amdgpu_sriov_vf(adev))<br>
                 return;<br>
 <br>
-       tmp = RREG32_SOC15(GC, 0, regCP_INT_CNTL_RING0);<br>
-<br>
-       tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, CNTX_BUSY_INT_ENABLE,<br>
-                           enable ? 1 : 0);<br>
-       tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, CNTX_EMPTY_INT_ENABLE,<br>
-                           enable ? 1 : 0);<br>
-       tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, CMP_BUSY_INT_ENABLE,<br>
-                           enable ? 1 : 0);<br>
-       tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, GFX_IDLE_INT_ENABLE,<br>
-                           enable ? 1 : 0);<br>
-<br>
-       WREG32_SOC15(GC, 0, regCP_INT_CNTL_RING0, tmp);<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>
+                               tmp = RREG32_SOC15_IP(GC, cp_int_cntl_reg);<br>
+                               tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, CNTX_BUSY_INT_ENABLE,<br>
+                                                   enable ? 1 : 0);<br>
+                               tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, CNTX_EMPTY_INT_ENABLE,<br>
+                                                   enable ? 1 : 0);<br>
+                               tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, CMP_BUSY_INT_ENABLE,<br>
+                                                   enable ? 1 : 0);<br>
+                               tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, GFX_IDLE_INT_ENABLE,<br>
+                                                   enable ? 1 : 0);<br>
+                               WREG32_SOC15_IP(GC, cp_int_cntl_reg, tmp);<br>
+                       }<br>
+               }<br>
+       }<br>
 }<br>
 <br>
 static int gfx_v12_0_init_csb(struct amdgpu_device *adev)<br>
@@ -4745,15 +4787,42 @@ static int gfx_v12_0_eop_irq(struct amdgpu_device *adev,<br>
 <br>
 static int gfx_v12_0_set_priv_reg_fault_state(struct amdgpu_device *adev,<br>
                                               struct amdgpu_irq_src *source,<br>
-                                             unsigned type,<br>
+                                             unsigned int 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>
-               WREG32_FIELD15_PREREG(GC, 0, CP_INT_CNTL_RING0,<br>
-                                     PRIV_REG_INT_ENABLE,<br>
-                                     state == AMDGPU_IRQ_STATE_ENABLE ? 1 : 0);<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>
+                                                                   PRIV_REG_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>
+                                                                   PRIV_REG_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>
@@ -4764,15 +4833,28 @@ static int gfx_v12_0_set_priv_reg_fault_state(struct amdgpu_device *adev,<br>
 <br>
 static int gfx_v12_0_set_priv_inst_fault_state(struct amdgpu_device *adev,<br>
                                                struct amdgpu_irq_src *source,<br>
-                                              unsigned type,<br>
+                                              unsigned int 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>
-               WREG32_FIELD15_PREREG(GC, 0, CP_INT_CNTL_RING0,<br>
-                              PRIV_INSTR_INT_ENABLE,<br>
-                              state == AMDGPU_IRQ_STATE_ENABLE ? 1 : 0);<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>
+                                                                   PRIV_INSTR_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>
@@ -4796,8 +4878,8 @@ static void gfx_v12_0_handle_priv_fault(struct amdgpu_device *adev,<br>
         case 0:<br>
                 for (i = 0; i < adev->gfx.num_gfx_rings; i++) {<br>
                         ring = &adev->gfx.gfx_ring[i];<br>
-                       /* we only enabled 1 gfx queue per pipe for now */<br>
-                       if (ring->me == me_id && ring->pipe == pipe_id)<br>
+                       if (ring->me == me_id && ring->pipe == pipe_id &&<br>
+                           ring->queue == queue_id)<br>
                                 drm_sched_fault(&ring->sched);<br>
                 }<br>
                 break;<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 216<br>
****************************************<br>
</div>
</span></font></div>
</div>
</body>
</html>