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

irqchip/loongson-pch-msi: Switch to MSI parent domains

Remove the global PCI/MSI irqdomain implementation and provide the
required MSI parent functionality by filling in msi_parent_ops, so the
PCI/MSI code can detect the new parent and setup per-device MSI domains.

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Tianyang Zhang <zhangtianyang@loongson.cn>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20240815112608.26925-2-zhangtianyang@loongson.cn

authored by

Huacai Chen and committed by
Thomas Gleixner
0b3af759 e68ac2b4

+24 -35
+1
drivers/irqchip/Kconfig
··· 685 685 depends on PCI 686 686 default MACH_LOONGSON64 687 687 select IRQ_DOMAIN_HIERARCHY 688 + select IRQ_MSI_LIB 688 689 select PCI_MSI 689 690 help 690 691 Support for the Loongson PCH MSI Controller.
+23 -35
drivers/irqchip/irq-loongson-pch-msi.c
··· 15 15 #include <linux/pci.h> 16 16 #include <linux/slab.h> 17 17 18 + #include "irq-msi-lib.h" 19 + 18 20 static int nr_pics; 19 21 20 22 struct pch_msi_data { ··· 28 26 }; 29 27 30 28 static struct fwnode_handle *pch_msi_handle[MAX_IO_PICS]; 31 - 32 - static void pch_msi_mask_msi_irq(struct irq_data *d) 33 - { 34 - pci_msi_mask_irq(d); 35 - irq_chip_mask_parent(d); 36 - } 37 - 38 - static void pch_msi_unmask_msi_irq(struct irq_data *d) 39 - { 40 - irq_chip_unmask_parent(d); 41 - pci_msi_unmask_irq(d); 42 - } 43 - 44 - static struct irq_chip pch_msi_irq_chip = { 45 - .name = "PCH PCI MSI", 46 - .irq_mask = pch_msi_mask_msi_irq, 47 - .irq_unmask = pch_msi_unmask_msi_irq, 48 - .irq_ack = irq_chip_ack_parent, 49 - .irq_set_affinity = irq_chip_set_affinity_parent, 50 - }; 51 29 52 30 static int pch_msi_allocate_hwirq(struct pch_msi_data *priv, int num_req) 53 31 { ··· 66 84 msg->address_lo = lower_32_bits(priv->doorbell); 67 85 msg->data = data->hwirq; 68 86 } 69 - 70 - static struct msi_domain_info pch_msi_domain_info = { 71 - .flags = MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS | 72 - MSI_FLAG_MULTI_PCI_MSI | MSI_FLAG_PCI_MSIX, 73 - .chip = &pch_msi_irq_chip, 74 - }; 75 87 76 88 static struct irq_chip middle_irq_chip = { 77 89 .name = "PCH MSI", ··· 131 155 static const struct irq_domain_ops pch_msi_middle_domain_ops = { 132 156 .alloc = pch_msi_middle_domain_alloc, 133 157 .free = pch_msi_middle_domain_free, 158 + .select = msi_lib_irq_domain_select, 159 + }; 160 + 161 + #define PCH_MSI_FLAGS_REQUIRED (MSI_FLAG_USE_DEF_DOM_OPS | \ 162 + MSI_FLAG_USE_DEF_CHIP_OPS | \ 163 + MSI_FLAG_PCI_MSI_MASK_PARENT) 164 + 165 + #define PCH_MSI_FLAGS_SUPPORTED (MSI_GENERIC_FLAGS_MASK | \ 166 + MSI_FLAG_PCI_MSIX | \ 167 + MSI_FLAG_MULTI_PCI_MSI) 168 + 169 + static struct msi_parent_ops pch_msi_parent_ops = { 170 + .required_flags = PCH_MSI_FLAGS_REQUIRED, 171 + .supported_flags = PCH_MSI_FLAGS_SUPPORTED, 172 + .bus_select_mask = MATCH_PCI_MSI, 173 + .bus_select_token = DOMAIN_BUS_NEXUS, 174 + .prefix = "PCH-", 175 + .init_dev_msi_info = msi_lib_init_dev_msi_info, 134 176 }; 135 177 136 178 static int pch_msi_init_domains(struct pch_msi_data *priv, 137 179 struct irq_domain *parent, 138 180 struct fwnode_handle *domain_handle) 139 181 { 140 - struct irq_domain *middle_domain, *msi_domain; 182 + struct irq_domain *middle_domain; 141 183 142 184 middle_domain = irq_domain_create_hierarchy(parent, 0, priv->num_irqs, 143 185 domain_handle, ··· 168 174 169 175 irq_domain_update_bus_token(middle_domain, DOMAIN_BUS_NEXUS); 170 176 171 - msi_domain = pci_msi_create_irq_domain(domain_handle, 172 - &pch_msi_domain_info, 173 - middle_domain); 174 - if (!msi_domain) { 175 - pr_err("Failed to create PCI MSI domain\n"); 176 - irq_domain_remove(middle_domain); 177 - return -ENOMEM; 178 - } 177 + middle_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT; 178 + middle_domain->msi_parent_ops = &pch_msi_parent_ops; 179 179 180 180 return 0; 181 181 }