drivers/gpu/drm/xe/xe_pm.c

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

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/xe/xe_pm.c
Extension
.c
Size
28217 bytes
Lines
1036
Domain
Driver Families
Bucket
drivers/gpu
Inferred role
Driver Families: exported/initcall integration point
Status
integration 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 (product_name && strstr(product_name, "NUC13RNG")) {
			drm_warn(&xe->drm, "BMG + D3Cold not supported on this platform\n");
			return 0;
		}
	}

	return DEFAULT_VRAM_THRESHOLD;
}

static void xe_pm_wake_rebind_workers(struct xe_device *xe)
{
	struct xe_vm *vm, *next;

	mutex_lock(&xe->rebind_resume_lock);
	list_for_each_entry_safe(vm, next, &xe->rebind_resume_list,
				 preempt.pm_activate_link) {
		list_del_init(&vm->preempt.pm_activate_link);
		xe_vm_resume_rebind_worker(vm);
	}
	mutex_unlock(&xe->rebind_resume_lock);
}

static int xe_pm_notifier_callback(struct notifier_block *nb,
				   unsigned long action, void *data)
{
	struct xe_device *xe = container_of(nb, struct xe_device, pm_notifier);
	int err = 0;

	switch (action) {
	case PM_HIBERNATION_PREPARE:
	case PM_SUSPEND_PREPARE:
	{
		struct xe_validation_ctx ctx;

		reinit_completion(&xe->pm_block);
		xe_pm_block_begin_signalling();
		xe_pm_runtime_get(xe);
		(void)xe_validation_ctx_init(&ctx, &xe->val, NULL,
					     (struct xe_val_flags) {.exclusive = true});
		err = xe_bo_evict_all_user(xe);
		xe_validation_ctx_fini(&ctx);
		if (err)
			drm_dbg(&xe->drm, "Notifier evict user failed (%d)\n", err);

		err = xe_bo_notifier_prepare_all_pinned(xe);
		if (err)
			drm_dbg(&xe->drm, "Notifier prepare pin failed (%d)\n", err);
		/*
		 * Keep the runtime pm reference until post hibernation / post suspend to
		 * avoid a runtime suspend interfering with evicted objects or backup
		 * allocations.
		 */
		xe_pm_block_end_signalling();
		break;
	}
	case PM_POST_HIBERNATION:
	case PM_POST_SUSPEND:
		complete_all(&xe->pm_block);
		xe_pm_wake_rebind_workers(xe);
		xe_bo_notifier_unprepare_all_pinned(xe);
		xe_pm_runtime_put(xe);
		break;
	}

	return NOTIFY_DONE;
}

/**
 * xe_pm_init - Initialize Xe Power Management
 * @xe: xe device instance
 *
 * This component is responsible for System and Device sleep states.
 *
 * Returns 0 for success, negative error code otherwise.
 */
int xe_pm_init(struct xe_device *xe)
{
	u32 vram_threshold;
	int err;

	xe->pm_notifier.notifier_call = xe_pm_notifier_callback;
	err = register_pm_notifier(&xe->pm_notifier);
	if (err)
		return err;

	/* For now suspend/resume is only allowed with GuC */
	if (!xe_device_uc_enabled(xe))
		return 0;

	if (xe->d3cold.capable) {

Annotation

Implementation Notes