]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/cpufreq
authorLinus Torvalds <torvalds@woody.linux-foundation.org>
Sat, 17 Nov 2007 02:30:26 +0000 (18:30 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Sat, 17 Nov 2007 02:30:26 +0000 (18:30 -0800)
* master.kernel.org:/pub/scm/linux/kernel/git/davej/cpufreq:
  [CPUFREQ] Fix up whitespace in conservative governor.
  [CPUFREQ] Make cpufreq_conservative handle out-of-sync events properly
  [CPUFREQ] architectural pstate driver for powernow-k8

1  2 
arch/x86/kernel/cpu/cpufreq/powernow-k8.c
arch/x86/kernel/cpu/cpufreq/powernow-k8.h

index 9c36a53676b770830e1efffb5770788d34ab2ee4,f105ffd09960887d74153885131e9f06d622a6a8..99e1ef9939bec24bc210791eecc6f23f328c24ae
@@@ -46,7 -46,7 +46,7 @@@
  
  #define PFX "powernow-k8: "
  #define BFX PFX "BIOS error: "
- #define VERSION "version 2.00.00"
+ #define VERSION "version 2.20.00"
  #include "powernow-k8.h"
  
  /* serialize freq changes  */
@@@ -57,7 -57,7 +57,7 @@@ static struct powernow_k8_data *powerno
  static int cpu_family = CPU_OPTERON;
  
  #ifndef CONFIG_SMP
 -static cpumask_t cpu_core_map[1];
 +DEFINE_PER_CPU(cpumask_t, cpu_core_map);
  #endif
  
  /* Return a frequency in MHz, given an input fid */
@@@ -73,33 -73,11 +73,11 @@@ static u32 find_khz_freq_from_fid(u32 f
        return 1000 * find_freq_from_fid(fid);
  }
  
- /* Return a frequency in MHz, given an input fid and did */
- static u32 find_freq_from_fiddid(u32 fid, u32 did)
+ static u32 find_khz_freq_from_pstate(struct cpufreq_frequency_table *data, u32 pstate)
  {
-       if (current_cpu_data.x86 == 0x10)
-               return 100 * (fid + 0x10) >> did;
-       else
-               return 100 * (fid + 0x8) >> did;
- }
- static u32 find_khz_freq_from_fiddid(u32 fid, u32 did)
- {
-       return 1000 * find_freq_from_fiddid(fid, did);
- }
- static u32 find_fid_from_pstate(u32 pstate)
- {
-       u32 hi, lo;
-       rdmsr(MSR_PSTATE_DEF_BASE + pstate, lo, hi);
-       return lo & HW_PSTATE_FID_MASK;
+       return data[pstate].frequency;
  }
  
- static u32 find_did_from_pstate(u32 pstate)
- {
-       u32 hi, lo;
-       rdmsr(MSR_PSTATE_DEF_BASE + pstate, lo, hi);
-       return (lo & HW_PSTATE_DID_MASK) >> HW_PSTATE_DID_SHIFT;
- }
  
  /* Return the vco fid for an input fid
   *
@@@ -142,9 -120,7 +120,7 @@@ static int query_current_values_with_pe
        if (cpu_family == CPU_HW_PSTATE) {
                rdmsr(MSR_PSTATE_STATUS, lo, hi);
                i = lo & HW_PSTATE_MASK;
-               rdmsr(MSR_PSTATE_DEF_BASE + i, lo, hi);
-               data->currfid = lo & HW_PSTATE_FID_MASK;
-               data->currdid = (lo & HW_PSTATE_DID_MASK) >> HW_PSTATE_DID_SHIFT;
+               data->currpstate = i;
                return 0;
        }
        do {
@@@ -168,7 -144,7 +144,7 @@@ static void count_off_irt(struct powern
        return;
  }
  
 -/* the voltage stabalization time */
 +/* the voltage stabilization time */
  static void count_off_vst(struct powernow_k8_data *data)
  {
        udelay(data->vstable * VST_UNITS_20US);
@@@ -295,7 -271,7 +271,7 @@@ static int decrease_vid_code_by_step(st
  static int transition_pstate(struct powernow_k8_data *data, u32 pstate)
  {
        wrmsr(MSR_PSTATE_CTRL, pstate, 0);
-       data->currfid = find_fid_from_pstate(pstate);
+       data->currpstate = pstate;
        return 0;
  }
  
@@@ -667,7 -643,7 +643,7 @@@ static int fill_powernow_table(struct p
  
        dprintk("cfid 0x%x, cvid 0x%x\n", data->currfid, data->currvid);
        data->powernow_table = powernow_table;
 -      if (first_cpu(cpu_core_map[data->cpu]) == data->cpu)
 +      if (first_cpu(per_cpu(cpu_core_map, data->cpu)) == data->cpu)
                print_basics(data);
  
        for (j = 0; j < data->numps; j++)
@@@ -821,7 -797,7 +797,7 @@@ static int powernow_k8_cpu_init_acpi(st
  
        /* fill in data */
        data->numps = data->acpi_data.state_count;
 -      if (first_cpu(cpu_core_map[data->cpu]) == data->cpu)
 +      if (first_cpu(per_cpu(cpu_core_map, data->cpu)) == data->cpu)
                print_basics(data);
        powernow_k8_acpi_pst_values(data, 0);
  
@@@ -845,17 -821,20 +821,20 @@@ err_out
  static int fill_powernow_table_pstate(struct powernow_k8_data *data, struct cpufreq_frequency_table *powernow_table)
  {
        int i;
+       u32 hi = 0, lo = 0;
+       rdmsr(MSR_PSTATE_CUR_LIMIT, hi, lo);
+       data->max_hw_pstate = (hi & HW_PSTATE_MAX_MASK) >> HW_PSTATE_MAX_SHIFT;
  
        for (i = 0; i < data->acpi_data.state_count; i++) {
                u32 index;
                u32 hi = 0, lo = 0;
-               u32 fid;
-               u32 did;
  
                index = data->acpi_data.states[i].control & HW_PSTATE_MASK;
-               if (index > MAX_HW_PSTATE) {
+               if (index > data->max_hw_pstate) {
                        printk(KERN_ERR PFX "invalid pstate %d - bad value %d.\n", i, index);
                        printk(KERN_ERR PFX "Please report to BIOS manufacturer\n");
+                       powernow_table[i].frequency = CPUFREQ_ENTRY_INVALID;
+                       continue;
                }
                rdmsr(MSR_PSTATE_DEF_BASE + index, lo, hi);
                if (!(hi & HW_PSTATE_VALID_MASK)) {
                        continue;
                }
  
-               fid = lo & HW_PSTATE_FID_MASK;
-               did = (lo & HW_PSTATE_DID_MASK) >> HW_PSTATE_DID_SHIFT;
+               powernow_table[i].index = index;
  
-               dprintk("   %d : fid 0x%x, did 0x%x\n", index, fid, did);
-               powernow_table[i].index = index | (fid << HW_FID_INDEX_SHIFT) | (did << HW_DID_INDEX_SHIFT);
-               powernow_table[i].frequency = find_khz_freq_from_fiddid(fid, did);
-               if (powernow_table[i].frequency != (data->acpi_data.states[i].core_frequency * 1000)) {
-                       printk(KERN_INFO PFX "invalid freq entries %u kHz vs. %u kHz\n",
-                               powernow_table[i].frequency,
-                               (unsigned int) (data->acpi_data.states[i].core_frequency * 1000));
-                       powernow_table[i].frequency = CPUFREQ_ENTRY_INVALID;
-                       continue;
-               }
+               powernow_table[i].frequency = data->acpi_data.states[i].core_frequency * 1000;
        }
        return 0;
  }
@@@ -1020,22 -986,18 +986,18 @@@ static int transition_frequency_fidvid(
  /* Take a frequency, and issue the hardware pstate transition command */
  static int transition_frequency_pstate(struct powernow_k8_data *data, unsigned int index)
  {
-       u32 fid = 0;
-       u32 did = 0;
        u32 pstate = 0;
        int res, i;
        struct cpufreq_freqs freqs;
  
        dprintk("cpu %d transition to index %u\n", smp_processor_id(), index);
  
-       /* get fid did for hardware pstate transition */
+       /* get MSR index for hardware pstate transition */
        pstate = index & HW_PSTATE_MASK;
-       if (pstate > MAX_HW_PSTATE)
+       if (pstate > data->max_hw_pstate)
                return 0;
-       fid = (index & HW_FID_INDEX_MASK) >> HW_FID_INDEX_SHIFT;
-       did = (index & HW_DID_INDEX_MASK) >> HW_DID_INDEX_SHIFT;
-       freqs.old = find_khz_freq_from_fiddid(data->currfid, data->currdid);
-       freqs.new = find_khz_freq_from_fiddid(fid, did);
+       freqs.old = find_khz_freq_from_pstate(data->powernow_table, data->currpstate);
+       freqs.new = find_khz_freq_from_pstate(data->powernow_table, pstate);
  
        for_each_cpu_mask(i, *(data->available_cores)) {
                freqs.cpu = i;
        }
  
        res = transition_pstate(data, pstate);
-       data->currfid = find_fid_from_pstate(pstate);
-       data->currdid = find_did_from_pstate(pstate);
-       freqs.new = find_khz_freq_from_fiddid(data->currfid, data->currdid);
+       freqs.new = find_khz_freq_from_pstate(data->powernow_table, pstate);
  
        for_each_cpu_mask(i, *(data->available_cores)) {
                freqs.cpu = i;
@@@ -1090,10 -1050,7 +1050,7 @@@ static int powernowk8_target(struct cpu
        if (query_current_values_with_pending_wait(data))
                goto err_out;
  
-       if (cpu_family == CPU_HW_PSTATE)
-               dprintk("targ: curr fid 0x%x, did 0x%x\n",
-                       data->currfid, data->currdid);
-       else {
+       if (cpu_family != CPU_HW_PSTATE) {
                dprintk("targ: curr fid 0x%x, vid 0x%x\n",
                data->currfid, data->currvid);
  
        mutex_unlock(&fidvid_mutex);
  
        if (cpu_family == CPU_HW_PSTATE)
-               pol->cur = find_khz_freq_from_fiddid(data->currfid, data->currdid);
+               pol->cur = find_khz_freq_from_pstate(data->powernow_table, newstate);
        else
                pol->cur = find_khz_freq_from_fid(data->currfid);
        ret = 0;
@@@ -1214,7 -1171,7 +1171,7 @@@ static int __cpuinit powernowk8_cpu_ini
        if (cpu_family == CPU_HW_PSTATE)
                pol->cpus = cpumask_of_cpu(pol->cpu);
        else
 -              pol->cpus = cpu_core_map[pol->cpu];
 +              pol->cpus = per_cpu(cpu_core_map, pol->cpu);
        data->available_cores = &(pol->cpus);
  
        /* Take a crude guess here.
            + (3 * (1 << data->irt) * 10)) * 1000;
  
        if (cpu_family == CPU_HW_PSTATE)
-               pol->cur = find_khz_freq_from_fiddid(data->currfid, data->currdid);
+               pol->cur = find_khz_freq_from_pstate(data->powernow_table, data->currpstate);
        else
                pol->cur = find_khz_freq_from_fid(data->currfid);
        dprintk("policy current frequency %d kHz\n", pol->cur);
        cpufreq_frequency_table_get_attr(data->powernow_table, pol->cpu);
  
        if (cpu_family == CPU_HW_PSTATE)
-               dprintk("cpu_init done, current fid 0x%x, did 0x%x\n",
-                       data->currfid, data->currdid);
+               dprintk("cpu_init done, current pstate 0x%x\n", data->currpstate);
        else
                dprintk("cpu_init done, current fid 0x%x, vid 0x%x\n",
                        data->currfid, data->currvid);
@@@ -1281,7 -1237,7 +1237,7 @@@ static unsigned int powernowk8_get (uns
        cpumask_t oldmask = current->cpus_allowed;
        unsigned int khz = 0;
  
 -      data = powernow_data[first_cpu(cpu_core_map[cpu])];
 +      data = powernow_data[first_cpu(per_cpu(cpu_core_map, cpu))];
  
        if (!data)
                return -EINVAL;
                goto out;
  
        if (cpu_family == CPU_HW_PSTATE)
-               khz = find_khz_freq_from_fiddid(data->currfid, data->currdid);
+               khz = find_khz_freq_from_pstate(data->powernow_table, data->currpstate);
        else
                khz = find_khz_freq_from_fid(data->currfid);
  
index 7c4f6e0faed4a555ac599837d347dee7958d4feb,8ae88f181286e3fac7643106a829d008e2a250c6..afd2b520d35c6258a25a2bc0f804279b647ae430
@@@ -10,6 -10,7 +10,7 @@@ struct powernow_k8_data 
  
        u32 numps;  /* number of p-states */
        u32 batps;  /* number of p-states supported on battery */
+       u32 max_hw_pstate; /* maximum legal hardware pstate */
  
        /* these values are constant when the PSB is used to determine
         * vid/fid pairings, but are modified during the ->target() call
@@@ -21,8 -22,8 +22,8 @@@
        u32 plllock; /* pll lock time, units 1 us */
          u32 exttype; /* extended interface = 1 */
  
-       /* keep track of the current fid / vid or did */
-       u32 currvid, currfid, currdid;
+       /* keep track of the current fid / vid or pstate */
+       u32 currvid, currfid, currpstate;
  
        /* the powernow_table includes all frequency and vid/fid pairings:
         * fid are the lower 8 bits of the index, vid are the upper 8 bits.
  
  /* Hardware Pstate _PSS and MSR definitions */
  #define USE_HW_PSTATE         0x00000080
- #define HW_PSTATE_FID_MASK    0x0000003f
- #define HW_PSTATE_DID_MASK    0x000001c0
- #define HW_PSTATE_DID_SHIFT   6
  #define HW_PSTATE_MASK                0x00000007
  #define HW_PSTATE_VALID_MASK  0x80000000
- #define HW_FID_INDEX_SHIFT    8
- #define HW_FID_INDEX_MASK     0x0000ff00
- #define HW_DID_INDEX_SHIFT    16
- #define HW_DID_INDEX_MASK     0x00ff0000
- #define HW_WATTS_MASK         0xff
- #define HW_PWR_DVR_MASK               0x300
- #define HW_PWR_DVR_SHIFT      8
- #define HW_PWR_MAX_MULT               3
- #define MAX_HW_PSTATE         8       /* hw pstate supports up to 8 */
+ #define HW_PSTATE_MAX_MASK    0x000000f0
+ #define HW_PSTATE_MAX_SHIFT   4
  #define MSR_PSTATE_DEF_BASE   0xc0010064 /* base of Pstate MSRs */
  #define MSR_PSTATE_STATUS     0xc0010063 /* Pstate Status MSR */
  #define MSR_PSTATE_CTRL       0xc0010062 /* Pstate control MSR */
+ #define MSR_PSTATE_CUR_LIMIT  0xc0010061 /* pstate current limit MSR */
  
  /* define the two driver architectures */
  #define CPU_OPTERON 0
  #define PLL_LOCK_CONVERSION (1000/5) /* ms to ns, then divide by clock period */
  
  #define MAXIMUM_VID_STEPS 1  /* Current cpus only allow a single step of 25mV */
 -#define VST_UNITS_20US 20   /* Voltage Stabalization Time is in units of 20us */
 +#define VST_UNITS_20US 20   /* Voltage Stabilization Time is in units of 20us */
  
  /*
 - * Most values of interest are enocoded in a single field of the _PSS
 + * Most values of interest are encoded in a single field of the _PSS
   * entries: the "control" value.
   */