linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: George-Daniel Matei <danielgeorgem@chromium.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
	LKML <linux-kernel@vger.kernel.org>,
	 linux-pci@vger.kernel.org
Subject: Re: [PATCH] PCI: r8169: add suspend/resume aspm quirk
Date: Wed, 10 Jul 2024 17:20:58 +0300 (EEST)	[thread overview]
Message-ID: <87b22115-2b88-db66-f97c-aa8eea22f8cf@linux.intel.com> (raw)
In-Reply-To: <20240708153815.2757367-1-danielgeorgem@chromium.org>

On Mon, 8 Jul 2024, George-Daniel Matei wrote:

> Added aspm suspend/resume hooks that run
> before and after suspend and resume to change
> the ASPM states of the PCI bus in order to allow
> the system suspend while trying to prevent card hangs
> 
> Signed-off-by: George-Daniel Matei <danielgeorgem@chromium.org>
> ---
>  drivers/pci/quirks.c | 142 +++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 142 insertions(+)
> 
> diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
> index dc12d4a06e21..aa3dba2211d3 100644
> --- a/drivers/pci/quirks.c
> +++ b/drivers/pci/quirks.c
> @@ -6189,6 +6189,148 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x56b0, aspm_l1_acceptable_latency
>  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x56b1, aspm_l1_acceptable_latency);
>  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x56c0, aspm_l1_acceptable_latency);
>  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x56c1, aspm_l1_acceptable_latency);
> +
> +static const struct dmi_system_id chromebox_match_table[] = {
> +	{
> +		.matches = {
> +			DMI_MATCH(DMI_PRODUCT_NAME, "Brask"),
> +			DMI_MATCH(DMI_BIOS_VENDOR, "coreboot"),
> +		}
> +	},
> +	{
> +		.matches = {
> +			DMI_MATCH(DMI_PRODUCT_NAME, "Aurash"),
> +			DMI_MATCH(DMI_BIOS_VENDOR, "coreboot"),
> +		}
> +	},
> +		{
> +		.matches = {
> +			DMI_MATCH(DMI_PRODUCT_NAME, "Bujia"),
> +			DMI_MATCH(DMI_BIOS_VENDOR, "coreboot"),
> +		}
> +	},
> +	{
> +		.matches = {
> +			DMI_MATCH(DMI_PRODUCT_NAME, "Gaelin"),
> +			DMI_MATCH(DMI_BIOS_VENDOR, "coreboot"),
> +		}
> +	},
> +	{
> +		.matches = {
> +			DMI_MATCH(DMI_PRODUCT_NAME, "Gladios"),
> +			DMI_MATCH(DMI_BIOS_VENDOR, "coreboot"),
> +		}
> +	},
> +	{
> +		.matches = {
> +			DMI_MATCH(DMI_PRODUCT_NAME, "Hahn"),
> +			DMI_MATCH(DMI_BIOS_VENDOR, "coreboot"),
> +		}
> +	},
> +	{
> +		.matches = {
> +			DMI_MATCH(DMI_PRODUCT_NAME, "Jeev"),
> +			DMI_MATCH(DMI_BIOS_VENDOR, "coreboot"),
> +		}
> +	},
> +	{
> +		.matches = {
> +			DMI_MATCH(DMI_PRODUCT_NAME, "Kinox"),
> +			DMI_MATCH(DMI_BIOS_VENDOR, "coreboot"),
> +		}
> +	},
> +	{
> +		.matches = {
> +			DMI_MATCH(DMI_PRODUCT_NAME, "Kuldax"),
> +			DMI_MATCH(DMI_BIOS_VENDOR, "coreboot"),
> +		}
> +	},
> +	{
> +		.matches = {
> +			DMI_MATCH(DMI_PRODUCT_NAME, "Lisbon"),
> +			DMI_MATCH(DMI_BIOS_VENDOR, "coreboot"),
> +		}
> +	},
> +	{
> +			.matches = {
> +			DMI_MATCH(DMI_PRODUCT_NAME, "Moli"),
> +			DMI_MATCH(DMI_BIOS_VENDOR, "coreboot"),
> +		}
> +	},
> +	{ }
> +};
> +
> +static void rtl8169_suspend_aspm_settings(struct pci_dev *dev)
> +{
> +	u16 val = 0;
> +
> +	if (dmi_check_system(chromebox_match_table)) {
> +		//configure parent

Missing space.

> +		pcie_capability_clear_and_set_word(dev->bus->self,
> +						   PCI_EXP_LNKCTL,
> +						   PCI_EXP_LNKCTL_ASPMC,
> +						   PCI_EXP_LNKCTL_ASPM_L1);
> +
> +		pci_read_config_word(dev->bus->self,
> +				     dev->bus->self->l1ss + PCI_L1SS_CTL1,
> +				     &val);
> +		val = (val & ~PCI_L1SS_CTL1_L1SS_MASK) |
> +		      PCI_L1SS_CTL1_PCIPM_L1_2 | PCI_L1SS_CTL1_PCIPM_L1_2 |
> +		      PCI_L1SS_CTL1_ASPM_L1_1;
> +		pci_write_config_word(dev->bus->self,
> +				      dev->bus->self->l1ss + PCI_L1SS_CTL1,
> +				      val);

Touching ASPM state should be done through aspm driver, not by writing 
directly into LNKCTL and L1SS registers.

> +		//configure device

Missing space.

> +		pcie_capability_clear_and_set_word(dev, PCI_EXP_LNKCTL,
> +						   PCI_EXP_LNKCTL_ASPMC,
> +						   PCI_EXP_LNKCTL_ASPM_L1);
> +
> +		pci_read_config_word(dev, dev->l1ss + PCI_L1SS_CTL1, &val);
> +		val = (val & ~PCI_L1SS_CTL1_L1SS_MASK) |
> +		      PCI_L1SS_CTL1_PCIPM_L1_2 | PCI_L1SS_CTL1_PCIPM_L1_2 |
> +		      PCI_L1SS_CTL1_ASPM_L1_1;
> +		pci_write_config_word(dev, dev->l1ss + PCI_L1SS_CTL1, val);
> +	}
> +}
> +
> +DECLARE_PCI_FIXUP_SUSPEND(PCI_VENDOR_ID_REALTEK, 0x8168,
> +			  rtl8169_suspend_aspm_settings);
> +
> +static void rtl8169_resume_aspm_settings(struct pci_dev *dev)
> +{
> +	u16 val = 0;
> +
> +	if (dmi_check_system(chromebox_match_table)) {
> +		//configure device

Missing space

> +		pcie_capability_clear_and_set_word(dev, PCI_EXP_LNKCTL,
> +						   PCI_EXP_LNKCTL_ASPMC, 0);

pcie_capability_clear_word()

> +
> +		pci_read_config_word(dev->bus->self,

A copy-paste error for the device???

> +				     dev->bus->self->l1ss + PCI_L1SS_CTL1,
> +				     &val);
> +		val = val & ~PCI_L1SS_CTL1_L1SS_MASK;
> +		pci_write_config_word(dev->bus->self,
> +				      dev->bus->self->l1ss + PCI_L1SS_CTL1,
> +				      val);
> +
> +		//configure parent

Missing space

> +		pcie_capability_clear_and_set_word(dev->bus->self,
> +						   PCI_EXP_LNKCTL,
> +						   PCI_EXP_LNKCTL_ASPMC, 0);

pcie_capability_clear_and_set_word()

> +
> +		pci_read_config_word(dev->bus->self,
> +				     dev->bus->self->l1ss + PCI_L1SS_CTL1,
> +				     &val);
> +		val = val & ~PCI_L1SS_CTL1_L1SS_MASK;
> +		pci_write_config_word(dev->bus->self,
> +				      dev->bus->self->l1ss + PCI_L1SS_CTL1,
> +				      val);

Touching the same device twice here?

> +	}
> +}
> +
> +DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_REALTEK, 0x8168,
> +			 rtl8169_resume_aspm_settings);
>  #endif

-- 
 i.


      parent reply	other threads:[~2024-07-10 14:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-08 15:38 [PATCH] PCI: r8169: add suspend/resume aspm quirk George-Daniel Matei
2024-07-08 17:23 ` Bjorn Helgaas
2024-07-08 22:15   ` Heiner Kallweit
2024-07-10 15:09     ` George-Daniel Matei
2024-07-10 19:59       ` Heiner Kallweit
2024-07-17 17:12         ` George-Daniel Matei
2024-07-17 19:34           ` Heiner Kallweit
2024-07-10 21:38       ` Bjorn Helgaas
2024-07-25 12:56         ` George-Daniel Matei
2024-07-25 19:46           ` Heiner Kallweit
2024-07-11  5:45       ` Heiner Kallweit
2024-07-16 12:13         ` George-Daniel Matei
2024-07-16 19:25           ` Heiner Kallweit
2024-07-25 15:34             ` Bjorn Helgaas
2024-07-10 14:20 ` Ilpo Järvinen [this message]

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=87b22115-2b88-db66-f97c-aa8eea22f8cf@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=bhelgaas@google.com \
    --cc=danielgeorgem@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).