.. | .. |
---|
20 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
---|
21 | 21 | * |
---|
22 | 22 | */ |
---|
23 | | -#include <drm/drmP.h> |
---|
| 23 | + |
---|
| 24 | +#include <linux/pci.h> |
---|
| 25 | + |
---|
24 | 26 | #include "amdgpu.h" |
---|
25 | 27 | #include "amdgpu_ih.h" |
---|
26 | 28 | #include "sid.h" |
---|
27 | 29 | #include "si_ih.h" |
---|
| 30 | +#include "oss/oss_1_0_d.h" |
---|
| 31 | +#include "oss/oss_1_0_sh_mask.h" |
---|
28 | 32 | |
---|
29 | 33 | static void si_ih_set_interrupt_funcs(struct amdgpu_device *adev); |
---|
30 | 34 | |
---|
.. | .. |
---|
57 | 61 | |
---|
58 | 62 | static int si_ih_irq_init(struct amdgpu_device *adev) |
---|
59 | 63 | { |
---|
| 64 | + struct amdgpu_ih_ring *ih = &adev->irq.ih; |
---|
60 | 65 | int rb_bufsz; |
---|
61 | 66 | u32 interrupt_cntl, ih_cntl, ih_rb_cntl; |
---|
62 | | - u64 wptr_off; |
---|
63 | 67 | |
---|
64 | 68 | si_ih_disable_interrupts(adev); |
---|
65 | 69 | /* set dummy read address to dummy page address */ |
---|
.. | .. |
---|
77 | 81 | (rb_bufsz << 1) | |
---|
78 | 82 | IH_WPTR_WRITEBACK_ENABLE; |
---|
79 | 83 | |
---|
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); |
---|
83 | 86 | WREG32(IH_RB_CNTL, ih_rb_cntl); |
---|
84 | 87 | WREG32(IH_RB_RPTR, 0); |
---|
85 | 88 | WREG32(IH_RB_WPTR, 0); |
---|
.. | .. |
---|
101 | 104 | mdelay(1); |
---|
102 | 105 | } |
---|
103 | 106 | |
---|
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) |
---|
105 | 109 | { |
---|
106 | 110 | u32 wptr, tmp; |
---|
107 | 111 | |
---|
108 | | - wptr = le32_to_cpu(adev->wb.wb[adev->irq.ih.wptr_offs]); |
---|
| 112 | + wptr = le32_to_cpu(*ih->wptr_cpu); |
---|
109 | 113 | |
---|
110 | 114 | if (wptr & IH_RB_WPTR__RB_OVERFLOW_MASK) { |
---|
111 | 115 | wptr &= ~IH_RB_WPTR__RB_OVERFLOW_MASK; |
---|
112 | 116 | 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; |
---|
115 | 119 | tmp = RREG32(IH_RB_CNTL); |
---|
116 | 120 | tmp |= IH_RB_CNTL__WPTR_OVERFLOW_CLEAR_MASK; |
---|
117 | 121 | WREG32(IH_RB_CNTL, tmp); |
---|
118 | 122 | } |
---|
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); |
---|
133 | 124 | } |
---|
134 | 125 | |
---|
135 | 126 | 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) |
---|
137 | 129 | { |
---|
138 | | - u32 ring_index = adev->irq.ih.rptr >> 2; |
---|
| 130 | + u32 ring_index = ih->rptr >> 2; |
---|
139 | 131 | uint32_t dw[4]; |
---|
140 | 132 | |
---|
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]); |
---|
145 | 137 | |
---|
146 | | - entry->client_id = AMDGPU_IH_CLIENTID_LEGACY; |
---|
| 138 | + entry->client_id = AMDGPU_IRQ_CLIENTID_LEGACY; |
---|
147 | 139 | entry->src_id = dw[0] & 0xff; |
---|
148 | 140 | entry->src_data[0] = dw[1] & 0xfffffff; |
---|
149 | 141 | entry->ring_id = dw[2] & 0xff; |
---|
150 | 142 | entry->vmid = (dw[2] >> 8) & 0xff; |
---|
151 | 143 | |
---|
152 | | - adev->irq.ih.rptr += 16; |
---|
| 144 | + ih->rptr += 16; |
---|
153 | 145 | } |
---|
154 | 146 | |
---|
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) |
---|
156 | 149 | { |
---|
157 | | - WREG32(IH_RB_RPTR, adev->irq.ih.rptr); |
---|
| 150 | + WREG32(IH_RB_RPTR, ih->rptr); |
---|
158 | 151 | } |
---|
159 | 152 | |
---|
160 | 153 | static int si_ih_early_init(void *handle) |
---|
.. | .. |
---|
171 | 164 | int r; |
---|
172 | 165 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
---|
173 | 166 | |
---|
174 | | - r = amdgpu_ih_ring_init(adev, 64 * 1024, false); |
---|
| 167 | + r = amdgpu_ih_ring_init(adev, &adev->irq.ih, 64 * 1024, false); |
---|
175 | 168 | if (r) |
---|
176 | 169 | return r; |
---|
177 | 170 | |
---|
.. | .. |
---|
183 | 176 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
---|
184 | 177 | |
---|
185 | 178 | amdgpu_irq_fini(adev); |
---|
186 | | - amdgpu_ih_ring_fini(adev); |
---|
| 179 | + amdgpu_ih_ring_fini(adev, &adev->irq.ih); |
---|
187 | 180 | |
---|
188 | 181 | return 0; |
---|
189 | 182 | } |
---|
.. | .. |
---|
302 | 295 | |
---|
303 | 296 | static const struct amdgpu_ih_funcs si_ih_funcs = { |
---|
304 | 297 | .get_wptr = si_ih_get_wptr, |
---|
305 | | - .prescreen_iv = si_ih_prescreen_iv, |
---|
306 | 298 | .decode_iv = si_ih_decode_iv, |
---|
307 | 299 | .set_rptr = si_ih_set_rptr |
---|
308 | 300 | }; |
---|
309 | 301 | |
---|
310 | 302 | static void si_ih_set_interrupt_funcs(struct amdgpu_device *adev) |
---|
311 | 303 | { |
---|
312 | | - if (adev->irq.ih_funcs == NULL) |
---|
313 | | - adev->irq.ih_funcs = &si_ih_funcs; |
---|
| 304 | + adev->irq.ih_funcs = &si_ih_funcs; |
---|
314 | 305 | } |
---|
315 | 306 | |
---|
316 | 307 | const struct amdgpu_ip_block_version si_ih_ip_block = |
---|