@@ -3899,9 +3899,18 @@ _scsih_temp_threshold_events(struct MPT3SAS_ADAPTER *ioc,
3899
3899
}
3900
3900
}
3901
3901
3902
- static inline bool ata_12_16_cmd (struct scsi_cmnd * scmd )
3902
+ static int _scsih_set_satl_pending (struct scsi_cmnd * scmd , bool pending )
3903
3903
{
3904
- return (scmd -> cmnd [0 ] == ATA_12 || scmd -> cmnd [0 ] == ATA_16 );
3904
+ struct MPT3SAS_DEVICE * priv = scmd -> device -> hostdata ;
3905
+
3906
+ if (scmd -> cmnd [0 ] != ATA_12 && scmd -> cmnd [0 ] != ATA_16 )
3907
+ return 0 ;
3908
+
3909
+ if (pending )
3910
+ return test_and_set_bit (0 , & priv -> ata_command_pending );
3911
+
3912
+ clear_bit (0 , & priv -> ata_command_pending );
3913
+ return 0 ;
3905
3914
}
3906
3915
3907
3916
/**
@@ -3925,9 +3934,7 @@ _scsih_flush_running_cmds(struct MPT3SAS_ADAPTER *ioc)
3925
3934
if (!scmd )
3926
3935
continue ;
3927
3936
count ++ ;
3928
- if (ata_12_16_cmd (scmd ))
3929
- scsi_internal_device_unblock (scmd -> device ,
3930
- SDEV_RUNNING );
3937
+ _scsih_set_satl_pending (scmd , false);
3931
3938
mpt3sas_base_free_smid (ioc , smid );
3932
3939
scsi_dma_unmap (scmd );
3933
3940
if (ioc -> pci_error_recovery )
@@ -4063,13 +4070,6 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
4063
4070
if (ioc -> logging_level & MPT_DEBUG_SCSI )
4064
4071
scsi_print_command (scmd );
4065
4072
4066
- /*
4067
- * Lock the device for any subsequent command until command is
4068
- * done.
4069
- */
4070
- if (ata_12_16_cmd (scmd ))
4071
- scsi_internal_device_block (scmd -> device );
4072
-
4073
4073
sas_device_priv_data = scmd -> device -> hostdata ;
4074
4074
if (!sas_device_priv_data || !sas_device_priv_data -> sas_target ) {
4075
4075
scmd -> result = DID_NO_CONNECT << 16 ;
@@ -4083,6 +4083,19 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
4083
4083
return 0 ;
4084
4084
}
4085
4085
4086
+ /*
4087
+ * Bug work around for firmware SATL handling. The loop
4088
+ * is based on atomic operations and ensures consistency
4089
+ * since we're lockless at this point
4090
+ */
4091
+ do {
4092
+ if (test_bit (0 , & sas_device_priv_data -> ata_command_pending )) {
4093
+ scmd -> result = SAM_STAT_BUSY ;
4094
+ scmd -> scsi_done (scmd );
4095
+ return 0 ;
4096
+ }
4097
+ } while (_scsih_set_satl_pending (scmd , true));
4098
+
4086
4099
sas_target_priv_data = sas_device_priv_data -> sas_target ;
4087
4100
4088
4101
/* invalid device handle */
@@ -4650,8 +4663,7 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)
4650
4663
if (scmd == NULL )
4651
4664
return 1 ;
4652
4665
4653
- if (ata_12_16_cmd (scmd ))
4654
- scsi_internal_device_unblock (scmd -> device , SDEV_RUNNING );
4666
+ _scsih_set_satl_pending (scmd , false);
4655
4667
4656
4668
mpi_request = mpt3sas_base_get_msg_frame (ioc , smid );
4657
4669
0 commit comments