From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 06CB037F30B; Sat, 12 Sep 2026 19:32:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789241553; cv=none; b=PWSj+SvbOvmQgaufG+fZvg1/bRGp8p/IIzPKnC2cSpPyEoHNXreQxKUF/dxJNs9J2G7yj9SQBCvt2sdG6bDrWpESd/XLHAo8BVwReDdNPwG2rRuwxVM5QozdF3FEqj8AIUT0qn746aXYYrWgB9+YSphH7XJYuBPmZHgKEF/Az0s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789241553; c=relaxed/simple; bh=pIvU0vdyD1jYrI0pXNLqDSNhYOT5pvT0i4s8YT2ehIQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b2QH0nbUM+yoydfLDaiboOAKGh/FyEEyI8Dk7P8tHS5c/S/R0kSfKttL9SscLHp8P5hZ0JCByvdJqCj7qXNVb1dPWRJcTAYeKaRurltqspin7XuogsJqF+3gyatb8qKYIFg3yJ4qDtdGEBWue2sdJ6ll7xgn/wcZVoHcZ4XXu3s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=HMVYlhmm; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="HMVYlhmm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70A211F000FF; Sat, 12 Sep 2026 19:32:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789241551; bh=ZvBFwHc7J13a9vnZopxVtWQSuOKbfwXfNQtG8hBsThM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HMVYlhmmmdZtikGxkL2sxAPGUaRQ+yBRmY3VmV4+WP9O1AP9yMwwH6Om3puaTqCmr xK2SOYSpNt2x3hIYuJLhfI+c/KRai2tgltmb7+Pd4aDxRlLsAIAgpfl6mTD9rE2b/S D8K1oe4s2jV1PB6VlOlfoenC30WCMfh11pQHbvyI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Koichiro Den , Dave Jiang , Jakub Kicinski Subject: [PATCH 5.10 160/798] NTB: ntb_transport: Recycle TX entries before client callbacks Date: Sat, 12 Sep 2026 08:56:28 +0200 Message-ID: <20260912065520.687652282@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065516.948645775@linuxfoundation.org> References: <20260912065516.948645775@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Koichiro Den commit 256496397287334a19ed80ec7be92bffcae76b9d upstream. 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 Reviewed-by: Dave Jiang Link: https://patch.msgid.link/20260817053519.4135287-2-den@valinux.co.jp Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/ntb/ntb_transport.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) --- a/drivers/ntb/ntb_transport.c +++ b/drivers/ntb/ntb_transport.c @@ -1734,9 +1734,16 @@ static void ntb_transport_rxc_db(unsigne 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) { @@ -1776,15 +1783,13 @@ static void ntb_tx_copy_callback(void *d * "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(struct ntb_queue_entry *entry, void __iomem *offset)