drm/tyr: add CSF firmware interface support
Subsystems (7)
cover drm/tyr: add CSF firmware interface support
This series follows up to [1], which adds support for firmware loading and MCU booting to the Tyr driver. The changes included here were originally introduced in its v4, then dropped to reduce the scope of the series, and have been adjusted to work with the HRT (Higher-Ranked Lifetime Types) driver architecture and I/O projections support recently introduced.
The series adds support for the Command Stream Frontend (CSF) firmware interfaces, enabling communication between the Tyr driver and the MCU through shared memory.
The firmware binary is first validated to contain the shared section used for this communication. Firmware sections that need CPU access get a persistent CPU mapping alongside their GPU mapping, kept for the lifetime of the driver in the case of the shared section. This is the foundation for resolving firmware-reported MCU virtual addresses into validated views of the shared section: addresses are represented with a dedicated McuVa type nd are resolved into bound-checked and alignment-checked views. Read-only blocks (control, output) use a freely cloneable view, while writable blocks (input) use a view that takes an exclusive claim on its byte range, removing the need for locking around the interface state.
The global (GLB), command stream group (CSG), and command stream (CS) interfaces are implemented on top of this, providing access to the firmware control, input, and output blocks and allowing discovery of the available CSGs and CSs at runtime. The interface is versioned:GLB_VERSION is read once at probe time to select the layout matching the firmware's generation.
The global interface is initialized and programmed during probe and its readiness is notified through the Job IRQ.
A safe wrapper for arch_timer_get_rate() is also added for programming the GLB timers, and the CONFIG_64BIT restriction on system memory u64 accesses is dropped so the register bitfields used by these interfaces work on 32-bit too.
This series is based on drm-rust-next and depends on:
- [PATCH v6 0/2] drm/tyr: add Job IRQ handling [2] and its dependencies
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
---
Daniel Almeida (2):
drm/tyr: add MappedBo, a kernel BO with an always-valid CPU mapping drm/tyr: add McuVa and claim-checked MappedBo views
Deborah Brouwer (2):
drm/tyr: validate presence of CSF shared section
rust: time: add arch_timer_get_rate wrapper
Laura Nao (5):
rust: io: drop the CONFIG_64BIT restriction on system memory u64 access drm/tyr: drop unused KernelBo::bo() function
drm/tyr: add CSF firmware interface support
drm/tyr: program CSF global interface
drm/tyr: wait for global interface readiness
drivers/gpu/drm/tyr/driver.rs | 33 +- drivers/gpu/drm/tyr/fw.rs | 148 ++- drivers/gpu/drm/tyr/fw/interfaces.rs | 1524 +++++++++++++++++++++++++++ drivers/gpu/drm/tyr/fw/interfaces/layout.rs | 152 +++ drivers/gpu/drm/tyr/fw/interfaces/v1.rs | 1230 +++++++++++++++++++++ drivers/gpu/drm/tyr/fw/irq.rs | 1 - drivers/gpu/drm/tyr/fw/parser.rs | 14 + drivers/gpu/drm/tyr/gem.rs | 334 +++++- rust/helpers/time.c | 6 + rust/kernel/io.rs | 4 +- rust/kernel/time.rs | 30 + 11 files changed, 3432 insertions(+), 44 deletions(-)
---
base-commit: d1aec98b17f6ee395097b08ccb03c16d725d4ed1
change-id: 20260901-tyr-interfaces-3dd510152348
Best regards,
Signature · 1 line
Laura Nao <[email protected]>
PATCH 1/9 drm/tyr: validate presence of CSF shared section
From: Deborah Brouwer <[email protected]>
The firmware binary must have a shared section for communicating with the MCU. Check for this section after parsing and fail with -EINVAL if it is missing.
--- drivers/gpu/drm/tyr/fw/parser.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/gpu/drm/tyr/fw/parser.rs +14 -0
@@ -197,6 +197,20 @@ pub(super) fn parse(&mut self) -> Result<KVec<ParsedSection>> {return Err (EINVAL ); } +// Validate that the firmware contains the required shared memory section. +let has_shared_section = parsed_sections + .iter () + .any (|section| section.va.start ==super ::CSF_MCU_SHARED_REGION_START ); + +if !has_shared_section { +dev_err! ( + self.cursor.dev, +"No shared section found at 0x{:08x} in firmware\n" , +super ::CSF_MCU_SHARED_REGION_START + ); +return Err (EINVAL ); + } +Ok (parsed_sections) }
Signature · 1 line
2.39.5
Re: [PATCH 1/9] drm/tyr: validate presence of CSF shared section
Quoted 45 lines · Laura Nao
From: Deborah Brouwer <[email protected]>
The firmware binary must have a shared section for communicating with the MCU. Check for this section after parsing and fail with
-EINVALif it is missing.Signed-off-by Deborah Brouwer <[email protected]>Signed-off-by Laura Nao <[email protected]>---
drivers/gpu/drm/tyr/fw/parser.rs| 14 ++++++++++++++1 file changed, 14 insertions(+)drivers/gpu/drm/tyr/fw/parser.rs +14
-0@@ -197,6 +197,20 @@ pub(super) fn parse(&mut self) -> Result<KVec<ParsedSection>> {return Err (EINVAL ); } +// Validate that the firmware contains the required shared memory section. +let has_shared_section = parsed_sections + .iter () + .any (|section| section.va.start ==super ::CSF_MCU_SHARED_REGION_START ); + +if !has_shared_section { +dev_err! ( + self.cursor.dev, +"No shared section found at 0x{:08x} in firmware\n" , +super ::CSF_MCU_SHARED_REGION_START + ); +return Err (EINVAL ); + } +Ok (parsed_sections) }Signature · 2 lines
-- 2.39.5
PATCH 2/9 rust: io: drop the CONFIG_64BIT restriction on system memory u64 access
In reply to Laura NaoSysMemBackend's IoCapable<u64> impl is currently gated on CONFIG_64BIT, copying the MMIO backend's restriction. MMIO needs that gate because readq() is not available on 32bit. System memory has no such dependency:
a u64 volatile load/store compiles on any architecture, it's just not single-copy atomic on 32bit.
Drop the gate so u64-backed types, such as bitfields, work on 32bit too. Document the non-atomicity at the impl instead of enforcing it at build time.
--- rust/kernel/io.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
rust/kernel/io.rs +3 -1
@@ -1428,7 +1428,9 @@ fn io_write(view: SysMem<'_, $ty>, value: $ty) {impl_sysmem_io_capable! (u8 );impl_sysmem_io_capable! (u16 );impl_sysmem_io_capable! (u32 ); -#[cfg( CONFIG_64BIT )] +// Unlike MMIO, that needs `readq` which is not available on 32-bit, a +// system-memory `u64` access compiles on any target. It is just not +// single-copy atomic on 32-bit. impl_sysmem_io_capable! (u64 );impl IoCopyable for SysMemBackend {
Signature · 1 line
2.39.5
Gary Guo
reviewerRe: [PATCH 2/9] rust: io: drop the CONFIG_64BIT restriction on system memory u64 access
Quoted 6 lines · Laura Nao
SysMemBackend's IoCapable<u64> impl is currently gated on
CONFIG_64BIT, copying the MMIO backend's restriction. MMIO needs that gate becausereadq()is not available on 32bit. System memory has no such dependency:
a u64 volatile load/store compiles on any architecture, it's just not single-copy atomic on 32bit.
Quoted 7 lines
Drop the gate so u64-backed types, such as bitfields, work on 32bit too. Document the non-atomicity at the impl instead of enforcing it at build time.
Co-developed-by Daniel Almeida <[email protected]>Signed-off-by Daniel Almeida <[email protected]>Signed-off-by Laura Nao <[email protected]>
No. If you don't need atomicity, please use copy_read to read the value. It'll compile down to the same volatile read, just without atomicity guarantee.
Best,
Gary
Quoted 19 lines
--- rust/kernel/io.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)rust/kernel/io.rs +3
-1@@ -1428,7 +1428,9 @@ fn io_write(view: SysMem<'_, $ty>, value: $ty) {impl_sysmem_io_capable! (u8 );impl_sysmem_io_capable! (u16 );impl_sysmem_io_capable! (u32 ); -#[cfg( CONFIG_64BIT )] +// Unlike MMIO, that needs `readq` which is not available on 32-bit, a +// system-memory `u64` access compiles on any target. It is just not +// single-copy atomic on 32-bit. impl_sysmem_io_capable! (u64 );impl IoCopyable for SysMemBackend {
Re: [PATCH 2/9] rust: io: drop the CONFIG_64BIT restriction on system memory u64 access
Hi Gary,
Quoted 11 lines · Gary Guo
Quoted 10 lines · Laura Nao
SysMemBackend's IoCapable<u64> impl is currently gated on
CONFIG_64BIT, copying the MMIO backend's restriction. MMIO needs that gate becausereadq()is not available on 32bit. System memory has no such dependency:
a u64 volatile load/store compiles on any architecture, it's just not single-copy atomic on 32bit.Drop the gate so u64-backed types, such as bitfields, work on 32bit too. Document the non-atomicity at the impl instead of enforcing it at build time.
Quoted 7 lines
Quoted 3 lines
Co-developed-by Daniel Almeida <[email protected]>Signed-off-by Daniel Almeida <[email protected]>Signed-off-by Laura Nao <[email protected]>No. If you don't need atomicity, please use
copy_readto read the value. It'll compile down to the same volatile read, just without atomicity guarantee.
Ack, thanks for the feedback. I'll drop this in v2.
Best,
Laura
PATCH 3/9 drm/tyr: add MappedBo, a kernel BO with an always-valid CPU mapping
In reply to Laura NaoFrom: Daniel Almeida <[email protected]>
Firmware sections need CPU access at well-defined points: once at load time to copy the section payload in, and, for the shared section, for the lifetime of the driver to talk to the CSF interface blocks.
Introduce MappedBo, which pairs a KernelBo with one persistent vmap so the GPU mapping and the CPU mapping share a single lifetime, and hold it in Section instead of the bare KernelBo. Section payload initialization now writes through the persistent mapping.
This is the foundation for resolving firmware-reported MCU virtual addresses into validated views of the shared section: the object that owns both mappings is the natural place for those checks to live.
--- drivers/gpu/drm/tyr/fw.rs | 14 ++++++------- drivers/gpu/drm/tyr/gem.rs | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 7 deletions(-)
drivers/gpu/drm/tyr/fw.rs +7 -7
@@ -144,7 +144,7 @@ struct Section<'drm> {// Keep the BO backing this firmware section so that both the // GPU mapping and CPU mapping remain valid until the Section is dropped. #[expect(dead_code)] - mem: gem::KernelBo<'drm>, + mem: Arc<gem::MappedBo<'drm>>, }/// Loaded firmware with sections mapped into MCU VM.
@@ -171,13 +171,13 @@ fn drop(&mut self) { }impl <'drm>Firmware <'drm> { -fn init_section_mem (dev: &Device , mem: &mut KernelBo <'drm>, data: &KVec <u8 >) ->Result { +fn init_section_mem (dev: &Device , mem: &gem::MappedBo <'drm>, data: &KVec <u8 >) ->Result {if data.is_empty () {return Ok (()); } -let vmap = mem.bo ().vmap ::<0 >()?; -let size = mem.bo ().size (); +let vmap = mem.vmap (); +let size = mem.size ();if data.len () > size {dev_err! (dev,"fw section {} bigger than BO {}" , data.len (), size);
@@ -235,13 +235,13 @@ pub(crate) fn new(let va = u64::from (parsed.va.start); -let mut mem =KernelBo ::new ( +let mem = gem::MappedBo ::new (KernelBo ::new ( ddev, vm.clone (), size,KernelBoVaAlloc ::Explicit (va), parsed.vm_map_flags, - )?; + )?)?;let section_start = parsed.data_range.startas usize ;let section_end = parsed.data_range.endas usize ;
@@ -252,7 +252,7 @@ pub(crate) fn new(let bytes = fw_data.get (section_start..section_end).ok_or (EINVAL )?; data.extend_from_slice (bytes,GFP_KERNEL )?; -Self ::init_section_mem (dev, &mut mem, &data)?; +Self ::init_section_mem (dev, &mem, &data)?; sections.push (Section { data, mem },GFP_KERNEL )?; }
drivers/gpu/drm/tyr/gem.rs +49 -0
58 lines not on this page · raw message
Signature · 1 line
2.39.5
Daniel Almeida
maintainerRe: [PATCH 3/9] drm/tyr: add MappedBo, a kernel BO with an always-valid CPU mapping
See my reply to 4/9.
— Daniel
PATCH 4/9 drm/tyr: add McuVa and claim-checked MappedBo views
In reply to Laura NaoFrom: Daniel Almeida <[email protected]>
MappedBo currently hands out its CPU vmap directly, so any code writing into it does its own bounds checking (or none), and there is no way to express a validated window without leaking the raw mapping.
Introduce two types, in preparation for the CSF firmware interface, which will resolve MCU-address register fields into typed windows of a MappedBo:
- McuVa: a newtype over u32 marking that the integer is an address in the MCU's 32-bit address space. This is what register fields will store and what the hardware is handed. MappedBo construction rejects buffers extending past the 32-bit MCU space, guaranteeing that a validated window's address always fits back into a McuVa.
- MappedBoView / MappedBoViewMut: the resolved form. Created by MappedBo::try_view()/try_view_mut(), which validate a (va, len) window in one place: the window must be non-empty, fit within both the GPU VA range and the CPU mapping (so the safety argument stays local to MappedBo), and have a properly aligned CPU address (since the vmap base is already page-aligned per VMap's invariants, this just comes down to checking the offset's alignment). A window's reach may exceed its length when a consumer's type carries alignment tail padding: the padding must be mapped, but it doesn't count toward the VA-range bounds or the write claims. A malformed address is rejected with EINVAL at resolve time.
MappedBoView is the read-side view: it's freely cloneable, since overlapping readers on a block are harmless. MappedBoViewMut is the write-side view: it takes an exclusive claim on its byte range at construction (EBUSY on overlap, released on drop) and is deliberately not Clone, since the value it holds is the write capability. Together with &mut-based writer methods, this is meant to make "at most one writer per window" a property enforced across the whole driver at discovery time, so coarse locking around future firmware interface won't be required.
--- drivers/gpu/drm/tyr/fw.rs | 19 +-- drivers/gpu/drm/tyr/gem.rs | 306 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 308 insertions(+), 17 deletions(-)
drivers/gpu/drm/tyr/fw.rs +12 -7
@@ -171,12 +171,11 @@ fn drop(&mut self) { }impl <'drm>Firmware <'drm> { -fn init_section_mem (dev: &Device , mem: &gem::MappedBo <'drm>, data: &KVec <u8 >) ->Result { +fn init_section_mem (dev: &Device , mem: &Arc <gem::MappedBo <'drm>>, data: &KVec <u8 >) ->Result {if data.is_empty () {return Ok (()); } -let vmap = mem.vmap ();let size = mem.size ();if data.len () > size {
@@ -184,11 +183,17 @@ fn init_section_mem(dev: &Device, mem: &gem::MappedBo<'drm>, data: &KVec<u8>) ->return Err (EINVAL ); } -for (i, &byte)in data.iter ().enumerate () { - vmap.try_write8 (byte, i)?; - } - -Ok (()) +// Claim the payload extent for the duration of the copy. No +// interface views exist yet at this point, and the claim releases +// on drop, so this cannot conflict; it just keeps every write in +// the driver on the exclusive, claim-checked path. +let mut view = mem.try_view_mut ( + mem.va_range ().start.try_into ()?, + data.len ()as u64 , + data.len ()as u64 , + )?; + + view.write_bytes (0 , data) }fn request (ddev: &TyrDrmDevice , gpu_info: &GpuInfo ) ->Result <kernel::firmware::Firmware > {
drivers/gpu/drm/tyr/gem.rs +296 -10
356 lines not on this page · raw message
Signature · 1 line
2.39.5
Daniel Almeida
maintainerRe: [PATCH 4/9] drm/tyr: add McuVa and claim-checked MappedBo views
Hi Laura,
It’s been a while since I wrote this, and I now see this could use some improvements.
I think the first problem is that this conflates "MappedBo" with "the MappedBo backing the shared region". As soon as we try to add more users, this will be a problem. I propose that we split this into two types that build upon each other:
a) a generic layer MappedBo, which remains roughly as-is:
gem.rs:
pub(crate) struct MappedBo<'drm> {
vmap: shmem::VMapOwned<BoData>,
bo: KernelBo<'drm>,
}
impl<'drm> MappedBo<'drm> {
// pub(crate) API:
// no Arc, McuMappedBo has to hold it by value, otherwise a second holder // could write around the claims.
fn new(bo: KernelBo<'drm>) -> Result<Self>
fn va_range(...) -> ...
fn vmap(...) -> ...
}
impl Deref for MappedBo<'_> { type Target = Bo ... }
b) A MCU-specific BO type with the claims + offset logic:
fw/mcu_bo.rs:
pub(super) struct McuVa(...) + related McuVa impls.
#[pin_data]
pub(super) struct McuMappedBo<'drm> {
bo: MappedBo<'drm>, // private, no accessor
#[pin]
claims: Mutex<KVec<Range<u64>>>
}
impl<'drm> McuMappedBo<'drm> {
// pub super API
// builds its own MappedBo, checks the 32-bit range before allocating and // copies the section data from the fw binary before any view can exist. new(ddev, mcu_vm: Arc<Vm<'drm>>, va: McuVa, size: u64, flags: VmMapFlags,
data: &[u8]) -> Result<impl PinInit<Self,Error>> {...}// views borrow: &'a self instead of self: &Arc<Self> fn try_view<'a>(&'a self, va: McuVa, len: u64, reach: u64)
-> Result<McuView<'a>>
fn try_view_mut<'a>(&'a self, va: McuVa, len: u64, reach: u64)
-> Result<McuViewMut<'a>>
}c) Views get renamed to McuView, McuViewMut:
#[derive(Clone)]
pub(super) struct McuView<'a> {
vmap: &'a VMapOwned<BoData>,
base: u64,
range: Range<u64>,
reach: u64, // <———— Store this
}
pub(super) struct McuViewMut<'a> {
view: McuView<'a>,
claims: &'a Mutex<KVec<Range<u64>>>,
}
impl<'a> Deref for McuViewMut<'a> {
type Target = McuView<'a>;
fn deref(&self) -> &Self::Target {
&self.view
}
}
impl Drop for McuViewMut<'_> {
// return claim here.
}
drivers/gpu/drm/tyr/gem.rs fn drop(&mut self) { · line 246
Quoted 12 lines
drivers/gpu/drm/tyr/gem.rs +11
-0+// SAFETY: `MappedBo` may move between threads: the CPU mapping's address is +// valid from any thread; `KernelBo`'s teardown (GPU unmap through `Arc<Vm>` +// and the GEM object release) goes through thread-safe C APIs; and the only +// interior mutability (`claims`) is mutex-protected. +unsafe impl Send for MappedBo <'_> {} +// SAFETY: `&MappedBo` exposes the mutex-protected claims table, the `Deref` +// surface to the GEM object (thread-safe C APIs), and the mapping itself, +// whose contents are only ever accessed through volatile operations. The +// memory is shared with the MCU by design, so concurrent access is part of +// the model rather than a race the type system must rule out. +unsafe impl Sync for MappedBo <'_> {}
I don’t think we need a manual implementation here.
The rest of the patch looks good to me.
— Daniel
PATCH 5/9 drm/tyr: drop unused KernelBo::bo() function
In reply to Laura Nao--- drivers/gpu/drm/tyr/gem.rs | 4 ---- 1 file changed, 4 deletions(-)
drivers/gpu/drm/tyr/gem.rs +0 -4
@@ -142,10 +142,6 @@ pub(crate) fn new( }) } -pub (crate )fn bo (&self) -> &Bo { - &self.bo - } -/// Returns the GPU virtual address range occupied by this buffer. pub (crate )fn va_range (&self) ->Range <u64 > { self.va_range.clone ()
Signature · 1 line
2.39.5
Daniel Almeida
maintainerRe: [PATCH 5/9] drm/tyr: drop unused KernelBo::bo() function
Quoted 28 lines · Laura Nao
Signed-off-by Laura Nao <[email protected]>---
drivers/gpu/drm/tyr/gem.rs| 4 ----1 file changed, 4 deletions(-)drivers/gpu/drm/tyr/gem.rs +0
-4@@ -142,10 +142,6 @@ pub(crate) fn new( }) } -pub (crate )fn bo (&self) -> &Bo { - &self.bo - } -/// Returns the GPU virtual address range occupied by this buffer. pub (crate )fn va_range (&self) ->Range <u64 > { self.va_range.clone ()Signature · 2 lines
-- 2.39.5
Please squash into patch 3.
— Daniel
PATCH 6/9 drm/tyr: add CSF firmware interface support
In reply to Laura NaoAdd initial support for the Command Stream Frontend (CSF) firmware interfaces, enabling communication between the driver and the MCU through shared memory.
Implement the global (GLB), command stream group (CSG), and command stream (CS) interfaces. These provide access to the firmware control, input, and output blocks and allow discovery of the available CSGs and CSs at runtime.
Register block layouts are declared with a new iface_layout! macro from offset => field: Type entries, so each offset is stated once and a misplaced field results in a build error.
The interface is versioned: GLB_VERSION is read once at probe time to pick a [FwIfaces] variant, after which the code is statically typed for that generation's layout.
Store the global interface in the firmware state and initialize it after firmware boot during probe.
--- drivers/gpu/drm/tyr/driver.rs | 3 +- drivers/gpu/drm/tyr/fw.rs | 96 +- drivers/gpu/drm/tyr/fw/interfaces.rs | 1316 +++++++++++++++++++++++++++ drivers/gpu/drm/tyr/fw/interfaces/layout.rs | 152 ++++ drivers/gpu/drm/tyr/fw/interfaces/v1.rs | 1230 +++++++++++++++++++++++++ drivers/gpu/drm/tyr/gem.rs | 5 - 6 files changed, 2781 insertions(+), 21 deletions(-)
drivers/gpu/drm/tyr/driver.rs +2 -1
@@ -70,7 +70,7 @@ pub(crate) struct TyrDrmRegistrationData<'drm> { pub(crate) pdev: &'drm platform::Device<Bound>,/// Firmware sections. - pub(crate) fw: Firmware<'drm>, + pub(crate) fw: Arc<Firmware<'drm>>,#[pin] clks: Mutex<Clocks>,
@@ -159,6 +159,7 @@ fn probe<'bound>( )?; firmware.boot ()?; + firmware.enable_global_interface ()?; let reg_data = pin_init!(TyrDrmRegistrationData { pdev,
drivers/gpu/drm/tyr/fw.rs +81 -15
174 lines not on this page · raw message
drivers/gpu/drm/tyr/fw/interfaces.rs new file +1316 -0
1,316 lines not on this page · raw message
drivers/gpu/drm/tyr/fw/interfaces/layout.rs new file +152 -0
152 lines not on this page · raw message
drivers/gpu/drm/tyr/fw/interfaces/v1.rs new file +1230 -0
1,230 lines not on this page · raw message
drivers/gpu/drm/tyr/gem.rs +0 -5
@@ -325,7 +325,6 @@ fn resolve(&self, va: McuVa, len: u64, reach: u64) -> Result<Range<u64>> {/// Intended for blocks the firmware writes and the host only reads; /// read-read overlap is harmless, so these views are freely cloneable /// and no claim is taken. -#[expect(dead_code)] pub (crate )fn try_view ( self: &Arc <Self >, va: McuVa,
@@ -427,26 +426,22 @@ pub(crate) fn gpu_va(&self) -> McuVa { }/// Returns the length of the window in bytes. -#[allow(dead_code)] pub (crate )fn len (&self) ->u64 { self.range.end - self.range.start }/// Returns the window's byte offset within the CPU mapping. -#[allow(dead_code)] pub (crate )fn cpu_offset (&self) ->usize { (self.range.start - self.bo.va_range ().start)as usize }/// Returns the I/O view of the whole underlying mapping, for /// projection to this window. -#[expect(dead_code)] pub (crate )fn parent_view (&self) ->SysMem <'_,Region <0 >> { (&self.bo.vmap).as_view () }/// Returns the CPU address of the window's start. -#[expect(dead_code)] pub (crate )fn cpu_addr (&self) ->usize { self.bo.cpu_base () + self.cpu_offset () }
Signature · 1 line
2.39.5
Daniel Almeida
maintainerHi Laura,
I've left a few comments inline, plus a request to split this patch at the end. I'll get back to you on the versioning parts next week.
drivers/gpu/drm/tyr/fw.rs line 86
Quoted 6 lines
drivers/gpu/drm/tyr/fw.rs +5
-0+/// Maximum number of CSG interfaces supported by hardware. +const MAX_CSG :usize =16 ; + +/// Maximum number of CS interfaces supported by hardware. +const MAX_CS :usize =16 ;
Panthor allows up to 31 CSGs and 32 CSs per CSG (see MAX_CSGS and MAX_CS_PER_CSG in panthor_fw.h). With 16/16 here, we fail to probe on firmware that panthor accepts. Can we match panthor here?
nit: both counts come from the firmware (GLB_GROUP_NUM and GROUP_STREAM_NUM), so "supported by hardware" is a bit misleading.
drivers/gpu/drm/tyr/fw.rs pub(crate) struct Firmware<'drm> { · line 181
Quoted 8 lines
/// List of firmware sections.drivers/gpu/drm/tyr/fw.rs +4
-1-#[expect(dead_code)] sections: KVec<Section<'drm>>, + +/// The global FW interface. +#[pin] + global_iface: Mutex<FwIfaces<'drm>>, }
The CSGs are not part of the global interface, and a single mutex over everything means that all CSG operations get serialized behind GLB. Can we split this? Leaving the versioning aside, something like:
pub(super) struct Ifaces<'mem> {
glb: Pin<KBox<Mutex<GlbInterface<'mem>>>>,
csgs: Pin<KBox<[CsgSlot<'mem>]>>, // one lock per CSG
}
#[pin_data]
pub(super) struct CsgSlot<'mem> {
#[pin]
iface: Mutex<CsgInterface<'mem>>,
}
i.e.: one lock for GLB and one per CSG, with the CS interfaces inside their CSG. You can build the slots in place with KBox::pin_slice():
KBox::pin_slice(
|csg_idx| {
pin_init_scope(move || {
let iface = CsgInterface::new(mem, csg_idx, csg_stride)?; Ok(try_pin_init!(CsgSlot {
iface <- new_mutex!(iface),
}))
})
},
csg_num as usize,
GFP_KERNEL,)
With the split I suggested in 4/9, the views borrow the McuMappedBo instead of holding an Arc to it, so the McuMappedBo should live next to them in Firmware. This means that the shared section moves out of sections.
Now, a field can't borrow another field of the same struct in safe Rust, and pin-init doesn't support self-referential structs yet (Gary is working on it). Until then, I think we should do what nova-core does in 88b70f5a05af ("gpu: nova-core: use lifetime for Bar"), i.e.: take the reference with core::ptr::from_ref() in a single place, and justify it with a SAFETY comment:
#[pin_data(PinnedDrop)]
pub(crate) struct Firmware<'drm> {
...
/// Firmware sections other than the CSF shared section.
sections: KVec<Section<'drm>>,
// The interface views borrow shared, so ifaces is declared before it, // i.e. dropped before it. See Firmware::new().
ifaces: Ifaces<'drm>,
#[pin]
shared: McuMappedBo<'drm>,
/// Raw payload of the shared section, for reset purposes.
shared_data: KVec<u8>,
}
and in Firmware::new(), perhaps something like this:
try_pin_init!(Firmware {
...
shared <- shared,
shared_data,
// TODO: Make `ifaces` borrow `shared` through `#[pin_data]` once
// pin-init supports self-referential structs, and drop the unsafe.
ifaces: {
// SAFETY: `shared` is structurally pinned, so it has a stable
// address. The reference is only stored in the views inside
// `ifaces`, which is declared before `shared` and therefore
// dropped first, and the interface types keep their views
// private, so no reference with this lifetime escapes.
let shared: &'drm McuMappedBo<'drm> =
unsafe { &*core::ptr::from_ref(&*shared) };
// `PinnedDrop` does not run for a partially initialized
// `Firmware`, so stop the MCU on failure before its sections
// are freed.
Self::boot(dev, iomem)
.and_then(|()| Ifaces::new(shared))
.inspect_err(|_| {
let _ = Self::stop(dev, iomem);
vm.kill();
})?
},})
Note that boot() and stop() have to take dev and the iomem instead of &self, so that both the initializer and PinnedDrop can call them.
The key here is the field order. Fields are dropped in declaration order, so if someone ever swaps ifaces and shared, the McuMappedBo gets freed before the views that borrow it, and nothing catches that at build time. So please keep that comment on ifaces :)
Once pin-init supports self-referential structs, the unsafe block goes away and the compiler checks the field order for us, or at least that is what I understood from Gary's most recent talk anyway.
drivers/gpu/drm/tyr/fw.rs pub(crate) fn new( · line 252
Quoted 3 lines
gpu_info: &GpuInfo,drivers/gpu/drm/tyr/fw.rs +1
-1- ) -> Result<Firmware<'drm>> { + ) -> Result<Arc<Firmware<'drm>>> {
Nothing clones this Arc. In fact, I don't think we need a separate allocation at all: TyrDrmRegistrationData is already pinned, so Firmware can be a pinned field there and get built in place. Gary is also (very helpfully) on a crusade to remove all Arcs he can from Tyr, so lets not add more if we can help it. (Thanks, Gary!)
drivers/gpu/drm/tyr/fw/interfaces.rs line 215
Quoted 9 lines
drivers/gpu/drm/tyr/fw/interfaces.rs new file +9
-0+// SAFETY: `ptr` is a projection of `view.as_ptr()` by +// `cpu_offset()` bytes. Per `MappedBoView`'s invariants the +// window lies within the CPU mapping and the mapping covers +// `size_of::<B>()` bytes from its start (the resolve-time +// `reach`), so the typed view's full extent is valid; per +// `FwInterface::new()` the window holds the architectural block +// at `align_of::<B>()` alignment, and every field access stays +// within it. +unsafe {SysMemBackend ::project_view (view, ptr) }
Once the view stores reach (see 4/9), FwInterface::new() and FwInterfaceMut::new() can check it:
if view.reach() < core::mem::size_of::<B>() as u64 {
return Err(EINVAL);
}and this comment can then just point at that check.
drivers/gpu/drm/tyr/fw/interfaces.rs line 866
Quoted 4 lines
drivers/gpu/drm/tyr/fw/interfaces.rs new file +4
-0+/// State of the global interface. +enum GlobalInterfaceState <'drm> { +/// Interface is not yet initialized. +Disabled ,
Once the interfaces are built in Firmware's initializer, I don't think we need the Disabled variant anymore, neither here nor in CsgInterfaceState. The views don't change across a reset or suspend, so once built, they can live for as long as Firmware does.
Although they do not change, they do become unusable when resetting though, so how exactly we should do this is up for debate. Can you investigate a bit and propose something? We would really like to get rid of places where we have enums, checks and Options introduced, specially when these infect everything else :/
drivers/gpu/drm/tyr/fw/interfaces.rs line 1018
Quoted 2 lines
drivers/gpu/drm/tyr/fw/interfaces.rs new file +2
-0+// Validate the CSG number reported. +if csg_numas usize >super ::MAX_CSG {
Panthor also rejects too few, i.e.: group_num < 3 (MIN_CSGS) here, and stream_num < 8 (MIN_CS_PER_CSG) in the CSG path. As is, a firmware that reports 0 CSGs makes enable() succeed with no CSGs at all.
Panthor also checks that every CSG matches the first one (see compare_csg()), and that every CS matches the first CS, and fails probe otherwise. Can we do the same here?
Quoted 1 line
+ let
csg_control_offset=CSG_GROUP_CONTROL_OFFSET+csg_idx*csg_stride;
^ checked_mul() and checked_add()
By the way, this patch is about 2.8k lines, and it mixes three different kinds of things: the iface_layout! macro, the register layouts themselves, and the interface themselves, plus more. Can we split it? I think something along these lines would work:
1) GLB block layouts: iface_layout!, the GLB registers and blocks, and the GLB enums.
2) GLB interface support: FwInterface/FwInterfaceMut, GlbInterface and the Firmware changes above.
3) CSG block layouts and the CSG enums.
4) CS block layouts and the CS enums.
5) CSG/CS discovery: CsgInterface, CsInterface and the per-CSG locks.
You can use #[expect(dead_code)] for anything that doesn't have a user yet, and drop it in the patch that adds the user. This should keep everything <= 750ish lines I suppose. Some things gain a quick r-b too, like the stuff in blocks.rs, which is basically a datasheet copy.
Lastly, Onur's reset series [0] should land first, so this will need a rebase on top of it (after the Job IRQ series). After that, the registers are only reachable through HwGate, and I think the interfaces should live behind the gate as well, so that a reset waits for anyone using them. The lock order would then be the gate first, then the GLB/CSG locks.
Again, as I said, we will tackle versioning separately, because there's quite a lot to discuss between all of us there. But ideally I'd like to keep it as a separate patch and towards the end of the series so we don't build any dependencies on this idea and can drop it relatively pain-free if it's not well-received.
— Daniel
PATCH 7/9 rust: time: add arch_timer_get_rate wrapper
In reply to Laura NaoFrom: Deborah Brouwer <[email protected]>
Provide a safe Rust wrapper for arch_timer_get_rate().
The Rust binding calls a C helper that returns 0 when the ARM architectural timer is not available or not yet initialized. Map this to Option<u32> to make the absence of a valid rate explicit to Rust callers.
This allows Rust drivers to query the system timer frequency and select appropriate time sources when programming hardware timeouts.
--- rust/helpers/time.c | 6 ++++++ rust/kernel/time.rs | 30 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
rust/helpers/time.c +6 -0
@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0 +#include <clocksource/arm_arch_timer.h> #include <linux/delay.h> #include <linux/ktime.h> #include <linux/timekeeping.h>
@@ -38,3 +39,8 @@ __rust_helper void rust_helper_udelay(unsigned long usec) {udelay (usec); } + +__rust_helper u32 rust_helper_arch_timer_get_rate(void) +{ +return arch_timer_get_rate (); +}
rust/kernel/time.rs +30 -0
@@ -423,6 +423,36 @@ fn div(self, rhs: Self) -> Self::Output { } } +/// Returns the ARM architecture timer frequency in Hz, if available. +/// +/// This function queries the system-wide ARM architecture timer frequency. +/// The architecture timer provides a consistent time source across all CPU cores. +/// +/// Returns `None` if: +/// - The ARM architecture timer is not available (`CONFIG_ARM_ARCH_TIMER` not enabled) +/// - The timer rate is zero (not initialized) +/// +/// # Examples +/// +/// ``` +/// use kernel::time::arch_timer_get_rate; +/// +/// if let Some(rate) = arch_timer_get_rate() { +/// // Use `rate`. +/// } +/// ``` +pub fn arch_timer_get_rate () ->Option <u32 > { +// SAFETY: The C helper is available in all configs; it calls +// `arch_timer_get_rate()`, which falls back to an inline stub returning 0 +// when CONFIG_ARM_ARCH_TIMER is disabled. +let rate =unsafe { bindings::arch_timer_get_rate () }; +if rate ==0 { +None + }else { +Some (rate) + } +} +impl Delta {/// A span of time equal to zero. pub const ZERO :Self =Self { value:0 };
Signature · 1 line
2.39.5
Re: [PATCH 7/9] rust: time: add arch_timer_get_rate wrapper
Quoted 8 lines · Laura Nao
From: Deborah Brouwer <[email protected]>
Provide a safe Rust wrapper for
arch_timer_get_rate().The Rust binding calls a C helper that returns 0 when the ARM architectural timer is not available or not yet initialized. Map this to Option<u32> to make the absence of a valid rate explicit to Rust callers.
Quoted 5 lines
This allows Rust drivers to query the system timer frequency and select appropriate time sources when programming hardware timeouts.
Signed-off-by Deborah Brouwer <[email protected]>Signed-off-by Laura Nao <[email protected]>
Best regards,
Andreas Hindborg
Re: [PATCH 7/9] rust: time: add arch_timer_get_rate wrapper
In reply to Laura NaoQuoted 17 lines · On Tue, 15 Sep 2026 12:57:40 +0200 Laura Nao <[email protected]> wrote:
From: Deborah Brouwer <[email protected]>
Provide a safe Rust wrapper for
arch_timer_get_rate().The Rust binding calls a C helper that returns 0 when the ARM architectural timer is not available or not yet initialized. Map this to Option<u32> to make the absence of a valid rate explicit to Rust callers.
This allows Rust drivers to query the system timer frequency and select appropriate time sources when programming hardware timeouts.
Signed-off-by Deborah Brouwer <[email protected]>Signed-off-by Laura Nao <[email protected]>--- rust/helpers/time.c | 6 ++++++ rust/kernel/time.rs | 30 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
(snip)
Quoted 12 lines
rust/kernel/time.rs +12
-0+/// Returns the ARM architecture timer frequency in Hz, if available. +/// +/// This function queries the system-wide ARM architecture timer frequency. +/// The architecture timer provides a consistent time source across all CPU cores. +/// +/// Returns `None` if: +/// - The ARM architecture timer is not available (`CONFIG_ARM_ARCH_TIMER` not enabled) +/// - The timer rate is zero (not initialized) +/// +/// # Examples +/// +/// ```
rust/kernel/time.rs fn div(self, rhs: Self) -> Self::Output { · line 447
Quoted 10 lines
rust/kernel/time.rs +10
-0+/// use kernel::time::arch_timer_get_rate; +/// +/// if let Some(rate) = arch_timer_get_rate() { +/// // Use `rate`. +/// } +/// ``` +pub fn arch_timer_get_rate () ->Option <u32 > { +// SAFETY: The C helper is available in all configs; it calls +// `arch_timer_get_rate()`, which falls back to an inline stub returning 0 +// when CONFIG_ARM_ARCH_TIMER is disabled.
A SAFETY comment states why the unsafe call is sound. This one explains why the helper is available in all configs.
How about:
// SAFETY: It is always safe to call arch_timer_get_rate().
It just returns a variable without any lock. rust/kernel/time.rs already does this for ktime_get() and ktime_to_us().
rust/kernel/time.rs fn div(self, rhs: Self) -> Self::Output { · line 458
Quoted 12 lines
rust/kernel/time.rs +8
-0+let rate =unsafe { bindings::arch_timer_get_rate () }; +if rate ==0 { +None + }else { +Some (rate) + } +} +impl Delta {/// A span of time equal to zero. pub const ZERO :Self =Self { value:0 };
This puts the new function between impl ops::Div for Delta and impl Delta, so it splits the Delta blocks.
msecs_to_jiffies() is the only other free function in this file and it is at the top, next to the type aliases. Please put arch_timer_get_rate() there,
Gary Guo
reviewerRe: [PATCH 7/9] rust: time: add arch_timer_get_rate wrapper
In reply to Laura NaoQuoted 23 lines · Laura Nao
From: Deborah Brouwer <[email protected]>
Provide a safe Rust wrapper for
arch_timer_get_rate().The Rust binding calls a C helper that returns 0 when the ARM architectural timer is not available or not yet initialized. Map this to Option<u32> to make the absence of a valid rate explicit to Rust callers.
This allows Rust drivers to query the system timer frequency and select appropriate time sources when programming hardware timeouts.
Signed-off-by Deborah Brouwer <[email protected]>Signed-off-by Laura Nao <[email protected]>--- rust/helpers/time.c | 6 ++++++ rust/kernel/time.rs | 30 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)rust/helpers/time.c +0
-0
rust/helpers/time.c line 3
Quoted 3 lines
rust/helpers/time.c +1
-0@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0 +#include <clocksource/arm_arch_timer.h>
The header is from arm_arch_timer. I wonder if we want this to be exported from somewhere like kernel::arch::arm::time?
Best,
Gary
Quoted 53 lines
rust/helpers/time.c +5
-0#include <linux/delay.h> #include <linux/ktime.h> #include <linux/timekeeping.h> @@ -38,3 +39,8 @@ __rust_helper void rust_helper_udelay(unsigned long usec) {udelay (usec); } + +__rust_helper u32 rust_helper_arch_timer_get_rate(void) +{ +return arch_timer_get_rate (); +}rust/kernel/time.rs +30
-0@@ -423,6 +423,36 @@ fn div(self, rhs: Self) -> Self::Output { } } +/// Returns the ARM architecture timer frequency in Hz, if available. +/// +/// This function queries the system-wide ARM architecture timer frequency. +/// The architecture timer provides a consistent time source across all CPU cores. +/// +/// Returns `None` if: +/// - The ARM architecture timer is not available (`CONFIG_ARM_ARCH_TIMER` not enabled) +/// - The timer rate is zero (not initialized) +/// +/// # Examples +/// +/// ``` +/// use kernel::time::arch_timer_get_rate; +/// +/// if let Some(rate) = arch_timer_get_rate() { +/// // Use `rate`. +/// } +/// ``` +pub fn arch_timer_get_rate () ->Option <u32 > { +// SAFETY: The C helper is available in all configs; it calls +// `arch_timer_get_rate()`, which falls back to an inline stub returning 0 +// when CONFIG_ARM_ARCH_TIMER is disabled. +let rate =unsafe { bindings::arch_timer_get_rate () }; +if rate ==0 { +None + }else { +Some (rate) + } +} +impl Delta {/// A span of time equal to zero. pub const ZERO :Self =Self { value:0 };
PATCH 8/9 drm/tyr: program CSF global interface
In reply to Laura NaoInitialize the CSF global (GLB) interface after firmware boot.
Program the GLB input block with initial configuration:
- enable allocation across all present shader cores
- set power-off, progress, and idle timers
Then update GLB_REQ to enable persistent features and trigger configuration updates, and ring the global doorbell to notify the MCU.
--- drivers/gpu/drm/tyr/driver.rs | 2 +- drivers/gpu/drm/tyr/fw.rs | 6 +- drivers/gpu/drm/tyr/fw/interfaces.rs | 222 +++++++++++++++++++++++++++++++++-- 3 files changed, 219 insertions(+), 11 deletions(-)
drivers/gpu/drm/tyr/driver.rs +1 -1
@@ -159,7 +159,7 @@ fn probe<'bound>( )?; firmware.boot ()?; - firmware.enable_global_interface ()?; + firmware.enable_global_interface (&gpu_info, &core_clk)?; let reg_data = pin_init!(TyrDrmRegistrationData { pdev,
drivers/gpu/drm/tyr/fw.rs +3 -3
@@ -14,6 +14,7 @@//! [`Section`]: crate::fw::Section use kernel::{ + clk::Clk , device::{Bound ,Device ,//
@@ -370,7 +371,7 @@ fn stop(&self) -> Result { }/// Enable the global interface. -pub (crate )fn enable_global_interface (&self) ->Result { +pub (crate )fn enable_global_interface (&self, gpu_info: &GpuInfo , core_clk: &Clk ) ->Result {let shared_section = self.shared_section ()?;let version = interfaces::probe_version (&shared_section.mem)?;
@@ -379,7 +380,7 @@ pub(crate) fn enable_global_interface(&self) -> Result {match version.major ().get () {1 ..=4 =>match &mut *self.global_iface.lock () {FwIfaces ::V1 (iface) => { - iface.enable (shared_section) + iface.enable (&self.iomem, shared_section, gpu_info, core_clk) } },0 => {
@@ -391,6 +392,5 @@ pub(crate) fn enable_global_interface(&self) -> Result {Err (ENODEV ) } } - } }
drivers/gpu/drm/tyr/fw/interfaces.rs +215 -7
279 lines not on this page · raw message
Signature · 1 line
2.39.5
PATCH 9/9 drm/tyr: wait for global interface readiness
In reply to Laura NaoAdd 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.
--- 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(-)
drivers/gpu/drm/tyr/driver.rs +29 -1
@@ -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, });
drivers/gpu/drm/tyr/fw.rs +14 -9
@@ -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) + } }
drivers/gpu/drm/tyr/fw/irq.rs +0 -1
@@ -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 ,//
Signature · 1 line
2.39.5
Alice Ryhl
maintainerRe: [PATCH 9/9] drm/tyr: wait for global interface readiness
drivers/gpu/drm/tyr/fw.rs pub(crate) fn boot(&self) -> Result { · line 336
Quoted 12 lines · Laura Nao
io.write_reg(MCU_CONTROL::zeroed().with_req(McuControlMode::Auto)); if let Err(e) = poll::read_poll_timeout(drivers/gpu/drm/tyr/fw.rs +2
-4- || 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), ) {
Does the io.write_reg(JOB_IRQ_CLEAR::zeroed().with_glb(true)) line after this read_poll_timeout() also need to be removed?
Alice