linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Suganath Prabu <suganath-prabu.subramani@broadcom.com>
To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Sathya.Prakash@broadcom.com, sreekanth.reddy@broadcom.com,
	Suganath Prabu <suganath-prabu.subramani@broadcom.com>
Subject: [PATCH v7 5/8] mpt3sas: Fix Sync cache command failure during driver unload
Date: Wed, 31 Oct 2018 18:53:36 +0530	[thread overview]
Message-ID: <1540992219-20291-6-git-send-email-suganath-prabu.subramani@broadcom.com> (raw)
In-Reply-To: <1540992219-20291-1-git-send-email-suganath-prabu.subramani@broadcom.com>

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 <suganath-prabu.subramani@broadcom.com>
---
 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


  parent reply	other threads:[~2018-10-31 13:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-31 13:23 [PATCH v7 0/8] mpt3sas: some bug fixes patches Suganath Prabu
2018-10-31 13:23 ` [PATCH v7 1/8] mpt3sas: Added new #define variable IOC_OPERATIONAL_WAIT_COUNT Suganath Prabu
2018-10-31 13:23 ` [PATCH v7 2/8] mpt3sas: Separate out mpt3sas_wait_for_ioc Suganath Prabu
2018-10-31 13:23 ` [PATCH v7 3/8] mpt3sas: Refactor mpt3sas_wait_for_ioc function Suganath Prabu
2018-10-31 13:23 ` [PATCH v7 4/8] mpt3sas: Call sas_remove_host before removing the target devices Suganath Prabu
2018-10-31 13:23 ` Suganath Prabu [this message]
2018-10-31 13:23 ` [PATCH v7 6/8] mpt3sas: Don't modify EEDPTagMode field setting on SAS3.5 HBA devices Suganath Prabu
2018-10-31 13:23 ` [PATCH v7 7/8] mpt3sas: Fix driver modifying persistent data in Manufacturing page11 Suganath Prabu
2018-10-31 13:23 ` [PATCH v7 8/8] mpt3sas: Bump driver version to 27.100.00.00 Suganath Prabu
2018-11-02 18:25 ` [PATCH v7 0/8] mpt3sas: some bug fixes patches Bjorn Helgaas
2018-11-02 18:35   ` Andy Shevchenko
2018-11-07  1:45 ` Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1540992219-20291-6-git-send-email-suganath-prabu.subramani@broadcom.com \
    --to=suganath-prabu.subramani@broadcom.com \
    --cc=Sathya.Prakash@broadcom.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=sreekanth.reddy@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).