hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/gpu/drm/amd/amdgpu/cik_ih.c
....@@ -20,7 +20,9 @@
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 "cikd.h"
....@@ -103,9 +105,9 @@
103105 */
104106 static int cik_ih_irq_init(struct amdgpu_device *adev)
105107 {
108
+ struct amdgpu_ih_ring *ih = &adev->irq.ih;
106109 int rb_bufsz;
107110 u32 interrupt_cntl, ih_cntl, ih_rb_cntl;
108
- u64 wptr_off;
109111
110112 /* disable irqs */
111113 cik_ih_disable_interrupts(adev);
....@@ -131,9 +133,8 @@
131133 ih_rb_cntl |= IH_RB_CNTL__WPTR_WRITEBACK_ENABLE_MASK;
132134
133135 /* set the writeback address whether it's enabled or not */
134
- wptr_off = adev->wb.gpu_addr + (adev->irq.ih.wptr_offs * 4);
135
- WREG32(mmIH_RB_WPTR_ADDR_LO, lower_32_bits(wptr_off));
136
- WREG32(mmIH_RB_WPTR_ADDR_HI, upper_32_bits(wptr_off) & 0xFF);
136
+ WREG32(mmIH_RB_WPTR_ADDR_LO, lower_32_bits(ih->wptr_addr));
137
+ WREG32(mmIH_RB_WPTR_ADDR_HI, upper_32_bits(ih->wptr_addr) & 0xFF);
137138
138139 WREG32(mmIH_RB_CNTL, ih_rb_cntl);
139140
....@@ -183,11 +184,12 @@
183184 * Used by cik_irq_process().
184185 * Returns the value of the wptr.
185186 */
186
-static u32 cik_ih_get_wptr(struct amdgpu_device *adev)
187
+static u32 cik_ih_get_wptr(struct amdgpu_device *adev,
188
+ struct amdgpu_ih_ring *ih)
187189 {
188190 u32 wptr, tmp;
189191
190
- wptr = le32_to_cpu(adev->wb.wb[adev->irq.ih.wptr_offs]);
192
+ wptr = le32_to_cpu(*ih->wptr_cpu);
191193
192194 if (wptr & IH_RB_WPTR__RB_OVERFLOW_MASK) {
193195 wptr &= ~IH_RB_WPTR__RB_OVERFLOW_MASK;
....@@ -196,13 +198,13 @@
196198 * this should allow us to catchup.
197199 */
198200 dev_warn(adev->dev, "IH ring buffer overflow (0x%08X, 0x%08X, 0x%08X)\n",
199
- wptr, adev->irq.ih.rptr, (wptr + 16) & adev->irq.ih.ptr_mask);
200
- adev->irq.ih.rptr = (wptr + 16) & adev->irq.ih.ptr_mask;
201
+ wptr, ih->rptr, (wptr + 16) & ih->ptr_mask);
202
+ ih->rptr = (wptr + 16) & ih->ptr_mask;
201203 tmp = RREG32(mmIH_RB_CNTL);
202204 tmp |= IH_RB_CNTL__WPTR_OVERFLOW_CLEAR_MASK;
203205 WREG32(mmIH_RB_CNTL, tmp);
204206 }
205
- return (wptr & adev->irq.ih.ptr_mask);
207
+ return (wptr & ih->ptr_mask);
206208 }
207209
208210 /* CIK IV Ring
....@@ -228,34 +230,6 @@
228230 * [127:96] - reserved
229231 */
230232
231
-/**
232
- * cik_ih_prescreen_iv - prescreen an interrupt vector
233
- *
234
- * @adev: amdgpu_device pointer
235
- *
236
- * Returns true if the interrupt vector should be further processed.
237
- */
238
-static bool cik_ih_prescreen_iv(struct amdgpu_device *adev)
239
-{
240
- u32 ring_index = adev->irq.ih.rptr >> 2;
241
- u16 pasid;
242
-
243
- switch (le32_to_cpu(adev->irq.ih.ring[ring_index]) & 0xff) {
244
- case 146:
245
- case 147:
246
- pasid = le32_to_cpu(adev->irq.ih.ring[ring_index + 2]) >> 16;
247
- if (!pasid || amdgpu_vm_pasid_fault_credit(adev, pasid))
248
- return true;
249
- break;
250
- default:
251
- /* Not a VM fault */
252
- return true;
253
- }
254
-
255
- adev->irq.ih.rptr += 16;
256
- return false;
257
-}
258
-
259233 /**
260234 * cik_ih_decode_iv - decode an interrupt vector
261235 *
....@@ -265,18 +239,19 @@
265239 * position and also advance the position.
266240 */
267241 static void cik_ih_decode_iv(struct amdgpu_device *adev,
242
+ struct amdgpu_ih_ring *ih,
268243 struct amdgpu_iv_entry *entry)
269244 {
270245 /* wptr/rptr are in bytes! */
271
- u32 ring_index = adev->irq.ih.rptr >> 2;
246
+ u32 ring_index = ih->rptr >> 2;
272247 uint32_t dw[4];
273248
274
- dw[0] = le32_to_cpu(adev->irq.ih.ring[ring_index + 0]);
275
- dw[1] = le32_to_cpu(adev->irq.ih.ring[ring_index + 1]);
276
- dw[2] = le32_to_cpu(adev->irq.ih.ring[ring_index + 2]);
277
- dw[3] = le32_to_cpu(adev->irq.ih.ring[ring_index + 3]);
249
+ dw[0] = le32_to_cpu(ih->ring[ring_index + 0]);
250
+ dw[1] = le32_to_cpu(ih->ring[ring_index + 1]);
251
+ dw[2] = le32_to_cpu(ih->ring[ring_index + 2]);
252
+ dw[3] = le32_to_cpu(ih->ring[ring_index + 3]);
278253
279
- entry->client_id = AMDGPU_IH_CLIENTID_LEGACY;
254
+ entry->client_id = AMDGPU_IRQ_CLIENTID_LEGACY;
280255 entry->src_id = dw[0] & 0xff;
281256 entry->src_data[0] = dw[1] & 0xfffffff;
282257 entry->ring_id = dw[2] & 0xff;
....@@ -284,7 +259,7 @@
284259 entry->pasid = (dw[2] >> 16) & 0xffff;
285260
286261 /* wptr/rptr are in bytes! */
287
- adev->irq.ih.rptr += 16;
262
+ ih->rptr += 16;
288263 }
289264
290265 /**
....@@ -294,9 +269,10 @@
294269 *
295270 * Set the IH ring buffer rptr.
296271 */
297
-static void cik_ih_set_rptr(struct amdgpu_device *adev)
272
+static void cik_ih_set_rptr(struct amdgpu_device *adev,
273
+ struct amdgpu_ih_ring *ih)
298274 {
299
- WREG32(mmIH_RB_RPTR, adev->irq.ih.rptr);
275
+ WREG32(mmIH_RB_RPTR, ih->rptr);
300276 }
301277
302278 static int cik_ih_early_init(void *handle)
....@@ -318,7 +294,7 @@
318294 int r;
319295 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
320296
321
- r = amdgpu_ih_ring_init(adev, 64 * 1024, false);
297
+ r = amdgpu_ih_ring_init(adev, &adev->irq.ih, 64 * 1024, false);
322298 if (r)
323299 return r;
324300
....@@ -332,7 +308,7 @@
332308 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
333309
334310 amdgpu_irq_fini(adev);
335
- amdgpu_ih_ring_fini(adev);
311
+ amdgpu_ih_ring_fini(adev, &adev->irq.ih);
336312 amdgpu_irq_remove_domain(adev);
337313
338314 return 0;
....@@ -340,14 +316,9 @@
340316
341317 static int cik_ih_hw_init(void *handle)
342318 {
343
- int r;
344319 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
345320
346
- r = cik_ih_irq_init(adev);
347
- if (r)
348
- return r;
349
-
350
- return 0;
321
+ return cik_ih_irq_init(adev);
351322 }
352323
353324 static int cik_ih_hw_fini(void *handle)
....@@ -461,15 +432,13 @@
461432
462433 static const struct amdgpu_ih_funcs cik_ih_funcs = {
463434 .get_wptr = cik_ih_get_wptr,
464
- .prescreen_iv = cik_ih_prescreen_iv,
465435 .decode_iv = cik_ih_decode_iv,
466436 .set_rptr = cik_ih_set_rptr
467437 };
468438
469439 static void cik_ih_set_interrupt_funcs(struct amdgpu_device *adev)
470440 {
471
- if (adev->irq.ih_funcs == NULL)
472
- adev->irq.ih_funcs = &cik_ih_funcs;
441
+ adev->irq.ih_funcs = &cik_ih_funcs;
473442 }
474443
475444 const struct amdgpu_ip_block_version cik_ih_ip_block =