mirror_ubuntu-kernels/drivers/pci/controller/dwc
Johan Hovold f352ce9992 PCI: qcom: Fix potential deadlock when enabling ASPM
The qcom_pcie_enable_aspm() helper is called from pci_walk_bus() during
host init to enable ASPM.

Since pci_walk_bus() already holds a pci_bus_sem read lock, use
pci_enable_link_state_locked() to enable link states in order to avoid a
potential deadlock (e.g. in case someone takes a write lock before
reacquiring the read lock).

This issue was reported by lockdep:

  ============================================
  WARNING: possible recursive locking detected
  6.7.0-rc1 #4 Not tainted
  --------------------------------------------
  kworker/u16:6/147 is trying to acquire lock:
  ffffbf3ff9d2cfa0 (pci_bus_sem){++++}-{3:3}, at: pci_enable_link_state+0x74/0x1e8

  but task is already holding lock:
  ffffbf3ff9d2cfa0 (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 ***

Fixes: 9f4f3dfad8 ("PCI: qcom: Enable ASPM for platforms supporting 1.9.0 ops")
Link: https://lore.kernel.org/r/20231128081512.19387-4-johan+linaro@kernel.org
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
[bhelgaas: add "potential" in subject since the deadlock has only been
reported by lockdep, include helper name in commit log]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
2023-12-11 12:08:43 -06:00
..
Kconfig PCI: rcar-gen4: Add endpoint mode support 2023-10-23 12:40:10 +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 PCI: Explicitly include correct DT includes 2023-07-18 14:33:17 -05:00
pci-exynos.c PCI: exynos: Don't discard .remove() callback 2023-10-10 12:13:05 -05:00
pci-imx6.c Merge branch 'pci/misc' 2023-08-29 11:03:57 -05:00
pci-keystone.c PCI: keystone: Don't discard .probe() callback 2023-10-10 12:13:17 -05:00
pci-layerscape-ep.c PCI: layerscape-ep: Set 64-bit DMA mask 2023-10-10 17:40:05 +02:00
pci-layerscape.c PCI: Use PCI_HEADER_TYPE_* instead of literals 2023-10-03 11:55:59 -05:00
pci-meson.c Merge branch 'pci/misc' 2023-08-29 11:03:57 -05:00
pcie-al.c PCI: dwc: Rename struct pcie_port to dw_pcie_rp 2022-07-05 19:00:52 -05:00
pcie-armada8k.c PCI: Remove unnecessary <linux/of_irq.h> includes 2022-11-10 14:53:51 -06:00
pcie-artpec6.c PCI: Explicitly include correct DT includes 2023-07-18 14:33:17 -05:00
pcie-bt1.c PCI: dwc: Convert to platform remove callback returning void 2023-06-24 14:11:56 +00:00
pcie-designware-ep.c Merge branch 'pci/field-get' 2023-10-28 13:31:05 -05:00
pcie-designware-host.c PCI: dwc: Add host_post_init() callback 2023-10-14 20:02:17 +00:00
pcie-designware-plat.c PCI: Explicitly include correct DT includes 2023-07-18 14:33:17 -05: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/controller/rcar' 2023-10-28 13:31:01 -05:00
pcie-dw-rockchip.c PCI: Explicitly include correct DT includes 2023-07-18 14:33:17 -05:00
pcie-fu740.c PCI: fu740: Set the number of MSI vectors 2023-08-23 09:33:23 +02:00
pcie-hisi.c PCI: hisi: Avoid invalid address space conversions 2022-01-03 15:05:28 -06:00
pcie-histb.c PCI: dwc: Convert to platform remove callback returning void 2023-06-24 14:11:56 +00:00
pcie-intel-gw.c PCI: Explicitly include correct DT includes 2023-07-18 14:33:17 -05:00
pcie-keembay.c PCI: keembay: Remove cast between incompatible function type 2023-07-13 18:20:31 +00:00
pcie-kirin.c PCI: kirin: Don't discard .remove() callback 2023-10-10 12:13:09 -05:00
pcie-qcom-ep.c Merge branch 'pci/controller/speed' 2023-10-28 13:31:02 -05:00
pcie-qcom.c PCI: qcom: Fix potential deadlock when enabling ASPM 2023-12-11 12:08:43 -06:00
pcie-rcar-gen4.c PCI: rcar-gen4: Add endpoint mode support 2023-10-23 12:40:10 +00:00
pcie-spear13xx.c Merge branch 'pci/misc' 2022-08-04 11:46:53 -05: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/field-get' 2023-10-28 13:31:05 -05:00
pcie-uniphier-ep.c PCI: Explicitly include correct DT includes 2023-07-18 14:33:17 -05:00
pcie-uniphier.c PCI: dwc: Rename struct pcie_port to dw_pcie_rp 2022-07-05 19:00:52 -05:00
pcie-visconti.c PCI: dwc: Rename struct pcie_port to dw_pcie_rp 2022-07-05 19:00:52 -05:00