Commit 2db99aeb authored by Christophe Leroy's avatar Christophe Leroy Committed by Michael Ellerman

powerpc/mm: Refactor pte_update() on nohash/32

When CONFIG_PTE_64BIT is set, pte_update() operates on
'unsigned long long'
When CONFIG_PTE_64BIT is not set, pte_update() operates on
'unsigned long'

In asm/page.h, we have pte_basic_t which is 'unsigned long long'
when CONFIG_PTE_64BIT is set and 'unsigned long' otherwise.

Refactor pte_update() using pte_basic_t.
Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/590d67994a2847cd9fe088f7d974499e3a18b6ac.1589866984.git.christophe.leroy@csgroup.eu
parent fadaac67
...@@ -222,12 +222,9 @@ static inline void pmd_clear(pmd_t *pmdp) ...@@ -222,12 +222,9 @@ static inline void pmd_clear(pmd_t *pmdp)
* to properly flush the virtually tagged instruction cache of * to properly flush the virtually tagged instruction cache of
* those implementations. * those implementations.
*/ */
#ifndef CONFIG_PTE_64BIT static inline pte_basic_t pte_update(pte_t *p, unsigned long clr, unsigned long set)
static inline unsigned long pte_update(pte_t *p,
unsigned long clr,
unsigned long set)
{ {
#ifdef PTE_ATOMIC_UPDATES #if defined(PTE_ATOMIC_UPDATES) && !defined(CONFIG_PTE_64BIT)
unsigned long old, tmp; unsigned long old, tmp;
__asm__ __volatile__("\ __asm__ __volatile__("\
...@@ -241,8 +238,8 @@ static inline unsigned long pte_update(pte_t *p, ...@@ -241,8 +238,8 @@ static inline unsigned long pte_update(pte_t *p,
: "r" (p), "r" (clr), "r" (set), "m" (*p) : "r" (p), "r" (clr), "r" (set), "m" (*p)
: "cc" ); : "cc" );
#else /* PTE_ATOMIC_UPDATES */ #else /* PTE_ATOMIC_UPDATES */
unsigned long old = pte_val(*p); pte_basic_t old = pte_val(*p);
unsigned long new = (old & ~clr) | set; pte_basic_t new = (old & ~(pte_basic_t)clr) | set;
#if defined(CONFIG_PPC_8xx) && defined(CONFIG_PPC_16K_PAGES) #if defined(CONFIG_PPC_8xx) && defined(CONFIG_PPC_16K_PAGES)
p->pte = p->pte1 = p->pte2 = p->pte3 = new; p->pte = p->pte1 = p->pte2 = p->pte3 = new;
...@@ -257,21 +254,6 @@ static inline unsigned long pte_update(pte_t *p, ...@@ -257,21 +254,6 @@ static inline unsigned long pte_update(pte_t *p,
#endif #endif
return old; return old;
} }
#else /* CONFIG_PTE_64BIT */
static inline unsigned long long pte_update(pte_t *p,
unsigned long clr,
unsigned long set)
{
unsigned long long old = pte_val(*p);
*p = __pte((old & ~(unsigned long long)clr) | set);
#ifdef CONFIG_44x
if ((old & _PAGE_USER) && (old & _PAGE_EXEC))
icache_44x_need_flush = 1;
#endif
return old;
}
#endif /* CONFIG_PTE_64BIT */
#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
static inline int __ptep_test_and_clear_young(unsigned int context, unsigned long addr, pte_t *ptep) static inline int __ptep_test_and_clear_young(unsigned int context, unsigned long addr, pte_t *ptep)
......
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