From patchwork Tue Mar 5 10:58:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saurav Kashyap X-Patchwork-Id: 10839285 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AA87E17E4 for ; Tue, 5 Mar 2019 10:59:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 978C02B2A9 for ; Tue, 5 Mar 2019 10:59:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8BD382B352; Tue, 5 Mar 2019 10:59:49 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 14F882B2A9 for ; Tue, 5 Mar 2019 10:59:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727492AbfCEK7s (ORCPT ); Tue, 5 Mar 2019 05:59:48 -0500 Received: from mail-eopbgr690079.outbound.protection.outlook.com ([40.107.69.79]:30002 "EHLO NAM04-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727477AbfCEK7s (ORCPT ); Tue, 5 Mar 2019 05:59:48 -0500 Received: from BYAPR07CA0018.namprd07.prod.outlook.com (2603:10b6:a02:bc::31) by SN6PR07MB4382.namprd07.prod.outlook.com (2603:10b6:805:58::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.18; Tue, 5 Mar 2019 10:59:42 +0000 Received: from BY2NAM05FT031.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e52::209) by BYAPR07CA0018.outlook.office365.com (2603:10b6:a02:bc::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1665.18 via Frontend Transport; Tue, 5 Mar 2019 10:59:42 +0000 Authentication-Results: spf=fail (sender IP is 199.233.58.38) smtp.mailfrom=marvell.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=fail action=none header.from=marvell.com; Received-SPF: Fail (protection.outlook.com: domain of marvell.com does not designate 199.233.58.38 as permitted sender) receiver=protection.outlook.com; client-ip=199.233.58.38; helo=CAEXCH02.caveonetworks.com; Received: from CAEXCH02.caveonetworks.com (199.233.58.38) by BY2NAM05FT031.mail.protection.outlook.com (10.152.100.168) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA) id 15.20.1686.5 via Frontend Transport; Tue, 5 Mar 2019 10:59:42 +0000 Received: from dut1171.mv.qlogic.com (10.112.88.18) by CAEXCH02.caveonetworks.com (10.67.98.110) with Microsoft SMTP Server (TLS) id 14.2.347.0; Tue, 5 Mar 2019 02:59:39 -0800 Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id x25AxdjH013280; Tue, 5 Mar 2019 02:59:39 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id x25AxdEK013271; Tue, 5 Mar 2019 02:59:39 -0800 From: Saurav Kashyap To: CC: , Subject: [PATCH 13/26] qedf: fixup bit operations. Date: Tue, 5 Mar 2019 02:58:48 -0800 Message-ID: <20190305105901.13185-14-skashyap@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20190305105901.13185-1-skashyap@marvell.com> References: <20190305105901.13185-1-skashyap@marvell.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131962571825748708;(abac79dc-c90b-41ba-8033-08d666125e47);(abac79dc-c90b-41ba-8033-08d666125e47) X-Forefront-Antispam-Report: CIP:199.233.58.38;IPV:CAL;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(346002)(376002)(396003)(39860400002)(136003)(2980300002)(1109001)(1110001)(339900001)(189003)(199004)(1076003)(26826003)(498600001)(446003)(336012)(11346002)(51416003)(76176011)(8936002)(305945005)(48376002)(81156014)(81166006)(50226002)(36756003)(8676002)(87636003)(53936002)(86362001)(5660300002)(50466002)(316002)(486006)(356004)(6666004)(126002)(105606002)(2616005)(476003)(54906003)(42186006)(106466001)(36906005)(47776003)(68736007)(2906002)(26005)(6862004)(4326008)(80596001)(69596002)(85426001)(14444005)(16586007)(97736004)(2351001);DIR:OUT;SFP:1101;SCL:1;SRVR:SN6PR07MB4382;H:CAEXCH02.caveonetworks.com;FPR:;SPF:Fail;LANG:en;PTR:InfoDomainNonexistent;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b2dbfb94-a3ec-4c07-a587-08d6a159abc8 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(5600127)(711020)(4605104)(2017052603328);SRVR:SN6PR07MB4382; X-MS-TrafficTypeDiagnostic: SN6PR07MB4382: X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 0967749BC1 X-Microsoft-Exchange-Diagnostics: 1;SN6PR07MB4382;23:bQWX0Tmt1yUXV6njh490RBk7OsITOs/iEexYpHpkJUsLGhocUcBlKRGgrTNNp4XCm2gIYSSvJ+QmOMM79rrPu1ZTBdhtRfM/cfXO8NJ0MIeFkhMklV3lyAW3MyOnauQ369jNb3jEq758yXBG/7iGd9B7AaGzDzxxJOoLBNtcPKx9hJEKA8YDaoY+V6GvOxWHtKPAUzFdYeMPO41rYRARaBPD9y0ibRegPePzaOQQxIuU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info: 1Stv8/NIq3deLJE/w1TqwcoImLi5crOHz4KLxgFuy/dUYdDdrHN/73iNbPCvSBtm0o+JFb1N3/HT6rnuiLLbsUEQMD9sPv9k6tqmhYLcpRf1ArfwZKldOKDIYwYxZpTiEwE2bF10Jwdra0Vu/yEnZBXr6z3emR6Qpe1aJFwpX0BQYKo9Q/29UUobYMDS6f6/1BVM+pQMS/lSeYyk9Oob0+7k35MgemDmAjY98ZlBiDf/7pylig4WtvEqYH7r0h+iG3OZWftr7Ag5daIe10vJSWsRybcMfo7aCYJg28akfhmIFXPbpuGBQRIAzsOuqKE99lijU9AFR2qQWuToAyOwKln79qAfJHx4s+zAlnOfM1ZtY8yltkyOgQC6txKHlQht/7gcsbSDcU7fzagJd7h2gviKpohATqwDYBjnw3aSbp8= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2019 10:59:42.3209 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b2dbfb94-a3ec-4c07-a587-08d6a159abc8 X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e;Ip=[199.233.58.38];Helo=[CAEXCH02.caveonetworks.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR07MB4382 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hannes Reinecke test_bit() is atomic, test_bit() || test_bit() is not. So protect consecutive bit tests with a lock to avoid races. Signed-off-by: Hannes Reinecke Signed-off-by: Saurav Kashyap --- drivers/scsi/qedf/qedf_els.c | 4 ++++ drivers/scsi/qedf/qedf_main.c | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/qedf/qedf_els.c b/drivers/scsi/qedf/qedf_els.c index aad1f7c..f1f57637 100644 --- a/drivers/scsi/qedf/qedf_els.c +++ b/drivers/scsi/qedf/qedf_els.c @@ -358,20 +358,24 @@ void qedf_restart_rport(struct qedf_rport *fcport) struct fc_lport *lport; struct fc_rport_priv *rdata; u32 port_id; + unsigned long flags; if (!fcport) return; + spin_lock_irqsave(&fcport->rport_lock, flags); if (test_bit(QEDF_RPORT_IN_RESET, &fcport->flags) || !test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags) || test_bit(QEDF_RPORT_UPLOADING_CONNECTION, &fcport->flags)) { QEDF_ERR(&(fcport->qedf->dbg_ctx), "fcport %p already in reset or not offloaded.\n", fcport); + spin_unlock_irqrestore(&fcport->rport_lock, flags); return; } /* Set that we are now in reset */ set_bit(QEDF_RPORT_IN_RESET, &fcport->flags); + spin_unlock_irqrestore(&fcport->rport_lock, flags); rdata = fcport->rdata; if (rdata) { diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index fb9c288..880dcf2 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -1434,12 +1434,14 @@ static void qedf_rport_event_handler(struct fc_lport *lport, */ fcport = (struct qedf_rport *)&rp[1]; + spin_lock_irqsave(&fcport->rport_lock, flags); /* Only free this fcport if it is offloaded already */ if (test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags) && !test_bit(QEDF_RPORT_UPLOADING_CONNECTION, &fcport->flags)) { set_bit(QEDF_RPORT_UPLOADING_CONNECTION, &fcport->flags); + spin_unlock_irqrestore(&fcport->rport_lock, flags); qedf_cleanup_fcport(qedf, fcport); /* * Remove fcport to list of qedf_ctx list of offloaded @@ -1452,8 +1454,9 @@ static void qedf_rport_event_handler(struct fc_lport *lport, clear_bit(QEDF_RPORT_UPLOADING_CONNECTION, &fcport->flags); atomic_dec(&qedf->num_offloads); + } else { + spin_unlock_irqrestore(&fcport->rport_lock, flags); } - break; case RPORT_EV_NONE: