[PATCH v2 05/13] gpu: nova-core: gsp: move unload bundle error handling to Gsp::boot

From: Alexandre Courbot

Date: Mon Jun 22 2026 - 03:14:30 EST


The warning emitted when the unload bundle cannot be constructed is valid
regardless of the boot method, but it was local to `Tu102`. Move it to
`Gsp::boot` so it applies to all boot methods.

This requires the HAL's `boot` method to return the `Result` for the
unload bundle's creation, so `Gsp::boot` can display the warning.

Signed-off-by: Alexandre Courbot <acourbot@xxxxxxxxxx>
---
drivers/gpu/nova-core/gsp/boot.rs | 12 ++++++++++++
drivers/gpu/nova-core/gsp/hal.rs | 4 ++--
drivers/gpu/nova-core/gsp/hal/gh100.rs | 6 +++---
drivers/gpu/nova-core/gsp/hal/tu102.rs | 13 ++-----------
4 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/nova-core/gsp/boot.rs b/drivers/gpu/nova-core/gsp/boot.rs
index 3574f1a87344..3f11eaec26c7 100644
--- a/drivers/gpu/nova-core/gsp/boot.rs
+++ b/drivers/gpu/nova-core/gsp/boot.rs
@@ -59,6 +59,18 @@ pub(crate) fn boot(
// Perform the chipset-specific boot sequence, and retrieve the unload bundle.
let (res, unload_bundle) = hal.boot(&self, &ctx, &fb_layout, &wpr_meta);

+ // Display error for unload bundle if any, and convert to `Option`.
+ let unload_bundle = unload_bundle
+ .inspect_err(|e| {
+ dev_warn!(dev, "Failed to prepare unload firmware: {:?}\n", e);
+ dev_warn!(dev, "The GSP won't be able to unload properly on unbind.\n");
+ dev_warn!(
+ dev,
+ "The GPU will need to be reset before the driver can bind again.\n"
+ );
+ })
+ .ok();
+
// Run from a closure so we can retrieve the result, and run the unload sequence of the GSP
// in case of error.
let res = res.and_then(|()| {
diff --git a/drivers/gpu/nova-core/gsp/hal.rs b/drivers/gpu/nova-core/gsp/hal.rs
index a76be4e43272..00e39cc1fbde 100644
--- a/drivers/gpu/nova-core/gsp/hal.rs
+++ b/drivers/gpu/nova-core/gsp/hal.rs
@@ -53,7 +53,7 @@ pub(super) trait GspHal: Send {
/// Returns two things:
///
/// - The `Result` of the boot process itself,
- /// - The `UnloadBundle` to use with [`Gsp::unload`], or `None` if the bundle could not be
+ /// - The `UnloadBundle` to use with [`Gsp::unload`], or `Err` if the bundle could not be
/// created.
///
/// Note that the two returned values are independent: it is possible for the boot process to
@@ -65,7 +65,7 @@ fn boot(
ctx: &GspBootContext<'_>,
fb_layout: &FbLayout,
wpr_meta: &Coherent<GspFwWprMeta>,
- ) -> (Result, Option<crate::gsp::UnloadBundle>);
+ ) -> (Result, Result<crate::gsp::UnloadBundle>);

/// Performs HAL-specific post-GSP boot tasks.
///
diff --git a/drivers/gpu/nova-core/gsp/hal/gh100.rs b/drivers/gpu/nova-core/gsp/hal/gh100.rs
index ece40403b831..02203dfd3584 100644
--- a/drivers/gpu/nova-core/gsp/hal/gh100.rs
+++ b/drivers/gpu/nova-core/gsp/hal/gh100.rs
@@ -150,16 +150,16 @@ fn boot(
ctx: &GspBootContext<'_>,
fb_layout: &FbLayout,
wpr_meta: &Coherent<GspFwWprMeta>,
- ) -> (Result, Option<crate::gsp::UnloadBundle>) {
+ ) -> (Result, Result<crate::gsp::UnloadBundle>) {
let dev = ctx.dev();
let bar = ctx.bar;
let chipset = ctx.chipset;
let gsp_falcon = ctx.gsp_falcon;

- let mut unload_bundle = None;
+ let mut unload_bundle = Err(EAGAIN);

let res = (|| {
- unload_bundle = Some(crate::gsp::UnloadBundle(
+ unload_bundle = Ok(crate::gsp::UnloadBundle(
KBox::new(FspUnloadBundle, GFP_KERNEL)? as KBox<dyn UnloadBundle>,
));

diff --git a/drivers/gpu/nova-core/gsp/hal/tu102.rs b/drivers/gpu/nova-core/gsp/hal/tu102.rs
index fca8da281e16..984716fc0bf9 100644
--- a/drivers/gpu/nova-core/gsp/hal/tu102.rs
+++ b/drivers/gpu/nova-core/gsp/hal/tu102.rs
@@ -269,14 +269,14 @@ fn boot(
ctx: &GspBootContext<'_>,
fb_layout: &FbLayout,
wpr_meta: &Coherent<GspFwWprMeta>,
- ) -> (Result, Option<crate::gsp::UnloadBundle>) {
+ ) -> (Result, Result<crate::gsp::UnloadBundle>) {
let dev = ctx.dev();
let bar = ctx.bar;
let chipset = ctx.chipset;
let gsp_falcon = ctx.gsp_falcon;
let sec2_falcon = ctx.sec2_falcon;

- let mut unload_bundle = None;
+ let mut unload_bundle = Err(EAGAIN);

let res = (|| {
let bios = Vbios::new(dev, bar)?;
@@ -287,15 +287,6 @@ fn boot(
// can be probed again.
unload_bundle =
Sec2UnloadBundle::build(dev, bar, chipset, &bios, gsp_falcon, sec2_falcon)
- .inspect_err(|e| {
- dev_warn!(dev, "Failed to prepare unload firmware: {:?}\n", e);
- dev_warn!(dev, "The GSP won't be able to unload properly on unbind.\n");
- dev_warn!(
- dev,
- "The GPU will need to be reset before the driver can bind again.\n"
- );
- })
- .ok()
.map(crate::gsp::UnloadBundle);

// FWSEC-FRTS is not executed on chips where the FRTS region size is 0 (e.g. GA100).

--
2.54.0