Skip to content

Commit 482a483

Browse files
covanamKAGA-KOKO
authored andcommitted
drm/i915/request: Remove unnecessary modification of hrtimer:: Function
When a request is created, the hrtimer is not initialized and only its 'function' field is set to NULL. The hrtimer is only initialized when the request is enqueued. The point of setting 'function' to NULL is that, it can be used to check whether hrtimer_try_to_cancel() should be called while retiring the request. This "trick" is unnecessary, because hrtimer_try_to_cancel() already does its own check whether the timer is armed. If the timer is not armed, hrtimer_try_to_cancel() returns 0. Fully initialize the timer when the request is created, which allows to make the hrtimer::function field private once all users of hrtimer_init() are converted to hrtimer_setup(), which requires a valid callback function to be set. Because hrtimer_try_to_cancel() returns 0 if the timer is not armed, the logic to check whether to call i915_request_put() remains equivalent. Signed-off-by: Nam Cao <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/50f865045aa672a9730343ad131543da332b1d8d.1730386209.git.namcao@linutronix.de
1 parent fbf920f commit 482a483

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

drivers/gpu/drm/i915/i915_request.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,6 @@ i915_request_active_engine(struct i915_request *rq,
273273
return ret;
274274
}
275275

276-
static void __rq_init_watchdog(struct i915_request *rq)
277-
{
278-
rq->watchdog.timer.function = NULL;
279-
}
280-
281276
static enum hrtimer_restart __rq_watchdog_expired(struct hrtimer *hrtimer)
282277
{
283278
struct i915_request *rq =
@@ -294,6 +289,14 @@ static enum hrtimer_restart __rq_watchdog_expired(struct hrtimer *hrtimer)
294289
return HRTIMER_NORESTART;
295290
}
296291

292+
static void __rq_init_watchdog(struct i915_request *rq)
293+
{
294+
struct i915_request_watchdog *wdg = &rq->watchdog;
295+
296+
hrtimer_init(&wdg->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
297+
wdg->timer.function = __rq_watchdog_expired;
298+
}
299+
297300
static void __rq_arm_watchdog(struct i915_request *rq)
298301
{
299302
struct i915_request_watchdog *wdg = &rq->watchdog;
@@ -304,8 +307,6 @@ static void __rq_arm_watchdog(struct i915_request *rq)
304307

305308
i915_request_get(rq);
306309

307-
hrtimer_init(&wdg->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
308-
wdg->timer.function = __rq_watchdog_expired;
309310
hrtimer_start_range_ns(&wdg->timer,
310311
ns_to_ktime(ce->watchdog.timeout_us *
311312
NSEC_PER_USEC),
@@ -317,7 +318,7 @@ static void __rq_cancel_watchdog(struct i915_request *rq)
317318
{
318319
struct i915_request_watchdog *wdg = &rq->watchdog;
319320

320-
if (wdg->timer.function && hrtimer_try_to_cancel(&wdg->timer) > 0)
321+
if (hrtimer_try_to_cancel(&wdg->timer) > 0)
321322
i915_request_put(rq);
322323
}
323324

0 commit comments

Comments
 (0)