Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp475226rdb; Thu, 22 Feb 2024 09:15:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUtPu/Q+dplPeb6fuUYgyhR3QBQhVPx0NDddJUUxZ0vGqmYKvOX+xNyKl+ccyhtVWHnGv/SuSOcRyTtKvzLdvFRFNpkEQuwxztzyXjizQ== X-Google-Smtp-Source: AGHT+IGsc3yIeH2A8RD8Qs46+1zpyO6dKc+xRiqNkNgXWiN+fEtPLNpmMFTQj0SdLerF9jGhLuyE X-Received: by 2002:a05:6359:4c29:b0:17b:6cc5:c5d6 with SMTP id kj41-20020a0563594c2900b0017b6cc5c5d6mr2297253rwc.31.1708622156378; Thu, 22 Feb 2024 09:15:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708622156; cv=pass; d=google.com; s=arc-20160816; b=vpMmRIOPYBjkToqo+m7zHrzLHlzygdBWAyukDCpQQJaNjB501inmlth5svC+Ikw4hN XSbedMjf8Yw9ZyKkSQm+5d4lMTb+FqMr0rGIa/1GzoJAkqIgHNr9I8vpdQ/urBoar+WW jSjNLaG7+59cGnAvZiO5VEe4WygyUyhFdnUxyLZEMx/kSu/lnGUYFUS8Lc9n1kzw5YMV aqzWqyM1ZTJ29KabG45yHvF1hnware1vjq+cTnNwY1afyfqPG1JPlXVjToeqamB2mTtk ELmK0dkku0EwtjWZSzVw5JcbjTowcs3d9Q2mgY6L12oxPpuI1XDnk5gCOiHarfdxSBjM 0boA== 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:message-id:subject:cc:to:from :date:dkim-signature; bh=qzlbThFUiE8pb83ItH8eme4laUOU5eJPAfJTSW1t15M=; fh=akqPOcx3mIeNfEDyrQzbGO2yqJCgC4BYenTTxKjVBKc=; b=RUYpEHp63X1jYnIYtJ5VlG7eH63aomeF75JsD/FRuIWNdcfrrLFEWG3ZoG136MJJ2p Be07mRf4rWOiGzOErxaPWLPFM8zgxeNjv7ArDklO+bbO6/w5NjYdxrikWFKhfmu8z+h3 VmfBlLwXFHNmnRg5YJJhhxVr+rwl9htURsxi6wTr20DqbCKYk+ktZVXd2zdoJLnqRz4G 8E0ah7u81csjGZxsE47An/Xfo3JcMmgYBbBY1rKe0RmnjNqCJWmvzVbHMIRR21mrdZ3K I8QyGQ4F2b1um17OaAcV5WaAZAZoKnqU9sXjoLGGr6dPBHjnyJeDNnnuYIhw0Fuhtvcb YrvQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qMv3dQYD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-76920-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76920-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id k125-20020a632483000000b005dd565c5644si10204333pgk.751.2024.02.22.09.15.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 09:15:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76920-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qMv3dQYD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-76920-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76920-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 2DEB42883CD for ; Thu, 22 Feb 2024 17:06:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 22265154C12; Thu, 22 Feb 2024 17:06:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qMv3dQYD" 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 3A3C715099F; Thu, 22 Feb 2024 17:06:43 +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=1708621604; cv=none; b=kswNrQDrVARku7F8IK9dDiqbiristj14HmZihWpgrYn4PcO5FoM2fYxg8qihpzYw6mLFV9PafF+jUoEbyQGxsItbg1j95tilD3brUBiYLfHq1r6EHwwXW98v1gSvmX41N5lcTi4krVo3vrt7CQBgDq+IZ1CwmQV2K378igfsfEQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708621604; c=relaxed/simple; bh=kE8TIXCP4omiH8Tb48QLZ4vtCQlIIcYaY2PACwfRHLU=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=PXA93MwD/OdzL+FQOQgzWsH6W7CUa0KVCL6dkosrFMrtcALwmOscIayTgaSUL9i4jbbFTSRBUx1GCeO+9MDVX2VAQ68qHtDrZQ7XUMR+x7jdgR/9eYp1SQimodLGt31HTOv7Rq5GBoAFJqbIIX5G8YL5WLXYUf9z0AF4+3IciJ4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qMv3dQYD; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5688BC433C7; Thu, 22 Feb 2024 17:06:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708621603; bh=kE8TIXCP4omiH8Tb48QLZ4vtCQlIIcYaY2PACwfRHLU=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=qMv3dQYDhbkA55iCtTxciIgE1L7pMg9o9uWTVAV+VOYkCajdj9ypNeK3dAMJjedon Yfm16dXgjEDaJvw7MKL3T1NUQJuoykxKJy3QBBvO7KjZn6mhHuhTJGHvovxIKU2zrR zDIG+iHYedR7cXvE6GdAAvt5KB235VxZ/Plmw5wAIXTGdCIAdrxI/gYIsiztfOlUMO sRy4h/QB7EziUrqeYVH8Xhch+hYzriJXTd6xGKvdtvOfJu8/ojjSIEqc2no6ipAGbJ +fGCcGAK0vbTCM29gk3bUyqBGrb/tWnTENLA+Bk37mXCqwO4TnK5iKODRwQgZELV7b cavlvjo3SyKpg== Date: Thu, 22 Feb 2024 11:06:41 -0600 From: Bjorn Helgaas To: Vidya Sagar Cc: bhelgaas@google.com, rafael@kernel.org, lenb@kernel.org, will@kernel.org, lpieralisi@kernel.org, kw@linux.com, robh@kernel.org, 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 V3] PCI: Add support for preserving boot configuration Message-ID: <20240222170641.GA15593@bhelgaas> 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: <20240222124110.2681455-1-vidyas@nvidia.com> On Thu, Feb 22, 2024 at 06:11:10PM +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 PCIe host bridge > device-tree node. It also unifies the ACPI and DT based boot flows > in this regard. > +/** > + * of_pci_bridge_check_probe_only - Return true if the boot configuration > + * needs to be preserved I don't like the "check_probe_only" name because it's a boolean function but the name doesn't tell me what a true/false return value means. Something like "preserve_resources" would be better. If you want "probe_only", even removing the "check" would help. > + * @node: Device tree node with the domain information. > + * > + * This function looks for "linux,pci-probe-only" property 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. This is generic PCI, not PCIe-specific (also in commit log and comment below). I think "enumeration" specifically refers to discovering what devices are present, and the kernel always does that, so drop that part. Reconfiguring BARs and bridge windows is what we want to prevent. > + * NOTE: The scope of "linux,pci-probe-only" defined within a PCIe 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_check_probe_only(struct device_node *node) > +{ > + return of_property_read_bool(node, "linux,pci-probe-only"); > +} > +EXPORT_SYMBOL_GPL(of_pci_bridge_check_probe_only); Why does this need to be exported for modules and exposed via include/linux/pci.h? > +static void pci_check_config_preserve(struct pci_host_bridge *host_bridge) > +{ > + if (&host_bridge->dev) { Checking &host_bridge->dev doesn't seem like the right way to determine whether this is an ACPI host bridge. > + union acpi_object *obj; > + > + /* > + * 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(&host_bridge->dev), &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); > + }