mirror of https://gitee.com/openkylin/linux.git
nios2: improve readability of tlb functions
Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
This commit is contained in:
parent
e71c99fe8d
commit
c6b1d363f8
|
@ -62,19 +62,20 @@ void flush_tlb_one_pid(unsigned long addr, unsigned long mmu_pid)
|
||||||
|
|
||||||
tlbmisc = TLBMISC_RD | (way << TLBMISC_WAY_SHIFT);
|
tlbmisc = TLBMISC_RD | (way << TLBMISC_WAY_SHIFT);
|
||||||
WRCTL(CTL_TLBMISC, tlbmisc);
|
WRCTL(CTL_TLBMISC, tlbmisc);
|
||||||
|
|
||||||
pteaddr = RDCTL(CTL_PTEADDR);
|
pteaddr = RDCTL(CTL_PTEADDR);
|
||||||
|
if (((pteaddr >> 2) & 0xfffff) != (addr >> PAGE_SHIFT))
|
||||||
|
continue;
|
||||||
|
|
||||||
tlbmisc = RDCTL(CTL_TLBMISC);
|
tlbmisc = RDCTL(CTL_TLBMISC);
|
||||||
pid = (tlbmisc >> TLBMISC_PID_SHIFT) & TLBMISC_PID_MASK;
|
pid = (tlbmisc >> TLBMISC_PID_SHIFT) & TLBMISC_PID_MASK;
|
||||||
if (((((pteaddr >> 2) & 0xfffff)) == (addr >> PAGE_SHIFT)) &&
|
if (pid != mmu_pid)
|
||||||
pid == mmu_pid) {
|
continue;
|
||||||
pr_debug("Flush entry by writing way=%dl pid=%ld\n",
|
|
||||||
way, (pid_misc >> TLBMISC_PID_SHIFT));
|
|
||||||
|
|
||||||
WRCTL(CTL_PTEADDR, pteaddr_invalid(addr));
|
tlbmisc = TLBMISC_WE | (way << TLBMISC_WAY_SHIFT);
|
||||||
tlbmisc = TLBMISC_WE | (way << TLBMISC_WAY_SHIFT);
|
WRCTL(CTL_TLBMISC, tlbmisc);
|
||||||
WRCTL(CTL_TLBMISC, tlbmisc);
|
WRCTL(CTL_PTEADDR, pteaddr_invalid(addr));
|
||||||
WRCTL(CTL_TLBACC, 0);
|
WRCTL(CTL_TLBACC, 0);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WRCTL(CTL_TLBMISC, org_misc);
|
WRCTL(CTL_TLBMISC, org_misc);
|
||||||
|
@ -113,18 +114,18 @@ static void flush_tlb_one(unsigned long addr)
|
||||||
|
|
||||||
tlbmisc = TLBMISC_RD | (way << TLBMISC_WAY_SHIFT);
|
tlbmisc = TLBMISC_RD | (way << TLBMISC_WAY_SHIFT);
|
||||||
WRCTL(CTL_TLBMISC, tlbmisc);
|
WRCTL(CTL_TLBMISC, tlbmisc);
|
||||||
|
|
||||||
pteaddr = RDCTL(CTL_PTEADDR);
|
pteaddr = RDCTL(CTL_PTEADDR);
|
||||||
tlbmisc = RDCTL(CTL_TLBMISC);
|
if (((pteaddr >> 2) & 0xfffff) != (addr >> PAGE_SHIFT))
|
||||||
|
continue;
|
||||||
|
|
||||||
if ((((pteaddr >> 2) & 0xfffff)) == (addr >> PAGE_SHIFT)) {
|
pr_debug("Flush entry by writing way=%dl pid=%ld\n",
|
||||||
pr_debug("Flush entry by writing way=%dl pid=%ld\n",
|
way, (pid_misc >> TLBMISC_PID_SHIFT));
|
||||||
way, (pid_misc >> TLBMISC_PID_SHIFT));
|
|
||||||
|
|
||||||
WRCTL(CTL_PTEADDR, pteaddr_invalid(addr));
|
tlbmisc = TLBMISC_WE | (way << TLBMISC_WAY_SHIFT);
|
||||||
tlbmisc = TLBMISC_WE | (way << TLBMISC_WAY_SHIFT);
|
WRCTL(CTL_TLBMISC, tlbmisc);
|
||||||
WRCTL(CTL_TLBMISC, tlbmisc);
|
WRCTL(CTL_PTEADDR, pteaddr_invalid(addr));
|
||||||
WRCTL(CTL_TLBACC, 0);
|
WRCTL(CTL_TLBACC, 0);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WRCTL(CTL_TLBMISC, org_misc);
|
WRCTL(CTL_TLBMISC, org_misc);
|
||||||
|
@ -187,7 +188,7 @@ void dump_tlb(void)
|
||||||
dump_tlb_line(i);
|
dump_tlb_line(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void flush_tlb_pid(unsigned long pid)
|
void flush_tlb_pid(unsigned long mmu_pid)
|
||||||
{
|
{
|
||||||
unsigned long addr = 0;
|
unsigned long addr = 0;
|
||||||
unsigned int line;
|
unsigned int line;
|
||||||
|
@ -202,17 +203,18 @@ void flush_tlb_pid(unsigned long pid)
|
||||||
|
|
||||||
for (way = 0; way < cpuinfo.tlb_num_ways; way++) {
|
for (way = 0; way < cpuinfo.tlb_num_ways; way++) {
|
||||||
unsigned long tlbmisc;
|
unsigned long tlbmisc;
|
||||||
|
unsigned long pid;
|
||||||
|
|
||||||
tlbmisc = TLBMISC_RD | (way << TLBMISC_WAY_SHIFT);
|
tlbmisc = TLBMISC_RD | (way << TLBMISC_WAY_SHIFT);
|
||||||
WRCTL(CTL_TLBMISC, tlbmisc);
|
WRCTL(CTL_TLBMISC, tlbmisc);
|
||||||
tlbmisc = RDCTL(CTL_TLBMISC);
|
tlbmisc = RDCTL(CTL_TLBMISC);
|
||||||
|
pid = (tlbmisc >> TLBMISC_PID_SHIFT) & TLBMISC_PID_MASK;
|
||||||
|
if (pid != mmu_pid)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (((tlbmisc>>TLBMISC_PID_SHIFT) & TLBMISC_PID_MASK)
|
tlbmisc = TLBMISC_WE | (way << TLBMISC_WAY_SHIFT);
|
||||||
== pid) {
|
WRCTL(CTL_TLBMISC, tlbmisc);
|
||||||
tlbmisc = TLBMISC_WE | (way << TLBMISC_WAY_SHIFT);
|
WRCTL(CTL_TLBACC, 0);
|
||||||
WRCTL(CTL_TLBMISC, tlbmisc);
|
|
||||||
WRCTL(CTL_TLBACC, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addr += PAGE_SIZE;
|
addr += PAGE_SIZE;
|
||||||
|
@ -265,6 +267,10 @@ void flush_tlb_all(void)
|
||||||
|
|
||||||
void set_mmu_pid(unsigned long pid)
|
void set_mmu_pid(unsigned long pid)
|
||||||
{
|
{
|
||||||
WRCTL(CTL_TLBMISC, (RDCTL(CTL_TLBMISC) & TLBMISC_WAY) |
|
unsigned long tlbmisc;
|
||||||
((pid & TLBMISC_PID_MASK) << TLBMISC_PID_SHIFT));
|
|
||||||
|
tlbmisc = RDCTL(CTL_TLBMISC);
|
||||||
|
tlbmisc = (tlbmisc & TLBMISC_WAY);
|
||||||
|
tlbmisc |= (pid & TLBMISC_PID_MASK) << TLBMISC_PID_SHIFT;
|
||||||
|
WRCTL(CTL_TLBMISC, tlbmisc);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue