Skip to content

Commit 683fafe

Browse files
committed
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>
1 parent 205353f commit 683fafe

7 files changed

Lines changed: 21 additions & 36 deletions

File tree

‎arch/csky/abiv1/inc/abi/ckmmu.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ static inline void tlb_invalid_indexed(void)
8585

8686
static inline void setup_pgd(unsigned long pgd, bool kernel)
8787
{
88-
cpwcr("cpcr29", pgd);
88+
cpwcr("cpcr29", pgd | BIT(0));
8989
}
9090

9191
static inline unsigned long get_pgd(void)
9292
{
93-
return cprcr("cpcr29");
93+
return cprcr("cpcr29") & ~BIT(0);
9494
}
9595
#endif /* __ASM_CSKY_CKMMUV1_H */

‎arch/csky/abiv2/inc/abi/ckmmu.h‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,16 @@ static inline void tlb_invalid_indexed(void)
9090
mtcr("cr<8, 15>", 0x02000000);
9191
}
9292

93-
/* setup hardrefil pgd */
94-
static inline unsigned long get_pgd(void)
95-
{
96-
return mfcr("cr<29, 15>");
97-
}
98-
9993
static inline void setup_pgd(unsigned long pgd, bool kernel)
10094
{
10195
if (kernel)
102-
mtcr("cr<28, 15>", pgd);
96+
mtcr("cr<28, 15>", pgd | BIT(0));
10397
else
104-
mtcr("cr<29, 15>", pgd);
98+
mtcr("cr<29, 15>", pgd | BIT(0));
10599
}
106100

101+
static inline unsigned long get_pgd(void)
102+
{
103+
return mfcr("cr<29, 15>") & ~BIT(0);
104+
}
107105
#endif /* __ASM_CSKY_CKMMUV2_H */

‎arch/csky/include/asm/mmu_context.h‎

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,10 @@
1414
#include <linux/sched.h>
1515
#include <abi/ckmmu.h>
1616

17-
static inline void tlbmiss_handler_setup_pgd(unsigned long pgd, bool kernel)
18-
{
19-
pgd -= PAGE_OFFSET;
20-
pgd += phys_offset;
21-
pgd |= 1;
22-
setup_pgd(pgd, kernel);
23-
}
24-
2517
#define TLBMISS_HANDLER_SETUP_PGD(pgd) \
26-
tlbmiss_handler_setup_pgd((unsigned long)pgd, 0)
18+
setup_pgd(__pa(pgd), false)
2719
#define TLBMISS_HANDLER_SETUP_PGD_KERNEL(pgd) \
28-
tlbmiss_handler_setup_pgd((unsigned long)pgd, 1)
29-
30-
static inline unsigned long tlb_get_pgd(void)
31-
{
32-
return ((get_pgd() - phys_offset) & ~1) + PAGE_OFFSET;
33-
}
20+
setup_pgd(__pa(pgd), true)
3421

3522
#define cpu_context(cpu, mm) ((mm)->context.asid[cpu])
3623
#define cpu_asid(cpu, mm) (cpu_context((cpu), (mm)) & ASID_MASK)

‎arch/csky/include/asm/page.h‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ typedef struct page *pgtable_t;
7272
#define __pgd(x) ((pgd_t) { (x) })
7373
#define __pgprot(x) ((pgprot_t) { (x) })
7474

75-
extern unsigned long phys_offset;
75+
extern unsigned long va_pa_offset;
7676

77-
#define ARCH_PFN_OFFSET PFN_DOWN(phys_offset + PHYS_OFFSET_OFFSET)
77+
#define ARCH_PFN_OFFSET PFN_DOWN(va_pa_offset + PHYS_OFFSET_OFFSET)
78+
79+
#define __pa(x) ((unsigned long)(x) - PAGE_OFFSET + va_pa_offset)
80+
#define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET - va_pa_offset))
7881

79-
#define __pa(x) ((unsigned long)(x) - PAGE_OFFSET + phys_offset)
80-
#define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET - \
81-
phys_offset))
8282
#define __pa_symbol(x) __pa(RELOC_HIDE((unsigned long)(x), 0))
8383

8484
#define MAP_NR(x) PFN_DOWN((unsigned long)(x) - PAGE_OFFSET - \

‎arch/csky/kernel/entry.S‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ ENTRY(csky_\name)
4040
WR_MCIR a2
4141
#endif
4242
bclri r6, 0
43-
lrw a2, phys_offset
43+
lrw a2, va_pa_offset
4444
ld.w a2, (a2, 0)
4545
subu r6, a2
4646
bseti r6, 31
@@ -51,7 +51,7 @@ ENTRY(csky_\name)
5151
addu r6, a2
5252
ldw r6, (r6)
5353

54-
lrw a2, phys_offset
54+
lrw a2, va_pa_offset
5555
ld.w a2, (a2, 0)
5656
subu r6, a2
5757
bseti r6, 31

‎arch/csky/kernel/setup.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,16 @@ void __init setup_arch(char **cmdline_p)
142142
#endif
143143
}
144144

145-
unsigned long phys_offset;
146-
EXPORT_SYMBOL(phys_offset);
145+
unsigned long va_pa_offset;
146+
EXPORT_SYMBOL(va_pa_offset);
147147

148148
asmlinkage __visible void __init csky_start(unsigned int unused,
149149
void *dtb_start)
150150
{
151151
/* Clean up bss section */
152152
memset(__bss_start, 0, __bss_stop - __bss_start);
153153

154-
phys_offset = read_mmu_msa0() & ~(SSEG_SIZE - 1);
154+
va_pa_offset = read_mmu_msa0() & ~(SSEG_SIZE - 1);
155155

156156
pre_trap_init();
157157
pre_mmu_init();

‎arch/csky/mm/fault.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
8181

8282
unsigned long pgd_base;
8383

84-
pgd_base = tlb_get_pgd();
84+
pgd_base = __va(get_pgd());
8585
pgd = (pgd_t *)pgd_base + offset;
8686
pgd_k = init_mm.pgd + offset;
8787

0 commit comments

Comments
 (0)