summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Burnicki <martin.burnicki@meinberg.de>2023-05-04 16:29:46 +0200
committerMartin Burnicki <martin.burnicki@meinberg.de>2023-05-04 16:29:46 +0200
commitf47f1dcd05ec15ed9e91f3aaca9484cb2d32951b (patch)
treeaf3dfc9d8baf0cc1256d37203e41c77548839aca
parent41fe0058cd3529e5b7449c6fc2235812d87a621c (diff)
downloadmbgtools-lx-f47f1dcd05ec15ed9e91f3aaca9484cb2d32951b.tar.gz
mbgtools-lx-f47f1dcd05ec15ed9e91f3aaca9484cb2d32951b.zip
Fix build on kernel 6.3 and newer
Commit bc292ab00f6c of the kernel source introduced vma->vm_flags wrapper functions to avoid race conditions when the flags are updated. See the discussion at https://lore.kernel.org/lkml/ZA7x9y60sfGOanHl@kroah.com/T/ These wrapper functions first appeared in v6.3-rc1~113^2~116.
-rw-r--r--mbgclock/mbgclock_main.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/mbgclock/mbgclock_main.c b/mbgclock/mbgclock_main.c
index c2977b4..1b044ae 100644
--- a/mbgclock/mbgclock_main.c
+++ b/mbgclock/mbgclock_main.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgclock_main.c 1.42 2022/07/25 16:41:59 martin.burnicki REL_M $
+ * $Id: mbgclock_main.c 1.43 2023/05/04 14:27:54 martin REL_M $
*
* Description:
* Main file for the mbgclock driver for Linux which allows access to
@@ -12,6 +12,8 @@
*
* -----------------------------------------------------------------------
* $Log: mbgclock_main.c $
+ * Revision 1.43 2023/05/04 14:27:54 martin
+ * Fixed build for kernel 6.3 and newer.
* Revision 1.42 2022/07/25 16:41:59 martin.burnicki
* Support getting full version string from git.
* Revision 1.41 2022/01/21 18:09:36 martin.burnicki
@@ -252,6 +254,18 @@
#endif
+// Commit bc292ab00f6c of the kernel source introduced
+// vma->vm_flags wrapper functions to avoid race conditions
+// when the flags are updated. See the discussion at
+// https://lore.kernel.org/lkml/ZA7x9y60sfGOanHl@kroah.com/T/
+// These wrapper functions first appeared in v6.3-rc1~113^2~116.
+
+#if ( LINUX_VERSION_CODE >= KERNEL_VERSION( 6, 3, 0 ) )
+ #define HAVE_VMA_VM_FLAGS_WRAPPER_FUNCTIONS 1
+#else
+ #define HAVE_VMA_VM_FLAGS_WRAPPER_FUNCTIONS 0
+#endif
+
// The 'struct file_operations' contains the fields 'unlocked_ioctl' and 'compat_ioctl'
// since kernel ~2.6.11, and the symbols HAVE_UNLOCKED_IOCTL and HAVE_COMPAT_IOCTL
@@ -1936,7 +1950,11 @@ int mbgclock_mmap( struct file * filp, struct vm_area_struct *vma )
vma->vm_end, vma->vm_start, (unsigned long) PAGE_SIZE );
#endif
- vma->vm_flags |= VM_IO;
+ #if HAVE_VMA_VM_FLAGS_WRAPPER_FUNCTIONS
+ vm_flags_set( vma, VM_IO );
+ #else
+ vma->vm_flags |= VM_IO;
+ #endif
#if defined( pgprot_noncached )
vma->vm_page_prot = pgprot_noncached( vma->vm_page_prot );