File Index
Files and directories
Sign in
FILE

i915_timer_util.c

File preview with syntax highlighting.

linux-6.19.14/drivers/gpu/drm/i915/i915_timer_util.c C
 1// SPDX-License-Identifier: MIT
 2/* Copyright © 2025 Intel Corporation */
 3
 4#include <linux/jiffies.h>
 5
 6#include "i915_timer_util.h"
 7
 8void cancel_timer(struct timer_list *t)
 9{
10	if (!timer_active(t))
11		return;
12
13	timer_delete(t);
14	WRITE_ONCE(t->expires, 0);
15}
16
17void set_timer_ms(struct timer_list *t, unsigned long timeout)
18{
19	if (!timeout) {
20		cancel_timer(t);
21		return;
22	}
23
24	timeout = msecs_to_jiffies(timeout);
25
26	/*
27	 * Paranoia to make sure the compiler computes the timeout before
28	 * loading 'jiffies' as jiffies is volatile and may be updated in
29	 * the background by a timer tick. All to reduce the complexity
30	 * of the addition and reduce the risk of losing a jiffy.
31	 */
32	barrier();
33
34	/* Keep t->expires = 0 reserved to indicate a canceled timer. */
35	mod_timer(t, jiffies + timeout ?: 1);
36}
~/ Read-only file preview.