Skip to content

Commit 0a9b9d1

Browse files
committed
Merge tag 'pm-6.12-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull power management fix from Rafael Wysocki: "Fix a locking issue in the asymmetric CPU capacity setup code in the intel_pstate driver that may lead to a deadlock if CPU online/offline runs in parallel with the code in question, which is unlikely but not impossible (Rafael Wysocki)" * tag 'pm-6.12-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: cpufreq: intel_pstate: Rearrange locking in hybrid_init_cpu_capacity_scaling()
2 parents 4ba05b0 + 1a1030d commit 0a9b9d1

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

drivers/cpufreq/intel_pstate.c

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,26 +1028,29 @@ static void hybrid_update_cpu_capacity_scaling(void)
10281028
}
10291029
}
10301030

1031-
static void __hybrid_init_cpu_capacity_scaling(void)
1031+
static void __hybrid_refresh_cpu_capacity_scaling(void)
10321032
{
10331033
hybrid_max_perf_cpu = NULL;
10341034
hybrid_update_cpu_capacity_scaling();
10351035
}
10361036

1037-
static void hybrid_init_cpu_capacity_scaling(bool refresh)
1037+
static void hybrid_refresh_cpu_capacity_scaling(void)
10381038
{
1039-
bool disable_itmt = false;
1039+
guard(mutex)(&hybrid_capacity_lock);
10401040

1041-
mutex_lock(&hybrid_capacity_lock);
1041+
__hybrid_refresh_cpu_capacity_scaling();
1042+
}
10421043

1044+
static void hybrid_init_cpu_capacity_scaling(bool refresh)
1045+
{
10431046
/*
10441047
* If hybrid_max_perf_cpu is set at this point, the hybrid CPU capacity
10451048
* scaling has been enabled already and the driver is just changing the
10461049
* operation mode.
10471050
*/
10481051
if (refresh) {
1049-
__hybrid_init_cpu_capacity_scaling();
1050-
goto unlock;
1052+
hybrid_refresh_cpu_capacity_scaling();
1053+
return;
10511054
}
10521055

10531056
/*
@@ -1056,19 +1059,13 @@ static void hybrid_init_cpu_capacity_scaling(bool refresh)
10561059
* do not do that when SMT is in use.
10571060
*/
10581061
if (hwp_is_hybrid && !sched_smt_active() && arch_enable_hybrid_capacity_scale()) {
1059-
__hybrid_init_cpu_capacity_scaling();
1060-
disable_itmt = true;
1061-
}
1062-
1063-
unlock:
1064-
mutex_unlock(&hybrid_capacity_lock);
1065-
1066-
/*
1067-
* Disabling ITMT causes sched domains to be rebuilt to disable asym
1068-
* packing and enable asym capacity.
1069-
*/
1070-
if (disable_itmt)
1062+
hybrid_refresh_cpu_capacity_scaling();
1063+
/*
1064+
* Disabling ITMT causes sched domains to be rebuilt to disable asym
1065+
* packing and enable asym capacity.
1066+
*/
10711067
sched_clear_itmt_support();
1068+
}
10721069
}
10731070

10741071
static bool hybrid_clear_max_perf_cpu(void)
@@ -1404,7 +1401,7 @@ static void intel_pstate_update_limits_for_all(void)
14041401
mutex_lock(&hybrid_capacity_lock);
14051402

14061403
if (hybrid_max_perf_cpu)
1407-
__hybrid_init_cpu_capacity_scaling();
1404+
__hybrid_refresh_cpu_capacity_scaling();
14081405

14091406
mutex_unlock(&hybrid_capacity_lock);
14101407
}

0 commit comments

Comments
 (0)