From 255153afbcfdcf30d20048fb76a6d9418537b5d9 Mon Sep 17 00:00:00 2001 From: Brendan Shephard Date: Mon, 15 Dec 2025 18:34:16 +1000 Subject: [PATCH] drm/nova: Align GEM memory allocation to system page size Use page::page_align for GEM object memory allocation to ensure the allocation is page aligned. This is important on systems where the default page size is not 4k. Such as 16k or 64k aarch64 systems. This change uses the updated page_align() function which returns Option for overflow safety. (See "rust: Return Option from page_align and ensure no usize overflow"). Signed-off-by: Brendan Shephard Link: https://patch.msgid.link/20251215083416.266469-1-bshephar@bne-home.net [ Import page module only. - Danilo ] Signed-off-by: Danilo Krummrich --- drivers/gpu/drm/nova/gem.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/nova/gem.rs b/drivers/gpu/drm/nova/gem.rs index 2760ba4f3450b..6ccfa5da57617 100644 --- a/drivers/gpu/drm/nova/gem.rs +++ b/drivers/gpu/drm/nova/gem.rs @@ -3,6 +3,7 @@ use kernel::{ drm, drm::{gem, gem::BaseObject}, + page, prelude::*, sync::aref::ARef, }; @@ -27,11 +28,10 @@ impl gem::DriverObject for NovaObject { impl NovaObject { /// Create a new DRM GEM object. pub(crate) fn new(dev: &NovaDevice, size: usize) -> Result>> { - let aligned_size = size.next_multiple_of(1 << 12); - - if size == 0 || size > aligned_size { + if size == 0 { return Err(EINVAL); } + let aligned_size = page::page_align(size).ok_or(EINVAL)?; gem::Object::new(dev, aligned_size) } -- 2.47.3