From: Daniel Almeida <daniel.almeida@collabora.com>
To: Deborah Brouwer <deborah.brouwer@collabora.com>
Cc: Alice Ryhl <aliceryhl@google.com>,
Danilo Krummrich <dakr@kernel.org>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Benno Lossin <lossin@kernel.org>, Gary Guo <gary@garyguo.net>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
rust-for-linux@vger.kernel.org, boris.brezillon@collabora.com,
samitolvanen@google.com, acourbot@nvidia.com,
alvin.sun@linux.dev, laura.nao@collabora.com, work@onurozkan.dev,
beata.michalska@arm.com, steven.price@arm.com, lyude@redhat.com
Subject: Re: [PATCH v6 1/7] drm/tyr: add resources to RegistrationData
Date: Wed, 15 Jul 2026 18:51:17 -0300 [thread overview]
Message-ID: <5D445C5B-6C4D-49CE-98B2-3BCD68014626@collabora.com> (raw)
In-Reply-To: <20260709-fw-boot-b4-v6-1-ca391e1a4108@collabora.com>
> On 9 Jul 2026, at 18:36, Deborah Brouwer <deborah.brouwer@collabora.com> wrote:
>
> Currently Tyr is not storing any resources in its drm::Driver
> RegistrationData.
>
> Move Tyr's device-private resources and gpu information from
> drm::Driver::Data to drm::Driver::RegistrationData. This allows Tyr to
> access this data safely within the lifetime of its binding to its parent
> platform device and while registered with userspace.
>
> Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
> ---
> drivers/gpu/drm/tyr/driver.rs | 42 +++++++++++++++++++++---------------------
> drivers/gpu/drm/tyr/file.rs | 11 ++++++-----
> 2 files changed, 27 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/gpu/drm/tyr/driver.rs b/drivers/gpu/drm/tyr/driver.rs
> index 8348c6cd3929..46ce5c41e310 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, //
> @@ -27,10 +28,7 @@
> regulator,
> regulator::Regulator,
> sizes::SZ_2M,
> - sync::{
> - aref::ARef,
> - Mutex, //
> - },
> + sync::Mutex,
> time, //
> };
>
> @@ -53,13 +51,17 @@
>
> #[pin_data(PinnedDrop)]
> pub(crate) struct TyrPlatformDriverData<'bound> {
> - _device: ARef<TyrDrmDevice>,
> _reg: drm::Registration<'bound, TyrDrmDriver>,
> }
>
> +/// 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 TyrDrmDeviceData {
> - pub(crate) pdev: ARef<platform::Device>,
> +pub(crate) struct TyrDrmRegistrationData<'bound> {
> + /// Parent platform device.
> + pub(crate) pdev: &'bound platform::Device<Bound>,
>
> #[pin]
> clks: Mutex<Clocks>,
> @@ -67,9 +69,10 @@ pub(crate) struct TyrDrmDeviceData {
> #[pin]
> regulators: Mutex<Regulators>,
>
> - /// Some information on the GPU.
> - ///
> - /// This is mainly queried by userspace, i.e.: Mesa.
> + /// GPU MMIO register mapping.
> + pub(crate) iomem: IoMem<'bound>,
> +
> + /// GPU information read from hardware during probe.
> pub(crate) gpu_info: GpuInfo,
> }
>
> @@ -134,10 +137,10 @@ 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 unreg_dev = drm::UnregisteredDevice::<TyrDrmDriver>::new(pdev, Ok(()))?;
>
> - 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,18 +150,15 @@ fn probe<'bound>(
> _mali: mali_regulator,
> _sram: sram_regulator,
> }),
> + iomem,
> gpu_info,
> });
>
> - 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(),
> - _reg: reg,
> - };
> + let driver = TyrPlatformDriverData { _reg: reg };
>
> // We need this to be dev_info!() because dev_dbg!() does not work at
> // all in Rust for now, and we need to see whether probe succeeded.
> @@ -184,8 +184,8 @@ fn drop(self: Pin<&mut Self>) {}
>
> #[vtable]
> impl drm::Driver for TyrDrmDriver {
> - type Data = TyrDrmDeviceData;
> - type RegistrationData<'a> = ();
> + type Data = ();
> + 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..9f60a90d4948 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]
> @@ -31,15 +32,15 @@ fn open(_dev: &drm::Device<Self::Driver>) -> Result<Pin<KBox<Self>>> {
>
> impl TyrDrmFileData {
> pub(crate) fn dev_query(
> - ddev: &TyrDrmDevice<Registered>,
> - _reg_data: &(),
> + _ddev: &TyrDrmDevice<Registered>,
> + reg_data: &TyrDrmRegistrationData<'_>,
> devquery: &mut uapi::drm_panthor_dev_query,
> _file: &TyrDrmFile,
> ) -> Result<u32> {
> if devquery.pointer == 0 {
> match devquery.type_ {
> uapi::drm_panthor_dev_query_type_DRM_PANTHOR_DEV_QUERY_GPU_INFO => {
> - devquery.size = core::mem::size_of_val(&ddev.gpu_info) as u32;
> + devquery.size = core::mem::size_of_val(®_data.gpu_info) as u32;
> Ok(0)
> }
> _ => Err(EINVAL),
> @@ -53,7 +54,7 @@ pub(crate) fn dev_query(
> )
> .writer();
>
> - writer.write(&ddev.gpu_info)?;
> + writer.write(®_data.gpu_info)?;
>
> Ok(0)
> }
>
> --
> 2.54.0
>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
next prev parent reply other threads:[~2026-07-15 21:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-09 21:36 [PATCH v6 0/7] drm/tyr: firmware loading and MCU boot support Deborah Brouwer
2026-07-09 21:36 ` [PATCH v6 1/7] drm/tyr: add resources to RegistrationData Deborah Brouwer
2026-07-15 21:51 ` Daniel Almeida [this message]
2026-07-09 21:36 ` [PATCH v6 2/7] drm/tyr: add a generic slot manager Deborah Brouwer
2026-07-10 13:23 ` Alice Ryhl
2026-07-15 23:17 ` Daniel Almeida
2026-07-09 21:36 ` [PATCH v6 3/7] drm/tyr: add Memory Management Unit (MMU) support Deborah Brouwer
2026-07-10 13:45 ` Alice Ryhl
2026-07-16 23:24 ` Daniel Almeida
2026-07-09 21:36 ` [PATCH v6 4/7] drm/tyr: add GPU virtual memory (VM) support Deborah Brouwer
2026-07-10 14:15 ` Alice Ryhl
2026-07-14 3:12 ` Deborah Brouwer
2026-07-10 14:27 ` Alice Ryhl
2026-07-09 21:36 ` [PATCH v6 5/7] drm/tyr: add a kernel buffer object Deborah Brouwer
2026-07-09 21:36 ` [PATCH v6 6/7] drm/tyr: add parser for firmware binary Deborah Brouwer
2026-07-09 21:36 ` [PATCH v6 7/7] drm/tyr: add Microcontroller Unit (MCU) booting Deborah Brouwer
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=5D445C5B-6C4D-49CE-98B2-3BCD68014626@collabora.com \
--to=daniel.almeida@collabora.com \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=alvin.sun@linux.dev \
--cc=beata.michalska@arm.com \
--cc=boris.brezillon@collabora.com \
--cc=dakr@kernel.org \
--cc=deborah.brouwer@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gary@garyguo.net \
--cc=laura.nao@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=lyude@redhat.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=samitolvanen@google.com \
--cc=simona@ffwll.ch \
--cc=steven.price@arm.com \
--cc=work@onurozkan.dev \
/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