From: John Garry <john.garry@huawei.com>
To: <axboe@kernel.dk>, <damien.lemoal@opensource.wdc.com>,
<jejb@linux.ibm.com>, <martin.petersen@oracle.com>,
<brking@us.ibm.com>, <hare@suse.de>, <hch@lst.de>
Cc: <linux-block@vger.kernel.org>, <linux-ide@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-scsi@vger.kernel.org>,
<chenxiang66@hisilicon.com>, John Garry <john.garry@huawei.com>
Subject: [PATCH RFC v2 17/18] scsi: libsas: Queue internal abort commands as requests
Date: Thu, 9 Jun 2022 18:29:18 +0800 [thread overview]
Message-ID: <1654770559-101375-18-git-send-email-john.garry@huawei.com> (raw)
In-Reply-To: <1654770559-101375-1-git-send-email-john.garry@huawei.com>
Like what we did for SMP commands, send internal abort 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@huawei.com>
---
drivers/scsi/hisi_sas/hisi_sas_main.c | 4 +---
drivers/scsi/libsas/sas_init.c | 19 ++++++++++++++----
drivers/scsi/libsas/sas_internal.h | 3 +++
drivers/scsi/libsas/sas_scsi_host.c | 28 +++++++++++++++------------
include/scsi/libsas.h | 16 ++++++++++++++-
5 files changed, 50 insertions(+), 20 deletions(-)
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 2c5c6301f224..50ca7d63ab58 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -554,13 +554,11 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags)
if (test_bit(HISI_SAS_HW_FAULT_BIT, &hisi_hba->flags))
return -EIO;
- hisi_hba = dev_to_hisi_hba(device);
-
if (unlikely(test_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags)))
return -EINVAL;
port = to_hisi_sas_port(sas_port);
- dq = &hisi_hba->dq[task->abort_task.qid];
+ dq = &hisi_hba->dq[sas_task_to_hwq(task)];
break;
default:
dev_err(hisi_hba->dev, "task prep: unknown/unsupported proto (0x%x)\n",
diff --git a/drivers/scsi/libsas/sas_init.c b/drivers/scsi/libsas/sas_init.c
index 8d03b8abcaa3..1224ad2b44ce 100644
--- a/drivers/scsi/libsas/sas_init.c
+++ b/drivers/scsi/libsas/sas_init.c
@@ -23,7 +23,8 @@
static struct kmem_cache *sas_event_cache;
-struct sas_task *sas_alloc_slow_task(struct sas_ha_struct *sas_ha, gfp_t flags)
+struct sas_task *sas_alloc_slow_task_qid(struct sas_ha_struct *sas_ha,
+ gfp_t flags, unsigned int qid)
{
struct request *rq;
struct sas_task *task;
@@ -34,9 +35,14 @@ struct sas_task *sas_alloc_slow_task(struct sas_ha_struct *sas_ha, gfp_t flags)
sdev = shost->sdev;
- rq = scsi_alloc_request(sdev->request_queue, REQ_OP_DRV_IN,
- BLK_MQ_REQ_RESERVED | BLK_MQ_REQ_NOWAIT);
-
+ if (qid == -1U) {
+ rq = scsi_alloc_request(sdev->request_queue, REQ_OP_DRV_IN,
+ BLK_MQ_REQ_RESERVED | BLK_MQ_REQ_NOWAIT);
+ } else {
+ rq = scsi_alloc_request_hwq(sdev->request_queue, REQ_OP_DRV_IN,
+ BLK_MQ_REQ_RESERVED | BLK_MQ_REQ_NOWAIT,
+ qid);
+ }
if (IS_ERR(rq))
return NULL;
@@ -57,6 +63,11 @@ struct sas_task *sas_alloc_slow_task(struct sas_ha_struct *sas_ha, gfp_t flags)
scmd->host_scribble = NULL;
return task;
}
+
+struct sas_task *sas_alloc_slow_task(struct sas_ha_struct *sas_ha, gfp_t flags)
+{
+ return sas_alloc_slow_task_qid(sas_ha, flags, -1U);
+}
EXPORT_SYMBOL_GPL(sas_alloc_slow_task);
void sas_free_task(struct sas_task *task)
diff --git a/drivers/scsi/libsas/sas_internal.h b/drivers/scsi/libsas/sas_internal.h
index 52cfa75d432b..eb70cc0d04fe 100644
--- a/drivers/scsi/libsas/sas_internal.h
+++ b/drivers/scsi/libsas/sas_internal.h
@@ -102,6 +102,9 @@ int sas_execute_tmf(struct domain_device *device, void *parameter,
void sas_task_complete_internal(struct sas_task *task);
void sas_blk_end_sync_rq(struct request *rq, blk_status_t error);
+struct sas_task *sas_alloc_slow_task_qid(struct sas_ha_struct *sas_ha,
+ gfp_t flags, unsigned int qid);
+
#ifdef CONFIG_SCSI_SAS_HOST_SMP
extern void sas_smp_host_handler(struct bsg_job *job, struct Scsi_Host *shost);
#else
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index 520c301e4319..3c62a104f049 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -973,28 +973,32 @@ static int sas_execute_internal_abort(struct domain_device *device,
int res, retry;
for (retry = 0; retry < TASK_RETRY; retry++) {
- task = sas_alloc_slow_task(ha, GFP_KERNEL);
- if (!task)
- return -ENOMEM;
+ struct scsi_cmnd *scmd;
+ struct request *rq;
+
+ task = sas_alloc_slow_task_qid(ha, GFP_KERNEL, qid);
+ if (!task) {
+ res = -ENOMEM;
+ break;
+ }
task->dev = device;
task->task_proto = SAS_PROTOCOL_INTERNAL_ABORT;
- task->task_done = sas_task_internal_done;
+ task->task_done = sas_task_complete_internal;
task->slow_task->timer.function = sas_task_internal_timedout;
task->slow_task->timer.expires = jiffies + TASK_TIMEOUT;
add_timer(&task->slow_task->timer);
task->abort_task.tag = tag;
task->abort_task.type = type;
- task->abort_task.qid = qid;
- res = i->dft->lldd_execute_task(task, GFP_KERNEL);
- if (res) {
- del_timer_sync(&task->slow_task->timer);
- pr_err("Executing internal abort failed %016llx (%d)\n",
- SAS_ADDR(device->sas_addr), res);
- break;
- }
+ rq = sas_rq_from_task(task);
+
+ scmd = blk_mq_rq_to_pdu(rq);
+ ASSIGN_SAS_TASK(scmd, task);
+
+ rq->end_io = sas_blk_end_sync_rq;
+ blk_execute_rq_nowait(rq, true);
wait_for_completion(&task->slow_task->completion);
res = TMF_RESP_FUNC_FAILED;
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index 024b4c4eec3b..62acbc8a46fd 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -565,7 +565,6 @@ enum sas_internal_abort {
struct sas_internal_abort_task {
enum sas_internal_abort type;
- unsigned int qid;
u16 tag;
};
@@ -785,4 +784,19 @@ static inline struct sas_task *sas_scmd_to_task(struct scsi_cmnd *scmd)
return sas_rq_to_task(rq);
}
+static inline u32 sas_task_to_rq_unique_tag(struct sas_task *task)
+{
+ struct request *rq = sas_rq_from_task(task);
+
+ return blk_mq_unique_tag(rq);
+}
+
+static inline unsigned int sas_task_to_hwq(struct sas_task *task)
+{
+ u32 unique = sas_task_to_rq_unique_tag(task);
+
+ return blk_mq_unique_tag_to_hwq(unique);
+}
+
+
#endif /* _SASLIB_H_ */
--
2.26.2
next prev parent reply other threads:[~2022-06-09 10:38 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-09 10:29 [PATCH RFC v2 00/18] blk-mq/libata/scsi: SCSI driver tagging improvements John Garry
2022-06-09 10:29 ` [PATCH RFC v2 01/18] blk-mq: Add a flag for reserved requests John Garry
2022-06-14 6:43 ` Christoph Hellwig
2022-06-14 9:29 ` John Garry
2022-06-14 18:00 ` Bart Van Assche
2022-06-14 18:30 ` John Garry
2022-06-09 10:29 ` [PATCH RFC v2 02/18] scsi: core: Resurrect scsi_{get,free}_host_dev() John Garry
2022-06-14 6:44 ` Christoph Hellwig
2022-06-14 9:33 ` John Garry
2022-06-14 19:33 ` Bart Van Assche
2022-06-15 13:44 ` John Garry
2022-06-09 10:29 ` [PATCH RFC v2 03/18] scsi: core: Implement reserved command handling John Garry
2022-06-13 7:01 ` Damien Le Moal
2022-06-13 8:25 ` John Garry
2022-06-13 9:06 ` Damien Le Moal
2022-06-13 9:34 ` John Garry
2022-06-13 9:43 ` Damien Le Moal
2022-06-13 10:05 ` John Garry
2022-06-20 6:45 ` Hannes Reinecke
2022-06-20 7:06 ` Damien Le Moal
2022-06-14 18:20 ` Bart Van Assche
2022-06-14 23:43 ` Damien Le Moal
2022-06-15 7:35 ` John Garry
2022-06-16 2:47 ` Damien Le Moal
2022-06-16 8:24 ` John Garry
2022-06-16 8:41 ` Damien Le Moal
2022-06-20 8:27 ` Hannes Reinecke
2022-06-20 9:02 ` Damien Le Moal
2022-06-20 9:05 ` Christoph Hellwig
2022-06-20 11:24 ` Damien Le Moal
2022-06-20 11:56 ` Hannes Reinecke
2022-06-20 8:02 ` Hannes Reinecke
2022-06-20 6:24 ` Hannes Reinecke
2022-06-20 6:28 ` Christoph Hellwig
2022-06-20 7:03 ` Hannes Reinecke
2022-06-20 7:14 ` Damien Le Moal
2022-06-09 10:29 ` [PATCH RFC v2 04/18] scsi: core: Add support to send reserved commands John Garry
2022-06-13 7:03 ` Damien Le Moal
2022-06-13 9:40 ` John Garry
2022-06-13 9:41 ` Damien Le Moal
2022-06-09 10:29 ` [PATCH RFC v2 05/18] scsi: core: Allocate SCSI host sdev when required John Garry
2022-06-09 10:29 ` [PATCH RFC v2 06/18] libata-scsi: Add ata_scsi_queue_internal() John Garry
2022-06-13 7:12 ` Damien Le Moal
2022-06-13 9:41 ` John Garry
2022-06-09 10:29 ` [PATCH RFC v2 07/18] libata-scsi: Add ata_internal_queuecommand() John Garry
2022-06-13 7:16 ` Damien Le Moal
2022-06-13 9:44 ` John Garry
2022-06-09 10:29 ` [PATCH RFC v2 08/18] libata: Queue ATA internal commands as requests John Garry
2022-06-13 7:22 ` Damien Le Moal
2022-06-13 8:13 ` John Garry
2022-06-09 10:29 ` [PATCH RFC v2 09/18] scsi: ipr: Support reserved commands John Garry
2022-06-09 10:29 ` [PATCH RFC v2 10/18] libata/scsi: libsas: Add sas_queuecommand_internal() John Garry
2022-06-09 10:29 ` [PATCH RFC v2 11/18] scsi: libsas: Don't attempt to find scsi host rphy in slave alloc John Garry
2022-06-09 10:29 ` [PATCH RFC v2 12/18] scsi: libsas drivers: Prepare for reserved commands John Garry
2022-06-09 10:29 ` [PATCH RFC v2 13/18] scsi: libsas: Allocate SCSI commands for tasks John Garry
2022-06-09 10:29 ` [PATCH RFC v2 14/18] scsi: libsas: Queue SMP commands as requests John Garry
2022-06-09 10:29 ` [PATCH RFC v2 15/18] scsi: libsas: Queue TMF " John Garry
2022-06-09 10:29 ` [PATCH RFC v2 16/18] scsi: core: Add scsi_alloc_request_hwq() John Garry
2022-06-09 10:29 ` John Garry [this message]
2022-06-09 10:29 ` [PATCH RFC v2 18/18] scsi: libsas drivers: Remove private tag management John Garry
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1654770559-101375-18-git-send-email-john.garry@huawei.com \
--to=john.garry@huawei.com \
--cc=axboe@kernel.dk \
--cc=brking@us.ibm.com \
--cc=chenxiang66@hisilicon.com \
--cc=damien.lemoal@opensource.wdc.com \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=jejb@linux.ibm.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox