Problem: This is a work around for a bug with LSI Fusion MPT SAS2 when pefroming secure erase. Due to the very long time the operation takes commands issued during the erase will time out and will trigger execution of abort hook. Even though the abort hook is called for the specifc command which timed out this leads to entire device halt (scsi_state terminated) and premature termination of the secured erase. Fix: Set device state to busy while erase in progress to reject any incoming commands until the erase is done. The device is blocked any way during this time and cannot execute any other command. More data and logs can be found here - https://drive.google.com/file/d/0B9ocOHYHbbS1Q3VMdkkzeWFkTjg/view Signed-off-by: Andrey Grodzovsky <andrey2805@xxxxxxxxx> Cc: <linux-scsi@xxxxxxxxxxxxxxx> Cc: Sathya Prakash <sathya.prakash@xxxxxxxxxxxx> Cc: Chaitra P B <chaitra.basappa@xxxxxxxxxxxx> Cc: Suganath Prabu Subramani <suganath-prabu.subramani@xxxxxxxxxxxx> Cc: Sreekanth Reddy <Sreekanth.Reddy@xxxxxxxxxxxx> Cc: Hannes Reinecke <hare@xxxxxxx> Cc: <stable@xxxxxxxxxxxxxxx> --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git [PATCH]drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 5a97e32..5542dd02 100644 --- [PATCH]drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -3500,6 +3500,23 @@ _scsih_eedp_error_handling(struct scsi_cmnd *scmd, u16 ioc_status) SAM_STAT_CHECK_CONDITION; } +/** + * This is a work around for a bug with LSI Fusion MPT SAS2 when + * pefroming secure erase. Due to the verly long time the operation + * takes commands issued during the erase will time out and will trigger + * execution of abort hook. This leads to device reset and premature + * termination of the secured erase. + */ +static inline bool disk_erase_command(struct scsi_cmnd *scmd) +{ + /** + * Identify secure erase command according to + * ATA/ATAPI Command Set (ATA8-ACS) p.202 + */ + return scmd->cmd_len == 16 && scmd->cmnd[14] == 0xf4; +} + + /** * _scsih_qcmd - main scsi request entry point @@ -3528,6 +3545,14 @@ _scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd) scsi_print_command(scmd); #endif + /** + * Lock the device for any subsequent command until secured erase + * command is done. + */ + if (disk_erase_command(scmd)) + scsi_internal_device_block(scmd->device); + + sas_device_priv_data = scmd->device->hostdata; if (!sas_device_priv_data || !sas_device_priv_data->sas_target) { scmd->result = DID_NO_CONNECT << 16; @@ -4062,6 +4087,11 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply) if (scmd == NULL) return 1; + /* Secured erase is done. Unlock the device */ + if (disk_erase_command(scmd)) + scsi_internal_device_unblock(scmd->device, SDEV_RUNNING); + + mpi_request = mpt3sas_base_get_msg_frame(ioc, smid); if (mpi_reply == NULL) { -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html