Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp301270imu; Thu, 8 Nov 2018 02:05:17 -0800 (PST) X-Google-Smtp-Source: AJdET5f/s1+jtt5NQ+RTSrz+Q+hHrkTB8DFt6O7RipSdTIvb31U+mgso2VV7lQbuK4UJl/Keu9+R X-Received: by 2002:a62:3101:: with SMTP id x1-v6mr4031300pfx.204.1541671517459; Thu, 08 Nov 2018 02:05:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541671517; cv=none; d=google.com; s=arc-20160816; b=zJcgCq9BUWK8M8yLyUI9HKGyNfCZ7T6PnUzSAI0I0UI+rzAm7hXrcwBvcbk24WGBSu MHEI6uO5vMhuefwA2QEiSXma4QHOu4DWBp8sFHIGnDGVK8fWSopIy2S+1HV7sxYF5+2T FXqNpTW9H/JL2wy28nRwiJ3hZkj2Bz7Zfp4k49CwzcfE09g3app2pE4jWVBmMkymzRCt uz9LnzcMX4txo3Gkl1f3MkHvn9uknsvpcw4R58yRzg25L07Cf88lzmDbrVL1N5TfKagD 6xBhdH/sG/RQXJKf8S9Xsp7Fl/JnIfOIvbKYOOCGePrPAUO3EbxT/74lg4BVsQOBUgRo tjPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=hVHd4HY1c6suqw6Tchx9VvlQCLo8O5JqtAQtRdB9Yf0=; b=KkLaikk39MCWWT2Y6WB+Ra6jIZfmFj/IfdNrx9KVKGQcIGF7moKkaRbsU5GtkEdwtA NYgRUtRl/ruM9mW/ZwmnuBjWa5qq+TLw4Gu6vgF6BaC0Mq7TkQiRYguF7zIJE9bortIp NxzSC8UiRbsza0I2qIAWuJsrUYYJz/6iylUmTQCJa598ugDU09VR0K0A0LZ2np+FHOeN 0zVhEQiRlaKgkN6t6/pSu5Ii+5Lg81Tc9AEHkw1w1PF6WzfkzJsex/6TWnNQCNbf89AZ xD41n+vOjQfCGx+xvP+/B1g8mInfY/NUqBQcSsvvQhwXex2AzE46fzmrQVcYj0Tt5YYn lmog== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 31-v6si3647568pli.416.2018.11.08.02.05.00; Thu, 08 Nov 2018 02:05:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726758AbeKHThA (ORCPT + 99 others); Thu, 8 Nov 2018 14:37:00 -0500 Received: from 59-120-53-16.HINET-IP.hinet.net ([59.120.53.16]:22681 "EHLO ATCSQR.andestech.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726283AbeKHThA (ORCPT ); Thu, 8 Nov 2018 14:37:00 -0500 Received: from mail.andestech.com (atcpcs16.andestech.com [10.0.1.222]) by ATCSQR.andestech.com with ESMTP id wA8A2PS2059702; Thu, 8 Nov 2018 18:02:25 +0800 (GMT-8) (envelope-from nylon7@andestech.com) Received: from app09.andestech.com (10.0.15.117) by ATCPCS16.andestech.com (10.0.1.222) with Microsoft SMTP Server id 14.3.123.3; Thu, 8 Nov 2018 18:02:09 +0800 From: Nylon Chen To: , , CC: , Nylon Chen Subject: [PATCH v2 2/2] nds32: support hardware prefetcher Date: Thu, 8 Nov 2018 18:00:12 +0800 Message-ID: <20181108100012.2519-1-nylon7@andestech.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.0.15.117] X-DNSRBL: X-MAIL: ATCSQR.andestech.com wA8A2PS2059702 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- arch/nds32/Kconfig.cpu | 7 +++++++ arch/nds32/include/asm/bitfield.h | 6 ++++++ arch/nds32/kernel/head.S | 2 +- arch/nds32/kernel/setup.c | 7 +++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/arch/nds32/Kconfig.cpu b/arch/nds32/Kconfig.cpu index b8c8984d1456..8fd1236db3fa 100644 --- a/arch/nds32/Kconfig.cpu +++ b/arch/nds32/Kconfig.cpu @@ -143,6 +143,13 @@ config CACHE_L2 Say Y here to enable L2 cache if your SoC are integrated with L2CC. If unsure, say N. +config HW_PRE + bool "Enable hardware prefetcher" + default y + help + Say Y here to enable hardware prefetcher feature. + Only when CPU_VER.REV >= 0x09 can support. + menu "Memory configuration" choice diff --git a/arch/nds32/include/asm/bitfield.h b/arch/nds32/include/asm/bitfield.h index 8e84fc385b94..2a33700e7ffa 100644 --- a/arch/nds32/include/asm/bitfield.h +++ b/arch/nds32/include/asm/bitfield.h @@ -735,14 +735,20 @@ #define N13MISC_CTL_offRTP 1 /* Disable Return Target Predictor */ #define N13MISC_CTL_offPTEPF 2 /* Disable HPTWK L2 PTE pefetch */ #define N13MISC_CTL_offSP_SHADOW_EN 4 /* Enable shadow stack pointers */ +#define MISC_CTL_offHWPRE 11 /* Enable HardWare PREFETCH */ /* bit 6, 9:31 reserved */ #define N13MISC_CTL_makBTB ( 0x1 << N13MISC_CTL_offBTB ) #define N13MISC_CTL_makRTP ( 0x1 << N13MISC_CTL_offRTP ) #define N13MISC_CTL_makPTEPF ( 0x1 << N13MISC_CTL_offPTEPF ) #define N13MISC_CTL_makSP_SHADOW_EN ( 0x1 << N13MISC_CTL_offSP_SHADOW_EN ) +#define MISC_CTL_makHWPRE_EN ( 0x1 << MISC_CTL_offHWPRE ) +#ifdef CONFIG_HW_PRE +#define MISC_init (N13MISC_CTL_makBTB|N13MISC_CTL_makRTP|N13MISC_CTL_makSP_SHADOW_EN|MISC_CTL_makHWPRE_EN) +#else #define MISC_init (N13MISC_CTL_makBTB|N13MISC_CTL_makRTP|N13MISC_CTL_makSP_SHADOW_EN) +#endif /****************************************************************************** * PRUSR_ACC_CTL (Privileged Resource User Access Control Registers) diff --git a/arch/nds32/kernel/head.S b/arch/nds32/kernel/head.S index c5fdae174ced..029e27fb0d71 100644 --- a/arch/nds32/kernel/head.S +++ b/arch/nds32/kernel/head.S @@ -160,7 +160,7 @@ _tlb: #endif mtsr $r3, $TLB_MISC - mfsr $r0, $MISC_CTL ! Enable BTB and RTP and shadow sp + mfsr $r0, $MISC_CTL ! Enable BTB, RTP, shadow sp and HW_PRE ori $r0, $r0, #MISC_init mtsr $r0, $MISC_CTL diff --git a/arch/nds32/kernel/setup.c b/arch/nds32/kernel/setup.c index 87683583f206..637f4e2f6577 100644 --- a/arch/nds32/kernel/setup.c +++ b/arch/nds32/kernel/setup.c @@ -39,6 +39,7 @@ #define HWCAP_FPU_DP 0x040000 #define HWCAP_V2 0x080000 #define HWCAP_DX_REGS 0x100000 +#define HWCAP_HWPRE 0x200000 unsigned long cpu_id, cpu_rev, cpu_cfgid; char cpu_series; @@ -74,6 +75,7 @@ static const char *hwcap_str[] = { "fpu_dp", "v2", "dx_regs", + "hw_pre", NULL, }; @@ -214,6 +216,11 @@ static void __init setup_cpuinfo(void) if (__nds32__mfsr(NDS32_SR_MSC_CFG) & MSC_CFG_mskL2C) elf_hwcap |= HWCAP_L2C; +#ifdef CONFIG_HW_PRE + if (__nds32__mfsr(NDS32_SR_MISC_CTL) & MISC_CTL_makHWPRE_EN) + elf_hwcap |= HWCAP_HWPRE; +#endif + tmp = __nds32__mfsr(NDS32_SR_CACHE_CTL); if (!IS_ENABLED(CONFIG_CPU_DCACHE_DISABLE)) tmp |= CACHE_CTL_mskDC_EN; -- 2.18.0