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: Return forcewake reference type from force_wake_get_any_engine()

Adjust the signature of force_wake_get_any_engine() such that it returns
a 'struct xe_force_wake_ref' rather than a boolean success/failure.
Failure cases are now recognized by inspecting the hardware engine
returned by reference; a NULL hwe indicates that no engine's forcewake
could be obtained.

These changes will make it cleaner and easier to incorporate scope-based
cleanup in force_wake_get_any_engine()'s caller in a future patch.

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

+19 -19
+19 -19
drivers/gpu/drm/xe/xe_drm_client.c
··· 285 285 return NULL; 286 286 } 287 287 288 - static bool force_wake_get_any_engine(struct xe_device *xe, 289 - struct xe_hw_engine **phwe, 290 - unsigned int *pfw_ref) 288 + /* 289 + * Pick any engine and grab its forcewake. On error phwe will be NULL and 290 + * the returned forcewake reference will be invalid. Callers should check 291 + * phwe against NULL. 292 + */ 293 + static struct xe_force_wake_ref force_wake_get_any_engine(struct xe_device *xe, 294 + struct xe_hw_engine **phwe) 291 295 { 292 296 enum xe_force_wake_domains domain; 293 - unsigned int fw_ref; 297 + struct xe_force_wake_ref fw_ref = {}; 294 298 struct xe_hw_engine *hwe; 295 - struct xe_force_wake *fw; 299 + 300 + *phwe = NULL; 296 301 297 302 hwe = any_engine(xe); 298 303 if (!hwe) 299 - return false; 304 + return fw_ref; /* will be invalid */ 300 305 301 306 domain = xe_hw_engine_to_fw_domain(hwe); 302 - fw = gt_to_fw(hwe->gt); 303 307 304 - fw_ref = xe_force_wake_get(fw, domain); 305 - if (!xe_force_wake_ref_has_domain(fw_ref, domain)) { 306 - xe_force_wake_put(fw, fw_ref); 307 - return false; 308 - } 308 + fw_ref = xe_force_wake_constructor(gt_to_fw(hwe->gt), domain); 309 + if (xe_force_wake_ref_has_domain(fw_ref.domains, domain)) 310 + *phwe = hwe; /* valid forcewake */ 309 311 310 - *phwe = hwe; 311 - *pfw_ref = fw_ref; 312 - 313 - return true; 312 + return fw_ref; 314 313 } 315 314 316 315 static void show_run_ticks(struct drm_printer *p, struct drm_file *file) ··· 321 322 struct xe_hw_engine *hwe; 322 323 struct xe_exec_queue *q; 323 324 u64 gpu_timestamp; 324 - unsigned int fw_ref; 325 + struct xe_force_wake_ref fw_ref; 325 326 326 327 /* 327 328 * RING_TIMESTAMP registers are inaccessible in VF mode. ··· 339 340 !atomic_read(&xef->exec_queue.pending_removal)); 340 341 341 342 xe_pm_runtime_get(xe); 342 - if (!force_wake_get_any_engine(xe, &hwe, &fw_ref)) { 343 + fw_ref = force_wake_get_any_engine(xe, &hwe); 344 + if (!hwe) { 343 345 xe_pm_runtime_put(xe); 344 346 return; 345 347 } ··· 360 360 361 361 gpu_timestamp = xe_hw_engine_read_timestamp(hwe); 362 362 363 - xe_force_wake_put(gt_to_fw(hwe->gt), fw_ref); 363 + xe_force_wake_put(gt_to_fw(hwe->gt), fw_ref.domains); 364 364 xe_pm_runtime_put(xe); 365 365 366 366 for (class = 0; class < XE_ENGINE_CLASS_MAX; class++) {