Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

of/irq: Add support code for multi-parent version of "msi-parent"

Since 126b16e2ad98 ("Docs: dt: add generic MSI bindings"),
the definition of "msi-parent" has evolved, while maintaining
some degree of compatibility. It can now express multiple MSI
controllers as parents, as well as some sideband data being
communicated to the controller.

This patch adds the parsing of the property, iterating over
the multiple parents until a suitable irqdomain is found.
It can also fallback to the original parsing if the old
binding is detected.

This support code gets used in the subsequent patches.

Suggested-by: Robin Murphy <robin.murphy@arm.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>

+68
+59
drivers/of/irq.c
··· 682 682 683 683 return rid_out; 684 684 } 685 + 686 + static struct irq_domain *__of_get_msi_domain(struct device_node *np, 687 + enum irq_domain_bus_token token) 688 + { 689 + struct irq_domain *d; 690 + 691 + d = irq_find_matching_host(np, token); 692 + if (!d) 693 + d = irq_find_host(np); 694 + 695 + return d; 696 + } 697 + 698 + /** 699 + * of_msi_get_domain - Use msi-parent to find the relevant MSI domain 700 + * @dev: device for which the domain is requested 701 + * @np: device node for @dev 702 + * @token: bus type for this domain 703 + * 704 + * Parse the msi-parent property (both the simple and the complex 705 + * versions), and returns the corresponding MSI domain. 706 + * 707 + * Returns: the MSI domain for this device (or NULL on failure). 708 + */ 709 + struct irq_domain *of_msi_get_domain(struct device *dev, 710 + struct device_node *np, 711 + enum irq_domain_bus_token token) 712 + { 713 + struct device_node *msi_np; 714 + struct irq_domain *d; 715 + 716 + /* Check for a single msi-parent property */ 717 + msi_np = of_parse_phandle(np, "msi-parent", 0); 718 + if (msi_np && !of_property_read_bool(msi_np, "#msi-cells")) { 719 + d = __of_get_msi_domain(msi_np, token); 720 + if (!d) 721 + of_node_put(msi_np); 722 + return d; 723 + } 724 + 725 + if (token == DOMAIN_BUS_PLATFORM_MSI) { 726 + /* Check for the complex msi-parent version */ 727 + struct of_phandle_args args; 728 + int index = 0; 729 + 730 + while (!of_parse_phandle_with_args(np, "msi-parent", 731 + "#msi-cells", 732 + index, &args)) { 733 + d = __of_get_msi_domain(args.np, token); 734 + if (d) 735 + return d; 736 + 737 + of_node_put(args.np); 738 + index++; 739 + } 740 + } 741 + 742 + return NULL; 743 + }
+9
include/linux/of_irq.h
··· 46 46 extern int of_irq_get_byname(struct device_node *dev, const char *name); 47 47 extern int of_irq_to_resource_table(struct device_node *dev, 48 48 struct resource *res, int nr_irqs); 49 + extern struct irq_domain *of_msi_get_domain(struct device *dev, 50 + struct device_node *np, 51 + enum irq_domain_bus_token token); 49 52 #else 50 53 static inline int of_irq_count(struct device_node *dev) 51 54 { ··· 66 63 struct resource *res, int nr_irqs) 67 64 { 68 65 return 0; 66 + } 67 + static inline struct irq_domain *of_msi_get_domain(struct device *dev, 68 + struct device_node *np, 69 + enum irq_domain_bus_token token) 70 + { 71 + return NULL; 69 72 } 70 73 #endif 71 74