Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1630438pxb; Wed, 9 Feb 2022 00:35:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJy0a7bXJf9DlzZAGS7JM+6jIq6oPEnYq74E/kzADBYAqaxVlFyLa+AbV8Vre3rE0un2xpnj X-Received: by 2002:a17:90b:1652:: with SMTP id il18mr1335545pjb.205.1644395746020; Wed, 09 Feb 2022 00:35:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644395746; cv=none; d=google.com; s=arc-20160816; b=dGlRrpInxWHL6g1udW+ormypiaNZnfc3dp8SxQAYZPvhl2WEhL2arn7eYpkhvikMrJ 15DuybBkcz1YBHyYOk2gtBQTumJCO2d90Ya1U6egymuNOpHXDJowf09r6j3Ki2kEhF95 X1qI13mr4uJ5g8dS/dKZe8oeQrY3ihNZdSaShzwlgm5nKECFoqGvqnt8K22Nxze4SWrK h9F4g28kZ2Z6Vwg/rZnDgghMwcM2PdhhPdqMMh3DCbAaz9lfM7PedbH2I+efWdNd6AzG RItSfNGg68cJzaJhFE0TFIA1JOQoKFVxE0zAg9dPGnDgq/2emAJZ+JPC/2qE23xwIF0S 8hNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=n9It9rI9aIo4zACaOaEqlv+uQg0zWL1/ExzrUhBtMJ8=; b=VnMMEG4d0/LGP1n9s0PioGZ3ARc0G+ElO+4lWHIpk3NWBXGyqR0xh4Zjk3UrDY3HYS WOwMspAF8bJS7xxgqvcUuTzhgtEf9YKrWEn/OCpJId8+SGxSSJDKm16TjrzkvgDd4JEO PJG6FMTeULgJy41hNJTRgVIZ0ALsKMw3Rs9iI4m/xDn2posNNUNW4d55dJpyKne9VDqt 1CcnF2bU+Ud4abus8AsBz+16Nexn1/ApFEkKuFes8B4pst/rfTmamTN37foWJDy1adCv XDAUvQOW3glR43SkpfuItiEMORv1ZDUH1PaSwipGYhTsuyCda8mItVAi0DkjRIHzap4T EcUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qphQZw38; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id y20si13542565plr.285.2022.02.09.00.35.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 00:35:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qphQZw38; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E73D2C03E96E; Wed, 9 Feb 2022 00:35:35 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387313AbiBGLlI (ORCPT + 99 others); Mon, 7 Feb 2022 06:41:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238765AbiBGL2R (ORCPT ); Mon, 7 Feb 2022 06:28:17 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0EA4C0364B6; Mon, 7 Feb 2022 03:26:47 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A79E76091A; Mon, 7 Feb 2022 11:26:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87002C004E1; Mon, 7 Feb 2022 11:26:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233184; bh=lV1mkuh7zyPWVcvLXzJOB2GkO6mowb3cwC8cFqZQMqI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qphQZw38ZA6I73laFsNqdqEqAWo6HKF9w3UZeG7BifWgOS1HVwUnOLi65NukDxQei ph9nTa+xpfu7j0ErtyEPhaSJSqr+5OORAQZZKkEvo07Ex6StR7bjOHRUApfeFntXDc SSbdEBpRDBOw0kOT9yBntM6sNLj/GPCrB7eErapc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jared Holzman , Bernard Metzler , Jason Gunthorpe Subject: [PATCH 5.15 043/110] RDMA/siw: Fix broken RDMA Read Fence/Resume logic. Date: Mon, 7 Feb 2022 12:06:16 +0100 Message-Id: <20220207103803.734262243@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bernard Metzler commit b43a76f423aa304037603fd6165c4a534d2c09a7 upstream. Code unconditionally resumed fenced SQ processing after next RDMA Read completion, even if other RDMA Read responses are still outstanding, or ORQ is full. Also adds comments for better readability of fence processing, and removes orq_get_tail() helper, which is not needed anymore. Fixes: 8b6a361b8c48 ("rdma/siw: receive path") Fixes: a531975279f3 ("rdma/siw: main include file") Link: https://lore.kernel.org/r/20220130170815.1940-1-bmt@zurich.ibm.com Reported-by: Jared Holzman Signed-off-by: Bernard Metzler Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/sw/siw/siw.h | 7 +------ drivers/infiniband/sw/siw/siw_qp_rx.c | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 15 deletions(-) --- a/drivers/infiniband/sw/siw/siw.h +++ b/drivers/infiniband/sw/siw/siw.h @@ -644,14 +644,9 @@ static inline struct siw_sqe *orq_get_cu return &qp->orq[qp->orq_get % qp->attrs.orq_size]; } -static inline struct siw_sqe *orq_get_tail(struct siw_qp *qp) -{ - return &qp->orq[qp->orq_put % qp->attrs.orq_size]; -} - static inline struct siw_sqe *orq_get_free(struct siw_qp *qp) { - struct siw_sqe *orq_e = orq_get_tail(qp); + struct siw_sqe *orq_e = &qp->orq[qp->orq_put % qp->attrs.orq_size]; if (READ_ONCE(orq_e->flags) == 0) return orq_e; --- a/drivers/infiniband/sw/siw/siw_qp_rx.c +++ b/drivers/infiniband/sw/siw/siw_qp_rx.c @@ -1153,11 +1153,12 @@ static int siw_check_tx_fence(struct siw spin_lock_irqsave(&qp->orq_lock, flags); - rreq = orq_get_current(qp); - /* free current orq entry */ + rreq = orq_get_current(qp); WRITE_ONCE(rreq->flags, 0); + qp->orq_get++; + if (qp->tx_ctx.orq_fence) { if (unlikely(tx_waiting->wr_status != SIW_WR_QUEUED)) { pr_warn("siw: [QP %u]: fence resume: bad status %d\n", @@ -1165,10 +1166,12 @@ static int siw_check_tx_fence(struct siw rv = -EPROTO; goto out; } - /* resume SQ processing */ + /* resume SQ processing, if possible */ if (tx_waiting->sqe.opcode == SIW_OP_READ || tx_waiting->sqe.opcode == SIW_OP_READ_LOCAL_INV) { - rreq = orq_get_tail(qp); + + /* SQ processing was stopped because of a full ORQ */ + rreq = orq_get_free(qp); if (unlikely(!rreq)) { pr_warn("siw: [QP %u]: no ORQE\n", qp_id(qp)); rv = -EPROTO; @@ -1181,15 +1184,14 @@ static int siw_check_tx_fence(struct siw resume_tx = 1; } else if (siw_orq_empty(qp)) { + /* + * SQ processing was stopped by fenced work request. + * Resume since all previous Read's are now completed. + */ qp->tx_ctx.orq_fence = 0; resume_tx = 1; - } else { - pr_warn("siw: [QP %u]: fence resume: orq idx: %d:%d\n", - qp_id(qp), qp->orq_get, qp->orq_put); - rv = -EPROTO; } } - qp->orq_get++; out: spin_unlock_irqrestore(&qp->orq_lock, flags);