]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
drm/xe/pf: Don't advertise support to enable VFs if not ready
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Tue, 7 May 2024 16:57:57 +0000 (18:57 +0200)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Wed, 15 May 2024 20:31:52 +0000 (22:31 +0200)
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@intel.com>
Reviewed-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
Acked-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240507165757.2835-1-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_sriov.c

index 1c3fa84b6adb0fe638e24ac70a2b51570c204602..a274a5fb14018b5d8cbe1d41775662e8cf76ecc6 100644 (file)
@@ -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.
+                */
+               drm_info(&xe->drm, "Support for SR-IOV is not available\n");
+               pci_sriov_set_totalvfs(pdev, 0);
        }
 
        xe_assert(xe, !xe->sriov.__mode);