[PATCH] drm/xe/pf: Don't advertise support to enable VFs if not ready

Michal Wajdeczko michal.wajdeczko at intel.com
Tue May 14 13:46:16 UTC 2024



On 14.05.2024 15:09, Lucas De Marchi wrote:
> On Tue, May 07, 2024 at 06:57:57PM GMT, Michal Wajdeczko wrote:
>> Even if we have not enabled SR-IOV support using the platform
>> specific has_sriov flag, the hardware may still report SR-IOV
>> capability and the PCI layer may wrongly advertise driver support
>> to enable VFs.  Explicitly reset the number of supported VFs to
>> zero to avoid confusion.
>>
>> Applications may read the /sys/bus/pci/devices/.../sriov_totalvfs
>> prior to enabling VFs using the sriov_numvfs to check if such an
>> operation is possible.
>>
>> Signed-off-by: Michal Wajdeczko <michal.wajdeczko at intel.com>
>> ---
>> drivers/gpu/drm/xe/xe_sriov.c | 11 +++++++++++
>> 1 file changed, 11 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/xe/xe_sriov.c
>> b/drivers/gpu/drm/xe/xe_sriov.c
>> index 1c3fa84b6adb..a274a5fb1401 100644
>> --- a/drivers/gpu/drm/xe/xe_sriov.c
>> +++ b/drivers/gpu/drm/xe/xe_sriov.c
>> @@ -53,6 +53,7 @@ static bool test_is_vf(struct xe_device *xe)
>>  */
>> void xe_sriov_probe_early(struct xe_device *xe)
>> {
>> +    struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
>>     enum xe_sriov_mode mode = XE_SRIOV_MODE_NONE;
>>     bool has_sriov = xe->info.has_sriov;
>>
>> @@ -61,6 +62,16 @@ void xe_sriov_probe_early(struct xe_device *xe)
>>             mode = XE_SRIOV_MODE_VF;
>>         else if (xe_sriov_pf_readiness(xe))
>>             mode = XE_SRIOV_MODE_PF;
>> +    } else if (pci_sriov_get_totalvfs(pdev)) {
>> +        /*
>> +         * Even if we have not enabled SR-IOV support using the
>> +         * platform specific has_sriov flag, the hardware may still
>> +         * report SR-IOV capability and the PCI layer may wrongly
>> +         * advertise driver support to enable VFs. Explicitly reset
>> +         * the number of supported VFs to zero to avoid confusion.
> 
> Aren't these 2 different things? The PCI layer is reporting SR-IOV
> availability as reported by the HW, which doesn't mean the driver
> supports it.

Without support in our PF driver we can't support any VFs, even if HW is
reporting that it can. What we do here is aligned what the PCI layer is
expecting from the PF drivers if there is something to adjust - see [1]

/sys/bus/pci/devices/.../sriov_totalvfs

"This file appears when a physical PCIe device supports SR-IOV.
Userspace applications can read this file to determine the
maximum number of Virtual Functions (VFs) a PCIe physical
function (PF) can support. Typically, this is the value reported
in the PF's SR-IOV extended capability structure's TotalVFs
element.  Drivers have the ability at probe time to reduce the
value read from this file via the pci_sriov_set_totalvfs()
function"

[1]
https://elixir.bootlin.com/linux/latest/source/Documentation/ABI/testing/sysfs-bus-pci#L289


> 
> Lucas De Marchi
> 
>> +         */
>> +        drm_info(&xe->drm, "Support for SR-IOV is not available\n");
>> +        pci_sriov_set_totalvfs(pdev, 0);
>>     }
>>
>>     xe_assert(xe, !xe->sriov.__mode);
>> -- 
>> 2.43.0
>>


More information about the Intel-xe mailing list