From patchwork Wed Dec 27 04:34:29 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: 10133399 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 D15B96037D for ; Wed, 27 Dec 2017 04:35:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA1332D864 for ; Wed, 27 Dec 2017 04:35:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE8182DA5E; Wed, 27 Dec 2017 04:35:19 +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 403CA2D864 for ; Wed, 27 Dec 2017 04:35:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751833AbdL0EfR (ORCPT ); Tue, 26 Dec 2017 23:35:17 -0500 Received: from mail-cys01nam02on0045.outbound.protection.outlook.com ([104.47.37.45]:3552 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751694AbdL0EfJ (ORCPT ); Tue, 26 Dec 2017 23:35:09 -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=S01UtKGv+FMyHOGiiAp7Otk56zYpxiMtgy0uMfWbzOA=; b=RgoyO5DtmsUWxyE4Pr7Ccw9qGQBGvuv9R6aASWjL62m19ZzdwZqTQKd7C3l+TKwj4pjF53P2SufRfJJ2DGFdGkDSbdQxfZ2zvDDK0lxUxLZqIjcAZ3KiNE3ZoXC7/t4BjiVkqTmIPqFCDcrASMkWg8iiO8tXoPt9sKgOEO6B0wY= Received: from MWHPR0201CA0047.namprd02.prod.outlook.com (2603:10b6:301:73::24) by BN1PR0201MB0737.namprd02.prod.outlook.com (2a01:111:e400:56::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.345.14; Wed, 27 Dec 2017 04:35:07 +0000 Received: from BL2FFO11FD050.protection.gbl (2a01:111:f400:7c09::115) by MWHPR0201CA0047.outlook.office365.com (2603:10b6:301:73::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.366.8 via Frontend Transport; Wed, 27 Dec 2017 04:35:06 +0000 Authentication-Results: spf=pass (sender IP is 208.19.100.21) smtp.mailfrom=microsemi.com; wdc.com; dkim=none (message not signed) header.d=none;wdc.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 BL2FFO11FD050.mail.protection.outlook.com (10.173.161.212) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.345.12 via Frontend Transport; Wed, 27 Dec 2017 04:34:46 +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; Tue, 26 Dec 2017 20:34:54 -0800 From: Raghava Aditya Renukunta To: , , CC: , , , "Guilherme G . Piccoli" , Bart Van Assche Subject: [PATCH v2 08/30] scsi: aacraid: Move code to wait for IO completion to shutdown func Date: Tue, 26 Dec 2017 20:34:29 -0800 Message-ID: <20171227043451.27813-9-RaghavaAditya.Renukunta@microsemi.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20171227043451.27813-1-RaghavaAditya.Renukunta@microsemi.com> References: <20171227043451.27813-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)(346002)(39380400002)(396003)(376002)(39860400002)(2980300002)(438002)(199004)(189003)(4326008)(81156014)(305945005)(5660300001)(48376002)(50466002)(8676002)(36756003)(1076002)(106002)(2950100002)(53936002)(76176011)(6666003)(2201001)(69596002)(59450400001)(97736004)(86362001)(72206003)(51416003)(16586007)(54906003)(478600001)(50226002)(104016004)(106466001)(2906002)(8936002)(81166006)(110136005)(316002)(77096006)(57986006)(68736007)(47776003)(356003)(76506005); DIR:OUT; SFP:1101; SCL:1; SRVR:BN1PR0201MB0737; H:avsrvexchhts1.microsemi.net; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD050; 1:B/wdFWuL5rcm8SoOgxlvTs4g/tbhFHo0ZxJ9ZwYKRjxa7DQe0SQ8EQtAJZhKbMbzYglOj22QeN75GHYy0MVlB/kB1H7RKqB+1TCyz9E7GIp0/AqLnVp7rHX5poiSRPJZ X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e75c49ea-15f4-424b-cb5e-08d54ce328bd X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(4608076)(2017052603307)(7153060); SRVR:BN1PR0201MB0737; X-Microsoft-Exchange-Diagnostics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Fcvkem6MpLNDT9/oIb9sBJ8VvGRyoXzUFJjmG+PJJCHYJ5vYbWS4M8FYdOqMFv9qQaoOtJU84hFUd/H/uyfQHnXH2xfhVkcEXjwR2m2m/RluqCASlLn9+nHmjTCbekzhIYMqR/yQYXx5uS5Mln78Vp7RPD3tKt68GtNm8ckaDWmf+wKvAffG2IV1nPCfCaG8f1OJRjK+YOiQh5ngS3NR+J3fA0AtfWx98+mYCMB5s0B7OWFOnZ/CtuVjAyGX1Iistz9sRLYDJrqGADP/jv1kZMyoRrTiFUmvWLHGrQy3zFSpG4/M5+CJ5VdNf9cXeyzkTK8bWes2YsG0XrutvHGCk5f75lEn9t4CNTXGd4xGa1l7sXIjv2hfk9il1j8U3Y2UOk7AhFsAcscNZuvdBscL5sdKiAb1ucxY26nAQzH9T/lGnJ5NY8e+FPJ50e4l8Mj/UrdI44XA6lOXdgXesLlYSnjb8XxU/v+ZQXnn3KFyqukLeZI/8nYarmOee8RLFDozBSoPDZqz3UUSQubMlHeuXiTQ/FllTVxbj/JQ2MPnPY7KArJnkEtXgNybbrY1Y7wAdgxb8O94sowFhrs0e0pmjelVU7+smL+bqmQg= 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)(93006095)(93004095)(3231023)(944501075)(6055026)(6041268)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(6072148)(201708071742011); SRVR:BN1PR0201MB0737; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:BN1PR0201MB0737; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0201MB0737; 4:T79s3vt1eGYbKwNHd30Ww+59UR0Tc8zSoKQBvuezKZK3v+slq+OgwGnwukJNlo9sOeZZg7yD0HCv9LvNmED8GmCgya/cOpS9Wgg6LgjnHxzcJM50nAWVsA0MpH3Umb5LXsY/UJgjKJ4Znj6HHVUcl9edxbdrTkT72voEJ9UcS/2FRpbjd3XWQoRXns7DwpNtimWWxejRDtb0mIOyPzH8EhIq7cL62wAN9z2UaYy5DxYAbOROPw6Zuor9Y7l4T5Neeqglj4ZyRZfr2gI4EZwLXFnJK/suIFas0H/P7jo8GnNdIruQtSd6sgKLjqHu8q1y X-Forefront-PRVS: 0534947130 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN1PR0201MB0737; 23:/v4NQKJ3ytsISlcWo6cB78Z8EKMDjiv0WSp2OxO?= =?us-ascii?Q?NwD09/t9t6d/KtgFztY2v0RZC5GIVAnYpOgJ8I8rnJEkGUeCvrc51Ewg+8si?= =?us-ascii?Q?zCkftuui8/84OTdRmXP2nooH4aea5AT7OZIWu4OHMBELUCO7r+cC9cSyG727?= =?us-ascii?Q?7+DViSHslozQU5MviMtZ3ENFUIU+AfTDoP15Th7vt/fa/YuzpeM5kEP06AMq?= =?us-ascii?Q?zkMUgWB7RIZPZLAD8HHmXTT61YcFrdkbQiK08hYDy5CZ4Iv87REMvMkKAWkv?= =?us-ascii?Q?BdNURFdcNO0r001yGSmoudaIOfQZUMd/aJFK6IBxORR4PcVf4nwaiTYlSmvR?= =?us-ascii?Q?kjpKc780nAgZ+OWF7wVLar7VOEIsGlQaCN89WHmtO+e/j4WK0BH4cQbsgctb?= =?us-ascii?Q?yKSetMacoq5cJO6E/VqLzdh2Y1Ze5vfHG9+0LJHbsjtr18Ck+f1yg6e/GBiG?= =?us-ascii?Q?cl+zWgoyP94nAAlpbS3g4kPfWdK3VjVD8t+y7GzB6VA823PqaTfgk7PcCwDn?= =?us-ascii?Q?sOYUWAZgUuyEijFZ/pR8RWBJJTvY9eI27egdzN5gjfhHLirfRnHGoINuhL+A?= =?us-ascii?Q?uDW2AW0dN2XPbCTFh8k0++5mJWB+YWWfpsAdSDkglEtO29DTQkWHyg8xUlGY?= =?us-ascii?Q?PV5FEoqKOVpe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VA2O1plpd0oETBK2vYdJq0PiEMwdShCxzU61sPVBEFv7olCFTqL5PksL9V6Fku/2OGiuxhXWdVvNIdH/iayB9UuMLU=; 24:HlPPfD/js/4bPF1EcMM9Fa2+Hhc3BaKNON0uj+meEzv7FyhL19YFQTrk8s4K7zlc1Wewc0Og43ZCuLReQ+7INLyJPeeItZ4nmBg3BFJZzBg=; 7:YORRylWMBAEdZHxJH5cI4E7U2tjWVgXZu4UnrD0lWKdgg1nL0hAh2Gs4mz4N2Er748RMCu2Mx0fCUwA0x4+VY2WswsRSuk/+nhTpF3ym9ViCnItRCJps1i6+EtHrshUffnXsSBYoMjIiyLeVAMl/8w3erDmHpOMRTId7sH9RDdlMBlB2ZDqL73cnlXd9k+65+Y96K/pO8Wh8b6otLTV0VpHEn9IcHR0PzjbFILJ6ctYm5S86oqPiq6AfIAF1vpih SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: microsemi.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Dec 2017 04:34:46.4019 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e75c49ea-15f4-424b-cb5e-08d54ce328bd 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: BN1PR0201MB0737 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 --- Changes in V2: None 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)