Skip to content

Commit c72303e

Browse files
tomitamoekogregkh
authored andcommitted
Revert "drm/xe/gt: Update handling of xe_force_wake_get return"
This reverts commit d42b447. The reverted commit updated the handling of xe_force_wake_get to match the new "return refcounted domain mask" semantics introduced in commit a7ddcea ("drm/xe: Error handling in xe_force_wake_get()"). However, that API change only exists in 6.13 and later. In 6.12 stable kernel, xe_force_wake_get still returns a status code. The update incorrectly treats the return value as a mask, causing the return value of 0 to be misinterpreted as an error. As a result, the driver probe fails with -ETIMEDOUT in xe_pci_probe -> xe_device_probe -> xe_gt_init_hwconfig -> xe_force_wake_get. [ 1254.323172] xe 0000:00:02.0: [drm] Found ALDERLAKE_P (device ID 46a6) display version 13.00 stepping D0 [ 1254.323175] xe 0000:00:02.0: [drm:xe_pci_probe [xe]] ALDERLAKE_P 46a6:000c dgfx:0 gfx:Xe_LP (12.00) media:Xe_M (12.00) display:yes dma_m_s:39 tc:1 gscfi:0 cscfi:0 [ 1254.323275] xe 0000:00:02.0: [drm:xe_pci_probe [xe]] Stepping = (G:C0, M:C0, B:**) [ 1254.323328] xe 0000:00:02.0: [drm:xe_pci_probe [xe]] SR-IOV support: no (mode: none) [ 1254.323379] xe 0000:00:02.0: [drm:intel_pch_type [xe]] Found Alder Lake PCH [ 1254.323475] xe 0000:00:02.0: probe with driver xe failed with error -110 Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/5373 Cc: Badal Nilawar <[email protected]> Cc: Matthew Brost <[email protected]> Cc: Rodrigo Vivi <[email protected]> Cc: Lucas De Marchi <[email protected]> Cc: Himal Prasad Ghimiray <[email protected]> Cc: Nirmoy Das <[email protected]> Acked-by: Rodrigo Vivi <[email protected]> Signed-off-by: Tomita Moeko <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 69fbb3f commit c72303e

File tree

1 file changed

+47
-58
lines changed

1 file changed

+47
-58
lines changed

drivers/gpu/drm/xe/xe_gt.c

Lines changed: 47 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ void xe_gt_sanitize(struct xe_gt *gt)
9898

9999
static void xe_gt_enable_host_l2_vram(struct xe_gt *gt)
100100
{
101-
unsigned int fw_ref;
102101
u32 reg;
102+
int err;
103103

104104
if (!XE_WA(gt, 16023588340))
105105
return;
106106

107-
fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
108-
if (!fw_ref)
107+
err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
108+
if (WARN_ON(err))
109109
return;
110110

111111
if (!xe_gt_is_media_type(gt)) {
@@ -115,29 +115,29 @@ static void xe_gt_enable_host_l2_vram(struct xe_gt *gt)
115115
}
116116

117117
xe_gt_mcr_multicast_write(gt, XEHPC_L3CLOS_MASK(3), 0xF);
118-
xe_force_wake_put(gt_to_fw(gt), fw_ref);
118+
xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
119119
}
120120

121121
static void xe_gt_disable_host_l2_vram(struct xe_gt *gt)
122122
{
123-
unsigned int fw_ref;
124123
u32 reg;
124+
int err;
125125

126126
if (!XE_WA(gt, 16023588340))
127127
return;
128128

129129
if (xe_gt_is_media_type(gt))
130130
return;
131131

132-
fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
133-
if (!fw_ref)
132+
err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
133+
if (WARN_ON(err))
134134
return;
135135

136136
reg = xe_gt_mcr_unicast_read_any(gt, XE2_GAMREQSTRM_CTRL);
137137
reg &= ~CG_DIS_CNTLBUS;
138138
xe_gt_mcr_multicast_write(gt, XE2_GAMREQSTRM_CTRL, reg);
139139

140-
xe_force_wake_put(gt_to_fw(gt), fw_ref);
140+
xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
141141
}
142142

