Skip to content

Clearing/flushing data cache from a kernel module #98

Description

@Juan-Gg

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions