[PATCH v2 7/7] drm: nova: convert to use DRM registration data

From: Danilo Krummrich

Date: Tue Jun 02 2026 - 21:34:00 EST


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@xxxxxxxxxx>
---
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