drm/i915: Respect GM965/GM45 bit-17-instead-of-bit-11 option for swizzling.
[safe/jmp/linux-2.6] / drivers / acpi / processor_perflib.c
index b477a4b..0d7b772 100644 (file)
 #include <asm/uaccess.h>
 #endif
 
+#ifdef CONFIG_X86
+#include <asm/cpufeature.h>
+#endif
+
 #include <acpi/acpi_bus.h>
+#include <acpi/acpi_drivers.h>
 #include <acpi/processor.h>
 
-#define ACPI_PROCESSOR_COMPONENT       0x01000000
 #define ACPI_PROCESSOR_CLASS           "processor"
 #define ACPI_PROCESSOR_FILE_PERFORMANCE        "performance"
 #define _COMPONENT             ACPI_PROCESSOR_COMPONENT
@@ -64,15 +68,21 @@ static DEFINE_MUTEX(performance_mutex);
  * policy is adjusted accordingly.
  */
 
-static unsigned int ignore_ppc = 0;
-module_param(ignore_ppc, uint, 0644);
+/* ignore_ppc:
+ * -1 -> cpufreq low level drivers not initialized -> _PSS, etc. not called yet
+ *       ignore _PPC
+ *  0 -> cpufreq low level drivers initialized -> consider _PPC values
+ *  1 -> ignore _PPC totally -> forced by user through boot param
+ */
+static int ignore_ppc = -1;
+module_param(ignore_ppc, int, 0644);
 MODULE_PARM_DESC(ignore_ppc, "If the frequency of your machine gets wrongly" \
                 "limited by BIOS, this should help");
 
 #define PPC_REGISTERED   1
 #define PPC_IN_USE       2
 
-static int acpi_processor_ppc_status = 0;
+static int acpi_processor_ppc_status;
 
 static int acpi_processor_ppc_notifier(struct notifier_block *nb,
                                       unsigned long event, void *data)
@@ -81,15 +91,20 @@ static int acpi_processor_ppc_notifier(struct notifier_block *nb,
        struct acpi_processor *pr;
        unsigned int ppc = 0;
 
-       if (ignore_ppc)
+       if (event == CPUFREQ_START && ignore_ppc <= 0) {
+               ignore_ppc = 0;
                return 0;
+       }
 
-       mutex_lock(&performance_mutex);
+       if (ignore_ppc)
+               return 0;
 
        if (event != CPUFREQ_INCOMPATIBLE)
-               goto out;
+               return 0;
 
-       pr = processors[policy->cpu];
+       mutex_lock(&performance_mutex);
+
+       pr = per_cpu(processors, policy->cpu);
        if (!pr || !pr->performance)
                goto out;
 
@@ -115,7 +130,7 @@ static struct notifier_block acpi_ppc_notifier_block = {
 static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
 {
        acpi_status status = 0;
-       unsigned long ppc = 0;
+       unsigned long long ppc = 0;
 
 
        if (!pr)
@@ -323,7 +338,6 @@ static int acpi_processor_get_performance_info(struct acpi_processor *pr)
        acpi_status status = AE_OK;
        acpi_handle handle = NULL;
 
-
        if (!pr || !pr->performance || !pr->handle)
                return -EINVAL;
 
@@ -336,13 +350,27 @@ static int acpi_processor_get_performance_info(struct acpi_processor *pr)
 
        result = acpi_processor_get_performance_control(pr);
        if (result)
-               return result;
+               goto update_bios;
 
        result = acpi_processor_get_performance_states(pr);
        if (result)
-               return result;
+               goto update_bios;
 
        return 0;
+
+       /*
+        * Having _PPC but missing frequencies (_PSS, _PCT) is a very good hint that
+        * the BIOS is older than the CPU and does not know its frequencies
+        */
+ update_bios:
+#ifdef CONFIG_X86
+       if (ACPI_SUCCESS(acpi_get_handle(pr->handle, "_PPC", &handle))){
+               if(boot_cpu_has(X86_FEATURE_EST))
+                       printk(KERN_WARNING FW_BUG "BIOS needs update for CPU "
+                              "frequency support\n");
+       }
+#endif
+       return result;
 }
 
 int acpi_processor_notify_smm(struct module *calling_module)
@@ -411,6 +439,7 @@ EXPORT_SYMBOL(acpi_processor_notify_smm);
 
 static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file);
 static struct file_operations acpi_processor_perf_fops = {
+       .owner = THIS_MODULE,
        .open = acpi_processor_perf_open_fs,
        .read = seq_read,
        .llseek = seq_lseek,
@@ -456,7 +485,6 @@ static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file)
 
 static void acpi_cpufreq_add_file(struct acpi_processor *pr)
 {
-       struct proc_dir_entry *entry = NULL;
        struct acpi_device *device = NULL;
 
 
@@ -464,14 +492,9 @@ static void acpi_cpufreq_add_file(struct acpi_processor *pr)
                return;
 
        /* add file 'performance' [R/W] */
-       entry = create_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE,
-                                 S_IFREG | S_IRUGO,
-                                 acpi_device_dir(device));
-       if (entry){
-               entry->proc_fops = &acpi_processor_perf_fops;
-               entry->data = acpi_driver_data(device);
-               entry->owner = THIS_MODULE;
-       }
+       proc_create_data(ACPI_PROCESSOR_FILE_PERFORMANCE, S_IFREG | S_IRUGO,
+                        acpi_device_dir(device),
+                        &acpi_processor_perf_fops, acpi_driver_data(device));
        return;
 }
 
