From patchwork Thu Dec 28 20:33:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10135865 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 89B7B60318 for ; Thu, 28 Dec 2017 20:34:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C1642B3EB for ; Thu, 28 Dec 2017 20:34:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70FD42B88E; Thu, 28 Dec 2017 20:34:17 +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 052632B3EB for ; Thu, 28 Dec 2017 20:34:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755283AbdL1UeP (ORCPT ); Thu, 28 Dec 2017 15:34:15 -0500 Received: from mail-co1nam03on0089.outbound.protection.outlook.com ([104.47.40.89]:60974 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754886AbdL1UeH (ORCPT ); Thu, 28 Dec 2017 15:34:07 -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=GJqMxrkzUhEvint6ZycFuf5CJ9A2Vo7EkqPF1uhRBj8=; b=PI/ET17EjWGrEnoazxnOT6MtPwh98KTWfEo4Ue7e5dN5TN/eXd9Xz/wNIZEYa3rSAIDKn98x6ml+9pAiX+r/DiCOZrS7zwuCyZ2k/d67lMnq6ikoXvX0NM80RJSHQvxAsZj4hf6I167iPicuDaiXRneyoSX8y8vlYixkptI9Ku8= Received: from SN4PR0701CA0023.namprd07.prod.outlook.com (2603:10b6:803:28::33) by CY4PR0701MB3809.namprd07.prod.outlook.com (2603:10b6:910:94::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.345.14; Thu, 28 Dec 2017 20:34:06 +0000 Received: from BN1BFFO11FD006.protection.gbl (2a01:111:f400:7c10::1:149) by SN4PR0701CA0023.outlook.office365.com (2603:10b6:803:28::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.366.8 via Frontend Transport; Thu, 28 Dec 2017 20:34:06 +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 BN1BFFO11FD006.mail.protection.outlook.com (10.58.144.69) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.345.12 via Frontend Transport; Thu, 28 Dec 2017 20:33:45 +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; Thu, 28 Dec 2017 12:33: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 vBSKXnqq002896; Thu, 28 Dec 2017 12:33:49 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id vBSKXnYs002894; Thu, 28 Dec 2017 12:33:49 -0800 From: Himanshu Madhani To: , CC: , Subject: [PATCH v2 19/37] qla2xxx: Add lock protection around host lookup Date: Thu, 28 Dec 2017 12:33:27 -0800 Message-ID: <20171228203345.2702-20-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20171228203345.2702-1-himanshu.madhani@cavium.com> References: <20171228203345.2702-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)(39850400004)(396003)(39380400002)(346002)(376002)(2980300002)(448002)(189003)(199004)(80596001)(87636003)(47776003)(72206003)(81166006)(59450400001)(4326008)(5660300001)(69596002)(8936002)(48376002)(81156014)(76176011)(1076002)(51416003)(2906002)(50226002)(50466002)(42186006)(85326001)(316002)(106466001)(356003)(16586007)(478600001)(305945005)(110136005)(54906003)(2950100002)(86362001)(6666003)(36756003)(8676002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR0701MB3809; 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; BN1BFFO11FD006; 1:miNfImcZvT5dasoR5LBQyBH15SBd+2tyqNCl1nPdyz3a8mmkS0B+WwDy3dk6rVXJrMVKQDn7ulrou2vVIUzGaexFbTLoFeoRmuFCxpN9bqSolGcv7LvpQUXcIEePif7b X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b2e7aac4-e502-4672-44b6-08d54e324b21 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:CY4PR0701MB3809; X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3809; 3:/EKZIeijy+RfbH8qa3NSdFdvgbstpDRUXmJe5haKV93nfBzXKan4kypCmp/9lOvNYGqqINXyYx1A1fYKZq1XHi2Ud5BP8MYopXVd62SjHc0FVYtt07HRR2CBTnCmiL7mVJtjjxkC0YtqZcYm2ggidlYX2kKrSqy8yRZ36AU1+6uNVNa/yGWy7VfBv6z7G61K6bInHvgs8W8VuCBgf/rQaWFKtAOokM0vI8f+7Or9ZagSlVvN8acnLRG09PEkQwxh6hpQ491q/ZOAIQUZpvxCsKMaUAXuxrEQ2/slNC8CY9PCJOgspErYD6iHiAtV8cvgfJXMakV61z8FcgU0Jc+nJA==; 25:ULus9lE22ZwWUc9OpEAZRb5xyAtIVeztdqr/7CQwOV6QClcYN6W8BprlcQaokvJhe2T9zpnKaFmC/VWsIYd2MTl4kuz/x+Vy+oDP2x4Cwwv5+iLK3ZtX4OlADXe2fMeaGmk3mgtaG5d8pYuYXffqgyeNTM9beFarHG9D84hPOTyFAomoHbF0sBzLHrkaw/xJwoDYMjl9rKAZDJBS37mgTSBaICIHZQDIRgs0cQ+c4+UhSbv4cO5XqPSpIAlConWdO5nvqAG0SzEDP3rCYQdteH3GvcobUaQXRiwWfQ5B9p16wdUQD7XwXxLKLd97M3tpK/hdh4FJUlEhCX/X8dvz5w==; 31:AZ6DqFROXdEkwenKrgiisOpxhCJcy7t2/YqoNv9EaehiVJijLXd2IpygEowKDbjSzVwAxBNMd5w6wcw41kxsCD7WuawuefNAGhu5Vue3S8pdh3szv3I8ticouVz9EpTaU18edDvZNswKvFOrnlMeuB1RMW6DIQo5TPOaJcl5T2T8hsuyPPvQA6zpNqQTFQeuduzwIy+YlWUUr5w+G7TvYaCZMHEO8A/so8ShvI8XHWU= X-MS-TrafficTypeDiagnostic: CY4PR0701MB3809: X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3809; 20:pg116Zs1jAKxCldDsyU9shE194oXCGNiGQZkT55f/GnY2JqySTxD6CSNC9zn9hwPPROlyunATE0NMuIuzeD7MCgP7zUPQD+kKeMq2Gl7oEri7iikur78Hd8Y9x3pZQ80a/KRA9pfnSZVr4is1P7I5x3reEZl8RNWmE87tIn1mO2W7nNpL8wtL5AtmWMN62aWBrs7l5LXxRDRMvVjEq/TKbDesOSWkGJPRgz3j/amBeIN3ZvogZfDsMEj+xOerhp+YnJDzS7XIwT4W1NBgtymjWrNEhSUYQHxKu8oZBeFoghJOv0dPsW9Mn4qWnAylwjaYvZGzI+2Cplu9bYhvqJ1s+CfrYhXa3SrVC48Vs+QQ1USjtW/MiN/YQPhGXXTuGxJLQ+cAdRzSxdF3sJVOK8Hr2SkLA0oFdPE+02qWR4do4zCXpivRWiyWs7k4NMZ0+lYqNEzBJmY84O6ATiX3gNm/n61fwDdiWjEzX62sajWTbm4jUB5oNBF/RqO6WLC1Hxb; 4:PkT/kmyq9uazoOfMxGWz2R3YWMv8b/7cw+FY4wkvtztEU05yn/F9Qe1i2fWMTtaDQaakgFtZY44iY6fMYu+7O4/JIxFspj1YGHs+pIZUXQYbuZKRmNyiiCvGVTu38wpuzUJiI84Aizybzur6btYNPjCDqLAFw/5ZxuUmnYvuITLFptqM/V0l5DuDLTqAFQsk2sdKeQglyqCGvTzvv7fEg3JtjXlLxbrNX7q2q6+VuuH6PXcD1xNmaOmHjGz58Rhk7FNsyowv6EyL5d8HwzBtHQ== 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)(3231023)(944501075)(93006095)(93001095)(10201501046)(6041268)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(6072148)(201708071742011); SRVR:CY4PR0701MB3809; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:CY4PR0701MB3809; X-Forefront-PRVS: 05352A48BE X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR0701MB3809; 23:Q7whjqjiv26XHg0YDBH7IO8YIZWtjr/VrWvsh2k?= =?us-ascii?Q?eCh9iehDmIOGoaM0niZ7lsGRJJwqzJra1k7WllVP6xpDVNSnfIJJGK5WE1Kx?= =?us-ascii?Q?6oHBfDe1QyEkPvKx7yB/5ywpWCuok3Q3yO96eVxbJitFEKc9XoVEWbAqNmgN?= =?us-ascii?Q?igjVUKM/I0CugJSTIzorhnjD9IEkNzQ7cWKrDzPQOD7r0r79+lE5h6rpfCfs?= =?us-ascii?Q?MPu3MOUniTUt5lX7g0+WDFGNSwd6ky7x0ZryodbMfkQayKMvBlRnqWYPlH6X?= =?us-ascii?Q?Uqp/af1jAQDVFB7fwZwie71fXGDinRLXaGFm/qDsoKqfU8L4+SMc17sTqDmh?= =?us-ascii?Q?Y7B5ylQMl63pZkwPZ/UNQaG7wWbBg3naDLFgPb3eUMHgwM6WVhhmq68IVsu6?= =?us-ascii?Q?x5jKUike6BgzIWj3FDZoB2xvGjFYeh9hXe3PJDqIkmBj/JqOfr4dFZAAoiq1?= =?us-ascii?Q?PcQFoYx2hFvdX479OTbeqa0Ykdjz4+qDPv8H/qDas5tqXdzsfCMXNPX5ZIlD?= =?us-ascii?Q?zR+ndC5/j1epAQtwMMprqBqnU7OWAESNg2vp1kSoVioklEq+2jZfP+KyiDWc?= =?us-ascii?Q?QbWCM1k9ZZ956NM2MxLSMfwnccBS+t25CMoTkrynOeTwUGvYMtpofFjd1IjU?= =?us-ascii?Q?TcP6ecX1Ir61EUKAF5wTntm/wQO/K1IZSHEo3Vr7+PrGezxRES07SFUBRKyx?= =?us-ascii?Q?JLQUPOGWtNP6YWY3IR0iZuWueGdl9oK35244Bz6pMvI7p0bcHN8Nzmfq54dO?= =?us-ascii?Q?0IoN6U//VdhmEMeZzG1aYCZq7VK2D3nwUmWQPvhDTz9BQ1t1htCN4QMYAPnv?= =?us-ascii?Q?S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DCL8fkixjRSZoRL7Z/ljgZdbElFHyRaMJTsqM4dN49WCQpBoWXGtS8ssnlERAPq7OAd9asuF1AVUvsT/qa5Qk9xhGvOG34zv304h5c3BN05NK/V2gwZc7CccGz6jyLxfY0ZJ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Dec 2017 20:33:45.5008 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b2e7aac4-e502-4672-44b6-08d54e324b21 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: CY4PR0701MB3809 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 f26acb7ce315..4f4d8b2b7b32 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -3939,6 +3939,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, @@ -4020,7 +4021,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 2570146beae4..bf365f8a9d32 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 d4ead404100c..5695fc249b73 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -7184,20 +7184,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); } }