mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-03-19 05:24:11 +00:00
powerpc/8xx: Refactor calculation of number of entries per PTE in page tables
On 8xx, the number of entries occupied by a PTE in the page tables depends on the size of the page. At the time being, this calculation is done in two places: in pte_update() and in set_huge_pte_at() Refactor this calculation into a helper called number_of_cells_per_pte(). For the time being, the val param is unused. It will be used by following patch. Instead of opencoding is_hugepd(), use hugepd_ok() with a forward declaration. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/f6ea2483c2c389567b007945948f704d18cfaeea.1598862623.git.christophe.leroy@csgroup.eu
This commit is contained in:
parent
542db12a9c
commit
175a999915
2 changed files with 16 additions and 8 deletions
|
@ -227,6 +227,17 @@ static inline void pmd_clear(pmd_t *pmdp)
|
||||||
*/
|
*/
|
||||||
#ifdef CONFIG_PPC_8xx
|
#ifdef CONFIG_PPC_8xx
|
||||||
static pmd_t *pmd_off(struct mm_struct *mm, unsigned long addr);
|
static pmd_t *pmd_off(struct mm_struct *mm, unsigned long addr);
|
||||||
|
static int hugepd_ok(hugepd_t hpd);
|
||||||
|
|
||||||
|
static int number_of_cells_per_pte(pmd_t *pmd, pte_basic_t val, int huge)
|
||||||
|
{
|
||||||
|
if (!huge)
|
||||||
|
return PAGE_SIZE / SZ_4K;
|
||||||
|
else if (hugepd_ok(*((hugepd_t *)pmd)))
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return SZ_512K / SZ_4K;
|
||||||
|
}
|
||||||
|
|
||||||
static inline pte_basic_t pte_update(struct mm_struct *mm, unsigned long addr, pte_t *p,
|
static inline pte_basic_t pte_update(struct mm_struct *mm, unsigned long addr, pte_t *p,
|
||||||
unsigned long clr, unsigned long set, int huge)
|
unsigned long clr, unsigned long set, int huge)
|
||||||
|
@ -237,12 +248,7 @@ static inline pte_basic_t pte_update(struct mm_struct *mm, unsigned long addr, p
|
||||||
int num, i;
|
int num, i;
|
||||||
pmd_t *pmd = pmd_off(mm, addr);
|
pmd_t *pmd = pmd_off(mm, addr);
|
||||||
|
|
||||||
if (!huge)
|
num = number_of_cells_per_pte(pmd, new, huge);
|
||||||
num = PAGE_SIZE / SZ_4K;
|
|
||||||
else if ((pmd_val(*pmd) & _PMD_PAGE_MASK) != _PMD_PAGE_8M)
|
|
||||||
num = SZ_512K / SZ_4K;
|
|
||||||
else
|
|
||||||
num = 1;
|
|
||||||
|
|
||||||
for (i = 0; i < num; i++, entry++, new += SZ_4K)
|
for (i = 0; i < num; i++, entry++, new += SZ_4K)
|
||||||
*entry = new;
|
*entry = new;
|
||||||
|
|
|
@ -266,8 +266,7 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_
|
||||||
pmd_t *pmd = pmd_off(mm, addr);
|
pmd_t *pmd = pmd_off(mm, addr);
|
||||||
pte_basic_t val;
|
pte_basic_t val;
|
||||||
pte_basic_t *entry = &ptep->pte;
|
pte_basic_t *entry = &ptep->pte;
|
||||||
int num = is_hugepd(*((hugepd_t *)pmd)) ? 1 : SZ_512K / SZ_4K;
|
int num, i;
|
||||||
int i;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure hardware valid bit is not set. We don't do
|
* Make sure hardware valid bit is not set. We don't do
|
||||||
|
@ -280,6 +279,9 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_
|
||||||
pte = set_pte_filter(pte);
|
pte = set_pte_filter(pte);
|
||||||
|
|
||||||
val = pte_val(pte);
|
val = pte_val(pte);
|
||||||
|
|
||||||
|
num = number_of_cells_per_pte(pmd, val, 1);
|
||||||
|
|
||||||
for (i = 0; i < num; i++, entry++, val += SZ_4K)
|
for (i = 0; i < num; i++, entry++, val += SZ_4K)
|
||||||
*entry = val;
|
*entry = val;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue