From mboxrd@z Thu Jan 1 00:00:00 1970 From: Suneel Garapati Date: Tue, 29 Oct 2019 14:08:02 -0700 Subject: [U-Boot] [RFC PATCH 10/29] drivers: pci-uclass: Add support for Alternate-RoutingID capability In-Reply-To: <20191029210821.1954-1-suneelglinux@gmail.com> References: <20191029210821.1954-1-suneelglinux@gmail.com> Message-ID: <20191029210821.1954-11-suneelglinux@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de From: Suneel Garapati 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 --- 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