Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <namcao@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/50f865045aa672a9730343ad131543da332b1d8d.1730386209.git.namcao@linutronix.de

authored by

Nam Cao and committed by
Thomas Gleixner
482a483c fbf920f2

+9 -8
+9 -8
drivers/gpu/drm/i915/i915_request.c
··· 273 273 return ret; 274 274 } 275 275 276 - static void __rq_init_watchdog(struct i915_request *rq) 277 - { 278 - rq->watchdog.timer.function = NULL; 279 - } 280 - 281 276 static enum hrtimer_restart __rq_watchdog_expired(struct hrtimer *hrtimer) 282 277 { 283 278 struct i915_request *rq = ··· 289 294 return HRTIMER_NORESTART; 290 295 } 291 296 297 + static void __rq_init_watchdog(struct i915_request *rq) 298 + { 299 + struct i915_request_watchdog *wdg = &rq->watchdog; 300 + 301 + hrtimer_init(&wdg->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 302 + wdg->timer.function = __rq_watchdog_expired; 303 + } 304 + 292 305 static void __rq_arm_watchdog(struct i915_request *rq) 293 306 { 294 307 struct i915_request_watchdog *wdg = &rq->watchdog; ··· 307 304 308 305 i915_request_get(rq); 309 306 310 - hrtimer_init(&wdg->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 311 - wdg->timer.function = __rq_watchdog_expired; 312 307 hrtimer_start_range_ns(&wdg->timer, 313 308 ns_to_ktime(ce->watchdog.timeout_us * 314 309 NSEC_PER_USEC), ··· 318 317 { 319 318 struct i915_request_watchdog *wdg = &rq->watchdog; 320 319 321 - if (wdg->timer.function && hrtimer_try_to_cancel(&wdg->timer) > 0) 320 + if (hrtimer_try_to_cancel(&wdg->timer) > 0) 322 321 i915_request_put(rq); 323 322 } 324 323