drm/xe/vf: Add proper detection of the SR-IOV VF mode
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Wed, 27 Mar 2024 18:27:40 +0000 (19:27 +0100)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Thu, 28 Mar 2024 12:45:37 +0000 (13:45 +0100)
SR-IOV VF mode detection is based on testing VF capability bit on
the register that is accessible from both the PF and enabled VFs.

Bspec: 49904, 53227
Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240327182740.407-4-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/regs/xe_sriov_regs.h
drivers/gpu/drm/xe/xe_sriov.c

index 58a4e0fad1e10e4b65c6846ea11f6ed77831b6c4..617ddb84b7faf30b08ffbae9de50f071b91f94c8 100644 (file)
@@ -14,4 +14,7 @@
 #define   LMEM_EN                      REG_BIT(31)
 #define   LMTT_DIR_PTR                 REG_GENMASK(30, 0) /* in multiples of 64KB */
 
+#define VF_CAP_REG                     XE_REG(0x1901f8, XE_REG_OPTION_VF)
+#define   VF_CAP                       REG_BIT(0)
+
 #endif
index 2bcef998c8a98c777e8b1973dbcc0e7ab63711d3..3e103edf717449687206072ec9f18f6e24d70c30 100644 (file)
@@ -5,7 +5,11 @@
 
 #include <drm/drm_managed.h>
 
+#include "regs/xe_sriov_regs.h"
+
 #include "xe_assert.h"
+#include "xe_device.h"
+#include "xe_mmio.h"
 #include "xe_sriov.h"
 
 /**
@@ -28,6 +32,13 @@ const char *xe_sriov_mode_to_string(enum xe_sriov_mode mode)
        }
 }
 
+static bool test_is_vf(struct xe_device *xe)
+{
+       u32 value = xe_mmio_read32(xe_root_mmio_gt(xe), VF_CAP_REG);
+
+       return value & VF_CAP;
+}
+
 /**
  * xe_sriov_probe_early - Probe a SR-IOV mode.
  * @xe: the &xe_device to probe mode on
@@ -44,8 +55,10 @@ void xe_sriov_probe_early(struct xe_device *xe)
        enum xe_sriov_mode mode = XE_SRIOV_MODE_NONE;
        bool has_sriov = xe->info.has_sriov;
 
-       /* TODO: replace with proper mode detection */
-       xe_assert(xe, !has_sriov);
+       if (has_sriov) {
+               if (test_is_vf(xe))
+                       mode = XE_SRIOV_MODE_VF;
+       }
 
        xe_assert(xe, !xe->sriov.__mode);
        xe->sriov.__mode = mode;