drivers/gpu/drm/xe/xe_sleep.h

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_sleep.h

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/xe/xe_sleep.h
Extension
.h
Size
1311 bytes
Lines
58
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

#ifndef _XE_SLEEP_H_
#define _XE_SLEEP_H_

#include <linux/delay.h>
#include <linux/math64.h>

/**
 * xe_sleep_relaxed_ms() - Sleep for an approximate time.
 * @delay_ms: time in msec to sleep
 *
 * For smaller timeouts, sleep with 0.5ms accuracy.
 */
static inline void xe_sleep_relaxed_ms(unsigned int delay_ms)
{
	unsigned long min_us, max_us;

	if (!delay_ms)
		return;

	if (delay_ms > 20) {
		msleep(delay_ms);
		return;
	}

	min_us = mul_u32_u32(delay_ms, 1000);
	max_us = min_us + 500;

	usleep_range(min_us, max_us);
}

/**
 * xe_sleep_exponential_ms() - Sleep for a exponentially increased time.
 * @sleep_period_ms: current time in msec to sleep
 * @max_sleep_ms: maximum time in msec to sleep
 *
 * Sleep for the @sleep_period_ms and exponentially increase this time for the
 * next loop, unless reaching the @max_sleep_ms limit.
 *
 * Return: approximate time in msec the task was delayed.
 */
static inline unsigned int xe_sleep_exponential_ms(unsigned int *sleep_period_ms,
						   unsigned int max_sleep_ms)
{
	unsigned int delay_ms = *sleep_period_ms;
	unsigned int next_delay_ms = 2 * delay_ms;

	xe_sleep_relaxed_ms(delay_ms);
	*sleep_period_ms = min(next_delay_ms, max_sleep_ms);
	return delay_ms;
}

#endif

Annotation

Implementation Notes