Skip to content

Commit 9a35a26

Browse files
covanambjorn-helgaas
authored andcommitted
PCI: mediatek-gen3: 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 & fixed merge conflict] Signed-off-by: Manivannan Sadhasivam <mani@kernel.org> [bhelgaas: rebase on dev_fwnode() conversion] Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Link: https://patch.msgid.link/bfbd2e375269071b69e1aa85e629ee4b7c99518f.1750858083.git.namcao@linutronix.de
1 parent e275e38 commit 9a35a26

2 files changed

Lines changed: 26 additions & 42 deletions

File tree

drivers/pci/controller/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ config PCIE_MEDIATEK_GEN3
203203
tristate "MediaTek Gen3 PCIe controller"
204204
depends on ARCH_AIROHA || ARCH_MEDIATEK || COMPILE_TEST
205205
depends on PCI_MSI
206+
select IRQ_MSI_LIB
206207
help
207208
Adds support for PCIe Gen3 MAC controller for MediaTek SoCs.
208209
This PCIe controller is compatible with Gen3, Gen2 and Gen1 speed,

drivers/pci/controller/pcie-mediatek-gen3.c

Lines changed: 25 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/delay.h>
1313
#include <linux/iopoll.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>
@@ -187,7 +188,6 @@ struct mtk_msi_set {
187188
* @saved_irq_state: IRQ enable state saved at suspend time
188189
* @irq_lock: lock protecting IRQ register access
189190
* @intx_domain: legacy INTx IRQ domain
190-
* @msi_domain: MSI IRQ domain
191191
* @msi_bottom_domain: MSI IRQ bottom domain
192192
* @msi_sets: MSI sets information
193193
* @lock: lock protecting IRQ bit map
@@ -210,7 +210,6 @@ struct mtk_gen3_pcie {
210210
u32 saved_irq_state;
211211
raw_spinlock_t irq_lock;
212212
struct irq_domain *intx_domain;
213-
struct irq_domain *msi_domain;
214213
struct irq_domain *msi_bottom_domain;
215214
struct mtk_msi_set msi_sets[PCIE_MSI_SET_NUM];
216215
struct mutex lock;
@@ -526,30 +525,22 @@ static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie)
526525
return 0;
527526
}
528527

529-
static void mtk_pcie_msi_irq_mask(struct irq_data *data)
530-
{
531-
pci_msi_mask_irq(data);
532-
irq_chip_mask_parent(data);
533-
}
534-
535-
static void mtk_pcie_msi_irq_unmask(struct irq_data *data)
536-
{
537-
pci_msi_unmask_irq(data);
538-
irq_chip_unmask_parent(data);
539-
}
540-
541-
static struct irq_chip mtk_msi_irq_chip = {
542-
.irq_ack = irq_chip_ack_parent,
543-
.irq_mask = mtk_pcie_msi_irq_mask,
544-
.irq_unmask = mtk_pcie_msi_irq_unmask,
545-
.name = "MSI",
546-
};
547-
548-
static struct msi_domain_info mtk_msi_domain_info = {
549-
.flags = MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS |
550-
MSI_FLAG_NO_AFFINITY | MSI_FLAG_PCI_MSIX |
551-
MSI_FLAG_MULTI_PCI_MSI,
552-
.chip = &mtk_msi_irq_chip,
528+
#define MTK_MSI_FLAGS_REQUIRED (MSI_FLAG_USE_DEF_DOM_OPS | \
529+
MSI_FLAG_USE_DEF_CHIP_OPS | \
530+
MSI_FLAG_NO_AFFINITY | \
531+
MSI_FLAG_PCI_MSI_MASK_PARENT)
532+
533+
#define MTK_MSI_FLAGS_SUPPORTED (MSI_GENERIC_FLAGS_MASK | \
534+
MSI_FLAG_PCI_MSIX | \
535+
MSI_FLAG_MULTI_PCI_MSI)
536+
537+
static const struct msi_parent_ops mtk_msi_parent_ops = {
538+
.required_flags = MTK_MSI_FLAGS_REQUIRED,
539+
.supported_flags = MTK_MSI_FLAGS_SUPPORTED,
540+
.bus_select_token = DOMAIN_BUS_PCI_MSI,
541+
.chip_flags = MSI_CHIP_FLAG_SET_ACK,
542+
.prefix = "MTK3-",
543+
.init_dev_msi_info = msi_lib_init_dev_msi_info,
553544
};
554545

555546
static void mtk_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
@@ -756,28 +747,23 @@ static int mtk_pcie_init_irq_domains(struct mtk_gen3_pcie *pcie)
756747
/* Setup MSI */
757748
mutex_init(&pcie->lock);
758749

759-
pcie->msi_bottom_domain = irq_domain_create_linear(dev_fwnode(dev), PCIE_MSI_IRQS_NUM,
760-
&mtk_msi_bottom_domain_ops, pcie);
750+
struct irq_domain_info info = {
751+
.fwnode = dev_fwnode(dev),
752+
.ops = &mtk_msi_bottom_domain_ops,
753+
.host_data = pcie,
754+
.size = PCIE_MSI_IRQS_NUM,
755+
};
756+
757+
pcie->msi_bottom_domain = msi_create_parent_irq_domain(&info, &mtk_msi_parent_ops);
761758
if (!pcie->msi_bottom_domain) {
762759
dev_err(dev, "failed to create MSI bottom domain\n");
763760
ret = -ENODEV;
764761
goto err_msi_bottom_domain;
765762
}
766763

767-
pcie->msi_domain = pci_msi_create_irq_domain(dev->fwnode,
768-
&mtk_msi_domain_info,
769-
pcie->msi_bottom_domain);
770-
if (!pcie->msi_domain) {
771-
dev_err(dev, "failed to create MSI domain\n");
772-
ret = -ENODEV;
773-
goto err_msi_domain;
774-
}
775-
776764
of_node_put(intc_node);
777765
return 0;
778766

779-
err_msi_domain:
780-
irq_domain_remove(pcie->msi_bottom_domain);
781767
err_msi_bottom_domain:
782768
irq_domain_remove(pcie->intx_domain);
783769
out_put_node:
@@ -792,9 +778,6 @@ static void mtk_pcie_irq_teardown(struct mtk_gen3_pcie *pcie)
792778
if (pcie->intx_domain)
793779
irq_domain_remove(pcie->intx_domain);
794780

795-
if (pcie->msi_domain)
796-
irq_domain_remove(pcie->msi_domain);
797-
798781
if (pcie->msi_bottom_domain)
799782
irq_domain_remove(pcie->msi_bottom_domain);
800783

0 commit comments

Comments
 (0)