Re: [PATCH 1/3] drm/xe/pf: Add _locked variant of the GGTT bulk config function
Piotr Piórkowski <[email protected]>
| Newsgroups | org.freedesktop.lists.intel-xe |
|---|---|
| Message-ID | <[email protected]> |
Michal Wajdeczko <[email protected]> wrote on śro [2026-sie-05 17:47:31 +0200]: > We will soon want to provision all VFs, including their GGTT config, > in one step. Split existing GGTT 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 GGTT provisioning. > > Signed-off-by: Michal Wajdeczko <[email protected]> > --- > drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 37 ++++++++++++++++------ > drivers/gpu/drm/xe/xe_gt_sriov_pf_config.h | 2 ++ > 2 files changed, 29 insertions(+), 10 deletions(-) > > diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c > index 2c9b85b84b1b..47623315d615 100644 > --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c > +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c > @@ -668,7 +668,7 @@ static int pf_config_bulk_set_u64_done(struct xe_gt *gt, unsigned int first, uns > } > > /** > - * xe_gt_sriov_pf_config_bulk_set_ggtt - Provision many VFs with GGTT. > + * xe_gt_sriov_pf_config_bulk_set_ggtt_locked() - Provision many VFs with GGTT. > * @gt: the &xe_gt (can't be media) > * @vfid: starting VF identifier (can't be 0) > * @num_vfs: number of VFs to provision > @@ -678,31 +678,49 @@ static int pf_config_bulk_set_u64_done(struct xe_gt *gt, unsigned int first, uns > * > * Return: 0 on success or a negative error code on failure. > */ > -int xe_gt_sriov_pf_config_bulk_set_ggtt(struct xe_gt *gt, unsigned int vfid, > - unsigned int num_vfs, u64 size) > +int xe_gt_sriov_pf_config_bulk_set_ggtt_locked(struct xe_gt *gt, unsigned int vfid, > + unsigned int num_vfs, u64 size) > { > unsigned int n; > int err = 0; > > xe_gt_assert(gt, vfid); > xe_gt_assert(gt, xe_gt_is_main_type(gt)); > + lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt)); > > 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_ggtt(gt, n, size); > if (err) > break; > } > - mutex_unlock(xe_gt_sriov_pf_master_mutex(gt)); > > return pf_config_bulk_set_u64_done(gt, vfid, num_vfs, size, > - xe_gt_sriov_pf_config_get_ggtt, > + pf_get_vf_config_ggtt, > "GGTT", n, err); > } > > +/** > + * xe_gt_sriov_pf_config_bulk_set_ggtt() - Provision many VFs with GGTT. > + * @gt: the &xe_gt (can't be media) > + * @vfid: starting VF identifier (can't be 0) > + * @num_vfs: number of VFs to provision > + * @size: requested GGTT size > + * > + * 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_ggtt(struct xe_gt *gt, unsigned int vfid, > + unsigned int num_vfs, u64 size) > +{ > + guard(mutex)(xe_gt_sriov_pf_master_mutex(gt)); > + > + return xe_gt_sriov_pf_config_bulk_set_ggtt_locked(gt, vfid, num_vfs, size); > +} > + > /* Return: size of the largest continuous GGTT region */ > static u64 pf_get_max_ggtt(struct xe_gt *gt) > { > @@ -775,10 +793,9 @@ int xe_gt_sriov_pf_config_set_fair_ggtt(struct xe_gt *gt, unsigned int vfid, > xe_gt_assert(gt, num_vfs); > xe_gt_assert(gt, xe_gt_is_main_type(gt)); > > - mutex_lock(xe_gt_sriov_pf_master_mutex(gt)); > + guard(mutex)(xe_gt_sriov_pf_master_mutex(gt)); > + > fair = pf_estimate_fair_ggtt(gt, num_vfs); > - mutex_unlock(xe_gt_sriov_pf_master_mutex(gt)); > - > if (!fair) > return -ENOSPC; > > @@ -787,7 +804,7 @@ int xe_gt_sriov_pf_config_set_fair_ggtt(struct xe_gt *gt, unsigned int vfid, > xe_gt_sriov_info(gt, "Using non-profile provisioning (%s %llu vs %llu)\n", > "GGTT", fair, profile); > > - return xe_gt_sriov_pf_config_bulk_set_ggtt(gt, vfid, num_vfs, fair); > + return xe_gt_sriov_pf_config_bulk_set_ggtt_locked(gt, vfid, num_vfs, fair); > } > > /** > diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.h b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.h > index 2ec62c12ad5c..3741202908ee 100644 > --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.h > +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.h > @@ -18,6 +18,8 @@ int xe_gt_sriov_pf_config_set_fair_ggtt(struct xe_gt *gt, > unsigned int vfid, unsigned int num_vfs); > int xe_gt_sriov_pf_config_bulk_set_ggtt(struct xe_gt *gt, > unsigned int vfid, unsigned int num_vfs, u64 size); > +int xe_gt_sriov_pf_config_bulk_set_ggtt_locked(struct xe_gt *gt, > + unsigned int vfid, unsigned int num_vfs, u64 size); > > u32 xe_gt_sriov_pf_config_get_ctxs(struct xe_gt *gt, unsigned int vfid); > int xe_gt_sriov_pf_config_set_ctxs(struct xe_gt *gt, unsigned int vfid, u32 num_ctxs); > -- > 2.47.1 > Reviewed-by: Piotr Piórkowski <[email protected]> --