From: Xi Ruoyao <xry111@xry111.site>
To: lijun <lijun01@kylinos.cn>,
chenhuacai@kernel.org, kernel@xen0n.name, lvjianmin@loongson.cn,
dongbiao@loongson.cn, zhangbaoqi@loongson.cn
Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] LoongArch: Update the flush cache policy
Date: Tue, 07 May 2024 15:48:05 +0800 [thread overview]
Message-ID: <d41a1f6e2940e9747f9efcb3721646186940da03.camel@xry111.site> (raw)
In-Reply-To: <18342368-ce79-9820-26be-01834876fc9e@kylinos.cn>
On Tue, 2024-05-07 at 14:38 +0800, lijun wrote:
> I guess, final the value of addr is not important, just all of addr must
> read once is very important,
>
> so use two 'for()' and 'volatile' to flush all of addr 's cache,
> exactly as the name of the function is
>
> "flush_cache_last_level".
AFAIK do a read does not mean flushing the cache. The cacop instruction
is intended to do the cache flushing.
So why the cacop instruction in flush_cache_leaf is not enough to flush
it? Is there something wrong in flush_cache_leaf? It currently reads:
static void flush_cache_leaf(unsigned int leaf)
{
int i, j, nr_nodes;
uint64_t addr = CSR_DMW0_BASE;
struct cache_desc *cdesc = current_cpu_data.cache_leaves + leaf;
nr_nodes = cache_private(cdesc) ? 1 : loongson_sysconf.nr_nodes;
do {
for (i = 0; i < cdesc->sets; i++) {
for (j = 0; j < cdesc->ways; j++) {
flush_cache_line(leaf, addr);
addr++;
}
addr -= cdesc->ways;
addr += cdesc->linesz;
}
addr += (1ULL << NODE_ADDRSPACE_SHIFT);
} while (--nr_nodes > 0);
}
There is something bizarre: the flush_cache_line function uses the cacop
instruction in the Index Invalidate / Invalidate and Writeback mode, and
if I read the LoongArch manual correctly in this mode CSR_DMW0_BASE and
1ULL << NODE_ADDRSPACE_SHIFT are just ignored.
Is this something undocumented or flush_cache_leaf is just "incorrect"?
--
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University
next prev parent reply other threads:[~2024-05-07 7:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-06 9:24 Li Jun
2024-05-06 9:28 ` Xi Ruoyao
2024-05-06 10:08 ` lijun
2024-05-06 10:17 ` Xi Ruoyao
2024-05-07 0:53 ` lijun
2024-05-07 3:55 ` Xi Ruoyao
2024-05-07 6:38 ` lijun
2024-05-07 7:48 ` Xi Ruoyao [this message]
2024-05-07 6:06 ` kernel test robot
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=d41a1f6e2940e9747f9efcb3721646186940da03.camel@xry111.site \
--to=xry111@xry111.site \
--cc=chenhuacai@kernel.org \
--cc=dongbiao@loongson.cn \
--cc=kernel@xen0n.name \
--cc=lijun01@kylinos.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=lvjianmin@loongson.cn \
--cc=zhangbaoqi@loongson.cn \
/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
all inboxes | Powered by JetHome®