Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2773572imj; Mon, 11 Feb 2019 08:15:11 -0800 (PST) X-Google-Smtp-Source: AHgI3IbqygdUOWj4jWp7GeGNIyESMxAhC2GQCffW0KB3pV+Jf5BcWqCwBDGtl+8rpj1tYjjEhh85 X-Received: by 2002:a17:902:6bc9:: with SMTP id m9mr37767346plt.173.1549901711720; Mon, 11 Feb 2019 08:15:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549901711; cv=none; d=google.com; s=arc-20160816; b=YaYtN52ZsmMiEfwAG0MOcx8aSBux3dV6qcYadiHa8+TgBeuAz6BAfh3lbXLkBXk5Ik uQoppMrYi+BBr+qsBJwkaIjZN+hyZDdwYKiLExTyNCN8w0Pke36OxmhwP6FcY8cfeupa CSXOQ7V16C9ndvmn8TSKCm4V21grdTIyTjLTZTER8zmSzt0gg5P18EsDX1GI+y1ihgB3 op58qfbLBYdxmsaZ39fcWcgzwSSnqiShkzAjwtaN0CwCnWCPzosZyRwtRlGyJSe8YhxR OiheI2Ft/Rf6TAJpy4Eg7HiKlr3GcdSfm8gopZLo9WVn9NVYTnNJZuvGknh9dBTmEYo/ GAbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/5iaZKaqNpa2hks2c7Oshemb7JL6XXOKXctLd0cImkA=; b=fjCYA7TC7+G6Bb3b541VzgS+dYAZL40rxh2Am3xOi8V8Tl0eOPO3Bh5EWShMGKqLdA ZjC3aA7R3JjXeQf+Fh3lu6JeZPPqs1VhsNUx5xeXG/R8WkeRLFkJRivDc2/N6v0mu/Ch AOnPVuy3h/gmzUMkmPLEQMYqo2ZnnqFvnSYAdIAXNnxjX+5L7zNzyknc89mgOO7Jze07 eK4LSqFKsBKoikXzqFDfCxtV1HFtzOxwBlRG2jFHikF2UFjCDxyx4H1580isnbqro/EC rWWvSmIkxRHEeo6rv9ADjnrNZfozW/pE3qIw95iRHtLbwE85tdSYtl1/b8WN8Y4yMcJ3 iPOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="sFC7/YCc"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e17si9630271pgv.452.2019.02.11.08.14.54; Mon, 11 Feb 2019 08:15:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="sFC7/YCc"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728906AbfBKOXA (ORCPT + 99 others); Mon, 11 Feb 2019 09:23:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:55902 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728887AbfBKOW4 (ORCPT ); Mon, 11 Feb 2019 09:22:56 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 32BFE20838; Mon, 11 Feb 2019 14:22:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549894974; bh=/aJYqEK7Ddefz7S1Zp1r9lNu8IT7KlrBIm+E7KCLb0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sFC7/YCcbexGIx5iK3b9MT46UIsvwsNnROnTVO0onCLdd6rN2ih0MJzBDOhQWbScw yImDgSZzbcqMyU/fTG7TlIfLPSL8STVT86ApVP9sJGiF5mdNbV+HwbIk9p8QuKWQoa frQvqifbZNtUUKq44FOYo3DNFdDAm5RIBRB2tWBg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Suganath Prabu , Bjorn Helgaas , Andy Shevchenko , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.20 020/352] scsi: mpt3sas: Call sas_remove_host before removing the target devices Date: Mon, 11 Feb 2019 15:14:07 +0100 Message-Id: <20190211141847.651690005@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit dc730212e8a378763cb182b889f90c8101331332 ] Call sas_remove_host() before removing the target devices in the driver's .remove() callback function(i.e. during driver unload time). So that driver can provide a way to allow SYNC CACHE, START STOP unit commands etc. (which are issued from SML) to the target drives during driver unload time. Once sas_remove_host() is called before removing the target drives then driver can just clean up the resources allocated for target devices and no need to call sas_port_delete_phy(), sas_port_delete() API's as these API's internally called from sas_remove_host(). Signed-off-by: Suganath Prabu Reviewed-by: Bjorn Helgaas Reviewed-by: Andy Shevchenko Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 2 +- drivers/scsi/mpt3sas/mpt3sas_transport.c | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 03c52847ed07..adac18ba84d4 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -9641,6 +9641,7 @@ static void scsih_remove(struct pci_dev *pdev) /* release all the volumes */ _scsih_ir_shutdown(ioc); + sas_remove_host(shost); list_for_each_entry_safe(raid_device, next, &ioc->raid_device_list, list) { if (raid_device->starget) { @@ -9682,7 +9683,6 @@ static void scsih_remove(struct pci_dev *pdev) ioc->sas_hba.num_phys = 0; } - sas_remove_host(shost); mpt3sas_base_detach(ioc); spin_lock(&gioc_lock); list_del(&ioc->list); diff --git a/drivers/scsi/mpt3sas/mpt3sas_transport.c b/drivers/scsi/mpt3sas/mpt3sas_transport.c index 6a8a3c09b4b1..8338b4db0e31 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_transport.c +++ b/drivers/scsi/mpt3sas/mpt3sas_transport.c @@ -821,10 +821,13 @@ mpt3sas_transport_port_remove(struct MPT3SAS_ADAPTER *ioc, u64 sas_address, mpt3sas_port->remote_identify.sas_address, mpt3sas_phy->phy_id); mpt3sas_phy->phy_belongs_to_port = 0; - sas_port_delete_phy(mpt3sas_port->port, mpt3sas_phy->phy); + if (!ioc->remove_host) + sas_port_delete_phy(mpt3sas_port->port, + mpt3sas_phy->phy); list_del(&mpt3sas_phy->port_siblings); } - sas_port_delete(mpt3sas_port->port); + if (!ioc->remove_host) + sas_port_delete(mpt3sas_port->port); kfree(mpt3sas_port); } -- 2.19.1