aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/virtio_scsi.c
diff options
context:
space:
mode:
authorMing Lei <ming.lei@canonical.com>2014-11-14 22:47:14 -0500
committerChristoph Hellwig <hch@lst.de>2014-11-20 03:11:28 -0500
commitccbedf117f015d4f415130069b47d63c359bc110 (patch)
tree4280fcb1b70e7191305c7f8d18bfa774c90072c3 /drivers/scsi/virtio_scsi.c
parent4c413128a6ff3af013bd1d82860a7ee60f93fb28 (diff)
virtio_scsi: support multi hw queue of blk-mq
Since virtio_scsi has supported multi virtqueue already, it is natural to map the virtque to hw-queue of blk-mq. Signed-off-by: Ming Lei <ming.lei@canonical.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/scsi/virtio_scsi.c')
-rw-r--r--drivers/scsi/virtio_scsi.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 355afbc7fde1..8e40347da0a8 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -561,6 +561,15 @@ static int virtscsi_queuecommand_single(struct Scsi_Host *sh,
561 return virtscsi_queuecommand(vscsi, &vscsi->req_vqs[0], sc); 561 return virtscsi_queuecommand(vscsi, &vscsi->req_vqs[0], sc);
562} 562}
563 563
564static struct virtio_scsi_vq *virtscsi_pick_vq_mq(struct virtio_scsi *vscsi,
565 struct scsi_cmnd *sc)
566{
567 u32 tag = blk_mq_unique_tag(sc->request);
568 u16 hwq = blk_mq_unique_tag_to_hwq(tag);
569
570 return &vscsi->req_vqs[hwq];
571}
572
564static struct virtio_scsi_vq *virtscsi_pick_vq(struct virtio_scsi *vscsi, 573static struct virtio_scsi_vq *virtscsi_pick_vq(struct virtio_scsi *vscsi,
565 struct virtio_scsi_target_state *tgt) 574 struct virtio_scsi_target_state *tgt)
566{ 575{
@@ -604,7 +613,12 @@ static int virtscsi_queuecommand_multi(struct Scsi_Host *sh,
604 struct virtio_scsi *vscsi = shost_priv(sh); 613 struct virtio_scsi *vscsi = shost_priv(sh);
605 struct virtio_scsi_target_state *tgt = 614 struct virtio_scsi_target_state *tgt =
606 scsi_target(sc->device)->hostdata; 615 scsi_target(sc->device)->hostdata;
607 struct virtio_scsi_vq *req_vq = virtscsi_pick_vq(vscsi, tgt); 616 struct virtio_scsi_vq *req_vq;
617
618 if (shost_use_blk_mq(sh))
619 req_vq = virtscsi_pick_vq_mq(vscsi, sc);
620 else
621 req_vq = virtscsi_pick_vq(vscsi, tgt);
608 622
609 return virtscsi_queuecommand(vscsi, req_vq, sc); 623 return virtscsi_queuecommand(vscsi, req_vq, sc);
610} 624}
@@ -981,6 +995,7 @@ static int virtscsi_probe(struct virtio_device *vdev)
981 shost->max_id = num_targets; 995 shost->max_id = num_targets;
982 shost->max_channel = 0; 996 shost->max_channel = 0;
983 shost->max_cmd_len = VIRTIO_SCSI_CDB_SIZE; 997 shost->max_cmd_len = VIRTIO_SCSI_CDB_SIZE;
998 shost->nr_hw_queues = num_queues;
984 999
985 if (virtio_has_feature(vdev, VIRTIO_SCSI_F_T10_PI)) { 1000 if (virtio_has_feature(vdev, VIRTIO_SCSI_F_T10_PI)) {
986 host_prot = SHOST_DIF_TYPE1_PROTECTION | SHOST_DIF_TYPE2_PROTECTION | 1001 host_prot = SHOST_DIF_TYPE1_PROTECTION | SHOST_DIF_TYPE2_PROTECTION |