hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/gpu/drm/amd/amdgpu/si_ih.c
....@@ -20,11 +20,15 @@
2020 * OTHER DEALINGS IN THE SOFTWARE.
2121 *
2222 */
23
-#include <drm/drmP.h>
23
+
24
+#include <linux/pci.h>
25
+
2426 #include "amdgpu.h"
2527 #include "amdgpu_ih.h"
2628 #include "sid.h"
2729 #include "si_ih.h"
30
+#include "oss/oss_1_0_d.h"
31
+#include "oss/oss_1_0_sh_mask.h"
2832
2933 static void si_ih_set_interrupt_funcs(struct amdgpu_device *adev);
3034
....@@ -57,9 +61,9 @@
5761
5862 static int si_ih_irq_init(struct amdgpu_device *adev)
5963 {
64
+ struct amdgpu_ih_ring *ih = &adev->irq.ih;
6065 int rb_bufsz;
6166 u32 interrupt_cntl, ih_cntl, ih_rb_cntl;
62
- u64 wptr_off;
6367
6468 si_ih_disable_interrupts(adev);
6569 /* set dummy read address to dummy page address */
....@@ -77,9 +81,8 @@
7781 (rb_bufsz << 1) |
7882 IH_WPTR_WRITEBACK_ENABLE;
7983
80
- wptr_off = adev->wb.gpu_addr + (adev->irq.ih.wptr_offs * 4);
81
- WREG32(IH_RB_WPTR_ADDR_LO, lower_32_bits(wptr_off));
82
- WREG32(IH_RB_WPTR_ADDR_HI, upper_32_bits(wptr_off) & 0xFF);
84
+ WREG32(IH_RB_WPTR_ADDR_LO, lower_32_bits(ih->wptr_addr));
85
+ WREG32(IH_RB_WPTR_ADDR_HI, upper_32_bits(ih->wptr_addr) & 0xFF);
8386 WREG32(IH_RB_CNTL, ih_rb_cntl);
8487 WREG32(IH_RB_RPTR, 0);
8588 WREG32(IH_RB_WPTR, 0);
....@@ -101,60 +104,50 @@
101104 mdelay(1);
102105 }
103106
104
-static u32 si_ih_get_wptr(struct amdgpu_device *adev)
107
+static u32 si_ih_get_wptr(struct amdgpu_device *adev,
108
+ struct amdgpu_ih_ring *ih)
105109 {
106110 u32 wptr, tmp;
107111
108
- wptr = le32_to_cpu(adev->wb.wb[adev->irq.ih.wptr_offs]);
112
+ wptr = le32_to_cpu(*ih->wptr_cpu);
109113
110114 if (wptr & IH_RB_WPTR__RB_OVERFLOW_MASK) {
111115 wptr &= ~IH_RB_WPTR__RB_OVERFLOW_MASK;
112116 dev_warn(adev->dev, "IH ring buffer overflow (0x%08X, 0x%08X, 0x%08X)\n",
113
- wptr, adev->irq.ih.rptr, (wptr + 16) & adev->irq.ih.ptr_mask);
114
- adev->irq.ih.rptr = (wptr + 16) & adev->irq.ih.ptr_mask;
117
+ wptr, ih->rptr, (wptr + 16) & ih->ptr_mask);
118
+ ih->rptr = (wptr + 16) & ih->ptr_mask;
115119 tmp = RREG32(IH_RB_CNTL);
116120 tmp |= IH_RB_CNTL__WPTR_OVERFLOW_CLEAR_MASK;
117121 WREG32(IH_RB_CNTL, tmp);
118122 }
119
- return (wptr & adev->irq.ih.ptr_mask);
120
-}
121
-
122
-/**
123
- * si_ih_prescreen_iv - prescreen an interrupt vector
124
- *
125
- * @adev: amdgpu_device pointer
126
- *
127
- * Returns true if the interrupt vector should be further processed.
128
- */
129
-static bool si_ih_prescreen_iv(struct amdgpu_device *adev)
130
-{
131
- /* Process all interrupts */
132
- return true;
123
+ return (wptr & ih->ptr_mask);
133124 }
134125
135126 static void si_ih_decode_iv(struct amdgpu_device *adev,
136
- struct amdgpu_iv_entry *entry)
127
+ struct amdgpu_ih_ring *ih,
128
+ struct amdgpu_iv_entry *entry)
137129 {
138
- u32 ring_index = adev->irq.ih.rptr >> 2;
130
+ u32 ring_index = ih->rptr >> 2;
139131 uint32_t dw[4];
140132
141
- dw[0] = le32_to_cpu(adev->irq.ih.ring[ring_index + 0]);
142
- dw[1] = le32_to_cpu(adev->irq.ih.ring[ring_index + 1]);
143
- dw[2] = le32_to_cpu(adev->irq.ih.ring[ring_index + 2]);
144
- dw[3] = le32_to_cpu(adev->irq.ih.ring[ring_index + 3]);
133
+ dw[0] = le32_to_cpu(ih->ring[ring_index + 0]);
134
+ dw[1] = le32_to_cpu(ih->ring[ring_index + 1]);
135
+ dw[2] = le32_to_cpu(ih->ring[ring_index + 2]);
136
+ dw[3] = le32_to_cpu(ih->ring[ring_index + 3]);
145137
146
- entry->client_id = AMDGPU_IH_CLIENTID_LEGACY;
138
+ entry->client_id = AMDGPU_IRQ_CLIENTID_LEGACY;
147139 entry->src_id = dw[0] & 0xff;
148140 entry->src_data[0] = dw[1] & 0xfffffff;
149141 entry->ring_id = dw[2] & 0xff;
150142 entry->vmid = (dw[2] >> 8) & 0xff;
151143
152
- adev->irq.ih.rptr += 16;
144
+ ih->rptr += 16;
153145 }
154146
155
-static void si_ih_set_rptr(struct amdgpu_device *adev)
147
+static void si_ih_set_rptr(struct amdgpu_device *adev,
148
+ struct amdgpu_ih_ring *ih)
156149 {
157
- WREG32(IH_RB_RPTR, adev->irq.ih.rptr);
150
+ WREG32(IH_RB_RPTR, ih->rptr);
158151 }
159152
160153 static int si_ih_early_init(void *handle)
....@@ -171,7 +164,7 @@
171164 int r;
172165 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
173166
174
- r = amdgpu_ih_ring_init(adev, 64 * 1024, false);
167
+ r = amdgpu_ih_ring_init(adev, &adev->irq.ih, 64 * 1024, false);
175168 if (r)
176169 return r;
177170
....@@ -183,7 +176,7 @@
183176 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
184177
185178 amdgpu_irq_fini(adev);
186
- amdgpu_ih_ring_fini(adev);
179
+ amdgpu_ih_ring_fini(adev, &adev->irq.ih);
187180
188181 return 0;
189182 }
....@@ -302,15 +295,13 @@
302295
303296 static const struct amdgpu_ih_funcs si_ih_funcs = {
304297 .get_wptr = si_ih_get_wptr,
305
- .prescreen_iv = si_ih_prescreen_iv,
306298 .decode_iv = si_ih_decode_iv,
307299 .set_rptr = si_ih_set_rptr
308300 };
309301
310302 static void si_ih_set_interrupt_funcs(struct amdgpu_device *adev)
311303 {
312
- if (adev->irq.ih_funcs == NULL)
313
- adev->irq.ih_funcs = &si_ih_funcs;
304
+ adev->irq.ih_funcs = &si_ih_funcs;
314305 }
315306
316307 const struct amdgpu_ip_block_version si_ih_ip_block =