From patchwork Thu Nov 5 11:32:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 7560011 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 95AB29F36A for ; Thu, 5 Nov 2015 11:32:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AFC9D2088B for ; Thu, 5 Nov 2015 11:32:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5FEB52088A for ; Thu, 5 Nov 2015 11:32:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031853AbbKELck (ORCPT ); Thu, 5 Nov 2015 06:32:40 -0500 Received: from mail-wm0-f49.google.com ([74.125.82.49]:34570 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031044AbbKELcj (ORCPT ); Thu, 5 Nov 2015 06:32:39 -0500 Received: by wmnn186 with SMTP id n186so11448364wmn.1 for ; Thu, 05 Nov 2015 03:32:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=profitbricks_com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=QPLBC/ocJaQq3NVZeeN7sdXnoFkaejYftgYPrkfwGEA=; b=f6RsNOL6eWpYOTMsXFYfUaku46PLppunAy/n2kjjLow8fVjP9cyuUgR0CQPi/XhdYK lQRbnNKjgxuwLMoHrEFfltKYYwxnIOOuFBJTX1WHWfZdOsIz4N4w5LU0wePlZNz8rzYg o0+F12BfDGWJJu18qBAmcLT6wQ+Sb/C90bgjA6emL1tI6dG3On8dC29P5ztFUACx7zFx Owdaa+LaxdsifjcAXYYoQ+YWWRwJjQrTnrCSNHEUX7R4IydqXQuzLD/yg2EW2PV8GwyL yXW9BOb8U1mN6C7l5kaTBkhpp/33HCeAH4QL6HqJCZKhhgKuvCPZqToTwRN5daBd97pX YWdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=QPLBC/ocJaQq3NVZeeN7sdXnoFkaejYftgYPrkfwGEA=; b=l5x2RRouwVBca5KS6L+FR6jwmRiqNtP31FSXDzOTJiQWBZvDIMQL2b/iIBTDH3FhwO K+NCkeuccG7uqbGTzqa39p7sW2mIl/yE8RVy84bX+4kslYHNZUv2ptJXpMxsV1WfJ2CG 22FeZc+f/4VykrM/m6T5LpPSuiB8A+auQVauWxGEWMfgK6sCMQbCKGXPTS8mjuB728UX PtGqBI2IgDfZoy8C9aShjXYabttr+NcEdKZooC9/kPcc/MsqTCBrz2k+DwNwUfJZU0zm 3yRNVYMQqbhbdg/hocO2AiDjwOww1O49lzludP0ewQKpTcygHYeBhSPYv6qG4fpeMNA8 KKzA== X-Gm-Message-State: ALoCoQlySqGIxgDh+g02U2rC028dasTaPmAPm9GujdGEhwwZNgbRoi9UVTMkJjTINCExlKoKAO5U X-Received: by 10.28.16.1 with SMTP id 1mr2828960wmq.57.1446723158540; Thu, 05 Nov 2015 03:32:38 -0800 (PST) Received: from jinpu-GA-870A-USB3.pb.local ([62.217.45.26]) by smtp.gmail.com with ESMTPSA id uj4sm6498099wjc.34.2015.11.05.03.32.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Nov 2015 03:32:37 -0800 (PST) From: Jack Wang To: linux-scsi@vger.kernel.org, James.Bottomley@hansenpartnership.com, intel-linux-scu@intel.com Cc: hch@lst.de, brood@attotech.com, Jack Wang Subject: [PATCH 1/3] isci: remove SCSI host before detaching from SAS transport Date: Thu, 5 Nov 2015 12:32:29 +0100 Message-Id: <1446723149-9656-1-git-send-email-jinpu.wang@profitbricks.com> X-Mailer: git-send-email 1.9.1 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,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 commit cff549e4860f ("scsi: proper state checking and module refcount handling in scsi_device_get") , the reference count of scsi device was changed, which could lead to when rmmod with at least on drive attached, SCSI error handle will run into infinite loop, and lockup the system. Fix it by remove scsi host first, this way scsi core will not send commands down after detaching SAS transport. This is a follow up fix for Benjamin's fix for pm80xx. See also: http://www.spinics.net/lists/linux-scsi/msg90088.html Signed-off-by: Jack Wang Reviewed-by: Christoph Hellwig --- drivers/scsi/isci/init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c index 0dfcabe..9e0d069 100644 --- a/drivers/scsi/isci/init.c +++ b/drivers/scsi/isci/init.c @@ -272,11 +272,11 @@ static void isci_unregister(struct isci_host *isci_host) if (!isci_host) return; + shost = to_shost(isci_host); + scsi_remove_host(shost); sas_unregister_ha(&isci_host->sas_ha); - shost = to_shost(isci_host); sas_remove_host(shost); - scsi_remove_host(shost); scsi_host_put(shost); }