From patchwork Wed Sep 26 04:22:37 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: 10615259 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 B94833CF1 for ; Wed, 26 Sep 2018 04:23:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC1CD285CB for ; Wed, 26 Sep 2018 04:23:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0A6628668; Wed, 26 Sep 2018 04:23:20 +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=unavailable 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 4A3D7285CB for ; Wed, 26 Sep 2018 04:23:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726404AbeIZKeQ (ORCPT ); Wed, 26 Sep 2018 06:34:16 -0400 Received: from mail-qk1-f194.google.com ([209.85.222.194]:43974 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726544AbeIZKeP (ORCPT ); Wed, 26 Sep 2018 06:34:15 -0400 Received: by mail-qk1-f194.google.com with SMTP id v18-v6so5338889qka.10 for ; Tue, 25 Sep 2018 21:23:18 -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=0/V5YKy5esTLDrOt7DVdzxfFXSOKSFPF2j7Lhnoe424=; b=c+0M7EFHarkfLgbVMILS7nCpeJUkuJ7YOMoFkux4G7wLBb+tBfb7eLU6Jvbl+7Mgpq P4mMlhsXyplnNRD2R9GHCDrh1kMch5itW9KDRRtXaPIllRLo76wIrKyCUUfnoGulZ+kT T5nQTccQFHd88cpHxzwL+jfyWFhRY1yHohtJE= 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=0/V5YKy5esTLDrOt7DVdzxfFXSOKSFPF2j7Lhnoe424=; b=g0W8d+65RkdB4oZo8wEMfr7tIUu5E0s+8zf0R0U9KEqNQfzZyKGBz1dbX0sjxmNVhE iCZYCzBA4jCWBuKlws4igXKSafx4AZVwSdDEwtZW/qBQ60It4AjJZ5PJ0dU5p8IvDi36 Rh4RndR2Og2UUvthwv3AaFe5ZP7l3PZquTrMnD/5imPR4STYmtQhPl8bRb6Aq2Kc+wzt nuamxtkqvQglog9CrYlcEet8OUNysZu9Lq1CFWWIp6t6AesVLjIKiFasLNLsCQEMSdAq hvf3xB+95h4Wyuu5ljAXxmCBSlKbTQw0MOCGeiajO/QO6k5/8/Pa+jR4geDy4NIodG+y qiNw== X-Gm-Message-State: ABuFfoiOdXxJ3Eoc2DyozC2B8/n8hUzN4WG7/AZjK5UGqV/RT/kody84 xu4BAWxgbMWzR+Br1w3rXizacC5CDZE= X-Google-Smtp-Source: ACcGV619xuzpue1JiaUMXY+VdKy5NCqsKyaHxkfOTGfLB1y3j9TGTQenYAuLIqlvN4xJWGn/Jz4tTw== X-Received: by 2002:a37:6888:: with SMTP id d130-v6mr3001058qkc.192.1537935798138; Tue, 25 Sep 2018 21:23:18 -0700 (PDT) Received: from dhcp-10-123-74-106.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id a17-v6sm2375260qkb.62.2018.09.25.21.23.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Sep 2018 21:23:17 -0700 (PDT) From: Suganath Prabu S To: linux-scsi@vger.kernel.org, linux-pci@vger.kernel.org Cc: lukas@wunner.de, andy.shevchenko@gmail.com, Sathya.Prakash@broadcom.com, sreekanth.reddy@broadcom.com, Suganath Prabu S Subject: [PATCH v4 4/6] mpt3sas: Fix Sync cache command failure during driver unload. Date: Wed, 26 Sep 2018 09:52:37 +0530 Message-Id: <1537935759-14754-5-git-send-email-suganath-prabu.subramani@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1537935759-14754-1-git-send-email-suganath-prabu.subramani@broadcom.com> References: <1537935759-14754-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 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 v2 Changeset: Replaced this function mpt3sas_base_pci_device_is_unplugged with pci_device_is_present Signed-off-by: Suganath Prabu S --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 41 ++++++++++++++++++++++++++++++-- drivers/scsi/mpt3sas/mpt3sas_transport.c | 7 ++++-- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index f6e92eb..5d15d06 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -3806,6 +3806,43 @@ _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) { + if (!pci_device_is_present(ioc->pdev)) + return false; + + switch (scmd->cmnd[0]) { + case SYNCHRONIZE_CACHE: + case START_STOP: + return true; + default: + return false; + } + } + + return true; +} /** * _scsih_sas_control_complete - completion routine @@ -4640,7 +4677,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; @@ -9874,6 +9911,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) { @@ -9916,7 +9954,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 b10d73e..742da74 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_transport.c +++ b/drivers/scsi/mpt3sas/mpt3sas_transport.c @@ -817,10 +817,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); }