Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metal_dcache routines not accounting for "all" operations #208

Open
TacoGrandeTX opened this issue Dec 17, 2019 · 3 comments
Open

metal_dcache routines not accounting for "all" operations #208

TacoGrandeTX opened this issue Dec 17, 2019 · 3 comments

Comments

@TacoGrandeTX
Copy link

I was trying to use metal_dcache_l1_flush() and metal_dcache_l1_discard() and was taking a trap. While debugging the program, it appears we mishandle the case where we want the entire dcache flushed or discarded. To do the "all" ops, I assume we pass in a 0x0 for the addresss - or how do we indicate the "all" ops?

For the ops that target the entire dcache, we need to use "x0" as the "rs1" operand, not the register holding "address" (which in my testing is picking up register a5). I've added this to the function... no trap is taken but still need to confirm that the cache operation is taking place:

if (!address) {
        /* we flush all dcache by using x0 */
        __asm__ __volatile__ (".insn i 0x73, 0, x0, x0, -0x40" : : );
        __asm__ __volatile__ ("fence.i");         // FENCE
    }
else... 
@bsousi5
Copy link
Collaborator

bsousi5 commented Dec 18, 2019 via email

@TacoGrandeTX
Copy link
Author

Hi Bunnaroath,

So using another register like a5 with its content with address of 0x0, should do the same job.

That's not what the instruction description states from the Core Manuals:
• When rs1 = x0, CFLUSH.D.L1 writes back and invalidates all lines in the L1 D$.
• When rs1 != x0, CFLUSH.D.L1 writes back and invalidates the L1 D$ line containing the
virtual address in integer register rs1.

If we aren't using x0 as the rs1 operand, then we're getting the single line operation. In the case of passing 0x0 as the argument, we're then flushing/invalidating only the line at address 0x0.

@TacoGrandeTX
Copy link
Author

TacoGrandeTX commented Feb 28, 2020

@bsousi5 Do you plan on fixing this before the 19.08p3 release? Last month I thought you said you made a PR, but not seeing it.

bsousi5 pushed a commit that referenced this issue Apr 8, 2020
Add missing READMEs to software examples
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants