diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-08-16 18:51:57 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-08-16 18:51:57 -0400 |
commit | 3ec60b92d3bae719cf3a8b6e522af07ad3d1cc5b (patch) | |
tree | 194b96f2d90235f8511a125dfe29d8d3d9eed55c | |
parent | 45b6ae761e5259d457a797f66f4d4c16b620f268 (diff) | |
parent | 6be3ffaa0e15c64f560904b025f5c50bef5886f9 (diff) |
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio/vhost fixes from Michael Tsirkin:
- test fixes
- a vsock fix
* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
tools/virtio: add dma stubs
vhost/test: fix after swiotlb changes
vhost/vsock: drop space available check for TX vq
ringtest: test build fix
-rw-r--r-- | drivers/vhost/test.c | 8 | ||||
-rw-r--r-- | net/vmw_vsock/virtio_transport.c | 10 | ||||
-rw-r--r-- | tools/virtio/linux/dma-mapping.h | 16 | ||||
-rw-r--r-- | tools/virtio/linux/kernel.h | 14 | ||||
-rw-r--r-- | tools/virtio/linux/slab.h | 4 | ||||
-rw-r--r-- | tools/virtio/linux/virtio.h | 6 | ||||
-rw-r--r-- | tools/virtio/linux/virtio_config.h | 13 | ||||
-rw-r--r-- | tools/virtio/ringtest/ptr_ring.c | 1 |
8 files changed, 60 insertions, 12 deletions
diff --git a/drivers/vhost/test.c b/drivers/vhost/test.c index 388eec4e1a90..97fb2f8fa930 100644 --- a/drivers/vhost/test.c +++ b/drivers/vhost/test.c | |||
@@ -220,20 +220,20 @@ static long vhost_test_reset_owner(struct vhost_test *n) | |||
220 | { | 220 | { |
221 | void *priv = NULL; | 221 | void *priv = NULL; |
222 | long err; | 222 | long err; |
223 | struct vhost_memory *memory; | 223 | struct vhost_umem *umem; |
224 | 224 | ||
225 | mutex_lock(&n->dev.mutex); | 225 | mutex_lock(&n->dev.mutex); |
226 | err = vhost_dev_check_owner(&n->dev); | 226 | err = vhost_dev_check_owner(&n->dev); |
227 | if (err) | 227 | if (err) |
228 | goto done; | 228 | goto done; |
229 | memory = vhost_dev_reset_owner_prepare(); | 229 | umem = vhost_dev_reset_owner_prepare(); |
230 | if (!memory) { | 230 | if (!umem) { |
231 | err = -ENOMEM; | 231 | err = -ENOMEM; |
232 | goto done; | 232 | goto done; |
233 | } | 233 | } |
234 | vhost_test_stop(n, &priv); | 234 | vhost_test_stop(n, &priv); |
235 | vhost_test_flush(n); | 235 | vhost_test_flush(n); |
236 | vhost_dev_reset_owner(&n->dev, memory); | 236 | vhost_dev_reset_owner(&n->dev, umem); |
237 | done: | 237 | done: |
238 | mutex_unlock(&n->dev.mutex); | 238 | mutex_unlock(&n->dev.mutex); |
239 | return err; | 239 | return err; |
diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c index 699dfabdbccd..936d7eee62d0 100644 --- a/net/vmw_vsock/virtio_transport.c +++ b/net/vmw_vsock/virtio_transport.c | |||
@@ -87,9 +87,6 @@ virtio_transport_send_pkt_work(struct work_struct *work) | |||
87 | 87 | ||
88 | vq = vsock->vqs[VSOCK_VQ_TX]; | 88 | vq = vsock->vqs[VSOCK_VQ_TX]; |
89 | 89 | ||
90 | /* Avoid unnecessary interrupts while we're processing the ring */ | ||
91 | virtqueue_disable_cb(vq); | ||
92 | |||
93 | for (;;) { | 90 | for (;;) { |
94 | struct virtio_vsock_pkt *pkt; | 91 | struct virtio_vsock_pkt *pkt; |
95 | struct scatterlist hdr, buf, *sgs[2]; | 92 | struct scatterlist hdr, buf, *sgs[2]; |
@@ -99,7 +96,6 @@ virtio_transport_send_pkt_work(struct work_struct *work) | |||
99 | spin_lock_bh(&vsock->send_pkt_list_lock); | 96 | spin_lock_bh(&vsock->send_pkt_list_lock); |
100 | if (list_empty(&vsock->send_pkt_list)) { | 97 | if (list_empty(&vsock->send_pkt_list)) { |
101 | spin_unlock_bh(&vsock->send_pkt_list_lock); | 98 | spin_unlock_bh(&vsock->send_pkt_list_lock); |
102 | virtqueue_enable_cb(vq); | ||
103 | break; | 99 | break; |
104 | } | 100 | } |
105 | 101 | ||
@@ -118,13 +114,13 @@ virtio_transport_send_pkt_work(struct work_struct *work) | |||
118 | } | 114 | } |
119 | 115 | ||
120 | ret = virtqueue_add_sgs(vq, sgs, out_sg, in_sg, pkt, GFP_KERNEL); | 116 | ret = virtqueue_add_sgs(vq, sgs, out_sg, in_sg, pkt, GFP_KERNEL); |
117 | /* Usually this means that there is no more space available in | ||
118 | * the vq | ||
119 | */ | ||
121 | if (ret < 0) { | 120 | if (ret < 0) { |
122 | spin_lock_bh(&vsock->send_pkt_list_lock); | 121 | spin_lock_bh(&vsock->send_pkt_list_lock); |
123 | list_add(&pkt->list, &vsock->send_pkt_list); | 122 | list_add(&pkt->list, &vsock->send_pkt_list); |
124 | spin_unlock_bh(&vsock->send_pkt_list_lock); | 123 | spin_unlock_bh(&vsock->send_pkt_list_lock); |
125 | |||
126 | if (!virtqueue_enable_cb(vq) && ret == -ENOSPC) | ||
127 | continue; /* retry now that we have more space */ | ||
128 | break; | 124 | break; |
129 | } | 125 | } |
130 | 126 | ||
diff --git a/tools/virtio/linux/dma-mapping.h b/tools/virtio/linux/dma-mapping.h index 4f93af89ae16..18601f6689b9 100644 --- a/tools/virtio/linux/dma-mapping.h +++ b/tools/virtio/linux/dma-mapping.h | |||
@@ -14,4 +14,20 @@ enum dma_data_direction { | |||
14 | DMA_NONE = 3, | 14 | DMA_NONE = 3, |
15 | }; | 15 | }; |
16 | 16 | ||
17 | #define dma_alloc_coherent(d, s, hp, f) ({ \ | ||
18 | void *__dma_alloc_coherent_p = kmalloc((s), (f)); \ | ||
19 | *(hp) = (unsigned long)__dma_alloc_coherent_p; \ | ||
20 | __dma_alloc_coherent_p; \ | ||
21 | }) | ||
22 | |||
23 | #define dma_free_coherent(d, s, p, h) kfree(p) | ||
24 | |||
25 | #define dma_map_page(d, p, o, s, dir) (page_to_phys(p) + (o)) | ||
26 | |||
27 | #define dma_map_single(d, p, s, dir) (virt_to_phys(p)) | ||
28 | #define dma_mapping_error(...) (0) | ||
29 | |||
30 | #define dma_unmap_single(...) do { } while (0) | ||
31 | #define dma_unmap_page(...) do { } while (0) | ||
32 | |||
17 | #endif | 33 | #endif |
diff --git a/tools/virtio/linux/kernel.h b/tools/virtio/linux/kernel.h index 033849948215..d9554fc3f340 100644 --- a/tools/virtio/linux/kernel.h +++ b/tools/virtio/linux/kernel.h | |||
@@ -20,7 +20,9 @@ | |||
20 | 20 | ||
21 | #define PAGE_SIZE getpagesize() | 21 | #define PAGE_SIZE getpagesize() |
22 | #define PAGE_MASK (~(PAGE_SIZE-1)) | 22 | #define PAGE_MASK (~(PAGE_SIZE-1)) |
23 | #define PAGE_ALIGN(x) ((x + PAGE_SIZE - 1) & PAGE_MASK) | ||
23 | 24 | ||
25 | typedef unsigned long long phys_addr_t; | ||
24 | typedef unsigned long long dma_addr_t; | 26 | typedef unsigned long long dma_addr_t; |
25 | typedef size_t __kernel_size_t; | 27 | typedef size_t __kernel_size_t; |
26 | typedef unsigned int __wsum; | 28 | typedef unsigned int __wsum; |
@@ -57,6 +59,11 @@ static inline void *kzalloc(size_t s, gfp_t gfp) | |||
57 | return p; | 59 | return p; |
58 | } | 60 | } |
59 | 61 | ||
62 | static inline void *alloc_pages_exact(size_t s, gfp_t gfp) | ||
63 | { | ||
64 | return kmalloc(s, gfp); | ||
65 | } | ||
66 | |||
60 | static inline void kfree(void *p) | 67 | static inline void kfree(void *p) |
61 | { | 68 | { |
62 | if (p >= __kfree_ignore_start && p < __kfree_ignore_end) | 69 | if (p >= __kfree_ignore_start && p < __kfree_ignore_end) |
@@ -64,6 +71,11 @@ static inline void kfree(void *p) | |||
64 | free(p); | 71 | free(p); |
65 | } | 72 | } |
66 | 73 | ||
74 | static inline void free_pages_exact(void *p, size_t s) | ||
75 | { | ||
76 | kfree(p); | ||
77 | } | ||
78 | |||
67 | static inline void *krealloc(void *p, size_t s, gfp_t gfp) | 79 | static inline void *krealloc(void *p, size_t s, gfp_t gfp) |
68 | { | 80 | { |
69 | return realloc(p, s); | 81 | return realloc(p, s); |
@@ -105,6 +117,8 @@ static inline void free_page(unsigned long addr) | |||
105 | #define dev_err(dev, format, ...) fprintf (stderr, format, ## __VA_ARGS__) | 117 | #define dev_err(dev, format, ...) fprintf (stderr, format, ## __VA_ARGS__) |
106 | #define dev_warn(dev, format, ...) fprintf (stderr, format, ## __VA_ARGS__) | 118 | #define dev_warn(dev, format, ...) fprintf (stderr, format, ## __VA_ARGS__) |
107 | 119 | ||
120 | #define WARN_ON_ONCE(cond) ((cond) && fprintf (stderr, "WARNING\n")) | ||
121 | |||
108 | #define min(x, y) ({ \ | 122 | #define min(x, y) ({ \ |
109 | typeof(x) _min1 = (x); \ | 123 | typeof(x) _min1 = (x); \ |
110 | typeof(y) _min2 = (y); \ | 124 | typeof(y) _min2 = (y); \ |
diff --git a/tools/virtio/linux/slab.h b/tools/virtio/linux/slab.h index 81baeac8ae40..7e1c1197d439 100644 --- a/tools/virtio/linux/slab.h +++ b/tools/virtio/linux/slab.h | |||
@@ -1,2 +1,6 @@ | |||
1 | #ifndef LINUX_SLAB_H | 1 | #ifndef LINUX_SLAB_H |
2 | #define GFP_KERNEL 0 | ||
3 | #define GFP_ATOMIC 0 | ||
4 | #define __GFP_NOWARN 0 | ||
5 | #define __GFP_ZERO 0 | ||
2 | #endif | 6 | #endif |
diff --git a/tools/virtio/linux/virtio.h b/tools/virtio/linux/virtio.h index ee125e714053..9377c8b4ac16 100644 --- a/tools/virtio/linux/virtio.h +++ b/tools/virtio/linux/virtio.h | |||
@@ -3,8 +3,12 @@ | |||
3 | #include <linux/scatterlist.h> | 3 | #include <linux/scatterlist.h> |
4 | #include <linux/kernel.h> | 4 | #include <linux/kernel.h> |
5 | 5 | ||
6 | struct device { | ||
7 | void *parent; | ||
8 | }; | ||
9 | |||
6 | struct virtio_device { | 10 | struct virtio_device { |
7 | void *dev; | 11 | struct device dev; |
8 | u64 features; | 12 | u64 features; |
9 | }; | 13 | }; |
10 | 14 | ||
diff --git a/tools/virtio/linux/virtio_config.h b/tools/virtio/linux/virtio_config.h index 57a6964a1e35..9ba11815e0a1 100644 --- a/tools/virtio/linux/virtio_config.h +++ b/tools/virtio/linux/virtio_config.h | |||
@@ -40,6 +40,19 @@ static inline void __virtio_clear_bit(struct virtio_device *vdev, | |||
40 | #define virtio_has_feature(dev, feature) \ | 40 | #define virtio_has_feature(dev, feature) \ |
41 | (__virtio_test_bit((dev), feature)) | 41 | (__virtio_test_bit((dev), feature)) |
42 | 42 | ||
43 | /** | ||
44 | * virtio_has_iommu_quirk - determine whether this device has the iommu quirk | ||
45 | * @vdev: the device | ||
46 | */ | ||
47 | static inline bool virtio_has_iommu_quirk(const struct virtio_device *vdev) | ||
48 | { | ||
49 | /* | ||
50 | * Note the reverse polarity of the quirk feature (compared to most | ||
51 | * other features), this is for compatibility with legacy systems. | ||
52 | */ | ||
53 | return !virtio_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM); | ||
54 | } | ||
55 | |||
43 | static inline bool virtio_is_little_endian(struct virtio_device *vdev) | 56 | static inline bool virtio_is_little_endian(struct virtio_device *vdev) |
44 | { | 57 | { |
45 | return virtio_has_feature(vdev, VIRTIO_F_VERSION_1) || | 58 | return virtio_has_feature(vdev, VIRTIO_F_VERSION_1) || |
diff --git a/tools/virtio/ringtest/ptr_ring.c b/tools/virtio/ringtest/ptr_ring.c index 68e4f9f0da3a..bd2ad1d3b7a9 100644 --- a/tools/virtio/ringtest/ptr_ring.c +++ b/tools/virtio/ringtest/ptr_ring.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #define cache_line_size() SMP_CACHE_BYTES | 13 | #define cache_line_size() SMP_CACHE_BYTES |
14 | #define ____cacheline_aligned_in_smp __attribute__ ((aligned (SMP_CACHE_BYTES))) | 14 | #define ____cacheline_aligned_in_smp __attribute__ ((aligned (SMP_CACHE_BYTES))) |
15 | #define unlikely(x) (__builtin_expect(!!(x), 0)) | 15 | #define unlikely(x) (__builtin_expect(!!(x), 0)) |
16 | #define likely(x) (__builtin_expect(!!(x), 1)) | ||
16 | #define ALIGN(x, a) (((x) + (a) - 1) / (a) * (a)) | 17 | #define ALIGN(x, a) (((x) + (a) - 1) / (a) * (a)) |
17 | typedef pthread_spinlock_t spinlock_t; | 18 | typedef pthread_spinlock_t spinlock_t; |
18 | 19 | ||