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=1796180707; b=kJeiHaSgbUDaNG4kOHMDXXZdRecah2ki4j4/wP5o5Zw5yXG8QW41ixiQIzhbgOCcquMO qMRyq6QUlE0/ksAzy4cJYxOQr8eeJH/V5WURCFJUR7u1v2PdKBUoPucVKioU5OmC/ZCfG 55aB3PuELrClj3rnWcQKfPR4m7jzlYC63K7JctB0XdZfE5Gcr/ceGTnbDnbknqyHKr5I6 3wwcIn1TQFEu6Yz2amjJwdSXF+8oKt1DYjo4XFEVgquhpGPD2G8ERBXEdzVY36KMeDG/7 A0r3Xgg/Wa5rzGVwPOW6p08Ag2lWyBHIQLXquc4PMkka+tzhpbzglejPvU9dzqcfPXw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796180707; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=IwZOrghJSQU2K11UHjl1C7HMLukehWvKVT4nXwSz3LY=; b=mu3TTD+0NIxlUA7ITKrMecjL+fRFP/M+fmzZ6DYnq9o4VynppYu6V/4h5FJr7ziQGCEe pDExBSPYTTJMxJ0dwS91Fs612+YdKANIZ016YryZy6lDZlZfTEa2J8q/iJNcht8/6nS3K JK5gsNYkITgn0rYtPyoyZyfAYYNfxIac0XP7sSsJkAM6sw1hPOQFDc6zTbzt/sTmF0on/ GEiBoS85OVuEeJ+KTcAKxFXP2IGIJeAV2NaJ+VH9i+UAAmp9bNZ3wGI5/zOc6spuC6KKK R9UBc5MaH/EKjqVwsbcVzM6BBB1mQOeXWyU7swEVKv2hgXCGXosC7q+TD2cBAGg29SQ== 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="cCZHu/f5"; 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 E12F3606A322 for ; Wed, 2 Dec 2026 03:05:06 +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=cCZHu/f5 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 341C31F00896; Wed, 2 Dec 2026 03:05:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796180706; bh=IwZOrghJSQU2K11UHjl1C7HMLukehWvKVT4nXwSz3LY=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=cCZHu/f5Q8gkj/mxdGsnwP+hF8BgmXMIRJ9S8qWGeozGtEwNaRQi1jEBnI6SzWTFl hnA3WaWbtkKlDJjxqc0TPtVPHMW9FutEvZST1mGzxFSKoK/LRPhBE61jkcca2iFnlv 7igUe71Hp++SeVD9Wn24F8g70DLsbXu/Mb4974vZBPJkb3RFTbWtlOsL3A28Gp/ypl hsdO8X0zMx4AekahwnBNjoctbmaa6Ixw4uZdRIBQy8fTQ9pgOPCJDjx10acsHFYOuL qiWNhLAKKtN9Wo3UmfXmnioHIu27v0w2qOEYptC2bLDkd8DqFtwdtIMehF9wlVVW1Y QzDkdZwA+4Ypg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RFC PATCH v2] gpu: nova-core: gsp: retain debugfs logs on teardown and capture logpmu Reply-To: sashiko-reviews@lists.linux.dev To: =?utf-8?b?QWd1c3TDrW4gUGVyZWlyYQ==?= , "Danilo Krummrich" , "Alexandre Courbot" Cc: "David Airlie" , "Simona Vetter" , "Miguel Ojeda" , nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org, gary@garyguo.net In-Reply-To: <20261202025028.43497-1-agustin.pereira.ro@gmail.com> References: <20261202025028.43497-1-agustin.pereira.ro@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 03:05:05 +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 1 potential issue to consider: - [Medium] gpu: nova-core: skipped DebugfsRootGuard cleanup in NovaCoreModule::init() -- commit 1dbb3872186b6930edbf1c3b16aa11754d3182d1 Author: Agust=C3=ADn Pereira gpu: nova-core: gsp: retain debugfs logs on teardown and capture logpmu This commit captures PMU UCODE_LIBOS_PRINT events into a debugfs logpmu buffer and adds a keep_gsp_logging module parameter to retain snapshots of non-empty GSP debugfs log buffers after probe failures or device unbind. > diff --git a/drivers/gpu/nova-core/nova_core.rs b/drivers/gpu/nova-core/n= ova_core.rs > index a8f6dc22057be..f182ebb6b928f 100644 > --- a/drivers/gpu/nova-core/nova_core.rs > +++ b/drivers/gpu/nova-core/nova_core.rs > @@ -35,11 +35,53 @@ > // TODO: Move this into per-module data once that exists. > static mut DEBUGFS_ROOT: Option =3D None; [ ... ] > +/// Guard that clears retained logs and `DEBUGFS_ROOT` when dropped. > struct DebugfsRootGuard; > =20 > impl Drop for DebugfsRootGuard { > fn drop(&mut self) { > + // Drop retained `debugfs` scopes and free the `KVec` backing al= location > + // before removing `DEBUGFS_ROOT`. > + *RETAINED_LOGS.lock() =3D KVec::new(); > + > // SAFETY: This guard is dropped after `_driver` (due to field o= rder), > // so the driver is unregistered and no probe() can be running. > unsafe { DEBUGFS_ROOT =3D None }; > @@ -49,7 +91,7 @@ fn drop(&mut self) { > #[pin_data] > struct NovaCoreModule { > // Fields are dropped in declaration order, so `_driver` is dropped = first, > - // then `_debugfs_guard` clears `DEBUGFS_ROOT`. > + // then `_debugfs_guard` clears retained logs and `DEBUGFS_ROOT`. > #[pin] > _driver: Registration>, > _debugfs_guard: DebugfsRootGuard, > @@ -59,6 +101,10 @@ impl InPlaceModule for NovaCoreModule { > fn init(module: &'static kernel::ThisModule) -> impl PinInit { > let dir =3D debugfs::Dir::new(c"nova-core"); > =20 > + // SAFETY: We are the only driver code running during init, so `= RETAINED_LOGS` > + // is initialized exactly once before any driver callback can ac= cess it. > + unsafe { RETAINED_LOGS.init() }; > + > // SAFETY: We are the only driver code running during init, so t= here > // cannot be any concurrent access to `DEBUGFS_ROOT`. > unsafe { DEBUGFS_ROOT =3D Some(dir) }; [Severity: Medium] Does this leak RETAINED_LOGS and DEBUGFS_ROOT if Registration::new() fails in NovaCoreModule::init()? try_pin_init! runs field initializers in the order they appear in the initializer block and only drops fields that have already been initialized: drivers/gpu/nova-core/nova_core.rs:NovaCoreModule::init() { ... try_pin_init!(Self { _driver <- Registration::new(MODULE_NAME, module), _debugfs_guard: DebugfsRootGuard, }) } Because _driver is initialized before _debugfs_guard, an error from Registration::new() returns before DebugfsRootGuard is constructed, so DebugfsRootGuard::drop() never runs. Any RetainedLogEntry pushed into RETAINED_LOGS during synchronous probing in bus_add_driver() before registration fails (along with DEBUGFS_ROOT itself) will be leaked and its debugfs entries will remain dangling under /sys/kernel/debug/nova-core. Initializing _debugfs_guard before _driver inside try_pin_init! (while keeping the struct field declaration order unchanged for module unload) ensures DebugfsRootGuard::drop() runs if Registration::new() fails. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202025028.4349= 7-1-agustin.pereira.ro@gmail.com?part=3D1