Commit f7c4cdc7 authored by John Garry's avatar John Garry Committed by Jens Axboe

scsi: scsi_debug: Support host tagset

When host_max_queue is set (> 0), set the Scsi_Host.host_tagset such that
blk-mq will use a hostwide tagset over all SCSI host submission queues.

This means that we may expose all submission queues and always use the hwq
chosen by blk-mq.

And since if sdebug_host_max_queue is set, sdebug_max_queue is fixed to the
same value, we can simplify how sdebug_driver_template.can_queue is set.
Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
Tested-by: default avatarDouglas Gilbert <dgilbert@interlog.com>
Acked-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 8d98416a
...@@ -4696,19 +4696,14 @@ static int resp_rwp_zone(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) ...@@ -4696,19 +4696,14 @@ static int resp_rwp_zone(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)
static struct sdebug_queue *get_queue(struct scsi_cmnd *cmnd) static struct sdebug_queue *get_queue(struct scsi_cmnd *cmnd)
{ {
u16 hwq; u16 hwq;
u32 tag = blk_mq_unique_tag(cmnd->request);
if (sdebug_host_max_queue) { hwq = blk_mq_unique_tag_to_hwq(tag);
/* Provide a simple method to choose the hwq */
hwq = smp_processor_id() % submit_queues;
} else {
u32 tag = blk_mq_unique_tag(cmnd->request);
hwq = blk_mq_unique_tag_to_hwq(tag); pr_debug("tag=%#x, hwq=%d\n", tag, hwq);
if (WARN_ON_ONCE(hwq >= submit_queues))
hwq = 0;
pr_debug("tag=%#x, hwq=%d\n", tag, hwq);
if (WARN_ON_ONCE(hwq >= submit_queues))
hwq = 0;
}
return sdebug_q_arr + hwq; return sdebug_q_arr + hwq;
} }
...@@ -7347,10 +7342,7 @@ static int sdebug_driver_probe(struct device *dev) ...@@ -7347,10 +7342,7 @@ static int sdebug_driver_probe(struct device *dev)
sdbg_host = to_sdebug_host(dev); sdbg_host = to_sdebug_host(dev);
if (sdebug_host_max_queue) sdebug_driver_template.can_queue = sdebug_max_queue;
sdebug_driver_template.can_queue = sdebug_host_max_queue;
else
sdebug_driver_template.can_queue = sdebug_max_queue;
if (!sdebug_clustering) if (!sdebug_clustering)
sdebug_driver_template.dma_boundary = PAGE_SIZE - 1; sdebug_driver_template.dma_boundary = PAGE_SIZE - 1;
...@@ -7367,11 +7359,11 @@ static int sdebug_driver_probe(struct device *dev) ...@@ -7367,11 +7359,11 @@ static int sdebug_driver_probe(struct device *dev)
} }
/* /*
* Decide whether to tell scsi subsystem that we want mq. The * Decide whether to tell scsi subsystem that we want mq. The
* following should give the same answer for each host. If the host * following should give the same answer for each host.
* has a limit of hostwide max commands, then do not set.
*/ */
if (!sdebug_host_max_queue) hpnt->nr_hw_queues = submit_queues;
hpnt->nr_hw_queues = submit_queues; if (sdebug_host_max_queue)
hpnt->host_tagset = 1;
sdbg_host->shost = hpnt; sdbg_host->shost = hpnt;
*((struct sdebug_host_info **)hpnt->hostdata) = sdbg_host; *((struct sdebug_host_info **)hpnt->hostdata) = sdbg_host;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment