Skip to content

Commit 769ce53

Browse files
committed
Merge branch 'pci/controller/msi-parent'
- Use dev_fwnode() instead of of_fwnode_handle() to remove OF dependency in altera (fixes an unused variable), designware-host, mediatek, mediatek-gen3, mobiveil, plda, xilinx, xilinx-dma, xilinx-nwl (Jiri Slaby, Arnd Bergmann) - Convert aardvark, altera, brcmstb, designware-host, iproc, mediatek, mediatek-gen3, mobiveil, plda, rcar-host, vmd, xilinx, xilinx-dma, xilinx-nwl from using pci_msi_create_irq_domain() to using msi_create_parent_irq_domain() instead; this makes the interrupt controller per-PCI device, allows dynamic allocation of vectors after initialization, and allows support of IMS (Nam Cao) - Convert vmd to using lock guards to tidy the code (Nam Cao) * pci/controller/msi-parent: PCI: vmd: Switch to msi_create_parent_irq_domain() PCI: vmd: Convert to lock guards PCI: plda: Switch to msi_create_parent_irq_domain() PCI: xilinx: Switch to msi_create_parent_irq_domain() PCI: xilinx-nwl: Switch to msi_create_parent_irq_domain() PCI: xilinx-xdma: Switch to msi_create_parent_irq_domain() PCI: rcar-host: Switch to msi_create_parent_irq_domain() PCI: mediatek: Switch to msi_create_parent_irq_domain() PCI: mediatek-gen3: Switch to msi_create_parent_irq_domain() PCI: iproc: Switch to msi_create_parent_irq_domain() PCI: brcmstb: Switch to msi_create_parent_irq_domain() PCI: altera-msi: Switch to msi_create_parent_irq_domain() PCI: aardvark: Switch to msi_create_parent_irq_domain() PCI: mobiveil: Switch to msi_create_parent_irq_domain() PCI: dwc: Switch to msi_create_parent_irq_domain() PCI: controller: Use dev_fwnode() instead of of_fwnode_handle()
2 parents 7f837a2 + d7d8ab8 commit 769ce53

22 files changed

+436
-517
lines changed

