public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Zhou Shengqing <zhoushengqing@ttyinfo.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Len Brown <lenb@kernel.org>,
	linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCHv4] PCI/ACPI: _DSM PRESERVE_BOOT_CONFIG function rev id doesn't match with spec
Date: Thu, 27 Feb 2025 12:40:53 -0600	[thread overview]
Message-ID: <20250227184053.GA609152@bhelgaas> (raw)
In-Reply-To: <20241216052751.5460-1-zhoushengqing@ttyinfo.com>

On Mon, Dec 16, 2024 at 05:27:51AM +0000, Zhou Shengqing wrote:
> Per PCI Firmware Specification Revision 3.3 Table 4-7 _DSM Definitions
> for PCI. Preserve PCI Boot Configuration Initial Revision ID changed to 2.
> But the code remains unchanged, still 1.
> 
> v4:Initialize *obj to NULL.
> v3:try revision id 1 first, then try revision id 2.
> v2:add Fixes tag.

Thanks for working on this issue.

  - Thanks for the revision history.  For future posts, put it below
    the "---" line so it's in the email but not part of the commit log.

  - I think there's a leak in pci_acpi_preserve_config() because it
    doesn't free "obj" before it returns true.  If you agree, add a
    preparatory patch to fix this.

  - Add a preparatory patch to return false early in
    pci_acpi_preserve_config() if !ACPI_HANDLE(&host_bridge->dev) so
    the body of the function is unindented, similar to what
    acpi_pci_add_bus() does.

  - Add another preparatory patch that adds acpi_check_dsm() of the
    desired function/rev ID for DSM_PCI_PRESERVE_BOOT_CONFIG,
    DSM_PCI_POWER_ON_RESET_DELAY, DSM_PCI_DEVICE_READINESS_DURATIONS.
    Move the "Evaluate PCI Boot Configuration" comment above the
    acpi_check_dsm() since it applies to the whole function, not just
    the rev 1 code in this patch.

  - Rework this patch so it only adds acpi_check_dsm() and
    acpi_evaluate_dsm_typed() for rev 2.

  - Throughout, wrap code and comments to fit in 80 columns because
    that's the convention for the rest of the file.

  - You can use "BIT(DSM_PCI_PRESERVE_BOOT_CONFIG)" and similar
    instead of "1ULL << DSM_PCI_PRESERVE_BOOT_CONFIG" when calling
    acpi_check_dsm().

  - Add a [0/n] cover letter when posting the series.  Each patch
    should be a response to the cover letter.  "git format-patch" and
    "git send-email" will do that for you automatically.

> Fixes: 9d7d5db8e78e ("PCI: Move PRESERVE_BOOT_CONFIG _DSM evaluation to pci_register_host_bridge()")
> 
> Signed-off-by: Zhou Shengqing <zhoushengqing@ttyinfo.com>
> ---
>  drivers/pci/pci-acpi.c | 42 ++++++++++++++++++++++++++++++++----------
>  1 file changed, 32 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
> index af370628e583..f805cd134019 100644
> --- a/drivers/pci/pci-acpi.c
> +++ b/drivers/pci/pci-acpi.c
> @@ -123,19 +123,41 @@ phys_addr_t acpi_pci_root_get_mcfg_addr(acpi_handle handle)
>  bool pci_acpi_preserve_config(struct pci_host_bridge *host_bridge)
>  {
>  	if (ACPI_HANDLE(&host_bridge->dev)) {
> -		union acpi_object *obj;
> +		union acpi_object *obj = NULL;
>  
>  		/*
> -		 * 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.
> +		 * Per PCI Firmware r3.2, released Jan 26, 2015,
> +		 * DSM_PCI_PRESERVE_BOOT_CONFIG Revision ID is 1.
> +		 * But PCI Firmware r3.3, released Jan 20, 2021,
> +		 * changed sec 4.6.5 to say
> +		 * "lowest valid Revision ID value: 2". So try revision 1
> +		 * first for old platform, then try revision 2.
>  		 */
> -		obj = acpi_evaluate_dsm_typed(ACPI_HANDLE(&host_bridge->dev),
> -					      &pci_acpi_dsm_guid,
> -					      1, DSM_PCI_PRESERVE_BOOT_CONFIG,
> -					      NULL, ACPI_TYPE_INTEGER);
> -		if (obj && obj->integer.value == 0)
> -			return true;
> +		if (acpi_check_dsm(ACPI_HANDLE(&host_bridge->dev), &pci_acpi_dsm_guid, 1,
> +				   1ULL << DSM_PCI_PRESERVE_BOOT_CONFIG)) {
> +			/*
> +			 * 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_typed(ACPI_HANDLE(&host_bridge->dev),
> +						      &pci_acpi_dsm_guid,
> +						      1, DSM_PCI_PRESERVE_BOOT_CONFIG,
> +						      NULL, ACPI_TYPE_INTEGER);
> +			if (obj && obj->integer.value == 0)
> +				return true;
> +		}
> +
> +		if (acpi_check_dsm(ACPI_HANDLE(&host_bridge->dev), &pci_acpi_dsm_guid, 2,
> +				   1ULL << DSM_PCI_PRESERVE_BOOT_CONFIG)) {
> +			obj = acpi_evaluate_dsm_typed(ACPI_HANDLE(&host_bridge->dev),
> +						      &pci_acpi_dsm_guid,
> +						      2, DSM_PCI_PRESERVE_BOOT_CONFIG,
> +						      NULL, ACPI_TYPE_INTEGER);
> +			if (obj && obj->integer.value == 0)
> +				return true;
> +		}
> +
>  		ACPI_FREE(obj);
>  	}
>  
> -- 
> 2.39.2
> 

  reply	other threads:[~2025-02-27 18:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-16  5:27 [PATCHv4] PCI/ACPI: _DSM PRESERVE_BOOT_CONFIG function rev id doesn't match with spec Zhou Shengqing
2025-02-27 18:40 ` Bjorn Helgaas [this message]
2025-03-01  3:28   ` Zhou Shengqing
2025-03-03 22:46     ` Bjorn Helgaas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250227184053.GA609152@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=zhoushengqing@ttyinfo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox