Skip to content

Commit

Permalink
intel_idle: re-work bxt_idle_state_table_update() and its helper
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jbeulich authored and rafaeljw committed Jul 8, 2016
1 parent b55a026 commit 3451ab3
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions drivers/idle/intel_idle.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down

0 comments on commit 3451ab3

Please sign in to comment.