public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/12] drm/tyr: Use register! macro
@ 2026-03-24  0:18 Deborah Brouwer
  2026-03-24  0:18 ` [PATCH v3 01/12] drm/tyr: Use register! macro for GPU_CONTROL Deborah Brouwer
                   ` (12 more replies)
  0 siblings, 13 replies; 30+ messages in thread
From: Deborah Brouwer @ 2026-03-24  0:18 UTC (permalink / raw)
  To: dri-devel, rust-for-linux, Boqun Feng
  Cc: Danilo Krummrich, Alice Ryhl, Daniel Almeida, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Miguel Ojeda, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Trevor Gross, Steven Price, Boris Brezillon,
	Dirk Behme, Alexandre Courbot, Deborah Brouwer, Boqun Feng

This series changes the Tyr driver to use the kernel's register! macro
for hardware register access, replacing manual bit manipulation and custom
register structures with a more type-safe and maintainable approach.

---
Changes in v3:
- Update write_val() with write_reg() from API change.
- Replace const values with enums and use => ?=> syntax.
- Convert 1-bit fields to bool.
- Change module visibility from pub(super) to pub(crate).
- Add new commits to define mmu address registers.
- Add new commit exposing hardware DOORBELLS.
- Pick up Reviewed-by tags.

There are also change logs per patch.

- Link to v2: https://lore.kernel.org/r/20260311-b4-tyr-use-register-macro-v2-v2-0-b936d9eb8f51@collabora.com

This series applies on drm-rust-next.
base-commit: a19457958c30

Changes in v2:
- Rebase on v8 of register! macro series;
- Add documentation;
- Remove manual functions to get address bits;
- Revise gpu_info() to use macro;
- Revise l2_power_on() to use macro;
- Set interconnect coherency protocol with macro;
- Separate commits for each register page;
- Replace HI/LO pairs with 64bit registers
- Order registers by address;
- Remove doorbell clear field from GPU_IRQ_CLEAR;
- GPU command is redesigned to accommodate multiple layouts;
- MMU register bits corrected;
- Use UPPERCASE for register names;
- Move the consts to impl block for registers;

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>

---
Daniel Almeida (1):
      drm/tyr: Use register! macro for GPU_CONTROL

Deborah Brouwer (11):
      drm/tyr: Print GPU_ID without filtering
      drm/tyr: Set interconnect coherency during probe
      drm/tyr: Use register! macro for JOB_CONTROL
      drm/tyr: Use register! macro for MMU_CONTROL
      drm/tyr: Remove custom register struct
      drm/tyr: Add MMU address space registers
      drm/tyr: Add fields for MEMATTR register
      drm/tyr: Add fields for COMMAND register
      drm/tyr: Add fields for FAULTSTATUS register
      drm/tyr: Add fields for TRANSCFG register
      drm/tyr: Add DOORBELL_BLOCK registers

 drivers/gpu/drm/tyr/driver.rs |   29 +-
 drivers/gpu/drm/tyr/gpu.rs    |  213 +++---
 drivers/gpu/drm/tyr/regs.rs   | 1587 ++++++++++++++++++++++++++++++++++++++---
 3 files changed, 1589 insertions(+), 240 deletions(-)
---
base-commit: a19457958c3018783881c4416f272cd594f13049
change-id: 20260323-b4-tyr-use-register-macro-v3-d4366a02e975

Best regards,
-- 
Deborah Brouwer <deborah.brouwer@collabora.com>


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH v3 01/12] drm/tyr: Use register! macro for GPU_CONTROL
  2026-03-24  0:18 [PATCH v3 00/12] drm/tyr: Use register! macro Deborah Brouwer
