Skip to content

Commit ad9f0f8

Browse files
author
Myron Stowe
committed
PCI: apple: Convert to MSI parent infrastructure
JIRA: https://issues.redhat.com/browse/RHEL-120705 Upstream Status: 5d627a9 Conflict(s): Checking file drivers/pci/controller/pcie-apple.c: Hunk #2 FAILED at 134. Due to upstream patch not taking into account the former commit 31fccd6e85d7 "PCI: apple: Abstract register offsets via a SoC-specific structure". commit 5d627a9 Author: Marc Zyngier <maz@kernel.org> Date: Tue May 13 18:28:17 2025 +0100 PCI: apple: Convert to MSI parent infrastructure In an effort to move ARM64 away from the legacy MSI setup, convert the Apple PCIe driver to the MSI-parent infrastructure and let each device have its own MSI domain. [ tglx: Moved the struct out of the function call argument ] Signed-off-by: Marc Zyngier <maz@kernel.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Link: https://lore.kernel.org/all/20250513172819.2216709-8-maz@kernel.org Signed-off-by: Myron Stowe <mstowe@redhat.com>
1 parent 8b91f5f commit ad9f0f8

File tree

2 files changed

+24
-46
lines changed

2 files changed

+24
-46
lines changed

drivers/pci/controller/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ config PCIE_APPLE
4444
depends on OF
4545
depends on PCI_MSI
4646
select PCI_HOST_COMMON
47+
select IRQ_MSI_LIB
4748
help
4849
Say Y here if you want to enable PCIe controller support on Apple
4950
system-on-chips, like the Apple M1. This is required for the USB

drivers/pci/controller/pcie-apple.c

Lines changed: 23 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/kernel.h>
2424
#include <linux/iopoll.h>
2525
#include <linux/irqchip/chained_irq.h>
26+
#include <linux/irqchip/irq-msi-lib.h>
2627
#include <linux/irqdomain.h>
2728
#include <linux/list.h>
2829
#include <linux/module.h>
@@ -184,7 +185,6 @@ struct apple_pcie {
184185
struct device *dev;
185186
void __iomem *base;
186187
const struct hw_info *hw;
187-
struct irq_domain *domain;
188188
unsigned long *bitmap;
189189
struct list_head ports;
190190
struct list_head entry;
@@ -219,27 +219,6 @@ static void rmw_clear(u32 clr, void __iomem *addr)
219219
writel_relaxed(readl_relaxed(addr) & ~clr, addr);
220220
}
221221

222-
static void apple_msi_top_irq_mask(struct irq_data *d)
223-
{
224-
pci_msi_mask_irq(d);
225-
irq_chip_mask_parent(d);
226-
}
227-
228-
static void apple_msi_top_irq_unmask(struct irq_data *d)
229-
{
230-
pci_msi_unmask_irq(d);
231-
irq_chip_unmask_parent(d);
232-
}
233-
234-
static struct irq_chip apple_msi_top_chip = {
235-
.name = "PCIe MSI",
236-
.irq_mask = apple_msi_top_irq_mask,
237-
.irq_unmask = apple_msi_top_irq_unmask,
238-
.irq_eoi = irq_chip_eoi_parent,
239-
.irq_set_affinity = irq_chip_set_affinity_parent,
240-
.irq_set_type = irq_chip_set_type_parent,
241-
};
242-
243222
static void apple_msi_compose_msg(struct irq_data *data, struct msi_msg *msg)
244223
{
245224
msg->address_hi = upper_32_bits(DOORBELL_ADDR);
@@ -283,8 +262,7 @@ static int apple_msi_domain_alloc(struct irq_domain *domain, unsigned int virq,
283262

284263
for (i = 0; i < nr_irqs; i++) {
285264
irq_domain_set_hwirq_and_chip(domain, virq + i, hwirq + i,
286-
&apple_msi_bottom_chip,
287-
domain->host_data);
265+
&apple_msi_bottom_chip, pcie);
288266
}
289267

290268
return 0;
@@ -308,12 +286,6 @@ static const struct irq_domain_ops apple_msi_domain_ops = {
308286
.free = apple_msi_domain_free,
309287
};
310288

311-
static struct msi_domain_info apple_msi_info = {
312-
.flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS |
313-
MSI_FLAG_MULTI_PCI_MSI | MSI_FLAG_PCI_MSIX),
314-
.chip = &apple_msi_top_chip,
315-
};
316-
317289
static void apple_port_irq_mask(struct irq_data *data)
318290
{
319291
struct apple_pcie_port *port = irq_data_get_irq_chip_data(data);
@@ -698,11 +670,28 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
698670
return 0;
699671
}
700672

673+
static const struct msi_parent_ops apple_msi_parent_ops = {
674+
.supported_flags = (MSI_GENERIC_FLAGS_MASK |
675+
MSI_FLAG_PCI_MSIX |
676+
MSI_FLAG_MULTI_PCI_MSI),
677+
.required_flags = (MSI_FLAG_USE_DEF_DOM_OPS |
678+
MSI_FLAG_USE_DEF_CHIP_OPS |
679+
MSI_FLAG_PCI_MSI_MASK_PARENT),
680+
.chip_flags = MSI_CHIP_FLAG_SET_EOI,
681+
.bus_select_token = DOMAIN_BUS_PCI_MSI,
682+
.init_dev_msi_info = msi_lib_init_dev_msi_info,
683+
};
684+
701685
static int apple_msi_init(struct apple_pcie *pcie)
702686
{
703687
struct fwnode_handle *fwnode = dev_fwnode(pcie->dev);
688+
struct irq_domain_info info = {
689+
.fwnode = fwnode,
690+
.ops = &apple_msi_domain_ops,
691+
.size = pcie->nvecs,
692+
.host_data = pcie,
693+
};
704694
struct of_phandle_args args = {};
705-
struct irq_domain *parent;
706695
int ret;
707696

708697
ret = of_parse_phandle_with_args(to_of_node(fwnode), "msi-ranges",
@@ -722,28 +711,16 @@ static int apple_msi_init(struct apple_pcie *pcie)
722711
if (!pcie->bitmap)
723712
return -ENOMEM;
724713

725-
parent = irq_find_matching_fwspec(&pcie->fwspec, DOMAIN_BUS_WIRED);
726-
if (!parent) {
714+
info.parent = irq_find_matching_fwspec(&pcie->fwspec, DOMAIN_BUS_WIRED);
715+
if (!info.parent) {
727716
dev_err(pcie->dev, "failed to find parent domain\n");
728717
return -ENXIO;
729718
}
730719

731-
parent = irq_domain_create_hierarchy(parent, 0, pcie->nvecs, fwnode,
732-
&apple_msi_domain_ops, pcie);
733-
if (!parent) {
720+
if (!msi_create_parent_irq_domain(&info, &apple_msi_parent_ops)) {
734721
dev_err(pcie->dev, "failed to create IRQ domain\n");
735722
return -ENOMEM;
736723
}
737-
irq_domain_update_bus_token(parent, DOMAIN_BUS_NEXUS);
738-
739-
pcie->domain = pci_msi_create_irq_domain(fwnode, &apple_msi_info,
740-
parent);
741-
if (!pcie->domain) {
742-
dev_err(pcie->dev, "failed to create MSI domain\n");
743-
irq_domain_remove(parent);
744-
return -ENOMEM;
745-
}
746-
747724
return 0;
748725
}
749726

0 commit comments

Comments
 (0)