Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp6068013imd; Wed, 31 Oct 2018 06:25:50 -0700 (PDT) X-Google-Smtp-Source: AJdET5dpp1oXvXA2n4FegOimSqWtXxSiwxgGFxa8LhFwCCSvvlvFVR4Vp3CaKmXqLZKx5ms7RLki X-Received: by 2002:a17:902:2ec1:: with SMTP id r59-v6mr3387280plb.243.1540992350425; Wed, 31 Oct 2018 06:25:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540992350; cv=none; d=google.com; s=arc-20160816; b=KzoqVRgVi3oqtcgRjNBk9MEYb1zf+cN1ZKqqhaGyd+RB1wJh6Am3EHfezcTJtz0Wd6 cKskbKuk/aZKdYfv4ChfJYNqpM9ucgu+ExG+gGmmdH3hUJWDSts8S2XHBV/ebbAgfB0M ms8/YmfnR46MZx7ugAs+tbLu45h7fBLrH/Iin2DrEsBd90isgy78m1RUD5z/yvcl335D bbvy3pQp45sVGVUhoPnscYeX6Tm8ZTsI4jA7n6/8X0UOz0VZJwD/IBMpQQhEYuoCeaIY L0JLqQMeGONKH8ungysEsAErLzLwcc1w0MS5abyqbTWJ2mctc49JXeqgynj9mpyu+2c+ cr4w== 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=jB9V45TEiYcrejn/2logmOePeieDZLWqOPmZPOnfT8k=; b=wASMivG9plUiObewGNvdCWL/4KP/2eyIwqv45VXiH6val8B64lmo+ogYkbEaTBc5xQ wGeAqXQS8dXOzRZFP4EbfQJgvc9f9oV5cQ5+OckAsiyt+L7PFvjKHAP/vHJH7z9oLwyB KieGq9m7zRlFuD2XOiC9tuoH7NIXEvkiRAOf4u6pnCsUDYlfH1t84g5uWzlKrGhVUw2r bDe+eGOGTqNToczwRHE6ulWOYFF7XRbfveqWjqCuRD3YiUrhLWVMuLiEAU5oMBEJdyT8 6R7LupdY+8tm02iKJZbzMlh3eaJ7CgCxD92lCWfoEgI+XtjTiB1YNV0CzcJjYwG4/2S3 UQsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b="EVKX/tXK"; 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 x18-v6si26864818plr.146.2018.10.31.06.25.34; Wed, 31 Oct 2018 06:25:50 -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="EVKX/tXK"; 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 S1729400AbeJaWWp (ORCPT + 99 others); Wed, 31 Oct 2018 18:22:45 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:40086 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729271AbeJaWWo (ORCPT ); Wed, 31 Oct 2018 18:22:44 -0400 Received: by mail-wr1-f66.google.com with SMTP id i17-v6so16431132wre.7 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=lRn/XyfZsmOW848DLfYzseCjnTGHk9Gq/PpvtOgw3gM336EJgjqL6aH4Uz6N4vtnyd izK+39X5AptWCDOCeXSIOs8cFIfN8rBBLUSRaiDHQt+ZlidaGOJiynvDB3lGWaFxeeKG PPyQ1YM3BGAKUwH+s80ILdLIM+H2oujWL6wnsrVFp2zqFibo0XGwUmpXRe5XxRuoShZR imrqTZYO35arVf0ou9+KUZkAsnBoXPFOURdquTAfx4CKQek6yBPmmISKGVfAfU/cDr6t rbEz9UZOES5oisIKx+hJVpyw3EVP5A8UE4JFs/rPbptACV2rtyBu8/cIXdpXQrq6ZNQg Cjqw== X-Gm-Message-State: AGRZ1gIyXMJNkU+dAb4UFa2MgiBlJZcvx1Ont59Mju4nMadqpjb9S5nY W4Aoe4rwfjwE7MtWAuPQ1H/OAQ== 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-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. 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; -- 1.8.3.1