Skip to content

Commit f7d6040

Browse files
committed
Merge tag 'pm-4.10-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull power management fixes from Rafael Wysocki: "These add a quirk to intel_pstate to work around a firmware setting that leads to frequency scaling issues (discovered recently) on some Intel Kaby Lake processors, fix up the recently added brcmstb-avs cpufreq driver and avoid false-positive warnings from the runtime PM framework triggered by recent changes in i915. Specifics: - Add an intel_pstate driver quirk to work around a firmware setting that leads to frequency scaling issues on desktop Intel Kaby Lake processors in some configurations if the hardware-managed P-states (HWP) feature is in use (Srinivas Pandruvada) - Fix up the recently added brcmstb-avs cpufreq driver: fix a bug related to system suspend and change the sysfs interface to match the user space expectations (Markus Mayer) - Modify the runtime PM framework to avoid false-positive warnings from the might_sleep_if() assertions in it (Rafael Wysocki)" * tag 'pm-4.10-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: PM / runtime: Avoid false-positive warnings from might_sleep_if() cpufreq: intel_pstate: Disable energy efficiency optimization cpufreq: brcmstb-avs-cpufreq: properly retrieve P-state upon suspend cpufreq: brcmstb-avs-cpufreq: extend sysfs entry brcm_avs_pmap
2 parents 50dcb6c + cbf304e commit f7d6040

File tree

3 files changed

+50
-8
lines changed

3 files changed

+50
-8
lines changed

drivers/base/power/runtime.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -966,13 +966,13 @@ int __pm_runtime_idle(struct device *dev, int rpmflags)
966966
unsigned long flags;
967967
int retval;
968968

969-
might_sleep_if(!(rpmflags & RPM_ASYNC) && !dev->power.irq_safe);
970-
971969
if (rpmflags & RPM_GET_PUT) {
972970
if (!atomic_dec_and_test(&dev->power.usage_count))
973971
return 0;
974972
}
975973

974+
might_sleep_if(!(rpmflags & RPM_ASYNC) && !dev->power.irq_safe);
975+
976976
spin_lock_irqsave(&dev->power.lock, flags);
977977
retval = rpm_idle(dev, rpmflags);
978978
spin_unlock_irqrestore(&dev->power.lock, flags);
@@ -998,13 +998,13 @@ int __pm_runtime_suspend(struct device *dev, int rpmflags)
998998
unsigned long flags;
999999
int retval;
10001000

1001-
might_sleep_if(!(rpmflags & RPM_ASYNC) && !dev->power.irq_safe);
1002-
10031001
if (rpmflags & RPM_GET_PUT) {
10041002
if (!atomic_dec_and_test(&dev->power.usage_count))
10051003
return 0;
10061004
}
10071005

1006+
might_sleep_if(!(rpmflags & RPM_ASYNC) && !dev->power.irq_safe);
1007+
10081008
spin_lock_irqsave(&dev->power.lock, flags);
10091009
retval = rpm_suspend(dev, rpmflags);
10101010
spin_unlock_irqrestore(&dev->power.lock, flags);
@@ -1029,7 +1029,8 @@ int __pm_runtime_resume(struct device *dev, int rpmflags)
10291029
unsigned long flags;
10301030
int retval;
10311031

1032-
might_sleep_if(!(rpmflags & RPM_ASYNC) && !dev->power.irq_safe);
1032+
might_sleep_if(!(rpmflags & RPM_ASYNC) && !dev->power.irq_safe &&
1033+
dev->power.runtime_status != RPM_ACTIVE);
10331034

10341035
if (rpmflags & RPM_GET_PUT)
10351036
atomic_inc(&dev->power.usage_count);

