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

drm/xe/gsc: Update handling of xe_force_wake_get return

xe_force_wake_get() now returns the reference count-incremented domain
mask. If it fails for individual domains, the return value will always
be 0. However, for XE_FORCEWAKE_ALL, it may return a non-zero value even
in the event of failure. Update the return handling of xe_force_wake_get()
to reflect this behavior, and ensure that the return value is passed as
input to xe_force_wake_put().

v3
- return xe_wakeref_t instead of int in xe_force_wake_get()

v5
- return unsigned int for xe_force_wake_get()
- No need to WARN from caller in case of forcewake get failure.

v7
- Fix commit message

Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Reviewed-by: Badal Nilawar <badal.nilawar@intel.com>
Reviewed-by: Nirmoy Das <nirmoy.das@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20241014075601.2324382-9-himal.prasad.ghimiray@intel.com
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

authored by

Himal Prasad Ghimiray and committed by
Rodrigo Vivi
21eb4f17 82d9de63

+15 -17
+11 -12
drivers/gpu/drm/xe/xe_gsc.c
··· 261 261 { 262 262 struct xe_gt *gt = gsc_to_gt(gsc); 263 263 struct xe_tile *tile = gt_to_tile(gt); 264 + unsigned int fw_ref; 264 265 int ret; 265 266 266 267 if (XE_WA(tile->primary_gt, 14018094691)) { 267 - ret = xe_force_wake_get(gt_to_fw(tile->primary_gt), XE_FORCEWAKE_ALL); 268 + fw_ref = xe_force_wake_get(gt_to_fw(tile->primary_gt), XE_FORCEWAKE_ALL); 268 269 269 270 /* 270 271 * If the forcewake fails we want to keep going, because the worst 271 272 * case outcome in failing to apply the WA is that PXP won't work, 272 - * which is not fatal. We still throw a warning so the issue is 273 - * seen if it happens. 273 + * which is not fatal. Forcewake get warns implicitly in case of failure 274 274 */ 275 - xe_gt_WARN_ON(tile->primary_gt, ret); 276 - 277 275 xe_gt_mcr_multicast_write(tile->primary_gt, 278 276 EU_SYSTOLIC_LIC_THROTTLE_CTL_WITH_LOCK, 279 277 EU_SYSTOLIC_LIC_THROTTLE_CTL_LOCK_BIT); ··· 280 282 ret = gsc_upload(gsc); 281 283 282 284 if (XE_WA(tile->primary_gt, 14018094691)) 283 - xe_force_wake_put(gt_to_fw(tile->primary_gt), XE_FORCEWAKE_ALL); 285 + xe_force_wake_put(gt_to_fw(tile->primary_gt), fw_ref); 284 286 285 287 if (ret) 286 288 return ret; ··· 350 352 struct xe_gsc *gsc = container_of(work, typeof(*gsc), work); 351 353 struct xe_gt *gt = gsc_to_gt(gsc); 352 354 struct xe_device *xe = gt_to_xe(gt); 355 + unsigned int fw_ref; 353 356 u32 actions; 354 357 int ret; 355 358 ··· 360 361 spin_unlock_irq(&gsc->lock); 361 362 362 363 xe_pm_runtime_get(xe); 363 - xe_gt_WARN_ON(gt, xe_force_wake_get(gt_to_fw(gt), XE_FW_GSC)); 364 + fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GSC); 364 365 365 366 if (actions & GSC_ACTION_ER_COMPLETE) { 366 367 ret = gsc_er_complete(gt); ··· 380 381 xe_gsc_proxy_request_handler(gsc); 381 382 382 383 out: 383 - xe_force_wake_put(gt_to_fw(gt), XE_FW_GSC); 384 + xe_force_wake_put(gt_to_fw(gt), fw_ref); 384 385 xe_pm_runtime_put(xe); 385 386 } 386 387 ··· 600 601 { 601 602 struct xe_gt *gt = gsc_to_gt(gsc); 602 603 struct xe_mmio *mmio = &gt->mmio; 603 - int err; 604 + unsigned int fw_ref; 604 605 605 606 xe_uc_fw_print(&gsc->fw, p); 606 607 ··· 609 610 if (!xe_uc_fw_is_enabled(&gsc->fw)) 610 611 return; 611 612 612 - err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GSC); 613 - if (err) 613 + fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GSC); 614 + if (!fw_ref) 614 615 return; 615 616 616 617 drm_printf(p, "\nHECI1 FWSTS: 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n", ··· 621 622 xe_mmio_read32(mmio, HECI_FWSTS5(MTL_GSC_HECI1_BASE)), 622 623 xe_mmio_read32(mmio, HECI_FWSTS6(MTL_GSC_HECI1_BASE))); 623 624 624 - xe_force_wake_put(gt_to_fw(gt), XE_FW_GSC); 625 + xe_force_wake_put(gt_to_fw(gt), fw_ref); 625 626 }
+4 -5
drivers/gpu/drm/xe/xe_gsc_proxy.c
··· 450 450 { 451 451 struct xe_gt *gt = gsc_to_gt(gsc); 452 452 struct xe_device *xe = gt_to_xe(gt); 453 - int err = 0; 453 + unsigned int fw_ref = 0; 454 454 455 455 if (!gsc->proxy.component_added) 456 456 return; 457 457 458 458 /* disable HECI2 IRQs */ 459 459 xe_pm_runtime_get(xe); 460 - err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GSC); 461 - if (err) 460 + fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GSC); 461 + if (!fw_ref) 462 462 xe_gt_err(gt, "failed to get forcewake to disable GSC interrupts\n"); 463 463 464 464 /* try do disable irq even if forcewake failed */ 465 465 gsc_proxy_irq_toggle(gsc, false); 466 466 467 - if (!err) 468 - xe_force_wake_put(gt_to_fw(gt), XE_FW_GSC); 467 + xe_force_wake_put(gt_to_fw(gt), fw_ref); 469 468 xe_pm_runtime_put(xe); 470 469 471 470 xe_gsc_wait_for_worker_completion(gsc);