Netdev List
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: Koichiro Den <den@valinux.co.jp>, Jon Mason <jdmason@kudzu.us>,
	Allen Hubbe <allenbh@gmail.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: ntb@lists.linux.dev, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net 1/4] NTB: ntb_transport: Recycle TX entries before client callbacks
Date: Wed, 19 Aug 2026 14:16:09 -0700	[thread overview]
Message-ID: <5571c4ba-aa12-442a-aa2f-3b3e073e1305@intel.com> (raw)
In-Reply-To: <20260817053519.4135287-2-den@valinux.co.jp>



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: stable@vger.kernel.org
> Signed-off-by: Koichiro Den <den@valinux.co.jp>

Reviewed-by: Dave Jiang <dave.jiang@intel.com>

> ---
>  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)


  reply	other threads:[~2026-08-19 21:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-17  5:35 [PATCH net 0/4] net: ntb_netdev: Fix TX completion and error handling Koichiro Den
2026-08-17  5:35 ` [PATCH net 1/4] NTB: ntb_transport: Recycle TX entries before client callbacks Koichiro Den
2026-08-19 21:16   ` Dave Jiang [this message]
2026-08-17  5:35 ` [PATCH net 2/4] net: ntb_netdev: Fix TX busy and drop handling Koichiro Den
2026-08-19 23:39   ` Dave Jiang
2026-08-17  5:35 ` [PATCH net 3/4] NTB: ntb_transport: Fail TX enqueue when the QP link is down Koichiro Den
2026-08-19 23:46   ` Dave Jiang
2026-08-17  5:35 ` [PATCH net 4/4] NTB: ntb_transport: Reject oversized TX buffers Koichiro Den
2026-08-19 23:47   ` Dave Jiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5571c4ba-aa12-442a-aa2f-3b3e073e1305@intel.com \
    --to=dave.jiang@intel.com \
    --cc=allenbh@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=den@valinux.co.jp \
    --cc=edumazet@google.com \
    --cc=jdmason@kudzu.us \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=ntb@lists.linux.dev \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox