PCI: dwc: Move MSI interrupt setup into DWC common code
authorRob Herring <robh@kernel.org>
Thu, 5 Nov 2020 21:11:51 +0000 (15:11 -0600)
committerLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Thu, 19 Nov 2020 10:51:41 +0000 (10:51 +0000)
Platforms using the built-in DWC MSI controller all have a dedicated
interrupt with "msi" name or at index 0, so let's move setting up the
interrupt to the common DWC code.

spear13xx and dra7xx are the 2 oddballs with muxed interrupts, so
we need to prevent configuring the MSI interrupt by setting msi_irq
to negative.

Link: https://lore.kernel.org/r/20201105211159.1814485-9-robh@kernel.org
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Jingoo Han <jingoohan1@gmail.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: Richard Zhu <hongxing.zhu@nxp.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: Yue Wang <yue.wang@Amlogic.com>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: Jerome Brunet <jbrunet@baylibre.com>
Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Cc: Xiaowei Song <songxiaowei@hisilicon.com>
Cc: Binghui Wang <wangbinghui@hisilicon.com>
Cc: Stanimir Varbanov <svarbanov@mm-sol.com>
Cc: Andy Gross <agross@kernel.org>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Pratyush Anand <pratyush.anand@gmail.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: linux-samsung-soc@vger.kernel.org
Cc: linux-amlogic@lists.infradead.org
Cc: linux-arm-kernel@axis.com
Cc: linux-arm-msm@vger.kernel.org
Cc: linux-tegra@vger.kernel.org
13 files changed:
drivers/pci/controller/dwc/pci-dra7xx.c
drivers/pci/controller/dwc/pci-exynos.c
drivers/pci/controller/dwc/pci-imx6.c
drivers/pci/controller/dwc/pci-meson.c
drivers/pci/controller/dwc/pcie-artpec6.c
drivers/pci/controller/dwc/pcie-designware-host.c
drivers/pci/controller/dwc/pcie-designware-plat.c
drivers/pci/controller/dwc/pcie-histb.c
drivers/pci/controller/dwc/pcie-kirin.c
drivers/pci/controller/dwc/pcie-qcom.c
drivers/pci/controller/dwc/pcie-spear13xx.c
drivers/pci/controller/dwc/pcie-tegra194.c
drivers/pci/controller/dwc/pcie-uniphier.c

