@@ -131,11 +131,12 @@ static unsigned int mwait_substates __initdata;
131131#define MWAIT2flg (eax ) ((eax & 0xFF) << 24)
132132
133133static __always_inline int __intel_idle (struct cpuidle_device * dev ,
134- struct cpuidle_driver * drv , int index )
134+ struct cpuidle_driver * drv ,
135+ int index , bool irqoff )
135136{
136137 struct cpuidle_state * state = & drv -> states [index ];
137138 unsigned long eax = flg2MWAIT (state -> flags );
138- unsigned long ecx = 1 ; /* break on interrupt flag */
139+ unsigned long ecx = 1 * irqoff ; /* break on interrupt flag */
139140
140141 mwait_idle_with_hints (eax , ecx );
141142
@@ -159,19 +160,13 @@ static __always_inline int __intel_idle(struct cpuidle_device *dev,
159160static __cpuidle int intel_idle (struct cpuidle_device * dev ,
160161 struct cpuidle_driver * drv , int index )
161162{
162- return __intel_idle (dev , drv , index );
163+ return __intel_idle (dev , drv , index , true );
163164}
164165
165166static __cpuidle int intel_idle_irq (struct cpuidle_device * dev ,
166167 struct cpuidle_driver * drv , int index )
167168{
168- int ret ;
169-
170- raw_local_irq_enable ();
171- ret = __intel_idle (dev , drv , index );
172- raw_local_irq_disable ();
173-
174- return ret ;
169+ return __intel_idle (dev , drv , index , false);
175170}
176171
177172static __cpuidle int intel_idle_ibrs (struct cpuidle_device * dev ,
@@ -184,7 +179,7 @@ static __cpuidle int intel_idle_ibrs(struct cpuidle_device *dev,
184179 if (smt_active )
185180 __update_spec_ctrl (0 );
186181
187- ret = __intel_idle (dev , drv , index );
182+ ret = __intel_idle (dev , drv , index , true );
188183
189184 if (smt_active )
190185 __update_spec_ctrl (spec_ctrl );
@@ -196,7 +191,7 @@ static __cpuidle int intel_idle_xstate(struct cpuidle_device *dev,
196191 struct cpuidle_driver * drv , int index )
197192{
198193 fpu_idle_fpregs ();
199- return __intel_idle (dev , drv , index );
194+ return __intel_idle (dev , drv , index , true );
200195}
201196
202197/**
@@ -923,6 +918,35 @@ static struct cpuidle_state adl_l_cstates[] __initdata = {
923918 .enter = NULL }
924919};
925920
921+ static struct cpuidle_state mtl_l_cstates [] __initdata = {
922+ {
923+ .name = "C1E" ,
924+ .desc = "MWAIT 0x01" ,
925+ .flags = MWAIT2flg (0x01 ) | CPUIDLE_FLAG_ALWAYS_ENABLE ,
926+ .exit_latency = 1 ,
927+ .target_residency = 1 ,
928+ .enter = & intel_idle ,
929+ .enter_s2idle = intel_idle_s2idle , },
930+ {
931+ .name = "C6" ,
932+ .desc = "MWAIT 0x20" ,
933+ .flags = MWAIT2flg (0x20 ) | CPUIDLE_FLAG_TLB_FLUSHED ,
934+ .exit_latency = 140 ,
935+ .target_residency = 420 ,
936+ .enter = & intel_idle ,
937+ .enter_s2idle = intel_idle_s2idle , },
938+ {
939+ .name = "C10" ,
940+ .desc = "MWAIT 0x60" ,
941+ .flags = MWAIT2flg (0x60 ) | CPUIDLE_FLAG_TLB_FLUSHED ,
942+ .exit_latency = 310 ,
943+ .target_residency = 930 ,
944+ .enter = & intel_idle ,
945+ .enter_s2idle = intel_idle_s2idle , },
946+ {
947+ .enter = NULL }
948+ };
949+
926950static struct cpuidle_state gmt_cstates [] __initdata = {
927951 {
928952 .name = "C1" ,
@@ -1415,6 +1439,10 @@ static const struct idle_cpu idle_cpu_adl_l __initconst = {
14151439 .state_table = adl_l_cstates ,
14161440};
14171441
1442+ static const struct idle_cpu idle_cpu_mtl_l __initconst = {
1443+ .state_table = mtl_l_cstates ,
1444+ };
1445+
14181446static const struct idle_cpu idle_cpu_gmt __initconst = {
14191447 .state_table = gmt_cstates ,
14201448};
@@ -1501,6 +1529,7 @@ static const struct x86_cpu_id intel_idle_ids[] __initconst = {
15011529 X86_MATCH_INTEL_FAM6_MODEL (ICELAKE_D , & idle_cpu_icx ),
15021530 X86_MATCH_INTEL_FAM6_MODEL (ALDERLAKE , & idle_cpu_adl ),
15031531 X86_MATCH_INTEL_FAM6_MODEL (ALDERLAKE_L , & idle_cpu_adl_l ),
1532+ X86_MATCH_INTEL_FAM6_MODEL (METEORLAKE_L , & idle_cpu_mtl_l ),
15041533 X86_MATCH_INTEL_FAM6_MODEL (ATOM_GRACEMONT , & idle_cpu_gmt ),
15051534 X86_MATCH_INTEL_FAM6_MODEL (SAPPHIRERAPIDS_X , & idle_cpu_spr ),
15061535 X86_MATCH_INTEL_FAM6_MODEL (EMERALDRAPIDS_X , & idle_cpu_spr ),
@@ -1905,7 +1934,8 @@ static void __init spr_idle_state_table_update(void)
19051934
19061935static bool __init intel_idle_verify_cstate (unsigned int mwait_hint )
19071936{
1908- unsigned int mwait_cstate = MWAIT_HINT2CSTATE (mwait_hint ) + 1 ;
1937+ unsigned int mwait_cstate = (MWAIT_HINT2CSTATE (mwait_hint ) + 1 ) &
1938+ MWAIT_CSTATE_MASK ;
19091939 unsigned int num_substates = (mwait_substates >> mwait_cstate * 4 ) &
19101940 MWAIT_SUBSTATE_MASK ;
19111941
0 commit comments