@ 2026-03-24  0:18 ` Deborah Brouwer
  2026-03-24  9:56   ` Boris Brezillon
  2026-03-24 11:23   ` Danilo Krummrich
  2026-03-24  0:18 ` [PATCH v3 02/12] drm/tyr: Print GPU_ID without filtering Deborah Brouwer
                   ` (11 subsequent siblings)
  12 siblings, 2 replies; 30+ messages in thread
From: Deborah Brouwer @ 2026-03-24  0:18 UTC (permalink / raw)
  To: dri-devel, rust-for-linux, Boqun Feng
  Cc: Danilo Krummrich, Alice Ryhl, Daniel Almeida, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Miguel Ojeda, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Trevor Gross, Steven Price, Boris Brezillon,
	Dirk Behme, Alexandre Courbot, Deborah Brouwer, Boqun Feng

From: Daniel Almeida <daniel.almeida@collabora.com>

Convert the GPU_CONTROL register definitions to use the `register!` macro.

Using the `register!` macro allows us to replace manual bit masks and
shifts with typed register and field accessors, which makes the code
easier to read and avoids errors from bit manipulation.

Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com>
Co-developed-by: Deborah Brouwer <deborah.brouwer@collabora.com>
Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
---
 drivers/gpu/drm/tyr/driver.rs |  24 +-
 drivers/gpu/drm/tyr/gpu.rs    | 211 +++++------
 drivers/gpu/drm/tyr/regs.rs   | 803 +++++++++++++++++++++++++++++++++++++++---
 3 files changed, 842 insertions(+), 196 deletions(-)

diff --git a/drivers/gpu/drm/tyr/driver.rs b/drivers/gpu/drm/tyr/driver.rs
index 611434641580574ec6b5afa49a8fe79888bb7ace..3ebb5e08bfca342f136e8d365b1d9dcb6cc3dbca 100644
--- a/drivers/gpu/drm/tyr/driver.rs
+++ b/drivers/gpu/drm/tyr/driver.rs
@@ -13,7 +13,10 @@
     devres::Devres,
     drm,
     drm::ioctl,
-    io::poll,
+    io::{
+        poll,
+        Io, //
+    },
     new_mutex,
     of,
     platform,
@@ -33,8 +36,11 @@
     file::TyrDrmFileData,
     gem::TyrObject,
     gpu,
-    gpu::GpuInfo,
-    regs, //
+    gpu::{
+        gpu_info_log, //
+        GpuInfo,
+    },
+    regs::gpu_control::*, //
 };
 
 pub(crate) type IoMem = kernel::io::mem::IoMem<SZ_2M>;
@@ -78,11 +84,15 @@ unsafe impl Send for TyrDrmDeviceData {}
 unsafe impl Sync for TyrDrmDeviceData {}
 
 fn issue_soft_reset(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result {
-    regs::GPU_CMD.write(dev, iomem, regs::GPU_CMD_SOFT_RESET)?;
+    let io = (*iomem).access(dev)?;
+    io.write_reg(GPU_COMMAND::reset(ResetMode::SoftReset));
 
     poll::read_poll_timeout(
-        || regs::GPU_IRQ_RAWSTAT.read(dev, iomem),
-        |status| *status & regs::GPU_IRQ_RAWSTAT_RESET_COMPLETED != 0,
+        || {
+            let io = (*iomem).access(dev)?;
+            Ok(io.read(GPU_IRQ_RAWSTAT))
+        },
+        |status| status.reset_completed(),
         time::Delta::from_millis(1),
         time::Delta::from_millis(100),
     )
@@ -127,7 +137,7 @@ fn probe(
         gpu::l2_power_on(pdev.as_ref(), &iomem)?;
 
         let gpu_info = GpuInfo::new(pdev.as_ref(), &iomem)?;
-        gpu_info.log(pdev);
+        gpu_info_log(pdev.as_ref(), &iomem)?;
 
         let platform: ARef<platform::Device> = pdev.into();
 
diff --git a/drivers/gpu/drm/tyr/gpu.rs b/drivers/gpu/drm/tyr/gpu.rs
index a88775160f981e899e9c9b58debbda33e1b7244d..66fd6c016c62abe3c34669a2e47b680c3a3f873d 100644
--- a/drivers/gpu/drm/tyr/gpu.rs
+++ b/drivers/gpu/drm/tyr/gpu.rs
@@ -5,14 +5,16 @@
     DerefMut, //
 };
 use kernel::{
-    bits::genmask_u32,
     device::{
         Bound,
         Device, //
     },
     devres::Devres,
-    io::poll,
-    platform,
+    io::{
+        poll,
+        register::Array,
+        Io, //
+    },
     prelude::*,
     time::Delta,
     transmute::AsBytes,
@@ -21,7 +23,7 @@
 
 use crate::{
     driver::IoMem,
-    regs, //
+    regs::gpu_control::*, //
 };
 
 /// Struct containing information that can be queried by userspace. This is read from
@@ -29,120 +31,46 @@
 ///
 /// # Invariants
 ///
-/// - The layout of this struct identical to the C `struct drm_panthor_gpu_info`.
+/// - The layout of this struct is identical to the C `struct drm_panthor_gpu_info`.
 #[repr(transparent)]
 #[derive(Clone, Copy)]
 pub(crate) struct GpuInfo(pub(crate) uapi::drm_panthor_gpu_info);
 
 impl GpuInfo {
     pub(crate) fn new(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result<Self> {
-        let gpu_id = regs::GPU_ID.read(dev, iomem)?;
-        let csf_id = regs::GPU_CSF_ID.read(dev, iomem)?;
-        let gpu_rev = regs::GPU_REVID.read(dev, iomem)?;
-        let core_features = regs::GPU_CORE_FEATURES.read(dev, iomem)?;
-        let l2_features = regs::GPU_L2_FEATURES.read(dev, iomem)?;
-        let tiler_features = regs::GPU_TILER_FEATURES.read(dev, iomem)?;
-        let mem_features = regs::GPU_MEM_FEATURES.read(dev, iomem)?;
-        let mmu_features = regs::GPU_MMU_FEATURES.read(dev, iomem)?;
-        let thread_features = regs::GPU_THREAD_FEATURES.read(dev, iomem)?;
-        let max_threads = regs::GPU_THREAD_MAX_THREADS.read(dev, iomem)?;
-        let thread_max_workgroup_size = regs::GPU_THREAD_MAX_WORKGROUP_SIZE.read(dev, iomem)?;
-        let thread_max_barrier_size = regs::GPU_THREAD_MAX_BARRIER_SIZE.read(dev, iomem)?;
-        let coherency_features = regs::GPU_COHERENCY_FEATURES.read(dev, iomem)?;
-
-        let texture_features = regs::GPU_TEXTURE_FEATURES0.read(dev, iomem)?;
-
-        let as_present = regs::GPU_AS_PRESENT.read(dev, iomem)?;
-
-        let shader_present = u64::from(regs::GPU_SHADER_PRESENT_LO.read(dev, iomem)?);
-        let shader_present =
-            shader_present | u64::from(regs::GPU_SHADER_PRESENT_HI.read(dev, iomem)?) << 32;
-
-        let tiler_present = u64::from(regs::GPU_TILER_PRESENT_LO.read(dev, iomem)?);
-        let tiler_present =
-            tiler_present | u64::from(regs::GPU_TILER_PRESENT_HI.read(dev, iomem)?) << 32;
-
-        let l2_present = u64::from(regs::GPU_L2_PRESENT_LO.read(dev, iomem)?);
-        let l2_present = l2_present | u64::from(regs::GPU_L2_PRESENT_HI.read(dev, iomem)?) << 32;
+        let io = (*iomem).access(dev)?;
 
         Ok(Self(uapi::drm_panthor_gpu_info {
-            gpu_id,
-            gpu_rev,
-            csf_id,
-            l2_features,
-            tiler_features,
-            mem_features,
-            mmu_features,
-            thread_features,
-            max_threads,
-            thread_max_workgroup_size,
-            thread_max_barrier_size,
-            coherency_features,
-            // TODO: Add texture_features_{1,2,3}.
-            texture_features: [texture_features, 0, 0, 0],
-            as_present,
+            gpu_id: io.read(GPU_ID).into_raw(),
+            gpu_rev: io.read(REVIDR).into_raw(),
+            csf_id: io.read(CSF_ID).into_raw(),
+            l2_features: io.read(L2_FEATURES).into_raw(),
+            tiler_features: io.read(TILER_FEATURES).into_raw(),
+            mem_features: io.read(MEM_FEATURES).into_raw(),
+            mmu_features: io.read(MMU_FEATURES).into_raw(),
+            thread_features: io.read(THREAD_FEATURES).into_raw(),
+            max_threads: io.read(THREAD_MAX_THREADS).into_raw(),
+            thread_max_workgroup_size: io.read(THREAD_MAX_WORKGROUP_SIZE).into_raw(),
+            thread_max_barrier_size: io.read(THREAD_MAX_BARRIER_SIZE).into_raw(),
+            coherency_features: io.read(COHERENCY_FEATURES).into_raw(),
+            texture_features: [
+                io.read(TEXTURE_FEATURES::at(0)).supported_formats().get(),
+                io.read(TEXTURE_FEATURES::at(1)).supported_formats().get(),
+                io.read(TEXTURE_FEATURES::at(2)).supported_formats().get(),
+                io.read(TEXTURE_FEATURES::at(3)).supported_formats().get(),
+            ],
+            as_present: io.read(AS_PRESENT).into_raw(),
             selected_coherency: uapi::drm_panthor_gpu_coherency_DRM_PANTHOR_GPU_COHERENCY_NONE,
-            shader_present,
-            l2_present,
-            tiler_present,
-            core_features,
+            shader_present: io.read(SHADER_PRESENT).into_raw(),
+            l2_present: io.read(L2_PRESENT).into_raw(),
+            tiler_present: io.read(TILER_PRESENT).into_raw(),
+            core_features: io.read(CORE_FEATURES).into_raw(),
+            // Padding must be zero.
             pad: 0,
+            //GPU_FEATURES register is not available; it was introduced in arch 11.x.
             gpu_features: 0,
         }))
     }
-
-    pub(crate) fn log(&self, pdev: &platform::Device) {
-        let gpu_id = GpuId::from(self.gpu_id);
-
-        let model_name = if let Some(model) = GPU_MODELS
-            .iter()
-            .find(|&f| f.arch_major == gpu_id.arch_major && f.prod_major == gpu_id.prod_major)
-        {
-            model.name
-        } else {
-            "unknown"
-        };
-
-        dev_info!(
-            pdev,
-            "mali-{} id 0x{:x} major 0x{:x} minor 0x{:x} status 0x{:x}",
-            model_name,
-            self.gpu_id >> 16,
-            gpu_id.ver_major,
-            gpu_id.ver_minor,
-            gpu_id.ver_status
-        );
-
-        dev_info!(
-            pdev,
-            "Features: L2:{:#x} Tiler:{:#x} Mem:{:#x} MMU:{:#x} AS:{:#x}",
-            self.l2_features,
-            self.tiler_features,
-            self.mem_features,
-            self.mmu_features,
-            self.as_present
-        );
-
-        dev_info!(
-            pdev,
-            "shader_present=0x{:016x} l2_present=0x{:016x} tiler_present=0x{:016x}",
-            self.shader_present,
-            self.l2_present,
-            self.tiler_present
-        );
-    }
-
-    /// Returns the number of virtual address bits supported by the GPU.
-    #[expect(dead_code)]
-    pub(crate) fn va_bits(&self) -> u32 {
-        self.mmu_features & genmask_u32(0..=7)
-    }
-
-    /// Returns the number of physical address bits supported by the GPU.
-    #[expect(dead_code)]
-    pub(crate) fn pa_bits(&self) -> u32 {
-        (self.mmu_features >> 8) & genmask_u32(0..=7)
-    }
 }
 
 impl Deref for GpuInfo {
@@ -182,38 +110,59 @@ struct GpuModels {
     prod_major: 7,
 }];
 
-#[allow(dead_code)]
-pub(crate) struct GpuId {
-    pub(crate) arch_major: u32,
-    pub(crate) arch_minor: u32,
-    pub(crate) arch_rev: u32,
-    pub(crate) prod_major: u32,
-    pub(crate) ver_major: u32,
-    pub(crate) ver_minor: u32,
-    pub(crate) ver_status: u32,
-}
-
-impl From<u32> for GpuId {
-    fn from(value: u32) -> Self {
-        GpuId {
-            arch_major: (value & genmask_u32(28..=31)) >> 28,
-            arch_minor: (value & genmask_u32(24..=27)) >> 24,
-            arch_rev: (value & genmask_u32(20..=23)) >> 20,
-            prod_major: (value & genmask_u32(16..=19)) >> 16,
-            ver_major: (value & genmask_u32(12..=15)) >> 12,
-            ver_minor: (value & genmask_u32(4..=11)) >> 4,
-            ver_status: value & genmask_u32(0..=3),
-        }
-    }
+pub(crate) fn gpu_info_log(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result {
+    let io = (*iomem).access(dev)?;
+    let gpu_id = io.read(GPU_ID);
+
+    let model_name = if let Some(model) = GPU_MODELS.iter().find(|&f| {
+        f.arch_major == gpu_id.arch_major().get() && f.prod_major == gpu_id.prod_major().get()
+    }) {
+        model.name
+    } else {
+        "unknown"
+    };
+
+    dev_info!(
+        dev,
+        "mali-{} id 0x{:x} major 0x{:x} minor 0x{:x} status 0x{:x}",
+        model_name,
+        gpu_id.into_raw() >> 16,
+        gpu_id.ver_major().get(),
+        gpu_id.ver_minor().get(),
+        gpu_id.ver_status().get()
+    );
+
+    dev_info!(
+        dev,
+        "Features: L2:{:#x} Tiler:{:#x} Mem:{:#x} MMU:{:#x} AS:{:#x}",
+        io.read(L2_FEATURES).into_raw(),
+        io.read(TILER_FEATURES).into_raw(),
+        io.read(MEM_FEATURES).into_raw(),
+        io.read(MMU_FEATURES).into_raw(),
+        io.read(AS_PRESENT).into_raw(),
+    );
+
+    dev_info!(
+        dev,
+        "shader_present=0x{:016x} l2_present=0x{:016x} tiler_present=0x{:016x}",
+        io.read(SHADER_PRESENT).into_raw(),
+        io.read(L2_PRESENT).into_raw(),
+        io.read(TILER_PRESENT).into_raw(),
+    );
+    Ok(())
 }
 
 /// Powers on the l2 block.
 pub(crate) fn l2_power_on(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result {
-    regs::L2_PWRON_LO.write(dev, iomem, 1)?;
+    let io = (*iomem).access(dev)?;
+    io.write_reg(L2_PWRON::zeroed().with_const_request::<1>());
 
     poll::read_poll_timeout(
-        || regs::L2_READY_LO.read(dev, iomem),
-        |status| *status == 1,
+        || {
+            let io = (*iomem).access(dev)?;
+            Ok(io.read(L2_READY))
+        },
+        |status| status.ready() == 1,
         Delta::from_millis(1),
         Delta::from_millis(100),
     )
diff --git a/drivers/gpu/drm/tyr/regs.rs b/drivers/gpu/drm/tyr/regs.rs
index 611870c2e6af50a35daaef052db2dd33a7e8059c..5ba4919263af29c6e88435099cf801fa5874b117 100644
--- a/drivers/gpu/drm/tyr/regs.rs
+++ b/drivers/gpu/drm/tyr/regs.rs
@@ -1,5 +1,25 @@
 // SPDX-License-Identifier: GPL-2.0 or MIT
 
+//! # Definitions
+//!
+//! - **CEU**: Command Execution Unit - A hardware component that executes commands (instructions)
+//!   from the command stream.
+//! - **CS**: Command Stream - A sequence of instructions (commands) used to control a particular
+//!   job or sequence of jobs. The instructions exist in one or more command buffers.
+//! - **CSF**: Command Stream Frontend - The interface and implementation for job submission
+//!   exposed to the host CPU driver. This includes the global interface, as well as CSG and CS
+//!   interfaces.
+//! - **CSG**: Command Stream Group - A group of related command streams. The CSF manages multiple
+//!   CSGs, and each CSG contains multiple CSs.
+//! - **CSHW**: Command Stream Hardware - The hardware interpreting command streams, including the
+//!   iterator control aspects. Implements the CSF in conjunction with the MCU.
+//! - **GLB**: Global - Prefix for global interface registers that control operations common to
+//!   all CSs.
+//! - **JASID**: Job Address Space ID - Identifies the address space for a job.
+//! - **MCU**: Microcontroller Unit - Implements the CSF in conjunction with the command stream
+//!   hardware.
+//! - **MMU**: Memory Management Unit - Handles address translation and memory access protection.
+
 // We don't expect that all the registers and fields will be used, even in the
 // future.
 //
@@ -41,64 +61,731 @@ pub(crate) fn write(&self, dev: &Device<Bound>, iomem: &Devres<IoMem>, value: u3
     }
 }
 
-pub(crate) const GPU_ID: Register<0x0> = Register;
-pub(crate) const GPU_L2_FEATURES: Register<0x4> = Register;
-pub(crate) const GPU_CORE_FEATURES: Register<0x8> = Register;
-pub(crate) const GPU_CSF_ID: Register<0x1c> = Register;
-pub(crate) const GPU_REVID: Register<0x280> = Register;
-pub(crate) const GPU_TILER_FEATURES: Register<0xc> = Register;
-pub(crate) const GPU_MEM_FEATURES: Register<0x10> = Register;
-pub(crate) const GPU_MMU_FEATURES: Register<0x14> = Register;
-pub(crate) const GPU_AS_PRESENT: Register<0x18> = Register;
-pub(crate) const GPU_IRQ_RAWSTAT: Register<0x20> = Register;
-
-pub(crate) const GPU_IRQ_RAWSTAT_FAULT: u32 = bit_u32(0);
-pub(crate) const GPU_IRQ_RAWSTAT_PROTECTED_FAULT: u32 = bit_u32(1);
-pub(crate) const GPU_IRQ_RAWSTAT_RESET_COMPLETED: u32 = bit_u32(8);
-pub(crate) const GPU_IRQ_RAWSTAT_POWER_CHANGED_SINGLE: u32 = bit_u32(9);
-pub(crate) const GPU_IRQ_RAWSTAT_POWER_CHANGED_ALL: u32 = bit_u32(10);
-pub(crate) const GPU_IRQ_RAWSTAT_CLEAN_CACHES_COMPLETED: u32 = bit_u32(17);
-pub(crate) const GPU_IRQ_RAWSTAT_DOORBELL_STATUS: u32 = bit_u32(18);
-pub(crate) const GPU_IRQ_RAWSTAT_MCU_STATUS: u32 = bit_u32(19);
-
-pub(crate) const GPU_IRQ_CLEAR: Register<0x24> = Register;
-pub(crate) const GPU_IRQ_MASK: Register<0x28> = Register;
-pub(crate) const GPU_IRQ_STAT: Register<0x2c> = Register;
-pub(crate) const GPU_CMD: Register<0x30> = Register;
-pub(crate) const GPU_CMD_SOFT_RESET: u32 = 1 | (1 << 8);
-pub(crate) const GPU_CMD_HARD_RESET: u32 = 1 | (2 << 8);
-pub(crate) const GPU_THREAD_FEATURES: Register<0xac> = Register;
-pub(crate) const GPU_THREAD_MAX_THREADS: Register<0xa0> = Register;
-pub(crate) const GPU_THREAD_MAX_WORKGROUP_SIZE: Register<0xa4> = Register;
-pub(crate) const GPU_THREAD_MAX_BARRIER_SIZE: Register<0xa8> = Register;
-pub(crate) const GPU_TEXTURE_FEATURES0: Register<0xb0> = Register;
-pub(crate) const GPU_SHADER_PRESENT_LO: Register<0x100> = Register;
-pub(crate) const GPU_SHADER_PRESENT_HI: Register<0x104> = Register;
-pub(crate) const GPU_TILER_PRESENT_LO: Register<0x110> = Register;
-pub(crate) const GPU_TILER_PRESENT_HI: Register<0x114> = Register;
-pub(crate) const GPU_L2_PRESENT_LO: Register<0x120> = Register;
-pub(crate) const GPU_L2_PRESENT_HI: Register<0x124> = Register;
-pub(crate) const L2_READY_LO: Register<0x160> = Register;
-pub(crate) const L2_READY_HI: Register<0x164> = Register;
-pub(crate) const L2_PWRON_LO: Register<0x1a0> = Register;
-pub(crate) const L2_PWRON_HI: Register<0x1a4> = Register;
-pub(crate) const L2_PWRTRANS_LO: Register<0x220> = Register;
-pub(crate) const L2_PWRTRANS_HI: Register<0x204> = Register;
-pub(crate) const L2_PWRACTIVE_LO: Register<0x260> = Register;
-pub(crate) const L2_PWRACTIVE_HI: Register<0x264> = Register;
-
-pub(crate) const MCU_CONTROL: Register<0x700> = Register;
-pub(crate) const MCU_CONTROL_ENABLE: u32 = 1;
-pub(crate) const MCU_CONTROL_AUTO: u32 = 2;
-pub(crate) const MCU_CONTROL_DISABLE: u32 = 0;
-
-pub(crate) const MCU_STATUS: Register<0x704> = Register;
-pub(crate) const MCU_STATUS_DISABLED: u32 = 0;
-pub(crate) const MCU_STATUS_ENABLED: u32 = 1;
-pub(crate) const MCU_STATUS_HALT: u32 = 2;
-pub(crate) const MCU_STATUS_FATAL: u32 = 3;
-
-pub(crate) const GPU_COHERENCY_FEATURES: Register<0x300> = Register;
+/// These registers correspond to the GPU_CONTROL register page.
+/// They are involved in GPU configuration and control.
+pub(crate) mod gpu_control {
+    use core::convert::TryFrom;
+    use kernel::{
+        error::{
+            code::EINVAL,
+            Error, //
+        },
+        num::Bounded,
+        register,
+        uapi, //
+    };
+    use pin_init::Zeroable;
+
+    register! {
+        /// GPU identification register.
+        pub(crate) GPU_ID(u32) @ 0x0 {
+            /// Status of the GPU release.
+            3:0     ver_status;
+            /// Minor release version number.
+            11:4    ver_minor;
+            /// Major release version number.
+            15:12   ver_major;
+            /// Product identifier.
+            19:16   prod_major;
+            /// Architecture patch revision.
+            23:20   arch_rev;
+            /// Architecture minor revision.
+            27:24   arch_minor;
+            /// Architecture major revision.
+            31:28   arch_major;
+        }
+
+        /// Level 2 cache features register.
+        pub(crate) L2_FEATURES(u32) @ 0x4 {
+            /// Cache line size.
+            7:0     line_size;
+            /// Cache associativity.
+            15:8    associativity;
+            /// Cache slice size.
+            23:16   cache_size;
+            /// External bus width.
+            31:24   bus_width;
+        }
+
+        /// Shader core features.
+        pub(crate) CORE_FEATURES(u32) @ 0x8 {
+            /// Shader core variant.
+            7:0     core_variant;
+        }
+
+        /// Tiler features.
+        pub(crate) TILER_FEATURES(u32) @ 0xc {
+            /// Log of the tiler's bin size.
+            5:0     bin_size;
+            /// Maximum number of active levels.
+            11:8    max_levels;
+        }
+
+        /// Memory system features.
+        pub(crate) MEM_FEATURES(u32) @ 0x10 {
+            0:0     coherent_core_group => bool;
+            1:1     coherent_super_group => bool;
+            11:8    l2_slices;
+        }
+
+        /// Memory management unit features.
+        pub(crate) MMU_FEATURES(u32) @ 0x14 {
+            /// Number of bits supported in virtual addresses.
+            7:0     va_bits;
+            /// Number of bits supported in physical addresses.
+            15:8    pa_bits;
+        }
+
+        /// Address spaces present.
+        pub(crate) AS_PRESENT(u32) @ 0x18 {
+            31:0    present;
+        }
+
+        /// CSF version information.
+        pub(crate) CSF_ID(u32) @ 0x1c {
+            /// MCU revision ID.
+            3:0     mcu_rev;
+            /// MCU minor revision number.
+            9:4     mcu_minor;
+            /// MCU major revision number.
+            15:10   mcu_major;
+            /// CSHW revision ID.
+            19:16   cshw_rev;
+            /// CSHW minor revision number.
+            25:20   cshw_minor;
+            /// CSHW major revision number.
+            31:26   cshw_major;
+        }
+
+        /// IRQ sources raw status.
+        /// Writing to this register forces bits on, but does not clear them.
+        pub(crate) GPU_IRQ_RAWSTAT(u32) @ 0x20 {
+            /// A GPU fault has occurred, a 1-bit boolean flag.
+            0:0     gpu_fault => bool;
+            /// A GPU fault has occurred, a 1-bit boolean flag.
+            1:1     gpu_protected_fault => bool;
+            /// Reset has completed, a 1-bit boolean flag.
+            8:8     reset_completed => bool;
+            /// Set when a single power domain has powered up or down, a 1-bit boolean flag.
+            9:9     power_changed_single => bool;
+            /// Set when the all pending power domain changes are completed, a 1-bit boolean flag.
+            10:10   power_changed_all => bool;
+            /// Set when cache cleaning has completed, a 1-bit boolean flag.
+            17:17   clean_caches_completed => bool;
+            /// Mirrors the doorbell interrupt line to the CPU, a 1-bit boolean flag.
+            18:18   doorbell_mirror => bool;
+            /// MCU requires attention, a 1-bit boolean flag.
+            19:19   mcu_status => bool;
+        }
+
+        /// IRQ sources to clear. Write only.
+        pub(crate) GPU_IRQ_CLEAR(u32) @ 0x24 {
+            /// Clear the GPU_FAULT interrupt, a 1-bit boolean flag.
+            0:0     gpu_fault => bool;
+            /// Clear the GPU_PROTECTED_FAULT interrupt, a 1-bit boolean flag.
+            1:1     gpu_protected_fault => bool;
+            /// Clear the RESET_COMPLETED interrupt, a 1-bit boolean flag.
+            8:8     reset_completed => bool;
+            /// Clear the POWER_CHANGED_SINGLE interrupt, a 1-bit boolean flag.
+            9:9     power_changed_single => bool;
+            /// Clear the POWER_CHANGED_ALL interrupt, a 1-bit boolean flag.
+            10:10   power_changed_all => bool;
+            /// Clear the CLEAN_CACHES_COMPLETED interrupt, a 1-bit boolean flag.
+            17:17   clean_caches_completed => bool;
+            /// Clear the MCU_STATUS interrupt, a 1-bit boolean flag.
+            19:19   mcu_status => bool;
+        }
+
+        /// IRQ sources enabled.
+        pub(crate) GPU_IRQ_MASK(u32) @ 0x28 {
+            /// Enable the GPU_FAULT interrupt, a 1-bit boolean flag.
+            0:0     gpu_fault => bool;
+            /// Enable the GPU_PROTECTED_FAULT interrupt, a 1-bit boolean flag.
+            1:1     gpu_protected_fault => bool;
+            /// Enable the RESET_COMPLETED interrupt, a 1-bit boolean flag.
+            8:8     reset_completed => bool;
+            /// Enable the POWER_CHANGED_SINGLE interrupt, a 1-bit boolean flag.
+            9:9     power_changed_single => bool;
+            /// Enable the POWER_CHANGED_ALL interrupt, a 1-bit boolean flag.
+            10:10   power_changed_all => bool;
+            /// Enable the CLEAN_CACHES_COMPLETED interrupt, a 1-bit boolean flag.
+            17:17   clean_caches_completed => bool;
+            /// Enable the DOORBELL_MIRROR interrupt, a 1-bit boolean flag.
+            18:18   doorbell_mirror => bool;
+            /// Enable the MCU_STATUS interrupt, a 1-bit boolean flag.
+            19:19   mcu_status => bool;
+        }
+
+        /// IRQ status for enabled sources. Read only.
+        pub(crate) GPU_IRQ_STATUS(u32) @ 0x2c {
+            /// GPU_FAULT interrupt status, a 1-bit boolean flag.
+            0:0     gpu_fault => bool;
+            /// GPU_PROTECTED_FAULT interrupt status, a 1-bit boolean flag.
+            1:1     gpu_protected_fault => bool;
+            /// RESET_COMPLETED interrupt status, a 1-bit boolean flag.
+            8:8     reset_completed => bool;
+            /// POWER_CHANGED_SINGLE interrupt status, a 1-bit boolean flag.
+            9:9     power_changed_single => bool;
+            /// POWER_CHANGED_ALL interrupt status, a 1-bit boolean flag.
+            10:10   power_changed_all => bool;
+            /// CLEAN_CACHES_COMPLETED interrupt status, a 1-bit boolean flag.
+            17:17   clean_caches_completed => bool;
+            /// DOORBELL_MIRROR interrupt status, a 1-bit boolean flag.
+            18:18   doorbell_mirror => bool;
+            /// MCU_STATUS interrupt status, a 1-bit boolean flag.
+            19:19   mcu_status => bool;
+        }
+    }
+
+    /// Helpers for GPU_COMMAND Register
+    #[derive(Copy, Clone, Debug)]
+    #[repr(u8)]
+    pub(crate) enum GpuCommand {
+        /// No operation. This is the default value.
+        Nop = 0,
+        /// Reset the GPU.
+        Reset = 1,
+        /// Flush caches.
+        FlushCaches = 4,
+        /// Clear GPU faults.
+        ClearFault = 7,
+    }
+
+    impl TryFrom<Bounded<u32, 8>> for GpuCommand {
+        type Error = Error;
+
+        fn try_from(val: Bounded<u32, 8>) -> Result<Self, Self::Error> {
+            match val.get() {
+                0 => Ok(GpuCommand::Nop),
+                1 => Ok(GpuCommand::Reset),
+                4 => Ok(GpuCommand::FlushCaches),
+                7 => Ok(GpuCommand::ClearFault),
+                _ => Err(EINVAL),
+            }
+        }
+    }
+
+    impl From<GpuCommand> for Bounded<u32, 8> {
+        fn from(cmd: GpuCommand) -> Self {
+            (cmd as u8).into()
+        }
+    }
+
+    /// Reset mode for [`GPU_COMMAND::reset()`].
+    #[derive(Copy, Clone, Debug)]
+    #[repr(u8)]
+    pub(crate) enum ResetMode {
+        /// Stop all external bus interfaces, then reset the entire GPU.
+        SoftReset = 1,
+        /// Force a full GPU reset.
+        HardReset = 2,
+    }
+
+    impl TryFrom<Bounded<u32, 4>> for ResetMode {
+        type Error = Error;
+
+        fn try_from(val: Bounded<u32, 4>) -> Result<Self, Self::Error> {
+            match val.get() {
+                1 => Ok(ResetMode::SoftReset),
+                2 => Ok(ResetMode::HardReset),
+                _ => Err(EINVAL),
+            }
+        }
+    }
+
+    impl From<ResetMode> for Bounded<u32, 4> {
+        fn from(mode: ResetMode) -> Self {
+            Bounded::try_new(mode as u32).unwrap()
+        }
+    }
+
+    /// Cache flush mode for [`GPU_COMMAND::flush_caches()`].
+    #[derive(Copy, Clone, Debug)]
+    #[repr(u8)]
+    pub(crate) enum FlushMode {
+        /// No flush.
+        None = 0,
+        /// Clean the caches.
+        Clean = 1,
+        /// Invalidate the caches.
+        Invalidate = 2,
+        /// Clean and invalidate the caches.
+        CleanInvalidate = 3,
+    }
+
+    impl TryFrom<Bounded<u32, 4>> for FlushMode {
+        type Error = Error;
+
+        fn try_from(val: Bounded<u32, 4>) -> Result<Self, Self::Error> {
+            match val.get() {
+                0 => Ok(FlushMode::None),
+                1 => Ok(FlushMode::Clean),
+                2 => Ok(FlushMode::Invalidate),
+                3 => Ok(FlushMode::CleanInvalidate),
+                _ => Err(EINVAL),
+            }
+        }
+    }
+
+    impl From<FlushMode> for Bounded<u32, 4> {
+        fn from(mode: FlushMode) -> Self {
+            Bounded::try_new(mode as u32).unwrap()
+        }
+    }
+
+    register! {
+        /// GPU command register.
+        ///
+        /// Use the constructor methods to create commands:
+        /// - [`GPU_COMMAND::nop()`]
+        /// - [`GPU_COMMAND::reset()`]
+        /// - [`GPU_COMMAND::flush_caches()`]
+        /// - [`GPU_COMMAND::clear_fault()`]
+        pub(crate) GPU_COMMAND (u32) @ 0x30 {
+            7:0     command ?=> GpuCommand;
+        }
+        /// Internal alias for GPU_COMMAND in reset mode.
+        /// Use [`GPU_COMMAND::reset()`] instead.
+        GPU_COMMAND_RESET (u32) => GPU_COMMAND {
+            7:0     command ?=> GpuCommand;
+            11:8    reset_mode ?=> ResetMode;
+        }
+
+        /// Internal alias for GPU_COMMAND in cache flush mode.
+        /// Use [`GPU_COMMAND::flush_caches()`] instead.
+        GPU_COMMAND_FLUSH (u32) => GPU_COMMAND {
+            7:0     command ?=> GpuCommand;
+            /// L2 cache flush mode.
+            11:8    l2_flush ?=> FlushMode;
+            /// Shader core load/store cache flush mode.
+            15:12   lsc_flush ?=> FlushMode;
+            /// Shader core other caches flush mode.
+            19:16   other_flush ?=> FlushMode;
+        }
+    }
+
+    impl GPU_COMMAND {
+        /// Create a NOP command.
+        pub(crate) fn nop() -> Self {
+            Self::zeroed()
+        }
+
+        /// Create a reset command with the specified reset mode.
+        pub(crate) fn reset(mode: ResetMode) -> Self {
+            Self::from_raw(
+                GPU_COMMAND_RESET::zeroed()
+                    .with_command(GpuCommand::Reset)
+                    .with_reset_mode(mode)
+                    .into_raw(),
+            )
+        }
+
+        /// Create a cache flush command with the specified flush modes.
+        pub(crate) fn flush_caches(l2: FlushMode, lsc: FlushMode, other: FlushMode) -> Self {
+            Self::from_raw(
+                GPU_COMMAND_FLUSH::zeroed()
+                    .with_command(GpuCommand::FlushCaches)
+                    .with_l2_flush(l2)
+                    .with_lsc_flush(lsc)
+                    .with_other_flush(other)
+                    .into_raw(),
+            )
+        }
+
+        /// Create a clear fault command.
+        pub(crate) fn clear_fault() -> Self {
+            Self::zeroed().with_command(GpuCommand::ClearFault)
+        }
+    }
+
+    register! {
+        /// GPU status register. Read only.
+        pub(crate) GPU_STATUS(u32) @ 0x34 {
+            /// GPU active, a 1-bit boolean flag.
+            0:0     gpu_active => bool;
+            /// Power manager active, a 1-bit boolean flag
+            1:1     pwr_active => bool;
+            /// Page fault active, a 1-bit boolean flag.
+            4:4     page_fault => bool;
+            /// Protected mode active, a 1-bit boolean flag.
+            7:7     protected_mode_active => bool;
+            /// Debug mode active, a 1-bit boolean flag.
+            8:8     gpu_dbg_enabled => bool;
+        }
+    }
+
+    #[derive(Copy, Clone, Debug)]
+    #[repr(u8)]
+    pub(crate) enum ExceptionType {
+        /// Exception type: No error.
+        Ok = 0x00,
+        /// Exception type: GPU external bus error.
+        GpuBusFault = 0x80,
+        /// Exception type: GPU shareability error.
+        GpuShareabilityFault = 0x88,
+        /// Exception type: System shareability error.
+        SystemShareabilityFault = 0x89,
+        /// Exception type: GPU cacheability error.
+        GpuCacheabilityFault = 0x8A,
+    }
+
+    impl TryFrom<Bounded<u32, 8>> for ExceptionType {
+        type Error = Error;
+
+        fn try_from(val: Bounded<u32, 8>) -> Result<Self, Self::Error> {
+            match val.get() {
+                0x00 => Ok(ExceptionType::Ok),
+                0x80 => Ok(ExceptionType::GpuBusFault),
+                0x88 => Ok(ExceptionType::GpuShareabilityFault),
+                0x89 => Ok(ExceptionType::SystemShareabilityFault),
+                0x8A => Ok(ExceptionType::GpuCacheabilityFault),
+                _ => Err(EINVAL),
+            }
+        }
+    }
+
+    impl From<ExceptionType> for Bounded<u32, 8> {
+        fn from(exc: ExceptionType) -> Self {
+            (exc as u8).into()
+        }
+    }
+
+    #[derive(Copy, Clone, Debug)]
+    #[repr(u8)]
+    pub(crate) enum AccessType {
+        /// Access type: An atomic (read/write) transaction.
+        Atomic = 0,
+        /// Access type: An execute transaction.
+        Execute = 1,
+        /// Access type: A read transaction.
+        Read = 2,
+        /// Access type: A write transaction.
+        Write = 3,
+    }
+
+    impl From<Bounded<u32, 2>> for AccessType {
+        fn from(val: Bounded<u32, 2>) -> Self {
+            match val.get() {
+                0 => AccessType::Atomic,
+                1 => AccessType::Execute,
+                2 => AccessType::Read,
+                3 => AccessType::Write,
+                _ => unreachable!(),
+            }
+        }
+    }
+
+    impl From<AccessType> for Bounded<u32, 2> {
+        fn from(access: AccessType) -> Self {
+            Bounded::try_new(access as u32).unwrap()
+        }
+    }
+
+    register! {
+        /// GPU fault status register. Read only.
+        pub(crate) GPU_FAULTSTATUS(u32) @ 0x3c {
+            /// Exception type.
+            7:0     exception_type ?=> ExceptionType;
+            /// Access type.
+            9:8     access_type => AccessType;
+            /// The GPU_FAULTADDRESS is valid, a 1-bit boolean flag.
+            10:10   address_valid => bool;
+            /// The JASID field is valid, a 1-bit boolean flag.
+            11:11   jasid_valid => bool;
+            /// JASID of the fault, if known.
+            15:12   jasid;
+            /// ID of the source that triggered the fault.
+            31:16   source_id;
+        }
+
+        /// GPU fault address. Read only.
+        /// Once a fault is reported, it must be manually cleared by issuing a
+        /// [`GPU_COMMAND::clear_fault()`] command to the [`GPU_COMMAND`] register. No further GPU
+        /// faults will be reported until the previous fault has been cleared.
+        pub(crate) GPU_FAULTADDRESS(u64) @ 0x40 {
+            63:0    pointer;
+        }
+
+        /// Level 2 cache configuration.
+        pub(crate) L2_CONFIG(u32) @ 0x48 {
+            /// Requested cache size.
+            23:16   cache_size;
+            /// Requested hash function index.
+            31:24   hash_function;
+        }
+
+        /// Global time stamp offset.
+        pub(crate) TIMESTAMP_OFFSET(u64) @ 0x88 {
+            63:0    offset;
+        }
+
+        /// GPU cycle counter. Read only.
+        pub(crate) CYCLE_COUNT(u64) @ 0x90 {
+            63:0    count;
+        }
+
+        /// Global time stamp. Read only.
+        pub(crate) TIMESTAMP(u64) @ 0x98 {
+            63:0    timestamp;
+        }
+
+        /// Maximum number of threads per core. Read only constant.
+        pub(crate) THREAD_MAX_THREADS(u32) @ 0xa0 {
+            31:0    threads;
+        }
+
+        /// Maximum number of threads per workgroup. Read only constant.
+        pub(crate) THREAD_MAX_WORKGROUP_SIZE(u32) @ 0xa4 {
+            31:0    threads;
+        }
+
+        /// Maximum number of threads per barrier. Read only constant.
+        pub(crate) THREAD_MAX_BARRIER_SIZE(u32) @ 0xa8 {
+            31:0    threads;
+        }
+
+        /// Thread features. Read only constant.
+        pub(crate) THREAD_FEATURES(u32) @ 0xac {
+            /// Total number of registers per core.
+            21:0    max_registers;
+            /// Implementation technology type.
+            23:22   implementation_technology;
+            /// Maximum number of compute tasks waiting.
+            31:24   max_task_queue;
+        }
+
+        /// Support flags for compressed texture formats. Read only constant.
+        ///
+        /// A bitmap where each bit indicates support for a specific compressed texture format.
+        /// The bit position maps to an opaque format ID (`texture_features_key_t` in spec).
+        pub(crate) TEXTURE_FEATURES(u32)[4] @ 0xb0 {
+            31:0    supported_formats;
+        }
+
+        /// Shader core present bitmap. Read only constant.
+        pub(crate) SHADER_PRESENT(u64) @ 0x100 {
+            63:0    present;
+        }
+
+        /// Tiler present bitmap. Read only constant.
+        pub(crate) TILER_PRESENT(u64) @ 0x110 {
+            63:0    present;
+        }
+
+        /// L2 cache present bitmap. Read only constant.
+        pub(crate) L2_PRESENT(u64) @ 0x120 {
+            63:0    present;
+        }
+
+        /// Shader core ready bitmap. Read only.
+        pub(crate) SHADER_READY(u64) @ 0x140 {
+            63:0    ready;
+        }
+
+        /// Tiler ready bitmap. Read only.
+        pub(crate) TILER_READY(u64) @ 0x150 {
+            63:0    ready;
+        }
+
+        /// L2 ready bitmap. Read only.
+        pub(crate) L2_READY(u64) @ 0x160 {
+            63:0    ready;
+        }
+
+        /// Shader core power up bitmap.
+        pub(crate) SHADER_PWRON(u64) @ 0x180 {
+            63:0    request;
+        }
+
+        /// Tiler power up bitmap.
+        pub(crate) TILER_PWRON(u64) @ 0x190 {
+            63:0    request;
+        }
+
+        /// L2 power up bitmap.
+        pub(crate) L2_PWRON(u64) @ 0x1a0 {
+            63:0 request;
+        }
+
+        /// Shader core power down bitmap.
+        pub(crate) SHADER_PWROFF(u64) @ 0x1c0 {
+            63:0 request;
+        }
+
+        /// Tiler power down bitmap.
+        pub(crate) TILER_PWROFF(u64) @ 0x1d0 {
+            63:0 request;
+        }
+
+        /// L2 power down bitmap.
+        pub(crate) L2_PWROFF(u64) @ 0x1e0 {
+            63:0 request;
+        }
+
+        /// Shader core power transition bitmap. Read-only.
+        pub(crate) SHADER_PWRTRANS(u64) @ 0x200 {
+            63:0 changing;
+        }
+
+        /// Tiler power transition bitmap. Read-only.
+        pub(crate) TILER_PWRTRANS(u64) @ 0x210 {
+            63:0 changing;
+        }
+
+        /// L2 power transition bitmap. Read-only.
+        pub(crate) L2_PWRTRANS(u64) @ 0x220 {
+            63:0 changing;
+        }
+
+        /// Shader core active bitmap. Read-only.
+        pub(crate) SHADER_PWRACTIVE(u64) @ 0x240 {
+            63:0 active;
+        }
+
+        /// Tiler active bitmap. Read-only.
+        pub(crate) TILER_PWRACTIVE(u64) @ 0x250 {
+            63:0 active;
+        }
+
+        /// L2 active bitmap.  Read-only.
+        pub(crate) L2_PWRACTIVE(u64) @ 0x260 {
+            63:0 active;
+        }
+
+        /// Revision ID. Read only constant.
+        pub(crate) REVIDR(u32) @ 0x280 {
+            31:0    revision;
+        }
+
+        /// Coherency features present. Read only constant.
+        /// Supported protocols on the interconnect between the GPU and the
+        /// system into which it is integrated.
+        pub(crate) COHERENCY_FEATURES(u32) @ 0x300 {
+            /// ACE-Lite protocol supported, a 1-bit boolean flag.
+            0:0     ace_lite => bool;
+            /// ACE protocol supported, a 1-bit boolean flag.
+            1:1     ace => bool;
+        }
+    }
+
+    #[derive(Copy, Clone, Debug)]
+    #[repr(u8)]
+    pub(crate) enum CoherencyMode {
+        /// ACE-Lite coherency protocol.
+        AceLite = uapi::drm_panthor_gpu_coherency_DRM_PANTHOR_GPU_COHERENCY_ACE_LITE as u8,
+        /// ACE coherency protocol.
+        Ace = uapi::drm_panthor_gpu_coherency_DRM_PANTHOR_GPU_COHERENCY_ACE as u8,
+        /// No coherency protocol.
+        None = uapi::drm_panthor_gpu_coherency_DRM_PANTHOR_GPU_COHERENCY_NONE as u8,
+    }
+
+    impl TryFrom<Bounded<u32, 32>> for CoherencyMode {
+        type Error = Error;
+
+        fn try_from(val: Bounded<u32, 32>) -> Result<Self, Self::Error> {
+            match val.get() {
+                0 => Ok(CoherencyMode::AceLite),
+                1 => Ok(CoherencyMode::Ace),
+                31 => Ok(CoherencyMode::None),
+                _ => Err(EINVAL),
+            }
+        }
+    }
+
+    impl From<CoherencyMode> for Bounded<u32, 32> {
+        fn from(mode: CoherencyMode) -> Self {
+            (mode as u8).into()
+        }
+    }
+
+    register! {
+        /// Coherency enable. An index of which coherency protocols should be used.
+        /// This register only selects the protocol for coherency messages on the
+        /// interconnect. This is not to enable or disable coherency controlled by MMU.
+        pub(crate) COHERENCY_ENABLE(u32) @ 0x304 {
+            31:0    l2_cache_protocol_select ?=> CoherencyMode;
+        }
+    }
+
+    /// Helpers for MCU_CONTROL register
+    #[derive(Copy, Clone, Debug)]
+    #[repr(u8)]
+    pub(crate) enum McuControlMode {
+        /// Disable the MCU.
+        Disable = 0,
+        /// Enable the MCU.
+        Enable = 1,
+        /// Enable the MCU to execute and automatically reboot after a fast reset.
+        Auto = 2,
+    }
+
+    impl TryFrom<Bounded<u32, 2>> for McuControlMode {
+        type Error = Error;
+
+        fn try_from(val: Bounded<u32, 2>) -> Result<Self, Self::Error> {
+            match val.get() {
+                0 => Ok(McuControlMode::Disable),
+                1 => Ok(McuControlMode::Enable),
+                2 => Ok(McuControlMode::Auto),
+                _ => Err(EINVAL),
+            }
+        }
+    }
+
+    impl From<McuControlMode> for Bounded<u32, 2> {
+        fn from(mode: McuControlMode) -> Self {
+            Bounded::try_new(mode as u32).unwrap()
+        }
+    }
+
+    register! {
+        /// MCU control.
+        pub(crate) MCU_CONTROL(u32) @ 0x700 {
+            /// Request MCU state change.
+            1:0 req ?=> McuControlMode;
+        }
+    }
+
+    /// Helpers for MCU_STATUS register
+    #[derive(Copy, Clone, Debug)]
+    #[repr(u8)]
+    pub(crate) enum McuStatus {
+        /// MCU is disabled.
+        Disabled = 0,
+        /// MCU is enabled.
+        Enabled = 1,
+        /// The MCU has halted by itself in an orderly manner to enable the core group to be powered down.
+        Halt = 2,
+        /// The MCU has encountered an error that prevents it from continuing.
+        Fatal = 3,
+    }
+
+    impl From<Bounded<u32, 2>> for McuStatus {
+        fn from(val: Bounded<u32, 2>) -> Self {
+            match val.get() {
+                0 => McuStatus::Disabled,
+                1 => McuStatus::Enabled,
+                2 => McuStatus::Halt,
+                3 => McuStatus::Fatal,
+                _ => unreachable!(),
+            }
+        }
+    }
+
+    impl From<McuStatus> for Bounded<u32, 2> {
+        fn from(status: McuStatus) -> Self {
+            Bounded::try_new(status as u32).unwrap()
+        }
+    }
+
+    register! {
+        /// MCU status. Read only.
+        pub(crate) MCU_STATUS(u32) @ 0x704 {
+            /// Read current state of MCU.
+            1:0 value => McuStatus;
+        }
+    }
+}
 
 pub(crate) const JOB_IRQ_RAWSTAT: Register<0x1000> = Register;
 pub(crate) const JOB_IRQ_CLEAR: Register<0x1004> = Register;

-- 
2.52.0


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 02/12] drm/tyr: Print GPU_ID without filtering
  2026-03-24  0:18 [PATCH v3 00/12] drm/tyr: Use register! macro Deborah Brouwer
  2026-03-24  0:18 ` [PATCH v3 01/12] drm/tyr: Use register! macro for GPU_CONTROL Deborah Brouwer
@ 2026-03-24  0:18 ` Deborah Brouwer
  2026-03-24  9:54   ` Boris Brezillon
  2026-03-24  0:18 ` [PATCH v3 03/12] drm/tyr: Set interconnect coherency during probe Deborah Brouwer
                   ` (10 subsequent siblings)
  12 siblings, 1 reply; 30+ messages in thread
From: Deborah Brouwer @ 2026-03-24  0:18 UTC (permalink / raw)
  To: dri-devel, rust-for-linux, Boqun Feng
  Cc: Danilo Krummrich, Alice Ryhl, Daniel Almeida, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Miguel Ojeda, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Trevor Gross, Steven Price, Boris Brezillon,
	Dirk Behme, Alexandre Courbot, Deborah Brouwer, Boqun Feng

