aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/pci/pci.c
diff options
context:
space:
mode:
authorMartin Schwidefsky <schwidefsky@de.ibm.com>2013-06-25 10:36:29 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2013-08-22 06:20:03 -0400
commit5d0d8f43535bc4e19406ecf158340ccc4027a477 (patch)
tree14dedb7e575f97715f51e3c50c3044c804ff0409 /arch/s390/pci/pci.c
parent9389339f28c2f0a32ad5043a1fe05444a7f3e677 (diff)
s390/pci: use adapter interrupt vector helpers
Make use of the adapter interrupt helpers in the PCI code. This is the first step to convert the MSI interrupt code to PCI domains. The patch removes the limitation of 64 adapter interrupts per PCI function. Reviewed-by: Sebastian Ott <sebott@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390/pci/pci.c')
-rw-r--r--arch/s390/pci/pci.c347
1 files changed, 155 insertions, 192 deletions
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 5b8feffe65dd..27e7fed3707d 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -42,7 +42,6 @@
42#define SIC_IRQ_MODE_SINGLE 1 42#define SIC_IRQ_MODE_SINGLE 1
43 43
44#define ZPCI_NR_DMA_SPACES 1 44#define ZPCI_NR_DMA_SPACES 1
45#define ZPCI_MSI_VEC_BITS 6
46#define ZPCI_NR_DEVICES CONFIG_PCI_NR_FUNCTIONS 45#define ZPCI_NR_DEVICES CONFIG_PCI_NR_FUNCTIONS
47 46
48/* list of all detected zpci devices */ 47/* list of all detected zpci devices */
@@ -62,25 +61,13 @@ struct callback {
62}; 61};
63 62
64struct zdev_irq_map { 63struct zdev_irq_map {
65 unsigned long aibv; /* AI bit vector */ 64 struct airq_iv *aibv; /* Adapter interrupt bit vector */
66 int msi_vecs; /* consecutive MSI-vectors used */ 65 struct callback *cb; /* callback handler array */
67 int __unused; 66 int msi_vecs; /* consecutive MSI-vectors used */
68 struct callback cb[ZPCI_NR_MSI_VECS]; /* callback handler array */
69 spinlock_t lock; /* protect callbacks against de-reg */
70}; 67};
71 68
72struct intr_bucket { 69static struct airq_iv *zpci_aisb_iv;
73 /* amap of adapters, one bit per dev, corresponds to one irq nr */ 70static struct zdev_irq_map *zpci_imap[ZPCI_NR_DEVICES];
74 unsigned long *alloc;
75 /* AI summary bit, global page for all devices */
76 unsigned long *aisb;
77 /* pointer to aibv and callback data in zdev */
78 struct zdev_irq_map *imap[ZPCI_NR_DEVICES];
79 /* protects the whole bucket struct */
80 spinlock_t lock;
81};
82
83static struct intr_bucket *bucket;
84 71
85/* Adapter interrupt definitions */ 72/* Adapter interrupt definitions */
86static void zpci_irq_handler(struct airq_struct *airq); 73static void zpci_irq_handler(struct airq_struct *airq);
@@ -96,15 +83,12 @@ static DECLARE_BITMAP(zpci_iomap, ZPCI_IOMAP_MAX_ENTRIES);
96struct zpci_iomap_entry *zpci_iomap_start; 83struct zpci_iomap_entry *zpci_iomap_start;
97EXPORT_SYMBOL_GPL(zpci_iomap_start); 84EXPORT_SYMBOL_GPL(zpci_iomap_start);
98 85
99/* highest irq summary bit */
100static int __read_mostly aisb_max;
101
102static struct kmem_cache *zdev_irq_cache; 86static struct kmem_cache *zdev_irq_cache;
103static struct kmem_cache *zdev_fmb_cache; 87static struct kmem_cache *zdev_fmb_cache;
104 88
105static inline int irq_to_msi_nr(unsigned int irq) 89static inline int irq_to_msi_nr(unsigned int irq)
106{ 90{
107 return irq & ZPCI_MSI_MASK; 91 return irq & ZPCI_MSI_VEC_MASK;
108} 92}
109 93
110static inline int irq_to_dev_nr(unsigned int irq) 94static inline int irq_to_dev_nr(unsigned int irq)
@@ -112,11 +96,6 @@ static inline int irq_to_dev_nr(unsigned int irq)
112 return irq >> ZPCI_MSI_VEC_BITS; 96 return irq >> ZPCI_MSI_VEC_BITS;
113} 97}
114 98
115static inline struct zdev_irq_map *get_imap(unsigned int irq)
116{
117 return bucket->imap[irq_to_dev_nr(irq)];
118}
119
120struct zpci_dev *get_zdev(struct pci_dev *pdev) 99struct zpci_dev *get_zdev(struct pci_dev *pdev)
121{ 100{
122 return (struct zpci_dev *) pdev->sysdata; 101 return (struct zpci_dev *) pdev->sysdata;
@@ -160,8 +139,7 @@ int pci_proc_domain(struct pci_bus *bus)
160EXPORT_SYMBOL_GPL(pci_proc_domain); 139EXPORT_SYMBOL_GPL(pci_proc_domain);
161 140
162/* Modify PCI: Register adapter interruptions */ 141/* Modify PCI: Register adapter interruptions */
163static int zpci_register_airq(struct zpci_dev *zdev, unsigned int aisb, 142static int zpci_set_airq(struct zpci_dev *zdev)
164 u64 aibv)
165{ 143{
166 u64 req = ZPCI_CREATE_REQ(zdev->fh, 0, ZPCI_MOD_FC_REG_INT); 144 u64 req = ZPCI_CREATE_REQ(zdev->fh, 0, ZPCI_MOD_FC_REG_INT);
167 struct zpci_fib *fib; 145 struct zpci_fib *fib;
@@ -172,12 +150,12 @@ static int zpci_register_airq(struct zpci_dev *zdev, unsigned int aisb,
172 return -ENOMEM; 150 return -ENOMEM;
173 151
174 fib->isc = PCI_ISC; 152 fib->isc = PCI_ISC;
175 fib->noi = zdev->irq_map->msi_vecs;
176 fib->sum = 1; /* enable summary notifications */ 153 fib->sum = 1; /* enable summary notifications */
177 fib->aibv = aibv; 154 fib->noi = airq_iv_end(zdev->aibv);
178 fib->aibvo = 0; /* every function has its own page */ 155 fib->aibv = (unsigned long) zdev->aibv->vector;
179 fib->aisb = (u64) bucket->aisb + aisb / 8; 156 fib->aibvo = 0; /* each zdev has its own interrupt vector */
180 fib->aisbo = aisb & ZPCI_MSI_MASK; 157 fib->aisb = (unsigned long) zpci_aisb_iv->vector + (zdev->aisb/64)*8;
158 fib->aisbo = zdev->aisb & 63;
181 159
182 rc = zpci_mod_fc(req, fib); 160 rc = zpci_mod_fc(req, fib);
183 pr_debug("%s mpcifc returned noi: %d\n", __func__, fib->noi); 161 pr_debug("%s mpcifc returned noi: %d\n", __func__, fib->noi);
@@ -234,7 +212,7 @@ int zpci_unregister_ioat(struct zpci_dev *zdev, u8 dmaas)
234} 212}
235 213
236/* Modify PCI: Unregister adapter interruptions */ 214/* Modify PCI: Unregister adapter interruptions */
237static int zpci_unregister_airq(struct zpci_dev *zdev) 215static int zpci_clear_airq(struct zpci_dev *zdev)
238{ 216{
239 struct mod_pci_args args = { 0, 0, 0, 0 }; 217 struct mod_pci_args args = { 0, 0, 0, 0 };
240 218
@@ -404,152 +382,171 @@ static struct pci_ops pci_root_ops = {
404 .write = pci_write, 382 .write = pci_write,
405}; 383};
406 384
407/* store the last handled bit to implement fair scheduling of devices */
408static DEFINE_PER_CPU(unsigned long, next_sbit);
409
410static void zpci_irq_handler(struct airq_struct *airq) 385static void zpci_irq_handler(struct airq_struct *airq)
411{ 386{
412 unsigned long sbit, mbit, last = 0, start = __get_cpu_var(next_sbit); 387 unsigned long si, ai;
413 int rescan = 0, max = aisb_max;
414 struct zdev_irq_map *imap; 388 struct zdev_irq_map *imap;
389 int irqs_on = 0;
415 390
416 inc_irq_stat(IRQIO_PCI); 391 inc_irq_stat(IRQIO_PCI);
417 sbit = start; 392 for (si = 0;;) {
418 393 /* Scan adapter summary indicator bit vector */
419scan: 394 si = airq_iv_scan(zpci_aisb_iv, si, airq_iv_end(zpci_aisb_iv));
420 /* find summary_bit */ 395 if (si == -1UL) {
421 for_each_set_bit_left_cont(sbit, bucket->aisb, max) { 396 if (irqs_on++)
422 clear_bit(63 - (sbit & 63), bucket->aisb + (sbit >> 6)); 397 /* End of second scan with interrupts on. */
423 last = sbit; 398 break;
399 /* First scan complete, reenable interrupts. */
400 zpci_set_irq_ctrl(SIC_IRQ_MODE_SINGLE, NULL, PCI_ISC);
401 si = 0;
402 continue;
403 }
424 404
425 /* find vector bit */ 405 /* Scan the adapter interrupt vector for this device. */
426 imap = bucket->imap[sbit]; 406 imap = zpci_imap[si];
427 for_each_set_bit_left(mbit, &imap->aibv, imap->msi_vecs) { 407 for (ai = 0;;) {
408 ai = airq_iv_scan(imap->aibv, ai, imap->msi_vecs);
409 if (ai == -1UL)
410 break;
428 inc_irq_stat(IRQIO_MSI); 411 inc_irq_stat(IRQIO_MSI);
429 clear_bit(63 - mbit, &imap->aibv); 412 airq_iv_lock(imap->aibv, ai);
430 413 if (imap->cb[ai].handler)
431 spin_lock(&imap->lock); 414 imap->cb[ai].handler(ai, imap->cb[ai].data);
432 if (imap->cb[mbit].handler) 415 airq_iv_unlock(imap->aibv, ai);
433 imap->cb[mbit].handler(mbit,
434 imap->cb[mbit].data);
435 spin_unlock(&imap->lock);
436 } 416 }
437 } 417 }
418}
438 419
439 if (rescan) 420static int zpci_alloc_msi(struct zpci_dev *zdev, int msi_vecs)
440 goto out; 421{
441 422 unsigned long size;
442 /* scan the skipped bits */
443 if (start > 0) {
444 sbit = 0;
445 max = start;
446 start = 0;
447 goto scan;
448 }
449 423
450 /* enable interrupts again */ 424 /* Alloc aibv & callback space */
451 zpci_set_irq_ctrl(SIC_IRQ_MODE_SINGLE, NULL, PCI_ISC); 425 zdev->irq_map = kmem_cache_zalloc(zdev_irq_cache, GFP_KERNEL);
426 if (!zdev->irq_map)
427 goto out;
428 /* Store the number of used MSI vectors */
429 zdev->irq_map->msi_vecs = msi_vecs;
430 /* Allocate callback array */
431 size = sizeof(struct callback) * msi_vecs;
432 zdev->irq_map->cb = kzalloc(size, GFP_KERNEL);
433 if (!zdev->irq_map->cb)
434 goto out_map;
435 /* Allocate msi_map array */
436 size = sizeof(struct msi_map) * msi_vecs;
437 zdev->msi_map = kzalloc(size, GFP_KERNEL);
438 if (!zdev->msi_map)
439 goto out_cb;
440 return 0;
452 441
453 /* check again to not lose initiative */ 442out_cb:
454 rmb(); 443 kfree(zdev->irq_map->cb);
455 max = aisb_max; 444out_map:
456 sbit = find_first_bit_left(bucket->aisb, max); 445 kmem_cache_free(zdev_irq_cache, zdev->irq_map);
457 if (sbit != max) {
458 rescan++;
459 goto scan;
460 }
461out: 446out:
462 /* store next device bit to scan */ 447 return -ENOMEM;
463 __get_cpu_var(next_sbit) = (++last >= aisb_max) ? 0 : last;
464} 448}
465 449
466/* msi_vecs - number of requested interrupts, 0 place function to error state */ 450static void zpci_free_msi(struct zpci_dev *zdev)
467static int zpci_setup_msi(struct pci_dev *pdev, int msi_vecs) 451{
452 kfree(zdev->msi_map);
453 kfree(zdev->irq_map->cb);
454 kmem_cache_free(zdev_irq_cache, zdev->irq_map);
455}
456
457int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
468{ 458{
469 struct zpci_dev *zdev = get_zdev(pdev); 459 struct zpci_dev *zdev = get_zdev(pdev);
470 unsigned int aisb, msi_nr; 460 unsigned int msi_nr, msi_vecs;
461 unsigned long aisb;
471 struct msi_desc *msi; 462 struct msi_desc *msi;
472 int rc; 463 int rc;
473 464
474 /* store the number of used MSI vectors */ 465 pr_debug("%s: requesting %d MSI-X interrupts...", __func__, nvec);
475 zdev->irq_map->msi_vecs = min(msi_vecs, ZPCI_NR_MSI_VECS); 466 if (type != PCI_CAP_ID_MSIX && type != PCI_CAP_ID_MSI)
476 467 return -EINVAL;
477 spin_lock(&bucket->lock); 468 msi_vecs = min(nvec, ZPCI_MSI_VEC_MAX);
478 aisb = find_first_zero_bit(bucket->alloc, PAGE_SIZE);
479 /* alloc map exhausted? */
480 if (aisb == PAGE_SIZE) {
481 spin_unlock(&bucket->lock);
482 return -EIO;
483 }
484 set_bit(aisb, bucket->alloc);
485 spin_unlock(&bucket->lock);
486 469
470 /* Allocate adapter summary indicator bit */
471 rc = -EIO;
472 aisb = airq_iv_alloc_bit(zpci_aisb_iv);
473 if (aisb == -1UL)
474 goto out;
487 zdev->aisb = aisb; 475 zdev->aisb = aisb;
488 if (aisb + 1 > aisb_max)
489 aisb_max = aisb + 1;
490 476
491 /* wire up IRQ shortcut pointer */ 477 /* Create adapter interrupt vector */
492 bucket->imap[zdev->aisb] = zdev->irq_map; 478 rc = -ENOMEM;
493 pr_debug("%s: imap[%u] linked to %p\n", __func__, zdev->aisb, zdev->irq_map); 479 zdev->aibv = airq_iv_create(msi_vecs, AIRQ_IV_BITLOCK);
480 if (!zdev->aibv)
481 goto out_si;
494 482
495 /* TODO: irq number 0 wont be found if we return less than requested MSIs. 483 /* Allocate data structures for msi interrupts */
496 * ignore it for now and fix in common code. 484 rc = zpci_alloc_msi(zdev, msi_vecs);
485 if (rc)
486 goto out_iv;
487
488 /* Wire up shortcut pointer */
489 zpci_imap[aisb] = zdev->irq_map;
490 zdev->irq_map->aibv = zdev->aibv;
491
492 /*
493 * TODO: irq number 0 wont be found if we return less than the
494 * requested MSIs. Ignore it for now and fix in common code.
497 */ 495 */
498 msi_nr = aisb << ZPCI_MSI_VEC_BITS; 496 msi_nr = aisb << ZPCI_MSI_VEC_BITS;
499
500 list_for_each_entry(msi, &pdev->msi_list, list) { 497 list_for_each_entry(msi, &pdev->msi_list, list) {
501 rc = zpci_setup_msi_irq(zdev, msi, msi_nr, 498 rc = zpci_setup_msi_irq(zdev, msi, msi_nr,
502 aisb << ZPCI_MSI_VEC_BITS); 499 aisb << ZPCI_MSI_VEC_BITS);
503 if (rc) 500 if (rc)
504 return rc; 501 goto out_msi;
505 msi_nr++; 502 msi_nr++;
506 } 503 }
507 504
508 rc = zpci_register_airq(zdev, aisb, (u64) &zdev->irq_map->aibv); 505 /* Enable adapter interrupts */
509 if (rc) { 506 rc = zpci_set_airq(zdev);
510 clear_bit(aisb, bucket->alloc); 507 if (rc)
511 dev_err(&pdev->dev, "register MSI failed with: %d\n", rc); 508 goto out_msi;
512 return rc; 509
510 return (msi_vecs == nvec) ? 0 : msi_vecs;
511
512out_msi:
513 msi_nr -= aisb << ZPCI_MSI_VEC_BITS;
514 list_for_each_entry(msi, &pdev->msi_list, list) {
515 if (msi_nr-- == 0)
516 break;
517 zpci_teardown_msi_irq(zdev, msi);
513 } 518 }
514 return (zdev->irq_map->msi_vecs == msi_vecs) ? 519 zpci_free_msi(zdev);
515 0 : zdev->irq_map->msi_vecs; 520out_iv:
521 airq_iv_release(zdev->aibv);
522out_si:
523 airq_iv_free_bit(zpci_aisb_iv, aisb);
524out:
525 dev_err(&pdev->dev, "register MSI failed with: %d\n", rc);
526 return rc;
516} 527}
517 528
518static void zpci_teardown_msi(struct pci_dev *pdev) 529void arch_teardown_msi_irqs(struct pci_dev *pdev)
519{ 530{
520 struct zpci_dev *zdev = get_zdev(pdev); 531 struct zpci_dev *zdev = get_zdev(pdev);
521 struct msi_desc *msi; 532 struct msi_desc *msi;
522 int aisb, rc; 533 int rc;
534
535 pr_info("%s: on pdev: %p\n", __func__, pdev);
523 536
524 rc = zpci_unregister_airq(zdev); 537 /* Disable adapter interrupts */
538 rc = zpci_clear_airq(zdev);
525 if (rc) { 539 if (rc) {
526 dev_err(&pdev->dev, "deregister MSI failed with: %d\n", rc); 540 dev_err(&pdev->dev, "deregister MSI failed with: %d\n", rc);
527 return; 541 return;
528 } 542 }
529 543
530 msi = list_first_entry(&pdev->msi_list, struct msi_desc, list);
531 aisb = irq_to_dev_nr(msi->irq);
532
533 list_for_each_entry(msi, &pdev->msi_list, list) 544 list_for_each_entry(msi, &pdev->msi_list, list)
534 zpci_teardown_msi_irq(zdev, msi); 545 zpci_teardown_msi_irq(zdev, msi);
535 546
536 clear_bit(aisb, bucket->alloc); 547 zpci_free_msi(zdev);
537 if (aisb + 1 == aisb_max) 548 airq_iv_release(zdev->aibv);
538 aisb_max--; 549 airq_iv_free_bit(zpci_aisb_iv, zdev->aisb);
539}
540
541int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
542{
543 pr_debug("%s: requesting %d MSI-X interrupts...", __func__, nvec);
544 if (type != PCI_CAP_ID_MSIX && type != PCI_CAP_ID_MSI)
545 return -EINVAL;
546 return zpci_setup_msi(pdev, nvec);
547}
548
549void arch_teardown_msi_irqs(struct pci_dev *pdev)
550{
551 pr_info("%s: on pdev: %p\n", __func__, pdev);
552 zpci_teardown_msi(pdev);
553} 550}
554 551
555static void zpci_map_resources(struct zpci_dev *zdev) 552static void zpci_map_resources(struct zpci_dev *zdev)
@@ -589,24 +586,11 @@ struct zpci_dev *zpci_alloc_device(void)
589 586
590 /* Alloc memory for our private pci device data */ 587 /* Alloc memory for our private pci device data */
591 zdev = kzalloc(sizeof(*zdev), GFP_KERNEL); 588 zdev = kzalloc(sizeof(*zdev), GFP_KERNEL);
592 if (!zdev) 589 return zdev ? : ERR_PTR(-ENOMEM);
593 return ERR_PTR(-ENOMEM);
594
595 /* Alloc aibv & callback space */
596 zdev->irq_map = kmem_cache_zalloc(zdev_irq_cache, GFP_KERNEL);
597 if (!zdev->irq_map)
598 goto error;
599 WARN_ON((u64) zdev->irq_map & 0xff);
600 return zdev;
601
602error:
603 kfree(zdev);
604 return ERR_PTR(-ENOMEM);
605} 590}
606 591
607void zpci_free_device(struct zpci_dev *zdev) 592void zpci_free_device(struct zpci_dev *zdev)
608{ 593{
609 kmem_cache_free(zdev_irq_cache, zdev->irq_map);
610 kfree(zdev); 594 kfree(zdev);
611} 595}
612 596
@@ -643,7 +627,8 @@ int pcibios_add_platform_entries(struct pci_dev *pdev)
643 627
644int zpci_request_irq(unsigned int irq, irq_handler_t handler, void *data) 628int zpci_request_irq(unsigned int irq, irq_handler_t handler, void *data)
645{ 629{
646 int msi_nr = irq_to_msi_nr(irq); 630 unsigned int msi_nr = irq_to_msi_nr(irq);
631 unsigned int dev_nr = irq_to_dev_nr(irq);
647 struct zdev_irq_map *imap; 632 struct zdev_irq_map *imap;
648 struct msi_desc *msi; 633 struct msi_desc *msi;
649 634
@@ -651,10 +636,7 @@ int zpci_request_irq(unsigned int irq, irq_handler_t handler, void *data)
651 if (!msi) 636 if (!msi)
652 return -EIO; 637 return -EIO;
653 638
654 imap = get_imap(irq); 639 imap = zpci_imap[dev_nr];
655 spin_lock_init(&imap->lock);
656
657 pr_debug("%s: register handler for IRQ:MSI %d:%d\n", __func__, irq >> 6, msi_nr);
658 imap->cb[msi_nr].handler = handler; 640 imap->cb[msi_nr].handler = handler;
659 imap->cb[msi_nr].data = data; 641 imap->cb[msi_nr].data = data;
660 642
@@ -669,24 +651,25 @@ int zpci_request_irq(unsigned int irq, irq_handler_t handler, void *data)
669 651
670void zpci_free_irq(unsigned int irq) 652void zpci_free_irq(unsigned int irq)
671{ 653{
672 struct zdev_irq_map *imap = get_imap(irq); 654 unsigned int msi_nr = irq_to_msi_nr(irq);
673 int msi_nr = irq_to_msi_nr(irq); 655 unsigned int dev_nr = irq_to_dev_nr(irq);
674 unsigned long flags; 656 struct zdev_irq_map *imap;
675 657 struct msi_desc *msi;
676 pr_debug("%s: for irq: %d\n", __func__, irq);
677 658
678 spin_lock_irqsave(&imap->lock, flags); 659 /* Disable interrupt */
660 msi = irq_get_msi_desc(irq);
661 if (!msi)
662 return;
663 zpci_msi_set_mask_bits(msi, 1, 1);
664 imap = zpci_imap[dev_nr];
679 imap->cb[msi_nr].handler = NULL; 665 imap->cb[msi_nr].handler = NULL;
680 imap->cb[msi_nr].data = NULL; 666 imap->cb[msi_nr].data = NULL;
681 spin_unlock_irqrestore(&imap->lock, flags); 667 synchronize_rcu();
682} 668}
683 669
684int request_irq(unsigned int irq, irq_handler_t handler, 670int request_irq(unsigned int irq, irq_handler_t handler,
685 unsigned long irqflags, const char *devname, void *dev_id) 671 unsigned long irqflags, const char *devname, void *dev_id)
686{ 672{
687 pr_debug("%s: irq: %d handler: %p flags: %lx dev: %s\n",
688 __func__, irq, handler, irqflags, devname);
689
690 return zpci_request_irq(irq, handler, dev_id); 673 return zpci_request_irq(irq, handler, dev_id);
691} 674}
692EXPORT_SYMBOL_GPL(request_irq); 675EXPORT_SYMBOL_GPL(request_irq);
@@ -699,52 +682,32 @@ EXPORT_SYMBOL_GPL(free_irq);
699 682
700static int __init zpci_irq_init(void) 683static int __init zpci_irq_init(void)
701{ 684{
702 int cpu, rc; 685 int rc;
703
704 bucket = kzalloc(sizeof(*bucket), GFP_KERNEL);
705 if (!bucket)
706 return -ENOMEM;
707
708 bucket->aisb = (unsigned long *) get_zeroed_page(GFP_KERNEL);
709 if (!bucket->aisb) {
710 rc = -ENOMEM;
711 goto out_aisb;
712 }
713
714 bucket->alloc = (unsigned long *) get_zeroed_page(GFP_KERNEL);
715 if (!bucket->alloc) {
716 rc = -ENOMEM;
717 goto out_alloc;
718 }
719 686
720 rc = register_adapter_interrupt(&zpci_airq); 687 rc = register_adapter_interrupt(&zpci_airq);
721 if (rc) 688 if (rc)
722 goto out_ai; 689 goto out;
723 /* Set summary to 1 to be called every time for the ISC. */ 690 /* Set summary to 1 to be called every time for the ISC. */
724 *zpci_airq.lsi_ptr = 1; 691 *zpci_airq.lsi_ptr = 1;
725 692
726 for_each_online_cpu(cpu) 693 rc = -ENOMEM;
727 per_cpu(next_sbit, cpu) = 0; 694 zpci_aisb_iv = airq_iv_create(ZPCI_NR_DEVICES, AIRQ_IV_ALLOC);
695 if (!zpci_aisb_iv)
696 goto out_airq;
728 697
729 spin_lock_init(&bucket->lock);
730 zpci_set_irq_ctrl(SIC_IRQ_MODE_SINGLE, NULL, PCI_ISC); 698 zpci_set_irq_ctrl(SIC_IRQ_MODE_SINGLE, NULL, PCI_ISC);
731 return 0; 699 return 0;
732 700
733out_ai: 701out_airq:
734 free_page((unsigned long) bucket->alloc); 702 unregister_adapter_interrupt(&zpci_airq);
735out_alloc: 703out:
736 free_page((unsigned long) bucket->aisb);
737out_aisb:
738 kfree(bucket);
739 return rc; 704 return rc;
740} 705}
741 706
742static void zpci_irq_exit(void) 707static void zpci_irq_exit(void)
743{ 708{
744 free_page((unsigned long) bucket->alloc); 709 airq_iv_release(zpci_aisb_iv);
745 free_page((unsigned long) bucket->aisb);
746 unregister_adapter_interrupt(&zpci_airq); 710 unregister_adapter_interrupt(&zpci_airq);
747 kfree(bucket);
748} 711}
749 712
750static struct resource *zpci_alloc_bus_resource(unsigned long start, unsigned long size, 713static struct resource *zpci_alloc_bus_resource(unsigned long start, unsigned long size,