Skip to content

Commit 3ec60b9

Browse files
committed
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
2 parents 45b6ae7 + 6be3ffa commit 3ec60b9

File tree

8 files changed

+60
-12
lines changed

8 files changed

+60
-12
lines changed

drivers/vhost/test.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,20 +220,20 @@ static long vhost_test_reset_owner(struct vhost_test *n)
220220
{
221221
void *priv = NULL;
222222
long err;
223-
struct vhost_memory *memory;
223+
struct vhost_umem *umem;
224224

225225
mutex_lock(&n->dev.mutex);
226226
err = vhost_dev_check_owner(&n->dev);
227227
if (err)
228228
goto done;
229-
memory = vhost_dev_reset_owner_prepare();
230-
if (!memory) {
229+
umem = vhost_dev_reset_owner_prepare();
230+
if (!umem) {
231231
err = -ENOMEM;
232232
goto done;
233233
}
234234
vhost_test_stop(n, &priv);
235235
vhost_test_flush(n);
236-
vhost_dev_reset_owner(&n->dev, memory);
236+
vhost_dev_reset_owner(&n->dev, umem);
237237
done:
238238
mutex_unlock(&n->dev.mutex);
239239
return err;

net/vmw_vsock/virtio_transport.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ virtio_transport_send_pkt_work(struct work_struct *work)
8787

8888
vq = vsock->vqs[VSOCK_VQ_TX];
8989

90-
/* Avoid unnecessary interrupts while we're processing the ring */
91-
virtqueue_disable_cb(vq);
92-
9390
for (;;) {
9491
struct virtio_vsock_pkt *pkt;
9592
struct scatterlist hdr, buf, *sgs[2];
@@ -99,7 +96,6 @@ virtio_transport_send_pkt_work(struct work_struct *work)
9996
spin_lock_bh(&vsock->send_pkt_list_lock);
10097
if (list_empty(&vsock->send_pkt_list)) {
10198
spin_unlock_bh(&vsock->send_pkt_list_lock);
102-
virtqueue_enable_cb(vq);
10399
break;
104100
}
105101

@@ -118,13 +114,13 @@ virtio_transport_send_pkt_work(struct work_struct *work)
118114
}
119115

120116
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+
*/
121120
if (ret < 0) {
122121
spin_lock_bh(&vsock->send_pkt_list_lock);
123122
list_add(&pkt->list, &vsock->send_pkt_list);
124123
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 */
128124
break;
129125
}
130126

tools/virtio/linux/dma-mapping.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,20 @@ enum dma_data_direction {
1414
DMA_NONE = 3,
1515
};
1616

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+
1733
#endif

tools/virtio/linux/kernel.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020

2121
#define PAGE_SIZE getpagesize()
2222
#define PAGE_MASK (~(PAGE_SIZE-1))
23+
#define PAGE_ALIGN(x) ((x + PAGE_SIZE - 1) & PAGE_MASK)
2324

25+
typedef unsigned long long phys_addr_t;
2426
typedef unsigned long long dma_addr_t;
2527
typedef size_t __kernel_size_t;
2628
typedef unsigned int __wsum;
@@ -57,13 +59,23 @@ static inline void *kzalloc(size_t s, gfp_t gfp)
5759
return p;
5860
}
5961

62+
static inline void *alloc_pages_exact(size_t s, gfp_t gfp)
63+
{
64+
return kmalloc(s, gfp);
65+
}
66+
6067
static inline void kfree(void *p)
6168
{
6269
if (p >= __kfree_ignore_start && p < __kfree_ignore_end)
6370
return;
6471
free(p);
6572
}
6673

74+
static inline void free_pages_exact(void *p, size_t s)
75+
{
76+
kfree(p);
77+
}
78+
6779
static inline void *krealloc(void *p, size_t s, gfp_t gfp)
6880
{
6981
return realloc(p, s);
@@ -105,6 +117,8 @@ static inline void free_page(unsigned long addr)
105117
#define dev_err(dev, format, ...) fprintf (stderr, format, ## __VA_ARGS__)
106118
#define dev_warn(dev, format, ...) fprintf (stderr, format, ## __VA_ARGS__)
107119

120+
#define WARN_ON_ONCE(cond) ((cond) && fprintf (stderr, "WARNING\n"))
121+
108122
#define min(x, y) ({ \
109123
typeof(x) _min1 = (x); \
110124
typeof(y) _min2 = (y); \

tools/virtio/linux/slab.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
#ifndef LINUX_SLAB_H
2+
#define GFP_KERNEL 0
3+
#define GFP_ATOMIC 0
4+
#define __GFP_NOWARN 0
5+
#define __GFP_ZERO 0
26
#endif

tools/virtio/linux/virtio.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
#include <linux/scatterlist.h>
44
#include <linux/kernel.h>
55

6+
struct device {
7+
void *parent;
8+
};
9+
610
struct virtio_device {
7-
void *dev;
11+
struct device dev;
812
u64 features;
913
};
1014

tools/virtio/linux/virtio_config.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ static inline void __virtio_clear_bit(struct virtio_device *vdev,
4040
#define virtio_has_feature(dev, feature) \
4141
(__virtio_test_bit((dev), feature))
4242

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+
4356
static inline bool virtio_is_little_endian(struct virtio_device *vdev)
4457
{
4558
return virtio_has_feature(vdev, VIRTIO_F_VERSION_1) ||

tools/virtio/ringtest/ptr_ring.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#define cache_line_size() SMP_CACHE_BYTES
1414
#define ____cacheline_aligned_in_smp __attribute__ ((aligned (SMP_CACHE_BYTES)))
1515
#define unlikely(x) (__builtin_expect(!!(x), 0))
16+
#define likely(x) (__builtin_expect(!!(x), 1))
1617
#define ALIGN(x, a) (((x) + (a) - 1) / (a) * (a))
1718
typedef pthread_spinlock_t spinlock_t;
1819

0 commit comments

Comments
 (0)