[U-Boot] [PATCH] cmd_pci: Check for VendorID earlier

Simon Glass sjg at chromium.org
Fri Oct 9 11:36:49 CEST 2015


Hi Fabio,

On 8 October 2015 at 00:37, Fabio Estevam <festevam at gmail.com> wrote:
> From: Fabio Estevam <fabio.estevam at freescale.com>
>
> Since commit ff3e077bd2 ("dm: pci: Add a uclass for PCI") the following
> error message is seen:
>
> => pci 0
> Scanning PCI devices on bus 0
> BusDevFun  VendorId   DeviceId   Device Class       Sub-Class
> _____________________________________________________________
> 00.01.00   0x16c3     0xabcd     Bridge device           0x04
> Cannot read bus configuration: -1
>
> => pci 1
> Scanning PCI devices on bus 1
> BusDevFun  VendorId   DeviceId   Device Class       Sub-Class
> _____________________________________________________________
> 01.00.00   0x8086     0x08b1     Network controller      0x80
> Cannot read bus configuration: -1
>
> When we are done scanning the PCI devices pci_read_config_word() will
> return -1 and VendorID will contain 0xFFFF.
>
> The original code would exit the 'for' loop in this condition.
>
> Keep the same original behaviour by first testing the VendorID value
> and then checking and propagating the pci_read_config_word() error
> afterwards.
>
> Signed-off-by: Fabio Estevam <fabio.estevam at freescale.com>
> ---
>  common/cmd_pci.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/common/cmd_pci.c b/common/cmd_pci.c
> index dcecef8..92dc643 100644
> --- a/common/cmd_pci.c
> +++ b/common/cmd_pci.c
> @@ -77,10 +77,10 @@ void pciinfo(int BusNum, int ShortPCIListing)
>
>                         ret = pci_read_config_word(dev, PCI_VENDOR_ID,
>                                                    &VendorID);
> -                       if (ret)
> -                               goto error;
>                         if ((VendorID == 0xFFFF) || (VendorID == 0x0000))
>                                 continue;
> +                       if (ret)
> +                               goto error;
>
>                         if (!Function) pci_read_config_byte(dev, PCI_HEADER_TYPE, &HeaderType);
>
> --
> 1.9.1
>

This seems really odd to me. Why would pci_read_config_word() return
an error if there is no device there? Is that the real bug here?

Regards,
Simon


More information about the U-Boot mailing list