Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 21 Nov 2014 10:16:05 +0100 (CET) Received: from mail-pa0-f44.google.com ([209.85.220.44]:38121 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by eddie.linux-mips.org with ESMTP id S27006575AbaKUJPsKSSQF (ORCPT ); Fri, 21 Nov 2014 10:15:48 +0100 Received: by mail-pa0-f44.google.com with SMTP id et14so4531606pad.3 for ; Fri, 21 Nov 2014 01:15:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=VDC712PpDwNw8cOnO9RmkviQGhs8zpyorfHvGv0LYjM=; b=PCDWz5/CjKzS33QcTBFnY1zxTvcE8Je7x8Y5v3rEmtFY4E61g0mPMSRnXoTSOIUDE0 /YrhTanT4SYuMe1Em+6/FaaG6nSVQCTTjxNiFoZsFmG7tRQAMuv6povV6te7BRPTo1LR 2/yB3OOp8cGuZqglpDTrng5iSHeNIm4sou/TYCpck1QroA7twRh100JWIB1jQxeTj66E k+rQUkhx7+uDAkkYoLN3eIBRWZjttdybeaFOHs10h0z3k8ib2q1gq+9b8DOadeWIVGAG rSgYHsy3hjExr2FMrLC49pZlz+Wh31rwzHpQh5TTa2xN/+ySWCnciiuENSbF1569p2GF 8N9w== X-Received: by 10.68.245.7 with SMTP id xk7mr4895333pbc.65.1416561339854; Fri, 21 Nov 2014 01:15:39 -0800 (PST) Received: from localhost.localdomain ([222.92.8.142]) by mx.google.com with ESMTPSA id fb7sm4263864pab.10.2014.11.21.01.15.36 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 21 Nov 2014 01:15:38 -0800 (PST) From: Huacai Chen To: Ralf Baechle Cc: John Crispin , "Steven J. Hill" , linux-mips@linux-mips.org, Fuxin Zhang , Zhangjin Wu , Huacai Chen , Hongliang Tao Subject: [PATCH V5 1/7] MIPS: Loongson: Introduce and use cpu_has_coherent_cache feature Date: Fri, 21 Nov 2014 17:12:40 +0800 Message-Id: <1416561160-31199-2-git-send-email-chenhc@lemote.com> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1416561160-31199-1-git-send-email-chenhc@lemote.com> References: <1416561160-31199-1-git-send-email-chenhc@lemote.com> Return-Path: X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0) X-Orcpt: rfc822;linux-mips@linux-mips.org Original-Recipient: rfc822;linux-mips@linux-mips.org X-archive-position: 44331 X-ecartis-version: Ecartis v1.0.0 Sender: linux-mips-bounce@linux-mips.org Errors-to: linux-mips-bounce@linux-mips.org X-original-sender: chenhc@lemote.com Precedence: bulk List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: linux-mips X-List-ID: linux-mips List-subscribe: List-owner: List-post: List-archive: X-list: linux-mips Loongson-3 maintains cache coherency by hardware. So we introduce a cpu feature named cpu_has_coherent_cache and use it to modify MIPS's cache flushing functions. Signed-off-by: Huacai Chen Signed-off-by: Hongliang Tao --- arch/mips/Kconfig | 3 ++ arch/mips/include/asm/cpu-features.h | 3 ++ .../asm/mach-loongson/cpu-feature-overrides.h | 1 + arch/mips/mm/c-r4k.c | 21 ++++++++++++++++++++ 4 files changed, 28 insertions(+), 0 deletions(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 3348989..9e909b9 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -1636,6 +1636,7 @@ config CPU_BMIPS5000 config SYS_HAS_CPU_LOONGSON3 bool select CPU_SUPPORTS_CPUFREQ + select CPU_SUPPORTS_COHERENT_CACHE config SYS_HAS_CPU_LOONGSON2E bool @@ -1799,6 +1800,8 @@ config CPU_SUPPORTS_HUGEPAGES bool config CPU_SUPPORTS_UNCACHED_ACCELERATED bool +config CPU_SUPPORTS_COHERENT_CACHE + bool config MIPS_PGD_C0_CONTEXT bool default y if 64BIT && CPU_MIPSR2 && !CPU_XLP diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h index 2897cfa..f20bf5a 100644 --- a/arch/mips/include/asm/cpu-features.h +++ b/arch/mips/include/asm/cpu-features.h @@ -148,6 +148,9 @@ #ifndef cpu_has_pindexed_dcache #define cpu_has_pindexed_dcache (cpu_data[0].dcache.flags & MIPS_CACHE_PINDEX) #endif +#ifndef cpu_has_coherent_cache +#define cpu_has_coherent_cache 0 +#endif #ifndef cpu_has_local_ebase #define cpu_has_local_ebase 1 #endif diff --git a/arch/mips/include/asm/mach-loongson/cpu-feature-overrides.h b/arch/mips/include/asm/mach-loongson/cpu-feature-overrides.h index 6d69332..7efb191 100644 --- a/arch/mips/include/asm/mach-loongson/cpu-feature-overrides.h +++ b/arch/mips/include/asm/mach-loongson/cpu-feature-overrides.h @@ -58,5 +58,6 @@ #define cpu_has_local_ebase 0 #define cpu_has_wsbh IS_ENABLED(CONFIG_CPU_LOONGSON3) +#define cpu_has_coherent_cache IS_ENABLED(CONFIG_CPU_SUPPORTS_COHERENT_CACHE) #endif /* __ASM_MACH_LOONGSON_CPU_FEATURE_OVERRIDES_H */ diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c index dd261df..5131b4d 100644 --- a/arch/mips/mm/c-r4k.c +++ b/arch/mips/mm/c-r4k.c @@ -420,6 +420,9 @@ static void r4k_blast_scache_setup(void) static inline void local_r4k___flush_cache_all(void * args) { + if (cpu_has_coherent_cache) + return; + switch (current_cpu_type()) { case CPU_LOONGSON2: case CPU_LOONGSON3: @@ -447,6 +450,9 @@ static inline void local_r4k___flush_cache_all(void * args) static void r4k___flush_cache_all(void) { + if (cpu_has_coherent_cache) + return; + r4k_on_each_cpu(local_r4k___flush_cache_all, NULL); } @@ -493,6 +499,9 @@ static void r4k_flush_cache_range(struct vm_area_struct *vma, { int exec = vma->vm_flags & VM_EXEC; + if (cpu_has_coherent_cache) + return; + if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc)) r4k_on_each_cpu(local_r4k_flush_cache_range, vma); } @@ -616,6 +625,9 @@ static void r4k_flush_cache_page(struct vm_area_struct *vma, { struct flush_cache_page_args args; + if (cpu_has_coherent_cache) + return; + args.vma = vma; args.addr = addr; args.pfn = pfn; @@ -625,11 +637,17 @@ static void r4k_flush_cache_page(struct vm_area_struct *vma, static inline void local_r4k_flush_data_cache_page(void * addr) { + if (cpu_has_coherent_cache) + return; + r4k_blast_dcache_page((unsigned long) addr); } static void r4k_flush_data_cache_page(unsigned long addr) { + if (cpu_has_coherent_cache) + return; + if (in_atomic()) local_r4k_flush_data_cache_page((void *)addr); else @@ -814,6 +832,9 @@ static void local_r4k_flush_cache_sigtramp(void * arg) static void r4k_flush_cache_sigtramp(unsigned long addr) { + if (cpu_has_coherent_cache) + return; + r4k_on_each_cpu(local_r4k_flush_cache_sigtramp, (void *) addr); } -- 1.7.7.3