[PATCH v3 07/15] NTB: ntb_transport: Clear link state before QP cleanup
From: Koichiro Den
Date: Mon Sep 28 2026 - 11:42:16 EST
Cleanup leaves the transport link marked up after releasing its MWs.
A subsequent client link-up request can therefore start QP link work
before the transport has been set up again.
Clear link_is_up before cancelling QP work and releasing the MWs.
Have QP link work return if the transport went down after it was
queued.
Fixes: e26a5843f7f5 ("NTB: Split ntb_hw_intel and ntb_transport drivers")
Cc: stable@xxxxxxxxxxxxxxx
Reviewed-by: Logan Gunthorpe <logang@xxxxxxxxxxxx>
Reviewed-by: Dave Jiang <dave.jiang@xxxxxxxxx>
Signed-off-by: Koichiro Den <den@xxxxxxxxxxxxx>
---
Changes in v3:
- Use atomic accessors for link_is_up. (Frank)
- Carry over Reviewed-by.
v2: https://lore.kernel.org/r/20260910040836.3792333-7-den@xxxxxxxxxxxxx/
drivers/ntb/ntb_transport.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
index d290e5869c21..571d633c4f0b 100644
--- a/drivers/ntb/ntb_transport.c
+++ b/drivers/ntb/ntb_transport.c
@@ -974,6 +974,8 @@ static void ntb_transport_link_cleanup(struct ntb_transport_ctx *nt)
guard(mutex)(&nt->link_event_lock);
+ atomic_set(&nt->link_is_up, false);
+
qp_bitmap_alloc = nt->qp_bitmap & ~nt->qp_bitmap_free;
/* Pass along the info to any clients */
@@ -1139,7 +1141,9 @@ static void ntb_qp_link_work(struct work_struct *work)
struct ntb_transport_ctx *nt = qp->transport;
int val;
- WARN_ON(!atomic_read(&nt->link_is_up));
+ /* Pair with the link publication in ntb_transport_link_work(). */
+ if (!atomic_read_acquire(&nt->link_is_up))
+ return;
val = ntb_spad_read(nt->ndev, QP_LINKS);
--
2.51.0