Skip to content

Commit af18309

Browse files
kadesai16martinkpetersen
authored andcommitted
scsi: core: Add mq_poll support to SCSI layer
Currently IOPOLL support is only available in block layer. This patch adds mq_poll support to the SCSI layer. Link: https://lore.kernel.org/r/[email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: John Garry <[email protected]> Signed-off-by: Kashyap Desai <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 39ae3ed commit af18309

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

drivers/scsi/scsi_lib.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,6 +1810,19 @@ static void scsi_mq_exit_request(struct blk_mq_tag_set *set, struct request *rq,
18101810
cmd->sense_buffer);
18111811
}
18121812

1813+
1814+
static int scsi_mq_poll(struct blk_mq_hw_ctx *hctx)
1815+
{
1816+
struct request_queue *q = hctx->queue;
1817+
struct scsi_device *sdev = q->queuedata;
1818+
struct Scsi_Host *shost = sdev->host;
1819+
1820+
if (shost->hostt->mq_poll)
1821+
return shost->hostt->mq_poll(shost, hctx->queue_num);
1822+
1823+
return 0;
1824+
}
1825+
18131826
static int scsi_map_queues(struct blk_mq_tag_set *set)
18141827
{
18151828
struct Scsi_Host *shost = container_of(set, struct Scsi_Host, tag_set);
@@ -1877,6 +1890,7 @@ static const struct blk_mq_ops scsi_mq_ops_no_commit = {
18771890
.cleanup_rq = scsi_cleanup_rq,
18781891
.busy = scsi_mq_lld_busy,
18791892
.map_queues = scsi_map_queues,
1893+
.poll = scsi_mq_poll,
18801894
.set_rq_budget_token = scsi_mq_set_rq_budget_token,
18811895
.get_rq_budget_token = scsi_mq_get_rq_budget_token,
18821896
};
@@ -1907,6 +1921,7 @@ static const struct blk_mq_ops scsi_mq_ops = {
19071921
.cleanup_rq = scsi_cleanup_rq,
19081922
.busy = scsi_mq_lld_busy,
19091923
.map_queues = scsi_map_queues,
1924+
.poll = scsi_mq_poll,
19101925
.set_rq_budget_token = scsi_mq_set_rq_budget_token,
19111926
.get_rq_budget_token = scsi_mq_get_rq_budget_token,
19121927
};
@@ -1941,6 +1956,7 @@ int scsi_mq_setup_tags(struct Scsi_Host *shost)
19411956
else
19421957
tag_set->ops = &scsi_mq_ops_no_commit;
19431958
tag_set->nr_hw_queues = shost->nr_hw_queues ? : 1;
1959+
tag_set->nr_maps = shost->nr_maps ? : 1;
19441960
tag_set->queue_depth = shost->can_queue;
19451961
tag_set->cmd_size = cmd_size;
19461962
tag_set->numa_node = NUMA_NO_NODE;

include/scsi/scsi_cmnd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/timer.h>
1111
#include <linux/scatterlist.h>
1212
#include <scsi/scsi_device.h>
13+
#include <scsi/scsi_host.h>
1314
#include <scsi/scsi_request.h>
1415

1516
struct Scsi_Host;

include/scsi/scsi_host.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,16 @@ struct scsi_host_template {
280280
*/
281281
int (* map_queues)(struct Scsi_Host *shost);
282282

283+
/*
284+
* SCSI interface of blk_poll - poll for IO completions.
285+
* Only applicable if SCSI LLD exposes multiple h/w queues.
286+
*
287+
* Return value: Number of completed entries found.
288+
*
289+
* Status: OPTIONAL
290+
*/
291+
int (* mq_poll)(struct Scsi_Host *shost, unsigned int queue_num);
292+
283293
/*
284294
* Check if scatterlists need to be padded for DMA draining.
285295
*
@@ -622,6 +632,7 @@ struct Scsi_Host {
622632
* the total queue depth is can_queue.
623633
*/
624634
unsigned nr_hw_queues;
635+
unsigned nr_maps;
625636
unsigned active_mode:2;
626637
unsigned unchecked_isa_dma:1;
627638

0 commit comments

Comments
 (0)