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

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

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/i915/gt/selftest_migrate.c
Extension
.c
Size
23173 bytes
Lines
1040
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

struct spinner_timer {
	struct timer_list timer;
	struct igt_spinner spin;
};

static void spinner_kill(struct timer_list *timer)
{
	struct spinner_timer *st = timer_container_of(st, timer, timer);

	igt_spinner_end(&st->spin);
	pr_info("%s\n", __func__);
}

static int live_emit_pte_full_ring(void *arg)
{
	struct intel_gt *gt = arg;
	struct intel_migrate *migrate = &gt->migrate;
	struct drm_i915_private *i915 = migrate->context->engine->i915;
	struct drm_i915_gem_object *obj;
	struct intel_context *ce;
	struct i915_request *rq, *prev;
	struct spinner_timer st;
	struct sgt_dma it;
	int len, sz, err;
	u32 *cs;

	/*
	 * Simple regression test to check that we don't trample the
	 * rq->reserved_space when returning from emit_pte(), if the ring is
	 * nearly full.
	 */

	if (igt_spinner_init(&st.spin, to_gt(i915)))
		return -ENOMEM;

	obj = i915_gem_object_create_internal(i915, 2 * PAGE_SIZE);
	if (IS_ERR(obj)) {
		err = PTR_ERR(obj);
		goto out_spinner;
	}

	err = i915_gem_object_pin_pages_unlocked(obj);
	if (err)
		goto out_obj;

	ce = intel_migrate_create_context(migrate);
	if (IS_ERR(ce)) {
		err = PTR_ERR(ce);
		goto out_obj;
	}

	ce->ring_size = SZ_4K; /* Not too big */

	err = intel_context_pin(ce);
	if (err)
		goto out_put;

	rq = igt_spinner_create_request(&st.spin, ce, MI_ARB_CHECK);
	if (IS_ERR(rq)) {
		err = PTR_ERR(rq);
		goto out_unpin;
	}

	i915_request_add(rq);
	if (!igt_wait_for_spinner(&st.spin, rq)) {
		err = -EIO;
		goto out_unpin;
	}

	/*
	 * Fill the rest of the ring leaving I915_EMIT_PTE_NUM_DWORDS +
	 * ring->reserved_space at the end. To actually emit the PTEs we require
	 * slightly more than I915_EMIT_PTE_NUM_DWORDS, since our object size is
	 * greater than PAGE_SIZE. The correct behaviour is to wait for more
	 * ring space in emit_pte(), otherwise we trample on the reserved_space
	 * resulting in crashes when later submitting the rq.
	 */

	prev = NULL;
	do {
		if (prev)
			i915_request_add(rq);

		rq = i915_request_create(ce);
		if (IS_ERR(rq)) {
			err = PTR_ERR(rq);
			goto out_unpin;
		}

		sz = (rq->ring->space - rq->reserved_space) / sizeof(u32) -

Annotation

Implementation Notes