Re: [PATCH v5 01/35] gpu: nova-core: populate VF information in GSP_INIT

From: Eliot Courtney

Date: Tue Dec 01 2026 - 00:58:05 EST


On Tue Nov 24, 2026 at 10:58 PM JST, Alok Kumar wrote:
> From: Zhi Wang <zhiw@xxxxxxxxxx>
>
> GSP firmware requires the VF BAR layout to route interrupts and doorbell
> events to individual virtual functions.
>
> When vGPU mode is enabled, read the VF topology from the typed PCI SR-IOV
> extended capability and populate the existing NVKV VF information schema
> in GSP_INIT.
>
> Link: https://lore.kernel.org/nova-gpu/20260730181404.776028-2-zhiw@xxxxxxxxxx/
> Signed-off-by: Zhi Wang <zhiw@xxxxxxxxxx>
> Signed-off-by: Alexandre Courbot <acourbot@xxxxxxxxxx>
> Signed-off-by: Alok Kumar <alkumar@xxxxxxxxxx>
> ---
> drivers/gpu/nova-core/gsp/fw/commands.rs | 34 +++++++++++++++++++++++-
> 1 file changed, 33 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/nova-core/gsp/fw/commands.rs b/drivers/gpu/nova-core/gsp/fw/commands.rs
> index 3c9fa459af88..4cc4b086c1d7 100644
> --- a/drivers/gpu/nova-core/gsp/fw/commands.rs
> +++ b/drivers/gpu/nova-core/gsp/fw/commands.rs
> @@ -245,6 +245,38 @@ fn new(dev: &pci::Device<device::Bound>) -> Self {
> ];
>
> impl GspInitRequest {
> + fn build_vf_info(
> + dev: &pci::Device<device::Bound>,
> + vgpu_state: VgpuState,
> + ) -> Result<Option<VfInfo>> {
> + let total_vfs = match vgpu_state {
> + VgpuState::Disabled => return Ok(None),
> + VgpuState::Enabled { total_vfs } => total_vfs,
> + };
> +
> + let sriov = dev
> + .config_space_extended()?
> + .find_ext_capability::<pci::ExtSriovRegs>()?
> + .ok_or(ENODEV)?;
> +
> + let mut vf_bars = sriov.vf_bars()?;
> + let bar0 = vf_bars.next().ok_or(EINVAL)?;
> + let bar1 = vf_bars.next().ok_or(EINVAL)?;
> + let bar2 = vf_bars.next().ok_or(EINVAL)?;
> + let flags = u64::from(bar0.is_64bit)
> + | (u64::from(bar1.is_64bit) << 1)
> + | (u64::from(bar2.is_64bit) << 2);

What about making VfInfo::flags into a bitfield, instead of manually
shifting here?