Skip to content

Commit f49d4ae

Browse files
Chaitra P Bmartinkpetersen
authored andcommitted
scsi: mpt3sas: Proper handling of set/clear of "ATA command pending" flag.
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]>
1 parent 8fd03fd commit f49d4ae

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
@@ -4758,19 +4758,6 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
47584758
return 0;
47594759
}
47604760

4761-
/*
4762-
* Bug work around for firmware SATL handling. The loop
4763-
* is based on atomic operations and ensures consistency
4764-
* since we're lockless at this point
4765-
*/
4766-
do {
4767-
if (test_bit(0, &sas_device_priv_data->ata_command_pending)) {
4768-
scmd->result = SAM_STAT_BUSY;
4769-
scmd->scsi_done(scmd);
4770-
return 0;
4771-
}
4772-
} while (_scsih_set_satl_pending(scmd, true));
4773-
47744761
sas_target_priv_data = sas_device_priv_data->sas_target;
47754762

47764763
/* invalid device handle */
@@ -4796,6 +4783,19 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
47964783
sas_device_priv_data->block)
47974784
return SCSI_MLQUEUE_DEVICE_BUSY;
47984785

4786+
/*
4787+
* Bug work around for firmware SATL handling. The loop
4788+
* is based on atomic operations and ensures consistency
4789+
* since we're lockless at this point
4790+
*/
4791+
do {
4792+
if (test_bit(0, &sas_device_priv_data->ata_command_pending)) {
4793+
scmd->result = SAM_STAT_BUSY;
4794+
scmd->scsi_done(scmd);
4795+
return 0;
4796+
}
4797+
} while (_scsih_set_satl_pending(scmd, true));
4798+
47994799
if (scmd->sc_data_direction == DMA_FROM_DEVICE)
48004800
mpi_control = MPI2_SCSIIO_CONTROL_READ;
48014801
else if (scmd->sc_data_direction == DMA_TO_DEVICE)
@@ -4823,6 +4823,7 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
48234823
if (!smid) {
48244824
pr_err(MPT3SAS_FMT "%s: failed obtaining a smid\n",
48254825
ioc->name, __func__);
4826+
_scsih_set_satl_pending(scmd, false);
48264827
goto out;
48274828
}
48284829
mpi_request = mpt3sas_base_get_msg_frame(ioc, smid);
@@ -4854,6 +4855,7 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
48544855
pcie_device = sas_target_priv_data->pcie_dev;
48554856
if (ioc->build_sg_scmd(ioc, scmd, smid, pcie_device)) {
48564857
mpt3sas_base_free_smid(ioc, smid);
4858+
_scsih_set_satl_pending(scmd, false);
48574859
goto out;
48584860
}
48594861
} else

0 commit comments

Comments
 (0)