mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 15:22:21 -04:00
NTB: ntb_transport: Recycle TX entries before client callbacks
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: fce8a7bb5b ("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>
Link: https://patch.msgid.link/20260817053519.4135287-2-den@valinux.co.jp
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
8197c18005
commit
2564963972
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user