From patchwork Thu Jun 7 05:19:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10451157 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 53C1960375 for ; Thu, 7 Jun 2018 05:19:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4401029653 for ; Thu, 7 Jun 2018 05:19:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 389C329769; Thu, 7 Jun 2018 05:19:57 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI 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 2EBEF29653 for ; Thu, 7 Jun 2018 05:19:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752567AbeFGFTr (ORCPT ); Thu, 7 Jun 2018 01:19:47 -0400 Received: from mail-sn1nam01on0041.outbound.protection.outlook.com ([104.47.32.41]:12320 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751556AbeFGFTm (ORCPT ); Thu, 7 Jun 2018 01:19:42 -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=RviboREtSl/msJWUTspkfAazZkWx43trPHbBUilYnZILU+kwC7Ri+s8MkpcdoE+vDxVYdy0nA6Gfx/ItT00YE88cjPDJX5N//ahVsKqkvcRwR20GulZSuxVQHDlIgG1T/t4ObkEy02LGNQJCabqI8LZ0VPCfOwA6RQMF9VEPLbU= Received: from DM5PR07CA0106.namprd07.prod.outlook.com (2603:10b6:4:ae::35) by DM2PR07MB1516.namprd07.prod.outlook.com (2a01:111:e400:50c5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.820.15; Thu, 7 Jun 2018 05:19:39 +0000 Received: from CO1NAM05FT060.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e50::203) by DM5PR07CA0106.outlook.office365.com (2603:10b6:4:ae::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.841.14 via Frontend Transport; Thu, 7 Jun 2018 05:19:39 +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 CO1NAM05FT060.mail.protection.outlook.com (10.152.96.178) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.841.6 via Frontend Transport; Thu, 7 Jun 2018 05:19:39 +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, 6 Jun 2018 22:19:28 -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 w575JSej028011; Wed, 6 Jun 2018 22:19:28 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id w575JS5A028010; Wed, 6 Jun 2018 22:19:28 -0700 From: Himanshu Madhani To: , CC: , Subject: [PATCH 09/12] qla2xxx: Flush mailbox commands on chip reset Date: Wed, 6 Jun 2018 22:19:23 -0700 Message-ID: <20180607051926.27940-10-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180607051926.27940-1-himanshu.madhani@cavium.com> References: <20180607051926.27940-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)(39380400002)(396003)(2980300002)(438002)(199004)(189003)(486006)(6666003)(305945005)(47776003)(1076002)(50466002)(44832011)(336012)(80596001)(48376002)(69596002)(26005)(15650500001)(8936002)(5660300001)(186003)(446003)(476003)(126002)(478600001)(2616005)(106466001)(87636003)(76176011)(106002)(11346002)(50226002)(316002)(42186006)(16586007)(54906003)(110136005)(2906002)(72206003)(51416003)(36756003)(4326008)(356003)(59450400001)(81156014)(81166006)(86362001)(8676002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR07MB1516; 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; CO1NAM05FT060; 1:PnuNuDGFqJFz/BbR/byATuGuHuLwZ6Zi1Q2LidgvVCZ5OHJ4IBgJuXWygJCGj4QOnKBtSoRplW2J0o0tH0J4IbQWQCjlOHO/RkW1B+F/cnBf5siDcqW+t4/yM6e7bSih X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4608076)(2017052603328)(7153060); SRVR:DM2PR07MB1516; X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB1516; 3:OmATTDkT5MID/VsSX0hV21qkCc70+FGPi/lCO3fIT3OXIQ6T+rblo4irEYBQC65eSAQ6/5EADLNGXe/zEPTXNpl65XH9aLd1zxUbCjaf2vrfWNBBzi/0HfwQjWqdi3Ts3Iz45zEv26Yz2Yb6Br5W2if4veKKkRhBe2O/GdSK5h9OncbPEKW8u/0kfJZTyjzk88iPjVdE8s7UhK4Z4eG2v+BvPUdw1zhdq0NL0yslK+RlmcXCbSP3IA1ZKcd3Kozk1f/t1azCpspVoDF6rv5WoE9mznKOjCdz8lT8r6Kel79qS/qqWlMeseGLTAU0noC03c/f4VNAq9tTjhyf+qTgyRALrfZK0TotS14BXYH3CjU=; 25:SVIcmWseLE3FoaR8hy6XgWKPNdk7evfz9Vg1IAPpOxCpE9ww7UOQUhyrC0m3mNnAG77ofFDb5aHKqyZmYNP2mOKVoRdF9msmeKARCJLDwaPQZ9+fdmeXaRn9Mn3PuSzUbDNuvQ91i/p2FxgRxC87Cl5ptvfWX987HT5xTp2pDfKsm251idfqKywHYNrUu9kwYZXRScfPpynL9rAG+NuCm3c9fK5D1+NyLEDZXd3jdUmLxO+pKzJj5aUtgefmmitCF7i+mmqzaV17LYIwxb72OA59uHkmihqBGQNCi3O526Ep6z6C5XWcjdUQovpj80QzstHQLlryW1+RITUVwAEe3A== X-MS-TrafficTypeDiagnostic: DM2PR07MB1516: X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB1516; 31:6h4VPrGW82hNWa5o/p+9YB/9t1/lZmqGPV2iDDAjsxTE19UlQq/+fII9c2H22rea9mU5fu+ymwT9Q7o4qfRtg0p36CQslUbQ+6RtbBYkKhCBMjXfJROxvcfJ/O4aRKlRGBCktHIZSZ1arVbwi1uZOYOn1VjDsAWv2ASi0nwa2YZmyzM2/zqryYz7D92JkdIXNrg3jvRwRPbarV2OwRmLwAeBceWyYqcRXWz84B1Yu8A=; 20:xbHNFuzQ/nXAizeerxXrtpeyWF5U1mRPMeC9g3v6fiSGwjs68VKWXwAa/tRBecssh+MT0rq0aDF2FNwpsj7NBlSwrTsnK2vs2F2iy/nJ8aDNBeopXWP18ssaedI28Yv/k4luznWpfRasSjAuNeKAgIwn3DhWE+r7rar2b7/3wY3U5UIdTFKyqPFxOXoMWO6ciPsQU2T1OxPBAtP33iKTEF9sqGaIP0ArKEqSYStJXma45e+UxwpaKzR7khQnt5CfKjyOHmhLSFGB27wkXwSKJVBu4Mw3+sAO6LwWxM7KYStUJgyeC/ts4Eh6snTB0MIGs804ys1IsIMLUdabiTLTXECi7IRh9YNWjXP3XJn88bGap87yVWoydDkpPVaRqsLqomtTtIKlYY2uVdyj044X6A2Vea1PwDXGvbSTsAHTgOJSq202YElHteHhvDxZ/tsTCs4iHbdIBppg98inzKv2LuLEI9O9DWAahL0DWiYlag14Kk5IYYJ4Ovneav6EMOK8 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)(3002001)(10201501046)(93006095)(93004095)(3231254)(944501410)(52105095)(149027)(150027)(6041310)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(6072148)(201708071742011)(7699016); SRVR:DM2PR07MB1516; BCL:0; PCL:0; RULEID:; SRVR:DM2PR07MB1516; X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB1516; 4:2jIt5bNJNdNgkpJF4y5aUT5nypEZqm2juus5KLFGl0bDMntI/YzVebsaGpG0ww1jkAAAMR9fkU7bfmMjEGQdYameF4dAo7r/UdONs0vb+aXtNdneSIhQLAgtN4DGDl6vm+TE4LKUJWHYD1Ch9YFzrDlXBsevmyg21I/OjObSChUK9IhGKtD1AVHoVM3m7P4FqZxLNcA8guiYBuNz/wruW+jS531S1l1MPPGLOrIL0XG24FBBsd7djH2NKjLtKGrO0sYNamHSxlICcg8OfcBPqw== X-Forefront-PRVS: 06968FD8C4 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR07MB1516; 23:91HX0OZLrBmZGLOcL/Fv1oAfHRhQ2Df7m/xKRVAFI?= =?us-ascii?Q?wdO4AsPmPNRIL7vyrP4Pxeolb7Mi8ut83yK2a+veL5J5nrnWYTWPrT8gs3YR?= =?us-ascii?Q?FZMyq1xSygcZ4lnZvCIIb74R3IKG4gorgdt+k3fIRQxcBao1wtyLwUlr987w?= =?us-ascii?Q?c+lTqLCU+EKZdkmG+WYRuPXHVvS/xbMK+o+knVequOoy+lUQi4IuaikDgaUl?= =?us-ascii?Q?sSfmc2kApOdszAz9L7wMjmaNoVNX01e2Lk53DeLdCMCSZoQKXO1UQZ5+sJd5?= =?us-ascii?Q?bUAWCffEbF9dgBqESiext34o8FYfnra6Jhxaz4IMh6UR3NNuH5QEn4bQ2ZHe?= =?us-ascii?Q?qsiYSb4jxN59343gHuSU+i7F8XInOI/+qWXJqT51e9en1oo6Y20ft3qRqFzj?= =?us-ascii?Q?41qT5AQOnwA2ErM/RcqkK4xej//4LG3XHC5lkXW84DbSmdLrKPMrztvz8pe+?= =?us-ascii?Q?yYTYS9lMBEb5syxP551iuK+eubZxYBqRg0rquq3VFWCukRhjBLi1BbU3MnLD?= =?us-ascii?Q?35g+E6x5Fr7oQ4ECtiLkSPI4XbnDbXobVVp+yIngRKGIkyIKgi5NhknqJ/ZP?= =?us-ascii?Q?Jzc2w0cidnjlXG8mnEbOzxp6hRxZzHIBlwBsjZxvpMrhJcvqWxif4g9aatEo?= =?us-ascii?Q?hGHSim4Zw05CHpeO6b+nT90x9jkqiU+9hPiwJ1Krf48aUEk9hNmFhw3aVRkU?= =?us-ascii?Q?Gi7CG6ihrykDcCX2HVoR53r3EVXIW6fumHgvDVoxodDaUvRSROo8q+YVMHq5?= =?us-ascii?Q?3CGlA4pi2dIAjSMaKNekfxlQb7E3G7BlVcGEhT/qjcR3Qe/KtpEKHCKfpwhb?= =?us-ascii?Q?GcRSavbQQGkouGspdr3PT7YtaHKVmX8EBwEy2ihlYNgk+9rEGby1JgL05hlR?= =?us-ascii?Q?pMCNB+DiAtokMsxgDdxYrB4FRYKV5DHOPhAaSw2h4saY31ncXbXGv5vOlpm3?= =?us-ascii?Q?/5dc+YqyETAVOy7UBtVRzKcpJhP6oh6X5raSDlY4E5vspQbMDkQ4RpQ5vsLb?= =?us-ascii?Q?gFrP65zJt+Ulgvf4L4mpuZF2TvFgZLK3rwSpNOnipExc9NZv5AwgpzJlaQU6?= =?us-ascii?Q?mXlWJ4+2CZtB8RkTSmzzFqZRPqX0gMRgiIjR2ODKJiOtTwqKKngUb7X8nDFu?= =?us-ascii?Q?hPcTcZsy2pk7CE7/yVTt662GNpSm/6IanNoj3tNvLsqXy1xoue3GIER2cTPh?= =?us-ascii?Q?UHKK87D+amx9hw=3D?= X-Microsoft-Antispam-Message-Info: SgM6f5JaKOPVuRoB1G9XRt+Wuz4+TptsAVxLVxEcfF+W5/j9gqoqP5KKmwC5+g9F6D1OVj2aFB5aVmTuHU4OSXM6o3VDZnyVcdkggWeVVq0oILKuJOBsRY3WCh9BLPxrMRMurv4uMpTITpz/oR2/YnGFaBc9Di93zGGZ7yfHBx1jfYMq1qeVE45WgXknjP5U X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB1516; 6:8W3D89l6FNlJl4+QfxZvQcCZzkfmU4XfoAgEzlLgVdPQHvoz+SDgpqq7Ed+HRByzFL+70r4a9/J+WBzsudg/UjY7tNW1/BnRusQaSF8qE5UHHGBG4eBB/dk3zZ8XsPZc55tSWhlRNVwaYcjNcZJJJhGMZgar7/ECJkJ0EEBReAPlw72w9Qf+b6hiVGRxLlXfVCYX9ko/elp6OdHi901hhm8KehvL2DnONIFQDYKZdS1faNyaokzz1RFc9mAra4sRTS7FKZ2nJv9n1PX+znaIlEO+x+zHS7yEIIDC8bLmK8VHb4jmsA1uYbxFDEwRs8kI6u1s9+lBJpBxPUAVKaSByYvnnOqVIq3SjupkgfyqrTqAb3+xptExZ3v+SFfbnI98V7laVbvHARtmvDSaQMIyqRTSBEl5smRMelCKK7RToBWBIliesmTjGYVLhEo4A1mMqrQAmyYkRjTu6DpbrvqHjw==; 5:9Fspqidw6ToDjkYGGuUI9qe3rul2ezKzUlbSJ5NeV2C78tXGO6HdXM3qXVgfgHiW5jN9lOiKyS5E4u1BUfbtvggcpEiep4PhWvOneGbi22pLZ3WQ8WyhBzjxWBXUFDDaFQ+c6/u202Qis3fKW8TmDz6clWBvEQmAfFmKyzEZd2E=; 24:qmXCRfyGWU16dhc5oVayBm2mwRFwVni5g+k0HmQ9ExPtEuk56DFyiLmFKeI9npQouls3U/+Zw9dfzFE27Qn2+BY+SguhOP/iAVeY36Pcei4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB1516; 7:V0QAsrfoJJiJHDo3u6Hp2z35PJGc+m/FgFTRrX8JUSPjMlVk/Oj7gjl7kF5eIi9jFLSuCct/qi55QO65Q5/9HaxJAvIKDr6rB71xZMMA6kaYxVa6LEdgUZgYYpaTwtliQPUuN8xqgvz9vJNVYE3/0jpuBb8tBA9dt7UlDX9w1rCN5Kr1GgDVVWewG2s8wT0QU6zj83wJPKMj4cmjnUTGE3068N7Z6Dvw5Hs5cZxWj0JkLfjYGVeRqK0k5AGI+p7w X-MS-Office365-Filtering-Correlation-Id: 282eeee7-ad90-49dc-75e4-08d5cc364497 X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2018 05:19:39.1370 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 282eeee7-ad90-49dc-75e4-08d5cc364497 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: DM2PR07MB1516 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)) {