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

1 // SPDX-License-Identifier: GPL-2.0
2 /* pci_msi.c: Sparc64 MSI support common layer.
16 struct pci_pbm_info *pbm = msiq_cookie->pbm; in sparc64_msiq_interrupt()
17 unsigned long msiqid = msiq_cookie->msiqid; in sparc64_msiq_interrupt()
22 ops = pbm->msi_ops; in sparc64_msiq_interrupt()
24 err = ops->get_head(pbm, msiqid, &head); in sparc64_msiq_interrupt()
30 unsigned long msi; in sparc64_msiq_interrupt() local
32 err = ops->dequeue_msi(pbm, msiqid, &head, &msi); in sparc64_msiq_interrupt()
36 irq = pbm->msi_irq_table[msi - pbm->msi_first]; in sparc64_msiq_interrupt()
47 err = ops->set_head(pbm, msiqid, head); in sparc64_msiq_interrupt()
54 printk(KERN_EMERG "MSI: Get head on msiqid[%lu] gives error %d\n", in sparc64_msiq_interrupt()
59 printk(KERN_EMERG "MSI: Dequeue head[%lu] from msiqid[%lu] " in sparc64_msiq_interrupt()
65 printk(KERN_EMERG "MSI: Set head[%lu] on msiqid[%lu] " in sparc64_msiq_interrupt()
82 rotor = pbm->msiq_rotor; in pick_msiq()
83 ret = pbm->msiq_first + rotor; in pick_msiq()
85 if (++rotor >= pbm->msiq_num) in pick_msiq()
87 pbm->msiq_rotor = rotor; in pick_msiq()
99 for (i = 0; i < pbm->msi_num; i++) { in alloc_msi()
100 if (!test_and_set_bit(i, pbm->msi_bitmap)) in alloc_msi()
101 return i + pbm->msi_first; in alloc_msi()
104 return -ENOENT; in alloc_msi()
109 msi_num -= pbm->msi_first; in free_msi()
110 clear_bit(msi_num, pbm->msi_bitmap); in free_msi()
114 .name = "PCI-MSI",
126 struct pci_pbm_info *pbm = pdev->dev.archdata.host_controller; in sparc64_setup_msi_irq()
127 const struct sparc64_msiq_ops *ops = pbm->msi_ops; in sparc64_setup_msi_irq()
129 int msi, err; in sparc64_setup_msi_irq() local
133 err = -ENOMEM; in sparc64_setup_msi_irq()
138 "MSI"); in sparc64_setup_msi_irq()
144 msi = err; in sparc64_setup_msi_irq()
148 err = ops->msi_setup(pbm, msiqid, msi, in sparc64_setup_msi_irq()
149 (entry->pci.msi_attrib.is_64 ? 1 : 0)); in sparc64_setup_msi_irq()
153 pbm->msi_irq_table[msi - pbm->msi_first] = *irq_p; in sparc64_setup_msi_irq()
155 if (entry->pci.msi_attrib.is_64) { in sparc64_setup_msi_irq()
156 msg.address_hi = pbm->msi64_start >> 32; in sparc64_setup_msi_irq()
157 msg.address_lo = pbm->msi64_start & 0xffffffff; in sparc64_setup_msi_irq()
160 msg.address_lo = pbm->msi32_start; in sparc64_setup_msi_irq()
162 msg.data = msi; in sparc64_setup_msi_irq()
170 free_msi(pbm, msi); in sparc64_setup_msi_irq()
184 struct pci_pbm_info *pbm = pdev->dev.archdata.host_controller; in sparc64_teardown_msi_irq()
185 const struct sparc64_msiq_ops *ops = pbm->msi_ops; in sparc64_teardown_msi_irq()
189 for (i = 0; i < pbm->msi_num; i++) { in sparc64_teardown_msi_irq()
190 if (pbm->msi_irq_table[i] == irq) in sparc64_teardown_msi_irq()
193 if (i >= pbm->msi_num) { in sparc64_teardown_msi_irq()
194 pci_err(pdev, "%s: teardown: No MSI for irq %u\n", pbm->name, in sparc64_teardown_msi_irq()
199 msi_num = pbm->msi_first + i; in sparc64_teardown_msi_irq()
200 pbm->msi_irq_table[i] = ~0U; in sparc64_teardown_msi_irq()
202 err = ops->msi_teardown(pbm, msi_num); in sparc64_teardown_msi_irq()
204 pci_err(pdev, "%s: teardown: ops->teardown() on MSI %u, " in sparc64_teardown_msi_irq()
205 "irq %u, gives error %d\n", pbm->name, msi_num, irq, in sparc64_teardown_msi_irq()
221 size = (pbm->msi_num + (bits_per_ulong - 1)) & ~(bits_per_ulong - 1); in msi_bitmap_alloc()
225 pbm->msi_bitmap = kzalloc(size, GFP_KERNEL); in msi_bitmap_alloc()
226 if (!pbm->msi_bitmap) in msi_bitmap_alloc()
227 return -ENOMEM; in msi_bitmap_alloc()
234 kfree(pbm->msi_bitmap); in msi_bitmap_free()
235 pbm->msi_bitmap = NULL; in msi_bitmap_free()
242 size = pbm->msiq_num * sizeof(struct sparc64_msiq_cookie); in msi_table_alloc()
243 pbm->msiq_irq_cookies = kzalloc(size, GFP_KERNEL); in msi_table_alloc()
244 if (!pbm->msiq_irq_cookies) in msi_table_alloc()
245 return -ENOMEM; in msi_table_alloc()
247 for (i = 0; i < pbm->msiq_num; i++) { in msi_table_alloc()
250 p = &pbm->msiq_irq_cookies[i]; in msi_table_alloc()
251 p->pbm = pbm; in msi_table_alloc()
252 p->msiqid = pbm->msiq_first + i; in msi_table_alloc()
255 size = pbm->msi_num * sizeof(unsigned int); in msi_table_alloc()
256 pbm->msi_irq_table = kzalloc(size, GFP_KERNEL); in msi_table_alloc()
257 if (!pbm->msi_irq_table) { in msi_table_alloc()
258 kfree(pbm->msiq_irq_cookies); in msi_table_alloc()
259 pbm->msiq_irq_cookies = NULL; in msi_table_alloc()
260 return -ENOMEM; in msi_table_alloc()
268 kfree(pbm->msiq_irq_cookies); in msi_table_free()
269 pbm->msiq_irq_cookies = NULL; in msi_table_free()
271 kfree(pbm->msi_irq_table); in msi_table_free()
272 pbm->msi_irq_table = NULL; in msi_table_free()
280 int irq = ops->msiq_build_irq(pbm, msiqid, devino); in bringup_one_msi_queue()
286 nid = pbm->numa_node; in bringup_one_msi_queue()
287 if (nid != -1) { in bringup_one_msi_queue()
295 &pbm->msiq_irq_cookies[msiqid - pbm->msiq_first]); in bringup_one_msi_queue()
307 for (i = 0; i < pbm->msiq_num; i++) { in sparc64_bringup_msi_queues()
308 unsigned long msiqid = i + pbm->msiq_first; in sparc64_bringup_msi_queues()
309 unsigned long devino = i + pbm->msiq_first_devino; in sparc64_bringup_msi_queues()
326 val = of_get_property(pbm->op->dev.of_node, "#msi-eqs", &len); in sparc64_pbm_msi_init()
329 pbm->msiq_num = *val; in sparc64_pbm_msi_init()
330 if (pbm->msiq_num) { in sparc64_pbm_msi_init()
349 val = of_get_property(pbm->op->dev.of_node, "msi-eq-size", &len); in sparc64_pbm_msi_init()
353 pbm->msiq_ent_count = *val; in sparc64_pbm_msi_init()
355 mqp = of_get_property(pbm->op->dev.of_node, in sparc64_pbm_msi_init()
356 "msi-eq-to-devino", &len); in sparc64_pbm_msi_init()
358 mqp = of_get_property(pbm->op->dev.of_node, in sparc64_pbm_msi_init()
359 "msi-eq-devino", &len); in sparc64_pbm_msi_init()
363 pbm->msiq_first = mqp->first_msiq; in sparc64_pbm_msi_init()
364 pbm->msiq_first_devino = mqp->first_devino; in sparc64_pbm_msi_init()
366 val = of_get_property(pbm->op->dev.of_node, "#msi", &len); in sparc64_pbm_msi_init()
369 pbm->msi_num = *val; in sparc64_pbm_msi_init()
371 mrng = of_get_property(pbm->op->dev.of_node, "msi-ranges", &len); in sparc64_pbm_msi_init()
374 pbm->msi_first = mrng->first_msi; in sparc64_pbm_msi_init()
376 val = of_get_property(pbm->op->dev.of_node, "msi-data-mask", &len); in sparc64_pbm_msi_init()
379 pbm->msi_data_mask = *val; in sparc64_pbm_msi_init()
381 val = of_get_property(pbm->op->dev.of_node, "msix-data-width", &len); in sparc64_pbm_msi_init()
384 pbm->msix_data_width = *val; in sparc64_pbm_msi_init()
386 arng = of_get_property(pbm->op->dev.of_node, "msi-address-ranges", in sparc64_pbm_msi_init()
390 pbm->msi32_start = ((u64)arng->msi32_high << 32) | in sparc64_pbm_msi_init()
391 (u64) arng->msi32_low; in sparc64_pbm_msi_init()
392 pbm->msi64_start = ((u64)arng->msi64_high << 32) | in sparc64_pbm_msi_init()
393 (u64) arng->msi64_low; in sparc64_pbm_msi_init()
394 pbm->msi32_len = arng->msi32_len; in sparc64_pbm_msi_init()
395 pbm->msi64_len = arng->msi64_len; in sparc64_pbm_msi_init()
405 if (ops->msiq_alloc(pbm)) { in sparc64_pbm_msi_init()
412 ops->msiq_free(pbm); in sparc64_pbm_msi_init()
418 printk(KERN_INFO "%s: MSI Queue first[%u] num[%u] count[%u] " in sparc64_pbm_msi_init()
419 "devino[0x%x]\n", in sparc64_pbm_msi_init()
420 pbm->name, in sparc64_pbm_msi_init()
421 pbm->msiq_first, pbm->msiq_num, in sparc64_pbm_msi_init()
422 pbm->msiq_ent_count, in sparc64_pbm_msi_init()
423 pbm->msiq_first_devino); in sparc64_pbm_msi_init()
424 printk(KERN_INFO "%s: MSI first[%u] num[%u] mask[0x%x] " in sparc64_pbm_msi_init()
426 pbm->name, in sparc64_pbm_msi_init()
427 pbm->msi_first, pbm->msi_num, pbm->msi_data_mask, in sparc64_pbm_msi_init()
428 pbm->msix_data_width); in sparc64_pbm_msi_init()
429 printk(KERN_INFO "%s: MSI addr32[0x%llx:0x%x] " in sparc64_pbm_msi_init()
430 "addr64[0x%llx:0x%x]\n", in sparc64_pbm_msi_init()
431 pbm->name, in sparc64_pbm_msi_init()
432 pbm->msi32_start, pbm->msi32_len, in sparc64_pbm_msi_init()
433 pbm->msi64_start, pbm->msi64_len); in sparc64_pbm_msi_init()
434 printk(KERN_INFO "%s: MSI queues at RA [%016lx]\n", in sparc64_pbm_msi_init()
435 pbm->name, in sparc64_pbm_msi_init()
436 __pa(pbm->msi_queues)); in sparc64_pbm_msi_init()
438 pbm->msi_ops = ops; in sparc64_pbm_msi_init()
439 pbm->setup_msi_irq = sparc64_setup_msi_irq; in sparc64_pbm_msi_init()
440 pbm->teardown_msi_irq = sparc64_teardown_msi_irq; in sparc64_pbm_msi_init()
445 pbm->msiq_num = 0; in sparc64_pbm_msi_init()
446 printk(KERN_INFO "%s: No MSI support.\n", pbm->name); in sparc64_pbm_msi_init()