.. | .. |
---|
25 | 25 | |
---|
26 | 26 | static struct irq_domain *irq_default_domain; |
---|
27 | 27 | |
---|
| 28 | +static int irq_domain_alloc_irqs_locked(struct irq_domain *domain, int irq_base, |
---|
| 29 | + unsigned int nr_irqs, int node, void *arg, |
---|
| 30 | + bool realloc, const struct irq_affinity_desc *affinity); |
---|
28 | 31 | static void irq_domain_check_hierarchy(struct irq_domain *domain); |
---|
29 | 32 | |
---|
30 | 33 | struct irqchip_fwid { |
---|
.. | .. |
---|
53 | 56 | * @name: Optional user provided domain name |
---|
54 | 57 | * @pa: Optional user-provided physical address |
---|
55 | 58 | * |
---|
56 | | - * Allocate a struct irqchip_fwid, and return a poiner to the embedded |
---|
| 59 | + * Allocate a struct irqchip_fwid, and return a pointer to the embedded |
---|
57 | 60 | * fwnode_handle (or NULL on failure). |
---|
58 | 61 | * |
---|
59 | 62 | * Note: The types IRQCHIP_FWNODE_NAMED and IRQCHIP_FWNODE_NAMED_ID are |
---|
.. | .. |
---|
114 | 117 | } |
---|
115 | 118 | EXPORT_SYMBOL_GPL(irq_domain_free_fwnode); |
---|
116 | 119 | |
---|
117 | | -/** |
---|
118 | | - * __irq_domain_add() - Allocate a new irq_domain data structure |
---|
119 | | - * @fwnode: firmware node for the interrupt controller |
---|
120 | | - * @size: Size of linear map; 0 for radix mapping only |
---|
121 | | - * @hwirq_max: Maximum number of interrupts supported by controller |
---|
122 | | - * @direct_max: Maximum value of direct maps; Use ~0 for no limit; 0 for no |
---|
123 | | - * direct mapping |
---|
124 | | - * @ops: domain callbacks |
---|
125 | | - * @host_data: Controller private data pointer |
---|
126 | | - * |
---|
127 | | - * Allocates and initializes an irq_domain structure. |
---|
128 | | - * Returns pointer to IRQ domain, or NULL on failure. |
---|
129 | | - */ |
---|
130 | | -struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, int size, |
---|
131 | | - irq_hw_number_t hwirq_max, int direct_max, |
---|
132 | | - const struct irq_domain_ops *ops, |
---|
133 | | - void *host_data) |
---|
| 120 | +static struct irq_domain *__irq_domain_create(struct fwnode_handle *fwnode, |
---|
| 121 | + unsigned int size, |
---|
| 122 | + irq_hw_number_t hwirq_max, |
---|
| 123 | + int direct_max, |
---|
| 124 | + const struct irq_domain_ops *ops, |
---|
| 125 | + void *host_data) |
---|
134 | 126 | { |
---|
135 | 127 | struct irqchip_fwid *fwid; |
---|
136 | 128 | struct irq_domain *domain; |
---|
.. | .. |
---|
208 | 200 | domain->revmap_direct_max_irq = direct_max; |
---|
209 | 201 | irq_domain_check_hierarchy(domain); |
---|
210 | 202 | |
---|
| 203 | + return domain; |
---|
| 204 | +} |
---|
| 205 | + |
---|
| 206 | +static void __irq_domain_publish(struct irq_domain *domain) |
---|
| 207 | +{ |
---|
211 | 208 | mutex_lock(&irq_domain_mutex); |
---|
212 | 209 | debugfs_add_domain_dir(domain); |
---|
213 | 210 | list_add(&domain->link, &irq_domain_list); |
---|
214 | 211 | mutex_unlock(&irq_domain_mutex); |
---|
215 | 212 | |
---|
216 | 213 | pr_debug("Added domain %s\n", domain->name); |
---|
| 214 | +} |
---|
| 215 | + |
---|
| 216 | +/** |
---|
| 217 | + * __irq_domain_add() - Allocate a new irq_domain data structure |
---|
| 218 | + * @fwnode: firmware node for the interrupt controller |
---|
| 219 | + * @size: Size of linear map; 0 for radix mapping only |
---|
| 220 | + * @hwirq_max: Maximum number of interrupts supported by controller |
---|
| 221 | + * @direct_max: Maximum value of direct maps; Use ~0 for no limit; 0 for no |
---|
| 222 | + * direct mapping |
---|
| 223 | + * @ops: domain callbacks |
---|
| 224 | + * @host_data: Controller private data pointer |
---|
| 225 | + * |
---|
| 226 | + * Allocates and initializes an irq_domain structure. |
---|
| 227 | + * Returns pointer to IRQ domain, or NULL on failure. |
---|
| 228 | + */ |
---|
| 229 | +struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, unsigned int size, |
---|
| 230 | + irq_hw_number_t hwirq_max, int direct_max, |
---|
| 231 | + const struct irq_domain_ops *ops, |
---|
| 232 | + void *host_data) |
---|
| 233 | +{ |
---|
| 234 | + struct irq_domain *domain; |
---|
| 235 | + |
---|
| 236 | + domain = __irq_domain_create(fwnode, size, hwirq_max, direct_max, |
---|
| 237 | + ops, host_data); |
---|
| 238 | + if (domain) |
---|
| 239 | + __irq_domain_publish(domain); |
---|
| 240 | + |
---|
217 | 241 | return domain; |
---|
218 | 242 | } |
---|
219 | 243 | EXPORT_SYMBOL_GPL(__irq_domain_add); |
---|
.. | .. |
---|
497 | 521 | return; |
---|
498 | 522 | |
---|
499 | 523 | hwirq = irq_data->hwirq; |
---|
| 524 | + |
---|
| 525 | + mutex_lock(&irq_domain_mutex); |
---|
| 526 | + |
---|
500 | 527 | irq_set_status_flags(irq, IRQ_NOREQUEST); |
---|
501 | 528 | |
---|
502 | 529 | /* remove chip and handler */ |
---|
.. | .. |
---|
516 | 543 | |
---|
517 | 544 | /* Clear reverse map for this hwirq */ |
---|
518 | 545 | irq_domain_clear_mapping(domain, hwirq); |
---|
| 546 | + |
---|
| 547 | + mutex_unlock(&irq_domain_mutex); |
---|
519 | 548 | } |
---|
520 | 549 | |
---|
521 | | -int irq_domain_associate(struct irq_domain *domain, unsigned int virq, |
---|
522 | | - irq_hw_number_t hwirq) |
---|
| 550 | +static int irq_domain_associate_locked(struct irq_domain *domain, unsigned int virq, |
---|
| 551 | + irq_hw_number_t hwirq) |
---|
523 | 552 | { |
---|
524 | 553 | struct irq_data *irq_data = irq_get_irq_data(virq); |
---|
525 | 554 | int ret; |
---|
.. | .. |
---|
532 | 561 | if (WARN(irq_data->domain, "error: virq%i is already associated", virq)) |
---|
533 | 562 | return -EINVAL; |
---|
534 | 563 | |
---|
535 | | - mutex_lock(&irq_domain_mutex); |
---|
536 | 564 | irq_data->hwirq = hwirq; |
---|
537 | 565 | irq_data->domain = domain; |
---|
538 | 566 | if (domain->ops->map) { |
---|
.. | .. |
---|
549 | 577 | } |
---|
550 | 578 | irq_data->domain = NULL; |
---|
551 | 579 | irq_data->hwirq = 0; |
---|
552 | | - mutex_unlock(&irq_domain_mutex); |
---|
553 | 580 | return ret; |
---|
554 | 581 | } |
---|
555 | 582 | |
---|
.. | .. |
---|
560 | 587 | |
---|
561 | 588 | domain->mapcount++; |
---|
562 | 589 | irq_domain_set_mapping(domain, hwirq, irq_data); |
---|
563 | | - mutex_unlock(&irq_domain_mutex); |
---|
564 | 590 | |
---|
565 | 591 | irq_clear_status_flags(virq, IRQ_NOREQUEST); |
---|
566 | 592 | |
---|
567 | 593 | return 0; |
---|
| 594 | +} |
---|
| 595 | + |
---|
| 596 | +int irq_domain_associate(struct irq_domain *domain, unsigned int virq, |
---|
| 597 | + irq_hw_number_t hwirq) |
---|
| 598 | +{ |
---|
| 599 | + int ret; |
---|
| 600 | + |
---|
| 601 | + mutex_lock(&irq_domain_mutex); |
---|
| 602 | + ret = irq_domain_associate_locked(domain, virq, hwirq); |
---|
| 603 | + mutex_unlock(&irq_domain_mutex); |
---|
| 604 | + |
---|
| 605 | + return ret; |
---|
568 | 606 | } |
---|
569 | 607 | EXPORT_SYMBOL_GPL(irq_domain_associate); |
---|
570 | 608 | |
---|
.. | .. |
---|
625 | 663 | } |
---|
626 | 664 | EXPORT_SYMBOL_GPL(irq_create_direct_mapping); |
---|
627 | 665 | |
---|
| 666 | +static unsigned int irq_create_mapping_affinity_locked(struct irq_domain *domain, |
---|
| 667 | + irq_hw_number_t hwirq, |
---|
| 668 | + const struct irq_affinity_desc *affinity) |
---|
| 669 | +{ |
---|
| 670 | + struct device_node *of_node = irq_domain_get_of_node(domain); |
---|
| 671 | + int virq; |
---|
| 672 | + |
---|
| 673 | + pr_debug("irq_create_mapping(0x%p, 0x%lx)\n", domain, hwirq); |
---|
| 674 | + |
---|
| 675 | + /* Allocate a virtual interrupt number */ |
---|
| 676 | + virq = irq_domain_alloc_descs(-1, 1, hwirq, of_node_to_nid(of_node), |
---|
| 677 | + affinity); |
---|
| 678 | + if (virq <= 0) { |
---|
| 679 | + pr_debug("-> virq allocation failed\n"); |
---|
| 680 | + return 0; |
---|
| 681 | + } |
---|
| 682 | + |
---|
| 683 | + if (irq_domain_associate_locked(domain, virq, hwirq)) { |
---|
| 684 | + irq_free_desc(virq); |
---|
| 685 | + return 0; |
---|
| 686 | + } |
---|
| 687 | + |
---|
| 688 | + pr_debug("irq %lu on domain %s mapped to virtual irq %u\n", |
---|
| 689 | + hwirq, of_node_full_name(of_node), virq); |
---|
| 690 | + |
---|
| 691 | + return virq; |
---|
| 692 | +} |
---|
| 693 | + |
---|
628 | 694 | /** |
---|
629 | 695 | * irq_create_mapping_affinity() - Map a hardware interrupt into linux irq space |
---|
630 | 696 | * @domain: domain owning this hardware interrupt or NULL for default domain |
---|
.. | .. |
---|
637 | 703 | * on the number returned from that call. |
---|
638 | 704 | */ |
---|
639 | 705 | unsigned int irq_create_mapping_affinity(struct irq_domain *domain, |
---|
640 | | - irq_hw_number_t hwirq, |
---|
641 | | - const struct irq_affinity_desc *affinity) |
---|
| 706 | + irq_hw_number_t hwirq, |
---|
| 707 | + const struct irq_affinity_desc *affinity) |
---|
642 | 708 | { |
---|
643 | | - struct device_node *of_node; |
---|
644 | 709 | int virq; |
---|
645 | 710 | |
---|
646 | | - pr_debug("irq_create_mapping(0x%p, 0x%lx)\n", domain, hwirq); |
---|
647 | | - |
---|
648 | | - /* Look for default domain if nececssary */ |
---|
| 711 | + /* Look for default domain if necessary */ |
---|
649 | 712 | if (domain == NULL) |
---|
650 | 713 | domain = irq_default_domain; |
---|
651 | 714 | if (domain == NULL) { |
---|
652 | 715 | WARN(1, "%s(, %lx) called with NULL domain\n", __func__, hwirq); |
---|
653 | 716 | return 0; |
---|
654 | 717 | } |
---|
655 | | - pr_debug("-> using domain @%p\n", domain); |
---|
656 | 718 | |
---|
657 | | - of_node = irq_domain_get_of_node(domain); |
---|
| 719 | + mutex_lock(&irq_domain_mutex); |
---|
658 | 720 | |
---|
659 | 721 | /* Check if mapping already exists */ |
---|
660 | 722 | virq = irq_find_mapping(domain, hwirq); |
---|
661 | 723 | if (virq) { |
---|
662 | | - pr_debug("-> existing mapping on virq %d\n", virq); |
---|
663 | | - return virq; |
---|
| 724 | + pr_debug("existing mapping on virq %d\n", virq); |
---|
| 725 | + goto out; |
---|
664 | 726 | } |
---|
665 | 727 | |
---|
666 | | - /* Allocate a virtual interrupt number */ |
---|
667 | | - virq = irq_domain_alloc_descs(-1, 1, hwirq, of_node_to_nid(of_node), |
---|
668 | | - affinity); |
---|
669 | | - if (virq <= 0) { |
---|
670 | | - pr_debug("-> virq allocation failed\n"); |
---|
671 | | - return 0; |
---|
672 | | - } |
---|
673 | | - |
---|
674 | | - if (irq_domain_associate(domain, virq, hwirq)) { |
---|
675 | | - irq_free_desc(virq); |
---|
676 | | - return 0; |
---|
677 | | - } |
---|
678 | | - |
---|
679 | | - pr_debug("irq %lu on domain %s mapped to virtual irq %u\n", |
---|
680 | | - hwirq, of_node_full_name(of_node), virq); |
---|
| 728 | + virq = irq_create_mapping_affinity_locked(domain, hwirq, affinity); |
---|
| 729 | +out: |
---|
| 730 | + mutex_unlock(&irq_domain_mutex); |
---|
681 | 731 | |
---|
682 | 732 | return virq; |
---|
683 | 733 | } |
---|
.. | .. |
---|
781 | 831 | if (WARN_ON(type & ~IRQ_TYPE_SENSE_MASK)) |
---|
782 | 832 | type &= IRQ_TYPE_SENSE_MASK; |
---|
783 | 833 | |
---|
| 834 | + mutex_lock(&irq_domain_mutex); |
---|
| 835 | + |
---|
784 | 836 | /* |
---|
785 | 837 | * If we've already configured this interrupt, |
---|
786 | 838 | * don't do it again, or hell will break loose. |
---|
.. | .. |
---|
793 | 845 | * interrupt number. |
---|
794 | 846 | */ |
---|
795 | 847 | if (type == IRQ_TYPE_NONE || type == irq_get_trigger_type(virq)) |
---|
796 | | - return virq; |
---|
| 848 | + goto out; |
---|
797 | 849 | |
---|
798 | 850 | /* |
---|
799 | 851 | * If the trigger type has not been set yet, then set |
---|
.. | .. |
---|
801 | 853 | */ |
---|
802 | 854 | if (irq_get_trigger_type(virq) == IRQ_TYPE_NONE) { |
---|
803 | 855 | irq_data = irq_get_irq_data(virq); |
---|
804 | | - if (!irq_data) |
---|
805 | | - return 0; |
---|
| 856 | + if (!irq_data) { |
---|
| 857 | + virq = 0; |
---|
| 858 | + goto out; |
---|
| 859 | + } |
---|
806 | 860 | |
---|
807 | 861 | irqd_set_trigger_type(irq_data, type); |
---|
808 | | - return virq; |
---|
| 862 | + goto out; |
---|
809 | 863 | } |
---|
810 | 864 | |
---|
811 | 865 | pr_warn("type mismatch, failed to map hwirq-%lu for %s!\n", |
---|
812 | 866 | hwirq, of_node_full_name(to_of_node(fwspec->fwnode))); |
---|
813 | | - return 0; |
---|
| 867 | + virq = 0; |
---|
| 868 | + goto out; |
---|
814 | 869 | } |
---|
815 | 870 | |
---|
816 | 871 | if (irq_domain_is_hierarchy(domain)) { |
---|
817 | | - virq = irq_domain_alloc_irqs(domain, 1, NUMA_NO_NODE, fwspec); |
---|
818 | | - if (virq <= 0) |
---|
819 | | - return 0; |
---|
| 872 | + virq = irq_domain_alloc_irqs_locked(domain, -1, 1, NUMA_NO_NODE, |
---|
| 873 | + fwspec, false, NULL); |
---|
| 874 | + if (virq <= 0) { |
---|
| 875 | + virq = 0; |
---|
| 876 | + goto out; |
---|
| 877 | + } |
---|
820 | 878 | } else { |
---|
821 | 879 | /* Create mapping */ |
---|
822 | | - virq = irq_create_mapping(domain, hwirq); |
---|
| 880 | + virq = irq_create_mapping_affinity_locked(domain, hwirq, NULL); |
---|
823 | 881 | if (!virq) |
---|
824 | | - return virq; |
---|
| 882 | + goto out; |
---|
825 | 883 | } |
---|
826 | 884 | |
---|
827 | 885 | irq_data = irq_get_irq_data(virq); |
---|
828 | | - if (!irq_data) { |
---|
829 | | - if (irq_domain_is_hierarchy(domain)) |
---|
830 | | - irq_domain_free_irqs(virq, 1); |
---|
831 | | - else |
---|
832 | | - irq_dispose_mapping(virq); |
---|
833 | | - return 0; |
---|
| 886 | + if (WARN_ON(!irq_data)) { |
---|
| 887 | + virq = 0; |
---|
| 888 | + goto out; |
---|
834 | 889 | } |
---|
835 | 890 | |
---|
836 | 891 | /* Store trigger type */ |
---|
837 | 892 | irqd_set_trigger_type(irq_data, type); |
---|
| 893 | +out: |
---|
| 894 | + mutex_unlock(&irq_domain_mutex); |
---|
838 | 895 | |
---|
839 | 896 | return virq; |
---|
840 | 897 | } |
---|
.. | .. |
---|
886 | 943 | { |
---|
887 | 944 | struct irq_data *data; |
---|
888 | 945 | |
---|
889 | | - /* Look for default domain if nececssary */ |
---|
| 946 | + /* Look for default domain if necessary */ |
---|
890 | 947 | if (domain == NULL) |
---|
891 | 948 | domain = irq_default_domain; |
---|
892 | 949 | if (domain == NULL) |
---|
.. | .. |
---|
1076 | 1133 | struct irq_domain *domain; |
---|
1077 | 1134 | |
---|
1078 | 1135 | if (size) |
---|
1079 | | - domain = irq_domain_create_linear(fwnode, size, ops, host_data); |
---|
| 1136 | + domain = __irq_domain_create(fwnode, size, size, 0, ops, host_data); |
---|
1080 | 1137 | else |
---|
1081 | | - domain = irq_domain_create_tree(fwnode, ops, host_data); |
---|
| 1138 | + domain = __irq_domain_create(fwnode, 0, ~0, 0, ops, host_data); |
---|
| 1139 | + |
---|
1082 | 1140 | if (domain) { |
---|
1083 | 1141 | domain->parent = parent; |
---|
1084 | 1142 | domain->flags |= flags; |
---|
| 1143 | + |
---|
| 1144 | + __irq_domain_publish(domain); |
---|
1085 | 1145 | } |
---|
1086 | 1146 | |
---|
1087 | 1147 | return domain; |
---|
.. | .. |
---|
1399 | 1459 | return domain->ops->alloc(domain, irq_base, nr_irqs, arg); |
---|
1400 | 1460 | } |
---|
1401 | 1461 | |
---|
1402 | | -/** |
---|
1403 | | - * __irq_domain_alloc_irqs - Allocate IRQs from domain |
---|
1404 | | - * @domain: domain to allocate from |
---|
1405 | | - * @irq_base: allocate specified IRQ number if irq_base >= 0 |
---|
1406 | | - * @nr_irqs: number of IRQs to allocate |
---|
1407 | | - * @node: NUMA node id for memory allocation |
---|
1408 | | - * @arg: domain specific argument |
---|
1409 | | - * @realloc: IRQ descriptors have already been allocated if true |
---|
1410 | | - * @affinity: Optional irq affinity mask for multiqueue devices |
---|
1411 | | - * |
---|
1412 | | - * Allocate IRQ numbers and initialized all data structures to support |
---|
1413 | | - * hierarchy IRQ domains. |
---|
1414 | | - * Parameter @realloc is mainly to support legacy IRQs. |
---|
1415 | | - * Returns error code or allocated IRQ number |
---|
1416 | | - * |
---|
1417 | | - * The whole process to setup an IRQ has been split into two steps. |
---|
1418 | | - * The first step, __irq_domain_alloc_irqs(), is to allocate IRQ |
---|
1419 | | - * descriptor and required hardware resources. The second step, |
---|
1420 | | - * irq_domain_activate_irq(), is to program hardwares with preallocated |
---|
1421 | | - * resources. In this way, it's easier to rollback when failing to |
---|
1422 | | - * allocate resources. |
---|
1423 | | - */ |
---|
1424 | | -int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base, |
---|
1425 | | - unsigned int nr_irqs, int node, void *arg, |
---|
1426 | | - bool realloc, const struct irq_affinity_desc *affinity) |
---|
| 1462 | +static int irq_domain_alloc_irqs_locked(struct irq_domain *domain, int irq_base, |
---|
| 1463 | + unsigned int nr_irqs, int node, void *arg, |
---|
| 1464 | + bool realloc, const struct irq_affinity_desc *affinity) |
---|
1427 | 1465 | { |
---|
1428 | 1466 | int i, ret, virq; |
---|
1429 | | - |
---|
1430 | | - if (domain == NULL) { |
---|
1431 | | - domain = irq_default_domain; |
---|
1432 | | - if (WARN(!domain, "domain is NULL; cannot allocate IRQ\n")) |
---|
1433 | | - return -EINVAL; |
---|
1434 | | - } |
---|
1435 | 1467 | |
---|
1436 | 1468 | if (realloc && irq_base >= 0) { |
---|
1437 | 1469 | virq = irq_base; |
---|
.. | .. |
---|
1451 | 1483 | goto out_free_desc; |
---|
1452 | 1484 | } |
---|
1453 | 1485 | |
---|
1454 | | - mutex_lock(&irq_domain_mutex); |
---|
1455 | 1486 | ret = irq_domain_alloc_irqs_hierarchy(domain, virq, nr_irqs, arg); |
---|
1456 | | - if (ret < 0) { |
---|
1457 | | - mutex_unlock(&irq_domain_mutex); |
---|
| 1487 | + if (ret < 0) |
---|
1458 | 1488 | goto out_free_irq_data; |
---|
1459 | | - } |
---|
1460 | 1489 | |
---|
1461 | 1490 | for (i = 0; i < nr_irqs; i++) { |
---|
1462 | 1491 | ret = irq_domain_trim_hierarchy(virq + i); |
---|
1463 | | - if (ret) { |
---|
1464 | | - mutex_unlock(&irq_domain_mutex); |
---|
| 1492 | + if (ret) |
---|
1465 | 1493 | goto out_free_irq_data; |
---|
1466 | | - } |
---|
1467 | 1494 | } |
---|
1468 | | - |
---|
| 1495 | + |
---|
1469 | 1496 | for (i = 0; i < nr_irqs; i++) |
---|
1470 | 1497 | irq_domain_insert_irq(virq + i); |
---|
1471 | | - mutex_unlock(&irq_domain_mutex); |
---|
1472 | 1498 | |
---|
1473 | 1499 | return virq; |
---|
1474 | 1500 | |
---|
.. | .. |
---|
1476 | 1502 | irq_domain_free_irq_data(virq, nr_irqs); |
---|
1477 | 1503 | out_free_desc: |
---|
1478 | 1504 | irq_free_descs(virq, nr_irqs); |
---|
| 1505 | + return ret; |
---|
| 1506 | +} |
---|
| 1507 | + |
---|
| 1508 | +/** |
---|
| 1509 | + * __irq_domain_alloc_irqs - Allocate IRQs from domain |
---|
| 1510 | + * @domain: domain to allocate from |
---|
| 1511 | + * @irq_base: allocate specified IRQ number if irq_base >= 0 |
---|
| 1512 | + * @nr_irqs: number of IRQs to allocate |
---|
| 1513 | + * @node: NUMA node id for memory allocation |
---|
| 1514 | + * @arg: domain specific argument |
---|
| 1515 | + * @realloc: IRQ descriptors have already been allocated if true |
---|
| 1516 | + * @affinity: Optional irq affinity mask for multiqueue devices |
---|
| 1517 | + * |
---|
| 1518 | + * Allocate IRQ numbers and initialized all data structures to support |
---|
| 1519 | + * hierarchy IRQ domains. |
---|
| 1520 | + * Parameter @realloc is mainly to support legacy IRQs. |
---|
| 1521 | + * Returns error code or allocated IRQ number |
---|
| 1522 | + * |
---|
| 1523 | + * The whole process to setup an IRQ has been split into two steps. |
---|
| 1524 | + * The first step, __irq_domain_alloc_irqs(), is to allocate IRQ |
---|
| 1525 | + * descriptor and required hardware resources. The second step, |
---|
| 1526 | + * irq_domain_activate_irq(), is to program the hardware with preallocated |
---|
| 1527 | + * resources. In this way, it's easier to rollback when failing to |
---|
| 1528 | + * allocate resources. |
---|
| 1529 | + */ |
---|
| 1530 | +int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base, |
---|
| 1531 | + unsigned int nr_irqs, int node, void *arg, |
---|
| 1532 | + bool realloc, const struct irq_affinity_desc *affinity) |
---|
| 1533 | +{ |
---|
| 1534 | + int ret; |
---|
| 1535 | + |
---|
| 1536 | + if (domain == NULL) { |
---|
| 1537 | + domain = irq_default_domain; |
---|
| 1538 | + if (WARN(!domain, "domain is NULL; cannot allocate IRQ\n")) |
---|
| 1539 | + return -EINVAL; |
---|
| 1540 | + } |
---|
| 1541 | + |
---|
| 1542 | + mutex_lock(&irq_domain_mutex); |
---|
| 1543 | + ret = irq_domain_alloc_irqs_locked(domain, irq_base, nr_irqs, node, arg, |
---|
| 1544 | + realloc, affinity); |
---|
| 1545 | + mutex_unlock(&irq_domain_mutex); |
---|
| 1546 | + |
---|
1479 | 1547 | return ret; |
---|
1480 | 1548 | } |
---|
1481 | 1549 | |
---|
.. | .. |
---|
1836 | 1904 | irq_set_handler_data(virq, handler_data); |
---|
1837 | 1905 | } |
---|
1838 | 1906 | |
---|
| 1907 | +static int irq_domain_alloc_irqs_locked(struct irq_domain *domain, int irq_base, |
---|
| 1908 | + unsigned int nr_irqs, int node, void *arg, |
---|
| 1909 | + bool realloc, const struct irq_affinity_desc *affinity) |
---|
| 1910 | +{ |
---|
| 1911 | + return -EINVAL; |
---|
| 1912 | +} |
---|
| 1913 | + |
---|
1839 | 1914 | static void irq_domain_check_hierarchy(struct irq_domain *domain) |
---|
1840 | 1915 | { |
---|
1841 | 1916 | } |
---|