drivers/cpufreq/brcmstb-avs-cpufreq.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,8 +784,19 @@ static int brcm_avs_target_index(struct cpufreq_policy *policy,
784784
static int brcm_avs_suspend(struct cpufreq_policy *policy)
785785
{
786786
struct private_data *priv = policy->driver_data;
787+
int ret;
788+
789+
ret = brcm_avs_get_pmap(priv, &priv->pmap);
790+
if (ret)
791+
return ret;
787792

788-
return brcm_avs_get_pmap(priv, &priv->pmap);
793+
/*
794+
* We can't use the P-state returned by brcm_avs_get_pmap(), since
795+
* that's the initial P-state from when the P-map was downloaded to the
796+
* AVS co-processor, not necessarily the P-state we are running at now.
797+
* So, we get the current P-state explicitly.
798+
*/
799+
return brcm_avs_get_pstate(priv, &priv->pmap.state);
789800
}
790801

791802
static int brcm_avs_resume(struct cpufreq_policy *policy)
@@ -954,9 +965,9 @@ static ssize_t show_brcm_avs_pmap(struct cpufreq_policy *policy, char *buf)
954965
brcm_avs_parse_p1(pmap.p1, &mdiv_p0, &pdiv, &ndiv);
955966
brcm_avs_parse_p2(pmap.p2, &mdiv_p1, &mdiv_p2, &mdiv_p3, &mdiv_p4);
956967

957-
return sprintf(buf, "0x%08x 0x%08x %u %u %u %u %u %u %u\n",
968+
return sprintf(buf, "0x%08x 0x%08x %u %u %u %u %u %u %u %u %u\n",
958969
pmap.p1, pmap.p2, ndiv, pdiv, mdiv_p0, mdiv_p1, mdiv_p2,
959-
mdiv_p3, mdiv_p4);
970+
mdiv_p3, mdiv_p4, pmap.mode, pmap.state);
960971
}
961972

962973
static ssize_t show_brcm_avs_voltage(struct cpufreq_policy *policy, char *buf)

drivers/cpufreq/intel_pstate.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,25 @@ static void intel_pstate_hwp_enable(struct cpudata *cpudata)
12351235
cpudata->epp_default = intel_pstate_get_epp(cpudata, 0);
12361236
}
12371237

1238+
#define MSR_IA32_POWER_CTL_BIT_EE 19
1239+
1240+
/* Disable energy efficiency optimization */
1241+
static void intel_pstate_disable_ee(int cpu)
1242+
{
1243+
u64 power_ctl;
1244+
int ret;
1245+
1246+
ret = rdmsrl_on_cpu(cpu, MSR_IA32_POWER_CTL, &power_ctl);
1247+
if (ret)
1248+
return;
1249+
1250+
if (!(power_ctl & BIT(MSR_IA32_POWER_CTL_BIT_EE))) {
1251+
pr_info("Disabling energy efficiency optimization\n");
1252+
power_ctl |= BIT(MSR_IA32_POWER_CTL_BIT_EE);
1253+
wrmsrl_on_cpu(cpu, MSR_IA32_POWER_CTL, power_ctl);
1254+
}
1255+
}
1256+
12381257
static int atom_get_min_pstate(void)
12391258
{
12401259
u64 value;
@@ -1845,6 +1864,11 @@ static const struct x86_cpu_id intel_pstate_cpu_oob_ids[] __initconst = {
18451864
{}
18461865
};
18471866

1867+
static const struct x86_cpu_id intel_pstate_cpu_ee_disable_ids[] = {
1868+
ICPU(INTEL_FAM6_KABYLAKE_DESKTOP, core_params),
1869+
{}
1870+
};
1871+
18481872
static int intel_pstate_init_cpu(unsigned int cpunum)
18491873
{
18501874
struct cpudata *cpu;
@@ -1875,6 +1899,12 @@ static int intel_pstate_init_cpu(unsigned int cpunum)
18751899
cpu->cpu = cpunum;
18761900

18771901
if (hwp_active) {
1902+
const struct x86_cpu_id *id;
1903+
1904+
id = x86_match_cpu(intel_pstate_cpu_ee_disable_ids);
1905+
if (id)
1906+
intel_pstate_disable_ee(cpunum);
1907+
18781908
intel_pstate_hwp_enable(cpu);
18791909
pid_params.sample_rate_ms = 50;
18801910
pid_params.sample_rate_ns = 50 * NSEC_PER_MSEC;

0 commit comments

Comments
 (0)