From: sashiko-bot@kernel.org
To: "Janne Grunau" <j@jannau.net>, "Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Sami Tolvanen" <samitolvanen@google.com>,
"Lyude Paul" <lyude@redhat.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>
Cc: dri-devel@lists.freedesktop.org, nova-gpu@lists.linux.dev,
stable+noautosel@kernel.org,
"Deborah Brouwer" <deborah.brouwer@collabora.com>
Subject: Re: [PATCH v3 3/5] rust: drm: gem: shmem: Implement prime_import_sg_table callback
Date: Thu, 03 Dec 2026 10:31:50 +0000 [thread overview]
Message-ID: <sashiko-outbox-247585@kernel.org> (raw)
In-Reply-To: <20261203-rust-drm-gem-shmem-imported-sgt-v3-3-8ca393e83e20@jannau.net>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] rust: drm: shmem: no INVARIANT comment in
prime_import_sg_table_callback()
--
commit 3732704b088a1bef031019801b36e225d905f2b8
Author: Janne Grunau <j@jannau.net>
rust: drm: gem: shmem: Implement prime_import_sg_table callback
This commit implements the gem_prime_import_sg_table callback in Rust for
DRM shmem GEM objects so Object<T> is allocated and destroyed in Rust rather
than C. It also adds DriverObject::create_imported() and implements it for
Nova, Tyr, and the shmem KUnit test driver.
Link: https://lore.kernel.org/rust-for-linux/20261118114102.490384-1-aliceryhl@google.com/ [1]
> diff --git a/rust/kernel/drm/gem/shmem.rs b/rust/kernel/drm/gem/shmem.rs
> index 264ab188f77d4..d6977673e21a9 100644
> --- a/rust/kernel/drm/gem/shmem.rs
> +++ b/rust/kernel/drm/gem/shmem.rs
[ ... ]
> @@ -345,6 +346,67 @@ pub fn new(
> Ok(obj)
> }
>
> + /// Create a new shmem GEM object from another driver's scatter/gather table of pinned pages.
> + ///
> + /// This is a Rust re-implemetation of `drm_gem_shmem_prime_import_sg_table()` to avoid
> + /// creating and destroying `Self` in C code.
> + /// This function imports a scatter/gather table exported via DMA-BUF by another driver.
> + /// It should be only called via the &drm_driver.gem_prime_import_sg_table callback.
> + extern "C" fn prime_import_sg_table_callback(
> + raw_dev: *mut bindings::drm_device,
> + raw_attach: *mut bindings::dma_buf_attachment,
> + raw_sgt: *mut bindings::sg_table,
> + ) -> *mut bindings::drm_gem_object {
[ ... ]
> + let new: Pin<KBox<Self>> = match KBox::try_pin_init(
> + try_pin_init!(Self {
> + obj <- Opaque::init_zeroed(),
> + parent_resv_obj: None,
> + sgt_res: ManuallyDrop::new(SetOnce::new()),
> + sgt_lock <- new_mutex!(()),
> + inner <- T::create_imported(dev, size),
> + }),
> + GFP_KERNEL,
> + ) {
> + Ok(new) => new,
> + Err(e) => return e.to_ptr(),
> + };
> +
> + // SAFETY: `new.as_raw()` is guaranteed to be valid by the initialization above.
> + unsafe { (*new.as_raw()).funcs = &Self::VTABLE };
> +
> + // SAFETY: The arguments are all valid via the type invariants.
> + if let Err(e) = to_result(unsafe {
> + bindings::drm_gem_shmem_init(dev.as_raw(), new.as_raw_shmem(), size, true)
> + }) {
> + return e.to_ptr();
> + };
[Severity: Low]
Should this try_pin_init!(Self { ... }) carry an // INVARIANT: comment?
shmem::Object<T> documents an Invariants section requiring obj to hold a
valid initialized struct drm_gem_shmem_object for its lifetime. Per kernel
Rust coding guidelines, constructing it should explain why that invariant
holds once drm_gem_shmem_init() succeeds before exposing the object.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-rust-drm-gem-shmem-imported-sgt-v3-0-8ca393e83e20@jannau.net?part=3
next prev parent reply other threads:[~2026-12-03 10:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 10:14 [PATCH v3 0/5] Fix import of dma-buf buffers as DRM GEM shmem objects Janne Grunau
2026-12-03 10:14 ` [PATCH v3 1/5] rust: drm: gem: shmem: Do not use drm_gem_shmem_dumb_create() Janne Grunau
2026-12-03 10:14 ` [PATCH v3 2/5] drm/gem/shmem: Initialize private objects via drm_gem_shmem_init() too Janne Grunau
2026-12-03 10:14 ` [PATCH v3 3/5] rust: drm: gem: shmem: Implement prime_import_sg_table callback Janne Grunau
2026-12-03 10:31 ` sashiko-bot [this message]
2026-12-03 10:14 ` [PATCH v3 4/5] rust: drm: gem: add an is_imported() accessor Janne Grunau
2026-12-03 10:14 ` [PATCH v3 5/5] rust: drm: gem: shmem: Do not free SG table of imported objects Janne Grunau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-247585@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=deborah.brouwer@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gary@garyguo.net \
--cc=j@jannau.net \
--cc=lossin@kernel.org \
--cc=lyude@redhat.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=nova-gpu@lists.linux.dev \
--cc=ojeda@kernel.org \
--cc=samitolvanen@google.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=simona@ffwll.ch \
--cc=stable+noautosel@kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=tzimmermann@suse.de \
--cc=work@onurozkan.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox