All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Hubbard <jhubbard@nvidia.com>
To: Danilo Krummrich <dakr@kernel.org>,
	Alexandre Courbot <acourbot@nvidia.com>
Cc: "Timur Tabi" <ttabi@nvidia.com>,
	"Alistair Popple" <apopple@nvidia.com>,
	"Eliot Courtney" <ecourtney@nvidia.com>,
	"Zhi Wang" <zhiw@nvidia.com>, "David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Daniel Almeida" <daniel.almeida@collabora.com>,
	"Tamir Duberstein" <tamird@kernel.org>,
	"Onur Özkan" <work@onurozkan.dev>,
	nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org,
	LKML <linux-kernel@vger.kernel.org>,
	linux-pci@vger.kernel.org, rust-for-linux@vger.kernel.org,
	"John Hubbard" <jhubbard@nvidia.com>
Subject: [PATCH 4/9] gpu: nova-core: gsp: factor out the core reset and the core resume
Date: Thu, 19 Nov 2026 20:46:59 -0800	[thread overview]
Message-ID: <20261120044704.165223-5-jhubbard@nvidia.com> (raw)
In-Reply-To: <20261120044704.165223-1-jhubbard@nvidia.com>

The r000 boot protocol requires the driver to reset the GSP falcon
before running the binary of a load-and-execute event, and to resume
GSP-RM afterwards. The core reset and the core resume commands of the
CPU sequencer already do both.

In order to make the core reset and the core resume available outside
the sequencer, factor them out of it, into a module of their own.

No functional changes.

Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
 drivers/gpu/nova-core/gsp.rs           |  1 +
 drivers/gpu/nova-core/gsp/load_exec.rs | 78 ++++++++++++++++++++++++++
 drivers/gpu/nova-core/gsp/sequencer.rs | 48 +++-------------
 3 files changed, 88 insertions(+), 39 deletions(-)
 create mode 100644 drivers/gpu/nova-core/gsp/load_exec.rs

diff --git a/drivers/gpu/nova-core/gsp.rs b/drivers/gpu/nova-core/gsp.rs
index 2f1cdf8b7bec..854062112cf1 100644
--- a/drivers/gpu/nova-core/gsp.rs
+++ b/drivers/gpu/nova-core/gsp.rs
@@ -20,6 +20,7 @@
 pub(crate) mod cmdq;
 pub(crate) mod commands;
 mod fw;
+mod load_exec;
 mod logbuffer;
 mod nvkv;
 mod regs;
diff --git a/drivers/gpu/nova-core/gsp/load_exec.rs b/drivers/gpu/nova-core/gsp/load_exec.rs
new file mode 100644
index 000000000000..ccbfcbfe3ce5
--- /dev/null
+++ b/drivers/gpu/nova-core/gsp/load_exec.rs
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+
+//! The core reset and the core resume of the GSP falcon.
+
+use kernel::{
+    device,
+    dma::DmaAddress,
+    prelude::*,
+    time::Delta, //
+};
+
+use crate::falcon::{
+    gsp::Gsp,
+    sec2::Sec2,
+    Falcon, //
+};
+
+/// Resets the GSP falcon and its DMA-related registers.
+pub(super) fn reset_gsp_falcon(gsp_falcon: &Falcon<'_, Gsp>) -> Result {
+    gsp_falcon.reset()?;
+    gsp_falcon.dma_reset();
+    Ok(())
+}
+
+/// Resumes GSP-RM on the GSP falcon by starting the SEC2 falcon.
+///
+/// Resets the GSP falcon and writes `libos_dma_address` to its mailboxes before the start, and
+/// writes `bootloader_app_version` to its OS register once the resume has completed.
+///
+/// The SEC2 falcon must hold a loaded firmware that has not started.
+///
+/// # Errors
+///
+/// - `ETIMEDOUT` if the resume has not completed within two seconds.
+/// - `EIO` if `MAILBOX0` of the SEC2 falcon is not zero after the resume, or if the RISC-V core of
+///   the GSP falcon is not active.
+///
+/// Errors from the reset of the GSP falcon are propagated as-is.
+pub(super) fn resume_gsp_rm(
+    dev: &device::Device,
+    gsp_falcon: &Falcon<'_, Gsp>,
+    sec2_falcon: &Falcon<'_, Sec2>,
+    libos_dma_address: DmaAddress,
+    bootloader_app_version: u32,
+) -> Result {
+    // Reset the GSP to prepare it for resuming.
+    gsp_falcon.reset()?;
+
+    // Write the libOS DMA address to GSP mailboxes.
+    gsp_falcon.write_mailboxes(
+        Some(libos_dma_address as u32),
+        Some((libos_dma_address >> 32) as u32),
+    );
+
+    // Start the SEC2 falcon which will trigger GSP-RM to resume on the GSP.
+    sec2_falcon.start()?;
+
+    // Poll until GSP-RM reload/resume has completed (up to 2 seconds).
+    gsp_falcon.check_reload_completed(Delta::from_secs(2))?;
+
+    // Verify SEC2 completed successfully by checking its mailbox for errors.
+    let mbox0 = sec2_falcon.read_mailbox0();
+    if mbox0 != 0 {
+        dev_err!(dev, "Sequencer: sec2 errors: {:?}\n", mbox0);
+        return Err(EIO);
+    }
+
+    // Configure GSP with the bootloader version.
+    gsp_falcon.write_os_version(bootloader_app_version);
+
+    // Verify the GSP's RISC-V core is active indicating successful GSP boot.
+    if !gsp_falcon.is_riscv_active() {
+        dev_err!(dev, "Sequencer: RISC-V core is not active\n");
+        return Err(EIO);
+    }
+    Ok(())
+}
diff --git a/drivers/gpu/nova-core/gsp/sequencer.rs b/drivers/gpu/nova-core/gsp/sequencer.rs
index 23b09fb875e9..913989cd7615 100644
--- a/drivers/gpu/nova-core/gsp/sequencer.rs
+++ b/drivers/gpu/nova-core/gsp/sequencer.rs
@@ -32,6 +32,7 @@
             Cmdq, //
         },
         fw,
