Refactor to patch

This commit is contained in:
Zhengyi Chen 2024-01-25 21:37:16 +00:00
parent 3d1f979266
commit 20891fd58e
2 changed files with 48 additions and 3 deletions

View file

@ -1,6 +1,5 @@
// [TODO] Clean up headers...
// #include <asm/cacheflush.h>
#include <asm/cacheflush.h>
#include "linux/atomic/atomic-long.h"
#include <linux/device.h>
#include "linux/gfp.h"
@ -20,6 +19,8 @@
#include <linux/kernel.h>
#include <linux/version.h>
#include <asm/cacheflush_extra.h>
MODULE_AUTHOR("Zk.");
MODULE_DESCRIPTION("4.2.W1: mmap for point of coherency");
MODULE_LICENSE("GPL");
@ -59,7 +60,7 @@ static void my_shmem_vmops_close(struct vm_area_struct *vma)
__func__, page_address(pg), *(ulong *)(page_address(pg)),
sizeof(ulong));
// [!!] `dcache_clean_poc` seems not exported.
dcache_clean_poc(vaddr_start, vaddr_start + PAGE_SIZE);
__dcache_clean_poc(vaddr_start, vaddr_start + PAGE_SIZE);
pr_info("[%s] After flush: 0x%px has 0x%lx [+%ld].\n",
__func__, page_address(pg), *(ulong *)(page_address(pg)),
sizeof(ulong));

View file

@ -0,0 +1,44 @@
diff --git a/arch/arm64/include/asm/cacheflush_extra.h b/arch/arm64/include/asm/cacheflush_extra.h
new file mode 100644
index 000000000000..d989e93ff01a
--- /dev/null
+++ b/arch/arm64/include/asm/cacheflush_extra.h
@@ -0,0 +1,11 @@
+/*
+ * Get dcache_clean|inval_poc out to driverland!
+ */
+
+#ifndef __ASM_CACHEFLUSH_EX_H
+#define __ASM_CACHEFLUSH_EX_H
+
+/* Ref. cacheflush.h */
+extern void __dcache_clean_poc(unsigned long start, unsigned long end);
+
+#endif /* __ASM_CACHEFLUSH_EX_H */
\ No newline at end of file
diff --git a/arch/arm64/mm/flush.c b/arch/arm64/mm/flush.c
index 013eead9b695..d9bb343d4b5e 100644
--- a/arch/arm64/mm/flush.c
+++ b/arch/arm64/mm/flush.c
@@ -15,6 +15,8 @@
#include <asm/cache.h>
#include <asm/tlbflush.h>
+#include <asm/cacheflush_extra.h>
+
void sync_icache_aliases(unsigned long start, unsigned long end)
{
if (icache_is_aliasing()) {
@@ -62,6 +64,12 @@ void __sync_icache_dcache(pte_t pte)
}
EXPORT_SYMBOL_GPL(__sync_icache_dcache);
+void __dcache_clean_poc(ulong start, ulong end)
+{
+ dcache_clean_poc(start, end);
+}
+EXPORT_SYMBOL(__dcache_clean_poc);
+
/*
* This function is called when a page has been modified by the kernel. Mark
* it as dirty for later flushing when mapped in user space (if executable,