]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
intel_idle: re-work bxt_idle_state_table_update() and its helper
authorJan Beulich <JBeulich@suse.com>
Mon, 27 Jun 2016 06:35:12 +0000 (00:35 -0600)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 3 Nov 2016 17:26:17 +0000 (10:26 -0700)
Orabug: 24810432

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>
(cherry picked from commit 3451ab3ebf92b12801878d8b5c94845afd4219f0)
Signed-off-by: Brian Maly <brian.maly@oracle.com>
drivers/idle/intel_idle.c

index b5dd41d13d3d5986fc555ebfa0909d793e83ce8d..6874a2c361d0d2d712d5b488d5bdc2a5c568f1a3 100644 (file)
@@ -1155,6 +1155,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);
@@ -1168,43 +1171,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;
        }