Skip to contentSkip to conversation

PCI: cadence: fix build-time dependencies

PATCH In review Arnd Bergmann 2 participants 2 messages Dec 4, 2025 – Jan 5

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: cadence: fix build-time dependencies

From: Arnd Bergmann <[email protected]>

The split of the the cadence pcie controller driver into three modules does not match the Kconfig structure, as the common symbol tries to call into the more specific ones. If one is built-in but the other is a loadable module, we get one of these link errors:

arm-linux-gnueabi-ld: drivers/pci/controller/cadence/pcie-cadence-plat.o: in function `cdns_plat_pcie_probe':
pcie-cadence-plat.c:(.text+0x33c): undefined reference to `cdns_pcie_host_setup'
arm-linux-gnueabi-ld: drivers/pci/controller/cadence/pcie-cadence-plat.o: in function `cdns_plat_pcie_probe':
pcie-cadence-plat.c:(.text+0x264): undefined reference to `cdns_pcie_ep_setup'

Move the two parts back into a common module to ensure they can always link, while keeping the optional parts out of possible.

Fixes 611627a4e5e4 ("PCI: cadence: Add module support for platform controller driver")

---
We had discussed this on the list earlier, but I independently ran into the problem while build-testing. This was the version that actually ended up passing randconfig testing for me.

---
 drivers/pci/controller/cadence/Kconfig  | 15 +++++++++------
 drivers/pci/controller/cadence/Makefile | 12 +++++++++---
 2 files changed, 18 insertions(+), 9 deletions(-)
drivers/pci/controller/cadence/Kconfig +9 -6
index 9e651d545973..978ffe9a1da2 100644
@@ -7,16 +7,14 @@ config PCIE_CADENCE
 	tristate
 
 config PCIE_CADENCE_HOST
-	tristate
+	bool
 	depends on OF
 	select IRQ_DOMAIN
-	select PCIE_CADENCE
 
 config PCIE_CADENCE_EP
-	tristate
+	bool
 	depends on OF
 	depends on PCI_ENDPOINT
-	select PCIE_CADENCE
 
 config PCIE_CADENCE_PLAT
 	tristate
@@ -24,6 +22,7 @@ config PCIE_CADENCE_PLAT
 config PCIE_CADENCE_PLAT_HOST
 	tristate "Cadence platform PCIe controller (host mode)"
 	depends on OF
+	select PCIE_CADENCE
 	select PCIE_CADENCE_HOST
 	select PCIE_CADENCE_PLAT
 	help
@@ -35,6 +34,7 @@ config PCIE_CADENCE_PLAT_EP
 	tristate "Cadence platform PCIe controller (endpoint mode)"
 	depends on OF
 	depends on PCI_ENDPOINT
+	select PCIE_CADENCE
 	select PCIE_CADENCE_EP
 	select PCIE_CADENCE_PLAT
 	help
@@ -45,6 +45,7 @@ config PCIE_CADENCE_PLAT_EP
 config PCI_SKY1_HOST
 	tristate "CIX SKY1 PCIe controller (host mode)"
 	depends on OF && (ARCH_CIX || COMPILE_TEST)
+	select PCIE_CADENCE
 	select PCIE_CADENCE_HOST
 	select PCI_ECAM
 	help
@@ -60,6 +61,7 @@ config PCI_SKY1_HOST
 config PCIE_SG2042_HOST
 	tristate "Sophgo SG2042 PCIe controller (host mode)"
 	depends on OF && (ARCH_SOPHGO || COMPILE_TEST)
+	select PCIE_CADENCE
 	select PCIE_CADENCE_HOST
 	help
 	  Say Y here if you want to support the Sophgo SG2042 PCIe platform
@@ -68,14 +70,14 @@ config PCIE_SG2042_HOST
 
 config PCI_J721E
 	tristate
-	select PCIE_CADENCE_HOST if PCI_J721E_HOST != n
-	select PCIE_CADENCE_EP if PCI_J721E_EP != n
+	select PCIE_CADENCE
 
 config PCI_J721E_HOST
 	tristate "TI J721E PCIe controller (host mode)"
 	depends on ARCH_K3 || COMPILE_TEST
 	depends on OF
 	select PCI_J721E
+	select PCIE_CADENCE_HOST
 	help
 	  Say Y here if you want to support the TI J721E PCIe platform
 	  controller in host mode. TI J721E PCIe controller uses Cadence PCIe