Currently, Tyr prints just the upper 16 bits of the GPU_ID register,
namely, ARCH_MAJOR, ARCH_MINOR, ARCH_REV, and PRODUCT_MAJOR. This matches
the id printed by the panthor driver.

To avoid the manual bit shift, just print the full GPU_ID register. This
prints all of the same information and adds the VERSION_MAJOR,
VERSION_MINOR, and VERSION_STATUS.

Before this change:
  mali-g610 id 0xa867 major 0x0 minor 0x0 status 0x5

After this change:
  mali-g610 GPU_ID 0xa8670005 major 0x0 minor 0x0 status 0x5

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
---
 drivers/gpu/drm/tyr/gpu.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/tyr/gpu.rs b/drivers/gpu/drm/tyr/gpu.rs
index 66fd6c016c62abe3c34669a2e47b680c3a3f873d..4a50055b415c693a89cb99dba241b21351a14149 100644
--- a/drivers/gpu/drm/tyr/gpu.rs
+++ b/drivers/gpu/drm/tyr/gpu.rs
@@ -124,9 +124,9 @@ pub(crate) fn gpu_info_log(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result
 
     dev_info!(
         dev,
-        "mali-{} id 0x{:x} major 0x{:x} minor 0x{:x} status 0x{:x}",
+        "mali-{} GPU_ID 0x{:x} major 0x{:x} minor 0x{:x} status 0x{:x}",
         model_name,
-        gpu_id.into_raw() >> 16,
+        gpu_id.into_raw(),
         gpu_id.ver_major().get(),
         gpu_id.ver_minor().get(),
         gpu_id.ver_status().get()

-- 
2.52.0


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 03/12] drm/tyr: Set interconnect coherency during probe
  2026-03-24  0:18 [PATCH v3 00/12] drm/tyr: Use register! macro Deborah Brouwer
  2026-03-24  0:18 ` [PATCH v3 01/12] drm/tyr: Use register! macro for GPU_CONTROL Deborah Brouwer
  2026-03-24  0:18 ` [PATCH v3 02/12] drm/tyr: Print GPU_ID without filtering Deborah Brouwer
@ 2026-03-24  0:18 ` Deborah Brouwer
  2026-03-24  9:55   ` Boris Brezillon
  2026-03-24  0:18 ` [PATCH v3 04/12] drm/tyr: Use register! macro for JOB_CONTROL Deborah Brouwer
                   ` (9 subsequent siblings)
  12 siblings, 1 reply; 30+ messages in thread
From: Deborah Brouwer @ 2026-03-24  0:18 UTC (permalink / raw)
  To: dri-devel, rust-for-linux, Boqun Feng
  Cc: Danilo Krummrich, Alice Ryhl, Daniel Almeida, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Miguel Ojeda, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Trevor Gross, Steven Price, Boris Brezillon,
	Dirk Behme, Alexandre Courbot, Deborah Brouwer, Boqun Feng

Currently GpuInfo reports the interconnect coherency protocol as none
without actually reading the `COHERENCY_ENABLE` register.

Although the result is the same, write `NO_COHERENCY` to the register
during probe and then read back the register to populate the GpuInfo
struct.

This ensures that GpuInfo is populated consistently and is always as
accurate as possible by reporting the register values directly.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
---
 drivers/gpu/drm/tyr/driver.rs | 5 +++++
 drivers/gpu/drm/tyr/gpu.rs    | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tyr/driver.rs b/drivers/gpu/drm/tyr/driver.rs
index 3ebb5e08bfca342f136e8d365b1d9dcb6cc3dbca..7232d9f9547c239689dc424380109a4e5140dd84 100644
--- a/drivers/gpu/drm/tyr/driver.rs
+++ b/drivers/gpu/drm/tyr/driver.rs
@@ -136,6 +136,11 @@ fn probe(
         issue_soft_reset(pdev.as_ref(), &iomem)?;
         gpu::l2_power_on(pdev.as_ref(), &iomem)?;
 
+        let io = (*iomem).access(pdev.as_ref())?;
+        // FIXME: This needs to be set properly once we get
+        // device_get_dma_attr() properly exposed to the rust drivers.
+        io.write_reg(COHERENCY_ENABLE::zeroed().with_l2_cache_protocol_select(CoherencyMode::None));
+
         let gpu_info = GpuInfo::new(pdev.as_ref(), &iomem)?;
         gpu_info_log(pdev.as_ref(), &iomem)?;
 
diff --git a/drivers/gpu/drm/tyr/gpu.rs b/drivers/gpu/drm/tyr/gpu.rs
index 4a50055b415c693a89cb99dba241b21351a14149..d5240f4567ca4e763b09e015908bdc5c22276e0d 100644
--- a/drivers/gpu/drm/tyr/gpu.rs
+++ b/drivers/gpu/drm/tyr/gpu.rs
@@ -60,7 +60,7 @@ pub(crate) fn new(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result<Self> {
                 io.read(TEXTURE_FEATURES::at(3)).supported_formats().get(),
             ],
             as_present: io.read(AS_PRESENT).into_raw(),
-            selected_coherency: uapi::drm_panthor_gpu_coherency_DRM_PANTHOR_GPU_COHERENCY_NONE,
+            selected_coherency: io.read(COHERENCY_ENABLE).into_raw(),
             shader_present: io.read(SHADER_PRESENT).into_raw(),
             l2_present: io.read(L2_PRESENT).into_raw(),
             tiler_present: io.read(TILER_PRESENT).into_raw(),

-- 
2.52.0


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 04/12] drm/tyr: Use register! macro for JOB_CONTROL
  2026-03-24  0:18 [PATCH v3 00/12] drm/tyr: Use register! macro Deborah Brouwer
                   ` (2 preceding siblings ...)
  2026-03-24  0:18 ` [PATCH v3 03/12] drm/tyr: Set interconnect coherency during probe Deborah Brouwer
@ 2026-03-24  0:18 ` Deborah Brouwer
  2026-03-24 10:00   ` Boris Brezillon
  2026-03-24  0:18 ` [PATCH v3 05/12] drm/tyr: Use register! macro for MMU_CONTROL Deborah Brouwer
                   ` (8 subsequent siblings)
  12 siblings, 1 reply; 30+ messages in thread
From: Deborah Brouwer @ 2026-03-24  0:18 UTC (permalink / raw)
  To: dri-devel, rust-for-linux, Boqun Feng
  Cc: Danilo Krummrich, Alice Ryhl, Daniel Almeida, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Miguel Ojeda, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Trevor Gross, Steven Price, Boris Brezillon,
	Dirk Behme, Alexandre Courbot, Deborah Brouwer, Boqun Feng

Convert the JOB_CONTROL register definitions to use the `register!` macro.

Using the `register!` macro allows us to replace manual bit masks and
shifts with typed register and field accessors, which makes the code
easier to read and avoids errors from bit manipulation.

Co-developed-by: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
---
 drivers/gpu/drm/tyr/regs.rs | 58 ++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 50 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/tyr/regs.rs b/drivers/gpu/drm/tyr/regs.rs
index 5ba4919263af29c6e88435099cf801fa5874b117..bae3f917dd3ad3fe0dfd8425a119347f9d1ebbe8 100644
--- a/drivers/gpu/drm/tyr/regs.rs
+++ b/drivers/gpu/drm/tyr/regs.rs
@@ -28,7 +28,6 @@
 #![allow(dead_code)]
 
 use kernel::{
-    bits::bit_u32,
     device::{
         Bound,
         Device, //
@@ -787,14 +786,57 @@ fn from(status: McuStatus) -> Self {
     }
 }
 
-pub(crate) const JOB_IRQ_RAWSTAT: Register<0x1000> = Register;
-pub(crate) const JOB_IRQ_CLEAR: Register<0x1004> = Register;
-pub(crate) const JOB_IRQ_MASK: Register<0x1008> = Register;
-pub(crate) const JOB_IRQ_STAT: Register<0x100c> = Register;
-
-pub(crate) const JOB_IRQ_GLOBAL_IF: u32 = bit_u32(31);
-
 pub(crate) const MMU_IRQ_RAWSTAT: Register<0x2000> = Register;
 pub(crate) const MMU_IRQ_CLEAR: Register<0x2004> = Register;
 pub(crate) const MMU_IRQ_MASK: Register<0x2008> = Register;
 pub(crate) const MMU_IRQ_STAT: Register<0x200c> = Register;
+
+/// These registers correspond to the JOB_CONTROL register page.
+/// They are involved in communication between the firmware running on the MCU and the host.
+pub(crate) mod job_control {
+    use kernel::register;
+
+    register! {
+        /// Raw status of job interrupts.
+        ///
+        /// Write to this register to trigger these interrupts.
+        /// Writing a 1 to a bit forces that bit on.
+        pub(crate) JOB_IRQ_RAWSTAT(u32) @ 0x1000 {
+            /// CSG request. These bits indicate that CSGn requires attention from the host.
+            30:0    csg;
+            /// GLB request. Indicates that the GLB interface requires attention from the host.
+            31:31   glb;
+        }
+
+        /// Clear job interrupts. Write only.
+        ///
+        /// Write a 1 to a bit to clear the corresponding bit in [`JOB_IRQ_RAWSTAT`].
+        pub(crate) JOB_IRQ_CLEAR(u32) @ 0x1004 {
+            /// Clear CSG request interrupts.
+            30:0    csg;
+            /// Clear GLB request interrupt.
+            31:31   glb;
+        }
+
+        /// Mask for job interrupts.
+        ///
+        /// Set each bit to 1 to enable the corresponding interrupt source or to 0 to disable it.
+        pub(crate) JOB_IRQ_MASK(u32) @ 0x1008 {
+            /// Enable CSG request interrupts.
+            30:0    csg;
+            /// Enable GLB request interrupt.
+            31:31   glb;
+        }
+
+        /// Active job interrupts. Read only.
+        ///
+        /// This register contains the result of ANDing together [`JOB_IRQ_RAWSTAT`] and
+        /// [`JOB_IRQ_MASK`].
+        pub(crate) JOB_IRQ_STATUS(u32) @ 0x100c {
+            /// CSG request interrupt status.
+            30:0    csg;
+            /// GLB request interrupt status.
+            31:31   glb;
+        }
+    }
+}

-- 
2.52.0


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 05/12] drm/tyr: Use register! macro for MMU_CONTROL
  2026-03-24  0:18 [PATCH v3 00/12] drm/tyr: Use register! macro Deborah Brouwer
                   ` (3 preceding siblings ...)
  2026-03-24  0:18 ` [PATCH v3 04/12] drm/tyr: Use register! macro for JOB_CONTROL Deborah Brouwer
@ 2026-03-24  0:18 ` Deborah Brouwer
  2026-03-24 10:01   ` Boris Brezillon
  2026-03-24  0:18 ` [PATCH v3 06/12] drm/tyr: Remove custom register struct Deborah Brouwer
                   ` (7 subsequent siblings)
  12 siblings, 1 reply; 30+ messages in thread
From: Deborah Brouwer @ 2026-03-24  0:18 UTC (permalink / raw)
  To: dri-devel, rust-for-linux, Boqun Feng
  Cc: Danilo Krummrich, Alice Ryhl, Daniel Almeida, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Miguel Ojeda, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Trevor Gross, Steven Price, Boris Brezillon,
	Dirk Behme, Alexandre Courbot, Deborah Brouwer, Boqun Feng

Convert the MMU_CONTROL register definitions to use the `register!` macro.

Using the `register!` macro allows us to replace manual bit masks and
shifts with typed register and field accessors, which makes the code
easier to read and avoids errors from bit manipulation.

Co-developed-by: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
---
 drivers/gpu/drm/tyr/regs.rs | 56 +++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 51 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/tyr/regs.rs b/drivers/gpu/drm/tyr/regs.rs
index bae3f917dd3ad3fe0dfd8425a119347f9d1ebbe8..869bad81d988b4c3d4d65e014d646b6db568e919 100644
--- a/drivers/gpu/drm/tyr/regs.rs
+++ b/drivers/gpu/drm/tyr/regs.rs
@@ -786,11 +786,6 @@ fn from(status: McuStatus) -> Self {
     }
 }
 
-pub(crate) const MMU_IRQ_RAWSTAT: Register<0x2000> = Register;
-pub(crate) const MMU_IRQ_CLEAR: Register<0x2004> = Register;
-pub(crate) const MMU_IRQ_MASK: Register<0x2008> = Register;
-pub(crate) const MMU_IRQ_STAT: Register<0x200c> = Register;
-
 /// These registers correspond to the JOB_CONTROL register page.
 /// They are involved in communication between the firmware running on the MCU and the host.
 pub(crate) mod job_control {
@@ -840,3 +835,54 @@ pub(crate) mod job_control {
         }
     }
 }
+
+/// These registers correspond to the MMU_CONTROL register page.
+/// They are involved in MMU configuration and control.
+pub(crate) mod mmu_control {
+    use kernel::register;
+
+    register! {
+        /// IRQ sources raw status.
+        ///
+        /// This register contains the raw unmasked interrupt sources for MMU status and exception
+        /// handling.
+        ///
+        /// Writing to this register forces bits on.
+        /// Use [`IRQ_CLEAR`] to clear interrupts.
+        pub(crate) IRQ_RAWSTAT(u32) @ 0x2000 {
+            /// Page fault for address spaces.
+            15:0    page_fault;
+            /// Command completed in address spaces.
+            31:16   command_completed;
+        }
+
+        /// IRQ sources to clear.
+        /// Write a 1 to a bit to clear the corresponding bit in [`IRQ_RAWSTAT`].
+        pub(crate) IRQ_CLEAR(u32) @ 0x2004 {
+            /// Clear the PAGE_FAULT interrupt.
+            15:0    page_fault;
+            /// Clear the COMMAND_COMPLETED interrupt.
+            31:16   command_completed;
+        }
+
+        /// IRQ sources enabled.
+        ///
+        /// Set each bit to 1 to enable the corresponding interrupt source, and to 0 to disable it.
+        pub(crate) IRQ_MASK(u32) @ 0x2008 {
+            /// Enable the PAGE_FAULT interrupt.
+            15:0    page_fault;
+            /// Enable the COMMAND_COMPLETED interrupt.
+            31:16   command_completed;
+        }
+
+        /// IRQ status for enabled sources. Read only.
+        ///
+        /// This register contains the result of ANDing together [`IRQ_RAWSTAT`] and [`IRQ_MASK`].
+        pub(crate) IRQ_STATUS(u32) @ 0x200c {
+            /// PAGE_FAULT interrupt status.
+            15:0    page_fault;
+            /// COMMAND_COMPLETED interrupt status.
+            31:16   command_completed;
+        }
+    }
+}

-- 
2.52.0


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 06/12] drm/tyr: Remove custom register struct
  2026-03-24  0:18 [PATCH v3 00/12] drm/tyr: Use register! macro Deborah Brouwer
                   ` (4 preceding siblings ...)
  2026-03-24  0:18 ` [PATCH v3 05/12] drm/tyr: Use register! macro for MMU_CONTROL Deborah Brouwer
@ 2026-03-24  0:18 ` Deborah Brouwer
  2026-03-24 10:02   ` Boris Brezillon
  2026-03-24  0:18 ` [PATCH v3 07/12] drm/tyr: Add MMU address space registers Deborah Brouwer
                   ` (6 subsequent siblings)
  12 siblings, 1 reply; 30+ messages in thread
From: Deborah Brouwer @ 2026-03-24  0:18 UTC (permalink / raw)
  To: dri-devel, rust-for-linux, Boqun Feng
  Cc: Danilo Krummrich, Alice Ryhl, Daniel Almeida, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Miguel Ojeda, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Trevor Gross, Steven Price, Boris Brezillon,
	Dirk Behme, Alexandre Courbot, Deborah Brouwer, Boqun Feng

Now that Tyr uses the register! macro, it no longer needs to define a
custom register struct or read/write functions, so delete them.

Co-developed-by: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
---
 drivers/gpu/drm/tyr/regs.rs | 33 ---------------------------------
 1 file changed, 33 deletions(-)

diff --git a/drivers/gpu/drm/tyr/regs.rs b/drivers/gpu/drm/tyr/regs.rs
index 869bad81d988b4c3d4d65e014d646b6db568e919..f337d99387417a2eca94cd2d7ce8c8fa38bb1cee 100644
--- a/drivers/gpu/drm/tyr/regs.rs
+++ b/drivers/gpu/drm/tyr/regs.rs
@@ -27,39 +27,6 @@
 // does.
 #![allow(dead_code)]
 
-use kernel::{
-    device::{
-        Bound,
-        Device, //
-    },
-    devres::Devres,
-    io::Io,
-    prelude::*, //
-};
-
-use crate::driver::IoMem;
-
-/// Represents a register in the Register Set
-///
-/// TODO: Replace this with the Nova `register!()` macro when it is available.
-/// In particular, this will automatically give us 64bit register reads and
-/// writes.
-pub(crate) struct Register<const OFFSET: usize>;
-
-impl<const OFFSET: usize> Register<OFFSET> {
-    #[inline]
-    pub(crate) fn read(&self, dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result<u32> {
-        let value = (*iomem).access(dev)?.read32(OFFSET);
-        Ok(value)
-    }
-
-    #[inline]
-    pub(crate) fn write(&self, dev: &Device<Bound>, iomem: &Devres<IoMem>, value: u32) -> Result {
-        (*iomem).access(dev)?.write32(value, OFFSET);
-        Ok(())
-    }
-}
-
 /// These registers correspond to the GPU_CONTROL register page.
 /// They are involved in GPU configuration and control.
 pub(crate) mod gpu_control {

-- 
2.52.0


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 07/12] drm/tyr: Add MMU address space registers
  2026-03-24  0:18 [PATCH v3 00/12] drm/tyr: Use register! macro Deborah Brouwer
                   ` (5 preceding siblings ...)
  2026-03-24  0:18 ` [PATCH v3 06/12] drm/tyr: Remove custom register struct Deborah Brouwer
@ 2026-03-24  0:18 ` Deborah Brouwer
  2026-03-24 10:03   ` Boris Brezillon
  2026-03-24  0:18 ` [PATCH v3 08/12] drm/tyr: Add fields for MEMATTR register Deborah Brouwer
                   ` (5 subsequent siblings)
  12 siblings, 1 reply; 30+ messages in thread
From: Deborah Brouwer @ 2026-03-24  0:18 UTC (permalink / raw)
  To: dri-devel, rust-for-linux, Boqun Feng
  Cc: Danilo Krummrich, Alice Ryhl, Daniel Almeida, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Miguel Ojeda, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Trevor Gross, Steven Price, Boris Brezillon,
	Dirk Behme, Alexandre Courbot, Deborah Brouwer, Boqun Feng

Add a new module for the per-address-space MMU registers and constants.
Leave the more complex register field definitions empty for now; they
will be filled in by follow-up commits.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
---
 drivers/gpu/drm/tyr/regs.rs | 66 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)

diff --git a/drivers/gpu/drm/tyr/regs.rs b/drivers/gpu/drm/tyr/regs.rs
index f337d99387417a2eca94cd2d7ce8c8fa38bb1cee..428b6d8c4d6bfd341713bbb7d79e0556a2d04415 100644
--- a/drivers/gpu/drm/tyr/regs.rs
+++ b/drivers/gpu/drm/tyr/regs.rs
@@ -852,4 +852,70 @@ pub(crate) mod mmu_control {
             31:16   command_completed;
         }
     }
+
+    /// Per-address space registers ASn [0..15] within the MMU_CONTROL page.
+    ///
+    /// This array contains 16 instances of the MMU_AS_CONTROL register page.
+    pub(crate) mod mmu_as_control {
+        use kernel::register;
+
+        /// Maximum number of hardware address space slots.
+        /// The actual number of slots available is usually lower.
+        pub(crate) const MAX_AS: usize = 16;
+
+        /// Address space register stride. The elements in the array are spaced 64B apart.
+        const STRIDE: usize = 0x40;
+
+        register! {
+            /// Translation table base address. A 64-bit pointer.
+            ///
+            /// This field contains the address of the top level of a translation table structure.
+            /// This must be 16-byte-aligned, so address bits [3:0] are assumed to be zero.
+            pub(crate) TRANSTAB(u64)[MAX_AS, stride = STRIDE] @ 0x2400 {
+                /// Base address of the translation table.
+                63:0    base;
+            }
+
+            /// Memory attributes.
+            ///
+            /// Each address space can configure up to 8 different memory attribute profiles.
+            /// Each attribute profile follows the MMU_MEMATTR_STAGE1 layout.
+            pub(crate) MEMATTR(u64)[MAX_AS, stride = STRIDE] @ 0x2408 {}
+
+            /// Lock region address for each address space.
+            pub(crate) LOCKADDR(u64)[MAX_AS, stride = STRIDE] @ 0x2410 {
+                /// Lock region size.
+                5:0     size;
+                /// Lock region base address.
+                63:12   base;
+            }
+
+            /// MMU command register for each address space. Write only.
+            pub(crate) COMMAND(u32)[MAX_AS, stride = STRIDE] @ 0x2418 {}
+
+            /// Fault status register for each address space. Read only.
+            pub(crate) FAULTSTATUS(u32)[MAX_AS, stride = STRIDE] @ 0x241c {}
+
+            /// Fault address for each address space. Read only.
+            pub(crate) FAULTADDRESS(u64)[MAX_AS, stride = STRIDE] @ 0x2420 {
+                63:0    pointer;
+            }
+
+            /// MMU status register for each address space. Read only.
+            pub(crate) STATUS(u32)[MAX_AS, stride = STRIDE] @ 0x2428 {
+                /// External address space command is active, a 1-bit boolean flag.
+                0:0     active_ext => bool;
+                /// Internal address space command is active, a 1-bit boolean flag.
+                1:1     active_int => bool;
+            }
+
+            /// Translation configuration and control.
+            pub(crate) TRANSCFG(u64)[MAX_AS, stride = STRIDE] @ 0x2430 {}
+
+            /// Extra fault information for each address space. Read only.
+            pub(crate) FAULTEXTRA(u64)[MAX_AS, stride = STRIDE] @ 0x2438 {
+                63:0    value;
+            }
+        }
+    }
 }

-- 
2.52.0


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 08/12] drm/tyr: Add fields for MEMATTR register
  2026-03-24  0:18 [PATCH v3 00/12] drm/tyr: Use register! macro Deborah Brouwer
                   ` (6 preceding siblings ...)
  2026-03-24  0:18 ` [PATCH v3 07/12] drm/tyr: Add MMU address space registers Deborah Brouwer
@ 2026-03-24  0:18 ` Deborah Brouwer
  2026-03-24 10:05   ` Boris Brezillon
  2026-03-24  0:18 ` [PATCH v3 09/12] drm/tyr: Add fields for COMMAND register Deborah Brouwer
                   ` (4 subsequent siblings)
  12 siblings, 1 reply; 30+ messages in thread
From: Deborah Brouwer @ 2026-03-24  0:18 UTC (permalink / raw)
  To: dri-devel, rust-for-linux, Boqun Feng
  Cc: Danilo Krummrich, Alice Ryhl, Daniel Almeida, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Miguel Ojeda, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Trevor Gross, Steven Price, Boris Brezillon,
	Dirk Behme, Alexandre Courbot, Deborah Brouwer, Boqun Feng

The MEMATTR register allows up to eight memory attributes to be
defined simultaneously. Add these attribute fields and helpers to
define them.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
---
 drivers/gpu/drm/tyr/regs.rs | 162 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 160 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/tyr/regs.rs b/drivers/gpu/drm/tyr/regs.rs
