drm/linux: Add invalidate_mapping_pages()
authorFrançois Tigeot <ftigeot@wolfpond.org>
Mon, 7 Jan 2019 19:44:57 +0000 (20:44 +0100)
committerFrançois Tigeot <ftigeot@wolfpond.org>
Mon, 7 Jan 2019 19:44:57 +0000 (20:44 +0100)
Inspired-by: FreeBSD
sys/dev/drm/include/linux/fs.h
sys/dev/drm/include/linux/types.h

index a454f4d..cf88372 100644 (file)
@@ -63,4 +63,18 @@ struct file_operations {
 
 extern loff_t noop_llseek(struct file *file, loff_t offset, int whence);
 
+static inline unsigned long
+invalidate_mapping_pages(struct vm_object *obj, pgoff_t start, pgoff_t end)
+{
+       int start_count, end_count, clean_only = 1;
+
+       VM_OBJECT_LOCK(obj);
+       start_count = obj->resident_page_count;
+       /* Only non-dirty pages must be freed or invalidated */
+       vm_object_page_remove(obj, start, end, clean_only);
+       end_count = obj->resident_page_count;
+       VM_OBJECT_UNLOCK(obj);
+       return (start_count - end_count);
+}
+
 #endif /* _LINUX_FS_H_ */
index 5b93f7b..036dea7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015-2018 François Tigeot <ftigeot@wolfpond.org>
+ * Copyright (c) 2015-2019 François Tigeot <ftigeot@wolfpond.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -45,4 +45,6 @@ typedef _Bool bool;
 
 typedef unsigned short umode_t;
 
+typedef unsigned long pgoff_t;
+
 #endif /* _LINUX_TYPES_H_ */