[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [RFC PATCH 2/2] xen/grant-table: Use unpopulated DMAable pages instead of real RAM ones
From: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx> Depends on CONFIG_XEN_UNPOPULATED_ALLOC. If enabled then unpopulated DMAable (contiguous) pages will be allocated for grant mapping into instead of ballooning out real RAM pages. TODO: Fallback to real RAM pages if xen_alloc_unpopulated_dma_pages() fails. Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx> --- drivers/xen/grant-table.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c index 8ccccac..2bb4392 100644 --- a/drivers/xen/grant-table.c +++ b/drivers/xen/grant-table.c @@ -864,6 +864,25 @@ EXPORT_SYMBOL_GPL(gnttab_free_pages); */ int gnttab_dma_alloc_pages(struct gnttab_dma_alloc_args *args) { +#ifdef CONFIG_XEN_UNPOPULATED_ALLOC + int ret; + + ret = xen_alloc_unpopulated_dma_pages(args->dev, args->nr_pages, + args->pages); + if (ret < 0) + return ret; + + ret = gnttab_pages_set_private(args->nr_pages, args->pages); + if (ret < 0) { + gnttab_dma_free_pages(args); + return ret; + } + + args->vaddr = page_to_virt(args->pages[0]); + args->dev_bus_addr = page_to_phys(args->pages[0]); + + return ret; +#else unsigned long pfn, start_pfn; size_t size; int i, ret; @@ -910,6 +929,7 @@ int gnttab_dma_alloc_pages(struct gnttab_dma_alloc_args *args) fail: gnttab_dma_free_pages(args); return ret; +#endif } EXPORT_SYMBOL_GPL(gnttab_dma_alloc_pages); @@ -919,6 +939,12 @@ EXPORT_SYMBOL_GPL(gnttab_dma_alloc_pages); */ int gnttab_dma_free_pages(struct gnttab_dma_alloc_args *args) { +#ifdef CONFIG_XEN_UNPOPULATED_ALLOC + gnttab_pages_clear_private(args->nr_pages, args->pages); + xen_free_unpopulated_dma_pages(args->dev, args->nr_pages, args->pages); + + return 0; +#else size_t size; int i, ret; @@ -946,6 +972,7 @@ int gnttab_dma_free_pages(struct gnttab_dma_alloc_args *args) dma_free_wc(args->dev, size, args->vaddr, args->dev_bus_addr); return ret; +#endif } EXPORT_SYMBOL_GPL(gnttab_dma_free_pages); #endif -- 2.7.4
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |