Re: [PATCH v5 2/6] drm/xe/vf: Split submission config query helpers
Michal Wajdeczko <[email protected]>
| Newsgroups | org.freedesktop.lists.intel-xe |
|---|---|
| Message-ID | <[email protected]> |
On 8/10/2026 12:14 PM, Satyanarayana K V P wrote: > Refactor vf_get_submission_cfg() into separate vf_get_ctxs_cfg() > and vf_get_dbs_cfg() functions which allows independent error > handling and validation for each resource, and improves testability. > > Signed-off-by: Satyanarayana K V P <[email protected]> > Cc: Michal Wajdeczko <[email protected]> Reviewed-by: Michal Wajdeczko <[email protected]> with small nit below > --- > V4 -> V5: > - Allow zero DBs are valid configuration (Michal W). > > V3 -> V4: > - Removed coverage for more error scenarios. (Michal W). > - Updated fucntion names. (Michal W) > - Added error scenarios in new commit. > - Updated commit message. > > V2 -> V3: > - Added coverage for more error scenarios. > --- > drivers/gpu/drm/xe/xe_gt_sriov_vf.c | 49 +++++++++++++++++++++++------ > 1 file changed, 40 insertions(+), 9 deletions(-) > > diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c > index 37899fcf5b22..339ea0d3344c 100644 > --- a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c > +++ b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c > @@ -568,11 +568,11 @@ static int vf_get_lmem_info(struct xe_gt *gt) > return size ? 0 : -ENODATA; > } > > -static int vf_get_submission_cfg(struct xe_gt *gt) > +static int vf_get_ctxs_cfg(struct xe_gt *gt) > { > struct xe_gt_sriov_vf_selfconfig *config = >->sriov.vf.self_config; > struct xe_guc *guc = >->uc.guc; > - u32 num_ctxs, num_dbs; > + u32 num_ctxs; > int err; > > xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt))); > @@ -581,27 +581,58 @@ static int vf_get_submission_cfg(struct xe_gt *gt) > if (unlikely(err)) > return err; > > - err = guc_action_query_single_klv32(guc, GUC_KLV_VF_CFG_NUM_DOORBELLS_KEY, &num_dbs); > - if (unlikely(err)) > - return err; > - > if (config->num_ctxs && config->num_ctxs != num_ctxs) { > xe_gt_sriov_err(gt, "Unexpected CTXs reassignment: %u != %u\n", > num_ctxs, config->num_ctxs); > return -EREMCHG; > } > + > + xe_gt_sriov_dbg_verbose(gt, "CTXs %u\n", num_ctxs); > + > + config->num_ctxs = num_ctxs; > + > + return config->num_ctxs ? 0 : -ENODATA; nit: we can now code all this as: if (!num_ctxs) { xe_gt_sriov_err(gt, "No CTXs assigned!\n"); return -ENODATA; } xe_gt_sriov_dbg_verbose(gt, "CTXs %u\n", num_ctxs); config->num_ctxs = num_ctxs; return 0; but we can postpone that until we will be forced to switch to SIGID > +} > + > +static int vf_get_dbs_cfg(struct xe_gt *gt) > +{ > + struct xe_gt_sriov_vf_selfconfig *config = >->sriov.vf.self_config; > + struct xe_guc *guc = >->uc.guc; > + u32 num_dbs; > + int err; > + > + xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt))); > + > + err = guc_action_query_single_klv32(guc, GUC_KLV_VF_CFG_NUM_DOORBELLS_KEY, &num_dbs); > + if (unlikely(err)) > + return err; > + > if (config->num_dbs && config->num_dbs != num_dbs) { > xe_gt_sriov_err(gt, "Unexpected DBs reassignment: %u != %u\n", > num_dbs, config->num_dbs); > return -EREMCHG; > } > > - xe_gt_sriov_dbg_verbose(gt, "CTXs %u DBs %u\n", num_ctxs, num_dbs); > + xe_gt_sriov_dbg_verbose(gt, "DBs %u\n", num_dbs); > > - config->num_ctxs = num_ctxs; > config->num_dbs = num_dbs; > > - return config->num_ctxs ? 0 : -ENODATA; > + return 0; > +} > + > +static int vf_get_submission_cfg(struct xe_gt *gt) > +{ > + int err; > + > + err = vf_get_ctxs_cfg(gt); > + if (unlikely(err)) > + return err; > + > + err = vf_get_dbs_cfg(gt); > + if (unlikely(err)) > + return err; > + > + return 0; > } > > static void vf_cache_gmdid(struct xe_gt *gt)