drivers/pci/controller/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ config PCI_AARDVARK
1313
depends on OF
1414
depends on PCI_MSI
1515
select PCI_BRIDGE_EMUL
16+
select IRQ_MSI_LIB
1617
help
1718
Add support for Aardvark 64bit PCIe Host Controller. This
1819
controller is part of the South Bridge of the Marvel Armada
@@ -29,6 +30,7 @@ config PCIE_ALTERA_MSI
2930
tristate "Altera PCIe MSI feature"
3031
depends on PCIE_ALTERA
3132
depends on PCI_MSI
33+
select IRQ_MSI_LIB
3234
help
3335
Say Y here if you want PCIe MSI support for the Altera FPGA.
3436
This MSI driver supports Altera MSI to GIC controller IP.
@@ -62,6 +64,7 @@ config PCIE_BRCMSTB
6264
BMIPS_GENERIC || COMPILE_TEST
6365
depends on OF
6466
depends on PCI_MSI
67+
select IRQ_MSI_LIB
6568
default ARCH_BRCMSTB || BMIPS_GENERIC
6669
help
6770
Say Y here to enable PCIe host controller support for
@@ -98,6 +101,7 @@ config PCIE_IPROC_MSI
98101
bool "Broadcom iProc PCIe MSI support"
99102
depends on PCIE_IPROC_PLATFORM || PCIE_IPROC_BCMA
100103
depends on PCI_MSI
104+
select IRQ_MSI_LIB
101105
default ARCH_BCM_IPROC
102106
help
103107
Say Y here if you want to enable MSI support for Broadcom's iProc
@@ -152,6 +156,7 @@ config PCI_IXP4XX
152156
config VMD
153157
depends on PCI_MSI && X86_64 && !UML
154158
tristate "Intel Volume Management Device Driver"
159+
select IRQ_MSI_LIB
155160
help
156161
Adds support for the Intel Volume Management Device (VMD). VMD is a
157162
secondary PCI host bridge that allows PCI Express root ports,
@@ -191,6 +196,7 @@ config PCIE_MEDIATEK
191196
depends on ARCH_AIROHA || ARCH_MEDIATEK || COMPILE_TEST
192197
depends on OF
193198
depends on PCI_MSI
199+
select IRQ_MSI_LIB
194200
help
195201
Say Y here if you want to enable PCIe controller support on
196202
MediaTek SoCs.
@@ -199,6 +205,7 @@ config PCIE_MEDIATEK_GEN3
199205
tristate "MediaTek Gen3 PCIe controller"
200206
depends on ARCH_AIROHA || ARCH_MEDIATEK || COMPILE_TEST
201207
depends on PCI_MSI
208+
select IRQ_MSI_LIB
202209
help
203210
Adds support for PCIe Gen3 MAC controller for MediaTek SoCs.
204211
This PCIe controller is compatible with Gen3, Gen2 and Gen1 speed,
@@ -237,6 +244,7 @@ config PCIE_RCAR_HOST
237244
bool "Renesas R-Car PCIe controller (host mode)"
238245
depends on ARCH_RENESAS || COMPILE_TEST
239246
depends on PCI_MSI
247+
select IRQ_MSI_LIB
240248
help
241249
Say Y here if you want PCIe controller support on R-Car SoCs in host
242250
mode.
@@ -315,6 +323,7 @@ config PCIE_XILINX
315323
bool "Xilinx AXI PCIe controller"
316324
depends on OF
317325
depends on PCI_MSI
326+
select IRQ_MSI_LIB
318327
help
319328
Say 'Y' here if you want kernel to support the Xilinx AXI PCIe
320329
Host Bridge driver.
@@ -324,6 +333,7 @@ config PCIE_XILINX_DMA_PL
324333
depends on ARCH_ZYNQMP || COMPILE_TEST
325334
depends on PCI_MSI
326335
select PCI_HOST_COMMON
336+
select IRQ_MSI_LIB
327337
help
328338
Say 'Y' here if you want kernel support for the Xilinx PL DMA
329339
PCIe host bridge. The controller is a Soft IP which can act as
@@ -334,6 +344,7 @@ config PCIE_XILINX_NWL
334344
bool "Xilinx NWL PCIe controller"
335345
depends on ARCH_ZYNQMP || COMPILE_TEST
336346
depends on PCI_MSI
347+
select IRQ_MSI_LIB
337348
help
338349
Say 'Y' here if you want kernel support for Xilinx
339350
NWL PCIe controller. The controller can act as Root Port

drivers/pci/controller/dwc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ config PCIE_DW_DEBUGFS
1919
config PCIE_DW_HOST
2020
bool
2121
select PCIE_DW
22+
select IRQ_MSI_LIB
2223

2324
config PCIE_DW_EP
2425
bool

drivers/pci/controller/dwc/pcie-designware-host.c

Lines changed: 24 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <linux/iopoll.h>
1212
#include <linux/irqchip/chained_irq.h>
13+
#include <linux/irqchip/irq-msi-lib.h>
1314
#include <linux/irqdomain.h>
1415
#include <linux/msi.h>
1516
#include <linux/of_address.h>
@@ -23,35 +24,21 @@
2324
static struct pci_ops dw_pcie_ops;
2425
static struct pci_ops dw_child_pcie_ops;
2526

26-
static void dw_msi_ack_irq(struct irq_data *d)
27-
{
28-
irq_chip_ack_parent(d);
29-
}
30-
31-
static void dw_msi_mask_irq(struct irq_data *d)
32-
{
33-
pci_msi_mask_irq(d);
34-
irq_chip_mask_parent(d);
35-
}
36-
37-
static void dw_msi_unmask_irq(struct irq_data *d)
38-
{
39-
pci_msi_unmask_irq(d);
40-
irq_chip_unmask_parent(d);
41-
}
42-
43-
static struct irq_chip dw_pcie_msi_irq_chip = {
44-
.name = "PCI-MSI",
45-
.irq_ack = dw_msi_ack_irq,
46-
.irq_mask = dw_msi_mask_irq,
47-
.irq_unmask = dw_msi_unmask_irq,
48-
};
49-
50-
static struct msi_domain_info dw_pcie_msi_domain_info = {
51-
.flags = MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS |
52-
MSI_FLAG_NO_AFFINITY | MSI_FLAG_PCI_MSIX |
53-
MSI_FLAG_MULTI_PCI_MSI,
54-
.chip = &dw_pcie_msi_irq_chip,
27+
#define DW_PCIE_MSI_FLAGS_REQUIRED (MSI_FLAG_USE_DEF_DOM_OPS | \
28+
MSI_FLAG_USE_DEF_CHIP_OPS | \
29+
MSI_FLAG_NO_AFFINITY | \
30+
MSI_FLAG_PCI_MSI_MASK_PARENT)
31+
#define DW_PCIE_MSI_FLAGS_SUPPORTED (MSI_FLAG_MULTI_PCI_MSI | \
32+
MSI_FLAG_PCI_MSIX | \
33+
MSI_GENERIC_FLAGS_MASK)
34+
35+
static const struct msi_parent_ops dw_pcie_msi_parent_ops = {
36+
.required_flags = DW_PCIE_MSI_FLAGS_REQUIRED,
37+
.supported_flags = DW_PCIE_MSI_FLAGS_SUPPORTED,
38+
.bus_select_token = DOMAIN_BUS_PCI_MSI,
39+
.chip_flags = MSI_CHIP_FLAG_SET_ACK,
40+
.prefix = "DW-",
41+
.init_dev_msi_info = msi_lib_init_dev_msi_info,
5542
};
5643

