public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/10] PCI: Improve PCIe Capability RMW concurrency control
@ 2023-06-20 13:46 Ilpo Järvinen
  2023-06-20 13:46 ` [PATCH v3 01/10] PCI: Add locking to RMW PCI Express Capability Register accessors Ilpo Järvinen
                   ` (10 more replies)
  0 siblings, 11 replies; 16+ messages in thread
From: Ilpo Järvinen @ 2023-06-20 13:46 UTC (permalink / raw)
  To: linux-pci, Bjorn Helgaas, Lorenzo Pieralisi, Rob Herring,
	Krzysztof Wilczyński, Emmanuel Grumbach, Rafael J . Wysocki,
	Heiner Kallweit, Lukas Wunner
  Cc: LKML, Dean Luick, Andy Shevchenko, Ilpo Järvinen

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@linux.intel.com/T/#t

v3:
- Split link retraining change off from ASPM patch & reorder it earlier
- Adjust changelog to take into account the move of link retraining
  code into PCI core and no longer refer to ASPM (currently in
  pci/enumeration branch)
- based on top of pci/main

v2:
- Keep the RMW ops caller API the same
- Make pcie_capability_clear_and_set_word() a wrapper that uses
  locked/unlocked variant based on the capability reg
- Extracted LNKCTL2 changes out from this series to keep this purely
  a series which fixes something (LNKCTL2 RMW lock is necessary only
  when PCIe BW control is introduced).
- Added Fixes tags (it's a bit rathole but yeah, they're there now).
- Renamed cap_lock to pcie_cap_lock
- Changed ath1* to clear the ASPMC field before setting it


Ilpo Järvinen (10):
  PCI: Add locking to RMW PCI Express Capability Register accessors
  PCI: Make link retraining use RMW accessors for changing LNKCTL
  PCI: pciehp: Use RMW accessors for changing LNKCTL
  PCI/ASPM: Use RMW accessors for changing LNKCTL
  drm/amdgpu: Use RMW accessors for changing LNKCTL
  drm/radeon: Use RMW accessors for changing LNKCTL
  net/mlx5: Use RMW accessors for changing LNKCTL
  wifi: ath11k: Use RMW accessors for changing LNKCTL
  wifi: ath12k: Use RMW accessors for changing LNKCTL
  wifi: ath10k: Use RMW accessors for changing LNKCTL

 drivers/gpu/drm/amd/amdgpu/cik.c              | 36 +++++-------------
 drivers/gpu/drm/amd/amdgpu/si.c               | 36 +++++-------------
 drivers/gpu/drm/radeon/cik.c                  | 36 +++++-------------
 drivers/gpu/drm/radeon/si.c                   | 37 +++++-------------
 .../ethernet/mellanox/mlx5/core/fw_reset.c    |  9 +----
 drivers/net/wireless/ath/ath10k/pci.c         |  9 +++--
 drivers/net/wireless/ath/ath11k/pci.c         | 10 +++--
 drivers/net/wireless/ath/ath12k/pci.c         | 10 +++--
 drivers/pci/access.c                          | 20 ++++++++--
 drivers/pci/hotplug/pciehp_hpc.c              | 12 ++----
 drivers/pci/pcie/aspm.c                       | 38 ++++++++-----------
 drivers/pci/probe.c                           |  1 +
 include/linux/pci.h                           | 34 ++++++++++++++++-
 13 files changed, 128 insertions(+), 160 deletions(-)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2023-06-21 14:48 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-20 13:46 [PATCH v3 00/10] PCI: Improve PCIe Capability RMW concurrency control Ilpo Järvinen
2023-06-20 13:46 ` [PATCH v3 01/10] PCI: Add locking to RMW PCI Express Capability Register accessors Ilpo Järvinen
2023-06-20 13:46 ` [PATCH v3 02/10] PCI: Make link retraining use RMW accessors for changing LNKCTL Ilpo Järvinen
2023-06-20 13:46 ` [PATCH v3 03/10] PCI: pciehp: Use " Ilpo Järvinen
2023-06-20 13:46 ` [PATCH v3 04/10] PCI/ASPM: " Ilpo Järvinen
2023-06-20 13:46 ` [PATCH v3 05/10] drm/amdgpu: " Ilpo Järvinen
2023-06-20 13:46 ` [PATCH v3 06/10] drm/radeon: " Ilpo Järvinen
2023-06-20 13:46 ` [PATCH v3 07/10] net/mlx5: " Ilpo Järvinen
2023-06-21 14:46   ` Simon Horman
2023-06-20 13:46 ` [PATCH v3 08/10] wifi: ath11k: " Ilpo Järvinen
2023-06-21 14:47   ` Simon Horman
2023-06-20 13:46 ` [PATCH v3 09/10] wifi: ath12k: " Ilpo Järvinen
2023-06-21 14:47   ` Simon Horman
2023-06-20 13:46 ` [PATCH v3 10/10] wifi: ath10k: " Ilpo Järvinen
2023-06-21 14:46   ` Simon Horman
2023-06-20 14:11 ` [PATCH v3 00/10] PCI: Improve PCIe Capability RMW concurrency control Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox