git: 84fc57a369df - main - linuxkpi: Add more `struct folio`-related functions
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 22 Apr 2026 18:10:18 UTC
The branch main has been updated by dumbbell:
URL: https://cgit.FreeBSD.org/src/commit/?id=84fc57a369dfac882cb9e9333635aaa11978948f
commit 84fc57a369dfac882cb9e9333635aaa11978948f
Author: Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
AuthorDate: 2026-04-11 14:19:39 +0000
Commit: Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
CommitDate: 2026-04-22 18:09:53 +0000
linuxkpi: Add more `struct folio`-related functions
The i915 DRM driver started to replace the use of `struct page` by
`struct folio` in its GEM shmem code in Linux 6.12.
linuxkpi were missing a few more functions: `kmap_local_folio()`,
`memcpy_to_folio()` and `offset_in_folio()`. They are equivalent of
their `struct page` counterparts.
One difference is that `kmap_local_folio()` takes an offset argument and
the returned address takes this offset into account.
Reviewed by: bz
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D56438
---
sys/compat/linuxkpi/common/include/linux/highmem.h | 22 ++++++++++++++++++++++
sys/compat/linuxkpi/common/include/linux/mm.h | 1 +
2 files changed, 23 insertions(+)
diff --git a/sys/compat/linuxkpi/common/include/linux/highmem.h b/sys/compat/linuxkpi/common/include/linux/highmem.h
index dc1c4fe2f299..294b2666031b 100644
--- a/sys/compat/linuxkpi/common/include/linux/highmem.h
+++ b/sys/compat/linuxkpi/common/include/linux/highmem.h
@@ -99,6 +99,19 @@ kmap_local_page(struct page *page)
return (kmap(page));
}
+static inline void *
+kmap_local_folio(struct folio *folio, size_t offset)
+{
+ struct page *page;
+ char *vaddr;
+
+ page = &folio->page;
+ vaddr = kmap_local_page(page);
+ vaddr += offset;
+
+ return (vaddr);
+}
+
static inline void *
kmap_local_page_prot(struct page *page, pgprot_t prot)
{
@@ -168,4 +181,13 @@ memcpy_to_page(struct page *page, size_t offset, const char *from, size_t len)
kunmap_local(to);
}
+static inline void
+memcpy_to_folio(struct folio *folio, size_t offset, const char *from, size_t len)
+{
+ struct page *page;
+
+ page = &folio->page;
+ memcpy_to_page(page, offset, from, len);
+}
+
#endif /* _LINUXKPI_LINUX_HIGHMEM_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/mm.h b/sys/compat/linuxkpi/common/include/linux/mm.h
index 156b00a0c0f0..a639c0947031 100644
--- a/sys/compat/linuxkpi/common/include/linux/mm.h
+++ b/sys/compat/linuxkpi/common/include/linux/mm.h
@@ -264,6 +264,7 @@ vma_pages(struct vm_area_struct *vma)
}
#define offset_in_page(off) ((unsigned long)(off) & (PAGE_SIZE - 1))
+#define offset_in_folio(folio, p) ((unsigned long)(p) & (folio_size(folio) - 1))
static inline void
set_page_dirty(struct page *page)