Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3712538imu; Mon, 28 Jan 2019 09:28:12 -0800 (PST) X-Google-Smtp-Source: ALg8bN5lV09FPA6+QjB3UuQaKWQkSP37L/FMjdwt/W0mtgh5jPG6liWDQgxXXzURnbIaXWiE+TVG X-Received: by 2002:a17:902:e08b:: with SMTP id cb11mr22835597plb.263.1548696492266; Mon, 28 Jan 2019 09:28:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548696492; cv=none; d=google.com; s=arc-20160816; b=MhNiGER5OAkxmfkay+Kg8818uvynRrFjptyPNnBOqnBaLNlVYYkMs+U/lH1nGJQzPf uE4I4DgoTjSguuxfjzEkX/LvU0uun2w2Op/OOqVuLewH8ZruWgIvM4VkKtbG/K2sM2ZY bkhX2INcPZvS5sPt56+NB/FzTKgT1WN92zVnD1Fek5rQ515O0jZjM6qlq/andrF9a+5i HnXtqp6f6P81ksUnKFyo/ytuKgShUx4y5g8kIj2wvHLoo48AjnnLMlLloFX8TDKXnAQr wRpNa34tzv6nt+bw1PascFrLtMc4MmlTmez/HQTf8lAOQTv1aloh49OpJvqaQHH3ZVjp akwQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iBss9k8r37AYkNBEMPiKliQJnCD8tce1lxxKL/rNqSs=; b=y+xusDa3d75opxC8uYtdtxbbZFfoxZFw/7dxrtLH9OYxpciBtPEU6Wzg+0hV6GUORH WU/gNdJ6LCucY4PxG7F0ZUB3EC2GdMynSTbgGulgriXs6hR3jbXhn5dwBeH8CsbBnDAG ikyaI5SizdiZ+In0uGFHogIDVIVbwpalFoemQEgjiOJsdNA/qJojdDG6k5Zq1wCp5ePc KVbR3GjtncanxLiDOFhOeMfztSTq2olYQ9iV/EoMBt+xsaomlvgvB+tnfSEBqLT2FnRO 7ng+kKbCtw3fp+JOYTMtxE9lOcngwPZoBHpNQ+gnYiB6PMLdmVPTC4BAAeSBM4XIHA0i BVCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DjIu2kHO; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p16si32909574plr.31.2019.01.28.09.27.56; Mon, 28 Jan 2019 09:28:12 -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=DjIu2kHO; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731360AbfA1R1p (ORCPT + 99 others); Mon, 28 Jan 2019 12:27:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:45440 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730714AbfA1QAJ (ORCPT ); Mon, 28 Jan 2019 11:00:09 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5E54321848; Mon, 28 Jan 2019 16:00:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691209; bh=s3dxhdB3JhZg5ETt3DbvYjSzWhCaL4XheDOipV/nq0o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DjIu2kHOx5PrI8UMEJIi6sAKi7+6+KEVhx1iILtmEdb7ZMGyuFjIpCTjpz8M6c9U3 31CcLSPXj/R8+r2OCCDuT/eRy85ANfsVd6Mg8Y8pyoS4w+utBr6MIM08pmHJdNSqQU hl8cHgqCz1nCU4Pe6kv4sv+Ag8wIxbWGl639h5fc= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Suganath Prabu , "Martin K . Petersen" , Sasha Levin , MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 016/258] scsi: mpt3sas: Call sas_remove_host before removing the target devices Date: Mon, 28 Jan 2019 10:55:22 -0500 Message-Id: <20190128155924.51521-16-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suganath Prabu [ 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 53133cfd420f..622832e55211 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -9809,6 +9809,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) { @@ -9851,7 +9852,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 f8cc2677c1cd..20d36061c217 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_transport.c +++ b/drivers/scsi/mpt3sas/mpt3sas_transport.c @@ -834,10 +834,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