From bcb3961567b6416a7f37898eae18dab083d21a68 Mon Sep 17 00:00:00 2001 From: Rodrigo Cataldo Date: Thu, 1 Dec 2022 17:28:17 +0100 Subject: [PATCH] drivers: pcie: late initialization of pcie when PCIe controller is used For architectures that rely on a PCIe controller (for example, ARM64), scanning the PCI space will only succeed after the controller has initialized. Therefore, in the presence of PCIe controller, the PCIe initialization is bumped to the next system init level. In the past, drivers like ivshmem would do a late scan of the PCI space in case the early scan failed; however, the cited commit removed this feature and ivshmem fails for ARM64. This commit fix this by making the early scan succeed. Fixes: a96016d74703 ("drivers: ivshmem: Remove unnecessary BDF lookup ...") Signed-off-by: Rodrigo Cataldo Co-authored-by: Henri Xavier --- drivers/pcie/host/pcie.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/pcie/host/pcie.c b/drivers/pcie/host/pcie.c index d3ba736046b..7a4aa4a5985 100644 --- a/drivers/pcie/host/pcie.c +++ b/drivers/pcie/host/pcie.c @@ -529,4 +529,15 @@ static int pcie_init(const struct device *dev) return 0; } -SYS_INIT(pcie_init, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); + +/* + * If a pcie controller is employed, pcie_scan() depends on it for working. + * Thus, pcie must be bumped to the next level + */ +#ifdef CONFIG_PCIE_CONTROLLER +#define PCIE_SYS_INIT_LEVEL PRE_KERNEL_2 +#else +#define PCIE_SYS_INIT_LEVEL PRE_KERNEL_1 +#endif + +SYS_INIT(pcie_init, PCIE_SYS_INIT_LEVEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);