aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-09-09 17:52:05 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-09-09 17:52:05 -0400
commitd0acc7dfd90eb97e90ccd42a567034017ec60fb8 (patch)
tree38650e8e367943cdb1dda7edf3e7a857947aac7f
parentdaf6b9b68fca57effe3fcf74a8528f17516c420f (diff)
parent5e59d9a1aed26abcc79abe78af5cfd34e53cbe7f (diff)
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio fixes from Michael Tsirkin: "This includes a couple of bugfixs for virtio. The virtio console patch is actually also in x86/tip targeting 4.9 because it helps vmap stacks, but it also fixes IOMMU_PLATFORM which was added in 4.8, and it seems important not to ship that in a broken configuration" * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: virtio_console: Stop doing DMA on the stack virtio: mark vring_dma_dev() static
-rw-r--r--drivers/char/virtio_console.c23
-rw-r--r--drivers/virtio/virtio_ring.c2
2 files changed, 16 insertions, 9 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index d2406fe25533..5da47e26a012 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -165,6 +165,12 @@ struct ports_device {
165 */ 165 */
166 struct virtqueue *c_ivq, *c_ovq; 166 struct virtqueue *c_ivq, *c_ovq;
167 167
168 /*
169 * A control packet buffer for guest->host requests, protected
170 * by c_ovq_lock.
171 */
172 struct virtio_console_control cpkt;
173
168 /* Array of per-port IO virtqueues */ 174 /* Array of per-port IO virtqueues */
169 struct virtqueue **in_vqs, **out_vqs; 175 struct virtqueue **in_vqs, **out_vqs;
170 176
@@ -560,28 +566,29 @@ static ssize_t __send_control_msg(struct ports_device *portdev, u32 port_id,
560 unsigned int event, unsigned int value) 566 unsigned int event, unsigned int value)
561{ 567{
562 struct scatterlist sg[1]; 568 struct scatterlist sg[1];
563 struct virtio_console_control cpkt;
564 struct virtqueue *vq; 569 struct virtqueue *vq;
565 unsigned int len; 570 unsigned int len;
566 571
567 if (!use_multiport(portdev)) 572 if (!use_multiport(portdev))
568 return 0; 573 return 0;
569 574
570 cpkt.id = cpu_to_virtio32(portdev->vdev, port_id);
571 cpkt.event = cpu_to_virtio16(portdev->vdev, event);
572 cpkt.value = cpu_to_virtio16(portdev->vdev, value);
573
574 vq = portdev->c_ovq; 575 vq = portdev->c_ovq;
575 576
576 sg_init_one(sg, &cpkt, sizeof(cpkt));
577
578 spin_lock(&portdev->c_ovq_lock); 577 spin_lock(&portdev->c_ovq_lock);
579 if (virtqueue_add_outbuf(vq, sg, 1, &cpkt, GFP_ATOMIC) == 0) { 578
579 portdev->cpkt.id = cpu_to_virtio32(portdev->vdev, port_id);
580 portdev->cpkt.event = cpu_to_virtio16(portdev->vdev, event);
581 portdev->cpkt.value = cpu_to_virtio16(portdev->vdev, value);
582
583 sg_init_one(sg, &portdev->cpkt, sizeof(struct virtio_console_control));
584
585 if (virtqueue_add_outbuf(vq, sg, 1, &portdev->cpkt, GFP_ATOMIC) == 0) {
580 virtqueue_kick(vq); 586 virtqueue_kick(vq);
581 while (!virtqueue_get_buf(vq, &len) 587 while (!virtqueue_get_buf(vq, &len)
582 && !virtqueue_is_broken(vq)) 588 && !virtqueue_is_broken(vq))
583 cpu_relax(); 589 cpu_relax();
584 } 590 }
591
585 spin_unlock(&portdev->c_ovq_lock); 592 spin_unlock(&portdev->c_ovq_lock);
586 return 0; 593 return 0;
587} 594}
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index e383ecdaca59..ed9c9eeedfe5 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -167,7 +167,7 @@ static bool vring_use_dma_api(struct virtio_device *vdev)
167 * making all of the arch DMA ops work on the vring device itself 167 * making all of the arch DMA ops work on the vring device itself
168 * is a mess. For now, we use the parent device for DMA ops. 168 * is a mess. For now, we use the parent device for DMA ops.
169 */ 169 */
170struct device *vring_dma_dev(const struct vring_virtqueue *vq) 170static struct device *vring_dma_dev(const struct vring_virtqueue *vq)
171{ 171{
172 return vq->vq.vdev->dev.parent; 172 return vq->vq.vdev->dev.parent;
173} 173}