From patchwork Wed Aug 1 06:13:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10551751 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 941671708 for ; Wed, 1 Aug 2018 06:13:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 835A42A5FC for ; Wed, 1 Aug 2018 06:13:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7745D2A69A; Wed, 1 Aug 2018 06:13:53 +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 99E752A5FC for ; Wed, 1 Aug 2018 06:13:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733221AbeHAH5s (ORCPT ); Wed, 1 Aug 2018 03:57:48 -0400 Received: from mail-by2nam01on0054.outbound.protection.outlook.com ([104.47.34.54]:9219 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1733143AbeHAH5s (ORCPT ); Wed, 1 Aug 2018 03:57:48 -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=agdFNcqpqw2bpdJoT3fg0i93RnikgVDk1tMvGSMiqhs=; b=ny+21kYJSIhDrs8Wi1qOlMIILg4SXDnPrOlq5wAKcVfzKvoPbfy72lHywtgCBUBXev5NWgh4X/swrAQJtcjQvprE3xT3+H71lwdTMEl4zBllSlJ1aNwBwwt6soiP+EuPoGCuoHMY1/e0jq34xMBwDIMNbgWK81noB/vWJ5DxmuM= Received: from BYAPR07CA0027.namprd07.prod.outlook.com (2603:10b6:a02:bc::40) by BN3PR0701MB1378.namprd07.prod.outlook.com (2a01:111:e400:4018::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.19; Wed, 1 Aug 2018 06:13:48 +0000 Received: from BY2NAM05FT043.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e52::202) by BYAPR07CA0027.outlook.office365.com (2603:10b6:a02:bc::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.995.17 via Frontend Transport; Wed, 1 Aug 2018 06:13:48 +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 BY2NAM05FT043.mail.protection.outlook.com (10.152.100.180) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.1038.3 via Frontend Transport; Wed, 1 Aug 2018 06:13:47 +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, 31 Jul 2018 23:13:37 -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 w716DcoW028785; Tue, 31 Jul 2018 23:13:38 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id w716Dcsu028784; Tue, 31 Jul 2018 23:13:38 -0700 From: Himanshu Madhani To: , CC: , Subject: [PATCH v2 10/16] qla2xxx: Flush mailbox commands on chip reset Date: Tue, 31 Jul 2018 23:13:29 -0700 Message-ID: <20180801061335.28709-11-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180801061335.28709-1-himanshu.madhani@cavium.com> References: <20180801061335.28709-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)(376002)(136003)(39860400002)(346002)(2980300002)(438002)(189003)(199004)(446003)(4326008)(47776003)(48376002)(110136005)(50466002)(16586007)(42186006)(476003)(6666003)(80596001)(36756003)(44832011)(54906003)(2616005)(486006)(69596002)(11346002)(50226002)(26005)(106002)(5660300001)(126002)(316002)(52396003)(478600001)(106466001)(76176011)(81166006)(575784001)(72206003)(81156014)(87636003)(86362001)(2906002)(8936002)(15650500001)(305945005)(1076002)(8676002)(51416003)(356003)(14444005)(186003)(336012);DIR:OUT;SFP:1101;SCL:1;SRVR:BN3PR0701MB1378;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;BY2NAM05FT043;1:+c1cw42v5tnlR1glkN5sBKUy6YxMYyX3LrjUX4zHhQAtUd8pHVMON+HIihNxQH8uqgYBxkgyVUcEMOuH1gJZuwTkNZkRs5JccfUA2Jdrk/leIH+sTv6IqLEY2SwQCZ8o X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9aee19f6-a49b-45ab-74cc-08d5f775f1aa X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4608076)(2017052603328)(7153060);SRVR:BN3PR0701MB1378; X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1378;3:VIh+q7CGNHoafR8lmxtJwH/MXTyvlLAIe7HaF1O2penWlcG0mx7HvLyjO9G/TZ/vNNcymuk68HOyDMDZsHQjA/EljNG/tU2Jtb+odSu6B6oWoEhMzGHm1EYm3/R7RDPcEalPAKVXK2ze8ZFqApe9mJmOdtjISuAAvdB38FoQ5L/R+XfjRcW/DrUkh6CgDMtvObnKqxoUyKdwPQVzwIG9XMXSPltZ1x2YhcyVqum2CSZ5Pjy2H/70Vqx7jh+ofBhz+GIBRMwt2AUSbZRj7WDBzE9Xmq1mGQxtjJv1xv1FKC7G0uGEc/QmEUEvzXBUFex6Oc2nMASx+GT3EGh4Azdte2Yzv1HVzlPTESxoFWm2WXI=;25:1kn+IObkn24tOCR3fNw1sr9HS4GJDc7auhaVu32Av3SiE3i9qD6H6gjQrA23SSLHF6pNoxs0YpEHO+JcQBtQo3S71wI9Rs0adAarnPMEkowVXH0QfDQse9jTWHlr3jAunfNBojbhTR5ESekdsh5AsPWkJR2vucclt6cR92/emSa/hrZ6CZbQCDnlNddypobM3VnZpMHD0Oa/D27AhJ1OGEgdorR4r/Qp++maYNJi3nhJ17nQDTjmHgdfrS4A/xIFcI0xKSSpDePe8NvHOxjy89AWpRltUePMCsIUkfSEkJd98bjQrEgWbAlwiH7XYahB/EkpYy3bCnUH+GEdLghufA== X-MS-TrafficTypeDiagnostic: BN3PR0701MB1378: X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1378;31:AYbgaD1ty4SKIzbYVFUYJaj3tUitbOfJMbFi+rn8ZE1nZGMp6DdSpjuDmqLzXHNVUlqyCyPapfe9afktul9u/htoA3poe8m1A+lWDILoCzVQxSCTxsbGc/IIbumuzoEl9gom6y0PuPECwyFldeO+OM1AxQiUAu4ZOh3hVgp6eli2ZKcU0oIfSNOAyJ9T37I/4GRmFbSRGpwP5xA5mgbeBQbkyCneJUcVwZAMcYqVEsM=;20:N/vy8/D73NRN6qp8hQgN8OlWQr6QlZzvF4Af0mLAHNSzSPCznmrco8ootwqIu6SxhSfRWTUQCvhitAODWygA3Pa4X4rWZEQa3lf+M7ep/MOJeoSb8SJYe/yA7ffRbo3ani1k/dCpnlmFMPwuB8NGtkGATj0l5feuuM9EQLNgVEBmOu5Y4ibbSn7hyQauywiXqhDrL2W47grQ063qx+n2Pr2DcGkn2Wmld/XDtOmzZ9xcDSVPzSQgRqPo801z/0EkXywuFtrCSkL86zgs8nSPZqeszsp3k1pcCQpJ06a1lDAr6PPYH+4BZChYHasHpkkC1jGXVZVBarMRYutN9Boks0kTZ9xeCXFxEEr+dK+elCssL4+qC7q0WrV0vP+dN6pnD51HS58wWhCx79Kuoawh/Wxpq83Li2vtP26my/uz01sEEbIlumgJCEeASJu6VDRxrW4IfS9lR5cN7vZrDwEbePoPCe4K8LcfMwQQou0J5gcyJa+Oh8G0jAa++OHZEKET 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)(93006095)(93004095)(10201501046)(3231311)(944501410)(52105095)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011)(7699016);SRVR:BN3PR0701MB1378;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0701MB1378; X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1378;4:ARGoajpDpSViaUesxAybFIirJ9A9bXLzikjZhJKi1nyocsu4c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CI5RXkT/Kz7ZRuRowB7EvQPxPayS/NTW4xgDIbBB2XmvRownGGCfYZRbUhbqM6w2XV73+djS0mV/EQ9V0RNqdwMTO8pvE9UyWh0QxcDI5F6JldlHblzoNcMDDDOToByTUnIhBLoP21ynkiqV0ZP7+lEYwjc9JkaL3X9/4YkJFdCP8nu7DC08C7QeTSFYkPdYWZjgUnRxY4tcdUhyvxEIzrGFisAH7nrlieTC3eLVZLWXMkGmIe5GUNnQ==;5:n936RukMV2KnsrpqvqllMAx2Ck9xeSWwiAnet4H0lMvDIgNWTeWTvL/9BeM2Qih9wWd0aCwMGC4O9wHcB21Vgi+CXmxNvSMn7WBjvKrf8JepuNSWIwCfDmQU3cBAAAzDLIpeClY4TZHQV5SOu7VNjdxtaQenLeNhNJ8KJh9OpAE=;7:ssTo5Q0YNwRctzOsrJzi5v/U8A2CNMAyNHQmOa1nu5MvCFepMSfBU1eUnj9vhXLNMBmsxgpSEDtls0YBg6O+sNt6MHs5XsdWyK9iUdxg6aYLKIMKGJMPwEu7j/L+BLukYB4kS1p2esrUkyl9tOZKEfd5cfuzImxExA4mLt1DX9Q2juJRIz+bRREuwZKVeKS6TR3UMbZB3JXpXSXGxY5WN7wfn6uLshl1eVIM613BdzSFgVx1rLGgzRxm3lCMbgqU SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2018 06:13:47.8319 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9aee19f6-a49b-45ab-74cc-08d5f775f1aa 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: BN3PR0701MB1378 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 ee4d1f4fdf95..40bcf938cf4f 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -3598,6 +3598,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; @@ -3843,6 +3844,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. */ @@ -4156,6 +4160,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 f94335301c70..7a984f5e6f11 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -6282,6 +6282,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. @@ -6296,13 +6297,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 17537f0b3b54..10847cdca093 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 e218d68de532..04e0c7f51e68 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -2815,6 +2815,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)) {