aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-01-22 15:40:09 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-01-22 15:40:09 -0500
commit585457fc8383e373ab923e46cd1f70bbfe46763f (patch)
treef4e38133fb9b90543150a904cc1f6cc6b5657c7b
parentbb6c01c2dde67b165cf7c808b0f00677b6f94b96 (diff)
parent0db1dba5dfaf70fb3baf07973996db2078528cde (diff)
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio/vhost fixes from Michael Tsirkin: "Random fixes and cleanups that accumulated over the time" * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: virtio/s390: virtio: constify virtio_config_ops structures virtio/s390: add missing \n to end of dev_err message virtio/s390: support READ_STATUS command for virtio-ccw tools/virtio/ringtest: tweaks for s390 tools/virtio/ringtest: fix run-on-all.sh for offline cpus virtio_console: fix a crash in config_work_handler vhost/scsi: silence uninitialized variable warning vhost: scsi: constify target_core_fabric_ops structures
-rw-r--r--drivers/char/virtio_console.c2
-rw-r--r--drivers/s390/virtio/virtio_ccw.c29
-rw-r--r--drivers/vhost/scsi.c4
-rw-r--r--tools/virtio/ringtest/main.h12
-rwxr-xr-xtools/virtio/ringtest/run-on-all.sh5
5 files changed, 45 insertions, 7 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 8b00e79c2683..17857beb4892 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1862,7 +1862,7 @@ static void config_work_handler(struct work_struct *work)
1862{ 1862{
1863 struct ports_device *portdev; 1863 struct ports_device *portdev;
1864 1864
1865 portdev = container_of(work, struct ports_device, control_work); 1865 portdev = container_of(work, struct ports_device, config_work);
1866 if (!use_multiport(portdev)) { 1866 if (!use_multiport(portdev)) {
1867 struct virtio_device *vdev; 1867 struct virtio_device *vdev;
1868 struct port *port; 1868 struct port *port;
diff --git a/drivers/s390/virtio/virtio_ccw.c b/drivers/s390/virtio/virtio_ccw.c
index 639ed4e6afd1..070c4da95f48 100644
--- a/drivers/s390/virtio/virtio_ccw.c
+++ b/drivers/s390/virtio/virtio_ccw.c
@@ -145,6 +145,7 @@ static struct airq_info *airq_areas[MAX_AIRQ_AREAS];
145#define CCW_CMD_WRITE_CONF 0x21 145#define CCW_CMD_WRITE_CONF 0x21
146#define CCW_CMD_WRITE_STATUS 0x31 146#define CCW_CMD_WRITE_STATUS 0x31
147#define CCW_CMD_READ_VQ_CONF 0x32 147#define CCW_CMD_READ_VQ_CONF 0x32
148#define CCW_CMD_READ_STATUS 0x72
148#define CCW_CMD_SET_IND_ADAPTER 0x73 149#define CCW_CMD_SET_IND_ADAPTER 0x73
149#define CCW_CMD_SET_VIRTIO_REV 0x83 150#define CCW_CMD_SET_VIRTIO_REV 0x83
150 151
@@ -160,6 +161,7 @@ static struct airq_info *airq_areas[MAX_AIRQ_AREAS];
160#define VIRTIO_CCW_DOING_SET_CONF_IND 0x04000000 161#define VIRTIO_CCW_DOING_SET_CONF_IND 0x04000000
161#define VIRTIO_CCW_DOING_SET_IND_ADAPTER 0x08000000 162#define VIRTIO_CCW_DOING_SET_IND_ADAPTER 0x08000000
162#define VIRTIO_CCW_DOING_SET_VIRTIO_REV 0x10000000 163#define VIRTIO_CCW_DOING_SET_VIRTIO_REV 0x10000000
164#define VIRTIO_CCW_DOING_READ_STATUS 0x20000000
163#define VIRTIO_CCW_INTPARM_MASK 0xffff0000 165#define VIRTIO_CCW_INTPARM_MASK 0xffff0000
164 166
165static struct virtio_ccw_device *to_vc_device(struct virtio_device *vdev) 167static struct virtio_ccw_device *to_vc_device(struct virtio_device *vdev)
@@ -452,7 +454,7 @@ static void virtio_ccw_del_vq(struct virtqueue *vq, struct ccw1 *ccw)
452 * This may happen on device detach. 454 * This may happen on device detach.
453 */ 455 */
454 if (ret && (ret != -ENODEV)) 456 if (ret && (ret != -ENODEV))
455 dev_warn(&vq->vdev->dev, "Error %d while deleting queue %d", 457 dev_warn(&vq->vdev->dev, "Error %d while deleting queue %d\n",
456 ret, index); 458 ret, index);
457 459
458 vring_del_virtqueue(vq); 460 vring_del_virtqueue(vq);
@@ -892,6 +894,28 @@ out_free:
892static u8 virtio_ccw_get_status(struct virtio_device *vdev) 894static u8 virtio_ccw_get_status(struct virtio_device *vdev)
893{ 895{
894 struct virtio_ccw_device *vcdev = to_vc_device(vdev); 896 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
897 u8 old_status = *vcdev->status;
898 struct ccw1 *ccw;
899
900 if (vcdev->revision < 1)
901 return *vcdev->status;
902
903 ccw = kzalloc(sizeof(*ccw), GFP_DMA | GFP_KERNEL);
904 if (!ccw)
905 return old_status;
906
907 ccw->cmd_code = CCW_CMD_READ_STATUS;
908 ccw->flags = 0;
909 ccw->count = sizeof(*vcdev->status);
910 ccw->cda = (__u32)(unsigned long)vcdev->status;
911 ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_READ_STATUS);
912/*
913 * If the channel program failed (should only happen if the device
914 * was hotunplugged, and then we clean up via the machine check
915 * handler anyway), vcdev->status was not overwritten and we just
916 * return the old status, which is fine.
917*/
918 kfree(ccw);
895 919
896 return *vcdev->status; 920 return *vcdev->status;
897} 921}
@@ -920,7 +944,7 @@ static void virtio_ccw_set_status(struct virtio_device *vdev, u8 status)
920 kfree(ccw); 944 kfree(ccw);
921} 945}
922 946
923static struct virtio_config_ops virtio_ccw_config_ops = { 947static const struct virtio_config_ops virtio_ccw_config_ops = {
924 .get_features = virtio_ccw_get_features, 948 .get_features = virtio_ccw_get_features,
925 .finalize_features = virtio_ccw_finalize_features, 949 .finalize_features = virtio_ccw_finalize_features,
926 .get = virtio_ccw_get_config, 950 .get = virtio_ccw_get_config,
@@ -987,6 +1011,7 @@ static void virtio_ccw_check_activity(struct virtio_ccw_device *vcdev,
987 case VIRTIO_CCW_DOING_READ_CONFIG: 1011 case VIRTIO_CCW_DOING_READ_CONFIG:
988 case VIRTIO_CCW_DOING_WRITE_CONFIG: 1012 case VIRTIO_CCW_DOING_WRITE_CONFIG:
989 case VIRTIO_CCW_DOING_WRITE_STATUS: 1013 case VIRTIO_CCW_DOING_WRITE_STATUS:
1014 case VIRTIO_CCW_DOING_READ_STATUS:
990 case VIRTIO_CCW_DOING_SET_VQ: 1015 case VIRTIO_CCW_DOING_SET_VQ:
991 case VIRTIO_CCW_DOING_SET_IND: 1016 case VIRTIO_CCW_DOING_SET_IND:
992 case VIRTIO_CCW_DOING_SET_CONF_IND: 1017 case VIRTIO_CCW_DOING_SET_CONF_IND:
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index 253310cdaaca..fd6c8b66f06f 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -843,7 +843,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
843 struct iov_iter out_iter, in_iter, prot_iter, data_iter; 843 struct iov_iter out_iter, in_iter, prot_iter, data_iter;
844 u64 tag; 844 u64 tag;
845 u32 exp_data_len, data_direction; 845 u32 exp_data_len, data_direction;
846 unsigned out, in; 846 unsigned int out = 0, in = 0;
847 int head, ret, prot_bytes; 847 int head, ret, prot_bytes;
848 size_t req_size, rsp_size = sizeof(struct virtio_scsi_cmd_resp); 848 size_t req_size, rsp_size = sizeof(struct virtio_scsi_cmd_resp);
849 size_t out_size, in_size; 849 size_t out_size, in_size;
@@ -2087,7 +2087,7 @@ static struct configfs_attribute *vhost_scsi_wwn_attrs[] = {
2087 NULL, 2087 NULL,
2088}; 2088};
2089 2089
2090static struct target_core_fabric_ops vhost_scsi_ops = { 2090static const struct target_core_fabric_ops vhost_scsi_ops = {
2091 .module = THIS_MODULE, 2091 .module = THIS_MODULE,
2092 .name = "vhost", 2092 .name = "vhost",
2093 .get_fabric_name = vhost_scsi_get_fabric_name, 2093 .get_fabric_name = vhost_scsi_get_fabric_name,
diff --git a/tools/virtio/ringtest/main.h b/tools/virtio/ringtest/main.h
index 34e63cc4c572..14142faf040b 100644
--- a/tools/virtio/ringtest/main.h
+++ b/tools/virtio/ringtest/main.h
@@ -26,6 +26,16 @@ static inline void wait_cycles(unsigned long long cycles)
26#define VMEXIT_CYCLES 500 26#define VMEXIT_CYCLES 500
27#define VMENTRY_CYCLES 500 27#define VMENTRY_CYCLES 500
28 28
29#elif defined(__s390x__)
30static inline void wait_cycles(unsigned long long cycles)
31{
32 asm volatile("0: brctg %0,0b" : : "d" (cycles));
33}
34
35/* tweak me */
36#define VMEXIT_CYCLES 200
37#define VMENTRY_CYCLES 200
38
29#else 39#else
30static inline void wait_cycles(unsigned long long cycles) 40static inline void wait_cycles(unsigned long long cycles)
31{ 41{
@@ -81,6 +91,8 @@ extern unsigned ring_size;
81/* Is there a portable way to do this? */ 91/* Is there a portable way to do this? */
82#if defined(__x86_64__) || defined(__i386__) 92#if defined(__x86_64__) || defined(__i386__)
83#define cpu_relax() asm ("rep; nop" ::: "memory") 93#define cpu_relax() asm ("rep; nop" ::: "memory")
94#elif defined(__s390x__)
95#define cpu_relax() barrier()
84#else 96#else
85#define cpu_relax() assert(0) 97#define cpu_relax() assert(0)
86#endif 98#endif
diff --git a/tools/virtio/ringtest/run-on-all.sh b/tools/virtio/ringtest/run-on-all.sh
index 2e69ca812b4c..29b0d3920bfc 100755
--- a/tools/virtio/ringtest/run-on-all.sh
+++ b/tools/virtio/ringtest/run-on-all.sh
@@ -1,12 +1,13 @@
1#!/bin/sh 1#!/bin/sh
2 2
3CPUS_ONLINE=$(lscpu --online -p=cpu|grep -v -e '#')
3#use last CPU for host. Why not the first? 4#use last CPU for host. Why not the first?
4#many devices tend to use cpu0 by default so 5#many devices tend to use cpu0 by default so
5#it tends to be busier 6#it tends to be busier
6HOST_AFFINITY=$(lscpu -p=cpu | tail -1) 7HOST_AFFINITY=$(echo "${CPUS_ONLINE}"|tail -n 1)
7 8
8#run command on all cpus 9#run command on all cpus
9for cpu in $(seq 0 $HOST_AFFINITY) 10for cpu in $CPUS_ONLINE
10do 11do
11 #Don't run guest and host on same CPU 12 #Don't run guest and host on same CPU
12 #It actually works ok if using signalling 13 #It actually works ok if using signalling