]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe/pf: Use migration-friendly context IDs auto-provisioning
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Wed, 5 Nov 2025 18:32:50 +0000 (19:32 +0100)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Fri, 7 Nov 2025 18:47:42 +0000 (19:47 +0100)
Instead of trying very hard to find the largest fair number of GuC
context IDs that could be allocated for VFs on the current GT, pick
some smaller rounded down to power-of-two value that is more likely
to be provisioned in the same manner by the other PF instance:

 num VFs | num contexts
 --------+-------------
  63..32 | 1024
  31..16 | 2048
  15..8  | 4096
   7..4  | 8192
   3..2  | 16384
      1  | 32768 (regular PF)
      1  | 64512 (admin only PF)

Add also helper function to determine if the PF is admin-only,
and for now use .probe_display flag for that.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
Link: https://patch.msgid.link/20251105183253.863-2-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
drivers/gpu/drm/xe/xe_sriov_pf_helpers.h

index d90261a7ab7cadf355682eacf37dc184bbadeb78..14feda215d5b368a4cb3de4e7f1e970da058a931 100644 (file)
@@ -985,6 +985,16 @@ int xe_gt_sriov_pf_config_bulk_set_ctxs(struct xe_gt *gt, unsigned int vfid,
                                           "GuC context IDs", no_unit, n, err);
 }
 
+static u32 pf_profile_fair_ctxs(struct xe_gt *gt, unsigned int num_vfs)
+{
+       bool admin_only_pf = xe_sriov_pf_admin_only(gt_to_xe(gt));
+
+       if (admin_only_pf && num_vfs == 1)
+               return ALIGN_DOWN(GUC_ID_MAX, SZ_1K);
+
+       return rounddown_pow_of_two(GUC_ID_MAX / num_vfs);
+}
+
 static u32 pf_estimate_fair_ctxs(struct xe_gt *gt, unsigned int num_vfs)
 {
        struct xe_guc_id_mgr *idm = &gt->uc.guc.submission_state.idm;
@@ -1017,6 +1027,7 @@ static u32 pf_estimate_fair_ctxs(struct xe_gt *gt, unsigned int num_vfs)
 int xe_gt_sriov_pf_config_set_fair_ctxs(struct xe_gt *gt, unsigned int vfid,
                                        unsigned int num_vfs)
 {
+       u32 profile = pf_profile_fair_ctxs(gt, num_vfs);
        u32 fair;
 
        xe_gt_assert(gt, vfid);
@@ -1029,6 +1040,11 @@ int xe_gt_sriov_pf_config_set_fair_ctxs(struct xe_gt *gt, unsigned int vfid,
        if (!fair)
                return -ENOSPC;
 
+       fair = min(fair, profile);
+       if (fair < profile)
+               xe_gt_sriov_info(gt, "Using non-profile provisioning (%s %u vs %u)\n",
+                                "GuC context IDs", fair, profile);
+
        return xe_gt_sriov_pf_config_bulk_set_ctxs(gt, vfid, num_vfs, fair);
 }
 
index 4a4340fb633afecf6bb2e13957a8537e4bc1910f..3ddeba4451cdb889324fad18875634835efb6570 100644 (file)
@@ -48,6 +48,17 @@ static inline unsigned int xe_sriov_pf_num_vfs(const struct xe_device *xe)
        return pci_num_vf(to_pci_dev(xe->drm.dev));
 }
 
+/**
+ * xe_sriov_pf_admin_only() - Check if PF is mainly used for VFs administration.
+ * @xe: the PF &xe_device
+ *
+ * Return: True if PF is mainly used for VFs administration.
+ */
+static inline bool xe_sriov_pf_admin_only(const struct xe_device *xe)
+{
+       return !xe->info.probe_display;
+}
+
 static inline struct mutex *xe_sriov_pf_master_mutex(struct xe_device *xe)
 {
        xe_assert(xe, IS_SRIOV_PF(xe));