dm: pci: Fix handling of errors when scanning device
authorPali Rohár <pali@kernel.org>
Tue, 7 Sep 2021 16:07:08 +0000 (18:07 +0200)
committerSimon Glass <sjg@chromium.org>
Sat, 25 Sep 2021 15:46:15 +0000 (09:46 -0600)
commit2348e72d6d56129cf84c5c98cf9d5631efb098e9
tree7018d691acd767ce4bfcda07420a3bc3ce947d8e
parent8ae8da10b339349586daad0ceb5c0cb655b5ef6d
dm: pci: Fix handling of errors when scanning device

Some PCIe controller's read_config() method support indicating error
directly via return value, but some cannot distinguish all-ones (or
all-zeros) read response from an error.

The current code in pci_bind_bus_devices() interprets all-ones /
all-zeros in PCI_VENDOR_ID register as "nothing connected", and
continues the cycle, but an error returned via return value breaks the
cycle.

This is wrong for the PCIe controllers which return this error via
return value.

Handle all errors when reading PCI_VENDOR_ID the same way.

This fixes enumeration of PCI devices for example when there is a PCI
bridge connected behind another PCI bridge and not all ports are
connected to a device, and the controller (for example Aardvark)
translates the UR error (Unsupported Request) as -EOPNOTSUPP.

Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
drivers/pci/pci-uclass.c