diff mbox series

[v2,15/24] mpi3mr: allow certain commands during pci-remove hook

Message ID 20210407020451.924822-16-kashyap.desai@broadcom.com
State Superseded
Headers show
Series Introducing mpi3mr driver | expand

Commit Message

Kashyap Desai April 7, 2021, 2:04 a.m. UTC
This patch allows SSU and Sync Cache commands to be sent to the controller
instead of driver returning DID_NO_CONNECT during driver unload to flush
any cached data from the drive.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cc: sathya.prakash@broadcom.com
---
 drivers/scsi/mpi3mr/mpi3mr_os.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

Comments

Tomas Henzl April 15, 2021, 12:19 p.m. UTC | #1
On 4/7/21 4:04 AM, Kashyap Desai wrote:
> This patch allows SSU and Sync Cache commands to be sent to the controller

> instead of driver returning DID_NO_CONNECT during driver unload to flush

> any cached data from the drive.

> 

> Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>

> Reviewed-by: Hannes Reinecke <hare@suse.de>

> Cc: sathya.prakash@broadcom.com

> ---

>  drivers/scsi/mpi3mr/mpi3mr_os.c | 24 +++++++++++++++++++++++-

>  1 file changed, 23 insertions(+), 1 deletion(-)

> 

> diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c

> index a521e59efd28..558be8c75a88 100644

> --- a/drivers/scsi/mpi3mr/mpi3mr_os.c

> +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c

> @@ -2862,6 +2862,27 @@ static int mpi3mr_target_alloc(struct scsi_target *starget)

>  	return retval;

>  }

>  

> +

> +/**

> + * mpi3mr_allow_scmd_to_fw - Command is allowed during shutdown

> + * @scmd: SCSI Command reference

> + *

> + * Checks whether a CDB is allowed during shutdown or not.

> + *

> + * Return: TRUE for allowed commands, FALSE otherwise.

> + */

> +

> +inline bool mpi3mr_allow_scmd_to_fw(struct scsi_cmnd *scmd)

> +{

> +	switch (scmd->cmnd[0]) {

> +	case SYNCHRONIZE_CACHE:

> +	case START_STOP:

> +		return true;

> +	default:

> +		return false;

> +	}

> +}

> +

>  /**

>   * mpi3mr_qcmd - I/O request despatcher

>   * @shost: SCSI Host reference

> @@ -2897,7 +2918,8 @@ static int mpi3mr_qcmd(struct Scsi_Host *shost,

>  		goto out;

>  	}

>  

> -	if (mrioc->stop_drv_processing) {

> +	if (mrioc->stop_drv_processing &&

> +	    !(mpi3mr_allow_scmd_to_fw(scmd))) {

>  		scmd->result = DID_NO_CONNECT << 16;

>  		scmd->scsi_done(scmd);

>  		goto out;

> 

Looks good

Reviewed-by: Tomas Henzl <thenzl@redhat.com>
diff mbox series

Patch

diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
index a521e59efd28..558be8c75a88 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_os.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
@@ -2862,6 +2862,27 @@  static int mpi3mr_target_alloc(struct scsi_target *starget)
 	return retval;
 }
 
+
+/**
+ * mpi3mr_allow_scmd_to_fw - Command is allowed during shutdown
+ * @scmd: SCSI Command reference
+ *
+ * Checks whether a CDB is allowed during shutdown or not.
+ *
+ * Return: TRUE for allowed commands, FALSE otherwise.
+ */
+
+inline bool mpi3mr_allow_scmd_to_fw(struct scsi_cmnd *scmd)
+{
+	switch (scmd->cmnd[0]) {
+	case SYNCHRONIZE_CACHE:
+	case START_STOP:
+		return true;
+	default:
+		return false;
+	}
+}
+
 /**
  * mpi3mr_qcmd - I/O request despatcher
  * @shost: SCSI Host reference
@@ -2897,7 +2918,8 @@  static int mpi3mr_qcmd(struct Scsi_Host *shost,
 		goto out;
 	}
 
-	if (mrioc->stop_drv_processing) {
+	if (mrioc->stop_drv_processing &&
+	    !(mpi3mr_allow_scmd_to_fw(scmd))) {
 		scmd->result = DID_NO_CONNECT << 16;
 		scmd->scsi_done(scmd);
 		goto out;