Skip to content

Commit

Permalink
Merge tag 'loongarch-fixes-5.19-3' of git://git.kernel.org/pub/scm/li…
Browse files Browse the repository at this point in the history
…nux/kernel/git/chenhuacai/linux-loongson

Pull LoongArch fixes from Huacai Chen:
 "Some bug fixes and a trivial cleanup"

* tag 'loongarch-fixes-5.19-3' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson:
  LoongArch: Make compute_return_era() return void
  LoongArch: Fix wrong fpu version
  LoongArch: Fix EENTRY/MERRENTRY setting in setup_tlb_handler()
  LoongArch: Fix sleeping in atomic context in setup_tlb_handler()
  LoongArch: Fix the _stext symbol address
  LoongArch: Fix the !THP build
  • Loading branch information
Linus Torvalds committed Jun 25, 2022
2 parents 29eeafc + ea18d43 commit cb84318
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 15 deletions.
3 changes: 1 addition & 2 deletions arch/loongarch/include/asm/branch.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ static inline unsigned long exception_era(struct pt_regs *regs)
return regs->csr_era;
}

static inline int compute_return_era(struct pt_regs *regs)
static inline void compute_return_era(struct pt_regs *regs)
{
regs->csr_era += 4;
return 0;
}

#endif /* _ASM_BRANCH_H */
10 changes: 5 additions & 5 deletions arch/loongarch/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,11 @@ static inline void update_mmu_cache_pmd(struct vm_area_struct *vma,

#define kern_addr_valid(addr) (1)

static inline unsigned long pmd_pfn(pmd_t pmd)
{
return (pmd_val(pmd) & _PFN_MASK) >> _PFN_SHIFT;
}

#ifdef CONFIG_TRANSPARENT_HUGEPAGE

/* We don't have hardware dirty/accessed bits, generic_pmdp_establish is fine.*/
Expand Down Expand Up @@ -497,11 +502,6 @@ static inline pmd_t pmd_mkyoung(pmd_t pmd)
return pmd;
}

static inline unsigned long pmd_pfn(pmd_t pmd)
{
return (pmd_val(pmd) & _PFN_MASK) >> _PFN_SHIFT;
}

static inline struct page *pmd_page(pmd_t pmd)
{
if (pmd_trans_huge(pmd))
Expand Down
2 changes: 1 addition & 1 deletion arch/loongarch/kernel/cpu-probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ void cpu_probe(void)

c->cputype = CPU_UNKNOWN;
c->processor_id = read_cpucfg(LOONGARCH_CPUCFG0);
c->fpu_vers = (read_cpucfg(LOONGARCH_CPUCFG2) >> 3) & 0x3;
c->fpu_vers = (read_cpucfg(LOONGARCH_CPUCFG2) & CPUCFG2_FPVERS) >> 3;

c->fpu_csr0 = FPU_CSR_RN;
c->fpu_mask = FPU_CSR_RSVD;
Expand Down
2 changes: 0 additions & 2 deletions arch/loongarch/kernel/head.S
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

__REF

SYM_ENTRY(_stext, SYM_L_GLOBAL, SYM_A_NONE)

SYM_CODE_START(kernel_entry) # kernel entry point

/* Config direct window and set PG */
Expand Down
3 changes: 1 addition & 2 deletions arch/loongarch/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,7 @@ asmlinkage void noinstr do_ri(struct pt_regs *regs)

die_if_kernel("Reserved instruction in kernel code", regs);

if (unlikely(compute_return_era(regs) < 0))
goto out;
compute_return_era(regs);

if (unlikely(get_user(opcode, era) < 0)) {
status = SIGSEGV;
Expand Down
1 change: 1 addition & 0 deletions arch/loongarch/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ SECTIONS
HEAD_TEXT_SECTION

. = ALIGN(PECOFF_SEGMENT_ALIGN);
_stext = .;
.text : {
TEXT_TEXT
SCHED_TEXT
Expand Down
7 changes: 4 additions & 3 deletions arch/loongarch/mm/tlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,16 @@ void setup_tlb_handler(int cpu)
if (pcpu_handlers[cpu])
return;

page = alloc_pages_node(cpu_to_node(cpu), GFP_KERNEL, get_order(vec_sz));
page = alloc_pages_node(cpu_to_node(cpu), GFP_ATOMIC, get_order(vec_sz));
if (!page)
return;

addr = page_address(page);
pcpu_handlers[cpu] = virt_to_phys(addr);
pcpu_handlers[cpu] = (unsigned long)addr;
memcpy((void *)addr, (void *)eentry, vec_sz);
local_flush_icache_range((unsigned long)addr, (unsigned long)addr + vec_sz);
csr_write64(pcpu_handlers[cpu], LOONGARCH_CSR_TLBRENTRY);
csr_write64(pcpu_handlers[cpu], LOONGARCH_CSR_EENTRY);
csr_write64(pcpu_handlers[cpu], LOONGARCH_CSR_MERRENTRY);
csr_write64(pcpu_handlers[cpu] + 80*VECSIZE, LOONGARCH_CSR_TLBRENTRY);
}
#endif
Expand Down

0 comments on commit cb84318

Please sign in to comment.