[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1647945585-197349-6-git-send-email-john.garry@huawei.com>
Date: Tue, 22 Mar 2022 18:39:39 +0800
From: John Garry <john.garry@...wei.com>
To: <axboe@...nel.dk>, <damien.lemoal@...nsource.wdc.com>,
<bvanassche@....org>, <jejb@...ux.ibm.com>,
<martin.petersen@...cle.com>, <hch@....de>, <ming.lei@...hat.com>,
<hare@...e.de>
CC: <chenxiang66@...ilicon.com>, <linux-block@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <linux-ide@...r.kernel.org>,
<linux-scsi@...r.kernel.org>, <dm-devel@...hat.com>,
<beanhuo@...ron.com>, John Garry <john.garry@...wei.com>
Subject: [PATCH 05/11] scsi: libsas: Send TMF commands through the block layer
Like what we did with SMP commands, send TMF commands through the block
layer.
Signed-off-by: John Garry <john.garry@...wei.com>
---
drivers/scsi/libsas/sas_scsi_host.c | 44 +++++++++++++++++++++--------
1 file changed, 32 insertions(+), 12 deletions(-)
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index 91133ad37ae8..04c6298d1340 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -1070,15 +1070,39 @@ int sas_execute_tmf(struct domain_device *device, void *parameter,
struct sas_internal *i =
to_sas_internal(device->port->ha->core.shost->transportt);
int res, retry;
+ struct request_queue *request_queue;
+ struct request *rq;
+ struct sas_ha_struct *ha = device->port->ha;
+ struct Scsi_Host *shost = ha->core.shost;
+
+ request_queue = sas_alloc_request_queue(shost);
+ if (IS_ERR(request_queue))
+ return PTR_ERR(request_queue);
for (retry = 0; retry < TASK_RETRY; retry++) {
+ struct scsi_cmnd *scmd;
+
task = sas_alloc_slow_task(GFP_KERNEL);
- if (!task)
- return -ENOMEM;
+ if (!task) {
+ res = -ENOMEM;
+ break;
+ }
task->dev = device;
task->task_proto = device->tproto;
+ rq = scsi_alloc_request(request_queue, REQ_OP_DRV_IN, 0);
+ if (IS_ERR(rq)) {
+ res = PTR_ERR(rq);
+ break;
+ }
+
+ scmd = blk_mq_rq_to_pdu(rq);
+ scmd->submitter = SUBMITTED_BY_SCSI_CUSTOM_OPS;
+ ASSIGN_SAS_TASK(scmd, task);
+
+ task->uldd_task = scmd;
+
if (dev_is_sata(device)) {
task->ata_task.device_control_reg_update = 1;
if (force_phy_id >= 0) {
@@ -1093,20 +1117,14 @@ int sas_execute_tmf(struct domain_device *device, void *parameter,
task->task_done = sas_task_internal_done;
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);
+ rq->timeout = TASK_TIMEOUT;
- 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;
- }
+ blk_execute_rq_nowait(rq, true, NULL);
wait_for_completion(&task->slow_task->completion);
+ __blk_mq_end_request(rq, BLK_STS_OK);
+
if (i->dft->lldd_tmf_exec_complete)
i->dft->lldd_tmf_exec_complete(device);
@@ -1177,6 +1195,8 @@ int sas_execute_tmf(struct domain_device *device, void *parameter,
SAS_ADDR(device->sas_addr), TASK_RETRY);
sas_free_task(task);
+ blk_cleanup_queue(request_queue);
+
return res;
}
--
2.26.2
Powered by blists - more mailing lists