drivers/gpu/drm/xe/xe_late_bind_fw.c

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

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/xe/xe_late_bind_fw.c
Extension
.c
Size
12785 bytes
Lines
465
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 (lbfw->payload && late_bind->wq) {
			drm_dbg(&xe->drm, "Flush work: load %s firmware\n",
				fw_id_to_name[lbfw->id]);
			flush_work(&lbfw->work);
		}
	}
}

static void xe_late_bind_work(struct work_struct *work)
{
	struct xe_late_bind_fw *lbfw = container_of(work, struct xe_late_bind_fw, work);
	struct xe_late_bind *late_bind = container_of(lbfw, struct xe_late_bind,
						      late_bind_fw[lbfw->id]);
	struct xe_device *xe = late_bind_to_xe(late_bind);
	int retry = LB_FW_LOAD_RETRY_MAXCOUNT;
	int ret;
	int slept;

	xe_device_assert_mem_access(xe);

	/* we can queue this before the component is bound */
	for (slept = 0; slept < LB_INIT_TIMEOUT_MS; slept += 100) {
		if (late_bind->component.ops)
			break;
		msleep(100);
	}

	if (!late_bind->component.ops) {
		drm_err(&xe->drm, "Late bind component not bound\n");
		/* Do not re-attempt fw load */
		drmm_kfree(&xe->drm, (void *)lbfw->payload);
		lbfw->payload = NULL;
		goto out;
	}

	drm_dbg(&xe->drm, "Load %s firmware\n", fw_id_to_name[lbfw->id]);

	do {
		ret = late_bind->component.ops->push_payload(late_bind->component.mei_dev,
							     lbfw->type,
							     lbfw->flags,
							     lbfw->payload,
							     lbfw->payload_size);
		if (!ret)
			break;
		msleep(LB_FW_LOAD_RETRY_PAUSE_MS);
	} while (--retry && ret == -EBUSY);

	if (!ret) {
		drm_dbg(&xe->drm, "Load %s firmware successful\n",
			fw_id_to_name[lbfw->id]);
		goto out;
	}

	if (ret > 0)
		drm_err(&xe->drm, "Load %s firmware failed with err %d, %s\n",
			fw_id_to_name[lbfw->id], ret, xe_late_bind_parse_status(ret));
	else
		drm_err(&xe->drm, "Load %s firmware failed with err %d",
			fw_id_to_name[lbfw->id], ret);
	/* Do not re-attempt fw load */
	drmm_kfree(&xe->drm, (void *)lbfw->payload);
	lbfw->payload = NULL;

out:
	xe_pm_runtime_put(xe);
}

int xe_late_bind_fw_load(struct xe_late_bind *late_bind)
{
	struct xe_device *xe = late_bind_to_xe(late_bind);
	struct xe_late_bind_fw *lbfw;
	int fw_id;

	if (!late_bind->component_added)
		return -ENODEV;

	if (late_bind->disable)
		return 0;

	for (fw_id = 0; fw_id < XE_LB_FW_MAX_ID; fw_id++) {
		lbfw = &late_bind->late_bind_fw[fw_id];
		if (lbfw->payload) {
			xe_pm_runtime_get_noresume(xe);
			queue_work(late_bind->wq, &lbfw->work);
		}
	}
	return 0;
}

Annotation

Implementation Notes