aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/block/xen-blkback/blkback.c8
-rw-r--r--drivers/net/xen-netback/interface.c7
-rw-r--r--drivers/xen/gntdev.c4
-rw-r--r--drivers/xen/grant-table.c29
-rw-r--r--drivers/xen/xen-scsiback.c6
-rw-r--r--include/xen/grant_table.h3
6 files changed, 44 insertions, 13 deletions
diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
index 63fc7f06a014..908e630240bd 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -100,7 +100,7 @@ module_param(log_stats, int, 0644);
100 100
101#define BLKBACK_INVALID_HANDLE (~0) 101#define BLKBACK_INVALID_HANDLE (~0)
102 102
103/* Number of free pages to remove on each call to free_xenballooned_pages */ 103/* Number of free pages to remove on each call to gnttab_free_pages */
104#define NUM_BATCH_FREE_PAGES 10 104#define NUM_BATCH_FREE_PAGES 10
105 105
106static inline int get_free_page(struct xen_blkif *blkif, struct page **page) 106static inline int get_free_page(struct xen_blkif *blkif, struct page **page)
@@ -111,7 +111,7 @@ static inline int get_free_page(struct xen_blkif *blkif, struct page **page)
111 if (list_empty(&blkif->free_pages)) { 111 if (list_empty(&blkif->free_pages)) {
112 BUG_ON(blkif->free_pages_num != 0); 112 BUG_ON(blkif->free_pages_num != 0);
113 spin_unlock_irqrestore(&blkif->free_pages_lock, flags); 113 spin_unlock_irqrestore(&blkif->free_pages_lock, flags);
114 return alloc_xenballooned_pages(1, page, false); 114 return gnttab_alloc_pages(1, page);
115 } 115 }
116 BUG_ON(blkif->free_pages_num == 0); 116 BUG_ON(blkif->free_pages_num == 0);
117 page[0] = list_first_entry(&blkif->free_pages, struct page, lru); 117 page[0] = list_first_entry(&blkif->free_pages, struct page, lru);
@@ -151,14 +151,14 @@ static inline void shrink_free_pagepool(struct xen_blkif *blkif, int num)
151 blkif->free_pages_num--; 151 blkif->free_pages_num--;
152 if (++num_pages == NUM_BATCH_FREE_PAGES) { 152 if (++num_pages == NUM_BATCH_FREE_PAGES) {
153 spin_unlock_irqrestore(&blkif->free_pages_lock, flags); 153 spin_unlock_irqrestore(&blkif->free_pages_lock, flags);
154 free_xenballooned_pages(num_pages, page); 154 gnttab_free_pages(num_pages, page);
155 spin_lock_irqsave(&blkif->free_pages_lock, flags); 155 spin_lock_irqsave(&blkif->free_pages_lock, flags);
156 num_pages = 0; 156 num_pages = 0;
157 } 157 }
158 } 158 }
159 spin_unlock_irqrestore(&blkif->free_pages_lock, flags); 159 spin_unlock_irqrestore(&blkif->free_pages_lock, flags);
160 if (num_pages != 0) 160 if (num_pages != 0)
161 free_xenballooned_pages(num_pages, page); 161 gnttab_free_pages(num_pages, page);
162} 162}
163 163
164#define vaddr(page) ((unsigned long)pfn_to_kaddr(page_to_pfn(page))) 164#define vaddr(page) ((unsigned long)pfn_to_kaddr(page_to_pfn(page)))
diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
index 9259a732e8a4..2e07f8433412 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -483,9 +483,8 @@ int xenvif_init_queue(struct xenvif_queue *queue)
483 * better enable it. The long term solution would be to use just a 483 * better enable it. The long term solution would be to use just a
484 * bunch of valid page descriptors, without dependency on ballooning 484 * bunch of valid page descriptors, without dependency on ballooning
485 */ 485 */
486 err = alloc_xenballooned_pages(MAX_PENDING_REQS, 486 err = gnttab_alloc_pages(MAX_PENDING_REQS,
487 queue->mmap_pages, 487 queue->mmap_pages);
488 false);
489 if (err) { 488 if (err) {
490 netdev_err(queue->vif->dev, "Could not reserve mmap_pages\n"); 489 netdev_err(queue->vif->dev, "Could not reserve mmap_pages\n");
491 return -ENOMEM; 490 return -ENOMEM;
@@ -662,7 +661,7 @@ void xenvif_disconnect(struct xenvif *vif)
662 */ 661 */
663void xenvif_deinit_queue(struct xenvif_queue *queue) 662void xenvif_deinit_queue(struct xenvif_queue *queue)
664{ 663{
665 free_xenballooned_pages(MAX_PENDING_REQS, queue->mmap_pages); 664 gnttab_free_pages(MAX_PENDING_REQS, queue->mmap_pages);
666} 665}
667 666
668void xenvif_free(struct xenvif *vif) 667void xenvif_free(struct xenvif *vif)
diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
index 6444172f2842..8cc3f069a10f 100644
--- a/drivers/xen/gntdev.c
+++ b/drivers/xen/gntdev.c
@@ -119,7 +119,7 @@ static void gntdev_free_map(struct grant_map *map)
119 return; 119 return;
120 120
121 if (map->pages) 121 if (map->pages)
122 free_xenballooned_pages(map->count, map->pages); 122 gnttab_free_pages(map->count, map->pages);
123 kfree(map->pages); 123 kfree(map->pages);
124 kfree(map->grants); 124 kfree(map->grants);
125 kfree(map->map_ops); 125 kfree(map->map_ops);
@@ -152,7 +152,7 @@ static struct grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count)
152 NULL == add->pages) 152 NULL == add->pages)
153 goto err; 153 goto err;
154 154
155 if (alloc_xenballooned_pages(count, add->pages, false /* lowmem */)) 155 if (gnttab_alloc_pages(count, add->pages))
156 goto err; 156 goto err;
157 157
158 for (i = 0; i < count; i++) { 158 for (i = 0; i < count; i++) {
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 999d7abdbcec..b4f93c490f83 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -50,6 +50,7 @@
50#include <xen/interface/memory.h> 50#include <xen/interface/memory.h>
51#include <xen/hvc-console.h> 51#include <xen/hvc-console.h>
52#include <xen/swiotlb-xen.h> 52#include <xen/swiotlb-xen.h>
53#include <xen/balloon.h>
53#include <asm/xen/hypercall.h> 54#include <asm/xen/hypercall.h>
54#include <asm/xen/interface.h> 55#include <asm/xen/interface.h>
55 56
@@ -671,6 +672,34 @@ void gnttab_free_auto_xlat_frames(void)
671} 672}
672EXPORT_SYMBOL_GPL(gnttab_free_auto_xlat_frames); 673EXPORT_SYMBOL_GPL(gnttab_free_auto_xlat_frames);
673 674
675/**
676 * gnttab_alloc_pages - alloc pages suitable for grant mapping into
677 * @nr_pages: number of pages to alloc
678 * @pages: returns the pages
679 */
680int gnttab_alloc_pages(int nr_pages, struct page **pages)
681{
682 int ret;
683
684 ret = alloc_xenballooned_pages(nr_pages, pages, false);
685 if (ret < 0)
686 return ret;
687
688 return 0;
689}
690EXPORT_SYMBOL(gnttab_alloc_pages);
691
692/**
693 * gnttab_free_pages - free pages allocated by gnttab_alloc_pages()
694 * @nr_pages; number of pages to free
695 * @pages: the pages
696 */
697void gnttab_free_pages(int nr_pages, struct page **pages)
698{
699 free_xenballooned_pages(nr_pages, pages);
700}
701EXPORT_SYMBOL(gnttab_free_pages);
702
674/* Handling of paged out grant targets (GNTST_eagain) */ 703/* Handling of paged out grant targets (GNTST_eagain) */
675#define MAX_DELAY 256 704#define MAX_DELAY 256
676static inline void 705static inline void
diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c
index e999496eda3e..ecd540a7a562 100644
--- a/drivers/xen/xen-scsiback.c
+++ b/drivers/xen/xen-scsiback.c
@@ -227,7 +227,7 @@ static void put_free_pages(struct page **page, int num)
227 return; 227 return;
228 if (i > scsiback_max_buffer_pages) { 228 if (i > scsiback_max_buffer_pages) {
229 n = min(num, i - scsiback_max_buffer_pages); 229 n = min(num, i - scsiback_max_buffer_pages);
230 free_xenballooned_pages(n, page + num - n); 230 gnttab_free_pages(n, page + num - n);
231 n = num - n; 231 n = num - n;
232 } 232 }
233 spin_lock_irqsave(&free_pages_lock, flags); 233 spin_lock_irqsave(&free_pages_lock, flags);
@@ -244,7 +244,7 @@ static int get_free_page(struct page **page)
244 spin_lock_irqsave(&free_pages_lock, flags); 244 spin_lock_irqsave(&free_pages_lock, flags);
245 if (list_empty(&scsiback_free_pages)) { 245 if (list_empty(&scsiback_free_pages)) {
246 spin_unlock_irqrestore(&free_pages_lock, flags); 246 spin_unlock_irqrestore(&free_pages_lock, flags);
247 return alloc_xenballooned_pages(1, page, false); 247 return gnttab_alloc_pages(1, page);
248 } 248 }
249 page[0] = list_first_entry(&scsiback_free_pages, struct page, lru); 249 page[0] = list_first_entry(&scsiback_free_pages, struct page, lru);
250 list_del(&page[0]->lru); 250 list_del(&page[0]->lru);
@@ -2106,7 +2106,7 @@ static void __exit scsiback_exit(void)
2106 while (free_pages_num) { 2106 while (free_pages_num) {
2107 if (get_free_page(&page)) 2107 if (get_free_page(&page))
2108 BUG(); 2108 BUG();
2109 free_xenballooned_pages(1, &page); 2109 gnttab_free_pages(1, &page);
2110 } 2110 }
2111 scsiback_deregister_configfs(); 2111 scsiback_deregister_configfs();
2112 xenbus_unregister_driver(&scsiback_driver); 2112 xenbus_unregister_driver(&scsiback_driver);
diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h
index 7235d8f35459..949803e20872 100644
--- a/include/xen/grant_table.h
+++ b/include/xen/grant_table.h
@@ -163,6 +163,9 @@ void gnttab_free_auto_xlat_frames(void);
163 163
164#define gnttab_map_vaddr(map) ((void *)(map.host_virt_addr)) 164#define gnttab_map_vaddr(map) ((void *)(map.host_virt_addr))
165 165
166int gnttab_alloc_pages(int nr_pages, struct page **pages);
167void gnttab_free_pages(int nr_pages, struct page **pages);
168
166int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, 169int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
167 struct gnttab_map_grant_ref *kmap_ops, 170 struct gnttab_map_grant_ref *kmap_ops,
168 struct page **pages, unsigned int count); 171 struct page **pages, unsigned int count);