Thomas Gleixner ba1366f3d0 PCI: vmd: Prevent recursive locking on interrupt allocation
Tejas reported the following recursive locking issue:

 swapper/0/1 is trying to acquire lock:
 ffff8881074fd0a0 (&md->mutex){+.+.}-{3:3}, at: msi_get_virq+0x30/0xc0
 
 but task is already holding lock:
 ffff8881017cd6a0 (&md->mutex){+.+.}-{3:3}, at: __pci_enable_msi_range+0xf2/0x290
 
 stack backtrace:
  __mutex_lock+0x9d/0x920
  msi_get_virq+0x30/0xc0
  pci_irq_vector+0x26/0x30
  vmd_msi_init+0xcc/0x210
  msi_domain_alloc+0xbf/0x150
  msi_domain_alloc_irqs_descs_locked+0x3e/0xb0
  __pci_enable_msi_range+0x155/0x290
  pci_alloc_irq_vectors_affinity+0xba/0x100
  pcie_port_device_register+0x307/0x550
  pcie_portdrv_probe+0x3c/0xd0
  pci_device_probe+0x95/0x110

This is caused by the VMD MSI code which does a lookup of the Linux
interrupt number for an VMD managed MSI[X] vector. The lookup function
tries to acquire the already held mutex.

Avoid that by caching the Linux interrupt number at initialization time
instead of looking it up over and over.

Fixes: 82ff8e6b78fc ("PCI/MSI: Use msi_get_virq() in pci_get_vector()")
Reported-by: "Surendrakumar Upadhyay, TejaskumarX" <tejaskumarx.surendrakumar.upadhyay@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: "Surendrakumar Upadhyay, TejaskumarX" <tejaskumarx.surendrakumar.upadhyay@intel.com>
Cc: linux-pci@vger.kernel.org
Link: https://lore.kernel.org/r/87a6euub2a.ffs@tglx
2022-02-21 08:26:53 +01:00
..
2022-01-13 09:57:52 -06:00
2022-01-13 09:57:52 -06:00
2021-06-16 17:20:40 -05:00
2020-07-29 14:25:18 -05:00
2022-01-07 20:43:23 -06:00
2022-01-16 08:08:11 +02:00
2021-11-02 19:06:30 +01:00
2021-12-09 11:52:21 +01:00
2022-01-16 08:08:11 +02:00
2021-11-06 14:36:12 -07:00
2022-01-16 08:08:11 +02:00
2022-01-22 08:33:37 +02:00
2022-01-16 08:08:11 +02:00
2021-02-10 16:46:29 -06:00
2021-09-28 13:43:17 -05:00
2020-08-05 18:23:14 -05:00