From patchwork Wed Oct 31 13:23:36 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: 10662649 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 5CEC313BF for ; Wed, 31 Oct 2018 13:24:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C3EF25F31 for ; Wed, 31 Oct 2018 13:24:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4075C28935; Wed, 31 Oct 2018 13:24:45 +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 DDD8C25F31 for ; Wed, 31 Oct 2018 13:24:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729392AbeJaWWo (ORCPT ); Wed, 31 Oct 2018 18:22:44 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:41567 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729287AbeJaWWo (ORCPT ); Wed, 31 Oct 2018 18:22:44 -0400 Received: by mail-wr1-f66.google.com with SMTP id x12-v6so16474186wrw.8 for ; Wed, 31 Oct 2018 06:24:42 -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=jB9V45TEiYcrejn/2logmOePeieDZLWqOPmZPOnfT8k=; b=EVKX/tXKjrcASTlT+eldUGSd7RlsV8crz7rjAP3Dp+QBZUCwFEERJb9FazvyiWGQMf bDXBUp4f4CDrUzK6Z06dQ1NcP7kGyMjANLeipZOmPo/U38mnKN1fs9jVy3FisSbi187p w3UVJCkZBUGQjQpj4LiOVABnXreo88xoWVdXQ= 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=jB9V45TEiYcrejn/2logmOePeieDZLWqOPmZPOnfT8k=; b=cGv6Rwo+3KJQ7Tref3eEjcRDWVIHLDDuhVbxIaNciSIybJV7HuCjvk3n/d5qr9CKQa jdE12uG6JiJzprimVoyr9H64DJ7aUOU1PL55h/qqBbSYd/Db11+lcMPNFMkhOj0WESUq SMX5mwwuLteT5SfCwFcliSbFJpWQShvpozuLrwceN5Pym3HcFvDD+dkcd5rs/9499ZZU +pB8EZIpe2AdN0fiizVFXXUWc+as4Xl5FLrpi+8wO13ys+DeiUXkEAKc5FgnWu/oTvvc ppii0Ngpmn1xGwak7IQkh7ULPIWFrThnbugSbOvoQ8rEEsLf6NYaWTGYWqYX/tnzuOgX ypqA== X-Gm-Message-State: AGRZ1gJ1IilhJjyNy9aY7JdklxZF/7KD0t8p6YrwTmzy8/bV/Ooeijya +A6ixfWPEEfitoPIdj3kackDsLCqKZs= X-Google-Smtp-Source: AJdET5eXTnCTWhKvy2OCWvWOkY9n5Fs1pW845aUou399XgTEXZts1WwI514oVX7U61972Zp8E8uzAw== X-Received: by 2002:a5d:4292:: with SMTP id k18-v6mr2733638wrq.225.1540992281488; Wed, 31 Oct 2018 06:24:41 -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.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Oct 2018 06:24:41 -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 5/8] mpt3sas: Fix Sync cache command failure during driver unload Date: Wed, 31 Oct 2018 18:53:36 +0530 Message-Id: <1540992219-20291-6-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 This is to fix SYNC CACHE and START STOP command failures with DID_NO_CONNECT during driver unload. In driver's IO submission patch (i.e. in driver's .queuecommand()) driver won't allow any SCSI commands to the IOC when ioc->remove_host flag is set and hence SYNC CACHE commands which are issued to the target drives (where write cache is enabled) during driver unload time is failed with DID_NO_CONNECT status. Now modified the driver to allow SYNC CACHE and START STOP commands to IOC, even when remove_host flag is set. Signed-off-by: Suganath Prabu --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 12f565c..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;