diff options
| author | Brendan Shephard <bshephar@bne-home.net> | 2025-12-15 18:34:16 +1000 |
|---|---|---|
| committer | Danilo Krummrich <dakr@kernel.org> | 2025-12-29 15:43:20 +0100 |
| commit | 255153afbcfdcf30d20048fb76a6d9418537b5d9 (patch) | |
| tree | 9b1fffaa9a90c7d77fd1714694228ff0c5a77b9a /drivers/gpu | |
| parent | f91ffed95c06e94c835cd7deaea666d69948cde9 (diff) | |
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<usize> for overflow safety. (See "rust: Return Option from
page_align and ensure no usize overflow").
Signed-off-by: Brendan Shephard <bshephar@bne-home.net>
Link: https://patch.msgid.link/20251215083416.266469-1-bshephar@bne-home.net
[ Import page module only. - Danilo ]
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'drivers/gpu')
| -rw-r--r-- | drivers/gpu/drm/nova/gem.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/gpu/drm/nova/gem.rs b/drivers/gpu/drm/nova/gem.rs index 2760ba4f3450..6ccfa5da5761 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<ARef<gem::Object<Self>>> { - 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) } |
