From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it0-f67.google.com ([209.85.214.67]:36032 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752270AbcKQBPZ (ORCPT ); Wed, 16 Nov 2016 20:15:25 -0500 Received: by mail-it0-f67.google.com with SMTP id n68so11273104itn.3 for ; Wed, 16 Nov 2016 17:15:25 -0800 (PST) From: Andrey Grodzovsky To: stable@vger.kernel.org Cc: Andrey Grodzovsky , Sreekanth Reddy , Hannes Reinecke , PDL-MPT-FUSIONLINUX , "Martin K. Petersen" Subject: [PATCH] [SCSI] mpt2sas: Fix secure erase premature termination Date: Wed, 16 Nov 2016 20:15:08 -0500 Message-Id: <1479345308-27261-1-git-send-email-andrey2805@gmail.com> In-Reply-To: References: Sender: stable-owner@vger.kernel.org List-ID: 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 specific 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 P.S This is a backport from the same fix for mpt3sas driver intended for pre-4.4 stable trees. Signed-off-by: Andrey Grodzovsky Cc: Sreekanth Reddy Cc: Hannes Reinecke Cc: PDL-MPT-FUSIONLINUX Cc: Martin K. Petersen --- drivers/scsi/mpt2sas/mpt2sas_scsih.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c index 3f26147..988c1da 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c @@ -3884,6 +3884,11 @@ _scsih_setup_direct_io(struct MPT2SAS_ADAPTER *ioc, struct scsi_cmnd *scmd, _scsih_scsi_direct_io_set(ioc, smid, 1); } +static inline bool ata_12_16_cmd(struct scsi_cmnd *scmd) +{ + return (scmd->cmnd[0] == ATA_12 || scmd->cmnd[0] == ATA_16); +} + /** * _scsih_qcmd - main scsi request entry point * @scmd: pointer to scsi command object @@ -3906,6 +3911,13 @@ _scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd) u32 mpi_control; u16 smid; + /** + * Lock the device for any subsequent command until + * command is done. + */ + if (ata_12_16_cmd(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; @@ -4447,6 +4459,9 @@ _scsih_io_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply) if (scmd == NULL) return 1; + if (ata_12_16_cmd(scmd)) + scsi_internal_device_unblock(scmd->device, SDEV_RUNNING); + mpi_request = mpt2sas_base_get_msg_frame(ioc, smid); if (mpi_reply == NULL) { -- 2.1.4