From: John Hubbard <[email protected]> The r000 boot protocol requires the driver to wait for the GSP suspend bit after each load-and-execute event, as the shutdown path already does.
In order to make the wait available to the boot sequence, factor it out of the shutdown path, into a method of the GSP falcon. No functional changes. Signed-off-by: John Hubbard <[email protected]> Reviewed-by: Eliot Courtney <[email protected]> Signed-off-by: Eliot Courtney <[email protected]> --- drivers/gpu/nova-core/falcon/gsp.rs | 15 +++++++++++++++ drivers/gpu/nova-core/gsp/boot.rs | 8 +------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/nova-core/falcon/gsp.rs b/drivers/gpu/nova-core/falcon/gsp.rs index 54247691b53c..2ea28fa53db8 100644 --- a/drivers/gpu/nova-core/falcon/gsp.rs +++ b/drivers/gpu/nova-core/falcon/gsp.rs @@ -54,6 +54,21 @@ pub(crate) fn is_processor_suspended(&self) -> bool { .processor_suspended() } + /// Waits until GSP-RM has suspended the RISC-V core. + /// + /// # Errors + /// + /// - `ETIMEDOUT` if the core has not suspended within five seconds. + pub(crate) fn wait_for_processor_suspend(&self) -> Result { + read_poll_timeout( + || Ok(self.is_processor_suspended()), + |suspended| *suspended, + Delta::from_millis(10), + Delta::from_secs(5), + ) + .map(|_| ()) + } + /// Clears the SWGEN0 latch in the GSP falcon. /// /// While the latch is set, no later message signals the tree, so a caller that consumed a diff --git a/drivers/gpu/nova-core/gsp/boot.rs b/drivers/gpu/nova-core/gsp/boot.rs index 9d5da5b165ac..2815fe8b306e 100644 --- a/drivers/gpu/nova-core/gsp/boot.rs +++ b/drivers/gpu/nova-core/gsp/boot.rs @@ -97,13 +97,7 @@ fn shutdown_gsp( cmdq.send_rpc_command(commands::rpc::UnloadingGuestDriver::new(mode))?; // Wait until GSP signals it is suspended. - read_poll_timeout( - || Ok(gsp_falcon.is_processor_suspended()), - |suspended| *suspended, - Delta::from_millis(10), - Delta::from_secs(5), - ) - .map(|_| ()) + gsp_falcon.wait_for_processor_suspend() } /// Attempts to unload the GSP firmware. -- 2.56.1
