Skip to content

Commit e449cb9

Browse files
covanambjorn-helgaas
authored andcommitted
PCI: mediatek: Switch to msi_create_parent_irq_domain()
Switch to msi_create_parent_irq_domain() from pci_msi_create_irq_domain() which was using legacy MSI domain setup. Signed-off-by: Nam Cao <namcao@linutronix.de> [mani: reworded commit message] Signed-off-by: Manivannan Sadhasivam <mani@kernel.org> [bhelgaas: rebase on dev_fwnode() conversion, drop fwnode local var] Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Link: https://patch.msgid.link/76f6e6ce6021607cd0fdfd79fef7d2eb69d9f361.1750858083.git.namcao@linutronix.de
1 parent 9a35a26 commit e449cb9

2 files changed

Lines changed: 23 additions & 26 deletions

File tree

drivers/pci/controller/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ config PCIE_MEDIATEK
195195
depends on ARCH_AIROHA || ARCH_MEDIATEK || COMPILE_TEST
196196
depends on OF
197197
depends on PCI_MSI
198+
select IRQ_MSI_LIB
198199
help
199200
Say Y here if you want to enable PCIe controller support on
200201
MediaTek SoCs.

drivers/pci/controller/pcie-mediatek.c

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/iopoll.h>
1313
#include <linux/irq.h>
1414
#include <linux/irqchip/chained_irq.h>
15+
#include <linux/irqchip/irq-msi-lib.h>
1516
#include <linux/irqdomain.h>
1617
#include <linux/kernel.h>
1718
#include <linux/mfd/syscon.h>
@@ -180,7 +181,6 @@ struct mtk_pcie_soc {
180181
* @irq: GIC irq
181182
* @irq_domain: legacy INTx IRQ domain
182183
* @inner_domain: inner IRQ domain
183-
* @msi_domain: MSI IRQ domain
184184
* @lock: protect the msi_irq_in_use bitmap
185185
* @msi_irq_in_use: bit map for assigned MSI IRQ
186186
*/
@@ -200,7 +200,6 @@ struct mtk_pcie_port {
200200
int irq;
201201
struct irq_domain *irq_domain;
202202
struct irq_domain *inner_domain;
203-
struct irq_domain *msi_domain;
204203
struct mutex lock;
205204
DECLARE_BITMAP(msi_irq_in_use, MTK_MSI_IRQS_NUM);
206205
};
@@ -470,40 +469,39 @@ static const struct irq_domain_ops msi_domain_ops = {
470469
.free = mtk_pcie_irq_domain_free,
471470
};
472471

473-
static struct irq_chip mtk_msi_irq_chip = {
474-
.name = "MTK PCIe MSI",
475-
.irq_ack = irq_chip_ack_parent,
476-
.irq_mask = pci_msi_mask_irq,
477-
.irq_unmask = pci_msi_unmask_irq,
478-
};
472+
#define MTK_MSI_FLAGS_REQUIRED (MSI_FLAG_USE_DEF_DOM_OPS | \
473+
MSI_FLAG_USE_DEF_CHIP_OPS | \
474+
MSI_FLAG_NO_AFFINITY)
475+
476+
#define MTK_MSI_FLAGS_SUPPORTED (MSI_GENERIC_FLAGS_MASK | \
477+
MSI_FLAG_PCI_MSIX)
479478

480-
static struct msi_domain_info mtk_msi_domain_info = {
481-
.flags = MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS |
482-
MSI_FLAG_NO_AFFINITY | MSI_FLAG_PCI_MSIX,
483-
.chip = &mtk_msi_irq_chip,
479+
static const struct msi_parent_ops mtk_msi_parent_ops = {
480+
.required_flags = MTK_MSI_FLAGS_REQUIRED,
481+
.supported_flags = MTK_MSI_FLAGS_SUPPORTED,
482+
.bus_select_token = DOMAIN_BUS_PCI_MSI,
483+
.chip_flags = MSI_CHIP_FLAG_SET_ACK,
484+
.prefix = "MTK-",
485+
.init_dev_msi_info = msi_lib_init_dev_msi_info,
484486
};
485487

486488
static int mtk_pcie_allocate_msi_domains(struct mtk_pcie_port *port)
487489
{
488-
struct fwnode_handle *fwnode = dev_fwnode(port->pcie->dev);
489-
490490
mutex_init(&port->lock);
491491

492-
port->inner_domain = irq_domain_create_linear(fwnode, MTK_MSI_IRQS_NUM,
493-
&msi_domain_ops, port);
492+
struct irq_domain_info info = {
493+
.fwnode = dev_fwnode(port->pcie->dev),
494+
.ops = &msi_domain_ops,
495+
.host_data = port,
496+
.size = MTK_MSI_IRQS_NUM,
497+
};
498+
499+
port->inner_domain = msi_create_parent_irq_domain(&info, &mtk_msi_parent_ops);
494500
if (!port->inner_domain) {
495501
dev_err(port->pcie->dev, "failed to create IRQ domain\n");
496502
return -ENOMEM;
497503
}
498504

499-
port->msi_domain = pci_msi_create_irq_domain(fwnode, &mtk_msi_domain_info,
500-
port->inner_domain);
501-
if (!port->msi_domain) {
502-
dev_err(port->pcie->dev, "failed to create MSI domain\n");
503-
irq_domain_remove(port->inner_domain);
504-
return -ENOMEM;
505-
}
506-
507505
return 0;
508506
}
509507

@@ -532,8 +530,6 @@ static void mtk_pcie_irq_teardown(struct mtk_pcie *pcie)
532530
irq_domain_remove(port->irq_domain);
533531

534532
if (IS_ENABLED(CONFIG_PCI_MSI)) {
535-
if (port->msi_domain)
536-
irq_domain_remove(port->msi_domain);
537533
if (port->inner_domain)
538534
irq_domain_remove(port->inner_domain);
539535
}

0 commit comments

Comments
 (0)