@@ -97,14 +97,14 @@ void xe_gt_sanitize(struct xe_gt *gt)
97
97
98
98
static void xe_gt_enable_host_l2_vram (struct xe_gt * gt )
99
99
{
100
+ unsigned int fw_ref ;
100
101
u32 reg ;
101
- int err ;
102
102
103
103
if (!XE_WA (gt , 16023588340 ))
104
104
return ;
105
105
106
- err = xe_force_wake_get (gt_to_fw (gt ), XE_FW_GT );
107
- if (WARN_ON ( err ) )
106
+ fw_ref = xe_force_wake_get (gt_to_fw (gt ), XE_FW_GT );
107
+ if (! fw_ref )
108
108
return ;
109
109
110
110
if (!xe_gt_is_media_type (gt )) {
@@ -114,29 +114,29 @@ static void xe_gt_enable_host_l2_vram(struct xe_gt *gt)
114
114
}
115
115
116
116
xe_gt_mcr_multicast_write (gt , XEHPC_L3CLOS_MASK (3 ), 0x3 );
117
- xe_force_wake_put (gt_to_fw (gt ), XE_FW_GT );
117
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
118
118
}
119
119
120
120
static void xe_gt_disable_host_l2_vram (struct xe_gt * gt )
121
121
{
122
+ unsigned int fw_ref ;
122
123
u32 reg ;
123
- int err ;
124
124
125
125
if (!XE_WA (gt , 16023588340 ))
126
126
return ;
127
127
128
128
if (xe_gt_is_media_type (gt ))
129
129
return ;
130
130
131
- err = xe_force_wake_get (gt_to_fw (gt ), XE_FW_GT );
132
- if (WARN_ON ( err ) )
131
+ fw_ref = xe_force_wake_get (gt_to_fw (gt ), XE_FW_GT );
132
+ if (! fw_ref )
133
133
return ;
134
134
135
135
reg = xe_gt_mcr_unicast_read_any (gt , XE2_GAMREQSTRM_CTRL );
136
136
reg &= ~CG_DIS_CNTLBUS ;
137
137
xe_gt_mcr_multicast_write (gt , XE2_GAMREQSTRM_CTRL , reg );
138
138
139
- xe_force_wake_put (gt_to_fw (gt ), XE_FW_GT );
139
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
140
140
}
141
141
142
142
/**
@@ -402,11 +402,14 @@ static void dump_pat_on_error(struct xe_gt *gt)
402
402
403
403
static int gt_fw_domain_init (struct xe_gt * gt )
404
404
{
405
+ unsigned int fw_ref ;
405
406
int err , i ;
406
407
407
- err = xe_force_wake_get (gt_to_fw (gt ), XE_FW_GT );
408
- if (err )
408
+ fw_ref = xe_force_wake_get (gt_to_fw (gt ), XE_FW_GT );
409
+ if (!fw_ref ) {
410
+ err = - ETIMEDOUT ;
409
411
goto err_hw_fence_irq ;
412
+ }
410
413
411
414
if (!xe_gt_is_media_type (gt )) {
412
415
err = xe_ggtt_init (gt_to_tile (gt )-> mem .ggtt );
@@ -441,14 +444,12 @@ static int gt_fw_domain_init(struct xe_gt *gt)
441
444
*/
442
445
gt -> info .gmdid = xe_mmio_read32 (& gt -> mmio , GMD_ID );
443
446
444
- err = xe_force_wake_put (gt_to_fw (gt ), XE_FW_GT );
445
- XE_WARN_ON (err );
446
-
447
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
447
448
return 0 ;
448
449
449
450
err_force_wake :
450
451
dump_pat_on_error (gt );
451
- xe_force_wake_put (gt_to_fw (gt ), XE_FW_GT );
452
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
452
453
err_hw_fence_irq :
453
454
for (i = 0 ; i < XE_ENGINE_CLASS_MAX ; ++ i )
454
455
xe_hw_fence_irq_finish (& gt -> fence_irq [i ]);
@@ -458,11 +459,14 @@ static int gt_fw_domain_init(struct xe_gt *gt)
458
459
459
460
static int all_fw_domain_init (struct xe_gt * gt )
460
461
{
462
+ unsigned int fw_ref ;
461
463
int err , i ;
462
464
463
- err = xe_force_wake_get (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
464
- if (err )
465
- goto err_hw_fence_irq ;
465
+ fw_ref = xe_force_wake_get (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
466
+ if (!xe_force_wake_ref_has_domain (fw_ref , XE_FORCEWAKE_ALL )) {
467
+ err = - ETIMEDOUT ;
468
+ goto err_force_wake ;
469
+ }
466
470
467
471
xe_gt_mcr_set_implicit_defaults (gt );
468
472
xe_reg_sr_apply_mmio (& gt -> reg_sr , gt );
@@ -526,14 +530,12 @@ static int all_fw_domain_init(struct xe_gt *gt)
526
530
if (IS_SRIOV_PF (gt_to_xe (gt )))
527
531
xe_gt_sriov_pf_init_hw (gt );
528
532
529
- err = xe_force_wake_put (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
530
- XE_WARN_ON (err );
533
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
531
534
532
535
return 0 ;
533
536
534
537
err_force_wake :
535
- xe_force_wake_put (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
536
- err_hw_fence_irq :
538
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
537
539
for (i = 0 ; i < XE_ENGINE_CLASS_MAX ; ++ i )
538
540
xe_hw_fence_irq_finish (& gt -> fence_irq [i ]);
539
541
@@ -546,11 +548,12 @@ static int all_fw_domain_init(struct xe_gt *gt)
546
548
*/
547
549
int xe_gt_init_hwconfig (struct xe_gt * gt )
548
550
{
551
+ unsigned int fw_ref ;
549
552
int err ;
550
553
551
- err = xe_force_wake_get (gt_to_fw (gt ), XE_FW_GT );
552
- if (err )
553
- goto out ;
554
+ fw_ref = xe_force_wake_get (gt_to_fw (gt ), XE_FW_GT );
555
+ if (! fw_ref )
556
+ return - ETIMEDOUT ;
554
557
555
558
xe_gt_mcr_init_early (gt );
556
559
xe_pat_init (gt );
@@ -568,8 +571,7 @@ int xe_gt_init_hwconfig(struct xe_gt *gt)
568
571
xe_gt_enable_host_l2_vram (gt );
569
572
570
573
out_fw :
571
- xe_force_wake_put (gt_to_fw (gt ), XE_FW_GT );
572
- out :
574
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
573
575
return err ;
574
576
}
575
577
@@ -764,6 +766,7 @@ static int do_gt_restart(struct xe_gt *gt)
764
766
765
767
static int gt_reset (struct xe_gt * gt )
766
768
{
769
+ unsigned int fw_ref ;
767
770
int err ;
768
771
769
772
if (xe_device_wedged (gt_to_xe (gt )))
@@ -784,9 +787,11 @@ static int gt_reset(struct xe_gt *gt)
784
787
785
788
xe_gt_sanitize (gt );
786
789
787
- err = xe_force_wake_get (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
788
- if (err )
789
- goto err_msg ;
790
+ fw_ref = xe_force_wake_get (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
791
+ if (!xe_force_wake_ref_has_domain (fw_ref , XE_FORCEWAKE_ALL )) {
792
+ err = - ETIMEDOUT ;
793
+ goto err_out ;
794
+ }
790
795
791
796
xe_uc_gucrc_disable (& gt -> uc );
792
797
xe_uc_stop_prepare (& gt -> uc );
@@ -804,17 +809,15 @@ static int gt_reset(struct xe_gt *gt)
804
809
if (err )
805
810
goto err_out ;
806
811
807
- err = xe_force_wake_put (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
808
- XE_WARN_ON (err );
812
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
809
813
xe_pm_runtime_put (gt_to_xe (gt ));
810
814
811
815
xe_gt_info (gt , "reset done\n" );
812
816
813
817
return 0 ;
814
818
815
819
err_out :
816
- XE_WARN_ON (xe_force_wake_put (gt_to_fw (gt ), XE_FORCEWAKE_ALL ));
817
- err_msg :
820
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
818
821
XE_WARN_ON (xe_uc_start (& gt -> uc ));
819
822
err_fail :
820
823
xe_gt_err (gt , "reset failed (%pe)\n" , ERR_PTR (err ));
@@ -846,22 +849,25 @@ void xe_gt_reset_async(struct xe_gt *gt)
846
849
847
850
void xe_gt_suspend_prepare (struct xe_gt * gt )
848
851
{
849
- XE_WARN_ON (xe_force_wake_get (gt_to_fw (gt ), XE_FORCEWAKE_ALL ));
852
+ unsigned int fw_ref ;
853
+
854
+ fw_ref = xe_force_wake_get (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
850
855
851
856
xe_uc_stop_prepare (& gt -> uc );
852
857
853
- XE_WARN_ON ( xe_force_wake_put (gt_to_fw (gt ), XE_FORCEWAKE_ALL ) );
858
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
854
859
}
855
860
856
861
int xe_gt_suspend (struct xe_gt * gt )
857
862
{
863
+ unsigned int fw_ref ;
858
864
int err ;
859
865
860
866
xe_gt_dbg (gt , "suspending\n" );
861
867
xe_gt_sanitize (gt );
862
868
863
- err = xe_force_wake_get (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
864
- if (err )
869
+ fw_ref = xe_force_wake_get (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
870
+ if (! xe_force_wake_ref_has_domain ( fw_ref , XE_FORCEWAKE_ALL ) )
865
871
goto err_msg ;
866
872
867
873
err = xe_uc_suspend (& gt -> uc );
@@ -872,24 +878,27 @@ int xe_gt_suspend(struct xe_gt *gt)
872
878
873
879
xe_gt_disable_host_l2_vram (gt );
874
880
875
- XE_WARN_ON ( xe_force_wake_put (gt_to_fw (gt ), XE_FORCEWAKE_ALL ) );
881
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
876
882
xe_gt_dbg (gt , "suspended\n" );
877
883
878
884
return 0 ;
879
885
880
- err_force_wake :
881
- XE_WARN_ON (xe_force_wake_put (gt_to_fw (gt ), XE_FORCEWAKE_ALL ));
882
886
err_msg :
887
+ err = - ETIMEDOUT ;
888
+ err_force_wake :
889
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
883
890
xe_gt_err (gt , "suspend failed (%pe)\n" , ERR_PTR (err ));
884
891
885
892
return err ;
886
893
}
887
894
888
895
void xe_gt_shutdown (struct xe_gt * gt )
889
896
{
890
- xe_force_wake_get (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
897
+ unsigned int fw_ref ;
898
+
899
+ fw_ref = xe_force_wake_get (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
891
900
do_gt_reset (gt );
892
- xe_force_wake_put (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
901
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
893
902
}
894
903
895
904
/**
@@ -914,11 +923,12 @@ int xe_gt_sanitize_freq(struct xe_gt *gt)
914
923
915
924
int xe_gt_resume (struct xe_gt * gt )
916
925
{
926
+ unsigned int fw_ref ;
917
927
int err ;
918
928
919
929
xe_gt_dbg (gt , "resuming\n" );
920
- err = xe_force_wake_get (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
921
- if (err )
930
+ fw_ref = xe_force_wake_get (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
931
+ if (! xe_force_wake_ref_has_domain ( fw_ref , XE_FORCEWAKE_ALL ) )
922
932
goto err_msg ;
923
933
924
934
err = do_gt_restart (gt );
@@ -927,14 +937,15 @@ int xe_gt_resume(struct xe_gt *gt)
927
937
928
938
xe_gt_idle_enable_pg (gt );
929
939
930
- XE_WARN_ON ( xe_force_wake_put (gt_to_fw (gt ), XE_FORCEWAKE_ALL ) );
940
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
931
941
xe_gt_dbg (gt , "resumed\n" );
932
942
933
943
return 0 ;
934
944
935
- err_force_wake :
936
- XE_WARN_ON (xe_force_wake_put (gt_to_fw (gt ), XE_FORCEWAKE_ALL ));
937
945
err_msg :
946
+ err = - ETIMEDOUT ;
947
+ err_force_wake :
948
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
938
949
xe_gt_err (gt , "resume failed (%pe)\n" , ERR_PTR (err ));
939
950
940
951
return err ;
0 commit comments