index 428b6d8c4d6bfd341713bbb7d79e0556a2d04415..9bf2723ab6412034be9a77930532cc89d0adb128 100644
--- a/drivers/gpu/drm/tyr/regs.rs
+++ b/drivers/gpu/drm/tyr/regs.rs
@@ -857,7 +857,16 @@ pub(crate) mod mmu_control {
     ///
     /// This array contains 16 instances of the MMU_AS_CONTROL register page.
     pub(crate) mod mmu_as_control {
-        use kernel::register;
+        use core::convert::TryFrom;
+
+        use kernel::{
+            error::{
+                code::EINVAL,
+                Error, //
+            },
+            num::Bounded,
+            register, //
+        };
 
         /// Maximum number of hardware address space slots.
         /// The actual number of slots available is usually lower.
@@ -875,12 +884,161 @@ pub(crate) mod mmu_as_control {
                 /// Base address of the translation table.
                 63:0    base;
             }
+        }
+
+        /// Helpers for MEMATTR Register.
+
+        #[derive(Copy, Clone, Debug)]
+        #[repr(u8)]
+        pub(crate) enum AllocPolicySelect {
+            /// Ignore ALLOC_R/ALLOC_W fields.
+            Impl = 2,
+            /// Use ALLOC_R/ALLOC_W fields for allocation policy.
+            Alloc = 3,
+        }
+
+        impl TryFrom<Bounded<u8, 2>> for AllocPolicySelect {
+            type Error = Error;
+
+            fn try_from(val: Bounded<u8, 2>) -> Result<Self, Self::Error> {
+                match val.get() {
+                    2 => Ok(Self::Impl),
+                    3 => Ok(Self::Alloc),
+                    _ => Err(EINVAL),
+                }
+            }
+        }
+
+        impl From<AllocPolicySelect> for Bounded<u8, 2> {
+            fn from(val: AllocPolicySelect) -> Self {
+                Bounded::try_new(val as u8).unwrap()
+            }
+        }
 
+        /// Coherency policy for memory attributes. Indicates the shareability of cached accesses.
+        ///
+        /// The hardware spec defines different interpretations of these values depending on
+        /// whether TRANSCFG.MODE is set to IDENTITY or not. IDENTITY mode does not use translation
+        /// tables (all input addresses map to the same output address); it is deprecated and not used
+        /// by the driver. This enum assumes that TRANSCFG.MODE is not set to IDENTITY.
+        #[derive(Copy, Clone, Debug)]
+        #[repr(u8)]
+        pub(crate) enum Coherency {
+            /// Midgard inner domain coherency.
+            ///
+            /// Most flexible mode - can map non-coherent, internally coherent, and system/IO
+            /// coherent memory. Used for non-cacheable memory in MAIR conversion.
+            MidgardInnerDomain = 0,
+            /// CPU inner domain coherency.
+            ///
+            /// Can map non-coherent and system/IO coherent memory. Used for write-back
+            /// cacheable memory in MAIR conversion to maintain CPU-GPU cache coherency.
+            CpuInnerDomain = 1,
+            /// CPU inner domain with shader coherency.
+            ///
+            /// Can map internally coherent and system/IO coherent memory. Used for
+            /// GPU-internal shared buffers requiring shader coherency.
+            CpuInnerDomainShaderCoh = 2,
+        }
+
+        impl TryFrom<Bounded<u8, 2>> for Coherency {
+            type Error = Error;
+
+            fn try_from(val: Bounded<u8, 2>) -> Result<Self, Self::Error> {
+                match val.get() {
+                    0 => Ok(Self::MidgardInnerDomain),
+                    1 => Ok(Self::CpuInnerDomain),
+                    2 => Ok(Self::CpuInnerDomainShaderCoh),
+                    _ => Err(EINVAL),
+                }
+            }
+        }
+
+        impl From<Coherency> for Bounded<u8, 2> {
+            fn from(val: Coherency) -> Self {
+                Bounded::try_new(val as u8).unwrap()
+            }
+        }
+
+        #[derive(Copy, Clone, Debug)]
+        #[repr(u8)]
+        pub(crate) enum MemoryType {
+            /// Normal memory (shared).
+            Shared = 0,
+            /// Normal memory, inner/outer non-cacheable.
+            NonCacheable = 1,
+            /// Normal memory, inner/outer write-back cacheable.
+            WriteBack = 2,
+            /// Triggers MEMORY_ATTRIBUTE_FAULT.
+            Fault = 3,
+        }
+
+        impl From<Bounded<u8, 2>> for MemoryType {
+            fn from(val: Bounded<u8, 2>) -> Self {
+                match val.get() {
+                    0 => Self::Shared,
+                    1 => Self::NonCacheable,
+                    2 => Self::WriteBack,
+                    3 => Self::Fault,
+                    _ => unreachable!(),
+                }
+            }
+        }
+
+        impl From<MemoryType> for Bounded<u8, 2> {
+            fn from(val: MemoryType) -> Self {
+                Bounded::try_new(val as u8).unwrap()
+            }
+        }
+
+        register! {
+            /// Stage 1 memory attributes (8-bit bitfield).
+            ///
+            /// This is not an actual register, but a bitfield definition used by the MEMATTR
+            /// register. Each of the 8 bytes in MEMATTR follows this layout.
+            MMU_MEMATTR_STAGE1(u8) @ 0x0 {
+                /// Inner cache write allocation policy.
+                0:0     alloc_w => bool;
+                /// Inner cache read allocation policy.
+                1:1     alloc_r => bool;
+                /// Inner allocation policy select.
+                3:2     alloc_sel ?=> AllocPolicySelect;
+                /// Coherency policy.
+                5:4     coherency ?=> Coherency;
+                /// Memory type.
+                7:6     memory_type => MemoryType;
+            }
+        }
+
+        impl TryFrom<Bounded<u64, 8>> for MMU_MEMATTR_STAGE1 {
+            type Error = Error;
+
+            fn try_from(val: Bounded<u64, 8>) -> Result<Self, Self::Error> {
+                Ok(Self::from_raw(val.get() as u8))
+            }
+        }
+
+        impl From<MMU_MEMATTR_STAGE1> for Bounded<u64, 8> {
+            fn from(val: MMU_MEMATTR_STAGE1) -> Self {
+                Bounded::try_new(u64::from(val.into_raw())).unwrap()
+            }
+        }
+
+        register! {
             /// Memory attributes.
             ///
             /// Each address space can configure up to 8 different memory attribute profiles.
             /// Each attribute profile follows the MMU_MEMATTR_STAGE1 layout.
-            pub(crate) MEMATTR(u64)[MAX_AS, stride = STRIDE] @ 0x2408 {}
+            pub(crate) MEMATTR(u64)[MAX_AS, stride = STRIDE] @ 0x2408 {
+                7:0     attribute0 ?=> MMU_MEMATTR_STAGE1;
+                15:8    attribute1 ?=> MMU_MEMATTR_STAGE1;
+                23:16   attribute2 ?=> MMU_MEMATTR_STAGE1;
+                31:24   attribute3 ?=> MMU_MEMATTR_STAGE1;
+                39:32   attribute4 ?=> MMU_MEMATTR_STAGE1;
+                47:40   attribute5 ?=> MMU_MEMATTR_STAGE1;
+                55:48   attribute6 ?=> MMU_MEMATTR_STAGE1;
+                63:56   attribute7 ?=> MMU_MEMATTR_STAGE1;
+            }
 
             /// Lock region address for each address space.
             pub(crate) LOCKADDR(u64)[MAX_AS, stride = STRIDE] @ 0x2410 {

-- 
2.52.0


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 09/12] drm/tyr: Add fields for COMMAND register
  2026-03-24  0:18 [PATCH v3 00/12] drm/tyr: Use register! macro Deborah Brouwer
                   ` (7 preceding siblings ...)
  2026-03-24  0:18 ` [PATCH v3 08/12] drm/tyr: Add fields for MEMATTR register Deborah Brouwer
@ 2026-03-24  0:18 ` Deborah Brouwer
  2026-03-24 10:09   ` Boris Brezillon
  2026-03-24  0:18 ` [PATCH v3 10/12] drm/tyr: Add fields for FAULTSTATUS register Deborah Brouwer
                   ` (3 subsequent siblings)
  12 siblings, 1 reply; 30+ messages in thread
From: Deborah Brouwer @ 2026-03-24  0:18 UTC (permalink / raw)
  To: dri-devel, rust-for-linux, Boqun Feng
  Cc: Danilo Krummrich, Alice Ryhl, Daniel Almeida, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Miguel Ojeda, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Trevor Gross, Steven Price, Boris Brezillon,
	Dirk Behme, Alexandre Courbot, Deborah Brouwer, Boqun Feng

The MMU COMMAND register accepts specific commands. Enumerate those
commands and use the register! macro to ensure that only those commands
can be written to the MMU COMMAND register.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
---
 drivers/gpu/drm/tyr/regs.rs | 47 ++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tyr/regs.rs b/drivers/gpu/drm/tyr/regs.rs
index 9bf2723ab6412034be9a77930532cc89d0adb128..6fbd6268724eb6b2ea8d76c5d991353dcbe87068 100644
--- a/drivers/gpu/drm/tyr/regs.rs
+++ b/drivers/gpu/drm/tyr/regs.rs
@@ -1048,8 +1048,53 @@ fn from(val: MMU_MEMATTR_STAGE1) -> Self {
                 63:12   base;
             }
 
+        }
+
+        /// Helpers for MMU COMMAND register.
+        #[derive(Copy, Clone, Debug)]
+        #[repr(u8)]
+        pub(crate) enum MmuCommand {
+            /// No operation, nothing happens.
+            Nop = 0,
+            /// Propagate settings to the MMU.
+            Update = 1,
+            /// Lock an address region.
+            Lock = 2,
+            /// Unlock an address region.
+            Unlock = 3,
+            /// Clean and invalidate the L2 cache, then unlock.
+            FlushPt = 4,
+            /// Clean and invalidate all caches, then unlock.
+            FlushMem = 5,
+        }
+
+        impl TryFrom<Bounded<u32, 8>> for MmuCommand {
+            type Error = Error;
+
+            fn try_from(val: Bounded<u32, 8>) -> Result<Self, Self::Error> {
+                match val.get() {
+                    0 => Ok(MmuCommand::Nop),
+                    1 => Ok(MmuCommand::Update),
+                    2 => Ok(MmuCommand::Lock),
+                    3 => Ok(MmuCommand::Unlock),
+                    4 => Ok(MmuCommand::FlushPt),
+                    5 => Ok(MmuCommand::FlushMem),
+                    _ => Err(EINVAL),
+                }
+            }
+        }
+
+        impl From<MmuCommand> for Bounded<u32, 8> {
+            fn from(cmd: MmuCommand) -> Self {
+                (cmd as u8).into()
+            }
+        }
+
+        register! {
             /// MMU command register for each address space. Write only.
-            pub(crate) COMMAND(u32)[MAX_AS, stride = STRIDE] @ 0x2418 {}
+            pub(crate) COMMAND(u32)[MAX_AS, stride = STRIDE] @ 0x2418 {
+                7:0     command ?=> MmuCommand;
+            }
 
             /// Fault status register for each address space. Read only.
             pub(crate) FAULTSTATUS(u32)[MAX_AS, stride = STRIDE] @ 0x241c {}

-- 
2.52.0


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 10/12] drm/tyr: Add fields for FAULTSTATUS register
  2026-03-24  0:18 [PATCH v3 00/12] drm/tyr: Use register! macro Deborah Brouwer
                   ` (8 preceding siblings ...)
  2026-03-24  0:18 ` [PATCH v3 09/12] drm/tyr: Add fields for COMMAND register Deborah Brouwer
@ 2026-03-24  0:18 ` Deborah Brouwer
  2026-03-24  0:18 ` [PATCH v3 11/12] drm/tyr: Add fields for TRANSCFG register Deborah Brouwer
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 30+ messages in thread
From: Deborah Brouwer @ 2026-03-24  0:18 UTC (permalink / raw)
  To: dri-devel, rust-for-linux, Boqun Feng
  Cc: Danilo Krummrich, Alice Ryhl, Daniel Almeida, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Miguel Ojeda, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Trevor Gross, Steven Price, Boris Brezillon,
	Dirk Behme, Alexandre Courbot, Deborah Brouwer, Boqun Feng

The MMU FAULTSTATUS register communicates specific information about
fault exception, access type, and source. Enumerate this information and
use the register! macro to decode the defined values from this register.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
---
 drivers/gpu/drm/tyr/regs.rs | 131 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 130 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tyr/regs.rs b/drivers/gpu/drm/tyr/regs.rs
index 6fbd6268724eb6b2ea8d76c5d991353dcbe87068..3d96d3264952616112e77939dfa2c753039dea35 100644
--- a/drivers/gpu/drm/tyr/regs.rs
+++ b/drivers/gpu/drm/tyr/regs.rs
@@ -1095,9 +1095,138 @@ fn from(cmd: MmuCommand) -> Self {
             pub(crate) COMMAND(u32)[MAX_AS, stride = STRIDE] @ 0x2418 {
                 7:0     command ?=> MmuCommand;
             }
+        }
+
+        /// MMU exception types for FAULTSTATUS register.
+        #[derive(Copy, Clone, Debug)]
+        #[repr(u8)]
+        pub(crate) enum MmuExceptionType {
+            /// No error.
+            Ok = 0x00,
+            /// Invalid translation table entry, level 0.
+            TranslationFault0 = 0xC0,
+            /// Invalid translation table entry, level 1.
+            TranslationFault1 = 0xC1,
+            /// Invalid translation table entry, level 2.
+            TranslationFault2 = 0xC2,
+            /// Invalid translation table entry, level 3.
+            TranslationFault3 = 0xC3,
+            /// Invalid block descriptor.
+            TranslationFault4 = 0xC4,
+            /// Page permission error, level 0.
+            PermissionFault0 = 0xC8,
+            /// Page permission error, level 1.
+            PermissionFault1 = 0xC9,
+            /// Page permission error, level 2.
+            PermissionFault2 = 0xCA,
+            /// Page permission error, level 3.
+            PermissionFault3 = 0xCB,
+            /// Access flag not set, level 1.
+            AccessFlag1 = 0xD9,
+            /// Access flag not set, level 2.
+            AccessFlag2 = 0xDA,
+            /// Access flag not set, level 3.
+            AccessFlag3 = 0xDB,
+            /// Virtual address out of range.
+            AddressSizeFaultIn = 0xE0,
+            /// Physical address out of range, level 0.
+            AddressSizeFaultOut0 = 0xE4,
+            /// Physical address out of range, level 1.
+            AddressSizeFaultOut1 = 0xE5,
+            /// Physical address out of range, level 2.
+            AddressSizeFaultOut2 = 0xE6,
+            /// Physical address out of range, level 3.
+            AddressSizeFaultOut3 = 0xE7,
+            /// Page attribute error, level 0.
+            MemoryAttributeFault0 = 0xE8,
+            /// Page attribute error, level 1.
+            MemoryAttributeFault1 = 0xE9,
+            /// Page attribute error, level 2.
+            MemoryAttributeFault2 = 0xEA,
+            /// Page attribute error, level 3.
+            MemoryAttributeFault3 = 0xEB,
+        }
+
+        impl TryFrom<Bounded<u32, 8>> for MmuExceptionType {
+            type Error = Error;
+
+            fn try_from(val: Bounded<u32, 8>) -> Result<Self, Self::Error> {
+                match val.get() {
+                    0x00 => Ok(MmuExceptionType::Ok),
+                    0xC0 => Ok(MmuExceptionType::TranslationFault0),
+                    0xC1 => Ok(MmuExceptionType::TranslationFault1),
+                    0xC2 => Ok(MmuExceptionType::TranslationFault2),
+                    0xC3 => Ok(MmuExceptionType::TranslationFault3),
+                    0xC4 => Ok(MmuExceptionType::TranslationFault4),
+                    0xC8 => Ok(MmuExceptionType::PermissionFault0),
+                    0xC9 => Ok(MmuExceptionType::PermissionFault1),
+                    0xCA => Ok(MmuExceptionType::PermissionFault2),
+                    0xCB => Ok(MmuExceptionType::PermissionFault3),
+                    0xD9 => Ok(MmuExceptionType::AccessFlag1),
+                    0xDA => Ok(MmuExceptionType::AccessFlag2),
+                    0xDB => Ok(MmuExceptionType::AccessFlag3),
+                    0xE0 => Ok(MmuExceptionType::AddressSizeFaultIn),
+                    0xE4 => Ok(MmuExceptionType::AddressSizeFaultOut0),
+                    0xE5 => Ok(MmuExceptionType::AddressSizeFaultOut1),
+                    0xE6 => Ok(MmuExceptionType::AddressSizeFaultOut2),
+                    0xE7 => Ok(MmuExceptionType::AddressSizeFaultOut3),
+                    0xE8 => Ok(MmuExceptionType::MemoryAttributeFault0),
+                    0xE9 => Ok(MmuExceptionType::MemoryAttributeFault1),
+                    0xEA => Ok(MmuExceptionType::MemoryAttributeFault2),
+                    0xEB => Ok(MmuExceptionType::MemoryAttributeFault3),
+                    _ => Err(EINVAL),
+                }
+            }
+        }
+
+        impl From<MmuExceptionType> for Bounded<u32, 8> {
+            fn from(exc: MmuExceptionType) -> Self {
+                (exc as u8).into()
+            }
+        }
+
+        /// Access type for MMU faults.
+        #[derive(Copy, Clone, Debug)]
+        #[repr(u8)]
+        pub(crate) enum MmuAccessType {
+            /// An atomic (read/write) transaction.
+            Atomic = 0,
+            /// An execute transaction.
+            Execute = 1,
+            /// A read transaction.
+            Read = 2,
+            /// A write transaction.
+            Write = 3,
+        }
+
+        impl From<Bounded<u32, 2>> for MmuAccessType {
+            fn from(val: Bounded<u32, 2>) -> Self {
+                match val.get() {
+                    0 => MmuAccessType::Atomic,
+                    1 => MmuAccessType::Execute,
+                    2 => MmuAccessType::Read,
+                    3 => MmuAccessType::Write,
+                    _ => unreachable!(),
+                }
+            }
+        }
 
+        impl From<MmuAccessType> for Bounded<u32, 2> {
+            fn from(access: MmuAccessType) -> Self {
+                Bounded::try_new(access as u32).unwrap()
+            }
+        }
+
+        register! {
             /// Fault status register for each address space. Read only.
-            pub(crate) FAULTSTATUS(u32)[MAX_AS, stride = STRIDE] @ 0x241c {}
+            pub(crate) FAULTSTATUS(u32)[MAX_AS, stride = STRIDE] @ 0x241c {
+                /// Exception type.
+                7:0     exception_type ?=> MmuExceptionType;
+                /// Access type.
+                9:8     access_type => MmuAccessType;
+                /// ID of the source that triggered the fault.
+                31:16   source_id;
+            }
 
             /// Fault address for each address space. Read only.
             pub(crate) FAULTADDRESS(u64)[MAX_AS, stride = STRIDE] @ 0x2420 {

-- 
2.52.0


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 11/12] drm/tyr: Add fields for TRANSCFG register
  2026-03-24  0:18 [PATCH v3 00/12] drm/tyr: Use register! macro Deborah Brouwer
                   ` (9 preceding siblings ...)
  2026-03-24  0:18 ` [PATCH v3 10/12] drm/tyr: Add fields for FAULTSTATUS register Deborah Brouwer
@ 2026-03-24  0:18 ` Deborah Brouwer
  2026-03-24  0:18 ` [PATCH v3 12/12] drm/tyr: Add DOORBELL_BLOCK registers Deborah Brouwer
  2026-03-24 10:58 ` [PATCH v3 00/12] drm/tyr: Use register! macro Alice Ryhl
  12 siblings, 0 replies; 30+ messages in thread
From: Deborah Brouwer @ 2026-03-24  0:18 UTC (permalink / raw)
  To: dri-devel, rust-for-linux, Boqun Feng
  Cc: Danilo Krummrich, Alice Ryhl, Daniel Almeida, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Miguel Ojeda, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Trevor Gross, Steven Price, Boris Brezillon,
	Dirk Behme, Alexandre Courbot, Deborah Brouwer, Boqun Feng

The translation configuration register for address spaces includes
fields that are limited in their possible values such as address
space modes, input and output restrictions, translation table
memory attributes.

Add these fields to the TRANSCFG register and enumerate their
possible values using the register! macro to ensure that only defined
values are used in this register.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
---
 drivers/gpu/drm/tyr/regs.rs | 225 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 224 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tyr/regs.rs b/drivers/gpu/drm/tyr/regs.rs
index 3d96d3264952616112e77939dfa2c753039dea35..7e895b6e7deccc049a0ee3963d511c4b579e5ec7 100644
--- a/drivers/gpu/drm/tyr/regs.rs
+++ b/drivers/gpu/drm/tyr/regs.rs
@@ -1240,9 +1240,232 @@ fn from(access: MmuAccessType) -> Self {
                 /// Internal address space command is active, a 1-bit boolean flag.
                 1:1     active_int => bool;
             }
+        }
+
+        /// Helpers for TRANSCFG register.
+        ///
+        /// Address space mode for TRANSCFG register.
+        #[derive(Copy, Clone, Debug)]
+        #[repr(u8)]
+        pub(crate) enum AddressSpaceMode {
+            /// The MMU forces all memory access to fail with a decode fault.
+            Unmapped = 1,
+            /// All input addresses map to the same output address (deprecated).
+            Identity = 2,
+            /// Translation tables interpreted according to AArch64 4kB granule specification.
+            Aarch64_4K = 6,
+            /// Translation tables interpreted according to AArch64 64kB granule specification.
+            Aarch64_64K = 8,
+        }
+
+        impl TryFrom<Bounded<u64, 4>> for AddressSpaceMode {
+            type Error = Error;
+
+            fn try_from(val: Bounded<u64, 4>) -> Result<Self, Self::Error> {
+                match val.get() {
+                    1 => Ok(AddressSpaceMode::Unmapped),
+                    2 => Ok(AddressSpaceMode::Identity),
+                    6 => Ok(AddressSpaceMode::Aarch64_4K),
+                    8 => Ok(AddressSpaceMode::Aarch64_64K),
+                    _ => Err(EINVAL),
+                }
+            }
+        }
+
+        impl From<AddressSpaceMode> for Bounded<u64, 4> {
+            fn from(mode: AddressSpaceMode) -> Self {
+                Bounded::try_new(mode as u64).unwrap()
+            }
+        }
+
+        /// Input address range restriction for TRANSCFG register.
+        #[derive(Copy, Clone, Debug)]
+        #[repr(u8)]
+        pub(crate) enum InaBits {
+            /// Invalid VA range (reset value).
+            Reset = 0,
+            /// 48-bit VA range.
+            Bits48 = 7,
+            /// 47-bit VA range.
+            Bits47 = 8,
+            /// 46-bit VA range.
+            Bits46 = 9,
+            /// 45-bit VA range.
+            Bits45 = 10,
+            /// 44-bit VA range.
+            Bits44 = 11,
+            /// 43-bit VA range.
+            Bits43 = 12,
+            /// 42-bit VA range.
+            Bits42 = 13,
+            /// 41-bit VA range.
+            Bits41 = 14,
+            /// 40-bit VA range.
+            Bits40 = 15,
+            /// 39-bit VA range.
+            Bits39 = 16,
+            /// 38-bit VA range.
+            Bits38 = 17,
+            /// 37-bit VA range.
+            Bits37 = 18,
+            /// 36-bit VA range.
+            Bits36 = 19,
+            /// 35-bit VA range.
+            Bits35 = 20,
+            /// 34-bit VA range.
+            Bits34 = 21,
+            /// 33-bit VA range.
+            Bits33 = 22,
+            /// 32-bit VA range.
+            Bits32 = 23,
+            /// 31-bit VA range.
+            Bits31 = 24,
+            /// 30-bit VA range.
+            Bits30 = 25,
+            /// 29-bit VA range.
+            Bits29 = 26,
+            /// 28-bit VA range.
+            Bits28 = 27,
+            /// 27-bit VA range.
+            Bits27 = 28,
+            /// 26-bit VA range.
+            Bits26 = 29,
+            /// 25-bit VA range.
+            Bits25 = 30,
+        }
+
+        impl TryFrom<Bounded<u64, 5>> for InaBits {
+            type Error = Error;
+
+            fn try_from(val: Bounded<u64, 5>) -> Result<Self, Self::Error> {
+                match val.get() {
+                    0 => Ok(InaBits::Reset),
+                    7 => Ok(InaBits::Bits48),
+                    8 => Ok(InaBits::Bits47),
+                    9 => Ok(InaBits::Bits46),
+                    10 => Ok(InaBits::Bits45),
+                    11 => Ok(InaBits::Bits44),
+                    12 => Ok(InaBits::Bits43),
+                    13 => Ok(InaBits::Bits42),
+                    14 => Ok(InaBits::Bits41),
+                    15 => Ok(InaBits::Bits40),
+                    16 => Ok(InaBits::Bits39),
+                    17 => Ok(InaBits::Bits38),
+                    18 => Ok(InaBits::Bits37),
+                    19 => Ok(InaBits::Bits36),
+                    20 => Ok(InaBits::Bits35),
+                    21 => Ok(InaBits::Bits34),
+                    22 => Ok(InaBits::Bits33),
+                    23 => Ok(InaBits::Bits32),
+                    24 => Ok(InaBits::Bits31),
+                    25 => Ok(InaBits::Bits30),
+                    26 => Ok(InaBits::Bits29),
+                    27 => Ok(InaBits::Bits28),
+                    28 => Ok(InaBits::Bits27),
+                    29 => Ok(InaBits::Bits26),
+                    30 => Ok(InaBits::Bits25),
+                    _ => Err(EINVAL),
+                }
+            }
+        }
+
+        impl From<InaBits> for Bounded<u64, 5> {
+            fn from(bits: InaBits) -> Self {
+                Bounded::try_new(bits as u64).unwrap()
+            }
+        }
+
+        /// Translation table memory attributes for TRANSCFG register.
+        #[derive(Copy, Clone, Debug)]
+        #[repr(u8)]
+        pub(crate) enum PtwMemattr {
+            /// Invalid (reset value, not valid for enabled address space).
+            Invalid = 0,
+            /// Normal memory, inner/outer non-cacheable.
+            NonCacheable = 1,
+            /// Normal memory, inner/outer write-back cacheable.
+            WriteBack = 2,
+        }
+
+        impl TryFrom<Bounded<u64, 2>> for PtwMemattr {
+            type Error = Error;
+
+            fn try_from(val: Bounded<u64, 2>) -> Result<Self, Self::Error> {
+                match val.get() {
+                    0 => Ok(PtwMemattr::Invalid),
+                    1 => Ok(PtwMemattr::NonCacheable),
+                    2 => Ok(PtwMemattr::WriteBack),
+                    _ => Err(EINVAL),
+                }
+            }
+        }
+
+        impl From<PtwMemattr> for Bounded<u64, 2> {
+            fn from(attr: PtwMemattr) -> Self {
+                Bounded::try_new(attr as u64).unwrap()
+            }
+        }
+
+        /// Translation table memory shareability for TRANSCFG register.
+        #[derive(Copy, Clone, Debug)]
+        #[repr(u8)]
+        #[allow(clippy::enum_variant_names)]
+        pub(crate) enum PtwShareability {
+            /// Non-shareable.
+            NonShareable = 0,
+            /// Outer shareable.
+            OuterShareable = 2,
+            /// Inner shareable.
+            InnerShareable = 3,
+        }
+
+        impl TryFrom<Bounded<u64, 2>> for PtwShareability {
+            type Error = Error;
+
+            fn try_from(val: Bounded<u64, 2>) -> Result<Self, Self::Error> {
+                match val.get() {
+                    0 => Ok(PtwShareability::NonShareable),
+                    2 => Ok(PtwShareability::OuterShareable),
+                    3 => Ok(PtwShareability::InnerShareable),
+                    _ => Err(EINVAL),
+                }
+            }
+        }
+
+        impl From<PtwShareability> for Bounded<u64, 2> {
+            fn from(sh: PtwShareability) -> Self {
+                Bounded::try_new(sh as u64).unwrap()
+            }
+        }
 
+        register! {
             /// Translation configuration and control.
-            pub(crate) TRANSCFG(u64)[MAX_AS, stride = STRIDE] @ 0x2430 {}
+            pub(crate) TRANSCFG(u64)[MAX_AS, stride = STRIDE] @ 0x2430 {
+                /// Address space mode.
+                3:0     mode ?=> AddressSpaceMode;
+                /// Address input restriction.
+                10:6    ina_bits ?=> InaBits;
+                /// Address output restriction.
+                18:14   outa_bits;
+                /// Translation table concatenation enable, a 1-bit boolean flag.
+                22:22   sl_concat_en => bool;
+                /// Translation table memory attributes.
+                25:24   ptw_memattr ?=> PtwMemattr;
+                /// Translation table memory shareability.
+                29:28   ptw_sh ?=> PtwShareability;
+                /// Inner read allocation hint for translation table walks, a 1-bit boolean flag.
+                30:30   r_allocate => bool;
+                /// Disable hierarchical access permissions.
+                33:33   disable_hier_ap => bool;
+                /// Disable access fault checking.
+                34:34   disable_af_fault => bool;
+                /// Disable execution on all writable pages.
+                35:35   wxn => bool;
+                /// Enable execution on readable pages.
+                36:36   xreadable => bool;
+                /// Page-based hardware attributes for translation table walks.
+                63:60   ptw_pbha;
+            }
 
             /// Extra fault information for each address space. Read only.
             pub(crate) FAULTEXTRA(u64)[MAX_AS, stride = STRIDE] @ 0x2438 {

-- 
2.52.0


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 12/12] drm/tyr: Add DOORBELL_BLOCK registers
  2026-03-24  0:18 [PATCH v3 00/12] drm/tyr: Use register! macro Deborah Brouwer
                   ` (10 preceding siblings ...)
  2026-03-24  0:18 ` [PATCH v3 11/12] drm/tyr: Add fields for TRANSCFG register Deborah Brouwer
@ 2026-03-24  0:18 ` Deborah Brouwer
  2026-03-24 10:10   ` Boris Brezillon
  2026-03-24 10:58 ` [PATCH v3 00/12] drm/tyr: Use register! macro Alice Ryhl
  12 siblings, 1 reply; 30+ messages in thread
From: Deborah Brouwer @ 2026-03-24  0:18 UTC (permalink / raw)
  To: dri-devel, rust-for-linux, Boqun Feng
  Cc: Danilo Krummrich, Alice Ryhl, Daniel Almeida, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Miguel Ojeda, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Trevor Gross, Steven Price, Boris Brezillon,
	Dirk Behme, Alexandre Courbot, Deborah Brouwer, Boqun Feng

DOORBELL_BLOCK_n[0-63] is an array of GPU control register pages.
Each block is memory-mappable and contains a single DOORBELL register
used to trigger actions in the GPU.

Add definitions for the DOORBELL_BLOCK registers using the register! macro
so they can be used by future Tyr interfaces.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
---
 drivers/gpu/drm/tyr/regs.rs | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/gpu/drm/tyr/regs.rs b/drivers/gpu/drm/tyr/regs.rs
index 7e895b6e7deccc049a0ee3963d511c4b579e5ec7..9c1da1f039ccf9fc118def974d48dd40c17f4305 100644
--- a/drivers/gpu/drm/tyr/regs.rs
+++ b/drivers/gpu/drm/tyr/regs.rs
@@ -1474,3 +1474,25 @@ fn from(sh: PtwShareability) -> Self {
         }
     }
 }
