From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 16E17606A32C for ; Thu, 3 Dec 2026 12:56:16 +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: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 73C0C10E06B; Thu, 3 Dec 2026 12:56:10 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id D6AB210E06B for ; Thu, 3 Dec 2026 12:56:03 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 3192E60018; Thu, 3 Dec 2026 12:56:03 +0000 (UTC) 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 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-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "dri-devel" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: 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