mirror of
https://github.com/torvalds/linux.git
synced 2026-11-12 20:54:48 +01:00
drm/xe/pf: Add _locked variant of the contexts bulk config function
We will soon want to provision all VFs, including their GuC context IDs config, in one step. Split existing GuC IDs bulk configuration function into two functions, one of which will expect the master lock to be already taken. Use this new function in the fair GuC IDs provisioning. Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com> Reviewed-by: Piotr Piórkowski <piotr.piorkowski@intel.com> Link: https://patch.msgid.link/20260805154733.604-3-michal.wajdeczko@intel.com
This commit is contained in:
parent
196de4b20b
commit
9147b754f0
|
|
@ -1116,7 +1116,41 @@ static int pf_config_bulk_set_u32_done(struct xe_gt *gt, unsigned int first, uns
|
|||
}
|
||||
|
||||
/**
|
||||
* xe_gt_sriov_pf_config_bulk_set_ctxs - Provision many VFs with GuC context IDs.
|
||||
* xe_gt_sriov_pf_config_bulk_set_ctxs_locked() - Provision many VFs with GuC context IDs.
|
||||
* @gt: the &xe_gt
|
||||
* @vfid: starting VF identifier
|
||||
* @num_vfs: number of VFs to provision
|
||||
* @num_ctxs: requested number of GuC contexts IDs (0 to release)
|
||||
*
|
||||
* This function can only be called on PF.
|
||||
*
|
||||
* Return: 0 on success or a negative error code on failure.
|
||||
*/
|
||||
int xe_gt_sriov_pf_config_bulk_set_ctxs_locked(struct xe_gt *gt, unsigned int vfid,
|
||||
unsigned int num_vfs, u32 num_ctxs)
|
||||
{
|
||||
unsigned int n;
|
||||
int err = 0;
|
||||
|
||||
xe_gt_assert(gt, vfid);
|
||||
lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt));
|
||||
|
||||
if (!num_vfs)
|
||||
return 0;
|
||||
|
||||
for (n = vfid; n < vfid + num_vfs; n++) {
|
||||
err = pf_provision_vf_ctxs(gt, n, num_ctxs);
|
||||
if (err)
|
||||
break;
|
||||
}
|
||||
|
||||
return pf_config_bulk_set_u32_done(gt, vfid, num_vfs, num_ctxs,
|
||||
pf_get_vf_config_ctxs,
|
||||
"GuC context IDs", no_unit, n, err);
|
||||
}
|
||||
|
||||
/**
|
||||
* xe_gt_sriov_pf_config_bulk_set_ctxs() - Provision many VFs with GuC context IDs.
|
||||
* @gt: the &xe_gt
|
||||
* @vfid: starting VF identifier
|
||||
* @num_vfs: number of VFs to provision
|
||||
|
|
@ -1129,25 +1163,9 @@ static int pf_config_bulk_set_u32_done(struct xe_gt *gt, unsigned int first, uns
|
|||
int xe_gt_sriov_pf_config_bulk_set_ctxs(struct xe_gt *gt, unsigned int vfid,
|
||||
unsigned int num_vfs, u32 num_ctxs)
|
||||
{
|
||||
unsigned int n;
|
||||
int err = 0;
|
||||
guard(mutex)(xe_gt_sriov_pf_master_mutex(gt));
|
||||
|
||||
xe_gt_assert(gt, vfid);
|
||||
|
||||
if (!num_vfs)
|
||||
return 0;
|
||||
|
||||
mutex_lock(xe_gt_sriov_pf_master_mutex(gt));
|
||||
for (n = vfid; n < vfid + num_vfs; n++) {
|
||||
err = pf_provision_vf_ctxs(gt, n, num_ctxs);
|
||||
if (err)
|
||||
break;
|
||||
}
|
||||
mutex_unlock(xe_gt_sriov_pf_master_mutex(gt));
|
||||
|
||||
return pf_config_bulk_set_u32_done(gt, vfid, num_vfs, num_ctxs,
|
||||
xe_gt_sriov_pf_config_get_ctxs,
|
||||
"GuC context IDs", no_unit, n, err);
|
||||
return xe_gt_sriov_pf_config_bulk_set_ctxs_locked(gt, vfid, num_vfs, num_ctxs);
|
||||
}
|
||||
|
||||
static u32 pf_profile_fair_ctxs(struct xe_gt *gt, unsigned int num_vfs)
|
||||
|
|
@ -1198,10 +1216,9 @@ int xe_gt_sriov_pf_config_set_fair_ctxs(struct xe_gt *gt, unsigned int vfid,
|
|||
xe_gt_assert(gt, vfid);
|
||||
xe_gt_assert(gt, num_vfs);
|
||||
|
||||
mutex_lock(xe_gt_sriov_pf_master_mutex(gt));
|
||||
fair = pf_estimate_fair_ctxs(gt, num_vfs);
|
||||
mutex_unlock(xe_gt_sriov_pf_master_mutex(gt));
|
||||
guard(mutex)(xe_gt_sriov_pf_master_mutex(gt));
|
||||
|
||||
fair = pf_estimate_fair_ctxs(gt, num_vfs);
|
||||
if (!fair)
|
||||
return -ENOSPC;
|
||||
|
||||
|
|
@ -1210,7 +1227,7 @@ int xe_gt_sriov_pf_config_set_fair_ctxs(struct xe_gt *gt, unsigned int vfid,
|
|||
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);
|
||||
return xe_gt_sriov_pf_config_bulk_set_ctxs_locked(gt, vfid, num_vfs, fair);
|
||||
}
|
||||
|
||||
static u32 pf_get_min_spare_dbs(struct xe_gt *gt)
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ int xe_gt_sriov_pf_config_set_ctxs(struct xe_gt *gt, unsigned int vfid, u32 num_
|
|||
int xe_gt_sriov_pf_config_set_fair_ctxs(struct xe_gt *gt, unsigned int vfid, unsigned int num_vfs);
|
||||
int xe_gt_sriov_pf_config_bulk_set_ctxs(struct xe_gt *gt, unsigned int vfid, unsigned int num_vfs,
|
||||
u32 num_ctxs);
|
||||
int xe_gt_sriov_pf_config_bulk_set_ctxs_locked(struct xe_gt *gt, unsigned int vfid,
|
||||
unsigned int num_vfs, u32 num_ctxs);
|
||||
|
||||
u32 xe_gt_sriov_pf_config_get_dbs(struct xe_gt *gt, unsigned int vfid);
|
||||
int xe_gt_sriov_pf_config_set_dbs(struct xe_gt *gt, unsigned int vfid, u32 num_dbs);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user