5744
/* MSI int handler */
@@ -227,26 +214,19 @@ static const struct irq_domain_ops dw_pcie_msi_domain_ops = {
227214
int dw_pcie_allocate_domains(struct dw_pcie_rp *pp)
228215
{
229216
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
230-
struct fwnode_handle *fwnode = of_fwnode_handle(pci->dev->of_node);
231-
232-
pp->irq_domain = irq_domain_create_linear(fwnode, pp->num_vectors,
233-
&dw_pcie_msi_domain_ops, pp);
217+
struct irq_domain_info info = {
218+
.fwnode = dev_fwnode(pci->dev),
219+
.ops = &dw_pcie_msi_domain_ops,
220+
.size = pp->num_vectors,
221+
.host_data = pp,
222+
};
223+
224+
pp->irq_domain = msi_create_parent_irq_domain(&info, &dw_pcie_msi_parent_ops);
234225
if (!pp->irq_domain) {
235226
dev_err(pci->dev, "Failed to create IRQ domain\n");
236227
return -ENOMEM;
237228
}
238229

239-
irq_domain_update_bus_token(pp->irq_domain, DOMAIN_BUS_NEXUS);
240-
241-
pp->msi_domain = pci_msi_create_irq_domain(fwnode,
242-
&dw_pcie_msi_domain_info,
243-
pp->irq_domain);
244-
if (!pp->msi_domain) {
245-
dev_err(pci->dev, "Failed to create MSI domain\n");
246-
irq_domain_remove(pp->irq_domain);
247-
return -ENOMEM;
248-
}
249-
250230
return 0;
251231
}
252232

@@ -260,7 +240,6 @@ static void dw_pcie_free_msi(struct dw_pcie_rp *pp)
260240
NULL, NULL);
261241
}
262242

263-
irq_domain_remove(pp->msi_domain);
264243
irq_domain_remove(pp->irq_domain);
265244
}
266245

drivers/pci/controller/dwc/pcie-designware.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,6 @@ struct dw_pcie_rp {
417417
const struct dw_pcie_host_ops *ops;
418418
int msi_irq[MAX_MSI_CTRLS];
419419
struct irq_domain *irq_domain;
420-
struct irq_domain *msi_domain;
421420
dma_addr_t msi_data;
422421
struct irq_chip *msi_irq_chip;
423422
u32 num_vectors;

drivers/pci/controller/mobiveil/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ config PCIE_MOBIVEIL
99
config PCIE_MOBIVEIL_HOST
1010
bool
1111
depends on PCI_MSI
12+
select IRQ_MSI_LIB
1213
select PCIE_MOBIVEIL
1314

1415
config PCIE_LAYERSCAPE_GEN4

drivers/pci/controller/mobiveil/pcie-mobiveil-host.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/init.h>
1313
#include <linux/interrupt.h>
1414
#include <linux/irq.h>
15+
#include <linux/irqchip/irq-msi-lib.h>
1516
#include <linux/irqchip/chained_irq.h>
1617
#include <linux/irqdomain.h>
1718
#include <linux/kernel.h>
@@ -353,16 +354,19 @@ static const struct irq_domain_ops intx_domain_ops = {
353354
.map = mobiveil_pcie_intx_map,
354355
};
355356

356-
static struct irq_chip mobiveil_msi_irq_chip = {
357-
.name = "Mobiveil PCIe MSI",
358-
.irq_mask = pci_msi_mask_irq,
359-
.irq_unmask = pci_msi_unmask_irq,
360-
};
357+
#define MOBIVEIL_MSI_FLAGS_REQUIRED (MSI_FLAG_USE_DEF_DOM_OPS | \
358+
MSI_FLAG_USE_DEF_CHIP_OPS | \
359+
MSI_FLAG_NO_AFFINITY)
360+
361+
#define MOBIVEIL_MSI_FLAGS_SUPPORTED (MSI_GENERIC_FLAGS_MASK | \
362+
MSI_FLAG_PCI_MSIX)
361363

