mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-07-22 01:43:37 -04:00
New Loongson-3 (Loongson-3A R2, Loongson-3A R3, and newer) has SFB (Store Fill Buffer) which can improve the performance of memory access. Now, SFB enablement is controlled by CONFIG_LOONGSON3_ENHANCEMENT, and the generic kernel has no benefit from SFB (even it is running on a new Loongson-3 machine). With this patch, we can enable SFB at runtime by detecting the CPU type (the expense is war_io_reorder_wmb() will always be a 'sync', which will hurt the performance of old Loongson-3). [paul.burton@mips.com: Further info from Huacai: In practise, I found that sometimes there are boot failures if I enable SFB/LPA in cpu_probe(). I don't know why because processor designers also haven't give me an explaination, but I think this may have some relationships to speculative execution.] Signed-off-by: Huacai Chen <chenhc@lemote.com> Signed-off-by: Paul Burton <paul.burton@mips.com> Patchwork: https://patchwork.linux-mips.org/patch/20426/ Cc: Ralf Baechle <ralf@linux-mips.org> Cc: James Hogan <jhogan@kernel.org> Cc: linux-mips@linux-mips.org Cc: Fuxin Zhang <zhangfx@lemote.com> Cc: Zhangjin Wu <wuzhangjin@gmail.com> Cc: Huacai Chen <chenhuacai@gmail.com>
74 lines
1.7 KiB
C
74 lines
1.7 KiB
C
/*
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
* for more details.
|
|
*
|
|
* Copyright (C) 2005 Embedded Alley Solutions, Inc
|
|
* Copyright (C) 2005 Ralf Baechle (ralf@linux-mips.org)
|
|
* Copyright (C) 2009 Jiajie Chen (chenjiajie@cse.buaa.edu.cn)
|
|
* Copyright (C) 2012 Huacai Chen (chenhc@lemote.com)
|
|
*/
|
|
#ifndef __ASM_MACH_LOONGSON64_KERNEL_ENTRY_H
|
|
#define __ASM_MACH_LOONGSON64_KERNEL_ENTRY_H
|
|
|
|
#include <asm/cpu.h>
|
|
|
|
/*
|
|
* Override macros used in arch/mips/kernel/head.S.
|
|
*/
|
|
.macro kernel_entry_setup
|
|
#ifdef CONFIG_CPU_LOONGSON3
|
|
.set push
|
|
.set mips64
|
|
/* Set LPA on LOONGSON3 config3 */
|
|
mfc0 t0, CP0_CONFIG3
|
|
or t0, (0x1 << 7)
|
|
mtc0 t0, CP0_CONFIG3
|
|
/* Set ELPA on LOONGSON3 pagegrain */
|
|
mfc0 t0, CP0_PAGEGRAIN
|
|
or t0, (0x1 << 29)
|
|
mtc0 t0, CP0_PAGEGRAIN
|
|
/* Enable STFill Buffer */
|
|
mfc0 t0, CP0_PRID
|
|
andi t0, (PRID_IMP_MASK | PRID_REV_MASK)
|
|
slti t0, (PRID_IMP_LOONGSON_64 | PRID_REV_LOONGSON3A_R2)
|
|
bnez t0, 1f
|
|
mfc0 t0, CP0_CONFIG6
|
|
or t0, 0x100
|
|
mtc0 t0, CP0_CONFIG6
|
|
1:
|
|
_ehb
|
|
.set pop
|
|
#endif
|
|
.endm
|
|
|
|
/*
|
|
* Do SMP slave processor setup.
|
|
*/
|
|
.macro smp_slave_setup
|
|
#ifdef CONFIG_CPU_LOONGSON3
|
|
.set push
|
|
.set mips64
|
|
/* Set LPA on LOONGSON3 config3 */
|
|
mfc0 t0, CP0_CONFIG3
|
|
or t0, (0x1 << 7)
|
|
mtc0 t0, CP0_CONFIG3
|
|
/* Set ELPA on LOONGSON3 pagegrain */
|
|
mfc0 t0, CP0_PAGEGRAIN
|
|
or t0, (0x1 << 29)
|
|
mtc0 t0, CP0_PAGEGRAIN
|
|
/* Enable STFill Buffer */
|
|
mfc0 t0, CP0_PRID
|
|
andi t0, (PRID_IMP_MASK | PRID_REV_MASK)
|
|
slti t0, (PRID_IMP_LOONGSON_64 | PRID_REV_LOONGSON3A_R2)
|
|
bnez t0, 1f
|
|
mfc0 t0, CP0_CONFIG6
|
|
or t0, 0x100
|
|
mtc0 t0, CP0_CONFIG6
|
|
1:
|
|
_ehb
|
|
.set pop
|
|
#endif
|
|
.endm
|
|
|
|
#endif /* __ASM_MACH_LOONGSON64_KERNEL_ENTRY_H */
|