From 90f7cf5411932c0c643fd98f5a5041e004d6964d Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Wed, 2 Dec 2026 11:12:41 +0100 Subject: [PATCH] drm/asahi: g17: copy and prepare VM_BIND batches in kvmalloc memory vm_bind_g17() copies the user's array of bind operations into a KVec and prepares every operation into a PreparedUserBindBatch whose KVec has room for all of them, 160 bytes an operation on arm64. Both are kmalloc'ed, so physically contiguous. A batch of about 210,000 operations or more asks kmalloc for more than 32 MiB: the page allocator warns (mm/page_alloc.c, __alloc_frozen_pages_noprof), VM_BIND fails with ENOMEM and Borealis reports a lost device. One vkQueueBindSparse of 100,000 blocks of a sparse image is enough, since Borealis binds each 64 KiB block as two 32 KiB halves, each with its read-only shadow. Neither buffer needs to be physically contiguous. Use KVVec, which falls back to vmalloc, for both. Signed-off-by: Jos Dehaes --- drivers/gpu/drm/asahi/file.rs | 2 +- drivers/gpu/drm/asahi/mmu/bind.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/asahi/file.rs b/drivers/gpu/drm/asahi/file.rs index 37387915a9e7a..ca49c68f614ea 100644 --- a/drivers/gpu/drm/asahi/file.rs +++ b/drivers/gpu/drm/asahi/file.rs @@ -1233,7 +1233,7 @@ impl File { let count = usize::try_from(data.num_binds)?; let stride = usize::try_from(data.stride)?; let size = stride.checked_mul(count).ok_or(EOVERFLOW)?; - let mut bytes = KVec::new(); + let mut bytes = KVVec::new(); UserSlice::new(UserPtr::from_addr(data.userptr as usize), size) .reader() .read_all(&mut bytes, GFP_KERNEL)?; diff --git a/drivers/gpu/drm/asahi/mmu/bind.rs b/drivers/gpu/drm/asahi/mmu/bind.rs index 84f7d0fcd8127..0cfe69fa76934 100644 --- a/drivers/gpu/drm/asahi/mmu/bind.rs +++ b/drivers/gpu/drm/asahi/mmu/bind.rs @@ -44,14 +44,14 @@ pub(super) enum PreparedUserBindOp { /// then reclaims them itself, on every path. pub(crate) struct PreparedUserBindBatch<'a> { vm: &'a Vm, - pub(super) ops: KVec, + pub(super) ops: KVVec, } impl<'a> PreparedUserBindBatch<'a> { pub(crate) fn new(vm: &'a Vm, capacity: usize) -> Result { Ok(Self { vm, - ops: KVec::with_capacity(capacity, GFP_KERNEL)?, + ops: KVVec::with_capacity(capacity, GFP_KERNEL)?, }) } pub(crate) fn push_map(&mut self, map: PreparedUserMap) -> Result {