diff mbox series

[U-Boot,RFC,10/29] drivers: pci-uclass: Add support for Alternate-RoutingID capability

Message ID 20191029210821.1954-11-suneelglinux@gmail.com
State RFC
Delegated to: Tom Rini
Headers show
Series arm: Introduce Marvell/Cavium OcteonTX | expand

Commit Message

Suneel Garapati Oct. 29, 2019, 9:08 p.m. UTC
From: Suneel Garapati <sgarapati@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 <sgarapati@marvell.com>
---
 drivers/pci/pci-uclass.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

Comments

Simon Glass Nov. 20, 2019, 3 a.m. UTC | #1
On Tue, 29 Oct 2019 at 14:08, Suneel Garapati <suneelglinux@gmail.com> wrote:
>
> From: Suneel Garapati <sgarapati@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 <sgarapati@marvell.com>
> ---
>  drivers/pci/pci-uclass.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

>
> 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,

/*
 * Update ...

(please fix globally)

Also again I think this needs to be behind a Kconfig.

> +                        * 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
>

Regards,
Simon
diff mbox series

Patch

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;