Commit f79ee301 authored by Matt Roper's avatar Matt Roper Committed by Rodrigo Vivi
Browse files

drm/xe: Add backpointer from gt to tile



Rather than a backpointer to the xe_device, a GT should have a
backpointer to its tile (which can then be used to lookup the device if
necessary).

The gt_to_xe() helper macro (which moves from xe_gt.h to xe_gt_types.h)
can and should still be used to jump directly from an xe_gt to
xe_device.

v2:
 - Fix kunit test build
 - Move a couple changes to the previous patch. (Lucas)

Reviewed-by: default avatarMatt Atwood <matthew.s.atwood@intel.com>
Reviewed-by: default avatarLucas De Marchi <lucas.demarchi@intel.com>
Link: https://lore.kernel.org/r/20230601215244.678611-4-matthew.d.roper@intel.com


Signed-off-by: default avatarMatt Roper <matthew.d.roper@intel.com>
Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
parent a5edc7cd
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ static int ccs_test_migrate(struct xe_gt *gt, struct xe_bo *bo,
	}

	/* Check last CCS value, or at least last value in page. */
	offset = xe_device_ccs_bytes(gt->xe, bo->size);
	offset = xe_device_ccs_bytes(gt_to_xe(gt), bo->size);
	offset = min_t(u32, offset, PAGE_SIZE) / sizeof(u64) - 1;
	if (cpu_map[offset] != get_val) {
		KUNIT_FAIL(test,
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

static int bb_prefetch(struct xe_gt *gt)
{
	struct xe_device *xe = gt->xe;
	struct xe_device *xe = gt_to_xe(gt);

	if (GRAPHICS_VERx100(xe) >= 1250 && !xe_gt_is_media_type(gt))
		/*
+6 −6
Original line number Diff line number Diff line
@@ -142,14 +142,14 @@ static void xe_ggtt_initial_clear(struct xe_ggtt *ggtt)
	u64 start, end;

	/* Display may have allocated inside ggtt, so be careful with clearing here */
	xe_device_mem_access_get(ggtt->gt->xe);
	xe_device_mem_access_get(gt_to_xe(ggtt->gt));
	mutex_lock(&ggtt->lock);
	drm_mm_for_each_hole(hole, &ggtt->mm, start, end)
		xe_ggtt_clear(ggtt, start, end - start);

	xe_ggtt_invalidate(ggtt->gt);
	mutex_unlock(&ggtt->lock);
	xe_device_mem_access_put(ggtt->gt->xe);
	xe_device_mem_access_put(gt_to_xe(ggtt->gt));
}

int xe_ggtt_init(struct xe_gt *gt, struct xe_ggtt *ggtt)
@@ -286,14 +286,14 @@ static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
	if (err)
		return err;

	xe_device_mem_access_get(ggtt->gt->xe);
	xe_device_mem_access_get(gt_to_xe(ggtt->gt));
	mutex_lock(&ggtt->lock);
	err = drm_mm_insert_node_in_range(&ggtt->mm, &bo->ggtt_node, bo->size,
					  alignment, 0, start, end, 0);
	if (!err)
		xe_ggtt_map_bo(ggtt, bo);
	mutex_unlock(&ggtt->lock);
	xe_device_mem_access_put(ggtt->gt->xe);
	xe_device_mem_access_put(gt_to_xe(ggtt->gt));

	return err;
}
@@ -322,7 +322,7 @@ int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)

void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct drm_mm_node *node)
{
	xe_device_mem_access_get(ggtt->gt->xe);
	xe_device_mem_access_get(gt_to_xe(ggtt->gt));
	mutex_lock(&ggtt->lock);

	xe_ggtt_clear(ggtt, node->start, node->size);
@@ -332,7 +332,7 @@ void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct drm_mm_node *node)
	xe_ggtt_invalidate(ggtt->gt);

	mutex_unlock(&ggtt->lock);
	xe_device_mem_access_put(ggtt->gt->xe);
	xe_device_mem_access_put(gt_to_xe(ggtt->gt));
}

void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
+0 −5
Original line number Diff line number Diff line
@@ -49,11 +49,6 @@ static inline bool xe_gt_is_media_type(struct xe_gt *gt)
	return gt->info.type == XE_GT_TYPE_MEDIA;
}

#define gt_to_xe(gt__)								\
	_Generic(gt__,								\
		 const struct xe_gt *: (const struct xe_device *)((gt__)->xe),	\
		 struct xe_gt *: (gt__)->xe)

static inline bool xe_gt_is_usm_hwe(struct xe_gt *gt, struct xe_hw_engine *hwe)
{
	struct xe_device *xe = gt_to_xe(gt);
+3 −3
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@
#include "xe_device_types.h"

#define xe_gt_printk(_gt, _level, _fmt, ...) \
	drm_##_level(&(_gt)->xe->drm, "GT%u: " _fmt, (_gt)->info.id, ##__VA_ARGS__)
	drm_##_level(&gt_to_xe(_gt)->drm, "GT%u: " _fmt, (_gt)->info.id, ##__VA_ARGS__)

#define xe_gt_err(_gt, _fmt, ...) \
	xe_gt_printk((_gt), err, _fmt, ##__VA_ARGS__)
@@ -32,10 +32,10 @@
	xe_gt_printk((_gt), err_ratelimited, _fmt, ##__VA_ARGS__)

#define xe_gt_WARN(_gt, _condition, _fmt, ...) \
	drm_WARN(&(_gt)->xe->drm, _condition, "GT%u: " _fmt, (_gt)->info.id, ##__VA_ARGS__)
	drm_WARN(&gt_to_xe(_gt)->drm, _condition, "GT%u: " _fmt, (_gt)->info.id, ##__VA_ARGS__)

#define xe_gt_WARN_ONCE(_gt, _condition, _fmt, ...) \
	drm_WARN_ONCE(&(_gt)->xe->drm, _condition, "GT%u: " _fmt, (_gt)->info.id, ##__VA_ARGS__)
	drm_WARN_ONCE(&gt_to_xe(_gt)->drm, _condition, "GT%u: " _fmt, (_gt)->info.id, ##__VA_ARGS__)

#define xe_gt_WARN_ON(_gt, _condition) \
	xe_gt_WARN((_gt), _condition, "%s(%s)", "gt_WARN_ON", __stringify(_condition))
Loading