mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Laura Nao <laura.nao@collabora.com>
To: "Danilo Krummrich" <dakr@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Daniel Almeida" <daniel.almeida@collabora.com>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Tamir Duberstein" <tamird@kernel.org>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	"Onur Özkan" <work@onurozkan.dev>,
	"FUJITA Tomonori" <fujita.tomonori@gmail.com>,
	"Frederic Weisbecker" <frederic@kernel.org>,
	"Lyude Paul" <lyude@redhat.com>,
	"Thomas Gleixner" <tglx@kernel.org>,
	"Anna-Maria Behnsen" <anna-maria@linutronix.de>,
	"John Stultz" <jstultz@google.com>,
	"Stephen Boyd" <sboyd@kernel.org>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	 driver-core@lists.linux.dev, rust-for-linux@vger.kernel.org,
	 kernel@collabora.com, Laura Nao <laura.nao@collabora.com>,
	 Deborah Brouwer <deborah.brouwer@collabora.com>
Subject: [PATCH 9/9] drm/tyr: wait for global interface readiness
Date: Tue, 15 Sep 2026 12:57:42 +0200	[thread overview]
Message-ID: <20260915-tyr-interfaces-v1-9-5d28f1f75aca@collabora.com> (raw)
In-Reply-To: <20260915-tyr-interfaces-v1-0-5d28f1f75aca@collabora.com>

Add a wait helper for global interface readiness using the Job IRQ.
JobIrqEvents signals readiness and wakes waiters when the firmware sets
the GLB bit. After booting the firmware, probe waits until the firmware
reports that the global interface is ready to accept requests.
Register the Job IRQ before booting the firmware so that the initial GLB
event is not missed. Store the JobIrqMaskGuard returned by
job_irq_init() ahead of the ThreadedRegistration in
TyrDrmRegistrationData so the Job IRQ is masked before it is freed.

Co-developed-by: Daniel Almeida <daniel.almeida@collabora.com>
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>
Signed-off-by: Laura Nao <laura.nao@collabora.com>
---
 drivers/gpu/drm/tyr/driver.rs | 30 +++++++++++++++++++++++++++++-
 drivers/gpu/drm/tyr/fw.rs     | 23 ++++++++++++++---------
 drivers/gpu/drm/tyr/fw/irq.rs |  1 -
 3 files changed, 43 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/tyr/driver.rs b/drivers/gpu/drm/tyr/driver.rs
index 2dcf33ec93ea..138afeecfb3d 100644
--- a/drivers/gpu/drm/tyr/driver.rs
+++ b/drivers/gpu/drm/tyr/driver.rs
@@ -21,6 +21,7 @@
         poll,
         Io, //
     },
+    irq::ThreadedRegistration,
     new_mutex,
     of,
     platform,
@@ -37,10 +38,18 @@
 
 use crate::{
     file::TyrDrmFileData,
-    fw::Firmware,
+    fw::{
+        irq::{
+            job_irq_init,
+            JobIrq,
+            JobIrqMaskGuard, //
+        },
+        Firmware, //
+    },
     gem::Bo,
     gpu,
     gpu::GpuInfo,
+    irq::TyrIrq,
     mmu::Mmu,
     regs::gpu_control::*, //
 };
@@ -81,6 +90,12 @@ pub(crate) struct TyrDrmRegistrationData<'drm> {
     /// GPU MMIO register mapping.
     pub(crate) iomem: Arc<IoMem<'drm>>,
 
+    /// Masks the Job IRQ on drop. Must be declared before `job_irq` so it is
+    /// dropped first (see [`JobIrqMaskGuard`]).
+    _job_irq_mask: JobIrqMaskGuard<'drm>,
+
+    job_irq: Pin<KBox<ThreadedRegistration<'drm, TyrIrq<JobIrq<'drm>>>>>,
+
     /// GPU information read from hardware during probe.
     pub(crate) gpu_info: GpuInfo,
 }
@@ -158,7 +173,18 @@ fn probe<'bound>(
             &gpu_info,
         )?;
 
+        let (_job_irq_mask, job_irq_registration) =
+            // SAFETY: The resulting registration is stored in
+            // `TyrDrmRegistrationData`, which is dropped normally when
+            // the driver is unbound. It is not leaked or forgotten.
+            unsafe { job_irq_init(pdev, iomem.clone(), firmware.events.clone()) }?;
+
+        let job_irq = KBox::pin_init(job_irq_registration, GFP_KERNEL)?;
+
         firmware.boot()?;
+        firmware.wait_ready(1000).inspect_err(|e| {
+            dev_err!(pdev, "Error waiting for firmware to be ready: {:?}\n", e);
+        })?;
         firmware.enable_global_interface(&gpu_info, &core_clk)?;
 
         let reg_data = pin_init!(TyrDrmRegistrationData {
@@ -174,6 +200,8 @@ fn probe<'bound>(
                     _sram: sram_regulator,
                 }),
                 iomem,
+                _job_irq_mask,
+                job_irq,
                 gpu_info,
         });
 