143143
/**
@@ -407,14 +407,11 @@ static void dump_pat_on_error(struct xe_gt *gt)
407407

408408
static int gt_fw_domain_init(struct xe_gt *gt)
409409
{
410-
unsigned int fw_ref;
411410
int err, i;
412411

413-
fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
414-
if (!fw_ref) {
415-
err = -ETIMEDOUT;
412+
err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
413+
if (err)
416414
goto err_hw_fence_irq;
417-
}
418415

419416
if (!xe_gt_is_media_type(gt)) {
420417
err = xe_ggtt_init(gt_to_tile(gt)->mem.ggtt);
@@ -449,12 +446,14 @@ static int gt_fw_domain_init(struct xe_gt *gt)
449446
*/
450447
gt->info.gmdid = xe_mmio_read32(gt, GMD_ID);
451448

452-
xe_force_wake_put(gt_to_fw(gt), fw_ref);
449+
err = xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
450+
XE_WARN_ON(err);
451+
453452
return 0;
454453

455454
err_force_wake:
456455
dump_pat_on_error(gt);
457-
xe_force_wake_put(gt_to_fw(gt), fw_ref);
456+
xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
458457
err_hw_fence_irq:
459458
for (i = 0; i < XE_ENGINE_CLASS_MAX; ++i)
460459
xe_hw_fence_irq_finish(&gt->fence_irq[i]);
@@ -464,14 +463,11 @@ static int gt_fw_domain_init(struct xe_gt *gt)
464463

465464
static int all_fw_domain_init(struct xe_gt *gt)
466465
{
467-
unsigned int fw_ref;
468466
int err, i;
469467

470-
fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
471-
if (!xe_force_wake_ref_has_domain(fw_ref, XE_FORCEWAKE_ALL)) {
472-
err = -ETIMEDOUT;
473-
goto err_force_wake;
474-
}
468+
err = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
469+
if (err)
470+
goto err_hw_fence_irq;
475471

476472
xe_gt_mcr_set_implicit_defaults(gt);
477473
xe_wa_process_gt(gt);
@@ -537,12 +533,14 @@ static int all_fw_domain_init(struct xe_gt *gt)
537533
if (IS_SRIOV_PF(gt_to_xe(gt)))
538534
xe_gt_sriov_pf_init_hw(gt);
539535

540-
xe_force_wake_put(gt_to_fw(gt), fw_ref);
536+
err = xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL);
537+
XE_WARN_ON(err);
541538

542539
return 0;
543540

544541
err_force_wake:
545-
xe_force_wake_put(gt_to_fw(gt), fw_ref);
542+
xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL);
543+
err_hw_fence_irq:
546544
for (i = 0; i < XE_ENGINE_CLASS_MAX; ++i)
547545
xe_hw_fence_irq_finish(&gt->fence_irq[i]);
548546

@@ -555,12 +553,11 @@ static int all_fw_domain_init(struct xe_gt *gt)
555553
*/
556554
int xe_gt_init_hwconfig(struct xe_gt *gt)
557555
{
558-
unsigned int fw_ref;
559556
int err;
560557

561-
fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
562-
if (!fw_ref)
563-
return -ETIMEDOUT;
558+
err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
559+
if (err)
560+
goto out;
564561

565562
xe_gt_mcr_init_early(gt);
566563
xe_pat_init(gt);
@@ -578,7 +575,8 @@ int xe_gt_init_hwconfig(struct xe_gt *gt)
578575
xe_gt_enable_host_l2_vram(gt);
579576

580577
out_fw:
581-
xe_force_wake_put(gt_to_fw(gt), fw_ref);
578+
xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
579+
out:
582580
return err;
583581
}
584582

@@ -746,7 +744,6 @@ static int do_gt_restart(struct xe_gt *gt)
746744

747745
static int gt_reset(struct xe_gt *gt)
748746
{
749-
unsigned int fw_ref;
750747
int err;
751748

752749
if (xe_device_wedged(gt_to_xe(gt)))
@@ -767,11 +764,9 @@ static int gt_reset(struct xe_gt *gt)
767764

768765
xe_gt_sanitize(gt);
769766

770-
fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
771-
if (!xe_force_wake_ref_has_domain(fw_ref, XE_FORCEWAKE_ALL)) {
772-
err = -ETIMEDOUT;
773-
goto err_out;
774-
}
767+
err = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
768+
if (err)
769+
goto err_msg;
775770

776771
if (IS_SRIOV_PF(gt_to_xe(gt)))
777772
xe_gt_sriov_pf_stop_prepare(gt);
@@ -792,15 +787,17 @@ static int gt_reset(struct xe_gt *gt)
792787
if (err)
793788
goto err_out;
794789

795-
xe_force_wake_put(gt_to_fw(gt), fw_ref);
790+
err = xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL);
791+
XE_WARN_ON(err);
796792
xe_pm_runtime_put(gt_to_xe(gt));
797793

