]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/xe/pf: Move GGTT config KLVs encoding to helper
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Fri, 11 Jul 2025 19:33:13 +0000 (21:33 +0200)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Tue, 15 Jul 2025 11:05:18 +0000 (13:05 +0200)
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: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
Link: https://lore.kernel.org/r/20250711193316.1920-4-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c

index 79b364fbe06d9ccdb5c0b9ba1e7c0b18abb03d39..e7aea89e721526a1c0b5b8b235c71942c406cd55 100644 (file)
@@ -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++] = 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);
+       if (details) {
+               cfg[n++] = PREP_GUC_KLV_TAG(VF_CFG_GGTT_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(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)
 {