kernel_samsung_a53x/drivers/infiniband/hw/hfi1
Chengfeng Ye 9bf65b3f0d IB/hfi1: Fix potential deadlock on &irq_src_lock and &dd->uctxt_lock
[ Upstream commit 2f19c4b8395ccb6eb25ccafee883c8cfbe3fc193 ]

handle_receive_interrupt_napi_sp() running inside interrupt handler
could introduce inverse lock ordering between &dd->irq_src_lock
and &dd->uctxt_lock, if read_mod_write() is preempted by the isr.

          [CPU0]                                        |          [CPU1]
hfi1_ipoib_dev_open()                                   |
--> hfi1_netdev_enable_queues()                         |
--> enable_queues(rx)                                   |
--> hfi1_rcvctrl()                                      |
--> set_intr_bits()                                     |
--> read_mod_write()                                    |
--> spin_lock(&dd->irq_src_lock)                        |
                                                        | hfi1_poll()
                                                        | --> poll_next()
                                                        | --> spin_lock_irq(&dd->uctxt_lock)
                                                        |
                                                        | --> hfi1_rcvctrl()
                                                        | --> set_intr_bits()
                                                        | --> read_mod_write()
                                                        | --> spin_lock(&dd->irq_src_lock)
<interrupt>                                             |
   --> handle_receive_interrupt_napi_sp()               |
   --> set_all_fastpath()                               |
   --> hfi1_rcd_get_by_index()                          |
   --> spin_lock_irqsave(&dd->uctxt_lock)               |

This flaw was found by an experimental static analysis tool I am
developing for irq-related deadlock.

To prevent the potential deadlock, the patch use spin_lock_irqsave()
on &dd->irq_src_lock inside read_mod_write() to prevent the possible
deadlock scenario.

Signed-off-by: Chengfeng Ye <dg573847474@gmail.com>
Link: https://lore.kernel.org/r/20230926101116.2797-1-dg573847474@gmail.com
Acked-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-23 23:20:45 +01:00
..
affinity.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
affinity.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
aspm.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
aspm.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
chip.c IB/hfi1: Fix potential deadlock on &irq_src_lock and &dd->uctxt_lock 2024-11-23 23:20:45 +01:00
chip.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
chip_registers.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
common.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
debugfs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
debugfs.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
device.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
device.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
driver.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
efivar.c RDMA/hfi1: Workaround truncation compilation error 2024-11-18 11:43:04 +01:00
efivar.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
eprom.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
eprom.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
exp_rcv.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
exp_rcv.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fault.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fault.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
file_ops.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
firmware.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hfi.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
init.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intr.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
iowait.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
iowait.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ipoib.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ipoib_main.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ipoib_rx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ipoib_tx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Kconfig Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mad.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mad.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mmu_rb.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mmu_rb.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
msix.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
msix.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
netdev.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
netdev_rx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
opa_compat.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
opfn.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
opfn.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pcie.c RDMA/hfi1: Use FIELD_GET() to extract Link Width 2024-11-18 11:43:13 +01:00
pio.c IB/hfi1: Fix a memleak in init_credit_return 2024-11-18 22:25:39 +01:00
pio.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pio_copy.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
platform.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
platform.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
qp.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
qp.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
qsfp.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
qsfp.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ruc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdma.c IB/hfi1: Fix sdma.h tx->num_descs off-by-one error 2024-11-18 22:25:37 +01:00
sdma.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdma_txreq.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sysfs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tid_rdma.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tid_rdma.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
trace.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
trace.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
trace_ctxts.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
trace_dbg.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
trace_ibhdrs.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
trace_iowait.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
trace_misc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
trace_mmu.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
trace_rc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
trace_rx.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
trace_tid.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
trace_tx.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
uc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ud.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
user_exp_rcv.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
user_exp_rcv.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
user_pages.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
user_sdma.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
user_sdma.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
verbs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
verbs.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
verbs_txreq.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
verbs_txreq.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vnic.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vnic_main.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vnic_sdma.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00