[PATCH 3/9] drm/tyr: request the gpu IRQ
From: Daniel Almeida
Date: Fri Nov 27 2026 - 21:16:38 EST
The gpu IRQ reports gpu-wide events, such as gpu faults, completed
resets and power changes. Tyr does not request it, so nothing can report
a gpu fault.
Add GpuIrq, a TyrIrqTrait implementation for the GPU_CONTROL IRQ
registers, and request the "gpu" interrupt in probe before the firmware
is loaded. Keep the registration in TyrDrmRegistrationData ahead of the
clocks and regulators, since dropping it writes the IRQ mask through
MMIO, which needs them enabled.
All interrupt sources stay masked for now. The next patch unmasks and
reports gpu faults.
Signed-off-by: Daniel Almeida <daniel.almeida@xxxxxxxxxxxxx>
---
drivers/gpu/drm/tyr/driver.rs | 17 +++++++++-
drivers/gpu/drm/tyr/gpu.rs | 2 ++
drivers/gpu/drm/tyr/gpu/irq.rs | 77 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 95 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/tyr/driver.rs b/drivers/gpu/drm/tyr/driver.rs
index 1fb91d0757f7..383335e8707d 100644
--- a/drivers/gpu/drm/tyr/driver.rs
+++ b/drivers/gpu/drm/tyr/driver.rs
@@ -33,7 +33,13 @@
file::TyrDrmFileData,
fw::Firmware,
gem::Bo,
- gpu::GpuInfo,
+ gpu::{
+ irq::{
+ gpu_irq_init,
+ GpuIrq, //
+ },
+ GpuInfo, //
+ },
irq::TyrIrqRegistration,
mmu::{
irq::{
@@ -84,6 +90,10 @@ pub(crate) struct TyrDrmRegistrationData<'drm> {
// field before the clocks and regulators.
_mmu_irq: Pin<KBox<TyrIrqRegistration<'drm, MmuIrq<'drm>>>>,
+ // `TyrIrqRegistration::drop()` writes to the GPU registers, so keep this
+ // field before the clocks and regulators.
+ _gpu_irq: Pin<KBox<TyrIrqRegistration<'drm, GpuIrq>>>,
+
#[pin]
clks: Mutex<Clocks>,
@@ -157,6 +167,10 @@ fn probe<'bound>(
// drops at unbind, and every error path before that drops it.
let mmu_irq = unsafe { mmu_irq_init(pdev, hw.clone(), &gpu_info) }?;
+ // SAFETY: The registration ends up in `TyrDrmRegistrationData`, which `_reg`
+ // drops at unbind, and every error path before that drops it.
+ let gpu_irq = unsafe { gpu_irq_init(pdev, hw.clone()) }?;
+
let firmware = Firmware::new(
pdev.as_ref(),
hw.clone(),
@@ -180,6 +194,7 @@ fn probe<'bound>(
reset <- reset::ResetHandle::new(pdev, hw.clone()),
fw: firmware,
_mmu_irq: mmu_irq,
+ _gpu_irq: gpu_irq,
clks <- new_mutex!(Clocks {
core: core_clk,
stacks: stacks_clk,
diff --git a/drivers/gpu/drm/tyr/gpu.rs b/drivers/gpu/drm/tyr/gpu.rs
index 820de9d60c19..cc86ea04607d 100644
--- a/drivers/gpu/drm/tyr/gpu.rs
+++ b/drivers/gpu/drm/tyr/gpu.rs
@@ -28,6 +28,8 @@
}, //
};
+pub(crate) mod irq;
+
/// Struct containing information that can be queried by userspace. This is read from
/// the GPU's registers.
#[repr(transparent)]
diff --git a/drivers/gpu/drm/tyr/gpu/irq.rs b/drivers/gpu/drm/tyr/gpu/irq.rs
new file mode 100644
index 000000000000..a27ccf5c37a6
--- /dev/null
+++ b/drivers/gpu/drm/tyr/gpu/irq.rs
@@ -0,0 +1,77 @@
+// SPDX-License-Identifier: GPL-2.0 or MIT
+
+//! IRQ handling for the GPU IRQ.
+//!
+//! The GPU IRQ reports GPU-wide events, such as faults, completed resets and power changes.
+
+use kernel::{
+ device::Bound,
+ io::Io,
+ platform,
+ prelude::*,
+ sync::Arc, //
+};
+
+use crate::{
+ driver::IoMem,
+ irq::{
+ TyrIrqRegistration,
+ TyrIrqTrait, //
+ },
+ regs::gpu_control::{
+ GPU_IRQ_CLEAR,
+ GPU_IRQ_MASK,
+ GPU_IRQ_RAWSTAT,
+ GPU_IRQ_STATUS, //
+ },
+ reset::HwGate, //
+};
+
+/// The GPU IRQ, signalling GPU-wide events.
+pub(crate) struct GpuIrq;
+
+/// Requests a threaded IRQ registration for the GPU IRQ.
+///
+/// # Safety
+///
+/// Callers must not `mem::forget()` the resulting registration or otherwise prevent its
+/// [`Drop`] implementation from running.
+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;
+ // Ensure interrupt sources are disabled until the handler is registered.
+ gpu_irq.clear_mask(hw.access().iomem());
+
+ // SAFETY: The caller guarantees the resulting registration will not be leaked.
+ unsafe { TyrIrqRegistration::request(pdev, c"gpu", c"tyr-gpu", gpu_irq, hw) }
+}
+
+impl TyrIrqTrait for GpuIrq {
+ fn read_status(&self, io: &IoMem<'_>) -> u32 {
+ io.read(GPU_IRQ_STATUS).into_raw()
+ }
+
+ fn clear_mask(&self, io: &IoMem<'_>) {
+ io.write_reg(GPU_IRQ_MASK::zeroed());
+ }
+
+ fn reenable_mask(&self, io: &IoMem<'_>) {
+ io.write_reg(GPU_IRQ_MASK::from_raw(self.mask()));
+ }
+
+ fn read_raw_status(&self, io: &IoMem<'_>) -> u32 {
+ io.read(GPU_IRQ_RAWSTAT).into_raw()
+ }
+
+ fn clear_status(&self, io: &IoMem<'_>, status: u32) {
+ io.write_reg(GPU_IRQ_CLEAR::from_raw(status));
+ }
+
+ fn mask(&self) -> u32 {
+ GPU_IRQ_MASK::zeroed().into_raw()
+ }
+
+ fn handle(&self, _status: u32) {}
+}
--
2.56.0