From: Scott Wood <scottwood@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] ARMv8: fix bug for flush data cache by set/way
Date: Mon, 7 Apr 2014 17:24:21 -0500 [thread overview]
Message-ID: <1396909461.32034.232.camel@snotra.buserror.net> (raw)
In-Reply-To: <1396230635-31864-1-git-send-email-leoy@marvell.com>
On Mon, 2014-03-31 at 09:50 +0800, Leo Yan wrote:
> When flush the d$ with set/way instruction, it need calculate the way's
> offset = log2(Associativity); but in current uboot's code, it use below
> formula to calculate the offset: log2(Associativity * 2 - 1), so finally
> it cannot flush data cache properly.
More specifically, the "Associativity" above is actually "Associativity
- 1", and clz isn't quite log2().
> Signed-off-by: Leo Yan <leoy@marvell.com>
> ---
> arch/arm/cpu/armv8/cache.S | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/arch/arm/cpu/armv8/cache.S b/arch/arm/cpu/armv8/cache.S
> index 546a83e..256d2e2 100644
> --- a/arch/arm/cpu/armv8/cache.S
> +++ b/arch/arm/cpu/armv8/cache.S
> @@ -30,9 +30,7 @@ ENTRY(__asm_flush_dcache_level)
> add x2, x2, #4 /* x2 <- log2(cache line size) */
> mov x3, #0x3ff
> and x3, x3, x6, lsr #3 /* x3 <- max number of #ways */
> - add w4, w3, w3
> - sub w4, w4, 1 /* round up log2(#ways + 1) */
> - clz w5, w4 /* bit position of #ways */
> + clz w5, w3 /* bit position of #ways */
> mov x4, #0x7fff
> and x4, x4, x6, lsr #13 /* x4 <- max number of #sets */
> /* x1 <- cache level << 1 */
I believe the new code will fail on a cache with associativity 1. x3
would be 0, since it's actually associativity minus one, and thus w5
would be 32. w5 is later interpreted as x5, so it would actually do a
32-bit shift rather than whatever behavior ARM specifies for shift
counts larger than the word size.
-Scott
next prev parent reply other threads:[~2014-04-07 22:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-31 1:50 [U-Boot] [PATCH] ARMv8: fix bug for flush data cache by set/way Leo Yan
2014-04-07 20:28 ` Albert ARIBAUD
2014-04-07 22:24 ` Scott Wood [this message]
[not found] <1396228307-30882-1-git-send-email-leoy@marvell.com>
[not found] ` <533A35A2.00C5E2.32003@APP8.CORPEASE.NET>
2014-04-01 7:20 ` Leo Yan
2014-04-01 7:41 ` Leo Yan
2014-04-01 10:47 ` FengHua
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=1396909461.32034.232.camel@snotra.buserror.net \
--to=scottwood@freescale.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