[PATCH 03/16] NTB: ntb_transport: Start TX offload thread after queue setup
From: Koichiro Den <hidden>
Date: 2026-08-10 16:51:53
Also in:
lkml
Subsystem:
ntb driver core, the rest · Maintainers:
Jon Mason, Dave Jiang, Allen Hubbe, Linus Torvalds
ntb_transport_create_queue() starts the per-QP TX offload thread before
DMA mappings and queue entries are allocated. If later setup fails, the
error path returns the QP to the free bitmap without stopping the
thread. A retry can then reinitialize its waitqueue while the old thread
is still waiting on it.
Start the thread only after all fallible queue setup has completed.
Thread creation failure itself remains non-fatal and falls back to
inline copy as before.
Fixes: 322617a06c97 ("NTB: ntb_transport: Add 'tx_memcpy_offload' module option")
Signed-off-by: Koichiro Den <redacted>
---
drivers/ntb/ntb_transport.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
index 3a9635faad9e..044d8b5747fc 100644
--- a/drivers/ntb/ntb_transport.c
+++ b/drivers/ntb/ntb_transport.c@@ -2063,20 +2063,6 @@ ntb_transport_create_queue(void *data, struct device *client_dev, qp->tx_handler = handlers->tx_handler; qp->event_handler = handlers->event_handler; - init_waitqueue_head(&qp->tx_offload_wq); - if (tx_memcpy_offload) { - qp->tx_offload_thread = kthread_run(ntb_tx_memcpy_kthread, qp, - "ntb-txcpy/%s/%u", - pci_name(ndev->pdev), qp->qp_num); - if (IS_ERR(qp->tx_offload_thread)) { - dev_warn(&nt->ndev->dev, - "tx memcpy offload thread creation failed: %ld; falling back to inline copy\n", - PTR_ERR(qp->tx_offload_thread)); - qp->tx_offload_thread = NULL; - } - } else - qp->tx_offload_thread = NULL; - dma_cap_zero(dma_mask); dma_cap_set(DMA_MEMCPY, dma_mask);
@@ -2137,6 +2123,20 @@ ntb_transport_create_queue(void *data, struct device *client_dev, &qp->tx_free_q); } + init_waitqueue_head(&qp->tx_offload_wq); + qp->tx_offload_thread = NULL; + if (tx_memcpy_offload) { + qp->tx_offload_thread = kthread_run(ntb_tx_memcpy_kthread, qp, + "ntb-txcpy/%s/%u", + pci_name(ndev->pdev), qp->qp_num); + if (IS_ERR(qp->tx_offload_thread)) { + dev_warn(&nt->ndev->dev, + "tx memcpy offload thread creation failed: %ld; falling back to inline copy\n", + PTR_ERR(qp->tx_offload_thread)); + qp->tx_offload_thread = NULL; + } + } + ntb_db_clear(qp->ndev, qp_bit); ntb_db_clear_mask(qp->ndev, qp_bit);
--
2.51.0