@@ -87,6 +89,7 @@ config PCI_J721E_EP
 	depends on OF
 	depends on PCI_ENDPOINT
 	select PCI_J721E
+	select PCIE_CADENCE_EP
 	help
 	  Say Y here if you want to support the TI J721E PCIe platform
 	  controller in endpoint mode. TI J721E PCIe controller uses Cadence PCIe
drivers/pci/controller/cadence/Makefile +9 -3
index b8ec1cecfaa8..139ac0a0de6f 100644
@@ -1,11 +1,17 @@
 # SPDX-License-Identifier: GPL-2.0
 pcie-cadence-mod-y := pcie-cadence-hpa.o pcie-cadence.o
+obj-$(CONFIG_PCIE_CADENCE) = pcie-cadence-mod.o
+
+ifdef CONFIG_PCIE_CADENCE_HOST
 pcie-cadence-host-mod-y := pcie-cadence-host-common.o pcie-cadence-host.o pcie-cadence-host-hpa.o
+obj-$(CONFIG_PCIE_CADENCE) += pcie-cadence-host-mod.o
+endif
+
+ifdef CONFIG_PCIE_CADENCE_EP
 pcie-cadence-ep-mod-y := pcie-cadence-ep.o
+obj-$(CONFIG_PCIE_CADENCE) += pcie-cadence-ep-mod.o
+endif
 
-obj-$(CONFIG_PCIE_CADENCE) = pcie-cadence-mod.o
-obj-$(CONFIG_PCIE_CADENCE_HOST) += pcie-cadence-host-mod.o
-obj-$(CONFIG_PCIE_CADENCE_EP) += pcie-cadence-ep-mod.o
 obj-$(CONFIG_PCIE_CADENCE_PLAT) += pcie-cadence-plat.o
 obj-$(CONFIG_PCI_J721E) += pci-j721e.o
 obj-$(CONFIG_PCIE_SG2042_HOST) += pcie-sg2042.o
Signature · 1 line
2.39.5
#1 lore raw
Quoted 36 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The split of the the cadence pcie controller driver into three modules does not match the Kconfig structure, as the common symbol tries to call into the more specific ones. If one is built-in but the other is a loadable module, we get one of these link errors:

arm-linux-gnueabi-ld: drivers/pci/controller/cadence/pcie-cadence-plat.o: in function `cdns_plat_pcie_probe':
pcie-cadence-plat.c:(.text+0x33c): undefined reference to `cdns_pcie_host_setup'
arm-linux-gnueabi-ld: drivers/pci/controller/cadence/pcie-cadence-plat.o: in function `cdns_plat_pcie_probe':
pcie-cadence-plat.c:(.text+0x264): undefined reference to `cdns_pcie_ep_setup'

Move the two parts back into a common module to ensure they can always link, while keeping the optional parts out of possible.

Fixes 611627a4e5e4 ("PCI: cadence: Add module support for platform controller driver")

---
We had discussed this on the list earlier, but I independently ran into the problem while build-testing. This was the version that actually ended up passing randconfig testing for me.

---
 drivers/pci/controller/cadence/Kconfig  | 15 +++++++++------
 drivers/pci/controller/cadence/Makefile | 12 +++++++++---
 2 files changed, 18 insertions(+), 9 deletions(-)
drivers/pci/controller/cadence/Kconfig +1 -1
index 9e651d545973..978ffe9a1da2 100644
@@ -7,16 +7,14 @@ config PCIE_CADENCE
 	tristate
 
 config PCIE_CADENCE_HOST
-	tristate
+	bool

drivers/pci/controller/cadence/Kconfig config PCIE_CADENCE · line 19

Quoted 10 lines
drivers/pci/controller/cadence/Kconfig +1 -3
 	depends on OF
 	select IRQ_DOMAIN
-	select PCIE_CADENCE
 
 config PCIE_CADENCE_EP
-	tristate
+	bool
 	depends on OF
 	depends on PCI_ENDPOINT
-	select PCIE_CADENCE

Atleast PCIE_CADENCE_EP calls the APIs exported by pcie-cadence.c. So shouldn't this one select PCIE_CADENCE logically?

- Mani

Quoted 88 lines
drivers/pci/controller/cadence/Kconfig +7 -2
 config PCIE_CADENCE_PLAT
 	tristate
