Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5995504ybc; Wed, 27 Nov 2019 13:06:04 -0800 (PST) X-Google-Smtp-Source: APXvYqy0nEzncA2RuXLtq+k7KKWI78l22xxSLbqZFQ3QUZmawSyS4aiTXmYdhtTpKzgdYFFM25/4 X-Received: by 2002:a17:906:69d7:: with SMTP id g23mr50994020ejs.20.1574888763937; Wed, 27 Nov 2019 13:06:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888763; cv=none; d=google.com; s=arc-20160816; b=U990k4ADDSbFZ6eMwUbMYTo5gSQLKK3+unBKI3yzTt9KsKj8F9nBN5ZIHMZZkueboE IjnL11+9MMMcOBnrFRjCpwwo5tE9PC4lETbdkvAvCiv3GCIfzINKhkDPu3r7FKeeiT7g vur4BX4CzmR5UuW706iTKFgLwbSgPHjQgrNEMhX9lWbqXSJv/znm4bKoDdFH0fSsVerR AycCWj9pKiAJGO2fSSZbMzjlIXrD9CVuyTLjg2H1kxCeYyQnkwFOpEzRGl8E5jDppOKh rPkumQLUuU91IyT3rY4IqQRXihoslQWAIpxjUMLJw9DYjX04Asadvq+AGSh6K3vRVD7r UjYw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RyZS664bGOy80BUS3yNceBXZMoiVCPhVAfY7kfrhz1s=; b=Vobl5elYsAv9vszvdWAVLUkw5zzKyD/LAx0j1XNuCfr1l/5M+ajmBH6Tv5zzHCtSIR 0djwS43Wg7/eOSPmseghJiDRgm0p8Qa775aUmrRv74pVF9/IgWXrNetTJGL+gocZLEsu RKRBtHcjXBS2szLiF+EtZpKtIfeYqfhYjqTmnv1uGxQm4h8yNjSL+9dqYmqvojvZaY3/ +gbCD3Oh4Krmg2FiJZ4FK4OzIzD9tl0BvEZYsLd7byyrOx2G/6UdCPqwgsMHujrXOMXp D7flXbv92EEvlShRuipDxxllnBVMnWOtqGde9x8yl74p26cs4dUdv0H3cMv8zWIK/yrS Dllg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="t/CHeaBP"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w2si11397432edf.32.2019.11.27.13.05.39; Wed, 27 Nov 2019 13:06:03 -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="t/CHeaBP"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732170AbfK0VEg (ORCPT + 99 others); Wed, 27 Nov 2019 16:04:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:58108 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731875AbfK0VEd (ORCPT ); Wed, 27 Nov 2019 16:04:33 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5D60F20637; Wed, 27 Nov 2019 21:04:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888672; bh=PBdKjAcHh0/xYmzKeZZ8qeouI77njMrZJRvV4742/wA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t/CHeaBPsBZ2Q8yDQ3g5caate3bKtyVgHy/jzEUvGlioOWPy0oa5mJJkzhM27aSsA bHdnaMeoUL5T+Vzna2nwzEyYcmLL4buB6rPJ2iStA/FmB/9EdbI3bMN05BqyaC/lp3 3yjxolt0rer4S/Y4xMaAfOlg+UAupfNzvGH/ne6s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Suganath Prabu , Bjorn Helgaas , Andy Shevchenko , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.19 224/306] scsi: mpt3sas: Fix Sync cache command failure during driver unload Date: Wed, 27 Nov 2019 21:31:14 +0100 Message-Id: <20191127203131.415433937@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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