362-
static struct msi_domain_info mobiveil_msi_domain_info = {
363-
.flags = MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS |
364-
MSI_FLAG_NO_AFFINITY | MSI_FLAG_PCI_MSIX,
365-
.chip = &mobiveil_msi_irq_chip,
364+
static const struct msi_parent_ops mobiveil_msi_parent_ops = {
365+
.required_flags = MOBIVEIL_MSI_FLAGS_REQUIRED,
366+
.supported_flags = MOBIVEIL_MSI_FLAGS_SUPPORTED,
367+
.bus_select_token = DOMAIN_BUS_PCI_MSI,
368+
.prefix = "Mobiveil-",
369+
.init_dev_msi_info = msi_lib_init_dev_msi_info,
366370
};
367371

368372
static void mobiveil_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
@@ -435,23 +439,20 @@ static const struct irq_domain_ops msi_domain_ops = {
435439
static int mobiveil_allocate_msi_domains(struct mobiveil_pcie *pcie)
436440
{
437441
struct device *dev = &pcie->pdev->dev;
438-
struct fwnode_handle *fwnode = of_fwnode_handle(dev->of_node);
439442
struct mobiveil_msi *msi = &pcie->rp.msi;
440443

441444
mutex_init(&msi->lock);
442-
msi->dev_domain = irq_domain_create_linear(NULL, msi->num_of_vectors,
443-
&msi_domain_ops, pcie);
444-
if (!msi->dev_domain) {
445-
dev_err(dev, "failed to create IRQ domain\n");
446-
return -ENOMEM;
447-
}
448445

449-
msi->msi_domain = pci_msi_create_irq_domain(fwnode,
450-
&mobiveil_msi_domain_info,
451-
msi->dev_domain);
452-
if (!msi->msi_domain) {
446+
struct irq_domain_info info = {
447+
.fwnode = dev_fwnode(dev),
448+
.ops = &msi_domain_ops,
449+
.host_data = pcie,
450+
.size = msi->num_of_vectors,
451+
};
452+
453+
msi->dev_domain = msi_create_parent_irq_domain(&info, &mobiveil_msi_parent_ops);
454+
if (!msi->dev_domain) {
453455
dev_err(dev, "failed to create MSI domain\n");
454-
irq_domain_remove(msi->dev_domain);
455456
return -ENOMEM;
456457
}
457458

@@ -464,9 +465,8 @@ static int mobiveil_pcie_init_irq_domain(struct mobiveil_pcie *pcie)
464465
struct mobiveil_root_port *rp = &pcie->rp;
465466

466467
/* setup INTx */
467-
rp->intx_domain = irq_domain_create_linear(of_fwnode_handle(dev->of_node), PCI_NUM_INTX,
468-
&intx_domain_ops, pcie);
469-
468+
rp->intx_domain = irq_domain_create_linear(dev_fwnode(dev), PCI_NUM_INTX, &intx_domain_ops,
469+
pcie);
470470
if (!rp->intx_domain) {
471471
dev_err(dev, "Failed to get a INTx IRQ domain\n");
472472
return -ENOMEM;

drivers/pci/controller/mobiveil/pcie-mobiveil.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@
135135

136136
struct mobiveil_msi { /* MSI information */
137137
struct mutex lock; /* protect bitmap variable */
138-
struct irq_domain *msi_domain;
139138
struct irq_domain *dev_domain;
140139
phys_addr_t msi_pages_phys;
141140
int num_of_vectors;

0 commit comments

Comments
 (0)