drivers/gpu/drm/i915/gt/intel_rc6.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/gt/intel_rc6.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/i915/gt/intel_rc6.c
Extension
.c
Size
26291 bytes
Lines
873
Domain
Driver Families
Bucket
drivers/gpu
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (IS_GEN9_LP(i915)) {
			mul = 10000;
			div = 12;
		} else {
			mul = 1280;
			div = 1;
		}

		overflow_hw = BIT_ULL(32);
		time_hw = intel_uncore_read_fw(uncore, reg);
	}

	/*
	 * Counter wrap handling.
	 *
	 * Store previous hw counter values for counter wrap-around handling. But
	 * relying on a sufficient frequency of queries otherwise counters can still wrap.
	 */
	prev_hw = rc6->prev_hw_residency[id];
	rc6->prev_hw_residency[id] = time_hw;

	/* RC6 delta from last sample. */
	if (time_hw >= prev_hw)
		time_hw -= prev_hw;
	else
		time_hw += overflow_hw - prev_hw;

	/* Add delta to RC6 extended raw driver copy. */
	time_hw += rc6->cur_residency[id];
	rc6->cur_residency[id] = time_hw;

	intel_uncore_forcewake_put__locked(uncore, fw_domains);
	spin_unlock_irqrestore(&uncore->lock, flags);

	return mul_u64_u32_div(time_hw, mul, div);
}

u64 intel_rc6_residency_us(struct intel_rc6 *rc6, enum intel_rc6_res_type id)
{
	return DIV_ROUND_UP_ULL(intel_rc6_residency_ns(rc6, id), 1000);
}

void intel_rc6_print_residency(struct seq_file *m, const char *title,
			       enum intel_rc6_res_type id)
{
	struct intel_gt *gt = m->private;
	i915_reg_t reg = gt->rc6.res_reg[id];
	intel_wakeref_t wakeref;

	with_intel_runtime_pm(gt->uncore->rpm, wakeref)
		seq_printf(m, "%s %u (%llu us)\n", title,
			   intel_uncore_read(gt->uncore, reg),
			   intel_rc6_residency_us(&gt->rc6, id));
}

#if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
#include "selftest_rc6.c"
#endif

Annotation

Implementation Notes