[PATCH v5 1/7] drm/tyr: add resources to RegistrationData

From: Deborah Brouwer

Date: Wed Jul 08 2026 - 20:48:00 EST


Currently Tyr is not storing any resources in its drm::Driver
RegistrationData.

Move Tyr's parent platform device, clocks, regulators, and MMIO mapping to
its RegistrationData. This allows Tyr to access these resources with
lifetime awareness while the DRM device is registered with userspace.

Signed-off-by: Deborah Brouwer <deborah.brouwer@xxxxxxxxxxxxx>
---
drivers/gpu/drm/tyr/driver.rs | 38 ++++++++++++++++++++++++++------------
drivers/gpu/drm/tyr/file.rs | 5 +++--
2 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/tyr/driver.rs b/drivers/gpu/drm/tyr/driver.rs
index 8348c6cd3929..2d2a44c19b6d 100644
--- a/drivers/gpu/drm/tyr/driver.rs
+++ b/drivers/gpu/drm/tyr/driver.rs
@@ -6,6 +6,7 @@
OptionalClk, //
},
device::{
+ Bound,
Core,
Device,
DeviceContext, //
@@ -57,9 +58,24 @@ pub(crate) struct TyrPlatformDriverData<'bound> {
_reg: drm::Registration<'bound, TyrDrmDriver>,
}

+/// Data owned by the DRM [`Device`].
+///
+/// This data is stored in the DRM device itself and is not tied to the DRM
+/// registration or parent platform device binding lifetime.
#[pin_data]
pub(crate) struct TyrDrmDeviceData {
- pub(crate) pdev: ARef<platform::Device>,
+ /// GPU information read from hardware during probe.
+ pub(crate) gpu_info: GpuInfo,
+}
+
+/// Data owned by the DRM [`Registration`].
+///
+/// This data can have references tied to the parent platform device binding scope
+/// and is accessible only while the DRM device is registered with userspace.
+#[pin_data]
+pub(crate) struct TyrDrmRegistrationData<'bound> {
+ /// Parent platform device.
+ pub(crate) pdev: &'bound platform::Device<Bound>,

#[pin]
clks: Mutex<Clocks>,
@@ -67,10 +83,8 @@ pub(crate) struct TyrDrmDeviceData {
#[pin]
regulators: Mutex<Regulators>,

- /// Some information on the GPU.
- ///
- /// This is mainly queried by userspace, i.e.: Mesa.
- pub(crate) gpu_info: GpuInfo,
+ /// GPU MMIO register mapping.
+ pub(crate) iomem: IoMem<'bound>,
}

fn issue_soft_reset(dev: &Device, iomem: &IoMem<'_>) -> Result {
@@ -134,10 +148,11 @@ fn probe<'bound>(
// other threads of execution.
unsafe { pdev.dma_set_mask_and_coherent(DmaMask::try_new(pa_bits)?)? };

- let platform: ARef<platform::Device> = pdev.into();
+ let drm_data = try_pin_init!(TyrDrmDeviceData { gpu_info });
+ let unreg_dev = drm::UnregisteredDevice::<TyrDrmDriver>::new(pdev, drm_data)?;

- let data = try_pin_init!(TyrDrmDeviceData {
- pdev: platform.clone(),
+ let reg_data = try_pin_init!(TyrDrmRegistrationData {
+ pdev,
clks <- new_mutex!(Clocks {
core: core_clk,
stacks: stacks_clk,
@@ -147,13 +162,12 @@ fn probe<'bound>(
_mali: mali_regulator,
_sram: sram_regulator,
}),
- gpu_info,
+ iomem,
});

- let tdev = drm::UnregisteredDevice::<TyrDrmDriver>::new(pdev, data)?;
// SAFETY: `reg` is stored in `TyrPlatformDriverData` and dropped when the driver is
// unbound; it is never forgotten.
- let reg = unsafe { drm::Registration::new(pdev.as_ref(), tdev, (), 0)? };
+ let reg = unsafe { drm::Registration::new(pdev.as_ref(), unreg_dev, reg_data, 0)? };

let driver = TyrPlatformDriverData {
_device: reg.device().into(),
@@ -185,7 +199,7 @@ fn drop(self: Pin<&mut Self>) {}
#[vtable]
impl drm::Driver for TyrDrmDriver {
type Data = TyrDrmDeviceData;
- type RegistrationData<'a> = ();
+ type RegistrationData<'bound> = TyrDrmRegistrationData<'bound>;
type File = TyrDrmFileData;
type Object = drm::gem::shmem::Object<BoData>;
type ParentDevice<Ctx: DeviceContext> = platform::Device<Ctx>;
diff --git a/drivers/gpu/drm/tyr/file.rs b/drivers/gpu/drm/tyr/file.rs
index b686041d5d6b..72c32e524be9 100644
--- a/drivers/gpu/drm/tyr/file.rs
+++ b/drivers/gpu/drm/tyr/file.rs
@@ -12,7 +12,8 @@

use crate::driver::{
TyrDrmDevice,
- TyrDrmDriver, //
+ TyrDrmDriver,
+ TyrDrmRegistrationData, //
};

#[pin_data]
@@ -32,7 +33,7 @@ fn open(_dev: &drm::Device<Self::Driver>) -> Result<Pin<KBox<Self>>> {
impl TyrDrmFileData {
pub(crate) fn dev_query(
ddev: &TyrDrmDevice<Registered>,
- _reg_data: &(),
+ _reg_data: &TyrDrmRegistrationData<'_>,
devquery: &mut uapi::drm_panthor_dev_query,
_file: &TyrDrmFile,
) -> Result<u32> {

--
2.54.0