From: Mark Rutland <mark.rutland@arm.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] ARMv8: Bug fix of dcache_disable()
Date: Mon, 9 Feb 2015 11:05:54 +0000 [thread overview]
Message-ID: <20150209110554.GB4250@leverpostej> (raw)
In-Reply-To: <1423471919-5386-1-git-send-email-fenghua@phytium.com.cn>
On Mon, Feb 09, 2015 at 08:51:59AM +0000, fenghua at phytium.com.cn wrote:
> From: David Feng <fenghua@phytium.com.cn>
>
> The cache disable operation shoud be performed after flush_dcache_all().
> If cache disable operation is performed before
> flush_dcache_all(), flush_dcache_all() store data directly to memory
> and may be overrided by data copy in cache.
The reasoning above (and hence this patch) is wrong.
While the caches are on, they can allocate lines for any portion of the
address space with cacheable attributes, and can acquire dirty cache
lines from other CPUs. Additionally, there is no restriction preventing
lines from migrating between levels of cache while they are active.
So calling flush_dcache_all (which performs maintenance by Set/Way)
while the caches are enabled is wrong. Per the architecture it provides
no guarantee whatsoever.
To empty the caches by Set/Way, they must first be disabled. Note that
this only guarantees that the caches are empty; not where the data went.
Other CPUs might acquire dirty lines, or the data might only reach a
system cache rather than memory.
If you need certain portions of data to be flushed out to memory, then
those must be flushed by VA. If flush_dcache_all performs any memory
accesses before it has completed Set/Way maintenance, it is buggy.
Thanks,
Mark.
>
> Signed-off-by: David Feng <fenghua@phytium.com.cn>
> ---
> arch/arm/cpu/armv8/cache_v8.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/cpu/armv8/cache_v8.c b/arch/arm/cpu/armv8/cache_v8.c
> index 9dbcdf2..dc2fc8c 100644
> --- a/arch/arm/cpu/armv8/cache_v8.c
> +++ b/arch/arm/cpu/armv8/cache_v8.c
> @@ -124,9 +124,10 @@ void dcache_disable(void)
> if (!(sctlr & CR_C))
> return;
>
> + flush_dcache_all();
> +
> set_sctlr(sctlr & ~(CR_C|CR_M));
>
> - flush_dcache_all();
> __asm_invalidate_tlb_all();
> }
>
> --
> 1.7.9.5
>
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
>
next prev parent reply other threads:[~2015-02-09 11:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-09 8:51 [U-Boot] [PATCH] ARMv8: Bug fix of dcache_disable() fenghua at phytium.com.cn
2015-02-09 11:05 ` Mark Rutland [this message]
2015-02-11 3:26 ` FengHua
2015-02-11 15:51 ` Mark Rutland
2015-02-26 15:06 ` FengHua
2015-03-03 11:58 ` Mark Rutland
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150209110554.GB4250@leverpostej \
--to=mark.rutland@arm.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox