linux/drivers/pci/endpoint
Bhanu Seshu Kumar Valluri b8b3bdfb10 PCI: endpoint: pci-epf-test: Fix sleeping function being called from atomic context
[ Upstream commit 25423cda14 ]

When Root Complex (RC) triggers a Doorbell interrupt to Endpoint (EP), it
triggers the below warning in the EP:

 BUG: sleeping function called from invalid context at kernel/locking/mutex.c:271
 Call trace:
  __might_resched+0x130/0x158
  __might_sleep+0x70/0x88
  mutex_lock+0x2c/0x80
  pci_epc_get_msi+0x78/0xd8
  pci_epf_test_raise_irq.isra.0+0x74/0x138
  pci_epf_test_doorbell_handler+0x34/0x50

The BUG arises because the EP's pci_epf_test_doorbell_handler() which is
running in the hard IRQ context is making an indirect call to
pci_epc_get_msi(), which uses mutex inside.

To fix the issue, convert the hard IRQ handler to a threaded IRQ handler to
allow it to call functions that can sleep during bottom half execution.
Also, register the threaded IRQ handler with IRQF_ONESHOT to keep the
interrupt line disabled until the threaded IRQ handler completes execution.

Fixes: eff0c286aa ("PCI: endpoint: pci-epf-test: Add doorbell test support")
Signed-off-by: Bhanu Seshu Kumar Valluri <bhanuseshukumar@gmail.com>
[mani: reworded description a bit]
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Niklas Cassel <cassel@kernel.org>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20251014024109.42287-1-bhanuseshukumar@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2025-12-18 14:02:38 +01:00
..
functions PCI: endpoint: pci-epf-test: Fix sleeping function being called from atomic context 2025-12-18 14:02:38 +01:00
Kconfig PCI: endpoint: Add RC-to-EP doorbell support using platform MSI controller 2025-07-24 16:51:17 -05:00
Makefile PCI: endpoint: Add RC-to-EP doorbell support using platform MSI controller 2025-07-24 16:51:17 -05:00
pci-ep-cfs.c PCI: endpoint: Fix configfs group removal on driver teardown 2025-06-25 16:09:12 -06:00
pci-ep-msi.c PCI: endpoint: pci-ep-msi: Fix NULL vs IS_ERR() check in pci_epf_write_msi_msg() 2025-08-11 16:28:33 +05:30
pci-epc-core.c PCI: endpoint: Align pci_epc_set_msix(), pci_epc_ops::set_msix() nr_irqs encoding 2025-05-28 16:47:56 -05:00
pci-epc-mem.c PCI: endpoint: Improve pci_epc_mem_alloc_addr() 2024-10-12 17:25:54 +05:30
pci-epf-core.c Merge branch 'pci/endpoint/doorbell' 2025-07-31 16:11:45 -05:00