Lines Matching refs:pbm

16 	struct pci_pbm_info *pbm = msiq_cookie->pbm;  in sparc64_msiq_interrupt()  local
22 ops = pbm->msi_ops; in sparc64_msiq_interrupt()
24 err = ops->get_head(pbm, msiqid, &head); in sparc64_msiq_interrupt()
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()
74 static u32 pick_msiq(struct pci_pbm_info *pbm) in pick_msiq() argument
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()
95 static int alloc_msi(struct pci_pbm_info *pbm) in alloc_msi() argument
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()
107 static void free_msi(struct pci_pbm_info *pbm, int msi_num) in free_msi() argument
109 msi_num -= pbm->msi_first; in free_msi()
110 clear_bit(msi_num, pbm->msi_bitmap); in free_msi()
126 struct pci_pbm_info *pbm = pdev->dev.archdata.host_controller; in sparc64_setup_msi_irq() local
127 const struct sparc64_msiq_ops *ops = pbm->msi_ops; in sparc64_setup_msi_irq()
140 err = alloc_msi(pbm); in sparc64_setup_msi_irq()
146 msiqid = pick_msiq(pbm); in sparc64_setup_msi_irq()
148 err = ops->msi_setup(pbm, msiqid, msi, in sparc64_setup_msi_irq()
153 pbm->msi_irq_table[msi - pbm->msi_first] = *irq_p; 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()
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() local
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()
205 "irq %u, gives error %d\n", pbm->name, msi_num, irq, in sparc64_teardown_msi_irq()
210 free_msi(pbm, msi_num); in sparc64_teardown_msi_irq()
216 static int msi_bitmap_alloc(struct pci_pbm_info *pbm) in msi_bitmap_alloc() argument
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()
232 static void msi_bitmap_free(struct pci_pbm_info *pbm) in msi_bitmap_free() argument
234 kfree(pbm->msi_bitmap); in msi_bitmap_free()
235 pbm->msi_bitmap = NULL; in msi_bitmap_free()
238 static int msi_table_alloc(struct pci_pbm_info *pbm) in msi_table_alloc() argument
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()
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()
266 static void msi_table_free(struct pci_pbm_info *pbm) in msi_table_free() argument
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()
275 static int bringup_one_msi_queue(struct pci_pbm_info *pbm, in bringup_one_msi_queue() argument
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()
295 &pbm->msiq_irq_cookies[msiqid - pbm->msiq_first]); in bringup_one_msi_queue()
302 static int sparc64_bringup_msi_queues(struct pci_pbm_info *pbm, in sparc64_bringup_msi_queues() argument
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()
312 err = bringup_one_msi_queue(pbm, ops, msiqid, devino); in sparc64_bringup_msi_queues()
320 void sparc64_pbm_msi_init(struct pci_pbm_info *pbm, in sparc64_pbm_msi_init() argument
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()
358 mqp = of_get_property(pbm->op->dev.of_node, 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()
392 pbm->msi64_start = ((u64)arng->msi64_high << 32) | 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()
397 if (msi_bitmap_alloc(pbm)) in sparc64_pbm_msi_init()
400 if (msi_table_alloc(pbm)) { in sparc64_pbm_msi_init()
401 msi_bitmap_free(pbm); in sparc64_pbm_msi_init()
405 if (ops->msiq_alloc(pbm)) { in sparc64_pbm_msi_init()
406 msi_table_free(pbm); in sparc64_pbm_msi_init()
407 msi_bitmap_free(pbm); in sparc64_pbm_msi_init()
411 if (sparc64_bringup_msi_queues(pbm, ops)) { in sparc64_pbm_msi_init()
412 ops->msiq_free(pbm); in sparc64_pbm_msi_init()
413 msi_table_free(pbm); in sparc64_pbm_msi_init()
414 msi_bitmap_free(pbm); 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()
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()
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()
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()