@@ -98,14 +98,14 @@ void xe_gt_sanitize(struct xe_gt *gt)
98
98
99
99
static void xe_gt_enable_host_l2_vram (struct xe_gt * gt )
100
100
{
101
+ unsigned int fw_ref ;
101
102
u32 reg ;
102
- int err ;
103
103
104
104
if (!XE_WA (gt , 16023588340 ))
105
105
return ;
106
106
107
- err = xe_force_wake_get (gt_to_fw (gt ), XE_FW_GT );
108
- if (WARN_ON ( err ) )
107
+ fw_ref = xe_force_wake_get (gt_to_fw (gt ), XE_FW_GT );
108
+ if (! fw_ref )
109
109
return ;
110
110
111
111
if (!xe_gt_is_media_type (gt )) {
@@ -115,29 +115,29 @@ static void xe_gt_enable_host_l2_vram(struct xe_gt *gt)
115
115
}
116
116
117
117
xe_gt_mcr_multicast_write (gt , XEHPC_L3CLOS_MASK (3 ), 0x3 );
118
- xe_force_wake_put (gt_to_fw (gt ), XE_FW_GT );
118
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
119
119
}
120
120
121
121
static void xe_gt_disable_host_l2_vram (struct xe_gt * gt )
122
122
{
123
+ unsigned int fw_ref ;
123
124
u32 reg ;
124
- int err ;
125
125
126
126
if (!XE_WA (gt , 16023588340 ))
127
127
return ;
128
128
129
129
if (xe_gt_is_media_type (gt ))
130
130
return ;
131
131
132
- err = xe_force_wake_get (gt_to_fw (gt ), XE_FW_GT );
133
- if (WARN_ON ( err ) )
132
+ fw_ref = xe_force_wake_get (gt_to_fw (gt ), XE_FW_GT );
133
+ if (! fw_ref )
134
134
return ;
135
135
136
136
reg = xe_gt_mcr_unicast_read_any (gt , XE2_GAMREQSTRM_CTRL );
137
137
reg &= ~CG_DIS_CNTLBUS ;
138
138
xe_gt_mcr_multicast_write (gt , XE2_GAMREQSTRM_CTRL , reg );
139
139
140
- xe_force_wake_put (gt_to_fw (gt ), XE_FW_GT );
140
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
141
141
}
142
142
143
143
/**
@@ -405,11 +405,14 @@ static void dump_pat_on_error(struct xe_gt *gt)
405
405
406
406
static int gt_fw_domain_init (struct xe_gt * gt )
407
407
{
408
+ unsigned int fw_ref ;
408
409
int err , i ;
409
410
410
- err = xe_force_wake_get (gt_to_fw (gt ), XE_FW_GT );
411
- if (err )
411
+ fw_ref = xe_force_wake_get (gt_to_fw (gt ), XE_FW_GT );
412
+ if (!fw_ref ) {
413
+ err = - ETIMEDOUT ;
412
414
goto err_hw_fence_irq ;
415
+ }
413
416
414
417
if (!xe_gt_is_media_type (gt )) {
415
418
err = xe_ggtt_init (gt_to_tile (gt )-> mem .ggtt );
@@ -444,14 +447,12 @@ static int gt_fw_domain_init(struct xe_gt *gt)
444
447
*/
445
448
gt -> info .gmdid = xe_mmio_read32 (gt , GMD_ID );
446
449
447
- err = xe_force_wake_put (gt_to_fw (gt ), XE_FW_GT );
448
- XE_WARN_ON (err );
449
-
450
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
450
451
return 0 ;
451
452
452
453
err_force_wake :
453
454
dump_pat_on_error (gt );
454
- xe_force_wake_put (gt_to_fw (gt ), XE_FW_GT );
455
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
455
456
err_hw_fence_irq :
456
457
for (i = 0 ; i < XE_ENGINE_CLASS_MAX ; ++ i )
457
458
xe_hw_fence_irq_finish (& gt -> fence_irq [i ]);
@@ -461,11 +462,14 @@ static int gt_fw_domain_init(struct xe_gt *gt)
461
462
462
463
static int all_fw_domain_init (struct xe_gt * gt )
463
464
{
465
+ unsigned int fw_ref ;
464
466
int err , i ;
465
467
466
- err = xe_force_wake_get (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
467
- if (err )
468
- goto err_hw_fence_irq ;
468
+ fw_ref = xe_force_wake_get (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
469
+ if (!xe_force_wake_ref_has_domain (fw_ref , XE_FORCEWAKE_ALL )) {
470
+ err = - ETIMEDOUT ;
471
+ goto err_force_wake ;
472
+ }
469
473
470
474
xe_gt_mcr_set_implicit_defaults (gt );
471
475
xe_wa_process_gt (gt );
@@ -531,14 +535,12 @@ static int all_fw_domain_init(struct xe_gt *gt)
531
535
if (IS_SRIOV_PF (gt_to_xe (gt )))
532
536
xe_gt_sriov_pf_init_hw (gt );
533
537
534
- err = xe_force_wake_put (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
535
- XE_WARN_ON (err );
538
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
536
539
537
540
return 0 ;
538
541
539
542
err_force_wake :
540
- xe_force_wake_put (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
541
- err_hw_fence_irq :
543
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
542
544
for (i = 0 ; i < XE_ENGINE_CLASS_MAX ; ++ i )
543
545
xe_hw_fence_irq_finish (& gt -> fence_irq [i ]);
544
546
@@ -551,11 +553,12 @@ static int all_fw_domain_init(struct xe_gt *gt)
551
553
*/
552
554
int xe_gt_init_hwconfig (struct xe_gt * gt )
553
555
{
556
+ unsigned int fw_ref ;
554
557
int err ;
555
558
556
- err = xe_force_wake_get (gt_to_fw (gt ), XE_FW_GT );
557
- if (err )
558
- goto out ;
559
+ fw_ref = xe_force_wake_get (gt_to_fw (gt ), XE_FW_GT );
560
+ if (! fw_ref )
561
+ return - ETIMEDOUT ;
559
562
560
563
xe_gt_mcr_init_early (gt );
561
564
xe_pat_init (gt );
@@ -573,8 +576,7 @@ int xe_gt_init_hwconfig(struct xe_gt *gt)
573
576
xe_gt_enable_host_l2_vram (gt );
574
577
575
578
out_fw :
576
- xe_force_wake_put (gt_to_fw (gt ), XE_FW_GT );
577
- out :
579
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
578
580
return err ;
579
581
}
580
582
@@ -744,6 +746,7 @@ static int do_gt_restart(struct xe_gt *gt)
744
746
745
747
static int gt_reset (struct xe_gt * gt )
746
748
{
749
+ unsigned int fw_ref ;
747
750
int err ;
748
751
749
752
if (xe_device_wedged (gt_to_xe (gt )))
@@ -764,9 +767,11 @@ static int gt_reset(struct xe_gt *gt)
764
767
765
768
xe_gt_sanitize (gt );
766
769
767
- err = xe_force_wake_get (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
768
- if (err )
769
- goto err_msg ;
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
+ }
770
775
771
776
xe_uc_gucrc_disable (& gt -> uc );
772
777
xe_uc_stop_prepare (& gt -> uc );
@@ -784,17 +789,15 @@ static int gt_reset(struct xe_gt *gt)
784
789
if (err )
785
790
goto err_out ;
786
791
787
- err = xe_force_wake_put (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
788
- XE_WARN_ON (err );
792
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
789
793
xe_pm_runtime_put (gt_to_xe (gt ));
790
794
791
795
xe_gt_info (gt , "reset done\n" );
792
796
793
797
return 0 ;
794
798
795
799
err_out :
796
- XE_WARN_ON (xe_force_wake_put (gt_to_fw (gt ), XE_FORCEWAKE_ALL ));
797
- err_msg :
800
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
798
801
XE_WARN_ON (xe_uc_start (& gt -> uc ));
799
802
err_fail :
800
803
xe_gt_err (gt , "reset failed (%pe)\n" , ERR_PTR (err ));
@@ -826,22 +829,25 @@ void xe_gt_reset_async(struct xe_gt *gt)
826
829
827
830
void xe_gt_suspend_prepare (struct xe_gt * gt )
828
831
{
829
- XE_WARN_ON (xe_force_wake_get (gt_to_fw (gt ), XE_FORCEWAKE_ALL ));
832
+ unsigned int fw_ref ;
833
+
834
+ fw_ref = xe_force_wake_get (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
830
835
831
836
xe_uc_suspend_prepare (& gt -> uc );
832
837
833
- XE_WARN_ON ( xe_force_wake_put (gt_to_fw (gt ), XE_FORCEWAKE_ALL ) );
838
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
834
839
}
835
840
836
841
int xe_gt_suspend (struct xe_gt * gt )
837
842
{
843
+ unsigned int fw_ref ;
838
844
int err ;
839
845
840
846
xe_gt_dbg (gt , "suspending\n" );
841
847
xe_gt_sanitize (gt );
842
848
843
- err = xe_force_wake_get (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
844
- if (err )
849
+ fw_ref = xe_force_wake_get (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
850
+ if (! xe_force_wake_ref_has_domain ( fw_ref , XE_FORCEWAKE_ALL ) )
845
851
goto err_msg ;
846
852
847
853
err = xe_uc_suspend (& gt -> uc );
@@ -852,24 +858,27 @@ int xe_gt_suspend(struct xe_gt *gt)
852
858
853
859
xe_gt_disable_host_l2_vram (gt );
854
860
855
- XE_WARN_ON ( xe_force_wake_put (gt_to_fw (gt ), XE_FORCEWAKE_ALL ) );
861
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
856
862
xe_gt_dbg (gt , "suspended\n" );
857
863
858
864
return 0 ;
859
865
860
- err_force_wake :
861
- XE_WARN_ON (xe_force_wake_put (gt_to_fw (gt ), XE_FORCEWAKE_ALL ));
862
866
err_msg :
867
+ err = - ETIMEDOUT ;
868
+ err_force_wake :
869
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
863
870
xe_gt_err (gt , "suspend failed (%pe)\n" , ERR_PTR (err ));
864
871
865
872
return err ;
866
873
}
867
874
868
875
void xe_gt_shutdown (struct xe_gt * gt )
869
876
{
870
- xe_force_wake_get (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
877
+ unsigned int fw_ref ;
878
+
879
+ fw_ref = xe_force_wake_get (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
871
880
do_gt_reset (gt );
872
- xe_force_wake_put (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
881
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
873
882
}
874
883
875
884
/**
@@ -894,11 +903,12 @@ int xe_gt_sanitize_freq(struct xe_gt *gt)
894
903
895
904
int xe_gt_resume (struct xe_gt * gt )
896
905
{
906
+ unsigned int fw_ref ;
897
907
int err ;
898
908
899
909
xe_gt_dbg (gt , "resuming\n" );
900
- err = xe_force_wake_get (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
901
- if (err )
910
+ fw_ref = xe_force_wake_get (gt_to_fw (gt ), XE_FORCEWAKE_ALL );
911
+ if (! xe_force_wake_ref_has_domain ( fw_ref , XE_FORCEWAKE_ALL ) )
902
912
goto err_msg ;
903
913
904
914
err = do_gt_restart (gt );
@@ -907,14 +917,15 @@ int xe_gt_resume(struct xe_gt *gt)
907
917
908
918
xe_gt_idle_enable_pg (gt );
909
919
910
- XE_WARN_ON ( xe_force_wake_put (gt_to_fw (gt ), XE_FORCEWAKE_ALL ) );
920
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
911
921
xe_gt_dbg (gt , "resumed\n" );
912
922
913
923
return 0 ;
914
924
915
- err_force_wake :
916
- XE_WARN_ON (xe_force_wake_put (gt_to_fw (gt ), XE_FORCEWAKE_ALL ));
917
925
err_msg :
926
+ err = - ETIMEDOUT ;
927
+ err_force_wake :
928
+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
918
929
xe_gt_err (gt , "resume failed (%pe)\n" , ERR_PTR (err ));
919
930
920
931
return err ;
0 commit comments