Skip to content

Commit 4b361b1

Browse files
PCI: j721e: Add config guards for Cadence Host and Endpoint library APIs
Commit under Fixes enabled loadable module support for the driver under the assumption that it shall be the sole user of the Cadence Host and Endpoint library APIs. This assumption guarantees that we won't end up in a case where the driver is built-in and the library support is built as a loadable module. With the introduction of [1], this assumption is no longer valid. The SG2042 driver could be built as a loadable module, implying that the Cadence Host library is also selected as a loadable module. However, the pci-j721e.c driver could be built-in as indicated by CONFIG_PCI_J721E=y due to which the Cadence Endpoint library is built-in. Despite the library drivers being built as specified by their respective consumers, since the 'pci-j721e.c' driver has references to the Cadence Host library APIs as well, we run into a build error as reported at [0]. Fix this by adding config guards as a temporary workaround. The proper fix is to split the 'pci-j721e.c' driver into independent Host and Endpoint drivers as aligned at [2]. [0]: https://lore.kernel.org/r/202511111705.MZ7ls8Hm-lkp@intel.com/ [1]: commit 1c72774 ("PCI: sg2042: Add Sophgo SG2042 PCIe driver") [2]: https://lore.kernel.org/r/37f6f8ce-12b2-44ee-a94c-f21b29c98821@app.fastmail.com/ Fixes: a2790bf ("PCI: j721e: Add support to build as a loadable module") Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202511111705.MZ7ls8Hm-lkp@intel.com/ Suggested-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com> Signed-off-by: Manivannan Sadhasivam <mani@kernel.org> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20251117113246.1460644-1-s-vadapalli@ti.com
1 parent 8f0b4cc commit 4b361b1

1 file changed

Lines changed: 25 additions & 16 deletions

File tree

drivers/pci/controller/cadence/pci-j721e.c

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -620,9 +620,11 @@ static int j721e_pcie_probe(struct platform_device *pdev)
620620
gpiod_set_value_cansleep(pcie->reset_gpio, 1);
621621
}
622622

623-
ret = cdns_pcie_host_setup(rc);
624-
if (ret < 0)
625-
goto err_pcie_setup;
623+
if (IS_ENABLED(CONFIG_PCI_J721E_HOST)) {
624+
ret = cdns_pcie_host_setup(rc);
625+
if (ret < 0)
626+
goto err_pcie_setup;
627+
}
626628

627629
break;
628630
case PCI_MODE_EP:
@@ -632,9 +634,11 @@ static int j721e_pcie_probe(struct platform_device *pdev)
632634
goto err_get_sync;
633635
}
634636

635-
ret = cdns_pcie_ep_setup(ep);
636-
if (ret < 0)
637-
goto err_pcie_setup;
637+
if (IS_ENABLED(CONFIG_PCI_J721E_EP)) {
638+
ret = cdns_pcie_ep_setup(ep);
639+
if (ret < 0)
640+
goto err_pcie_setup;
641+
}
638642

639643
break;
640644
}
@@ -659,10 +663,11 @@ static void j721e_pcie_remove(struct platform_device *pdev)
659663
struct cdns_pcie_ep *ep;
660664
struct cdns_pcie_rc *rc;
661665

662-
if (pcie->mode == PCI_MODE_RC) {
666+
if (IS_ENABLED(CONFIG_PCI_J721E_HOST) &&
667+
pcie->mode == PCI_MODE_RC) {
663668
rc = container_of(cdns_pcie, struct cdns_pcie_rc, pcie);
664669
cdns_pcie_host_disable(rc);
665-
} else {
670+
} else if (IS_ENABLED(CONFIG_PCI_J721E_EP)) {
666671
ep = container_of(cdns_pcie, struct cdns_pcie_ep, pcie);
667672
cdns_pcie_ep_disable(ep);
668673
}
@@ -728,10 +733,12 @@ static int j721e_pcie_resume_noirq(struct device *dev)
728733
gpiod_set_value_cansleep(pcie->reset_gpio, 1);
729734
}
730735

731-
ret = cdns_pcie_host_link_setup(rc);
732-
if (ret < 0) {
733-
clk_disable_unprepare(pcie->refclk);
734-
return ret;
736+
if (IS_ENABLED(CONFIG_PCI_J721E_HOST)) {
737+
ret = cdns_pcie_host_link_setup(rc);
738+
if (ret < 0) {
739+
clk_disable_unprepare(pcie->refclk);
740+
return ret;
741+
}
735742
}
736743

737744
/*
@@ -741,10 +748,12 @@ static int j721e_pcie_resume_noirq(struct device *dev)
741748
for (enum cdns_pcie_rp_bar bar = RP_BAR0; bar <= RP_NO_BAR; bar++)
742749
rc->avail_ib_bar[bar] = true;
743750

744-
ret = cdns_pcie_host_init(rc);
745-
if (ret) {
746-
clk_disable_unprepare(pcie->refclk);
747-
return ret;
751+
if (IS_ENABLED(CONFIG_PCI_J721E_HOST)) {
752+
ret = cdns_pcie_host_init(rc);
753+
if (ret) {
754+
clk_disable_unprepare(pcie->refclk);
755+
return ret;
756+
}
748757
}
749758
}
750759

0 commit comments

Comments
 (0)