Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

RDMA/siw: Always report immediate post SQ errors

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>

authored by

Bernard Metzler and committed by
Jason Gunthorpe
fdd0fe94 fb0b0829

+14 -11
+14 -11
drivers/infiniband/sw/siw/siw_verbs.c
··· 769 769 struct siw_wqe *wqe = tx_wqe(qp); 770 770 771 771 unsigned long flags; 772 - int rv = 0; 772 + int rv = 0, imm_err = 0; 773 773 774 774 if (wr && !rdma_is_kernel_res(&qp->base_qp.res)) { 775 775 siw_dbg_qp(qp, "wr must be empty for user mapped sq\n"); ··· 955 955 * Send directly if SQ processing is not in progress. 956 956 * Eventual immediate errors (rv < 0) do not affect the involved 957 957 * RI resources (Verbs, 8.3.1) and thus do not prevent from SQ 958 - * processing, if new work is already pending. But rv must be passed 959 - * to caller. 958 + * processing, if new work is already pending. But rv and pointer 959 + * to failed work request must be passed to caller. 960 960 */ 961 + if (unlikely(rv < 0)) { 962 + /* 963 + * Immediate error 964 + */ 965 + siw_dbg_qp(qp, "Immediate error %d\n", rv); 966 + imm_err = rv; 967 + *bad_wr = wr; 968 + } 961 969 if (wqe->wr_status != SIW_WR_IDLE) { 962 970 spin_unlock_irqrestore(&qp->sq_lock, flags); 963 971 goto skip_direct_sending; ··· 990 982 991 983 up_read(&qp->state_lock); 992 984 993 - if (rv >= 0) 994 - return 0; 995 - /* 996 - * Immediate error 997 - */ 998 - siw_dbg_qp(qp, "error %d\n", rv); 985 + if (unlikely(imm_err)) 986 + return imm_err; 999 987 1000 - *bad_wr = wr; 1001 - return rv; 988 + return (rv >= 0) ? 0 : rv; 1002 989 } 1003 990 1004 991 /*