From patchwork Wed Dec 20 06:56:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10125087 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 76AA56057F for ; Wed, 20 Dec 2017 06:57:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6983B29649 for ; Wed, 20 Dec 2017 06:57:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C21929655; Wed, 20 Dec 2017 06:57:39 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 D589A2964E for ; Wed, 20 Dec 2017 06:57:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932508AbdLTG5h (ORCPT ); Wed, 20 Dec 2017 01:57:37 -0500 Received: from mail-sn1nam01on0078.outbound.protection.outlook.com ([104.47.32.78]:54675 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932372AbdLTG5S (ORCPT ); Wed, 20 Dec 2017 01:57:18 -0500 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=VIfxdMagXKyY7DTj+GHH/YS+uQPVzJpOK6GELppmNbw=; b=FYIVHSUq/UyPsUDA/aq12Ed6NYU5hNpn3ZG4bj7rLJM0TStgGBuKRpwai6eMW9nCtC3KUEdVBskirl0+31AM8k9RTIC4NJXcrGHeDPhkyXnDW1Wi5p9+oZN7Lxb3Z0M9Jmt1FxtHsp+f8wYa/8/XvnRPRUTL2p/MxTeJwGxo+Yc= Received: from SN4PR0701CA0005.namprd07.prod.outlook.com (2603:10b6:803:28::15) by SN4PR0701MB3824.namprd07.prod.outlook.com (2603:10b6:803:4f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.323.15; Wed, 20 Dec 2017 06:57:14 +0000 Received: from BN1AFFO11FD027.protection.gbl (2a01:111:f400:7c10::114) by SN4PR0701CA0005.outlook.office365.com (2603:10b6:803:28::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.345.14 via Frontend Transport; Wed, 20 Dec 2017 06:57:14 +0000 Authentication-Results: spf=permerror (sender IP is 50.232.66.26) smtp.mailfrom=cavium.com; vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=cavium.com; Received-SPF: PermError (protection.outlook.com: domain of cavium.com used an invalid SPF mechanism) Received: from CAEXCH02.caveonetworks.com (50.232.66.26) by BN1AFFO11FD027.mail.protection.outlook.com (10.58.52.87) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.302.6 via Frontend Transport; Wed, 20 Dec 2017 06:57:01 +0000 Received: from dut1171.mv.qlogic.com (172.29.51.171) by CAEXCH02.caveonetworks.com (10.17.4.29) with Microsoft SMTP Server id 14.2.347.0; Tue, 19 Dec 2017 22:56:49 -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 vBK6unpS021638; Tue, 19 Dec 2017 22:56:49 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id vBK6unJl021637; Tue, 19 Dec 2017 22:56:49 -0800 From: Himanshu Madhani To: , CC: , Subject: [PATCH 23/43] qla2xxx: Add lock protection around host lookup Date: Tue, 19 Dec 2017 22:56:24 -0800 Message-ID: <20171220065644.21511-24-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20171220065644.21511-1-himanshu.madhani@cavium.com> References: <20171220065644.21511-1-himanshu.madhani@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)(39860400002)(346002)(376002)(39380400002)(396003)(2980300002)(448002)(189003)(199004)(2906002)(478600001)(8936002)(356003)(106466001)(51416003)(81166006)(72206003)(76176011)(50226002)(48376002)(85326001)(4326008)(305945005)(87636003)(47776003)(1076002)(2950100002)(69596002)(81156014)(6666003)(5660300001)(50466002)(42186006)(8676002)(59450400001)(80596001)(575784001)(36756003)(16586007)(86362001)(110136005)(54906003)(316002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN4PR0701MB3824; H:CAEXCH02.caveonetworks.com; FPR:; SPF:PermError; PTR:50-232-66-26-static.hfc.comcastbusiness.net; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD027; 1:zOK+QU1ns9qnvuBQSC6WpCoh4AgkEV2Gtzfwn8IszdVsCaeyPG+T6VGeAW0kYspiqtMXgk+mW69b009SatPNIf6wiPx3YqfBtcElpPstibBt0OJJRj5ormO3Z5RfhXq4 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c5b6ed1d-2902-4d90-41ef-08d54776df32 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:SN4PR0701MB3824; X-Microsoft-Exchange-Diagnostics: 1; SN4PR0701MB3824; 3:Pt75uLClT9+Ucf1peAgLbFwpQzyNiiLR3yA03Kezaj/saoNT60ixxAC6DGdrUMuc/6zfBW6bXpnmOEr4HuYscqejaxV/hwyGUg3z9h+0fwdqdXdofPAp78FrthbFEQ7aK628jwIkDvALQ2cIeXJ2EmoWrKvoYgmwrW2OY6x7KbMlTaUkvimW/Mwv1QFrs6px4fx3R5QCo1Gk5980iuxaaI+mFQne+FcAJBGojVkHgNkF5wmDO+5oPCXz5UE9wa3L2BVCNUTKhXvehXipwk9lx05kvLtxjmvCxLTdpGz6urWOP8drtJfOZh/MK3GxTThKI+qnitoSjEr7Rf1KNcC7W1n6JvVrmGph7N4QhHNTS1w=; 25:JiMvO0QGMlfqpPLfbdP0m5X5/qW+2Ww42lS/2KNQ/JB+3KhCUcCPnB3xG5V29vBiGRJV63tomBmgvh1xOxTK1aVU3FEqjcHFEIVWb+I4dihlmkVcGVlszXgRMipkfkZxRgr4yfXHkFCLFXaar05tNgOuOImmBnYUtaVb0WUnOgVHM96MUaI9vI6yDGI8YKICWRFMWiukerEickZFJiM/rkdZVhinhaXValx3vGwMMHVDP+OEHIzqza12HnIbIT/3S7KmQVz4jZ29eBx6ji0PiMkxd4uODBYsK6UzlI46JOFcvdvWDaitWK+G0Zyy5a/vr7PagPq6B8GWMhUmzWdUjg== X-MS-TrafficTypeDiagnostic: SN4PR0701MB3824: X-Microsoft-Exchange-Diagnostics: 1; SN4PR0701MB3824; 31:FVkrwq7EYTTQcINaL18LGsCvsethQ327hc7l0TLhWfe6j4U4IWelXtfccVvJ+GONB3mWQjValiAo/qB2fxXaRBzk1tL/rDur5e0DDVZ7by6MYvTIl1QBBTzLBRhEZx/FkiANQvNqbqIKgl/qFHm3U5nXW29snW2iy5STkOr7anfhuAy8CMKM7Yud1BL72UBOkO+2mc7eu+SY2q7ypfGRiRyTwRpptj9aMGX3qmhIncg=; 20:zjF5nVUqC6qXkwus15IPIGvTeXjO/YW/8u/V3+1vY4av8AzwQW4R4E8bN8ReCQkXX7NCnPR9zErtccRhVH8S6xaG3x1hlwTYA+VeF6R1Cn6gxrTp2EzuAZNQTmnV8rXp4b84RqZHyu4sRjwhoDYeOBaWOVg0KGdA1tRFLfEhDgn3YtQV3JMU2a9fb/j4YeFxYo504JMAJfwIlPWXTzfTTtwk6ZhPR/3ASu9kQM/ZMlasSagEgo4B0W4BF00PaoxEQBn2W+alfxX2AKiGSHHDnwxLtocjstjZYkRWN8TVIkWcKQHmjuIoGjeB3kbHZELrvpb48kJkcwGDcX8WyqX2o0/wowCw6jMA4Dk5ysFAmEuVW4TMNa50NDqs0ndoRQn9or6MoRB5oKQOhe7YIwVNgg+4nrLtQRnuD6hfZnqNUR+7q62EPPqs8LU2Sj1lubzOGCNJ80B3mBq1AKXicBX4ZSNx2ArOy4sFJDwAav7NBrWJIPTH46izXRlCRmtddU7q X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231023)(93006095)(93001095)(6041268)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:SN4PR0701MB3824; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:SN4PR0701MB3824; X-Microsoft-Exchange-Diagnostics: 1; SN4PR0701MB3824; 4:6SlIJkpThJ3ocMDFN3QDrGCAZjupdVyzDjBfv2SenDsJkKuOuPQy1mg9DVE4LfU8e11lp4MDOr1q++KqWmQyyVu8NtwdiTatnny2qQlbsQ+whpjMifcroETX0w3sWE41U5iF5lUlrAfL02kWyyb7oy89R68etSC5o5/rACQ3cRaNhCZS02eL4EDRs1GJnPZAiIBATKAgTMS5tIr0ITjC/YB6v5MA6LoAL4R3VmTXda0rhj/ebn4EzuO7CULB1pek8FDd0Er2Ihndqx7w+eHDxA== X-Forefront-PRVS: 0527DFA348 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN4PR0701MB3824; 23:PnTKsmNQ9TIlC1LyQil+Ihi615jykqy0u1BCuiu?= =?us-ascii?Q?bwibbpRr7ZZosrwQPGy7i20H1240seJY2FCRx50mVfAsDqZylqJ60BrSombB?= =?us-ascii?Q?C60WR5GM0gtg03x1tt1RGsYDgf3Kal9fex8KxOJ60VmUqwbNOkkYSNd8RgIJ?= =?us-ascii?Q?sSI2WXy3R1OkhTBOgoifHc94he7tblCQowGwooNPRReR/fBmLE0Bpr/ILUmN?= =?us-ascii?Q?QbEeCjRDLQwOwVzlXGYE5oHe9VRvKql/+VWnJij8H8vBYS3SM7VeGKZJm9es?= =?us-ascii?Q?9Ikd1oHBoJ/3D4xAFIzS7rhqyG5Ym4FKiol9GIsJhYkUkBNK54nCnzqZGs3d?= =?us-ascii?Q?ypbA87eMXayNAxGjVPnxapPTumAGX2gxY8lcCLvvo3jgYdVstaQ+wLJXMSra?= =?us-ascii?Q?7r/1kj8DMHTiPrWs8wPv37kEg0Kq5sg6vGJs7JoI5cEZhX4NqOc6GvIl9GvZ?= =?us-ascii?Q?0T7yLsw2VWhWzc8B18tc+XwOYznDWisu78Jml84CsN7EKLJ0+BNdo1NBxp54?= =?us-ascii?Q?z+NIHz4Ij3WchjWMGThphW7hUDuxh30ecNtDgLiF6Y3nmIRq4Incl8HTQw9j?= =?us-ascii?Q?8R+EP5R1pnRQ4QVJRXcIVdeu9v0XFnDLyUm5ZBZnCIHVkFW0qom5wibB9tIt?= =?us-ascii?Q?MU1EyZVyLANZt9KlnTKEefeISDcGFSKixAh31PpreprXqjl2VLVyR3U6kI7F?= =?us-ascii?Q?w9chw+oWMXNK2/yEgnFzn8QSeZd0hnyLK0G33Zq9kTLRHDSrXW1ZswEp+58V?= =?us-ascii?Q?QGRwW7mH7kgiB3lbdhJcVSGxWNHwMXcLEh9qhiZtIPscd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CBdRM1eXF6zlUJyrQex+YmGvq7PIkfPUXRJMDq750rs0rqccEB+/8+sd0jQ1qX86KfLhMVPsZL+7MQjxwFXoejFEKN6QDFqL4PiauBKMyWyu+GXUzdRIia6idxqJUFp+65OoDrU75q0ucA6VOTSp3bN4qFEKbUyrkUlpmIB54pTEwumTqzDwgKy SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2017 06:57:01.5687 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c5b6ed1d-2902-4d90-41ef-08d54776df32 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: SN4PR0701MB3824 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: Quinn Tran Host lookup via btree is currently protected by the hardware_lock. Add hardware_lock when modifying btree to store host pointer. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_init.c | 3 +++ drivers/scsi/qla2xxx/qla_mid.c | 9 +++++---- drivers/scsi/qla2xxx/qla_target.c | 6 ------ 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index cdcd84278fd0..300cd795dad4 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -3977,6 +3977,7 @@ qla2x00_configure_hba(scsi_qla_host_t *vha) struct qla_hw_data *ha = vha->hw; scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); port_id_t id; + unsigned long flags; /* Get host addresses. */ rval = qla2x00_get_adapter_id(vha, @@ -4058,7 +4059,9 @@ qla2x00_configure_hba(scsi_qla_host_t *vha) id.b.area = area; id.b.al_pa = al_pa; id.b.rsvd_1 = 0; + spin_lock_irqsave(&ha->hardware_lock, flags); qlt_update_host_map(vha, id); + spin_unlock_irqrestore(&ha->hardware_lock, flags); if (!vha->flags.init_done) ql_log(ql_log_info, vha, 0x2010, diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c index a823fa6b7060..12a29eca02e1 100644 --- a/drivers/scsi/qla2xxx/qla_mid.c +++ b/drivers/scsi/qla2xxx/qla_mid.c @@ -50,10 +50,11 @@ qla24xx_allocate_vp_id(scsi_qla_host_t *vha) spin_lock_irqsave(&ha->vport_slock, flags); list_add_tail(&vha->list, &ha->vp_list); + spin_unlock_irqrestore(&ha->vport_slock, flags); + spin_lock_irqsave(&ha->hardware_lock, flags); qlt_update_vp_map(vha, SET_VP_IDX); - - spin_unlock_irqrestore(&ha->vport_slock, flags); + spin_unlock_irqrestore(&ha->hardware_lock, flags); mutex_unlock(&ha->vport_lock); return vp_id; @@ -158,9 +159,9 @@ qla24xx_disable_vp(scsi_qla_host_t *vha) atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); /* Remove port id from vp target map */ - spin_lock_irqsave(&vha->hw->vport_slock, flags); + spin_lock_irqsave(&vha->hw->hardware_lock, flags); qlt_update_vp_map(vha, RESET_AL_PA); - spin_unlock_irqrestore(&vha->hw->vport_slock, flags); + spin_unlock_irqrestore(&vha->hw->hardware_lock, flags); qla2x00_mark_vp_devices_dead(vha); atomic_set(&vha->vp_state, VP_FAILED); diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index 48e0a12dca61..c7c81d5cf69c 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -7206,20 +7206,14 @@ qlt_update_vp_map(struct scsi_qla_host *vha, int cmd) void qlt_update_host_map(struct scsi_qla_host *vha, port_id_t id) { - unsigned long flags; - struct qla_hw_data *ha = vha->hw; if (!vha->d_id.b24) { - spin_lock_irqsave(&ha->vport_slock, flags); vha->d_id = id; qlt_update_vp_map(vha, SET_AL_PA); - spin_unlock_irqrestore(&ha->vport_slock, flags); } else if (vha->d_id.b24 != id.b24) { - spin_lock_irqsave(&ha->vport_slock, flags); qlt_update_vp_map(vha, RESET_AL_PA); vha->d_id = id; qlt_update_vp_map(vha, SET_AL_PA); - spin_unlock_irqrestore(&ha->vport_slock, flags); } }