798794
xe_gt_info(gt, "reset done\n");
799795

800796
return 0;
801797

802798
err_out:
803-
xe_force_wake_put(gt_to_fw(gt), fw_ref);
799+
XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL));
800+
err_msg:
804801
XE_WARN_ON(xe_uc_start(&gt->uc));
805802
err_fail:
806803
xe_gt_err(gt, "reset failed (%pe)\n", ERR_PTR(err));
@@ -832,25 +829,22 @@ void xe_gt_reset_async(struct xe_gt *gt)
832829

833830
void xe_gt_suspend_prepare(struct xe_gt *gt)
834831
{
835-
unsigned int fw_ref;
836-
837-
fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
832+
XE_WARN_ON(xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL));
838833

839834
xe_uc_suspend_prepare(&gt->uc);
840835

841-
xe_force_wake_put(gt_to_fw(gt), fw_ref);
836+
XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL));
842837
}
843838

844839
int xe_gt_suspend(struct xe_gt *gt)
845840
{
846-
unsigned int fw_ref;
847841
int err;
848842

849843
xe_gt_dbg(gt, "suspending\n");
850844
xe_gt_sanitize(gt);
851845

852-
fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
853-
if (!xe_force_wake_ref_has_domain(fw_ref, XE_FORCEWAKE_ALL))
846+
err = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
847+
if (err)
854848
goto err_msg;
855849

856850
err = xe_uc_suspend(&gt->uc);
@@ -861,27 +855,24 @@ int xe_gt_suspend(struct xe_gt *gt)
861855

862856
xe_gt_disable_host_l2_vram(gt);
863857

864-
xe_force_wake_put(gt_to_fw(gt), fw_ref);
858+
XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL));
865859
xe_gt_dbg(gt, "suspended\n");
866860

867861
return 0;
868862

869-
err_msg:
870-
err = -ETIMEDOUT;
871863
err_force_wake:
872-
xe_force_wake_put(gt_to_fw(gt), fw_ref);
864+
XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL));
865+
err_msg:
873866
xe_gt_err(gt, "suspend failed (%pe)\n", ERR_PTR(err));
874867

875868
return err;
876869
}
877870

878871
void xe_gt_shutdown(struct xe_gt *gt)
879872
{
880-
unsigned int fw_ref;
881-
882-
fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
873+
xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
883874
do_gt_reset(gt);
884-
xe_force_wake_put(gt_to_fw(gt), fw_ref);
875+
xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL);
885876
}
886877

887878
/**
@@ -906,12 +897,11 @@ int xe_gt_sanitize_freq(struct xe_gt *gt)
906897

907898
int xe_gt_resume(struct xe_gt *gt)
908899
{
909-
unsigned int fw_ref;
910900
int err;
911901

912902
xe_gt_dbg(gt, "resuming\n");
913-
fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
914-
if (!xe_force_wake_ref_has_domain(fw_ref, XE_FORCEWAKE_ALL))
903+
err = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
904+
if (err)
915905
goto err_msg;
916906

917907
err = do_gt_restart(gt);
@@ -920,15 +910,14 @@ int xe_gt_resume(struct xe_gt *gt)
920910

921911
xe_gt_idle_enable_pg(gt);
922912

923-
xe_force_wake_put(gt_to_fw(gt), fw_ref);
913+
XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL));
924914
xe_gt_dbg(gt, "resumed\n");
925915

926916
return 0;
927917

928-
err_msg:
929-
err = -ETIMEDOUT;
930918
err_force_wake:
931-
xe_force_wake_put(gt_to_fw(gt), fw_ref);
919+
XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL));
920+
err_msg:
932921
xe_gt_err(gt, "resume failed (%pe)\n", ERR_PTR(err));
933922

934923
return err;

0 commit comments

Comments
 (0)