From patchwork Wed Jan 10 03:07:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vidya Sagar X-Patchwork-Id: 13515645 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1D4CBC47077 for ; Wed, 10 Jan 2024 03:08:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=U8g1JfIfrvRSzOzBZ+B5T9Nqp56ZsCvEyoZM8CIVYwo=; b=t78mDNqz+pE2E/ fFtcZgprofG5pPw3e8PQ7lz3sLfpsUyqZ+e6BAdAwNiEPJEkif/wXuXmguJMqCVUzAdhNKFzkb/T1 opmjV3e6UTI62we76LPe1Y/xHzZhQG4X2jJr6dCf4Y2chvTUQbkh1rYpvIsbII/GyRKmEr7u3f2bi 7hgzfKaMECAY3ih/k7R71jEz7XBRCQ+QUPXmmymuBfALfdzt3ApkZKBRmh/V2ziSIUep/f1NPiwIV UZp8fDTlig3ixteD3sqB3ZRhtz6HDLYr23GL9dRME1nHEHWa56eLkhUe0uaTGcwFNdHqavTGuurVA fDK7zhm6yh3Q2N+Bp6EA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rNOwv-00ABgr-2p; Wed, 10 Jan 2024 03:08:14 +0000 Received: from mail-dm6nam04on20600.outbound.protection.outlook.com ([2a01:111:f403:2409::600] helo=NAM04-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rNOws-00ABej-1i for linux-arm-kernel@lists.infradead.org; Wed, 10 Jan 2024 03:08:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aV25UR8uYyH8MJhSFIG6tfsZBxh4yj3Jw3avR0RNBH3ounOIcMZcBRHF/8N2AOb3s9gVWxMx+1fdz23cEmKyS3Eou3VMMhkt29rDNwxBd+zr/IIuPjxqMshjKPv3UmOpxIJiS+duEylEoz2e1RJ9T2MXodE1CGmTHmUCJQ5WYnFL6qZzcW9COuEV16VxsEI0ZjaHReZwFwjXwrs1nNPoyeo6wULc3UFEZhFdJ2fsbwovak9ucqPf6w0PpHkY5rFc6nGqhg3P22kKMut/xL6XRyobev5QWLlxv+bz3EwoC80Dt48NrUrWu8udNStiDz2jUA3Tq2Sz2MmnxWZ3A91PHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ws8eUAUXvLKzq5m+4Z1rBqx1wHa1LCUR+6dLSrIMg6I=; b=KoV6ZdjAYD0ZFUWMM1acw8IoR4wfxOsWrj2XnjUkKr9jyJ1b0ErzZPS/BTWiGnDFSx/4D/6u3X1KFePoBJ1srmlpAynGKjLHs2c3gagWX7ByZ7m6ieMRhR+iFYT+YfcbQpCtjopbHUy02KrW1msGtXvIg8jhIK5kIYVczzaNP25DgUX9lInxafMW/aiUsdApg3utXdcETXCzp2BUeQmP6CSheTrhFsP9OJBu3EJgivWrV69u6KOuXFLal6/S2HZ5PPuWwK0LzL2Ag+B3tLJeULY2ujVaQqG+Q6nGnmMts08HNpS9KcKJu1Qybfruq2/s/b/7AbI4NU+2LrzgEncfSQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ws8eUAUXvLKzq5m+4Z1rBqx1wHa1LCUR+6dLSrIMg6I=; b=DDJPbSoVOrpRNAVREZ086WeDp1WMxXvC+0C0g+wzYTRyBbnORXZgGzwmoWaQcMZgq30P6yMphMjw9wjW5si1BlUP14myjkuyMdTA8029wgRIAtk57sqq0PreZ3Fj5DQmWfRGRn4pcb9ko30v3OCBG+o+8QbpqlLV4nsvaLOdgsNHDPnQ+06+31WbySdk2uy7G5DCYwV6RKMsKGCCo8zZVsKPesXSRIT1U4XuR+Y5PZ/c51K1+RSv9BNtOVeRBaCFSrU4jka+K9gjvMTaNe7hKuK715KcU7lydsxBxDkQQNKrAyC3xND6o14lZsGqDMASrtQR3jyHPnBkcijROvlxGg== Received: from CH2PR03CA0024.namprd03.prod.outlook.com (2603:10b6:610:59::34) by DS0PR12MB7630.namprd12.prod.outlook.com (2603:10b6:8:11d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.24; Wed, 10 Jan 2024 03:08:03 +0000 Received: from DS3PEPF000099DD.namprd04.prod.outlook.com (2603:10b6:610:59:cafe::c) by CH2PR03CA0024.outlook.office365.com (2603:10b6:610:59::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.23 via Frontend Transport; Wed, 10 Jan 2024 03:08:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by DS3PEPF000099DD.mail.protection.outlook.com (10.167.17.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.14 via Frontend Transport; Wed, 10 Jan 2024 03:08:03 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 9 Jan 2024 19:07:46 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 9 Jan 2024 19:07:46 -0800 Received: from vidyas-desktop.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Tue, 9 Jan 2024 19:07:41 -0800 From: Vidya Sagar To: , , , , , , , CC: , , , , , , , , , , "kernel test robot" Subject: [PATCH V2 2/2] PCI: Add support for "preserve-boot-config" property Date: Wed, 10 Jan 2024 08:37:25 +0530 Message-ID: <20240110030725.710547-3-vidyas@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240110030725.710547-1-vidyas@nvidia.com> References: <20240110030725.710547-1-vidyas@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DD:EE_|DS0PR12MB7630:EE_ X-MS-Office365-Filtering-Correlation-Id: 1c0f881a-afac-48cb-888d-08dc11895c0a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1E1a+0fgxta8HwcKIG9QY46PMrMzrCKPt0gfK1vK9sAgtPwOE3htC9q/iy4CMFYzFDGxRydSp94li+zxZkK80mFUonEhFMEgQ3UBfeYI2t+wY9TxwXr4nT3LJqDOzVvj5PZAFw1ToqmZ+Mj+V4gH/bHhRFPPI0rf03aptd1nD1pJuEWs3RXEYravO8zOh17w65QsFxhtKXZz99ei1uoZXaJVwqCpoT/o4ljzKvnFq0D47lrSPjQs4Ki5L632ZvoGhwdm9w9ndQSLJq4H8keT1HBhvnE17Dfsm2LePz60K6/qOF6CzFjDSOukP47vPH48Rq2fn3RN0XxAhCMp0Vz6v54xGzlDeLXLTD2JWzkV3yEkLVjvLjreBXuyLz80GbRSykZz5qpyMWX9qWNBO+yvEtWHrWM9+8J6Zt44F8cClGguksePkU4WMric7FhWpbimEjZc4NVxTpMWX7ylV2nAIQnbppFNN1A32JvdjFu9aWwer9XLI9s5cID/rkDgdUB6lchgrc8oRQXS/RZj0PTHi1tZxJr5V1li2NEB4+//AQcHZRGE9eoypec/IXORCOdSf3ZLB7uQjrUagJ5/FPZ6a8/wKXmgTXLreI1lksiWz0ocm49cliFRVQp9bINeNqAkMH5CJysJHwphxcx9uztUgxcoXb84+JBuYBVXrU+0iAJvhwJ+nQ6+xLUzkTCkbro2NLReSnqDPF/TZfpZxwLsWyd18M94ydlcHD/r6ptzEBHjBxlVbf7Tp+JSwjWT1XSY X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(136003)(346002)(39860400002)(396003)(376002)(230922051799003)(1800799012)(186009)(451199024)(82310400011)(64100799003)(36840700001)(40470700004)(46966006)(2906002)(7416002)(5660300002)(41300700001)(83380400001)(40480700001)(40460700003)(336012)(426003)(1076003)(26005)(2616005)(36860700001)(47076005)(7696005)(6666004)(478600001)(86362001)(356005)(7636003)(4326008)(70206006)(8936002)(8676002)(54906003)(70586007)(82740400003)(36756003)(110136005)(316002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2024 03:08:03.0747 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1c0f881a-afac-48cb-888d-08dc11895c0a X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099DD.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7630 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240109_190810_572452_E2C60177 X-CRM114-Status: GOOD ( 19.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add support for "preserve-boot-config" property that can be used to selectively (i.e. per host bridge) instruct the kernel to preserve the boot time configuration done by the platform firmware. Reported-by: kernel test robot Signed-off-by: Vidya Sagar --- V2: * Addressed issues reported by kernel test robot drivers/pci/controller/pci-host-common.c | 5 ++++- drivers/pci/of.c | 18 ++++++++++++++++++ drivers/pci/probe.c | 2 +- include/linux/of_pci.h | 6 ++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/pci-host-common.c b/drivers/pci/controller/pci-host-common.c index 6be3266cd7b5..d3475dc9ec44 100644 --- a/drivers/pci/controller/pci-host-common.c +++ b/drivers/pci/controller/pci-host-common.c @@ -68,13 +68,16 @@ int pci_host_common_probe(struct platform_device *pdev) of_pci_check_probe_only(); + bridge->preserve_config = + of_pci_check_preserve_boot_config(dev->of_node); + /* Parse and map our Configuration Space windows */ cfg = gen_pci_init(dev, bridge, ops); if (IS_ERR(cfg)) return PTR_ERR(cfg); /* Do not reassign resources if probe only */ - if (!pci_has_flag(PCI_PROBE_ONLY)) + if (!(pci_has_flag(PCI_PROBE_ONLY) || bridge->preserve_config)) pci_add_flags(PCI_REASSIGN_ALL_BUS); bridge->sysdata = cfg; diff --git a/drivers/pci/of.c b/drivers/pci/of.c index 51e3dd0ea5ab..ed3c0dd9804e 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -258,6 +258,24 @@ void of_pci_check_probe_only(void) } EXPORT_SYMBOL_GPL(of_pci_check_probe_only); +/** + * of_pci_check_preserve_boot_config - Return true if the boot configuration + * needs to be preserved + * @node: Device tree node with the domain information. + * + * This function looks for a property called "preserve-boot-config" for a given + * PCIe controller's node and returns true if found. Having this property + * for a PCIe controller ensures that the kernel doesn't re-enumerate and + * reconfigure the BAR resources that are already done by the platform firmware. + * + * Return: true if the property exists false otherwise. + */ +bool of_pci_check_preserve_boot_config(struct device_node *node) +{ + return of_property_read_bool(node, "preserve-boot-config"); +} +EXPORT_SYMBOL_GPL(of_pci_check_preserve_boot_config); + /** * devm_of_pci_get_host_bridge_resources() - Resource-managed parsing of PCI * host bridge resources from DT diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 795534589b98..79d0ac34f567 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -3085,7 +3085,7 @@ int pci_host_probe(struct pci_host_bridge *bridge) * ioport_resource trees in either pci_bus_claim_resources() * or pci_bus_assign_resources(). */ - if (pci_has_flag(PCI_PROBE_ONLY)) { + if (pci_has_flag(PCI_PROBE_ONLY) || bridge->preserve_config) { pci_bus_claim_resources(bus); } else { pci_bus_size_bridges(bus); diff --git a/include/linux/of_pci.h b/include/linux/of_pci.h index 29658c0ee71f..ba5532005125 100644 --- a/include/linux/of_pci.h +++ b/include/linux/of_pci.h @@ -13,6 +13,7 @@ struct device_node *of_pci_find_child_device(struct device_node *parent, unsigned int devfn); int of_pci_get_devfn(struct device_node *np); void of_pci_check_probe_only(void); +bool of_pci_check_preserve_boot_config(struct device_node *node); #else static inline struct device_node *of_pci_find_child_device(struct device_node *parent, unsigned int devfn) @@ -26,6 +27,11 @@ static inline int of_pci_get_devfn(struct device_node *np) } static inline void of_pci_check_probe_only(void) { } + +static inline bool of_pci_check_preserve_boot_config(struct device_node *node) +{ + return false; +} #endif #if IS_ENABLED(CONFIG_OF_IRQ)