Skip to content

Commit e2f3f8b

Browse files
Nylon ChenGreentime Hu
authored andcommitted
nds32: support hardware prefetcher
We add a config for user to enable or disable this feature. It can be used to control the hardware prefetch function. Signed-off-by: Nylon Chen <nylon7@andestech.com> Acked-by: Greentime Hu <greentime@andestech.com> Signed-off-by: Greentime Hu <greentime@andestech.com>
1 parent a523406 commit e2f3f8b

4 files changed

Lines changed: 21 additions & 1 deletion

File tree

‎arch/nds32/Kconfig.cpu‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,13 @@ config CACHE_L2
177177
Say Y here to enable L2 cache if your SoC are integrated with L2CC.
178178
If unsure, say N.
179179

180+
config HW_PRE
181+
bool "Enable hardware prefetcher"
182+
default y
183+
help
184+
Say Y here to enable hardware prefetcher feature.
185+
Only when CPU_VER.REV >= 0x09 can support.
186+
180187
menu "Memory configuration"
181188

182189
choice

‎arch/nds32/include/asm/bitfield.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,14 +740,20 @@
740740
#define N13MISC_CTL_offRTP 1 /* Disable Return Target Predictor */
741741
#define N13MISC_CTL_offPTEPF 2 /* Disable HPTWK L2 PTE pefetch */
742742
#define N13MISC_CTL_offSP_SHADOW_EN 4 /* Enable shadow stack pointers */
743+
#define MISC_CTL_offHWPRE 11 /* Enable HardWare PREFETCH */
743744
/* bit 6, 9:31 reserved */
744745

745746
#define N13MISC_CTL_makBTB ( 0x1 << N13MISC_CTL_offBTB )
746747
#define N13MISC_CTL_makRTP ( 0x1 << N13MISC_CTL_offRTP )
747748
#define N13MISC_CTL_makPTEPF ( 0x1 << N13MISC_CTL_offPTEPF )
748749
#define N13MISC_CTL_makSP_SHADOW_EN ( 0x1 << N13MISC_CTL_offSP_SHADOW_EN )
750+
#define MISC_CTL_makHWPRE_EN ( 0x1 << MISC_CTL_offHWPRE )
749751

752+
#ifdef CONFIG_HW_PRE
753+
#define MISC_init (N13MISC_CTL_makBTB|N13MISC_CTL_makRTP|N13MISC_CTL_makSP_SHADOW_EN|MISC_CTL_makHWPRE_EN)
754+
#else
750755
#define MISC_init (N13MISC_CTL_makBTB|N13MISC_CTL_makRTP|N13MISC_CTL_makSP_SHADOW_EN)
756+
#endif
751757

752758
/******************************************************************************
753759
* PRUSR_ACC_CTL (Privileged Resource User Access Control Registers)

‎arch/nds32/kernel/head.S‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ _tlb:
151151
#endif
152152
mtsr $r3, $TLB_MISC
153153

154-
mfsr $r0, $MISC_CTL ! Enable BTB and RTP and shadow sp
154+
mfsr $r0, $MISC_CTL ! Enable BTB, RTP, shadow sp, and HW_PRE
155155
ori $r0, $r0, #MISC_init
156156
mtsr $r0, $MISC_CTL
157157

‎arch/nds32/kernel/setup.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#define HWCAP_FPU_DP 0x040000
4040
#define HWCAP_V2 0x080000
4141
#define HWCAP_DX_REGS 0x100000
42+
#define HWCAP_HWPRE 0x200000
4243

4344
unsigned long cpu_id, cpu_rev, cpu_cfgid;
4445
bool has_fpu = false;
@@ -75,6 +76,7 @@ static const char *hwcap_str[] = {
7576
"fpu_dp",
7677
"v2",
7778
"dx_regs",
79+
"hw_pre",
7880
NULL,
7981
};
8082

@@ -221,6 +223,11 @@ static void __init setup_cpuinfo(void)
221223
if (__nds32__mfsr(NDS32_SR_MSC_CFG) & MSC_CFG_mskL2C)
222224
elf_hwcap |= HWCAP_L2C;
223225

226+
#ifdef CONFIG_HW_PRE
227+
if (__nds32__mfsr(NDS32_SR_MISC_CTL) & MISC_CTL_makHWPRE_EN)
228+
elf_hwcap |= HWCAP_HWPRE;
229+
#endif
230+
224231
tmp = __nds32__mfsr(NDS32_SR_CACHE_CTL);
225232
if (!IS_ENABLED(CONFIG_CPU_DCACHE_DISABLE))
226233
tmp |= CACHE_CTL_mskDC_EN;

0 commit comments

Comments
 (0)