[PATCH 2/2] gpu: nova-core: reject binding to SR-IOV Virtual Functions

John Hubbard posted 2 patches 23 hours ago
[PATCH 2/2] gpu: nova-core: reject binding to SR-IOV Virtual Functions
Posted by John Hubbard 23 hours ago
Nova-core must only bind to Physical Functions (PFs) and regular PCI
devices, not to Virtual Functions (VFs) created through SR-IOV.

Detect VFs using the newly added is_virtfn() method, and leave them
unclaimed. This allows a VFIO kernel module to claim the VFs instead.

Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
 drivers/gpu/nova-core/driver.rs | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/nova-core/driver.rs b/drivers/gpu/nova-core/driver.rs
index 5d23a91f51dd..004c15763694 100644
--- a/drivers/gpu/nova-core/driver.rs
+++ b/drivers/gpu/nova-core/driver.rs
@@ -54,6 +54,11 @@ impl pci::Driver for NovaCore {
     fn probe(pdev: &pci::Device<Core>, _info: &Self::IdInfo) -> Result<Pin<KBox<Self>>> {
         dev_dbg!(pdev.as_ref(), "Probe Nova Core GPU driver.\n");
 
+        // NovaCore must only bind to Physical Functions (PFs), not Virtual Functions (VFs)
+        if pdev.is_virtfn() {
+            return Err(ENODEV);
+        }
+
         pdev.enable_device_mem()?;
         pdev.set_master();
 
-- 
2.51.0
Re: [PATCH 2/2] gpu: nova-core: reject binding to SR-IOV Virtual Functions
Posted by Alistair Popple 20 hours ago
On 2025-10-01 at 08:07 +1000, John Hubbard <jhubbard@nvidia.com> wrote...
> Nova-core must only bind to Physical Functions (PFs) and regular PCI
> devices, not to Virtual Functions (VFs) created through SR-IOV.
> 
> Detect VFs using the newly added is_virtfn() method, and leave them
> unclaimed. This allows a VFIO kernel module to claim the VFs instead.

See my comments on the cover letter, but does the kernel driver core continue
trying to probe other drivers if this one failed? Or does it just give up? If it
just gives up I'm not sure this really helps much, although I suppose if
NovaCore can't use the VFs for anything useful anyway then it probably should
fail.

> Signed-off-by: John Hubbard <jhubbard@nvidia.com>
> ---
>  drivers/gpu/nova-core/driver.rs | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/gpu/nova-core/driver.rs b/drivers/gpu/nova-core/driver.rs
> index 5d23a91f51dd..004c15763694 100644
> --- a/drivers/gpu/nova-core/driver.rs
> +++ b/drivers/gpu/nova-core/driver.rs
> @@ -54,6 +54,11 @@ impl pci::Driver for NovaCore {
>      fn probe(pdev: &pci::Device<Core>, _info: &Self::IdInfo) -> Result<Pin<KBox<Self>>> {
>          dev_dbg!(pdev.as_ref(), "Probe Nova Core GPU driver.\n");
>  
> +        // NovaCore must only bind to Physical Functions (PFs), not Virtual Functions (VFs)
> +        if pdev.is_virtfn() {
> +            return Err(ENODEV);
> +        }
> +
>          pdev.enable_device_mem()?;
>          pdev.set_master();
>  
> -- 
> 2.51.0
>
Re: [PATCH 2/2] gpu: nova-core: reject binding to SR-IOV Virtual Functions
Posted by John Hubbard 19 hours ago
On 9/30/25 5:33 PM, Alistair Popple wrote:
> On 2025-10-01 at 08:07 +1000, John Hubbard <jhubbard@nvidia.com> wrote...
>> Nova-core must only bind to Physical Functions (PFs) and regular PCI
>> devices, not to Virtual Functions (VFs) created through SR-IOV.
>>
>> Detect VFs using the newly added is_virtfn() method, and leave them
>> unclaimed. This allows a VFIO kernel module to claim the VFs instead.
> 
> See my comments on the cover letter, but does the kernel driver core continue
> trying to probe other drivers if this one failed? Or does it just give up? If it
> just gives up I'm not sure this really helps much, although I suppose if
> NovaCore can't use the VFs for anything useful anyway then it probably should
> fail.

It keeps going. :)

thanks,
John Hubbard

> 
>> Signed-off-by: John Hubbard <jhubbard@nvidia.com>
>> ---
>>  drivers/gpu/nova-core/driver.rs | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/gpu/nova-core/driver.rs b/drivers/gpu/nova-core/driver.rs
>> index 5d23a91f51dd..004c15763694 100644
>> --- a/drivers/gpu/nova-core/driver.rs
>> +++ b/drivers/gpu/nova-core/driver.rs
>> @@ -54,6 +54,11 @@ impl pci::Driver for NovaCore {
>>      fn probe(pdev: &pci::Device<Core>, _info: &Self::IdInfo) -> Result<Pin<KBox<Self>>> {
>>          dev_dbg!(pdev.as_ref(), "Probe Nova Core GPU driver.\n");
>>  
>> +        // NovaCore must only bind to Physical Functions (PFs), not Virtual Functions (VFs)
>> +        if pdev.is_virtfn() {
>> +            return Err(ENODEV);
>> +        }
>> +
>>          pdev.enable_device_mem()?;
>>          pdev.set_master();
>>  
>> -- 
>> 2.51.0
>>