git: fe13793bb442 - releng/14.1 - linuxkpi: Make arch_io_*_memtype_wc amd64-only

From: Tijl Coosemans <tijl_at_FreeBSD.org>
Date: Sun, 12 May 2024 15:58:02 UTC
The branch releng/14.1 has been updated by tijl:

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

commit fe13793bb44212607c231a9c793de05aea74dc7b
Author:     Tijl Coosemans <tijl@FreeBSD.org>
AuthorDate: 2024-05-08 18:49:56 +0000
Commit:     Tijl Coosemans <tijl@FreeBSD.org>
CommitDate: 2024-05-12 15:56:55 +0000

    linuxkpi: Make arch_io_*_memtype_wc amd64-only
    
    Linux only implements these functions on x86.  They return 0 on other
    architectures.  The FreeBSD implementation calls PHYS_TO_DMAP but this
    panics on i386 because it does not have a direct map so return 0 on i386
    as well for now.  These functions are only used by graphics/drm-*-kmod
    to mark the VRAM aperture write-combining but this is also accomplished
    by a call to vm_phys_fictitious_reg_range so this change is sufficient
    to fix drm-*-kmod on i386 for FreeBSD 14.1.
    
    Reviewed by:    kib
    Approved by:    re (cperciva)
    Differential Revision:  https://reviews.freebsd.org/D45125
    
    (cherry picked from commit 2ae0f5a4d0931067c672be9a791909f0e32d5a0e)
    (cherry picked from commit 2d97bd0639cd0af43b7beb6f45ef15bcf110db57)
---
 sys/compat/linuxkpi/common/include/linux/io.h | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/io.h b/sys/compat/linuxkpi/common/include/linux/io.h
index bce70ed0cb8d..164347dbc4e7 100644
--- a/sys/compat/linuxkpi/common/include/linux/io.h
+++ b/sys/compat/linuxkpi/common/include/linux/io.h
@@ -541,30 +541,29 @@ 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)
 {
+#if defined(__amd64__)
 	vm_offset_t va;
 
 	va = PHYS_TO_DMAP(start);
-
-#ifdef VM_MEMATTR_WRITE_COMBINING
 	return (-pmap_change_attr(va, size, VM_MEMATTR_WRITE_COMBINING));
 #else
-	return (-pmap_change_attr(va, size, VM_MEMATTR_UNCACHEABLE));
+	return (0);
 #endif
 }
 
 static inline void
 arch_io_free_memtype_wc(resource_size_t start, resource_size_t size)
 {
+#if defined(__amd64__)
 	vm_offset_t va;
 
 	va = PHYS_TO_DMAP(start);
 
 	pmap_change_attr(va, size, VM_MEMATTR_WRITE_BACK);
-}
 #endif
+}
 
 #endif	/* _LINUXKPI_LINUX_IO_H_ */