Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp270172imm; Tue, 16 Oct 2018 23:04:11 -0700 (PDT) X-Google-Smtp-Source: ACcGV60a/+XF6u3uPbUxiXMmHVJoqh+n8lRqUgObA+G8cUOqVZkeNLwwu0qcXzZ5NPD6GWaWBBXG X-Received: by 2002:a62:ce83:: with SMTP id y125-v6mr25308320pfg.201.1539756251252; Tue, 16 Oct 2018 23:04:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539756251; cv=none; d=google.com; s=arc-20160816; b=lxiRrhgvrE3MCUMn6ziQJ4zY5lOgR5EgVjuBaHmcH/VrP+ylK6BUYlkm0KJ71pwZIj NRhlGaiuxewPGZfhhjAx+o4sqcGItVeQMFgmn2UnuY6XHJxKOg++UrphlXaxkPgmiN4L sOLfaVR9J3NzwN5p6b1kKBHIey0x9FbeQr7mdrK8FrPuj19Akd0HANiwD7EY84HKLskA vKLHylrOIhpxD2KRvbyla3J54a2LCKVSoGQvbfEozS+/jNUHWd69GIzFW0h6z12aUBPa IvVe9gxzVN39EOwa9wCZxmJcXCGCD/sYs3mDtxCTT2Ya7SNfWGPo4epRqZvV/bhqPlR8 mapg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=Q9qIuTLxRg9OeFnbMrw8PFoAgwe6dGo2J+7euWhkhmQ=; b=qCSFBAPJvrzYmOlGIRYcbeP/FMjknm+AG5maDaf7qVXzz1Wgg9cMDsTFwzxZBCB1sT QgtFGT5h4Z0V0XCsy2kDHPkcYLOKbMwhQcwf8Gd7X1ciRuNzb5JkZsQgfzlYcGgoVO7B sKivmhFdV9qmkrLs+7fagEFgDb2IlGX96qJC855YCs+c6tBK19aLy3obwJyZWiRUFQAe S5e03VIPsyOGOuyex99h23Nisevmw3gyURQY31SE3twORnf/HifdXfzZpKIPi3FdxVaj 3JLrfQTuTSdFmqWeOxdKOqPuPXdAImH/T3s1gLshJM3oyl+pcnwBI/xlQyFphIOnvX// MRQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=d2iJC7Dp; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e12-v6si15023285pfi.271.2018.10.16.23.03.55; Tue, 16 Oct 2018 23:04:11 -0700 (PDT) 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=@broadcom.com header.s=google header.b=d2iJC7Dp; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727218AbeJQNxb (ORCPT + 99 others); Wed, 17 Oct 2018 09:53:31 -0400 Received: from mail-yb1-f196.google.com ([209.85.219.196]:45464 "EHLO mail-yb1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727192AbeJQNxa (ORCPT ); Wed, 17 Oct 2018 09:53:30 -0400 Received: by mail-yb1-f196.google.com with SMTP id d9-v6so9870157ybr.12 for ; Tue, 16 Oct 2018 22:59:31 -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=Q9qIuTLxRg9OeFnbMrw8PFoAgwe6dGo2J+7euWhkhmQ=; b=d2iJC7DpuKNorsBKsLbXzoBvOKxMrP+wjmEz80ALGNeoNgU8HFHE7347Yp1D33Yh6l sJhOQpV4ACrXni3D7KtELr+Nfr1vJ69j4HsT2Rb5JwcblN9We4AJDqttd1cXkIuFok4p cUpOWYcz426Et50buPK38RYnhWKtp0SlfnXmM= 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=Q9qIuTLxRg9OeFnbMrw8PFoAgwe6dGo2J+7euWhkhmQ=; b=SN2GWUEomAwZuixsVey3H72SCqD7XqgrVhTFlWlTlNONNmRS1cbhuvWmV92Dskz4RI Pg14EzAKKnU3mF7a4IAM2kk0RHEtbKCiyMqFjuQM3qt+PPguvFRwcZHn6YABF64gz80e DyXI4LGTNl8QeScTPeSjZPc39EoKTLUVJUkPkJbLjp1m2lFvlpWLESP4IfFvht99fEud +dMV9+Vzo1Ivz90P6IzeENIIraarx3G3rolZdzmkWfV7ouTVPJNzqQ8sxJBcadupaQ0E hs2D4sb5ieiXQHG+16xeoBUDjhbIz5eFk5pdTnS33BxxGdrD8WN6EMiM6cOqD2pWUdrH X+yg== X-Gm-Message-State: ABuFfojOKJtnVhjdHZGxwTFDBBJZ3edey8dU2Go+cATFbewUISmWnjK7 MF4HORfJnhbMR6PqzEkIzwRDrA== X-Received: by 2002:a25:d183:: with SMTP id i125-v6mr13233866ybg.466.1539755970877; Tue, 16 Oct 2018 22:59:30 -0700 (PDT) Received: from dhcp-10-123-74-106.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id y1-v6sm3930329ywf.34.2018.10.16.22.59.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Oct 2018 22:59:30 -0700 (PDT) From: Suganath Prabu To: helgaas@kernel.org, lukas@wunner.de, linux-scsi@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Cc: benh@kernel.crashing.org, ruscur@russell.cc, sbobroff@linux.ibm.com, oohall@gmail.com, andy.shevchenko@gmail.com, Sathya.Prakash@broadcom.com, sreekanth.reddy@broadcom.com, Suganath Prabu Subject: [v5 2/4] mpt3sas: Fix Sync cache command failure during driver unload Date: Wed, 17 Oct 2018 11:29:05 +0530 Message-Id: <1539755947-27014-3-git-send-email-suganath-prabu.subramani@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1539755947-27014-1-git-send-email-suganath-prabu.subramani@broadcom.com> References: <1539755947-27014-1-git-send-email-suganath-prabu.subramani@broadcom.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is to fix Sync cache and start stop command failures with DID_NO_CONNECT during driver unload. 1) Release drives first from SML, then remove internally in driver. 2) And allow sync cache and Start stop commands to firmware, even when remove_host flag is set. Signed-off-by: Suganath Prabu --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 38 ++++++++++++++++++++++++++++++-- drivers/scsi/mpt3sas/mpt3sas_transport.c | 7 ++++-- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 4d73b5e..df56cbe 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -3748,6 +3748,40 @@ _scsih_tm_tr_complete(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, return _scsih_check_for_pending_tm(ioc, smid); } +/** _scsih_allow_scmd_to_device - check whether scmd needs to + * issue to IOC or not. + * @ioc: per adapter object + * @scmd: pointer to scsi command object + * + * Returns true if scmd can be issued to IOC otherwise returns false. + */ +inline bool _scsih_allow_scmd_to_device(struct MPT3SAS_ADAPTER *ioc, + struct scsi_cmnd *scmd) +{ + + if (ioc->pci_error_recovery) + return false; + + if (ioc->hba_mpi_version_belonged == MPI2_VERSION) { + if (ioc->remove_host) + return false; + + return true; + } + + if (ioc->remove_host) { + + switch (scmd->cmnd[0]) { + case SYNCHRONIZE_CACHE: + case START_STOP: + return true; + default: + return false; + } + } + + return true; +} /** * _scsih_sas_control_complete - completion routine @@ -4571,7 +4605,7 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd) return 0; } - if (ioc->pci_error_recovery || ioc->remove_host) { + if (!(_scsih_allow_scmd_to_device(ioc, scmd))) { scmd->result = DID_NO_CONNECT << 16; scmd->scsi_done(scmd); return 0; @@ -9641,6 +9675,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 +9717,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 7acb408..8ce45e2 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_transport.c +++ b/drivers/scsi/mpt3sas/mpt3sas_transport.c @@ -808,10 +808,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); } -- 1.8.3.1