diff options
author | Guo Ren <ren_guo@c-sky.com> | 2019-04-19 17:10:52 +0800 |
---|---|---|
committer | Guo Ren <ren_guo@c-sky.com> | 2019-04-22 13:44:57 +0800 |
commit | 683fafebf93bcde9948246849348b888e185cb22 (patch) | |
tree | dc612f1998fe65de5c7357f6d4d3d0c202b5fd89 | |
parent | 205353fa06cc5dbfe1949de013ba905bb151c702 (diff) | |
download | linux-683fafebf93bcde9948246849348b888e185cb22.tar.gz linux-683fafebf93bcde9948246849348b888e185cb22.tar.bz2 linux-683fafebf93bcde9948246849348b888e185cb22.zip |
csky: Use va_pa_offset instead of phys_offset
The name of phys_offset is so common for global export and it may
conflict with some local name. So change phys_offset to va_pa_offset
which also used by riscv.
Also use __pa() and __va() instead of using phys_offset directly.
Signed-off-by: Guo Ren <ren_guo@c-sky.com>
Cc: Arnd Bergmann <arnd@arndb.de>
-rw-r--r-- | arch/csky/abiv1/inc/abi/ckmmu.h | 4 | ||||
-rw-r--r-- | arch/csky/abiv2/inc/abi/ckmmu.h | 14 | ||||
-rw-r--r-- | arch/csky/include/asm/mmu_context.h | 17 | ||||
-rw-r--r-- | arch/csky/include/asm/page.h | 10 | ||||
-rw-r--r-- | arch/csky/kernel/entry.S | 4 | ||||
-rw-r--r-- | arch/csky/kernel/setup.c | 6 | ||||
-rw-r--r-- | arch/csky/mm/fault.c | 2 |
7 files changed, 21 insertions, 36 deletions
diff --git a/arch/csky/abiv1/inc/abi/ckmmu.h b/arch/csky/abiv1/inc/abi/ckmmu.h index 85339bd224c4..81f37715c0d2 100644 --- a/arch/csky/abiv1/inc/abi/ckmmu.h +++ b/arch/csky/abiv1/inc/abi/ckmmu.h @@ -85,11 +85,11 @@ static inline void tlb_invalid_indexed(void) static inline void setup_pgd(unsigned long pgd, bool kernel) { - cpwcr("cpcr29", pgd); + cpwcr("cpcr29", pgd | BIT(0)); } static inline unsigned long get_pgd(void) { - return cprcr("cpcr29"); + return cprcr("cpcr29") & ~BIT(0); } #endif /* __ASM_CSKY_CKMMUV1_H */ diff --git a/arch/csky/abiv2/inc/abi/ckmmu.h b/arch/csky/abiv2/inc/abi/ckmmu.h index 31d75e1a724a..e4480e6bc3b3 100644 --- a/arch/csky/abiv2/inc/abi/ckmmu.h +++ b/arch/csky/abiv2/inc/abi/ckmmu.h @@ -90,18 +90,16 @@ static inline void tlb_invalid_indexed(void) mtcr("cr<8, 15>", 0x02000000); } -/* setup hardrefil pgd */ -static inline unsigned long get_pgd(void) -{ - return mfcr("cr<29, 15>"); -} - static inline void setup_pgd(unsigned long pgd, bool kernel) { if (kernel) - mtcr("cr<28, 15>", pgd); + mtcr("cr<28, 15>", pgd | BIT(0)); else - mtcr("cr<29, 15>", pgd); + mtcr("cr<29, 15>", pgd | BIT(0)); } +static inline unsigned long get_pgd(void) +{ + return mfcr("cr<29, 15>") & ~BIT(0); +} #endif /* __ASM_CSKY_CKMMUV2_H */ diff --git a/arch/csky/include/asm/mmu_context.h b/arch/csky/include/asm/mmu_context.h index c41f86b22460..734db3a122e1 100644 --- a/arch/csky/include/asm/mmu_context.h +++ b/arch/csky/include/asm/mmu_context.h @@ -14,23 +14,10 @@ #include <linux/sched.h> #include <abi/ckmmu.h> -static inline void tlbmiss_handler_setup_pgd(unsigned long pgd, bool kernel) -{ - pgd -= PAGE_OFFSET; - pgd += phys_offset; - pgd |= 1; - setup_pgd(pgd, kernel); -} - #define TLBMISS_HANDLER_SETUP_PGD(pgd) \ - tlbmiss_handler_setup_pgd((unsigned long)pgd, 0) + setup_pgd(__pa(pgd), false) #define TLBMISS_HANDLER_SETUP_PGD_KERNEL(pgd) \ - tlbmiss_handler_setup_pgd((unsigned long)pgd, 1) - -static inline unsigned long tlb_get_pgd(void) -{ - return ((get_pgd() - phys_offset) & ~1) + PAGE_OFFSET; -} + setup_pgd(__pa(pgd), true) #define cpu_context(cpu, mm) ((mm)->context.asid[cpu]) #define cpu_asid(cpu, mm) (cpu_context((cpu), (mm)) & ASID_MASK) diff --git a/arch/csky/include/asm/page.h b/arch/csky/include/asm/page.h index 4ce3d5c28ffc..9738eacefdc7 100644 --- a/arch/csky/include/asm/page.h +++ b/arch/csky/include/asm/page.h @@ -72,13 +72,13 @@ typedef struct page *pgtable_t; #define __pgd(x) ((pgd_t) { (x) }) #define __pgprot(x) ((pgprot_t) { (x) }) -extern unsigned long phys_offset; +extern unsigned long va_pa_offset; -#define ARCH_PFN_OFFSET PFN_DOWN(phys_offset + PHYS_OFFSET_OFFSET) +#define ARCH_PFN_OFFSET PFN_DOWN(va_pa_offset + PHYS_OFFSET_OFFSET) + +#define __pa(x) ((unsigned long)(x) - PAGE_OFFSET + va_pa_offset) +#define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET - va_pa_offset)) -#define __pa(x) ((unsigned long)(x) - PAGE_OFFSET + phys_offset) -#define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET - \ - phys_offset)) #define __pa_symbol(x) __pa(RELOC_HIDE((unsigned long)(x), 0)) #define MAP_NR(x) PFN_DOWN((unsigned long)(x) - PAGE_OFFSET - \ diff --git a/arch/csky/kernel/entry.S b/arch/csky/kernel/entry.S index e5bbd8c184f3..a7e84ccccbd8 100644 --- a/arch/csky/kernel/entry.S +++ b/arch/csky/kernel/entry.S @@ -40,7 +40,7 @@ ENTRY(csky_\name) WR_MCIR a2 #endif bclri r6, 0 - lrw a2, phys_offset + lrw a2, va_pa_offset ld.w a2, (a2, 0) subu r6, a2 bseti r6, 31 @@ -51,7 +51,7 @@ ENTRY(csky_\name) addu r6, a2 ldw r6, (r6) - lrw a2, phys_offset + lrw a2, va_pa_offset ld.w a2, (a2, 0) subu r6, a2 bseti r6, 31 diff --git a/arch/csky/kernel/setup.c b/arch/csky/kernel/setup.c index 36fc04b9417d..23ee604aafdb 100644 --- a/arch/csky/kernel/setup.c +++ b/arch/csky/kernel/setup.c @@ -142,8 +142,8 @@ void __init setup_arch(char **cmdline_p) #endif } -unsigned long phys_offset; -EXPORT_SYMBOL(phys_offset); +unsigned long va_pa_offset; +EXPORT_SYMBOL(va_pa_offset); asmlinkage __visible void __init csky_start(unsigned int unused, void *dtb_start) @@ -151,7 +151,7 @@ asmlinkage __visible void __init csky_start(unsigned int unused, /* Clean up bss section */ memset(__bss_start, 0, __bss_stop - __bss_start); - phys_offset = read_mmu_msa0() & ~(SSEG_SIZE - 1); + va_pa_offset = read_mmu_msa0() & ~(SSEG_SIZE - 1); pre_trap_init(); pre_mmu_init(); diff --git a/arch/csky/mm/fault.c b/arch/csky/mm/fault.c index e1725f8a06f9..5beb25ca1c79 100644 --- a/arch/csky/mm/fault.c +++ b/arch/csky/mm/fault.c @@ -81,7 +81,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write, unsigned long pgd_base; - pgd_base = tlb_get_pgd(); + pgd_base = __va(get_pgd()); pgd = (pgd_t *)pgd_base + offset; pgd_k = init_mm.pgd + offset; |