Skip to content

Commit b5d2caf

Browse files
Chaitra P Bgregkh
authored andcommitted
scsi: mpt3sas: Proper handling of set/clear of "ATA command pending" flag.
[ Upstream commit f49d4ae ] 1. In IO path, setting of "ATA command pending" flag early before device removal, invalid device handle etc., checks causes any new commands to be always returned with SAM_STAT_BUSY and when the driver removes the drive the SML issues SYNC Cache command and that command is always returned with SAM_STAT_BUSY and thus making SYNC Cache command to requeued. 2. If the driver gets an ATA PT command for a SATA drive then the driver set "ATA command pending" flag in device specific data structure not to allow any further commands until the ATA PT command is completed. However, after setting the flag if the driver decides to return the command back to upper layers without actually issuing to the firmware (i.e., returns from qcmd failure return paths) then the corresponding flag is not cleared and this prevents the driver from sending any new commands to the drive. This patch fixes above two issues by setting of "ATA command pending" flag after checking for whether device deleted, invalid device handle, device busy with task management. And by setting "ATA command pending" flag to false in all of the qcmd failure return paths after setting the flag. Signed-off-by: Chaitra P B <[email protected]> Signed-off-by: Suganath Prabu S <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 3807b6f commit b5d2caf

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

drivers/scsi/mpt3sas/mpt3sas_scsih.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4106,19 +4106,6 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
41064106
return 0;
41074107
}
41084108

4109-
/*
4110-
* Bug work around for firmware SATL handling. The loop
4111-
* is based on atomic operations and ensures consistency
4112-
* since we're lockless at this point
4113-
*/
4114-
do {
4115-
if (test_bit(0, &sas_device_priv_data->ata_command_pending)) {
4116-
scmd->result = SAM_STAT_BUSY;
4117-
scmd->scsi_done(scmd);
4118-
return 0;
4119-
}
4120-
} while (_scsih_set_satl_pending(scmd, true));
4121-
41224109
sas_target_priv_data = sas_device_priv_data->sas_target;
41234110

41244111
/* invalid device handle */
@@ -4144,6 +4131,19 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
41444131
sas_device_priv_data->block)
41454132
return SCSI_MLQUEUE_DEVICE_BUSY;
41464133

4134+
/*
4135+
* Bug work around for firmware SATL handling. The loop
4136+
* is based on atomic operations and ensures consistency
4137+
* since we're lockless at this point
4138+
*/
4139+
do {
4140+
if (test_bit(0, &sas_device_priv_data->ata_command_pending)) {
4141+
scmd->result = SAM_STAT_BUSY;
4142+
scmd->scsi_done(scmd);
4143+
return 0;
4144+
}
4145+
} while (_scsih_set_satl_pending(scmd, true));
4146+
41474147
if (scmd->sc_data_direction == DMA_FROM_DEVICE)
41484148
mpi_control = MPI2_SCSIIO_CONTROL_READ;
41494149
else if (scmd->sc_data_direction == DMA_TO_DEVICE)
@@ -4170,6 +4170,7 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
41704170
if (!smid) {
41714171
pr_err(MPT3SAS_FMT "%s: failed obtaining a smid\n",
41724172
ioc->name, __func__);
4173+
_scsih_set_satl_pending(scmd, false);
41734174
goto out;
41744175
}
41754176
mpi_request = mpt3sas_base_get_msg_frame(ioc, smid);
@@ -4200,6 +4201,7 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
42004201
if (mpi_request->DataLength) {
42014202
if (ioc->build_sg_scmd(ioc, scmd, smid)) {
42024203
mpt3sas_base_free_smid(ioc, smid);
4204+
_scsih_set_satl_pending(scmd, false);
42034205
goto out;
42044206
}
42054207
} else

0 commit comments

Comments
 (0)