Skip to content

Commit

Permalink
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/…
Browse files Browse the repository at this point in the history
…davej/cpufreq

* 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/davej/cpufreq:
  [CPUFREQ] Fix BUG: using smp_processor_id() in preemptible code
  [CPUFREQ] Don't export governors for default governor
  [CPUFREQ][6/6] cpufreq: Add idle microaccounting in ondemand governor
  [CPUFREQ][5/6] cpufreq: Changes to get_cpu_idle_time_us(), used by ondemand governor
  [CPUFREQ][4/6] cpufreq_ondemand: Parameterize down differential
  [CPUFREQ][3/6] cpufreq: get_cpu_idle_time() changes in ondemand for idle-microaccounting
  [CPUFREQ][2/6] cpufreq: Change load calculation in ondemand for software coordination
  [CPUFREQ][1/6] cpufreq: Add cpu number parameter to __cpufreq_driver_getavg()
  [CPUFREQ] use deferrable delayed work init in conservative governor
  [CPUFREQ] drivers/cpufreq/cpufreq.c: Adjust error handling code involving cpufreq_cpu_put
  [CPUFREQ] add error handling for cpufreq_register_governor() error
  [CPUFREQ] acpi-cpufreq: add error handling for cpufreq_register_driver() error
  [CPUFREQ] Coding style fixes to arch/x86/kernel/cpu/cpufreq/powernow-k6.c
  [CPUFREQ] Coding style fixes to arch/x86/kernel/cpu/cpufreq/elanfreq.c
  • Loading branch information
Linus Torvalds committed Oct 11, 2008
2 parents b922df7 + 4f6e6b9 commit 098ef21
Show file tree
Hide file tree
Showing 12 changed files with 204 additions and 106 deletions.
13 changes: 8 additions & 5 deletions arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ static u32 get_cur_val(const cpumask_t *mask)
* Only IA32_APERF/IA32_MPERF ratio is architecturally defined and
* no meaning should be associated with absolute values of these MSRs.
*/
static unsigned int get_measured_perf(unsigned int cpu)
static unsigned int get_measured_perf(struct cpufreq_policy *policy,
unsigned int cpu)
{
union {
struct {
Expand Down Expand Up @@ -326,7 +327,7 @@ static unsigned int get_measured_perf(unsigned int cpu)

#endif

retval = per_cpu(drv_data, cpu)->max_freq * perf_percent / 100;
retval = per_cpu(drv_data, policy->cpu)->max_freq * perf_percent / 100;

put_cpu();
set_cpus_allowed_ptr(current, &saved_mask);
Expand Down Expand Up @@ -785,7 +786,11 @@ static int __init acpi_cpufreq_init(void)
if (ret)
return ret;

return cpufreq_register_driver(&acpi_cpufreq_driver);
ret = cpufreq_register_driver(&acpi_cpufreq_driver);
if (ret)
free_percpu(acpi_perf_data);

return ret;
}

static void __exit acpi_cpufreq_exit(void)
Expand All @@ -795,8 +800,6 @@ static void __exit acpi_cpufreq_exit(void)
cpufreq_unregister_driver(&acpi_cpufreq_driver);

free_percpu(acpi_perf_data);

return;
}

module_param(acpi_pstate_strict, uint, 0644);
Expand Down
42 changes: 21 additions & 21 deletions arch/x86/kernel/cpu/cpufreq/elanfreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#include <linux/cpufreq.h>

#include <asm/msr.h>
#include <asm/timex.h>
#include <asm/io.h>
#include <linux/timex.h>
#include <linux/io.h>

#define REG_CSCIR 0x22 /* Chip Setup and Control Index Register */
#define REG_CSCDR 0x23 /* Chip Setup and Control Data Register */
Expand Down Expand Up @@ -82,7 +82,7 @@ static unsigned int elanfreq_get_cpu_frequency(unsigned int cpu)
u8 clockspeed_reg; /* Clock Speed Register */

local_irq_disable();
outb_p(0x80,REG_CSCIR);
outb_p(0x80, REG_CSCIR);
clockspeed_reg = inb_p(REG_CSCDR);
local_irq_enable();

Expand All @@ -98,10 +98,10 @@ static unsigned int elanfreq_get_cpu_frequency(unsigned int cpu)
}

