[PATCH 9/9] drm/tyr: disable an address space that faults

From: Daniel Almeida

Date: Fri Nov 27 2026 - 21:17:04 EST


When an address space reports a page fault, the mmu IRQ handler logs the
fault and masks its page-fault interrupt, but the address space stays
mapped.

Switch the faulting address space to UNMAPPED from the handler, so that
every later access through it fails, like panthor does. Do it in place
rather than evicting the VM: the VM keeps its slot, so the slot is not
handed to another VM while the firmware or a command stream group (when
implemented) may still use it by number. This matches panthor, which
keeps ptdev->mmu->as.slots[as].vm and vm->as.id set when an address
space faults.

Signed-off-by: Daniel Almeida <daniel.almeida@xxxxxxxxxxxxx>
---
drivers/gpu/drm/tyr/driver.rs | 2 +-
drivers/gpu/drm/tyr/mmu/address_space.rs | 2 +-
drivers/gpu/drm/tyr/mmu/irq.rs | 10 ++++++++++
3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/tyr/driver.rs b/drivers/gpu/drm/tyr/driver.rs
index c88fc5194dc2..6b2dcef3e2df 100644
--- a/drivers/gpu/drm/tyr/driver.rs
+++ b/drivers/gpu/drm/tyr/driver.rs
@@ -165,7 +165,7 @@ fn probe<'bound>(

// SAFETY: The registration ends up in `TyrDrmRegistrationData`, which `_reg`
// drops at unbind, and every error path before that drops it.
- let mmu_irq = unsafe { mmu_irq_init(pdev, hw.clone(), &gpu_info) }?;
+ let mmu_irq = unsafe { mmu_irq_init(pdev, hw.clone(), &gpu_info, mmu.clone()) }?;

// SAFETY: The registration ends up in `TyrDrmRegistrationData`, which `_reg`
// drops at unbind, and every error path before that drops it.
diff --git a/drivers/gpu/drm/tyr/mmu/address_space.rs b/drivers/gpu/drm/tyr/mmu/address_space.rs
index fa4c26a6eb12..6af45887ec61 100644
--- a/drivers/gpu/drm/tyr/mmu/address_space.rs
+++ b/drivers/gpu/drm/tyr/mmu/address_space.rs
@@ -309,7 +309,7 @@ fn as_enable(
/// Disables an AS slot, clears its configuration and flushes the L2 and load/store caches.
///
/// Returns an error if the slot is invalid or if register writes/commands fail.
- fn as_disable(&mut self, io: &IoMem<'_>, as_nr: usize) -> Result {
+ pub(super) fn as_disable(&mut self, io: &IoMem<'_>, as_nr: usize) -> Result {
self.validate_as_slot(as_nr)?;

// Release any pending LOCK before disabling the address space.
diff --git a/drivers/gpu/drm/tyr/mmu/irq.rs b/drivers/gpu/drm/tyr/mmu/irq.rs
index 53ff1b2151ee..d2cc76becd1e 100644
--- a/drivers/gpu/drm/tyr/mmu/irq.rs
+++ b/drivers/gpu/drm/tyr/mmu/irq.rs
@@ -32,6 +32,7 @@
TyrIrqRegistration,
TyrIrqTrait, //
},
+ mmu::Mmu,
regs::{
gpu_control::AS_PRESENT,
join_u64,
@@ -56,6 +57,8 @@ pub(crate) struct MmuIrq<'a> {
dev: &'a Device<Bound>,
/// Shared gate that coordinates hardware access with GPU reset.
hw: Arc<HwGate<'a>>,
+ /// MMU, used to disable the address spaces that fault.
+ mmu: Arc<Mmu<'a>>,
/// Interrupt sources to unmask: the page-fault bit of each present address
/// space that has not faulted yet.
mask: Atomic<u32>,
@@ -71,11 +74,13 @@ pub(crate) unsafe fn mmu_irq_init<'a>(
pdev: &'a platform::Device<Bound>,
hw: Arc<HwGate<'a>>,
gpu_info: &GpuInfo,
+ mmu: Arc<Mmu<'a>>,
) -> Result<Pin<KBox<TyrIrqRegistration<'a, MmuIrq<'a>>>>> {
let present = AS_PRESENT::from_raw(gpu_info.as_present).present().get();
let mmu_irq = MmuIrq {
dev: pdev.as_ref(),
hw: hw.clone(),
+ mmu,
mask: Atomic::new(IRQ_MASK::zeroed().try_with_page_fault(present)?.into_raw()),
};
// Ensure interrupt sources are disabled until the handler is registered.
@@ -146,6 +151,8 @@ fn mask(&self) -> u32 {

fn handle(&self, status: u32) {
let faults = IRQ_RAWSTAT::from_raw(status).page_fault();
+
+ let mut as_manager = self.mmu.as_manager.lock();
let hw_guard = self.hw.access();
let io = hw_guard.iomem();

@@ -156,6 +163,9 @@ fn handle(&self, status: u32) {
pending &= pending - 1;

let _ = self.report_fault(io, as_nr);
+ if let Err(e) = as_manager.as_disable(io, as_nr) {
+ dev_err!(self.dev, "Failed to disable AS{}: {:?}\n", as_nr, e);
+ }
}

// Nothing resolves these faults yet, and an address space that faulted

--
2.56.0