drivers/gpu/drm/i915/i915_timer_util.c

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

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/i915/i915_timer_util.c
Extension
.c
Size
799 bytes
Lines
37
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

// SPDX-License-Identifier: MIT
/* Copyright © 2025 Intel Corporation */

#include <linux/jiffies.h>

#include "i915_timer_util.h"

void cancel_timer(struct timer_list *t)
{
	if (!timer_active(t))
		return;

	timer_delete(t);
	WRITE_ONCE(t->expires, 0);
}

void set_timer_ms(struct timer_list *t, unsigned long timeout)
{
	if (!timeout) {
		cancel_timer(t);
		return;
	}

	timeout = msecs_to_jiffies(timeout);

	/*
	 * Paranoia to make sure the compiler computes the timeout before
	 * loading 'jiffies' as jiffies is volatile and may be updated in
	 * the background by a timer tick. All to reduce the complexity
	 * of the addition and reduce the risk of losing a jiffy.
	 */
	barrier();

	/* Keep t->expires = 0 reserved to indicate a canceled timer. */
	mod_timer(t, jiffies + timeout ?: 1);
}

Annotation

Implementation Notes