Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid
[linux-2.6-microblaze.git] / drivers / iommu / dma-iommu.c
index 60c7e9e..d19f3d6 100644 (file)
@@ -175,7 +175,7 @@ EXPORT_SYMBOL(iommu_put_dma_cookie);
 void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list)
 {
 
-       if (!is_of_node(dev->iommu_fwspec->iommu_fwnode))
+       if (!is_of_node(dev_iommu_fwspec_get(dev)->iommu_fwnode))
                iort_iommu_msi_get_resv_regions(dev, list);
 
 }
@@ -447,20 +447,17 @@ static void __iommu_dma_free_pages(struct page **pages, int count)
        kvfree(pages);
 }
 
-static struct page **__iommu_dma_alloc_pages(unsigned int count,
-               unsigned long order_mask, gfp_t gfp)
+static struct page **__iommu_dma_alloc_pages(struct device *dev,
+               unsigned int count, unsigned long order_mask, gfp_t gfp)
 {
        struct page **pages;
-       unsigned int i = 0, array_size = count * sizeof(*pages);
+       unsigned int i = 0, nid = dev_to_node(dev);
 
        order_mask &= (2U << MAX_ORDER) - 1;
        if (!order_mask)
                return NULL;
 
-       if (array_size <= PAGE_SIZE)
-               pages = kzalloc(array_size, GFP_KERNEL);
-       else
-               pages = vzalloc(array_size);
+       pages = kvzalloc(count * sizeof(*pages), GFP_KERNEL);
        if (!pages)
                return NULL;
 
@@ -479,10 +476,12 @@ static struct page **__iommu_dma_alloc_pages(unsigned int count,
                for (order_mask &= (2U << __fls(count)) - 1;
                     order_mask; order_mask &= ~order_size) {
                        unsigned int order = __fls(order_mask);
+                       gfp_t alloc_flags = gfp;
 
                        order_size = 1U << order;
-                       page = alloc_pages((order_mask - order_size) ?
-                                          gfp | __GFP_NORETRY : gfp, order);
+                       if (order_mask > order_size)
+                               alloc_flags |= __GFP_NORETRY;
+                       page = alloc_pages_node(nid, alloc_flags, order);
                        if (!page)
                                continue;
                        if (!order)
@@ -567,7 +566,8 @@ struct page **iommu_dma_alloc(struct device *dev, size_t size, gfp_t gfp,
                alloc_sizes = min_size;
 
        count = PAGE_ALIGN(size) >> PAGE_SHIFT;
-       pages = __iommu_dma_alloc_pages(count, alloc_sizes >> PAGE_SHIFT, gfp);
+       pages = __iommu_dma_alloc_pages(dev, count, alloc_sizes >> PAGE_SHIFT,
+                                       gfp);
        if (!pages)
                return NULL;