From patchwork Wed Oct 31 13:23:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suganath Prabu S X-Patchwork-Id: 10662657 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 74AE914DE for ; Wed, 31 Oct 2018 13:25:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6461425F31 for ; Wed, 31 Oct 2018 13:25:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 56B2128935; Wed, 31 Oct 2018 13:25:10 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 EC68F25F31 for ; Wed, 31 Oct 2018 13:25:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729378AbeJaWWl (ORCPT ); Wed, 31 Oct 2018 18:22:41 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:40081 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729268AbeJaWWl (ORCPT ); Wed, 31 Oct 2018 18:22:41 -0400 Received: by mail-wr1-f65.google.com with SMTP id i17-v6so16430919wre.7 for ; Wed, 31 Oct 2018 06:24:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lEqXr7wEAOW839/yy/MKqF6Va7CQZ2BXCDmuyFLxywI=; b=DpT6mIZZJ0+NzvD6Nl0BhDZ0KoTsh7kUuB67G+E33fxa3cZsl08mJJW007TzbQqVV+ GoaNh+X7/7JKQ6u5FCO0AsH13jYz8NnMEoznusb+AD73qrsKK+Eyz22jROPQMIIA44ky 244l9PktC4JPOhtxHFyCOrOrf1bLWO3DrEFF8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lEqXr7wEAOW839/yy/MKqF6Va7CQZ2BXCDmuyFLxywI=; b=YjK8pF6SgcfpcJEh0B2LyGC/fjqDmg8oEe9hX/YLheFwN1W9NfYDtAsSOjYjitrkCY E4rnhOfPX315KHXkL26Mfek+sFcx7qtayWsxoynuBdN+sDVBY3w4Sx2+/RAr7GTibRmT BQSS4CXGwaEa6r1pMnVMnkgjX2947+m1TrwrW44U287eqSQLw88NMRMX6yU4PLAAwOSy bBx6DXQdUKNFmCdFhiy2Z+8XiVfxEserF30f4Q3ogMIHVzUL0rWZClumO5MSgUyLMh5s FaWGfCtv9taaHaL4EEwY+rucz8LiOiMOF8t/uFYXqmKAGmGvsDiLRXCU0dgqNVXZZpJY uf3w== X-Gm-Message-State: AGRZ1gIPbTWiJhQy0O6Sp5sZEtBEB0zrr8BDF6C8PX0SfzMkmz9ritzL IAtVomByXD8CUdXUvufw96yadAfpvTY= X-Google-Smtp-Source: AJdET5cU/ljDR9qQ8iAVsf08RqaJa+2RENxF6ii9hDeU8t/40xN1ofRd/2VDhoepexBRG0Ehio8SIA== X-Received: by 2002:a5d:69ce:: with SMTP id s14-v6mr1743754wrw.177.1540992278274; Wed, 31 Oct 2018 06:24:38 -0700 (PDT) Received: from dhcp-10-123-74-106.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id r16-v6sm25202614wrv.21.2018.10.31.06.24.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Oct 2018 06:24:37 -0700 (PDT) From: Suganath Prabu To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sathya.Prakash@broadcom.com, sreekanth.reddy@broadcom.com, Suganath Prabu Subject: [PATCH v7 4/8] mpt3sas: Call sas_remove_host before removing the target devices Date: Wed, 31 Oct 2018 18:53:35 +0530 Message-Id: <1540992219-20291-5-git-send-email-suganath-prabu.subramani@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1540992219-20291-1-git-send-email-suganath-prabu.subramani@broadcom.com> References: <1540992219-20291-1-git-send-email-suganath-prabu.subramani@broadcom.com> 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 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 --- 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 4d73b5e..12f565c 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 9685c87..60ae2d0 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_transport.c +++ b/drivers/scsi/mpt3sas/mpt3sas_transport.c @@ -806,10 +806,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); }