rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] drm/nova: Align GEM memory allocation to system page size
@ 2025-12-08  7:18 Brendan Shephard
  2025-12-13 14:45 ` kernel test robot
  0 siblings, 1 reply; 2+ messages in thread
From: Brendan Shephard @ 2025-12-08  7:18 UTC (permalink / raw)
  To: aliceryhl, joelagnelf, acourbot, airlied
  Cc: rust-for-linux, nouveau, Brendan Shephard

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>
---
Changes in v2:
- Updated to use the new page_align() Option<usize> return value
- Prerequisite patch:
  https://lore.kernel.org/rust-for-linux/20251204224006.353646-2-bshephar@bne-home.net/T/#u

Changes in v3:
- Add back missing semi-colon after ok_or().
- Reword commit message to be more concise.
- Link to v2: https://lore.kernel.org/rust-for-linux/20251208064405.573026-1-bshephar@bne-home.net/T/#u

 drivers/gpu/drm/nova/gem.rs | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/nova/gem.rs b/drivers/gpu/drm/nova/gem.rs
index 2760ba4f3450..6d715044f1fa 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::page_align,
     prelude::*,
     sync::aref::ARef,
 };
@@ -27,11 +28,7 @@ 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 {
-            return Err(EINVAL);
-        }
+        let aligned_size = page_align(size).ok_or(EINVAL)?;
 
         gem::Object::new(dev, aligned_size)
     }

base-commit: 37bb2e7217b01404e2abf9d90d8e5705a5603b52
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] drm/nova: Align GEM memory allocation to system page size
  2025-12-08  7:18 [PATCH v3] drm/nova: Align GEM memory allocation to system page size Brendan Shephard
@ 2025-12-13 14:45 ` kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2025-12-13 14:45 UTC (permalink / raw)
  To: Brendan Shephard, aliceryhl, joelagnelf, acourbot, airlied
  Cc: llvm, oe-kbuild-all, rust-for-linux, nouveau, Brendan Shephard

Hi Brendan,

kernel test robot noticed the following build errors:

[auto build test ERROR on 37bb2e7217b01404e2abf9d90d8e5705a5603b52]

url:    https://github.com/intel-lab-lkp/linux/commits/Brendan-Shephard/drm-nova-Align-GEM-memory-allocation-to-system-page-size/20251208-153603
base:   37bb2e7217b01404e2abf9d90d8e5705a5603b52
patch link:    https://lore.kernel.org/r/20251208071810.653223-1-bshephar%40bne-home.net
patch subject: [PATCH v3] drm/nova: Align GEM memory allocation to system page size
config: x86_64-buildonly-randconfig-002-20251213 (https://download.01.org/0day-ci/archive/20251213/202512132208.bhsQf8d8-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
rustc: rustc 1.88.0 (6b00bc388 2025-06-23)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251213/202512132208.bhsQf8d8-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202512132208.bhsQf8d8-lkp@intel.com/

All errors (new ones prefixed by >>):

>> error[E0599]: no method named `ok_or` found for type `usize` in the current scope
   --> drivers/gpu/drm/nova/gem.rs:31:45
   |
   31 |         let aligned_size = page_align(size).ok_or(EINVAL)?;
   |                                             ^^^^^ method not found in `usize`

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-12-13 14:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-08  7:18 [PATCH v3] drm/nova: Align GEM memory allocation to system page size Brendan Shephard
2025-12-13 14:45 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).