Skip to content

Commit 7741098

Browse files
Joel FernandesGnurou
authored andcommitted
gpu: nova-core: sequencer: Implement core resume operation
Implement core resume operation. This is the last step of the sequencer resulting in resume of the GSP and proceeding to INIT_DONE stage of GSP boot. Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com> Reviewed-by: Lyude Paul <lyude@redhat.com> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com> Message-ID: <20251114195552.739371-12-joelagnelf@nvidia.com>
1 parent 9641f05 commit 7741098

2 files changed

Lines changed: 42 additions & 3 deletions

File tree

drivers/gpu/nova-core/falcon/gsp.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ impl Falcon<Gsp> {
4545
}
4646

4747
/// Checks if GSP reload/resume has completed during the boot process.
48-
#[expect(dead_code)]
4948
pub(crate) fn check_reload_completed(&self, bar: &Bar0, timeout: Delta) -> Result<bool> {
5049
read_poll_timeout(
5150
|| Ok(regs::NV_PGC6_BSI_SECURE_SCRATCH_14::read(bar)),

drivers/gpu/nova-core/gsp/sequencer.rs

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ pub(crate) enum GspSeqCmd {
7979
CoreReset,
8080
CoreStart,
8181
CoreWaitForHalt,
82+
CoreResume,
8283
}
8384

8485
impl GspSeqCmd {
@@ -116,7 +117,7 @@ impl GspSeqCmd {
116117
fw::SeqBufOpcode::CoreReset => (GspSeqCmd::CoreReset, opcode_size),
117118
fw::SeqBufOpcode::CoreStart => (GspSeqCmd::CoreStart, opcode_size),
118119
fw::SeqBufOpcode::CoreWaitForHalt => (GspSeqCmd::CoreWaitForHalt, opcode_size),
119-
_ => return Err(EINVAL),
120+
fw::SeqBufOpcode::CoreResume => (GspSeqCmd::CoreResume, opcode_size),
120121
};
121122

122123
if data.len() < size {
@@ -129,7 +130,6 @@ impl GspSeqCmd {
129130
}
130131

131132
/// GSP Sequencer for executing firmware commands during boot.
132-
#[expect(dead_code)]
133133
pub(crate) struct GspSequencer<'a> {
134134
/// Sequencer information with command data.
135135
seq_info: GspSequence,
@@ -233,6 +233,46 @@ impl GspSeqCmdRunner for GspSeqCmd {
233233
seq.gsp_falcon.wait_till_halted(seq.bar)?;
234234
Ok(())
235235
}
236+
GspSeqCmd::CoreResume => {
237+
// At this point, 'SEC2-RTOS' has been loaded into SEC2 by the sequencer
238+
// but neither SEC2-RTOS nor GSP-RM is running yet. This part of the
239+
// sequencer will start both.
240+
241+
// Reset the GSP to prepare it for resuming.
242+
seq.gsp_falcon.reset(seq.bar)?;
243+
244+
// Write the libOS DMA handle to GSP mailboxes.
245+
seq.gsp_falcon.write_mailboxes(
246+
seq.bar,
247+
Some(seq.libos_dma_handle as u32),
248+
Some((seq.libos_dma_handle >> 32) as u32),
249+
);
250+
251+
// Start the SEC2 falcon which will trigger GSP-RM to resume on the GSP.
252+
seq.sec2_falcon.start(seq.bar)?;
253+
254+
// Poll until GSP-RM reload/resume has completed (up to 2 seconds).
255+
seq.gsp_falcon
256+
.check_reload_completed(seq.bar, Delta::from_secs(2))?;
257+
258+
// Verify SEC2 completed successfully by checking its mailbox for errors.
259+
let mbox0 = seq.sec2_falcon.read_mailbox0(seq.bar);
260+
if mbox0 != 0 {
261+
dev_err!(seq.dev, "Sequencer: sec2 errors: {:?}\n", mbox0);
262+
return Err(EIO);
263+
}
264+
265+
// Configure GSP with the bootloader version.
266+
seq.gsp_falcon
267+
.write_os_version(seq.bar, seq.bootloader_app_version);
268+
269+
// Verify the GSP's RISC-V core is active indicating successful GSP boot.
270+
if !seq.gsp_falcon.is_riscv_active(seq.bar) {
271+
dev_err!(seq.dev, "Sequencer: RISC-V core is not active\n");
272+
return Err(EIO);
273+
}
274+
Ok(())
275+
}
236276
}
237277
}
238278
}

0 commit comments

Comments
 (0)