From patchwork Wed Jul 18 21:26:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10533303 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 EE43C6053F for ; Wed, 18 Jul 2018 21:27:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCB7F29823 for ; Wed, 18 Jul 2018 21:27:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D0A1D29837; Wed, 18 Jul 2018 21:27:16 +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 24C1D29823 for ; Wed, 18 Jul 2018 21:27:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730255AbeGRWHB (ORCPT ); Wed, 18 Jul 2018 18:07:01 -0400 Received: from mail-eopbgr680052.outbound.protection.outlook.com ([40.107.68.52]:58687 "EHLO NAM04-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729702AbeGRWHB (ORCPT ); Wed, 18 Jul 2018 18:07:01 -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=NanGSRU2KqUEUpiz/ZZbc4LkBiPgvRR3yfQ+UNn313I=; b=NH7/vqYIsP7wvZOwV3/EE8qCP/0yuhpU6s+A1pZXsE+gJr6wK4FTPZgGqcPCarXtVPaDxHomqZ1otJ145mJ2yXlOEP9MU5TI4fC9K15pm2y6k7CjdgLwS5Ke6sdFh5Y2AHrDADXSLPHwa7Ls2IhbPcDJ+Uo/H8JNu9IyX3GFlKI= Received: from DM5PR07CA0048.namprd07.prod.outlook.com (2603:10b6:3:16::34) by CY1PR0701MB1388.namprd07.prod.outlook.com (2a01:111:e400:4c1b::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.952.21; Wed, 18 Jul 2018 21:27:07 +0000 Received: from DM3NAM05FT029.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e51::208) by DM5PR07CA0048.outlook.office365.com (2603:10b6:3:16::34) 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, 18 Jul 2018 21:27:07 +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 DM3NAM05FT029.mail.protection.outlook.com (10.152.98.140) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.995.0 via Frontend Transport; Wed, 18 Jul 2018 21:27:07 +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, 18 Jul 2018 14:26:56 -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 w6ILQuKK013396; Wed, 18 Jul 2018 14:26:56 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id w6ILQu6N013395; Wed, 18 Jul 2018 14:26:56 -0700 From: Himanshu Madhani To: , CC: , Subject: [PATCH 09/12] qla2xxx: Flush mailbox commands on chip reset Date: Wed, 18 Jul 2018 14:26:51 -0700 Message-ID: <20180718212654.13325-10-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180718212654.13325-1-himanshu.madhani@cavium.com> References: <20180718212654.13325-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)(136003)(396003)(346002)(376002)(2980300002)(438002)(189003)(199004)(76176011)(356003)(51416003)(14444005)(47776003)(305945005)(86362001)(8676002)(4326008)(1076002)(6666003)(81166006)(5660300001)(81156014)(446003)(16586007)(126002)(11346002)(486006)(48376002)(44832011)(80596001)(15650500001)(69596002)(476003)(8936002)(50466002)(2906002)(50226002)(36756003)(478600001)(316002)(106002)(72206003)(186003)(2616005)(87636003)(110136005)(42186006)(106466001)(336012)(26005)(54906003)(6346003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0701MB1388; 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; DM3NAM05FT029; 1:KxyQJ+/ZcfU/NC2NnxwCUWPbEah5fSbCFAhE03R2hUyUrnzQp2Tr8CqwHGybVuc72T7mNx71U80uLz4NrQ8uWutnHpE+FKDNQIVcYKPoKOGp04LAl5Z7CGhe2K0BTxYO X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cd0708b5-4dc7-4fdd-7494-08d5ecf536d0 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600067)(711020)(4608076)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060); SRVR:CY1PR0701MB1388; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1388; 3:gIsdUzrdg2uX8HjeeNHBa/ogDErXSWjHn/2L3AJFBiw3Q9vmV09aRTJlJVhkYD1ApN8NT9It/EzTPM6iBPtf6GDwUvydAISBiDXbp2I6qPLchSkgWtDg8mE4pu/TU3LtphTn3L24wqbcAHuBTk+SKfLzsaJxA3Lwz41kw6s0hlIVkevjp/OceqyHRJBj72ZuBogEtoXDHubZ/tG+EgZc14GELxL3iTgLVhaxzMYTRSiOte2OPUTng640ifJxG4eIYFOLWxKHlZ0lhk+7yKjjXpfqI9tnzTVrC2ipMzeTTeodCrch9AhN6fEj9kLVCzgOI4MQGB6sWPTdBabaFf+mwidkEc7d6jKwVdBITQNKr6E=; 25:Qmnixf98tyiIuCgtfEbdPqyFzZroEkuOlvm//J2toypU9c0Gy0dIBy+6QuJjTePFLD51cSf0tCvH82i23Ld9z6MbgAvWNJlQd8Qi7GHMfMm9AdAlYACn5Sg8g0pd6d7DqaNG3DUpH1NWTrfCiq8O/u5TjqDgc0SIo+2VrH7eA9gIxc+Y6IbSaG+NPYzxnEDNMGB9NrQDgJjJ7tLnmhxHjL86edzkG0jzSSZeeHGp4JKGcZpysfQTQfvrZweOxw2WQ+lZo1ccOUtamEjI3CaFQZso8msYSC3c6QopaZhWBi12HPYAOhHzEi0abJ8heAI9JkGDOyJN/6Aiy2Alugf90g== X-MS-TrafficTypeDiagnostic: CY1PR0701MB1388: X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1388; 31:7S3F64E9JKaDnCKBrA3IXMJOXPFDhM1aJWff2qK7gJw5nCn83jg0pdSwHcQZxhkk5XuE3cskhp/cdahHMJp9qLTcSYdft2joN2TmBHbNRK45/1UBWdUEgSDD3YpM7mQVLxZnqpg2lKAg6zg58gX1YO6AhKbvwUjNHK6qtA7sXwlNAsnPgPvodyEdHH/H4GuS10nmtzmhx7lXRj6tLBSncnTpQF8EUjPUpCUGMJYzs90=; 20:rCPBo7yjcud8f6KD+aR4swVzTtmD5P33LxoUmPS0ob8aMu66yHFE2u2FIeGEzWBD3ECy12eobbiv2j9e7T9zG04+/+I/v/JbOL1w7mqZzb4SwKKwbYA/aj4auk46uKVweay5Z4pNlLMu0ZfTX9lsxDLTn/MIdg8T0QmPKxdIvqGLE/MDkzBPM/7CoCAh95nsPLx3bObIBnfDONMLM+jG2o3afxovF02ogBCvQ1pcv/j3kn20HE02opQ2qESGpzJMAaI2pC9tF4S27B4HyAF9dgYK0/V3xXGNosdqtUxqk473dxsudn8IBb+mBgzAb499X8PejYcCkS3+hl3I9PzU4BqpkXQGV6JvQIxdNnt4US0LzjQRdyjSVZH70aduyiG69SxMkUTVTI1GvNJlnvZFRDYARr/aEvlus9o6ip5fdKhW/P3087/6mQtLrbulvCn9SMCy35F7qQvoswZ7v9rEGAfY2MMcRHDD//5xxDH4RdYiF/C13nbNQQQiiH2xpk+n 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)(3231311)(944501410)(52105095)(10201501046)(93006095)(93004095)(149027)(150027)(6041310)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:CY1PR0701MB1388; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0701MB1388; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1388; 4:RPR1pNAVAaZvAXpdTpczy5dkiWUFW/2SHpLUAXbtMe+CltpptsN47xK1dxWp/AJQTCe3WS38J/isqqifJwYix2eJQssaVp529Dv/fdydRuhZbMLpuThP7zG/ltPQKE6SqmEWldehXkAoarWAT4t3Ufgma1nH395M94lzA/qrQlarHQxsObDEO66Qfj3GNcSo8TQqmFYQ89wki5glqpmQMC+cjIY837qIYXfZJXfmyzIkGFOSpKwOwl1dm2j5SCsy8cfppqCO6lt+KTPsfxKoFg== X-Forefront-PRVS: 0737B96801 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0701MB1388; 23:HdA4BfMUs7FLW0dRzMbEqjrooqrD9ap9FURX4di?= =?us-ascii?Q?kqKJeOkwzfetwDk1y4lW2BJFX2f36mZlDG6QbtUA+Rj7Q2/kiITbSSp6rPUA?= =?us-ascii?Q?55HJ0UkhpL7kJWsbjmQJ9GT5G4eS8Jxe7090jgfYaSJJdgamoGkV0d8jntDJ?= =?us-ascii?Q?F1FB0kBtYZ4MkOq5c/VKd93D2NHlJfmclNTvrWZSkpwZf4ZKLn/S6Ri0xs25?= =?us-ascii?Q?NpVPfLBDRFeMvqhLbsSELwbQWais2sMZtTgwokpcBj8ObCZGu7RmkojBeAFd?= =?us-ascii?Q?37yNm/QiY3o1rSHPJ1ei2l5JmT8kgDS6ueEdw5JsZEbudU/hmZVDiESb+dC9?= =?us-ascii?Q?j6ibnh1WQa5w+HZ66xRsVcabPqdiQZcIbCastkBQx0G9u8XQYrQzkn/OV603?= =?us-ascii?Q?M7MZHxVx8+ojCATIhDbv9qpxJQh2rKzpY90u5k1VPDwEZeSZpgXJCMXxilKX?= =?us-ascii?Q?BVgOjlCaV6zA3ys3uOmnPOsvjfyqjaKAIY9bGcZzoVLYbbNh8BO0ewUH5FjV?= =?us-ascii?Q?rZVeTtVsT8bkOM9PE3Zxtqa36H3crV4Utb2bfLlZDXi4FqMM/q9o7jAmof7s?= =?us-ascii?Q?Ubq6rMULNJMHXKrljFsfLy+L6PwxmSAfuT2HCh5+s742AOPX6vxOzdbZ2weC?= =?us-ascii?Q?EBt/qeX3Qn37tndC/KIXf95Fm0khuqo3fbU6zmIL1dLcd4/mpgJ6xvwXwRVv?= =?us-ascii?Q?K5tCaJSyfgOHs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-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2018 21:27:07.0441 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cd0708b5-4dc7-4fdd-7494-08d5ecf536d0 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: CY1PR0701MB1388 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 | 4 ++++ drivers/scsi/qla2xxx/qla_init.c | 18 ++++++++++++++++++ drivers/scsi/qla2xxx/qla_mbx.c | 35 +++++++++++++++++++++++++++++++++-- drivers/scsi/qla2xxx/qla_os.c | 3 +++ 4 files changed, 58 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index ee4d1f4fdf95..9a98f1c73f5e 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. */ diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 78d9c96ffe78..a08502eaa789 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -6390,6 +6390,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. @@ -6411,6 +6412,23 @@ qla2x00_abort_isp_cleanup(scsi_qla_host_t *vha) 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 6e80c9fe71fd..4fb2ca41d7b5 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -167,6 +167,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 +178,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) { + rval = QLA_ABORTED; + goto premature_exit; + } ha->flags.mbox_busy = 1; /* Save mailbox command for debug */ @@ -231,7 +238,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 +248,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 +262,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 +270,16 @@ 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) { + 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 +293,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 +308,13 @@ 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) { + 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; @@ -304,6 +330,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) { @@ -489,7 +516,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 e6b65933fbbc..6bdb9cf38b77 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)) {