@@ -24,6 +22,7 @@ config PCIE_CADENCE_PLAT
 config PCIE_CADENCE_PLAT_HOST
 	tristate "Cadence platform PCIe controller (host mode)"
 	depends on OF
+	select PCIE_CADENCE
 	select PCIE_CADENCE_HOST
 	select PCIE_CADENCE_PLAT
 	help
@@ -35,6 +34,7 @@ config PCIE_CADENCE_PLAT_EP
 	tristate "Cadence platform PCIe controller (endpoint mode)"
 	depends on OF
 	depends on PCI_ENDPOINT
+	select PCIE_CADENCE
 	select PCIE_CADENCE_EP
 	select PCIE_CADENCE_PLAT
 	help
@@ -45,6 +45,7 @@ config PCIE_CADENCE_PLAT_EP
 config PCI_SKY1_HOST
 	tristate "CIX SKY1 PCIe controller (host mode)"
 	depends on OF && (ARCH_CIX || COMPILE_TEST)
+	select PCIE_CADENCE
 	select PCIE_CADENCE_HOST
 	select PCI_ECAM
 	help
@@ -60,6 +61,7 @@ config PCI_SKY1_HOST
 config PCIE_SG2042_HOST
 	tristate "Sophgo SG2042 PCIe controller (host mode)"
 	depends on OF && (ARCH_SOPHGO || COMPILE_TEST)
+	select PCIE_CADENCE
 	select PCIE_CADENCE_HOST
 	help
 	  Say Y here if you want to support the Sophgo SG2042 PCIe platform
@@ -68,14 +70,14 @@ config PCIE_SG2042_HOST
 
 config PCI_J721E
 	tristate
-	select PCIE_CADENCE_HOST if PCI_J721E_HOST != n
-	select PCIE_CADENCE_EP if PCI_J721E_EP != n
+	select PCIE_CADENCE
 
 config PCI_J721E_HOST
 	tristate "TI J721E PCIe controller (host mode)"
 	depends on ARCH_K3 || COMPILE_TEST
 	depends on OF
 	select PCI_J721E
+	select PCIE_CADENCE_HOST
 	help
 	  Say Y here if you want to support the TI J721E PCIe platform
 	  controller in host mode. TI J721E PCIe controller uses Cadence PCIe
@@ -87,6 +89,7 @@ config PCI_J721E_EP
 	depends on OF
 	depends on PCI_ENDPOINT
 	select PCI_J721E
+	select PCIE_CADENCE_EP
 	help
 	  Say Y here if you want to support the TI J721E PCIe platform
 	  controller in endpoint mode. TI J721E PCIe controller uses Cadence PCIe
drivers/pci/controller/cadence/Makefile +9 -3
index b8ec1cecfaa8..139ac0a0de6f 100644
@@ -1,11 +1,17 @@
 # SPDX-License-Identifier: GPL-2.0
 pcie-cadence-mod-y := pcie-cadence-hpa.o pcie-cadence.o
+obj-$(CONFIG_PCIE_CADENCE) = pcie-cadence-mod.o
+
+ifdef CONFIG_PCIE_CADENCE_HOST
 pcie-cadence-host-mod-y := pcie-cadence-host-common.o pcie-cadence-host.o pcie-cadence-host-hpa.o
+obj-$(CONFIG_PCIE_CADENCE) += pcie-cadence-host-mod.o
+endif
+
+ifdef CONFIG_PCIE_CADENCE_EP
 pcie-cadence-ep-mod-y := pcie-cadence-ep.o
+obj-$(CONFIG_PCIE_CADENCE) += pcie-cadence-ep-mod.o
+endif
 
-obj-$(CONFIG_PCIE_CADENCE) = pcie-cadence-mod.o
-obj-$(CONFIG_PCIE_CADENCE_HOST) += pcie-cadence-host-mod.o
-obj-$(CONFIG_PCIE_CADENCE_EP) += pcie-cadence-ep-mod.o
 obj-$(CONFIG_PCIE_CADENCE_PLAT) += pcie-cadence-plat.o
 obj-$(CONFIG_PCI_J721E) += pci-j721e.o
 obj-$(CONFIG_PCIE_SG2042_HOST) += pcie-sg2042.o
Signature · 1 line
2.39.5
Signature · 1 line
மணிவண்ணன் சதாசிவம்