]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
RDMA/siw: Always report immediate post SQ errors
authorBernard Metzler <bernard.metzler@linux.dev>
Tue, 23 Sep 2025 14:45:36 +0000 (16:45 +0200)
committerJason Gunthorpe <jgg@nvidia.com>
Fri, 26 Sep 2025 16:12:19 +0000 (13:12 -0300)
In siw_post_send(), any immediate error encountered during processing of
the work request list must be reported to the caller, even if previous
work requests in that list were just accepted and added to the send queue.

Not reporting those errors confuses the caller, which would wait
indefinitely for the failing and potentially subsequently aborted work
requests completion.

This fixes a case where immediate errors were overwritten by subsequent
code in siw_post_send().

Fixes: 303ae1cdfdf7 ("rdma/siw: application interface")
Link: https://patch.msgid.link/r/20250923144536.103825-1-bernard.metzler@linux.dev
Suggested-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Bernard Metzler <bernard.metzler@linux.dev>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/sw/siw/siw_verbs.c

index 35c3bde0d00af88b31f2df8feed57577bf61b19d..efa2f097b58289aaa3fb2bba08ed9ba43b968d1c 100644 (file)
@@ -769,7 +769,7 @@ int siw_post_send(struct ib_qp *base_qp, const struct ib_send_wr *wr,
        struct siw_wqe *wqe = tx_wqe(qp);
 
        unsigned long flags;
-       int rv = 0;
+       int rv = 0, imm_err = 0;
 
        if (wr && !rdma_is_kernel_res(&qp->base_qp.res)) {
                siw_dbg_qp(qp, "wr must be empty for user mapped sq\n");
@@ -955,9 +955,17 @@ int siw_post_send(struct ib_qp *base_qp, const struct ib_send_wr *wr,
         * Send directly if SQ processing is not in progress.
         * Eventual immediate errors (rv < 0) do not affect the involved
         * RI resources (Verbs, 8.3.1) and thus do not prevent from SQ
-        * processing, if new work is already pending. But rv must be passed
-        * to caller.
+        * processing, if new work is already pending. But rv and pointer
+        * to failed work request must be passed to caller.
         */
+       if (unlikely(rv < 0)) {
+               /*
+                * Immediate error
+                */
+               siw_dbg_qp(qp, "Immediate error %d\n", rv);
+               imm_err = rv;
+               *bad_wr = wr;
+       }
        if (wqe->wr_status != SIW_WR_IDLE) {
                spin_unlock_irqrestore(&qp->sq_lock, flags);
                goto skip_direct_sending;
@@ -982,15 +990,10 @@ skip_direct_sending:
 
        up_read(&qp->state_lock);
 
-       if (rv >= 0)
-               return 0;
-       /*
-        * Immediate error
-        */
-       siw_dbg_qp(qp, "error %d\n", rv);
+       if (unlikely(imm_err))
+               return imm_err;
 
-       *bad_wr = wr;
-       return rv;
+       return (rv >= 0) ? 0 : rv;
 }
 
 /*