From patchwork Tue Sep 4 21:19:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10587989 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 6756B14E0 for ; Tue, 4 Sep 2018 21:19:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5675628F76 for ; Tue, 4 Sep 2018 21:19:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4ABCB2A127; Tue, 4 Sep 2018 21:19:40 +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,DKIM_SIGNED, DKIM_VALID,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 8AAC928F76 for ; Tue, 4 Sep 2018 21:19:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727447AbeIEBqd (ORCPT ); Tue, 4 Sep 2018 21:46:33 -0400 Received: from mail-sn1nam01on0061.outbound.protection.outlook.com ([104.47.32.61]:25376 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726869AbeIEBqc (ORCPT ); Tue, 4 Sep 2018 21:46:32 -0400 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:X-MS-Exchange-SenderADCheck; bh=6njvopa9PxyH0aQT2fkjhjiVRUwv/fqJiVpYrzdcClE=; b=FFQ8yED3XdB86xqn8aTLC1ebj+2Rjg0y/445BZnARP1GTlF4VGhpIx7V+R9djo8AQ1ygMxVvP6LaF78YonaUaQUO432nNbQAZSGtfl4AVZSZwnHrqnHQn1ELQ2R96j2i+PxeUeXxMxzMUfDCcORiza4pjXsoaXc9L0yoNFspN0o= Received: from DM5PR07CA0077.namprd07.prod.outlook.com (2603:10b6:4:ad::42) by DM6PR07MB5499.namprd07.prod.outlook.com (2603:10b6:5:30::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1101.18; Tue, 4 Sep 2018 21:19:34 +0000 Received: from CO1NAM05FT006.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e50::200) by DM5PR07CA0077.outlook.office365.com (2603:10b6:4:ad::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1101.16 via Frontend Transport; Tue, 4 Sep 2018 21:19:34 +0000 Received-SPF: Pass (protection.outlook.com: domain of cavium.com designates 50.232.66.26 as permitted sender) receiver=protection.outlook.com; client-ip=50.232.66.26; helo=CAEXCH02.caveonetworks.com; Received: from CAEXCH02.caveonetworks.com (50.232.66.26) by CO1NAM05FT006.mail.protection.outlook.com (10.152.96.111) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.1143.1 via Frontend Transport; Tue, 4 Sep 2018 21:19:33 +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, 4 Sep 2018 14:19:21 -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 w84LJMev031994; Tue, 4 Sep 2018 14:19:22 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id w84LJM0E031993; Tue, 4 Sep 2018 14:19:22 -0700 From: Himanshu Madhani To: , CC: , Subject: [PATCH 08/13] qla2xxx: Reduce holding sess_lock to prevent CPU lock-up Date: Tue, 4 Sep 2018 14:19:16 -0700 Message-ID: <20180904211921.31927-9-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180904211921.31927-1-himanshu.madhani@cavium.com> References: <20180904211921.31927-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)(396003)(136003)(39860400002)(376002)(346002)(2980300002)(438002)(199004)(189003)(186003)(305945005)(106002)(42186006)(316002)(16586007)(54906003)(110136005)(50466002)(76176011)(2906002)(8676002)(6346003)(48376002)(1076002)(356003)(51416003)(26005)(86362001)(14444005)(478600001)(5660300001)(72206003)(8936002)(81156014)(106466001)(81166006)(50226002)(87636003)(6666003)(44832011)(47776003)(80596001)(486006)(336012)(4326008)(69596002)(446003)(36756003)(476003)(2616005)(126002)(11346002);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR07MB5499;H:CAEXCH02.caveonetworks.com;FPR:;SPF:Pass;LANG:en;PTR:50-232-66-26-static.hfc.comcastbusiness.net;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;CO1NAM05FT006;1:VXaEu5netEBfId5v2pyUf97o/ReffgognjkkSOXyQZ2AW8M3vyX2YMdH9l0YI0hkSvW+zhrBTpIt18PSmAi8h8BPFTgRA0aBX40WCrfjQmWGFVGDJjQjjUA4ggwYcABh X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5bf3f22e-818f-4fe4-5062-08d612ac1c67 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4608076)(2017052603328)(7153060);SRVR:DM6PR07MB5499; X-Microsoft-Exchange-Diagnostics: 1;DM6PR07MB5499;3:8xzA/AJp34N18gTY0veFsDWMriHOPcwVmLz7GVxc1CI2/Y9iDQ/P/ZlAoy1fHwVrEFweNn9xVYqsjR4COfID+gBXB81QWWeaN70NxJ8fzyj3omG2J/Fz4YpE+DAAz4djTEuxZphiktMhdj7Om2EtQTLbNLgoBbIv6RTIQalwqUwFLLvreJua4XuVHn8u4u+9o1DfE63YNWdMDEHky8dq9oeAuyzVY6q1K+1vCiC3K7bFZOOLcLl2Te4qXbnaQdUZmosX+M8E/fqDcNQpuKxWn1KBftVEkVqh6hrhqrFckL2UCR2F45+ZHksa2wrOqxyWU0diDMQSIy1szxMekFw9qVRPOdgJJ3Tqde1eGZ0WUoE=;25:HRQc4J8UWhcY/XlQpBYdEUS88j9dghJVXB5KnliwZcU3Wpe58SEjdiNvNjvKA4KfTOHrSRhDG6QuILhvM5bqQ0XdkB5iIhcsHTk7sTzhX99Y81P5YUI8tn35w8uZsFbP43J7+Wzr/095d1utdH/WxYNVAd8WNPYWd5OJKAW/V03+Qz+sgq6X5Yzd7jbeiS3yyFT034j6MYs0mY0DbPX/zJ7Tu6VCgn7eOxAiaNHF1EppFmI2Iw2XMtMvooAT1gl16y1CmT+MUPPvcb9Ij6+j5N50/rbOy+V7rnjjjpEiZnB76zOT/cxotWm4cdJ68bdi4GJTUE0B31+Sj7P6HQUbWg== X-MS-TrafficTypeDiagnostic: DM6PR07MB5499: X-Microsoft-Exchange-Diagnostics: 1;DM6PR07MB5499;31:qfZWS611rcZI1i/ojA8FpYbpCIZapPEzT+KwZHlrSkhk0RlQkLr1zVgRiuxzOQQ9FWn1mFuE7UygbI7B3MGvlUivqgQXmFwG9vrUhS9zjfmHmm5lDyZgiVM9UZkbKaa7ilcycgwNV22/df44zKyLy5SbJRC0IIIgAWhfX/5983M6v3kS1l0mLForiQl9HuCjrRbyXu1fGxd0f7HY6dqf27VybC/8LGwFxF+Cqm3TZaY=;20:BR76vP8q5xsNUOWjvadF8V7xsxdpBlMXAfFpu45dMf7u2MKsnzn84rWP5MS08w2VK26eO7teKfR0AVJpS/kZ7ohm/G3s0Z17eEpDoNkNjzOVEpx98eTw4xHIaxwv2hbeveN6hIPzm2wfiBDvG6UZcnjGHWffJp1of+ZERJUsT7TtdoXG8NV5/WXpC3jdSs1OceWRvL9AyAo5bXig7f4GVhX//HspRD7n5XZjx0qQFxH8w1LLP27sPzI/m3UxjrHXcPqNlVnKj/bqhaIsbLSZdzZnDCwOnl6XjnBFGOcwe4B8fTjecD27s6A4vvespTO9cLnErULbX7Z4weNDAsrXD+rsc7YrHxNJbQQRewDmKP+bUqsdq31Opq+yESWGQRTXdo4uI86OF3LTmm7vCweJGXozFqPsJnJnv2OcdrLQ2UlBdq2PjMQ6PHawfFMmpCdiZPcPRZXPthydTMcycfXqZRfcNERMCp4kmEpICvUkYvoE1eDC3howxmqvPrDEO9Jz X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3002001)(3231311)(944501410)(52105095)(93006095)(93004095)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699016);SRVR:DM6PR07MB5499;BCL:0;PCL:0;RULEID:;SRVR:DM6PR07MB5499; X-Microsoft-Exchange-Diagnostics: 1;DM6PR07MB5499;4:zirW1g/SStGpAodw7aUNqGYN7oklpqxYHu30GiwxkT40Aro/IWMebKoU/NnhCgEzExJFe5h8P0IkbsoGY5cHTAJJw9WYJcCMDdhkSztTU+NzDuM9Bu2jxg3Y9e5y2vVCvitWBQS41faYEjwsWf0zZPpAvC5tMO6HXuswmlv6ID08o0rFF9GHCShE/CU7j8MX5UqAmuBvwTNabp5EOFuRytHqxzkaVtbAVLdMPpX5sDi5VfjM9pc6zY3PZrfQ5K2nGDaD80Y/OeyhXg/k7FbkIA== X-Forefront-PRVS: 0785459C39 X-Microsoft-Exchange-Diagnostics: 1;DM6PR07MB5499;23:WHtdhBo3Ijd7auSMHV+7seeNPT9fD7aE61IXPpHivHkIOiLJT3iwRF39T24KnFZDpvnYLogdDYQ85toLwaecWfpmLHtLvBqJ17M9/O/TiF2P7hoUDjugiWAEbowOcozc+M2BJt9lnxRV3cW2kWq1Snt+xM9+kjkqAyunikXtReLqRjzqYFz8lOnCWFPSKDLUtceX+uDUlBGr51sopLr8ZzUHj6LwoHjEqNooO7nG103JWs/Gy4z17nvMTzbXfsxKDDdKlmNWK2AjjB3aIM3+WIm+hY+3DSsBSNGsE3kEiIvSM12ucthjDNdQ/up7Sdx+9iegu2zGtzrRn2bA0ZVFnp1L/bTp2mUlf7fKx+zhMDqR9LbvEQwRs1VpDq+xo5GvxAULKYRP9KkTWOiPAO58qIJvyKSDCGGGcf3EB0f89RJqUVOsGOj6viIl3g5RtP2qR3P5rT+pg9ikiNeuu0zN5sYmAZW2HlecOYHGOxpTr29HcIJ31yVlSzkTzpEXcWAWeIH1CW3mTrZD6cbp6wIX/x3/LNqMDdGnjoVVNkz2ptvAwmt+BK2Ridg9B0vm2Q1wkPf3X9eY0qZ4F1eB2uWswHvNRtcloiX/q7vSM1E00XHtPluyNcV59WZ85fytrUGCZDCPxkxYwr2Yxx4NREk8tDg8jlIDMptic1ZewtihAbsgF19HYyc0AR2JPB9bwgLl3BvM4GkQkK0Olx87PaYyGvMi/z8bhuLwPohrC5RFoDDZCaoIjSs8t85+RmKMnmaqh8mCG+iCoFyEWpgVTZz1XQFVUQbhQpR6fnA8NXqSmCf0U/sjkrSy4/ZwJ5U9Ss1WJ45/GfmIVmzGVNh/wG9rd7WfTUF8ANGgNpeEMtxh6PWEdiqow7aBrZ8eBGSfgV1dODyZ8f3qEv0VRN3YDc+0JINLOI2+DMsm7DwiWGUPJTS3YwsNmn35xXVubPYVooMkIkzBTk5OJWFBzwmWnqt2PgK2i8bUK3o01LpN7GA0VaB3J7sntjpvO0E1oF9OxsBsETMLRan09M++KICB6Kz1Y7UlZPUEpufFPV23i6puQWqp9y/paeD5spdWzu09hAxlOmjk62AS/oOghgqVSqvrxoUAkyDi34fzEEw/W1c17IQtfkeO3ckZULfmVnKM7Hz/ X-Microsoft-Antispam-Message-Info: SwQQUV608Yiub8p4kCqz9B4NhCmNpLE15d06HZyyj+bhvGr11gMxjaQJU0sVffWVN53JXsfoSQEFKuDEC85sNvnW4xtYFXtQUEKl0Kx3XKe7On4weGwKianMqahUgBg1elw0AFjH3/yNbl7Vy6zzP94pvivxmk/9m6CIj8J5g9BDPo7KwYhk9J6zKn8DMXdDXsuupvTKvEgfOVUTRzB2BPi3ndHYhZpRqEqN6zcJjOvpcLV6F7Tx3FBJtG9TBulwzMmSEzutOsLGPMHcs4N6S8V+3HVczgjfQirgb387WImGLZNf4FsnraESdTLMW7IqWTQlh/7J9h/dndKTGkjv5qb+RzGrKBLbKRjDwivcuBU= X-Microsoft-Exchange-Diagnostics: 1;DM6PR07MB5499;6:nXE75Dxx7W6gGoORQuHGiUnidczvIEYHewX09NqReE1eQJJ8eW+jdfpcN+q6bT1tHsWnhkoSVLVlWiIbA5lXzXoRJpojKL0P8jfyc48uPPxb8UA6P8I8POsyvTDie3okvQAK4whrPpRau+3RaJ5hEOY11eTJ1IIktYxpPod0K5H0pjHCI/US9zIv9BCUhOd0etzjC34AdixTYLgoKB54A6a7VOI6pMI/X6phCVKY/qt/C2UVAsSULikT4n1K3ScnqIYlR9Y/fj4IAWkb/UqTlWVe+fDu6SbVqNTJbWnTvOZw8dg5ysWFoEIZZWzuHC8gkhmJqCWRwMidolOInkNOavj2TmPd81DXe/8JQWxvl43B2ZWQsXQWTapSagDtCM9wVUTC2VHRBiP7C5Jnmcko278kFjp7bOLTUsHghmtBc7lfOmqCqI+T1FYwIOtxbqOT/Wt2D6+lrjiD3mLc8IF4YA==;5:niAHm9vmZCnoP+6Rdje55LftgMFui1VH4m1V7/rFMdfXSmW6HfAPS0vogGjJhKxXBbJLcmLDiz0PIH54f+ENsaCHjRSnBumzeQw21Px3htSsad6Q3YszdTDZnEIvVm03Rk0/XIPIbhl3Sm5ppHCgcJYkJJWkap2xP1UtxJLQdos=;7:RkQqw1Ugt+p29QVJCG5fk+Qzd02v9sZzfIyaJABSn8HTBftZ95UCF3EYr38HhYUWXWRjMv1ec7POioCLF+yTy1Xw9ZJdR7QxkuDNoCIWvwUU4xpWpUF3TjNesxJJP0zzdeEAljSvglAIrqhAR6iSVf/2nqe+8j5A6cKNqJNEUUKE1O+a9HeAkeCNvShZVdzoafdkYOB0bzUNYO72tCZ+f9H7Q3Rnx+glYt115cuAd7FakhM8l09HhW4saSNxcW3J SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2018 21:19:33.7055 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5bf3f22e-818f-4fe4-5062-08d612ac1c67 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: DM6PR07MB5499 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 - Reduce sess_lock holding to prevent CPU Lock up. sess_lock was held across fc_port registration and deletion. These calls can be blocked by upper layer. Sess_lock is also being accessed by interrupt thread. - reduce number of loops in processing work_list to prevent kernel complain of CPU lockup or holding sess_lock. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_def.h | 2 +- drivers/scsi/qla2xxx/qla_gs.c | 18 ++++++++++++------ drivers/scsi/qla2xxx/qla_init.c | 33 +++++++++++++++++---------------- drivers/scsi/qla2xxx/qla_os.c | 3 +-- drivers/scsi/qla2xxx/qla_target.c | 2 ++ 5 files changed, 33 insertions(+), 25 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 3a03fe217ac2..8b8c7c8db1ca 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -262,8 +262,8 @@ struct name_list_extended { struct get_name_list_extended *l; dma_addr_t ldma; struct list_head fcports; - spinlock_t fcports_lock; u32 size; + u8 sent; }; /* * Timeout timer counts in seconds diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c index 385c46f2576e..3c8882a3e6bc 100644 --- a/drivers/scsi/qla2xxx/qla_gs.c +++ b/drivers/scsi/qla2xxx/qla_gs.c @@ -3946,11 +3946,10 @@ void qla24xx_async_gnnft_done(scsi_qla_host_t *vha, srb_t *sp) if ((qla_dual_mode_enabled(vha) || qla_ini_mode_enabled(vha)) && atomic_read(&fcport->state) == FCS_ONLINE) { - qla2x00_mark_device_lost(vha, fcport, - ql2xplogiabsentdevice, 0); + if (fcport->loop_id != FC_NO_LOOP_ID) { + if (fcport->flags & FCF_FCP2_DEVICE) + fcport->logout_on_delete = 0; - if (fcport->loop_id != FC_NO_LOOP_ID && - (fcport->flags & FCF_FCP2_DEVICE) == 0) { ql_dbg(ql_dbg_disc, vha, 0x20f0, "%s %d %8phC post del sess\n", __func__, __LINE__, @@ -4188,12 +4187,13 @@ static void qla2x00_async_gpnft_gnnft_sp_done(void *s, int res) sp->rc = res; rc = qla2x00_post_nvme_gpnft_done_work(vha, sp, QLA_EVT_GPNFT); - if (!rc) { + if (rc) { qla24xx_sp_unmap(vha, sp); set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); return; } + return; } if (cmd == GPN_FT_CMD) { @@ -4243,6 +4243,8 @@ static int qla24xx_async_gnnft(scsi_qla_host_t *vha, struct srb *sp, vha->scan.scan_flags &= ~SF_SCANNING; spin_unlock_irqrestore(&vha->work_lock, flags); WARN_ON(1); + set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); + set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); goto done_free_sp; } @@ -4276,8 +4278,12 @@ static int qla24xx_async_gnnft(scsi_qla_host_t *vha, struct srb *sp, sp->done = qla2x00_async_gpnft_gnnft_sp_done; rval = qla2x00_start_sp(sp); - if (rval != QLA_SUCCESS) + if (rval != QLA_SUCCESS) { + spin_lock_irqsave(&vha->work_lock, flags); + vha->scan.scan_flags &= ~SF_SCANNING; + spin_unlock_irqrestore(&vha->work_lock, flags); goto done_free_sp; + } ql_dbg(ql_dbg_disc, vha, 0xffff, "Async-%s hdl=%x FC4Type %x.\n", sp->name, diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 49c8f0119620..c675066b080e 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -790,6 +790,7 @@ qla24xx_async_gnl_sp_done(void *s, int res) sp->name, res, sp->u.iocb_cmd.u.mbx.in_mb[1], sp->u.iocb_cmd.u.mbx.in_mb[2]); + sp->fcport->flags &= ~(FCF_ASYNC_SENT|FCF_ASYNC_ACTIVE); memset(&ea, 0, sizeof(ea)); ea.sp = sp; ea.rc = res; @@ -817,25 +818,24 @@ qla24xx_async_gnl_sp_done(void *s, int res) (loop_id & 0x7fff)); } - spin_lock_irqsave(&vha->gnl.fcports_lock, flags); + spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); INIT_LIST_HEAD(&h); fcport = tf = NULL; if (!list_empty(&vha->gnl.fcports)) list_splice_init(&vha->gnl.fcports, &h); + spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); list_for_each_entry_safe(fcport, tf, &h, gnl_entry) { list_del_init(&fcport->gnl_entry); - spin_lock(&vha->hw->tgt.sess_lock); + spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); - spin_unlock(&vha->hw->tgt.sess_lock); + spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); ea.fcport = fcport; qla2x00_fcport_event_handler(vha, &ea); } - spin_unlock_irqrestore(&vha->gnl.fcports_lock, flags); - spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); /* create new fcport if fw has knowledge of new sessions */ for (i = 0; i < n; i++) { port_id_t id; @@ -868,6 +868,8 @@ qla24xx_async_gnl_sp_done(void *s, int res) } } + spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); + vha->gnl.sent = 0; spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); sp->free(sp); @@ -887,27 +889,24 @@ int qla24xx_async_gnl(struct scsi_qla_host *vha, fc_port_t *fcport) ql_dbg(ql_dbg_disc, vha, 0x20d9, "Async-gnlist WWPN %8phC \n", fcport->port_name); - spin_lock_irqsave(&vha->gnl.fcports_lock, flags); - if (!list_empty(&fcport->gnl_entry)) { - spin_unlock_irqrestore(&vha->gnl.fcports_lock, flags); - rval = QLA_SUCCESS; - goto done; - } - - spin_lock(&vha->hw->tgt.sess_lock); + spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); + fcport->flags |= FCF_ASYNC_SENT; fcport->disc_state = DSC_GNL; fcport->last_rscn_gen = fcport->rscn_gen; fcport->last_login_gen = fcport->login_gen; - spin_unlock(&vha->hw->tgt.sess_lock); list_add_tail(&fcport->gnl_entry, &vha->gnl.fcports); - spin_unlock_irqrestore(&vha->gnl.fcports_lock, flags); + if (vha->gnl.sent) { + spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); + return QLA_SUCCESS; + } + vha->gnl.sent = 1; + spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); if (!sp) goto done; - fcport->flags |= FCF_ASYNC_SENT; sp->type = SRB_MB_IOCB; sp->name = "gnlist"; sp->gen1 = fcport->rscn_gen; @@ -1185,7 +1184,9 @@ void __qla24xx_handle_gpdb_event(scsi_qla_host_t *vha, struct event_arg *ea) vha->fcport_count++; ea->fcport->login_succ = 1; + spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); qla24xx_sched_upd_fcport(ea->fcport); + spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); } else if (ea->fcport->login_succ) { /* * We have an existing session. A late RSCN delivery diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 210e5c2999f4..b8b7415bc59d 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -2730,7 +2730,7 @@ static void qla2x00_iocb_work_fn(struct work_struct *work) struct scsi_qla_host, iocb_work); struct qla_hw_data *ha = vha->hw; struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); - int i = 20; + int i = 2; unsigned long flags; if (test_bit(UNLOADING, &base_vha->dpc_flags)) @@ -4603,7 +4603,6 @@ struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht, spin_lock_init(&vha->work_lock); spin_lock_init(&vha->cmd_list_lock); - spin_lock_init(&vha->gnl.fcports_lock); init_waitqueue_head(&vha->fcport_waitQ); init_waitqueue_head(&vha->vref_waitq); diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index 79c290fc36dd..d5f6ce8c86df 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -601,7 +601,9 @@ void qla2x00_async_nack_sp_done(void *s, int res) sp->fcport->login_succ = 1; vha->fcport_count++; + spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); qla24xx_sched_upd_fcport(sp->fcport); + spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); } else { sp->fcport->login_retry = 0; sp->fcport->disc_state = DSC_LOGIN_COMPLETE;