Merge "This patch includes updated scripts to use different docker containers for...
[kvmfornfv.git] / kernel / mm / cma.c
index 3a7a67b..bd0e141 100644 (file)
@@ -182,8 +182,9 @@ int __init cma_init_reserved_mem(phys_addr_t base, phys_addr_t size,
        if (!size || !memblock_is_region_reserved(base, size))
                return -EINVAL;
 
-       /* ensure minimal alignment requied by mm core */
-       alignment = PAGE_SIZE << max(MAX_ORDER - 1, pageblock_order);
+       /* ensure minimal alignment required by mm core */
+       alignment = PAGE_SIZE <<
+                       max_t(unsigned long, MAX_ORDER - 1, pageblock_order);
 
        /* alignment should be aligned with order_per_bit */
        if (!IS_ALIGNED(alignment >> PAGE_SHIFT, 1 << order_per_bit))
@@ -238,7 +239,7 @@ int __init cma_declare_contiguous(phys_addr_t base,
        /*
         * high_memory isn't direct mapped memory so retrieving its physical
         * address isn't appropriate.  But it would be useful to check the
-        * physical address of the highmem boundary so it's justfiable to get
+        * physical address of the highmem boundary so it's justifiable to get
         * the physical address from it.  On x86 there is a validation check for
         * this case, so the following workaround is needed to avoid it.
         */
@@ -266,8 +267,8 @@ int __init cma_declare_contiguous(phys_addr_t base,
         * migratetype page by page allocator's buddy algorithm. In the case,
         * you couldn't get a contiguous memory, which is not what we want.
         */
-       alignment = max(alignment,
-               (phys_addr_t)PAGE_SIZE << max(MAX_ORDER - 1, pageblock_order));
+       alignment = max(alignment,  (phys_addr_t)PAGE_SIZE <<
+                         max_t(unsigned long, MAX_ORDER - 1, pageblock_order));
        base = ALIGN(base, alignment);
        size = ALIGN(size, alignment);
        limit &= ~(alignment - 1);
@@ -316,13 +317,15 @@ int __init cma_declare_contiguous(phys_addr_t base,
                 */
                if (base < highmem_start && limit > highmem_start) {
                        addr = memblock_alloc_range(size, alignment,
-                                                   highmem_start, limit);
+                                                   highmem_start, limit,
+                                                   MEMBLOCK_NONE);
                        limit = highmem_start;
                }
 
                if (!addr) {
                        addr = memblock_alloc_range(size, alignment, base,
-                                                   limit);
+                                                   limit,
+                                                   MEMBLOCK_NONE);
                        if (!addr) {
                                ret = -ENOMEM;
                                goto err;
@@ -359,9 +362,11 @@ err:
  * This function allocates part of contiguous memory on specific
  * contiguous memory area.
  */
-struct page *cma_alloc(struct cma *cma, unsigned int count, unsigned int align)
+struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align)
 {
-       unsigned long mask, offset, pfn, start = 0;
+       unsigned long mask, offset;
+       unsigned long pfn = -1;
+       unsigned long start = 0;
        unsigned long bitmap_maxno, bitmap_no, bitmap_count;
        struct page *page = NULL;
        int ret;
@@ -369,7 +374,7 @@ struct page *cma_alloc(struct cma *cma, unsigned int count, unsigned int align)
        if (!cma || !cma->count)
                return NULL;
 
-       pr_debug("%s(cma %p, count %d, align %d)\n", __func__, (void *)cma,
+       pr_debug("%s(cma %p, count %zu, align %d)\n", __func__, (void *)cma,
                 count, align);
 
        if (!count)
@@ -416,7 +421,7 @@ struct page *cma_alloc(struct cma *cma, unsigned int count, unsigned int align)
                start = bitmap_no + mask + 1;
        }
 
-       trace_cma_alloc(page ? pfn : -1UL, page, count, align);
+       trace_cma_alloc(pfn, page, count, align);
 
        pr_debug("%s(): returned %p\n", __func__, page);
        return page;