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 CCCB3606A322 for ; Sat, 5 Dec 2026 14:50:23 +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=fyRaCfnH Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F08E610E75D; Sat, 5 Dec 2026 14:50:17 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id AE5E410E75D for ; Sat, 5 Dec 2026 14:50:11 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 5415E4440A; Sat, 5 Dec 2026 14:50:11 +0000 (UTC) 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 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-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=-11.1 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 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