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

drm/xe/vf: Cache value of the GMDID register

Read and cache value of the GMDID register as part of the config
query that VF driver is doing over MMIO.

While the VF driver likely already obtained the value of the GMDID
register once during the early driver probe, we couldn't cache it
then as the GT structures were not ready yet.

Cache it now, in case the driver needs it later when the GuC MMIO
communication, required to query GMDID from GuC, could be no longer
desired as it will be replaced by the CTB communication.

While around, assert that we will query GMDID only when applicable.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240523192240.844-6-michal.wajdeczko@intel.com

+19
+17
drivers/gpu/drm/xe/xe_gt_sriov_vf.c
··· 284 284 return 0; 285 285 } 286 286 287 + static bool has_gmdid(struct xe_device *xe) 288 + { 289 + return GRAPHICS_VERx100(xe) >= 1270; 290 + } 291 + 287 292 /** 288 293 * xe_gt_sriov_vf_gmdid - Query GMDID over MMIO. 289 294 * @gt: the &xe_gt ··· 305 300 int err; 306 301 307 302 xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt))); 303 + xe_gt_assert(gt, !GRAPHICS_VERx100(gt_to_xe(gt)) || has_gmdid(gt_to_xe(gt))); 308 304 xe_gt_assert(gt, gt->sriov.vf.guc_version.major > 1 || gt->sriov.vf.guc_version.minor >= 2); 309 305 310 306 err = guc_action_query_single_klv32(guc, GUC_KLV_GLOBAL_CFG_GMD_ID_KEY, &value); ··· 415 409 return config->num_ctxs ? 0 : -ENODATA; 416 410 } 417 411 412 + static void vf_cache_gmdid(struct xe_gt *gt) 413 + { 414 + xe_gt_assert(gt, has_gmdid(gt_to_xe(gt))); 415 + xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt))); 416 + 417 + gt->sriov.vf.runtime.gmdid = xe_gt_sriov_vf_gmdid(gt); 418 + } 419 + 418 420 /** 419 421 * xe_gt_sriov_vf_query_config - Query SR-IOV config data over MMIO. 420 422 * @gt: the &xe_gt ··· 449 435 err = vf_get_submission_cfg(gt); 450 436 if (unlikely(err)) 451 437 return err; 438 + 439 + if (has_gmdid(xe)) 440 + vf_cache_gmdid(gt); 452 441 453 442 return 0; 454 443 }
+2
drivers/gpu/drm/xe/xe_gt_sriov_vf_types.h
··· 52 52 * struct xe_gt_sriov_vf_runtime - VF runtime data. 53 53 */ 54 54 struct xe_gt_sriov_vf_runtime { 55 + /** @gmdid: cached value of the GDMID register. */ 56 + u32 gmdid; 55 57 /** @regs_size: size of runtime register array. */ 56 58 u32 regs_size; 57 59 /** @num_regs: number of runtime registers in the array. */