From patchwork Tue Mar 26 07:38:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saurav Kashyap X-Patchwork-Id: 10870527 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 1474417E6 for ; Tue, 26 Mar 2019 07:39:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0040028FEC for ; Tue, 26 Mar 2019 07:39:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E856D2907D; Tue, 26 Mar 2019 07:39:58 +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 45D2828FEC for ; Tue, 26 Mar 2019 07:39:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731126AbfCZHj5 (ORCPT ); Tue, 26 Mar 2019 03:39:57 -0400 Received: from mail-eopbgr750071.outbound.protection.outlook.com ([40.107.75.71]:44534 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730790AbfCZHj4 (ORCPT ); Tue, 26 Mar 2019 03:39:56 -0400 Received: from BYAPR07CA0034.namprd07.prod.outlook.com (2603:10b6:a02:bc::47) by MW2PR07MB4026.namprd07.prod.outlook.com (2603:10b6:907:6::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1730.18; Tue, 26 Mar 2019 07:39:54 +0000 Received: from DM3NAM05FT018.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e51::201) by BYAPR07CA0034.outlook.office365.com (2603:10b6:a02:bc::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1730.15 via Frontend Transport; Tue, 26 Mar 2019 07:39:53 +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 DM3NAM05FT018.mail.protection.outlook.com (10.152.98.127) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA) id 15.20.1750.4 via Frontend Transport; Tue, 26 Mar 2019 07:39:53 +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, 26 Mar 2019 00:39:37 -0700 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 x2Q7dblO026879; Tue, 26 Mar 2019 00:39:37 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id x2Q7dbhc026878; Tue, 26 Mar 2019 00:39:37 -0700 From: Saurav Kashyap To: CC: , Subject: [PATCH v2 13/26] qedf: fixup bit operations. Date: Tue, 26 Mar 2019 00:38:45 -0700 Message-ID: <20190326073858.26792-14-skashyap@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20190326073858.26792-1-skashyap@marvell.com> References: <20190326073858.26792-1-skashyap@marvell.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131980595936368948;(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)(376002)(396003)(136003)(346002)(39860400002)(2980300002)(1109001)(1110001)(339900001)(189003)(199004)(4326008)(5660300002)(36756003)(446003)(476003)(11346002)(6862004)(69596002)(85426001)(498600001)(8676002)(81166006)(81156014)(87636003)(80596001)(26826003)(8936002)(86362001)(36906005)(50226002)(1076003)(54906003)(336012)(48376002)(76176011)(106466001)(51416003)(6666004)(26005)(50466002)(2351001)(14444005)(305945005)(316002)(53936002)(47776003)(97736004)(42186006)(16586007)(68736007)(486006)(105606002)(2906002)(126002)(356004)(2616005);DIR:OUT;SFP:1101;SCL:1;SRVR:MW2PR07MB4026;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: adb98e18-c05a-45ca-a3ef-08d6b1be3c7e X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(5600127)(711020)(4605104)(2017052603328);SRVR:MW2PR07MB4026; X-MS-TrafficTypeDiagnostic: MW2PR07MB4026: X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 09888BC01D X-Microsoft-Antispam-Message-Info: cswkD9468sskidjbeVdWqEjQhsPI8LhMYXuZ2QwfCTH11asf6A0VHImTIfQDPdHa/B/djljdDMMfm85iP2H3v2K6hev32MdzNmcwrQxuT/NpEXhuDiiTn+dW0rc8RCf1dnXrKkwtZE3swhGgOwWi5xUxe1tlrAycoTYVlko11z6M8YmlUdcVN8KJOVccOckqFXlp+d3/ITWhTa+iWQEPHDE327SmgQyzGIDTEn2nahu6kdUgQPhOMYTdNUnSgyJSkzuYLBuS+tYbyOyyOikNnM+WiwKAqeqk8tN8MV2eVPzKDh67EE7IuTZxCBOMSri7F/V5BsqiyFmmpMiPmEy86+4Gu43Kglsqfa8JwZH7LWL/Efi+y+Ma0H0M9FmmiYWCYGiV8uMLqD3DSdCSFgi+sG8tvYxF/ysmpIxfQ2YT9B4= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2019 07:39:53.2886 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: adb98e18-c05a-45ca-a3ef-08d6b1be3c7e 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: MW2PR07MB4026 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: