2
0
mirror of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-09-04 20:19:47 +08:00
linux/drivers/pci/controller/dwc
Johan Hovold 1e56086415 PCI/ASPM: Fix deadlock when enabling ASPM
A last minute revert in 6.7-final introduced a potential deadlock when
enabling ASPM during probe of Qualcomm PCIe controllers as reported by
lockdep:

  ============================================
  WARNING: possible recursive locking detected
  6.7.0 #40 Not tainted
  --------------------------------------------
  kworker/u16:5/90 is trying to acquire lock:
  ffffacfa78ced000 (pci_bus_sem){++++}-{3:3}, at: pcie_aspm_pm_state_change+0x58/0xdc

              but task is already holding lock:
  ffffacfa78ced000 (pci_bus_sem){++++}-{3:3}, at: pci_walk_bus+0x34/0xbc

              other info that might help us debug this:
   Possible unsafe locking scenario:

         CPU0
         ----
    lock(pci_bus_sem);
    lock(pci_bus_sem);

               *** DEADLOCK ***

  Call trace:
   print_deadlock_bug+0x25c/0x348
   __lock_acquire+0x10a4/0x2064
   lock_acquire+0x1e8/0x318
   down_read+0x60/0x184
   pcie_aspm_pm_state_change+0x58/0xdc
   pci_set_full_power_state+0xa8/0x114
   pci_set_power_state+0xc4/0x120
   qcom_pcie_enable_aspm+0x1c/0x3c [pcie_qcom]
   pci_walk_bus+0x64/0xbc
   qcom_pcie_host_post_init_2_7_0+0x28/0x34 [pcie_qcom]

The deadlock can easily be reproduced on machines like the Lenovo ThinkPad
X13s by adding a delay to increase the race window during asynchronous
probe where another thread can take a write lock.

Add a new pci_set_power_state_locked() and associated helper functions that
can be called with the PCI bus semaphore held to avoid taking the read lock
twice.

Link: https://lore.kernel.org/r/ZZu0qx2cmn7IwTyQ@hovoldconsulting.com
Link: https://lore.kernel.org/r/20240130100243.11011-1-johan+linaro@kernel.org
Fixes: f93e71aea6 ("Revert "PCI/ASPM: Remove pcie_aspm_pm_state_change()"")
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: <stable@vger.kernel.org>	# 6.7
2024-01-31 09:03:51 -06:00
..
Kconfig PCI: dwc: Convert SOC_SIFIVE to ARCH_SIFIVE 2023-12-16 00:22:37 +00:00
Makefile PCI: rcar-gen4: Add R-Car Gen4 PCIe controller support for host mode 2023-10-23 12:40:10 +00:00
pci-dra7xx.c Merge branch 'pci/irq-clean-up' 2024-01-15 12:10:40 -06:00
pci-exynos.c Merge branch 'pci/controller/remove-void-return' 2024-01-15 12:10:40 -06:00
pci-imx6.c Merge branch 'pci/irq-clean-up' 2024-01-15 12:10:40 -06:00
pci-keystone.c Merge branch 'pci/irq-clean-up' 2024-01-15 12:10:40 -06:00
pci-layerscape-ep.c Merge branch 'pci/irq-clean-up' 2024-01-15 12:10:40 -06:00
pci-layerscape.c Merge branch 'pci/controller/layerscape' 2024-01-15 12:10:38 -06:00
pci-meson.c PCI: dwc: Drop host prefix from struct dw_pcie_host_ops members 2024-01-06 07:51:08 +00:00
pcie-al.c PCI: dwc: Drop host prefix from struct dw_pcie_host_ops members 2024-01-06 07:51:08 +00:00
pcie-armada8k.c PCI: dwc: Drop host prefix from struct dw_pcie_host_ops members 2024-01-06 07:51:08 +00:00
pcie-artpec6.c Merge branch 'pci/irq-clean-up' 2024-01-15 12:10:40 -06:00
pcie-bt1.c PCI: dwc: Drop host prefix from struct dw_pcie_host_ops members 2024-01-06 07:51:08 +00:00
pcie-designware-ep.c Merge branch 'pci/irq-clean-up' 2024-01-15 12:10:40 -06:00
pcie-designware-host.c PCI: dwc: Drop host prefix from struct dw_pcie_host_ops members 2024-01-06 07:51:08 +00:00
pcie-designware-plat.c Merge branch 'pci/irq-clean-up' 2024-01-15 12:10:40 -06:00
pcie-designware.c PCI: dwc: Expose dw_pcie_write_dbi2() to module 2023-10-23 12:39:17 +00:00
pcie-designware.h Merge branch 'pci/irq-clean-up' 2024-01-15 12:10:40 -06:00
pcie-dw-rockchip.c Merge branch 'pci/irq-clean-up' 2024-01-15 12:10:40 -06:00
pcie-fu740.c PCI: dwc: Drop host prefix from struct dw_pcie_host_ops members 2024-01-06 07:51:08 +00:00
pcie-hisi.c PCI: hisi: Avoid invalid address space conversions 2022-01-03 15:05:28 -06:00
pcie-histb.c PCI: dwc: Drop host prefix from struct dw_pcie_host_ops members 2024-01-06 07:51:08 +00:00
pcie-intel-gw.c Merge branch 'pci/controller/dwc' 2024-01-15 12:10:37 -06:00
pcie-keembay.c Merge branch 'pci/irq-clean-up' 2024-01-15 12:10:40 -06:00
pcie-kirin.c Merge branch 'pci/controller/remove-void-return' 2024-01-15 12:10:40 -06:00
pcie-qcom-ep.c Merge branch 'pci/irq-clean-up' 2024-01-15 12:10:40 -06:00
pcie-qcom.c PCI/ASPM: Fix deadlock when enabling ASPM 2024-01-31 09:03:51 -06:00
pcie-rcar-gen4.c Merge branch 'pci/irq-clean-up' 2024-01-15 12:10:40 -06:00
pcie-spear13xx.c PCI: dwc: Drop host prefix from struct dw_pcie_host_ops members 2024-01-06 07:51:08 +00:00
pcie-tegra194-acpi.c PCI: dwc: Simplify in/outbound iATU setup methods 2022-08-01 15:15:09 -05:00
pcie-tegra194.c Merge branch 'pci/irq-clean-up' 2024-01-15 12:10:40 -06:00
pcie-uniphier-ep.c Merge branch 'pci/irq-clean-up' 2024-01-15 12:10:40 -06:00
pcie-uniphier.c Merge branch 'pci/irq-clean-up' 2024-01-15 12:10:40 -06:00
pcie-visconti.c PCI: dwc: Drop host prefix from struct dw_pcie_host_ops members 2024-01-06 07:51:08 +00:00