Commit 61dabe82 authored by Jani Nikula's avatar Jani Nikula
Browse files

drm/i915/gt: add a macro for mock gt wakeref special value and use it



Add a dedicated macro for the special mock gt wakeref value, with a cast
to intel_wakeref_t, instead of assuming you can assign or compare the
wakeref to -ENODEV directly.

Arguably the whole thing is a hack that should not exist, but at least
make it slightly less hacky.

Side note: If this value were to ever end up in
intel_ref_tracker_free(), it would wreak havoc.

Reviewed-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/1da887a6b4fe1ec45355571ea7b56d91fadf0af2.1726680898.git.jani.nikula@intel.com


Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
parent c45c7b24
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -105,9 +105,13 @@ int intel_gt_runtime_resume(struct intel_gt *gt);

ktime_t intel_gt_get_awake_time(const struct intel_gt *gt);

#define INTEL_WAKEREF_MOCK_GT ((intel_wakeref_t)-ENODEV)

static inline bool is_mock_gt(const struct intel_gt *gt)
{
	return I915_SELFTEST_ONLY(gt->awake == -ENODEV);
	BUILD_BUG_ON(INTEL_WAKEREF_DEF == INTEL_WAKEREF_MOCK_GT);

	return I915_SELFTEST_ONLY(gt->awake == INTEL_WAKEREF_MOCK_GT);
}

#endif /* INTEL_GT_PM_H */
+1 −1
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ void intel_gt_invalidate_tlb_full(struct intel_gt *gt, u32 seqno)
{
	intel_wakeref_t wakeref;

	if (I915_SELFTEST_ONLY(gt->awake == -ENODEV))
	if (is_mock_gt(gt))
		return;

	if (intel_gt_is_wedged(gt))
+1 −1
Original line number Diff line number Diff line
@@ -203,7 +203,7 @@ struct drm_i915_private *mock_gem_device(void)
	intel_root_gt_init_early(i915);
	mock_uncore_init(&i915->uncore, i915);
	atomic_inc(&to_gt(i915)->wakeref.count); /* disable; no hw support */
	to_gt(i915)->awake = -ENODEV;
	to_gt(i915)->awake = INTEL_WAKEREF_MOCK_GT;
	mock_gt_probe(i915);

	ret = intel_region_ttm_device_init(i915);