diff options
author | David S. Miller <davem@davemloft.net> | 2017-08-01 13:07:50 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-08-01 13:07:50 -0400 |
commit | 29fda25a2d31098044f8dfa177c4d2834071828e (patch) | |
tree | 9e4be11c49a4405c19ece8f81fbb1db478da1055 /drivers/virtio | |
parent | bb1182bc3e5956a93ab3ef8a3cbfb7966c42a94a (diff) | |
parent | bc78d646e708dabd1744ca98744dea316f459497 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Two minor conflicts in virtio_net driver (bug fix overlapping addition
of a helper) and MAINTAINERS (new driver edit overlapping revamp of
PHY entry).
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/virtio')
-rw-r--r-- | drivers/virtio/virtio_balloon.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 22caf808bfab..f0b3a0b9d42f 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c | |||
@@ -104,12 +104,6 @@ static u32 page_to_balloon_pfn(struct page *page) | |||
104 | return pfn * VIRTIO_BALLOON_PAGES_PER_PAGE; | 104 | return pfn * VIRTIO_BALLOON_PAGES_PER_PAGE; |
105 | } | 105 | } |
106 | 106 | ||
107 | static struct page *balloon_pfn_to_page(u32 pfn) | ||
108 | { | ||
109 | BUG_ON(pfn % VIRTIO_BALLOON_PAGES_PER_PAGE); | ||
110 | return pfn_to_page(pfn / VIRTIO_BALLOON_PAGES_PER_PAGE); | ||
111 | } | ||
112 | |||
113 | static void balloon_ack(struct virtqueue *vq) | 107 | static void balloon_ack(struct virtqueue *vq) |
114 | { | 108 | { |
115 | struct virtio_balloon *vb = vq->vdev->priv; | 109 | struct virtio_balloon *vb = vq->vdev->priv; |
@@ -138,8 +132,10 @@ static void set_page_pfns(struct virtio_balloon *vb, | |||
138 | { | 132 | { |
139 | unsigned int i; | 133 | unsigned int i; |
140 | 134 | ||
141 | /* Set balloon pfns pointing at this page. | 135 | /* |
142 | * Note that the first pfn points at start of the page. */ | 136 | * Set balloon pfns pointing at this page. |
137 | * Note that the first pfn points at start of the page. | ||
138 | */ | ||
143 | for (i = 0; i < VIRTIO_BALLOON_PAGES_PER_PAGE; i++) | 139 | for (i = 0; i < VIRTIO_BALLOON_PAGES_PER_PAGE; i++) |
144 | pfns[i] = cpu_to_virtio32(vb->vdev, | 140 | pfns[i] = cpu_to_virtio32(vb->vdev, |
145 | page_to_balloon_pfn(page) + i); | 141 | page_to_balloon_pfn(page) + i); |
@@ -182,18 +178,16 @@ static unsigned fill_balloon(struct virtio_balloon *vb, size_t num) | |||
182 | return num_allocated_pages; | 178 | return num_allocated_pages; |
183 | } | 179 | } |
184 | 180 | ||
185 | static void release_pages_balloon(struct virtio_balloon *vb) | 181 | static void release_pages_balloon(struct virtio_balloon *vb, |
182 | struct list_head *pages) | ||
186 | { | 183 | { |
187 | unsigned int i; | 184 | struct page *page, *next; |
188 | struct page *page; | ||
189 | 185 | ||
190 | /* Find pfns pointing at start of each page, get pages and free them. */ | 186 | list_for_each_entry_safe(page, next, pages, lru) { |
191 | for (i = 0; i < vb->num_pfns; i += VIRTIO_BALLOON_PAGES_PER_PAGE) { | ||
192 | page = balloon_pfn_to_page(virtio32_to_cpu(vb->vdev, | ||
193 | vb->pfns[i])); | ||
194 | if (!virtio_has_feature(vb->vdev, | 187 | if (!virtio_has_feature(vb->vdev, |
195 | VIRTIO_BALLOON_F_DEFLATE_ON_OOM)) | 188 | VIRTIO_BALLOON_F_DEFLATE_ON_OOM)) |
196 | adjust_managed_page_count(page, 1); | 189 | adjust_managed_page_count(page, 1); |
190 | list_del(&page->lru); | ||
197 | put_page(page); /* balloon reference */ | 191 | put_page(page); /* balloon reference */ |
198 | } | 192 | } |
199 | } | 193 | } |
@@ -203,6 +197,7 @@ static unsigned leak_balloon(struct virtio_balloon *vb, size_t num) | |||
203 | unsigned num_freed_pages; | 197 | unsigned num_freed_pages; |
204 | struct page *page; | 198 | struct page *page; |
205 | struct balloon_dev_info *vb_dev_info = &vb->vb_dev_info; | 199 | struct balloon_dev_info *vb_dev_info = &vb->vb_dev_info; |
200 | LIST_HEAD(pages); | ||
206 | 201 | ||
207 | /* We can only do one array worth at a time. */ | 202 | /* We can only do one array worth at a time. */ |
208 | num = min(num, ARRAY_SIZE(vb->pfns)); | 203 | num = min(num, ARRAY_SIZE(vb->pfns)); |
@@ -216,6 +211,7 @@ static unsigned leak_balloon(struct virtio_balloon *vb, size_t num) | |||
216 | if (!page) | 211 | if (!page) |
217 | break; | 212 | break; |
218 | set_page_pfns(vb, vb->pfns + vb->num_pfns, page); | 213 | set_page_pfns(vb, vb->pfns + vb->num_pfns, page); |
214 | list_add(&page->lru, &pages); | ||
219 | vb->num_pages -= VIRTIO_BALLOON_PAGES_PER_PAGE; | 215 | vb->num_pages -= VIRTIO_BALLOON_PAGES_PER_PAGE; |
220 | } | 216 | } |
221 | 217 | ||
@@ -227,7 +223,7 @@ static unsigned leak_balloon(struct virtio_balloon *vb, size_t num) | |||
227 | */ | 223 | */ |
228 | if (vb->num_pfns != 0) | 224 | if (vb->num_pfns != 0) |
229 | tell_host(vb, vb->deflate_vq); | 225 | tell_host(vb, vb->deflate_vq); |
230 | release_pages_balloon(vb); | 226 | release_pages_balloon(vb, &pages); |
231 | mutex_unlock(&vb->balloon_lock); | 227 | mutex_unlock(&vb->balloon_lock); |
232 | return num_freed_pages; | 228 | return num_freed_pages; |
233 | } | 229 | } |