From: Alexandre Courbot <acourbot@nvidia.com>
To: Danilo Krummrich <dakr@kernel.org>,
Alice Ryhl <aliceryhl@google.com>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>, Gary Guo <gary@garyguo.net>,
John Hubbard <jhubbard@nvidia.com>,
Alistair Popple <apopple@nvidia.com>,
Timur Tabi <ttabi@nvidia.com>,
Eliot Courtney <ecourtney@nvidia.com>,
Zhi Wang <zhiw@nvidia.com>
Cc: nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
Alexandre Courbot <acourbot@nvidia.com>
Subject: [PATCH v3 11/12] gpu: nova-core: gsp: pass GspBootContext mutably
Date: Mon, 29 Jun 2026 21:31:54 +0900 [thread overview]
Message-ID: <20260629-nova-bootcontext-v3-11-26cb29ee8dee@nvidia.com> (raw)
In-Reply-To: <20260629-nova-bootcontext-v3-0-26cb29ee8dee@nvidia.com>
We want to move the `Fsp` instance into `Gpu`, which will require
passing it as a mutable reference in `GspBootContext`, since
`Fsp::boot_fmc` is a mutable method. In order to use the mutable
references it contains, `GspBootContext` must also be mutable.
We will also follow up by making some methods of the `Falcon`s mutable,
which also requires passing them as mutable references.
Thus, make the `GspBootContext` passed to `Gsp::boot` and `Gsp::unload`
mutable, and pass mutable references to it to the GSP boot HAL methods.
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
drivers/gpu/nova-core/gsp/boot.rs | 28 +++++++++++++++-------------
drivers/gpu/nova-core/gsp/hal.rs | 11 ++++++++---
drivers/gpu/nova-core/gsp/hal/gh100.rs | 4 ++--
drivers/gpu/nova-core/gsp/hal/tu102.rs | 6 +++---
4 files changed, 28 insertions(+), 21 deletions(-)
diff --git a/drivers/gpu/nova-core/gsp/boot.rs b/drivers/gpu/nova-core/gsp/boot.rs
index 5f11c8e10a0a..dce07878449e 100644
--- a/drivers/gpu/nova-core/gsp/boot.rs
+++ b/drivers/gpu/nova-core/gsp/boot.rs
@@ -39,7 +39,7 @@ impl super::Gsp {
/// [`Self::unload`]) returned.
pub(crate) fn boot(
self: Pin<&mut Self>,
- ctx: super::GspBootContext<'_>,
+ mut ctx: super::GspBootContext<'_>,
) -> Result<Option<super::UnloadBundle>> {
let pdev = ctx.pdev;
let bar = ctx.bar;
@@ -56,21 +56,23 @@ pub(crate) fn boot(
let wpr_meta = Coherent::init(dev, GFP_KERNEL, GspFwWprMeta::new(&gsp_fw, &fb_layout))?;
// Perform the chipset-specific boot sequence, and retrieve the unload bundle.
- let unload_bundle = hal.boot(&self, &ctx, &fb_layout, &wpr_meta)?.or_else(|| {
- 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"
- );
+ let unload_bundle = hal
+ .boot(&self, &mut ctx, &fb_layout, &wpr_meta)?
+ .or_else(|| {
+ 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"
+ );
- None
- });
+ None
+ });
- let unload_guard =
+ let mut unload_guard =
ScopeGuard::new_with_data((ctx, unload_bundle), |(ctx, unload_bundle)| {
let _ = self.unload(ctx, unload_bundle);
});
- let ctx = &unload_guard.0;
+ let ctx = &mut unload_guard.0;
gsp_falcon.write_os_version(bar, gsp_fw.bootloader.app_version);
@@ -123,7 +125,7 @@ fn shutdown_gsp(
/// This stops all activity on the GSP.
pub(crate) fn unload(
&self,
- ctx: super::GspBootContext<'_>,
+ mut ctx: super::GspBootContext<'_>,
unload_bundle: Option<super::UnloadBundle>,
) -> Result {
let dev = ctx.dev();
@@ -142,7 +144,7 @@ pub(crate) fn unload(
res = res.and(
unload_bundle
.0
- .run(&ctx)
+ .run(&mut ctx)
.inspect_err(|e| dev_err!(dev, "Unload bundle failed: {:?}\n", e)),
);
} else {
diff --git a/drivers/gpu/nova-core/gsp/hal.rs b/drivers/gpu/nova-core/gsp/hal.rs
index 90f076f640e0..a5d0da05ef5f 100644
--- a/drivers/gpu/nova-core/gsp/hal.rs
+++ b/drivers/gpu/nova-core/gsp/hal.rs
@@ -29,7 +29,7 @@
/// required for unloading is prepared at load time, and stored here until it needs to be run.
pub(super) trait UnloadBundle: Send {
/// Performs the steps required to properly reset the GSP after it has been stopped.
- fn run(&self, ctx: &GspBootContext<'_>) -> Result;
+ fn run(&self, ctx: &mut GspBootContext<'_>) -> Result;
}
/// Trait implemented by GSP HALs.
@@ -41,7 +41,7 @@ pub(super) trait GspHal: Send {
fn boot(
&self,
gsp: &Gsp,
- ctx: &GspBootContext<'_>,
+ ctx: &mut GspBootContext<'_>,
fb_layout: &FbLayout,
wpr_meta: &Coherent<GspFwWprMeta>,
) -> Result<Option<crate::gsp::UnloadBundle>>;
@@ -50,7 +50,12 @@ fn boot(
///
/// This method is called by the GSP boot code after the GSP is confirmed to be running, and
/// after the initialization commands have been pushed onto its queue.
- fn post_boot(&self, _gsp: &Gsp, _ctx: &GspBootContext<'_>, _gsp_fw: &GspFirmware) -> Result {
+ fn post_boot(
+ &self,
+ _gsp: &Gsp,
+ _ctx: &mut GspBootContext<'_>,
+ _gsp_fw: &GspFirmware,
+ ) -> Result {
Ok(())
}
}
diff --git a/drivers/gpu/nova-core/gsp/hal/gh100.rs b/drivers/gpu/nova-core/gsp/hal/gh100.rs
index 8dfbc402c13b..a617b8f5974f 100644
--- a/drivers/gpu/nova-core/gsp/hal/gh100.rs
+++ b/drivers/gpu/nova-core/gsp/hal/gh100.rs
@@ -117,7 +117,7 @@ fn wait_for_gsp_lockdown_release(
struct FspUnloadBundle;
impl UnloadBundle for FspUnloadBundle {
- fn run(&self, ctx: &GspBootContext<'_>) -> Result {
+ fn run(&self, ctx: &mut GspBootContext<'_>) -> Result {
// GSP falcon does most of the work of resetting, so just wait for it to finish.
read_poll_timeout(
|| Ok(ctx.gsp_falcon.is_riscv_active(ctx.bar)),
@@ -140,7 +140,7 @@ impl GspHal for Gh100 {
fn boot(
&self,
gsp: &Gsp,
- ctx: &GspBootContext<'_>,
+ ctx: &mut GspBootContext<'_>,
fb_layout: &FbLayout,
wpr_meta: &Coherent<GspFwWprMeta>,
) -> Result<Option<crate::gsp::UnloadBundle>> {
diff --git a/drivers/gpu/nova-core/gsp/hal/tu102.rs b/drivers/gpu/nova-core/gsp/hal/tu102.rs
index 6a114f696c22..305515ef2700 100644
--- a/drivers/gpu/nova-core/gsp/hal/tu102.rs
+++ b/drivers/gpu/nova-core/gsp/hal/tu102.rs
@@ -78,7 +78,7 @@ struct Sec2UnloadBundle {
}
impl UnloadBundle for Sec2UnloadBundle {
- fn run(&self, ctx: &GspBootContext<'_>) -> Result {
+ fn run(&self, ctx: &mut GspBootContext<'_>) -> Result {
let dev = ctx.dev();
let bar = ctx.bar;
@@ -264,7 +264,7 @@ impl GspHal for Tu102 {
fn boot(
&self,
gsp: &Gsp,
- ctx: &GspBootContext<'_>,
+ ctx: &mut GspBootContext<'_>,
fb_layout: &FbLayout,
wpr_meta: &Coherent<GspFwWprMeta>,
) -> Result<Option<crate::gsp::UnloadBundle>> {
@@ -324,7 +324,7 @@ fn boot(
Ok(unload_guard.dismiss())
}
- fn post_boot(&self, gsp: &Gsp, ctx: &GspBootContext<'_>, gsp_fw: &GspFirmware) -> Result {
+ fn post_boot(&self, gsp: &Gsp, ctx: &mut GspBootContext<'_>, gsp_fw: &GspFirmware) -> Result {
GspSequencer::run(
&gsp.cmdq,
ctx,
--
2.54.0
next prev parent reply other threads:[~2026-06-29 12:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 12:31 [PATCH v3 00/12] gpu: nova-core: consolidate and streamline GSP boot process Alexandre Courbot
2026-06-29 12:31 ` [PATCH v3 01/12] gpu: nova-core: gsp: sequencer: use GspBootContext Alexandre Courbot
2026-06-29 12:31 ` [PATCH v3 02/12] gpu: nova-core: gsp: sequencer: do not store sequence into GspSequencer Alexandre Courbot
2026-06-29 12:31 ` [PATCH v3 03/12] gpu: nova-core: gsp: replace BootUnloadGuard with local handlers Alexandre Courbot
2026-06-29 12:31 ` [PATCH v3 04/12] gpu: nova-core: gsp: pass GspBootContext to unload methods Alexandre Courbot
2026-06-29 12:31 ` [PATCH v3 05/12] gpu: nova-core: gsp: centralize missing unload bundle warnings Alexandre Courbot
2026-06-29 12:31 ` [PATCH v3 06/12] gpu: nova-core: gsp: fold TU102 unload bundle construction into HAL method Alexandre Courbot
2026-06-29 12:31 ` [PATCH v3 07/12] gpu: nova-core: gsp: turn FWSEC execution " Alexandre Courbot
2026-06-29 12:31 ` [PATCH v3 08/12] gpu: nova-core: gsp: make use of FWSEC bootloader a property of the TU102 HAL Alexandre Courbot
2026-06-29 12:31 ` [PATCH v3 09/12] gpu: nova-core: introduce GspBootMethod Alexandre Courbot
2026-06-29 12:31 ` [PATCH v3 10/12] gpu: nova-core: avoid repeated calls to pci::Device::as_ref Alexandre Courbot
2026-06-29 12:31 ` Alexandre Courbot [this message]
2026-06-29 12:31 ` [PATCH v3 12/12] gpu: nova-core: store Fsp instance in Gpu Alexandre Courbot
2026-06-29 13:05 ` [PATCH v3 00/12] gpu: nova-core: consolidate and streamline GSP boot process Alexandre Courbot
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=20260629-nova-bootcontext-v3-11-26cb29ee8dee@nvidia.com \
--to=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=apopple@nvidia.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=ecourtney@nvidia.com \
--cc=gary@garyguo.net \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nova-gpu@lists.linux.dev \
--cc=rust-for-linux@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=ttabi@nvidia.com \
--cc=zhiw@nvidia.com \
/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