index 4d0c35a4aa59864dcf9d21eefbd3af47ca9eb6ba..6b75c68dddb56163b7ddb86025c9cf719f4692b3 100644 (file)
@@ -489,6 +489,9 @@ static int __init dra7xx_add_pcie_port(struct dra7xx_pcie *dra7xx,
        if (pp->irq < 0)
                return pp->irq;
 
+       /* MSI IRQ is muxed */
+       pp->msi_irq = -ENODEV;
+
        ret = dra7xx_pcie_init_irq_domain(pp);
        if (ret < 0)
                return ret;
index 242683cde04a5d62e7b19121fea1ed52daadd6c4..7734394953e579549f8b0874c61fc08fe136b387 100644 (file)
@@ -415,12 +415,6 @@ static int __init exynos_add_pcie_port(struct exynos_pcie *ep,
                return ret;
        }
 
-       if (IS_ENABLED(CONFIG_PCI_MSI)) {
-               pp->msi_irq = platform_get_irq(pdev, 0);
-               if (pp->msi_irq < 0)
-                       return pp->msi_irq;
-       }
-
        pp->ops = &exynos_pcie_host_ops;
 
        ret = dw_pcie_host_init(pp);
index 5cf1ef12fb9b05f892cfed3aa84db05e99dc7bcd..95e7cf06863dbc5707ba3afe0539c313cb69e678 100644 (file)
@@ -853,12 +853,6 @@ static int imx6_add_pcie_port(struct imx6_pcie *imx6_pcie,
        struct device *dev = &pdev->dev;
        int ret;
 
-       if (IS_ENABLED(CONFIG_PCI_MSI)) {
-               pp->msi_irq = platform_get_irq_byname(pdev, "msi");
-               if (pp->msi_irq < 0)
-                       return pp->msi_irq;
-       }
-
        pp->ops = &imx6_pcie_host_ops;
 
        ret = dw_pcie_host_init(pp);
index 1913dc2c8fa0864d6d266842a18f68f220a69214..10d65b3093e4a2a48d4173c150d153adfbdee8ff 100644 (file)
@@ -405,12 +405,6 @@ static int meson_add_pcie_port(struct meson_pcie *mp,
        struct device *dev = &pdev->dev;
        int ret;
 
-       if (IS_ENABLED(CONFIG_PCI_MSI)) {
-               pp->msi_irq = platform_get_irq(pdev, 0);
-               if (pp->msi_irq < 0)
-                       return pp->msi_irq;
-       }
-
        pp->ops = &meson_pcie_host_ops;
 
        ret = dw_pcie_host_init(pp);
index 52ad7909cd0c0d11259f9f30cf1d43a92ddb75c9..a5239a58cee06018fd35a90dd5bf1560ef2a920f 100644 (file)
@@ -348,12 +348,6 @@ static int artpec6_add_pcie_port(struct artpec6_pcie *artpec6_pcie,
        struct device *dev = pci->dev;
        int ret;
 
-       if (IS_ENABLED(CONFIG_PCI_MSI)) {
-               pp->msi_irq = platform_get_irq_byname(pdev, "msi");
-               if (pp->msi_irq < 0)
-                       return pp->msi_irq;
-       }
-
        pp->ops = &artpec6_pcie_host_ops;
 
        ret = dw_pcie_host_init(pp);
index 1bd6a9762426183a2cbc27337c877813e24862dc..95deef0eaadfe05d446012d2c84b091bf2ca1666 100644 (file)
@@ -373,13 +373,22 @@ int dw_pcie_host_init(struct pcie_port *pp)
                }
 
                if (!pp->ops->msi_host_init) {
+                       if (!pp->msi_irq) {
+                               pp->msi_irq = platform_get_irq_byname_optional(pdev, "msi");
+                               if (pp->msi_irq < 0) {
+                                       pp->msi_irq = platform_get_irq(pdev, 0);
+                                       if (pp->msi_irq < 0)
+                                               return pp->msi_irq;
+                               }
+                       }
+
                        pp->msi_irq_chip = &dw_pci_msi_bottom_irq_chip;
 
                        ret = dw_pcie_allocate_domains(pp);
                        if (ret)
                                return ret;
 
-                       if (pp->msi_irq)
+                       if (pp->msi_irq > 0)
                                irq_set_chained_handler_and_data(pp->msi_irq,
                                                            dw_chained_msi_isr,
                                                            pp);
index 13fede1d41572d2c6a4855db30a494f234caaa80..3da38ac6a87a0ea8bf7e54fe08d43e81e6946279 100644 (file)
@@ -116,12 +116,6 @@ static int dw_plat_add_pcie_port(struct dw_plat_pcie *dw_plat_pcie,
        if (pp->irq < 0)
                return pp->irq;
 
-       if (IS_ENABLED(CONFIG_PCI_MSI)) {
-               pp->msi_irq = platform_get_irq(pdev, 0);
-               if (pp->msi_irq < 0)
-                       return pp->msi_irq;
-       }
-
        pp->num_vectors = MAX_MSI_IRQS;
        pp->ops = &dw_plat_pcie_host_ops;
 
index afc1abbe49aa9e9526cfec6bddf10c4e6021458e..777e24902afbf08fba89a0812abfe3966e0b0224 100644 (file)
@@ -400,12 +400,6 @@ static int histb_pcie_probe(struct platform_device *pdev)
                return PTR_ERR(hipcie->bus_reset);
        }
 
-       if (IS_ENABLED(CONFIG_PCI_MSI)) {
-               pp->msi_irq = platform_get_irq_byname(pdev, "msi");
-               if (pp->msi_irq < 0)
-                       return pp->msi_irq;
-       }
-
        hipcie->phy = devm_phy_get(dev, "phy");
        if (IS_ERR(hipcie->phy)) {
                dev_info(dev, "no pcie-phy found\n");
index 3042a23cf09a46d7ab77f22eb6c8051f7251c87b..ba03dbca7885e7b77c7bfe65dbc87992f60d3880 100644 (file)
@@ -439,31 +439,9 @@ static const struct dw_pcie_host_ops kirin_pcie_host_ops = {
        .host_init = kirin_pcie_host_init,
 };
 
-static int kirin_pcie_add_msi(struct dw_pcie *pci,
-                               struct platform_device *pdev)
-{
-       int irq;
-
-       if (IS_ENABLED(CONFIG_PCI_MSI)) {
-               irq = platform_get_irq(pdev, 0);
-               if (irq < 0)
-                       return irq;
-
-               pci->pp.msi_irq = irq;
-       }
-
-       return 0;
-}
-
 static int kirin_add_pcie_port(struct dw_pcie *pci,
                               struct platform_device *pdev)
 {
-       int ret;
-
-       ret = kirin_pcie_add_msi(pci, pdev);
-       if (ret)
-               return ret;
-
        pci->pp.ops = &kirin_pcie_host_ops;
 
        return dw_pcie_host_init(&pci->pp);
index 3b4f70b9f3f0cb1a2e5101fc09f28effd684f964..7ac08f0cae17d101b853efa0121133a9198618e5 100644 (file)
@@ -1424,14 +1424,6 @@ static int qcom_pcie_probe(struct platform_device *pdev)
 
        pp->ops = &qcom_pcie_dw_ops;
 
-       if (IS_ENABLED(CONFIG_PCI_MSI)) {
-               pp->msi_irq = platform_get_irq_byname(pdev, "msi");
-               if (pp->msi_irq < 0) {
-                       ret = pp->msi_irq;
-                       goto err_pm_runtime_put;
-               }
-       }
-
        ret = phy_init(pcie->phy);
        if (ret) {
                pm_runtime_disable(&pdev->dev);
index 1ed7e3501ff1cc56bc2eacbd1a987df215e5dcf2..800c34a60a33459ba75a8dc3ef7ce1f67e5157ad 100644 (file)
@@ -185,6 +185,7 @@ static int spear13xx_add_pcie_port(struct spear13xx_pcie *spear13xx_pcie,
        }
 
        pp->ops = &spear13xx_pcie_host_ops;
+       pp->msi_irq = -ENODEV;
 
        ret = dw_pcie_host_init(pp);
        if (ret) {
index 5e2841f58700f63a791c4bf5646cdf907ceef7ab..77fc3ba3dec109898a9626127d19f61fa8956914 100644 (file)
@@ -1554,14 +1554,6 @@ static int tegra_pcie_config_rp(struct tegra_pcie_dw *pcie)
        char *name;
        int ret;
 
-       if (IS_ENABLED(CONFIG_PCI_MSI)) {
-               pp->msi_irq = of_irq_get_byname(dev->of_node, "msi");
-               if (!pp->msi_irq) {
-                       dev_err(dev, "Failed to get MSI interrupt\n");
-                       return -ENODEV;
-               }
-       }
-
        pm_runtime_enable(dev);
 
        ret = pm_runtime_get_sync(dev);
index 33130fb4af90df93e571a798141443cffb8d4106..6198bd106b8a71a3204629ac9f56699ead74a4ae 100644 (file)
@@ -341,12 +341,6 @@ static int uniphier_add_pcie_port(struct uniphier_pcie_priv *priv,
 
        pp->ops = &uniphier_pcie_host_ops;
 
-       if (IS_ENABLED(CONFIG_PCI_MSI)) {
-               pp->msi_irq = platform_get_irq_byname(pdev, "msi");
-               if (pp->msi_irq < 0)
-                       return pp->msi_irq;
-       }
-
        ret = dw_pcie_host_init(pp);
        if (ret) {
                dev_err(dev, "Failed to initialize host (%d)\n", ret);