[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231011212206.GA1043224@bhelgaas>
Date: Wed, 11 Oct 2023 16:22:06 -0500
From: Bjorn Helgaas <helgaas@...nel.org>
To: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
Cc: linux-pci@...r.kernel.org,
Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
Rob Herring <robh@...nel.org>,
Krzysztof Wilczyński <kw@...ux.com>,
Lukas Wunner <lukas@...ner.de>,
"Rafael J . Wysocki" <rafael@...nel.org>,
Heiner Kallweit <hkallweit1@...il.com>,
Emmanuel Grumbach <emmanuel.grumbach@...el.com>,
linux-kernel@...r.kernel.org, Bjorn Helgaas <bhelgaas@...gle.com>,
ath10k@...ts.infradead.org, ath11k@...ts.infradead.org,
ath12k@...ts.infradead.org, intel-wired-lan@...ts.osuosl.org,
linux-arm-kernel@...ts.infradead.org,
linux-bluetooth@...r.kernel.org, linux-mediatek@...ts.infradead.org,
linux-rdma@...r.kernel.org, linux-wireless@...r.kernel.org,
netdev@...r.kernel.org
Subject: Re: [PATCH v2 03/13] PCI/ASPM: Disable ASPM when driver requests it
On Mon, Sep 18, 2023 at 04:10:53PM +0300, Ilpo Järvinen wrote:
> PCI core/ASPM service driver allows controlling ASPM state through
> pci_disable_link_state() and pci_enable_link_state() API. It was
> decided earlier (see the Link below), to not allow ASPM changes when OS
> does not have control over it but only log a warning about the problem
> (commit 2add0ec14c25 ("PCI/ASPM: Warn when driver asks to disable ASPM,
> but we can't do it")). Similarly, if ASPM is not enabled through
> config, ASPM cannot be disabled.
> ...
> +#ifndef CONFIG_PCIEASPM
> +/*
> + * Always disable ASPM when requested, even when CONFIG_PCIEASPM is
> + * not build to avoid drivers adding code to do it on their own
> + * which caused issues when core does not know about the out-of-band
> + * ASPM state changes.
> + */
> +int pci_disable_link_state_locked(struct pci_dev *pdev, int state)
> +{
> + struct pci_dev *parent = pdev->bus->self;
> + struct pci_bus *linkbus = pdev->bus;
> + struct pci_dev *child;
> + u16 aspm_enabled, linkctl;
> + int ret;
> +
> + if (!parent)
> + return -ENODEV;
P.S. I think this should look the same to the user (same dmesg log and
same taint, if we do that) as the CONFIG_PCIEASPM=y case.
> + ret = pcie_capability_read_word(parent, PCI_EXP_LNKCTL, &linkctl);
> + if (ret != PCIBIOS_SUCCESSFUL)
> + return pcibios_err_to_errno(ret);
> + aspm_enabled = linkctl & PCI_EXP_LNKCTL_ASPMC;
> +
> + ret = pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &linkctl);
> + if (ret != PCIBIOS_SUCCESSFUL)
> + return pcibios_err_to_errno(ret);
> + aspm_enabled |= linkctl & PCI_EXP_LNKCTL_ASPMC;
> +
> + /* If no states need to be disabled, don't touch LNKCTL */
> + if (state & aspm_enabled)
> + return 0;
> +
> + ret = pcie_capability_clear_word(parent, PCI_EXP_LNKCTL, PCI_EXP_LNKCTL_ASPMC);
> + if (ret != PCIBIOS_SUCCESSFUL)
> + return pcibios_err_to_errno(ret);
> + list_for_each_entry(child, &linkbus->devices, bus_list)
> + pcie_capability_clear_word(child, PCI_EXP_LNKCTL, PCI_EXP_LNKCTL_ASPMC);
This disables *all* ASPM states, unlike the version when
CONFIG_PCIEASPM is enabled. I suppose there's a reason, and maybe a
comment could elaborate on it?
When CONFIG_PCIEASPM is not enabled, I don't think we actively
*disable* ASPM in the hardware; we just leave it as-is, so firmware
might have left it enabled.
> +
> + return 0;
> +}
Conceptually it seems like the LNKCTL updates here should be the same
whether CONFIG_PCIEASPM is enabled or not (subject to the question
above).
When CONFIG_PCIEASPM is enabled, we might need to do more stuff, but
it seems like the core should be the same.
Bjorn
Powered by blists - more mailing lists