Skip to content

Commit 3b41f88

Browse files
hghimirarodrigovivi
authored andcommitted
drm/xe/device: 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() - xe_force_wake_put() error doesn't need to be escalated/considered as probing error. It internally WARNS on domain ack failure. v5 - return unsigned int xe_force_wake_get() v7 - Fix commit message(Badal) v9 - s/uint/unsigned int (Nikula) Cc: Jani Nikula <[email protected]> Cc: Badal Nilawar <[email protected]> Cc: Rodrigo Vivi <[email protected]> Signed-off-by: Himal Prasad Ghimiray <[email protected]> Reviewed-by: Nirmoy Das <[email protected]> Reviewed-by: Badal Nilawar <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent 79f716b commit 3b41f88

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

drivers/gpu/drm/xe/xe_device.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -604,18 +604,18 @@ int xe_device_probe_early(struct xe_device *xe)
604604
static int probe_has_flat_ccs(struct xe_device *xe)
605605
{
606606
struct xe_gt *gt;
607+
unsigned int fw_ref;
607608
u32 reg;
608-
int err;
609609

610610
/* Always enabled/disabled, no runtime check to do */
611611
if (GRAPHICS_VER(xe) < 20 || !xe->info.has_flat_ccs)
612612
return 0;
613613

614614
gt = xe_root_mmio_gt(xe);
615615

616-
err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
617-
if (err)
618-
return err;
616+
fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
617+
if (!fw_ref)
618+
return -ETIMEDOUT;
619619

620620
reg = xe_gt_mcr_unicast_read_any(gt, XE2_FLAT_CCS_BASE_RANGE_LOWER);
621621
xe->info.has_flat_ccs = (reg & XE2_FLAT_CCS_ENABLE);
@@ -624,7 +624,8 @@ static int probe_has_flat_ccs(struct xe_device *xe)
624624
drm_dbg(&xe->drm,
625625
"Flat CCS has been disabled in bios, May lead to performance impact");
626626

627-
return xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
627+
xe_force_wake_put(gt_to_fw(gt), fw_ref);
628+
return 0;
628629
}
629630

630631
int xe_device_probe(struct xe_device *xe)
@@ -875,6 +876,7 @@ void xe_device_wmb(struct xe_device *xe)
875876
void xe_device_td_flush(struct xe_device *xe)
876877
{
877878
struct xe_gt *gt;
879+
unsigned int fw_ref;
878880
u8 id;
879881

880882
if (!IS_DGFX(xe) || GRAPHICS_VER(xe) < 20)
@@ -889,7 +891,8 @@ void xe_device_td_flush(struct xe_device *xe)
889891
if (xe_gt_is_media_type(gt))
890892
continue;
891893

892-
if (xe_force_wake_get(gt_to_fw(gt), XE_FW_GT))
894+
fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
895+
if (!fw_ref)
893896
return;
894897

895898
xe_mmio_write32(&gt->mmio, XE2_TDF_CTRL, TRANSIENT_FLUSH_REQUEST);
@@ -904,22 +907,22 @@ void xe_device_td_flush(struct xe_device *xe)
904907
150, NULL, false))
905908
xe_gt_err_once(gt, "TD flush timeout\n");
906909

907-
xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
910+
xe_force_wake_put(gt_to_fw(gt), fw_ref);
908911
}
909912
}
910913

911914
void xe_device_l2_flush(struct xe_device *xe)
912915
{
913916
struct xe_gt *gt;
914-
int err;
917+
unsigned int fw_ref;
915918

916919
gt = xe_root_mmio_gt(xe);
917920

918921
if (!XE_WA(gt, 16023588340))
919922
return;
920923

921-
err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
922-
if (err)
924+
fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
925+
if (!fw_ref)
923926
return;
924927

925928
spin_lock(&gt->global_invl_lock);
@@ -929,7 +932,7 @@ void xe_device_l2_flush(struct xe_device *xe)
929932
xe_gt_err_once(gt, "Global invalidation timeout\n");
930933
spin_unlock(&gt->global_invl_lock);
931934

932-
xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
935+
xe_force_wake_put(gt_to_fw(gt), fw_ref);
933936
}
934937

935938
u32 xe_device_ccs_bytes(struct xe_device *xe, u64 size)

0 commit comments

Comments
 (0)