]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
NTB: epf: Fix doorbell bitmask and IRQ vector handling
authorKoichiro Den <den@valinux.co.jp>
Wed, 13 May 2026 02:49:22 +0000 (11:49 +0900)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 23 Jun 2026 16:37:44 +0000 (11:37 -0500)
commit4fdea8dbb62d746429498e07385a3ba0b0f6d1ab
treea3d524ca1cc8896f28e04398bde7604a7cb2cdfe
parent3147f0964cecca15e349cbfbdd6a28eb6d50379d
NTB: epf: Fix doorbell bitmask and IRQ vector handling

The EPF driver currently stores the incoming doorbell as a vector number
(irq_no + 1) in db_val and db_clear() clears all bits unconditionally.
This breaks db_read()/db_clear() semantics when multiple doorbells are
used.

Store doorbells as a bitmask (BIT_ULL(vector)) and make
db_clear(db_bits) clear only the specified bits. Use atomic64 operations
as db_val is updated from interrupt context.

Once db_val is stored as a bitmask, the ISR's doorbell vector is used
not only for ntb_db_event(), but also as the bit index for BIT_ULL().
The existing ISR derives that vector by subtracting pci_irq_vector(pdev,
0) from the Linux IRQ number passed to the handler, but Linux IRQ
numbers are not guaranteed to be contiguous.

Pass per-vector context as request_irq() dev_id instead, so the ISR gets
the device vector directly.

Validate the doorbell vector before updating db_val or calling
ntb_db_event(), so an unexpected vector cannot create an invalid shift
or be reported to NTB clients.

While at it, read and validate mw_count before requesting interrupt
vectors. An unsupported memory-window count does not need IRQs, and
failing before ntb_epf_init_isr() keeps the probe error path simple.

Fixes: 812ce2f8d14e ("NTB: Add support for EPF PCI Non-Transparent Bridge")
Suggested-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Koichiro Den <den@valinux.co.jp>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20260513024923.451765-12-den@valinux.co.jp
drivers/ntb/hw/epf/ntb_hw_epf.c