Lines Matching +full:msi +full:- +full:x

1 // SPDX-License-Identifier: GPL-2.0
2 /* pci_msi.c: Sparc64 MSI support common layer.
18 struct pci_pbm_info *pbm = msiq_cookie->pbm; in sparc64_msiq_interrupt()
19 unsigned long msiqid = msiq_cookie->msiqid; in sparc64_msiq_interrupt()
24 ops = pbm->msi_ops; in sparc64_msiq_interrupt()
26 err = ops->get_head(pbm, msiqid, &head); in sparc64_msiq_interrupt()
32 unsigned long msi; in sparc64_msiq_interrupt() local
34 err = ops->dequeue_msi(pbm, msiqid, &head, &msi); in sparc64_msiq_interrupt()
38 irq = pbm->msi_irq_table[msi - pbm->msi_first]; in sparc64_msiq_interrupt()
49 err = ops->set_head(pbm, msiqid, head); in sparc64_msiq_interrupt()
56 printk(KERN_EMERG "MSI: Get head on msiqid[%lu] gives error %d\n", in sparc64_msiq_interrupt()
61 printk(KERN_EMERG "MSI: Dequeue head[%lu] from msiqid[%lu] " in sparc64_msiq_interrupt()
67 printk(KERN_EMERG "MSI: Set head[%lu] on msiqid[%lu] " in sparc64_msiq_interrupt()
84 rotor = pbm->msiq_rotor; in pick_msiq()
85 ret = pbm->msiq_first + rotor; in pick_msiq()
87 if (++rotor >= pbm->msiq_num) in pick_msiq()
89 pbm->msiq_rotor = rotor; in pick_msiq()
101 for (i = 0; i < pbm->msi_num; i++) { in alloc_msi()
102 if (!test_and_set_bit(i, pbm->msi_bitmap)) in alloc_msi()
103 return i + pbm->msi_first; in alloc_msi()
106 return -ENOENT; in alloc_msi()
111 msi_num -= pbm->msi_first; in free_msi()
112 clear_bit(msi_num, pbm->msi_bitmap); in free_msi()
116 .name = "PCI-MSI",
128 struct pci_pbm_info *pbm = pdev->dev.archdata.host_controller; in sparc64_setup_msi_irq()
129 const struct sparc64_msiq_ops *ops = pbm->msi_ops; in sparc64_setup_msi_irq()
131 int msi, err; in sparc64_setup_msi_irq() local
135 err = -ENOMEM; in sparc64_setup_msi_irq()
140 "MSI"); in sparc64_setup_msi_irq()
146 msi = err; in sparc64_setup_msi_irq()
150 err = ops->msi_setup(pbm, msiqid, msi, in sparc64_setup_msi_irq()
151 (entry->pci.msi_attrib.is_64 ? 1 : 0)); in sparc64_setup_msi_irq()
155 pbm->msi_irq_table[msi - pbm->msi_first] = *irq_p; in sparc64_setup_msi_irq()
157 if (entry->pci.msi_attrib.is_64) { in sparc64_setup_msi_irq()
158 msg.address_hi = pbm->msi64_start >> 32; in sparc64_setup_msi_irq()
159 msg.address_lo = pbm->msi64_start & 0xffffffff; in sparc64_setup_msi_irq()
162 msg.address_lo = pbm->msi32_start; in sparc64_setup_msi_irq()
164 msg.data = msi; in sparc64_setup_msi_irq()
172 free_msi(pbm, msi); in sparc64_setup_msi_irq()
186 struct pci_pbm_info *pbm = pdev->dev.archdata.host_controller; in sparc64_teardown_msi_irq()
187 const struct sparc64_msiq_ops *ops = pbm->msi_ops; in sparc64_teardown_msi_irq()
191 for (i = 0; i < pbm->msi_num; i++) { in sparc64_teardown_msi_irq()
192 if (pbm->msi_irq_table[i] == irq) in sparc64_teardown_msi_irq()
195 if (i >= pbm->msi_num) { in sparc64_teardown_msi_irq()
196 pci_err(pdev, "%s: teardown: No MSI for irq %u\n", pbm->name, in sparc64_teardown_msi_irq()
201 msi_num = pbm->msi_first + i; in sparc64_teardown_msi_irq()
202 pbm->msi_irq_table[i] = ~0U; in sparc64_teardown_msi_irq()
204 err = ops->msi_teardown(pbm, msi_num); in sparc64_teardown_msi_irq()
206 pci_err(pdev, "%s: teardown: ops->teardown() on MSI %u, " in sparc64_teardown_msi_irq()
207 "irq %u, gives error %d\n", pbm->name, msi_num, irq, in sparc64_teardown_msi_irq()
223 size = (pbm->msi_num + (bits_per_ulong - 1)) & ~(bits_per_ulong - 1); in msi_bitmap_alloc()
227 pbm->msi_bitmap = kzalloc(size, GFP_KERNEL); in msi_bitmap_alloc()
228 if (!pbm->msi_bitmap) in msi_bitmap_alloc()
229 return -ENOMEM; in msi_bitmap_alloc()
236 kfree(pbm->msi_bitmap); in msi_bitmap_free()
237 pbm->msi_bitmap = NULL; in msi_bitmap_free()
244 size = pbm->msiq_num * sizeof(struct sparc64_msiq_cookie); in msi_table_alloc()
245 pbm->msiq_irq_cookies = kzalloc(size, GFP_KERNEL); in msi_table_alloc()
246 if (!pbm->msiq_irq_cookies) in msi_table_alloc()
247 return -ENOMEM; in msi_table_alloc()
249 for (i = 0; i < pbm->msiq_num; i++) { in msi_table_alloc()
252 p = &pbm->msiq_irq_cookies[i]; in msi_table_alloc()
253 p->pbm = pbm; in msi_table_alloc()
254 p->msiqid = pbm->msiq_first + i; in msi_table_alloc()
257 size = pbm->msi_num * sizeof(unsigned int); in msi_table_alloc()
258 pbm->msi_irq_table = kzalloc(size, GFP_KERNEL); in msi_table_alloc()
259 if (!pbm->msi_irq_table) { in msi_table_alloc()
260 kfree(pbm->msiq_irq_cookies); in msi_table_alloc()
261 pbm->msiq_irq_cookies = NULL; in msi_table_alloc()
262 return -ENOMEM; in msi_table_alloc()
270 kfree(pbm->msiq_irq_cookies); in msi_table_free()
271 pbm->msiq_irq_cookies = NULL; in msi_table_free()
273 kfree(pbm->msi_irq_table); in msi_table_free()
274 pbm->msi_irq_table = NULL; in msi_table_free()
282 int irq = ops->msiq_build_irq(pbm, msiqid, devino); in bringup_one_msi_queue()
288 nid = pbm->numa_node; in bringup_one_msi_queue()
289 if (nid != -1) { in bringup_one_msi_queue()
294 &pbm->msiq_irq_cookies[msiqid - pbm->msiq_first]); in bringup_one_msi_queue()
306 for (i = 0; i < pbm->msiq_num; i++) { in sparc64_bringup_msi_queues()
307 unsigned long msiqid = i + pbm->msiq_first; in sparc64_bringup_msi_queues()
308 unsigned long devino = i + pbm->msiq_first_devino; in sparc64_bringup_msi_queues()
325 val = of_get_property(pbm->op->dev.of_node, "#msi-eqs", &len); in sparc64_pbm_msi_init()
328 pbm->msiq_num = *val; in sparc64_pbm_msi_init()
329 if (pbm->msiq_num) { in sparc64_pbm_msi_init()
348 val = of_get_property(pbm->op->dev.of_node, "msi-eq-size", &len); in sparc64_pbm_msi_init()
352 pbm->msiq_ent_count = *val; in sparc64_pbm_msi_init()
354 mqp = of_get_property(pbm->op->dev.of_node, in sparc64_pbm_msi_init()
355 "msi-eq-to-devino", &len); in sparc64_pbm_msi_init()
357 mqp = of_get_property(pbm->op->dev.of_node, in sparc64_pbm_msi_init()
358 "msi-eq-devino", &len); in sparc64_pbm_msi_init()
362 pbm->msiq_first = mqp->first_msiq; in sparc64_pbm_msi_init()
363 pbm->msiq_first_devino = mqp->first_devino; in sparc64_pbm_msi_init()
365 val = of_get_property(pbm->op->dev.of_node, "#msi", &len); in sparc64_pbm_msi_init()
368 pbm->msi_num = *val; in sparc64_pbm_msi_init()
370 mrng = of_get_property(pbm->op->dev.of_node, "msi-ranges", &len); in sparc64_pbm_msi_init()
373 pbm->msi_first = mrng->first_msi; in sparc64_pbm_msi_init()
375 val = of_get_property(pbm->op->dev.of_node, "msi-data-mask", &len); in sparc64_pbm_msi_init()
378 pbm->msi_data_mask = *val; in sparc64_pbm_msi_init()
380 val = of_get_property(pbm->op->dev.of_node, "msix-data-width", &len); in sparc64_pbm_msi_init()
383 pbm->msix_data_width = *val; in sparc64_pbm_msi_init()
385 arng = of_get_property(pbm->op->dev.of_node, "msi-address-ranges", in sparc64_pbm_msi_init()
389 pbm->msi32_start = ((u64)arng->msi32_high << 32) | in sparc64_pbm_msi_init()
390 (u64) arng->msi32_low; in sparc64_pbm_msi_init()
391 pbm->msi64_start = ((u64)arng->msi64_high << 32) | in sparc64_pbm_msi_init()
392 (u64) arng->msi64_low; in sparc64_pbm_msi_init()
393 pbm->msi32_len = arng->msi32_len; in sparc64_pbm_msi_init()
394 pbm->msi64_len = arng->msi64_len; in sparc64_pbm_msi_init()
404 if (ops->msiq_alloc(pbm)) { in sparc64_pbm_msi_init()
411 ops->msiq_free(pbm); in sparc64_pbm_msi_init()
417 printk(KERN_INFO "%s: MSI Queue first[%u] num[%u] count[%u] " in sparc64_pbm_msi_init()
418 "devino[0x%x]\n", in sparc64_pbm_msi_init()
419 pbm->name, in sparc64_pbm_msi_init()
420 pbm->msiq_first, pbm->msiq_num, in sparc64_pbm_msi_init()
421 pbm->msiq_ent_count, in sparc64_pbm_msi_init()
422 pbm->msiq_first_devino); in sparc64_pbm_msi_init()
423 printk(KERN_INFO "%s: MSI first[%u] num[%u] mask[0x%x] " in sparc64_pbm_msi_init()
425 pbm->name, in sparc64_pbm_msi_init()
426 pbm->msi_first, pbm->msi_num, pbm->msi_data_mask, in sparc64_pbm_msi_init()
427 pbm->msix_data_width); in sparc64_pbm_msi_init()
428 printk(KERN_INFO "%s: MSI addr32[0x%llx:0x%x] " in sparc64_pbm_msi_init()
429 "addr64[0x%llx:0x%x]\n", in sparc64_pbm_msi_init()
430 pbm->name, in sparc64_pbm_msi_init()
431 pbm->msi32_start, pbm->msi32_len, in sparc64_pbm_msi_init()
432 pbm->msi64_start, pbm->msi64_len); in sparc64_pbm_msi_init()
433 printk(KERN_INFO "%s: MSI queues at RA [%016lx]\n", in sparc64_pbm_msi_init()
434 pbm->name, in sparc64_pbm_msi_init()
435 __pa(pbm->msi_queues)); in sparc64_pbm_msi_init()
437 pbm->msi_ops = ops; in sparc64_pbm_msi_init()
438 pbm->setup_msi_irq = sparc64_setup_msi_irq; in sparc64_pbm_msi_init()
439 pbm->teardown_msi_irq = sparc64_teardown_msi_irq; in sparc64_pbm_msi_init()
444 pbm->msiq_num = 0; in sparc64_pbm_msi_init()
445 printk(KERN_INFO "%s: No MSI support.\n", pbm->name); in sparc64_pbm_msi_init()