gpu: nova-core: use Init for firmware initialization
Subsystems (5)
Danilo Krummrich
maintainerPATCH v2 1/1 gpu: nova-core: use Init for firmware initialization
Now that SGTable no longer requires pinning, move Radix3 and GspFirmware from PinInit to Init.
In an x86-64 build, GspFirmware is 312 bytes, including its 216-byte Radix3. This is reasonable for the stack, but returning it by value increases boot()'s local stack reservation from 432 to 1040 bytes.
On TU102 for instance, the nested hal.boot() call reserves another 1128 bytes for locals.
Thus, keep the KBox allocation and in-place initialization.
---
Changes in v2:
- Convert to impl Init to not increase the overall stack usage.
--- drivers/gpu/nova-core/firmware/gsp.rs | 8 ++- drivers/gpu/nova-core/firmware/radix3.rs | 67 +++++++++++------------- drivers/gpu/nova-core/gsp/boot.rs | 3 +- 3 files changed, 36 insertions(+), 42 deletions(-)
drivers/gpu/nova-core/firmware/gsp.rs +3 -5
@@ -25,10 +25,8 @@ };/// The GSP firmware image, its signatures, and the GSP bootloader. -#[pin_data] pub (crate )struct GspFirmware <'a> {/// The firmware image and the radix3 table that maps it. -#[pin] radix3:Radix3 <'a>,/// Device-mapped GSP signatures matching the GPU's [`Chipset`]. pub (crate ) signatures:Coherent <'a, [u8 ]>,
@@ -42,8 +40,8 @@ impl<'a> GspFirmware<'a> {pub (crate )fn new ( dev: &'a device::Device <device::Bound >, chipset:Chipset , - ) ->impl PinInit <Self ,Error > + 'a { - pin_init::pin_init_scope (move || { + ) ->impl Init <Self ,Error > + 'a { + pin_init::init_scope (move || {let firmware =request_tlv (dev, chipset,"gsp" )?;let tlv =Tlv ::new (firmware.data ())?;dev_dbg! (dev,"loaded gsp firmware v{}\n" , tlv.get_string (b"VERS" )?);
@@ -58,7 +56,7 @@ pub(crate) fn new(let signatures =Coherent ::from_slice (dev, tlv.get_bytes (b"SIGN" )?,GFP_KERNEL )?; - Ok(try_pin_init!(Self { + Ok(try_init!(Self { radix3 <- Radix3::new(dev, fw_vvec), signatures, bootloader: {
drivers/gpu/nova-core/firmware/radix3.rs +31 -36
79 lines not on this page · raw message
drivers/gpu/nova-core/gsp/boot.rs +2 -1
@@ -40,7 +40,8 @@ pub(crate) fn boot(let dev = pdev.as_ref ();let hal =super ::hal::gsp_hal (chipset); -let gsp_fw =KBox ::pin_init (GspFirmware ::new (dev, chipset),GFP_KERNEL )?; +// Initialize the firmware in place to limit stack usage during boot. +let gsp_fw =KBox ::init (GspFirmware ::new (dev, chipset),GFP_KERNEL )?; self.cmdq .send_command_no_wait (commands::SetSystemInfo ::new (pdev, chipset))?;
base-commit: 0504beeb95d1be229d7cce00a12033468f5ac50b
Signature · 1 line
2.56.1
Quoted 10 lines · Danilo Krummrich
Now that SGTable no longer requires pinning, move Radix3 and GspFirmware from PinInit to Init.
In an x86-64 build, GspFirmware is 312 bytes, including its 216-byte Radix3. This is reasonable for the stack, but returning it by value increases boot()'s local stack reservation from 432 to 1040 bytes.
On TU102 for instance, the nested
hal.boot()call reserves another 1128 bytes for locals.
Quoted 7 lines
Thus, keep the KBox allocation and in-place initialization.
Signed-off-by Danilo Krummrich <[email protected]>---
Changes in v2:
- Convert to impl Init to not increase the overall stack usage.
---