Skip to content

Commit 21eb4f1

Browse files
hghimirarodrigovivi
authored andcommitted
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 <[email protected]> Cc: Rodrigo Vivi <[email protected]> Cc: Lucas De Marchi <[email protected]> Signed-off-by: Himal Prasad Ghimiray <[email protected]> Reviewed-by: Badal Nilawar <[email protected]> Reviewed-by: Nirmoy Das <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent 82d9de6 commit 21eb4f1

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

drivers/gpu/drm/xe/xe_gsc.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -261,19 +261,17 @@ static int gsc_upload_and_init(struct xe_gsc *gsc)
261261
{
262262
struct xe_gt *gt = gsc_to_gt(gsc);
263263
struct xe_tile *tile = gt_to_tile(gt);
264+
unsigned int fw_ref;
264265
int ret;
265266

266267
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);
268269

269270
/*
270271
* If the forcewake fails we want to keep going, because the worst
271272
* 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
274274
*/
275-
xe_gt_WARN_ON(tile->primary_gt, ret);
276-
277275
xe_gt_mcr_multicast_write(tile->primary_gt,
278276
EU_SYSTOLIC_LIC_THROTTLE_CTL_WITH_LOCK,
279277
EU_SYSTOLIC_LIC_THROTTLE_CTL_LOCK_BIT);
@@ -282,7 +280,7 @@ static int gsc_upload_and_init(struct xe_gsc *gsc)
282280
ret = gsc_upload(gsc);
283281

284282
if (XE_WA(tile->primary_gt, 14018094691))
285-
xe_force_wake_put(gt_to_fw(tile->primary_gt), XE_FORCEWAKE_ALL);
283+
xe_force_wake_put(gt_to_fw(tile->primary_gt), fw_ref);
286284

287285
if (ret)
288286
return ret;
@@ -352,6 +350,7 @@ static void gsc_work(struct work_struct *work)
352350
struct xe_gsc *gsc = container_of(work, typeof(*gsc), work);
353351
struct xe_gt *gt = gsc_to_gt(gsc);
354352
struct xe_device *xe = gt_to_xe(gt);
353+
unsigned int fw_ref;
355354
u32 actions;
356355
int ret;
357356

@@ -361,7 +360,7 @@ static void gsc_work(struct work_struct *work)
361360
spin_unlock_irq(&gsc->lock);
362361

363362
xe_pm_runtime_get(xe);
364-
xe_gt_WARN_ON(gt, xe_force_wake_get(gt_to_fw(gt), XE_FW_GSC));
363+
fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GSC);
365364

366365
if (actions & GSC_ACTION_ER_COMPLETE) {
367366
ret = gsc_er_complete(gt);
@@ -381,7 +380,7 @@ static void gsc_work(struct work_struct *work)
381380
xe_gsc_proxy_request_handler(gsc);
382381

383382
out:
384-
xe_force_wake_put(gt_to_fw(gt), XE_FW_GSC);
383+
xe_force_wake_put(gt_to_fw(gt), fw_ref);
385384
xe_pm_runtime_put(xe);
386385
}
387386

@@ -601,7 +600,7 @@ void xe_gsc_print_info(struct xe_gsc *gsc, struct drm_printer *p)
601600
{
602601
struct xe_gt *gt = gsc_to_gt(gsc);
603602
struct xe_mmio *mmio = &gt->mmio;
604-
int err;
603+
unsigned int fw_ref;
605604

606605
xe_uc_fw_print(&gsc->fw, p);
607606

@@ -610,8 +609,8 @@ void xe_gsc_print_info(struct xe_gsc *gsc, struct drm_printer *p)
610609
if (!xe_uc_fw_is_enabled(&gsc->fw))
611610
return;
612611

613-
err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GSC);
614-
if (err)
612+
fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GSC);
613+
if (!fw_ref)
615614
return;
616615

617616
drm_printf(p, "\nHECI1 FWSTS: 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n",
@@ -622,5 +621,5 @@ void xe_gsc_print_info(struct xe_gsc *gsc, struct drm_printer *p)
622621
xe_mmio_read32(mmio, HECI_FWSTS5(MTL_GSC_HECI1_BASE)),
623622
xe_mmio_read32(mmio, HECI_FWSTS6(MTL_GSC_HECI1_BASE)));
624623

625-
xe_force_wake_put(gt_to_fw(gt), XE_FW_GSC);
624+
xe_force_wake_put(gt_to_fw(gt), fw_ref);
626625
}

drivers/gpu/drm/xe/xe_gsc_proxy.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -450,22 +450,21 @@ void xe_gsc_proxy_remove(struct xe_gsc *gsc)
450450
{
451451
struct xe_gt *gt = gsc_to_gt(gsc);
452452
struct xe_device *xe = gt_to_xe(gt);
453-
int err = 0;
453+
unsigned int fw_ref = 0;
454454

455455
if (!gsc->proxy.component_added)
456456
return;
457457

458458
/* disable HECI2 IRQs */
459459
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)
462462
xe_gt_err(gt, "failed to get forcewake to disable GSC interrupts\n");
463463

464464
/* try do disable irq even if forcewake failed */
465465
gsc_proxy_irq_toggle(gsc, false);
466466

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);
469468
xe_pm_runtime_put(xe);
470469

471470
xe_gsc_wait_for_worker_completion(gsc);

0 commit comments

Comments
 (0)