From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796385035; b=feSyOW+VFH+LB3QWUNjLGo/BCCUs+fnPMoIm6wDI4fIS8yRLSeokyUqdFhQn2NteOYg5 RZ7sBq52LhJGzvyH51F0L0syu3zBU5aBORHCE0kxn1tsXxWJyILq/L8m8m4bIvV8BmmVf VZhPV6Wr1MPHnSiFMXCv4HbNZhy5+VJjhoErE/xBEPStNMK5HjsNRlHz2jK0RjwDP7cFO UPjrGvtbF3ereQLEW2ArvdoXGQVs+Qzo/wvTmIZFFpSHKdTBc1jD9qUeusR6SOFpzONvU 1rLVdckdj79Z+y9hWZhebgU2ltsI8CMZ7ETMFvKCqeHMsfmFXAv4GisC8aS48P9w+6g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385035; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=iwHSZJibpoFLEGnzJbttRndRzHDC7YZXotx/4g5uKG0=; b=41aKnLxm15zVv7O5wYzaAYP9MhQzu3N84FG0vlXsAuii+wEfvEBrFM+wBfOu6UQzxbBG H7vHXJ9yKul4yQBNz+5qm/1nByu07rvKLNT9L7zt6tn8W7zJcAM8APSnKnRgvrFH2qnp3 qyIGlo1thsAKvhQDTNpJ9MX8yHx5wNpbXrP/Y4yh77Lvl15iag7bIAJLkZWfbqFyUU3MI fUmZy7hG5V59GOBeGxvefZP59gtnDEGYzRsG8S3yYyW3pP46uR6jbuweUkPk/sr8G4bI2 tRLh+CUXx6Z40BKuShr1DvTuWGP9xKGQCfgeUVm0aNqcUvy0XN8eCMfGtSAw80u42gg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=VLzmFwOV; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 955E7606A322; Fri, 4 Dec 2026 11:50:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=VLzmFwOV Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4E4D1F0092C; Fri, 4 Dec 2026 11:50:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385035; bh=iwHSZJibpoFLEGnzJbttRndRzHDC7YZXotx/4g5uKG0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=VLzmFwOV4AIIZdg4KE2rKQDnUUem1UwVeMFrPYKksxD2NYWK+OwXK/f0vkOxmf6wx QoFlustHmBT/HoKR0G98nRBZUdgGeaTttoiclWNjN/zsgvWR+29pLUIYP5HfL2X8Mm H56PJnDIgGO/axuWeMXtABSSqltHIOKT9A6hxuXE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Quanye Yang , Farhad Alemi , Jack Wang , Leon Romanovsky , Sasha Levin Subject: [PATCH 6.6 0392/1167] RDMA/rtrs-clt: Fix recv repost to satisfy ib_drain_rq Date: Fri, 4 Dec 2026 18:56:59 +0900 Message-ID: <20261204100712.237942048@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Quanye Yang [ Upstream commit 3255d6b83491574b115806ec958d8f6ca090fa9c ] On disconnect the client error recovery path calls ib_drain_qp(), which requires one free RQ slot and that no recv WQEs are posted while the queue is being drained. When the server is loaded with always_invalidate=N, the path does not advertise RTRS_MSG_NEW_RKEY_F. A client-requested invalidation is then a standalone SEND_WITH_INV. The recv completion path did not repost that WQE; it posted two empty recv WQEs later, when the RDMA-with-IMM response carried RTRS_IO_RSP_W_INV_IMM. If the invalidate receive never arrived, each such response increased RQ occupancy by one until ib_post_recv() started returning -ENOMEM and __ib_drain_rq() failed with: failed to drain recv queue: -12 Repost one empty recv WQE for every receive completion, including SEND_WITH_INV completions on the always_invalidate=N path, and only while the path is still connected so CQ polling cannot race with ib_drain_qp(). Size IO connection RQs to 2 * queue_depth + 1 to match the posted recv count and leave the drain slot. Tested with a synthetic RTRS client flooding unpaired RTRS_IO_RSP_W_INV_IMM messages; error recovery no longer triggers __ib_drain_rq() warnings. Fixes: 6a98d71daea1 ("RDMA/rtrs: client: main functionality") Signed-off-by: Quanye Yang Link: https://lore.kernel.org/linux-rdma/CA+0ovCihE2_pxLimjmmR8NMz4g-ie8dvvq1jmAj-Om33y3Vzfg@mail.gmail.com Link: https://patch.msgid.link/20261005-rtrs-fix-ib-drain-rq-v2-1-35535a3ed115@proton.me Tested-by: Quanye Yang Reported-by: Farhad Alemi Acked-by: Jack Wang Signed-off-by: Leon Romanovsky [ sashal: Kept the branch's min_t(int, ...) form and older error-message context, changing only the intended queue_depth * 3 + 1 to * 2 + 1 and dropping the old repost block in favor of the new helper. ] Signed-off-by: Sasha Levin --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 45 +++++++++----------------- 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 068016c3413be..1d113f39e0b8b 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -584,25 +584,21 @@ static struct ib_cqe io_comp_cqe = { .done = rtrs_clt_rdma_done }; -/* - * Post x2 empty WRs: first is for this RDMA with IMM, - * second is for RECV with INV, which happened earlier. - */ -static int rtrs_post_recv_empty_x2(struct rtrs_con *con, struct ib_cqe *cqe) +static int rtrs_clt_repost_recv(struct rtrs_clt_con *con) { - struct ib_recv_wr wr_arr[2], *wr; - int i; + struct rtrs_clt_path *clt_path = to_clt_path(con->c.path); + int err; - memset(wr_arr, 0, sizeof(wr_arr)); - for (i = 0; i < ARRAY_SIZE(wr_arr); i++) { - wr = &wr_arr[i]; - wr->wr_cqe = cqe; - if (i) - /* Chain backwards */ - wr->next = &wr_arr[i - 1]; - } + if (READ_ONCE(clt_path->state) != RTRS_CLT_CONNECTED) + return 0; - return ib_post_recv(con->qp, wr, NULL); + err = rtrs_post_recv_empty(&con->c, &io_comp_cqe); + if (err) { + rtrs_err(con->c.path, "rtrs_post_recv_empty(): %pe\n", + ERR_PTR(err)); + rtrs_rdma_error_recovery(con); + } + return err; } static void rtrs_clt_rdma_done(struct ib_cq *cq, struct ib_wc *wc) @@ -663,19 +659,7 @@ static void rtrs_clt_rdma_done(struct ib_cq *cq, struct ib_wc *wc) rtrs_wrn(con->c.path, "Unknown IMM type %u\n", imm_type); } - if (w_inval) - /* - * Post x2 empty WRs: first is for this RDMA with IMM, - * second is for RECV with INV, which happened earlier. - */ - err = rtrs_post_recv_empty_x2(&con->c, &io_comp_cqe); - else - err = rtrs_post_recv_empty(&con->c, &io_comp_cqe); - if (err) { - rtrs_err(con->c.path, "rtrs_post_recv_empty(): %d\n", - err); - rtrs_rdma_error_recovery(con); - } + rtrs_clt_repost_recv(con); break; case IB_WC_RECV: /* @@ -691,6 +675,7 @@ static void rtrs_clt_rdma_done(struct ib_cq *cq, struct ib_wc *wc) return rtrs_clt_rkey_rsp_done(con, wc); } + rtrs_clt_repost_recv(con); break; case IB_WC_RDMA_WRITE: /* @@ -1709,7 +1694,7 @@ static int create_con_cq_qp(struct rtrs_clt_con *con) /* QD * (REQ + RSP + FR REGS or INVS) + drain */ clt_path->queue_depth * 4 + 1); max_recv_wr = min_t(int, wr_limit, - clt_path->queue_depth * 3 + 1); + clt_path->queue_depth * 2 + 1); max_send_sge = 2; } atomic_set(&con->c.sq_wr_avail, max_send_wr); -- 2.53.0