[PATCH 4/9] drm/tyr: report gpu faults
From: Daniel Almeida
Date: Fri Nov 27 2026 - 21:16:43 EST
A gpu fault sets GPU_FAULT in the gpu IRQ and records the fault in
GPU_FAULTSTATUS and, when known, its physical address in
GPU_FAULTADDRESS. Tyr keeps every gpu IRQ source masked, so gpu faults
go unreported.
Unmask GPU_FAULT and log each fault with its exception type, access
type, source and, when valid, address. Then issue CLEAR_FAULT, since the
fault registers keep a fault until it is cleared, and until then, no
further gpu faults are reported.
Signed-off-by: Daniel Almeida <daniel.almeida@xxxxxxxxxxxxx>
---
drivers/gpu/drm/tyr/driver.rs | 2 +-
drivers/gpu/drm/tyr/gpu/irq.rs | 75 +++++++++++++++++++++++++++++++++++-------
2 files changed, 64 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/tyr/driver.rs b/drivers/gpu/drm/tyr/driver.rs
index 383335e8707d..c88fc5194dc2 100644
--- a/drivers/gpu/drm/tyr/driver.rs
+++ b/drivers/gpu/drm/tyr/driver.rs
@@ -92,7 +92,7 @@ pub(crate) struct TyrDrmRegistrationData<'drm> {
// `TyrIrqRegistration::drop()` writes to the GPU registers, so keep this
// field before the clocks and regulators.
- _gpu_irq: Pin<KBox<TyrIrqRegistration<'drm, GpuIrq>>>,
+ _gpu_irq: Pin<KBox<TyrIrqRegistration<'drm, GpuIrq<'drm>>>>,
#[pin]
clks: Mutex<Clocks>,
diff --git a/drivers/gpu/drm/tyr/gpu/irq.rs b/drivers/gpu/drm/tyr/gpu/irq.rs
index a27ccf5c37a6..3dd1f634c847 100644
--- a/drivers/gpu/drm/tyr/gpu/irq.rs
+++ b/drivers/gpu/drm/tyr/gpu/irq.rs
@@ -5,7 +5,10 @@
//! The GPU IRQ reports GPU-wide events, such as faults, completed resets and power changes.
use kernel::{
- device::Bound,
+ device::{
+ Bound,
+ Device, //
+ },
io::Io,
platform,
prelude::*,
@@ -18,17 +21,29 @@
TyrIrqRegistration,
TyrIrqTrait, //
},
- regs::gpu_control::{
- GPU_IRQ_CLEAR,
- GPU_IRQ_MASK,
- GPU_IRQ_RAWSTAT,
- GPU_IRQ_STATUS, //
+ regs::{
+ gpu_control::{
+ GPU_COMMAND,
+ GPU_FAULTADDRESS_HI,
+ GPU_FAULTADDRESS_LO,
+ GPU_FAULTSTATUS,
+ GPU_IRQ_CLEAR,
+ GPU_IRQ_MASK,
+ GPU_IRQ_RAWSTAT,
+ GPU_IRQ_STATUS, //
+ },
+ join_u64, //
},
reset::HwGate, //
};
/// The GPU IRQ, signalling GPU-wide events.
-pub(crate) struct GpuIrq;
+pub(crate) struct GpuIrq<'a> {
+ /// Device used for logging.
+ dev: &'a Device<Bound>,
+ /// Shared gate that coordinates hardware access with GPU reset.
+ hw: Arc<HwGate<'a>>,
+}
/// Requests a threaded IRQ registration for the GPU IRQ.
///
@@ -39,8 +54,11 @@
pub(crate) unsafe fn gpu_irq_init<'a>(
pdev: &'a platform::Device<Bound>,
hw: Arc<HwGate<'a>>,
-) -> Result<Pin<KBox<TyrIrqRegistration<'a, GpuIrq>>>> {
- let gpu_irq = GpuIrq;
+) -> Result<Pin<KBox<TyrIrqRegistration<'a, GpuIrq<'a>>>>> {
+ let gpu_irq = GpuIrq {
+ dev: pdev.as_ref(),
+ hw: hw.clone(),
+ };
// Ensure interrupt sources are disabled until the handler is registered.
gpu_irq.clear_mask(hw.access().iomem());
@@ -48,7 +66,7 @@ pub(crate) unsafe fn gpu_irq_init<'a>(
unsafe { TyrIrqRegistration::request(pdev, c"gpu", c"tyr-gpu", gpu_irq, hw) }
}
-impl TyrIrqTrait for GpuIrq {
+impl TyrIrqTrait for GpuIrq<'_> {
fn read_status(&self, io: &IoMem<'_>) -> u32 {
io.read(GPU_IRQ_STATUS).into_raw()
}
@@ -70,8 +88,41 @@ fn clear_status(&self, io: &IoMem<'_>, status: u32) {
}
fn mask(&self) -> u32 {
- GPU_IRQ_MASK::zeroed().into_raw()
+ // Only GPU faults are handled. DOORBELL_MIRROR must stay masked because
+ // GPU_IRQ_CLEAR cannot clear it.
+ GPU_IRQ_MASK::zeroed().with_gpu_fault(true).into_raw()
}
- fn handle(&self, _status: u32) {}
+ fn handle(&self, _status: u32) {
+ let hw_guard = self.hw.access();
+ let io = hw_guard.iomem();
+ let fault = io.read(GPU_FAULTSTATUS);
+
+ match fault.exception_type() {
+ Ok(exception) => dev_err!(
+ self.dev,
+ "GPU fault: {:?} on {:?} access, source {:#x}\n",
+ exception,
+ fault.access_type(),
+ fault.source_id().get()
+ ),
+ Err(_) => dev_err!(
+ self.dev,
+ "GPU fault: GPU_FAULTSTATUS {:#010x}\n",
+ fault.into_raw()
+ ),
+ }
+
+ if fault.address_valid() {
+ let address = join_u64(
+ io.read(GPU_FAULTADDRESS_LO).into_raw(),
+ io.read(GPU_FAULTADDRESS_HI).into_raw(),
+ );
+ dev_err!(self.dev, "GPU fault at PA {:#018x}\n", address);
+ }
+
+ // The fault registers keep this fault until it is cleared, and until
+ // then, no further GPU faults are reported.
+ io.write_reg(GPU_COMMAND::clear_fault());
+ }
}
--
2.56.0