+
+/// This module corresponds to the DOORBELL_BLOCK_n[0-63] register pages.
+pub(crate) mod doorbell_block {
+    use kernel::register;
+
+    /// Number of doorbells available.
+    pub(crate) const NUM_DOORBELLS: usize = 64;
+
+    /// Doorbell block stride (64KiB).
+    ///
+    /// Each block occupies a full page, allowing it to be mapped
+    /// separately into a virtual address space.
+    const STRIDE: usize = 0x10000;
+
+    register! {
+        /// Doorbell request register. Write-only.
+        pub(crate) DOORBELL(u32)[NUM_DOORBELLS, stride = STRIDE] @ 0x80000 {
+            /// Doorbell set. Writing 1 triggers the doorbell.
+            0:0    ring => bool;
+        }
+    }
+}

-- 
2.52.0


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 02/12] drm/tyr: Print GPU_ID without filtering
  2026-03-24  0:18 ` [PATCH v3 02/12] drm/tyr: Print GPU_ID without filtering Deborah Brouwer
@ 2026-03-24  9:54   ` Boris Brezillon
  0 siblings, 0 replies; 30+ messages in thread
From: Boris Brezillon @ 2026-03-24  9:54 UTC (permalink / raw)
  To: Deborah Brouwer
  Cc: dri-devel, rust-for-linux, Boqun Feng, Danilo Krummrich,
	Alice Ryhl, Daniel Almeida, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Miguel Ojeda,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, Steven Price, Dirk Behme, Alexandre Courbot

On Mon, 23 Mar 2026 17:18:04 -0700
Deborah Brouwer <deborah.brouwer@collabora.com> wrote:

> Currently, Tyr prints just the upper 16 bits of the GPU_ID register,
> namely, ARCH_MAJOR, ARCH_MINOR, ARCH_REV, and PRODUCT_MAJOR. This matches
> the id printed by the panthor driver.
> 
> To avoid the manual bit shift, just print the full GPU_ID register. This
> prints all of the same information and adds the VERSION_MAJOR,
> VERSION_MINOR, and VERSION_STATUS.
> 
> Before this change:
>   mali-g610 id 0xa867 major 0x0 minor 0x0 status 0x5
> 
> After this change:
>   mali-g610 GPU_ID 0xa8670005 major 0x0 minor 0x0 status 0x5
> 
> Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>

