git: 22319e99b799 - stable/13 - linuxkpi: Add `pin_user_pages*()` functions
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 16 Feb 2023 11:56:09 UTC
The branch stable/13 has been updated by dumbbell (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=22319e99b799b792848a0b9da2322b7bc5db8a2e commit 22319e99b799b792848a0b9da2322b7bc5db8a2e Author: Jean-Sébastien Pédron <dumbbell@FreeBSD.org> AuthorDate: 2023-01-10 10:09:56 +0000 Commit: Jean-Sébastien Pédron <dumbbell@FreeBSD.org> CommitDate: 2023-02-16 11:55:16 +0000 linuxkpi: Add `pin_user_pages*()` functions They were defined in the i915 DRM driver. I move the code in linuxkpi so it can benefit other drivers. Reviewed by: manu Approved by: manu Differential Revision: https://reviews.freebsd.org/D38078 (cherry picked from commit 3d751b7a719fd7934e902a34285ce4e5bbaf1e16) --- sys/compat/linuxkpi/common/include/linux/mm.h | 33 +++++++++++++++++++++++++-- sys/compat/linuxkpi/common/src/linux_page.c | 6 ++--- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/mm.h b/sys/compat/linuxkpi/common/include/linux/mm.h index 8f5b543e1002..43d1cb0f8aad 100644 --- a/sys/compat/linuxkpi/common/include/linux/mm.h +++ b/sys/compat/linuxkpi/common/include/linux/mm.h @@ -257,25 +257,54 @@ get_page(struct vm_page *page) extern long get_user_pages(unsigned long start, unsigned long nr_pages, - int gup_flags, struct page **, + unsigned int gup_flags, struct page **, struct vm_area_struct **); +static inline long +pin_user_pages(unsigned long start, unsigned long nr_pages, + unsigned int gup_flags, struct page **pages, + struct vm_area_struct **vmas) +{ + return get_user_pages(start, nr_pages, gup_flags, pages, vmas); +} + extern int __get_user_pages_fast(unsigned long start, int nr_pages, int write, struct page **); +static inline int +pin_user_pages_fast(unsigned long start, int nr_pages, + unsigned int gup_flags, struct page **pages) +{ + return __get_user_pages_fast( + start, nr_pages, !!(gup_flags & FOLL_WRITE), pages); +} + extern long get_user_pages_remote(struct task_struct *, struct mm_struct *, unsigned long start, unsigned long nr_pages, - int gup_flags, struct page **, + unsigned int gup_flags, struct page **, struct vm_area_struct **); +static inline long +pin_user_pages_remote(struct task_struct *task, struct mm_struct *mm, + unsigned long start, unsigned long nr_pages, + unsigned int gup_flags, struct page **pages, + struct vm_area_struct **vmas) +{ + return get_user_pages_remote( + task, mm, start, nr_pages, gup_flags, pages, vmas); +} + static inline void put_page(struct vm_page *page) { vm_page_unwire(page, PQ_ACTIVE); } +#define unpin_user_page(page) put_page(page) +#define unpin_user_pages(pages, npages) release_pages(pages, npages) + #define copy_highpage(to, from) pmap_copy_page(from, to) static inline pgprot_t diff --git a/sys/compat/linuxkpi/common/src/linux_page.c b/sys/compat/linuxkpi/common/src/linux_page.c index 8b2006668f8f..10172d341e95 100644 --- a/sys/compat/linuxkpi/common/src/linux_page.c +++ b/sys/compat/linuxkpi/common/src/linux_page.c @@ -249,7 +249,7 @@ __get_user_pages_fast(unsigned long start, int nr_pages, int write, long get_user_pages_remote(struct task_struct *task, struct mm_struct *mm, - unsigned long start, unsigned long nr_pages, int gup_flags, + unsigned long start, unsigned long nr_pages, unsigned int gup_flags, struct page **pages, struct vm_area_struct **vmas) { vm_map_t map; @@ -260,8 +260,8 @@ get_user_pages_remote(struct task_struct *task, struct mm_struct *mm, } long -get_user_pages(unsigned long start, unsigned long nr_pages, int gup_flags, - struct page **pages, struct vm_area_struct **vmas) +get_user_pages(unsigned long start, unsigned long nr_pages, + unsigned int gup_flags, struct page **pages, struct vm_area_struct **vmas) { vm_map_t map;