From patchwork Tue Mar 26 07:38:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saurav Kashyap X-Patchwork-Id: 10870523 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 9954514DE for ; Tue, 26 Mar 2019 07:39:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F76328FEC for ; Tue, 26 Mar 2019 07:39:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73D572907D; Tue, 26 Mar 2019 07:39: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=-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 1D69228FEC for ; Tue, 26 Mar 2019 07:39:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731118AbfCZHjx (ORCPT ); Tue, 26 Mar 2019 03:39:53 -0400 Received: from mail-eopbgr710059.outbound.protection.outlook.com ([40.107.71.59]:60960 "EHLO NAM05-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730935AbfCZHjx (ORCPT ); Tue, 26 Mar 2019 03:39:53 -0400 Received: from DM5PR07CA0087.namprd07.prod.outlook.com (2603:10b6:4:ae::16) by BN3PR07MB2530.namprd07.prod.outlook.com (2a01:111:e400:c5f0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1730.15; Tue, 26 Mar 2019 07:39:51 +0000 Received: from DM3NAM05FT017.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e51::209) by DM5PR07CA0087.outlook.office365.com (2603:10b6:4:ae::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1750.15 via Frontend Transport; Tue, 26 Mar 2019 07:39:51 +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 DM3NAM05FT017.mail.protection.outlook.com (10.152.98.126) 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:50 +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:34 -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 x2Q7dY7e026875; Tue, 26 Mar 2019 00:39:34 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id x2Q7dYwR026874; Tue, 26 Mar 2019 00:39:34 -0700 From: Saurav Kashyap To: CC: , Subject: [PATCH v2 12/26] qedf: fixup locking in qedf_restart_rport() Date: Tue, 26 Mar 2019 00:38:44 -0700 Message-ID: <20190326073858.26792-13-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: 131980595912986861;(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)(396003)(136003)(376002)(346002)(39860400002)(2980300002)(1109001)(1110001)(339900001)(189003)(199004)(476003)(80596001)(486006)(68736007)(26005)(126002)(6862004)(81156014)(8676002)(85426001)(81166006)(47776003)(69596002)(8936002)(4326008)(1076003)(50226002)(36756003)(6666004)(76176011)(51416003)(356004)(97736004)(11346002)(2616005)(336012)(446003)(86362001)(16586007)(5660300002)(106466001)(316002)(54906003)(87636003)(105606002)(2351001)(2906002)(26826003)(48376002)(14444005)(36906005)(42186006)(50466002)(498600001)(305945005)(53936002);DIR:OUT;SFP:1101;SCL:1;SRVR:BN3PR07MB2530;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: ea5b9391-7ac0-401a-dbc0-08d6b1be3b19 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(5600127)(711020)(4605104)(2017052603328);SRVR:BN3PR07MB2530; X-MS-TrafficTypeDiagnostic: BN3PR07MB2530: X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 09888BC01D X-Microsoft-Antispam-Message-Info: RuV7Uur4iluvTe0aDmJu6VIVPTtIWsdcCI3e4uWEeIOMjuDgG5r0XbQ1+k7gew4Wn6LP8OrLoBWnOGrRJ1s8dHCRVesYx4KhCu70dzkD3Ii3xXzzn3ZHzvxG1FF4N8htRQXxKRm1OZFZo4Fx9hJqXb+AfH6mVb7I3KvsdUNSVZpWMAuDKWj8Il0PIBRn/6bi9/rfTLIOvOJ8M4l/yGoCoqs6xH5dYajA5Cz3QdEgEBTac/METqXXQdLr6ngQIRZC2y/n6E/R8WVlKOly/pKRMuiBo2Cg1eN24IPH3VkDx4KgZdjtVZvjJmVlBtLYg1wmhyO8eIICxuNzlhZyOtg3howTlwt2OnvblPVQmj2MXf7XvnpsWilnM2Gg5MF/1FN7TeewPvPsRok8GsLzrXNL9KTB95Y3kI/4vAyhZpxeHu8= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2019 07:39:50.9601 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ea5b9391-7ac0-401a-dbc0-08d6b1be3b19 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: BN3PR07MB2530 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 fc_rport_create() needs to be called with disc_mutex held. And we should re-assign the 'rdata' pointer in case it got changed. Signed-off-by: Hannes Reinecke Signed-off-by: Saurav Kashyap --- drivers/scsi/qedf/qedf_els.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/qedf/qedf_els.c b/drivers/scsi/qedf/qedf_els.c index ac2bfc2..aad1f7c 100644 --- a/drivers/scsi/qedf/qedf_els.c +++ b/drivers/scsi/qedf/qedf_els.c @@ -380,10 +380,16 @@ void qedf_restart_rport(struct qedf_rport *fcport) QEDF_ERR(&(fcport->qedf->dbg_ctx), "LOGO port_id=%x.\n", port_id); fc_rport_logoff(rdata); + mutex_lock(&lport->disc.disc_mutex); /* Recreate the rport and log back in */ rdata = fc_rport_create(lport, port_id); - if (rdata) + if (rdata) { + mutex_unlock(&lport->disc.disc_mutex); fc_rport_login(rdata); + fcport->rdata = rdata; + } else { + mutex_unlock(&lport->disc.disc_mutex); + } } clear_bit(QEDF_RPORT_IN_RESET, &fcport->flags); }