Re: [PATCH v2 02/14] NTB: ntb_transport: Start TX offload thread after queue setup

From: Frank Li

Date: Fri Sep 11 2026 - 12:41:31 EST


On Thu, Sep 10, 2026 at 01:08:24PM +0900, Koichiro Den wrote:
> 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 after queue setup.
>
> Fixes: 322617a06c97 ("NTB: ntb_transport: Add 'tx_memcpy_offload' module option")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Koichiro Den <den@xxxxxxxxxxxxx>
> ---

Reviewed-by: Frank Li <Frank.Li@xxxxxxx>

> Changes in v2:
> - No changes.
>
> NOTE: Originally submitted as part of the direct TX/RX series v1:
> https://lore.kernel.org/r/20260810165136.2292436-4-den@xxxxxxxxxxxxx/
>
> 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 3389d6ca9ebd..55a20ae9a85e 100644
> --- a/drivers/ntb/ntb_transport.c
> +++ b/drivers/ntb/ntb_transport.c
> @@ -2055,20 +2055,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);
>
> @@ -2129,6 +2115,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
>