From patchwork Wed Jul 25 17:01:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10544461 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 83458112E for ; Wed, 25 Jul 2018 17:01:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F9422A1A0 for ; Wed, 25 Jul 2018 17:01:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6DF262A869; Wed, 25 Jul 2018 17:01:42 +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 998BD2A803 for ; Wed, 25 Jul 2018 17:01:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729524AbeGYSON (ORCPT ); Wed, 25 Jul 2018 14:14:13 -0400 Received: from mail-sn1nam02on0088.outbound.protection.outlook.com ([104.47.36.88]:21075 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729494AbeGYSOM (ORCPT ); Wed, 25 Jul 2018 14:14:12 -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=6uYVugJimp1daRCXvkmARiyzhavNyZNFNC7tM/MRJts=; b=kDhyKqSa9qspSocgEMsFiW+tEJukk6UBxJFme0bR/RvZ7yx2VvSGnUOUsSa5bMQ/h3S1Ft8+mjK5Fde8BrNCfermzCme1Dec/YIf5iCYVWT2EefA1mDBplIsr2W2W+ZlJRrjiO84iOWvMsCjpyMk6m9wJIwOtMGyQV7FLk0JCgE= Received: from DM5PR07CA0030.namprd07.prod.outlook.com (2603:10b6:3:16::16) by BY2PR07MB1459.namprd07.prod.outlook.com (2a01:111:e400:515f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.20; Wed, 25 Jul 2018 17:01:35 +0000 Received: from DM3NAM05FT022.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e51::205) by DM5PR07CA0030.outlook.office365.com (2603:10b6:3:16::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.973.16 via Frontend Transport; Wed, 25 Jul 2018 17:01:34 +0000 Authentication-Results: spf=pass (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=bestguesspass action=none header.from=cavium.com; 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 DM3NAM05FT022.mail.protection.outlook.com (10.152.98.132) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P256) id 15.20.1017.0 via Frontend Transport; Wed, 25 Jul 2018 17:01:34 +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; Wed, 25 Jul 2018 10:01:22 -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 w6PH1MEu010344; Wed, 25 Jul 2018 10:01:22 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id w6PH1MlB010343; Wed, 25 Jul 2018 10:01:22 -0700 From: Himanshu Madhani To: , CC: , Subject: [PATCH 10/16] qla2xxx: Flush mailbox commands on chip reset Date: Wed, 25 Jul 2018 10:01:14 -0700 Message-ID: <20180725170120.10269-11-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180725170120.10269-1-himanshu.madhani@cavium.com> References: <20180725170120.10269-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)(396003)(346002)(136003)(376002)(2980300002)(438002)(189003)(199004)(446003)(2906002)(87636003)(80596001)(69596002)(1076002)(5660300001)(2616005)(106466001)(11346002)(186003)(51416003)(126002)(15650500001)(26005)(8676002)(81166006)(336012)(76176011)(44832011)(478600001)(36756003)(486006)(8936002)(356003)(305945005)(72206003)(81156014)(476003)(50226002)(106002)(54906003)(110136005)(47776003)(6666003)(86362001)(16586007)(4326008)(14444005)(48376002)(50466002)(316002)(42186006);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR07MB1459;H:CAEXCH02.caveonetworks.com;FPR:;SPF:Pass;LANG:en;PTR:50-232-66-26-static.hfc.comcastbusiness.net;MX:1;A:1; X-Microsoft-Exchange-Diagnostics: 1;DM3NAM05FT022;1:8Wjbr+uATyHos63MO42coUyICZPNgkn3pJzzYuZKd2LoFYyLRurC09luQSJVGEmRghk5Ca+5pAkj47I+5D4DMQ4FRDPPdgAKfBI9fGuYSw1aSvTTwRqXrG2I2pfb9xr5 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 10d450e2-1c25-4788-e871-08d5f2504710 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(5600073)(711020)(4608076)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060);SRVR:BY2PR07MB1459; X-Microsoft-Exchange-Diagnostics: 1;BY2PR07MB1459;3:4XP+E/3y9GtOH7BRxPKAF/3kSnMfyTkOcpK51SV1xlfsjhu0vfjjE4GqnKwie3ooOuwirkPZUkW6zbfYrBil9CY2DoTF0uXv6BLVDD6B98Ch+yMfsco7HLDODcUHf6o6uIBy+Sciy1S0w6gPyE+8p0NrWwGYqxlvWsBRXslAFa33TJXZKIZjjS/BHYAkuqj6y436ze2gtfEyXEs9PUegUma+D0NmCUDk1obeTfr2bvSHUX9QRySJSEQqvdpPF+Yi3oUjK88UtngVzRS3oaK0dZt8/AEzXknoXyJ0BfBEFEAjCa1NdpY8gS4PrWDOelcLhmUMzyU22/hb4gzjWuu8sYwEs5R1ZnLhBSYxSTUKMbo=;25:/3Xf9z/YIJ/kchT6dltAt+DVEfi1yiTj8osidfif4NfFVZg5C4HUvUUO6ptjGuyZEAAJEI1zojH48pX6fEi+l3JA0N5IoYJg43Smw4P7juA7XzuNjFIUz4ZQgBP5xRWk98nlZA+naP+h2Id4kGZPOHeETywxe9188oXABbiyK5KK9ZDQjTdsSQZ34VnHiHiLyXBN9YOkjH960gga05lJCbQV8savOn1ypdiaTxbjjVxhN3HWHJZEK+kNDyVMoIUJ3ZWLPzRcbg0++cvQA+3vulQW3qNEzAhWAopzqhZsSoCvycA1OAsrjPpAMsvZHtePMMz0E28ew5evLbv6X1pqyQ== X-MS-TrafficTypeDiagnostic: BY2PR07MB1459: X-Microsoft-Exchange-Diagnostics: 1;BY2PR07MB1459;31:P/6VXXl/MKMydezfab5eEVwoo2UIPMaFSoOV9/1pFrrXkT3z3IMdMPgTohPO+0Kl86zAtvNhOgmz/e6jO8LbQQ42xYXQzPT2r5CUxlf4NQSIDWV67jGNo6vdUZZrQenBJVUqxMWXkTbQZxZz9/OiK1tfh/JZX8Jb3dsveCmMruowPWdYTshdWQ90JztIv0LN6Uy0824DMy8FOWx1D4ZaBNRzyiiVB17X/dlyt+9Qx0Q=;20:GBxhOuLjUTIILsrQFw7xNZwWmPpcVn9pIhMMRUXgqI/Wsms1Ktq3LPQY700kK6g3koV+SGyWraioxInCxibMcKlDBJ1Fkhe3BhR75mAxhsz0PQFedhTEOj+0wXCs6D4Mq5hd9c8Jzxzx/zfE91HlXHup2q1ywoVMpLiWgxRQE/zfuKW+PS1rDo40HCy9o9RB95i2COgIL7mb003YzJFZl3CFDq7XkyIjCLy1XewVs8Y5K8Wh4r4gMpvcvCLNQI0NSkrxe3CbKURou994Sv4DIh5ecYKgd19KvNUnRW2f6CnU6njBgm6Jke8L4qC7aSnQ9vSpQQ5l1D4d/SllikBTlZrTX2QILRzuq38CwRMCVBJsb8x4cnwahdBs6PLJt8k1krHOhgXQamE17BXdgW8ypxXXdnrADrEQEog67i5jGaqRP6wYQZsDQuBInqc6LfflOz3LVqZxKIN0CvrRfWBbSuMet60ie8kg7FavzGYjyRFmaPlAcG7ahGiQaxw3Jqg5 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)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93004095)(3231311)(944501410)(52105095)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016);SRVR:BY2PR07MB1459;BCL:0;PCL:0;RULEID:;SRVR:BY2PR07MB1459; X-Microsoft-Exchange-Diagnostics: 1;BY2PR07MB1459;4:lDRQVi9+BAXaHqBRF7rKoVjff7YHKeTusdR/HV6IhrewO691pIpZzMvM7emVh498W5hz44qqB+0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xMNWcrUgqK0radzyAeTGPFT77vn05jBA2uoQIiDyjavTQHClQY8FasJQ7e94ezEYmmEp+1v8ofSFvf/T+gADbTx8hEmDHO48dVjX4moU5Hsb16Og/G8hcF/LR2ej6tI3jlZJA3rJlOV8BmdORgQi61b+nKbGRbw==;5:7UKMvIfbiI0E1/MwGCFJAfMqTjdI2oRg+jaClaq+RCPqwSOfiz+Ceq3e/xlbtD+bqXN39lrYNoFzEpmRRbS6+Ip1m0to3PlaKJ8ZDKw1a8e13l1uv8TEXsv7nj6nxUQOk+G0SObaw7/Hv78pj3febdXiiPfokHvbJDxB4VQKcY8=;7:PVHnZr0iKJkRfrR1nEtZ/A1iNfCvzovvq6anLysIMBri6hqAnKWguJEn/zzFpQWQoCpBIshpGAGiEr87/isx3LAa5F7u0qAgOUQhR4bnGD2zwg2gJQAYgpnMGmKxNlGMX2CwZxni8NoridsRqVAxZZWfBG2QwtDPjnW+XUKtKolRU2q/haps00yYD/NyytZtlWNvBMxYnQd+UY0NsmOSJOF8QXUmhj+1e30ToYWp6Ud1/rZaxLhk3XBS04j9vq6+ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2018 17:01:34.3264 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 10d450e2-1c25-4788-e871-08d5f2504710 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: BY2PR07MB1459 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 Flush pending mailbox commands on chip reset. Wake up command that's waiting for an interrupt and wait for mailbox counters to go to zero. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_def.h | 5 +++++ drivers/scsi/qla2xxx/qla_init.c | 21 ++++++++++++++++- drivers/scsi/qla2xxx/qla_mbx.c | 50 +++++++++++++++++++++++++++++++++++++---- drivers/scsi/qla2xxx/qla_os.c | 3 +++ 4 files changed, 74 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index b595479d445b..ddcaa0786f37 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -3600,6 +3600,7 @@ struct qla_hw_data { uint32_t detected_lr_sfp:1; uint32_t using_lr_setting:1; uint32_t rida_fmt2:1; + uint32_t purge_mbox:1; } flags; uint16_t max_exchg; @@ -3845,6 +3846,9 @@ struct qla_hw_data { int port_down_retry_count; uint8_t mbx_count; uint8_t aen_mbx_count; + atomic_t num_pend_mbx_stage1; + atomic_t num_pend_mbx_stage2; + atomic_t num_pend_mbx_stage3; uint32_t login_retry_count; /* SNS command interfaces. */ @@ -4158,6 +4162,7 @@ struct qla_hw_data { struct work_struct board_disable; struct mr_data_fx00 mr; + uint32_t chip_reset; struct qlt_hw_data tgt; int allow_cna_fw_dump; diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index dff4dc588947..ff79bed54e07 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -6280,6 +6280,7 @@ qla2x00_abort_isp_cleanup(scsi_qla_host_t *vha) ql_log(ql_log_info, vha, 0x00af, "Performing ISP error recovery - ha=%p.\n", ha); + ha->flags.purge_mbox = 1; /* For ISP82XX, reset_chip is just disabling interrupts. * Driver waits for the completion of the commands. * the interrupts need to be enabled. @@ -6294,13 +6295,31 @@ qla2x00_abort_isp_cleanup(scsi_qla_host_t *vha) ha->current_topology = 0; ha->flags.fw_started = 0; ha->flags.fw_init_done = 0; - ha->base_qpair->chip_reset++; + ha->chip_reset++; + ha->base_qpair->chip_reset = ha->chip_reset; for (i = 0; i < ha->max_qpairs; i++) { if (ha->queue_pair_map[i]) ha->queue_pair_map[i]->chip_reset = ha->base_qpair->chip_reset; } + /* purge MBox commands */ + if (atomic_read(&ha->num_pend_mbx_stage3)) { + clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); + complete(&ha->mbx_intr_comp); + } + + i = 0; + while (atomic_read(&ha->num_pend_mbx_stage3) || + atomic_read(&ha->num_pend_mbx_stage2) || + atomic_read(&ha->num_pend_mbx_stage1)) { + msleep(20); + i++; + if (i > 50) + break; + } + ha->flags.purge_mbox = 0; + atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); if (atomic_read(&vha->loop_state) != LOOP_DOWN) { atomic_set(&vha->loop_state, LOOP_DOWN); diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c index 4b576aabba30..70517cd09e32 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -110,6 +110,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) unsigned long wait_time; struct qla_hw_data *ha = vha->hw; scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); + u32 chip_reset; ql_dbg(ql_dbg_mbx, vha, 0x1000, "Entered %s.\n", __func__); @@ -140,7 +141,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) rval = QLA_SUCCESS; abort_active = test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); - + chip_reset = ha->chip_reset; if (ha->flags.pci_channel_io_perm_failure) { ql_log(ql_log_warn, vha, 0x1003, @@ -167,6 +168,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) return QLA_FUNCTION_TIMEOUT; } + atomic_inc(&ha->num_pend_mbx_stage1); /* * Wait for active mailbox commands to finish by waiting at most tov * seconds. This is to serialize actual issuing of mailbox cmds during @@ -177,8 +179,14 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) ql_log(ql_log_warn, vha, 0xd035, "Cmd access timeout, cmd=0x%x, Exiting.\n", mcp->mb[0]); + atomic_dec(&ha->num_pend_mbx_stage1); return QLA_FUNCTION_TIMEOUT; } + atomic_dec(&ha->num_pend_mbx_stage1); + if (ha->flags.purge_mbox || chip_reset != ha->chip_reset) { + rval = QLA_ABORTED; + goto premature_exit; + } ha->flags.mbox_busy = 1; /* Save mailbox command for debug */ @@ -189,6 +197,13 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) spin_lock_irqsave(&ha->hardware_lock, flags); + if (ha->flags.purge_mbox || chip_reset != ha->chip_reset) { + rval = QLA_ABORTED; + ha->flags.mbox_busy = 0; + spin_unlock_irqrestore(&ha->hardware_lock, flags); + goto premature_exit; + } + /* Load mailbox registers. */ if (IS_P3P_TYPE(ha)) optr = (uint16_t __iomem *)®->isp82.mailbox_in[0]; @@ -231,7 +246,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) "jiffies=%lx.\n", jiffies); /* Wait for mbx cmd completion until timeout */ - + atomic_inc(&ha->num_pend_mbx_stage2); if ((!abort_active && io_lock_on) || IS_NOPOLLING_TYPE(ha)) { set_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); @@ -241,6 +256,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) spin_unlock_irqrestore(&ha->hardware_lock, flags); ha->flags.mbox_busy = 0; + atomic_dec(&ha->num_pend_mbx_stage2); ql_dbg(ql_dbg_mbx, vha, 0x1010, "Pending mailbox timeout, exiting.\n"); rval = QLA_FUNCTION_TIMEOUT; @@ -254,6 +270,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) spin_unlock_irqrestore(&ha->hardware_lock, flags); wait_time = jiffies; + atomic_inc(&ha->num_pend_mbx_stage3); if (!wait_for_completion_timeout(&ha->mbx_intr_comp, mcp->tov * HZ)) { ql_dbg(ql_dbg_mbx, vha, 0x117a, @@ -261,7 +278,17 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) spin_lock_irqsave(&ha->hardware_lock, flags); clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); spin_unlock_irqrestore(&ha->hardware_lock, flags); + + } else if (ha->flags.purge_mbox || + chip_reset != ha->chip_reset) { + ha->flags.mbox_busy = 0; + atomic_dec(&ha->num_pend_mbx_stage2); + atomic_dec(&ha->num_pend_mbx_stage3); + rval = QLA_ABORTED; + goto premature_exit; } + atomic_dec(&ha->num_pend_mbx_stage3); + if (time_after(jiffies, wait_time + 5 * HZ)) ql_log(ql_log_warn, vha, 0x1015, "cmd=0x%x, waited %d msecs\n", command, jiffies_to_msecs(jiffies - wait_time)); @@ -275,6 +302,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) spin_unlock_irqrestore(&ha->hardware_lock, flags); ha->flags.mbox_busy = 0; + atomic_dec(&ha->num_pend_mbx_stage2); ql_dbg(ql_dbg_mbx, vha, 0x1012, "Pending mailbox timeout, exiting.\n"); rval = QLA_FUNCTION_TIMEOUT; @@ -289,6 +317,14 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) wait_time = jiffies + mcp->tov * HZ; /* wait at most tov secs */ while (!ha->flags.mbox_int) { + if (ha->flags.purge_mbox || + chip_reset != ha->chip_reset) { + ha->flags.mbox_busy = 0; + atomic_dec(&ha->num_pend_mbx_stage2); + rval = QLA_ABORTED; + goto premature_exit; + } + if (time_after(jiffies, wait_time)) break; @@ -312,6 +348,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) "Waited %d sec.\n", (uint)((jiffies - (wait_time - (mcp->tov * HZ)))/HZ)); } + atomic_dec(&ha->num_pend_mbx_stage2); /* Check whether we timed out */ if (ha->flags.mbox_int) { @@ -390,7 +427,8 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) /* Capture FW dump only, if PCI device active */ if (!pci_channel_offline(vha->hw->pdev)) { pci_read_config_word(ha->pdev, PCI_VENDOR_ID, &w); - if (w == 0xffff || ictrl == 0xffffffff) { + if (w == 0xffff || ictrl == 0xffffffff || + (chip_reset != ha->chip_reset)) { /* This is special case if there is unload * of driver happening and if PCI device go * into bad state due to PCI error condition @@ -497,7 +535,11 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) complete(&ha->mbx_cmd_comp); mbx_done: - if (rval) { + if (rval == QLA_ABORTED) { + ql_log(ql_log_info, vha, 0xd035, + "Chip Reset in progress. Purging Mbox cmd=0x%x.\n", + mcp->mb[0]); + } else if (rval) { if (ql2xextended_error_logging & (ql_dbg_disc|ql_dbg_mbx)) { pr_warn("%s [%s]-%04x:%ld: **** Failed", QL_MSGHDR, dev_name(&ha->pdev->dev), 0x1020+0x800, diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 79514d43cb32..106150f1a86e 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -2816,6 +2816,9 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) ha->link_data_rate = PORT_SPEED_UNKNOWN; ha->optrom_size = OPTROM_SIZE_2300; ha->max_exchg = FW_MAX_EXCHANGES_CNT; + atomic_set(&ha->num_pend_mbx_stage1, 0); + atomic_set(&ha->num_pend_mbx_stage2, 0); + atomic_set(&ha->num_pend_mbx_stage3, 0); /* Assign ISP specific operations. */ if (IS_QLA2100(ha)) {