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 doorbells auto-provisioning

Instead of trying very hard to find the largest fair number of GuC
doorbell 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 doorbells
--------+--------------
63..32 | 4
31..16 | 8
15..8 | 16
7..4 | 32
3..2 | 64
1 | 128 (regular PF)
1 | 240 (admin only PF)

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-3-michal.wajdeczko@intel.com

+17
+17
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
··· 1249 1249 "GuC doorbell IDs", no_unit, n, err); 1250 1250 } 1251 1251 1252 + static u32 pf_profile_fair_dbs(struct xe_gt *gt, unsigned int num_vfs) 1253 + { 1254 + bool admin_only_pf = xe_sriov_pf_admin_only(gt_to_xe(gt)); 1255 + 1256 + /* XXX: preliminary */ 1257 + if (admin_only_pf && num_vfs == 1) 1258 + return GUC_NUM_DOORBELLS - SZ_16; 1259 + 1260 + return rounddown_pow_of_two(GUC_NUM_DOORBELLS / (num_vfs + 1)); 1261 + } 1262 + 1252 1263 static u32 pf_estimate_fair_dbs(struct xe_gt *gt, unsigned int num_vfs) 1253 1264 { 1254 1265 struct xe_guc_db_mgr *dbm = &gt->uc.guc.dbm; ··· 1292 1281 int xe_gt_sriov_pf_config_set_fair_dbs(struct xe_gt *gt, unsigned int vfid, 1293 1282 unsigned int num_vfs) 1294 1283 { 1284 + u32 profile = pf_profile_fair_dbs(gt, num_vfs); 1295 1285 u32 fair; 1296 1286 1297 1287 xe_gt_assert(gt, vfid); ··· 1304 1292 1305 1293 if (!fair) 1306 1294 return -ENOSPC; 1295 + 1296 + fair = min(fair, profile); 1297 + if (fair < profile) 1298 + xe_gt_sriov_info(gt, "Using non-profile provisioning (%s %u vs %u)\n", 1299 + "GuC doorbell IDs", fair, profile); 1307 1300 1308 1301 return xe_gt_sriov_pf_config_bulk_set_dbs(gt, vfid, num_vfs, fair); 1309 1302 }