Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2317801imm; Mon, 28 May 2018 06:00:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrQGnTsjd0SP0YTkQPCyUn8v9yaUEIgM7vHdJq/X8KJ5kXiu9FhMOG22mkI9tHeTTQbzq4n X-Received: by 2002:a17:902:4203:: with SMTP id g3-v6mr13862076pld.315.1527512443767; Mon, 28 May 2018 06:00:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527512443; cv=none; d=google.com; s=arc-20160816; b=v5JOzQnmctHaURakh3rdN46X61GjVM4Zu6a+hCwPgrPiZX418Cg74w+gsu17uaOvPA kK9ysMlqDMlNfrMRJoacQrV1yvR8ujlxEzxSSStDYRH3Bhf9xUB4SJD+oK5kOXKJ6lcD Pluy2ZHyZpBghEzZugTJkB9wtL4srN7nZzta+ENeV5QEaobg8zH6IbDgOhmtWHoGWAyh UB21fH+2KQTGcVPv/asPwGgHJehkBaeDiS6hevgsi1UzptHxlwNHBzU2CRxQk0NbKhlK leyfhULZBhsSpC3blEypz/fxKjbe3+vFmuhsOSXpwcUioBh0jnWtFKlkvZM1GPob55dv MT4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=a5TWBw1Un9xoa7icSnVZnWMm+M/0nclHX4w+mEnmeRI=; b=XRYkipZo3D4+XhHeETL1WWYTGhGdllrHr0Xdloa1PN1om0744G9wWvknYBS7YV9n0M GMEmFvIMgka6kzhRy+RiQ++v6KM32SyJRrNXmB7iW4R1fpPJaWOYJGvQN2BBbz+idL5Y BYHwy03tW+AmJAtTZ86xKQe7bEvcGe/BUvuy+Nkvl4MEPFXHbOjlg/YDZLrgejEZ5wqV X5pvizD2wovt/KK+V3Zre/mFBGpSwEqvA9R22JaDHZa960ul9ZK5PYMy11PwNEAS+muS tlLfh6bA9I7lfNzkHnyfFGFA2XSd83tETlRD7xLXWJEa2WB54ogzd8dSKtkAD5fwbfR1 d3Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yppPJ93c; 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 l36-v6si30684928plg.82.2018.05.28.06.00.28; Mon, 28 May 2018 06:00:43 -0700 (PDT) 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=yppPJ93c; 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 S939062AbeE1M7v (ORCPT + 99 others); Mon, 28 May 2018 08:59:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:42916 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164204AbeE1Kxw (ORCPT ); Mon, 28 May 2018 06:53:52 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 03DB620883; Mon, 28 May 2018 10:53:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527504831; bh=yjJZjeDo0IigEXPlIlQp6hJsPH+TU2Ofni80EGeUXkk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yppPJ93cjwUPUq09pKVANU5DuP3yf86F4//iCX3JjHofEcnqFgz1cDD4hHTjaq0rN tRqCS6EzLop35jRTtpE/wjCNVRkpmjR1vnSKEaaPplunkRvbZWR4efXmRLTxiFyJ44 flO1xBVcTAkEkfLFRRDEz1x6p9J9qjuAlsat+oNM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michal Kalderon , Ariel Elior , Jason Gunthorpe , Sasha Levin Subject: [PATCH 4.14 278/496] RDMA/qedr: Fix QP state initialization race Date: Mon, 28 May 2018 12:01:03 +0200 Message-Id: <20180528100331.566934911@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100319.498712256@linuxfoundation.org> References: <20180528100319.498712256@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: "Kalderon, Michal" [ Upstream commit caf61b1b8b88ccf1451f7321a176393797e8d292 ] Once the FW is transitioned to error, FLUSH cqes can be received. We want the driver to be aware of the fact that QP is already in error. Without this fix, a user may see false error messages in the dmesg log, mentioning that a FLUSH cqe was received while QP is not in error state. Fixes: cecbcddf ("qedr: Add support for QP verbs") Signed-off-by: Michal Kalderon Signed-off-by: Ariel Elior Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/hw/qedr/verbs.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) --- a/drivers/infiniband/hw/qedr/verbs.c +++ b/drivers/infiniband/hw/qedr/verbs.c @@ -1663,14 +1663,15 @@ static void qedr_reset_qp_hwq_info(struc static int qedr_update_qp_state(struct qedr_dev *dev, struct qedr_qp *qp, + enum qed_roce_qp_state cur_state, enum qed_roce_qp_state new_state) { int status = 0; - if (new_state == qp->state) + if (new_state == cur_state) return 0; - switch (qp->state) { + switch (cur_state) { case QED_ROCE_QP_STATE_RESET: switch (new_state) { case QED_ROCE_QP_STATE_INIT: @@ -1774,6 +1775,7 @@ int qedr_modify_qp(struct ib_qp *ibqp, s struct qedr_dev *dev = get_qedr_dev(&qp->dev->ibdev); const struct ib_global_route *grh = rdma_ah_read_grh(&attr->ah_attr); enum ib_qp_state old_qp_state, new_qp_state; + enum qed_roce_qp_state cur_state; int rc = 0; DP_DEBUG(dev, QEDR_MSG_QP, @@ -1992,13 +1994,25 @@ int qedr_modify_qp(struct ib_qp *ibqp, s qp->dest_qp_num = attr->dest_qp_num; } + cur_state = qp->state; + + /* Update the QP state before the actual ramrod to prevent a race with + * fast path. Modifying the QP state to error will cause the device to + * flush the CQEs and while polling the flushed CQEs will considered as + * a potential issue if the QP isn't in error state. + */ + if ((attr_mask & IB_QP_STATE) && qp->qp_type != IB_QPT_GSI && + !udata && qp_params.new_state == QED_ROCE_QP_STATE_ERR) + qp->state = QED_ROCE_QP_STATE_ERR; + if (qp->qp_type != IB_QPT_GSI) rc = dev->ops->rdma_modify_qp(dev->rdma_ctx, qp->qed_qp, &qp_params); if (attr_mask & IB_QP_STATE) { if ((qp->qp_type != IB_QPT_GSI) && (!udata)) - rc = qedr_update_qp_state(dev, qp, qp_params.new_state); + rc = qedr_update_qp_state(dev, qp, cur_state, + qp_params.new_state); qp->state = qp_params.new_state; }