git: 789dbdbb4857 - main - linuxkpi: Add arch_io_{reserve,free}_memtype_wc

From: Emmanuel Vadot <manu_at_FreeBSD.org>
Date: Mon, 08 Aug 2022 14:04:28 UTC
The branch main has been updated by manu:

URL: https://cgit.FreeBSD.org/src/commit/?id=789dbdbb485749340110be550a03c6df22bc9c9c

commit 789dbdbb485749340110be550a03c6df22bc9c9c
Author:     Emmanuel Vadot <manu@FreeBSD.org>
AuthorDate: 2022-08-02 08:27:00 +0000
Commit:     Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2022-08-08 13:22:36 +0000

    linuxkpi: Add arch_io_{reserve,free}_memtype_wc
    
    Reviewed by:    hselasky
    Obtained from:  drm-kmod
    Sponsored by:   Beckhoff Automation GmbH & Co. KG
    Differential Revision:  https://reviews.freebsd.org/D36022
---
 sys/compat/linuxkpi/common/include/linux/io.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/io.h b/sys/compat/linuxkpi/common/include/linux/io.h
index 0790e518a1a3..32183707c255 100644
--- a/sys/compat/linuxkpi/common/include/linux/io.h
+++ b/sys/compat/linuxkpi/common/include/linux/io.h
@@ -38,6 +38,7 @@
 
 #include <linux/compiler.h>
 #include <linux/types.h>
+#include <asm/set_memory.h>
 
 /*
  * XXX This is all x86 specific.  It should be bus space access.
@@ -494,4 +495,19 @@ void lkpi_arch_phys_wc_del(int);
 #define	arch_phys_wc_index(x)	\
 	(((x) < __MTRR_ID_BASE) ? -1 : ((x) - __MTRR_ID_BASE))
 
+#if defined(__amd64__) || defined(__i386__) || defined(__aarch64__) || defined(__powerpc__) || defined(__riscv)
+static inline int
+arch_io_reserve_memtype_wc(resource_size_t start, resource_size_t size)
+{
+
+	return (set_memory_wc(start, size >> PAGE_SHIFT));
+}
+
+static inline void
+arch_io_free_memtype_wc(resource_size_t start, resource_size_t size)
+{
+	set_memory_wb(start, size >> PAGE_SHIFT);
+}
+#endif
+
 #endif	/* _LINUXKPI_LINUX_IO_H_ */