drm/xe/pf: Use migration-friendly context IDs auto-provisioning

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
This commit is contained in:
Michal Wajdeczko
2025-11-05 19:32:50 +01:00
parent 715974499a
commit 8fb1d7d3cf
2 changed files with 27 additions and 0 deletions

View 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);
}

View 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));