From nobody Thu Feb 16 11:56:09 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PHYLg12sBz3q5g5; Thu, 16 Feb 2023 11:56:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PHYLf1r0qz49rp; Thu, 16 Feb 2023 11:56:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676548570; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9dzPAOQfNF9fwhtclbEp2aJxr/wonIi41mg2MvYfq8Y=; b=p5i3r+DmOcFBz7vGswyFEl90N5KmMNVz+zGjb8gIeIZ2Or5fv2faAANgaZifLfiBjQsWvE 3nwlUuzVRNMPMe5+fkFW+SmePcCbFQwKavY5LUYuIpkPqWeGbo8UBANMXw35lX0lIRfaDN hYFlben3JROpVIfGi5tla6du9FA8uUvr8m9S6wLeMDTOooRi+g7AqETiXdSE5QpXQEVgmK mCr9mpFlRLPhNxyxebxGdBfqPEp9Xn5wbLuSIegurEf8v9wnB9k9GLwf5bphVieyn1jeEa qw7ntBpMJSuJXEQHBAPY0bqrZNFKF0aXsJDguSutEORvMo7ERR0z1M41FNAoXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676548570; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9dzPAOQfNF9fwhtclbEp2aJxr/wonIi41mg2MvYfq8Y=; b=YXnCo3bUUKuykjqwhtVfQMdKVKYwJIW23vj4UYaaMoc6sTB9eF7l7/L3KV5SsZGopHdiAQ 1n2K6w2niffj+g+WL3n+6JObQhDe3xfD0jVdlCv5zOyI2bp+uNCp98yxPT2zV6578gFQw3 zXzECk6phhuBhLP5SmgXHACrEDOTItX7sqZFNopeZPclwA0PWf8OTFijplaMV1qyaqth9C slTrDbtn6Sg5WX8XdPrx5N5liCmpmvTtCjkb1s1rhQW9z8/kqyzokd7L1v35odZSi+6TxN CdjcZDl6rJoCXn9lwq+A7dJp4aXQzHetCIwsEYspi5hqt4A72ae/KWt2gLfWWA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676548570; a=rsa-sha256; cv=none; b=vz0Gs8gc3enk5YiE6HMBITvK8QWprR3QYle5zcd0g6s5XstMOZYjnYP3lzeEsmBVerFVJj W0uWQs5PsRtzcZzDdz+AkGCkZ/EKhFIOEB12O8X6mcX3n9WFsLz2rGt18BPg78KzDbAT91 N7wmW9LBfEkcNKFJ3t8zoZAVMJFMDpybzr4k/eNlmn1zCL5j1A81iET5hR09lyqxM1hAN2 SFPQQMC4jllkjp3JDZAT8bUmgdEOv6kiTTukcd39IzCTb/unf1lXaZLcU8mEG2HT4fcIUz +C9q8K5u2K7cbFNjACVCm/NVaNLaq+UchFG2fTyIsO0QpPIqBycde0z+AiD4UQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PHYLd2b0Kz137f; Thu, 16 Feb 2023 11:56:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 31GBu9WF055678; Thu, 16 Feb 2023 11:56:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31GBu9sl055677; Thu, 16 Feb 2023 11:56:09 GMT (envelope-from git) Date: Thu, 16 Feb 2023 11:56:09 GMT Message-Id: <202302161156.31GBu9sl055677@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: =?utf-8?Q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Subject: git: 22319e99b799 - stable/13 - linuxkpi: Add `pin_user_pages*()` functions List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dumbbell X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 22319e99b799b792848a0b9da2322b7bc5db8a2e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N 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 AuthorDate: 2023-01-10 10:09:56 +0000 Commit: Jean-Sébastien Pédron 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;