2009-06-26 15:52:54

by Langsdorf, Mark

[permalink] [raw]
Subject: [PATCH][cpufreq][Powernow-k8] support family 0xf with 2 low p-states

Provide support for family 0xf processors with 2 P-states
below the elevator voltage. Remove the checks that prevent
this configuration from being supported and increase the
transition voltage to prevent errors during the transition.

Signed-off-by: Mark Langsdorf <[email protected]>
---
arch/x86/kernel/cpu/cpufreq/powernow-k8.c | 30 ++++++++++------------------
arch/x86/kernel/cpu/cpufreq/powernow-k8.h | 3 +-
2 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
index 81cbe64..ae068f5 100644
--- a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
+++ b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
@@ -299,7 +299,7 @@ static int transition_pstate(struct powernow_k8_data *data, u32 pstate)
static int transition_fid_vid(struct powernow_k8_data *data,
u32 reqfid, u32 reqvid)
{
- if (core_voltage_pre_transition(data, reqvid))
+ if (core_voltage_pre_transition(data, reqvid, reqfid))
return 1;

if (core_frequency_transition(data, reqfid))
@@ -327,17 +327,20 @@ static int transition_fid_vid(struct powernow_k8_data *data,

/* Phase 1 - core voltage transition ... setup voltage */
static int core_voltage_pre_transition(struct powernow_k8_data *data,
- u32 reqvid)
+ u32 reqvid, u32 reqfid)
{
u32 rvosteps = data->rvo;
u32 savefid = data->currfid;
- u32 maxvid, lo;
+ u32 maxvid, lo, rvomult = 1;

dprintk("ph1 (cpu%d): start, currfid 0x%x, currvid 0x%x, "
"reqvid 0x%x, rvo 0x%x\n",
smp_processor_id(),
data->currfid, data->currvid, reqvid, data->rvo);

+ if ((savefid < LO_FID_TABLE_TOP) && (reqfid < LO_FID_TABLE_TOP))
+ rvomult = 2;
+ rvosteps *= rvomult;
rdmsr(MSR_FIDVID_STATUS, lo, maxvid);
maxvid = 0x1f & (maxvid >> 16);
dprintk("ph1 maxvid=0x%x\n", maxvid);
@@ -351,7 +354,8 @@ static int core_voltage_pre_transition(struct powernow_k8_data *data,
return 1;
}

- while ((rvosteps > 0) && ((data->rvo + data->currvid) > reqvid)) {
+ while ((rvosteps > 0) &&
+ ((rvomult * data->rvo + data->currvid) > reqvid)) {
if (data->currvid == maxvid) {
rvosteps = 0;
} else {
@@ -384,13 +388,6 @@ static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid)
u32 vcoreqfid, vcocurrfid, vcofiddiff;
u32 fid_interval, savevid = data->currvid;

- if ((reqfid < HI_FID_TABLE_BOTTOM) &&
- (data->currfid < HI_FID_TABLE_BOTTOM)) {
- printk(KERN_ERR PFX "ph2: illegal lo-lo transition "
- "0x%x 0x%x\n", reqfid, data->currfid);
- return 1;
- }
-
if (data->currfid == reqfid) {
printk(KERN_ERR PFX "ph2 null fid transition 0x%x\n",
data->currfid);
@@ -407,6 +404,9 @@ static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid)
vcofiddiff = vcocurrfid > vcoreqfid ? vcocurrfid - vcoreqfid
: vcoreqfid - vcocurrfid;

+ if ((reqfid <= LO_FID_TABLE_TOP) && (data->currfid <= LO_FID_TABLE_TOP))
+ vcofiddiff = 0;
+
while (vcofiddiff > 2) {
(data->currfid & 1) ? (fid_interval = 1) : (fid_interval = 2);

@@ -1081,14 +1081,6 @@ static int transition_frequency_fidvid(struct powernow_k8_data *data,
return 0;
}

- if ((fid < HI_FID_TABLE_BOTTOM) &&
- (data->currfid < HI_FID_TABLE_BOTTOM)) {
- printk(KERN_ERR PFX
- "ignoring illegal change in lo freq table-%x to 0x%x\n",
- data->currfid, fid);
- return 1;
- }
-
dprintk("cpu %d, changing to fid 0x%x, vid 0x%x\n",
smp_processor_id(), fid, vid);
freqs.old = find_khz_freq_from_fid(data->currfid);
diff --git a/arch/x86/kernel/cpu/cpufreq/powernow-k8.h b/arch/x86/kernel/cpu/cpufreq/powernow-k8.h
index c9c1190..02ce824 100644
--- a/arch/x86/kernel/cpu/cpufreq/powernow-k8.h
+++ b/arch/x86/kernel/cpu/cpufreq/powernow-k8.h
@@ -215,7 +215,8 @@ struct pst_s {

#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "powernow-k8", msg)

-static int core_voltage_pre_transition(struct powernow_k8_data *data, u32 reqvid);
+static int core_voltage_pre_transition(struct powernow_k8_data *data,
+ u32 reqvid, u32 regfid);
static int core_voltage_post_transition(struct powernow_k8_data *data, u32 reqvid);
static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid);

--
1.6.0.2


2009-07-02 21:16:38

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH][cpufreq][Powernow-k8] support family 0xf with 2 low p-states

On Sun, 26 Jul 2009 10:55:25 -0500
Mark Langsdorf <[email protected]> wrote:
>
> Subject: [PATCH][cpufreq][Powernow-k8] support family 0xf with 2 low p-states

Please leave the subsystem identification text outside the [].
Documentation/SubmittingPatches section 15 has details.


> --- a/arch/x86/kernel/cpu/cpufreq/powernow-k8.h
> +++ b/arch/x86/kernel/cpu/cpufreq/powernow-k8.h
> @@ -215,7 +215,8 @@ struct pst_s {
>
> #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "powernow-k8", msg)
>
> -static int core_voltage_pre_transition(struct powernow_k8_data *data, u32 reqvid);
> +static int core_voltage_pre_transition(struct powernow_k8_data *data,
> + u32 reqvid, u32 regfid);
> static int core_voltage_post_transition(struct powernow_k8_data *data, u32 reqvid);
> static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid);

It's fairly dopey to have static function declarations in a header file
- no other .c fail can _use_ them, so they may as well be tucked away
inside their .c file. And that's only needed if the functions indeed
need to be forward-declared.

2009-07-10 10:05:31

by Peter Zijlstra

[permalink] [raw]
Subject: Re: [PATCH][cpufreq][Powernow-k8] support family 0xf with 2 low p-states

On Thu, 2009-07-02 at 14:15 -0700, Andrew Morton wrote:
> On Sun, 26 Jul 2009 10:55:25 -0500
> Mark Langsdorf <[email protected]> wrote:
> >
> > Subject: [PATCH][cpufreq][Powernow-k8] support family 0xf with 2 low p-states
>
> Please leave the subsystem identification text outside the [].
> Documentation/SubmittingPatches section 15 has details.
>
>
> > --- a/arch/x86/kernel/cpu/cpufreq/powernow-k8.h
> > +++ b/arch/x86/kernel/cpu/cpufreq/powernow-k8.h
> > @@ -215,7 +215,8 @@ struct pst_s {
> >
> > #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "powernow-k8", msg)
> >
> > -static int core_voltage_pre_transition(struct powernow_k8_data *data, u32 reqvid);
> > +static int core_voltage_pre_transition(struct powernow_k8_data *data,
> > + u32 reqvid, u32 regfid);
> > static int core_voltage_post_transition(struct powernow_k8_data *data, u32 reqvid);
> > static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid);
>
> It's fairly dopey to have static function declarations in a header file
> - no other .c fail can _use_ them, so they may as well be tucked away

hehe, FAIL, hehe ;-)

> inside their .c file. And that's only needed if the functions indeed
> need to be forward-declared.