/* 33 MHz is not 32 MHz... */
if ((clockspeed_reg & 0xE0)==0xA0)
if ((clockspeed_reg & 0xE0) == 0xA0)
return 33000;

return ((1<<((clockspeed_reg & 0xE0) >> 5)) * 1000);
return (1<<((clockspeed_reg & 0xE0) >> 5)) * 1000;
}


Expand All @@ -117,7 +117,7 @@ static unsigned int elanfreq_get_cpu_frequency(unsigned int cpu)
* There is no return value.
*/

static void elanfreq_set_cpu_state (unsigned int state)
static void elanfreq_set_cpu_state(unsigned int state)
{
struct cpufreq_freqs freqs;

Expand All @@ -144,20 +144,20 @@ static void elanfreq_set_cpu_state (unsigned int state)
*/

local_irq_disable();
outb_p(0x40,REG_CSCIR); /* Disable hyperspeed mode */
outb_p(0x00,REG_CSCDR);
outb_p(0x40, REG_CSCIR); /* Disable hyperspeed mode */
outb_p(0x00, REG_CSCDR);
local_irq_enable(); /* wait till internal pipelines and */
udelay(1000); /* buffers have cleaned up */

local_irq_disable();

/* now, set the CPU clock speed register (0x80) */
outb_p(0x80,REG_CSCIR);
outb_p(elan_multiplier[state].val80h,REG_CSCDR);
outb_p(0x80, REG_CSCIR);
outb_p(elan_multiplier[state].val80h, REG_CSCDR);

/* now, the hyperspeed bit in PMU Force Mode Register (0x40) */
outb_p(0x40,REG_CSCIR);
outb_p(elan_multiplier[state].val40h,REG_CSCDR);
outb_p(0x40, REG_CSCIR);
outb_p(elan_multiplier[state].val40h, REG_CSCDR);
udelay(10000);
local_irq_enable();

Expand All @@ -173,12 +173,12 @@ static void elanfreq_set_cpu_state (unsigned int state)
* for the hardware supported by the driver.
*/

static int elanfreq_verify (struct cpufreq_policy *policy)
static int elanfreq_verify(struct cpufreq_policy *policy)
{
return cpufreq_frequency_table_verify(policy, &elanfreq_table[0]);
}

static int elanfreq_target (struct cpufreq_policy *policy,
static int elanfreq_target(struct cpufreq_policy *policy,
unsigned int target_freq,
unsigned int relation)
{
Expand All @@ -205,15 +205,15 @@ static int elanfreq_cpu_init(struct cpufreq_policy *policy)

/* capability check */
if ((c->x86_vendor != X86_VENDOR_AMD) ||
(c->x86 != 4) || (c->x86_model!=10))
(c->x86 != 4) || (c->x86_model != 10))
return -ENODEV;

/* max freq */
if (!max_freq)
max_freq = elanfreq_get_cpu_frequency(0);

/* table init */
for (i=0; (elanfreq_table[i].frequency != CPUFREQ_TABLE_END); i++) {
for (i = 0; (elanfreq_table[i].frequency != CPUFREQ_TABLE_END); i++) {
if (elanfreq_table[i].frequency > max_freq)
elanfreq_table[i].frequency = CPUFREQ_ENTRY_INVALID;
}
Expand All @@ -224,7 +224,7 @@ static int elanfreq_cpu_init(struct cpufreq_policy *policy)

result = cpufreq_frequency_table_cpuinfo(policy, elanfreq_table);
if (result)
return (result);
return result;

cpufreq_frequency_table_get_attr(elanfreq_table, policy->cpu);
return 0;
Expand Down Expand Up @@ -260,7 +260,7 @@ __setup("elanfreq=", elanfreq_setup);
#endif


static struct freq_attr* elanfreq_attr[] = {
static struct freq_attr *elanfreq_attr[] = {
&cpufreq_freq_attr_scaling_available_freqs,
NULL,
};
Expand All @@ -284,9 +284,9 @@ static int __init elanfreq_init(void)

/* Test if we have the right hardware */
if ((c->x86_vendor != X86_VENDOR_AMD) ||
(c->x86 != 4) || (c->x86_model!=10)) {
(c->x86 != 4) || (c->x86_model != 10)) {
printk(KERN_INFO "elanfreq: error: no Elan processor found!\n");
return -ENODEV;
return -ENODEV;
}
return cpufreq_register_driver(&elanfreq_driver);
}
Expand All @@ -298,7 +298,7 @@ static void __exit elanfreq_exit(void)
}


module_param (max_freq, int, 0444);
module_param(max_freq, int, 0444);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Robert Schwebel <r.schwebel@pengutronix.de>, Sven Geggus <sven@geggus.net>");
Expand Down
41 changes: 20 additions & 21 deletions arch/x86/kernel/cpu/cpufreq/powernow-k6.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
#include <linux/slab.h>

#include <asm/msr.h>
#include <asm/timex.h>
#include <asm/io.h>
#include <linux/timex.h>
#include <linux/io.h>


#define POWERNOW_IOPORT 0xfff0 /* it doesn't matter where, as long
as it is unused */
#define POWERNOW_IOPORT 0xfff0 /* it doesn't matter where, as long
as it is unused */

static unsigned int busfreq; /* FSB, in 10 kHz */
static unsigned int max_multiplier;
Expand Down Expand Up @@ -53,7 +52,7 @@ static int powernow_k6_get_cpu_multiplier(void)

msrval = POWERNOW_IOPORT + 0x1;
wrmsr(MSR_K6_EPMR, msrval, 0); /* enable the PowerNow port */
invalue=inl(POWERNOW_IOPORT + 0x8);
invalue = inl(POWERNOW_IOPORT + 0x8);
msrval = POWERNOW_IOPORT + 0x0;
wrmsr(MSR_K6_EPMR, msrval, 0); /* disable it again */

Expand All @@ -67,9 +66,9 @@ static int powernow_k6_get_cpu_multiplier(void)
*
* Tries to change the PowerNow! multiplier
*/
static void powernow_k6_set_state (unsigned int best_i)
static void powernow_k6_set_state(unsigned int best_i)
{
unsigned long outvalue=0, invalue=0;
unsigned long outvalue = 0, invalue = 0;
unsigned long msrval;
struct cpufreq_freqs freqs;

Expand All @@ -90,10 +89,10 @@ static void powernow_k6_set_state (unsigned int best_i)

msrval = POWERNOW_IOPORT + 0x1;
wrmsr(MSR_K6_EPMR, msrval, 0); /* enable the PowerNow port */
invalue=inl(POWERNOW_IOPORT + 0x8);
invalue = inl(POWERNOW_IOPORT + 0x8);
invalue = invalue & 0xf;
outvalue = outvalue | invalue;
outl(outvalue ,(POWERNOW_IOPORT + 0x8));
outl(outvalue , (POWERNOW_IOPORT + 0x8));
msrval = POWERNOW_IOPORT + 0x0;
wrmsr(MSR_K6_EPMR, msrval, 0); /* disable it again */

Expand Down Expand Up @@ -124,7 +123,7 @@ static int powernow_k6_verify(struct cpufreq_policy *policy)
*
* sets a new CPUFreq policy
*/
static int powernow_k6_target (struct cpufreq_policy *policy,
static int powernow_k6_target(struct cpufreq_policy *policy,
unsigned int target_freq,
unsigned int relation)
{
Expand Down Expand Up @@ -152,7 +151,7 @@ static int powernow_k6_cpu_init(struct cpufreq_policy *policy)
busfreq = cpu_khz / max_multiplier;

/* table init */
for (i=0; (clock_ratio[i].frequency != CPUFREQ_TABLE_END); i++) {
for (i = 0; (clock_ratio[i].frequency != CPUFREQ_TABLE_END); i++) {
if (clock_ratio[i].index > max_multiplier)
clock_ratio[i].frequency = CPUFREQ_ENTRY_INVALID;
else
Expand All @@ -165,7 +164,7 @@ static int powernow_k6_cpu_init(struct cpufreq_policy *policy)

result = cpufreq_frequency_table_cpuinfo(policy, clock_ratio);
if (result)
return (result);
return result;

cpufreq_frequency_table_get_attr(clock_ratio, policy->cpu);

Expand All @@ -176,8 +175,8 @@ static int powernow_k6_cpu_init(struct cpufreq_policy *policy)
static int powernow_k6_cpu_exit(struct cpufreq_policy *policy)
{
unsigned int i;
for (i=0; i<8; i++) {
if (i==max_multiplier)
for (i = 0; i < 8; i++) {
if (i == max_multiplier)
powernow_k6_set_state(i);
}
cpufreq_frequency_table_put_attr(policy->cpu);
Expand All @@ -189,7 +188,7 @@ static unsigned int powernow_k6_get(unsigned int cpu)
return busfreq * powernow_k6_get_cpu_multiplier();
}

static struct freq_attr* powernow_k6_attr[] = {
static struct freq_attr *powernow_k6_attr[] = {
&cpufreq_freq_attr_scaling_available_freqs,
NULL,
};
Expand Down Expand Up @@ -227,7 +226,7 @@ static int __init powernow_k6_init(void)
}

if (cpufreq_register_driver(&powernow_k6_driver)) {
release_region (POWERNOW_IOPORT, 16);
release_region(POWERNOW_IOPORT, 16);
return -EINVAL;
}

Expand All @@ -243,13 +242,13 @@ static int __init powernow_k6_init(void)
static void __exit powernow_k6_exit(void)
{
cpufreq_unregister_driver(&powernow_k6_driver);
release_region (POWERNOW_IOPORT, 16);
release_region(POWERNOW_IOPORT, 16);
}


MODULE_AUTHOR ("Arjan van de Ven <arjanv@redhat.com>, Dave Jones <davej@codemonkey.org.uk>, Dominik Brodowski <linux@brodo.de>");
MODULE_DESCRIPTION ("PowerNow! driver for AMD K6-2+ / K6-3+ processors.");
MODULE_LICENSE ("GPL");
MODULE_AUTHOR("Arjan van de Ven <arjanv@redhat.com>, Dave Jones <davej@codemonkey.org.uk>, Dominik Brodowski <linux@brodo.de>");
MODULE_DESCRIPTION("PowerNow! driver for AMD K6-2+ / K6-3+ processors.");
MODULE_LICENSE("GPL");

module_init(powernow_k6_init);
module_exit(powernow_k6_exit);
30 changes: 19 additions & 11 deletions drivers/cpufreq/cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1467,34 +1467,36 @@ int cpufreq_driver_target(struct cpufreq_policy *policy,
unsigned int target_freq,
unsigned int relation)
{
int ret;
int ret = -EINVAL;

policy = cpufreq_cpu_get(policy->cpu);
if (!policy)
return -EINVAL;
goto no_policy;

if (unlikely(lock_policy_rwsem_write(policy->cpu)))
return -EINVAL;
goto fail;

ret = __cpufreq_driver_target(policy, target_freq, relation);

unlock_policy_rwsem_write(policy->cpu);

fail:
cpufreq_cpu_put(policy);
no_policy:
return ret;
}
EXPORT_SYMBOL_GPL(cpufreq_driver_target);

int __cpufreq_driver_getavg(struct cpufreq_policy *policy)
int __cpufreq_driver_getavg(struct cpufreq_policy *policy, unsigned int cpu)
{
int ret = 0;

policy = cpufreq_cpu_get(policy->cpu);
if (!policy)
return -EINVAL;

if (cpu_online(policy->cpu) && cpufreq_driver->getavg)
ret = cpufreq_driver->getavg(policy->cpu);
if (cpu_online(cpu) && cpufreq_driver->getavg)
ret = cpufreq_driver->getavg(policy, cpu);

cpufreq_cpu_put(policy);
return ret;
Expand Down Expand Up @@ -1717,13 +1719,17 @@ int cpufreq_update_policy(unsigned int cpu)
{
struct cpufreq_policy *data = cpufreq_cpu_get(cpu);
struct cpufreq_policy policy;
int ret = 0;
int ret;

if (!data)
return -ENODEV;
if (!data) {
ret = -ENODEV;
goto no_policy;
}

if (unlikely(lock_policy_rwsem_write(cpu)))
return -EINVAL;
if (unlikely(lock_policy_rwsem_write(cpu))) {
ret = -EINVAL;
goto fail;
}

dprintk("updating policy for CPU %u\n", cpu);
memcpy(&policy, data, sizeof(struct cpufreq_policy));
Expand All @@ -1750,7 +1756,9 @@ int cpufreq_update_policy(unsigned int cpu)

unlock_policy_rwsem_write(cpu);

fail:
cpufreq_cpu_put(data);
no_policy:
return ret;
}
EXPORT_SYMBOL(cpufreq_update_policy);
Expand Down
Loading

0 comments on commit 098ef21

Please sign in to comment.