Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / arch / i386 / oprofile / nmi_int.c
index d3450dc..ec0fd3c 100644 (file)
@@ -32,7 +32,7 @@ static int nmi_enabled = 0;
 
 #ifdef CONFIG_PM
 
-static int nmi_suspend(struct sys_device *dev, u32 state)
+static int nmi_suspend(struct sys_device *dev, pm_message_t state)
 {
        if (nmi_enabled == 1)
                nmi_stop();
@@ -70,7 +70,7 @@ static int __init init_driverfs(void)
 }
 
 
-static void __exit exit_driverfs(void)
+static void exit_driverfs(void)
 {
        sysdev_unregister(&device_oprofile);
        sysdev_class_unregister(&oprofile_sysclass);
@@ -84,7 +84,7 @@ static void __exit exit_driverfs(void)
 
 static int nmi_callback(struct pt_regs * regs, int cpu)
 {
-       return model->check_ctrs(cpu, &cpu_msrs[cpu], regs);
+       return model->check_ctrs(regs, &cpu_msrs[cpu]);
 }
  
  
@@ -122,7 +122,7 @@ static void nmi_save_registers(void * dummy)
 static void free_msrs(void)
 {
        int i;
-       for (i = 0; i < NR_CPUS; ++i) {
+       for_each_possible_cpu(i) {
                kfree(cpu_msrs[i].counters);
                cpu_msrs[i].counters = NULL;
                kfree(cpu_msrs[i].controls);
@@ -138,10 +138,7 @@ static int allocate_msrs(void)
        size_t counters_size = sizeof(struct op_msr) * model->num_counters;
 
        int i;
-       for (i = 0; i < NR_CPUS; ++i) {
-               if (!cpu_online(i))
-                       continue;
-
+       for_each_online_cpu(i) {
                cpu_msrs[i].counters = kmalloc(counters_size, GFP_KERNEL);
                if (!cpu_msrs[i].counters) {
                        success = 0;
@@ -300,35 +297,26 @@ static int nmi_create_files(struct super_block * sb, struct dentry * root)
 }
  
  
-struct oprofile_operations nmi_ops = {
-       .create_files   = nmi_create_files,
-       .setup          = nmi_setup,
-       .shutdown       = nmi_shutdown,
-       .start          = nmi_start,
-       .stop           = nmi_stop
-};
-
-static int __init p4_init(void)
+static int __init p4_init(char ** cpu_type)
 {
-       __u8 cpu_model = current_cpu_data.x86_model;
+       __u8 cpu_model = boot_cpu_data.x86_model;
 
-       if (cpu_model > 3)
+       if (cpu_model > 4)
                return 0;
 
 #ifndef CONFIG_SMP
-       nmi_ops.cpu_type = "i386/p4";
+       *cpu_type = "i386/p4";
        model = &op_p4_spec;
        return 1;
 #else
        switch (smp_num_siblings) {
                case 1:
-                       nmi_ops.cpu_type = "i386/p4";
+                       *cpu_type = "i386/p4";
                        model = &op_p4_spec;
                        return 1;
 
                case 2:
-                       nmi_ops.cpu_type = "i386/p4-ht";
+                       *cpu_type = "i386/p4-ht";
                        model = &op_p4_ht2_spec;
                        return 1;
        }
@@ -340,21 +328,22 @@ static int __init p4_init(void)
 }
 
 
-static int __init ppro_init(void)
+static int __init ppro_init(char ** cpu_type)
 {
-       __u8 cpu_model = current_cpu_data.x86_model;
+       __u8 cpu_model = boot_cpu_data.x86_model;
 
-       if (cpu_model > 0xd)
+       if (cpu_model == 14)
+               *cpu_type = "i386/core";
+       else if (cpu_model > 0xd)
                return 0;
-
-       if (cpu_model == 9) {
-               nmi_ops.cpu_type = "i386/p6_mobile";
+       else if (cpu_model == 9) {
+               *cpu_type = "i386/p6_mobile";
        } else if (cpu_model > 5) {
-               nmi_ops.cpu_type = "i386/piii";
+               *cpu_type = "i386/piii";
        } else if (cpu_model > 2) {
-               nmi_ops.cpu_type = "i386/pii";
+               *cpu_type = "i386/pii";
        } else {
-               nmi_ops.cpu_type = "i386/ppro";
+               *cpu_type = "i386/ppro";
        }
 
        model = &op_ppro_spec;
@@ -364,11 +353,12 @@ static int __init ppro_init(void)
 /* in order to get driverfs right */
 static int using_nmi;
 
-int __init nmi_init(struct oprofile_operations ** ops)
+int __init op_nmi_init(struct oprofile_operations *ops)
 {
-       __u8 vendor = current_cpu_data.x86_vendor;
-       __u8 family = current_cpu_data.x86;
+       __u8 vendor = boot_cpu_data.x86_vendor;
+       __u8 family = boot_cpu_data.x86;
+       char *cpu_type;
+
        if (!cpu_has_apic)
                return -ENODEV;
  
@@ -381,13 +371,13 @@ int __init nmi_init(struct oprofile_operations ** ops)
                                return -ENODEV;
                        case 6:
                                model = &op_athlon_spec;
-                               nmi_ops.cpu_type = "i386/athlon";
+                               cpu_type = "i386/athlon";
                                break;
                        case 0xf:
                                model = &op_athlon_spec;
                                /* Actually it could be i386/hammer too, but give
                                   user space an consistent name. */
-                               nmi_ops.cpu_type = "x86-64/hammer";
+                               cpu_type = "x86-64/hammer";
                                break;
                        }
                        break;
@@ -396,13 +386,13 @@ int __init nmi_init(struct oprofile_operations ** ops)
                        switch (family) {
                                /* Pentium IV */
                                case 0xf:
-                                       if (!p4_init())
+                                       if (!p4_init(&cpu_type))
                                                return -ENODEV;
                                        break;
 
                                /* A P6-class processor */
                                case 6:
-                                       if (!ppro_init())
+                                       if (!ppro_init(&cpu_type))
                                                return -ENODEV;
                                        break;
 
@@ -417,13 +407,18 @@ int __init nmi_init(struct oprofile_operations ** ops)
 
        init_driverfs();
        using_nmi = 1;
-       *ops = &nmi_ops;
+       ops->create_files = nmi_create_files;
+       ops->setup = nmi_setup;
+       ops->shutdown = nmi_shutdown;
+       ops->start = nmi_start;
+       ops->stop = nmi_stop;
+       ops->cpu_type = cpu_type;
        printk(KERN_INFO "oprofile: using NMI interrupt.\n");
        return 0;
 }
 
 
-void __exit nmi_exit(void)
+void op_nmi_exit(void)
 {
        if (using_nmi)
                exit_driverfs();