From: "Björn Roy Baron" <bjorn3_gh@protonmail.com>
To: "Björn Roy Baron" <bjorn3_gh@protonmail.com>
Cc: "Wedson Almeida Filho" <wedsonaf@gmail.com>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"Gary Guo" <gary@garyguo.net>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Asahi Lina" <lina@asahilina.net>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Maíra Canal" <mcanal@igalia.com>,
"Melissa Wen" <mwen@igalia.com>,
rust-for-linux@vger.kernel.org, dri-devel@lists.freedesktop.org,
"Miguel Ojeda" <ojeda@kernel.org>,
"Faith Ekstrand" <faith.ekstrand@collabora.com>
Subject: Re: [RFC PATCH 2/9] rust: drm: gem: add method to return DmaResv from GEMObject
Date: Wed, 22 Mar 2023 19:57:52 +0000 [thread overview]
Message-ID: <WENj4NV4lBApL7fmZeHMIenxaW7Lq7Y6ksqnxHMOI8Sm2p-JrJgpccljUEIDTDhRUiWf39U5lr0pX6szVchMNQZVyLNW-E1tV1lVrLKWIkg=@protonmail.com> (raw)
In-Reply-To: <kUn0Ms6i7sC5-okmT2pJ5OPhQ8bwDPmuTB8UfKJQBTZUN2veEF3w0awEwLF1Z4-XtoiT7qJTMiTMF6uXBqAxvHHd4BH6q3ty2bh12ci23Vs=@protonmail.com>
On Wednesday, March 22nd, 2023 at 20:45, Björn Roy Baron <bjorn3_gh@protonmail.com> wrote:
> On Friday, March 17th, 2023 at 13:12, Maíra Canal <mcanal@igalia.com> wrote:
>
> > A GEMObject, related to struct drm_gem_object, holds a pointer
> > to reservation object associated with the this GEM object. Therefore,
> > expose this reservation object through the DmaResv safe abstraction.
> >
> > Signed-off-by: Maíra Canal <mcanal@igalia.com>
> > ---
> > rust/kernel/drm/gem/mod.rs | 7 +++++++
> > 1 file changed, 7 insertions(+)
> >
> > diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs
> > index c4a42bb2f718..dae95e5748a7 100644
> > --- a/rust/kernel/drm/gem/mod.rs
> > +++ b/rust/kernel/drm/gem/mod.rs
> > @@ -11,6 +11,7 @@ use alloc::boxed::Box;
> >
> > use crate::{
> > bindings,
> > + dma_resv::DmaResv,
> > drm::{device, drv, file},
> > error::{to_result, Result},
> > prelude::*,
> > @@ -136,6 +137,12 @@ pub trait BaseObject: IntoGEMObject {
> > self.gem_obj().size
> > }
> >
> > + /// Returns the pointer to reservation object associated with this GEM object.
> > + fn resv(&self) -> DmaResv {
> > + // SAFETY: Every GEM object holds a reference to a reservation object
> > + unsafe { DmaResv::from_raw(self.gem_obj().resv) }
> > + }
>
> There is nothing ensuring that DmaResv doesn't outlive self and thus may have been deallocated. You could change DmaResv to be a newtype around UnsafeCell<dma_resv> and then return an &DmaResv here. This way &DmaResv can't outlive &self.
Actually Opaque<dma_resv> may be better as no fields of dma_resv are used on the rust side.
>
> > +
> > /// Sets the exportable flag, which controls whether the object can be exported via PRIME.
> > fn set_exportable(&mut self, exportable: bool) {
> > self.mut_gem_obj().exportable = exportable;
> > --
> > 2.39.2
>
> Cheers,
> Bjorn
Cheers,
Bjorn
next prev parent reply other threads:[~2023-03-24 8:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-17 12:12 [RFC PATCH 0/9] Rust version of the VGEM driver Maíra Canal
2023-03-17 12:12 ` [RFC PATCH 1/9] rust: dma_resv: add DMA Reservation abstraction Maíra Canal
2023-03-17 12:12 ` [RFC PATCH 2/9] rust: drm: gem: add method to return DmaResv from GEMObject Maíra Canal
2023-03-22 19:45 ` Björn Roy Baron
2023-03-22 19:57 ` Björn Roy Baron [this message]
2023-03-17 12:12 ` [RFC PATCH 3/9] rust: dma_fence: add method to return an indication if the fence is signaled Maíra Canal
2023-03-17 12:12 ` [RFC PATCH 4/9] rust: dma_fence: expose the fence's seqno publically Maíra Canal
2023-03-17 12:12 ` [RFC PATCH 5/9] rust: drm: gem: shmem: set map_wc on gem_create_object callback Maíra Canal
2023-03-17 12:12 ` [RFC PATCH 6/9] drm/vgem: move IOCTLs numbers to enum Maíra Canal
2023-03-17 12:12 ` [RFC PATCH 7/9] drm/rustgem: implement a Rust version of VGEM Maíra Canal
2023-03-17 12:12 ` [RFC PATCH 8/9] drm/rustgem: implement timeout to prevent hangs Maíra Canal
2023-03-17 12:12 ` [RFC PATCH 9/9] drm/rustgem: create dummy IOCTL with number 0x00 Maíra Canal
2023-04-13 9:08 ` Daniel Vetter
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='WENj4NV4lBApL7fmZeHMIenxaW7Lq7Y6ksqnxHMOI8Sm2p-JrJgpccljUEIDTDhRUiWf39U5lr0pX6szVchMNQZVyLNW-E1tV1lVrLKWIkg=@protonmail.com' \
--to=bjorn3_gh@protonmail.com \
--cc=alex.gaynor@gmail.com \
--cc=boqun.feng@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=faith.ekstrand@collabora.com \
--cc=gary@garyguo.net \
--cc=lina@asahilina.net \
--cc=mcanal@igalia.com \
--cc=mwen@igalia.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tzimmermann@suse.de \
--cc=wedsonaf@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).