drm/xe: Limit drm_mm_node_allocated access to xe_ggtt_node
authorRodrigo Vivi <rodrigo.vivi@intel.com>
Wed, 21 Aug 2024 19:38:37 +0000 (15:38 -0400)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Thu, 22 Aug 2024 18:00:44 +0000 (14:00 -0400)
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>
drivers/gpu/drm/xe/display/xe_fb_pin.c
drivers/gpu/drm/xe/xe_ggtt.c
drivers/gpu/drm/xe/xe_ggtt.h
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c

index db74c33..de4930b 100644 (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);
 
index e0da24b..7c8bbaa 100644 (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
index 5147930..f816b3c 100644 (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,
index 3ca98f8..947750d 100644 (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));