From nobody Fri Jan 27 21:27:49 2023 X-Original-To: dev-commits-src-main@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 4P3VzV0ZkPz3c87v; Fri, 27 Jan 2023 21:27:50 +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 4P3VzT5XpWz4NYV; Fri, 27 Jan 2023 21:27:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674854869; 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=ym4/QkxLjxbX4ia6h3iGn6vxhQxHu4G8dHCzeBLR+J0=; b=ICwhBgI3PLcEhLPGlJ/DeL88SzWwdPzWotak/Tbeqml5aYNyc1vO2PT/4t6P/dmblGOC2q fL01BAjp38PKMK2yxqrRN1vnh1ziQbJ/XkdHV4jl0zSXpXvC/dcnvXsVmXNIXMXkz0l0P6 Cnab7mqmGYH9JtxqJ7liHga2rls/LsLpBiAFRVZFg3Owqf/XmSQMI3Rl4WBaRSU4L+HZ1f Y/V6MgUMCdABxLhwccP0RMmVoitDmknwt9rhicCo17YS1pVcENuiyT0jtq+J88eLJ+mnoc 6muHviwF62iDGE99kpS89j7VUzOXjHvLp9HJgcDQKWFeUBAbvDzxCHOIeLEnLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674854869; 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=ym4/QkxLjxbX4ia6h3iGn6vxhQxHu4G8dHCzeBLR+J0=; b=LpIdvGILtj7lbga6clDXqLTTnm8ZITzzF5hmwDIZSNq2omkUxopFqhg/BrOA8wKKiBPLqd p+dGo1iSwfhhvvQ048/oG4GCjpd+c2fs6Z5hfRguXOggD1WwxJpABpp//pY4kzuygT8gAA EOV8WfkMaPAciXNQEfBSap8Kn4861QVgHqkZIHk9kgkCN3FxjIib3zjLzueSa51rogW/4E IN8/XxvUd2qykxDPVZRoux2cVg98AyLthivd4mLZuoX2X+eIi5gsRUbY9mJVo2IbnCIUXX rkI8dlPzSHCgxTvwO5zl6kddt0kazJYrSVBqdTdXvwVElQjVvespl3CoN3zbsg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674854869; a=rsa-sha256; cv=none; b=kz9hFcQRmYus5JYXIo1XGcf1XZOuxlMRbj6ZCLabSy2tnMCgPnHIOKx0XloBkInkFkl5i9 WbJAerJHRsUBv35bQnxvm7cqJ8rEGJgnyb7dBQOcJn/bLj/QNYRdbEo0r3VNZHEz5tB+tc RGRLg9fMXQdopO9TyrGmXNl2phIAnMRuwH19T5IvwfkH4l4VjGnqLmJHSxcdjGcwGo2gUx lMtCqq0nuD25DbzStp8TgRoLlwn4MqTZgFW7h8nXhLi+bHpM7pViNRuUmJLblDycEp5FcO NIwF9vSlYbP//nEPyKfyZjZg3sCTnFX2QG9szD4HdiPqVlD7iReupBE+oW742Q== 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 4P3VzT4dg5zPW5; Fri, 27 Jan 2023 21:27:49 +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 30RLRnE5000544; Fri, 27 Jan 2023 21:27:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30RLRnP1000543; Fri, 27 Jan 2023 21:27:49 GMT (envelope-from git) Date: Fri, 27 Jan 2023 21:27:49 GMT Message-Id: <202301272127.30RLRnP1000543@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Subject: git: 3d751b7a719f - main - linuxkpi: Add `pin_user_pages*()` functions List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 3d751b7a719fd7934e902a34285ce4e5bbaf1e16 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dumbbell (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=3d751b7a719fd7934e902a34285ce4e5bbaf1e16 commit 3d751b7a719fd7934e902a34285ce4e5bbaf1e16 Author: Jean-Sébastien Pédron AuthorDate: 2023-01-10 10:09:56 +0000 Commit: Jean-Sébastien Pédron CommitDate: 2023-01-27 20:54:39 +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 --- 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 2e0e47f774be..542d0c874b43 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 c4d0d332af14..9b3dac96081f 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;