diff options
| author | Ben Zong-You Xie <[email protected]> | 2025-12-29 15:19:12 +0800 |
|---|---|---|
| committer | Anup Patel <[email protected]> | 2026-02-11 12:11:06 +0530 |
| commit | 6d26b43c477a7616d1f030261430127fa6c61d27 (patch) | |
| tree | 14172ff1a148fbfc4f987b62ff3125b97c0cf806 /lib/utils/cache | |
| parent | 85bff9cc163e05130899264eb6e963fc582de117 (diff) | |
lib: utils/cache: add cache enable function
Add functions to enable/disable the cache.
Signed-off-by: Ben Zong-You Xie <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Anup Patel <[email protected]>
Diffstat (limited to 'lib/utils/cache')
| -rw-r--r-- | lib/utils/cache/cache.c | 11 | ||||
| -rw-r--r-- | lib/utils/cache/fdt_cmo_helper.c | 23 |
2 files changed, 34 insertions, 0 deletions
diff --git a/lib/utils/cache/cache.c b/lib/utils/cache/cache.c index 6bc3d10e..2810d5e9 100644 --- a/lib/utils/cache/cache.c +++ b/lib/utils/cache/cache.c @@ -44,3 +44,14 @@ int cache_flush_all(struct cache_device *dev) return dev->ops->cache_flush_all(dev); } + +int cache_enable(struct cache_device *dev, bool enable) +{ + if (!dev) + return SBI_ENODEV; + + if (!dev->ops || !dev->ops->cache_enable) + return SBI_ENOTSUPP; + + return dev->ops->cache_enable(dev, enable); +} diff --git a/lib/utils/cache/fdt_cmo_helper.c b/lib/utils/cache/fdt_cmo_helper.c index d87bab76..3ab8abe6 100644 --- a/lib/utils/cache/fdt_cmo_helper.c +++ b/lib/utils/cache/fdt_cmo_helper.c @@ -41,6 +41,29 @@ int fdt_cmo_llc_flush_all(void) return cache_flush_all(llc); } +int fdt_cmo_private_flc_enable(bool enable) +{ + struct cache_device *flc = get_hart_flc(sbi_scratch_thishart_ptr()); + + if (!flc || !flc->cpu_private) + return SBI_ENODEV; + + return cache_enable(flc, enable); +} + +int fdt_cmo_llc_enable(bool enable) +{ + struct cache_device *llc = get_hart_flc(sbi_scratch_thishart_ptr()); + + if (!llc) + return SBI_ENODEV; + + while (llc->next) + llc = llc->next; + + return cache_enable(llc, enable); +} + static int fdt_cmo_cold_init(const void *fdt) { struct sbi_scratch *scratch; |
