dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Lyude Paul" <lyude@redhat.com>
Cc: dri-devel@lists.freedesktop.org, ojeda@kernel.org
Subject: Re: [PATCH v19 1/4] rust: drm: gem: shmem: Add DmaResvGuard helper
Date: Mon, 08 Jun 2026 18:43:28 +0000	[thread overview]
Message-ID: <20260608184329.0BF6C1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260608183057.2001376-2-lyude@redhat.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Incorrect use of `#[inline(always)]` instead of `#[inline]` for abstraction methods.
--

commit 35068fc880d5bd0d2870750a321a6b8155d32ae4
Author: Lyude Paul <lyude@redhat.com>

rust: drm: gem: shmem: Add DmaResvGuard helper

This commit adds a temporary DmaResvGuard helper type for managing the
dma_resv lock on GEM shmem objects. It implements a drop handler to
automatically release the lock.

> diff --git a/rust/kernel/drm/gem/shmem.rs b/rust/kernel/drm/gem/shmem.rs
> index 34af402899a0e..79ebd746e9611 100644
> --- a/rust/kernel/drm/gem/shmem.rs
> +++ b/rust/kernel/drm/gem/shmem.rs

[ ... ]

> @@ -235,3 +241,32 @@ impl<T: DriverObject, C: DeviceContext> driver::AllocImpl for Object<T, C> {
>          dumb_map_offset: None,
>      };
>  }
> +
> +/// Private helper-type for holding the `dma_resv` object for a GEM shmem object.
> +///
> +/// When this is dropped, the `dma_resv` lock is dropped as well.
> +///
> +// TODO: This should be replace with a WwMutex equivalent once we have such bindings in the kernel.
> +struct DmaResvGuard<'a, T: DriverObject, C: DeviceContext = Registered>(
> +    &'a Object<T, C>,
> +    NotThreadSafe,
> +);
> +
> +impl<'a, T: DriverObject, C: DeviceContext> DmaResvGuard<'a, T, C> {
> +    #[inline(always)]

[Severity: Low]
This isn't a bug, but should this use #[inline] instead of #[inline(always)]?

According to the Rust subsystem guidelines, #[inline(always)] should be
reserved for functions using build_assert!() that depend on function
parameters. For small abstraction functions that simply forward to binding
calls like this one, #[inline] is the correct annotation.

> +    #[expect(unused)]
> +    fn new(obj: &'a Object<T, C>) -> Self {
> +        // SAFETY: This lock is initialized throughout the lifetime of `object`.
> +        unsafe { bindings::dma_resv_lock(obj.raw_dma_resv(), ptr::null_mut()) };
> +
> +        Self(obj, NotThreadSafe)
> +    }
> +}
> +
> +impl<'a, T: DriverObject, C: DeviceContext> Drop for DmaResvGuard<'a, T, C> {
> +    #[inline(always)]

[Severity: Low]
This isn't a bug, but could this drop method also use #[inline] instead of
#[inline(always)] for the same reason mentioned above?

> +    fn drop(&mut self) {
> +        // SAFETY: We are releasing the lock grabbed during the creation of this object.
> +        unsafe { bindings::dma_resv_unlock(self.0.raw_dma_resv()) };
> +    }
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260608183057.2001376-1-lyude@redhat.com?part=1

  reply	other threads:[~2026-06-08 18:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-08 18:29 [PATCH v19 0/4] Rust bindings for gem shmem Lyude Paul
2026-06-08 18:29 ` [PATCH v19 1/4] rust: drm: gem: shmem: Add DmaResvGuard helper Lyude Paul
2026-06-08 18:43   ` sashiko-bot [this message]
2026-06-09 18:19     ` lyude
2026-06-09 19:28       ` Miguel Ojeda
2026-06-08 18:29 ` [PATCH v19 2/4] rust: drm: gem: shmem: Add vmap functions Lyude Paul
2026-06-08 18:45   ` sashiko-bot
2026-06-08 18:29 ` [PATCH v19 3/4] rust: faux: Allow retrieving a bound Device Lyude Paul
2026-06-08 18:41   ` sashiko-bot
2026-06-08 18:29 ` [PATCH v19 4/4] rust: drm: gem: Introduce shmem::Object::sg_table() Lyude Paul
2026-06-08 18:48   ` sashiko-bot
2026-06-10 15:46     ` lyude
2026-06-08 18:50 ` [PATCH v19 0/4] Rust bindings for gem shmem Danilo Krummrich
2026-06-10  0:20 ` Deborah Brouwer

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=20260608184329.0BF6C1F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=lyude@redhat.com \
    --cc=ojeda@kernel.org \
    --cc=sashiko-reviews@lists.linux.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