summaryrefslogtreecommitdiffstats
path: root/drivers/vhost/vhost.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman2019-06-17 11:23:24 +0200
committerGreg Kroah-Hartman2019-06-17 11:23:24 +0200
commita954e5fb4bc2d401b8fc3b4c7cd316497ff80225 (patch)
tree06af23b232c7c2e795a2fef8a5a0604ec64d5092 /drivers/vhost/vhost.c
parentRevert "usb: mtu3: fix up undefined reference to usb_debug_root" (diff)
parentLinux 5.2-rc5 (diff)
downloadkernel-qcow2-linux-a954e5fb4bc2d401b8fc3b4c7cd316497ff80225.tar.gz
kernel-qcow2-linux-a954e5fb4bc2d401b8fc3b4c7cd316497ff80225.tar.xz
kernel-qcow2-linux-a954e5fb4bc2d401b8fc3b4c7cd316497ff80225.zip
Merge 5.2-rc5 into usb-next
We need the USB fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/vhost/vhost.c')
-rw-r--r--drivers/vhost/vhost.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 1e3ed41ae1f3..3f3eac4bcc58 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -413,8 +413,24 @@ static void vhost_dev_free_iovecs(struct vhost_dev *dev)
vhost_vq_free_iovecs(dev->vqs[i]);
}
+bool vhost_exceeds_weight(struct vhost_virtqueue *vq,
+ int pkts, int total_len)
+{
+ struct vhost_dev *dev = vq->dev;
+
+ if ((dev->byte_weight && total_len >= dev->byte_weight) ||
+ pkts >= dev->weight) {
+ vhost_poll_queue(&vq->poll);
+ return true;
+ }
+
+ return false;
+}
+EXPORT_SYMBOL_GPL(vhost_exceeds_weight);
+
void vhost_dev_init(struct vhost_dev *dev,
- struct vhost_virtqueue **vqs, int nvqs, int iov_limit)
+ struct vhost_virtqueue **vqs, int nvqs,
+ int iov_limit, int weight, int byte_weight)
{
struct vhost_virtqueue *vq;
int i;
@@ -428,6 +444,8 @@ void vhost_dev_init(struct vhost_dev *dev,
dev->mm = NULL;
dev->worker = NULL;
dev->iov_limit = iov_limit;
+ dev->weight = weight;
+ dev->byte_weight = byte_weight;
init_llist_head(&dev->work_list);
init_waitqueue_head(&dev->wait);
INIT_LIST_HEAD(&dev->read_list);