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
This commit is contained in:
Jean-Sébastien Pédron 2023-01-10 11:09:56 +01:00
parent 3e0856b63f
commit 3d751b7a71
No known key found for this signature in database
GPG Key ID: 39E99761A5FD94CC
2 changed files with 34 additions and 5 deletions

View File

@ -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

View File

@ -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;