public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] RDMA/siw: avoid hiding errors in siw_post_send()
@ 2025-09-04 17:36 Stefan Metzmacher
  2025-09-05 18:37 ` Bernard Metzler
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Metzmacher @ 2025-09-04 17:36 UTC (permalink / raw)
  To: linux-rdma; +Cc: metze, Bernard Metzler

When we hit situations like "sq full", "too many sge's" or similar
things while queueing sqes, we should remember the error before
rv = siw_activate_tx(qp); clears the return value.

Currently we hide such errors and confuse the caller
which is waiting (most likely forever) for a post completion
to arrive.

Also if we already queued some sqes with success we need to process
them as no error happened, but at the end we need to return the
error relative to the bad_wr to the caller.

Cc: Bernard Metzler <bernard.metzler@linux.dev>
Cc: linux-rdma@vger.kernel.org
Fixes: 303ae1cdfdf7 ("rdma/siw: application interface")
Signed-off-by: Stefan Metzmacher <metze@samba.org>
---
 drivers/infiniband/sw/siw/siw_verbs.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/infiniband/sw/siw/siw_verbs.c b/drivers/infiniband/sw/siw/siw_verbs.c
index 556a2b4b42ed..a3f548652c37 100644
--- a/drivers/infiniband/sw/siw/siw_verbs.c
+++ b/drivers/infiniband/sw/siw/siw_verbs.c
@@ -770,6 +770,8 @@ int siw_post_send(struct ib_qp *base_qp, const struct ib_send_wr *wr,
 
 	unsigned long flags;
 	int rv = 0;
+	size_t num_queued = 0;
+	int error = 0;
 
 	if (wr && !rdma_is_kernel_res(&qp->base_qp.res)) {
 		siw_dbg_qp(qp, "wr must be empty for user mapped sq\n");
@@ -948,9 +950,24 @@ int siw_post_send(struct ib_qp *base_qp, const struct ib_send_wr *wr,
 		sqe->flags |= SIW_WQE_VALID;
 
 		qp->sq_put++;
+		num_queued++;
 		wr = wr->next;
 	}
 
+	if (unlikely(rv < 0)) {
+		/*
+		 * If at least one was queued
+		 * we should start the tx, but
+		 * still return an error with
+		 * the bad_wr at the end.
+		 */
+		error = rv;
+		if (num_queued == 0) {
+			spin_unlock_irqrestore(&qp->sq_lock, flags);
+			goto skip_direct_sending;
+		}
+	}
+
 	/*
 	 * Send directly if SQ processing is not in progress.
 	 * Eventual immediate errors (rv < 0) do not affect the involved
@@ -982,6 +999,9 @@ int siw_post_send(struct ib_qp *base_qp, const struct ib_send_wr *wr,
 
 	up_read(&qp->state_lock);
 
+	if (unlikely(error != 0))
+		rv = error;
+
 	if (rv >= 0)
 		return 0;
 	/*
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-09-23 14:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-04 17:36 [PATCH] RDMA/siw: avoid hiding errors in siw_post_send() Stefan Metzmacher
2025-09-05 18:37 ` Bernard Metzler
2025-09-23 11:40   ` Stefan Metzmacher
2025-09-23 14:39     ` Bernard Metzler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox