dm: pci: Allow scan bridge child devices before relocation
PATCH 1/5 dm: pci: Allow scan bridge child devices before relocation
On some platforms pci devices behind bridge need to be probed (eg:
a pci uart on recent x86 chipset) before relocation. Remove such limitation so that dm pci can be used before relocation.
---
drivers/pci/pci-uclass.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/pci/pci-uclass.c +0 -4
@@ -641,10 +641,6 @@ static int pci_uclass_post_probe(struct udevice *bus) {int ret; -/* Don't scan buses before relocation */ -if (!(gd->flags &GD_FLG_RELOC )) -return 0 ; -debug ("%s: probing bus %d\n" , __func__, bus->seq); ret =pci_bind_bus_devices (bus);if (ret)
Signature · 1 line
1.8.2.1
PATCH 2/5 x86: fsp: Reserve different malloc size before relocation
Currently Intel queensbay fsp initializes a CAR size with only 4KiB, which is not enough when dm pci is enabled before relocation. Change arch/x86/start.s to reserve a small size before fsp_init() is called and some bigger size after fsp_init() which can be configured via the exisiting CONFIG_MALLOC_F_LEN.
---
arch/x86/Kconfig | 5 +++++ arch/x86/cpu/start.S | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-)
arch/x86/Kconfig +5 -0
@@ -227,6 +227,11 @@ config FSP_TEMP_RAM_ADDR Stack top address which is used in FspInit after DRAM is ready and CAR is disabled. +config SYS_MALLOC_F_LEN_PRE_FSP + hex + depends on HAVE_FSP + default 0x800 + config SMP bool "Enable Symmetric Multiprocessing" default n
arch/x86/cpu/start.S +9 -1
@@ -137,7 +137,15 @@ skip_hob: movl %esp, %ecx #if defined(CONFIG_SYS_MALLOC_F_LEN) - subl $CONFIG_SYS_MALLOC_F_LEN, %esp +#ifdef CONFIG_HAVE_FSP + test %esi, %esi + jnz 1f + subl $CONFIG_SYS_MALLOC_F_LEN_PRE_FSP, %esp + jmp 2f +#endif +1: + subl $CONFIG_SYS_MALLOC_F_LEN, %esp +2: movl %eax, %edx addl $GD_MALLOC_BASE, %edx movl %esp, (%edx)
Signature · 1 line
1.8.2.1
PATCH 2/5 x86: fsp: Reserve different malloc size before relocation
Hi Bin,
Quoted 51 lines · Bin Meng
Currently Intel queensbay fsp initializes a CAR size with only 4KiB, which is not enough when dm pci is enabled before relocation. Change
arch/x86/start.sto reserve a small size beforefsp_init()is called and some bigger size afterfsp_init()which can be configured via the exisitingCONFIG_MALLOC_F_LEN.Signed-off-by Bin Meng <[email protected]>---
arch/x86/Kconfig | 5 +++++ arch/x86/cpu/start.S | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-)arch/x86/Kconfig +5
-0@@ -227,6 +227,11 @@ config FSP_TEMP_RAM_ADDR Stack top address which is used in FspInit after DRAM is ready and CAR is disabled. +config SYS_MALLOC_F_LEN_PRE_FSP + hex + depends on HAVE_FSP + default 0x800 + config SMP bool "Enable Symmetric Multiprocessing" default narch/x86/cpu/start.S +9
-2@@ -137,7 +137,15 @@ skip_hob: movl %esp, %ecx #if defined(CONFIG_SYS_MALLOC_F_LEN) - subl $CONFIG_SYS_MALLOC_F_LEN, %esp +#ifdef CONFIG_HAVE_FSP + test %esi, %esi + jnz 1f + subl $CONFIG_SYS_MALLOC_F_LEN_PRE_FSP, %esp + jmp 2f +#endif +1: + subl $CONFIG_SYS_MALLOC_F_LEN, %esp +2: movl %eax, %edx addl $GD_MALLOC_BASE, %edx movl %esp, (%edx) --
Quoted 2 lines
1.8.2.1
This is a bit of an unfortunate problem. While CONFIG_SYS_MALLOC_F_LEN is a generic thing (and in fact I'm about to send a series to make x86 use board_init_f_mem() instead of all this code) CONFIG_SYS_MALLOC_F_LEN_PRE_FSP is not.
One option (with my new series) is to simply change the stack after board_init_f_mem() returns. Let's see what you think of that series and then we can revisit this.
Regards,
Simon
PATCH 2/5 x86: fsp: Reserve different malloc size before relocation
Hi Simon,
Quoted 62 lines · Simon Glass
Hi Bin,
Quoted 51 lines · Bin Meng
Currently Intel queensbay fsp initializes a CAR size with only 4KiB, which is not enough when dm pci is enabled before relocation. Change
arch/x86/start.sto reserve a small size beforefsp_init()is called and some bigger size afterfsp_init()which can be configured via the exisitingCONFIG_MALLOC_F_LEN.Signed-off-by Bin Meng <[email protected]>---
arch/x86/Kconfig | 5 +++++ arch/x86/cpu/start.S | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-)arch/x86/Kconfig +5
-0@@ -227,6 +227,11 @@ config FSP_TEMP_RAM_ADDR Stack top address which is used in FspInit after DRAM is ready and CAR is disabled. +config SYS_MALLOC_F_LEN_PRE_FSP + hex + depends on HAVE_FSP + default 0x800 + config SMP bool "Enable Symmetric Multiprocessing" default narch/x86/cpu/start.S +9
-2@@ -137,7 +137,15 @@ skip_hob: movl %esp, %ecx #if defined(CONFIG_SYS_MALLOC_F_LEN) - subl $CONFIG_SYS_MALLOC_F_LEN, %esp +#ifdef CONFIG_HAVE_FSP + test %esi, %esi + jnz 1f + subl $CONFIG_SYS_MALLOC_F_LEN_PRE_FSP, %esp + jmp 2f +#endif +1: + subl $CONFIG_SYS_MALLOC_F_LEN, %esp +2: movl %eax, %edx addl $GD_MALLOC_BASE, %edx movl %esp, (%edx) --Quoted 2 lines
1.8.2.1
This is a bit of an unfortunate problem. While
CONFIG_SYS_MALLOC_F_LENis a generic thing (and in fact I'm about to send a series to make x86 useboard_init_f_mem()instead of all this code)CONFIG_SYS_MALLOC_F_LEN_PRE_FSPis not.
Quoted 4 lines
One option (with my new series) is to simply change the stack after
board_init_f_mem()returns. Let's see what you think of that series and then we can revisit this.
OK, I will test this on top of your series.
Regards,
Bin
PATCH 3/5 x86: queensbay: Support pre-relocation dm pci
In reply to Bin MengIncrease CONFIG_MALLOC_F_LEN so that dm pci does not fail with -ENOMEM before relocation. This makes pci uart work again on Intel Crown Bay.
---
arch/x86/cpu/queensbay/Kconfig | 3 +++ arch/x86/cpu/queensbay/tnc.c | 13 +++++++++++++ arch/x86/dts/crownbay.dts | 2 -- 3 files changed, 16 insertions(+), 2 deletions(-)
arch/x86/cpu/queensbay/Kconfig +3 -0
@@ -42,4 +42,7 @@ config CPU_ADDR_BITS int default 32 +config SYS_MALLOC_F_LEN + default 0x8000 + endif
arch/x86/cpu/queensbay/tnc.c +13 -0
@@ -13,6 +13,7 @@#include <asm/arch/tnc.h> #include <asm/fsp/fsp_support.h> #include <asm/processor.h> +#include <dm.h> static void unprotect_spi_flash (void ) {
@@ -36,6 +37,18 @@ int arch_cpu_init(void)if (ret)return ret; +return 0 ; +} + +int arch_cpu_init_dm (void ) +{ +struct udevice *dev; +int ret; + + ret =uclass_first_device (UCLASS_PCI , &dev); +if (ret) +return ret; +unprotect_spi_flash ();return 0 ;
arch/x86/dts/crownbay.dts +0 -2
@@ -100,13 +100,11 @@ pcie at 17,0 { #address-cells = <3>; #size-cells = <2>; - compatible = "intel,pci"; device_type = "pci"; topcliff at 0,0 { #address-cells = <3>; #size-cells = <2>; - compatible = "intel,pci"; device_type = "pci"; pciuart0: uart at a,1 {
Signature · 1 line
1.8.2.1
PATCH 3/5 x86: queensbay: Support pre-relocation dm pci
Hi Bin,
Quoted 16 lines · Bin Meng
Increase
CONFIG_MALLOC_F_LENso that dm pci does not fail with-ENOMEMbefore relocation. This makes pci uart work again on Intel Crown Bay.Signed-off-by Bin Meng <[email protected]>---
arch/x86/cpu/queensbay/Kconfig | 3 +++ arch/x86/cpu/queensbay/tnc.c | 13 +++++++++++++ arch/x86/dts/crownbay.dts | 2 -- 3 files changed, 16 insertions(+), 2 deletions(-)arch/x86/cpu/queensbay/Kconfig +0
-0
arch/x86/cpu/queensbay/Kconfig config CPU_ADDR_BITS · line 46
Quoted 5 lines
arch/x86/cpu/queensbay/Kconfig +2
-0@@ -42,4 +42,7 @@ config CPU_ADDR_BITS int default 32 +config SYS_MALLOC_F_LEN + default 0x8000
32KB? Wow that's a huge amount. How much does it actually use? Perhaps we should change PCI so that it respects the u-boot,dm-pre-reloc property?
Quoted 52 lines
arch/x86/cpu/queensbay/Kconfig +1
-0+ endifarch/x86/cpu/queensbay/tnc.c +13
-0@@ -13,6 +13,7 @@#include <asm/arch/tnc.h> #include <asm/fsp/fsp_support.h> #include <asm/processor.h> +#include <dm.h> static void unprotect_spi_flash (void ) {@@ -36,6 +37,18 @@ int arch_cpu_init(void)if (ret)return ret; +return 0 ; +} + +int arch_cpu_init_dm (void ) +{ +struct udevice *dev; +int ret; + + ret =uclass_first_device (UCLASS_PCI , &dev); +if (ret) +return ret; +unprotect_spi_flash ();return 0 ;arch/x86/dts/crownbay.dts +0
-3@@ -100,13 +100,11 @@ pcie at 17,0 { #address-cells = <3>; #size-cells = <2>; - compatible = "intel,pci"; device_type = "pci"; topcliff at 0,0 { #address-cells = <3>; #size-cells = <2>; - compatible = "intel,pci"; device_type = "pci"; pciuart0: uart at a,1 { --
Quoted 2 lines
1.8.2.1
Regards,
Simon
PATCH 3/5 x86: queensbay: Support pre-relocation dm pci
Hi Simon,
Quoted 22 lines · Simon Glass
Hi Bin,
Quoted 19 lines · Bin Meng
Increase
CONFIG_MALLOC_F_LENso that dm pci does not fail with-ENOMEMbefore relocation. This makes pci uart work again on Intel Crown Bay.Signed-off-by Bin Meng <[email protected]>---
arch/x86/cpu/queensbay/Kconfig | 3 +++ arch/x86/cpu/queensbay/tnc.c | 13 +++++++++++++ arch/x86/dts/crownbay.dts | 2 -- 3 files changed, 16 insertions(+), 2 deletions(-)arch/x86/cpu/queensbay/Kconfig +0
-0@@ -42,4 +42,7 @@ config CPU_ADDR_BITS int default 32
Quoted 7 lines
arch/x86/cpu/queensbay/Kconfig config CPU_ADDR_BITS · line 46
Quoted 2 lines
arch/x86/cpu/queensbay/Kconfig +2
-0+config SYS_MALLOC_F_LEN + default 0x800032KB? Wow that's a huge amount. How much does it actually use? Perhaps we should change PCI so that it respects the u-boot,dm-pre-reloc property?
I just add a zero to the original value :) I did not measure the actual memory consumption since after fsp_init() we have plenty of memory to be used as the stack. For queensbay platform, it has lots of pci devices each of which will need allocate some memory for dm pci to use.
Regards,
Bin
PATCH 3/5 x86: queensbay: Support pre-relocation dm pci
Hi Bin,
Quoted 33 lines · Bin Meng
Hi Simon,
Quoted 22 lines · Simon Glass
Hi Bin,
Quoted 19 lines · Bin Meng
Increase
CONFIG_MALLOC_F_LENso that dm pci does not fail with-ENOMEMbefore relocation. This makes pci uart work again on Intel Crown Bay.Signed-off-by Bin Meng <[email protected]>---
arch/x86/cpu/queensbay/Kconfig | 3 +++ arch/x86/cpu/queensbay/tnc.c | 13 +++++++++++++ arch/x86/dts/crownbay.dts | 2 -- 3 files changed, 16 insertions(+), 2 deletions(-)arch/x86/cpu/queensbay/Kconfig +0
-0@@ -42,4 +42,7 @@ config CPU_ADDR_BITS int default 32Quoted 7 lines
arch/x86/cpu/queensbay/Kconfig config CPU_ADDR_BITS · line 46
Quoted 2 lines
arch/x86/cpu/queensbay/Kconfig +2
-0+config SYS_MALLOC_F_LEN + default 0x800032KB? Wow that's a huge amount. How much does it actually use? Perhaps we should change PCI so that it respects the u-boot,dm-pre-reloc property?
Quoted 5 lines
I just add a zero to the original value :) I did not measure the actual memory consumption since after
fsp_init()we have plenty of memory to be used as the stack. For queensbay platform, it has lots of pci devices each of which will need allocate some memory for dm pci to use.
I think it is worth checking this and using a value closer to what you need. board_init_f.c has a debug output for it I think.
Also I wonder if we can avoid creating PCI devices for everything pre-relocation, when we only need serial?
Regards,
SImon
PATCH 3/5 x86: queensbay: Support pre-relocation dm pci
Hi Simon,
Quoted 36 lines · Simon Glass
Hi Bin,
Quoted 33 lines · Bin Meng
Hi Simon,
Quoted 29 lines · Simon Glass
Hi Bin,
Quoted 16 lines · Bin Meng
Increase
CONFIG_MALLOC_F_LENso that dm pci does not fail with-ENOMEMbefore relocation. This makes pci uart work again on Intel Crown Bay.Signed-off-by Bin Meng <[email protected]>---
arch/x86/cpu/queensbay/Kconfig | 3 +++ arch/x86/cpu/queensbay/tnc.c | 13 +++++++++++++ arch/x86/dts/crownbay.dts | 2 -- 3 files changed, 16 insertions(+), 2 deletions(-)arch/x86/cpu/queensbay/Kconfig +0
-0arch/x86/cpu/queensbay/Kconfig config CPU_ADDR_BITS · line 46
Quoted 5 lines
arch/x86/cpu/queensbay/Kconfig +2
-0@@ -42,4 +42,7 @@ config CPU_ADDR_BITS int default 32 +config SYS_MALLOC_F_LEN + default 0x800032KB? Wow that's a huge amount. How much does it actually use? Perhaps we should change PCI so that it respects the u-boot,dm-pre-reloc property?
Quoted 9 lines
Quoted 5 lines
I just add a zero to the original value :) I did not measure the actual memory consumption since after
fsp_init()we have plenty of memory to be used as the stack. For queensbay platform, it has lots of pci devices each of which will need allocate some memory for dm pci to use.I think it is worth checking this and using a value closer to what you need.
board_init_f.chas a debug output for it I think.
OK, I will have a check.
Quoted 3 lines
Also I wonder if we can avoid creating PCI devices for everything pre-relocation, when we only need serial?
Yes, looks that we only need serial. However x86 is a specific case since pci bus is the fundamental bus that is used to set up other devices. After conversion to dm pci, if we implement it correctly, any call to a pci api will trigger the enumeration and it is probably a side effect of using dm? I even think we can hardcoded pci uart in the pre-relocation phase without using dm at all, but that is not a portable way.
Regards,
Bin
PATCH 3/5 x86: queensbay: Support pre-relocation dm pci
Hi Bin,
Quoted 55 lines · Bin Meng
Hi Simon,
Quoted 36 lines · Simon Glass
Hi Bin,
Quoted 33 lines · Bin Meng
Hi Simon,
Quoted 29 lines · Simon Glass
Hi Bin,
Quoted 16 lines · Bin Meng
Increase
CONFIG_MALLOC_F_LENso that dm pci does not fail with-ENOMEMbefore relocation. This makes pci uart work again on Intel Crown Bay.Signed-off-by Bin Meng <[email protected]>---
arch/x86/cpu/queensbay/Kconfig | 3 +++ arch/x86/cpu/queensbay/tnc.c | 13 +++++++++++++ arch/x86/dts/crownbay.dts | 2 -- 3 files changed, 16 insertions(+), 2 deletions(-)arch/x86/cpu/queensbay/Kconfig +0
-0arch/x86/cpu/queensbay/Kconfig config CPU_ADDR_BITS · line 46
Quoted 5 lines
arch/x86/cpu/queensbay/Kconfig +2
-0@@ -42,4 +42,7 @@ config CPU_ADDR_BITS int default 32 +config SYS_MALLOC_F_LEN + default 0x800032KB? Wow that's a huge amount. How much does it actually use? Perhaps we should change PCI so that it respects the u-boot,dm-pre-reloc property?
Quoted 9 lines
Quoted 5 lines
I just add a zero to the original value :) I did not measure the actual memory consumption since after
fsp_init()we have plenty of memory to be used as the stack. For queensbay platform, it has lots of pci devices each of which will need allocate some memory for dm pci to use.I think it is worth checking this and using a value closer to what you need.
board_init_f.chas a debug output for it I think.OK, I will have a check.
Quoted 3 lines
Also I wonder if we can avoid creating PCI devices for everything pre-relocation, when we only need serial?
Quoted 7 lines
Yes, looks that we only need serial. However x86 is a specific case since pci bus is the fundamental bus that is used to set up other devices. After conversion to dm pci, if we implement it correctly, any call to a pci api will trigger the enumeration and it is probably a side effect of using dm? I even think we can hardcoded pci uart in the pre-relocation phase without using dm at all, but that is not a portable way.
Yes that's right. Of course for the UART we can do a special case at least for the debug UART, since that should be available early (before DM).
How about this:
- early stage, before board_init_f(): use special x86 PCI functions, enable UART
- pre-reloc: set up only a few devices which are needed before relocation
- post-reloc: full scan of PCI
Regards,
Simon
PATCH 3/5 x86: queensbay: Support pre-relocation dm pci
Hi Simon,
Quoted 70 lines · Simon Glass
Hi Bin,
Quoted 55 lines · Bin Meng
Hi Simon,
Quoted 36 lines · Simon Glass
Hi Bin,
Quoted 33 lines · Bin Meng
Hi Simon,
Quoted 29 lines · Simon Glass
Hi Bin,
Quoted 16 lines · Bin Meng
Increase
CONFIG_MALLOC_F_LENso that dm pci does not fail with-ENOMEMbefore relocation. This makes pci uart work again on Intel Crown Bay.Signed-off-by Bin Meng <[email protected]>---
arch/x86/cpu/queensbay/Kconfig | 3 +++ arch/x86/cpu/queensbay/tnc.c | 13 +++++++++++++ arch/x86/dts/crownbay.dts | 2 -- 3 files changed, 16 insertions(+), 2 deletions(-)arch/x86/cpu/queensbay/Kconfig +0
-0arch/x86/cpu/queensbay/Kconfig config CPU_ADDR_BITS · line 46
Quoted 5 lines
arch/x86/cpu/queensbay/Kconfig +2
-0@@ -42,4 +42,7 @@ config CPU_ADDR_BITS int default 32 +config SYS_MALLOC_F_LEN + default 0x800032KB? Wow that's a huge amount. How much does it actually use? Perhaps we should change PCI so that it respects the u-boot,dm-pre-reloc property?
Quoted 9 lines
Quoted 5 lines
I just add a zero to the original value :) I did not measure the actual memory consumption since after
fsp_init()we have plenty of memory to be used as the stack. For queensbay platform, it has lots of pci devices each of which will need allocate some memory for dm pci to use.I think it is worth checking this and using a value closer to what you need.
board_init_f.chas a debug output for it I think.OK, I will have a check.
Quoted 3 lines
Also I wonder if we can avoid creating PCI devices for everything pre-relocation, when we only need serial?
Quoted 7 lines
Yes, looks that we only need serial. However x86 is a specific case since pci bus is the fundamental bus that is used to set up other devices. After conversion to dm pci, if we implement it correctly, any call to a pci api will trigger the enumeration and it is probably a side effect of using dm? I even think we can hardcoded pci uart in the pre-relocation phase without using dm at all, but that is not a portable way.
Yes that's right. Of course for the UART we can do a special case at least for the debug UART, since that should be available early (before DM).
Quoted 6 lines
How about this:
- early stage, before
board_init_f(): use special x86 PCI functions, enable UART
- pre-reloc: set up only a few devices which are needed before relocation
- post-reloc: full scan of PCI
This sounds good. I will need do more investigation on this.
Regards,
Bin
PATCH 4/5 x86: Explicitly trigger pci bus configuration with driver model
In reply to Bin MengWith driver model, probing pci bus is all done on a lazy basis, as needed. On x86, pci bus is the fundamental device that needs to work before any other peripherals. In order to have a working pci before any other pci devices can be initialized, we need explicitly trigger the pci bus configuration.
---
common/board_r.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
common/board_r.c +16 -0
@@ -233,6 +233,22 @@ static int initr_pci(void) {#ifndef CONFIG_DM_PCI pci_init (); +#else +#ifdef CONFIG_X86 +/* +* With driver model, probing pci bus is all done on a lazy basis, +* as needed. On x86, pci bus is the fundamental device that needs +* to work before any other peripherals. In order to have a working +* pci before any other pci devices can be initialized, we need +* explicitly trigger the pci bus configuration. +*/ +struct udevice *dev; +int ret; + + ret =uclass_first_device (UCLASS_PCI , &dev); +if (ret) +return ret; +#endif #endif return 0 ;
Signature · 1 line
1.8.2.1
PATCH 4/5 x86: Explicitly trigger pci bus configuration with driver model
Hi Bin,
Quoted 25 lines · Bin Meng
With driver model, probing pci bus is all done on a lazy basis, as needed. On x86, pci bus is the fundamental device that needs to work before any other peripherals. In order to have a working pci before any other pci devices can be initialized, we need explicitly trigger the pci bus configuration.
Signed-off-by Bin Meng <[email protected]>---
common/board_r.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)common/board_r.c +5
-0@@ -233,6 +233,22 @@ static int initr_pci(void) {#ifndef CONFIG_DM_PCI pci_init (); +#else +#ifdef CONFIG_X86 +/* +* With driver model, probing pci bus is all done on a lazy basis, +* as needed. On x86, pci bus is the fundamental device that needs
common/board_r.c static int initr_pci(void) · line 250
Quoted 10 lines
common/board_r.c +10
-0+* to work before any other peripherals. In order to have a working +* pci before any other pci devices can be initialized, we need +* explicitly trigger the pci bus configuration. +*/ +struct udevice *dev; +int ret; + + ret =uclass_first_device (UCLASS_PCI , &dev); +if (ret) +return ret;
Won't this happen anyway when you first access a PCI device?
Quoted 7 lines
common/board_r.c +1
-1+#endif #endif return 0 ; --1.8.2.1
Regards,
Simon
PATCH 4/5 x86: Explicitly trigger pci bus configuration with driver model
Hi Simon,
Quoted 32 lines · Simon Glass
Hi Bin,
Quoted 29 lines · Bin Meng
With driver model, probing pci bus is all done on a lazy basis, as needed. On x86, pci bus is the fundamental device that needs to work before any other peripherals. In order to have a working pci before any other pci devices can be initialized, we need explicitly trigger the pci bus configuration.
Signed-off-by Bin Meng <[email protected]>---
common/board_r.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)common/board_r.c +9
-0@@ -233,6 +233,22 @@ static int initr_pci(void) {#ifndef CONFIG_DM_PCI pci_init (); +#else +#ifdef CONFIG_X86 +/* +* With driver model, probing pci bus is all done on a lazy basis, +* as needed. On x86, pci bus is the fundamental device that needs +* to work before any other peripherals. In order to have a working +* pci before any other pci devices can be initialized, we need +* explicitly trigger the pci bus configuration. +*/
Quoted 9 lines
common/board_r.c static int initr_pci(void) · line 250
Quoted 6 lines
common/board_r.c +6
-0+struct udevice *dev; +int ret; + + ret =uclass_first_device (UCLASS_PCI , &dev); +if (ret) +return ret;Won't this happen anyway when you first access a PCI device?
Unfortunately no. The pci bus configuration will not be triggered when calling pci config read/write.
[snip]
Regards,
Bin
PATCH 4/5 x86: Explicitly trigger pci bus configuration with driver model
Hi Bin,
Quoted 45 lines · Bin Meng
Hi Simon,
Quoted 32 lines · Simon Glass
Hi Bin,
Quoted 29 lines · Bin Meng
With driver model, probing pci bus is all done on a lazy basis, as needed. On x86, pci bus is the fundamental device that needs to work before any other peripherals. In order to have a working pci before any other pci devices can be initialized, we need explicitly trigger the pci bus configuration.
Signed-off-by Bin Meng <[email protected]>---
common/board_r.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)common/board_r.c +9
-0@@ -233,6 +233,22 @@ static int initr_pci(void) {#ifndef CONFIG_DM_PCI pci_init (); +#else +#ifdef CONFIG_X86 +/* +* With driver model, probing pci bus is all done on a lazy basis, +* as needed. On x86, pci bus is the fundamental device that needs +* to work before any other peripherals. In order to have a working +* pci before any other pci devices can be initialized, we need +* explicitly trigger the pci bus configuration. +*/ Quoted 9 lines
common/board_r.c static int initr_pci(void) · line 250
Quoted 6 lines
common/board_r.c +6
-0+struct udevice *dev; +int ret; + + ret =uclass_first_device (UCLASS_PCI , &dev); +if (ret) +return ret;Won't this happen anyway when you first access a PCI device?
Quoted 4 lines
Unfortunately no. The pci bus configuration will not be triggered when calling pci config read/write.
[snip]
We should be able to use the dm_pci_config..() functions and by just getting hold of the bus device it should probe the bus before doing any config. Then it would be auto-triggered.
In general we should try to make use of automatic probing - it was supposed to be a key feature of driver model.
Regards,
Simon
PATCH 4/5 x86: Explicitly trigger pci bus configuration with driver model
Hi Simon,
Quoted 48 lines · Simon Glass
Hi Bin,
Quoted 45 lines · Bin Meng
Hi Simon,
Quoted 41 lines · Simon Glass
Hi Bin,
Quoted 25 lines · Bin Meng
With driver model, probing pci bus is all done on a lazy basis, as needed. On x86, pci bus is the fundamental device that needs to work before any other peripherals. In order to have a working pci before any other pci devices can be initialized, we need explicitly trigger the pci bus configuration.
Signed-off-by Bin Meng <[email protected]>---
common/board_r.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)common/board_r.c +5
-0@@ -233,6 +233,22 @@ static int initr_pci(void) {#ifndef CONFIG_DM_PCI pci_init (); +#else +#ifdef CONFIG_X86 +/* +* With driver model, probing pci bus is all done on a lazy basis, +* as needed. On x86, pci bus is the fundamental device that needs common/board_r.c static int initr_pci(void) · line 250
Quoted 10 lines
common/board_r.c +10
-0+* to work before any other peripherals. In order to have a working +* pci before any other pci devices can be initialized, we need +* explicitly trigger the pci bus configuration. +*/ +struct udevice *dev; +int ret; + + ret =uclass_first_device (UCLASS_PCI , &dev); +if (ret) +return ret;Won't this happen anyway when you first access a PCI device?
Quoted 8 lines
Quoted 4 lines
Unfortunately no. The pci bus configuration will not be triggered when calling pci config read/write.
[snip]
We should be able to use the dm_pci_config..() functions and by just getting hold of the bus device it should probe the bus before doing any config. Then it would be auto-triggered.
So far I don't see any config r/w routines can trigger the enumeration.
Quoted 4 lines
In general we should try to make use of automatic probing - it was supposed to be a key feature of driver model.
Yep I know this is supposed to be done this way. I am not sure how it looks like on other domain, but at least it is now broken for dm pci. In order to get the enumeration process automatically triggered, we need make sure all public pci apis will end up triggering the configuration.
Regards,
Bin
PATCH 4/5 x86: Explicitly trigger pci bus configuration with driver model
Hi Bin,
Quoted 67 lines · Bin Meng
Hi Simon,
Quoted 48 lines · Simon Glass
Hi Bin,
Quoted 45 lines · Bin Meng
Hi Simon,
Quoted 41 lines · Simon Glass
Hi Bin,
Quoted 25 lines · Bin Meng
With driver model, probing pci bus is all done on a lazy basis, as needed. On x86, pci bus is the fundamental device that needs to work before any other peripherals. In order to have a working pci before any other pci devices can be initialized, we need explicitly trigger the pci bus configuration.
Signed-off-by Bin Meng <[email protected]>---
common/board_r.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)common/board_r.c +5
-0@@ -233,6 +233,22 @@ static int initr_pci(void) {#ifndef CONFIG_DM_PCI pci_init (); +#else +#ifdef CONFIG_X86 +/* +* With driver model, probing pci bus is all done on a lazy basis, +* as needed. On x86, pci bus is the fundamental device that needs common/board_r.c static int initr_pci(void) · line 250
Quoted 10 lines
common/board_r.c +10
-0+* to work before any other peripherals. In order to have a working +* pci before any other pci devices can be initialized, we need +* explicitly trigger the pci bus configuration. +*/ +struct udevice *dev; +int ret; + + ret =uclass_first_device (UCLASS_PCI , &dev); +if (ret) +return ret;Won't this happen anyway when you first access a PCI device?
Quoted 8 lines
Quoted 4 lines
Unfortunately no. The pci bus configuration will not be triggered when calling pci config read/write.
[snip]
We should be able to use the dm_pci_config..() functions and by just getting hold of the bus device it should probe the bus before doing any config. Then it would be auto-triggered.
So far I don't see any config r/w routines can trigger the enumeration.
Quoted 4 lines
In general we should try to make use of automatic probing - it was supposed to be a key feature of driver model.
Quoted 5 lines
Yep I know this is supposed to be done this way. I am not sure how it looks like on other domain, but at least it is now broken for dm pci. In order to get the enumeration process automatically triggered, we need make sure all public pci apis will end up triggering the configuration.
Provided that we always call uclass_get_device() or any of those *_get_* functions then the bus will be probed and thus enumerated.
The problem is that we have these sideways functions to accessing PCI on x86. Once we get rid of those then we should be OK. Everything should use a struct udevice.
Regards,
Simon
PATCH 4/5 x86: Explicitly trigger pci bus configuration with driver model
Hi Simon,
Quoted 70 lines · Simon Glass
Hi Bin,
Quoted 67 lines · Bin Meng
Hi Simon,
Quoted 48 lines · Simon Glass
Hi Bin,
Quoted 45 lines · Bin Meng
Hi Simon,
Quoted 41 lines · Simon Glass
Hi Bin,
Quoted 25 lines · Bin Meng
With driver model, probing pci bus is all done on a lazy basis, as needed. On x86, pci bus is the fundamental device that needs to work before any other peripherals. In order to have a working pci before any other pci devices can be initialized, we need explicitly trigger the pci bus configuration.
Signed-off-by Bin Meng <[email protected]>---
common/board_r.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)common/board_r.c +5
-0@@ -233,6 +233,22 @@ static int initr_pci(void) {#ifndef CONFIG_DM_PCI pci_init (); +#else +#ifdef CONFIG_X86 +/* +* With driver model, probing pci bus is all done on a lazy basis, +* as needed. On x86, pci bus is the fundamental device that needs common/board_r.c static int initr_pci(void) · line 250
Quoted 10 lines
common/board_r.c +10
-0+* to work before any other peripherals. In order to have a working +* pci before any other pci devices can be initialized, we need +* explicitly trigger the pci bus configuration. +*/ +struct udevice *dev; +int ret; + + ret =uclass_first_device (UCLASS_PCI , &dev); +if (ret) +return ret;Won't this happen anyway when you first access a PCI device?
Quoted 8 lines
Quoted 4 lines
Unfortunately no. The pci bus configuration will not be triggered when calling pci config read/write.
[snip]
We should be able to use the dm_pci_config..() functions and by just getting hold of the bus device it should probe the bus before doing any config. Then it would be auto-triggered.
So far I don't see any config r/w routines can trigger the enumeration.
Quoted 4 lines
In general we should try to make use of automatic probing - it was supposed to be a key feature of driver model.
Quoted 9 lines
Quoted 5 lines
Yep I know this is supposed to be done this way. I am not sure how it looks like on other domain, but at least it is now broken for dm pci. In order to get the enumeration process automatically triggered, we need make sure all public pci apis will end up triggering the configuration.
Provided that we always call
uclass_get_device()or any of those *_get_* functions then the bus will be probed and thus enumerated.
Yes.
Quoted 4 lines
The problem is that we have these sideways functions to accessing PCI on x86. Once we get rid of those then we should be OK. Everything should use a struct udevice.
Do you plan to fix this or is there already a patch that I missed?
Regards,
Bin
PATCH 4/5 x86: Explicitly trigger pci bus configuration with driver model
Hi Bin,
Quoted 83 lines · Bin Meng
Hi Simon,
Quoted 70 lines · Simon Glass
Hi Bin,
Quoted 67 lines · Bin Meng
Hi Simon,
Quoted 48 lines · Simon Glass
Hi Bin,
Quoted 45 lines · Bin Meng
Hi Simon,
Quoted 41 lines · Simon Glass
Hi Bin,
Quoted 25 lines · Bin Meng
With driver model, probing pci bus is all done on a lazy basis, as needed. On x86, pci bus is the fundamental device that needs to work before any other peripherals. In order to have a working pci before any other pci devices can be initialized, we need explicitly trigger the pci bus configuration.
Signed-off-by Bin Meng <[email protected]>---
common/board_r.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)common/board_r.c +5
-0@@ -233,6 +233,22 @@ static int initr_pci(void) {#ifndef CONFIG_DM_PCI pci_init (); +#else +#ifdef CONFIG_X86 +/* +* With driver model, probing pci bus is all done on a lazy basis, +* as needed. On x86, pci bus is the fundamental device that needs common/board_r.c static int initr_pci(void) · line 250
Quoted 10 lines
common/board_r.c +10
-0+* to work before any other peripherals. In order to have a working +* pci before any other pci devices can be initialized, we need +* explicitly trigger the pci bus configuration. +*/ +struct udevice *dev; +int ret; + + ret =uclass_first_device (UCLASS_PCI , &dev); +if (ret) +return ret;Won't this happen anyway when you first access a PCI device?
Quoted 8 lines
Quoted 4 lines
Unfortunately no. The pci bus configuration will not be triggered when calling pci config read/write.
[snip]
We should be able to use the dm_pci_config..() functions and by just getting hold of the bus device it should probe the bus before doing any config. Then it would be auto-triggered.
So far I don't see any config r/w routines can trigger the enumeration.
Quoted 4 lines
In general we should try to make use of automatic probing - it was supposed to be a key feature of driver model.
Quoted 9 lines
Quoted 5 lines
Yep I know this is supposed to be done this way. I am not sure how it looks like on other domain, but at least it is now broken for dm pci. In order to get the enumeration process automatically triggered, we need make sure all public pci apis will end up triggering the configuration.
Provided that we always call
uclass_get_device()or any of those *_get_* functions then the bus will be probed and thus enumerated.
Quoted 8 lines
Yes.
Quoted 4 lines
The problem is that we have these sideways functions to accessing PCI on x86. Once we get rid of those then we should be OK. Everything should use a struct udevice.
Do you plan to fix this or is there already a patch that I missed?
Not really. I am thinking that we should try to use the dm_pci functions but until we get into it I'm not sure how easy it is.
Regards,
Simon
PATCH 5/5 doc: dm: Update pci-info.txt for pci support
In reply to Bin MengCorrect two typos and mention how pci bus will be probed.
---
doc/driver-model/pci-info.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
doc/driver-model/pci-info.txt +3 -3
@@ -6,7 +6,7 @@ How busses are scanned Any config read will end up at pci_read_config(). This uses uclass_get_device_by_seq() to get the PCI bus for a particular bus number. -Bus number 0 will need to be requested first, and the alias in the device +Bus number 0 will need to be requested first, and the alias in the device tree file will point to the correct device:
@@ -23,7 +23,7 @@ tree file will point to the correct device: If there is no alias the devices will be numbered sequentially in the device tree. -The call to uclass_get_device by seq() will cause the PCI bus to be probed. +The call to uclass_get_device() will cause the PCI bus to be probed. This does a scan of the bus to locate available devices. These devices are bound to their appropriate driver if available. If there is no driver, then they are bound to a generic PCI driver which does nothing.
@@ -32,7 +32,7 @@ After probing a bus, the available devices will appear in the device tree under that bus. Note that this is all done on a lazy basis, as needed, so until something is -touched on PCI it will not be probed. +touched on PCI (eg: a call to pci_find_devices()) it will not be probed. PCI devices can appear in the device tree. If they do this serves to specify the driver to use for the device. In this case they will be bound at
Signature · 1 line
1.8.2.1
PATCH 5/5 doc: dm: Update pci-info.txt for pci support
Quoted 7 lines · Bin Meng
Correct two typos and mention how pci bus will be probed.
Signed-off-by Bin Meng <[email protected]>---
doc/driver-model/pci-info.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
PATCH 5/5 doc: dm: Update pci-info.txt for pci support
Quoted 10 lines · Simon Glass
Quoted 7 lines · Bin Meng
Correct two typos and mention how pci bus will be probed.
Signed-off-by Bin Meng <[email protected]>---
doc/driver-model/pci-info.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)Acked-by Simon Glass <[email protected]>
Applied to u-boot-x86, thanks!
PATCH 1/5 dm: pci: Allow scan bridge child devices before relocation
In reply to Bin MengQuoted 9 lines · Bin Meng
On some platforms pci devices behind bridge need to be probed (eg:
a pci uart on recent x86 chipset) before relocation. Remove such limitation so that dm pci can be used before relocation.Signed-off-by Bin Meng <[email protected]>---
drivers/pci/pci-uclass.c | 4 ---- 1 file changed, 4 deletions(-)
PATCH 1/5 dm: pci: Allow scan bridge child devices before relocation
Quoted 5 lines · Simon Glass
Quoted 4 lines · Bin Meng
On some platforms pci devices behind bridge need to be probed (eg:
a pci uart on recent x86 chipset) before relocation. Remove such limitation so that dm pci can be used before relocation.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Bin Meng <[email protected]>---
drivers/pci/pci-uclass.c | 4 ---- 1 file changed, 4 deletions(-)Acked-by Simon Glass <[email protected]>
Applied to u-boot-x86, thanks!
PATCH 1/5 dm: pci: Allow scan bridge child devices before relocation
Hi Bin,
Quoted 9 lines · Simon Glass
Quoted 8 lines · Simon Glass
Quoted 7 lines · Bin Meng
On some platforms pci devices behind bridge need to be probed (eg:
a pci uart on recent x86 chipset) before relocation. Remove such limitation so that dm pci can be used before relocation.Signed-off-by Bin Meng <[email protected]>---
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
drivers/pci/pci-uclass.c | 4 ---- 1 file changed, 4 deletions(-)Acked-by Simon Glass <[email protected]>Applied to u-boot-x86, thanks!
It turns out that this breaks chromebook_link, probably because of the large number of devices it adds to the tree before relocation.
When you can a chance can you please try to figure out a solution for this? I think we need to be able to mark certain devices as pre-reloc, but create devices the whole bus. It wastes time and memory.
I believe this is only needed for the serial port at present. How is that actually detected? Perhaps we could add it to the device tree or find another way to mark it as pre-relocation?
Regards,
Simon
PATCH 1/5 dm: pci: Allow scan bridge child devices before relocation
Hi Simon,
Quoted 15 lines · Simon Glass
Hi Bin,
Quoted 12 lines · Simon Glass
Quoted 11 lines · Simon Glass
Quoted 9 lines · Bin Meng
On some platforms pci devices behind bridge need to be probed (eg:
a pci uart on recent x86 chipset) before relocation. Remove such limitation so that dm pci can be used before relocation.Signed-off-by Bin Meng <[email protected]>---
drivers/pci/pci-uclass.c | 4 ---- 1 file changed, 4 deletions(-)
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Acked-by Simon Glass <[email protected]>Applied to u-boot-x86, thanks!
It turns out that this breaks
chromebook_link, probably because of the large number of devices it adds to the tree before relocation.
Oops, let's remove this patch from the u-boot-x86/master for now.
Quoted 8 lines
When you can a chance can you please try to figure out a solution for this? I think we need to be able to mark certain devices as pre-reloc, but create devices the whole bus. It wastes time and memory.
I believe this is only needed for the serial port at present. How is that actually detected? Perhaps we could add it to the device tree or find another way to mark it as pre-relocation?
I will look into pci uart with dm some time.
Regards,
Bin