From: Alice Ryhl <aliceryhl@google.com>
To: Lyude Paul <lyude@redhat.com>
Cc: dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Asahi Lina" <lina@asahilina.net>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Asahi Lina" <lina+kernel@asahilina.net>,
"Viresh Kumar" <viresh.kumar@linaro.org>,
"Shankari Anand" <shankari.ak0208@gmail.com>,
"open list" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 6/9] rust: drm: gem: shmem: Add DRM shmem helper abstraction
Date: Fri, 17 Oct 2025 13:30:24 +0000 [thread overview]
Message-ID: <aPJE8EC5OmlmSrYt@google.com> (raw)
In-Reply-To: <20251016210955.2813186-7-lyude@redhat.com>
On Thu, Oct 16, 2025 at 05:08:19PM -0400, Lyude Paul wrote:
> From: Asahi Lina <lina@asahilina.net>
>
> The DRM shmem helper includes common code useful for drivers which
> allocate GEM objects as anonymous shmem. Add a Rust abstraction for
> this. Drivers can choose the raw GEM implementation or the shmem layer,
> depending on their needs.
>
> Signed-off-by: Asahi Lina <lina@asahilina.net>
> Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com>
> Signed-off-by: Lyude Paul <lyude@redhat.com>
> +impl<T: DriverObject> gem::IntoGEMObject for Object<T> {
> + fn as_raw(&self) -> *mut bindings::drm_gem_object {
> + // SAFETY: Our immutable reference is proof that this is are to dereference
> + unsafe { &raw mut (*self.obj.get()).base }
Typo.
Also, in principle, this should refer to a type invariant saying that
`obj` is a valid shmem object.
> + }
> +
> + unsafe fn from_raw<'a>(obj: *mut bindings::drm_gem_object) -> &'a Object<T> {
> + // SAFETY: The safety contract of from_gem_obj() guarantees that `obj` is contained within
> + // `Self`
> + unsafe {
> + let obj: *mut Opaque<_> =
> + container_of!(obj, bindings::drm_gem_shmem_object, base).cast();
Please use Opaque::cast_from() instead of the unrestricted cast()
operation.
There are several instances of this throughout the file.
Alice
next prev parent reply other threads:[~2025-10-17 13:30 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-16 21:08 [PATCH v4 0/9] Rust bindings for gem shmem + iosys_map Lyude Paul
2025-10-16 21:08 ` [PATCH v4 1/9] Partially revert "rust: drm: gem: Implement AlwaysRefCounted for all gem objects automatically" Lyude Paul
2025-10-17 13:11 ` Alice Ryhl
2025-10-16 21:08 ` [PATCH v4 2/9] rust/drm: Add gem::impl_aref_for_gem_obj! Lyude Paul
2025-10-17 13:22 ` Alice Ryhl
2025-10-21 17:33 ` Lyude Paul
2025-10-22 8:14 ` Alice Ryhl
2025-10-16 21:08 ` [PATCH v4 3/9] rust: helpers: Add bindings/wrappers for dma_resv_lock Lyude Paul
2025-10-17 13:23 ` Alice Ryhl
2025-10-16 21:08 ` [PATCH v4 4/9] rust: drm: gem: Add raw_dma_resv() function Lyude Paul
2025-10-16 21:08 ` [PATCH v4 5/9] rust: gem: Introduce DriverObject::Args Lyude Paul
2025-10-17 13:24 ` Alice Ryhl
2025-10-16 21:08 ` [PATCH v4 6/9] rust: drm: gem: shmem: Add DRM shmem helper abstraction Lyude Paul
2025-10-17 13:30 ` Alice Ryhl [this message]
2025-10-16 21:08 ` [PATCH v4 7/9] rust: drm: gem: Introduce shmem::SGTable Lyude Paul
2025-10-16 21:08 ` [PATCH v4 8/9] rust: Introduce iosys_map bindings Lyude Paul
2025-10-16 22:26 ` Lyude Paul
2025-10-16 21:08 ` [PATCH v4 9/9] rust: drm/gem: Add vmap functions to shmem bindings Lyude Paul
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=aPJE8EC5OmlmSrYt@google.com \
--to=aliceryhl@google.com \
--cc=a.hindborg@kernel.org \
--cc=airlied@gmail.com \
--cc=alex.gaynor@gmail.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=lina+kernel@asahilina.net \
--cc=lina@asahilina.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=lyude@redhat.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=shankari.ak0208@gmail.com \
--cc=simona@ffwll.ch \
--cc=tmgross@umich.edu \
--cc=viresh.kumar@linaro.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.