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/xe/drm_client: Use scope-based cleanup

Use scope-based cleanup for forcewake and runtime PM.

v2:
- Use xe_force_wake_release_only rather than a custom one-off class for
"any engine" forcewake. (Gustavo)

Reviewed-by: Gustavo Sousa <gustavo.sousa@intel.com>
Link: https://patch.msgid.link/20251118164338.3572146-44-matthew.d.roper@intel.com
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>

+16 -21
+16 -21
drivers/gpu/drm/xe/xe_drm_client.c
··· 321 321 struct xe_hw_engine *hwe; 322 322 struct xe_exec_queue *q; 323 323 u64 gpu_timestamp; 324 - struct xe_force_wake_ref fw_ref; 325 324 326 325 /* 327 326 * RING_TIMESTAMP registers are inaccessible in VF mode. ··· 337 338 wait_var_event(&xef->exec_queue.pending_removal, 338 339 !atomic_read(&xef->exec_queue.pending_removal)); 339 340 340 - xe_pm_runtime_get(xe); 341 - fw_ref = force_wake_get_any_engine(xe, &hwe); 342 - if (!hwe) { 343 - xe_pm_runtime_put(xe); 344 - return; 345 - } 341 + scoped_guard(xe_pm_runtime, xe) { 342 + CLASS(xe_force_wake_release_only, fw_ref)(force_wake_get_any_engine(xe, &hwe)); 343 + if (!hwe) 344 + return; 346 345 347 - /* Accumulate all the exec queues from this client */ 348 - mutex_lock(&xef->exec_queue.lock); 349 - xa_for_each(&xef->exec_queue.xa, i, q) { 350 - xe_exec_queue_get(q); 346 + /* Accumulate all the exec queues from this client */ 347 + mutex_lock(&xef->exec_queue.lock); 348 + xa_for_each(&xef->exec_queue.xa, i, q) { 349 + xe_exec_queue_get(q); 350 + mutex_unlock(&xef->exec_queue.lock); 351 + 352 + xe_exec_queue_update_run_ticks(q); 353 + 354 + mutex_lock(&xef->exec_queue.lock); 355 + xe_exec_queue_put(q); 356 + } 351 357 mutex_unlock(&xef->exec_queue.lock); 352 358 353 - xe_exec_queue_update_run_ticks(q); 354 - 355 - mutex_lock(&xef->exec_queue.lock); 356 - xe_exec_queue_put(q); 359 + gpu_timestamp = xe_hw_engine_read_timestamp(hwe); 357 360 } 358 - mutex_unlock(&xef->exec_queue.lock); 359 - 360 - gpu_timestamp = xe_hw_engine_read_timestamp(hwe); 361 - 362 - xe_force_wake_put(gt_to_fw(hwe->gt), fw_ref.domains); 363 - xe_pm_runtime_put(xe); 364 361 365 362 for (class = 0; class < XE_ENGINE_CLASS_MAX; class++) { 366 363 const char *class_name;