diff --git a/drivers/gpu/drm/tyr/fw.rs b/drivers/gpu/drm/tyr/fw.rs
index 1499ffdef51f..3a7a11c5723e 100644
--- a/drivers/gpu/drm/tyr/fw.rs
+++ b/drivers/gpu/drm/tyr/fw.rs
@@ -36,7 +36,8 @@
         ArcBorrow,
         Mutex, //
     },
-    time, //
+    time,
+    time::Msecs, //
 };
 
 use crate::{
@@ -68,10 +69,7 @@
             MCU_CONTROL,
             MCU_STATUS, //
         }, //
-        job_control::{
-            JOB_IRQ_CLEAR,
-            JOB_IRQ_RAWSTAT, //
-        }, //
+        job_control::JOB_IRQ_CLEAR,
     },
     vm::Vm, //
 };
@@ -179,6 +177,9 @@ pub(crate) struct Firmware<'drm> {
     /// The global FW interface.
     #[pin]
     global_iface: Mutex<FwIfaces<'drm>>,
+
+    /// Firmware events signalled via the Job IRQ.
+    pub(crate) events: Arc<irq::JobIrqEvents>,
 }
 
 #[pinned_drop]
@@ -291,6 +292,7 @@ pub(crate) fn new(
                     vm: vm.clone(),
                     sections,
                     global_iface <- new_mutex!(FwIfaces::new()?),
+                    events: irq::JobIrqEvents::new()?,
                 }),
                 GFP_KERNEL,
             )?)
@@ -327,10 +329,8 @@ pub(crate) fn boot(&self) -> Result {
         io.write_reg(MCU_CONTROL::zeroed().with_req(McuControlMode::Auto));
 
         if let Err(e) = poll::read_poll_timeout(
-            || Ok((io.read(MCU_STATUS), io.read(JOB_IRQ_RAWSTAT))),
-            |(mcu_status, irq_rawstat)| {
-                mcu_status.value() == McuStatus::Enabled && irq_rawstat.glb()
-            },
+            || Ok(io.read(MCU_STATUS)),
+            |status| status.value() == McuStatus::Enabled,
             time::Delta::from_millis(1),
             time::Delta::from_millis(100),
         ) {
@@ -393,4 +393,9 @@ pub(crate) fn enable_global_interface(&self, gpu_info: &GpuInfo, core_clk: &Clk)
             }
         }
     }
+
+    /// Waits until the firmware signals readiness via the GLB IRQ bit.
+    pub(crate) fn wait_ready(&self, timeout_ms: Msecs) -> Result {
+        self.events.wait_ready(timeout_ms)
+    }
 }
diff --git a/drivers/gpu/drm/tyr/fw/irq.rs b/drivers/gpu/drm/tyr/fw/irq.rs
index 7dd894de18cb..95380cb428ba 100644
--- a/drivers/gpu/drm/tyr/fw/irq.rs
+++ b/drivers/gpu/drm/tyr/fw/irq.rs
@@ -3,7 +3,6 @@
 //! IRQ handling for the Job IRQ.
 //!
 //! The Job IRQ signals events from the MCU, including global interface acknowledgements.
-#![allow(dead_code)]
 
 use kernel::{
     device::Bound, //

-- 
2.39.5


      parent reply	other threads:[~2026-09-15 10:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-15 10:57 [PATCH 0/9] drm/tyr: add CSF firmware interface support Laura Nao
2026-09-15 10:57 ` [PATCH 1/9] drm/tyr: validate presence of CSF shared section Laura Nao
2026-09-15 10:57 ` [PATCH 2/9] rust: io: drop the CONFIG_64BIT restriction on system memory u64 access Laura Nao
2026-09-15 11:18   ` Gary Guo
2026-09-15 10:57 ` [PATCH 3/9] drm/tyr: add MappedBo, a kernel BO with an always-valid CPU mapping Laura Nao
2026-09-15 10:57 ` [PATCH 4/9] drm/tyr: add McuVa and claim-checked MappedBo views Laura Nao
2026-09-15 10:57 ` [PATCH 5/9] drm/tyr: drop unused KernelBo::bo() function Laura Nao
2026-09-15 10:57 ` [PATCH 6/9] drm/tyr: add CSF firmware interface support Laura Nao
2026-09-15 10:57 ` [PATCH 7/9] rust: time: add arch_timer_get_rate wrapper Laura Nao
2026-09-15 10:57 ` [PATCH 8/9] drm/tyr: program CSF global interface Laura Nao
2026-09-15 10:57 ` Laura Nao [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260915-tyr-interfaces-v1-9-5d28f1f75aca@collabora.com \
    --to=laura.nao@collabora.com \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=anna-maria@linutronix.de \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=deborah.brouwer@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=driver-core@lists.linux.dev \
    --cc=frederic@kernel.org \
    --cc=fujita.tomonori@gmail.com \
    --cc=gary@garyguo.net \
    --cc=jstultz@google.com \
    --cc=kernel@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=lyude@redhat.com \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=sboyd@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tamird@kernel.org \
    --cc=tglx@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=work@onurozkan.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®