Commit c5e43b83 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'virtio-for-linus' of...

Merge tag 'virtio-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus

Pull minor virtio-balloon fix from Rusty Russell:
 "Theoretical fix, which greatly simplifies upcoming balloon patches
  which will go in via some vm tree."

* tag 'virtio-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus:
  virtio-balloon: fix add/get API use
parents 6f5410b6 9c378abc
...@@ -47,7 +47,7 @@ struct virtio_balloon ...@@ -47,7 +47,7 @@ struct virtio_balloon
struct task_struct *thread; struct task_struct *thread;
/* Waiting for host to ack the pages we released. */ /* Waiting for host to ack the pages we released. */
struct completion acked; wait_queue_head_t acked;
/* Number of balloon pages we've told the Host we're not using. */ /* Number of balloon pages we've told the Host we're not using. */
unsigned int num_pages; unsigned int num_pages;
...@@ -89,29 +89,25 @@ static struct page *balloon_pfn_to_page(u32 pfn) ...@@ -89,29 +89,25 @@ static struct page *balloon_pfn_to_page(u32 pfn)
static void balloon_ack(struct virtqueue *vq) static void balloon_ack(struct virtqueue *vq)
{ {
struct virtio_balloon *vb; struct virtio_balloon *vb = vq->vdev->priv;
unsigned int len;
vb = virtqueue_get_buf(vq, &len); wake_up(&vb->acked);
if (vb)
complete(&vb->acked);
} }
static void tell_host(struct virtio_balloon *vb, struct virtqueue *vq) static void tell_host(struct virtio_balloon *vb, struct virtqueue *vq)
{ {
struct scatterlist sg; struct scatterlist sg;
unsigned int len;
sg_init_one(&sg, vb->pfns, sizeof(vb->pfns[0]) * vb->num_pfns); sg_init_one(&sg, vb->pfns, sizeof(vb->pfns[0]) * vb->num_pfns);
init_completion(&vb->acked);
/* We should always be able to add one buffer to an empty queue. */ /* We should always be able to add one buffer to an empty queue. */
if (virtqueue_add_buf(vq, &sg, 1, 0, vb, GFP_KERNEL) < 0) if (virtqueue_add_buf(vq, &sg, 1, 0, vb, GFP_KERNEL) < 0)
BUG(); BUG();
virtqueue_kick(vq); virtqueue_kick(vq);
/* When host has read buffer, this completes via balloon_ack */ /* When host has read buffer, this completes via balloon_ack */
wait_for_completion(&vb->acked); wait_event(vb->acked, virtqueue_get_buf(vq, &len));
} }
static void set_page_pfns(u32 pfns[], struct page *page) static void set_page_pfns(u32 pfns[], struct page *page)
...@@ -231,12 +227,8 @@ static void update_balloon_stats(struct virtio_balloon *vb) ...@@ -231,12 +227,8 @@ static void update_balloon_stats(struct virtio_balloon *vb)
*/ */
static void stats_request(struct virtqueue *vq) static void stats_request(struct virtqueue *vq)
{ {
struct virtio_balloon *vb; struct virtio_balloon *vb = vq->vdev->priv;
unsigned int len;
vb = virtqueue_get_buf(vq, &len);
if (!vb)
return;
vb->need_stats_update = 1; vb->need_stats_update = 1;
wake_up(&vb->config_change); wake_up(&vb->config_change);
} }
...@@ -245,11 +237,14 @@ static void stats_handle_request(struct virtio_balloon *vb) ...@@ -245,11 +237,14 @@ static void stats_handle_request(struct virtio_balloon *vb)
{ {
struct virtqueue *vq; struct virtqueue *vq;
struct scatterlist sg; struct scatterlist sg;
unsigned int len;
vb->need_stats_update = 0; vb->need_stats_update = 0;
update_balloon_stats(vb); update_balloon_stats(vb);
vq = vb->stats_vq; vq = vb->stats_vq;
if (!virtqueue_get_buf(vq, &len))
return;
sg_init_one(&sg, vb->stats, sizeof(vb->stats)); sg_init_one(&sg, vb->stats, sizeof(vb->stats));
if (virtqueue_add_buf(vq, &sg, 1, 0, vb, GFP_KERNEL) < 0) if (virtqueue_add_buf(vq, &sg, 1, 0, vb, GFP_KERNEL) < 0)
BUG(); BUG();
...@@ -358,6 +353,7 @@ static int virtballoon_probe(struct virtio_device *vdev) ...@@ -358,6 +353,7 @@ static int virtballoon_probe(struct virtio_device *vdev)
INIT_LIST_HEAD(&vb->pages); INIT_LIST_HEAD(&vb->pages);
vb->num_pages = 0; vb->num_pages = 0;
init_waitqueue_head(&vb->config_change); init_waitqueue_head(&vb->config_change);
init_waitqueue_head(&vb->acked);
vb->vdev = vdev; vb->vdev = vdev;
vb->need_stats_update = 0; vb->need_stats_update = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment