[Top] [All Lists]

Re: [PATCH V9 03/13] MIPS: Loongson: Introduce and use cpu_has_coherent_

To: "Steven J. Hill" <>
Subject: Re: [PATCH V9 03/13] MIPS: Loongson: Introduce and use cpu_has_coherent_cache feature
From: Huacai Chen <>
Date: Fri, 12 Apr 2013 11:07:57 +0800
Cc: Ralf Baechle <>,,, Fuxin Zhang <>, Zhangjin Wu <>, Hongliang Tao <>, Hua Yan <>
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed;; s=20120113; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=BGuLmSOHjHahGBRnN2jvJx2KEPi8IvhUN0n+M04LptU=; b=PeuQS2AB6KnNZnI1D9ybYHdEx1mGDi6L2m7ArqwwWnpZgCaiLdhOkoCBd6LA46zeI0 OwbDNFuvApEl0knuGFaS6e0ILjsOKG6fMSvbS7/ds7xGWQ0/8xMJuJYoYdNsY2vAFUun YQFiOtS0MFKJQnmROUoCKiHFLZCqVrmvQ9EmS6GMeq6kronYY5APwLcVMdPjjPASoZnL zHBZ8I8TqHnolhTobeMH/t/8ExY9ZpZJyXIqmFYP3oLZEunWlSn37vZQ8bYHByrrqddY FWQtVfYoGBy91+uLpWY9IXenJthLDXj9hFlktzXid0+dXjE5lnRPGmruR12zX3RXabPE 8Luw==
In-reply-to: <>
List-archive: <>
List-help: <>
List-id: linux-mips <>
List-owner: <>
List-post: <>
List-software: Ecartis version 1.0.0
List-subscribe: <>
List-unsubscribe: <>
Original-recipient: rfc822;
References: <> <> <>
Hi, Steven,

Maybe you are misunderstand Loongson-3's "hardware-maintained cache". Loongson-3's hardware maintain the cache coherency between multi-cores (also maintain coherency between CPU-core and DMA), but Loongson-3 can *still* has cache alias (Cache alias in Loongson is sovled by 16K PageSize).

Meanwhile, I know why you misunderstand, because my code is like this:

static inline void local_r4k___flush_cache_all(void * args)
        if (cpu_has_coherent_cache)

This implies that Loongson-3 has no cache alias, but in fact this is wrong if Loongson has configured PageSize < 16K.

I think I should make my code in all flush functions like this:
static inline void local_r4k___flush_cache_all(void * args)
        if (cpu_has_coherent_cache && !cpu_has_dc_aliases)

Am I right?

On Fri, Apr 12, 2013 at 1:05 AM, Steven J. Hill <> wrote:
Hash: SHA1

On 01/30/2013 12:24 AM, Huacai Chen wrote:
> 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
> <> Signed-off-by: Hua Yan <> ---
> arch/mips/include/asm/cacheflush.h                 |    6 +++++
> arch/mips/include/asm/cpu-features.h               |    3 ++
> .../asm/mach-loongson/cpu-feature-overrides.h      |    6 +++++
> arch/mips/mm/c-r4k.c                               |   21
> ++++++++++++++++++- 4 files changed, 34 insertions(+), 2 deletions(-)

This patch masks the problem that you are not properly probing your L1 caches
to start with. For some reason in 'probe_pcache()' you reach the default case
where the primary data cache is marked as having aliases. If your CPU truly is
HW coherent with no aliases, then MIPS_CACHE_ALIASES should never get set.
Fixing this would eliminate the 'arch/mips/include/asm/cacheflush.h' and
'arch/mips/mm/c-r4k.c' changes completely. There is no need to add more CPU
feature bits for this single platform, thus changes to 'cpu-features.h' and
'cpu-features-overrides.h' will not be accepted.

Also, please do not copy the <> mailing list
unless your patch touches files outside of 'arch/mips' in order to cut down
traffic on an already busy list. Thanks.

- -----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird -


<Prev in Thread] Current Thread [Next in Thread>