mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
virtio, vhost: fixes, features, performance
new iommu device vhost guest memory access using vmap (just meta-data for now) minor fixes Signed-off-by: Michael S. Tsirkin <[email protected]> Note: due to code driver changes the driver-core tree, the following patch is needed when merging tree with commit92ce7e83b4("driver_find_device: Unify the match function with class_find_device()") in the driver-core tree: From: Nathan Chancellor <[email protected]> Subject: [PATCH] iommu/virtio: Constify data parameter in viommu_match_node After commit92ce7e83b4("driver_find_device: Unify the match function with class_find_device()") in the driver-core tree. Signed-off-by: Nathan Chancellor <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> --- drivers/iommu/virtio-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c index 4620dd221ffd..433f4d2ee956 100644 --- a/drivers/iommu/virtio-iommu.c +++ b/drivers/iommu/virtio-iommu.c @@ -839,7 +839,7 @@ static void viommu_put_resv_regions(struct device *dev, struct list_head *head) static struct iommu_ops viommu_ops; static struct virtio_driver virtio_iommu_drv; -static int viommu_match_node(struct device *dev, void *data) +static int viommu_match_node(struct device *dev, const void *data) { return dev->parent->fwnode == data; } -----BEGIN PGP SIGNATURE----- iQEcBAABAgAGBQJdJ5qUAAoJECgfDbjSjVRpQs0H/2qWcIG1zjGKyh9KWrfgOusG /QIqeP50d7SC6oqdyd00tzmExqO1xdGLPFzYixdOsU817te1gHBP4Rfmzo01jZRd CUzZNnZQ2JRsDshiA6G2ui+wn1/a/cB3RPN4rT1mquDYS53QmsRGDQDnpp84TXMV aocB8TS6halbRzKMq3VmaWHIvzNXnt4dwQR542+PyeLLn9bUx2QwWj2ON3QwxixK dVRZow3GwLGBhKTA/Z1Z/Bta4fEfOKjUGP2XWgvL6zOr+nZR4eQ8w5WXVJYzR+d6 1JCfqTxleweT2k6Tu5VwtTNlQkxn/XvQAeisppOiEE6NnPjubyI9wMQIvL7bkpo= =uJbC -----END PGP SIGNATURE----- Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost Pull virtio, vhost updates from Michael Tsirkin: "Fixes, features, performance: - new iommu device - vhost guest memory access using vmap (just meta-data for now) - minor fixes" * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: virtio-mmio: add error check for platform_get_irq scsi: virtio_scsi: Use struct_size() helper iommu/virtio: Add event queue iommu/virtio: Add probe request iommu: Add virtio-iommu driver PCI: OF: Initialize dev->fwnode appropriately of: Allow the iommu-map property to omit untranslated devices dt-bindings: virtio: Add virtio-pci-iommu node dt-bindings: virtio-mmio: Add IOMMU description vhost: fix clang build warning vhost: access vq metadata through kernel virtual address vhost: factor out setting vring addr and num vhost: introduce helpers to get the size of metadata area vhost: rename vq_iotlb_prefetch() to vq_meta_prefetch() vhost: fine grain userspace memory accessors vhost: generalize adding used elem
This commit is contained in:
commit
3a1d5384b7
15 changed files with 2228 additions and 131 deletions
|
|
@ -956,7 +956,7 @@ static void handle_tx(struct vhost_net *net)
|
|||
if (!sock)
|
||||
goto out;
|
||||
|
||||
if (!vq_iotlb_prefetch(vq))
|
||||
if (!vq_meta_prefetch(vq))
|
||||
goto out;
|
||||
|
||||
vhost_disable_notify(&net->dev, vq);
|
||||
|
|
@ -1125,7 +1125,7 @@ static void handle_rx(struct vhost_net *net)
|
|||
if (!sock)
|
||||
goto out;
|
||||
|
||||
if (!vq_iotlb_prefetch(vq))
|
||||
if (!vq_meta_prefetch(vq))
|
||||
goto out;
|
||||
|
||||
vhost_disable_notify(&net->dev, vq);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -12,6 +12,9 @@
|
|||
#include <linux/virtio_config.h>
|
||||
#include <linux/virtio_ring.h>
|
||||
#include <linux/atomic.h>
|
||||
#include <linux/pagemap.h>
|
||||
#include <linux/mmu_notifier.h>
|
||||
#include <asm/cacheflush.h>
|
||||
|
||||
struct vhost_work;
|
||||
typedef void (*vhost_work_fn_t)(struct vhost_work *work);
|
||||
|
|
@ -80,6 +83,24 @@ enum vhost_uaddr_type {
|
|||
VHOST_NUM_ADDRS = 3,
|
||||
};
|
||||
|
||||
struct vhost_map {
|
||||
int npages;
|
||||
void *addr;
|
||||
struct page **pages;
|
||||
};
|
||||
|
||||
struct vhost_uaddr {
|
||||
unsigned long uaddr;
|
||||
size_t size;
|
||||
bool write;
|
||||
};
|
||||
|
||||
#if defined(CONFIG_MMU_NOTIFIER) && ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE == 0
|
||||
#define VHOST_ARCH_CAN_ACCEL_UACCESS 1
|
||||
#else
|
||||
#define VHOST_ARCH_CAN_ACCEL_UACCESS 0
|
||||
#endif
|
||||
|
||||
/* The virtqueue structure describes a queue attached to a device. */
|
||||
struct vhost_virtqueue {
|
||||
struct vhost_dev *dev;
|
||||
|
|
@ -90,7 +111,22 @@ struct vhost_virtqueue {
|
|||
struct vring_desc __user *desc;
|
||||
struct vring_avail __user *avail;
|
||||
struct vring_used __user *used;
|
||||
|
||||
#if VHOST_ARCH_CAN_ACCEL_UACCESS
|
||||
/* Read by memory accessors, modified by meta data
|
||||
* prefetching, MMU notifier and vring ioctl().
|
||||
* Synchonrized through mmu_lock (writers) and RCU (writers
|
||||
* and readers).
|
||||
*/
|
||||
struct vhost_map __rcu *maps[VHOST_NUM_ADDRS];
|
||||
/* Read by MMU notifier, modified by vring ioctl(),
|
||||
* synchronized through MMU notifier
|
||||
* registering/unregistering.
|
||||
*/
|
||||
struct vhost_uaddr uaddrs[VHOST_NUM_ADDRS];
|
||||
#endif
|
||||
const struct vhost_umem_node *meta_iotlb[VHOST_NUM_ADDRS];
|
||||
|
||||
struct file *kick;
|
||||
struct eventfd_ctx *call_ctx;
|
||||
struct eventfd_ctx *error_ctx;
|
||||
|
|
@ -145,6 +181,8 @@ struct vhost_virtqueue {
|
|||
bool user_be;
|
||||
#endif
|
||||
u32 busyloop_timeout;
|
||||
spinlock_t mmu_lock;
|
||||
int invalidate_count;
|
||||
};
|
||||
|
||||
struct vhost_msg_node {
|
||||
|
|
@ -158,6 +196,9 @@ struct vhost_msg_node {
|
|||
|
||||
struct vhost_dev {
|
||||
struct mm_struct *mm;
|
||||
#ifdef CONFIG_MMU_NOTIFIER
|
||||
struct mmu_notifier mmu_notifier;
|
||||
#endif
|
||||
struct mutex mutex;
|
||||
struct vhost_virtqueue **vqs;
|
||||
int nvqs;
|
||||
|
|
@ -212,7 +253,7 @@ bool vhost_enable_notify(struct vhost_dev *, struct vhost_virtqueue *);
|
|||
int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log,
|
||||
unsigned int log_num, u64 len,
|
||||
struct iovec *iov, int count);
|
||||
int vq_iotlb_prefetch(struct vhost_virtqueue *vq);
|
||||
int vq_meta_prefetch(struct vhost_virtqueue *vq);
|
||||
|
||||
struct vhost_msg_node *vhost_new_msg(struct vhost_virtqueue *vq, int type);
|
||||
void vhost_enqueue_msg(struct vhost_dev *dev,
|
||||
|
|
|
|||
Loading…
Reference in a new issue