Skip to contentSkip to conversation

gpu: nova-core: use Init for firmware initialization

PATCH In review Danilo Krummrich 2 participants 2 messages Nov 22 – Nov 24

Subsystems (5)
lore
Share & tools
lore

Danilo Krummrich

author maintainer
#0 lore raw

PATCH 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
index 341a8b19aa38..1cf17d0fb36b 100644
@@ -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
index 4fb1b69ac9d5..defe1f331918 100644
@@ -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
Reviewed-by on v2 1/1
#1 lore raw
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.

---
Changes in v2:
- Convert to impl Init to not increase the overall stack usage.
---