From: Jules Maselbas <jmaselbas@kalray.eu>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org, Yann Sionneau <ysionneau@kalray.eu>
Subject: Re: [PATCH 2/5] kvx: Implement dcache invalidation primitive
Date: Tue, 2 Mar 2021 12:44:48 +0100 [thread overview]
Message-ID: <20210302114448.GE9273@tellis.lin.mbt.kalray.eu> (raw)
In-Reply-To: <cd974769-fc79-ada3-a8e6-cd3cadfdbe89@pengutronix.de>
On Tue, Mar 02, 2021 at 09:40:50AM +0100, Ahmad Fatoum wrote:
> Hello,
>
> > +
> > +void kvx_dcache_invalidate_mem_area(uint64_t addr, int size)
> > +{
> > + /* if hwloop iterations cost < _K1_DCACHE_REFILL_PERCENT cache refill,
> > + * use hwloop, otherwise invalid the whole cache
> > + */
> > + if (size <
> > + (K1_DCACHE_REFILL_PERCENT * (K1_DCACHE_REFILL * K1_DCACHE_SIZE))
> > + / (100 * (K1_DCACHE_REFILL + K1_DCACHE_HWLOOP))) {
> > + /* number of lines that must be invalidated */
> > + int invalid_lines = ((addr + size) -
> > + (addr & (~(K1_DCACHE_LINE_SIZE - 1))));
> > +
> > + invalid_lines = invalid_lines / K1_DCACHE_LINE_SIZE
> > + + (0 != (invalid_lines % K1_DCACHE_LINE_SIZE));
> > + if (__builtin_constant_p(invalid_lines) && invalid_lines <= 2) {
>
> Note that currently this will always be false, because of lack of link time
> optimization. You could split this away the check into the header and leave the
> juicy parts here if you want to have this optimization.
>
Yes we can drop one branch, I am tempted to always invalidate the whole
cache and be done with it. I will send a new patch anyway.
> > + /* when inlining (and doing constant folding),
> > + * gcc is able to unroll small loops
> > + */
> > + int i;
> > +
> > + for (i = 0; i < invalid_lines; i++) {
> > + __builtin_kvx_dinvall((void *)(addr
> > + + i * K1_DCACHE_LINE_SIZE));
> > + }
> > + } else if (invalid_lines > 0) {
> > + __asm__ __volatile__ (
> > + "loopdo %1, 0f\n;;\n"
> > + "dinvall 0[%0]\n"
> > + "addd %0 = %0, %2\n;;\n"
> > + "0:\n"
> > + : "+r"(addr)
> > + : "r" (invalid_lines),
> > + "i" (K1_DCACHE_LINE_SIZE)
> > + : "ls", "le", "lc", "memory");
> > + }
> > + } else {
> > + __builtin_kvx_dinval();
> > + }
> > +}
> >
>
> --
> Pengutronix e.K. | |
> Steuerwalder Str. 21 | http://www.pengutronix.de/ |
> 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
>
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2021-03-03 20:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-01 15:58 [PATCH 1/5] kvx: Implement setjmp/longjmp/initjmp Jules Maselbas
2021-03-01 15:58 ` [PATCH 2/5] kvx: Implement dcache invalidation primitive Jules Maselbas
2021-03-02 8:40 ` Ahmad Fatoum
2021-03-02 11:44 ` Jules Maselbas [this message]
2021-03-01 15:58 ` [PATCH 3/5] kvx: Implement dma handling primitives Jules Maselbas
2021-03-02 8:37 ` Ahmad Fatoum
2021-03-02 8:44 ` Ahmad Fatoum
2021-03-02 10:14 ` Lucas Stach
2021-03-02 10:58 ` Jules Maselbas
2021-03-03 9:14 ` Lucas Stach
2021-03-03 9:33 ` Yann Sionneau
2021-03-03 9:52 ` Ahmad Fatoum
2021-03-01 15:58 ` [PATCH 4/5] kvx: Request enough privilege to boot Linux Jules Maselbas
2021-03-01 15:58 ` [PATCH 5/5] kvx: lib: dtb: Remove unused variable Jules Maselbas
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=20210302114448.GE9273@tellis.lin.mbt.kalray.eu \
--to=jmaselbas@kalray.eu \
--cc=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=ysionneau@kalray.eu \
/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