Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp765758ybc; Sat, 16 Nov 2019 08:18:29 -0800 (PST) X-Google-Smtp-Source: APXvYqzvBkv8s3/zPZPBgiJDdGVLlaapM/1DstwXAH4D4LUZEYlTh7vxUKLUyXu0ijSxgo4ny/D+ X-Received: by 2002:a17:906:73d5:: with SMTP id n21mr10791408ejl.228.1573921109136; Sat, 16 Nov 2019 08:18:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573921109; cv=none; d=google.com; s=arc-20160816; b=byewTnk3pvRD8voyA/0kZbFFuDiNfCJyJy3vwxpCJpr7vWZmEAunm/dJGKjX4OsjuD EShK2UQKNhAUtY0QITPMUd8U5KxhB0cWxWP8f0643JIhuJTGFiphyqelsHRietS4jWZJ Yb2q4zDI2DqR7Z6/5ogRjCyMukUzwxIfk/RUsx9HHlBoDM1LceyWFWF3DbrrUvGzngGC pXlz1RzlnJFMy/2wypriPsutaxBxLSBSm4n8QceBlZbbhZ3pR7W20nH3FbR2A166h8ZH zwpr1zHBNH/PjYiHIqW2h6b8qZhO9SFEN3y0Ppvfj1a+333vMCKwFM1XjCtVriXmT4qY TVcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RyZS664bGOy80BUS3yNceBXZMoiVCPhVAfY7kfrhz1s=; b=RJw0UnuqjVDPvKa3rORbxmvvnn8B8bR2DrOCXucav9CEhGAuBvboM6OgRojplxB/l2 2BterRqWSAOHp1iGLAXa2s+eMrockndYOpwITm4F0EYCtCHe9JcANlc8DNOyywCqdJEg s1aUMOt2kbgW1DSFmKZTQZessAUyIGiuppeKw0NFmxxB87OsLW+oE/D8H1lNYVJZTK4j gq+sst8jY3thYKkO989/x7nJercY9f/4eFvwJVTbQfZvMm7ocWaCThqhbYxS3bmV6YdK zNszwN33u/SeLCThi49uCxf7zyaZ7YZTDu4LWo1alLYTECDKTdO6DMCARmexhBRc08Sp IIDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0QkpbPys; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n8si7928884eja.438.2019.11.16.08.18.03; Sat, 16 Nov 2019 08:18:29 -0800 (PST) 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=@kernel.org header.s=default header.b=0QkpbPys; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729687AbfKPPrV (ORCPT + 99 others); Sat, 16 Nov 2019 10:47:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:53242 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729486AbfKPPqp (ORCPT ); Sat, 16 Nov 2019 10:46:45 -0500 Received: from sasha-vm.mshome.net (unknown [50.234.116.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2233E20891; Sat, 16 Nov 2019 15:46:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573919204; bh=PBdKjAcHh0/xYmzKeZZ8qeouI77njMrZJRvV4742/wA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0QkpbPys4DyDwA1k5+xcMW1XeBKKd1Irk7dAW+xenkNb/LabV8XEW3UDfsCw6JQLr hdm0BTyDoh4pbIrs2lhjjlMw/nYbv3aSJJ8te6mto1WHuCiGVGaAm3fQ2GRMZj8xTb rCbILEpiprPciTMjzSzYZowYoR4ZBJ5xKCgdRotg= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Suganath Prabu , Bjorn Helgaas , Andy Shevchenko , "Martin K . Petersen" , Sasha Levin , MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 207/237] scsi: mpt3sas: Fix Sync cache command failure during driver unload Date: Sat, 16 Nov 2019 10:40:42 -0500 Message-Id: <20191116154113.7417-207-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154113.7417-1-sashal@kernel.org> References: <20191116154113.7417-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suganath Prabu [ Upstream commit 9029a72500b95578a35877a43473b82cb0386c53 ] 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 Reviewed-by: Bjorn Helgaas Reviewed-by: Andy Shevchenko Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- 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 73d661a0ecbb9..d3c944d997039 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -3791,6 +3791,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 @@ -4623,7 +4657,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; -- 2.20.1