Commit 92ba2032 authored by Michal Wajdeczko's avatar Michal Wajdeczko
Browse files

drm/xe/pf: Move GGTT config KLVs encoding to helper



In upcoming patch we will want to encode GGTT config KLVs based
on raw numbers, without relying on the allocated GGTT node.

Signed-off-by: default avatarMichal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: default avatarPiotr Piórkowski <piotr.piorkowski@intel.com>
Link: https://lore.kernel.org/r/20250711193316.1920-4-michal.wajdeczko@intel.com
parent 1c38dd6a
Loading
Loading
Loading
Loading
+20 −11
Original line number Diff line number Diff line
@@ -238,25 +238,34 @@ static struct xe_gt_sriov_config *pf_pick_vf_config(struct xe_gt *gt, unsigned i
}

/* Return: number of configuration dwords written */
static u32 encode_config_ggtt(u32 *cfg, const struct xe_gt_sriov_config *config, bool details)
static u32 encode_ggtt(u32 *cfg, u64 start, u64 size, bool details)
{
	u32 n = 0;

	if (xe_ggtt_node_allocated(config->ggtt_region)) {
	if (details) {
		cfg[n++] = PREP_GUC_KLV_TAG(VF_CFG_GGTT_START);
			cfg[n++] = lower_32_bits(config->ggtt_region->base.start);
			cfg[n++] = upper_32_bits(config->ggtt_region->base.start);
		cfg[n++] = lower_32_bits(start);
		cfg[n++] = upper_32_bits(start);
	}

	cfg[n++] = PREP_GUC_KLV_TAG(VF_CFG_GGTT_SIZE);
		cfg[n++] = lower_32_bits(config->ggtt_region->base.size);
		cfg[n++] = upper_32_bits(config->ggtt_region->base.size);
	}
	cfg[n++] = lower_32_bits(size);
	cfg[n++] = upper_32_bits(size);

	return n;
}

/* Return: number of configuration dwords written */
static u32 encode_config_ggtt(u32 *cfg, const struct xe_gt_sriov_config *config, bool details)
{
	struct xe_ggtt_node *node = config->ggtt_region;

	if (!xe_ggtt_node_allocated(node))
		return 0;

	return encode_ggtt(cfg, node->base.start, node->base.size, details);
}

/* Return: number of configuration dwords written */
static u32 encode_config(u32 *cfg, const struct xe_gt_sriov_config *config, bool details)
{