aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShengqi Chen <harry-chen@outlook.com>2023-12-06 20:37:50 +0000
committerGitHub <noreply@github.com>2023-12-06 20:37:50 +0000
commit86239a5b9c54e5d34c75446e23c4c88f8defc59f (patch)
tree916e88439db2a2f8e1efe03dd8efba3d536e935d
parent687e4d7f9cadc17a4b8ebb67bc156b7b0a699192 (diff)
-rw-r--r--config/kernel-flush_dcache_page.m45
-rw-r--r--config/kernel.m46
-rw-r--r--include/os/linux/kernel/linux/dcache_compat.h15
3 files changed, 22 insertions, 4 deletions
diff --git a/config/kernel-flush_dcache_page.m4 b/config/kernel-flush_dcache_page.m4
index 2340c386ef57..aa916c87d531 100644
--- a/config/kernel-flush_dcache_page.m4
+++ b/config/kernel-flush_dcache_page.m4
@@ -1,7 +1,8 @@
dnl #
dnl # Starting from Linux 5.13, flush_dcache_page() becomes an inline
-dnl # function and may indirectly referencing GPL-only cpu_feature_keys on
-dnl # powerpc
+dnl # function and may indirectly referencing GPL-only symbols:
+dnl # on powerpc: cpu_feature_keys
+dnl # on riscv: PageHuge (added from 6.2)
dnl #
dnl #
diff --git a/config/kernel.m4 b/config/kernel.m4
index 056517a841f2..d25b65994f6f 100644
--- a/config/kernel.m4
+++ b/config/kernel.m4
@@ -168,6 +168,9 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [
ZFS_AC_KERNEL_SRC_CPU_HAS_FEATURE
ZFS_AC_KERNEL_SRC_FLUSH_DCACHE_PAGE
;;
+ riscv*)
+ ZFS_AC_KERNEL_SRC_FLUSH_DCACHE_PAGE
+ ;;
esac
AC_MSG_CHECKING([for available kernel interfaces])
@@ -310,6 +313,9 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
ZFS_AC_KERNEL_CPU_HAS_FEATURE
ZFS_AC_KERNEL_FLUSH_DCACHE_PAGE
;;
+ riscv*)
+ ZFS_AC_KERNEL_FLUSH_DCACHE_PAGE
+ ;;
esac
])
diff --git a/include/os/linux/kernel/linux/dcache_compat.h b/include/os/linux/kernel/linux/dcache_compat.h
index 1e35204932d1..ab1711b99f3f 100644
--- a/include/os/linux/kernel/linux/dcache_compat.h
+++ b/include/os/linux/kernel/linux/dcache_compat.h
@@ -42,8 +42,8 @@
/*
* Starting from Linux 5.13, flush_dcache_page() becomes an inline function
* and under some configurations, may indirectly referencing GPL-only
- * cpu_feature_keys on powerpc. Override this function when it is detected
- * being GPL-only.
+ * symbols, e.g., cpu_feature_keys on powerpc and PageHuge on riscv.
+ * Override this function when it is detected being GPL-only.
*/
#if defined __powerpc__ && defined HAVE_FLUSH_DCACHE_PAGE_GPL_ONLY
#include <linux/simd_powerpc.h>
@@ -53,6 +53,17 @@
clear_bit(PG_dcache_clean, &(page)->flags); \
} while (0)
#endif
+/*
+ * For riscv implementation, the use of PageHuge can be safely removed.
+ * Because it handles pages allocated by HugeTLB, while flush_dcache_page
+ * in zfs module is only called on kernel pages.
+ */
+#if defined __riscv && defined HAVE_FLUSH_DCACHE_PAGE_GPL_ONLY
+#define flush_dcache_page(page) do { \
+ if (test_bit(PG_dcache_clean, &(page)->flags)) \
+ clear_bit(PG_dcache_clean, &(page)->flags); \
+ } while (0)
+#endif
/*
* 2.6.30 API change,