Message ID | 1453831814-23973-1-git-send-email-swarren@wwwdotorg.org |
---|---|
State | Accepted |
Delegated to: | Simon Glass |
Headers | show |
On 26 January 2016 at 11:10, Stephen Warren <swarren@wwwdotorg.org> wrote: > From: Stephen Warren <swarren@nvidia.com> > > With CONFIG_DM_PCI enabled, PCI buses are not enumerated at boot, as they > are without that config option enabled. No command exists to enumerate the > PCI buses. Hence, unless some board-specific code causes PCI enumeration, > PCI-based Ethernet devices are not detected, and network access is not > available. > > This patch implements "pci enum" in the CONFIG_DM_PCI case, thus giving a > mechanism whereby PCI can be enumerated. > > do_pci()'s handling of case 'e' is moved into a single location before the > dev variable is assigned, in order to skip calculation of dev. The enum > sub-command doesn't need the dev value, and skipping its calculation > avoids an irrelevant error being printed. > > Using a command to initialize PCI like this has a disadvantage relative to > enumerating PCI at boot. In particular, Ethernet devices are not probed > during PCI enumeration, but only when used. This defers setting variables > such as ethact, ethaddr, etc. until the first network-related command is > executed. Hopefully this will not cause further issues. Perhaps in the > long term, we need a "net start/enum" command too? > > Signed-off-by: Stephen Warren <swarren@nvidia.com> > --- > This series naturally needs to be applied in order in a single branch. > This series depends on all previous applied test/py patches. > > common/cmd_pci.c | 18 +++++------------- > drivers/pci/pci-uclass.c | 15 +++++++++++++++ > 2 files changed, 20 insertions(+), 13 deletions(-) Reviewed-by: Simon Glass <sjg@chromium.org>
On Wed, Jan 27, 2016 at 2:10 AM, Stephen Warren <swarren@wwwdotorg.org> wrote: > From: Stephen Warren <swarren@nvidia.com> > > With CONFIG_DM_PCI enabled, PCI buses are not enumerated at boot, as they > are without that config option enabled. No command exists to enumerate the > PCI buses. Hence, unless some board-specific code causes PCI enumeration, > PCI-based Ethernet devices are not detected, and network access is not > available. > > This patch implements "pci enum" in the CONFIG_DM_PCI case, thus giving a > mechanism whereby PCI can be enumerated. > > do_pci()'s handling of case 'e' is moved into a single location before the > dev variable is assigned, in order to skip calculation of dev. The enum > sub-command doesn't need the dev value, and skipping its calculation > avoids an irrelevant error being printed. > > Using a command to initialize PCI like this has a disadvantage relative to > enumerating PCI at boot. In particular, Ethernet devices are not probed > during PCI enumeration, but only when used. This defers setting variables > such as ethact, ethaddr, etc. until the first network-related command is > executed. Hopefully this will not cause further issues. Perhaps in the > long term, we need a "net start/enum" command too? > > Signed-off-by: Stephen Warren <swarren@nvidia.com> > --- > This series naturally needs to be applied in order in a single branch. > This series depends on all previous applied test/py patches. > > common/cmd_pci.c | 18 +++++------------- > drivers/pci/pci-uclass.c | 15 +++++++++++++++ > 2 files changed, 20 insertions(+), 13 deletions(-) > Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
On 26 January 2016 at 23:17, Bin Meng <bmeng.cn@gmail.com> wrote: > On Wed, Jan 27, 2016 at 2:10 AM, Stephen Warren <swarren@wwwdotorg.org> wrote: >> From: Stephen Warren <swarren@nvidia.com> >> >> With CONFIG_DM_PCI enabled, PCI buses are not enumerated at boot, as they >> are without that config option enabled. No command exists to enumerate the >> PCI buses. Hence, unless some board-specific code causes PCI enumeration, >> PCI-based Ethernet devices are not detected, and network access is not >> available. >> >> This patch implements "pci enum" in the CONFIG_DM_PCI case, thus giving a >> mechanism whereby PCI can be enumerated. >> >> do_pci()'s handling of case 'e' is moved into a single location before the >> dev variable is assigned, in order to skip calculation of dev. The enum >> sub-command doesn't need the dev value, and skipping its calculation >> avoids an irrelevant error being printed. >> >> Using a command to initialize PCI like this has a disadvantage relative to >> enumerating PCI at boot. In particular, Ethernet devices are not probed >> during PCI enumeration, but only when used. This defers setting variables >> such as ethact, ethaddr, etc. until the first network-related command is >> executed. Hopefully this will not cause further issues. Perhaps in the >> long term, we need a "net start/enum" command too? >> >> Signed-off-by: Stephen Warren <swarren@nvidia.com> >> --- >> This series naturally needs to be applied in order in a single branch. >> This series depends on all previous applied test/py patches. >> >> common/cmd_pci.c | 18 +++++------------- >> drivers/pci/pci-uclass.c | 15 +++++++++++++++ >> 2 files changed, 20 insertions(+), 13 deletions(-) >> > > Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Applied to u-boot-dm, thanks!
diff --git a/common/cmd_pci.c b/common/cmd_pci.c index 8094d3380fbd..2f4978af9fe3 100644 --- a/common/cmd_pci.c +++ b/common/cmd_pci.c @@ -578,9 +578,10 @@ static int do_pci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if ((bdf = get_pci_dev(argv[2])) == -1) return 1; break; -#ifdef CONFIG_CMD_PCI_ENUM +#if defined(CONFIG_CMD_PCI_ENUM) || defined(CONFIG_DM_PCI) case 'e': - break; + pci_init(); + return 0; #endif default: /* scan bus */ value = 1; /* short listing */ @@ -621,15 +622,6 @@ static int do_pci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) break; case 'd': /* display */ return pci_cfg_display(dev, addr, size, value); -#ifdef CONFIG_CMD_PCI_ENUM - case 'e': -# ifdef CONFIG_DM_PCI - printf("This command is not yet supported with driver model\n"); -# else - pci_init(); -# endif - break; -#endif case 'n': /* next */ if (argc < 4) goto usage; @@ -665,9 +657,9 @@ static int do_pci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) static char pci_help_text[] = "[bus] [long]\n" " - short or long list of PCI devices on bus 'bus'\n" -#ifdef CONFIG_CMD_PCI_ENUM +#if defined(CONFIG_CMD_PCI_ENUM) || defined(CONFIG_DM_PCI) "pci enum\n" - " - re-enumerate PCI buses\n" + " - Enumerate PCI buses\n" #endif "pci header b.d.f\n" " - show header of PCI device 'bus.device.function'\n" diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index 685df9d274e4..f51f08289d66 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -1247,3 +1247,18 @@ U_BOOT_DRIVER(pci_generic_drv) = { .id = UCLASS_PCI_GENERIC, .of_match = pci_generic_ids, }; + +void pci_init(void) +{ + struct udevice *bus; + + /* + * Enumerate all known controller devices. Enumeration has the side- + * effect of probing them, so PCIe devices will be enumerated too. + */ + for (uclass_first_device(UCLASS_PCI, &bus); + bus; + uclass_next_device(&bus)) { + ; + } +}