public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Kai-Heng Feng <kai.heng.feng@canonical.com>
Cc: bhelgaas@google.com, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org, nirmal.patel@linux.intel.com,
	jonathan.derrick@linux.dev, ilpo.jarvinen@linux.intel.com,
	david.e.box@linux.intel.com
Subject: Re: [PATCH 1/2] PCI: ASPM: Allow OS to configure ASPM where BIOS is incapable of
Date: Fri, 16 Aug 2024 17:28:00 -0500	[thread overview]
Message-ID: <20240816222800.GA75500@bhelgaas> (raw)
In-Reply-To: <20240530085227.91168-1-kai.heng.feng@canonical.com>

On Thu, May 30, 2024 at 04:52:26PM +0800, Kai-Heng Feng wrote:
> Since commit f492edb40b54 ("PCI: vmd: Add quirk to configure PCIe ASPM
> and LTR"), ASPM is configured for NVMe devices enabled in VMD domain.
> 
> However, that doesn't cover the case when FADT has ACPI_FADT_NO_ASPM
> set.
> 
> So add a new attribute to bypass aspm_disabled so OS can configure ASPM.
> 
> Fixes: f492edb40b54 ("PCI: vmd: Add quirk to configure PCIe ASPM and LTR")
> Link: https://lore.kernel.org/linux-pm/218aa81f-9c6-5929-578d-8dc15f83dd48@panix.com/
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> ---
>  drivers/pci/pcie/aspm.c | 8 ++++++--
>  include/linux/pci.h     | 1 +
>  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
> index cee2365e54b8..e719605857b1 100644
> --- a/drivers/pci/pcie/aspm.c
> +++ b/drivers/pci/pcie/aspm.c
> @@ -1416,8 +1416,12 @@ static int __pci_enable_link_state(struct pci_dev *pdev, int state, bool locked)
>  	 * the _OSC method), we can't honor that request.
>  	 */
>  	if (aspm_disabled) {
> -		pci_warn(pdev, "can't override BIOS ASPM; OS doesn't have ASPM control\n");
> -		return -EPERM;
> +		if (aspm_support_enabled && pdev->aspm_os_control)
> +			pci_info(pdev, "BIOS can't program ASPM, let OS control it\n");
> +		else {
> +			pci_warn(pdev, "can't override BIOS ASPM; OS doesn't have ASPM control\n");
> +			return -EPERM;

1) I dislike having this VMD-specific special case in the generic
code.

2) I think the "BIOS can't program ASPM ..." message is a little bit
misleading.  We're making the assumption that BIOS doesn't know about
devices below the VMD bridge, but we really don't know that.  BIOS
*could* have a VMD driver, and it could configure ASPM below the VMD.
We're just assuming that it doesn't.

It's also a little bit too verbose -- I think we get this message for
*every* device below VMD?  Maybe the vmd driver could print something
about ignoring the ACPI FADT "PCIe ASPM Controls" bit once per VMD?
Then it's clearly connected to something firmware folks know about.

3) The code ends up looking like this:

  if (aspm_disabled) {
    if (aspm_support_enabled && pdev->aspm_os_control)
      pci_info(pdev, "BIOS can't program ASPM, let OS control it\n");
    else {
      pci_warn(pdev, "can't override BIOS ASPM; OS doesn't have ASPM control\n");
      return -EPERM;
    }
  }

and I think it's confusing to check "aspm_support_enabled" and
"pdev->aspm_os_control" after we've already decided that ASPM is
sort of disabled by "aspm_disabled".

Plus, we're left with questions about all the *other* tests of
"aspm_disabled" in pcie_aspm_sanity_check(),
pcie_aspm_pm_state_change(), pcie_aspm_powersave_config_link(),
__pci_disable_link_state(), etc.  Why do they *not* need this change?

And what about pcie_aspm_init_link_state()?  Why doesn't *it* pay
attention to "aspm_disabled"?  It's all very complicated.

This is similar in some ways to native_aer, native_pme, etc., which we
negotiate with _OSC.  I wonder if we could make something similar for
this, since it's another case where we want to make something specific
to a host bridge instead of global.

> +		}
>  	}
>  
>  	if (!locked)
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index fb004fd4e889..58cbd4bea320 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -467,6 +467,7 @@ struct pci_dev {
>  	unsigned int	no_command_memory:1;	/* No PCI_COMMAND_MEMORY */
>  	unsigned int	rom_bar_overlap:1;	/* ROM BAR disable broken */
>  	unsigned int	rom_attr_enabled:1;	/* Display of ROM attribute enabled? */
> +	unsigned int	aspm_os_control:1;	/* Display of ROM attribute enabled? */

Comment is wrong (but I hope we can avoid a per-device bit anyway).

>  	pci_dev_flags_t dev_flags;
>  	atomic_t	enable_cnt;	/* pci_enable_device has been called */
>  
> -- 
> 2.43.0
> 

  parent reply	other threads:[~2024-08-16 22:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-30  8:52 [PATCH 1/2] PCI: ASPM: Allow OS to configure ASPM where BIOS is incapable of Kai-Heng Feng
2024-05-30  8:52 ` [PATCH 2/2] PCI: vmd: Let OS control ASPM for devices under VMD domain Kai-Heng Feng
2024-08-02  0:04   ` Bjorn Helgaas
2024-08-02  1:04     ` Kai-Heng Feng
2024-08-16  6:17       ` Kai-Heng Feng
2024-07-26  7:22 ` [PATCH 1/2] PCI: ASPM: Allow OS to configure ASPM where BIOS is incapable of Hui Wang
2024-08-16 22:28 ` Bjorn Helgaas [this message]
2024-08-19  5:31   ` Kai-Heng Feng

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=20240816222800.GA75500@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=david.e.box@linux.intel.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jonathan.derrick@linux.dev \
    --cc=kai.heng.feng@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=nirmal.patel@linux.intel.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