Skip to content

Commit 0e7d572

Browse files
apopple-nvidiaGnurou
authored andcommitted
gpu: nova-core: gsp: Wait for gsp initialization to complete
This adds the GSP init done command to wait for GSP initialization to complete. Once this command has been received the GSP is fully operational and will respond properly to normal RPC commands. Signed-off-by: Alistair Popple <apopple@nvidia.com> Co-developed-by: Joel Fernandes <joelagnelf@nvidia.com> Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com> Reviewed-by: Lyude Paul <lyude@redhat.com> [acourbot@nvidia.com: move new definitions to end of commands.rs, rename to `wait_gsp_init_done` and remove timeout argument.] Signed-off-by: Alexandre Courbot <acourbot@nvidia.com> Message-ID: <20251114195552.739371-13-joelagnelf@nvidia.com>
1 parent 7741098 commit 0e7d572

2 files changed

Lines changed: 48 additions & 3 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,9 @@ impl super::Gsp {
236236
};
237237
GspSequencer::run(&mut self.cmdq, seq_params)?;
238238

239+
// Wait until GSP is fully initialized.
240+
commands::wait_gsp_init_done(&mut self.cmdq)?;
241+
239242
Ok(())
240243
}
241244
}

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

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
// SPDX-License-Identifier: GPL-2.0
22

3-
use core::convert::Infallible;
3+
use core::{
4+
array,
5+
convert::Infallible, //
6+
};
47

58
use kernel::{
69
device,
710
pci,
811
prelude::*,
9-
transmute::AsBytes, //
12+
time::Delta,
13+
transmute::{
14+
AsBytes,
15+
FromBytes, //
16+
}, //
1017
};
1118

1219
use crate::{
1320
gsp::{
14-
cmdq::CommandToGsp,
21+
cmdq::{
22+
Cmdq,
23+
CommandToGsp,
24+
MessageFromGsp, //
25+
},
1526
fw::{
1627
commands::*,
1728
MsgFunction, //
@@ -127,3 +138,34 @@ impl CommandToGsp for SetRegistry {
127138
dst.write_all(string_data.as_slice())
128139
}
129140
}
141+
142+
/// Message type for GSP initialization done notification.
143+
struct GspInitDone {}
144+
145+
// SAFETY: `GspInitDone` is a zero-sized type with no bytes, therefore it
146+
// trivially has no uninitialized bytes.
147+
unsafe impl FromBytes for GspInitDone {}
148+
149+
impl MessageFromGsp for GspInitDone {
150+
const FUNCTION: MsgFunction = MsgFunction::GspInitDone;
151+
type InitError = Infallible;
152+
type Message = GspInitDone;
153+
154+
fn read(
155+
_msg: &Self::Message,
156+
_sbuffer: &mut SBufferIter<array::IntoIter<&[u8], 2>>,
157+
) -> Result<Self, Self::InitError> {
158+
Ok(GspInitDone {})
159+
}
160+
}
161+
162+
/// Waits for GSP initialization to complete.
163+
pub(crate) fn wait_gsp_init_done(cmdq: &mut Cmdq) -> Result {
164+
loop {
165+
match cmdq.receive_msg::<GspInitDone>(Delta::from_secs(10)) {
166+
Ok(_) => break Ok(()),
167+
Err(ERANGE) => continue,
168+
Err(e) => break Err(e),
169+
}
170+
}
171+
}

0 commit comments

Comments
 (0)