Skip to content
New issue

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

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

Already on GitHub? # to your account

Clearing/flushing data cache from a kernel module #98

Open
Juan-Gg opened this issue Jun 28, 2024 · 0 comments
Open

Clearing/flushing data cache from a kernel module #98

Juan-Gg opened this issue Jun 28, 2024 · 0 comments

Comments

@Juan-Gg
Copy link

Juan-Gg commented Jun 28, 2024

I have implemented a DMA-like accelerator, and I am in the process of writing a kernel driver to control it from user space.

I need to clear the processor's cache so my user process does not read outdated data. When I previously tested my accelerator with a bare-metal program, I used the following macro:

#define FLUSH_D_CACHE() ({__asm__ volatile("csrwi 0x7C1, 0x00"); \
 __asm__ volatile("csrwi 0x7C1, 0x01");})

But it uses machine-level CSRs, which of course causes an illegal instruction exception when ran inside a kernel module.

How can I do this? According to this, support for cache clearing is limited.

If the software route does not work out, I suppose there is a way to flush the data cache in hardware. I could maybe route a signal from my accelerator to the cache subsystem that forces a cache flush. Any ideas?

@Juan-Gg Juan-Gg changed the title Clearing data cache from a kernel module Clearing/flushing data cache from a kernel module Jun 28, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant