From patchwork Fri Dec 7 22:29:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Don Brace X-Patchwork-Id: 10718967 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 98ABD109C for ; Fri, 7 Dec 2018 22:29:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 848CC2F0A8 for ; Fri, 7 Dec 2018 22:29:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 781802F2E3; Fri, 7 Dec 2018 22:29:38 +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,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 2072E2F0A8 for ; Fri, 7 Dec 2018 22:29:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726095AbeLGW3g (ORCPT ); Fri, 7 Dec 2018 17:29:36 -0500 Received: from mail-eopbgr730074.outbound.protection.outlook.com ([40.107.73.74]:39200 "EHLO NAM05-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726073AbeLGW3g (ORCPT ); Fri, 7 Dec 2018 17:29:36 -0500 Received: from BN6PR19CA0110.namprd19.prod.outlook.com (2603:10b6:404:a0::24) by DM5PR19MB0938.namprd19.prod.outlook.com (2603:10b6:3:32::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1404.22; Fri, 7 Dec 2018 22:29:32 +0000 Received: from BN1BFFO11FD017.protection.gbl (2a01:111:f400:7c10::1:133) by BN6PR19CA0110.outlook.office365.com (2603:10b6:404:a0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1404.17 via Frontend Transport; Fri, 7 Dec 2018 22:29:30 +0000 Authentication-Results: spf=pass (sender IP is 208.19.100.23) 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.23 as permitted sender) receiver=protection.outlook.com; client-ip=208.19.100.23; helo=AVMBX3.microsemi.net; Received: from AVMBX3.microsemi.net (208.19.100.23) by BN1BFFO11FD017.mail.protection.outlook.com (10.58.144.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.1404.13 via Frontend Transport; Fri, 7 Dec 2018 22:29:26 +0000 Received: from AVMBX3.microsemi.net (10.100.34.33) by AVMBX3.microsemi.net (10.100.34.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1531.3; Fri, 7 Dec 2018 14:29:25 -0800 Received: from [127.0.1.1] (10.238.32.34) by avmbx3.microsemi.net (10.100.34.33) with Microsoft SMTP Server id 15.1.1531.3 via Frontend Transport; Fri, 7 Dec 2018 14:29:24 -0800 Subject: [PATCH 13/20] smartpqi: check for null device pointers From: Don Brace To: , , , , , , , , , , , CC: Date: Fri, 7 Dec 2018 16:29:24 -0600 Message-ID: <154422176445.1218.16736923839560332932.stgit@brunhilda> In-Reply-To: <154422079293.1218.12539829857034151457.stgit@brunhilda> References: <154422079293.1218.12539829857034151457.stgit@brunhilda> User-Agent: StGit/0.19-dirty MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:208.19.100.23;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(7916004)(376002)(346002)(39860400002)(136003)(396003)(2980300002)(189003)(199004)(33896004)(106466001)(47776003)(486006)(186003)(77096007)(97736004)(26005)(44832011)(478600001)(476003)(103116003)(2486003)(23676004)(8936002)(356004)(126002)(69596002)(8676002)(68736007)(81166006)(81156014)(76176011)(9686003)(316002)(50466002)(230700001)(16576012)(58126008)(106002)(110136005)(53936002)(5660300001)(305945005)(446003)(4326008)(2906002)(86362001)(11346002)(33716001)(14444005)(2201001)(336012)(921003)(1121003)(2101003)(83996005);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR19MB0938;H:AVMBX3.microsemi.net;FPR:;SPF:Pass;LANG:en;PTR:InfoDomainNonexistent;MX:1;A:1; X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11FD017;1:AadgM7dFmj8XVCmpuuBuVE1KLN9QjMlJo7cPj4t0fS+oChzkJdrc9x7d+ck0AMEyOni5Y4bEKWAyHXK6OP+iva1bxN4NWJxcr6UCHtq39n2AVEQpivE9cF5yN/DeATlw X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e095ce25-59c5-47df-8fd2-08d65c93725b X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4608076)(2017052603328)(7153060);SRVR:DM5PR19MB0938; X-Microsoft-Exchange-Diagnostics: 1;DM5PR19MB0938;3:brnX3KWXVFcnper6n3I4WZw+B0Gs6XeTp9ihJtHLqteW31cCMrKuht7dHrhwI+1ynnOKkfLIE3SB1HHdqqEvCfbAtmMtGVBxnu0tO2DlW1egeJbqrUvDFMKA/V/p+KnMyXrLSALjmMHNSSwoHwO4IJNBTl7IHTvLdsA7/BLF9/2DUD3ylC8aqycrO4UCL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yIUJr183lWzVZdADeHBM5xr1kzsKUYtZqZVyn+7h2N4ATpt//CEdr5RCXjlrbSk/MhDlGfyv/FoAzVjwGLD0lN2hIVKJulakLLn9tvhSSRGtCcdSvR2QNthqLQhPohzjyVKAmx9XBOloULjzKxTiEQWKeFFdimDlwLtI3cTKt5/koYqApA/ERsqkEgM1mJNix78msPOjNGPEKhnOB75FzRjgvIy1yJvy9YUImeFjKefTGVdlCIw9bdj0SSWqHxJyt98yRLbUz+huxS7VXayDv4+m/kwwy/aKHzMWCnZD/4oL1vJzxOPk+pH9cOO5Aozb0O68bOe1SVonxEsrpVdmeC2cTc32oStZk= X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93004095)(3002001)(10201501046)(3231455)(999002)(944501520)(52105112)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123564045)(201708071742011)(7699051)(76991095);SRVR:DM5PR19MB0938;BCL:0;PCL:0;RULEID:;SRVR:DM5PR19MB0938; X-Microsoft-Exchange-Diagnostics: 1;DM5PR19MB0938;4:XfhYlu7Ptewhiv8S7ycB+6lHr5wXjiQ0QuHCdPW+BnvEEZg20pZWue60FmOwyq3LmkwdXIVPNwK1tLXWq+8GZHlsMyPeGsBkgfAfAIGP8fdAd3Qqq3dwSooBhJvmNXnFXXP55M+wT/N+Dyz4J5ubNJZtEXAaC8rVfPuGeZhy7BZzaFjb/6ydijxviOksM9szw6pqTaKdMDrCPxkBBGgQTz7G0h2Aq5XEJE74ejm/QZ9HgamWmCc7funTHhouXspaMof3fuyGV9sekBuQXA6zHg== X-Forefront-PRVS: 0879599414 X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BDM5PR19MB0938=3B23=3AVyBe/+l?= =?utf-8?q?3mugPS5Jnk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8iuxFJ3VaKD9uIKIbU8B5slNFnOkedq85L9EmXpoTUZu?= =?utf-8?q?6YpTrPk7/BG5uac00RBHLOCue0a/kxDRslHM6lV11B0jsKiNCIHwR+n7oZgz7IzHB?= =?utf-8?q?A6x42E7RLb+zzgszHHiHBzIItWCrhZGQNbN4qJnyaZzX012gTVShKe290H4zQAW4E?= =?utf-8?q?2aCtelEbnOeOESAM7I5jTAfTjO1i/B8+yEt9TIShid5qgwgYVRv5JBMFd4o2BBnBk?= =?utf-8?q?MwMjtGyV1ran1839N25RwPJkN8z1eXLczcHNvEcEPgyUQa4uscBP8W2KBj8OQ=3D?= =?utf-8?q?=3D?= X-Microsoft-Antispam-Message-Info: 3Bdp6eyHC5pIaebFeqXGMNvRnZd/XeoofPig5zmPvTptiXYkjeUIllCD37164dDUqfTSyTNIyvUGG5oZaoOdCpfZ/8YXyqSizK8TqR4bTigrxFhA+EYBUNn+OFnQwSJx2GicWR7Zcq0um31Ewisv/ZTP0zxFpyMHCXJx3F2VdQd9XRdAmSgqrgmzum4yjzfDXR0GBwcHg0cQYqkB6uhopNU+hkNDEhxeibdxHsRWeDeXROgy/wM4vyrgN4vcOuosLANUD5dvg+/jtCUD3P19CUf6EpBRtuQNWrRH64qTgqXB/mSBYjMV76SMesgjTn44A5aEflcV7Z6fsotdIZOFD1mkQPsYsb6wXW1vXoU4v84= X-Microsoft-Exchange-Diagnostics: 1;DM5PR19MB0938;6:VhjDLi17vTBrRjVvs7y6X9E/LMHA1jp+At/toKJjuNgy5PeZpQDsgGuKwshlXWtnQ9vBmU9CwWZvmtuaDoUnbrnau0NzOX/T7wMDqubzXQAQVf/KixAGj9mV4zY4dw5pnqwP8/fze2YCpf0RtC+OHf1UPxsCygxGvL1wFf2NXBi21KV9tmDWrTA0fDQzEp5xWKAtQUWivMUie+HAqoQRiZt4j4NsTh2Gd0Sgc0SuNmv7Xd7+2GDbUe5XppLK1A/cdb5dSXPcVuhaAgLWi1eywkcAfw4D32XCWux266iC8fb/BPyTlP579lz69NatAmt55Q68UvAAKbjDA9sOQTpbHFJvRbf8Zk/G0Z/U/jczxiUNrXJgU0aZepJh8RSvn1lU7wQ3MXEYdzhDwHoXNgoLujb+Qw9hEDSwfvSihZnnHfkRZ42TMF4CQ6FmehcPYLYikESAy26KPMoxmQiiX+iDsw==;5:O7sMBsBQDb5UNRkejcDcUz7yIB3jedstBmzm+PWflmDT1IlugCyMLnq7D/+P6fUxLyRKWmvLToxIEQbRJ8aPVAedoP5tlBL4iNcsqND8NIf6DC3uLw13ucm5OwlQkZCsZq3PYkttzo7NKqcAi3INAM7OwxjKrnj2uD6BP4VZHlw=;7:ZVoUPvLAvmGEif0QMHFKcVOMqiBLqEtfVodv9nmWKItMogeapxf6s5MChOCnDTKjE8ULhRkWYF+DdxAVXmJMksMUPFZoy4Dy4wHANjoUDcsO8GM7NKdo1uDbLxQ8aaDBh7Z62DIZgVFXGwSWn74kAQ== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: microsemi.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2018 22:29:26.6647 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e095ce25-59c5-47df-8fd2-08d65c93725b 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.23];Helo=[AVMBX3.microsemi.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR19MB0938 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: Mahesh Rajashekhara - wait on all outstanding I/O to complete before the device is removed. - check for null device pointers in IO entry/completion functions. Reviewed-by: Scott Teel Reviewed-by: Murthy Bhat Reviewed-by: Dave Carroll Reviewed-by: Kevin Barnett Signed-off-by: Mahesh Rajashekhara Signed-off-by: Don Brace --- drivers/scsi/smartpqi/smartpqi.h | 2 + drivers/scsi/smartpqi/smartpqi_init.c | 65 +++++++++++++++++++++++++++++++-- 2 files changed, 64 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/smartpqi/smartpqi.h b/drivers/scsi/smartpqi/smartpqi.h index a39c324dedab..4f52b5be3693 100644 --- a/drivers/scsi/smartpqi/smartpqi.h +++ b/drivers/scsi/smartpqi/smartpqi.h @@ -862,6 +862,7 @@ struct pqi_scsi_dev { u8 volume_offline : 1; bool aio_enabled; /* only valid for physical disks */ bool in_reset; + bool in_remove; bool device_offline; u8 vendor[8]; /* bytes 8-15 of inquiry data */ u8 model[16]; /* bytes 16-31 of inquiry data */ @@ -1063,6 +1064,7 @@ struct pqi_ctrl_info { struct mutex lun_reset_mutex; bool controller_online; bool block_requests; + bool in_shutdown; u8 inbound_spanning_supported : 1; u8 outbound_spanning_supported : 1; u8 pqi_mode_enabled : 1; diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c index c5640b379505..5f7ae5946ddc 100644 --- a/drivers/scsi/smartpqi/smartpqi_init.c +++ b/drivers/scsi/smartpqi/smartpqi_init.c @@ -74,6 +74,8 @@ static int pqi_aio_submit_io(struct pqi_ctrl_info *ctrl_info, struct scsi_cmnd *scmd, u32 aio_handle, u8 *cdb, unsigned int cdb_length, struct pqi_queue_group *queue_group, struct pqi_encryption_info *encryption_info, bool raid_bypass); +static int pqi_device_wait_for_pending_io(struct pqi_ctrl_info *ctrl_info, + struct pqi_scsi_dev *device, unsigned long timeout_secs); /* for flags argument to pqi_submit_raid_request_synchronous() */ #define PQI_SYNC_FLAGS_INTERRUPTABLE 0x1 @@ -317,6 +319,17 @@ static inline bool pqi_device_in_reset(struct pqi_scsi_dev *device) return device->in_reset; } +static inline void pqi_device_remove_start(struct pqi_scsi_dev *device) +{ + device->in_remove = true; +} + +static inline bool pqi_device_in_remove(struct pqi_ctrl_info *ctrl_info, + struct pqi_scsi_dev *device) +{ + return device->in_remove & !ctrl_info->in_shutdown; +} + static inline void pqi_schedule_rescan_worker_with_delay( struct pqi_ctrl_info *ctrl_info, unsigned long delay) { @@ -1487,9 +1500,24 @@ static int pqi_add_device(struct pqi_ctrl_info *ctrl_info, return rc; } +#define PQI_PENDING_IO_TIMEOUT_SECS 20 + static inline void pqi_remove_device(struct pqi_ctrl_info *ctrl_info, struct pqi_scsi_dev *device) { + int rc; + + pqi_device_remove_start(device); + + rc = pqi_device_wait_for_pending_io(ctrl_info, device, + PQI_PENDING_IO_TIMEOUT_SECS); + if (rc) + dev_err(&ctrl_info->pci_dev->dev, + "scsi %d:%d:%d:%d removing device with %d outstanding commands\n", + ctrl_info->scsi_host->host_no, device->bus, + device->target, device->lun, + atomic_read(&device->scsi_cmds_outstanding)); + if (pqi_is_logical_device(device)) scsi_remove_device(device->sdev); else @@ -5042,7 +5070,17 @@ void pqi_prep_for_scsi_done(struct scsi_cmnd *scmd) { struct pqi_scsi_dev *device; + if (!scmd->device) { + set_host_byte(scmd, DID_NO_CONNECT); + return; + } + device = scmd->device->hostdata; + if (!device) { + set_host_byte(scmd, DID_NO_CONNECT); + return; + } + atomic_dec(&device->scsi_cmds_outstanding); } @@ -5059,9 +5097,16 @@ static int pqi_scsi_queue_command(struct Scsi_Host *shost, device = scmd->device->hostdata; ctrl_info = shost_to_hba(shost); + if (!device) { + set_host_byte(scmd, DID_NO_CONNECT); + pqi_scsi_done(scmd); + return 0; + } + atomic_inc(&device->scsi_cmds_outstanding); - if (pqi_ctrl_offline(ctrl_info)) { + if (pqi_ctrl_offline(ctrl_info) || pqi_device_in_remove(ctrl_info, + device)) { set_host_byte(scmd, DID_NO_CONNECT); pqi_scsi_done(scmd); return 0; @@ -5214,12 +5259,23 @@ static void pqi_fail_io_queued_for_device(struct pqi_ctrl_info *ctrl_info, } static int pqi_device_wait_for_pending_io(struct pqi_ctrl_info *ctrl_info, - struct pqi_scsi_dev *device) + struct pqi_scsi_dev *device, unsigned long timeout_secs) { + unsigned long timeout; + + timeout = (timeout_secs * HZ) + jiffies; + while (atomic_read(&device->scsi_cmds_outstanding)) { pqi_check_ctrl_health(ctrl_info); if (pqi_ctrl_offline(ctrl_info)) return -ENXIO; + if (timeout_secs != NO_TIMEOUT) { + if (time_after(jiffies, timeout)) { + dev_err(&ctrl_info->pci_dev->dev, + "timed out waiting for pending IO\n"); + return -ETIMEDOUT; + } + } usleep_range(1000, 2000); } @@ -5345,7 +5401,8 @@ static int pqi_device_reset(struct pqi_ctrl_info *ctrl_info, msleep(PQI_LUN_RESET_RETRY_INTERVAL_MSECS); } if (rc == 0) - rc = pqi_device_wait_for_pending_io(ctrl_info, device); + rc = pqi_device_wait_for_pending_io(ctrl_info, + device, NO_TIMEOUT); return rc == 0 ? SUCCESS : FAILED; } @@ -7189,6 +7246,8 @@ static void pqi_pci_remove(struct pci_dev *pci_dev) if (!ctrl_info) return; + ctrl_info->in_shutdown = true; + pqi_remove_ctrl(ctrl_info); }