@@ -518,13 +541,13 @@ static int acpi_processor_get_psd(struct acpi_processor   *pr)
 
        psd = buffer.pointer;
        if (!psd || (psd->type != ACPI_TYPE_PACKAGE)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSD data\n"));
+               printk(KERN_ERR PREFIX "Invalid _PSD data\n");
                result = -EFAULT;
                goto end;
        }
 
        if (psd->package.count != 1) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSD data\n"));
+               printk(KERN_ERR PREFIX "Invalid _PSD data\n");
                result = -EFAULT;
                goto end;
        }
@@ -537,19 +560,19 @@ static int acpi_processor_get_psd(struct acpi_processor   *pr)
        status = acpi_extract_package(&(psd->package.elements[0]),
                &format, &state);
        if (ACPI_FAILURE(status)) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSD data\n"));
+               printk(KERN_ERR PREFIX "Invalid _PSD data\n");
                result = -EFAULT;
                goto end;
        }
 
        if (pdomain->num_entries != ACPI_PSD_REV0_ENTRIES) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown _PSD:num_entries\n"));
+               printk(KERN_ERR PREFIX "Unknown _PSD:num_entries\n");
                result = -EFAULT;
                goto end;
        }
 
        if (pdomain->revision != ACPI_PSD_REV0_REVISION) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown _PSD:revision\n"));
+               printk(KERN_ERR PREFIX "Unknown _PSD:revision\n");
                result = -EFAULT;
                goto end;
        }
@@ -577,7 +600,7 @@ int acpi_processor_preregister_performance(
 
        /* Call _PSD for all CPUs */
        for_each_possible_cpu(i) {
-               pr = processors[i];
+               pr = per_cpu(processors, i);
                if (!pr) {
                        /* Look only at processors in ACPI namespace */
                        continue;
@@ -608,7 +631,7 @@ int acpi_processor_preregister_performance(
         * domain info.
         */
        for_each_possible_cpu(i) {
-               pr = processors[i];
+               pr = per_cpu(processors, i);
                if (!pr)
                        continue;
 
@@ -629,7 +652,7 @@ int acpi_processor_preregister_performance(
 
        cpus_clear(covered_cpus);
        for_each_possible_cpu(i) {
-               pr = processors[i];
+               pr = per_cpu(processors, i);
                if (!pr)
                        continue;
 
@@ -656,7 +679,7 @@ int acpi_processor_preregister_performance(
                        if (i == j)
                                continue;
 
-                       match_pr = processors[j];
+                       match_pr = per_cpu(processors, j);
                        if (!match_pr)
                                continue;
 
@@ -685,7 +708,7 @@ int acpi_processor_preregister_performance(
                        if (i == j)
                                continue;
 
-                       match_pr = processors[j];
+                       match_pr = per_cpu(processors, j);
                        if (!match_pr)
                                continue;
 
@@ -702,7 +725,7 @@ int acpi_processor_preregister_performance(
 
 err_ret:
        for_each_possible_cpu(i) {
-               pr = processors[i];
+               pr = per_cpu(processors, i);
                if (!pr || !pr->performance)
                        continue;
 
@@ -733,7 +756,7 @@ acpi_processor_register_performance(struct acpi_processor_performance
 
        mutex_lock(&performance_mutex);
 
-       pr = processors[cpu];
+       pr = per_cpu(processors, cpu);
        if (!pr) {
                mutex_unlock(&performance_mutex);
                return -ENODEV;
@@ -771,7 +794,7 @@ acpi_processor_unregister_performance(struct acpi_processor_performance
 
        mutex_lock(&performance_mutex);
 
-       pr = processors[cpu];
+       pr = per_cpu(processors, cpu);
        if (!pr) {
                mutex_unlock(&performance_mutex);
                return;