Re: [PATCH net 1/4] NTB: ntb_transport: Recycle TX entries before client callbacks
Dave Jiang <[email protected]>
| Newsgroups | dev.linux.lists.ntb,org.kernel.vger.linux-kernel,org.kernel.vger.netdev |
|---|---|
| Message-ID | <[email protected]> |
On 8/16/26 10:35 PM, Koichiro Den wrote:
> ntb_tx_copy_callback() invokes the client callback before returning the
> entry to tx_free_q. The callback may wake a stopped client queue, only
> for the next enqueue to find no local entry and return -EBUSY. The window
> is narrow, but the retry is unnecessary.
>
> Save the callback data and length, then return the entry to tx_free_q
> before invoking the client. A completion callback then means both the
> client buffer and transport entry are ready for reuse.
>
> Fixes: fce8a7bb5b4b ("PCI-Express Non-Transparent Bridge Support")
> Cc: [email protected]
> Signed-off-by: Koichiro Den <[email protected]>
Reviewed-by: Dave Jiang <[email protected]>
> ---
> drivers/ntb/ntb_transport.c | 23 ++++++++++++++---------
> 1 file changed, 14 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
> index f59f926d4bfa..e92b96f4afad 100644
> --- a/drivers/ntb/ntb_transport.c
> +++ b/drivers/ntb/ntb_transport.c
> @@ -1719,9 +1719,16 @@ static void ntb_transport_rxc_db(unsigned long data)
> static void ntb_tx_copy_callback(void *data,
> const struct dmaengine_result *res)
> {
> + struct ntb_payload_header __iomem *hdr;
> struct ntb_queue_entry *entry = data;
> - struct ntb_transport_qp *qp = entry->qp;
> - struct ntb_payload_header __iomem *hdr = entry->tx_hdr;
> + struct ntb_transport_qp *qp;
> + unsigned int len;
> + void *cb_data;
> +
> + qp = entry->qp;
> + hdr = entry->tx_hdr;
> + cb_data = entry->cb_data;
> + len = entry->len;
>
> /* we need to check DMA results if we are using DMA */
> if (res) {
> @@ -1768,15 +1775,13 @@ static void ntb_tx_copy_callback(void *data,
> * "link down" or similar. Since no payload is being sent in these
> * cases, there is nothing to add to the completion queue.
> */
> - if (entry->len > 0) {
> - qp->tx_bytes += entry->len;
> -
> - if (qp->tx_handler)
> - qp->tx_handler(qp, qp->cb_data, entry->cb_data,
> - entry->len);
> - }
> + if (len > 0)
> + qp->tx_bytes += len;
>
> ntb_list_add(&qp->ntb_tx_free_q_lock, &entry->entry, &qp->tx_free_q);
> +
> + if (len > 0 && qp->tx_handler)
> + qp->tx_handler(qp, qp->cb_data, cb_data, len);
> }
>
> static void ntb_memcpy_tx_on_stack(struct ntb_queue_entry *entry, void __iomem *offset)