Re: [PATCH 09/15] gpu: nova-core: gsp: drain the message queue while waiting for GSP suspend

From: Eliot Courtney

Date: Thu Dec 03 2026 - 23:33:36 EST


On Thu Dec 3, 2026 at 9:09 PM JST, Alexandre Courbot wrote:
> From: John Hubbard <jhubbard@xxxxxxxxxx>
>
> Unlike r570's UnloadingGuestDriver RPC, which GSP-RM answers only once
> it is ready to suspend, r000's GSP_SUSPEND command has no reply, and
> GSP-RM posts messages while tearing down. Because the GSP event
> interrupt is already unregistered before unload(), nothing drains the
> queue during the wait for the RISC-V core to suspend.
>
> Drain the message queue on each poll iteration of shutdown_gsp(). On
> r570, drain() returns immediately when no message is pending and
> consumes any trailing events posted after the UnloadingGuestDriver
> reply.
>
> Signed-off-by: John Hubbard <jhubbard@xxxxxxxxxx>
> Signed-off-by: Alexandre Courbot <acourbot@xxxxxxxxxx>
> ---
> drivers/gpu/nova-core/gsp/boot.rs | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/nova-core/gsp/boot.rs b/drivers/gpu/nova-core/gsp/boot.rs
> index 2904f1ac7459..fb474e5984a8 100644
> --- a/drivers/gpu/nova-core/gsp/boot.rs
> +++ b/drivers/gpu/nova-core/gsp/boot.rs
> @@ -106,8 +106,19 @@ fn shutdown_gsp(
> // Command to shut the GSP down.
> cmdq.send_rpc_command(commands::rpc::UnloadingGuestDriver::new(mode))?;
>
> - // Wait until GSP signals it is suspended.
> - gsp_falcon.wait_for_processor_suspend()
> + // Wait until GSP signals it is suspended. GSP-RM posts messages while it suspends, and the
> + // GSP event interrupt is already freed, so this poll drains them.
> + read_poll_timeout(
> + || {
> + cmdq.drain()?;

not for this patch, but we might consider adding a timeout to drain() to
handle a misbehaving firmware or something

Reviewed-by: Eliot Courtney <ecourtney@xxxxxxxxxx>