From patchwork Thu Aug 2 20:16:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10554167 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 0143C157D for ; Thu, 2 Aug 2018 20:17:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DEECC2C444 for ; Thu, 2 Aug 2018 20:17:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D25ED2C459; Thu, 2 Aug 2018 20:17:18 +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 10C432C444 for ; Thu, 2 Aug 2018 20:17:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729764AbeHBWJ7 (ORCPT ); Thu, 2 Aug 2018 18:09:59 -0400 Received: from mail-eopbgr690077.outbound.protection.outlook.com ([40.107.69.77]:41683 "EHLO NAM04-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729623AbeHBWJ6 (ORCPT ); Thu, 2 Aug 2018 18:09:58 -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=mqRjNawpNh9pCMpeKaa1mf27P3jWoY+0xwXY+/REJr8=; b=dkc5j4MwB7q1CGm00lxLf6Z12RRjqDPei4uVrTy+QN0bARLR+aXxY8ocm8bj/CNRrral0iEv45KGD8nrM8Y79avKLqL/vAD7bCvc5pAN8bFsuayHIdstkrafHQStbFZm86EkCSph7YGZjMfvDdCYkgqlq+cHcObC2mFQC2qtBFc= Received: from BYAPR07CA0024.namprd07.prod.outlook.com (2603:10b6:a02:bc::37) by BN3PR0701MB1377.namprd07.prod.outlook.com (2a01:111:e400:4018::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.15; Thu, 2 Aug 2018 20:17:11 +0000 Received: from BY2NAM05FT024.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e52::207) by BYAPR07CA0024.outlook.office365.com (2603:10b6:a02:bc::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1017.15 via Frontend Transport; Thu, 2 Aug 2018 20:17:11 +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 BY2NAM05FT024.mail.protection.outlook.com (10.152.100.161) 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; Thu, 2 Aug 2018 20:17:11 +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, 2 Aug 2018 13:17:01 -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 w72KH0hF007978; Thu, 2 Aug 2018 13:17:00 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id w72KH0pn007977; Thu, 2 Aug 2018 13:17:00 -0700 From: Himanshu Madhani To: , CC: , Subject: [PATCH v3 10/16] qla2xxx: Flush mailbox commands on chip reset Date: Thu, 2 Aug 2018 13:16:52 -0700 Message-ID: <20180802201658.7903-11-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180802201658.7903-1-himanshu.madhani@cavium.com> References: <20180802201658.7903-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)(346002)(376002)(39860400002)(396003)(136003)(2980300002)(438002)(189003)(199004)(80596001)(336012)(8676002)(4326008)(446003)(86362001)(575784001)(51416003)(76176011)(72206003)(1076002)(8936002)(16586007)(316002)(6666003)(42186006)(186003)(48376002)(110136005)(54906003)(356003)(69596002)(305945005)(50466002)(2906002)(87636003)(478600001)(106002)(26005)(5660300001)(106466001)(14444005)(50226002)(476003)(47776003)(126002)(11346002)(2616005)(81166006)(44832011)(15650500001)(36756003)(81156014)(486006);DIR:OUT;SFP:1101;SCL:1;SRVR:BN3PR0701MB1377;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;BY2NAM05FT024;1:NdsPGmW5pSeN7jal0xYPzPIPbDuDGvU2ZMnUr228FKKA+u7MPJrjNggwkSZ3UdImugv6y79YUcwr9LvwiaCq0bPYe21SY+C47Eno7LeGvPpaHrrvIMSXq4YzdqUeNxpz X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ae7f22ae-a4a6-446f-f7e6-08d5f8b4edf3 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(5600074)(711020)(4608076)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060);SRVR:BN3PR0701MB1377; X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1377;3:0XShaWnecKKxK7Q0DyU28HOSaByOZjQpWW3zzRCjF0h+Wy9xXv4dVkWrQYaKoTX1VN4nq5llb/4tVS1FppZDB6K93Rl0JD2MF3dP/IWBKnfHBpcuOdrjMj4RXBOAL5r1cga0WPJHIy6HwMPuQms16DwOlrs8cooj9HipPNT29ra8txb8IOVx0vKFaU3Xc0JMJ/MFAxs1Tm3jX/+Z49lIXoTywtT4XvTFG4D6bPGhaBoJnIniFEV7Iw50IptathsvzO0hRnTmbDR4h0/vtXL110DQMf0xAjeE+uvGHCI20SidZSks/dS9aA/T3/5tnv/6NyJJalR1qMKuRkYmq1DZlSE+xbim1pSvoBfbjflMOTU=;25:AgY/U99INm016cvuV+mUxLIIPfF1nvXYHQysSdRJTb0w/vvR/wsp0NMUWlsEwTGzH718h2NN0YYMLikqhSjt/CBaD4vcUZ3APyGs7sIxF/ZgQD9CRUx4L4SuibufPRaV9yw9xPdA0viikA97pyDX7P4gcT1v3E9K3kUck9NjQx0TWO7xBJwex1fEAIK/axale5W1vf0Q2AS6AoT932T1rXTc8eNz1W6cByaxSLjUq3iK2uWFqcc7i5SUiHD8NzbeKxCn8ZHxCQbtJUcQgyre0+7YM/iPkSP1X8bU+PBRDZoZ86bI1/NKp/7gpYwwDzemT7ylKl8uKNjrhpL70zOVSg== X-MS-TrafficTypeDiagnostic: BN3PR0701MB1377: X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1377;31:YK8oQgrr/v1J+7Kb+zSNdMlxxXxv3FqrgX601Ta7z6qirdMNCrBKrNYPrYX12s5vppRWFlPYKzdrHlBcGgnc7geBBK8p+BFN9n7dCtuqiYBnUazxuvkj6axn9OONPw/Mqa/LfRdpbF6hILjG0Xmg2yyZhJa58xaxco1hzK/AygMweYI3KtGrd9TSlnqWL7d3i1CKSyvBk4OozbGmqa1U4Wa2d2Fh6zTrft90wEgJjf0=;20:UjIVkXBErb4FGQZ9IfK6NxyQ+6oovrSQ70WkywR3bX0sHhkQQU3wd/VECXlJTVuKSqLKcO1wl+Wc12hacd059oWlB9i+dW7JVghPXZxjj6gt6AN4rVXiAURvAa+XZpw32+nJMr3ernrL7z6G3eGQOS7TF/HVm8kkKai3KdhVtTEioFOTIxw9X4eOODScL1ro+LrqyvyNoCV0tUWIqJOc6m5+EakkIeIVOp7v68+O//0i/4anwLjNP0Iu7+r6Ykk3u2we9RXOAgX3YfnlPoFJkOO0N2lyDmQJmy0gkOSomOPDBXZ3b3xEwpjyYMsbLM0sdNklmQeY5/bq596WvhLqVGmu8USmnvpYxaacDfNwqXFRVCM0zfjZfogmLuYoy3DS0ftjLClAiYCjBAVSp1GJeWdhyPjX/YIbnGJm4LANDwJwjxCyoiXzAVOIprU27+u1UixikXtjxM7GhlWVy/NtYdq+C7+U8nedtpzie5XsrmesExZsiyvOZCq77Zxod5TG 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)(3231311)(944501410)(52105095)(93006095)(93004095)(10201501046)(3002001)(149027)(150027)(6041310)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123560045)(6072148)(201708071742011)(7699016);SRVR:BN3PR0701MB1377;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0701MB1377; X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1377;4:/Sa92ZYd5VMs/gYGRTIQkqvAbcR5hm97m4KEuR7C6dKAzljSTeXf89vj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Ucy2uigp96hGmAQM1Jy2Bmx7K0uF4pnbusktJpn7DwM9exLWu3TPI6mppEgU1iTUrqRPyLXDfg6zzf5rwhR6967XyiTCyrd2/ryJIeSxl5OHNuYmPd8MRfAAcYrYA1oQX+FETLbD7AfESdUbyEBW3VNXqNP9XX1OeA09q626HqAAHQPjN5+4AQfh8BKhGcSkh0HVGpP8UWb5dgIooCNvoZWamAvOA==;5:ALdjQnekU76FGeitTMBnLv7hvTNrtGSsbkNXxsjPESLiTW3XRSfc3J/GxYfc7j7t+N7Z2nxaKRr5Zj4NAw8uN9eppRTunIcpCQY+NG4RUDPLUi+nqltu8ZVt+D+yGIkFVk+1jUdCZsIk8tQwoPLfNZLy8u9FPzzf87J/GkJ7AqU=;7:B0laWLN0LEXqEpP7ixsLAWF7b7f0m053L2nLMNkwU9pqQQumuroJBN3bT0NLEXvEzg8Hluf7h+LzOw8jgiYS6n4pyfgow9CEJmsEEeU/fDr9ZzLCZ9pMFvZvykqNW8a1l29yPvpMtDUzUx750OIpXVLr1ohRsuUBb8KT+chP3gkwnoBhGhGSxU+70JNB76EAZbvesgUzWook0ciIEfq4wKaqk3bQBVvT5lQKdtClH5++DQwytdkJL5QkEXgyjtOj SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2018 20:17:11.0752 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ae7f22ae-a4a6-446f-f7e6-08d5f8b4edf3 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: BN3PR0701MB1377 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 bb565f556c2f..a10a8bb895e9 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -6283,6 +6283,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. @@ -6297,13 +6298,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)) {