From: Joel Fernandes <joelagnelf@nvidia.com>
To: Timur Tabi <ttabi@nvidia.com>,
"gary@garyguo.net" <gary@garyguo.net>,
John Hubbard <jhubbard@nvidia.com>
Cc: "nouveau@lists.freedesktop.org" <nouveau@lists.freedesktop.org>,
Alexandre Courbot <acourbot@nvidia.com>,
"dakr@kernel.org" <dakr@kernel.org>,
"lyude@redhat.com" <lyude@redhat.com>,
"rust-for-linux@vger.kernel.org" <rust-for-linux@vger.kernel.org>
Subject: Re: [PATCH 3/7] gpu: nova-core: create debugfs root in PCI init closure
Date: Tue, 16 Dec 2025 17:01:59 -0500 [thread overview]
Message-ID: <378b8542-86a4-4c8c-b1ec-070d1b2372d6@nvidia.com> (raw)
In-Reply-To: <bc1ff6c7c86487143de7afaaef78d8361f590c13.camel@nvidia.com>
On 12/16/2025 3:28 PM, Timur Tabi wrote:
> On Tue, 2025-12-16 at 19:04 +0900, John Hubbard wrote:
>>> If I do that, then how do I access it from gsp.rs (the last patch in this series)?
>>
>> Given that the current PCI .probe() doesn't pass in module data,
>> I looked around and saw that Binder is using global_lock!()
>> instead of passing around module data. It seems like this area
>> is still new in Rust for Linux.
>>
>> I wonder if global_lock!() is what Gary had in mind? That is still
>> effectively global access, but at least it's synchronized,
>> unlike static mut.
>
> It's only 'mut' in that it needs to be initialized when the driver loads. After that, it's only
> referenced as non-mut:
>
> #[allow(static_mut_refs)]
> // SAFETY: `DEBUGFS_ROOT` is never modified after initialization, so it is safe to
> // create a shared reference to it.
> let novacore_dir = unsafe { crate::DEBUGFS_ROOT.as_ref() }.ok_or(ENOENT)?;
>
> The first internal version of this code did have global_lock!, but it caused problems. That's why
> Alex recommended to drop the lock and just have an unsafe initialization:
>
> https://github.com/Gnurou/linux/commit/d5435f662b8677545a93373b4c4c80d8b4be40c9
>
> It would be nice if Rust had a concept of a variable that was initialized at runtime once (before
> any concurrent access could occur), and was then read-only everywhere else.
>
Could the debugfs Rust abstraction add a directory lookup function
`Dir::lookup(name)` method and allow creating sub directories under a known
path? This would let `probe()` find the module-created root directory without
needing global state right? Then store references to this on a per-GPU basis
that the GSP code can access. Alternatively, the first probe can create the root
directory, and subsequent probes reuse it without requiring module-level root.
thanks,
- Joel
next prev parent reply other threads:[~2025-12-16 22:02 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-12 20:49 [PATCH 0/7] gpu: nova-core: expose the logging buffers via debugfs Timur Tabi
2025-12-12 20:49 ` [PATCH 1/7] rust: pci: add PCI device name method Timur Tabi
2025-12-15 11:35 ` Gary Guo
2025-12-15 16:49 ` lyude
2025-12-12 20:49 ` [PATCH 2/7] gpu: nova-core: Replace module_pci_driver! with explicit module init Timur Tabi
2025-12-13 23:46 ` Joel Fernandes
2025-12-15 11:36 ` Gary Guo
2025-12-12 20:49 ` [PATCH 3/7] gpu: nova-core: create debugfs root in PCI init closure Timur Tabi
2025-12-15 11:40 ` Gary Guo
2025-12-15 16:45 ` Timur Tabi
2025-12-16 10:04 ` John Hubbard
2025-12-16 20:28 ` Timur Tabi
2025-12-16 22:01 ` Joel Fernandes [this message]
2025-12-16 22:29 ` Timur Tabi
2025-12-16 23:17 ` Joel Fernandes
2025-12-16 23:29 ` Timur Tabi
2025-12-12 20:49 ` [PATCH 4/7] gpu: nova-core: implement BinaryWriter for LogBuffer Timur Tabi
2025-12-12 20:49 ` [PATCH 5/7] gpu: nova-core: use pin projection in method boot() Timur Tabi
2025-12-12 20:49 ` [PATCH 6/7] gpu: nova-core: create loginit debugfs entry Timur Tabi
2025-12-15 16:45 ` Timur Tabi
2025-12-12 20:49 ` [PATCH 7/7] gpu: nova-core: create GSP-RM logging buffers debugfs entries Timur Tabi
2025-12-13 23:44 ` Joel Fernandes
2025-12-13 19:19 ` [PATCH 0/7] gpu: nova-core: expose the logging buffers via debugfs Joel Fernandes
2025-12-13 20:47 ` Timur Tabi
2025-12-13 21:49 ` Joel Fernandes
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=378b8542-86a4-4c8c-b1ec-070d1b2372d6@nvidia.com \
--to=joelagnelf@nvidia.com \
--cc=acourbot@nvidia.com \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=jhubbard@nvidia.com \
--cc=lyude@redhat.com \
--cc=nouveau@lists.freedesktop.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=ttabi@nvidia.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).