Re: [PATCH 6/9] drm/tyr: add BO creation and lookup helpers

From: Daniel Almeida

Date: Thu Sep 03 2026 - 18:14:05 EST




> On 1 Sep 2026, at 13:09, Ke Sun via B4 Relay <devnull+sunke.kylinos.cn@xxxxxxxxxx> wrote:
>
> From: Alvin Sun <alvin.sun@xxxxxxxxx>
>
> Add the new_object() and lookup_handle() helpers.
>
> Signed-off-by: Alvin Sun <alvin.sun@xxxxxxxxx>
> ---
> drivers/gpu/drm/tyr/gem.rs | 29 ++++++++++++++++++++++++++++-
> 1 file changed, 28 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/tyr/gem.rs b/drivers/gpu/drm/tyr/gem.rs
> index 3bf3787f5c3fd..be1affe80db1a 100644
> --- a/drivers/gpu/drm/tyr/gem.rs
> +++ b/drivers/gpu/drm/tyr/gem.rs
> @@ -9,9 +9,11 @@
> use kernel::{
> drm::gem::{
> self,
> - shmem, //
> + shmem,
> + BaseObject, //
> },
> prelude::*,
> + sizes::SZ_4K,
> sync::{
> aref::ARef,
> Arc, //
> @@ -23,6 +25,7 @@
> TyrDrmDevice,
> TyrDrmDriver, //
> },
> + file::TyrDrmFile,
> vm::{
> Vm,
> VmMapFlags, //
> @@ -53,6 +56,30 @@ fn new(_dev: &TyrDrmDevice, _size: usize, args: BoCreateArgs) -> impl PinInit<Se
> /// Type alias for Tyr GEM buffer objects.
> pub(crate) type Bo = gem::shmem::Object<BoData>;
>
> +/// Create a new GEM buffer object.
> +pub(crate) fn new_object(ddev: &TyrDrmDevice, size: usize, flags: u32) -> Result<ARef<Bo>> {
> + if size == 0 {
> + return Err(EINVAL);
> + }
> +
> + let aligned_size = size.checked_next_multiple_of(SZ_4K).ok_or(EINVAL)?;

I think this needs to be PAGE_SIZE instead of SZ_4K.

> +
> + Bo::new(
> + ddev,
> + aligned_size,
> + shmem::ObjectConfig {
> + map_wc: true,
> + parent_resv_obj: None,
> + },
> + BoCreateArgs { flags },
> + )
> +}
> +
> +/// Look up a GEM object by handle for a DRM file.
> +pub(crate) fn lookup_handle(file: &TyrDrmFile, handle: u32) -> Result<ARef<Bo>> {
> + Bo::lookup_handle(file, handle)
> +}
> +
> /// Creates a dummy GEM object to serve as the root of a GPUVM.
> pub(crate) fn new_dummy_object(ddev: &TyrDrmDevice) -> Result<ARef<Bo>> {
> let bo = Bo::new(
>
> --
> 2.43.0
>
>