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

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

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/i915/gt/intel_engine_user.c
Extension
.c
Size
8516 bytes
Lines
329
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 legacy_ring {
	struct intel_gt *gt;
	u8 class;
	u8 instance;
};

static int legacy_ring_idx(const struct legacy_ring *ring)
{
	static const struct {
		u8 base, max;
	} map[] = {
		[RENDER_CLASS] = { RCS0, 1 },
		[COPY_ENGINE_CLASS] = { BCS0, 1 },
		[VIDEO_DECODE_CLASS] = { VCS0, I915_MAX_VCS },
		[VIDEO_ENHANCEMENT_CLASS] = { VECS0, I915_MAX_VECS },
		[COMPUTE_CLASS] = { CCS0, I915_MAX_CCS },
	};

	if (GEM_DEBUG_WARN_ON(ring->class >= ARRAY_SIZE(map)))
		return INVALID_ENGINE;

	if (GEM_DEBUG_WARN_ON(ring->instance >= map[ring->class].max))
		return INVALID_ENGINE;

	return map[ring->class].base + ring->instance;
}

static void add_legacy_ring(struct legacy_ring *ring,
			    struct intel_engine_cs *engine)
{
	if (engine->gt != ring->gt || engine->class != ring->class) {
		ring->gt = engine->gt;
		ring->class = engine->class;
		ring->instance = 0;
	}

	engine->legacy_idx = legacy_ring_idx(ring);
	if (engine->legacy_idx != INVALID_ENGINE)
		ring->instance++;
}

static void engine_rename(struct intel_engine_cs *engine, const char *name, u16 instance)
{
	char old[sizeof(engine->name)];

	memcpy(old, engine->name, sizeof(engine->name));
	scnprintf(engine->name, sizeof(engine->name), "%s%u", name, instance);
	drm_dbg(&engine->i915->drm, "renamed %s to %s\n", old, engine->name);
}

void intel_engines_driver_register(struct drm_i915_private *i915)
{
	u16 name_instance, other_instance = 0;
	struct legacy_ring ring = {};
	struct list_head *it, *next;
	struct rb_node **p, *prev;
	LIST_HEAD(engines);

	sort_engines(i915, &engines);

	prev = NULL;
	p = &i915->uabi_engines.rb_node;
	list_for_each_safe(it, next, &engines) {
		struct intel_engine_cs *engine =
			container_of(it, typeof(*engine), uabi_list);

		if (intel_gt_has_unrecoverable_error(engine->gt))
			continue; /* ignore incomplete engines */

		GEM_BUG_ON(engine->class >= ARRAY_SIZE(uabi_classes));
		engine->uabi_class = uabi_classes[engine->class];
		if (engine->uabi_class == I915_NO_UABI_CLASS) {
			name_instance = other_instance++;
		} else {
			GEM_BUG_ON(engine->uabi_class >=
				   ARRAY_SIZE(i915->engine_uabi_class_count));
			name_instance =
				i915->engine_uabi_class_count[engine->uabi_class]++;
		}
		engine->uabi_instance = name_instance;

		/*
		 * Replace the internal name with the final user and log facing
		 * name.
		 */
		engine_rename(engine,
			      intel_engine_class_repr(engine->class),
			      name_instance);

		if (engine->uabi_class == I915_NO_UABI_CLASS)

Annotation

Implementation Notes