[RESEND PATCH 2/4] pci-uclass: respect ofnode_read_pci_vendev retval
Torsten Duwe
duwe at lst.de
Wed Nov 19 17:47:40 CET 2025
Hi Peter,
please don't apply this one yet.
On Wed, 5 Nov 2025 17:44:32 +0100 (CET)
Torsten Duwe <duwe at lst.de> wrote:
> The vendor:device read in pci_uclass_child_post_bind() might fail,
> which is currently ignored. In that case e.g. the RP1 on the RasPi5
> is erroneously being treated as a host bridge.
>
> Mark the device's PCI info as invalid in case of failure.
>
> Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk at epam.com>
> Reviewed-by: Volodymyr Babchuk <volodymyr_babchuk at epam.com>
> Signed-off-by: Oleksii Moisieiev <oleksii_moisieiev at epam.com>
> Signed-off-by: Torsten Duwe <duwe at suse.de>
> Reviewed-by: Oleksii Moisieiev <oleksii_moisieiev at epam.com>
> ---
> drivers/pci/pci-uclass.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
> index c370f8c6400..4092e8ff5a9 100644
> --- a/drivers/pci/pci-uclass.c
> +++ b/drivers/pci/pci-uclass.c
> @@ -1200,6 +1200,7 @@ static int pci_uclass_post_probe(struct udevice *bus)
> static int pci_uclass_child_post_bind(struct udevice *dev)
> {
> struct pci_child_plat *pplat;
> + int err;
>
> if (!dev_has_ofnode(dev))
> return 0;
> @@ -1207,7 +1208,13 @@ static int pci_uclass_child_post_bind(struct udevice *dev)
> pplat = dev_get_parent_plat(dev);
>
> /* Extract vendor id and device id if available */
> - ofnode_read_pci_vendev(dev_ofnode(dev), &pplat->vendor, &pplat->device);
> + err = ofnode_read_pci_vendev(dev_ofnode(dev), &pplat->vendor,
> + &pplat->device);
> + if (err) {
> + /* Mark PCI device structure as invalid */
> + pplat->devfn = -1;
While I guess we all agree that an error return should not be ignored,
there might still be a better solution in this case. pplat->devfn = -1
might prevent the worst, but I assume the PCI dev
| 02.1f.07 0xffff 0xffff Does not fit any class 0xff
is a result of that.
> + return 0;
> + }
>
> /* Extract the devfn from fdt_pci_addr */
> pplat->devfn = pci_get_devfn(dev);
thanks,
Torsten
More information about the U-Boot
mailing list