From: John Hubbard <[email protected]>

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 <[email protected]>
Signed-off-by: Alexandre Courbot <[email protected]>
---
 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()?;
+
+                Ok(gsp_falcon.is_processor_suspended())
+            },
+            |suspended| *suspended,
+            Delta::from_millis(10),
+            Delta::from_secs(5),
+        )
+        .map(|_| ())
     }
 
     /// Attempts to unload the GSP firmware.

-- 
2.56.1

Reply via email to