Skip to content

Commit

Permalink
Merge branch 'pm-cpufreq'
Browse files Browse the repository at this point in the history
* pm-cpufreq:
  intel_pstate: remove setting P state to MAX on init
  intel_pstate: Set turbo VID for BayTrail
  • Loading branch information
Rafael J. Wysocki committed May 15, 2014
2 parents 75fa7d2 + d40a63c commit 68c8829
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions drivers/cpufreq/intel_pstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#define BYT_RATIOS 0x66a
#define BYT_VIDS 0x66b
#define BYT_TURBO_RATIOS 0x66c
#define BYT_TURBO_VIDS 0x66d


#define FRAC_BITS 6
Expand Down Expand Up @@ -70,8 +71,9 @@ struct pstate_data {
};

struct vid_data {
int32_t min;
int32_t max;
int min;
int max;
int turbo;
int32_t ratio;
};

Expand Down Expand Up @@ -359,14 +361,14 @@ static int byt_get_min_pstate(void)
{
u64 value;
rdmsrl(BYT_RATIOS, value);
return (value >> 8) & 0xFF;
return (value >> 8) & 0x3F;
}

static int byt_get_max_pstate(void)
{
u64 value;
rdmsrl(BYT_RATIOS, value);
return (value >> 16) & 0xFF;
return (value >> 16) & 0x3F;
}

static int byt_get_turbo_pstate(void)
Expand All @@ -393,6 +395,9 @@ static void byt_set_pstate(struct cpudata *cpudata, int pstate)
vid_fp = clamp_t(int32_t, vid_fp, cpudata->vid.min, cpudata->vid.max);
vid = fp_toint(vid_fp);

if (pstate > cpudata->pstate.max_pstate)
vid = cpudata->vid.turbo;

val |= vid;

wrmsrl(MSR_IA32_PERF_CTL, val);
Expand All @@ -402,13 +407,17 @@ static void byt_get_vid(struct cpudata *cpudata)
{
u64 value;


rdmsrl(BYT_VIDS, value);
cpudata->vid.min = int_tofp((value >> 8) & 0x7f);
cpudata->vid.max = int_tofp((value >> 16) & 0x7f);
cpudata->vid.min = int_tofp((value >> 8) & 0x3f);
cpudata->vid.max = int_tofp((value >> 16) & 0x3f);
cpudata->vid.ratio = div_fp(
cpudata->vid.max - cpudata->vid.min,
int_tofp(cpudata->pstate.max_pstate -
cpudata->pstate.min_pstate));

rdmsrl(BYT_TURBO_VIDS, value);
cpudata->vid.turbo = value & 0x7f;
}


Expand Down Expand Up @@ -545,12 +554,7 @@ static void intel_pstate_get_cpu_pstates(struct cpudata *cpu)

if (pstate_funcs.get_vid)
pstate_funcs.get_vid(cpu);

/*
* goto max pstate so we don't slow up boot if we are built-in if we are
* a module we will take care of it during normal operation
*/
intel_pstate_set_pstate(cpu, cpu->pstate.max_pstate);
intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate);
}

static inline void intel_pstate_calc_busy(struct cpudata *cpu,
Expand Down Expand Up @@ -695,11 +699,6 @@ static int intel_pstate_init_cpu(unsigned int cpunum)
cpu = all_cpu_data[cpunum];

intel_pstate_get_cpu_pstates(cpu);
if (!cpu->pstate.current_pstate) {
all_cpu_data[cpunum] = NULL;
kfree(cpu);
return -ENODATA;
}

cpu->cpu = cpunum;

Expand All @@ -710,7 +709,6 @@ static int intel_pstate_init_cpu(unsigned int cpunum)
cpu->timer.expires = jiffies + HZ/100;
intel_pstate_busy_pid_reset(cpu);
intel_pstate_sample(cpu);
intel_pstate_set_pstate(cpu, cpu->pstate.max_pstate);

add_timer_on(&cpu->timer, cpunum);

Expand Down

0 comments on commit 68c8829

Please sign in to comment.