Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp140271ybc; Mon, 18 Nov 2019 22:03:05 -0800 (PST) X-Google-Smtp-Source: APXvYqzH2kwPSRYMypoa7rBzDIjbzC6wDivmOa+HJHyawwayxJQxyLE0PuGmfpMXC6B9lXwYkZZN X-Received: by 2002:a17:906:7f8a:: with SMTP id f10mr33398424ejr.209.1574143385297; Mon, 18 Nov 2019 22:03:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574143385; cv=none; d=google.com; s=arc-20160816; b=J/iQ+QNvLFb1T705q1YyCBZ4ZMOzpu5e52tCtYPRqKvnGJDHMDgw3OcO7jmVALyaVq ygLAzuaijmtE1QELE9brH/TIMH+XhjpTmw9Kj/jWPN7BxXZrPYFqqmNJMmO7l61o/pqH a9B+XM+q0Sc9Rx4McYzw8BhbKYx7zrF7PGhUpPtnyGvUVBjNmnif9+vBt61cfshKzQ5v qqo5yHjMqJK/dUlQ3mn8Oh5RsFbeEWgt+qxP+6E1IiFF8BHrkY381rU7Eux6EE4iCjpr a/TJCYjMKGopOK2fQa1Qu3ftfs4fcrsRniEjwhR4PEdsJdAEHVWm3yHwjOM1ib1+thlt lNYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=J4a5nblzAf8S+QrdJlY6xngcuShM3u7nu9354f7fZWk=; b=qtQCjmE+CyE4Xfc/RdWNUtvO4okzbNYNS3SXQHeiC5yQ/4zehbtI4JL+uIiEgShZQX +efW5bGWBGi4IlJsl0sgcB8xtGqgREU2Ma97/DMHq7uMYgRRXt9AuYJNNHvWLPBNqIbb +Dd7761nYCLamQrdYU89nnpyl1CLV/buHh1kVawl8EaN34zX6Fa9BHGqNloJSxJNYZuR 6b63VkJuf6WEA8tBc7YqK8Vku1KUCZ+ljt0zDq1igw/8Sxdpc5qwv4uATk5vlcwXs4TB qxW1ThEKxOF5y4+2kiFb5FVbZMjxqiKrzXD1i5Yf+21asaWcjPZjZikpLTMnT9MvAMHO eOGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=piXoLK6W; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q40si16080323eda.218.2019.11.18.22.02.41; Mon, 18 Nov 2019 22:03:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=piXoLK6W; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730795AbfKSFp6 (ORCPT + 99 others); Tue, 19 Nov 2019 00:45:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:41824 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731026AbfKSFp4 (ORCPT ); Tue, 19 Nov 2019 00:45:56 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 35F932075E; Tue, 19 Nov 2019 05:45:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574142355; bh=82XU3aU5ABFzGlRmWBE0XT+9t7AA0CAjUdCcZDInlf8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=piXoLK6WL/Dd7d2edNnIgOoVA+ShTzaC/EwozeRS0R4bNOYHrIxIi6gxsvGnQZXzZ UgWj2Zp5ykil885niXpgLQPR8+E3VPh6rdKIj4N4ZNSJjAQ1xjBUvR8tbV4N2cZER5 TJPIFdvRnWq+sie42Cy0ilr2PHsrbPsjWYi674nk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vijay Immanuel , Doug Ledford , Sasha Levin Subject: [PATCH 4.14 054/239] IB/rxe: fixes for rdma read retry Date: Tue, 19 Nov 2019 06:17:34 +0100 Message-Id: <20191119051308.130440267@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191119051255.850204959@linuxfoundation.org> References: <20191119051255.850204959@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vijay Immanuel [ Upstream commit 030e46e495af855a13964a0aab9753ea82a96edc ] When a read request is retried for the remaining partial data, the response may restart from read response first or read response only. So support those cases. Do not advance the comp psn beyond the current wqe's last_psn as that could skip over an entire read wqe and will cause the req_retry() logic to set an incorrect req psn. An example sequence is as follows: Write PSN 40 -- this is the current WQE. Read request PSN 41 Write PSN 42 Receive ACK PSN 42 -- this will complete the current WQE for PSN 40, and set the comp psn to 42 which is a problem because the read request at PSN 41 has been skipped over. So when req_retry() tries to retransmit the read request, it sets the req psn to 42 which is incorrect. When retrying a read request, calculate the number of psns completed based on the dma resid instead of the wqe first_psn. The wqe first_psn could have moved if the read request was retried multiple times. Set the reth length to the dma resid to handle read retries for the remaining partial data. Signed-off-by: Vijay Immanuel Signed-off-by: Doug Ledford Signed-off-by: Sasha Levin --- drivers/infiniband/sw/rxe/rxe_comp.c | 21 ++++++++++++++++----- drivers/infiniband/sw/rxe/rxe_req.c | 15 +++++++++------ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_comp.c b/drivers/infiniband/sw/rxe/rxe_comp.c index 83cfe44f070ec..fd9ce03dbd292 100644 --- a/drivers/infiniband/sw/rxe/rxe_comp.c +++ b/drivers/infiniband/sw/rxe/rxe_comp.c @@ -253,6 +253,17 @@ static inline enum comp_state check_ack(struct rxe_qp *qp, case IB_OPCODE_RC_RDMA_READ_RESPONSE_MIDDLE: if (pkt->opcode != IB_OPCODE_RC_RDMA_READ_RESPONSE_MIDDLE && pkt->opcode != IB_OPCODE_RC_RDMA_READ_RESPONSE_LAST) { + /* read retries of partial data may restart from + * read response first or response only. + */ + if ((pkt->psn == wqe->first_psn && + pkt->opcode == + IB_OPCODE_RC_RDMA_READ_RESPONSE_FIRST) || + (wqe->first_psn == wqe->last_psn && + pkt->opcode == + IB_OPCODE_RC_RDMA_READ_RESPONSE_ONLY)) + break; + return COMPST_ERROR; } break; @@ -501,11 +512,11 @@ static inline enum comp_state complete_wqe(struct rxe_qp *qp, struct rxe_pkt_info *pkt, struct rxe_send_wqe *wqe) { - qp->comp.opcode = -1; - - if (pkt) { - if (psn_compare(pkt->psn, qp->comp.psn) >= 0) - qp->comp.psn = (pkt->psn + 1) & BTH_PSN_MASK; + if (pkt && wqe->state == wqe_state_pending) { + if (psn_compare(wqe->last_psn, qp->comp.psn) >= 0) { + qp->comp.psn = (wqe->last_psn + 1) & BTH_PSN_MASK; + qp->comp.opcode = -1; + } if (qp->req.wait_psn) { qp->req.wait_psn = 0; diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c index 08ae4f3a6a379..9fd4f04df3b33 100644 --- a/drivers/infiniband/sw/rxe/rxe_req.c +++ b/drivers/infiniband/sw/rxe/rxe_req.c @@ -73,9 +73,6 @@ static void req_retry(struct rxe_qp *qp) int npsn; int first = 1; - wqe = queue_head(qp->sq.queue); - npsn = (qp->comp.psn - wqe->first_psn) & BTH_PSN_MASK; - qp->req.wqe_index = consumer_index(qp->sq.queue); qp->req.psn = qp->comp.psn; qp->req.opcode = -1; @@ -107,11 +104,17 @@ static void req_retry(struct rxe_qp *qp) if (first) { first = 0; - if (mask & WR_WRITE_OR_SEND_MASK) + if (mask & WR_WRITE_OR_SEND_MASK) { + npsn = (qp->comp.psn - wqe->first_psn) & + BTH_PSN_MASK; retry_first_write_send(qp, wqe, mask, npsn); + } - if (mask & WR_READ_MASK) + if (mask & WR_READ_MASK) { + npsn = (wqe->dma.length - wqe->dma.resid) / + qp->mtu; wqe->iova += npsn * qp->mtu; + } } wqe->state = wqe_state_posted; @@ -435,7 +438,7 @@ static struct sk_buff *init_req_packet(struct rxe_qp *qp, if (pkt->mask & RXE_RETH_MASK) { reth_set_rkey(pkt, ibwr->wr.rdma.rkey); reth_set_va(pkt, wqe->iova); - reth_set_len(pkt, wqe->dma.length); + reth_set_len(pkt, wqe->dma.resid); } if (pkt->mask & RXE_IMMDT_MASK) -- 2.20.1