+        load_exec,
         GspBootContext,
         LibosMemoryRegionInitArgument, //
     },
@@ -213,11 +214,7 @@ fn run(&self, seq: &GspSequencer<'_>) -> Result {
             GspSeqCmd::RegPoll(cmd) => cmd.run(seq),
             GspSeqCmd::DelayUs(cmd) => cmd.run(seq),
             GspSeqCmd::RegStore(cmd) => cmd.run(seq),
-            GspSeqCmd::CoreReset => {
-                seq.gsp_falcon.reset()?;
-                seq.gsp_falcon.dma_reset();
-                Ok(())
-            }
+            GspSeqCmd::CoreReset => load_exec::reset_gsp_falcon(seq.gsp_falcon),
             GspSeqCmd::CoreStart => {
                 seq.gsp_falcon.start()?;
                 Ok(())
@@ -230,40 +227,13 @@ fn run(&self, seq: &GspSequencer<'_>) -> Result {
                 // At this point, 'SEC2-RTOS' has been loaded into SEC2 by the sequencer
                 // but neither SEC2-RTOS nor GSP-RM is running yet. This part of the
                 // sequencer will start both.
-
-                // Reset the GSP to prepare it for resuming.
-                seq.gsp_falcon.reset()?;
-
-                let libos_dma_address = seq.libos.dma_address();
-
-                // Write the libOS DMA address to GSP mailboxes.
-                seq.gsp_falcon.write_mailboxes(
-                    Some(libos_dma_address as u32),
-                    Some((libos_dma_address >> 32) as u32),
-                );
-
-                // Start the SEC2 falcon which will trigger GSP-RM to resume on the GSP.
-                seq.sec2_falcon.start()?;
-
-                // Poll until GSP-RM reload/resume has completed (up to 2 seconds).
-                seq.gsp_falcon.check_reload_completed(Delta::from_secs(2))?;
-
-                // Verify SEC2 completed successfully by checking its mailbox for errors.
-                let mbox0 = seq.sec2_falcon.read_mailbox0();
-                if mbox0 != 0 {
-                    dev_err!(seq.dev, "Sequencer: sec2 errors: {:?}\n", mbox0);
-                    return Err(EIO);
-                }
-
-                // Configure GSP with the bootloader version.
-                seq.gsp_falcon.write_os_version(seq.bootloader_app_version);
-
-                // Verify the GSP's RISC-V core is active indicating successful GSP boot.
-                if !seq.gsp_falcon.is_riscv_active() {
-                    dev_err!(seq.dev, "Sequencer: RISC-V core is not active\n");
-                    return Err(EIO);
-                }
-                Ok(())
+                load_exec::resume_gsp_rm(
+                    seq.dev,
+                    seq.gsp_falcon,
+                    seq.sec2_falcon,
+                    seq.libos.dma_address(),
+                    seq.bootloader_app_version,
+                )
             }
         }
     }
-- 
2.56.1


  parent reply	other threads:[~2026-11-20  4:47 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20  4:46 [PATCH 0/9] gpu: nova-core: run falcon binaries for the r000 GSP-RM John Hubbard
2026-11-20  4:46 ` [PATCH 1/9] rust: pci: add domain_nr() accessor John Hubbard
2026-11-20  4:54   ` sashiko-bot
2026-11-20  4:46 ` [PATCH 2/9] gpu: nova-core: falcon: factor out the wait for the GSP suspend John Hubbard
2026-11-20  4:49   ` sashiko-bot
2026-11-20  4:46 ` [PATCH 3/9] gpu: nova-core: falcon: factor out the BROM and BOOTVEC programming John Hubbard
2026-11-20  4:49   ` sashiko-bot
2026-11-20  4:46 ` John Hubbard [this message]
2026-11-20  4:49   ` [PATCH 4/9] gpu: nova-core: gsp: factor out the core reset and the core resume sashiko-bot
2026-11-20  4:47 ` [PATCH 5/9] gpu: nova-core: gsp: fix resume_gsp_rm()'s error messages John Hubbard
2026-11-20  4:49   ` sashiko-bot
2026-11-20  4:47 ` [PATCH 6/9] gpu: nova-core: falcon: select the BAR2 engine ID for framebuffer DMA John Hubbard
2026-11-20  4:53   ` sashiko-bot
2026-11-20  4:47 ` [PATCH 7/9] gpu: nova-core: gsp: add the r000 load-and-execute HS binary handler John Hubbard
2026-11-20  4:53   ` sashiko-bot
2026-11-20  4:47 ` [PATCH 8/9] gpu: nova-core: gsp: add the r000 load-and-execute bootloader handler John Hubbard
2026-11-20  4:52   ` sashiko-bot
2026-11-20  4:47 ` [PATCH 9/9] gpu: nova-core: gsp: add the load-and-execute event dispatcher John Hubbard
2026-11-20  4:51   ` sashiko-bot

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=20261120044704.165223-5-jhubbard@nvidia.com \
    --to=jhubbard@nvidia.com \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=apopple@nvidia.com \
    --cc=bhelgaas@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ecourtney@nvidia.com \
    --cc=gary@garyguo.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=nova-gpu@lists.linux.dev \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tamird@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=ttabi@nvidia.com \
    --cc=work@onurozkan.dev \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.