From patchwork Thu Dec 21 17:33:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raghava Aditya Renukunta X-Patchwork-Id: 10128099 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 A3A2760390 for ; Thu, 21 Dec 2017 17:34:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 910E429CE3 for ; Thu, 21 Dec 2017 17:34:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 85F9029D1B; Thu, 21 Dec 2017 17:34:54 +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=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 032E029CE3 for ; Thu, 21 Dec 2017 17:34:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754599AbdLURev (ORCPT ); Thu, 21 Dec 2017 12:34:51 -0500 Received: from mail-cys01nam02on0044.outbound.protection.outlook.com ([104.47.37.44]:6558 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753884AbdLURei (ORCPT ); Thu, 21 Dec 2017 12:34:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mscc365.onmicrosoft.com; s=selector1-microsemi-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=cdmoHw1X25AMCo2OCrqx/wpf4wsCtXzpK16fUKYmqSM=; b=NzCxKBYOVrYzRUkW/oNCcX8OM/5IBPnP/61d6sYpvxdDxmnoqgU1qZu4V+TuGoiUKbsCDbFv4pGpfpD08P3U4zqyAW1cjSslplYikGLu/nhaPTJ6rOXO4Q2PWyaq19KR/Mx2FjkPVh87fEyihJpSpHiZz/CkuagAA0+JSRVEsTE= Received: from MWHPR02CA0045.namprd02.prod.outlook.com (2603:10b6:301:60::34) by BN1PR0201MB0739.namprd02.prod.outlook.com (2a01:111:e400:56::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.323.15; Thu, 21 Dec 2017 17:34:35 +0000 Received: from BN1BFFO11FD036.protection.gbl (2a01:111:f400:7c10::1:195) by MWHPR02CA0045.outlook.office365.com (2603:10b6:301:60::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.323.15 via Frontend Transport; Thu, 21 Dec 2017 17:34:35 +0000 Authentication-Results: spf=pass (sender IP is 208.19.100.21) smtp.mailfrom=microsemi.com; linux.vnet.ibm.com; dkim=none (message not signed) header.d=none; linux.vnet.ibm.com; dmarc=bestguesspass action=none header.from=microsemi.com; Received-SPF: Pass (protection.outlook.com: domain of microsemi.com designates 208.19.100.21 as permitted sender) receiver=protection.outlook.com; client-ip=208.19.100.21; helo=avsrvexchhts1.microsemi.net; Received: from avsrvexchhts1.microsemi.net (208.19.100.21) by BN1BFFO11FD036.mail.protection.outlook.com (10.58.144.99) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.302.6 via Frontend Transport; Thu, 21 Dec 2017 17:34:20 +0000 Received: from localhost (10.181.72.13) by avsrvexchhts1.microsemi.net (10.100.34.105) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 21 Dec 2017 09:34:22 -0800 From: Raghava Aditya Renukunta To: , , CC: , , , "Guilherme G . Piccoli" Subject: [PATCH 08/29] scsi: aacraid: Move code to wait for IO completion to shutdown func Date: Thu, 21 Dec 2017 09:33:59 -0800 Message-ID: <20171221173420.8213-9-RaghavaAditya.Renukunta@microsemi.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20171221173420.8213-1-RaghavaAditya.Renukunta@microsemi.com> References: <20171221173420.8213-1-RaghavaAditya.Renukunta@microsemi.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:208.19.100.21; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(376002)(39860400002)(39380400002)(346002)(396003)(2980300002)(438002)(189003)(199004)(48376002)(76176011)(50466002)(4326008)(47776003)(51416003)(86362001)(8676002)(81156014)(77096006)(36756003)(68736007)(305945005)(69596002)(356003)(104016004)(59450400001)(57986006)(53936002)(106466001)(8936002)(81166006)(478600001)(1076002)(72206003)(50226002)(110136005)(316002)(97736004)(16586007)(5660300001)(76506005)(54906003)(106002)(2950100002)(2201001)(2906002)(6666003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN1PR0201MB0739; H:avsrvexchhts1.microsemi.net; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD036; 1:kh4BnMp3xDvIm16RcKQ5LTpgjjX2md7u2LrpDwyNZMNWFvfw/u19m9is1NXG/Nmwe1FJqswmUX4LcJmF9Zk+LKidlZUCsILFu2IFG7zTfuRdZFwZ4aNh+volMihdjlTZ X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 97dcda8c-8374-4e4e-2909-08d5489911e5 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(4608076)(2017052603307)(7153060); SRVR:BN1PR0201MB0739; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0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XaTyKwm88mqRpda/ibm7Smewfa21HTySU6iULceUHb4+2RQz18i7U1PDs9K3+fYqYWR6+BubPW0RYQeQ6s/+dj6mXtJGxxmuHO5M8rhe0eWffP9J4yu+Sbpaq6p1Ap5TgC+FW/Q9RjiJTZ2SteaDKoq+dp27plCexGc5S2Ivq2f5gyo5IgxMGaQbO6D9sFFKHZxrWxY7SZLM4nPrjT3Ks7qLcm9ojNIx2pgENmlQw/FYOHUcQCJOyWFROyBtzIbjxFBAjH0HqOGGRqn7v+htHM/wZELAfqsWGRQcTJr2lXRv3qUxmfjVRL+oR7AFbZM03qh3hfIJoL0e9t8yl5bVzlodlE3i96qKOnIRkNJHQUFwtHtfxpSOpzZV4ZVqn/j+3+yTat9c/yhbwLw51FKzNqlEJeNhKBhejmpAuoKHrcb54m/erjByChCuL09DWlTjwmhm98rh3EIb1zucRnSBl9AIgs9Vot6965bi8GraQ8KUvKeO3Jbf5k5VbF5B5kszpVmaM0Glq7vdal7PT7jt/q0pAiCqSifZHUuMkBeatxs9LBk0OLcMjJ9V6hnvdc9/TdTM/1DgZ3y+VJyTE= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(72170198267865); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231023)(93006095)(93004095)(6055026)(6041268)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011); SRVR:BN1PR0201MB0739; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:BN1PR0201MB0739; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0201MB0739; 4:8rTj4AHHpV8cgMS3QxCW6PQS4HCldf4/8bMNS5yrE5sWnDxVle1pSm6YpwVNB8uRCwNQT58Cs5WokJmv7C0aEkMedPNgufhDnK1Qc6UtvkoW5e6PtGXO6JajBad4K1EGGk1DuiNSYAXZsFiJs1OpdS7QJ11G3UuiN9vjxUTLPHer027njhFgRWXyiCEiylS05zwTZ6bWEIc0Fh0GmQiyWbv3PYVbjoazIdX/3OknuoaI3RyNToRiavmOGGcauH/LZIaUiDxYrki0txQtg0q6LPWwgODGvs9Zmi3RRE1YwsGeXffSC1/EpNRJ0G74Ouvi X-Forefront-PRVS: 0528942FD8 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN1PR0201MB0739; 23:RsGe9Qfl8JD1UaFPXP6/Pqz/+aooBndi+SSwyeD?= =?us-ascii?Q?Sxu3rdQ6aec8tcylTY7nF61d5zv/K72btmHrNO3WnsyjRN+srWrIsZpBGGuy?= =?us-ascii?Q?/oR+0Y7JdN+p9wwXVRtfSyHb0JnMr9k34NcjjIDVthX381RIX4ScPX5xIUC7?= =?us-ascii?Q?DUPmoCnn0dGrigXHKviENs1iXgQ1wcXyKj3FzKnf1kT7Jztik4m7g2Wu3c+H?= =?us-ascii?Q?+NnUxh8AlN5ZR3qTjyqm4A1AUKp7rrXzCEPExqbTCFB32TlH6Al4Gimh9r5z?= =?us-ascii?Q?hNsAGRE6Df/Au699t3q1v34xg+ZH1JUExS5aV+N0ABcDSOO62XcE2X3rMQpr?= =?us-ascii?Q?X2MiJpYi/C1RsEW0sCeoC6/pA+9qmfN7pei132qjMJA4imAo3f65sMHDQHPl?= =?us-ascii?Q?8wRQ6A0iG0CTEXR3oripSJqnEr/hv+87meRtCVZxu443sos0hMpV9E/rb5xf?= =?us-ascii?Q?5XHWGE8buhaWOEbLYAbGzPdcdnvwgNYLQlDv5qVIUAaZCoDemx7AM+o6k6DA?= =?us-ascii?Q?L0xjuaQ91wCP2vCVI08Hm5u5ppQvetfmANGZ9Sgcx29uJVLSuSXgYPSVXz2L?= =?us-ascii?Q?L1all+ZrbTv9kVpp6Dr2crF+xqGFA9vHXGZF1TtlHwP7kSlOPCFu8CZuaj5v?= =?us-ascii?Q?2YtVJFmSmhdvFt2aYrv/Q0yI7ULAfe4jXARq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Rq+zouJvK1Yg79EdVeswabaFeA/c41jnw/VESPLXEw84+1URoACebTSJ/Ka0zGOs7OjaZI2xjDo+xodTmE=; 24:30AtzbjYrD09nwc0bMkuvtmMIUd+Pkr+3aLcmYhunPCn+UFzuntq9i9lQqNvSkA6m45tKKOcmYid7VK4J7Nq5IBbOQNNjCfMs2AUYlfzY8k=; 7:52nSwOkHkODV3z0AGLOowyC4IoTUFPoIdLfebZv0ZSYZhyzV0iZg3GSK0BVsbIVALCeqSI40BLCIv40Q5X/f0NM0Ayq9NpDaj0XkQCwfxlvfOJvcuG0QHoM73bW3ravk0OEs+TzdCAPS68i7BOoEWqujUeMjNc+QINmgDHA5LGDEv6bDnHhTv7DBZGrwUK2D5HnJNFWtn6mv/gntriRCGOoWeIWktme88v9uqtcdjjuTf3oSf8+ElhQIGuPDSrnd SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: microsemi.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2017 17:34:20.6944 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 97dcda8c-8374-4e4e-2909-08d5489911e5 X-MS-Exchange-CrossTenant-Id: f267a5c8-86d8-4cc9-af71-1fd2c67c8fad X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f267a5c8-86d8-4cc9-af71-1fd2c67c8fad; Ip=[208.19.100.21]; Helo=[avsrvexchhts1.microsemi.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1PR0201MB0739 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 Ideally driver needs to wait for IO to be submitted or responded to before shutdown. Move code to wait for IO completion into shutdown path Signed-off-by: Raghava Aditya Renukunta --- drivers/scsi/aacraid/comminit.c | 36 ++++++++++++++++++++++++++++++++++++ drivers/scsi/aacraid/commsup.c | 25 ------------------------- 2 files changed, 36 insertions(+), 25 deletions(-) diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c index 9eff246..0dc7b5a 100644 --- a/drivers/scsi/aacraid/comminit.c +++ b/drivers/scsi/aacraid/comminit.c @@ -42,6 +42,8 @@ #include #include #include +#include +#include #include "aacraid.h" @@ -284,6 +286,38 @@ static void aac_queue_init(struct aac_dev * dev, struct aac_queue * q, u32 *mem, q->entries = qsize; } +static void aac_wait_for_io_completion(struct aac_dev *aac) +{ + unsigned long flagv = 0; + int i = 0; + + for (i = 60; i; --i) { + struct scsi_device *dev; + struct scsi_cmnd *command; + int active = 0; + + __shost_for_each_device(dev, aac->scsi_host_ptr) { + spin_lock_irqsave(&dev->list_lock, flagv); + list_for_each_entry(command, &dev->cmd_list, list) { + if (command->SCp.phase == AAC_OWNER_FIRMWARE) { + active++; + break; + } + } + spin_unlock_irqrestore(&dev->list_lock, flagv); + if (active) + break; + + } + /* + * We can exit If all the commands are complete + */ + if (active == 0) + break; + ssleep(1); + } +} + /** * aac_send_shutdown - shutdown an adapter * @dev: Adapter to shutdown @@ -306,6 +340,8 @@ int aac_send_shutdown(struct aac_dev * dev) mutex_unlock(&dev->ioctl_mutex); } + aac_wait_for_io_completion(dev); + fibctx = aac_fib_alloc(dev); if (!fibctx) return -ENOMEM; diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index 32b8bdb..9840bd3 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -1701,31 +1701,6 @@ int aac_reset_adapter(struct aac_dev *aac, int forced, u8 reset_type) */ host = aac->scsi_host_ptr; scsi_block_requests(host); - if (forced < 2) for (retval = 60; retval; --retval) { - struct scsi_device * dev; - struct scsi_cmnd * command; - int active = 0; - - __shost_for_each_device(dev, host) { - spin_lock_irqsave(&dev->list_lock, flagv); - list_for_each_entry(command, &dev->cmd_list, list) { - if (command->SCp.phase == AAC_OWNER_FIRMWARE) { - active++; - break; - } - } - spin_unlock_irqrestore(&dev->list_lock, flagv); - if (active) - break; - - } - /* - * We can exit If all the commands are complete - */ - if (active == 0) - break; - ssleep(1); - } /* Quiesce build, flush cache, write through mode */ if (forced < 2)