Re: [PATCH 2/2] PCI: controller: avoid building empty drivers

From: Robert Richter
Date: Fri Feb 26 2021 - 14:09:52 EST


On 25.02.21 15:37:10, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@xxxxxxxx>
>
> There are harmless warnings when compile testing the kernel with
> CONFIG_TRIM_UNUSED_KSYMS:
>
> drivers/pci/controller/dwc/pcie-al.o: no symbols
> drivers/pci/controller/pci-thunder-ecam.o: no symbols
> drivers/pci/controller/pci-thunder-pem.o: no symbols
>
> The problem here is that the host drivers get built even when the
> configuration symbols are all disabled, as they pretend to not be drivers
> but are silently enabled because of the promise that ACPI based systems
> need no drivers.
>
> Add back the normal symbols to have these drivers built, and change the
> logic to otherwise only build them when both CONFIG_PCI_QUIRKS and
> CONFIG_ACPI are enabled.
>
> As a side-effect, this enables compile-testing the drivers on other
> architectures, which in turn needs the acpi_get_rc_resources()
> function to be defined.
>
> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
> ---
> drivers/pci/controller/Makefile | 7 ++++++-
> drivers/pci/controller/dwc/Makefile | 7 ++++++-
> 2 files changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/controller/Makefile b/drivers/pci/controller/Makefile
> index e4559f2182f2..6d24a163033f 100644
> --- a/drivers/pci/controller/Makefile
> +++ b/drivers/pci/controller/Makefile
> @@ -11,10 +11,13 @@ obj-$(CONFIG_PCIE_RCAR_HOST) += pcie-rcar.o pcie-rcar-host.o
> obj-$(CONFIG_PCIE_RCAR_EP) += pcie-rcar.o pcie-rcar-ep.o
> obj-$(CONFIG_PCI_HOST_COMMON) += pci-host-common.o
> obj-$(CONFIG_PCI_HOST_GENERIC) += pci-host-generic.o
> +obj-$(CONFIG_PCI_HOST_THUNDER_ECAM) += pci-thunder-ecam.o
> +obj-$(CONFIG_PCI_HOST_THUNDER_PEM) += pci-thunder-pem.o
> obj-$(CONFIG_PCIE_XILINX) += pcie-xilinx.o
> obj-$(CONFIG_PCIE_XILINX_NWL) += pcie-xilinx-nwl.o
> obj-$(CONFIG_PCIE_XILINX_CPM) += pcie-xilinx-cpm.o
> obj-$(CONFIG_PCI_V3_SEMI) += pci-v3-semi.o
> +obj-$(CONFIG_PCI_XGENE) += pci-xgene.o
> obj-$(CONFIG_PCI_XGENE_MSI) += pci-xgene-msi.o
> obj-$(CONFIG_PCI_VERSATILE) += pci-versatile.o
> obj-$(CONFIG_PCIE_IPROC) += pcie-iproc.o
> @@ -47,8 +50,10 @@ obj-y += mobiveil/
> # ARM64 and use internal ifdefs to only build the pieces we need
> # depending on whether ACPI, the DT driver, or both are enabled.
>
> -ifdef CONFIG_PCI
> +ifdef CONFIG_ACPI
> +ifdef CONFIG_PCI_QUIRKS
> obj-$(CONFIG_ARM64) += pci-thunder-ecam.o
> obj-$(CONFIG_ARM64) += pci-thunder-pem.o
> obj-$(CONFIG_ARM64) += pci-xgene.o
> endif
> +endif

A possible double inclusion isn't really nice here, but it should work
that way.

Also, the menu entry for the driver is in fact only for the OF case,
as it is always included for ACPI even if the option is disabled (and
thus the choice is useless). But this is unrelated to this patch.

Anyway:

Reviewed-by: Robert Richter <rric@xxxxxxxxxx>

> diff --git a/drivers/pci/controller/dwc/Makefile b/drivers/pci/controller/dwc/Makefile
> index a751553fa0db..ba7c42f6df6f 100644
> --- a/drivers/pci/controller/dwc/Makefile
> +++ b/drivers/pci/controller/dwc/Makefile
> @@ -31,7 +31,12 @@ obj-$(CONFIG_PCIE_UNIPHIER_EP) += pcie-uniphier-ep.o
> # ARM64 and use internal ifdefs to only build the pieces we need
> # depending on whether ACPI, the DT driver, or both are enabled.
>
> -ifdef CONFIG_PCI
> +obj-$(CONFIG_PCIE_AL) += pcie-al.o
> +obj-$(CONFIG_PCI_HISI) += pcie-hisi.o
> +
> +ifdef CONFIG_ACPI
> +ifdef CONFIG_PCI_QUIRKS
> obj-$(CONFIG_ARM64) += pcie-al.o
> obj-$(CONFIG_ARM64) += pcie-hisi.o
> endif
> +endif
> --
> 2.29.2
>