mirror of
https://github.com/torvalds/linux.git
synced 2026-05-27 16:44:58 +02:00
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>
This commit is contained in:
parent
f91ffed95c
commit
255153afbc
|
|
@ -3,6 +3,7 @@
|
|||
use kernel::{
|
||||
drm,
|
||||
drm::{gem, gem::BaseObject},
|
||||
page,
|
||||
prelude::*,
|
||||
sync::aref::ARef,
|
||||
};
|
||||
|
|
@ -27,11 +28,10 @@ fn new(_dev: &NovaDevice, _size: usize) -> impl PinInit<Self, Error> {
|
|||
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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user