Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+27
+16
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
··· 985 985 "GuC context IDs", no_unit, n, err); 986 986 } 987 987 988 + static u32 pf_profile_fair_ctxs(struct xe_gt *gt, unsigned int num_vfs) 989 + { 990 + bool admin_only_pf = xe_sriov_pf_admin_only(gt_to_xe(gt)); 991 + 992 + if (admin_only_pf && num_vfs == 1) 993 + return ALIGN_DOWN(GUC_ID_MAX, SZ_1K); 994 + 995 + return rounddown_pow_of_two(GUC_ID_MAX / num_vfs); 996 + } 997 + 988 998 static u32 pf_estimate_fair_ctxs(struct xe_gt *gt, unsigned int num_vfs) 989 999 { 990 1000 struct xe_guc_id_mgr *idm = &gt->uc.guc.submission_state.idm; ··· 1027 1017 int xe_gt_sriov_pf_config_set_fair_ctxs(struct xe_gt *gt, unsigned int vfid, 1028 1018 unsigned int num_vfs) 1029 1019 { 1020 + u32 profile = pf_profile_fair_ctxs(gt, num_vfs); 1030 1021 u32 fair; 1031 1022 1032 1023 xe_gt_assert(gt, vfid); ··· 1039 1028 1040 1029 if (!fair) 1041 1030 return -ENOSPC; 1031 + 1032 + fair = min(fair, profile); 1033 + if (fair < profile) 1034 + xe_gt_sriov_info(gt, "Using non-profile provisioning (%s %u vs %u)\n", 1035 + "GuC context IDs", fair, profile); 1042 1036 1043 1037 return xe_gt_sriov_pf_config_bulk_set_ctxs(gt, vfid, num_vfs, fair); 1044 1038 }
+11
drivers/gpu/drm/xe/xe_sriov_pf_helpers.h
··· 48 48 return pci_num_vf(to_pci_dev(xe->drm.dev)); 49 49 } 50 50 51 + /** 52 + * xe_sriov_pf_admin_only() - Check if PF is mainly used for VFs administration. 53 + * @xe: the PF &xe_device 54 + * 55 + * Return: True if PF is mainly used for VFs administration. 56 + */ 57 + static inline bool xe_sriov_pf_admin_only(const struct xe_device *xe) 58 + { 59 + return !xe->info.probe_display; 60 + } 61 + 51 62 static inline struct mutex *xe_sriov_pf_master_mutex(struct xe_device *xe) 52 63 { 53 64 xe_assert(xe, IS_SRIOV_PF(xe));