From patchwork Wed Mar 21 12:51:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kalderon, Michal" X-Patchwork-Id: 10299423 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E10C0602B3 for ; Wed, 21 Mar 2018 12:52:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CABED28692 for ; Wed, 21 Mar 2018 12:52:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF3CE28B78; Wed, 21 Mar 2018 12:52:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C9DE28692 for ; Wed, 21 Mar 2018 12:52:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751587AbeCUMwx (ORCPT ); Wed, 21 Mar 2018 08:52:53 -0400 Received: from mail-sn1nam01on0085.outbound.protection.outlook.com ([104.47.32.85]:10265 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751545AbeCUMww (ORCPT ); Wed, 21 Mar 2018 08:52:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=kSKeJD+4uqw2X0X6AOlb2H+3Hwu4g3fz8JUukG0Qjz4=; b=J30vapni2cz4Kt1+7QvA92g74rdQH1hDjVW351KlN8S0PHhTvyjyWrcnuECiAQCHjgLKHnsT9N8n8RFgIGMHE3orqYo12Pslo9i4F/ejtfAiES6WisJVXiZAAl4hZciXYgvDURqFXH+tL2rHjLsizBX3GCLAbqpQUJkZXfyW4nk= Received: from DM5PR07CA0063.namprd07.prod.outlook.com (2603:10b6:4:ad::28) by BN7PR07MB4209.namprd07.prod.outlook.com (2603:10b6:406:b2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.609.10; Wed, 21 Mar 2018 12:52:50 +0000 Received: from BN1AFFO11FD006.protection.gbl (2a01:111:f400:7c10::115) by DM5PR07CA0063.outlook.office365.com (2603:10b6:4:ad::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.609.10 via Frontend Transport; Wed, 21 Mar 2018 12:52:50 +0000 Received-SPF: Fail (protection.outlook.com: domain of cavium.com does not designate 50.232.66.26 as permitted sender) receiver=protection.outlook.com; client-ip=50.232.66.26; helo=CAEXCH02.caveonetworks.com; Received: from CAEXCH02.caveonetworks.com (50.232.66.26) by BN1AFFO11FD006.mail.protection.outlook.com (10.58.52.66) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.527.18 via Frontend Transport; Wed, 21 Mar 2018 12:52:49 +0000 Received: from lb-tlvb-michal.il.qlogic.com.com (10.185.6.89) by CAEXCH02.caveonetworks.com (10.17.4.29) with Microsoft SMTP Server id 14.2.347.0; Wed, 21 Mar 2018 05:52:47 -0700 From: Michal Kalderon To: , , CC: , , Michal Kalderon , Ariel Elior Subject: [PATCH v3 for-rc 3/3] RDMA/qedr: Fix QP state initialization race Date: Wed, 21 Mar 2018 14:51:52 +0200 Message-ID: <1521636712-30608-4-git-send-email-Michal.Kalderon@cavium.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1521636712-30608-1-git-send-email-Michal.Kalderon@cavium.com> References: <1521636712-30608-1-git-send-email-Michal.Kalderon@cavium.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:50.232.66.26; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(39380400002)(396003)(376002)(346002)(39850400004)(2980300002)(1109001)(1110001)(339900001)(189003)(199004)(356003)(107886003)(16586007)(110136005)(54906003)(105606002)(51416003)(106466001)(69596002)(8676002)(50466002)(81156014)(81166006)(48376002)(2201001)(76176011)(36756003)(305945005)(5660300001)(316002)(4326008)(59450400001)(2950100002)(6346003)(26005)(186003)(77096007)(47776003)(50226002)(8936002)(104016004)(86362001)(336012)(72206003)(2906002)(478600001)(6666003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN7PR07MB4209; H:CAEXCH02.caveonetworks.com; FPR:; SPF:Fail; PTR:50-232-66-26-static.hfc.comcastbusiness.net; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD006; 1:3WRwzUSYhrqG4uds7r1prbFnKBk858WroS6WILaAxvvc0duxzT+vVOqD1j2MYMI8HzoINQqRvGU2Va0RFrTThohBZ8DeaZFdZBl57VJRb4heZW4ljkDafvBJVLmLkpXH X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ac822bd4-d2f6-4af8-b3d8-08d58f2aa761 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060); SRVR:BN7PR07MB4209; X-Microsoft-Exchange-Diagnostics: 1; BN7PR07MB4209; 3:Fc/xlqaSVZ/UMIlZA1OL4GTgha2LPFU6Vqthy7MbFWNL01UrXCCWokf1j0wGYilQ5dEf1OnWnSh/+6SDwqE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R5GK2ZGNjZirhgZCTPQsR3apeJ3xKu1MeER4+8yh/zW32/tZdDLv78alT5umoaSoRYnNih7tHOp5wTXRWxThupLd202jRfjsuSkEOEtr9iq/yiFgoE4dkm8CJToNvJ45z9vQImUF70dOq9yd/O8enLNaieynpb0BCdUnsMm7bjoqWotBOkImRnal4l5xbK1k1G3iXg0XskMd+QJ6zUnM0QFTlf2Oh2htEzj3Tr2abXkIFoqf8XTCSochpAd0W8oWhg9XQ2POTcbCR/sd+q2IEGSe5bzaZnbXP1h39oeXieuMH/beZUGOPyBqVmaOU0KwzQ+6Q4BWV+n3WhPot1hmpyW6pE+lalBoHT+4 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231221)(944501323)(52105095)(93006095)(93001095)(10201501046)(3002001)(6041310)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011); SRVR:BN7PR07MB4209; BCL:0; PCL:0; RULEID:; SRVR:BN7PR07MB4209; X-Microsoft-Exchange-Diagnostics: 1; BN7PR07MB4209; 4:K9f/EsG7sL6kR/nSp+ifW+fkRRjJnqb+TG6iLq2yRlylIsCsB8JuBpWo6oe+n2kd/FLarLJIeO7mHuQN3NEllD9MJVX4xyO8KRPhNnGyabmpMgCTRoILnSVpt2WAOwivWjAWhae/uc5CZC2ynbOcMCKbSM8t+2mgqRejS8YF1bxr2UiU5Gf4UksyziLRLa7uFMDFL32ApsfXstVEKgLydbMFoPutF0CWA6KMk8tZx4cmzRtT4AAHD6As9FXs5jBta5LtNAz56sRZJPx80nuPvA== X-Forefront-PRVS: 0618E4E7E1 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN7PR07MB4209; 23:c/Hdw4zcaL/KH7VosyUH1WeOu/PaGozcLutk/H+iK?= =?us-ascii?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bfGFx1v2vcNQg1ZVnogIgAg+8i24MBmcN5j6Bi4nDcv5L9u9/1GTKp2kqYfc1MprSdqO0OY1lK5gJdPduFLOuSe9GdxFFe4=; 24:6VgAij8Guc2RuvCVzO50M7wEU2zQov3YYu8Ku1Dls1R/oNo1Aev7GsxAVFBCPkjYjr+gcaqit62y/CDsPKtFuhC5nfVOm1OD8v11eFpfhSs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN7PR07MB4209; 7:cdBX/ocFhypZwhXzhS+bUhacM1YWMrgRNd3f2NH5rqkT5wOu2b+1X3xye6VvaB9oYhmftoxz4H49ppB9P7yx7ROUEdJOVwnV82+DqMLgJZ48XukFwnyJXuI60iI/2Gh2TzRiWWTO6UhvCp8fjuJBIbMiCGBmVYI2kVNlxpe6mlSQbvlB88HHW0p4+aSs0W452doImamvwjhNNvOHi7GqWKs9uZjxL+RgcJZ13tBH9jB+m6hfmPwpQ9dlIT8iTo3D X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Mar 2018 12:52:49.8957 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ac822bd4-d2f6-4af8-b3d8-08d58f2aa761 X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=711e4ccf-2e9b-4bcf-a551-4094005b6194; Ip=[50.232.66.26]; Helo=[CAEXCH02.caveonetworks.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR07MB4209 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/infiniband/hw/qedr/verbs.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c index 716fae0..419a158 100644 --- a/drivers/infiniband/hw/qedr/verbs.c +++ b/drivers/infiniband/hw/qedr/verbs.c @@ -1841,14 +1841,15 @@ static void qedr_reset_qp_hwq_info(struct qedr_qp_hwq_info *qph) 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: @@ -1955,6 +1956,7 @@ int qedr_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, 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, @@ -2175,13 +2177,25 @@ int qedr_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, 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; }