Like what we did with SMP commands, send TMF commands through the block layer. In future we can now also take advantage of the block layer request timeout handling. Signed-off-by: John Garry <john.garry@xxxxxxxxxx> --- drivers/scsi/libsas/sas_scsi_host.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c index f0566f4512b2..520c301e4319 100644 --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c @@ -1059,18 +1059,27 @@ int sas_execute_tmf(struct domain_device *device, void *parameter, struct sas_task *task; struct sas_internal *i = to_sas_internal(device->port->ha->core.shost->transportt); - struct sas_ha_struct *ha = device->port->ha; int res, retry; - + struct request *rq; + struct sas_ha_struct *ha = device->port->ha; for (retry = 0; retry < TASK_RETRY; retry++) { + struct scsi_cmnd *scmd; + task = sas_alloc_slow_task(ha, GFP_KERNEL); - if (!task) - return -ENOMEM; + if (!task) { + res = -ENOMEM; + break; + } task->dev = device; task->task_proto = device->tproto; + rq = sas_rq_from_task(task); + + scmd = blk_mq_rq_to_pdu(rq); + ASSIGN_SAS_TASK(scmd, task); + if (dev_is_sata(device)) { task->ata_task.device_control_reg_update = 1; if (force_phy_id >= 0) { @@ -1082,20 +1091,15 @@ int sas_execute_tmf(struct domain_device *device, void *parameter, memcpy(&task->ssp_task, parameter, para_len); } - task->task_done = sas_task_internal_done; + task->task_done = sas_task_complete_internal; task->tmf = tmf; task->slow_task->timer.function = sas_task_internal_timedout; task->slow_task->timer.expires = jiffies + TASK_TIMEOUT; add_timer(&task->slow_task->timer); - res = i->dft->lldd_execute_task(task, GFP_KERNEL); - if (res) { - del_timer_sync(&task->slow_task->timer); - pr_err("executing TMF task failed %016llx (%d)\n", - SAS_ADDR(device->sas_addr), res); - break; - } + rq->end_io = sas_blk_end_sync_rq; + blk_execute_rq_nowait(rq, true); wait_for_completion(&task->slow_task->completion); -- 2.26.2