drm/xe: Improve xe_gt_sriov_pf_config GGTT handling

Do not directly dereference xe_ggtt_node, and add
a function to retrieve the allocated GGTT size.

Reviewed-by: Matthew.brost@intel.com
Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
Link: https://patch.msgid.link/20260108101014.579906-15-dev@lankhorst.se
This commit is contained in:
Maarten Lankhorst 2026-01-08 11:10:21 +01:00
parent 9086170bfb
commit 8d88aa149a
3 changed files with 20 additions and 7 deletions

View File

@ -1196,3 +1196,14 @@ u64 xe_ggtt_node_addr(const struct xe_ggtt_node *node)
{
return node->base.start;
}
/**
* xe_ggtt_node_size - Get @node allocation size.
* @node: &xe_ggtt_node
*
* Get the allocated node's size.
*/
u64 xe_ggtt_node_size(const struct xe_ggtt_node *node)
{
return node->base.size;
}

View File

@ -62,5 +62,6 @@ u64 xe_ggtt_encode_pte_flags(struct xe_ggtt *ggtt, struct xe_bo *bo, u16 pat_ind
u64 xe_ggtt_read_pte(struct xe_ggtt *ggtt, u64 offset);
u64 xe_ggtt_node_addr(const struct xe_ggtt_node *node);
u64 xe_ggtt_node_size(const struct xe_ggtt_node *node);
#endif

View File

@ -284,7 +284,7 @@ static u32 encode_config_ggtt(u32 *cfg, const struct xe_gt_sriov_config *config,
if (!xe_ggtt_node_allocated(node))
return 0;
return encode_ggtt(cfg, node->base.start, node->base.size, details);
return encode_ggtt(cfg, xe_ggtt_node_addr(node), xe_ggtt_node_size(node), details);
}
static u32 encode_config_sched(struct xe_gt *gt, u32 *cfg, u32 n,
@ -545,9 +545,9 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
xe_ggtt_assign(node, vfid);
xe_gt_sriov_dbg_verbose(gt, "VF%u assigned GGTT %llx-%llx\n",
vfid, node->base.start, node->base.start + node->base.size - 1);
vfid, xe_ggtt_node_addr(node), xe_ggtt_node_addr(node) + size - 1);
err = pf_distribute_config_ggtt(gt->tile, vfid, node->base.start, node->base.size);
err = pf_distribute_config_ggtt(gt->tile, vfid, xe_ggtt_node_addr(node), size);
if (unlikely(err))
goto err;
@ -564,7 +564,7 @@ static u64 pf_get_vf_config_ggtt(struct xe_gt *gt, unsigned int vfid)
struct xe_ggtt_node *node = config->ggtt_region;
xe_gt_assert(gt, xe_gt_is_main_type(gt));
return xe_ggtt_node_allocated(node) ? node->base.size : 0;
return xe_ggtt_node_allocated(node) ? xe_ggtt_node_size(node) : 0;
}
/**
@ -3040,11 +3040,12 @@ int xe_gt_sriov_pf_config_print_ggtt(struct xe_gt *gt, struct drm_printer *p)
if (!xe_ggtt_node_allocated(config->ggtt_region))
continue;
string_get_size(config->ggtt_region->base.size, 1, STRING_UNITS_2,
string_get_size(xe_ggtt_node_size(config->ggtt_region), 1, STRING_UNITS_2,
buf, sizeof(buf));
drm_printf(p, "VF%u:\t%#0llx-%#llx\t(%s)\n",
n, config->ggtt_region->base.start,
config->ggtt_region->base.start + config->ggtt_region->base.size - 1,
n, xe_ggtt_node_addr(config->ggtt_region),
xe_ggtt_node_addr(config->ggtt_region) +
xe_ggtt_node_size(config->ggtt_region) - 1,
buf);
}