Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3ec60b92 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
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
parents 45b6ae76 6be3ffaa
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -220,20 +220,20 @@ static long vhost_test_reset_owner(struct vhost_test *n)
{
{
	void *priv = NULL;
	void *priv = NULL;
	long err;
	long err;
	struct vhost_memory *memory;
	struct vhost_umem *umem;


	mutex_lock(&n->dev.mutex);
	mutex_lock(&n->dev.mutex);
	err = vhost_dev_check_owner(&n->dev);
	err = vhost_dev_check_owner(&n->dev);
	if (err)
	if (err)
		goto done;
		goto done;
	memory = vhost_dev_reset_owner_prepare();
	umem = vhost_dev_reset_owner_prepare();
	if (!memory) {
	if (!umem) {
		err = -ENOMEM;
		err = -ENOMEM;
		goto done;
		goto done;
	}
	}
	vhost_test_stop(n, &priv);
	vhost_test_stop(n, &priv);
	vhost_test_flush(n);
	vhost_test_flush(n);
	vhost_dev_reset_owner(&n->dev, memory);
	vhost_dev_reset_owner(&n->dev, umem);
done:
done:
	mutex_unlock(&n->dev.mutex);
	mutex_unlock(&n->dev.mutex);
	return err;
	return err;
+3 −7
Original line number Original line Diff line number Diff line
@@ -87,9 +87,6 @@ virtio_transport_send_pkt_work(struct work_struct *work)


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


	/* Avoid unnecessary interrupts while we're processing the ring */
	virtqueue_disable_cb(vq);

	for (;;) {
	for (;;) {
		struct virtio_vsock_pkt *pkt;
		struct virtio_vsock_pkt *pkt;
		struct scatterlist hdr, buf, *sgs[2];
		struct scatterlist hdr, buf, *sgs[2];
@@ -99,7 +96,6 @@ virtio_transport_send_pkt_work(struct work_struct *work)
		spin_lock_bh(&vsock->send_pkt_list_lock);
		spin_lock_bh(&vsock->send_pkt_list_lock);
		if (list_empty(&vsock->send_pkt_list)) {
		if (list_empty(&vsock->send_pkt_list)) {
			spin_unlock_bh(&vsock->send_pkt_list_lock);
			spin_unlock_bh(&vsock->send_pkt_list_lock);
			virtqueue_enable_cb(vq);
			break;
			break;
		}
		}


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


		ret = virtqueue_add_sgs(vq, sgs, out_sg, in_sg, pkt, GFP_KERNEL);
		ret = virtqueue_add_sgs(vq, sgs, out_sg, in_sg, pkt, GFP_KERNEL);
		/* Usually this means that there is no more space available in
		 * the vq
		 */
		if (ret < 0) {
		if (ret < 0) {
			spin_lock_bh(&vsock->send_pkt_list_lock);
			spin_lock_bh(&vsock->send_pkt_list_lock);
			list_add(&pkt->list, &vsock->send_pkt_list);
			list_add(&pkt->list, &vsock->send_pkt_list);
			spin_unlock_bh(&vsock->send_pkt_list_lock);
			spin_unlock_bh(&vsock->send_pkt_list_lock);

			if (!virtqueue_enable_cb(vq) && ret == -ENOSPC)
				continue; /* retry now that we have more space */
			break;
			break;
		}
		}


+16 −0
Original line number Original line Diff line number Diff line
@@ -14,4 +14,20 @@ enum dma_data_direction {
	DMA_NONE = 3,
	DMA_NONE = 3,
};
};


#define dma_alloc_coherent(d, s, hp, f) ({ \
	void *__dma_alloc_coherent_p = kmalloc((s), (f)); \
	*(hp) = (unsigned long)__dma_alloc_coherent_p; \
	__dma_alloc_coherent_p; \
})

#define dma_free_coherent(d, s, p, h) kfree(p)

#define dma_map_page(d, p, o, s, dir) (page_to_phys(p) + (o))

#define dma_map_single(d, p, s, dir) (virt_to_phys(p))
#define dma_mapping_error(...) (0)

#define dma_unmap_single(...) do { } while (0)
#define dma_unmap_page(...) do { } while (0)

#endif
#endif
+14 −0
Original line number Original line Diff line number Diff line
@@ -20,7 +20,9 @@


#define PAGE_SIZE getpagesize()
#define PAGE_SIZE getpagesize()
#define PAGE_MASK (~(PAGE_SIZE-1))
#define PAGE_MASK (~(PAGE_SIZE-1))
#define PAGE_ALIGN(x) ((x + PAGE_SIZE - 1) & PAGE_MASK)


typedef unsigned long long phys_addr_t;
typedef unsigned long long dma_addr_t;
typedef unsigned long long dma_addr_t;
typedef size_t __kernel_size_t;
typedef size_t __kernel_size_t;
typedef unsigned int __wsum;
typedef unsigned int __wsum;
@@ -57,6 +59,11 @@ static inline void *kzalloc(size_t s, gfp_t gfp)
	return p;
	return p;
}
}


static inline void *alloc_pages_exact(size_t s, gfp_t gfp)
{
	return kmalloc(s, gfp);
}

static inline void kfree(void *p)
static inline void kfree(void *p)
{
{
	if (p >= __kfree_ignore_start && p < __kfree_ignore_end)
	if (p >= __kfree_ignore_start && p < __kfree_ignore_end)
@@ -64,6 +71,11 @@ static inline void kfree(void *p)
	free(p);
	free(p);
}
}


static inline void free_pages_exact(void *p, size_t s)
{
	kfree(p);
}

static inline void *krealloc(void *p, size_t s, gfp_t gfp)
static inline void *krealloc(void *p, size_t s, gfp_t gfp)
{
{
	return realloc(p, s);
	return realloc(p, s);
@@ -105,6 +117,8 @@ static inline void free_page(unsigned long addr)
#define dev_err(dev, format, ...) fprintf (stderr, format, ## __VA_ARGS__)
#define dev_err(dev, format, ...) fprintf (stderr, format, ## __VA_ARGS__)
#define dev_warn(dev, format, ...) fprintf (stderr, format, ## __VA_ARGS__)
#define dev_warn(dev, format, ...) fprintf (stderr, format, ## __VA_ARGS__)


#define WARN_ON_ONCE(cond) ((cond) && fprintf (stderr, "WARNING\n"))

#define min(x, y) ({				\
#define min(x, y) ({				\
	typeof(x) _min1 = (x);			\
	typeof(x) _min1 = (x);			\
	typeof(y) _min2 = (y);			\
	typeof(y) _min2 = (y);			\
+4 −0
Original line number Original line Diff line number Diff line
#ifndef LINUX_SLAB_H
#ifndef LINUX_SLAB_H
#define GFP_KERNEL 0
#define GFP_ATOMIC 0
#define __GFP_NOWARN 0
#define __GFP_ZERO 0
#endif
#endif
Loading