> ---
>  drivers/gpu/drm/tyr/gpu.rs | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tyr/gpu.rs b/drivers/gpu/drm/tyr/gpu.rs
> index 66fd6c016c62abe3c34669a2e47b680c3a3f873d..4a50055b415c693a89cb99dba241b21351a14149 100644
> --- a/drivers/gpu/drm/tyr/gpu.rs
> +++ b/drivers/gpu/drm/tyr/gpu.rs
> @@ -124,9 +124,9 @@ pub(crate) fn gpu_info_log(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result
>  
>      dev_info!(
>          dev,
> -        "mali-{} id 0x{:x} major 0x{:x} minor 0x{:x} status 0x{:x}",
> +        "mali-{} GPU_ID 0x{:x} major 0x{:x} minor 0x{:x} status 0x{:x}",
>          model_name,
> -        gpu_id.into_raw() >> 16,
> +        gpu_id.into_raw(),
>          gpu_id.ver_major().get(),
>          gpu_id.ver_minor().get(),
>          gpu_id.ver_status().get()
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 03/12] drm/tyr: Set interconnect coherency during probe
  2026-03-24  0:18 ` [PATCH v3 03/12] drm/tyr: Set interconnect coherency during probe Deborah Brouwer
@ 2026-03-24  9:55   ` Boris Brezillon
  0 siblings, 0 replies; 30+ messages in thread
From: Boris Brezillon @ 2026-03-24  9:55 UTC (permalink / raw)
  To: Deborah Brouwer
  Cc: dri-devel, rust-for-linux, Boqun Feng, Danilo Krummrich,
	Alice Ryhl, Daniel Almeida, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Miguel Ojeda,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, Steven Price, Dirk Behme, Alexandre Courbot

On Mon, 23 Mar 2026 17:18:05 -0700
Deborah Brouwer <deborah.brouwer@collabora.com> wrote:

> Currently GpuInfo reports the interconnect coherency protocol as none
> without actually reading the `COHERENCY_ENABLE` register.
> 
> Although the result is the same, write `NO_COHERENCY` to the register
> during probe and then read back the register to populate the GpuInfo
> struct.
> 
> This ensures that GpuInfo is populated consistently and is always as
> accurate as possible by reporting the register values directly.
> 
> Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>

> ---
>  drivers/gpu/drm/tyr/driver.rs | 5 +++++
>  drivers/gpu/drm/tyr/gpu.rs    | 2 +-
>  2 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/tyr/driver.rs b/drivers/gpu/drm/tyr/driver.rs
> index 3ebb5e08bfca342f136e8d365b1d9dcb6cc3dbca..7232d9f9547c239689dc424380109a4e5140dd84 100644
> --- a/drivers/gpu/drm/tyr/driver.rs
> +++ b/drivers/gpu/drm/tyr/driver.rs
> @@ -136,6 +136,11 @@ fn probe(
>          issue_soft_reset(pdev.as_ref(), &iomem)?;
>          gpu::l2_power_on(pdev.as_ref(), &iomem)?;
>  
> +        let io = (*iomem).access(pdev.as_ref())?;
> +        // FIXME: This needs to be set properly once we get
> +        // device_get_dma_attr() properly exposed to the rust drivers.
> +        io.write_reg(COHERENCY_ENABLE::zeroed().with_l2_cache_protocol_select(CoherencyMode::None));
> +
>          let gpu_info = GpuInfo::new(pdev.as_ref(), &iomem)?;
>          gpu_info_log(pdev.as_ref(), &iomem)?;
>  
> diff --git a/drivers/gpu/drm/tyr/gpu.rs b/drivers/gpu/drm/tyr/gpu.rs
> index 4a50055b415c693a89cb99dba241b21351a14149..d5240f4567ca4e763b09e015908bdc5c22276e0d 100644
> --- a/drivers/gpu/drm/tyr/gpu.rs
> +++ b/drivers/gpu/drm/tyr/gpu.rs
> @@ -60,7 +60,7 @@ pub(crate) fn new(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result<Self> {
>                  io.read(TEXTURE_FEATURES::at(3)).supported_formats().get(),
>              ],
>              as_present: io.read(AS_PRESENT).into_raw(),
> -            selected_coherency: uapi::drm_panthor_gpu_coherency_DRM_PANTHOR_GPU_COHERENCY_NONE,
> +            selected_coherency: io.read(COHERENCY_ENABLE).into_raw(),
>              shader_present: io.read(SHADER_PRESENT).into_raw(),
>              l2_present: io.read(L2_PRESENT).into_raw(),
>              tiler_present: io.read(TILER_PRESENT).into_raw(),
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 01/12] drm/tyr: Use register! macro for GPU_CONTROL
  2026-03-24  0:18 ` [PATCH v3 01/12] drm/tyr: Use register! macro for GPU_CONTROL Deborah Brouwer
@ 2026-03-24  9:56   ` Boris Brezillon
  2026-03-24 11:23   ` Danilo Krummrich
  1 sibling, 0 replies; 30+ messages in thread
From: Boris Brezillon @ 2026-03-24  9:56 UTC (permalink / raw)
  To: Deborah Brouwer
  Cc: dri-devel, rust-for-linux, Boqun Feng, Danilo Krummrich,
	Alice Ryhl, Daniel Almeida, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Miguel Ojeda,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, Steven Price, Dirk Behme, Alexandre Courbot

On Mon, 23 Mar 2026 17:18:03 -0700
Deborah Brouwer <deborah.brouwer@collabora.com> wrote:

> From: Daniel Almeida <daniel.almeida@collabora.com>
> 
> Convert the GPU_CONTROL register definitions to use the `register!` macro.
> 
> Using the `register!` macro allows us to replace manual bit masks and
> shifts with typed register and field accessors, which makes the code
> easier to read and avoids errors from bit manipulation.
> 
> Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com>
> Co-developed-by: Deborah Brouwer <deborah.brouwer@collabora.com>
> Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>

Acked-by: Boris Brezillon <boris.brezillon@collabora.com>

> ---
>  drivers/gpu/drm/tyr/driver.rs |  24 +-
>  drivers/gpu/drm/tyr/gpu.rs    | 211 +++++------
>  drivers/gpu/drm/tyr/regs.rs   | 803 +++++++++++++++++++++++++++++++++++++++---
>  3 files changed, 842 insertions(+), 196 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tyr/driver.rs b/drivers/gpu/drm/tyr/driver.rs
> index 611434641580574ec6b5afa49a8fe79888bb7ace..3ebb5e08bfca342f136e8d365b1d9dcb6cc3dbca 100644
> --- a/drivers/gpu/drm/tyr/driver.rs
> +++ b/drivers/gpu/drm/tyr/driver.rs
> @@ -13,7 +13,10 @@
>      devres::Devres,
>      drm,
>      drm::ioctl,
> -    io::poll,
> +    io::{
> +        poll,
> +        Io, //
> +    },
>      new_mutex,
>      of,
>      platform,
> @@ -33,8 +36,11 @@
>      file::TyrDrmFileData,
>      gem::TyrObject,
>      gpu,
> -    gpu::GpuInfo,
> -    regs, //
> +    gpu::{
> +        gpu_info_log, //
> +        GpuInfo,
> +    },
> +    regs::gpu_control::*, //
>  };
>  
>  pub(crate) type IoMem = kernel::io::mem::IoMem<SZ_2M>;
> @@ -78,11 +84,15 @@ unsafe impl Send for TyrDrmDeviceData {}
>  unsafe impl Sync for TyrDrmDeviceData {}
>  
>  fn issue_soft_reset(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result {
> -    regs::GPU_CMD.write(dev, iomem, regs::GPU_CMD_SOFT_RESET)?;
> +    let io = (*iomem).access(dev)?;
> +    io.write_reg(GPU_COMMAND::reset(ResetMode::SoftReset));
>  
>      poll::read_poll_timeout(
> -        || regs::GPU_IRQ_RAWSTAT.read(dev, iomem),
> -        |status| *status & regs::GPU_IRQ_RAWSTAT_RESET_COMPLETED != 0,
> +        || {
> +            let io = (*iomem).access(dev)?;
> +            Ok(io.read(GPU_IRQ_RAWSTAT))
> +        },
> +        |status| status.reset_completed(),
>          time::Delta::from_millis(1),
>          time::Delta::from_millis(100),
>      )
> @@ -127,7 +137,7 @@ fn probe(
>          gpu::l2_power_on(pdev.as_ref(), &iomem)?;
>  
>          let gpu_info = GpuInfo::new(pdev.as_ref(), &iomem)?;
> -        gpu_info.log(pdev);
> +        gpu_info_log(pdev.as_ref(), &iomem)?;
>  
>          let platform: ARef<platform::Device> = pdev.into();
>  
> diff --git a/drivers/gpu/drm/tyr/gpu.rs b/drivers/gpu/drm/tyr/gpu.rs
> index a88775160f981e899e9c9b58debbda33e1b7244d..66fd6c016c62abe3c34669a2e47b680c3a3f873d 100644
> --- a/drivers/gpu/drm/tyr/gpu.rs
> +++ b/drivers/gpu/drm/tyr/gpu.rs
> @@ -5,14 +5,16 @@
>      DerefMut, //
>  };
>  use kernel::{
> -    bits::genmask_u32,
>      device::{
>          Bound,
>          Device, //
>      },
>      devres::Devres,
> -    io::poll,
> -    platform,
> +    io::{
> +        poll,
> +        register::Array,
> +        Io, //
> +    },
>      prelude::*,
>      time::Delta,
>      transmute::AsBytes,
> @@ -21,7 +23,7 @@
>  
>  use crate::{
>      driver::IoMem,
> -    regs, //
> +    regs::gpu_control::*, //
>  };
>  
>  /// Struct containing information that can be queried by userspace. This is read from
> @@ -29,120 +31,46 @@
>  ///
>  /// # Invariants
>  ///
> -/// - The layout of this struct identical to the C `struct drm_panthor_gpu_info`.
> +/// - The layout of this struct is identical to the C `struct drm_panthor_gpu_info`.
>  #[repr(transparent)]
>  #[derive(Clone, Copy)]
>  pub(crate) struct GpuInfo(pub(crate) uapi::drm_panthor_gpu_info);
>  
>  impl GpuInfo {
>      pub(crate) fn new(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result<Self> {
> -        let gpu_id = regs::GPU_ID.read(dev, iomem)?;
> -        let csf_id = regs::GPU_CSF_ID.read(dev, iomem)?;
> -        let gpu_rev = regs::GPU_REVID.read(dev, iomem)?;
> -        let core_features = regs::GPU_CORE_FEATURES.read(dev, iomem)?;
> -        let l2_features = regs::GPU_L2_FEATURES.read(dev, iomem)?;
> -        let tiler_features = regs::GPU_TILER_FEATURES.read(dev, iomem)?;
> -        let mem_features = regs::GPU_MEM_FEATURES.read(dev, iomem)?;
> -        let mmu_features = regs::GPU_MMU_FEATURES.read(dev, iomem)?;
> -        let thread_features = regs::GPU_THREAD_FEATURES.read(dev, iomem)?;
> -        let max_threads = regs::GPU_THREAD_MAX_THREADS.read(dev, iomem)?;
> -        let thread_max_workgroup_size = regs::GPU_THREAD_MAX_WORKGROUP_SIZE.read(dev, iomem)?;
> -        let thread_max_barrier_size = regs::GPU_THREAD_MAX_BARRIER_SIZE.read(dev, iomem)?;
> -        let coherency_features = regs::GPU_COHERENCY_FEATURES.read(dev, iomem)?;
> -
> -        let texture_features = regs::GPU_TEXTURE_FEATURES0.read(dev, iomem)?;
> -
> -        let as_present = regs::GPU_AS_PRESENT.read(dev, iomem)?;
> -
> -        let shader_present = u64::from(regs::GPU_SHADER_PRESENT_LO.read(dev, iomem)?);
> -        let shader_present =
> -            shader_present | u64::from(regs::GPU_SHADER_PRESENT_HI.read(dev, iomem)?) << 32;
> -
> -        let tiler_present = u64::from(regs::GPU_TILER_PRESENT_LO.read(dev, iomem)?);
> -        let tiler_present =
> -            tiler_present | u64::from(regs::GPU_TILER_PRESENT_HI.read(dev, iomem)?) << 32;
> -
> -        let l2_present = u64::from(regs::GPU_L2_PRESENT_LO.read(dev, iomem)?);
> -        let l2_present = l2_present | u64::from(regs::GPU_L2_PRESENT_HI.read(dev, iomem)?) << 32;
> +        let io = (*iomem).access(dev)?;
>  
>          Ok(Self(uapi::drm_panthor_gpu_info {
> -            gpu_id,
> -            gpu_rev,
> -            csf_id,
> -            l2_features,
> -            tiler_features,
> -            mem_features,
> -            mmu_features,
> -            thread_features,
> -            max_threads,
> -            thread_max_workgroup_size,
> -            thread_max_barrier_size,
> -            coherency_features,
> -            // TODO: Add texture_features_{1,2,3}.
> -            texture_features: [texture_features, 0, 0, 0],
> -            as_present,
> +            gpu_id: io.read(GPU_ID).into_raw(),
> +            gpu_rev: io.read(REVIDR).into_raw(),
> +            csf_id: io.read(CSF_ID).into_raw(),
> +            l2_features: io.read(L2_FEATURES).into_raw(),
> +            tiler_features: io.read(TILER_FEATURES).into_raw(),
> +            mem_features: io.read(MEM_FEATURES).into_raw(),
> +            mmu_features: io.read(MMU_FEATURES).into_raw(),
> +            thread_features: io.read(THREAD_FEATURES).into_raw(),
> +            max_threads: io.read(THREAD_MAX_THREADS).into_raw(),
> +            thread_max_workgroup_size: io.read(THREAD_MAX_WORKGROUP_SIZE).into_raw(),
> +            thread_max_barrier_size: io.read(THREAD_MAX_BARRIER_SIZE).into_raw(),
> +            coherency_features: io.read(COHERENCY_FEATURES).into_raw(),
> +            texture_features: [
> +                io.read(TEXTURE_FEATURES::at(0)).supported_formats().get(),
> +                io.read(TEXTURE_FEATURES::at(1)).supported_formats().get(),
> +                io.read(TEXTURE_FEATURES::at(2)).supported_formats().get(),
> +                io.read(TEXTURE_FEATURES::at(3)).supported_formats().get(),
> +            ],
> +            as_present: io.read(AS_PRESENT).into_raw(),
>              selected_coherency: uapi::drm_panthor_gpu_coherency_DRM_PANTHOR_GPU_COHERENCY_NONE,
> -            shader_present,
> -            l2_present,
> -            tiler_present,
> -            core_features,
> +            shader_present: io.read(SHADER_PRESENT).into_raw(),
> +            l2_present: io.read(L2_PRESENT).into_raw(),
> +            tiler_present: io.read(TILER_PRESENT).into_raw(),
> +            core_features: io.read(CORE_FEATURES).into_raw(),
> +            // Padding must be zero.
>              pad: 0,
> +            //GPU_FEATURES register is not available; it was introduced in arch 11.x.
>              gpu_features: 0,
>          }))
>      }
> -
> -    pub(crate) fn log(&self, pdev: &platform::Device) {
> -        let gpu_id = GpuId::from(self.gpu_id);
> -
> -        let model_name = if let Some(model) = GPU_MODELS
> -            .iter()
> -            .find(|&f| f.arch_major == gpu_id.arch_major && f.prod_major == gpu_id.prod_major)
> -        {
> -            model.name
> -        } else {
> -            "unknown"
> -        };
> -
> -        dev_info!(
> -            pdev,
> -            "mali-{} id 0x{:x} major 0x{:x} minor 0x{:x} status 0x{:x}",
> -            model_name,
> -            self.gpu_id >> 16,
> -            gpu_id.ver_major,
> -            gpu_id.ver_minor,
> -            gpu_id.ver_status
> -        );
> -
> -        dev_info!(
> -            pdev,
> -            "Features: L2:{:#x} Tiler:{:#x} Mem:{:#x} MMU:{:#x} AS:{:#x}",
> -            self.l2_features,
> -            self.tiler_features,
> -            self.mem_features,
> -            self.mmu_features,
> -            self.as_present
> -        );
> -
> -        dev_info!(
> -            pdev,
> -            "shader_present=0x{:016x} l2_present=0x{:016x} tiler_present=0x{:016x}",
> -            self.shader_present,
> -            self.l2_present,
> -            self.tiler_present
> -        );
> -    }
> -
> -    /// Returns the number of virtual address bits supported by the GPU.
> -    #[expect(dead_code)]
> -    pub(crate) fn va_bits(&self) -> u32 {
> -        self.mmu_features & genmask_u32(0..=7)
> -    }
> -
> -    /// Returns the number of physical address bits supported by the GPU.
> -    #[expect(dead_code)]
> -    pub(crate) fn pa_bits(&self) -> u32 {
> -        (self.mmu_features >> 8) & genmask_u32(0..=7)
> -    }
>  }
>  
>  impl Deref for GpuInfo {
> @@ -182,38 +110,59 @@ struct GpuModels {
>      prod_major: 7,
>  }];
>  
> -#[allow(dead_code)]
> -pub(crate) struct GpuId {
> -    pub(crate) arch_major: u32,
> -    pub(crate) arch_minor: u32,
> -    pub(crate) arch_rev: u32,
> -    pub(crate) prod_major: u32,
> -    pub(crate) ver_major: u32,
> -    pub(crate) ver_minor: u32,
> -    pub(crate) ver_status: u32,
> -}
> -
> -impl From<u32> for GpuId {
> -    fn from(value: u32) -> Self {
> -        GpuId {
> -            arch_major: (value & genmask_u32(28..=31)) >> 28,
> -            arch_minor: (value & genmask_u32(24..=27)) >> 24,
> -            arch_rev: (value & genmask_u32(20..=23)) >> 20,
> -            prod_major: (value & genmask_u32(16..=19)) >> 16,
> -            ver_major: (value & genmask_u32(12..=15)) >> 12,
> -            ver_minor: (value & genmask_u32(4..=11)) >> 4,
> -            ver_status: value & genmask_u32(0..=3),
> -        }
> -    }
> +pub(crate) fn gpu_info_log(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result {
> +    let io = (*iomem).access(dev)?;
> +    let gpu_id = io.read(GPU_ID);
> +
> +    let model_name = if let Some(model) = GPU_MODELS.iter().find(|&f| {
> +        f.arch_major == gpu_id.arch_major().get() && f.prod_major == gpu_id.prod_major().get()
> +    }) {
> +        model.name
> +    } else {
> +        "unknown"
> +    };
> +
> +    dev_info!(
> +        dev,
> +        "mali-{} id 0x{:x} major 0x{:x} minor 0x{:x} status 0x{:x}",
> +        model_name,
> +        gpu_id.into_raw() >> 16,
> +        gpu_id.ver_major().get(),
> +        gpu_id.ver_minor().get(),
> +        gpu_id.ver_status().get()
> +    );
> +
> +    dev_info!(
> +        dev,
> +        "Features: L2:{:#x} Tiler:{:#x} Mem:{:#x} MMU:{:#x} AS:{:#x}",
> +        io.read(L2_FEATURES).into_raw(),
> +        io.read(TILER_FEATURES).into_raw(),
> +        io.read(MEM_FEATURES).into_raw(),
> +        io.read(MMU_FEATURES).into_raw(),
> +        io.read(AS_PRESENT).into_raw(),
> +    );
> +
> +    dev_info!(
> +        dev,
> +        "shader_present=0x{:016x} l2_present=0x{:016x} tiler_present=0x{:016x}",
> +        io.read(SHADER_PRESENT).into_raw(),
> +        io.read(L2_PRESENT).into_raw(),
> +        io.read(TILER_PRESENT).into_raw(),
> +    );
> +    Ok(())
>  }
>  
>  /// Powers on the l2 block.
>  pub(crate) fn l2_power_on(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result {
> -    regs::L2_PWRON_LO.write(dev, iomem, 1)?;
> +    let io = (*iomem).access(dev)?;
> +    io.write_reg(L2_PWRON::zeroed().with_const_request::<1>());
>  
>      poll::read_poll_timeout(
> -        || regs::L2_READY_LO.read(dev, iomem),
> -        |status| *status == 1,
> +        || {
> +            let io = (*iomem).access(dev)?;
> +            Ok(io.read(L2_READY))
> +        },
> +        |status| status.ready() == 1,
>          Delta::from_millis(1),
>          Delta::from_millis(100),
>      )
> diff --git a/drivers/gpu/drm/tyr/regs.rs b/drivers/gpu/drm/tyr/regs.rs
> index 611870c2e6af50a35daaef052db2dd33a7e8059c..5ba4919263af29c6e88435099cf801fa5874b117 100644
> --- a/drivers/gpu/drm/tyr/regs.rs
> +++ b/drivers/gpu/drm/tyr/regs.rs
> @@ -1,5 +1,25 @@
>  // SPDX-License-Identifier: GPL-2.0 or MIT
>  
> +//! # Definitions
> +//!
> +//! - **CEU**: Command Execution Unit - A hardware component that executes commands (instructions)
> +//!   from the command stream.
> +//! - **CS**: Command Stream - A sequence of instructions (commands) used to control a particular
> +//!   job or sequence of jobs. The instructions exist in one or more command buffers.
> +//! - **CSF**: Command Stream Frontend - The interface and implementation for job submission
> +//!   exposed to the host CPU driver. This includes the global interface, as well as CSG and CS
> +//!   interfaces.
> +//! - **CSG**: Command Stream Group - A group of related command streams. The CSF manages multiple
> +//!   CSGs, and each CSG contains multiple CSs.
> +//! - **CSHW**: Command Stream Hardware - The hardware interpreting command streams, including the
> +//!   iterator control aspects. Implements the CSF in conjunction with the MCU.
> +//! - **GLB**: Global - Prefix for global interface registers that control operations common to
> +//!   all CSs.
> +//! - **JASID**: Job Address Space ID - Identifies the address space for a job.
> +//! - **MCU**: Microcontroller Unit - Implements the CSF in conjunction with the command stream
> +//!   hardware.
> +//! - **MMU**: Memory Management Unit - Handles address translation and memory access protection.
> +
>  // We don't expect that all the registers and fields will be used, even in the
>  // future.
>  //
> @@ -41,64 +61,731 @@ pub(crate) fn write(&self, dev: &Device<Bound>, iomem: &Devres<IoMem>, value: u3
>      }
>  }
>  
> -pub(crate) const GPU_ID: Register<0x0> = Register;
> -pub(crate) const GPU_L2_FEATURES: Register<0x4> = Register;
> -pub(crate) const GPU_CORE_FEATURES: Register<0x8> = Register;
> -pub(crate) const GPU_CSF_ID: Register<0x1c> = Register;
> -pub(crate) const GPU_REVID: Register<0x280> = Register;
> -pub(crate) const GPU_TILER_FEATURES: Register<0xc> = Register;
> -pub(crate) const GPU_MEM_FEATURES: Register<0x10> = Register;
> -pub(crate) const GPU_MMU_FEATURES: Register<0x14> = Register;
> -pub(crate) const GPU_AS_PRESENT: Register<0x18> = Register;
> -pub(crate) const GPU_IRQ_RAWSTAT: Register<0x20> = Register;
> -
> -pub(crate) const GPU_IRQ_RAWSTAT_FAULT: u32 = bit_u32(0);
> -pub(crate) const GPU_IRQ_RAWSTAT_PROTECTED_FAULT: u32 = bit_u32(1);
> -pub(crate) const GPU_IRQ_RAWSTAT_RESET_COMPLETED: u32 = bit_u32(8);
> -pub(crate) const GPU_IRQ_RAWSTAT_POWER_CHANGED_SINGLE: u32 = bit_u32(9);
> -pub(crate) const GPU_IRQ_RAWSTAT_POWER_CHANGED_ALL: u32 = bit_u32(10);
> -pub(crate) const GPU_IRQ_RAWSTAT_CLEAN_CACHES_COMPLETED: u32 = bit_u32(17);
> -pub(crate) const GPU_IRQ_RAWSTAT_DOORBELL_STATUS: u32 = bit_u32(18);
> -pub(crate) const GPU_IRQ_RAWSTAT_MCU_STATUS: u32 = bit_u32(19);
> -
> -pub(crate) const GPU_IRQ_CLEAR: Register<0x24> = Register;
> -pub(crate) const GPU_IRQ_MASK: Register<0x28> = Register;
> -pub(crate) const GPU_IRQ_STAT: Register<0x2c> = Register;
> -pub(crate) const GPU_CMD: Register<0x30> = Register;
> -pub(crate) const GPU_CMD_SOFT_RESET: u32 = 1 | (1 << 8);
> -pub(crate) const GPU_CMD_HARD_RESET: u32 = 1 | (2 << 8);
> -pub(crate) const GPU_THREAD_FEATURES: Register<0xac> = Register;
> -pub(crate) const GPU_THREAD_MAX_THREADS: Register<0xa0> = Register;
> -pub(crate) const GPU_THREAD_MAX_WORKGROUP_SIZE: Register<0xa4> = Register;
> -pub(crate) const GPU_THREAD_MAX_BARRIER_SIZE: Register<0xa8> = Register;
> -pub(crate) const GPU_TEXTURE_FEATURES0: Register<0xb0> = Register;
> -pub(crate) const GPU_SHADER_PRESENT_LO: Register<0x100> = Register;
> -pub(crate) const GPU_SHADER_PRESENT_HI: Register<0x104> = Register;
> -pub(crate) const GPU_TILER_PRESENT_LO: Register<0x110> = Register;
> -pub(crate) const GPU_TILER_PRESENT_HI: Register<0x114> = Register;
> -pub(crate) const GPU_L2_PRESENT_LO: Register<0x120> = Register;
> -pub(crate) const GPU_L2_PRESENT_HI: Register<0x124> = Register;
> -pub(crate) const L2_READY_LO: Register<0x160> = Register;
> -pub(crate) const L2_READY_HI: Register<0x164> = Register;
> -pub(crate) const L2_PWRON_LO: Register<0x1a0> = Register;
> -pub(crate) const L2_PWRON_HI: Register<0x1a4> = Register;
> -pub(crate) const L2_PWRTRANS_LO: Register<0x220> = Register;
> -pub(crate) const L2_PWRTRANS_HI: Register<0x204> = Register;
> -pub(crate) const L2_PWRACTIVE_LO: Register<0x260> = Register;
> -pub(crate) const L2_PWRACTIVE_HI: Register<0x264> = Register;
> -
> -pub(crate) const MCU_CONTROL: Register<0x700> = Register;
> -pub(crate) const MCU_CONTROL_ENABLE: u32 = 1;
> -pub(crate) const MCU_CONTROL_AUTO: u32 = 2;
> -pub(crate) const MCU_CONTROL_DISABLE: u32 = 0;
> -
> -pub(crate) const MCU_STATUS: Register<0x704> = Register;
> -pub(crate) const MCU_STATUS_DISABLED: u32 = 0;
> -pub(crate) const MCU_STATUS_ENABLED: u32 = 1;
> -pub(crate) const MCU_STATUS_HALT: u32 = 2;
> -pub(crate) const MCU_STATUS_FATAL: u32 = 3;
> -
> -pub(crate) const GPU_COHERENCY_FEATURES: Register<0x300> = Register;
> +/// These registers correspond to the GPU_CONTROL register page.
> +/// They are involved in GPU configuration and control.
> +pub(crate) mod gpu_control {
> +    use core::convert::TryFrom;
> +    use kernel::{
> +        error::{
> +            code::EINVAL,
> +            Error, //
> +        },
> +        num::Bounded,
> +        register,
> +        uapi, //
> +    };
> +    use pin_init::Zeroable;
> +
> +    register! {
> +        /// GPU identification register.
> +        pub(crate) GPU_ID(u32) @ 0x0 {
> +            /// Status of the GPU release.
> +            3:0     ver_status;
> +            /// Minor release version number.
> +            11:4    ver_minor;
> +            /// Major release version number.
> +            15:12   ver_major;
> +            /// Product identifier.
> +            19:16   prod_major;
> +            /// Architecture patch revision.
> +            23:20   arch_rev;
> +            /// Architecture minor revision.
> +            27:24   arch_minor;
> +            /// Architecture major revision.
> +            31:28   arch_major;
> +        }
> +
> +        /// Level 2 cache features register.
> +        pub(crate) L2_FEATURES(u32) @ 0x4 {
> +            /// Cache line size.
> +            7:0     line_size;
> +            /// Cache associativity.
> +            15:8    associativity;
> +            /// Cache slice size.
> +            23:16   cache_size;
> +            /// External bus width.
> +            31:24   bus_width;
> +        }
> +
> +        /// Shader core features.
> +        pub(crate) CORE_FEATURES(u32) @ 0x8 {
> +            /// Shader core variant.
> +            7:0     core_variant;
> +        }
> +
> +        /// Tiler features.
> +        pub(crate) TILER_FEATURES(u32) @ 0xc {
> +            /// Log of the tiler's bin size.
> +            5:0     bin_size;
> +            /// Maximum number of active levels.
> +            11:8    max_levels;
> +        }
> +
> +        /// Memory system features.
> +        pub(crate) MEM_FEATURES(u32) @ 0x10 {
> +            0:0     coherent_core_group => bool;
> +            1:1     coherent_super_group => bool;
> +            11:8    l2_slices;
> +        }
> +
> +        /// Memory management unit features.
> +        pub(crate) MMU_FEATURES(u32) @ 0x14 {
> +            /// Number of bits supported in virtual addresses.
> +            7:0     va_bits;
> +            /// Number of bits supported in physical addresses.
> +            15:8    pa_bits;
> +        }
> +
> +        /// Address spaces present.
> +        pub(crate) AS_PRESENT(u32) @ 0x18 {
> +            31:0    present;
> +        }
> +
> +        /// CSF version information.
> +        pub(crate) CSF_ID(u32) @ 0x1c {
> +            /// MCU revision ID.
> +            3:0     mcu_rev;
> +            /// MCU minor revision number.
> +            9:4     mcu_minor;
> +            /// MCU major revision number.
> +            15:10   mcu_major;
> +            /// CSHW revision ID.
> +            19:16   cshw_rev;
> +            /// CSHW minor revision number.
> +            25:20   cshw_minor;
> +            /// CSHW major revision number.
> +            31:26   cshw_major;
> +        }
> +
> +        /// IRQ sources raw status.
> +        /// Writing to this register forces bits on, but does not clear them.
> +        pub(crate) GPU_IRQ_RAWSTAT(u32) @ 0x20 {
> +            /// A GPU fault has occurred, a 1-bit boolean flag.
> +            0:0     gpu_fault => bool;
> +            /// A GPU fault has occurred, a 1-bit boolean flag.
> +            1:1     gpu_protected_fault => bool;
> +            /// Reset has completed, a 1-bit boolean flag.
> +            8:8     reset_completed => bool;
> +            /// Set when a single power domain has powered up or down, a 1-bit boolean flag.
> +            9:9     power_changed_single => bool;
> +            /// Set when the all pending power domain changes are completed, a 1-bit boolean flag.
> +            10:10   power_changed_all => bool;
> +            /// Set when cache cleaning has completed, a 1-bit boolean flag.
> +            17:17   clean_caches_completed => bool;
> +            /// Mirrors the doorbell interrupt line to the CPU, a 1-bit boolean flag.
> +            18:18   doorbell_mirror => bool;
> +            /// MCU requires attention, a 1-bit boolean flag.
> +            19:19   mcu_status => bool;
> +        }
> +
> +        /// IRQ sources to clear. Write only.
> +        pub(crate) GPU_IRQ_CLEAR(u32) @ 0x24 {
> +            /// Clear the GPU_FAULT interrupt, a 1-bit boolean flag.
> +            0:0     gpu_fault => bool;
> +            /// Clear the GPU_PROTECTED_FAULT interrupt, a 1-bit boolean flag.
> +            1:1     gpu_protected_fault => bool;
> +            /// Clear the RESET_COMPLETED interrupt, a 1-bit boolean flag.
> +            8:8     reset_completed => bool;
> +            /// Clear the POWER_CHANGED_SINGLE interrupt, a 1-bit boolean flag.
> +            9:9     power_changed_single => bool;
> +            /// Clear the POWER_CHANGED_ALL interrupt, a 1-bit boolean flag.
> +            10:10   power_changed_all => bool;
> +            /// Clear the CLEAN_CACHES_COMPLETED interrupt, a 1-bit boolean flag.
> +            17:17   clean_caches_completed => bool;
> +            /// Clear the MCU_STATUS interrupt, a 1-bit boolean flag.
> +            19:19   mcu_status => bool;
> +        }
> +
> +        /// IRQ sources enabled.
> +        pub(crate) GPU_IRQ_MASK(u32) @ 0x28 {
> +            /// Enable the GPU_FAULT interrupt, a 1-bit boolean flag.
> +            0:0     gpu_fault => bool;
> +            /// Enable the GPU_PROTECTED_FAULT interrupt, a 1-bit boolean flag.
> +            1:1     gpu_protected_fault => bool;
> +            /// Enable the RESET_COMPLETED interrupt, a 1-bit boolean flag.
> +            8:8     reset_completed => bool;
> +            /// Enable the POWER_CHANGED_SINGLE interrupt, a 1-bit boolean flag.
> +            9:9     power_changed_single => bool;
> +            /// Enable the POWER_CHANGED_ALL interrupt, a 1-bit boolean flag.
> +            10:10   power_changed_all => bool;
> +            /// Enable the CLEAN_CACHES_COMPLETED interrupt, a 1-bit boolean flag.
> +            17:17   clean_caches_completed => bool;
> +            /// Enable the DOORBELL_MIRROR interrupt, a 1-bit boolean flag.
> +            18:18   doorbell_mirror => bool;
> +            /// Enable the MCU_STATUS interrupt, a 1-bit boolean flag.
> +            19:19   mcu_status => bool;
> +        }
> +
> +        /// IRQ status for enabled sources. Read only.
> +        pub(crate) GPU_IRQ_STATUS(u32) @ 0x2c {
> +            /// GPU_FAULT interrupt status, a 1-bit boolean flag.
> +            0:0     gpu_fault => bool;
> +            /// GPU_PROTECTED_FAULT interrupt status, a 1-bit boolean flag.
> +            1:1     gpu_protected_fault => bool;
> +            /// RESET_COMPLETED interrupt status, a 1-bit boolean flag.
> +            8:8     reset_completed => bool;
> +            /// POWER_CHANGED_SINGLE interrupt status, a 1-bit boolean flag.
> +            9:9     power_changed_single => bool;
> +            /// POWER_CHANGED_ALL interrupt status, a 1-bit boolean flag.
> +            10:10   power_changed_all => bool;
> +            /// CLEAN_CACHES_COMPLETED interrupt status, a 1-bit boolean flag.
> +            17:17   clean_caches_completed => bool;
> +            /// DOORBELL_MIRROR interrupt status, a 1-bit boolean flag.
> +            18:18   doorbell_mirror => bool;
> +            /// MCU_STATUS interrupt status, a 1-bit boolean flag.
> +            19:19   mcu_status => bool;
> +        }
> +    }
> +
> +    /// Helpers for GPU_COMMAND Register
> +    #[derive(Copy, Clone, Debug)]
> +    #[repr(u8)]
> +    pub(crate) enum GpuCommand {
> +        /// No operation. This is the default value.
> +        Nop = 0,
> +        /// Reset the GPU.
> +        Reset = 1,
> +        /// Flush caches.
> +        FlushCaches = 4,
> +        /// Clear GPU faults.
> +        ClearFault = 7,
> +    }
> +
> +    impl TryFrom<Bounded<u32, 8>> for GpuCommand {
> +        type Error = Error;
> +
> +        fn try_from(val: Bounded<u32, 8>) -> Result<Self, Self::Error> {
> +            match val.get() {
> +                0 => Ok(GpuCommand::Nop),
> +                1 => Ok(GpuCommand::Reset),
> +                4 => Ok(GpuCommand::FlushCaches),
> +                7 => Ok(GpuCommand::ClearFault),
> +                _ => Err(EINVAL),
> +            }
> +        }
> +    }
> +
> +    impl From<GpuCommand> for Bounded<u32, 8> {
> +        fn from(cmd: GpuCommand) -> Self {
> +            (cmd as u8).into()
> +        }
> +    }
> +
> +    /// Reset mode for [`GPU_COMMAND::reset()`].
> +    #[derive(Copy, Clone, Debug)]
> +    #[repr(u8)]
> +    pub(crate) enum ResetMode {
> +        /// Stop all external bus interfaces, then reset the entire GPU.
> +        SoftReset = 1,
> +        /// Force a full GPU reset.
> +        HardReset = 2,
> +    }
> +
> +    impl TryFrom<Bounded<u32, 4>> for ResetMode {
> +        type Error = Error;
> +
> +        fn try_from(val: Bounded<u32, 4>) -> Result<Self, Self::Error> {
> +            match val.get() {
> +                1 => Ok(ResetMode::SoftReset),
> +                2 => Ok(ResetMode::HardReset),
> +                _ => Err(EINVAL),
> +            }
> +        }
> +    }
> +
> +    impl From<ResetMode> for Bounded<u32, 4> {
> +        fn from(mode: ResetMode) -> Self {
> +            Bounded::try_new(mode as u32).unwrap()
> +        }
> +    }
> +
> +    /// Cache flush mode for [`GPU_COMMAND::flush_caches()`].
> +    #[derive(Copy, Clone, Debug)]
> +    #[repr(u8)]
> +    pub(crate) enum FlushMode {
> +        /// No flush.
> +        None = 0,
> +        /// Clean the caches.
> +        Clean = 1,
> +        /// Invalidate the caches.
> +        Invalidate = 2,
> +        /// Clean and invalidate the caches.
> +        CleanInvalidate = 3,
> +    }
> +
> +    impl TryFrom<Bounded<u32, 4>> for FlushMode {
> +        type Error = Error;
> +
> +        fn try_from(val: Bounded<u32, 4>) -> Result<Self, Self::Error> {
> +            match val.get() {
> +                0 => Ok(FlushMode::None),
> +                1 => Ok(FlushMode::Clean),
> +                2 => Ok(FlushMode::Invalidate),
> +                3 => Ok(FlushMode::CleanInvalidate),
> +                _ => Err(EINVAL),
> +            }
> +        }
> +    }
> +
> +    impl From<FlushMode> for Bounded<u32, 4> {
> +        fn from(mode: FlushMode) -> Self {
> +            Bounded::try_new(mode as u32).unwrap()
> +        }
> +    }
> +
> +    register! {
> +        /// GPU command register.
> +        ///
> +        /// Use the constructor methods to create commands:
> +        /// - [`GPU_COMMAND::nop()`]
> +        /// - [`GPU_COMMAND::reset()`]
> +        /// - [`GPU_COMMAND::flush_caches()`]
> +        /// - [`GPU_COMMAND::clear_fault()`]
> +        pub(crate) GPU_COMMAND (u32) @ 0x30 {
> +            7:0     command ?=> GpuCommand;
> +        }
> +        /// Internal alias for GPU_COMMAND in reset mode.
> +        /// Use [`GPU_COMMAND::reset()`] instead.
> +        GPU_COMMAND_RESET (u32) => GPU_COMMAND {
> +            7:0     command ?=> GpuCommand;
> +            11:8    reset_mode ?=> ResetMode;
> +        }
> +
> +        /// Internal alias for GPU_COMMAND in cache flush mode.
> +        /// Use [`GPU_COMMAND::flush_caches()`] instead.
> +        GPU_COMMAND_FLUSH (u32) => GPU_COMMAND {
> +            7:0     command ?=> GpuCommand;
> +            /// L2 cache flush mode.
> +            11:8    l2_flush ?=> FlushMode;
> +            /// Shader core load/store cache flush mode.
> +            15:12   lsc_flush ?=> FlushMode;
> +            /// Shader core other caches flush mode.
> +            19:16   other_flush ?=> FlushMode;
> +        }
> +    }
> +
> +    impl GPU_COMMAND {
> +        /// Create a NOP command.
> +        pub(crate) fn nop() -> Self {
> +            Self::zeroed()
> +        }
> +
> +        /// Create a reset command with the specified reset mode.
> +        pub(crate) fn reset(mode: ResetMode) -> Self {
> +            Self::from_raw(
> +                GPU_COMMAND_RESET::zeroed()
> +                    .with_command(GpuCommand::Reset)
> +                    .with_reset_mode(mode)
> +                    .into_raw(),
> +            )
> +        }
> +
> +        /// Create a cache flush command with the specified flush modes.
> +        pub(crate) fn flush_caches(l2: FlushMode, lsc: FlushMode, other: FlushMode) -> Self {
> +            Self::from_raw(
> +                GPU_COMMAND_FLUSH::zeroed()
> +                    .with_command(GpuCommand::FlushCaches)
> +                    .with_l2_flush(l2)
> +                    .with_lsc_flush(lsc)
> +                    .with_other_flush(other)
> +                    .into_raw(),
> +            )
> +        }
> +
> +        /// Create a clear fault command.
> +        pub(crate) fn clear_fault() -> Self {
> +            Self::zeroed().with_command(GpuCommand::ClearFault)
> +        }
> +    }
> +
> +    register! {
> +        /// GPU status register. Read only.
> +        pub(crate) GPU_STATUS(u32) @ 0x34 {
> +            /// GPU active, a 1-bit boolean flag.
> +            0:0     gpu_active => bool;
> +            /// Power manager active, a 1-bit boolean flag
> +            1:1     pwr_active => bool;
> +            /// Page fault active, a 1-bit boolean flag.
> +            4:4     page_fault => bool;
> +            /// Protected mode active, a 1-bit boolean flag.
> +            7:7     protected_mode_active => bool;
> +            /// Debug mode active, a 1-bit boolean flag.
> +            8:8     gpu_dbg_enabled => bool;
> +        }
> +    }
> +
> +    #[derive(Copy, Clone, Debug)]
> +    #[repr(u8)]
> +    pub(crate) enum ExceptionType {
> +        /// Exception type: No error.
> +        Ok = 0x00,
> +        /// Exception type: GPU external bus error.
> +        GpuBusFault = 0x80,
> +        /// Exception type: GPU shareability error.
> +        GpuShareabilityFault = 0x88,
> +        /// Exception type: System shareability error.
> +        SystemShareabilityFault = 0x89,
> +        /// Exception type: GPU cacheability error.
> +        GpuCacheabilityFault = 0x8A,
> +    }
> +
> +    impl TryFrom<Bounded<u32, 8>> for ExceptionType {
> +        type Error = Error;
> +
> +        fn try_from(val: Bounded<u32, 8>) -> Result<Self, Self::Error> {
> +            match val.get() {
> +                0x00 => Ok(ExceptionType::Ok),
> +                0x80 => Ok(ExceptionType::GpuBusFault),
> +                0x88 => Ok(ExceptionType::GpuShareabilityFault),
> +                0x89 => Ok(ExceptionType::SystemShareabilityFault),
> +                0x8A => Ok(ExceptionType::GpuCacheabilityFault),
> +                _ => Err(EINVAL),
> +            }
> +        }
> +    }
> +
> +    impl From<ExceptionType> for Bounded<u32, 8> {
> +        fn from(exc: ExceptionType) -> Self {
> +            (exc as u8).into()
> +        }
> +    }
> +
> +    #[derive(Copy, Clone, Debug)]
> +    #[repr(u8)]
> +    pub(crate) enum AccessType {
> +        /// Access type: An atomic (read/write) transaction.
> +        Atomic = 0,
> +        /// Access type: An execute transaction.
> +        Execute = 1,
> +        /// Access type: A read transaction.
> +        Read = 2,
> +        /// Access type: A write transaction.
> +        Write = 3,
> +    }
> +
> +    impl From<Bounded<u32, 2>> for AccessType {
> +        fn from(val: Bounded<u32, 2>) -> Self {
> +            match val.get() {
> +                0 => AccessType::Atomic,
> +                1 => AccessType::Execute,
> +                2 => AccessType::Read,
> +                3 => AccessType::Write,
> +                _ => unreachable!(),
> +            }
> +        }
> +    }
> +
> +    impl From<AccessType> for Bounded<u32, 2> {
> +        fn from(access: AccessType) -> Self {
> +            Bounded::try_new(access as u32).unwrap()
> +        }
> +    }
> +
> +    register! {
> +        /// GPU fault status register. Read only.
> +        pub(crate) GPU_FAULTSTATUS(u32) @ 0x3c {
> +            /// Exception type.
> +            7:0     exception_type ?=> ExceptionType;
> +            /// Access type.
> +            9:8     access_type => AccessType;
> +            /// The GPU_FAULTADDRESS is valid, a 1-bit boolean flag.
> +            10:10   address_valid => bool;
> +            /// The JASID field is valid, a 1-bit boolean flag.
> +            11:11   jasid_valid => bool;
> +            /// JASID of the fault, if known.
> +            15:12   jasid;
> +            /// ID of the source that triggered the fault.
> +            31:16   source_id;
> +        }
> +
> +        /// GPU fault address. Read only.
> +        /// Once a fault is reported, it must be manually cleared by issuing a
> +        /// [`GPU_COMMAND::clear_fault()`] command to the [`GPU_COMMAND`] register. No further GPU
> +        /// faults will be reported until the previous fault has been cleared.
> +        pub(crate) GPU_FAULTADDRESS(u64) @ 0x40 {
> +            63:0    pointer;
> +        }
> +
> +        /// Level 2 cache configuration.
> +        pub(crate) L2_CONFIG(u32) @ 0x48 {
> +            /// Requested cache size.
> +            23:16   cache_size;
> +            /// Requested hash function index.
> +            31:24   hash_function;
> +        }
> +
> +        /// Global time stamp offset.
> +        pub(crate) TIMESTAMP_OFFSET(u64) @ 0x88 {
> +            63:0    offset;
> +        }
> +
> +        /// GPU cycle counter. Read only.
> +        pub(crate) CYCLE_COUNT(u64) @ 0x90 {
> +            63:0    count;
> +        }
> +
> +        /// Global time stamp. Read only.
> +        pub(crate) TIMESTAMP(u64) @ 0x98 {
> +            63:0    timestamp;
> +        }
> +
> +        /// Maximum number of threads per core. Read only constant.
> +        pub(crate) THREAD_MAX_THREADS(u32) @ 0xa0 {
> +            31:0    threads;
> +        }
> +
> +        /// Maximum number of threads per workgroup. Read only constant.
> +        pub(crate) THREAD_MAX_WORKGROUP_SIZE(u32) @ 0xa4 {
> +            31:0    threads;
> +        }
> +
> +        /// Maximum number of threads per barrier. Read only constant.
> +        pub(crate) THREAD_MAX_BARRIER_SIZE(u32) @ 0xa8 {
> +            31:0    threads;
> +        }
> +
> +        /// Thread features. Read only constant.
> +        pub(crate) THREAD_FEATURES(u32) @ 0xac {
> +            /// Total number of registers per core.
> +            21:0    max_registers;
> +            /// Implementation technology type.
> +            23:22   implementation_technology;
> +            /// Maximum number of compute tasks waiting.
> +            31:24   max_task_queue;
> +        }
> +
> +        /// Support flags for compressed texture formats. Read only constant.
> +        ///
> +        /// A bitmap where each bit indicates support for a specific compressed texture format.
> +        /// The bit position maps to an opaque format ID (`texture_features_key_t` in spec).
> +        pub(crate) TEXTURE_FEATURES(u32)[4] @ 0xb0 {
> +            31:0    supported_formats;
> +        }
> +
> +        /// Shader core present bitmap. Read only constant.
> +        pub(crate) SHADER_PRESENT(u64) @ 0x100 {
> +            63:0    present;
> +        }
> +
> +        /// Tiler present bitmap. Read only constant.
> +        pub(crate) TILER_PRESENT(u64) @ 0x110 {
> +            63:0    present;
> +        }
> +
> +        /// L2 cache present bitmap. Read only constant.
> +        pub(crate) L2_PRESENT(u64) @ 0x120 {
> +            63:0    present;
> +        }
> +
> +        /// Shader core ready bitmap. Read only.
> +        pub(crate) SHADER_READY(u64) @ 0x140 {
> +            63:0    ready;
> +        }
> +
> +        /// Tiler ready bitmap. Read only.
> +        pub(crate) TILER_READY(u64) @ 0x150 {
> +            63:0    ready;
> +        }
> +
> +        /// L2 ready bitmap. Read only.
> +        pub(crate) L2_READY(u64) @ 0x160 {
> +            63:0    ready;
> +        }
> +
> +        /// Shader core power up bitmap.
> +        pub(crate) SHADER_PWRON(u64) @ 0x180 {
> +            63:0    request;
> +        }
> +
> +        /// Tiler power up bitmap.
> +        pub(crate) TILER_PWRON(u64) @ 0x190 {
> +            63:0    request;
> +        }
> +
> +        /// L2 power up bitmap.
> +        pub(crate) L2_PWRON(u64) @ 0x1a0 {
> +            63:0 request;
> +        }
> +
> +        /// Shader core power down bitmap.
> +        pub(crate) SHADER_PWROFF(u64) @ 0x1c0 {
> +            63:0 request;
> +        }
> +
> +        /// Tiler power down bitmap.
> +        pub(crate) TILER_PWROFF(u64) @ 0x1d0 {
> +            63:0 request;
> +        }
> +
> +        /// L2 power down bitmap.
> +        pub(crate) L2_PWROFF(u64) @ 0x1e0 {
> +            63:0 request;
> +        }
> +
> +        /// Shader core power transition bitmap. Read-only.
> +        pub(crate) SHADER_PWRTRANS(u64) @ 0x200 {
> +            63:0 changing;
> +        }
> +
> +        /// Tiler power transition bitmap. Read-only.
> +        pub(crate) TILER_PWRTRANS(u64) @ 0x210 {
> +            63:0 changing;
> +        }
> +
> +        /// L2 power transition bitmap. Read-only.
> +        pub(crate) L2_PWRTRANS(u64) @ 0x220 {
> +            63:0 changing;
> +        }
> +
> +        /// Shader core active bitmap. Read-only.
> +        pub(crate) SHADER_PWRACTIVE(u64) @ 0x240 {
> +            63:0 active;
> +        }
> +
> +        /// Tiler active bitmap. Read-only.
> +        pub(crate) TILER_PWRACTIVE(u64) @ 0x250 {
> +            63:0 active;
> +        }
> +
> +        /// L2 active bitmap.  Read-only.
> +        pub(crate) L2_PWRACTIVE(u64) @ 0x260 {
> +            63:0 active;
> +        }
> +
> +        /// Revision ID. Read only constant.
> +        pub(crate) REVIDR(u32) @ 0x280 {
> +            31:0    revision;
> +        }
> +
> +        /// Coherency features present. Read only constant.
> +        /// Supported protocols on the interconnect between the GPU and the
> +        /// system into which it is integrated.
> +        pub(crate) COHERENCY_FEATURES(u32) @ 0x300 {
> +            /// ACE-Lite protocol supported, a 1-bit boolean flag.
> +            0:0     ace_lite => bool;
> +            /// ACE protocol supported, a 1-bit boolean flag.
> +            1:1     ace => bool;
> +        }
> +    }
> +
> +    #[derive(Copy, Clone, Debug)]
> +    #[repr(u8)]
> +    pub(crate) enum CoherencyMode {
> +        /// ACE-Lite coherency protocol.
> +        AceLite = uapi::drm_panthor_gpu_coherency_DRM_PANTHOR_GPU_COHERENCY_ACE_LITE as u8,
> +        /// ACE coherency protocol.
> +        Ace = uapi::drm_panthor_gpu_coherency_DRM_PANTHOR_GPU_COHERENCY_ACE as u8,
> +        /// No coherency protocol.
> +        None = uapi::drm_panthor_gpu_coherency_DRM_PANTHOR_GPU_COHERENCY_NONE as u8,
> +    }
> +
> +    impl TryFrom<Bounded<u32, 32>> for CoherencyMode {
> +        type Error = Error;
> +
> +        fn try_from(val: Bounded<u32, 32>) -> Result<Self, Self::Error> {
> +            match val.get() {
> +                0 => Ok(CoherencyMode::AceLite),
> +                1 => Ok(CoherencyMode::Ace),
> +                31 => Ok(CoherencyMode::None),
> +                _ => Err(EINVAL),
> +            }
> +        }
> +    }
> +
> +    impl From<CoherencyMode> for Bounded<u32, 32> {
> +        fn from(mode: CoherencyMode) -> Self {
> +            (mode as u8).into()
> +        }
> +    }
> +
> +    register! {
> +        /// Coherency enable. An index of which coherency protocols should be used.
> +        /// This register only selects the protocol for coherency messages on the
> +        /// interconnect. This is not to enable or disable coherency controlled by MMU.
> +        pub(crate) COHERENCY_ENABLE(u32) @ 0x304 {
> +            31:0    l2_cache_protocol_select ?=> CoherencyMode;
> +        }
> +    }
> +
> +    /// Helpers for MCU_CONTROL register
> +    #[derive(Copy, Clone, Debug)]
> +    #[repr(u8)]
> +    pub(crate) enum McuControlMode {
> +        /// Disable the MCU.
> +        Disable = 0,
> +        /// Enable the MCU.
> +        Enable = 1,
> +        /// Enable the MCU to execute and automatically reboot after a fast reset.
> +        Auto = 2,
> +    }
> +
> +    impl TryFrom<Bounded<u32, 2>> for McuControlMode {
> +        type Error = Error;
> +
> +        fn try_from(val: Bounded<u32, 2>) -> Result<Self, Self::Error> {
> +            match val.get() {
> +                0 => Ok(McuControlMode::Disable),
> +                1 => Ok(McuControlMode::Enable),
> +                2 => Ok(McuControlMode::Auto),
> +                _ => Err(EINVAL),
> +            }
> +        }
> +    }
> +
> +    impl From<McuControlMode> for Bounded<u32, 2> {
> +        fn from(mode: McuControlMode) -> Self {
> +            Bounded::try_new(mode as u32).unwrap()
> +        }
> +    }
> +
> +    register! {
> +        /// MCU control.
> +        pub(crate) MCU_CONTROL(u32) @ 0x700 {
> +            /// Request MCU state change.
> +            1:0 req ?=> McuControlMode;
> +        }
> +    }
> +
> +    /// Helpers for MCU_STATUS register
> +    #[derive(Copy, Clone, Debug)]
> +    #[repr(u8)]
> +    pub(crate) enum McuStatus {
> +        /// MCU is disabled.
> +        Disabled = 0,
> +        /// MCU is enabled.
> +        Enabled = 1,
> +        /// The MCU has halted by itself in an orderly manner to enable the core group to be powered down.
> +        Halt = 2,
> +        /// The MCU has encountered an error that prevents it from continuing.
> +        Fatal = 3,
> +    }
> +
> +    impl From<Bounded<u32, 2>> for McuStatus {
> +        fn from(val: Bounded<u32, 2>) -> Self {
> +            match val.get() {
> +                0 => McuStatus::Disabled,
> +                1 => McuStatus::Enabled,
> +                2 => McuStatus::Halt,
> +                3 => McuStatus::Fatal,
> +                _ => unreachable!(),
> +            }
> +        }
> +    }
> +
> +    impl From<McuStatus> for Bounded<u32, 2> {
> +        fn from(status: McuStatus) -> Self {
> +            Bounded::try_new(status as u32).unwrap()
> +        }
> +    }
> +
> +    register! {
> +        /// MCU status. Read only.
> +        pub(crate) MCU_STATUS(u32) @ 0x704 {
> +            /// Read current state of MCU.
> +            1:0 value => McuStatus;
> +        }
> +    }
> +}
>  
>  pub(crate) const JOB_IRQ_RAWSTAT: Register<0x1000> = Register;
>  pub(crate) const JOB_IRQ_CLEAR: Register<0x1004> = Register;
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 04/12] drm/tyr: Use register! macro for JOB_CONTROL
  2026-03-24  0:18 ` [PATCH v3 04/12] drm/tyr: Use register! macro for JOB_CONTROL Deborah Brouwer
@ 2026-03-24 10:00   ` Boris Brezillon
  0 siblings, 0 replies; 30+ messages in thread
From: Boris Brezillon @ 2026-03-24 10:00 UTC (permalink / raw)
  To: Deborah Brouwer
  Cc: dri-devel, rust-for-linux, Boqun Feng, Danilo Krummrich,
	Alice Ryhl, Daniel Almeida, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Miguel Ojeda,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, Steven Price, Dirk Behme, Alexandre Courbot

On Mon, 23 Mar 2026 17:18:06 -0700
Deborah Brouwer <deborah.brouwer@collabora.com> wrote:

> Convert the JOB_CONTROL register definitions to use the `register!` macro.
> 
> Using the `register!` macro allows us to replace manual bit masks and
> shifts with typed register and field accessors, which makes the code
> easier to read and avoids errors from bit manipulation.
> 
> Co-developed-by: Daniel Almeida <daniel.almeida@collabora.com>
> Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com>
> Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
> Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>

> ---
>  drivers/gpu/drm/tyr/regs.rs | 58 ++++++++++++++++++++++++++++++++++++++-------
>  1 file changed, 50 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tyr/regs.rs b/drivers/gpu/drm/tyr/regs.rs
> index 5ba4919263af29c6e88435099cf801fa5874b117..bae3f917dd3ad3fe0dfd8425a119347f9d1ebbe8 100644
> --- a/drivers/gpu/drm/tyr/regs.rs
> +++ b/drivers/gpu/drm/tyr/regs.rs
> @@ -28,7 +28,6 @@
>  #![allow(dead_code)]
>  
>  use kernel::{
> -    bits::bit_u32,
>      device::{
>          Bound,
>          Device, //
> @@ -787,14 +786,57 @@ fn from(status: McuStatus) -> Self {
>      }
>  }
>  
> -pub(crate) const JOB_IRQ_RAWSTAT: Register<0x1000> = Register;
> -pub(crate) const JOB_IRQ_CLEAR: Register<0x1004> = Register;
> -pub(crate) const JOB_IRQ_MASK: Register<0x1008> = Register;
> -pub(crate) const JOB_IRQ_STAT: Register<0x100c> = Register;
> -
> -pub(crate) const JOB_IRQ_GLOBAL_IF: u32 = bit_u32(31);
> -
>  pub(crate) const MMU_IRQ_RAWSTAT: Register<0x2000> = Register;
>  pub(crate) const MMU_IRQ_CLEAR: Register<0x2004> = Register;
>  pub(crate) const MMU_IRQ_MASK: Register<0x2008> = Register;
>  pub(crate) const MMU_IRQ_STAT: Register<0x200c> = Register;
> +
> +/// These registers correspond to the JOB_CONTROL register page.
> +/// They are involved in communication between the firmware running on the MCU and the host.
> +pub(crate) mod job_control {
> +    use kernel::register;
> +
> +    register! {
> +        /// Raw status of job interrupts.
> +        ///
> +        /// Write to this register to trigger these interrupts.
> +        /// Writing a 1 to a bit forces that bit on.
> +        pub(crate) JOB_IRQ_RAWSTAT(u32) @ 0x1000 {
> +            /// CSG request. These bits indicate that CSGn requires attention from the host.
> +            30:0    csg;
> +            /// GLB request. Indicates that the GLB interface requires attention from the host.
> +            31:31   glb;

Should this be

               31:31   glb => bool;

?

> +        }
> +
> +        /// Clear job interrupts. Write only.
> +        ///
> +        /// Write a 1 to a bit to clear the corresponding bit in [`JOB_IRQ_RAWSTAT`].
> +        pub(crate) JOB_IRQ_CLEAR(u32) @ 0x1004 {
> +            /// Clear CSG request interrupts.
> +            30:0    csg;
> +            /// Clear GLB request interrupt.
> +            31:31   glb;
> +        }
> +
> +        /// Mask for job interrupts.
> +        ///
> +        /// Set each bit to 1 to enable the corresponding interrupt source or to 0 to disable it.
> +        pub(crate) JOB_IRQ_MASK(u32) @ 0x1008 {
> +            /// Enable CSG request interrupts.
> +            30:0    csg;
> +            /// Enable GLB request interrupt.
> +            31:31   glb;
> +        }
> +
> +        /// Active job interrupts. Read only.
> +        ///
> +        /// This register contains the result of ANDing together [`JOB_IRQ_RAWSTAT`] and
> +        /// [`JOB_IRQ_MASK`].
> +        pub(crate) JOB_IRQ_STATUS(u32) @ 0x100c {
> +            /// CSG request interrupt status.
> +            30:0    csg;
> +            /// GLB request interrupt status.
> +            31:31   glb;
> +        }
> +    }
> +}
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 05/12] drm/tyr: Use register! macro for MMU_CONTROL
  2026-03-24  0:18 ` [PATCH v3 05/12] drm/tyr: Use register! macro for MMU_CONTROL Deborah Brouwer
@ 2026-03-24 10:01   ` Boris Brezillon
  0 siblings, 0 replies; 30+ messages in thread
From: Boris Brezillon @ 2026-03-24 10:01 UTC (permalink / raw)
  To: Deborah Brouwer
  Cc: dri-devel, rust-for-linux, Boqun Feng, Danilo Krummrich,
	Alice Ryhl, Daniel Almeida, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Miguel Ojeda,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, Steven Price, Dirk Behme, Alexandre Courbot

On Mon, 23 Mar 2026 17:18:07 -0700
Deborah Brouwer <deborah.brouwer@collabora.com> wrote:

> Convert the MMU_CONTROL register definitions to use the `register!` macro.
> 
> Using the `register!` macro allows us to replace manual bit masks and
> shifts with typed register and field accessors, which makes the code
> easier to read and avoids errors from bit manipulation.
> 
> Co-developed-by: Daniel Almeida <daniel.almeida@collabora.com>
> Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com>
> Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
> Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>

> ---
>  drivers/gpu/drm/tyr/regs.rs | 56 +++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 51 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tyr/regs.rs b/drivers/gpu/drm/tyr/regs.rs
> index bae3f917dd3ad3fe0dfd8425a119347f9d1ebbe8..869bad81d988b4c3d4d65e014d646b6db568e919 100644
> --- a/drivers/gpu/drm/tyr/regs.rs
> +++ b/drivers/gpu/drm/tyr/regs.rs
> @@ -786,11 +786,6 @@ fn from(status: McuStatus) -> Self {
>      }
>  }
>  
> -pub(crate) const MMU_IRQ_RAWSTAT: Register<0x2000> = Register;
> -pub(crate) const MMU_IRQ_CLEAR: Register<0x2004> = Register;
> -pub(crate) const MMU_IRQ_MASK: Register<0x2008> = Register;
> -pub(crate) const MMU_IRQ_STAT: Register<0x200c> = Register;
> -
>  /// These registers correspond to the JOB_CONTROL register page.
>  /// They are involved in communication between the firmware running on the MCU and the host.
>  pub(crate) mod job_control {
> @@ -840,3 +835,54 @@ pub(crate) mod job_control {
>          }
>      }
>  }
> +
> +/// These registers correspond to the MMU_CONTROL register page.
> +/// They are involved in MMU configuration and control.
> +pub(crate) mod mmu_control {
> +    use kernel::register;
> +
> +    register! {
> +        /// IRQ sources raw status.
> +        ///
> +        /// This register contains the raw unmasked interrupt sources for MMU status and exception
> +        /// handling.
> +        ///
> +        /// Writing to this register forces bits on.
> +        /// Use [`IRQ_CLEAR`] to clear interrupts.
> +        pub(crate) IRQ_RAWSTAT(u32) @ 0x2000 {
> +            /// Page fault for address spaces.
> +            15:0    page_fault;
> +            /// Command completed in address spaces.
> +            31:16   command_completed;
> +        }
> +
> +        /// IRQ sources to clear.
> +        /// Write a 1 to a bit to clear the corresponding bit in [`IRQ_RAWSTAT`].
> +        pub(crate) IRQ_CLEAR(u32) @ 0x2004 {
> +            /// Clear the PAGE_FAULT interrupt.
> +            15:0    page_fault;
> +            /// Clear the COMMAND_COMPLETED interrupt.
> +            31:16   command_completed;
> +        }
> +
> +        /// IRQ sources enabled.
> +        ///
> +        /// Set each bit to 1 to enable the corresponding interrupt source, and to 0 to disable it.
> +        pub(crate) IRQ_MASK(u32) @ 0x2008 {
> +            /// Enable the PAGE_FAULT interrupt.
> +            15:0    page_fault;
> +            /// Enable the COMMAND_COMPLETED interrupt.
> +            31:16   command_completed;
> +        }
> +
> +        /// IRQ status for enabled sources. Read only.
> +        ///
> +        /// This register contains the result of ANDing together [`IRQ_RAWSTAT`] and [`IRQ_MASK`].
> +        pub(crate) IRQ_STATUS(u32) @ 0x200c {
> +            /// PAGE_FAULT interrupt status.
> +            15:0    page_fault;
> +            /// COMMAND_COMPLETED interrupt status.
> +            31:16   command_completed;
> +        }
> +    }
> +}
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 06/12] drm/tyr: Remove custom register struct
  2026-03-24  0:18 ` [PATCH v3 06/12] drm/tyr: Remove custom register struct Deborah Brouwer
@ 2026-03-24 10:02   ` Boris Brezillon
  0 siblings, 0 replies; 30+ messages in thread
From: Boris Brezillon @ 2026-03-24 10:02 UTC (permalink / raw)
  To: Deborah Brouwer
  Cc: dri-devel, rust-for-linux, Boqun Feng, Danilo Krummrich,
	Alice Ryhl, Daniel Almeida, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Miguel Ojeda,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, Steven Price, Dirk Behme, Alexandre Courbot

On Mon, 23 Mar 2026 17:18:08 -0700
Deborah Brouwer <deborah.brouwer@collabora.com> wrote:

> Now that Tyr uses the register! macro, it no longer needs to define a
> custom register struct or read/write functions, so delete them.
> 
> Co-developed-by: Daniel Almeida <daniel.almeida@collabora.com>
> Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com>
> Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
> Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>

> ---
>  drivers/gpu/drm/tyr/regs.rs | 33 ---------------------------------
>  1 file changed, 33 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tyr/regs.rs b/drivers/gpu/drm/tyr/regs.rs
> index 869bad81d988b4c3d4d65e014d646b6db568e919..f337d99387417a2eca94cd2d7ce8c8fa38bb1cee 100644
> --- a/drivers/gpu/drm/tyr/regs.rs
> +++ b/drivers/gpu/drm/tyr/regs.rs
> @@ -27,39 +27,6 @@
>  // does.
>  #![allow(dead_code)]
>  
> -use kernel::{
> -    device::{
> -        Bound,
> -        Device, //
> -    },
> -    devres::Devres,
> -    io::Io,
> -    prelude::*, //
> -};
> -
> -use crate::driver::IoMem;
> -
> -/// Represents a register in the Register Set
> -///
> -/// TODO: Replace this with the Nova `register!()` macro when it is available.
> -/// In particular, this will automatically give us 64bit register reads and
> -/// writes.
> -pub(crate) struct Register<const OFFSET: usize>;
> -
> -impl<const OFFSET: usize> Register<OFFSET> {
> -    #[inline]
> -    pub(crate) fn read(&self, dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result<u32> {
> -        let value = (*iomem).access(dev)?.read32(OFFSET);
> -        Ok(value)
> -    }
> -
> -    #[inline]
> -    pub(crate) fn write(&self, dev: &Device<Bound>, iomem: &Devres<IoMem>, value: u32) -> Result {
> -        (*iomem).access(dev)?.write32(value, OFFSET);
> -        Ok(())
> -    }
> -}
> -
>  /// These registers correspond to the GPU_CONTROL register page.
>  /// They are involved in GPU configuration and control.
>  pub(crate) mod gpu_control {
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 07/12] drm/tyr: Add MMU address space registers
  2026-03-24  0:18 ` [PATCH v3 07/12] drm/tyr: Add MMU address space registers Deborah Brouwer
@ 2026-03-24 10:03   ` Boris Brezillon
  0 siblings, 0 replies; 30+ messages in thread
From: Boris Brezillon @ 2026-03-24 10:03 UTC (permalink / raw)
  To: Deborah Brouwer
  Cc: dri-devel, rust-for-linux, Boqun Feng, Danilo Krummrich,
	Alice Ryhl, Daniel Almeida, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Miguel Ojeda,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, Steven Price, Dirk Behme, Alexandre Courbot

On Mon, 23 Mar 2026 17:18:09 -0700
Deborah Brouwer <deborah.brouwer@collabora.com> wrote:

> Add a new module for the per-address-space MMU registers and constants.
> Leave the more complex register field definitions empty for now; they
> will be filled in by follow-up commits.
> 
> Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>

> ---
>  drivers/gpu/drm/tyr/regs.rs | 66 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 66 insertions(+)
> 
> diff --git a/drivers/gpu/drm/tyr/regs.rs b/drivers/gpu/drm/tyr/regs.rs
> index f337d99387417a2eca94cd2d7ce8c8fa38bb1cee..428b6d8c4d6bfd341713bbb7d79e0556a2d04415 100644
> --- a/drivers/gpu/drm/tyr/regs.rs
> +++ b/drivers/gpu/drm/tyr/regs.rs
> @@ -852,4 +852,70 @@ pub(crate) mod mmu_control {
>              31:16   command_completed;
>          }
>      }
> +
> +    /// Per-address space registers ASn [0..15] within the MMU_CONTROL page.
> +    ///
> +    /// This array contains 16 instances of the MMU_AS_CONTROL register page.
> +    pub(crate) mod mmu_as_control {
> +        use kernel::register;
> +
> +        /// Maximum number of hardware address space slots.
> +        /// The actual number of slots available is usually lower.
> +        pub(crate) const MAX_AS: usize = 16;
> +
> +        /// Address space register stride. The elements in the array are spaced 64B apart.
> +        const STRIDE: usize = 0x40;
> +
> +        register! {
> +            /// Translation table base address. A 64-bit pointer.
> +            ///
> +            /// This field contains the address of the top level of a translation table structure.
> +            /// This must be 16-byte-aligned, so address bits [3:0] are assumed to be zero.
> +            pub(crate) TRANSTAB(u64)[MAX_AS, stride = STRIDE] @ 0x2400 {
> +                /// Base address of the translation table.
> +                63:0    base;
> +            }
> +
> +            /// Memory attributes.
> +            ///
> +            /// Each address space can configure up to 8 different memory attribute profiles.
> +            /// Each attribute profile follows the MMU_MEMATTR_STAGE1 layout.
> +            pub(crate) MEMATTR(u64)[MAX_AS, stride = STRIDE] @ 0x2408 {}
> +
> +            /// Lock region address for each address space.
> +            pub(crate) LOCKADDR(u64)[MAX_AS, stride = STRIDE] @ 0x2410 {
> +                /// Lock region size.
> +                5:0     size;
> +                /// Lock region base address.
> +                63:12   base;
> +            }
> +
> +            /// MMU command register for each address space. Write only.
> +            pub(crate) COMMAND(u32)[MAX_AS, stride = STRIDE] @ 0x2418 {}
> +
> +            /// Fault status register for each address space. Read only.
> +            pub(crate) FAULTSTATUS(u32)[MAX_AS, stride = STRIDE] @ 0x241c {}
> +
> +            /// Fault address for each address space. Read only.
> +            pub(crate) FAULTADDRESS(u64)[MAX_AS, stride = STRIDE] @ 0x2420 {
> +                63:0    pointer;
> +            }
> +
> +            /// MMU status register for each address space. Read only.
> +            pub(crate) STATUS(u32)[MAX_AS, stride = STRIDE] @ 0x2428 {
> +                /// External address space command is active, a 1-bit boolean flag.
> +                0:0     active_ext => bool;
> +                /// Internal address space command is active, a 1-bit boolean flag.
> +                1:1     active_int => bool;
> +            }
> +
> +            /// Translation configuration and control.
> +            pub(crate) TRANSCFG(u64)[MAX_AS, stride = STRIDE] @ 0x2430 {}
> +
> +            /// Extra fault information for each address space. Read only.
> +            pub(crate) FAULTEXTRA(u64)[MAX_AS, stride = STRIDE] @ 0x2438 {
> +                63:0    value;
> +            }
> +        }
> +    }
>  }
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 08/12] drm/tyr: Add fields for MEMATTR register
  2026-03-24  0:18 ` [PATCH v3 08/12] drm/tyr: Add fields for MEMATTR register Deborah Brouwer
@ 2026-03-24 10:05   ` Boris Brezillon
  0 siblings, 0 replies; 30+ messages in thread
From: Boris Brezillon @ 2026-03-24 10:05 UTC (permalink / raw)
  To: Deborah Brouwer
  Cc: dri-devel, rust-for-linux, Boqun Feng, Danilo Krummrich,
	Alice Ryhl, Daniel Almeida, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Miguel Ojeda,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, Steven Price, Dirk Behme, Alexandre Courbot

On Mon, 23 Mar 2026 17:18:10 -0700
Deborah Brouwer <deborah.brouwer@collabora.com> wrote:

> The MEMATTR register allows up to eight memory attributes to be
> defined simultaneously. Add these attribute fields and helpers to
> define them.
> 
> Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>

> ---
>  drivers/gpu/drm/tyr/regs.rs | 162 +++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 160 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tyr/regs.rs b/drivers/gpu/drm/tyr/regs.rs
> index 428b6d8c4d6bfd341713bbb7d79e0556a2d04415..9bf2723ab6412034be9a77930532cc89d0adb128 100644
> --- a/drivers/gpu/drm/tyr/regs.rs
> +++ b/drivers/gpu/drm/tyr/regs.rs
> @@ -857,7 +857,16 @@ pub(crate) mod mmu_control {
>      ///
>      /// This array contains 16 instances of the MMU_AS_CONTROL register page.
>      pub(crate) mod mmu_as_control {
> -        use kernel::register;
> +        use core::convert::TryFrom;
> +
> +        use kernel::{
> +            error::{
> +                code::EINVAL,
> +                Error, //
> +            },
> +            num::Bounded,
> +            register, //
> +        };
>  
>          /// Maximum number of hardware address space slots.
>          /// The actual number of slots available is usually lower.
> @@ -875,12 +884,161 @@ pub(crate) mod mmu_as_control {
>                  /// Base address of the translation table.
>                  63:0    base;
>              }
> +        }
> +
> +        /// Helpers for MEMATTR Register.
> +
> +        #[derive(Copy, Clone, Debug)]
> +        #[repr(u8)]
> +        pub(crate) enum AllocPolicySelect {
> +            /// Ignore ALLOC_R/ALLOC_W fields.
> +            Impl = 2,
> +            /// Use ALLOC_R/ALLOC_W fields for allocation policy.
> +            Alloc = 3,
> +        }
> +
> +        impl TryFrom<Bounded<u8, 2>> for AllocPolicySelect {
> +            type Error = Error;
> +
> +            fn try_from(val: Bounded<u8, 2>) -> Result<Self, Self::Error> {
> +                match val.get() {
> +                    2 => Ok(Self::Impl),
> +                    3 => Ok(Self::Alloc),
> +                    _ => Err(EINVAL),
> +                }
> +            }
> +        }
> +
> +        impl From<AllocPolicySelect> for Bounded<u8, 2> {
> +            fn from(val: AllocPolicySelect) -> Self {
> +                Bounded::try_new(val as u8).unwrap()
> +            }
> +        }
>  
> +        /// Coherency policy for memory attributes. Indicates the shareability of cached accesses.
> +        ///
> +        /// The hardware spec defines different interpretations of these values depending on
> +        /// whether TRANSCFG.MODE is set to IDENTITY or not. IDENTITY mode does not use translation
> +        /// tables (all input addresses map to the same output address); it is deprecated and not used
> +        /// by the driver. This enum assumes that TRANSCFG.MODE is not set to IDENTITY.
> +        #[derive(Copy, Clone, Debug)]
> +        #[repr(u8)]
> +        pub(crate) enum Coherency {
> +            /// Midgard inner domain coherency.
> +            ///
> +            /// Most flexible mode - can map non-coherent, internally coherent, and system/IO
> +            /// coherent memory. Used for non-cacheable memory in MAIR conversion.
> +            MidgardInnerDomain = 0,
> +            /// CPU inner domain coherency.
> +            ///
> +            /// Can map non-coherent and system/IO coherent memory. Used for write-back
> +            /// cacheable memory in MAIR conversion to maintain CPU-GPU cache coherency.
> +            CpuInnerDomain = 1,
> +            /// CPU inner domain with shader coherency.
> +            ///
> +            /// Can map internally coherent and system/IO coherent memory. Used for
> +            /// GPU-internal shared buffers requiring shader coherency.
> +            CpuInnerDomainShaderCoh = 2,
> +        }
> +
> +        impl TryFrom<Bounded<u8, 2>> for Coherency {
> +            type Error = Error;
> +
> +            fn try_from(val: Bounded<u8, 2>) -> Result<Self, Self::Error> {
> +                match val.get() {
> +                    0 => Ok(Self::MidgardInnerDomain),
> +                    1 => Ok(Self::CpuInnerDomain),
> +                    2 => Ok(Self::CpuInnerDomainShaderCoh),
> +                    _ => Err(EINVAL),
> +                }
> +            }
> +        }
> +
> +        impl From<Coherency> for Bounded<u8, 2> {
> +            fn from(val: Coherency) -> Self {
> +                Bounded::try_new(val as u8).unwrap()
> +            }
> +        }
> +
> +        #[derive(Copy, Clone, Debug)]
> +        #[repr(u8)]
> +        pub(crate) enum MemoryType {
> +            /// Normal memory (shared).
> +            Shared = 0,
> +            /// Normal memory, inner/outer non-cacheable.
> +            NonCacheable = 1,
> +            /// Normal memory, inner/outer write-back cacheable.
> +            WriteBack = 2,
> +            /// Triggers MEMORY_ATTRIBUTE_FAULT.
> +            Fault = 3,
> +        }
> +
> +        impl From<Bounded<u8, 2>> for MemoryType {
> +            fn from(val: Bounded<u8, 2>) -> Self {
> +                match val.get() {
> +                    0 => Self::Shared,
> +                    1 => Self::NonCacheable,
> +                    2 => Self::WriteBack,
> +                    3 => Self::Fault,
> +                    _ => unreachable!(),
> +                }
> +            }
> +        }
> +
> +        impl From<MemoryType> for Bounded<u8, 2> {
> +            fn from(val: MemoryType) -> Self {
> +                Bounded::try_new(val as u8).unwrap()
> +            }
> +        }
> +
> +        register! {
> +            /// Stage 1 memory attributes (8-bit bitfield).
> +            ///
> +            /// This is not an actual register, but a bitfield definition used by the MEMATTR
> +            /// register. Each of the 8 bytes in MEMATTR follows this layout.
> +            MMU_MEMATTR_STAGE1(u8) @ 0x0 {
> +                /// Inner cache write allocation policy.
> +                0:0     alloc_w => bool;
> +                /// Inner cache read allocation policy.
> +                1:1     alloc_r => bool;
> +                /// Inner allocation policy select.
> +                3:2     alloc_sel ?=> AllocPolicySelect;
> +                /// Coherency policy.
> +                5:4     coherency ?=> Coherency;
> +                /// Memory type.
> +                7:6     memory_type => MemoryType;
> +            }
> +        }
> +
> +        impl TryFrom<Bounded<u64, 8>> for MMU_MEMATTR_STAGE1 {
> +            type Error = Error;
> +
> +            fn try_from(val: Bounded<u64, 8>) -> Result<Self, Self::Error> {
> +                Ok(Self::from_raw(val.get() as u8))
> +            }
> +        }
> +
> +        impl From<MMU_MEMATTR_STAGE1> for Bounded<u64, 8> {
> +            fn from(val: MMU_MEMATTR_STAGE1) -> Self {
> +                Bounded::try_new(u64::from(val.into_raw())).unwrap()
> +            }
> +        }
> +
> +        register! {
>              /// Memory attributes.
>              ///
>              /// Each address space can configure up to 8 different memory attribute profiles.
>              /// Each attribute profile follows the MMU_MEMATTR_STAGE1 layout.
> -            pub(crate) MEMATTR(u64)[MAX_AS, stride = STRIDE] @ 0x2408 {}
> +            pub(crate) MEMATTR(u64)[MAX_AS, stride = STRIDE] @ 0x2408 {
> +                7:0     attribute0 ?=> MMU_MEMATTR_STAGE1;
> +                15:8    attribute1 ?=> MMU_MEMATTR_STAGE1;
> +                23:16   attribute2 ?=> MMU_MEMATTR_STAGE1;
> +                31:24   attribute3 ?=> MMU_MEMATTR_STAGE1;
> +                39:32   attribute4 ?=> MMU_MEMATTR_STAGE1;
> +                47:40   attribute5 ?=> MMU_MEMATTR_STAGE1;
> +                55:48   attribute6 ?=> MMU_MEMATTR_STAGE1;
> +                63:56   attribute7 ?=> MMU_MEMATTR_STAGE1;
> +            }
>  
>              /// Lock region address for each address space.
>              pub(crate) LOCKADDR(u64)[MAX_AS, stride = STRIDE] @ 0x2410 {
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 09/12] drm/tyr: Add fields for COMMAND register
  2026-03-24  0:18 ` [PATCH v3 09/12] drm/tyr: Add fields for COMMAND register Deborah Brouwer
@ 2026-03-24 10:09   ` Boris Brezillon
  0 siblings, 0 replies; 30+ messages in thread
From: Boris Brezillon @ 2026-03-24 10:09 UTC (permalink / raw)
  To: Deborah Brouwer
  Cc: dri-devel, rust-for-linux, Boqun Feng, Danilo Krummrich,
	Alice Ryhl, Daniel Almeida, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Miguel Ojeda,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, Steven Price, Dirk Behme, Alexandre Courbot

On Mon, 23 Mar 2026 17:18:11 -0700
Deborah Brouwer <deborah.brouwer@collabora.com> wrote:

> The MMU COMMAND register accepts specific commands. Enumerate those
> commands and use the register! macro to ensure that only those commands
> can be written to the MMU COMMAND register.
> 
> Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>

Though I'm wondering why we do that in multiple steps. I'd rather have
a single commit defining everything MMU related (basically patches 5 and
7-11 merged into a single commit).

> ---
>  drivers/gpu/drm/tyr/regs.rs | 47 ++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 46 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/tyr/regs.rs b/drivers/gpu/drm/tyr/regs.rs
> index 9bf2723ab6412034be9a77930532cc89d0adb128..6fbd6268724eb6b2ea8d76c5d991353dcbe87068 100644
> --- a/drivers/gpu/drm/tyr/regs.rs
> +++ b/drivers/gpu/drm/tyr/regs.rs
> @@ -1048,8 +1048,53 @@ fn from(val: MMU_MEMATTR_STAGE1) -> Self {
>                  63:12   base;
>              }
>  

nit: do we need an extra blank line here?

> +        }
> +
> +        /// Helpers for MMU COMMAND register.
> +        #[derive(Copy, Clone, Debug)]
> +        #[repr(u8)]
> +        pub(crate) enum MmuCommand {
> +            /// No operation, nothing happens.
> +            Nop = 0,
> +            /// Propagate settings to the MMU.
> +            Update = 1,
> +            /// Lock an address region.
> +            Lock = 2,
> +            /// Unlock an address region.
> +            Unlock = 3,
> +            /// Clean and invalidate the L2 cache, then unlock.
> +            FlushPt = 4,
> +            /// Clean and invalidate all caches, then unlock.
> +            FlushMem = 5,
> +        }
> +
> +        impl TryFrom<Bounded<u32, 8>> for MmuCommand {
> +            type Error = Error;
> +
> +            fn try_from(val: Bounded<u32, 8>) -> Result<Self, Self::Error> {
> +                match val.get() {
> +                    0 => Ok(MmuCommand::Nop),
> +                    1 => Ok(MmuCommand::Update),
> +                    2 => Ok(MmuCommand::Lock),
> +                    3 => Ok(MmuCommand::Unlock),
> +                    4 => Ok(MmuCommand::FlushPt),
> +                    5 => Ok(MmuCommand::FlushMem),
> +                    _ => Err(EINVAL),
> +                }
> +            }
> +        }
> +
> +        impl From<MmuCommand> for Bounded<u32, 8> {
> +            fn from(cmd: MmuCommand) -> Self {
> +                (cmd as u8).into()
> +            }
> +        }
> +
> +        register! {
>              /// MMU command register for each address space. Write only.
> -            pub(crate) COMMAND(u32)[MAX_AS, stride = STRIDE] @ 0x2418 {}
> +            pub(crate) COMMAND(u32)[MAX_AS, stride = STRIDE] @ 0x2418 {
> +                7:0     command ?=> MmuCommand;
> +            }
>  
>              /// Fault status register for each address space. Read only.
>              pub(crate) FAULTSTATUS(u32)[MAX_AS, stride = STRIDE] @ 0x241c {}
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 12/12] drm/tyr: Add DOORBELL_BLOCK registers
  2026-03-24  0:18 ` [PATCH v3 12/12] drm/tyr: Add DOORBELL_BLOCK registers Deborah Brouwer
@ 2026-03-24 10:10   ` Boris Brezillon
  0 siblings, 0 replies; 30+ messages in thread
From: Boris Brezillon @ 2026-03-24 10:10 UTC (permalink / raw)
  To: Deborah Brouwer
  Cc: dri-devel, rust-for-linux, Boqun Feng, Danilo Krummrich,
	Alice Ryhl, Daniel Almeida, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Miguel Ojeda,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, Steven Price, Dirk Behme, Alexandre Courbot

On Mon, 23 Mar 2026 17:18:14 -0700
Deborah Brouwer <deborah.brouwer@collabora.com> wrote:

> DOORBELL_BLOCK_n[0-63] is an array of GPU control register pages.
> Each block is memory-mappable and contains a single DOORBELL register
> used to trigger actions in the GPU.
> 
> Add definitions for the DOORBELL_BLOCK registers using the register! macro
> so they can be used by future Tyr interfaces.
> 
> Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>

> ---
>  drivers/gpu/drm/tyr/regs.rs | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/drivers/gpu/drm/tyr/regs.rs b/drivers/gpu/drm/tyr/regs.rs
> index 7e895b6e7deccc049a0ee3963d511c4b579e5ec7..9c1da1f039ccf9fc118def974d48dd40c17f4305 100644
> --- a/drivers/gpu/drm/tyr/regs.rs
> +++ b/drivers/gpu/drm/tyr/regs.rs
> @@ -1474,3 +1474,25 @@ fn from(sh: PtwShareability) -> Self {
>          }
>      }
>  }
> +
> +/// This module corresponds to the DOORBELL_BLOCK_n[0-63] register pages.
> +pub(crate) mod doorbell_block {
> +    use kernel::register;
> +
> +    /// Number of doorbells available.
> +    pub(crate) const NUM_DOORBELLS: usize = 64;
> +
> +    /// Doorbell block stride (64KiB).
> +    ///
> +    /// Each block occupies a full page, allowing it to be mapped
> +    /// separately into a virtual address space.
> +    const STRIDE: usize = 0x10000;
> +
> +    register! {
> +        /// Doorbell request register. Write-only.
> +        pub(crate) DOORBELL(u32)[NUM_DOORBELLS, stride = STRIDE] @ 0x80000 {
> +            /// Doorbell set. Writing 1 triggers the doorbell.
> +            0:0    ring => bool;
> +        }
> +    }
> +}
> 


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 00/12] drm/tyr: Use register! macro
  2026-03-24  0:18 [PATCH v3 00/12] drm/tyr: Use register! macro Deborah Brouwer
                   ` (11 preceding siblings ...)
  2026-03-24  0:18 ` [PATCH v3 12/12] drm/tyr: Add DOORBELL_BLOCK registers Deborah Brouwer
@ 2026-03-24 10:58 ` Alice Ryhl
  2026-03-24 12:35   ` Boris Brezillon
  12 siblings, 1 reply; 30+ messages in thread
From: Alice Ryhl @ 2026-03-24 10:58 UTC (permalink / raw)
  To: Deborah Brouwer
  Cc: dri-devel, rust-for-linux, Boqun Feng, Danilo Krummrich,
	Daniel Almeida, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Miguel Ojeda,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, Steven Price, Boris Brezillon, Dirk Behme,
	Alexandre Courbot

On Tue, Mar 24, 2026 at 1:18 AM Deborah Brouwer
<deborah.brouwer@collabora.com> wrote:
>
> This series changes the Tyr driver to use the kernel's register! macro
> for hardware register access, replacing manual bit manipulation and custom
> register structures with a more type-safe and maintainable approach.

Please double check the AI review:
https://sashiko.dev/#/patchset/20260323-b4-tyr-use-register-macro-v3-v3-0-a87daf9e4701%40collabora.com

There are some concerns regarding clock cleanup on patch 3 that seem valid.

Alice

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 01/12] drm/tyr: Use register! macro for GPU_CONTROL
  2026-03-24  0:18 ` [PATCH v3 01/12] drm/tyr: Use register! macro for GPU_CONTROL Deborah Brouwer
  2026-03-24  9:56   ` Boris Brezillon
@ 2026-03-24 11:23   ` Danilo Krummrich
  2026-03-24 12:06     ` Boris Brezillon
  1 sibling, 1 reply; 30+ messages in thread
From: Danilo Krummrich @ 2026-03-24 11:23 UTC (permalink / raw)
  To: Deborah Brouwer
  Cc: dri-devel, rust-for-linux, Boqun Feng, Alice Ryhl, Daniel Almeida,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Miguel Ojeda, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Trevor Gross, Steven Price,
	Boris Brezillon, Dirk Behme, Alexandre Courbot

On Tue Mar 24, 2026 at 1:18 AM CET, Deborah Brouwer wrote:
> +    register! {
> +        /// GPU identification register.
> +        pub(crate) GPU_ID(u32) @ 0x0 {
> +            /// Status of the GPU release.
> +            3:0     ver_status;
> +            /// Minor release version number.
> +            11:4    ver_minor;
> +            /// Major release version number.
> +            15:12   ver_major;
> +            /// Product identifier.
> +            19:16   prod_major;
> +            /// Architecture patch revision.
> +            23:20   arch_rev;
> +            /// Architecture minor revision.
> +            27:24   arch_minor;
> +            /// Architecture major revision.
> +            31:28   arch_major;
> +        }

Are you sure that this is the field order you want to choose for Tyr? nova-core
had this order in the past (we're changing this currently), as it came from
OpenRM headers, but it is pretty unusual for datasheets and TRMs, which is also
why the register!() macro examples use the typical and recommended order, i.e.

	pub(crate) GPU_ID(u32) @ 0x0 {
	    /// Architecture major revision.
	    31:28   arch_major;
	    /// Architecture minor revision.
	    27:24   arch_minor;
	    /// Architecture patch revision.
	    23:20   arch_rev;
	    /// Product identifier.
	    19:16   prod_major;
	    /// Major release version number.
	    15:12   ver_major;
	    /// Minor release version number.
	    11:4    ver_minor;
	    /// Status of the GPU release.
	    3:0     ver_status;
	}

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 01/12] drm/tyr: Use register! macro for GPU_CONTROL
  2026-03-24 11:23   ` Danilo Krummrich
@ 2026-03-24 12:06     ` Boris Brezillon
  2026-03-24 17:31       ` Danilo Krummrich
  0 siblings, 1 reply; 30+ messages in thread
From: Boris Brezillon @ 2026-03-24 12:06 UTC (permalink / raw)
  To: Danilo Krummrich
  Cc: Deborah Brouwer, dri-devel, rust-for-linux, Boqun Feng,
	Alice Ryhl, Daniel Almeida, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Miguel Ojeda,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, Steven Price, Dirk Behme, Alexandre Courbot

On Tue, 24 Mar 2026 12:23:54 +0100
"Danilo Krummrich" <dakr@kernel.org> wrote:

> On Tue Mar 24, 2026 at 1:18 AM CET, Deborah Brouwer wrote:
> > +    register! {
> > +        /// GPU identification register.
> > +        pub(crate) GPU_ID(u32) @ 0x0 {
> > +            /// Status of the GPU release.
> > +            3:0     ver_status;
> > +            /// Minor release version number.
> > +            11:4    ver_minor;
> > +            /// Major release version number.
> > +            15:12   ver_major;
> > +            /// Product identifier.
> > +            19:16   prod_major;
> > +            /// Architecture patch revision.
> > +            23:20   arch_rev;
> > +            /// Architecture minor revision.
> > +            27:24   arch_minor;
> > +            /// Architecture major revision.
> > +            31:28   arch_major;
> > +        }  
> 
> Are you sure that this is the field order you want to choose for Tyr? nova-core
> had this order in the past (we're changing this currently), as it came from
> OpenRM headers, but it is pretty unusual for datasheets and TRMs, which is also
> why the register!() macro examples use the typical and recommended order, i.e.
> 
> 	pub(crate) GPU_ID(u32) @ 0x0 {
> 	    /// Architecture major revision.
> 	    31:28   arch_major;
> 	    /// Architecture minor revision.
> 	    27:24   arch_minor;
> 	    /// Architecture patch revision.
> 	    23:20   arch_rev;
> 	    /// Product identifier.
> 	    19:16   prod_major;
> 	    /// Major release version number.
> 	    15:12   ver_major;
> 	    /// Minor release version number.
> 	    11:4    ver_minor;
> 	    /// Status of the GPU release.
> 	    3:0     ver_status;
> 	}

It's defined in ascending bit order in the datasheets we have, so if
we're ever going to auto-generate those from the xml, we'd likely have
the same definitions Deborah came up with, unless the script re-orders
things in descending bit order.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 00/12] drm/tyr: Use register! macro
  2026-03-24 10:58 ` [PATCH v3 00/12] drm/tyr: Use register! macro Alice Ryhl
@ 2026-03-24 12:35   ` Boris Brezillon
  0 siblings, 0 replies; 30+ messages in thread
From: Boris Brezillon @ 2026-03-24 12:35 UTC (permalink / raw)
  To: Alice Ryhl
  Cc: Deborah Brouwer, dri-devel, rust-for-linux, Boqun Feng,
	Danilo Krummrich, Daniel Almeida, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Miguel Ojeda, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Trevor Gross, Steven Price, Dirk Behme,
	Alexandre Courbot

On Tue, 24 Mar 2026 11:58:36 +0100
Alice Ryhl <aliceryhl@google.com> wrote:

> On Tue, Mar 24, 2026 at 1:18 AM Deborah Brouwer
> <deborah.brouwer@collabora.com> wrote:
> >
> > This series changes the Tyr driver to use the kernel's register! macro
> > for hardware register access, replacing manual bit manipulation and custom
> > register structures with a more type-safe and maintainable approach.  
> 
> Please double check the AI review:
> https://sashiko.dev/#/patchset/20260323-b4-tyr-use-register-macro-v3-v3-0-a87daf9e4701%40collabora.com
> 
> There are some concerns regarding clock cleanup on patch 3 that seem valid.

I think all comments are valid except

> The commit message explicitly notes that the previous format matches
> the ID printed by the panthor driver. Is there a strong technical
> reason to break this log consistency between related DRM drivers just
> to avoid a single bit shift operation?

I don't think there was a good reason to hide the lower half of the raw
ID in Panthor. It's true that all the fields in the lower 16-bits are
extracted and printed separately, but it's just super confusing to have
only the higher 16 bits exposed (I've been tricked multiple times when
looking at some logs, and had to go look back at the source code to
remember what this raw id was exactly).

TLDR; that's one case where I think diverging from Panthor is a good
thing. I don't mind if the decision is to not expose the raw ID at
all and have all the fields extracted with something like

	mali-<name> (arch: <major>.<minor> product: <product> version: <major>.<minor>.<status>)

or if we decide to keep the raw ID around.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 01/12] drm/tyr: Use register! macro for GPU_CONTROL
  2026-03-24 12:06     ` Boris Brezillon
@ 2026-03-24 17:31       ` Danilo Krummrich
  2026-03-24 18:15         ` Boris Brezillon
  0 siblings, 1 reply; 30+ messages in thread
From: Danilo Krummrich @ 2026-03-24 17:31 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: Deborah Brouwer, dri-devel, rust-for-linux, Boqun Feng,
	Alice Ryhl, Daniel Almeida, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Miguel Ojeda,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, Steven Price, Dirk Behme, Alexandre Courbot

On Tue Mar 24, 2026 at 1:06 PM CET, Boris Brezillon wrote:
> It's defined in ascending bit order in the datasheets we have, so if
> we're ever going to auto-generate those from the xml, we'd likely have
> the same definitions Deborah came up with, unless the script re-orders
> things in descending bit order.

Huh, that is very uncommon; is it actually

	15:0
	31:16

or is it

	0:15
	16:31

in your datasheets?

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 01/12] drm/tyr: Use register! macro for GPU_CONTROL
  2026-03-24 17:31       ` Danilo Krummrich
@ 2026-03-24 18:15         ` Boris Brezillon
  2026-03-24 19:03           ` Danilo Krummrich
  0 siblings, 1 reply; 30+ messages in thread
From: Boris Brezillon @ 2026-03-24 18:15 UTC (permalink / raw)
  To: Danilo Krummrich
  Cc: Deborah Brouwer, dri-devel, rust-for-linux, Boqun Feng,
	Alice Ryhl, Daniel Almeida, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Miguel Ojeda,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, Steven Price, Dirk Behme, Alexandre Courbot

On Tue, 24 Mar 2026 18:31:42 +0100
"Danilo Krummrich" <dakr@kernel.org> wrote:

> On Tue Mar 24, 2026 at 1:06 PM CET, Boris Brezillon wrote:
> > It's defined in ascending bit order in the datasheets we have, so if
> > we're ever going to auto-generate those from the xml, we'd likely have
> > the same definitions Deborah came up with, unless the script re-orders
> > things in descending bit order.  
> 
> Huh, that is very uncommon; is it actually
> 
> 	15:0
> 	31:16

This ^.

> 
> or is it
> 
> 	0:15
> 	16:31
> 
> in your datasheets?


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 01/12] drm/tyr: Use register! macro for GPU_CONTROL
  2026-03-24 18:15         ` Boris Brezillon
@ 2026-03-24 19:03           ` Danilo Krummrich
  0 siblings, 0 replies; 30+ messages in thread
From: Danilo Krummrich @ 2026-03-24 19:03 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: Deborah Brouwer, dri-devel, rust-for-linux, Boqun Feng,
	Alice Ryhl, Daniel Almeida, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Miguel Ojeda,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, Steven Price, Dirk Behme, Alexandre Courbot

On Tue Mar 24, 2026 at 7:15 PM CET, Boris Brezillon wrote:
> On Tue, 24 Mar 2026 18:31:42 +0100
> "Danilo Krummrich" <dakr@kernel.org> wrote:
>> 	15:0
>> 	31:16
>
> This ^.

Odd, never seen this in a datasheet so far. Anyways, makes sense for Tyr then.

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2026-03-24 19:03 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-24  0:18 [PATCH v3 00/12] drm/tyr: Use register! macro Deborah Brouwer
2026-03-24  0:18 ` [PATCH v3 01/12] drm/tyr: Use register! macro for GPU_CONTROL Deborah Brouwer
2026-03-24  9:56   ` Boris Brezillon
2026-03-24 11:23   ` Danilo Krummrich
2026-03-24 12:06     ` Boris Brezillon
2026-03-24 17:31       ` Danilo Krummrich
2026-03-24 18:15         ` Boris Brezillon
2026-03-24 19:03           ` Danilo Krummrich
2026-03-24  0:18 ` [PATCH v3 02/12] drm/tyr: Print GPU_ID without filtering Deborah Brouwer
2026-03-24  9:54   ` Boris Brezillon
2026-03-24  0:18 ` [PATCH v3 03/12] drm/tyr: Set interconnect coherency during probe Deborah Brouwer
2026-03-24  9:55   ` Boris Brezillon
2026-03-24  0:18 ` [PATCH v3 04/12] drm/tyr: Use register! macro for JOB_CONTROL Deborah Brouwer
2026-03-24 10:00   ` Boris Brezillon
2026-03-24  0:18 ` [PATCH v3 05/12] drm/tyr: Use register! macro for MMU_CONTROL Deborah Brouwer
2026-03-24 10:01   ` Boris Brezillon
2026-03-24  0:18 ` [PATCH v3 06/12] drm/tyr: Remove custom register struct Deborah Brouwer
2026-03-24 10:02   ` Boris Brezillon
2026-03-24  0:18 ` [PATCH v3 07/12] drm/tyr: Add MMU address space registers Deborah Brouwer
2026-03-24 10:03   ` Boris Brezillon
2026-03-24  0:18 ` [PATCH v3 08/12] drm/tyr: Add fields for MEMATTR register Deborah Brouwer
2026-03-24 10:05   ` Boris Brezillon
2026-03-24  0:18 ` [PATCH v3 09/12] drm/tyr: Add fields for COMMAND register Deborah Brouwer
2026-03-24 10:09   ` Boris Brezillon
2026-03-24  0:18 ` [PATCH v3 10/12] drm/tyr: Add fields for FAULTSTATUS register Deborah Brouwer
2026-03-24  0:18 ` [PATCH v3 11/12] drm/tyr: Add fields for TRANSCFG register Deborah Brouwer
2026-03-24  0:18 ` [PATCH v3 12/12] drm/tyr: Add DOORBELL_BLOCK registers Deborah Brouwer
2026-03-24 10:10   ` Boris Brezillon
2026-03-24 10:58 ` [PATCH v3 00/12] drm/tyr: Use register! macro Alice Ryhl
2026-03-24 12:35   ` Boris Brezillon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox