Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796302563; b=C9G1zmGnqL7qneCYN9wRjGJ3v0TR69w9VRhqZ5I6iVFzhMMUo7sEO74cgaqiw77JmGoC hhz/J7vEYxWFDaxQGZTlYYvVCKT7tIhR7doWTilwhKjjDXsxVNt5hJp4E5lBO/Yz+Ld0q uVPiWkoKMqi15c4iKVIMVHYlmWqmc9+tVGvSqQI1HTQYss4gbW1aiGU5c40VcoFycx0K7 +/uRdHeniEwh17cLjAgyujqCyR3qI4x+H4zHgVMIp2QUpnWYCh5Yceem1Kj2nwYCLkrbj idmNs5lUXpCbf0j4+9zpZtqjLwKJy3QqefmY88E8HGO6f96Yaee8PAU6CTve8Y2oYNQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796302563; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=0UEX8lLlJNpYahbZ6rhz1tuVbA1Y71W1XLSxL6a2M7o=; b=oFrFP4bRCkC2Qzt36vvM92AVKKOoyHvMa9XKQDoRnFYlLRMTEndWOy3Pb+iTksR441YX DtigHx6aHBAxFsXnWLv1+bv8aLkMkmomXmFGemrPj7ih9X/G0L3s19M6pmT01yWyDfFis u3vSPUNz23ifJVG9b34Tpikec3gsZfY5FyH5UZxTtFjq5pSBFWSeb2Pj/lKEJAJ5uA3YA 6BEOnaWAvs+WDdBwlPREL/py8JOoxzepAXtoo/p1UteWPXWtSOV1gQTFJ3R+D7HZ2DoAT Or5kR3r5m4OiInmBbJ4nHkPbXmYJyKHLPYK7LyXmYV1sM3mxRLSJtsIAhIhDca8dSIw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NsJ2aaQd; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6CB7E606A332 for ; Thu, 3 Dec 2026 12:56:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NsJ2aaQd Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89EB21F000C1; Thu, 3 Dec 2026 12:56:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796302562; bh=0UEX8lLlJNpYahbZ6rhz1tuVbA1Y71W1XLSxL6a2M7o=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=NsJ2aaQd4Tc9uZNVWOeYUMeDXDjPpHeWuRP/vM/r2NJjaXzHoPypcodv4UuwNhW8+ JeWv5zeVXv4Nw5oPPHjDIpM6sjH9rNJ8JrphMC6XVXMoxJ5wb/Cw3oGuoIP52EVv8H UGz1vndcBgse5XF1MsUoTLllHcZBs+aWabd7G57IfYWxsq/Mtfeft5cTtzxvb4V9zP CbZXlbY9fGO0ckEP5N1ho9sfPm6jVFSOLR7Ops3D01rPyGZVpAqxrBKlrxfpPOKFLe ASs0JHAyz0DL4Kb46J3jRo6IZiLql3zfs99pTmYs04jvS05blSRDvjul84vZ7KgJ8Z dV4Ww73S1dQnw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 09/15] gpu: nova-core: gsp: drain the message queue while waiting for GSP suspend Reply-To: sashiko-reviews@lists.linux.dev To: "Alexandre Courbot" , "Danilo Krummrich" , "Alice Ryhl" , "David Airlie" , "Simona Vetter" , "Miguel Ojeda" , "Boqun Feng" , "Gary Guo" , =?utf-8?b?QmrDtnJuIFJveSBCYXJvbg==?= , "Benno Lossin" , "Andreas Hindborg" , "Trevor Gross" , "Daniel Almeida" , "Tamir Duberstein" , =?utf-8?b?T251ciDDlnprYW4=?= , "Maarten Lankhorst" , "Maxime Ripard" , "Thomas Zimmermann" , "Jonathan Corbet" , "Shuah Khan" , "Randy Dunlap" Cc: "John Hubbard" , "Alistair Popple" , "Timur Tabi" , "Eliot Courtney" , "Zhi Wang" , "Alok Kumar" , nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org In-Reply-To: <20261203-b4-r000-switch-v1-9-b1463ec6dae2@nvidia.com> References: <20261203-b4-r000-switch-v1-0-b1463ec6dae2@nvidia.com> <20261203-b4-r000-switch-v1-9-b1463ec6dae2@nvidia.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 12:56:01 +0000 X-Mailing-List: nova-gpu@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] gpu: nova-core: cmdq.drain() error aborts GSP suspend wait in shutdown_gsp() - [Medium] gpu: nova-core: unbounded cmdq.drain() bypasses shutdown_gsp() timeout - [Low] gpu: nova-core: drain before suspend check in shutdown_gsp() misses events -- commit 5a7f5b0b34f6ff35ede1c640685237ffd7e41f84 Author: John Hubbard gpu: nova-core: gsp: drain the message queue while waiting for GSP suspend This patch replaces wait_for_processor_suspend() in Gsp::shutdown_gsp() with a read_poll_timeout() loop that calls cmdq.drain() on each poll iteration while waiting for the GSP RISC-V core to suspend. > diff --git a/drivers/gpu/nova-core/gsp/boot.rs b/drivers/gpu/nova-core/gs= p/boot.rs > index 2904f1ac74593..fb474e5984a80 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(m= ode))?; > =20 > - // 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 the= m. > + read_poll_timeout( > + || { > + cmdq.drain()?; [Severity: Medium] Can an error from cmdq.drain() abort the suspend wait before the GSP stops? read_poll_timeout() exits immediately when the closure returns Err. If a malformed message is stuck at the queue head (as left by GspInterrupt::handle_threaded() after disabling the event IRQ), cmdq.drain() returns Err(EIO) and skips waiting for is_processor_suspended(). Gsp::unload() then immediately runs unload_bundle to reset the falcon while GSP-RM is still tearing down. If unload_bundle is None, GspResources::drop= () frees the coherent DMA buffers while the GSP may still be performing DMA. Logging the first drain error, skipping further drains, and continuing to poll is_processor_suspended() until suspend or timeout would avoid this. > + > + Ok(gsp_falcon.is_processor_suspended()) [Severity: Low] Does draining before checking is_processor_suspended() miss trailing events posted just before the GSP suspends? CPU GSP-RM cmdq.drain() (queue empty) post final teardown message set processor_suspended is_processor_suspended() =3D=3D true read_poll_timeout() returns <-- final message never drained Because Gsp::unload() resets the falcon right after without another drain, final diagnostic messages logged by RpcMessage::log() can be lost. Checking is_processor_suspended() before cmdq.drain() (or draining once more after read_poll_timeout() returns) closes this window. > + }, > + |suspended| *suspended, > + Delta::from_millis(10), > + Delta::from_secs(5), > + ) > + .map(|_| ()) [Severity: Medium] Can cmdq.drain() spin indefinitely here and bypass the 5-second timeout? CmdqInner::drain() loops with Delta::ZERO until the queue is empty, advancing cpu_read_ptr on each message with no deadline, message cap, or reschedule point. read_poll_timeout() only checks the timeout after the closure returns. If malfunctioning GSP firmware keeps posting messages during suspend, shutdown_gsp() hangs forever, preventing Gsp::unload() from running unload_bundle and risking a CPU soft lockup on non-preemptible kernels. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203-b4-r000-sw= itch-v1-0-b1463ec6dae2@nvidia.com?part=3D9