diff options
| -rw-r--r-- | MAINTAINERS | 3 | ||||
| -rw-r--r-- | drivers/block/virtio_blk.c | 20 | ||||
| -rw-r--r-- | drivers/char/hw_random/virtio-rng.c | 3 | ||||
| -rw-r--r-- | drivers/net/virtio_net.c | 2 | ||||
| -rw-r--r-- | drivers/virtio/virtio_balloon.c | 14 | ||||
| -rw-r--r-- | drivers/virtio/virtio_pci.c | 6 | ||||
| -rw-r--r-- | drivers/virtio/virtio_ring.c | 12 | ||||
| -rw-r--r-- | tools/virtio/linux/kmemleak.h | 3 | ||||
| -rw-r--r-- | tools/virtio/linux/virtio.h | 4 | ||||
| -rw-r--r-- | tools/virtio/virtio_test.c | 2 |
10 files changed, 45 insertions, 24 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index e2ed69f1c430..ee175ff17256 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
| @@ -9432,7 +9432,6 @@ F: include/media/videobuf2-* | |||
| 9432 | 9432 | ||
| 9433 | VIRTIO CONSOLE DRIVER | 9433 | VIRTIO CONSOLE DRIVER |
| 9434 | M: Amit Shah <amit.shah@redhat.com> | 9434 | M: Amit Shah <amit.shah@redhat.com> |
| 9435 | L: virtio-dev@lists.oasis-open.org | ||
| 9436 | L: virtualization@lists.linux-foundation.org | 9435 | L: virtualization@lists.linux-foundation.org |
| 9437 | S: Maintained | 9436 | S: Maintained |
| 9438 | F: drivers/char/virtio_console.c | 9437 | F: drivers/char/virtio_console.c |
| @@ -9442,7 +9441,6 @@ F: include/uapi/linux/virtio_console.h | |||
| 9442 | VIRTIO CORE, NET AND BLOCK DRIVERS | 9441 | VIRTIO CORE, NET AND BLOCK DRIVERS |
| 9443 | M: Rusty Russell <rusty@rustcorp.com.au> | 9442 | M: Rusty Russell <rusty@rustcorp.com.au> |
| 9444 | M: "Michael S. Tsirkin" <mst@redhat.com> | 9443 | M: "Michael S. Tsirkin" <mst@redhat.com> |
| 9445 | L: virtio-dev@lists.oasis-open.org | ||
| 9446 | L: virtualization@lists.linux-foundation.org | 9444 | L: virtualization@lists.linux-foundation.org |
| 9447 | S: Maintained | 9445 | S: Maintained |
| 9448 | F: drivers/virtio/ | 9446 | F: drivers/virtio/ |
| @@ -9455,7 +9453,6 @@ F: include/uapi/linux/virtio_*.h | |||
| 9455 | VIRTIO HOST (VHOST) | 9453 | VIRTIO HOST (VHOST) |
| 9456 | M: "Michael S. Tsirkin" <mst@redhat.com> | 9454 | M: "Michael S. Tsirkin" <mst@redhat.com> |
| 9457 | L: kvm@vger.kernel.org | 9455 | L: kvm@vger.kernel.org |
| 9458 | L: virtio-dev@lists.oasis-open.org | ||
| 9459 | L: virtualization@lists.linux-foundation.org | 9456 | L: virtualization@lists.linux-foundation.org |
| 9460 | L: netdev@vger.kernel.org | 9457 | L: netdev@vger.kernel.org |
| 9461 | S: Maintained | 9458 | S: Maintained |
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 0eace43cea11..6d8a87f252de 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c | |||
| @@ -158,6 +158,7 @@ static int virtio_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *req) | |||
| 158 | unsigned long flags; | 158 | unsigned long flags; |
| 159 | unsigned int num; | 159 | unsigned int num; |
| 160 | const bool last = (req->cmd_flags & REQ_END) != 0; | 160 | const bool last = (req->cmd_flags & REQ_END) != 0; |
| 161 | int err; | ||
| 161 | 162 | ||
| 162 | BUG_ON(req->nr_phys_segments + 2 > vblk->sg_elems); | 163 | BUG_ON(req->nr_phys_segments + 2 > vblk->sg_elems); |
| 163 | 164 | ||
| @@ -198,11 +199,16 @@ static int virtio_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *req) | |||
| 198 | } | 199 | } |
| 199 | 200 | ||
| 200 | spin_lock_irqsave(&vblk->vq_lock, flags); | 201 | spin_lock_irqsave(&vblk->vq_lock, flags); |
| 201 | if (__virtblk_add_req(vblk->vq, vbr, vbr->sg, num) < 0) { | 202 | err = __virtblk_add_req(vblk->vq, vbr, vbr->sg, num); |
| 203 | if (err) { | ||
| 202 | virtqueue_kick(vblk->vq); | 204 | virtqueue_kick(vblk->vq); |
| 203 | spin_unlock_irqrestore(&vblk->vq_lock, flags); | 205 | spin_unlock_irqrestore(&vblk->vq_lock, flags); |
| 204 | blk_mq_stop_hw_queue(hctx); | 206 | blk_mq_stop_hw_queue(hctx); |
| 205 | return BLK_MQ_RQ_QUEUE_BUSY; | 207 | /* Out of mem doesn't actually happen, since we fall back |
| 208 | * to direct descriptors */ | ||
| 209 | if (err == -ENOMEM || err == -ENOSPC) | ||
| 210 | return BLK_MQ_RQ_QUEUE_BUSY; | ||
| 211 | return BLK_MQ_RQ_QUEUE_ERROR; | ||
| 206 | } | 212 | } |
| 207 | 213 | ||
| 208 | if (last) | 214 | if (last) |
| @@ -485,10 +491,11 @@ static struct blk_mq_ops virtio_mq_ops = { | |||
| 485 | static struct blk_mq_reg virtio_mq_reg = { | 491 | static struct blk_mq_reg virtio_mq_reg = { |
| 486 | .ops = &virtio_mq_ops, | 492 | .ops = &virtio_mq_ops, |
| 487 | .nr_hw_queues = 1, | 493 | .nr_hw_queues = 1, |
| 488 | .queue_depth = 64, | 494 | .queue_depth = 0, /* Set in virtblk_probe */ |
| 489 | .numa_node = NUMA_NO_NODE, | 495 | .numa_node = NUMA_NO_NODE, |
| 490 | .flags = BLK_MQ_F_SHOULD_MERGE, | 496 | .flags = BLK_MQ_F_SHOULD_MERGE, |
| 491 | }; | 497 | }; |
| 498 | module_param_named(queue_depth, virtio_mq_reg.queue_depth, uint, 0444); | ||
| 492 | 499 | ||
| 493 | static int virtblk_init_vbr(void *data, struct blk_mq_hw_ctx *hctx, | 500 | static int virtblk_init_vbr(void *data, struct blk_mq_hw_ctx *hctx, |
| 494 | struct request *rq, unsigned int nr) | 501 | struct request *rq, unsigned int nr) |
| @@ -553,6 +560,13 @@ static int virtblk_probe(struct virtio_device *vdev) | |||
| 553 | goto out_free_vq; | 560 | goto out_free_vq; |
| 554 | } | 561 | } |
| 555 | 562 | ||
| 563 | /* Default queue sizing is to fill the ring. */ | ||
| 564 | if (!virtio_mq_reg.queue_depth) { | ||
| 565 | virtio_mq_reg.queue_depth = vblk->vq->num_free; | ||
| 566 | /* ... but without indirect descs, we use 2 descs per req */ | ||
| 567 | if (!virtio_has_feature(vdev, VIRTIO_RING_F_INDIRECT_DESC)) | ||
| 568 | virtio_mq_reg.queue_depth /= 2; | ||
| 569 | } | ||
| 556 | virtio_mq_reg.cmd_size = | 570 | virtio_mq_reg.cmd_size = |
| 557 | sizeof(struct virtblk_req) + | 571 | sizeof(struct virtblk_req) + |
| 558 | sizeof(struct scatterlist) * sg_elems; | 572 | sizeof(struct scatterlist) * sg_elems; |
diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c index c12398d1517c..2ce0e225e58c 100644 --- a/drivers/char/hw_random/virtio-rng.c +++ b/drivers/char/hw_random/virtio-rng.c | |||
| @@ -47,8 +47,7 @@ static void register_buffer(u8 *buf, size_t size) | |||
| 47 | sg_init_one(&sg, buf, size); | 47 | sg_init_one(&sg, buf, size); |
| 48 | 48 | ||
| 49 | /* There should always be room for one buffer. */ | 49 | /* There should always be room for one buffer. */ |
| 50 | if (virtqueue_add_inbuf(vq, &sg, 1, buf, GFP_KERNEL) < 0) | 50 | virtqueue_add_inbuf(vq, &sg, 1, buf, GFP_KERNEL); |
| 51 | BUG(); | ||
| 52 | 51 | ||
| 53 | virtqueue_kick(vq); | 52 | virtqueue_kick(vq); |
| 54 | } | 53 | } |
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 841b60831df1..470b01f3e7b4 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c | |||
| @@ -938,7 +938,7 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd, | |||
| 938 | sgs[out_num] = &stat; | 938 | sgs[out_num] = &stat; |
| 939 | 939 | ||
| 940 | BUG_ON(out_num + 1 > ARRAY_SIZE(sgs)); | 940 | BUG_ON(out_num + 1 > ARRAY_SIZE(sgs)); |
| 941 | BUG_ON(virtqueue_add_sgs(vi->cvq, sgs, out_num, 1, vi, GFP_ATOMIC) < 0); | 941 | virtqueue_add_sgs(vi->cvq, sgs, out_num, 1, vi, GFP_ATOMIC); |
| 942 | 942 | ||
| 943 | if (unlikely(!virtqueue_kick(vi->cvq))) | 943 | if (unlikely(!virtqueue_kick(vi->cvq))) |
| 944 | return status == VIRTIO_NET_OK; | 944 | return status == VIRTIO_NET_OK; |
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 34bdabaecbd6..25ebe8eecdb7 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c | |||
| @@ -108,8 +108,7 @@ static void tell_host(struct virtio_balloon *vb, struct virtqueue *vq) | |||
| 108 | sg_init_one(&sg, vb->pfns, sizeof(vb->pfns[0]) * vb->num_pfns); | 108 | sg_init_one(&sg, vb->pfns, sizeof(vb->pfns[0]) * vb->num_pfns); |
| 109 | 109 | ||
| 110 | /* We should always be able to add one buffer to an empty queue. */ | 110 | /* We should always be able to add one buffer to an empty queue. */ |
| 111 | if (virtqueue_add_outbuf(vq, &sg, 1, vb, GFP_KERNEL) < 0) | 111 | virtqueue_add_outbuf(vq, &sg, 1, vb, GFP_KERNEL); |
| 112 | BUG(); | ||
| 113 | virtqueue_kick(vq); | 112 | virtqueue_kick(vq); |
| 114 | 113 | ||
| 115 | /* When host has read buffer, this completes via balloon_ack */ | 114 | /* When host has read buffer, this completes via balloon_ack */ |
| @@ -258,8 +257,7 @@ static void stats_handle_request(struct virtio_balloon *vb) | |||
| 258 | if (!virtqueue_get_buf(vq, &len)) | 257 | if (!virtqueue_get_buf(vq, &len)) |
| 259 | return; | 258 | return; |
| 260 | sg_init_one(&sg, vb->stats, sizeof(vb->stats)); | 259 | sg_init_one(&sg, vb->stats, sizeof(vb->stats)); |
| 261 | if (virtqueue_add_outbuf(vq, &sg, 1, vb, GFP_KERNEL) < 0) | 260 | virtqueue_add_outbuf(vq, &sg, 1, vb, GFP_KERNEL); |
| 262 | BUG(); | ||
| 263 | virtqueue_kick(vq); | 261 | virtqueue_kick(vq); |
| 264 | } | 262 | } |
| 265 | 263 | ||
| @@ -310,6 +308,12 @@ static int balloon(void *_vballoon) | |||
| 310 | else if (diff < 0) | 308 | else if (diff < 0) |
| 311 | leak_balloon(vb, -diff); | 309 | leak_balloon(vb, -diff); |
| 312 | update_balloon_size(vb); | 310 | update_balloon_size(vb); |
| 311 | |||
| 312 | /* | ||
| 313 | * For large balloon changes, we could spend a lot of time | ||
| 314 | * and always have work to do. Be nice if preempt disabled. | ||
| 315 | */ | ||
| 316 | cond_resched(); | ||
| 313 | } | 317 | } |
| 314 | return 0; | 318 | return 0; |
| 315 | } | 319 | } |
| @@ -338,7 +342,7 @@ static int init_vqs(struct virtio_balloon *vb) | |||
| 338 | 342 | ||
| 339 | /* | 343 | /* |
| 340 | * Prime this virtqueue with one buffer so the hypervisor can | 344 | * Prime this virtqueue with one buffer so the hypervisor can |
| 341 | * use it to signal us later. | 345 | * use it to signal us later (it can't be broken yet!). |
| 342 | */ | 346 | */ |
| 343 | sg_init_one(&sg, vb->stats, sizeof vb->stats); | 347 | sg_init_one(&sg, vb->stats, sizeof vb->stats); |
| 344 | if (virtqueue_add_outbuf(vb->stats_vq, &sg, 1, vb, GFP_KERNEL) | 348 | if (virtqueue_add_outbuf(vb->stats_vq, &sg, |
