From patchwork Fri May 13 20:28:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Owens X-Patchwork-Id: 9093191 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EFD5EBF29F for ; Fri, 13 May 2016 20:28:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DBCBE20131 for ; Fri, 13 May 2016 20:28:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 918BF2021A for ; Fri, 13 May 2016 20:28:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753528AbcEMU2k (ORCPT ); Fri, 13 May 2016 16:28:40 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:18969 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753520AbcEMU2i (ORCPT ); Fri, 13 May 2016 16:28:38 -0400 Received: from pps.filterd (m0001255.ppops.net [127.0.0.1]) by mx0b-00082601.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u4DKOBCv007794 for ; Fri, 13 May 2016 13:28:37 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=facebook; bh=oVOkSBZO7rFSXiazqxFOiW0L3TaFwxRyJngMS2Jxldc=; b=P+641wLeFROPtk3AjNKi/EyNQusWWyIz7Kff/NtV2LByQzg08KbAGxpdj1NF6JbFIpp7 5YGvMUag0JKfDr0qGFJyU3E9HeB9qycd44sCNSu7F2Vk5e54paCYIGKK+Hd23K2Nf/dp yXAI1IsiuBmnld0UpZxy/aXkMtxdIP9gqgE= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0b-00082601.pphosted.com with ESMTP id 22wndp83wj-14 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Fri, 13 May 2016 13:28:37 -0700 Received: from mx-out.facebook.com (192.168.52.123) by PRN-CHUB01.TheFacebook.com (192.168.16.11) with Microsoft SMTP Server (TLS) id 14.3.294.0; Fri, 13 May 2016 13:28:30 -0700 Received: from facebook.com (2401:db00:11:d0be:face:0:1b:0) by mx-out.facebook.com (10.223.101.97) with ESMTP id 40d35484194911e6ad4c24be0595f910-d03ddc50 for ; Fri, 13 May 2016 13:28:29 -0700 Received: by devbig337.prn1.facebook.com (Postfix, from userid 10532) id 43D9865C0843; Fri, 13 May 2016 13:28:28 -0700 (PDT) From: Calvin Owens To: Sathya Prakash , Chaitra P B , Suganath Prabu Subramani , "James E.J. Bottomley" , "Martin K. Petersen" CC: , , , , Subject: [PATCH] mpt3sas: Do scsi_remove_host() before deleting SAS PHY objects Date: Fri, 13 May 2016 13:28:19 -0700 Message-ID: <41278f83ecb4de381ab49aeb94e341dc533fde8f.1463170969.git.calvinowens@fb.com> X-Mailer: git-send-email 2.8.0.rc2 X-FB-Internal: Safe MIME-Version: 1.0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-05-13_08:, , signatures=0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On the hardware I'm testing on, simply removing the mpt3sas module triggers a litany of WARNs culminating in an OOPS: ------------[ cut here ]------------ WARNING: CPU: 5 PID: 13348 at lib/kobject.c:244 kobject_add_internal+0x359/0x8a0 kobject_add_internal failed for ArrayDevice09 (error: -2 parent: 6:0:15:0) CPU: 5 PID: 13348 Comm: rmmod Not tainted 4.6.0-rc2-mpt3sas-debug-00001-g7e7e6f4 #2 Hardware name: Wiwynn HoneyBadger/PantherPlus, BIOS HBP6.6 11/20/2015 ffffffff82b88ec0 ffff8806ce76f820 ffffffff81deff03 ffff8806ce76f898 0000000000000000 ffff8806ce76f868 ffffffff811191e2 ffff880749819af8 00000000000000f4 ffffed00d9cedf0f ffff880749819b08 ffff88074c9b8168 Call Trace: [] dump_stack+0x67/0x94 [] __warn+0x172/0x1b0 [] warn_slowpath_fmt+0x97/0xb0 [] kobject_add_internal+0x359/0x8a0 [] kobject_add+0x10e/0x1c0 [] device_add+0x30a/0x1490 [] enclosure_remove_device+0x172/0x1cc [enclosure] [] ses_intf_remove+0x1c4/0x270 [ses] [] device_del+0x2ab/0x680 [] device_unregister+0x12/0x30 [] __scsi_remove_device+0x1d5/0x250 [] scsi_forget_host+0x12c/0x1e0 [] scsi_remove_host+0x10c/0x300 [] scsih_remove+0x321/0x680 [mpt3sas] [] pci_device_remove+0x70/0x110 [] __device_release_driver+0x160/0x3a0 [] driver_detach+0x183/0x200 [] bus_remove_driver+0xdf/0x200 [] driver_unregister+0x67/0xa0 [] pci_unregister_driver+0x1e/0xe0 [] _mpt3sas_exit+0x23/0x219 [mpt3sas] [] SyS_delete_module+0x2ee/0x390 [] entry_SYSCALL_64_fastpath+0x18/0xa8 ---[ end trace fe163024b624f4af ]--- general protection fault: 0000 [#1] SMP KASAN CPU: 6 PID: 17388 Comm: rmmod Tainted: G W 4.6.0-rc2-00001-g7e7e6f4 #1 Hardware name: Wiwynn HoneyBadger/PantherPlus, BIOS HBP6.6 11/20/2015 task: ffff880753731740 ti: ffff8806896f0000 task.ti: ffff8806896f0000 RIP: 0010:[] [] klist_put+0x1f/0x160 RSP: 0018:ffff8806896f7a10 EFLAGS: 00010202 RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffff880753731f48 RDX: 000000000000000b RSI: 0000000000000001 RDI: 0000000000000058 RBP: ffff8806896f7a30 R08: 0000000000000006 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: ffff880752bec000 R13: 0000000000000001 R14: dffffc0000000000 R15: ffff880752bec2b0 FS: 00007feef8ea6700(0000) GS:ffff88075ef80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fe45044d020 CR3: 00000006f7092000 CR4: 00000000001006e0 Stack: 0000000000000000 ffff880752bec000 0000000000000000 dffffc0000000000 ffff8806896f7a40 ffffffff8290987e ffff8806896f7b00 ffffffff820aa3bd ffff8806896f7aa0 1ffff100d12def4f ffff880752bec390 ffffffff829183ca Call Trace: [] klist_del+0xe/0x10 [] device_del+0x12d/0x680 [] device_unregister+0x12/0x30 [] enclosure_unregister+0xe0/0x170 [enclosure] [] ses_intf_remove+0x190/0x270 [ses] [] device_del+0x2ab/0x680 [] device_unregister+0x12/0x30 [] __scsi_remove_device+0x1d5/0x250 [] scsi_forget_host+0x12c/0x1e0 [] scsi_remove_host+0x10c/0x300 [] scsih_remove+0x321/0x680 [mpt3sas] [] pci_device_remove+0x70/0x110 [] __device_release_driver+0x160/0x3a0 [] driver_detach+0x183/0x200 [] bus_remove_driver+0xdf/0x200 [] driver_unregister+0x67/0xa0 [] pci_unregister_driver+0x1e/0xe0 [] _mpt3sas_exit+0x23/0xa89 [mpt3sas] [] SyS_delete_module+0x2ee/0x390 [] entry_SYSCALL_64_fastpath+0x18/0xa8 The issue is that enclosure_remove_device() expects to be able to re-add the device that was previously enclosured: so with SES running, the order we unwind things matters in a way it otherwise wouldn't. Since mpt3sas deletes the SAS objects before the SCSI hosts, enclosure ends up trying to re-parent the SCSI device from the enclosure to the SAS PHY which has already been deleted. This obviously ends in sadness. The fix appears to be simple: just call scsi_remove_host() before we call sas_port_delete() and/or sas_remove_host(). Signed-off-by: Calvin Owens --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index e0e4920..4aa128a 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -8149,6 +8149,8 @@ void scsih_remove(struct pci_dev *pdev) _scsih_raid_device_remove(ioc, raid_device); } + scsi_remove_host(shost); + /* free ports attached to the sas_host */ list_for_each_entry_safe(mpt3sas_port, next_port, &ioc->sas_hba.sas_port_list, port_list) { @@ -8172,7 +8174,6 @@ void scsih_remove(struct pci_dev *pdev) } sas_remove_host(shost); - scsi_remove_host(shost); mpt3sas_base_detach(ioc); spin_lock(&gioc_lock); list_del(&ioc->list);