CONFIG_SYS_EARLY_PCI_INIT for PCI-attached eMMC
Hi all,
I'm currently playing with eMMC emulation for qemu-system-aarch64 -M virt and will likely propose upstream to allow user-instantiate emmc devices (-> -device sdhci-pci -device emmc).
To make U-Boot recognize such a setup, I currently need this:
include/configs/qemu-arm.h +2 -0
@@ -11,4 +11,6 @@/* For timer, QEMU emulates an ARMv7/ARMv8 architected timer */ +#define CONFIG_SYS_EARLY_PCI_INIT 1 +#endif /* __CONFIG_H */
Is this the right way to achieve? Then a patch for U-Boot would follow as well.
Jan
Signature · 2 lines
Siemens AG, Foundational Technologies Linux Expert Center
Quoted 21 lines · Jan Kiszka
Hi all,
I'm currently playing with eMMC emulation for qemu-system-aarch64 -M virt and will likely propose upstream to allow user-instantiate emmc devices (-> -device sdhci-pci -device emmc).
To make U-Boot recognize such a setup, I currently need this:
include/configs/qemu-arm.h +2
-0@@ -11,4 +11,6 @@/* For timer, QEMU emulates an ARMv7/ARMv8 architected timer */ +#define CONFIG_SYS_EARLY_PCI_INIT 1 +#endif /* __CONFIG_H */
Quoted 2 lines
Is this the right way to achieve? Then a patch for U-Boot would follow as well.
CONFIG_SYS_EARLY_PCI_INIT is not defined anywhere as a Kconfig symbol.
I'm wondering if we should change it like this instead:
common/board_r.c +1 -1
@@ -685,7 +685,7 @@ static void initcall_run_r(void)INITCALL (post_output_backlog);#endif WATCHDOG_RESET (); -#if CONFIG_IS_ENABLED (PCI_INIT_R ) &&CONFIG_IS_ENABLED (SYS_EARLY_PCI_INIT ) +#if CONFIG_IS_ENABLED (PCI_INIT_R )/* * Do early PCI configuration _before_ the flash gets initialised, * because PCU resources are crucial for flash access on some boards.
Quoted 25 lines
From: Fabio Estevam <[email protected]>
Date: Thu, 14 Aug 2025 09:22:57 -0300Quoted 21 lines · Jan Kiszka
Hi all,
I'm currently playing with eMMC emulation for qemu-system-aarch64 -M virt and will likely propose upstream to allow user-instantiate emmc devices (-> -device sdhci-pci -device emmc).
To make U-Boot recognize such a setup, I currently need this:
include/configs/qemu-arm.h +2
-0@@ -11,4 +11,6 @@/* For timer, QEMU emulates an ARMv7/ARMv8 architected timer */ +#define CONFIG_SYS_EARLY_PCI_INIT 1 +#endif /* __CONFIG_H */
Quoted 6 lines
Quoted 2 lines
Is this the right way to achieve? Then a patch for U-Boot would follow as well.
CONFIG_SYS_EARLY_PCI_INITis not defined anywhere as aKconfigsymbol.I'm wondering if we should change it like this instead:
Not without removing the 2nd pci_init_r() that is conditionalized on !CONFIG_IS_ENABLED(SYS_EARLY_PCI_INIT).
That would require some thorough testing though; I certainly wouldn't be sure calling pci_init_r() is safe at that point on the boards I maintain.
Quoted 14 lines
common/board_r.c +1
-1@@ -685,7 +685,7 @@ static void initcall_run_r(void)INITCALL (post_output_backlog);#endif WATCHDOG_RESET (); -#if CONFIG_IS_ENABLED (PCI_INIT_R ) &&CONFIG_IS_ENABLED (SYS_EARLY_PCI_INIT ) +#if CONFIG_IS_ENABLED (PCI_INIT_R )/* * Do early PCI configuration _before_ the flash gets initialised, * because PCU resources are crucial for flash access on some boards.
Quoted 6 lines · Mark Kettenis
Not without removing the 2nd
pci_init_r()that is conditionalized on !CONFIG_IS_ENABLED(SYS_EARLY_PCI_INIT).That would require some thorough testing though; I certainly wouldn't be sure calling
pci_init_r()is safe at that point on the boards I maintain.
You're right.
Maybe we could solve it with two patches:
1. Convert EARLY_PCI_INIT to a Kconfig symbol:
common/Kconfig +7 -0
@@ -824,6 +824,13 @@ config SYS_I2C_EEPROM_NXID endchoice +config EARLY_PCI_INIT + bool "Enumerate PCI buses early during init" + depends on PCI + help + Do early PCI configuration _before_ the flash gets initialised, + because PCU resources are crucial for flash access on some boards. + config PCI_INIT_R bool "Enumerate PCI buses during init" depends on PCI
2. Select CONFIG_EARLY_PCI_INIT in the defconfig
configs/qemu_arm_defconfig +1 -0
@@ -28,6 +28,7 @@ CONFIG_USE_PREBOOT=y # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_DISPLAY_BOARDINFO is not set # CONFIG_BOARD_INIT is not set +CONFIG_EARLY_PCI_INIT=y CONFIG_PCI_INIT_R=y CONFIG_CMD_BOOTEFI_SELFTEST=y CONFIG_CMD_NVEDIT_EFI=y
Quoted 20 lines · Fabio Estevam
Quoted 6 lines · Mark Kettenis
Not without removing the 2nd
pci_init_r()that is conditionalized on !CONFIG_IS_ENABLED(SYS_EARLY_PCI_INIT).That would require some thorough testing though; I certainly wouldn't be sure calling
pci_init_r()is safe at that point on the boards I maintain.You're right.
Maybe we could solve it with two patches:
1. Convert
EARLY_PCI_INITto aKconfigsymbol:common/Kconfig +0
-0
common/Kconfig config SYS_I2C_EEPROM_NXID · line 827
Quoted 4 lines
common/Kconfig +1
-0@@ -824,6 +824,13 @@ config SYS_I2C_EEPROM_NXID endchoice +config EARLY_PCI_INIT
Please, do not rename the symbol.
%s/EARLY_PCI_INIT/SYS_EARLY_PCI_INIT/
All configuration symbols starting on CONFIG_ should be defined in Kconfig. Only CFG_* are not Kconfig. Something must have gone wrong in the conversion work some years ago.
common/Kconfig config SYS_I2C_EEPROM_NXID · line 831
Quoted 4 lines
common/Kconfig +4
-0+ bool "Enumerate PCI buses early during init" + depends on PCI + help + Do early PCI configuration _before_ the flash gets initialised,
Highlighting is not supported in Kconfig.
%s/_before_/before/
common/Kconfig config SYS_I2C_EEPROM_NXID · line 832
Quoted 1 line
common/Kconfig +1
-0+ because PCU resources are crucial for flash access on some boards.
%s/PCU/PCI/
We were talking about eMMC, not SPI flash.
Quoted 12 lines
common/Kconfig +1
-0+ config PCI_INIT_R bool "Enumerate PCI buses during init" depends on PCI2. Select
CONFIG_EARLY_PCI_INITin the defconfigconfigs/qemu_arm_defconfig +0
-0
configs/qemu_arm_defconfig CONFIG_USE_PREBOOT=y · line 31
Quoted 4 lines
configs/qemu_arm_defconfig +1
-0@@ -28,6 +28,7 @@ CONFIG_USE_PREBOOT=y # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_DISPLAY_BOARDINFO is not set # CONFIG_BOARD_INIT is not set +CONFIG_EARLY_PCI_INIT=y
%s/EARLY_PCI_INIT/SYS_EARLY_PCI_INIT/
Otherwise looks good to me.
Best regards
Heinrich
Quoted 3 lines
configs/qemu_arm_defconfig +0
-0CONFIG_PCI_INIT_R=y CONFIG_CMD_BOOTEFI_SELFTEST=y CONFIG_CMD_NVEDIT_EFI=y
Quoted 28 lines · Heinrich Schuchardt
Quoted 20 lines · Fabio Estevam
Quoted 6 lines · Mark Kettenis
Not without removing the 2nd
pci_init_r()that is conditionalized on !CONFIG_IS_ENABLED(SYS_EARLY_PCI_INIT).That would require some thorough testing though; I certainly wouldn't be sure calling
pci_init_r()is safe at that point on the boards I maintain.You're right.
Maybe we could solve it with two patches:
1. Convert
EARLY_PCI_INITto aKconfigsymbol:common/Kconfig +0
-0common/Kconfig config SYS_I2C_EEPROM_NXID · line 827
Quoted 4 lines
common/Kconfig +1
-0@@ -824,6 +824,13 @@ config SYS_I2C_EEPROM_NXID endchoice +config EARLY_PCI_INITPlease, do not rename the symbol.
Quoted 5 lines
%s/EARLY_PCI_INIT/SYS_EARLY_PCI_INIT/
All configuration symbols starting on
CONFIG_should be defined inKconfig. Only CFG_* are notKconfig. Something must have gone wrong in the conversion work some years ago.
FWIW, this symbol is one of the cases where nothing enabled the CONFIG option. So yes, it needs to be added to Kconfig now in order to enable it, now that something want it. But that's how it was missed, and there may be other symbols beyond this and CONFIG_SYS_FAULT_MII_ADDR that I tripped on when doing allyesconfig.
Signature · 1 line
Tom
Quoted 70 lines · Heinrich Schuchardt
Quoted 24 lines · Fabio Estevam
Quoted 6 lines · Mark Kettenis
Not without removing the 2nd
pci_init_r()that is conditionalized on !CONFIG_IS_ENABLED(SYS_EARLY_PCI_INIT).That would require some thorough testing though; I certainly wouldn't be sure calling
pci_init_r()is safe at that point on the boards I maintain.You're right.
Maybe we could solve it with two patches:
1. Convert
EARLY_PCI_INITto aKconfigsymbol:common/Kconfig +0
-0@@ -824,6 +824,13 @@ config SYS_I2C_EEPROM_NXIDendchoice
Quoted 1 line
+config
EARLY_PCI_INITPlease, do not rename the symbol.
%s/EARLY_PCI_INIT/SYS_EARLY_PCI_INIT/
All configuration symbols starting on
CONFIG_should be defined inKconfig. Only CFG_* are notKconfig. Something must have gone wrong in the conversion work some years ago.Quoted 4 lines
+ bool "Enumerate PCI buses early during init"
+ depends on PCI
+ help
+ Do early PCI configuration _before_ the flash gets initialised,Highlighting is not supported in
Kconfig.%s/_before_/before/
Quoted 2 lines
+ because PCU resources are crucial for flash access on some boards.
%s/PCU/PCI/
We were talking about eMMC, not SPI flash.
Quoted 12 lines
+
configPCI_INIT_R
bool "Enumerate PCI buses during init"
depends on PCI2. Select
CONFIG_EARLY_PCI_INITin the defconfigconfigs/qemu_arm_defconfig +0
-0configs/qemu_arm_defconfig CONFIG_USE_PREBOOT=y · line 31
Quoted 4 lines
configs/qemu_arm_defconfig +1
-0@@ -28,6 +28,7 @@ CONFIG_USE_PREBOOT=y # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_DISPLAY_BOARDINFO is not set # CONFIG_BOARD_INIT is not set +CONFIG_EARLY_PCI_INIT=y%s/EARLY_PCI_INIT/SYS_EARLY_PCI_INIT/
Quoted 2 lines
Otherwise looks good to me.
Ack. Fabio, will you submit those two then?
Thanks!
Jan
Signature · 2 lines
Siemens AG, Foundational Technologies Linux Expert Center