From: "Danilo Krummrich" <dakr@kernel.org>
To: "Alvin Sun" <alvin.sun@linux.dev>
Cc: "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>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Alexander Viro" <viro@zeniv.linux.org.uk>,
"Christian Brauner" <brauner@kernel.org>,
"Jan Kara" <jack@suse.cz>,
"Matthew Brost" <matthew.brost@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Maíra Canal" <mcanal@igalia.com>,
"Melissa Wen" <mwen@igalia.com>,
"Wambui Karuga" <wambui.karugax@gmail.com>,
"Eric Anholt" <eric@anholt.net>, "Ben Gamari" <bgamari@gmail.com>,
rust-for-linux@vger.kernel.org, driver-core@lists.linux.dev,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 3/9] rust: debugfs: add Entry::from_raw and ScopedDir::from_dentry
Date: Mon, 03 Aug 2026 19:55:27 +0200 [thread overview]
Message-ID: <DKFI2XHD62AU.TP8WZCRG5EIW@kernel.org> (raw)
In-Reply-To: <20260731-tyr-debugfs-v2-v2-3-aea19eccb996@linux.dev>
On Thu Jul 30, 2026 at 7:05 PM CEST, Alvin Sun wrote:
> + /// Creates a [`ScopedDir`] wrapping an existing debugfs dentry.
> + ///
> + /// Files created under this directory are not automatically removed on drop;
> + /// their lifetime is tied to the dentry owner.
> + ///
> + /// # Safety
> + ///
> + /// The caller must ensure the dentry remains valid for the lifetime of the
> + /// returned `ScopedDir`.
> + pub unsafe fn from_dentry(dentry: *mut bindings::dentry) -> Self {
> + let _ = dentry;
> + ScopedDir {
> + #[cfg(CONFIG_DEBUG_FS)]
> + // SAFETY: The caller guarantees the dentry is valid and outlives this `ScopedDir`.
> + entry: ManuallyDrop::new(unsafe { Entry::from_raw(dentry) }),
> + _phantom: PhantomData,
> + }
> + }
I think what you actually want to express is that the DRM debugfs root dir
represents a view into an existing scope, where the data is T::RegistrationData.
Additionally, we want to be able to derive new debugfs::Scopes from this that
are shorter lived, so we can create new debugfs::Scopes e.g. in
drm::DriverFile<'a>, which I currently work on.
So, what I'm thinking of is a type like:
pub struct ScopeRef<'a, T> {
#[cfg(CONFIG_DEBUG_FS)]
dentry: Option<NonNull<bindings::dentry>>,
data: &'a T,
}
which has a corresponding unsafe constructor and provides methods to e.g. create
a new directory, returning a new ScopeRef<'a, T>, which can be stored in
lifetime scoped data.
Additionally, but that's somewhat orthogonal, we want debugfs::Scope to support
lifetime data, so a scope can participate in the driver lifecycle; the
corresponding synchronization is already in place with full proxy fops.
next prev parent reply other threads:[~2026-08-03 17:55 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-30 17:05 [PATCH v2 0/9] drm/tyr: add debugfs support Alvin Sun
2026-07-30 17:05 ` [PATCH v2 1/9] rust: seq_file: add as_raw() method Alvin Sun
2026-07-30 17:05 ` [PATCH v2 2/9] rust: debugfs: add SeqShow trait and seq_file file operations Alvin Sun
2026-07-31 13:08 ` Alice Ryhl
2026-07-31 16:52 ` Alvin Sun
2026-08-03 15:05 ` Alice Ryhl
2026-08-03 15:23 ` Danilo Krummrich
2026-07-30 17:05 ` [PATCH v2 3/9] rust: debugfs: add Entry::from_raw and ScopedDir::from_dentry Alvin Sun
2026-08-03 17:55 ` Danilo Krummrich [this message]
2026-07-30 17:05 ` [PATCH v2 4/9] drm: move debugfs_init after dev->registered is set Alvin Sun
2026-07-30 17:05 ` [PATCH v2 5/9] rust: drm: add debugfs_init callback to Driver trait Alvin Sun
2026-08-03 17:55 ` Danilo Krummrich
2026-07-30 17:05 ` [PATCH v2 6/9] rust: drm: add DrmSeqShow seq_file adapter Alvin Sun
2026-08-03 17:56 ` Danilo Krummrich
2026-07-30 17:05 ` [PATCH v2 7/9] rust: drm: gpuvm: add dump_gpuva_info to UniqueRefGpuVm Alvin Sun
2026-07-31 13:01 ` Alice Ryhl
2026-07-30 17:05 ` [PATCH v2 8/9] drm/tyr: add gpuvas debugfs file Alvin Sun
2026-07-31 12:59 ` Alice Ryhl
2026-07-31 16:29 ` Daniel Almeida
2026-08-03 17:56 ` Danilo Krummrich
2026-07-30 17:05 ` [PATCH v2 9/9] drm/debugfs: hold device reference for the lifetime of open files Alvin Sun
2026-08-03 17:56 ` Danilo Krummrich
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=DKFI2XHD62AU.TP8WZCRG5EIW@kernel.org \
--to=dakr@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=alvin.sun@linux.dev \
--cc=bgamari@gmail.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=brauner@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=driver-core@lists.linux.dev \
--cc=eric@anholt.net \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=jack@suse.cz \
--cc=lossin@kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matthew.brost@intel.com \
--cc=mcanal@igalia.com \
--cc=mripard@kernel.org \
--cc=mwen@igalia.com \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=tamird@kernel.org \
--cc=thomas.hellstrom@linux.intel.com \
--cc=tmgross@umich.edu \
--cc=tzimmermann@suse.de \
--cc=viro@zeniv.linux.org.uk \
--cc=wambui.karugax@gmail.com \
--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