drm/xe: Limit drm_mm_node_allocated access to xe_ggtt_node

Continue with the encapsulation of drm_mm_node inside xe_ggtt.

Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240821193842.352557-7-rodrigo.vivi@intel.com
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
This commit is contained in:
Rodrigo Vivi 2024-08-21 15:38:37 -04:00
parent 0567f18e07
commit 8b5ccc9743
No known key found for this signature in database
GPG Key ID: FA625F640EEB13CA
4 changed files with 19 additions and 7 deletions

View File

@ -323,7 +323,7 @@ static void __xe_unpin_fb_vma(struct i915_vma *vma)
if (vma->dpt)
xe_bo_unpin_map_no_vm(vma->dpt);
else if (!drm_mm_node_allocated(&vma->bo->ggtt_node.base) ||
else if (!xe_ggtt_node_allocated(&vma->bo->ggtt_node) ||
vma->bo->ggtt_node.base.start != vma->node.base.start)
xe_ggtt_node_remove(ggtt, &vma->node, false);

View File

@ -477,6 +477,17 @@ void xe_ggtt_node_remove(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
drm_dev_exit(idx);
}
/**
* xe_ggtt_node_allocated - Check if node is allocated
* @node: the &xe_ggtt_node to be inspected
*
* Return: True if allocated, False otherwise.
*/
bool xe_ggtt_node_allocated(const struct xe_ggtt_node *node)
{
return drm_mm_node_allocated(&node->base);
}
/**
* xe_ggtt_map_bo - Map the BO into GGTT
* @ggtt: the &xe_ggtt where node will be mapped

View File

@ -23,6 +23,7 @@ int xe_ggtt_node_insert_locked(struct xe_ggtt *ggtt,
u32 size, u32 align, u32 mm_flags);
void xe_ggtt_node_remove(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
bool invalidate);
bool xe_ggtt_node_allocated(const struct xe_ggtt_node *node);
void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
int xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,

View File

@ -235,7 +235,7 @@ static u32 encode_config_ggtt(u32 *cfg, const struct xe_gt_sriov_config *config)
{
u32 n = 0;
if (drm_mm_node_allocated(&config->ggtt_region.base)) {
if (xe_ggtt_node_allocated(&config->ggtt_region)) {
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);
@ -376,7 +376,7 @@ static void pf_release_ggtt(struct xe_tile *tile, struct xe_ggtt_node *node)
{
struct xe_ggtt *ggtt = tile->mem.ggtt;
if (drm_mm_node_allocated(&node->base)) {
if (xe_ggtt_node_allocated(node)) {
/*
* explicit GGTT PTE assignment to the PF using xe_ggtt_assign()
* is redundant, as PTE will be implicitly re-assigned to PF by
@ -406,14 +406,14 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
size = round_up(size, alignment);
if (drm_mm_node_allocated(&node->base)) {
if (xe_ggtt_node_allocated(node)) {
err = pf_distribute_config_ggtt(tile, vfid, 0, 0);
if (unlikely(err))
return err;
pf_release_ggtt(tile, node);
}
xe_gt_assert(gt, !drm_mm_node_allocated(&node->base));
xe_gt_assert(gt, !xe_ggtt_node_allocated(node));
if (!size)
return 0;
@ -439,7 +439,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_media_type(gt));
return drm_mm_node_allocated(&node->base) ? node->base.size : 0;
return xe_ggtt_node_allocated(node) ? node->base.size : 0;
}
/**
@ -2028,7 +2028,7 @@ int xe_gt_sriov_pf_config_print_ggtt(struct xe_gt *gt, struct drm_printer *p)
for (n = 1; n <= total_vfs; n++) {
config = &gt->sriov.pf.vfs[n].config;
if (!drm_mm_node_allocated(&config->ggtt_region.base))
if (!xe_ggtt_node_allocated(&config->ggtt_region))
continue;
string_get_size(config->ggtt_region.base.size, 1, STRING_UNITS_2, buf, sizeof(buf));