> On 28 Sep 2026, at 23:15, Ke Sun via B4 Relay > <[email protected]> wrote: > > From: Alvin Sun <[email protected]> > > Add helpers for the BO ioctls: new_object() creates a GEM object with > the size aligned up to PAGE_SIZE, and lookup_handle() resolves a handle > for a DRM file. > > Signed-off-by: Alvin Sun <[email protected]> > --- > drivers/gpu/drm/tyr/gem.rs | 31 ++++++++++++++++++++++++++++++- > 1 file changed, 30 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/tyr/gem.rs b/drivers/gpu/drm/tyr/gem.rs > index 3bf3787f5c3fd..0e0989a48678f 100644 > --- a/drivers/gpu/drm/tyr/gem.rs > +++ b/drivers/gpu/drm/tyr/gem.rs > @@ -9,8 +9,10 @@ > use kernel::{ > drm::gem::{ > self, > - shmem, // > + shmem, > + BaseObject, // > }, > + page::PAGE_SIZE, > prelude::*, > sync::{ > aref::ARef, > @@ -23,6 +25,7 @@ > TyrDrmDevice, > TyrDrmDriver, // > }, > + file::TyrDrmFile, > vm::{ > Vm, > VmMapFlags, // > @@ -53,6 +56,32 @@ 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. > +#[expect(dead_code)] > +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(PAGE_SIZE).ok_or(EINVAL)?; > + > + 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. > +#[expect(dead_code)] > +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 > > > Reviewed-by: Daniel Almeida <[email protected]>
