Commit 881fde1d authored by Becky Bruce's avatar Becky Bruce Committed by Benjamin Herrenschmidt

powerpc: hugetlb: modify include usage for FSL BookE code

The original 32-bit hugetlb implementation used PPC64 vs PPC32 to
determine which code path to take.  However, the final hugetlb
implementation for 64-bit FSL ended up shared with the FSL
32-bit code so the actual check needs to be FSL_BOOK3E vs
everything else.  This patch changes the include protections to
reflect this.

There are also a couple of related comment fixes.
Signed-off-by: default avatarBecky Bruce <beckyb@kernel.crashing.org>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent a1cd5419
...@@ -22,14 +22,14 @@ static inline pte_t *hugepte_offset(hugepd_t *hpdp, unsigned long addr, ...@@ -22,14 +22,14 @@ static inline pte_t *hugepte_offset(hugepd_t *hpdp, unsigned long addr,
unsigned pdshift) unsigned pdshift)
{ {
/* /*
* On 32-bit, we have multiple higher-level table entries that point to * On FSL BookE, we have multiple higher-level table entries that
* the same hugepte. Just use the first one since they're all * point to the same hugepte. Just use the first one since they're all
* identical. So for that case, idx=0. * identical. So for that case, idx=0.
*/ */
unsigned long idx = 0; unsigned long idx = 0;
pte_t *dir = hugepd_page(*hpdp); pte_t *dir = hugepd_page(*hpdp);
#ifdef CONFIG_PPC64 #ifndef CONFIG_PPC_FSL_BOOK3E
idx = (addr & ((1UL << pdshift) - 1)) >> hugepd_shift(*hpdp); idx = (addr & ((1UL << pdshift) - 1)) >> hugepd_shift(*hpdp);
#endif #endif
......
...@@ -33,17 +33,17 @@ unsigned int HPAGE_SHIFT; ...@@ -33,17 +33,17 @@ unsigned int HPAGE_SHIFT;
* implementations may have more than one gpage size due to limitations * implementations may have more than one gpage size due to limitations
* of the memory allocators, so we need multiple arrays * of the memory allocators, so we need multiple arrays
*/ */
#ifdef CONFIG_PPC64 #ifdef CONFIG_PPC_FSL_BOOK3E
#define MAX_NUMBER_GPAGES 1024
static u64 gpage_freearray[MAX_NUMBER_GPAGES];
static unsigned nr_gpages;
#else
#define MAX_NUMBER_GPAGES 128 #define MAX_NUMBER_GPAGES 128
struct psize_gpages { struct psize_gpages {
u64 gpage_list[MAX_NUMBER_GPAGES]; u64 gpage_list[MAX_NUMBER_GPAGES];
unsigned int nr_gpages; unsigned int nr_gpages;
}; };
static struct psize_gpages gpage_freearray[MMU_PAGE_COUNT]; static struct psize_gpages gpage_freearray[MMU_PAGE_COUNT];
#else
#define MAX_NUMBER_GPAGES 1024
static u64 gpage_freearray[MAX_NUMBER_GPAGES];
static unsigned nr_gpages;
#endif #endif
static inline int shift_to_mmu_psize(unsigned int shift) static inline int shift_to_mmu_psize(unsigned int shift)
...@@ -114,12 +114,12 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp, ...@@ -114,12 +114,12 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,
struct kmem_cache *cachep; struct kmem_cache *cachep;
pte_t *new; pte_t *new;
#ifdef CONFIG_PPC64 #ifdef CONFIG_PPC_FSL_BOOK3E
cachep = PGT_CACHE(pdshift - pshift);
#else
int i; int i;
int num_hugepd = 1 << (pshift - pdshift); int num_hugepd = 1 << (pshift - pdshift);
cachep = hugepte_cache; cachep = hugepte_cache;
#else
cachep = PGT_CACHE(pdshift - pshift);
#endif #endif
new = kmem_cache_zalloc(cachep, GFP_KERNEL|__GFP_REPEAT); new = kmem_cache_zalloc(cachep, GFP_KERNEL|__GFP_REPEAT);
...@@ -131,12 +131,7 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp, ...@@ -131,12 +131,7 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,
return -ENOMEM; return -ENOMEM;
spin_lock(&mm->page_table_lock); spin_lock(&mm->page_table_lock);
#ifdef CONFIG_PPC64 #ifdef CONFIG_PPC_FSL_BOOK3E
if (!hugepd_none(*hpdp))
kmem_cache_free(cachep, new);
else
hpdp->pd = ((unsigned long)new & ~PD_HUGE) | pshift;
#else
/* /*
* We have multiple higher-level entries that point to the same * We have multiple higher-level entries that point to the same
* actual pte location. Fill in each as we go and backtrack on error. * actual pte location. Fill in each as we go and backtrack on error.
...@@ -215,7 +210,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr, unsigned long sz ...@@ -215,7 +210,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr, unsigned long sz
return hugepte_offset(hpdp, addr, pdshift); return hugepte_offset(hpdp, addr, pdshift);
} }
#ifdef CONFIG_PPC32 #ifdef CONFIG_PPC_FSL_BOOK3E
/* Build list of addresses of gigantic pages. This function is used in early /* Build list of addresses of gigantic pages. This function is used in early
* boot before the buddy or bootmem allocator is setup. * boot before the buddy or bootmem allocator is setup.
*/ */
...@@ -335,7 +330,7 @@ void __init reserve_hugetlb_gpages(void) ...@@ -335,7 +330,7 @@ void __init reserve_hugetlb_gpages(void)
} }
} }
#else /* PPC64 */ #else /* !PPC_FSL_BOOK3E */
/* Build list of addresses of gigantic pages. This function is used in early /* Build list of addresses of gigantic pages. This function is used in early
* boot before the buddy or bootmem allocator is setup. * boot before the buddy or bootmem allocator is setup.
...@@ -373,7 +368,7 @@ int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep) ...@@ -373,7 +368,7 @@ int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
return 0; return 0;
} }
#ifdef CONFIG_PPC32 #ifdef CONFIG_PPC_FSL_BOOK3E
#define HUGEPD_FREELIST_SIZE \ #define HUGEPD_FREELIST_SIZE \
((PAGE_SIZE - sizeof(struct hugepd_freelist)) / sizeof(pte_t)) ((PAGE_SIZE - sizeof(struct hugepd_freelist)) / sizeof(pte_t))
...@@ -433,11 +428,11 @@ static void free_hugepd_range(struct mmu_gather *tlb, hugepd_t *hpdp, int pdshif ...@@ -433,11 +428,11 @@ static void free_hugepd_range(struct mmu_gather *tlb, hugepd_t *hpdp, int pdshif
unsigned long pdmask = ~((1UL << pdshift) - 1); unsigned long pdmask = ~((1UL << pdshift) - 1);
unsigned int num_hugepd = 1; unsigned int num_hugepd = 1;
#ifdef CONFIG_PPC64 #ifdef CONFIG_PPC_FSL_BOOK3E
unsigned int shift = hugepd_shift(*hpdp); /* Note: On fsl the hpdp may be the first of several */
#else
/* Note: On 32-bit the hpdp may be the first of several */
num_hugepd = (1 << (hugepd_shift(*hpdp) - pdshift)); num_hugepd = (1 << (hugepd_shift(*hpdp) - pdshift));
#else
unsigned int shift = hugepd_shift(*hpdp);
#endif #endif
start &= pdmask; start &= pdmask;
...@@ -455,10 +450,11 @@ static void free_hugepd_range(struct mmu_gather *tlb, hugepd_t *hpdp, int pdshif ...@@ -455,10 +450,11 @@ static void free_hugepd_range(struct mmu_gather *tlb, hugepd_t *hpdp, int pdshif
hpdp->pd = 0; hpdp->pd = 0;
tlb->need_flush = 1; tlb->need_flush = 1;
#ifdef CONFIG_PPC64
pgtable_free_tlb(tlb, hugepte, pdshift - shift); #ifdef CONFIG_PPC_FSL_BOOK3E
#else
hugepd_free(tlb, hugepte); hugepd_free(tlb, hugepte);
#else
pgtable_free_tlb(tlb, hugepte, pdshift - shift);
#endif #endif
} }
...@@ -590,12 +586,12 @@ void hugetlb_free_pgd_range(struct mmu_gather *tlb, ...@@ -590,12 +586,12 @@ void hugetlb_free_pgd_range(struct mmu_gather *tlb,
continue; continue;
hugetlb_free_pud_range(tlb, pgd, addr, next, floor, ceiling); hugetlb_free_pud_range(tlb, pgd, addr, next, floor, ceiling);
} else { } else {
#ifdef CONFIG_PPC32 #ifdef CONFIG_PPC_FSL_BOOK3E
/* /*
* Increment next by the size of the huge mapping since * Increment next by the size of the huge mapping since
* on 32-bit there may be more than one entry at the pgd * there may be more than one entry at the pgd level
* level for a single hugepage, but all of them point to * for a single hugepage, but all of them point to the
* the same kmem cache that holds the hugepte. * same kmem cache that holds the hugepte.
*/ */
next = addr + (1 << hugepd_shift(*(hugepd_t *)pgd)); next = addr + (1 << hugepd_shift(*(hugepd_t *)pgd));
#endif #endif
...@@ -817,7 +813,7 @@ static int __init hugepage_setup_sz(char *str) ...@@ -817,7 +813,7 @@ static int __init hugepage_setup_sz(char *str)
} }
__setup("hugepagesz=", hugepage_setup_sz); __setup("hugepagesz=", hugepage_setup_sz);
#ifdef CONFIG_FSL_BOOKE #ifdef CONFIG_PPC_FSL_BOOK3E
struct kmem_cache *hugepte_cache; struct kmem_cache *hugepte_cache;
static int __init hugetlbpage_init(void) static int __init hugetlbpage_init(void)
{ {
......
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
* indirect page table entries. * indirect page table entries.
*/ */
#ifdef CONFIG_PPC_BOOK3E_MMU #ifdef CONFIG_PPC_BOOK3E_MMU
#ifdef CONFIG_FSL_BOOKE #ifdef CONFIG_PPC_FSL_BOOK3E
struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT] = { struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT] = {
[MMU_PAGE_4K] = { [MMU_PAGE_4K] = {
.shift = 12, .shift = 12,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment