Skip to content

Commit 3302363

Browse files
committed
virtio/test: fix up after IOTLB changes
Allow building vringh without IOTLB (that's the case for userspace builds, will be useful for CAIF/VOD down the road too). Update for API tweaks. Don't include vringh with userspace builds. Cc: Jason Wang <[email protected]> Cc: Eugenio Pérez <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Acked-by: Jason Wang <[email protected]>
1 parent 247643f commit 3302363

File tree

6 files changed

+18
-4
lines changed

6 files changed

+18
-4
lines changed

drivers/vhost/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ config VHOST_IOTLB
33
tristate
44
help
55
Generic IOTLB implementation for vhost and vringh.
6+
This option is selected by any driver which needs to support
7+
an IOMMU in software.
68

79
config VHOST_RING
810
tristate

drivers/vhost/test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ static int vhost_test_open(struct inode *inode, struct file *f)
120120
vqs[VHOST_TEST_VQ] = &n->vqs[VHOST_TEST_VQ];
121121
n->vqs[VHOST_TEST_VQ].handle_kick = handle_vq_kick;
122122
vhost_dev_init(dev, vqs, VHOST_TEST_VQ_MAX, UIO_MAXIOV,
123-
VHOST_TEST_PKT_WEIGHT, VHOST_TEST_WEIGHT);
123+
VHOST_TEST_PKT_WEIGHT, VHOST_TEST_WEIGHT, NULL);
124124

125125
f->private_data = n;
126126

@@ -225,7 +225,7 @@ static long vhost_test_reset_owner(struct vhost_test *n)
225225
{
226226
void *priv = NULL;
227227
long err;
228-
struct vhost_umem *umem;
228+
struct vhost_iotlb *umem;
229229

230230
mutex_lock(&n->dev.mutex);
231231
err = vhost_dev_check_owner(&n->dev);

drivers/vhost/vringh.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
#include <linux/uaccess.h>
1414
#include <linux/slab.h>
1515
#include <linux/export.h>
16+
#if IS_REACHABLE(CONFIG_VHOST_IOTLB)
1617
#include <linux/bvec.h>
1718
#include <linux/highmem.h>
1819
#include <linux/vhost_iotlb.h>
20+
#endif
1921
#include <uapi/linux/virtio_config.h>
2022

2123
static __printf(1,2) __cold void vringh_bad(const char *fmt, ...)
@@ -1059,6 +1061,8 @@ int vringh_need_notify_kern(struct vringh *vrh)
10591061
}
10601062
EXPORT_SYMBOL(vringh_need_notify_kern);
10611063

1064+
#if IS_REACHABLE(CONFIG_VHOST_IOTLB)
1065+
10621066
static int iotlb_translate(const struct vringh *vrh,
10631067
u64 addr, u64 len, struct bio_vec iov[],
10641068
int iov_size, u32 perm)
@@ -1416,5 +1420,6 @@ int vringh_need_notify_iotlb(struct vringh *vrh)
14161420
}
14171421
EXPORT_SYMBOL(vringh_need_notify_iotlb);
14181422

1423+
#endif
14191424

14201425
MODULE_LICENSE("GPL");

include/linux/vringh.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
#include <linux/virtio_byteorder.h>
1515
#include <linux/uio.h>
1616
#include <linux/slab.h>
17+
#if IS_REACHABLE(CONFIG_VHOST_IOTLB)
1718
#include <linux/dma-direction.h>
1819
#include <linux/vhost_iotlb.h>
20+
#endif
1921
#include <asm/barrier.h>
2022

2123
/* virtio_ring with information needed for host access. */
@@ -254,6 +256,8 @@ static inline __virtio64 cpu_to_vringh64(const struct vringh *vrh, u64 val)
254256
return __cpu_to_virtio64(vringh_is_little_endian(vrh), val);
255257
}
256258

259+
#if IS_REACHABLE(CONFIG_VHOST_IOTLB)
260+
257261
void vringh_set_iotlb(struct vringh *vrh, struct vhost_iotlb *iotlb);
258262

259263
int vringh_init_iotlb(struct vringh *vrh, u64 features,
@@ -284,4 +288,6 @@ void vringh_notify_disable_iotlb(struct vringh *vrh);
284288

285289
int vringh_need_notify_iotlb(struct vringh *vrh);
286290

291+
#endif /* CONFIG_VHOST_IOTLB */
292+
287293
#endif /* _LINUX_VRINGH_H */

tools/virtio/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ test: virtio_test vringh_test
44
virtio_test: virtio_ring.o virtio_test.o
55
vringh_test: vringh_test.o vringh.o virtio_ring.o
66

7-
CFLAGS += -g -O2 -Werror -Wall -I. -I../include/ -I ../../usr/include/ -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE
7+
CFLAGS += -g -O2 -Werror -Wall -I. -I../include/ -I ../../usr/include/ -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE -include ../../include/linux/kconfig.h
88
vpath %.c ../../drivers/virtio ../../drivers/vhost
99
mod:
1010
${MAKE} -C `pwd`/../.. M=`pwd`/vhost_test V=${V}
@@ -22,7 +22,8 @@ OOT_CONFIGS=\
2222
CONFIG_VHOST=m \
2323
CONFIG_VHOST_NET=n \
2424
CONFIG_VHOST_SCSI=n \
25-
CONFIG_VHOST_VSOCK=n
25+
CONFIG_VHOST_VSOCK=n \
26+
CONFIG_VHOST_RING=n
2627
OOT_BUILD=KCFLAGS="-I "${OOT_VHOST} ${MAKE} -C ${OOT_KSRC} V=${V}
2728
oot-build:
2829
echo "UNSUPPORTED! Don't use the resulting modules in production!"

tools/virtio/generated/autoconf.h

Whitespace-only changes.

0 commit comments

Comments
 (0)