From: "Danilo Krummrich" <dakr@kernel.org>
To: "Alexandre Courbot" <acourbot@nvidia.com>
Cc: "Zhi Wang" <zhiw@nvidia.com>, <rust-for-linux@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <jgg@nvidia.com>,
<dave.jiang@intel.com>, <saeedm@nvidia.com>, <jic23@kernel.org>,
<gary@garyguo.net>, <joelagnelf@nvidia.com>,
<aliceryhl@google.com>, <kwilczynski@kernel.org>,
<ojeda@kernel.org>, <alex.gaynor@gmail.com>,
<boqun.feng@gmail.com>, <bjorn3_gh@protonmail.com>,
<lossin@kernel.org>, <a.hindborg@kernel.org>, <tmgross@umich.edu>,
<cjia@nvidia.com>, <smitra@nvidia.com>, <ankita@nvidia.com>,
<aniketa@nvidia.com>, <kwankhede@nvidia.com>,
<targupta@nvidia.com>, <kjaju@nvidia.com>, <alkumar@nvidia.com>,
<jhubbard@nvidia.com>, <zhiwang@kernel.org>,
<daniel.almeida@collabora.com>
Subject: Re: [PATCH v6 1/1] rust: introduce abstractions for fwctl
Date: Mon, 06 Jul 2026 13:30:55 +0200 [thread overview]
Message-ID: <DJRGD98J154Y.2MSNQJSXANX08@kernel.org> (raw)
In-Reply-To: <DJR76RV8NEKN.2MP5M9Z66U4TY@nvidia.com>
On Mon Jul 6, 2026 at 6:19 AM CEST, Alexandre Courbot wrote:
>> +impl<'a, T: Operations> Registration<'a, T> {
>> + /// Register a previously allocated fwctl device with the given registration data.
>> + ///
>> + /// The `reg_data` is owned by the registration and accessible during callbacks via
>> + /// `Device::registration_data_unchecked()`.
>> + ///
>> + /// # Safety
>> + ///
>> + /// Callers must not `mem::forget()` the returned [`Registration`] or otherwise prevent its
>> + /// [`Drop`] implementation from running, since `fwctl_unregister` must be called before the
>> + /// parent device is unbound.
>> + ///
>> + /// `dev` must be an unregistered [`Device`] that is not associated with any live
>> + /// [`Registration`], and no other thread may attempt to register the same device concurrently.
>> + pub unsafe fn new(
>> + _parent: &'a device::Device<device::Bound>,
>
> Why do we need `_parent`? Is it to provide a proof that the parent
> device is bound by the time of registration? If so, there is an obvious
> loophole: this method will accept any bound device, not necessarily the
> actual parent that was passed to `Device::new`.
>
> We should either store an `ARef<device::Device>` in `fwctl::Device` to
> perform the check at runtime, or add a requirement in the `Safety`
> paragraph that `_parent` must be the actual parent, since the method is
> already `unsafe` anyway.
Neither is needed, the fwctl::Device already carries a parent device pointer
(available through AsRef in Rust).
This function should just compare dev.as_ref() with parent (which I thought was
already the case in a previous version).
next prev parent reply other threads:[~2026-07-06 11:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 15:01 [PATCH v6 0/1] rust: introduce abstractions for fwctl Zhi Wang
2026-06-29 15:01 ` [PATCH v6 1/1] " Zhi Wang
2026-07-04 19:42 ` Danilo Krummrich
2026-07-06 4:19 ` Alexandre Courbot
2026-07-06 11:30 ` Danilo Krummrich [this message]
2026-07-06 12:00 ` Gary Guo
2026-07-07 11:33 ` Alexandre Courbot
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=DJRGD98J154Y.2MSNQJSXANX08@kernel.org \
--to=dakr@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=alkumar@nvidia.com \
--cc=aniketa@nvidia.com \
--cc=ankita@nvidia.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=cjia@nvidia.com \
--cc=daniel.almeida@collabora.com \
--cc=dave.jiang@intel.com \
--cc=gary@garyguo.net \
--cc=jgg@nvidia.com \
--cc=jhubbard@nvidia.com \
--cc=jic23@kernel.org \
--cc=joelagnelf@nvidia.com \
--cc=kjaju@nvidia.com \
--cc=kwankhede@nvidia.com \
--cc=kwilczynski@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=saeedm@nvidia.com \
--cc=smitra@nvidia.com \
--cc=targupta@nvidia.com \
--cc=tmgross@umich.edu \
--cc=zhiw@nvidia.com \
--cc=zhiwang@kernel.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.