Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp3278898ima; Tue, 23 Oct 2018 03:24:58 -0700 (PDT) X-Google-Smtp-Source: ACcGV632JWYdirifZus0gnb7R36aG+UAVIQfFgu1asdM0utC0AuvgDQIg2UzOQ/onzVdD8cEfrHq X-Received: by 2002:a62:104b:: with SMTP id y72-v6mr49477631pfi.113.1540290298012; Tue, 23 Oct 2018 03:24:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540290297; cv=none; d=google.com; s=arc-20160816; b=PcnlTLDdEENchKtLymmkXc2oS83O3zIXidJRveVVQ1TTDApn5aTbxdzS1miyhLlH/B hsICA7egRiawR9G8SAL+Aqys4ji5tWk+Lbx19V8vFuv5rIz1C9Ya3KUbZQlg77AtSXjR SWeUTSxq88F7X0UGohiHgEHyO3FsMOp/4WkCPKvEkMv8dxRDlxGFVd+ky6wI1psfx3UC o21l73+ZzkEJ3/btfwnlYstKfKDCtQ9JyFbsuvFAjZ5Y20u3fcrDSi1foT1sIh6qgWHu aQahAeMsRw+Bd7y4GbxL0+NkE7quZhx2xRfIPtutrSHrB135vR2YNR3FiRMGwlObm7wX Rdpg== 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=zWzyBaxgZowo/341gedHJbESpkMqKG/G6TiBCSuRyeY=; b=yqj+jxOHPBxvgqCkGnnEIkKghvhtShW4+6tlCr/uvIsEIfG10sVfkBhFtrCsLU+UMU d0kW1+5kgaKe25ySLXdX6p+NPgII+5SCSjhz6q5tb/OVh4ipLSD8ihXsUDjNG4FQ2kqo GyLD2t7bfbQvZdSVnQvWBgbvrD+jrqudBxarPSiScpKAxmkuM859t6M9ntra2Fu5qaKg nYA2gtVyK6X+dRF7M2OIEdWJXzIQj2EEZsj58/Ubx6c3lgNvy6OUd/4Tiyd1qwzxtWoy W8ZcRExoo3JTPkRCyFwOt8qlmMc3MOpCMwc57TqtX970ohD76Und4SVMXiXMPgQ87ocE Ak+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=crRxmpfo; 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 f2-v6si951345pgi.5.2018.10.23.03.24.43; Tue, 23 Oct 2018 03:24:57 -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=crRxmpfo; 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 S1727961AbeJWSo1 (ORCPT + 99 others); Tue, 23 Oct 2018 14:44:27 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:37188 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727844AbeJWSo1 (ORCPT ); Tue, 23 Oct 2018 14:44:27 -0400 Received: by mail-pg1-f196.google.com with SMTP id c10-v6so421275pgq.4 for ; Tue, 23 Oct 2018 03:21:40 -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=zWzyBaxgZowo/341gedHJbESpkMqKG/G6TiBCSuRyeY=; b=crRxmpfof31hBTkMJjSJ2nypUtrsPc0m0mWC6S1EpPQNkR8aSjSKfRJIxgP3avfB9t O5Y5r+Cudk909AFTfImCGcmSQkDlg3De3VPrCIaiRh7A9m4HbXbLbJMmG9EhGqdAHBhu yEKTp62pWDBmwacToIuSemV5ShEWXcprld6jU= 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=zWzyBaxgZowo/341gedHJbESpkMqKG/G6TiBCSuRyeY=; b=nB+ZYpJoYxL13bl1Q3UMSqq4637OVGA5ea75kCf2m1Q9uo6uzi2zhYMjswqUy5v0FD A5yQthbgpOZWIMLTO87j2sd+AvErrxHIT1zV1xsshT+LlwuPYZSnbLY6HHjJPlQyDuHy ddYkUUnhrryffwjGDaOkSdLtIJ/4sXVi6A6msFVT+uSs1TrfQF7+ufLVt5zHDMsnnvoJ tek01u84mN2QlEu/gsOjQfwv1sHVg8XcgeIEQQKMYRcJB0ZQfzKWI141jVQbMevvjYtY bJ+Zb9yjvKNjYQP3bJi+FZ5PZ6/7HIMMh0Hl1nD3vV58ZxFeyAUj3KAterfiSpdMOrTe 4Yig== X-Gm-Message-State: ABuFfohKMjXT2UUKy96h1E3D82rrzrhHBsWVg+9Amt1FVD4tiyM4Sj5p WWO7jtNVtZqWEKoXUdQPkW5JTw== X-Received: by 2002:a62:36c3:: with SMTP id d186-v6mr48123531pfa.133.1540290099892; Tue, 23 Oct 2018 03:21:39 -0700 (PDT) Received: from dhcp-10-123-74-106.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id m10-v6sm2918523pfg.180.2018.10.23.03.21.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 03:21:39 -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: [v6 2/4] mpt3sas: Fix Sync cache command failure during driver unload Date: Tue, 23 Oct 2018 15:51:19 +0530 Message-Id: <1540290081-15827-3-git-send-email-suganath-prabu.subramani@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1540290081-15827-1-git-send-email-suganath-prabu.subramani@broadcom.com> References: <1540290081-15827-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 bc1e67b..7d722b9 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_transport.c +++ b/drivers/scsi/mpt3sas/mpt3sas_transport.c @@ -807,10 +807,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