diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-11 15:20:31 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-11 15:20:31 -0500 |
commit | 6b9e2cea428cf7af93a84bcb865e478d8bf1c165 (patch) | |
tree | 11be387e37129fce0c4c111803df1a2e56637b60 /drivers/char | |
parent | 14ba9a2e4bacc6f5a0dbe0de5390daedd544508f (diff) | |
parent | f01a2a811ae04124fc9382925038fcbbd2f0b7c8 (diff) |
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio updates from Michael Tsirkin:
"virtio: virtio 1.0 support, misc patches
This adds a lot of infrastructure for virtio 1.0 support. Notable
missing pieces: virtio pci, virtio balloon (needs spec extension),
vhost scsi.
Plus, there are some minor fixes in a couple of places.
Note: some net drivers are affected by these patches. David said he's
fine with merging these patches through my tree.
Rusty's on vacation, he acked using my tree for these, too"
* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: (70 commits)
virtio_ccw: finalize_features error handling
virtio_ccw: future-proof finalize_features
virtio_pci: rename virtio_pci -> virtio_pci_common
virtio_pci: update file descriptions and copyright
virtio_pci: split out legacy device support
virtio_pci: setup config vector indirectly
virtio_pci: setup vqs indirectly
virtio_pci: delete vqs indirectly
virtio_pci: use priv for vq notification
virtio_pci: free up vq->priv
virtio_pci: fix coding style for structs
virtio_pci: add isr field
virtio: drop legacy_only driver flag
virtio_balloon: drop legacy_only driver flag
virtio_ccw: rev 1 devices set VIRTIO_F_VERSION_1
virtio: allow finalize_features to fail
virtio_ccw: legacy: don't negotiate rev 1/features
virtio: add API to detect legacy devices
virtio_console: fix sparse warnings
vhost: remove unnecessary forward declarations in vhost.h
...
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/virtio_console.c | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index cf7a561fad7c..de03df9dd7c9 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c | |||
@@ -355,7 +355,7 @@ static inline bool use_multiport(struct ports_device *portdev) | |||
355 | */ | 355 | */ |
356 | if (!portdev->vdev) | 356 | if (!portdev->vdev) |
357 | return 0; | 357 | return 0; |
358 | return portdev->vdev->features[0] & (1 << VIRTIO_CONSOLE_F_MULTIPORT); | 358 | return __virtio_test_bit(portdev->vdev, VIRTIO_CONSOLE_F_MULTIPORT); |
359 | } | 359 | } |
360 | 360 | ||
361 | static DEFINE_SPINLOCK(dma_bufs_lock); | 361 | static DEFINE_SPINLOCK(dma_bufs_lock); |
@@ -566,9 +566,9 @@ static ssize_t __send_control_msg(struct ports_device *portdev, u32 port_id, | |||
566 | if (!use_multiport(portdev)) | 566 | if (!use_multiport(portdev)) |
567 | return 0; | 567 | return 0; |
568 | 568 | ||
569 | cpkt.id = port_id; | 569 | cpkt.id = cpu_to_virtio32(portdev->vdev, port_id); |
570 | cpkt.event = event; | 570 | cpkt.event = cpu_to_virtio16(portdev->vdev, event); |
571 | cpkt.value = value; | 571 | cpkt.value = cpu_to_virtio16(portdev->vdev, value); |
572 | 572 | ||
573 | vq = portdev->c_ovq; | 573 | vq = portdev->c_ovq; |
574 | 574 | ||
@@ -669,8 +669,8 @@ done: | |||
669 | * Give out the data that's requested from the buffer that we have | 669 | * Give out the data that's requested from the buffer that we have |
670 | * queued up. | 670 | * queued up. |
671 | */ | 671 | */ |
672 | static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count, | 672 | static ssize_t fill_readbuf(struct port *port, char __user *out_buf, |
673 | bool to_user) | 673 | size_t out_count, bool to_user) |
674 | { | 674 | { |
675 | struct port_buffer *buf; | 675 | struct port_buffer *buf; |
676 | unsigned long flags; | 676 | unsigned long flags; |
@@ -688,7 +688,8 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count, | |||
688 | if (ret) | 688 | if (ret) |
689 | return -EFAULT; | 689 | return -EFAULT; |
690 | } else { | 690 | } else { |
691 | memcpy(out_buf, buf->buf + buf->offset, out_count); | 691 | memcpy((__force char *)out_buf, buf->buf + buf->offset, |
692 | out_count); | ||
692 | } | 693 | } |
693 | 694 | ||
694 | buf->offset += out_count; | 695 | buf->offset += out_count; |
@@ -1162,7 +1163,7 @@ static int get_chars(u32 vtermno, char *buf, int count) | |||
1162 | /* If we don't have an input queue yet, we can't get input. */ | 1163 | /* If we don't have an input queue yet, we can't get input. */ |
1163 | BUG_ON(!port->in_vq); | 1164 | BUG_ON(!port->in_vq); |
1164 | 1165 | ||
1165 | return fill_readbuf(port, buf, count, false); | 1166 | return fill_readbuf(port, (__force char __user *)buf, count, false); |
1166 | } | 1167 | } |
1167 | 1168 | ||
1168 | static void resize_console(struct port *port) | 1169 | static void resize_console(struct port *port) |
@@ -1602,7 +1603,8 @@ static void unplug_port(struct port *port) | |||
1602 | } | 1603 | } |
1603 | 1604 | ||
1604 | /* Any private messages that the Host and Guest want to share */ | 1605 | /* Any private messages that the Host and Guest want to share */ |
1605 | static void handle_control_message(struct ports_device *portdev, | 1606 | static void handle_control_message(struct virtio_device *vdev, |
1607 | struct ports_device *portdev, | ||
1606 | struct port_buffer *buf) | 1608 | struct port_buffer *buf) |
1607 | { | 1609 | { |
1608 | struct virtio_console_control *cpkt; | 1610 | struct virtio_console_control *cpkt; |
@@ -1612,15 +1614,16 @@ static void handle_control_message(struct ports_device *portdev, | |||
1612 | 1614 | ||
1613 | cpkt = (struct virtio_console_control *)(buf->buf + buf->offset); | 1615 | cpkt = (struct virtio_console_control *)(buf->buf + buf->offset); |
1614 | 1616 | ||
1615 | port = find_port_by_id(portdev, cpkt->id); | 1617 | port = find_port_by_id(portdev, virtio32_to_cpu(vdev, cpkt->id)); |
1616 | if (!port && cpkt->event != VIRTIO_CONSOLE_PORT_ADD) { | 1618 | if (!port && |
1619 | cpkt->event != cpu_to_virtio16(vdev, VIRTIO_CONSOLE_PORT_ADD)) { | ||
1617 | /* No valid header at start of buffer. Drop it. */ | 1620 | /* No valid header at start of buffer. Drop it. */ |
1618 | dev_dbg(&portdev->vdev->dev, | 1621 | dev_dbg(&portdev->vdev->dev, |
1619 | "Invalid index %u in control packet\n", cpkt->id); | 1622 | "Invalid index %u in control packet\n", cpkt->id); |
1620 | return; | 1623 | return; |
1621 | } | 1624 | } |
1622 | 1625 | ||
1623 | switch (cpkt->event) { | 1626 | switch (virtio16_to_cpu(vdev, cpkt->event)) { |
1624 | case VIRTIO_CONSOLE_PORT_ADD: | 1627 | case VIRTIO_CONSOLE_PORT_ADD: |
1625 | if (port) { | 1628 | if (port) { |
1626 | dev_dbg(&portdev->vdev->dev, | 1629 | dev_dbg(&portdev->vdev->dev, |
@@ -1628,13 +1631,15 @@ static void handle_control_message(struct ports_device *portdev, | |||
1628 | send_control_msg(port, VIRTIO_CONSOLE_PORT_READY, 1); | 1631 | send_control_msg(port, VIRTIO_CONSOLE_PORT_READY, 1); |
1629 | break; | 1632 | break; |
1630 | } | 1633 | } |
1631 | if (cpkt->id >= portdev->config.max_nr_ports) { | 1634 | if (virtio32_to_cpu(vdev, cpkt->id) >= |
1635 | portdev->config.max_nr_ports) { | ||
1632 | dev_warn(&portdev->vdev->dev, | 1636 | dev_warn(&portdev->vdev->dev, |
1633 | "Request for adding port with out-of-bound id %u, max. supported id: %u\n", | 1637 | "Request for adding port with " |
1638 | "out-of-bound id %u, max. supported id: %u\n", | ||
1634 | cpkt->id, portdev->config.max_nr_ports - 1); | 1639 | cpkt->id, portdev->config.max_nr_ports - 1); |
1635 | break; | 1640 | break; |
1636 | } | 1641 | } |
1637 | add_port(portdev, cpkt->id); | 1642 | add_port(portdev, virtio32_to_cpu(vdev, cpkt->id)); |
1638 | break; | 1643 | break; |
1639 | case VIRTIO_CONSOLE_PORT_REMOVE: | 1644 | case VIRTIO_CONSOLE_PORT_REMOVE: |
1640 | unplug_port(port); | 1645 | unplug_port(port); |
@@ -1670,7 +1675,7 @@ static void handle_control_message(struct ports_device *portdev, | |||
1670 | break; | 1675 | break; |
1671 | } | 1676 | } |
1672 | case VIRTIO_CONSOLE_PORT_OPEN: | 1677 | case VIRTIO_CONSOLE_PORT_OPEN: |
1673 | port->host_connected = cpkt->value; | 1678 | port->host_connected = virtio16_to_cpu(vdev, cpkt->value); |
1674 | wake_up_interruptible(&port->waitqueue); | 1679 | wake_up_interruptible(&port->waitqueue); |
1675 | /* | 1680 | /* |
1676 | * If the host port got closed and the host had any | 1681 | * If the host port got closed and the host had any |
@@ -1752,7 +1757,7 @@ static void control_work_handler(struct work_struct *work) | |||
1752 | buf->len = len; | 1757 | buf->len = len; |
1753 | buf->offset = 0; | 1758 | buf->offset = 0; |
1754 | 1759 | ||
1755 | handle_control_message(portdev, buf); | 1760 | handle_control_message(vq->vdev, portdev, buf); |
1756 | 1761 | ||
1757 | spin_lock(&portdev->c_ivq_lock); | 1762 | spin_lock(&portdev->c_ivq_lock); |
1758 | if (add_inbuf(portdev->c_ivq, buf) < 0) { | 1763 | if (add_inbuf(portdev->c_ivq, buf) < 0) { |