Re: [PATCH v3 00/10] PCI: Improve PCIe Capability RMW concurrency control

From: Andy Shevchenko
Date: Tue Jun 20 2023 - 10:12:11 EST


+Cc: Jonas

Jonas, might be interesting material in scope of Marvell WiFi PM flow.
Also shows that some WiFi chips disable ASPM which might be good to
have on Marvell as well.

On Tue, Jun 20, 2023 at 04:46:14PM +0300, Ilpo Järvinen wrote:
> PCI Express Capability RMW accessors don't properly protect against
> concurrent access. Link Control Register is written by a number of
> things in the kernel in a RMW fashion without any concurrency control.
> This could in the unlucky case lead to losing one of the updates. One
> of the most obvious path which can race with most of the other LNKCTL
> RMW operations seems to be ASPM policy sysfs write which triggers
> LNKCTL update. Similarly, Root Control Register can be concurrently
> accessed by AER and PME.
>
> Make pcie_capability_clear_and_set_word() (and other RMW accessors that
> call it) to use a per device spinlock to protect the RMW operations to
> the Capability Registers that require locking. Convert open-coded
> LNKCTL RMW operations to use pcie_capability_clear_and_set_word() to
> benefit from the locking.
>
> There's also a related series which improves ASPM service driver and
> device driver coordination by removing out-of-band ASPM state
> management from device drivers (which will remove some of the code
> fragments changed by this series but it has higher regression
> potential which is why it seems prudent to do these changes in two
> steps):
> https://lore.kernel.org/linux-pci/20230602114751.19671-1-ilpo.jarvinen@xxxxxxxxxxxxxxx/T/#t

--
With Best Regards,
Andy Shevchenko