From patchwork Mon Aug 17 07:07:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roese X-Patchwork-Id: 1345690 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=nkSGuJL5; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BVQDt3x2pz9sPC for ; Mon, 17 Aug 2020 17:10:54 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 730E782245; Mon, 17 Aug 2020 09:08:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1597648118; bh=8/5dsO/sdYHBLzc66ssXqQrumaCuApaBaQ8FOtpN8mQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=nkSGuJL5Grjy+o5nrSM+tL/PyxTIDR7uQ46Y95J7jcggtucHHYAJU3IuwbZiut0fb KuUTGG2WeHzpY2Mle6TdsKN3212b4q3KAiSqZbbAxwtHa0/vcHJhu5CpudBx7UCZ1t R54uLKQbEYzR8p+snTrZCM5kz2ZUkIdy7n2HKryP5YE6QoTPgwxMLnAShZXQA7apnN i+OsRLt3kGAVVWLDmK9DAvrqrRYZ0iJwMuKaI+qtWuHxwlUlVhAYIG8gV2HZOSBBzv TT5j6+YMdBK2xjUw2AN480EdzpuZrz2SPH9m9kLFL3OWK8Dtv7dULz4hXPd4airteh VYS7dmJpQQPQA== Received: by phobos.denx.de (Postfix, from userid 109) id 4AAB88224E; Mon, 17 Aug 2020 09:08:18 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, SPF_HELO_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from mx2.mailbox.org (mx2a.mailbox.org [IPv6:2001:67c:2050:104:0:2:25:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E6B54821FC for ; Mon, 17 Aug 2020 09:08:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=sr@denx.de Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 87963A29EB; Mon, 17 Aug 2020 09:08:10 +0200 (CEST) Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter04.heinlein-hosting.de (spamfilter04.heinlein-hosting.de [80.241.56.122]) (amavisd-new, port 10030) with ESMTP id aE7daYKT0Z-Y; Mon, 17 Aug 2020 09:08:07 +0200 (CEST) From: Stefan Roese To: u-boot@lists.denx.de Cc: sjg@chromium.org, awilliams@marvell.com, trini@konsulko.com, sgarapati@marvell.com, cchavva@marvell.com, Bin Meng Subject: [PATCH v2 12/25] pci: pci-uclass: Add support for Alternate-RoutingID capability Date: Mon, 17 Aug 2020 09:07:49 +0200 Message-Id: <20200817070802.1517632-13-sr@denx.de> In-Reply-To: <20200817070802.1517632-1-sr@denx.de> References: <20200817070802.1517632-1-sr@denx.de> MIME-Version: 1.0 X-MBO-SPAM-Probability: X-Rspamd-Score: -0.76 / 15.00 / 15.00 X-Rspamd-Queue-Id: 590311847 X-Rspamd-UID: 72910f X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean 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 Reviewed-by: Simon Glass Cc: Bin Meng Signed-off-by: Stefan Roese --- (no changes since v1) Changes in v1: - Change patch subject - Fixed multi-line comment style - Added CONFIG_PCI_ARID and enabled the new code optionally, so that the code size is not increased in all cases drivers/pci/Kconfig | 9 +++++++++ drivers/pci/pci-uclass.c | 26 ++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig index 4635752a95..377806f3b0 100644 --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig @@ -63,6 +63,15 @@ config PCI_SRIOV if available on a PCI Physical Function device and probe for applicable drivers. +config PCI_ARID + bool "Enable Alternate Routing-ID support for PCI" + depends on PCI || DM_PCI + default n + help + Say Y here if you want to enable Alternate Routing-ID capability + support on PCI devices. This helps to skip some devices in BDF + scan that are not present. + config PCIE_ECAM_GENERIC bool "Generic ECAM-based PCI host controller support" default n diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index 23135ebe04..fc60dfe395 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -798,6 +798,7 @@ int pci_bind_bus_devices(struct udevice *bus) ulong header_type; pci_dev_t bdf, end; bool found_multi; + int ari_off; int ret; found_multi = false; @@ -871,6 +872,31 @@ int pci_bind_bus_devices(struct udevice *bus) pplat->vendor = vendor; pplat->device = device; pplat->class = class; + + if (IS_ENABLED(CONFIG_PCI_ARID)) { + 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;