diff options
| -rw-r--r-- | arch/x86/kernel/cpu/cpufreq/powernow-k8.c | 109 | ||||
| -rw-r--r-- | arch/x86/kernel/cpu/cpufreq/powernow-k8.h | 3 |
2 files changed, 75 insertions, 37 deletions
diff --git a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c index 84bb395038d8..4e7271999a74 100644 --- a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c +++ b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c | |||
| @@ -737,44 +737,63 @@ static int find_psb_table(struct powernow_k8_data *data) | |||
| 737 | #ifdef CONFIG_X86_POWERNOW_K8_ACPI | 737 | #ifdef CONFIG_X86_POWERNOW_K8_ACPI |
| 738 | static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned int index) | 738 | static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned int index) |
| 739 | { | 739 | { |
| 740 | if (!data->acpi_data.state_count || (cpu_family == CPU_HW_PSTATE)) | 740 | if (!data->acpi_data->state_count || (cpu_family == CPU_HW_PSTATE)) |
| 741 | return; | 741 | return; |
| 742 | 742 | ||
| 743 | data->irt = (data->acpi_data.states[index].control >> IRT_SHIFT) & IRT_MASK; | 743 | data->irt = (data->acpi_data->states[index].control >> IRT_SHIFT) & IRT_MASK; |
| 744 | data->rvo = (data->acpi_data.states[index].control >> RVO_SHIFT) & RVO_MASK; | 744 | data->rvo = (data->acpi_data->states[index].control >> RVO_SHIFT) & RVO_MASK; |
| 745 | data->exttype = (data->acpi_data.states[index].control >> EXT_TYPE_SHIFT) & EXT_TYPE_MASK; | 745 | data->exttype = (data->acpi_data->states[index].control >> EXT_TYPE_SHIFT) & EXT_TYPE_MASK; |
| 746 | data->plllock = (data->acpi_data.states[index].control >> PLL_L_SHIFT) & PLL_L_MASK; | 746 | data->plllock = (data->acpi_data->states[index].control >> PLL_L_SHIFT) & PLL_L_MASK; |
| 747 | data->vidmvs = 1 << ((data->acpi_data.states[index].control >> MVS_SHIFT) & MVS_MASK); | 747 | data->vidmvs = 1 << ((data->acpi_data->states[index].control >> MVS_SHIFT) & MVS_MASK); |
| 748 | data->vstable = (data->acpi_data.states[index].control >> VST_SHIFT) & VST_MASK; | 748 | data->vstable = (data->acpi_data->states[index].control >> VST_SHIFT) & VST_MASK; |
| 749 | } | ||
| 750 | |||
| 751 | |||
| 752 | static struct acpi_processor_performance *acpi_perf_data; | ||
| 753 | static int preregister_valid; | ||
| 754 | |||
| 755 | static int powernow_k8_cpu_preinit_acpi(void) | ||
| 756 | { | ||
| 757 | acpi_perf_data = alloc_percpu(struct acpi_processor_performance); | ||
| 758 | if (!acpi_perf_data) | ||
| 759 | return -ENODEV; | ||
| 760 | |||
| 761 | if (acpi_processor_preregister_performance(acpi_perf_data)) | ||
| 762 | return -ENODEV; | ||
| 763 | else | ||
| 764 | preregister_valid = 1; | ||
| 765 | return 0; | ||
| 749 | } | 766 | } |
| 750 | 767 | ||
| 751 | static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) | 768 | static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) |
| 752 | { | 769 | { |
| 753 | struct cpufreq_frequency_table *powernow_table; | 770 | struct cpufreq_frequency_table *powernow_table; |
| 754 | int ret_val; | 771 | int ret_val; |
| 772 | int cpu = 0; | ||
| 755 | 773 | ||
| 756 | if (acpi_processor_register_performance(&data->acpi_data, data->cpu)) { | 774 | data->acpi_data = percpu_ptr(acpi_perf_data, cpu); |
| 775 | if (acpi_processor_register_performance(data->acpi_data, data->cpu)) { | ||
| 757 | dprintk("register performance failed: bad ACPI data\n"); | 776 | dprintk("register performance failed: bad ACPI data\n"); |
| 758 | return -EIO; | 777 | return -EIO; |
| 759 | } | 778 | } |
| 760 | 779 | ||
| 761 | /* verify the data contained in the ACPI structures */ | 780 | /* verify the data contained in the ACPI structures */ |
| 762 | if (data->acpi_data.state_count <= 1) { | 781 | if (data->acpi_data->state_count <= 1) { |
| 763 | dprintk("No ACPI P-States\n"); | 782 | dprintk("No ACPI P-States\n"); |
| 764 | goto err_out; | 783 | goto err_out; |
| 765 | } | 784 | } |
| 766 | 785 | ||
| 767 | if ((data->acpi_data.control_register.space_id != ACPI_ADR_SPACE_FIXED_HARDWARE) || | 786 | if ((data->acpi_data->control_register.space_id != ACPI_ADR_SPACE_FIXED_HARDWARE) || |
| 768 | (data->acpi_data.status_register.space_id != ACPI_ADR_SPACE_FIXED_HARDWARE)) { | 787 | (data->acpi_data->status_register.space_id != ACPI_ADR_SPACE_FIXED_HARDWARE)) { |
| 769 | dprintk("Invalid control/status registers (%x - %x)\n", | 788 | dprintk("Invalid control/status registers (%x - %x)\n", |
| 770 | data->acpi_data.control_register.space_id, | 789 | data->acpi_data->control_register.space_id, |
| 771 | data->acpi_data.status_register.space_id); | 790 | data->acpi_data->status_register.space_id); |
| 772 | goto err_out; | 791 | goto err_out; |
| 773 | } | 792 | } |
| 774 | 793 | ||
| 775 | /* fill in data->powernow_table */ | 794 | /* fill in data->powernow_table */ |
| 776 | powernow_table = kmalloc((sizeof(struct cpufreq_frequency_table) | 795 | powernow_table = kmalloc((sizeof(struct cpufreq_frequency_table) |
| 777 | * (data->acpi_data.state_count + 1)), GFP_KERNEL); | 796 | * (data->acpi_data->state_count + 1)), GFP_KERNEL); |
| 778 | if (!powernow_table) { | 797 | if (!powernow_table) { |
| 779 | dprintk("powernow_table memory alloc failure\n"); | 798 | dprintk("powernow_table memory alloc failure\n"); |
| 780 | goto err_out; | 799 | goto err_out; |
| @@ -787,12 +806,12 @@ static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) | |||
| 787 | if (ret_val) | 806 | if (ret_val) |
| 788 | goto err_out_mem; | 807 | goto err_out_mem; |
| 789 | 808 | ||
| 790 | powernow_table[data->acpi_data.state_count].frequency = CPUFREQ_TABLE_END; | 809 | powernow_table[data->acpi_data->state_count].frequency = CPUFREQ_TABLE_END; |
| 791 | powernow_table[data->acpi_data.state_count].index = 0; | 810 | powernow_table[data->acpi_data->state_count].index = 0; |
| 792 | data->powernow_table = powernow_table; | 811 | data->powernow_table = powernow_table; |
| 793 | 812 | ||
| 794 | /* fill in data */ | 813 | /* fill in data */ |
| 795 | data->numps = data->acpi_data.state_count; | 814 | data->numps = data->acpi_data->state_count; |
| 796 | if (first_cpu(per_cpu(cpu_core_map, data->cpu)) == data->cpu) | 815 | if (first_cpu(per_cpu(cpu_core_map, data->cpu)) == data->cpu) |
| 797 | print_basics(data); | 816 | print_basics(data); |
| 798 | powernow_k8_acpi_pst_values(data, 0); | 817 | powernow_k8_acpi_pst_values(data, 0); |
| @@ -800,16 +819,31 @@ static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) | |||
| 800 | /* notify BIOS that we exist */ | 819 | /* notify BIOS that we exist */ |
| 801 | acpi_processor_notify_smm(THIS_MODULE); | 820 | acpi_processor_notify_smm(THIS_MODULE); |
| 802 | 821 | ||
| 822 | /* determine affinity, from ACPI if available */ | ||
| 823 | if (preregister_valid) { | ||
| 824 | if ((data->acpi_data->shared_type == CPUFREQ_SHARED_TYPE_ALL) || | ||
| 825 | (data->acpi_data->shared_type == CPUFREQ_SHARED_TYPE_ANY)) | ||
| 826 | data->starting_core_affinity = data->acpi_data->shared_cpu_map; | ||
| 827 | else | ||
| 828 | data->starting_core_affinity = cpumask_of_cpu(data->cpu); | ||
| 829 | } else { | ||
| 830 | /* best guess from family if not */ | ||
| 831 | if (cpu_family == CPU_HW_PSTATE) | ||
| 832 | data->starting_core_affinity = cpumask_of_cpu(data->cpu); | ||
| 833 | else | ||
| 834 | data->starting_core_affinity = per_cpu(cpu_core_map, data->cpu); | ||
| 835 | } | ||
| 836 | |||
| 803 | return 0; | 837 | return 0; |
| 804 | 838 | ||
| 805 | err_out_mem: | 839 | err_out_mem: |
| 806 | kfree(powernow_table); | 840 | kfree(powernow_table); |
| 807 | 841 | ||
| 808 | err_out: | 842 | err_out: |
| 809 | acpi_processor_unregister_performance(&data->acpi_data, data->cpu); | 843 | acpi_processor_unregister_performance(data->acpi_data, data->cpu); |
| 810 | 844 | ||
| 811 | /* data->acpi_data.state_count informs us at ->exit() whether ACPI was used */ | 845 | /* data->acpi_data.state_count informs us at ->exit() whether ACPI was used */ |
| 812 | data->acpi_data.state_count = 0; | 846 | data->acpi_data->state_count = 0; |
| 813 | 847 | ||
| 814 | return -ENODEV; | 848 | return -ENODEV; |
| 815 | } | 849 | } |
| @@ -821,10 +855,10 @@ static int fill_powernow_table_pstate(struct powernow_k8_data *data, struct cpuf | |||
| 821 | rdmsr(MSR_PSTATE_CUR_LIMIT, hi, lo); | 855 | rdmsr(MSR_PSTATE_CUR_LIMIT, hi, lo); |
| 822 | data->max_hw_pstate = (hi & HW_PSTATE_MAX_MASK) >> HW_PSTATE_MAX_SHIFT; | 856 | data->max_hw_pstate = (hi & HW_PSTATE_MAX_MASK) >> HW_PSTATE_MAX_SHIFT; |
| 823 | 857 | ||
| 824 | for (i = 0; i < data->acpi_data.state_count; i++) { | 858 | for (i = 0; i < data->acpi_data->state_count; i++) { |
| 825 | u32 index; | 859 | u32 index; |
| 826 | 860 | ||
| 827 | index = data->acpi_data.states[i].control & HW_PSTATE_MASK; | 861 | index = data->acpi_data->states[i].control & HW_PSTATE_MASK; |
| 828 | if (index > data->max_hw_pstate) { | 862 | if (index > data->max_hw_pstate) { |
| 829 | printk(KERN_ERR PFX "invalid pstate %d - bad value %d.\n", i, index); | 863 | printk(KERN_ERR PFX "invalid pstate %d - bad value %d.\n", i, index); |
| 830 | printk(KERN_ERR PFX "Please report to BIOS manufacturer\n"); | 864 | printk(KERN_ERR PFX "Please report to BIOS manufacturer\n"); |
| @@ -840,7 +874,7 @@ static int fill_powernow_table_pstate(struct powernow_k8_data *data, struct cpuf | |||
| 840 | 874 | ||
| 841 | powernow_table[i].index = index; | 875 | powernow_table[i].index = index; |
| 842 | 876 | ||
| 843 | powernow_table[i].frequency = data->acpi_data.states[i].core_frequency * 1000; | 877 | powernow_table[i].frequency = data->acpi_data->states[i].core_frequency * 1000; |
| 844 | } | 878 | } |
| 845 | return 0; | 879 | return 0; |
| 846 | } | 880 | } |
| @@ -849,16 +883,16 @@ static int fill_powernow_table_fidvid(struct powernow_k8_data *data, struct cpuf | |||
| 849 | { | 883 | { |
| 850 | int i; | 884 | int i; |
| 851 | int cntlofreq = 0; | 885 | int cntlofreq = 0; |
| 852 | for (i = 0; i < data->acpi_data.state_count; i++) { | 886 | for (i = 0; i < data->acpi_data->state_count; i++) { |
| 853 | u32 fid; | 887 | u32 fid; |
| 854 | u32 vid; | 888 | u32 vid; |
| 855 | 889 | ||
| 856 | if (data->exttype) { | 890 | if (data->exttype) { |
| 857 | fid = data->acpi_data.states[i].status & EXT_FID_MASK; | 891 | fid = data->acpi_data->states[i].status & EXT_FID_MASK; |
| 858 | vid = (data->acpi_data.states[i].status >> VID_SHIFT) & EXT_VID_MASK; | 892 | vid = (data->acpi_data->states[i].status >> VID_SHIFT) & EXT_VID_MASK; |
| 859 | } else { | 893 | } else { |
| 860 | fid = data->acpi_data.states[i].control & FID_MASK; | 894 | fid = data->acpi_data->states[i].control & FID_MASK; |
| 861 | vid = (data->acpi_data.states[i].control >> VID_SHIFT) & VID_MASK; | 895 | vid = (data->acpi_data->states[i].control >> VID_SHIFT) & VID_MASK; |
| 862 | } | 896 | } |
| 863 | 897 | ||
| 864 | dprintk(" %d : fid 0x%x, vid 0x%x\n", i, fid, vid); | 898 | dprintk(" %d : fid 0x%x, vid 0x%x\n", i, fid, vid); |
| @@ -899,10 +933,10 @@ static int fill_powernow_table_fidvid(struct powernow_k8_data *data, struct cpuf | |||
| 899 | cntlofreq = i; | 933 | cntlofreq = i; |
| 900 | } | 934 | } |
| 901 | 935 | ||
| 902 | if (powernow_table[i].frequency != (data->acpi_data.states[i].core_frequency * 1000)) { | 936 | if (powernow_table[i].frequency != (data->acpi_data->states[i].core_frequency * 1000)) { |
| 903 | printk(KERN_INFO PFX "invalid freq entries %u kHz vs. %u kHz\n", | 937 | printk(KERN_INFO PFX "invalid freq entries %u kHz vs. %u kHz\n", |
| 904 | powernow_table[i].frequency, | 938 | powernow_table[i].frequency, |
| 905 | (unsigned int) (data->acpi_data.states[i].core_frequency * 1000)); | 939 | (unsigned int) (data->acpi_data->states[i].core_frequency * 1000)); |
| 906 | powernow_table[i].frequency = CPUFREQ_ENTRY_INVALID; | 940 | powernow_table[i].frequency = CPUFREQ_ENTRY_INVALID; |
| 907 | continue; | 941 | continue; |
| 908 | } | 942 | } |
| @@ -912,11 +946,12 @@ static int fill_powernow_table_fidvid(struct powernow_k8_data *data, struct cpuf | |||
| 912 | 946 | ||
| 913 | static void powernow_k8_cpu_exit_acpi(struct powernow_k8_data *data) | 947 | static void powernow_k8_cpu_exit_acpi(struct powernow_k8_data *data) |
| 914 | { | 948 | { |
| 915 | if (data->acpi_data.state_count) | 949 | if (data->acpi_data->state_count) |
| 916 | acpi_processor_unregister_performance(&data->acpi_data, data->cpu); | 950 | acpi_processor_unregister_performance(data->acpi_data, data->cpu); |
| 917 | } | 951 | } |
| 918 | 952 | ||
| 919 | #else | 953 | #else |
| 954 | static int powernow_k8_cpu_preinit_acpi(void) { return -ENODEV; } | ||
| 920 | static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) { return -ENODEV; } | 955 | static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) { return -ENODEV; } |
| 921 | static void powernow_k8_cpu_exit_acpi(struct powernow_k8_data *data) { return; } | 956 | static void powernow_k8_cpu_exit_acpi(struct powernow_k8_data *data) { return; } |
| 922 | static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned int index) { return; } | 957 | static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned int index) { return; } |
| @@ -1101,7 +1136,7 @@ static int powernowk8_verify(struct cpufreq_policy *pol) | |||
| 1101 | static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol) | 1136 | static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol) |
| 1102 | { | 1137 | { |
| 1103 | struct powernow_k8_data *data; | 1138 | struct powernow_k8_data *data; |
| 1104 | cpumask_t oldmask; | 1139 | cpumask_t oldmask = CPU_MASK_ALL; |
| 1105 | int rc; | 1140 | int rc; |
| 1106 | 1141 | ||
| 1107 | if (!cpu_online(pol->cpu)) | 1142 | if (!cpu_online(pol->cpu)) |
| @@ -1174,10 +1209,7 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol) | |||
| 1174 | /* run on any CPU again */ | 1209 | /* run on any CPU again */ |
| 1175 | set_cpus_allowed_ptr(current, &oldmask); | 1210 | set_cpus_allowed_ptr(current, &oldmask); |
| 1176 | 1211 | ||
| 1177 | if (cpu_family == CPU_HW_PSTATE) | 1212 | pol->cpus = data->starting_core_affinity; |
| 1178 | pol->cpus = cpumask_of_cpu(pol->cpu); | ||
| 1179 | else | ||
| 1180 | pol->cpus = per_cpu(cpu_core_map, pol->cpu); | ||
| 1181 | data->available_cores = &(pol->cpus); | 1213 | data->available_cores = &(pol->cpus); |
| 1182 | 1214 | ||
| 1183 | /* Take a crude guess here. | 1215 | /* Take a crude guess here. |
| @@ -1300,6 +1332,7 @@ static int __cpuinit powernowk8_init(void) | |||
| 1300 | } | 1332 | } |
| 1301 | 1333 | ||
| 1302 | if (supported_cpus == num_online_cpus()) { | 1334 | if (supported_cpus == num_online_cpus()) { |
| 1335 | powernow_k8_cpu_preinit_acpi(); | ||
| 1303 | printk(KERN_INFO PFX "Found %d %s " | 1336 | printk(KERN_INFO PFX "Found %d %s " |
| 1304 | "processors (%d cpu cores) (" VERSION ")\n", | 1337 | "processors (%d cpu cores) (" VERSION ")\n", |
| 1305 | num_online_nodes(), | 1338 | num_online_nodes(), |
| @@ -1316,6 +1349,10 @@ static void __exit powernowk8_exit(void) | |||
| 1316 | dprintk("exit\n"); | 1349 | dprintk("exit\n"); |
| 1317 | 1350 | ||
| 1318 | cpufreq_unregister_driver(&cpufreq_amd64_driver); | 1351 | cpufreq_unregister_driver(&cpufreq_amd64_driver); |
| 1352 | |||
| 1353 | #ifdef CONFIG_X86_POWERNOW_K8_ACPI | ||
| 1354 | free_percpu(acpi_perf_data); | ||
| 1355 | #endif | ||
| 1319 | } | 1356 | } |
| 1320 | 1357 | ||
| 1321 | MODULE_AUTHOR("Paul Devriendt <paul.devriendt@amd.com> and Mark Langsdorf <mark.langsdorf@amd.com>"); | 1358 | MODULE_AUTHOR("Paul Devriendt <paul.devriendt@amd.com> and Mark Langsdorf <mark.langsdorf@amd.com>"); |
diff --git a/arch/x86/kernel/cpu/cpufreq/powernow-k8.h b/arch/x86/kernel/cpu/cpufreq/powernow-k8.h index ab48cfed4d96..a62612cd4be8 100644 --- a/arch/x86/kernel/cpu/cpufreq/powernow-k8.h +++ b/arch/x86/kernel/cpu/cpufreq/powernow-k8.h | |||
| @@ -33,12 +33,13 @@ struct powernow_k8_data { | |||
| 33 | #ifdef CONFIG_X86_POWERNOW_K8_ACPI | 33 | #ifdef CONFIG_X86_POWERNOW_K8_ACPI |
| 34 | /* the acpi table needs to be kept. it's only available if ACPI was | 34 | /* the acpi table needs to be kept. it's only available if ACPI was |
| 35 | * used to determine valid frequency/vid/fid states */ | 35 | * used to determine valid frequency/vid/fid states */ |
| 36 | struct acpi_processor_performance acpi_data; | 36 | struct acpi_processor_performance *acpi_data; |
| 37 | #endif | 37 | #endif |
| 38 | /* we need to keep track of associated cores, but let cpufreq | 38 | /* we need to keep track of associated cores, but let cpufreq |
| 39 | * handle hotplug events - so just point at cpufreq pol->cpus | 39 | * handle hotplug events - so just point at cpufreq pol->cpus |
| 40 | * structure */ | 40 | * structure */ |
| 41 | cpumask_t *available_cores; | 41 | cpumask_t *available_cores; |
| 42 | cpumask_t starting_core_affinity; | ||
| 42 | }; | 43 | }; |
| 43 | 44 | ||
| 44 | 45 | ||
