From: Suneel Garapati <sgarap...@marvell.com>

If ARI capability is found on device, use it to update next function
number in bus scan and also helps to skip unnecessary bdf scans.

Signed-off-by: Suneel Garapati <sgarap...@marvell.com>
---
 drivers/pci/pci-uclass.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index f9823231b1..b02588b552 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -773,7 +773,7 @@ int pci_bind_bus_devices(struct udevice *bus)
        ulong header_type;
        pci_dev_t bdf, end;
        bool found_multi;
-       int ret;
+       int ret, ari_off;
 
        found_multi = false;
        end = PCI_BDF(bus->seq, PCI_MAX_PCI_DEVICES - 1,
@@ -846,6 +846,22 @@ int pci_bind_bus_devices(struct udevice *bus)
                pplat->vendor = vendor;
                pplat->device = device;
                pplat->class = class;
+
+               ari_off = dm_pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ARI);
+               if (ari_off) {
+                       u16 ari_cap;
+
+                       /* Read Next Function number in ARI Cap Register */
+                       dm_pci_read_config16(dev, ari_off + 4, &ari_cap);
+                       /* Update next scan on this function number,
+                        * subtract 1 in BDF to satisfy loop increment.
+                        */
+                       if (ari_cap & 0xff00) {
+                               bdf = PCI_BDF(PCI_BUS(bdf), PCI_DEV(ari_cap),
+                                             PCI_FUNC(ari_cap));
+                               bdf = bdf - 0x100;
+                       }
+               }
        }
 
        return 0;
-- 
2.23.0

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

Reply via email to