diff options
| -rw-r--r-- | arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c | 27 | ||||
| -rw-r--r-- | arch/x86/kernel/cpu/cpufreq/powernow-k7.c | 9 | ||||
| -rw-r--r-- | arch/x86/kernel/cpu/cpufreq/powernow-k8.c | 24 | ||||
| -rw-r--r-- | drivers/acpi/processor_core.c | 14 | ||||
| -rw-r--r-- | drivers/acpi/processor_perflib.c | 28 | ||||
| -rw-r--r-- | drivers/acpi/processor_throttling.c | 80 | ||||
| -rw-r--r-- | include/acpi/processor.h | 4 |
7 files changed, 128 insertions, 58 deletions
diff --git a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c index 88ea02dcb622..d0a001093b2d 100644 --- a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c +++ b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c | |||
| @@ -517,6 +517,17 @@ acpi_cpufreq_guess_freq(struct acpi_cpufreq_data *data, unsigned int cpu) | |||
| 517 | } | 517 | } |
| 518 | } | 518 | } |
| 519 | 519 | ||
| 520 | static void free_acpi_perf_data(void) | ||
| 521 | { | ||
| 522 | unsigned int i; | ||
| 523 | |||
| 524 | /* Freeing a NULL pointer is OK, and alloc_percpu zeroes. */ | ||
| 525 | for_each_possible_cpu(i) | ||
| 526 | free_cpumask_var(per_cpu_ptr(acpi_perf_data, i) | ||
| 527 | ->shared_cpu_map); | ||
| 528 | free_percpu(acpi_perf_data); | ||
| 529 | } | ||
| 530 | |||
| 520 | /* | 531 | /* |
| 521 | * acpi_cpufreq_early_init - initialize ACPI P-States library | 532 | * acpi_cpufreq_early_init - initialize ACPI P-States library |
| 522 | * | 533 | * |
| @@ -527,6 +538,7 @@ acpi_cpufreq_guess_freq(struct acpi_cpufreq_data *data, unsigned int cpu) | |||
| 527 | */ | 538 | */ |
| 528 | static int __init acpi_cpufreq_early_init(void) | 539 | static int __init acpi_cpufreq_early_init(void) |
| 529 | { | 540 | { |
| 541 | unsigned int i; | ||
| 530 | dprintk("acpi_cpufreq_early_init\n"); | 542 | dprintk("acpi_cpufreq_early_init\n"); |
| 531 | 543 | ||
| 532 | acpi_perf_data = alloc_percpu(struct acpi_processor_performance); | 544 | acpi_perf_data = alloc_percpu(struct acpi_processor_performance); |
| @@ -534,6 +546,15 @@ static int __init acpi_cpufreq_early_init(void) | |||
| 534 | dprintk("Memory allocation error for acpi_perf_data.\n"); | 546 | dprintk("Memory allocation error for acpi_perf_data.\n"); |
| 535 | return -ENOMEM; | 547 | return -ENOMEM; |
| 536 | } | 548 | } |
| 549 | for_each_possible_cpu(i) { | ||
| 550 | if (!alloc_cpumask_var(&per_cpu_ptr(acpi_perf_data, i) | ||
| 551 | ->shared_cpu_map, GFP_KERNEL)) { | ||
| 552 | |||
| 553 | /* Freeing a NULL pointer is OK: alloc_percpu zeroes. */ | ||
| 554 | free_acpi_perf_data(); | ||
| 555 | return -ENOMEM; | ||
| 556 | } | ||
| 557 | } | ||
| 537 | 558 | ||
| 538 | /* Do initialization in ACPI core */ | 559 | /* Do initialization in ACPI core */ |
| 539 | acpi_processor_preregister_performance(acpi_perf_data); | 560 | acpi_processor_preregister_performance(acpi_perf_data); |
| @@ -604,9 +625,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
| 604 | */ | 625 | */ |
| 605 | if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL || | 626 | if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL || |
| 606 | policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) { | 627 | policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) { |
| 607 | policy->cpus = perf->shared_cpu_map; | 628 | cpumask_copy(&policy->cpus, perf->shared_cpu_map); |
| 608 | } | 629 | } |
| 609 | policy->related_cpus = perf->shared_cpu_map; | 630 | cpumask_copy(&policy->related_cpus, perf->shared_cpu_map); |
| 610 | 631 | ||
| 611 | #ifdef CONFIG_SMP | 632 | #ifdef CONFIG_SMP |
| 612 | dmi_check_system(sw_any_bug_dmi_table); | 633 | dmi_check_system(sw_any_bug_dmi_table); |
| @@ -795,7 +816,7 @@ static int __init acpi_cpufreq_init(void) | |||
| 795 | 816 | ||
| 796 | ret = cpufreq_register_driver(&acpi_cpufreq_driver); | 817 | ret = cpufreq_register_driver(&acpi_cpufreq_driver); |
| 797 | if (ret) | 818 | if (ret) |
| 798 | free_percpu(acpi_perf_data); | 819 | free_acpi_perf_data(); |
| 799 | 820 | ||
| 800 | return ret; | 821 | return ret; |
| 801 | } | 822 | } |
diff --git a/arch/x86/kernel/cpu/cpufreq/powernow-k7.c b/arch/x86/kernel/cpu/cpufreq/powernow-k7.c index 7c7d56b43136..1b446d79a8fd 100644 --- a/arch/x86/kernel/cpu/cpufreq/powernow-k7.c +++ b/arch/x86/kernel/cpu/cpufreq/powernow-k7.c | |||
| @@ -310,6 +310,12 @@ static int powernow_acpi_init(void) | |||
| 310 | goto err0; | 310 | goto err0; |
| 311 | } | 311 | } |
| 312 | 312 | ||
| 313 | if (!alloc_cpumask_var(&acpi_processor_perf->shared_cpu_map, | ||
| 314 | GFP_KERNEL)) { | ||
| 315 | retval = -ENOMEM; | ||
| 316 | goto err05; | ||
| 317 | } | ||
| 318 | |||
| 313 | if (acpi_processor_register_performance(acpi_processor_perf, 0)) { | 319 | if (acpi_processor_register_performance(acpi_processor_perf, 0)) { |
| 314 | retval = -EIO; | 320 | retval = -EIO; |
| 315 | goto err1; | 321 | goto err1; |
| @@ -412,6 +418,8 @@ static int powernow_acpi_init(void) | |||
| 412 | err2: | 418 | err2: |
| 413 | acpi_processor_unregister_performance(acpi_processor_perf, 0); | 419 | acpi_processor_unregister_performance(acpi_processor_perf, 0); |
| 414 | err1: | 420 | err1: |
| 421 | free_cpumask_var(acpi_processor_perf->shared_cpu_map); | ||
| 422 | err05: | ||
| 415 | kfree(acpi_processor_perf); | 423 | kfree(acpi_processor_perf); |
| 416 | err0: | 424 | err0: |
| 417 | printk(KERN_WARNING PFX "ACPI perflib can not be used in this platform\n"); | 425 | printk(KERN_WARNING PFX "ACPI perflib can not be used in this platform\n"); |
| @@ -652,6 +660,7 @@ static int powernow_cpu_exit (struct cpufreq_policy *policy) { | |||
| 652 | #ifdef CONFIG_X86_POWERNOW_K7_ACPI | 660 | #ifdef CONFIG_X86_POWERNOW_K7_ACPI |
| 653 | if (acpi_processor_perf) { | 661 | if (acpi_processor_perf) { |
| 654 | acpi_processor_unregister_performance(acpi_processor_perf, 0); | 662 | acpi_processor_unregister_performance(acpi_processor_perf, 0); |
| 663 | free_cpumask_var(acpi_processor_perf->shared_cpu_map); | ||
| 655 | kfree(acpi_processor_perf); | 664 | kfree(acpi_processor_perf); |
| 656 | } | 665 | } |
| 657 | #endif | 666 | #endif |
diff --git a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c index 7f05f44b97e9..c3c9adbaa26f 100644 --- a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c +++ b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c | |||
| @@ -766,7 +766,7 @@ static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned | |||
| 766 | static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) | 766 | static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) |
| 767 | { | 767 | { |
| 768 | struct cpufreq_frequency_table *powernow_table; | 768 | struct cpufreq_frequency_table *powernow_table; |
| 769 | int ret_val; | 769 | int ret_val = -ENODEV; |
| 770 | 770 | ||
| 771 | if (acpi_processor_register_performance(&data->acpi_data, data->cpu)) { | 771 | if (acpi_processor_register_performance(&data->acpi_data, data->cpu)) { |
| 772 | dprintk("register performance failed: bad ACPI data\n"); | 772 | dprintk("register performance failed: bad ACPI data\n"); |
| @@ -815,6 +815,13 @@ static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) | |||
| 815 | /* notify BIOS that we exist */ | 815 | /* notify BIOS that we exist */ |
| 816 | acpi_processor_notify_smm(THIS_MODULE); | 816 | acpi_processor_notify_smm(THIS_MODULE); |
| 817 | 817 | ||
| 818 | if (!alloc_cpumask_var(&data->acpi_data.shared_cpu_map, GFP_KERNEL)) { | ||
| 819 | printk(KERN_ERR PFX | ||
| 820 | "unable to alloc powernow_k8_data cpumask\n"); | ||
| 821 | ret_val = -ENOMEM; | ||
| 822 | goto err_out_mem; | ||
| 823 | } | ||
| 824 | |||
| 818 | return 0; | 825 | return 0; |
| 819 | 826 | ||
| 820 | err_out_mem: | 827 | err_out_mem: |
| @@ -826,7 +833,7 @@ err_out: | |||
| 826 | /* data->acpi_data.state_count informs us at ->exit() whether ACPI was used */ | 833 | /* data->acpi_data.state_count informs us at ->exit() whether ACPI was used */ |
| 827 | data->acpi_data.state_count = 0; | 834 | data->acpi_data.state_count = 0; |
| 828 | 835 | ||
| 829 | return -ENODEV; | 836 | return ret_val; |
| 830 | } | 837 | } |
| 831 | 838 | ||
| 832 | static int fill_powernow_table_pstate(struct powernow_k8_data *data, struct cpufreq_frequency_table *powernow_table) | 839 | static int fill_powernow_table_pstate(struct powernow_k8_data *data, struct cpufreq_frequency_table *powernow_table) |
| @@ -929,6 +936,7 @@ static void powernow_k8_cpu_exit_acpi(struct powernow_k8_data *data) | |||
| 929 | { | 936 | { |
| 930 | if (data->acpi_data.state_count) | 937 | if (data->acpi_data.state_count) |
| 931 | acpi_processor_unregister_performance(&data->acpi_data, data->cpu); | 938 | acpi_processor_unregister_performance(&data->acpi_data, data->cpu); |
| 939 | free_cpumask_var(data->acpi_data.shared_cpu_map); | ||
| 932 | } | 940 | } |
| 933 | 941 | ||
| 934 | #else | 942 | #else |
| @@ -1134,7 +1142,8 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol) | |||
| 1134 | data->cpu = pol->cpu; | 1142 | data->cpu = pol->cpu; |
| 1135 | data->currpstate = HW_PSTATE_INVALID; | 1143 | data->currpstate = HW_PSTATE_INVALID; |
| 1136 | 1144 | ||
| 1137 | if (powernow_k8_cpu_init_acpi(data)) { | 1145 | rc = powernow_k8_cpu_init_acpi(data); |
| 1146 | if (rc) { | ||
| 1138 | /* | 1147 | /* |
| 1139 | * Use the PSB BIOS structure. This is only availabe on | 1148 | * Use the PSB BIOS structure. This is only availabe on |
| 1140 | * an UP version, and is deprecated by AMD. | 1149 | * an UP version, and is deprecated by AMD. |
| @@ -1152,20 +1161,17 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol) | |||
| 1152 | "ACPI maintainers and complain to your BIOS " | 1161 | "ACPI maintainers and complain to your BIOS " |
| 1153 | "vendor.\n"); | 1162 | "vendor.\n"); |
| 1154 | #endif | 1163 | #endif |
| 1155 | kfree(data); | 1164 | goto err_out; |
| 1156 | return -ENODEV; | ||
| 1157 | } | 1165 | } |
| 1158 | if (pol->cpu != 0) { | 1166 | if (pol->cpu != 0) { |
| 1159 | printk(KERN_ERR FW_BUG PFX "No ACPI _PSS objects for " | 1167 | printk(KERN_ERR FW_BUG PFX "No ACPI _PSS objects for " |
| 1160 | "CPU other than CPU0. Complain to your BIOS " | 1168 | "CPU other than CPU0. Complain to your BIOS " |
| 1161 | "vendor.\n"); | 1169 | "vendor.\n"); |
| 1162 | kfree(data); | 1170 | goto err_out; |
| 1163 | return -ENODEV; | ||
| 1164 | } | 1171 | } |
| 1165 | rc = find_psb_table(data); | 1172 | rc = find_psb_table(data); |
| 1166 | if (rc) { | 1173 | if (rc) { |
| 1167 | kfree(data); | 1174 | goto err_out; |
| 1168 | return -ENODEV; | ||
| 1169 | } | 1175 | } |
| 1170 | } | 1176 | } |
| 1171 | 1177 | ||
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 34948362f41d..0cc2fd31e376 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c | |||
| @@ -826,6 +826,11 @@ static int acpi_processor_add(struct acpi_device *device) | |||
| 826 | if (!pr) | 826 | if (!pr) |
| 827 | return -ENOMEM; | 827 | return -ENOMEM; |
| 828 | 828 | ||
| 829 | if (!alloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) { | ||
| 830 | kfree(pr); | ||
| 831 | return -ENOMEM; | ||
| 832 | } | ||
| 833 | |||
| 829 | pr->handle = device->handle; | 834 | pr->handle = device->handle; |
| 830 | strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME); | 835 | strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME); |
| 831 | strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS); | 836 | strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS); |
| @@ -845,10 +850,8 @@ static int acpi_processor_remove(struct acpi_device *device, int type) | |||
| 845 | 850 | ||
| 846 | pr = acpi_driver_data(device); | 851 | pr = acpi_driver_data(device); |
| 847 | 852 | ||
| 848 | if (pr->id >= nr_cpu_ids) { | 853 | if (pr->id >= nr_cpu_ids) |
| 849 | kfree(pr); | 854 | goto free; |
| 850 | return 0; | ||
| 851 | } | ||
| 852 | 855 | ||
| 853 | if (type == ACPI_BUS_REMOVAL_EJECT) { | 856 | if (type == ACPI_BUS_REMOVAL_EJECT) { |
| 854 | if (acpi_processor_handle_eject(pr)) | 857 | if (acpi_processor_handle_eject(pr)) |
| @@ -873,6 +876,9 @@ static int acpi_processor_remove(struct acpi_device *device, int type) | |||
| 873 | 876 | ||
| 874 | per_cpu(processors, pr->id) = NULL; | 877 | per_cpu(processors, pr->id) = NULL; |
| 875 | per_cpu(processor_device_array, pr->id) = NULL; | 878 | per_cpu(processor_device_array, pr->id) = NULL; |
| 879 | |||
| 880 | free: | ||
| 881 | free_cpumask_var(pr->throttling.shared_cpu_map); | ||
| 876 | kfree(pr); | 882 | kfree(pr); |
| 877 | 883 | ||
| 878 | return 0; | 884 | return 0; |
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c index 0d7b772bef50..846e227592d4 100644 --- a/drivers/acpi/processor_perflib.c +++ b/drivers/acpi/processor_perflib.c | |||
| @@ -588,12 +588,15 @@ int acpi_processor_preregister_performance( | |||
| 588 | int count, count_target; | 588 | int count, count_target; |
| 589 | int retval = 0; | 589 | int retval = 0; |
| 590 | unsigned int i, j; | 590 | unsigned int i, j; |
| 591 | cpumask_t covered_cpus; | 591 | cpumask_var_t covered_cpus; |
| 592 | struct acpi_processor *pr; | 592 | struct acpi_processor *pr; |
| 593 | struct acpi_psd_package *pdomain; | 593 | struct acpi_psd_package *pdomain; |
| 594 | struct acpi_processor *match_pr; | 594 | struct acpi_processor *match_pr; |
| 595 | struct acpi_psd_package *match_pdomain; | 595 | struct acpi_psd_package *match_pdomain; |
| 596 | 596 | ||
| 597 | if (!alloc_cpumask_var(&covered_cpus, GFP_KERNEL)) | ||
| 598 | return -ENOMEM; | ||
| 599 | |||
| 597 | mutex_lock(&performance_mutex); | 600 | mutex_lock(&performance_mutex); |
| 598 | 601 | ||
| 599 | retval = 0; | 602 | retval = 0; |
| @@ -617,7 +620,7 @@ int acpi_processor_preregister_performance( | |||
| 617 | } | 620 | } |
| 618 | 621 | ||
| 619 | pr->performance = percpu_ptr(performance, i); | 622 | pr->performance = percpu_ptr(performance, i); |
| 620 | cpu_set(i, pr->performance->shared_cpu_map); | 623 | cpumask_set_cpu(i, pr->performance->shared_cpu_map); |
| 621 | if (acpi_processor_get_psd(pr)) { | 624 | if (acpi_processor_get_psd(pr)) { |
| 622 | retval = -EINVAL; | 625 | retval = -EINVAL; |
| 623 | continue; | 626 | continue; |
| @@ -650,18 +653,18 @@ int acpi_processor_preregister_performance( | |||
| 650 | } | 653 | } |
| 651 | } | 654 | } |
| 652 | 655 | ||
| 653 | cpus_clear(covered_cpus); | 656 | cpumask_clear(covered_cpus); |
| 654 | for_each_possible_cpu(i) { | 657 | for_each_possible_cpu(i) { |
| 655 | pr = per_cpu(processors, i); | 658 | pr = per_cpu(processors, i); |
| 656 | if (!pr) | 659 | if (!pr) |
| 657 | continue; | 660 | continue; |
| 658 | 661 | ||
| 659 | if (cpu_isset(i, covered_cpus)) | 662 | if (cpumask_test_cpu(i, covered_cpus)) |
| 660 | continue; | 663 | continue; |
| 661 | 664 | ||
| 662 | pdomain = &(pr->performance->domain_info); | 665 | pdomain = &(pr->performance->domain_info); |
| 663 | cpu_set(i, pr->performance->shared_cpu_map); | 666 | cpumask_set_cpu(i, pr->performance->shared_cpu_map); |
| 664 | cpu_set(i, covered_cpus); | 667 | cpumask_set_cpu(i, covered_cpus); |
| 665 | if (pdomain->num_processors <= 1) | 668 | if (pdomain->num_processors <= 1) |
| 666 | continue; | 669 | continue; |
| 667 | 670 | ||
| @@ -699,8 +702,8 @@ int acpi_processor_preregister_performance( | |||
| 699 | goto err_ret; | 702 | goto err_ret; |
| 700 | } | 703 | } |
| 701 | 704 | ||
| 702 | cpu_set(j, covered_cpus); | 705 | cpumask_set_cpu(j, covered_cpus); |
| 703 | cpu_set(j, pr->performance->shared_cpu_map); | 706 | cpumask_set_cpu(j, pr->performance->shared_cpu_map); |
| 704 | count++; | 707 | count++; |
| 705 | } | 708 | } |
| 706 | 709 | ||
| @@ -718,8 +721,8 @@ int acpi_processor_preregister_performance( | |||
| 718 | 721 | ||
| 719 | match_pr->performance->shared_type = | 722 | match_pr->performance->shared_type = |
| 720 | pr->performance->shared_type; | 723 | pr->performance->shared_type; |
| 721 | match_pr->performance->shared_cpu_map = | 724 | cpumask_copy(match_pr->performance->shared_cpu_map, |
| 722 | pr->performance->shared_cpu_map; | 725 | pr->performance->shared_cpu_map); |
| 723 | } | 726 | } |
| 724 | } | 727 | } |
| 725 | 728 | ||
| @@ -731,14 +734,15 @@ err_ret: | |||
| 731 | 734 | ||
| 732 | /* Assume no coordination on any error parsing domain info */ | 735 | /* Assume no coordination on any error parsing domain info */ |
| 733 | if (retval) { | 736 | if (retval) { |
| 734 | cpus_clear(pr->performance->shared_cpu_map); | 737 | cpumask_clear(pr->performance->shared_cpu_map); |
| 735 | cpu_set(i, pr->performance->shared_cpu_map); | 738 | cpumask_set_cpu(i, pr->performance->shared_cpu_map); |
| 736 | pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ALL; | 739 | pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ALL; |
| 737 | } | 740 | } |
| 738 | pr->performance = NULL; /* Will be set for real in register */ | 741 | pr->performance = NULL; /* Will be set for real in register */ |
| 739 | } | 742 | } |
| 740 | 743 | ||
| 741 | mutex_unlock(&performance_mutex); | 744 | mutex_unlock(&performance_mutex); |
| 745 | free_cpumask_var(covered_cpus); | ||
| 742 | return retval; | 746 | return retval; |
| 743 | } | 747 | } |
| 744 | EXPORT_SYMBOL(acpi_processor_preregister_performance); | 748 | EXPORT_SYMBOL(acpi_processor_preregister_performance); |
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index a0c38c94a8a0..d27838171f4a 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c | |||
| @@ -61,11 +61,14 @@ static int acpi_processor_update_tsd_coord(void) | |||
| 61 | int count, count_target; | 61 | int count, count_target; |
| 62 | int retval = 0; | 62 | int retval = 0; |
| 63 | unsigned int i, j; | 63 | unsigned int i, j; |
| 64 | cpumask_t covered_cpus; | 64 | cpumask_var_t covered_cpus; |
| 65 | struct acpi_processor *pr, *match_pr; | 65 | struct acpi_processor *pr, *match_pr; |
| 66 | struct acpi_tsd_package *pdomain, *match_pdomain; | 66 | struct acpi_tsd_package *pdomain, *match_pdomain; |
| 67 | struct acpi_processor_throttling *pthrottling, *match_pthrottling; | 67 | struct acpi_processor_throttling *pthrottling, *match_pthrottling; |
| 68 | 68 | ||
| 69 | if (!alloc_cpumask_var(&covered_cpus, GFP_KERNEL)) | ||
| 70 | return -ENOMEM; | ||
| 71 | |||
| 69 | /* | 72 | /* |
| 70 | * Now that we have _TSD data from all CPUs, lets setup T-state | 73 | * Now that we have _TSD data from all CPUs, lets setup T-state |
| 71 | * coordination between all CPUs. | 74 | * coordination between all CPUs. |
| @@ -91,19 +94,19 @@ static int acpi_processor_update_tsd_coord(void) | |||
| 91 | if (retval) | 94 | if (retval) |
| 92 | goto err_ret; | 95 | goto err_ret; |
| 93 | 96 | ||
| 94 | cpus_clear(covered_cpus); | 97 | cpumask_clear(covered_cpus); |
| 95 | for_each_possible_cpu(i) { | 98 | for_each_possible_cpu(i) { |
| 96 | pr = per_cpu(processors, i); | 99 | pr = per_cpu(processors, i); |
| 97 | if (!pr) | 100 | if (!pr) |
| 98 | continue; | 101 | continue; |
| 99 | 102 | ||
| 100 | if (cpu_isset(i, covered_cpus)) | 103 | if (cpumask_test_cpu(i, covered_cpus)) |
| 101 | continue; | 104 | continue; |
| 102 | pthrottling = &pr->throttling; | 105 | pthrottling = &pr->throttling; |
| 103 | 106 | ||
| 104 | pdomain = &(pthrottling->domain_info); | 107 | pdomain = &(pthrottling->domain_info); |
| 105 | cpu_set(i, pthrottling->shared_cpu_map); | 108 | cpumask_set_cpu(i, pthrottling->shared_cpu_map); |
| 106 | cpu_set(i, covered_cpus); | 109 | cpumask_set_cpu(i, covered_cpus); |
| 107 | /* | 110 | /* |
| 108 | * If the number of processor in the TSD domain is 1, it is | 111 | * If the number of processor in the TSD domain is 1, it is |
| 109 | * unnecessary to parse the coordination for this CPU. | 112 | * unnecessary to parse the coordination for this CPU. |
| @@ -144,8 +147,8 @@ static int acpi_processor_update_tsd_coord(void) | |||
| 144 | goto err_ret; | 147 | goto err_ret; |
| 145 | } | 148 | } |
| 146 | 149 | ||
| 147 | cpu_set(j, covered_cpus); | 150 | cpumask_set_cpu(j, covered_cpus); |
| 148 | cpu_set(j, pthrottling->shared_cpu_map); | 151 | cpumask_set_cpu(j, pthrottling->shared_cpu_map); |
| 149 | count++; | 152 | count++; |
| 150 | } | 153 | } |
| 151 | for_each_possible_cpu(j) { | 154 | for_each_possible_cpu(j) { |
| @@ -165,12 +168,14 @@ static int acpi_processor_update_tsd_coord(void) | |||
| 165 | * If some CPUS have the same domain, they | 168 | * If some CPUS have the same domain, they |
| 166 | * will have the same shared_cpu_map. | 169 | * will have the same shared_cpu_map. |
| 167 | */ | 170 | */ |
| 168 | match_pthrottling->shared_cpu_map = | 171 | cpumask_copy(match_pthrottling->shared_cpu_map, |
| 169 | pthrottling->shared_cpu_map; | 172 | pthrottling->shared_cpu_map); |
| 170 | } | 173 | } |
| 171 | } | 174 | } |
| 172 | 175 | ||
| 173 | err_ret: | 176 | err_ret: |
| 177 | free_cpumask_var(covered_cpus); | ||
| 178 | |||
| 174 | for_each_possible_cpu(i) { | 179 | for_each_possible_cpu(i) { |
| 175 | pr = per_cpu(processors, i); | 180 | pr = per_cpu(processors, i); |
| 176 | if (!pr) | 181 | if (!pr) |
| @@ -182,8 +187,8 @@ err_ret: | |||
| 182 | */ | 187 | */ |
| 183 | if (retval) { | 188 | if (retval) { |
| 184 | pthrottling = &(pr->throttling); | 189 | pthrottling = &(pr->throttling); |
| 185 | cpus_clear(pthrottling->shared_cpu_map); | 190 | cpumask_clear(pthrottling->shared_cpu_map); |
| 186 | cpu_set(i, pthrottling->shared_cpu_map); | 191 | cpumask_set_cpu(i, pthrottling->shared_cpu_map); |
| 187 | pthrottling->shared_type = DOMAIN_COORD_TYPE_SW_ALL; | 192 | pthrottling->shared_type = DOMAIN_COORD_TYPE_SW_ALL; |
| 188 | } | 193 | } |
| 189 | } | 194 | } |
| @@ -567,7 +572,7 @@ static int acpi_processor_get_tsd(struct acpi_processor *pr) | |||
| 567 | pthrottling = &pr->throttling; | 572 | pthrottling = &pr->throttling; |
| 568 | pthrottling->tsd_valid_flag = 1; | 573 | pthrottling->tsd_valid_flag = 1; |
| 569 | pthrottling->shared_type = pdomain->coord_type; | 574 | pthrottling->shared_type = pdomain->coord_type; |
| 570 | cpu_set(pr->id, pthrottling->shared_cpu_map); | 575 | cpumask_set_cpu(pr->id, pthrottling->shared_cpu_map); |
| 571 | /* | 576 | /* |
| 572 | * If the coordination type is not defined in ACPI spec, | 577 | * If the coordination type is not defined in ACPI spec, |
| 573 | * the tsd_valid_flag will be clear and coordination type | 578 | * the tsd_valid_flag will be clear and coordination type |
| @@ -826,7 +831,7 @@ static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr) | |||
| 826 | 831 | ||
| 827 | static int acpi_processor_get_throttling(struct acpi_processor *pr) | 832 | static int acpi_processor_get_throttling(struct acpi_processor *pr) |
| 828 | { | 833 | { |
| 829 | cpumask_t saved_mask; | 834 | cpumask_var_t saved_mask; |
| 830 | int ret; | 835 | int ret; |
| 831 | 836 | ||
| 832 | if (!pr) | 837 | if (!pr) |
| @@ -834,14 +839,20 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr) | |||
| 834 | 839 | ||
| 835 | if (!pr->flags.throttling) | 840 | if (!pr->flags.throttling) |
| 836 | return -ENODEV; | 841 | return -ENODEV; |
| 842 | |||
| 843 | if (!alloc_cpumask_var(&saved_mask, GFP_KERNEL)) | ||
| 844 | return -ENOMEM; | ||
| 845 | |||
| 837 | /* | 846 | /* |
| 838 | * Migrate task to the cpu pointed by pr. | 847 | * Migrate task to the cpu pointed by pr. |
| 839 | */ | 848 | */ |
| 840 | saved_mask = current->cpus_allowed; | 849 | cpumask_copy(saved_mask, ¤t->cpus_allowed); |
| 841 | set_cpus_allowed_ptr(current, &cpumask_of_cpu(pr->id)); | 850 | /* FIXME: use work_on_cpu() */ |
| 851 | set_cpus_allowed_ptr(current, cpumask_of(pr->id)); | ||
| 842 | ret = pr->throttling.acpi_processor_get_throttling(pr); | 852 | ret = pr->throttling.acpi_processor_get_throttling(pr); |
| 843 | /* restore the previous state */ | 853 | /* restore the previous state */ |
| 844 | set_cpus_allowed_ptr(current, &saved_mask); | 854 | set_cpus_allowed_ptr(current, saved_mask); |
| 855 | free_cpumask_var(saved_mask); | ||
| 845 | 856 | ||
| 846 | return ret; | 857 | return ret; |
| 847 | } | 858 | } |
| @@ -986,13 +997,13 @@ static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr, | |||
| 986 | 997 | ||
| 987 | int acpi_processor_set_throttling(struct acpi_processor *pr, int state) | 998 | int acpi_processor_set_throttling(struct acpi_processor *pr, int state) |
| 988 | { | 999 | { |
| 989 | cpumask_t saved_mask; | 1000 | cpumask_var_t saved_mask; |
| 990 | int ret = 0; | 1001 | int ret = 0; |
| 991 | unsigned int i; | 1002 | unsigned int i; |
| 992 | struct acpi_processor *match_pr; | 1003 | struct acpi_processor *match_pr; |
| 993 | struct acpi_processor_throttling *p_throttling; | 1004 | struct acpi_processor_throttling *p_throttling; |
| 994 | struct throttling_tstate t_state; | 1005 | struct throttling_tstate t_state; |
| 995 | cpumask_t online_throttling_cpus; | 1006 | cpumask_var_t online_throttling_cpus; |
| 996 | 1007 | ||
| 997 | if (!pr) | 1008 | if (!pr) |
| 998 | return -EINVAL; | 1009 | return -EINVAL; |
| @@ -1003,17 +1014,25 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state) | |||
| 1003 | if ((state < 0) || (state > (pr->throttling.state_count - 1))) | 1014 | if ((state < 0) || (state > (pr->throttling.state_count - 1))) |
| 1004 | return -EINVAL; | 1015 | return -EINVAL; |
| 1005 | 1016 | ||
| 1006 | saved_mask = current->cpus_allowed; | 1017 | if (!alloc_cpumask_var(&saved_mask, GFP_KERNEL)) |
| 1018 | return -ENOMEM; | ||
| 1019 | |||
| 1020 | if (!alloc_cpumask_var(&online_throttling_cpus, GFP_KERNEL)) { | ||
| 1021 | free_cpumask_var(saved_mask); | ||
| 1022 | return -ENOMEM; | ||
| 1023 | } | ||
| 1024 | |||
| 1025 | cpumask_copy(saved_mask, ¤t->cpus_allowed); | ||
| 1007 | t_state.target_state = state; | 1026 | t_state.target_state = state; |
| 1008 | p_throttling = &(pr->throttling); | 1027 | p_throttling = &(pr->throttling); |
| 1009 | cpus_and(online_throttling_cpus, cpu_online_map, | 1028 | cpumask_and(online_throttling_cpus, cpu_online_mask, |
| 1010 | p_throttling->shared_cpu_map); | 1029 | p_throttling->shared_cpu_map); |
| 1011 | /* | 1030 | /* |
| 1012 | * The throttling notifier will be called for every | 1031 | * The throttling notifier will be called for every |
| 1013 | * affected cpu in order to get one proper T-state. | 1032 | * affected cpu in order to get one proper T-state. |
| 1014 | * The notifier event is THROTTLING_PRECHANGE. | 1033 | * The notifier event is THROTTLING_PRECHANGE. |
| 1015 | */ | 1034 | */ |
| 1016 | for_each_cpu_mask_nr(i, online_throttling_cpus) { | 1035 | for_each_cpu(i, online_throttling_cpus) { |
| 1017 | t_state.cpu = i; | 1036 | t_state.cpu = i; |
| 1018 | acpi_processor_throttling_notifier(THROTTLING_PRECHANGE, | 1037 | acpi_processor_throttling_notifier(THROTTLING_PRECHANGE, |
| 1019 | &t_state); | 1038 | &t_state); |
| @@ -1025,7 +1044,8 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state) | |||
| 1025 | * it can be called only for the cpu pointed by pr. | 1044 | * it can be called only for the cpu pointed by pr. |
| 1026 | */ | 1045 | */ |
| 1027 | if (p_throttling->shared_type == DOMAIN_COORD_TYPE_SW_ANY) { | 1046 | if (p_throttling->shared_type == DOMAIN_COORD_TYPE_SW_ANY) { |
| 1028 | set_cpus_allowed_ptr(current, &cpumask_of_cpu(pr->id)); | 1047 | /* FIXME: use work_on_cpu() */ |
| 1048 | set_cpus_allowed_ptr(current, cpumask_of(pr->id)); | ||
| 1029 | ret = p_throttling->acpi_processor_set_throttling(pr, | 1049 | ret = p_throttling->acpi_processor_set_throttling(pr, |
| 1030 | t_state.target_state); | 1050 | t_state.target_state); |
| 1031 | } else { | 1051 | } else { |
| @@ -1034,7 +1054,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state) | |||
| 1034 | * it is necessary to set T-state for every affected | 1054 | * it is necessary to set T-state for every affected |
| 1035 | * cpus. | 1055 | * cpus. |
| 1036 | */ | 1056 | */ |
| 1037 | for_each_cpu_mask_nr(i, online_throttling_cpus) { | 1057 | for_each_cpu(i, online_throttling_cpus) { |
| 1038 | match_pr = per_cpu(processors, i); | 1058 | match_pr = per_cpu(processors, i); |
| 1039 | /* | 1059 | /* |
| 1040 | * If the pointer is invalid, we will report the | 1060 | * If the pointer is invalid, we will report the |
| @@ -1056,7 +1076,8 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state) | |||
| 1056 | continue; | 1076 | continue; |
| 1057 | } | 1077 | } |
| 1058 | t_state.cpu = i; | 1078 | t_state.cpu = i; |
| 1059 | set_cpus_allowed_ptr(current, &cpumask_of_cpu(i)); | 1079 | /* FIXME: use work_on_cpu() */ |
| 1080 | set_cpus_allowed_ptr(current, cpumask_of(i)); | ||
| 1060 | ret = match_pr->throttling. | 1081 | ret = match_pr->throttling. |
| 1061 | acpi_processor_set_throttling( | 1082 | acpi_processor_set_throttling( |
| 1062 | match_pr, t_state.target_state); | 1083 | match_pr, t_state.target_state); |
| @@ -1068,13 +1089,16 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state) | |||
| 1068 | * affected cpu to update the T-states. | 1089 | * affected cpu to update the T-states. |
| 1069 | * The notifier event is THROTTLING_POSTCHANGE | 1090 | * The notifier event is THROTTLING_POSTCHANGE |
| 1070 | */ | 1091 | */ |
| 1071 | for_each_cpu_mask_nr(i, online_throttling_cpus) { | 1092 | for_each_cpu(i, online_throttling_cpus) { |
| 1072 | t_state.cpu = i; | 1093 | t_state.cpu = i; |
| 1073 | acpi_processor_throttling_notifier(THROTTLING_POSTCHANGE, | 1094 | acpi_processor_throttling_notifier(THROTTLING_POSTCHANGE, |
| 1074 | &t_state); | 1095 | &t_state); |
| 1075 | } | 1096 | } |
| 1076 | /* restore the previous state */ | 1097 | /* restore the previous state */ |
| 1077 | set_cpus_allowed_ptr(current, &saved_mask); | 1098 | /* FIXME: use work_on_cpu() */ |
| 1099 | set_cpus_allowed_ptr(current, saved_mask); | ||
| 1100 | free_cpumask_var(online_throttling_cpus); | ||
| 1101 | free_cpumask_var(saved_mask); | ||
| 1078 | return ret; | 1102 | return ret; |
| 1079 | } | 1103 | } |
| 1080 | 1104 | ||
| @@ -1120,7 +1144,7 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr) | |||
| 1120 | if (acpi_processor_get_tsd(pr)) { | 1144 | if (acpi_processor_get_tsd(pr)) { |
| 1121 | pthrottling = &pr->throttling; | 1145 | pthrottling = &pr->throttling; |
| 1122 | pthrottling->tsd_valid_flag = 0; | 1146 | pthrottling->tsd_valid_flag = 0; |
| 1123 | cpu_set(pr->id, pthrottling->shared_cpu_map); | 1147 | cpumask_set_cpu(pr->id, pthrottling->shared_cpu_map); |
| 1124 | pthrottling->shared_type = DOMAIN_COORD_TYPE_SW_ALL; | 1148 | pthrottling->shared_type = DOMAIN_COORD_TYPE_SW_ALL; |
| 1125 | } | 1149 | } |
| 1126 | 1150 | ||
diff --git a/include/acpi/processor.h b/include/acpi/processor.h index 3795590e152a..0574add2a1e3 100644 --- a/include/acpi/processor.h +++ b/include/acpi/processor.h | |||
| @@ -127,7 +127,7 @@ struct acpi_processor_performance { | |||
| 127 | unsigned int state_count; | 127 | unsigned int state_count; |
| 128 | struct acpi_processor_px *states; | 128 | struct acpi_processor_px *states; |
| 129 | struct acpi_psd_package domain_info; | 129 | struct acpi_psd_package domain_info; |
| 130 | cpumask_t shared_cpu_map; | 130 | cpumask_var_t shared_cpu_map; |
| 131 | unsigned int shared_type; | 131 | unsigned int shared_type; |
| 132 | }; | 132 | }; |
| 133 | 133 | ||
| @@ -172,7 +172,7 @@ struct acpi_processor_throttling { | |||
| 172 | unsigned int state_count; | 172 | unsigned int state_count; |
| 173 | struct acpi_processor_tx_tss *states_tss; | 173 | struct acpi_processor_tx_tss *states_tss; |
| 174 | struct acpi_tsd_package domain_info; | 174 | struct acpi_tsd_package domain_info; |
| 175 | cpumask_t shared_cpu_map; | 175 | cpumask_var_t shared_cpu_map; |
| 176 | int (*acpi_processor_get_throttling) (struct acpi_processor * pr); | 176 | int (*acpi_processor_get_throttling) (struct acpi_processor * pr); |
| 177 | int (*acpi_processor_set_throttling) (struct acpi_processor * pr, | 177 | int (*acpi_processor_set_throttling) (struct acpi_processor * pr, |
| 178 | int state); | 178 | int state); |
