Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp439759lqs; Tue, 5 Mar 2024 06:36:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVL5GCO5Q7k7OkRoww2C1l2Xjs3wUIfFynmtbKkCMuHsteAZ6pZvHMpi3ihI6UPg+YtytasLVaZxkWxL8Mcp6IaXZmPYQqEDBKSk9K7KQ== X-Google-Smtp-Source: AGHT+IFdXlBNNpXe1HIWzWwUTtVR1yrJHcucwJ2mCOKSnuUSgflRHPRMfD5RXH1haK/Jwa4HE3w6 X-Received: by 2002:a05:6808:394e:b0:3c2:c87:5706 with SMTP id en14-20020a056808394e00b003c20c875706mr1928650oib.5.1709649362193; Tue, 05 Mar 2024 06:36:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709649362; cv=pass; d=google.com; s=arc-20160816; b=FajaHKy+b3NcAzsACfexWlTEzqmo0AL5Pd8hKwNitOZTjLf7HV59eI2/ge0m9sXA/7 3QDRHvjVgpZUYQegi42O6GgdrEKCYk4rpwUItHnrkr1LityA4l3k8M5j+Kd66gD6mn0x xKxplm5nnl9Cz6WncQVuK78yJso3ElZ/tCcNPEi4MVK/9VNEgPRLgROA+N0tcXLp+JLK 22PioQYMyR6DEry3moEwN0X6dk0L+onQz2vd3IsocaLap/hITFEYRPLqrHWmLMOZ4aaL 2PHyM76ywwBCqrxd8dGwnxQMZ3RdCTh4ZJPFH8qkdgoV7F/u+76nuCO/2mQzFkKFm9Qd FCvw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=oET+xLzXbLm0O8be6/2vG0YC14UmnlGdoKu0PnzZ5r4=; fh=yuYUidodnSy/a5ifRJoMeVUKv4COloU/RV9BYpvCJVA=; b=oMvCKGSm0xzqzcXnJfe/9nStdGMzFAe+0hB+GdeF8jhjsApseG/5RipGZUQVQEvEuw MsLH4lDomM0wl/vrbIqk3yFbsS7sg4SBHmPT300Vk8wsyQIfTpadbi8WD3H7gbFMTaJq 72KK620rRMGiwdUPl1PwvRHVloo15vnv9RIM0cksUpevBf/lw2stNaStTb3uhyImG0Mq FB+JuRqQt6CSgJXIk1NlKtXeVX7BfgQ7rBGUa3ceQe3dOP2CRarI6CL/RILIITh/zfqJ ukfDX7gqDj4g/+qCYuKgcl9SstL5gGo1V1YeX95q7xihl7n/0YiuoRYjRHGbFxnBoOBG YOMA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tlcGZRPG; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-92491-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92491-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id q10-20020a65684a000000b005e0c8027182si9949158pgt.831.2024.03.05.06.36.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 06:36:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-92491-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tlcGZRPG; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-92491-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92491-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B19FBB246FF for ; Tue, 5 Mar 2024 14:10:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 18DA78662F; Tue, 5 Mar 2024 14:10:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tlcGZRPG" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 210935102B; Tue, 5 Mar 2024 14:10:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709647823; cv=none; b=Qa2MzxvRBeMQQtrGpWGG+0CA1S1+FktrHHtfWkBrz/LLq4Z8kPJGg+AdihYgRy1/tBYex5txDUSBKD8rxybvz6zy5Qitlu0H81FZfo82hmQ7ncDsrxS5ILU+b0h1nsI5IdwGwHueeCPZwJuVh5W4Ql4ANCOGJjUUPA0ktWji4z0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709647823; c=relaxed/simple; bh=yligJ8IXn0rMPUgLLCLFsqkXEZzbgJx9pASoGxdfXR4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FFXLlkfbN8mOlmwhn+yaxysdzKbxIufVFDjZ/nslE4Wsdr/b3i39EjFBcMhMT/NuJiC6y79CSQIvLd1wjEL/9hcr/S4iBZW1zYYevDwCB8k7spmZkL1Nle4N/VFi8t1AYEqEL6gwXmWdTUd/dErd5jjFQc6Z3pJahAgGNKlk3Rc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tlcGZRPG; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61E72C433C7; Tue, 5 Mar 2024 14:10:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709647822; bh=yligJ8IXn0rMPUgLLCLFsqkXEZzbgJx9pASoGxdfXR4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tlcGZRPGR3iQ3Rz6cSl+sC1Cd46r5Ye33DMAn5FrLL36CXD9BZQNfPcP+eD5kHU8P erNmTTXjdJzUzz6MpO4rPA74t7oPJs/J1h3bl8qVKDCyB/V3PA/wAqnsBHoUGg8mlK K/c8410PacOzLJ7pz2EhJ4+/OG0LzlthgNRgJds7EbXVB41PWzf0lKPtNbVRVIu0ps 1+8c8Nb1LLq4IVbq2OnGm6GOAE2JQSoZVVxA4ath12jYeOaeiDSH/3Ksisngcs6gVG mMwYTdkTa0hLLZ7wMrGWN6Hh/FZvIbmSGo5qbKIt4LktOPc8uvkNwpxmtQd1K9araP yTgfP0En4Nimw== Date: Tue, 5 Mar 2024 08:10:20 -0600 From: Rob Herring To: Vidya Sagar Cc: bhelgaas@google.com, rafael@kernel.org, lenb@kernel.org, will@kernel.org, lpieralisi@kernel.org, kw@linux.com, frowand.list@gmail.com, linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, treding@nvidia.com, jonathanh@nvidia.com, kthota@nvidia.com, mmaddireddy@nvidia.com, sagar.tv@gmail.com Subject: Re: [PATCH V4] PCI: Add support for preserving boot configuration Message-ID: <20240305141020.GA3259724-robh@kernel.org> References: <20240222124110.2681455-1-vidyas@nvidia.com> <20240223080021.1692996-1-vidyas@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240223080021.1692996-1-vidyas@nvidia.com> On Fri, Feb 23, 2024 at 01:30:21PM +0530, Vidya Sagar wrote: > Add support for preserving the boot configuration done by the > platform firmware per host bridge basis, based on the presence of > 'linux,pci-probe-only' property in the respective PCI host bridge > device-tree node. It also unifies the ACPI and DT based boot flows > in this regard. > > Signed-off-by: Vidya Sagar > --- > V4: > * Addressed Bjorn's review comments > > V3: > * Unified ACPI and DT flows as part of addressing Bjorn's review comments > > V2: > * Addressed issues reported by kernel test robot > > drivers/acpi/pci_root.c | 12 ------- > drivers/pci/controller/pci-host-common.c | 4 --- > drivers/pci/of.c | 21 +++++++++++ > drivers/pci/probe.c | 46 ++++++++++++++++++------ > include/linux/of_pci.h | 6 ++++ > 5 files changed, 62 insertions(+), 27 deletions(-) > > diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c > index 84030804a763..ddc2b3e89111 100644 > --- a/drivers/acpi/pci_root.c > +++ b/drivers/acpi/pci_root.c > @@ -1008,7 +1008,6 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root, > int node = acpi_get_node(device->handle); > struct pci_bus *bus; > struct pci_host_bridge *host_bridge; > - union acpi_object *obj; > > info->root = root; > info->bridge = device; > @@ -1050,17 +1049,6 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root, > if (!(root->osc_ext_control_set & OSC_CXL_ERROR_REPORTING_CONTROL)) > host_bridge->native_cxl_error = 0; > > - /* > - * Evaluate the "PCI Boot Configuration" _DSM Function. If it > - * exists and returns 0, we must preserve any PCI resource > - * assignments made by firmware for this host bridge. > - */ > - obj = acpi_evaluate_dsm(ACPI_HANDLE(bus->bridge), &pci_acpi_dsm_guid, 1, > - DSM_PCI_PRESERVE_BOOT_CONFIG, NULL); > - if (obj && obj->type == ACPI_TYPE_INTEGER && obj->integer.value == 0) > - host_bridge->preserve_config = 1; > - ACPI_FREE(obj); > - > acpi_dev_power_up_children_with_adr(device); > > pci_scan_child_bus(bus); > diff --git a/drivers/pci/controller/pci-host-common.c b/drivers/pci/controller/pci-host-common.c > index 6be3266cd7b5..e2602e38ae45 100644 > --- a/drivers/pci/controller/pci-host-common.c > +++ b/drivers/pci/controller/pci-host-common.c > @@ -73,10 +73,6 @@ int pci_host_common_probe(struct platform_device *pdev) > if (IS_ERR(cfg)) > return PTR_ERR(cfg); > > - /* Do not reassign resources if probe only */ > - if (!pci_has_flag(PCI_PROBE_ONLY)) > - pci_add_flags(PCI_REASSIGN_ALL_BUS); > - > bridge->sysdata = cfg; > bridge->ops = (struct pci_ops *)&ops->pci_ops; > bridge->msi_domain = true; > diff --git a/drivers/pci/of.c b/drivers/pci/of.c > index 51e3dd0ea5ab..f0f1156040a5 100644 > --- a/drivers/pci/of.c > +++ b/drivers/pci/of.c > @@ -258,6 +258,27 @@ void of_pci_check_probe_only(void) > } > EXPORT_SYMBOL_GPL(of_pci_check_probe_only); > > +/** > + * of_pci_bridge_preserve_resources - Return true if the boot configuration > + * needs to be preserved > + * @node: Device tree node with the domain information. > + * > + * This function looks for "linux,pci-probe-only" property for a given > + * PCI controller's node and returns true if found. Having this property > + * for a PCI controller ensures that the kernel doesn't reconfigure the > + * BARs and bridge windows that are already done by the platform firmware. > + * NOTE: The scope of "linux,pci-probe-only" defined within a PCI bridge device > + * is limited to the hierarchy under that particular bridge device. whereas > + * the scope of "linux,pci-probe-only" defined within chosen node is > + * system wide. > + * > + * Return: true if the property exists false otherwise. > + */ > +bool of_pci_bridge_preserve_resources(struct device_node *node) > +{ > + return of_property_read_bool(node, "linux,pci-probe-only"); This is the wrong type. The existing "linux,pci-probe-only" is a u32 and non-zero value means probe-only. This would return true for 'linux,pci-probe-only = <0>'. Also, this should also check chosen. If you make this work accepting NULL for node, then of_pci_check_probe_only() can be re-implemented to use it. Rob