The branch main has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=a5c7b44d6a46fc5a67a79cb9b31050a9cc7c50ce

commit a5c7b44d6a46fc5a67a79cb9b31050a9cc7c50ce
Author:     Bjoern A. Zeeb <b...@freebsd.org>
AuthorDate: 2024-09-12 21:17:51 +0000
Commit:     Bjoern A. Zeeb <b...@freebsd.org>
CommitDate: 2025-03-14 16:24:52 +0000

    LinuxKPI: always use contig allocations in linux_alloc_kmem()
    
    In linux_alloc_kmem() [used by *get_page*()] we always at least allocate
    PAGE_SIZE and we want the allocation to be contiguous so it can be passed
    to DMA.  Always use kmem_alloc_contig() and only change the low argument
    depending on the GFP_DMA32 flag being given or not.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      3 days
    Reviewed by:    jhb, dumbbell
    Differential Revision: https://reviews.freebsd.org/D46661
---
 sys/compat/linuxkpi/common/src/linux_page.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_page.c 
b/sys/compat/linuxkpi/common/src/linux_page.c
index 6ca926e89174..bece8c954bfd 100644
--- a/sys/compat/linuxkpi/common/src/linux_page.c
+++ b/sys/compat/linuxkpi/common/src/linux_page.c
@@ -182,12 +182,10 @@ linux_alloc_kmem(gfp_t flags, unsigned int order)
        size_t size = ((size_t)PAGE_SIZE) << order;
        void *addr;
 
-       if ((flags & GFP_DMA32) == 0) {
-               addr = kmem_malloc(size, flags & GFP_NATIVE_MASK);
-       } else {
-               addr = kmem_alloc_contig(size, flags & GFP_NATIVE_MASK, 0,
-                   BUS_SPACE_MAXADDR_32BIT, PAGE_SIZE, 0, VM_MEMATTR_DEFAULT);
-       }
+       addr = kmem_alloc_contig(size, flags & GFP_NATIVE_MASK, 0,
+           ((flags & GFP_DMA32) == 0) ? -1UL : BUS_SPACE_MAXADDR_32BIT,
+           PAGE_SIZE, 0, VM_MEMATTR_DEFAULT);
+
        return ((vm_offset_t)addr);
 }
 

Reply via email to