summaryrefslogtreecommitdiff
path: root/drivers/idle
diff options
context:
space:
mode:
authorJan Beulich <JBeulich@suse.com>2016-06-27 09:35:12 +0300
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-07-09 02:05:30 +0300
commit3451ab3ebf92b12801878d8b5c94845afd4219f0 (patch)
tree60b304f2539da187b430ae0539e2657b6487e646 /drivers/idle
parentb55a0262a4fb4a9754f8a3319df0a6d2fe4c4c58 (diff)
downloadlinux-3451ab3ebf92b12801878d8b5c94845afd4219f0.tar.xz
intel_idle: re-work bxt_idle_state_table_update() and its helper
Since irtl_ns_units[] has itself zero entries, make sure the caller recognized those cases along with the MSR read returning zero, as zero is not a valid value for exit_latency and target_residency. Signed-off-by: Jan Beulich <jbeulich@suse.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/idle')
-rw-r--r--drivers/idle/intel_idle.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index 170ab8e01075..5300f2545e2a 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -1187,6 +1187,9 @@ static unsigned long long irtl_2_usec(unsigned long long irtl)
{
unsigned long long ns;
+ if (!irtl)
+ return 0;
+
ns = irtl_ns_units[(irtl >> 10) & 0x3];
return div64_u64((irtl & 0x3FF) * ns, 1000);
@@ -1200,43 +1203,39 @@ static unsigned long long irtl_2_usec(unsigned long long irtl)
static void bxt_idle_state_table_update(void)
{
unsigned long long msr;
+ unsigned int usec;
rdmsrl(MSR_PKGC6_IRTL, msr);
- if (msr) {
- unsigned int usec = irtl_2_usec(msr);
-
+ usec = irtl_2_usec(msr);
+ if (usec) {
bxt_cstates[2].exit_latency = usec;
bxt_cstates[2].target_residency = usec;
}
rdmsrl(MSR_PKGC7_IRTL, msr);
- if (msr) {
- unsigned int usec = irtl_2_usec(msr);
-
+ usec = irtl_2_usec(msr);
+ if (usec) {
bxt_cstates[3].exit_latency = usec;
bxt_cstates[3].target_residency = usec;
}
rdmsrl(MSR_PKGC8_IRTL, msr);
- if (msr) {
- unsigned int usec = irtl_2_usec(msr);
-
+ usec = irtl_2_usec(msr);
+ if (usec) {
bxt_cstates[4].exit_latency = usec;
bxt_cstates[4].target_residency = usec;
}
rdmsrl(MSR_PKGC9_IRTL, msr);
- if (msr) {
- unsigned int usec = irtl_2_usec(msr);
-
+ usec = irtl_2_usec(msr);
+ if (usec) {
bxt_cstates[5].exit_latency = usec;
bxt_cstates[5].target_residency = usec;
}
rdmsrl(MSR_PKGC10_IRTL, msr);
- if (msr) {
- unsigned int usec = irtl_2_usec(msr);
-
+ usec = irtl_2_usec(msr);
+ if (usec) {
bxt_cstates[6].exit_latency = usec;
bxt_cstates[6].target_residency = usec;
}