From: Danilo Krummrich <dakr@kernel.org>
To: dakr@kernel.org, aliceryhl@google.com,
daniel.almeida@collabora.com, acourbot@nvidia.com,
ecourtney@nvidia.com, ojeda@kernel.org, boqun@kernel.org,
gary@garyguo.net, bjorn3_gh@protonmail.com, lossin@kernel.org,
a.hindborg@kernel.org, tmgross@umich.edu,
deborah.brouwer@collabora.com, boris.brezillon@collabora.com
Cc: driver-core@lists.linux.dev, linux-kernel@vger.kernel.org,
nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org,
rust-for-linux@vger.kernel.org
Subject: [PATCH v2 7/7] drm: nova: convert to use DRM registration data
Date: Wed, 3 Jun 2026 03:15:49 +0200 [thread overview]
Message-ID: <20260603011711.2077361-8-dakr@kernel.org> (raw)
In-Reply-To: <20260603011711.2077361-1-dakr@kernel.org>
Move the auxiliary device reference from drm::Device data into
RegistrationData, replacing the ARef<auxiliary::Device> with a borrowed
&'bound auxiliary::Device<Bound>. This makes the data lifetime-aware and
exercises the registration data path through the ioctl handlers.
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
---
drivers/gpu/drm/nova/driver.rs | 20 ++++++++++----------
drivers/gpu/drm/nova/file.rs | 19 +++++++++++--------
2 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/drivers/gpu/drm/nova/driver.rs b/drivers/gpu/drm/nova/driver.rs
index 4267e6e6dbb4..f46d7ff6fee3 100644
--- a/drivers/gpu/drm/nova/driver.rs
+++ b/drivers/gpu/drm/nova/driver.rs
@@ -3,6 +3,7 @@
use kernel::{
auxiliary,
device::{
+ Bound,
Core,
DeviceContext, //
},
@@ -13,7 +14,7 @@
},
prelude::*,
sync::aref::ARef,
- types::ForLt, //
+ types::CovariantForLt, //
};
use crate::file::File;
@@ -30,9 +31,8 @@ pub(crate) struct Nova<'bound> {
/// Convienence type alias for the DRM device type for this driver
pub(crate) type NovaDevice<Ctx = drm::Registered> = drm::Device<NovaDriver, Ctx>;
-#[pin_data]
-pub(crate) struct NovaData {
- pub(crate) adev: ARef<auxiliary::Device>,
+pub(crate) struct NovaData<'bound> {
+ pub(crate) adev: &'bound auxiliary::Device<Bound>,
}
const INFO: drm::DriverInfo = drm::DriverInfo {
@@ -65,10 +65,10 @@ fn probe<'bound>(
adev: &'bound auxiliary::Device<Core<'_>>,
_info: &'bound Self::IdInfo,
) -> impl PinInit<Self::Data<'bound>, Error> + 'bound {
- let data = try_pin_init!(NovaData { adev: adev.into() });
-
- let drm = drm::UnregisteredDevice::<Self>::new(adev, data)?;
- let reg = drm::Registration::new(adev.as_ref(), drm, (), 0)?;
+ let drm = drm::UnregisteredDevice::<Self>::new(adev, Ok(()))?;
+ let reg_data = NovaData { adev };
+ // SAFETY: We never bypass the destructor of `reg`.
+ let reg = unsafe { drm::Registration::new_with_lt(adev.as_ref(), drm, reg_data, 0)? };
Ok(Nova {
drm: reg.device().into(),
@@ -79,8 +79,8 @@ fn probe<'bound>(
#[vtable]
impl drm::Driver for NovaDriver {
- type Data = NovaData;
- type RegistrationData = ForLt!(());
+ type Data = ();
+ type RegistrationData = CovariantForLt!(NovaData<'_>);
type File = File;
type Object<Ctx: drm::DeviceContext> = gem::Object<NovaObject, Ctx>;
type ParentDevice<Ctx: DeviceContext> = auxiliary::Device<Ctx>;
diff --git a/drivers/gpu/drm/nova/file.rs b/drivers/gpu/drm/nova/file.rs
index df9760947d58..cd6c37b01e22 100644
--- a/drivers/gpu/drm/nova/file.rs
+++ b/drivers/gpu/drm/nova/file.rs
@@ -1,6 +1,10 @@
// SPDX-License-Identifier: GPL-2.0
-use crate::driver::{NovaDevice, NovaDriver};
+use crate::driver::{
+ NovaData,
+ NovaDevice,
+ NovaDriver, //
+};
use crate::gem::NovaObject;
use kernel::{
alloc::flags::*,
@@ -25,15 +29,14 @@ fn open(_dev: &NovaDevice) -> Result<Pin<KBox<Self>>> {
impl File {
/// IOCTL: get_param: Query GPU / driver metadata.
pub(crate) fn get_param(
- dev: &NovaDevice,
+ _dev: &NovaDevice,
_adev: &auxiliary::Device<Bound>,
- _reg_data: &(),
+ reg_data: &NovaData<'_>,
getparam: &mut uapi::drm_nova_getparam,
_file: &drm::File<File>,
) -> Result<u32> {
- let adev = &dev.adev;
- let parent = adev.parent();
- let pdev: &pci::Device = parent.try_into()?;
+ let parent = reg_data.adev.parent();
+ let pdev: &pci::Device<Bound> = parent.try_into()?;
let value = match getparam.param as u32 {
uapi::NOVA_GETPARAM_VRAM_BAR_SIZE => pdev.resource_len(1)?,
@@ -49,7 +52,7 @@ pub(crate) fn get_param(
pub(crate) fn gem_create(
dev: &NovaDevice,
_adev: &auxiliary::Device<Bound>,
- _reg_data: &(),
+ _reg_data: &NovaData<'_>,
req: &mut uapi::drm_nova_gem_create,
file: &drm::File<File>,
) -> Result<u32> {
@@ -64,7 +67,7 @@ pub(crate) fn gem_create(
pub(crate) fn gem_info(
_dev: &NovaDevice,
_adev: &auxiliary::Device<Bound>,
- _reg_data: &(),
+ _reg_data: &NovaData<'_>,
req: &mut uapi::drm_nova_gem_info,
file: &drm::File<File>,
) -> Result<u32> {
--
2.54.0
next prev parent reply other threads:[~2026-06-03 1:28 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 1:15 [PATCH v2 0/7] rust: drm: Higher-Ranked Lifetime private data Danilo Krummrich
2026-06-03 1:15 ` [PATCH v2 1/7] rust: drm: Add Driver::ParentDevice associated type Danilo Krummrich
2026-06-04 2:03 ` Claude review: " Claude Code Review Bot
2026-06-03 1:15 ` [PATCH v2 2/7] rust: drm: Add UnbindGuard for drm_dev_enter/exit critical sections Danilo Krummrich
2026-06-03 11:47 ` Gary Guo
2026-06-04 2:03 ` Claude review: " Claude Code Review Bot
2026-06-03 1:15 ` [PATCH v2 3/7] rust: drm: Add RegistrationData to drm::Driver Danilo Krummrich
2026-06-03 11:51 ` Gary Guo
2026-06-03 22:24 ` Danilo Krummrich
2026-06-03 22:36 ` Gary Guo
2026-06-03 23:29 ` Deborah Brouwer
2026-06-04 2:03 ` Claude review: " Claude Code Review Bot
2026-06-03 1:15 ` [PATCH v2 4/7] rust: drm: Wrap ioctl dispatch in UnbindGuard Danilo Krummrich
2026-06-04 2:03 ` Claude review: " Claude Code Review Bot
2026-06-03 1:15 ` [PATCH v2 5/7] rust: drm: Pass bound parent device to ioctl handlers Danilo Krummrich
2026-06-04 2:03 ` Claude review: " Claude Code Review Bot
2026-06-03 1:15 ` [PATCH v2 6/7] rust: drm: Pass registration data " Danilo Krummrich
2026-06-04 2:03 ` Claude review: " Claude Code Review Bot
2026-06-03 1:15 ` Danilo Krummrich [this message]
2026-06-04 2:03 ` Claude review: drm: nova: convert to use DRM registration data Claude Code Review Bot
2026-06-04 2:03 ` Claude review: rust: drm: Higher-Ranked Lifetime private data Claude Code Review Bot
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=20260603011711.2077361-8-dakr@kernel.org \
--to=dakr@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=boris.brezillon@collabora.com \
--cc=daniel.almeida@collabora.com \
--cc=deborah.brouwer@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=driver-core@lists.linux.dev \
--cc=ecourtney@nvidia.com \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=nova-gpu@lists.linux.dev \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
/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