[U-Boot] [PATCH 1/1] pci: pci_mvebu: fix bus enumeration if some buses have empty slots

Marek BehĂșn marek.behun at nic.cz
Tue May 14 15:07:44 UTC 2019


On Tue, 14 May 2019 16:58:59 +0200
Marek BehĂșn <marek.behun at nic.cz> wrote:

> The ofdata_to_platdata method for this driver returns -ENODEV if link
> is down for a given bus, for example if there is no device in the
> slot. This causes the uclass_{first,next}_device to return NULL for
> this bus in pci-uclass.c:pci_init, which of course stops probing of
> buses which come after.
> 
> So if the slot on the first bus is empty on Turris Omnia, and the slot
> on second bus has a device connected, the device is not probed in
> U-Boot. On Turris Omnia the PCIe devices have to be probed in U-Boot
> to work correctly in Linux. Therefore we need this fix.
> 
...
>  	if (!mvebu_pcie_link_up(pcie)) {
>  		debug("%s: %s - down\n", __func__, pcie->name);
> -		ret = -ENODEV;
>  		goto err;
>  	}
>  

The problem is how uclass_{first,next}_device functions work.

They use helpers uclass_find_{first,next}_device, which iterate all
devices. But uclass_{first,next}_device functions also use
uclass_get_device_tail on the device returned by helper. This function
can return NULL if device failed to probe, which causes the iteration
to stop.

Wouldn't it be better if uclass_next_device tried iterating via
uclass_find_next_device until a device was found which probed
successfully?

I don't know if this would break other things in U-Boot though.

Marek


More information about the U-Boot mailing list