@@ -97,14 +97,14 @@ void xe_gt_sanitize(struct xe_gt *gt)
9797
9898static void xe_gt_enable_host_l2_vram (struct xe_gt * gt )
9999{
100+ unsigned int fw_ref ;
100101 u32 reg ;
101- int err ;
102102
103103 if (!XE_WA (gt , 16023588340 ))
104104 return ;
105105
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 )
108108 return ;
109109
110110 if (!xe_gt_is_media_type (gt )) {
@@ -114,29 +114,29 @@ static void xe_gt_enable_host_l2_vram(struct xe_gt *gt)
114114 }
115115
116116 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 );
118118}
119119
120120static void xe_gt_disable_host_l2_vram (struct xe_gt * gt )
121121{
122+ unsigned int fw_ref ;
122123 u32 reg ;
123- int err ;
124124
125125 if (!XE_WA (gt , 16023588340 ))
126126 return ;
127127
128128 if (xe_gt_is_media_type (gt ))
129129 return ;
130130
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 )
133133 return ;
134134
135135 reg = xe_gt_mcr_unicast_read_any (gt , XE2_GAMREQSTRM_CTRL );
136136 reg &= ~CG_DIS_CNTLBUS ;
137137 xe_gt_mcr_multicast_write (gt , XE2_GAMREQSTRM_CTRL , reg );
138138
139- xe_force_wake_put (gt_to_fw (gt ), XE_FW_GT );
139+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
140140}
141141
142142/**
@@ -402,11 +402,14 @@ static void dump_pat_on_error(struct xe_gt *gt)
402402
403403static int gt_fw_domain_init (struct xe_gt * gt )
404404{
405+ unsigned int fw_ref ;
405406 int err , i ;
406407
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 ;
409411 goto err_hw_fence_irq ;
412+ }
410413
411414 if (!xe_gt_is_media_type (gt )) {
412415 err = xe_ggtt_init (gt_to_tile (gt )-> mem .ggtt );
@@ -441,14 +444,12 @@ static int gt_fw_domain_init(struct xe_gt *gt)
441444 */
442445 gt -> info .gmdid = xe_mmio_read32 (& gt -> mmio , GMD_ID );
443446
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 );
447448 return 0 ;
448449
449450err_force_wake :
450451 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 );
452453err_hw_fence_irq :
453454 for (i = 0 ; i < XE_ENGINE_CLASS_MAX ; ++ i )
454455 xe_hw_fence_irq_finish (& gt -> fence_irq [i ]);
@@ -458,11 +459,14 @@ static int gt_fw_domain_init(struct xe_gt *gt)
458459
459460static int all_fw_domain_init (struct xe_gt * gt )
460461{
462+ unsigned int fw_ref ;
461463 int err , i ;
462464
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+ }
466470
467471 xe_gt_mcr_set_implicit_defaults (gt );
468472 xe_reg_sr_apply_mmio (& gt -> reg_sr , gt );
@@ -526,14 +530,12 @@ static int all_fw_domain_init(struct xe_gt *gt)
526530 if (IS_SRIOV_PF (gt_to_xe (gt )))
527531 xe_gt_sriov_pf_init_hw (gt );
528532
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 );
531534
532535 return 0 ;
533536
534537err_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 );
537539 for (i = 0 ; i < XE_ENGINE_CLASS_MAX ; ++ i )
538540 xe_hw_fence_irq_finish (& gt -> fence_irq [i ]);
539541
@@ -546,11 +548,12 @@ static int all_fw_domain_init(struct xe_gt *gt)
546548 */
547549int xe_gt_init_hwconfig (struct xe_gt * gt )
548550{
551+ unsigned int fw_ref ;
549552 int err ;
550553
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 ;
554557
555558 xe_gt_mcr_init_early (gt );
556559 xe_pat_init (gt );
@@ -568,8 +571,7 @@ int xe_gt_init_hwconfig(struct xe_gt *gt)
568571 xe_gt_enable_host_l2_vram (gt );
569572
570573out_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 );
573575 return err ;
574576}
575577
@@ -764,6 +766,7 @@ static int do_gt_restart(struct xe_gt *gt)
764766
765767static int gt_reset (struct xe_gt * gt )
766768{
769+ unsigned int fw_ref ;
767770 int err ;
768771
769772 if (xe_device_wedged (gt_to_xe (gt )))
@@ -784,9 +787,11 @@ static int gt_reset(struct xe_gt *gt)
784787
785788 xe_gt_sanitize (gt );
786789
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+ }
790795
791796 xe_uc_gucrc_disable (& gt -> uc );
792797 xe_uc_stop_prepare (& gt -> uc );
@@ -804,17 +809,15 @@ static int gt_reset(struct xe_gt *gt)
804809 if (err )
805810 goto err_out ;
806811
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 );
809813 xe_pm_runtime_put (gt_to_xe (gt ));
810814
811815 xe_gt_info (gt , "reset done\n" );
812816
813817 return 0 ;
814818
815819err_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 );
818821 XE_WARN_ON (xe_uc_start (& gt -> uc ));
819822err_fail :
820823 xe_gt_err (gt , "reset failed (%pe)\n" , ERR_PTR (err ));
@@ -846,22 +849,25 @@ void xe_gt_reset_async(struct xe_gt *gt)
846849
847850void xe_gt_suspend_prepare (struct xe_gt * gt )
848851{
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 );
850855
851856 xe_uc_stop_prepare (& gt -> uc );
852857
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 );
854859}
855860
856861int xe_gt_suspend (struct xe_gt * gt )
857862{
863+ unsigned int fw_ref ;
858864 int err ;
859865
860866 xe_gt_dbg (gt , "suspending\n" );
861867 xe_gt_sanitize (gt );
862868
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 ) )
865871 goto err_msg ;
866872
867873 err = xe_uc_suspend (& gt -> uc );
@@ -872,24 +878,27 @@ int xe_gt_suspend(struct xe_gt *gt)
872878
873879 xe_gt_disable_host_l2_vram (gt );
874880
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 );
876882 xe_gt_dbg (gt , "suspended\n" );
877883
878884 return 0 ;
879885
880- err_force_wake :
881- XE_WARN_ON (xe_force_wake_put (gt_to_fw (gt ), XE_FORCEWAKE_ALL ));
882886err_msg :
887+ err = - ETIMEDOUT ;
888+ err_force_wake :
889+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
883890 xe_gt_err (gt , "suspend failed (%pe)\n" , ERR_PTR (err ));
884891
885892 return err ;
886893}
887894
888895void xe_gt_shutdown (struct xe_gt * gt )
889896{
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 );
891900 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 );
893902}
894903
895904/**
@@ -914,11 +923,12 @@ int xe_gt_sanitize_freq(struct xe_gt *gt)
914923
915924int xe_gt_resume (struct xe_gt * gt )
916925{
926+ unsigned int fw_ref ;
917927 int err ;
918928
919929 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 ) )
922932 goto err_msg ;
923933
924934 err = do_gt_restart (gt );
@@ -927,14 +937,15 @@ int xe_gt_resume(struct xe_gt *gt)
927937
928938 xe_gt_idle_enable_pg (gt );
929939
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 );
931941 xe_gt_dbg (gt , "resumed\n" );
932942
933943 return 0 ;
934944
935- err_force_wake :
936- XE_WARN_ON (xe_force_wake_put (gt_to_fw (gt ), XE_FORCEWAKE_ALL ));
937945err_msg :
946+ err = - ETIMEDOUT ;
947+ err_force_wake :
948+ xe_force_wake_put (gt_to_fw (gt ), fw_ref );
938949 xe_gt_err (gt , "resume failed (%pe)\n" , ERR_PTR (err ));
939950
940951 return err ;
0 commit comments