drivers/gpu/drm/xe/xe_exec_queue.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_exec_queue.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/xe/xe_exec_queue.c
Extension
.c
Size
51796 bytes
Lines
1862
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 (err) {
			__xe_exec_queue_free(q);
			return ERR_PTR(err);
		}
	}

	if (vm)
		q->vm = xe_vm_get(vm);

	if (extensions) {
		/*
		 * may set q->usm, must come before xe_lrc_create(),
		 * may overwrite q->sched_props, must come before q->ops->init()
		 */
		err = exec_queue_user_extensions(xe, q, extensions);
		if (err) {
			__xe_exec_queue_free(q);
			return ERR_PTR(err);
		}
	}

	return q;
}

static void xe_exec_queue_set_lrc(struct xe_exec_queue *q, struct xe_lrc *lrc, u16 idx)
{
	xe_assert(gt_to_xe(q->gt), idx < q->width);

	scoped_guard(spinlock, &q->lrc_lookup_lock) {
		q->lrc[idx] = lrc;
		if (xe_exec_queue_is_multi_queue(q))
			q->lrc[idx]->multi_queue.primary_lrc =
				q->multi_queue.group->primary->lrc[0];
	}
}

/**
 * xe_exec_queue_get_lrc() - Get the LRC from exec queue.
 * @q: The exec queue instance.
 * @idx: Index within multi-LRC array.
 *
 * Retrieves LRC of given index for the exec queue under lock
 * and takes reference.
 *
 * Return: Pointer to LRC on success, error on failure, NULL on
 * lookup failure.
 */
struct xe_lrc *xe_exec_queue_get_lrc(struct xe_exec_queue *q, u16 idx)
{
	struct xe_lrc *lrc;

	xe_assert(gt_to_xe(q->gt), idx < q->width);

	scoped_guard(spinlock, &q->lrc_lookup_lock) {
		lrc = q->lrc[idx];
		if (lrc)
			xe_lrc_get(lrc);
	}

	return lrc;
}

/**
 * xe_exec_queue_lrc() - Get the LRC from exec queue.
 * @q: The exec queue instance.
 *
 * Retrieves the primary LRC for the exec queue. Note that this function
 * returns only the first LRC instance, even when multiple parallel LRCs
 * are configured. This function does not increment reference count,
 * so the reference can be just forgotten after use.
 *
 * Return: Pointer to LRC on success, error on failure
 */
struct xe_lrc *xe_exec_queue_lrc(struct xe_exec_queue *q)
{
	return q->lrc[0];
}

static void __xe_exec_queue_fini(struct xe_exec_queue *q)
{
	int i;

	q->ops->fini(q);

	for (i = 0; i < q->width; ++i)
		xe_lrc_put(q->lrc[i]);
}

static int __xe_exec_queue_init(struct xe_exec_queue *q, u32 exec_queue_flags)
{

Annotation

Implementation Notes