From mboxrd@z Thu Jan 1 00:00:00 1970 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=1796482211; b=KFG4FViw3UNs5M9H14wy71TgPBsEtrD5t94vK35WQrNBjRh/1qYbH6po5ZOcogoyN2Gq zaqRnGim2/5M8Kc2hYQVK3ZXkJ5KBgUXm0dU/B8H+2a0OKOuscc/lOHKK7foYvzjVjIqi KZoI7VGRuRuTmJ/TvbFLxAxMPhhMaV+oRoieczPdGoGVnxH+fQqgtO3JfevVnSil+CTDQ EAxJUfghk2GDPcSJYtR5nan/uPADnFTHu9yuKE2BaNzd4i3uD4JWtUs1EzSyoZUsCQreG WfDF+NgltKg9vTElS4xAhhAdNZmQElcoS+DdS5eHGbdyRGToO9XBNqsJoAhbQrJfhNA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796482211; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=OzFDBWeBQ967fPEIGVFgqBvENwigXB9MhhEgk6dQjJ0=; b=tA7oM4Lrae1LniM0alR8TqWAwMeUnzQN4XnNf6OP/O446jjMb6Azz056rQqaWD+WpbJi XbmeUK9ow9GYC2T7c3lOUyL0ybkKf6OMBE8B9bV1hp6TXlX0sUVBnu1sZNahxywK0+ut7 3dEB2eMMOh9bTNBJ62vIBn0+WAjrnouSMzcpllsxOu1I2nkOBUmdvUAEf190ubgyOlIvL MHwzxpC7IilO0hmSAHzMoGsneLyBabHw+G2oVkJPpDW0QVDcgOnjJ0F1vRxpQA8zhEFZf b32I75r/5g2+hvgX1J1EFuatrJpcg+vrd5/g+AY97sX+QOu1ymhljK339wpI/woPQpA== 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=fyRaCfnH; 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 99B78606A322; Sat, 5 Dec 2026 14:50:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fyRaCfnH Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC31E1F0092B; Sat, 5 Dec 2026 14:50:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796482211; bh=OzFDBWeBQ967fPEIGVFgqBvENwigXB9MhhEgk6dQjJ0=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=fyRaCfnHvEnM1Tu055blO0yN6e/dqUmuCjYPReZLG+6FafNBqYU75w/8dh0rr/urm myEXauAGAIJBk2vWwTYowOLRaHzVj8/T+jdF+HWDIjaHR6V6Z75juOvqFeXazriS/8 SZddqcjmUqKzvaBwq/nvvock1Dqoj0fnyh1Sfrs8M6C+cEurkIJ6/16ORSvqkPmu4l 5wZWZcRxatfb8OJZgWtkGXq2zqvTW6OqqGdptuPJdu5rOCfi5Lv3XZmnSmk06to6Ek fKIYx4rRHkZZq38PdsSDfviyYChKNH2b0bsDTV3LhPxRSz4uHlwBYGT11KMqmH8Tn6 vOUY98YWH2kGw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v5 1/2] gpu: nova-core: publish typed SR-IOV PF APIs Reply-To: sashiko-reviews@lists.linux.dev To: "Simon Song" , dakr@kernel.org, acourbot@nvidia.com, kvm@vger.kernel.org, nova-gpu@lists.linux.dev, linux-pci@vger.kernel.org Cc: "Zhi Wang" , alex@shazbot.org, jgg@nvidia.com, yishaih@nvidia.com, skolothumtho@nvidia.com, kevin.tian@intel.com, airlied@gmail.com, simona@ffwll.ch, ojeda@kernel.org, alex.gaynor@gmail.com, boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com, lossin@kernel.org, a.hindborg@kernel.org, aliceryhl@google.com, tmgross@umich.edu, jhubbard@nvidia.com, ecourtney@nvidia.com, cjia@nvidia.com, smitra@nvidia.com, kjaju@nvidia.com, alkumar@nvidia.com, ankita@nvidia.com, aniketa@nvidia.com, kwankhede@nvidia.com, targupta@nvidia.com, zhiwang@kernel.org, boqun@kernel.org, daniel.almeida@collabora.com, tamird@kernel.org, work@onurozkan.dev, jgg@ziepe.ca, bhelgaas@google.com, kwilczynski@kernel.org, dri-devel@lists.freedesktop.org, peter@colberg.org, "Liam R. Howlett" , linux-mm@kvack.org, "Lorenzo Stoakes" In-Reply-To: <20261204144900.286240-2-xinmengs@nvidia.com> References: <20261204144900.286240-1-xinmengs@nvidia.com> <20261204144900.286240-2-xinmengs@nvidia.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 14:50:09 +0000 X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] gpu: nova-core: sriov_enable() enables VFs when vGPU is disabled - [Low] gpu: nova-core: unnecessary pin_data and existential lifetime on NovaCoreVfApi -- commit 173e704bc431988bf97e2a84f11723ac19f1a271 Author: Zhi Wang gpu: nova-core: publish typed SR-IOV PF APIs This commit registers NovaCoreVfApi as typed SR-IOV PF data during probe, implements the sriov_enable() and sriov_disable() callbacks, and exposes a VF-side handle and instance guard for managing vGPU instances. > diff --git a/drivers/gpu/nova-core/driver.rs b/drivers/gpu/nova-core/driv= er.rs > index bea1b1b0844c9..34c35b5e648fc 100644 > --- a/drivers/gpu/nova-core/driver.rs > +++ b/drivers/gpu/nova-core/driver.rs [ ... ] > @@ -154,4 +169,21 @@ fn probe<'bound>( > }, > }) > } > + > + fn sriov_enable<'a>( > + _dev: &'a pci::Device>, > + _this: Pin<&Self::Data<'a>>, > + token: pci::SriovEnable<'a>, > + ) -> Result> { > + token.enable_all() > + } [Severity: Medium] Can sriov_enable() enable hardware VFs on a PF that booted with vGPU disabled? probe() unconditionally installs _vf_registration even when VgpuState::Disabled leaves gpu.vgpu_manager() as None (for example on non-vGPU architectures or when FSP disables vGPU), so SriovEnable::enable() sees a non-null registration pointer and calls pci_enable_sriov(). Writing to sriov_numvfs then creates PCIe VFs on a GPU whose GSP firmware booted in bare-metal mode without SR-IOV mode or WPR2 VF partitions, leaving unconfigured VFs that NovaCoreVfApi::handle() rejects with ENODEV. Should sriov_enable() check _this.gpu.vgpu_manager().is_some() and return Err(ENODEV) when vGPU is disabled? [ ... ] > diff --git a/drivers/gpu/nova-core/vgpu/vgpu_api.rs b/drivers/gpu/nova-co= re/vgpu/vgpu_api.rs > index b263e96098a80..1064e461cd269 100644 > --- a/drivers/gpu/nova-core/vgpu/vgpu_api.rs > +++ b/drivers/gpu/nova-core/vgpu/vgpu_api.rs [ ... ] > @@ -51,27 +52,38 @@ fn from(vgpu_properties: &VgpuProperties) -> Self { > } > =20 > /// PF-owned operations available while a VF driver is bound. > -pub struct NovaCoreVfApi<'gpu> { > +#[pin_data] > +pub struct NovaCoreVfApi<'gpu> > +where > + // The GPU resources are invariant in their lifetime, which outlives= this API borrow. > + exists<'gpu_resources>: 'gpu, > +{ > pdev: &'gpu pci::Device, > - cmdq: &'gpu Cmdq<'gpu>, > - vgpu: Option<&'gpu VgpuManager<'gpu>>, > + #[uses('gpu_resources: invariant)] > + cmdq: &'gpu Cmdq<'gpu_resources>, > + #[uses('gpu_resources: invariant)] > + vgpu: Option<&'gpu VgpuManager<'gpu_resources>>, > total_vfs: Option>, > } [Severity: Low] Does NovaCoreVfApi need #[pin_data] and exists<'gpu_resources>: 'gpu? Both Cmdq and VgpuManager already hide their internal invariant lifetimes behind their own existential clauses so they remain covariant, and Gpu itse= lf is covariant as relied on by NovaCoreApi::new(). The comment claiming the borrowed GPU resources are invariant is therefore inaccurate. Because any T implements PinInit, NovaCoreVfApi can remain a plain struct returned directly from NovaCoreVfApi::new(), avoiding the with_vgpu() and with_project_ref() closures and letting open_instance() take &self like close_instance(), reset_instance(), and is_available(). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204144900.2862= 40-1-xinmengs@nvidia.com?part=3D1