virtio: fixes for 4.8

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.
 
 Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQEcBAABAgAGBQJX0vwhAAoJECgfDbjSjVRpcZQH/ie8unPbbdeV8kiYlW3CmYNl
 lZc2HzpW/mwm3gTO4ItJUWrvg0S2yfrEF167VJ1tjgRj7breXZ8zdQVVf3mvDykn
 66JB1VZ1lFdS06IUHxzeEfKItiqQBYye0PmhRZbDQa46YZzgvC/A6QArTr605JHd
 Iggerhncy4OzCQQYbxRE2izXt06cR/Mg9cw3yXOiK/9zWGu6MR92q8BAZmpSNq5d
 UbXRd/06UXYwGTd/pzOuq5n+/BnIy91oVpydWIIODr15SEMYfEJqfaFZqiJovuo2
 iE4yiHdbofm9rUkiuDCGrEHuLwkQ426oWQ9f6B7sZvtqysq+ZSutiXNpERITN3E=
 =k3Xr
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2016-09-09 14:52:05 -07:00
commit d0acc7dfd9
2 changed files with 16 additions and 9 deletions

View File

@ -165,6 +165,12 @@ struct ports_device {
*/
struct virtqueue *c_ivq, *c_ovq;
/*
* A control packet buffer for guest->host requests, protected
* by c_ovq_lock.
*/
struct virtio_console_control cpkt;
/* Array of per-port IO virtqueues */
struct virtqueue **in_vqs, **out_vqs;
@ -560,28 +566,29 @@ static ssize_t __send_control_msg(struct ports_device *portdev, u32 port_id,
unsigned int event, unsigned int value)
{
struct scatterlist sg[1];
struct virtio_console_control cpkt;
struct virtqueue *vq;
unsigned int len;
if (!use_multiport(portdev))
return 0;
cpkt.id = cpu_to_virtio32(portdev->vdev, port_id);
cpkt.event = cpu_to_virtio16(portdev->vdev, event);
cpkt.value = cpu_to_virtio16(portdev->vdev, value);
vq = portdev->c_ovq;
sg_init_one(sg, &cpkt, sizeof(cpkt));
spin_lock(&portdev->c_ovq_lock);
if (virtqueue_add_outbuf(vq, sg, 1, &cpkt, GFP_ATOMIC) == 0) {
portdev->cpkt.id = cpu_to_virtio32(portdev->vdev, port_id);
portdev->cpkt.event = cpu_to_virtio16(portdev->vdev, event);
portdev->cpkt.value = cpu_to_virtio16(portdev->vdev, value);
sg_init_one(sg, &portdev->cpkt, sizeof(struct virtio_console_control));
if (virtqueue_add_outbuf(vq, sg, 1, &portdev->cpkt, GFP_ATOMIC) == 0) {
virtqueue_kick(vq);
while (!virtqueue_get_buf(vq, &len)
&& !virtqueue_is_broken(vq))
cpu_relax();
}
spin_unlock(&portdev->c_ovq_lock);
return 0;
}

View File

@ -167,7 +167,7 @@ static bool vring_use_dma_api(struct virtio_device *vdev)
* making all of the arch DMA ops work on the vring device itself
* is a mess. For now, we use the parent device for DMA ops.
*/
struct device *vring_dma_dev(const struct vring_virtqueue *vq)
static struct device *vring_dma_dev(const struct vring_virtqueue *vq)
{
return vq->vq.vdev->dev.parent;
}