aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/cpufreq.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-12-11 15:45:35 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-11 15:45:35 -0500
commitbad73c5aa069f1f14cc07ce7bbae8d463635560c (patch)
treedb905bb3400e6fe70be95cd20158bed79b2b2c6c /drivers/cpufreq/cpufreq.c
parentb58ed041a360ed051fab17e4d9b0f451c6fedba7 (diff)
parentf316fc56555a5c3bcf6350f3d5ac26dd2c55f4cb (diff)
Merge tag 'pm+acpi-for-3.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull ACPI and power management updates from Rafael Wysocki: - Introduction of device PM QoS flags. - ACPI device power management update allowing subsystems other than PCI to use it more easily. - ACPI device enumeration rework allowing additional kinds of devices to be enumerated via ACPI. From Mika Westerberg, Adrian Hunter, Mathias Nyman, Andy Shevchenko, and Rafael J. Wysocki. - ACPICA update to version 20121018 from Bob Moore and Lv Zheng. - ACPI memory hotplug update from Wen Congyang and Yasuaki Ishimatsu. - Introduction of acpi_handle_<level>() messaging macros and ACPI-based CPU hot-remove support from Toshi Kani. - ACPI EC updates from Feng Tang. - cpufreq updates from Viresh Kumar, Fabio Baltieri and others. - cpuidle changes to quickly notice governor prediction failure from Youquan Song. - Support for using multiple cpuidle drivers at the same time and cpuidle cleanups from Daniel Lezcano. - devfreq updates from Nishanth Menon and others. - cpupower update from Thomas Renninger. - Fixes and small cleanups all over the place. * tag 'pm+acpi-for-3.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (196 commits) mmc: sdhci-acpi: enable runtime-pm for device HID INT33C6 ACPI: add Haswell LPSS devices to acpi_platform_device_ids list ACPI: add documentation about ACPI 5 enumeration pnpacpi: fix incorrect TEST_ALPHA() test ACPI / PM: Fix header of acpi_dev_pm_detach() in acpi.h ACPI / video: ignore BIOS initial backlight value for HP Folio 13-2000 ACPI : do not use Lid and Sleep button for S5 wakeup ACPI / PNP: Do not crash due to stale pointer use during system resume ACPI / video: Add "Asus UL30VT" to ACPI video detect blacklist ACPI: do acpisleep dmi check when CONFIG_ACPI_SLEEP is set spi / ACPI: add ACPI enumeration support gpio / ACPI: add ACPI support PM / devfreq: remove compiler error with module governors (2) cpupower: IvyBridge (0x3a and 0x3e models) support cpupower: Provide -c param for cpupower monitor to schedule process on all cores cpupower tools: Fix warning and a bug with the cpu package count cpupower tools: Fix malloc of cpu_info structure cpupower tools: Fix issues with sysfs_topology_read_file cpupower tools: Fix minor warnings cpupower tools: Update .gitignore for files created in the debug directories ...
Diffstat (limited to 'drivers/cpufreq/cpufreq.c')
-rw-r--r--drivers/cpufreq/cpufreq.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index fb8a5279c5d8..1f93dbd72355 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -15,6 +15,8 @@
15 * 15 *
16 */ 16 */
17 17
18#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
19
18#include <linux/kernel.h> 20#include <linux/kernel.h>
19#include <linux/module.h> 21#include <linux/module.h>
20#include <linux/init.h> 22#include <linux/init.h>
@@ -127,7 +129,7 @@ static int __init init_cpufreq_transition_notifier_list(void)
127pure_initcall(init_cpufreq_transition_notifier_list); 129pure_initcall(init_cpufreq_transition_notifier_list);
128 130
129static int off __read_mostly; 131static int off __read_mostly;
130int cpufreq_disabled(void) 132static int cpufreq_disabled(void)
131{ 133{
132 return off; 134 return off;
133} 135}
@@ -402,7 +404,7 @@ static int __cpufreq_set_policy(struct cpufreq_policy *data,
402static ssize_t store_##file_name \ 404static ssize_t store_##file_name \
403(struct cpufreq_policy *policy, const char *buf, size_t count) \ 405(struct cpufreq_policy *policy, const char *buf, size_t count) \
404{ \ 406{ \
405 unsigned int ret = -EINVAL; \ 407 unsigned int ret; \
406 struct cpufreq_policy new_policy; \ 408 struct cpufreq_policy new_policy; \
407 \ 409 \
408 ret = cpufreq_get_policy(&new_policy, policy->cpu); \ 410 ret = cpufreq_get_policy(&new_policy, policy->cpu); \
@@ -445,7 +447,7 @@ static ssize_t show_scaling_governor(struct cpufreq_policy *policy, char *buf)
445 else if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) 447 else if (policy->policy == CPUFREQ_POLICY_PERFORMANCE)
446 return sprintf(buf, "performance\n"); 448 return sprintf(buf, "performance\n");
447 else if (policy->governor) 449 else if (policy->governor)
448 return scnprintf(buf, CPUFREQ_NAME_LEN, "%s\n", 450 return scnprintf(buf, CPUFREQ_NAME_PLEN, "%s\n",
449 policy->governor->name); 451 policy->governor->name);
450 return -EINVAL; 452 return -EINVAL;
451} 453}
@@ -457,7 +459,7 @@ static ssize_t show_scaling_governor(struct cpufreq_policy *policy, char *buf)
457static ssize_t store_scaling_governor(struct cpufreq_policy *policy, 459static ssize_t store_scaling_governor(struct cpufreq_policy *policy,
458 const char *buf, size_t count) 460 const char *buf, size_t count)
459{ 461{
460 unsigned int ret = -EINVAL; 462 unsigned int ret;
461 char str_governor[16]; 463 char str_governor[16];
462 struct cpufreq_policy new_policy; 464 struct cpufreq_policy new_policy;
463 465
@@ -491,7 +493,7 @@ static ssize_t store_scaling_governor(struct cpufreq_policy *policy,
491 */ 493 */
492static ssize_t show_scaling_driver(struct cpufreq_policy *policy, char *buf) 494static ssize_t show_scaling_driver(struct cpufreq_policy *policy, char *buf)
493{ 495{
494 return scnprintf(buf, CPUFREQ_NAME_LEN, "%s\n", cpufreq_driver->name); 496 return scnprintf(buf, CPUFREQ_NAME_PLEN, "%s\n", cpufreq_driver->name);
495} 497}
496 498
497/** 499/**
@@ -512,7 +514,7 @@ static ssize_t show_scaling_available_governors(struct cpufreq_policy *policy,
512 if (i >= (ssize_t) ((PAGE_SIZE / sizeof(char)) 514 if (i >= (ssize_t) ((PAGE_SIZE / sizeof(char))
513 - (CPUFREQ_NAME_LEN + 2))) 515 - (CPUFREQ_NAME_LEN + 2)))
514 goto out; 516 goto out;
515 i += scnprintf(&buf[i], CPUFREQ_NAME_LEN, "%s ", t->name); 517 i += scnprintf(&buf[i], CPUFREQ_NAME_PLEN, "%s ", t->name);
516 } 518 }
517out: 519out:
518 i += sprintf(&buf[i], "\n"); 520 i += sprintf(&buf[i], "\n");
@@ -581,7 +583,7 @@ static ssize_t show_scaling_setspeed(struct cpufreq_policy *policy, char *buf)
581} 583}
582 584
583/** 585/**
584 * show_scaling_driver - show the current cpufreq HW/BIOS limitation 586 * show_bios_limit - show the current cpufreq HW/BIOS limitation
585 */ 587 */
586static ssize_t show_bios_limit(struct cpufreq_policy *policy, char *buf) 588static ssize_t show_bios_limit(struct cpufreq_policy *policy, char *buf)
587{ 589{
@@ -1468,12 +1470,23 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
1468 unsigned int relation) 1470 unsigned int relation)
1469{ 1471{
1470 int retval = -EINVAL; 1472 int retval = -EINVAL;
1473 unsigned int old_target_freq = target_freq;
1471 1474
1472 if (cpufreq_disabled()) 1475 if (cpufreq_disabled())
1473 return -ENODEV; 1476 return -ENODEV;
1474 1477
1475 pr_debug("target for CPU %u: %u kHz, relation %u\n", policy->cpu, 1478 /* Make sure that target_freq is within supported range */
1476 target_freq, relation); 1479 if (target_freq > policy->max)
1480 target_freq = policy->max;
1481 if (target_freq < policy->min)
1482 target_freq = policy->min;
1483
1484 pr_debug("target for CPU %u: %u kHz, relation %u, requested %u kHz\n",
1485 policy->cpu, target_freq, relation, old_target_freq);
1486
1487 if (target_freq == policy->cur)
1488 return 0;
1489
1477 if (cpu_online(policy->cpu) && cpufreq_driver->target) 1490 if (cpu_online(policy->cpu) && cpufreq_driver->target)
1478 retval = cpufreq_driver->target(policy, target_freq, relation); 1491 retval = cpufreq_driver->target(policy, target_freq, relation);
1479 1492
@@ -1509,12 +1522,14 @@ int __cpufreq_driver_getavg(struct cpufreq_policy *policy, unsigned int cpu)
1509{ 1522{
1510 int ret = 0; 1523 int ret = 0;
1511 1524
1525 if (!(cpu_online(cpu) && cpufreq_driver->getavg))
1526 return 0;
1527
1512 policy = cpufreq_cpu_get(policy->cpu); 1528 policy = cpufreq_cpu_get(policy->cpu);
1513 if (!policy) 1529 if (!policy)
1514 return -EINVAL; 1530 return -EINVAL;
1515 1531
1516 if (cpu_online(cpu) && cpufreq_driver->getavg) 1532 ret = cpufreq_driver->getavg(policy, cpu);
1517 ret = cpufreq_driver->getavg(policy, cpu);
1518 1533
1519 cpufreq_cpu_put(policy); 1534 cpufreq_cpu_put(policy);
1520 return ret; 1535 return ret;