mm: remove include/linux/bootmem.h
[linux-2.6-block.git] / arch / powerpc / mm / hugetlbpage.c
index 8a9a49c138652ba2b971a265db233988e01aa7b1..8cf035e68378b70b99a49261bc02ef28cda026fd 100644 (file)
 #include <linux/export.h>
 #include <linux/of_fdt.h>
 #include <linux/memblock.h>
-#include <linux/bootmem.h>
 #include <linux/moduleparam.h>
 #include <linux/swap.h>
 #include <linux/swapops.h>
+#include <linux/kmemleak.h>
 #include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/tlb.h>
@@ -95,7 +95,7 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,
                        break;
                else {
 #ifdef CONFIG_PPC_BOOK3S_64
-                       *hpdp = __hugepd(__pa(new) |
+                       *hpdp = __hugepd(__pa(new) | HUGEPD_VAL_BITS |
                                         (shift_to_mmu_psize(pshift) << 2));
 #elif defined(CONFIG_PPC_8xx)
                        *hpdp = __hugepd(__pa(new) | _PMD_USER |
@@ -112,20 +112,13 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,
                for (i = i - 1 ; i >= 0; i--, hpdp--)
                        *hpdp = __hugepd(0);
                kmem_cache_free(cachep, new);
+       } else {
+               kmemleak_ignore(new);
        }
        spin_unlock(ptl);
        return 0;
 }
 
-/*
- * These macros define how to determine which level of the page table holds
- * the hpdp.
- */
-#if defined(CONFIG_PPC_FSL_BOOK3E) || defined(CONFIG_PPC_8xx)
-#define HUGEPD_PGD_SHIFT PGDIR_SHIFT
-#define HUGEPD_PUD_SHIFT PUD_SHIFT
-#endif
-
 /*
  * At this point we do the placement change only for BOOK3S 64. This would
  * possibly work on other subarchs.
@@ -174,13 +167,13 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr, unsigned long sz
                }
        }
 #else
-       if (pshift >= HUGEPD_PGD_SHIFT) {
+       if (pshift >= PGDIR_SHIFT) {
                ptl = &mm->page_table_lock;
                hpdp = (hugepd_t *)pg;
        } else {
                pdshift = PUD_SHIFT;
                pu = pud_alloc(mm, pg, addr);
-               if (pshift >= HUGEPD_PUD_SHIFT) {
+               if (pshift >= PUD_SHIFT) {
                        ptl = pud_lockptr(mm, pu);
                        hpdp = (hugepd_t *)pu;
                } else {
@@ -621,15 +614,12 @@ static int __init add_huge_page_size(unsigned long long size)
         * firmware we only add hugetlb support for page sizes that can be
         * supported by linux page table layout.
         * For now we have
-        * Radix: 2M
+        * Radix: 2M and 1G
         * Hash: 16M and 16G
         */
        if (radix_enabled()) {
-               if (mmu_psize != MMU_PAGE_2M) {
-                       if (cpu_has_feature(CPU_FTR_POWER9_DD1) ||
-                           (mmu_psize != MMU_PAGE_1G))
-                               return -EINVAL;
-               }
+               if (mmu_psize != MMU_PAGE_2M && mmu_psize != MMU_PAGE_1G)
+                       return -EINVAL;
        } else {
                if (mmu_psize != MMU_PAGE_16M && mmu_psize != MMU_PAGE_16G)
                        return -EINVAL;
@@ -695,9 +685,9 @@ static int __init hugetlbpage_init(void)
                else
                        pdshift = PMD_SHIFT;
 #else
-               if (shift < HUGEPD_PUD_SHIFT)
+               if (shift < PUD_SHIFT)
                        pdshift = PMD_SHIFT;
-               else if (shift < HUGEPD_PGD_SHIFT)
+               else if (shift < PGDIR_SHIFT)
                        pdshift = PUD_SHIFT;
                else
                        pdshift = PGDIR_SHIFT;
@@ -849,8 +839,12 @@ pte_t *__find_linux_pte(pgd_t *pgdir, unsigned long ea,
                                ret_pte = (pte_t *) pmdp;
                                goto out;
                        }
-
-                       if (pmd_huge(pmd)) {
+                       /*
+                        * pmd_large check below will handle the swap pmd pte
+                        * we need to do both the check because they are config
+                        * dependent.
+                        */
+                       if (pmd_huge(pmd) || pmd_large(pmd)) {
                                ret_pte = (pte_t *) pmdp;
                                goto out;
                        } else if (is_hugepd(__hugepd(pmd_val(pmd))))