Skip to contentSkip to conversation

CONFIG_SYS_EARLY_PCI_INIT for PCI-attached eMMC

PATCH Jan Kiszka 5 participants 7 messages Aug 14, 2025

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

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
index e296f398798..4e22aa36fa6 100644
@@ -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
#1 lore raw
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
index e296f398798..4e22aa36fa6 100644
@@ -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
index 143d51d06330..3da749b05fcc 100644
@@ -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.
#2 lore raw
Quoted 25 lines

From: Fabio Estevam <[email protected]>
Date: Thu, 14 Aug 2025 09:22:57 -0300

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
index e296f398798..4e22aa36fa6 100644
@@ -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_INIT is not defined anywhere as a Kconfig symbol.

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
index 143d51d06330..3da749b05fcc 100644
@@ -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.
#3 lore raw
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
index a2f653f7e722..9119a1c0869f 100644
@@ -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
index d5890bf87fb3..a0d03dc19d0b 100644
@@ -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
#4 lore raw
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_INIT to a Kconfig symbol:

common/Kconfig +0 -0
index a2f653f7e722..9119a1c0869f 100644

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 PCI

2. Select CONFIG_EARLY_PCI_INIT in the defconfig

configs/qemu_arm_defconfig +0 -0
index d5890bf87fb3..a0d03dc19d0b 100644

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 -0
  CONFIG_PCI_INIT_R=y
  CONFIG_CMD_BOOTEFI_SELFTEST=y
  CONFIG_CMD_NVEDIT_EFI=y
#5 lore raw
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_INIT to a Kconfig symbol:

common/Kconfig +0 -0
index a2f653f7e722..9119a1c0869f 100644

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.

Quoted 5 lines

%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.

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
author
#6 lore raw
In reply to Heinrich Schuchardt
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_INIT to a Kconfig symbol:

common/Kconfig +0 -0
index a2f653f7e722..9119a1c0869f 100644
@@ -824,6 +824,13 @@ config SYS_I2C_EEPROM_NXID
 

  endchoice

Quoted 1 line

+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.

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

+
  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 +0 -0
index d5890bf87fb3..a0d03dc19d0b 100644

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/

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