diff options
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/acpi/acpica/hwregs.c | 11 | ||||
| -rw-r--r-- | drivers/acpi/atomicio.c | 2 | ||||
| -rw-r--r-- | drivers/acpi/bus.c | 8 | ||||
| -rw-r--r-- | drivers/acpi/processor_driver.c | 20 | ||||
| -rw-r--r-- | drivers/acpi/processor_idle.c | 251 | ||||
| -rw-r--r-- | drivers/acpi/scan.c | 3 | ||||
| -rw-r--r-- | drivers/acpi/sysfs.c | 14 | ||||
| -rw-r--r-- | drivers/cpuidle/cpuidle.c | 86 | ||||
| -rw-r--r-- | drivers/cpuidle/driver.c | 25 | ||||
| -rw-r--r-- | drivers/cpuidle/governors/ladder.c | 41 | ||||
| -rw-r--r-- | drivers/cpuidle/governors/menu.c | 29 | ||||
| -rw-r--r-- | drivers/cpuidle/sysfs.c | 22 | ||||
| -rw-r--r-- | drivers/idle/intel_idle.c | 130 | ||||
| -rw-r--r-- | drivers/pnp/pnpacpi/rsparser.c | 62 | ||||
| -rw-r--r-- | drivers/thermal/thermal_sys.c | 4 |
15 files changed, 464 insertions, 244 deletions
diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c index 55accb7018bb..cc70f3fdcdd1 100644 --- a/drivers/acpi/acpica/hwregs.c +++ b/drivers/acpi/acpica/hwregs.c | |||
| @@ -269,16 +269,17 @@ acpi_status acpi_hw_clear_acpi_status(void) | |||
| 269 | 269 | ||
| 270 | status = acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS, | 270 | status = acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS, |
| 271 | ACPI_BITMASK_ALL_FIXED_STATUS); | 271 | ACPI_BITMASK_ALL_FIXED_STATUS); |
| 272 | if (ACPI_FAILURE(status)) { | 272 | |
| 273 | goto unlock_and_exit; | 273 | acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags); |
| 274 | } | 274 | |
| 275 | if (ACPI_FAILURE(status)) | ||
| 276 | goto exit; | ||
| 275 | 277 | ||
| 276 | /* Clear the GPE Bits in all GPE registers in all GPE blocks */ | 278 | /* Clear the GPE Bits in all GPE registers in all GPE blocks */ |
| 277 | 279 | ||
| 278 | status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block, NULL); | 280 | status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block, NULL); |
| 279 | 281 | ||
| 280 | unlock_and_exit: | 282 | exit: |
| 281 | acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags); | ||
| 282 | return_ACPI_STATUS(status); | 283 | return_ACPI_STATUS(status); |
| 283 | } | 284 | } |
| 284 | 285 | ||
diff --git a/drivers/acpi/atomicio.c b/drivers/acpi/atomicio.c index 7489b89c300f..f151afe61aab 100644 --- a/drivers/acpi/atomicio.c +++ b/drivers/acpi/atomicio.c | |||
| @@ -76,7 +76,7 @@ static void __iomem *__acpi_ioremap_fast(phys_addr_t paddr, | |||
| 76 | { | 76 | { |
| 77 | struct acpi_iomap *map; | 77 | struct acpi_iomap *map; |
| 78 | 78 | ||
| 79 | map = __acpi_find_iomap(paddr, size); | 79 | map = __acpi_find_iomap(paddr, size/8); |
| 80 | if (map) | 80 | if (map) |
| 81 | return map->vaddr + (paddr - map->paddr); | 81 | return map->vaddr + (paddr - map->paddr); |
| 82 | else | 82 | else |
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 437ddbf0c49a..9ecec98bc76e 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c | |||
| @@ -911,10 +911,7 @@ void __init acpi_early_init(void) | |||
| 911 | } | 911 | } |
| 912 | #endif | 912 | #endif |
| 913 | 913 | ||
| 914 | status = | 914 | status = acpi_enable_subsystem(~ACPI_NO_ACPI_ENABLE); |
| 915 | acpi_enable_subsystem(~ | ||
| 916 | (ACPI_NO_HARDWARE_INIT | | ||
| 917 | ACPI_NO_ACPI_ENABLE)); | ||
| 918 | if (ACPI_FAILURE(status)) { | 915 | if (ACPI_FAILURE(status)) { |
| 919 | printk(KERN_ERR PREFIX "Unable to enable ACPI\n"); | 916 | printk(KERN_ERR PREFIX "Unable to enable ACPI\n"); |
| 920 | goto error0; | 917 | goto error0; |
| @@ -935,8 +932,7 @@ static int __init acpi_bus_init(void) | |||
| 935 | 932 | ||
| 936 | acpi_os_initialize1(); | 933 | acpi_os_initialize1(); |
| 937 | 934 | ||
| 938 | status = | 935 | status = acpi_enable_subsystem(ACPI_NO_ACPI_ENABLE); |
| 939 | acpi_enable_subsystem(ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE); | ||
| 940 | if (ACPI_FAILURE(status)) { | 936 | if (ACPI_FAILURE(status)) { |
| 941 | printk(KERN_ERR PREFIX | 937 | printk(KERN_ERR PREFIX |
| 942 | "Unable to start the ACPI Interpreter\n"); | 938 | "Unable to start the ACPI Interpreter\n"); |
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c index a4e0f1ba6040..9d7bc9f6b6cc 100644 --- a/drivers/acpi/processor_driver.c +++ b/drivers/acpi/processor_driver.c | |||
| @@ -426,7 +426,7 @@ static int acpi_cpu_soft_notify(struct notifier_block *nfb, | |||
| 426 | 426 | ||
| 427 | if (action == CPU_ONLINE && pr) { | 427 | if (action == CPU_ONLINE && pr) { |
| 428 | acpi_processor_ppc_has_changed(pr, 0); | 428 | acpi_processor_ppc_has_changed(pr, 0); |
| 429 | acpi_processor_cst_has_changed(pr); | 429 | acpi_processor_hotplug(pr); |
| 430 | acpi_processor_reevaluate_tstate(pr, action); | 430 | acpi_processor_reevaluate_tstate(pr, action); |
| 431 | acpi_processor_tstate_has_changed(pr); | 431 | acpi_processor_tstate_has_changed(pr); |
| 432 | } | 432 | } |
| @@ -503,8 +503,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device) | |||
| 503 | acpi_processor_get_throttling_info(pr); | 503 | acpi_processor_get_throttling_info(pr); |
| 504 | acpi_processor_get_limit_info(pr); | 504 | acpi_processor_get_limit_info(pr); |
| 505 | 505 | ||
| 506 | 506 | if (!cpuidle_get_driver() || cpuidle_get_driver() == &acpi_idle_driver) | |
| 507 | if (cpuidle_get_driver() == &acpi_idle_driver) | ||
| 508 | acpi_processor_power_init(pr, device); | 507 | acpi_processor_power_init(pr, device); |
| 509 | 508 | ||
| 510 | pr->cdev = thermal_cooling_device_register("Processor", device, | 509 | pr->cdev = thermal_cooling_device_register("Processor", device, |
| @@ -800,17 +799,9 @@ static int __init acpi_processor_init(void) | |||
| 800 | 799 | ||
| 801 | memset(&errata, 0, sizeof(errata)); | 800 | memset(&errata, 0, sizeof(errata)); |
| 802 | 801 | ||
| 803 | if (!cpuidle_register_driver(&acpi_idle_driver)) { | ||
| 804 | printk(KERN_DEBUG "ACPI: %s registered with cpuidle\n", | ||
| 805 | acpi_idle_driver.name); | ||
| 806 | } else { | ||
| 807 | printk(KERN_DEBUG "ACPI: acpi_idle yielding to %s\n", | ||
| 808 | cpuidle_get_driver()->name); | ||
| 809 | } | ||
| 810 | |||
| 811 | result = acpi_bus_register_driver(&acpi_processor_driver); | 802 | result = acpi_bus_register_driver(&acpi_processor_driver); |
| 812 | if (result < 0) | 803 | if (result < 0) |
| 813 | goto out_cpuidle; | 804 | return result; |
| 814 | 805 | ||
| 815 | acpi_processor_install_hotplug_notify(); | 806 | acpi_processor_install_hotplug_notify(); |
| 816 | 807 | ||
| @@ -821,11 +812,6 @@ static int __init acpi_processor_init(void) | |||
| 821 | acpi_processor_throttling_init(); | 812 | acpi_processor_throttling_init(); |
| 822 | 813 | ||
| 823 | return 0; | 814 | return 0; |
| 824 | |||
| 825 | out_cpuidle: | ||
| 826 | cpuidle_unregister_driver(&acpi_idle_driver); | ||
| 827 | |||
| 828 | return result; | ||
| 829 | } | 815 | } |
| 830 | 816 | ||
| 831 | static void __exit acpi_processor_exit(void) | 817 | static void __exit acpi_processor_exit(void) |
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 431ab11c8c1b..24fe3afa7119 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c | |||
| @@ -741,22 +741,25 @@ static inline void acpi_idle_do_entry(struct acpi_processor_cx *cx) | |||
| 741 | /** | 741 | /** |
| 742 | * acpi_idle_enter_c1 - enters an ACPI C1 state-type | 742 | * acpi_idle_enter_c1 - enters an ACPI C1 state-type |
| 743 | * @dev: the target CPU | 743 | * @dev: the target CPU |
| 744 | * @state: the state data | 744 | * @drv: cpuidle driver containing cpuidle state info |
| 745 | * @index: index of target state | ||
| 745 | * | 746 | * |
| 746 | * This is equivalent to the HALT instruction. | 747 | * This is equivalent to the HALT instruction. |
| 747 | */ | 748 | */ |
| 748 | static int acpi_idle_enter_c1(struct cpuidle_device *dev, | 749 | static int acpi_idle_enter_c1(struct cpuidle_device *dev, |
| 749 | struct cpuidle_state *state) | 750 | struct cpuidle_driver *drv, int index) |
| 750 | { | 751 | { |
| 751 | ktime_t kt1, kt2; | 752 | ktime_t kt1, kt2; |
| 752 | s64 idle_time; | 753 | s64 idle_time; |
| 753 | struct acpi_processor *pr; | 754 | struct acpi_processor *pr; |
| 754 | struct acpi_processor_cx *cx = cpuidle_get_statedata(state); | 755 | struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; |
| 756 | struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage); | ||
| 755 | 757 | ||
| 756 | pr = __this_cpu_read(processors); | 758 | pr = __this_cpu_read(processors); |
| 759 | dev->last_residency = 0; | ||
| 757 | 760 | ||
| 758 | if (unlikely(!pr)) | 761 | if (unlikely(!pr)) |
| 759 | return 0; | 762 | return -EINVAL; |
| 760 | 763 | ||
| 761 | local_irq_disable(); | 764 | local_irq_disable(); |
| 762 | 765 | ||
| @@ -764,7 +767,7 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev, | |||
| 764 | if (acpi_idle_suspend) { | 767 | if (acpi_idle_suspend) { |
| 765 | local_irq_enable(); | 768 | local_irq_enable(); |
| 766 | cpu_relax(); | 769 | cpu_relax(); |
| 767 | return 0; | 770 | return -EINVAL; |
| 768 | } | 771 | } |
| 769 | 772 | ||
| 770 | lapic_timer_state_broadcast(pr, cx, 1); | 773 | lapic_timer_state_broadcast(pr, cx, 1); |
| @@ -773,37 +776,47 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev, | |||
| 773 | kt2 = ktime_get_real(); | 776 | kt2 = ktime_get_real(); |
| 774 | idle_time = ktime_to_us(ktime_sub(kt2, kt1)); | 777 | idle_time = ktime_to_us(ktime_sub(kt2, kt1)); |
| 775 | 778 | ||
| 779 | /* Update device last_residency*/ | ||
| 780 | dev->last_residency = (int)idle_time; | ||
| 781 | |||
| 776 | local_irq_enable(); | 782 | local_irq_enable(); |
| 777 | cx->usage++; | 783 | cx->usage++; |
| 778 | lapic_timer_state_broadcast(pr, cx, 0); | 784 | lapic_timer_state_broadcast(pr, cx, 0); |
| 779 | 785 | ||
| 780 | return idle_time; | 786 | return index; |
| 781 | } | 787 | } |
| 782 | 788 | ||
| 783 | /** | 789 | /** |
| 784 | * acpi_idle_enter_simple - enters an ACPI state without BM handling | 790 | * acpi_idle_enter_simple - enters an ACPI state without BM handling |
| 785 | * @dev: the target CPU | 791 | * @dev: the target CPU |
| 786 | * @state: the state data | 792 | * @drv: cpuidle driver with cpuidle state information |
| 793 | * @index: the index of suggested state | ||
| 787 | */ | 794 | */ |
| 788 | static int acpi_idle_enter_simple(struct cpuidle_device *dev, | 795 | static int acpi_idle_enter_simple(struct cpuidle_device *dev, |
| 789 | struct cpuidle_state *state) | 796 | struct cpuidle_driver *drv, int index) |
| 790 | { | 797 | { |
| 791 | struct acpi_processor *pr; | 798 | struct acpi_processor *pr; |
| 792 | struct acpi_processor_cx *cx = cpuidle_get_statedata(state); | 799 | struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; |
| 800 | struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage); | ||
| 793 | ktime_t kt1, kt2; | 801 | ktime_t kt1, kt2; |
| 794 | s64 idle_time_ns; | 802 | s64 idle_time_ns; |
| 795 | s64 idle_time; | 803 | s64 idle_time; |
| 796 | 804 | ||
| 797 | pr = __this_cpu_read(processors); | 805 | pr = __this_cpu_read(processors); |
| 806 | dev->last_residency = 0; | ||
| 798 | 807 | ||
| 799 | if (unlikely(!pr)) | 808 | if (unlikely(!pr)) |
| 800 | return 0; | 809 | return -EINVAL; |
| 801 | |||
| 802 | if (acpi_idle_suspend) | ||
| 803 | return(acpi_idle_enter_c1(dev, state)); | ||
| 804 | 810 | ||
| 805 | local_irq_disable(); | 811 | local_irq_disable(); |
| 806 | 812 | ||
| 813 | if (acpi_idle_suspend) { | ||
| 814 | local_irq_enable(); | ||
| 815 | cpu_relax(); | ||
| 816 | return -EINVAL; | ||
| 817 | } | ||
| 818 | |||
| 819 | |||
| 807 | if (cx->entry_method != ACPI_CSTATE_FFH) { | 820 | if (cx->entry_method != ACPI_CSTATE_FFH) { |
| 808 | current_thread_info()->status &= ~TS_POLLING; | 821 | current_thread_info()->status &= ~TS_POLLING; |
| 809 | /* | 822 | /* |
| @@ -815,7 +828,7 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev, | |||
| 815 | if (unlikely(need_resched())) { | 828 | if (unlikely(need_resched())) { |
| 816 | current_thread_info()->status |= TS_POLLING; | 829 | current_thread_info()->status |= TS_POLLING; |
| 817 | local_irq_enable(); | 830 | local_irq_enable(); |
| 818 | return 0; | 831 | return -EINVAL; |
| 819 | } | 832 | } |
| 820 | } | 833 | } |
| 821 | 834 | ||
| @@ -837,6 +850,9 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev, | |||
| 837 | idle_time = idle_time_ns; | 850 | idle_time = idle_time_ns; |
| 838 | do_div(idle_time, NSEC_PER_USEC); | 851 | do_div(idle_time, NSEC_PER_USEC); |
| 839 | 852 | ||
| 853 | /* Update device last_residency*/ | ||
| 854 | dev->last_residency = (int)idle_time; | ||
| 855 | |||
| 840 | /* Tell the scheduler how much we idled: */ | 856 | /* Tell the scheduler how much we idled: */ |
| 841 | sched_clock_idle_wakeup_event(idle_time_ns); | 857 | sched_clock_idle_wakeup_event(idle_time_ns); |
| 842 | 858 | ||
| @@ -848,7 +864,7 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev, | |||
| 848 | 864 | ||
| 849 | lapic_timer_state_broadcast(pr, cx, 0); | 865 | lapic_timer_state_broadcast(pr, cx, 0); |
| 850 | cx->time += idle_time; | 866 | cx->time += idle_time; |
| 851 | return idle_time; | 867 | return index; |
| 852 | } | 868 | } |
| 853 | 869 | ||
| 854 | static int c3_cpu_count; | 870 | static int c3_cpu_count; |
| @@ -857,37 +873,43 @@ static DEFINE_SPINLOCK(c3_lock); | |||
| 857 | /** | 873 | /** |
| 858 | * acpi_idle_enter_bm - enters C3 with proper BM handling | 874 | * acpi_idle_enter_bm - enters C3 with proper BM handling |
| 859 | * @dev: the target CPU | 875 | * @dev: the target CPU |
| 860 | * @state: the state data | 876 | * @drv: cpuidle driver containing state data |
| 877 | * @index: the index of suggested state | ||
| 861 | * | 878 | * |
| 862 | * If BM is detected, the deepest non-C3 idle state is entered instead. | 879 | * If BM is detected, the deepest non-C3 idle state is entered instead. |
| 863 | */ | 880 | */ |
| 864 | static int acpi_idle_enter_bm(struct cpuidle_device *dev, | 881 | static int acpi_idle_enter_bm(struct cpuidle_device *dev, |
| 865 | struct cpuidle_state *state) | 882 | struct cpuidle_driver *drv, int index) |
| 866 | { | 883 | { |
| 867 | struct acpi_processor *pr; | 884 | struct acpi_processor *pr; |
| 868 | struct acpi_processor_cx *cx = cpuidle_get_statedata(state); | 885 | struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; |
| 886 | struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage); | ||
| 869 | ktime_t kt1, kt2; | 887 | ktime_t kt1, kt2; |
| 870 | s64 idle_time_ns; | 888 | s64 idle_time_ns; |
| 871 | s64 idle_time; | 889 | s64 idle_time; |
| 872 | 890 | ||
| 873 | 891 | ||
| 874 | pr = __this_cpu_read(processors); | 892 | pr = __this_cpu_read(processors); |
| 893 | dev->last_residency = 0; | ||
| 875 | 894 | ||
| 876 | if (unlikely(!pr)) | 895 | if (unlikely(!pr)) |
| 877 | return 0; | 896 | return -EINVAL; |
| 897 | |||
| 878 | 898 | ||
| 879 | if (acpi_idle_suspend) | 899 | if (acpi_idle_suspend) { |
| 880 | return(acpi_idle_enter_c1(dev, state)); | 900 | cpu_relax(); |
| 901 | return -EINVAL; | ||
| 902 | } | ||
| 881 | 903 | ||
| 882 | if (!cx->bm_sts_skip && acpi_idle_bm_check()) { | 904 | if (!cx->bm_sts_skip && acpi_idle_bm_check()) { |
| 883 | if (dev->safe_state) { | 905 | if (drv->safe_state_index >= 0) { |
| 884 | dev->last_state = dev->safe_state; | 906 | return drv->states[drv->safe_state_index].enter(dev, |
| 885 | return dev->safe_state->enter(dev, dev->safe_state); | 907 | drv, drv->safe_state_index); |
| 886 | } else { | 908 | } else { |
| 887 | local_irq_disable(); | 909 | local_irq_disable(); |
| 888 | acpi_safe_halt(); | 910 | acpi_safe_halt(); |
| 889 | local_irq_enable(); | 911 | local_irq_enable(); |
| 890 | return 0; | 912 | return -EINVAL; |
| 891 | } | 913 | } |
| 892 | } | 914 | } |
| 893 | 915 | ||
| @@ -904,7 +926,7 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, | |||
| 904 | if (unlikely(need_resched())) { | 926 | if (unlikely(need_resched())) { |
| 905 | current_thread_info()->status |= TS_POLLING; | 927 | current_thread_info()->status |= TS_POLLING; |
| 906 | local_irq_enable(); | 928 | local_irq_enable(); |
| 907 | return 0; | 929 | return -EINVAL; |
| 908 | } | 930 | } |
| 909 | } | 931 | } |
| 910 | 932 | ||
| @@ -954,6 +976,9 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, | |||
| 954 | idle_time = idle_time_ns; | 976 | idle_time = idle_time_ns; |
| 955 | do_div(idle_time, NSEC_PER_USEC); | 977 | do_div(idle_time, NSEC_PER_USEC); |
| 956 | 978 | ||
| 979 | /* Update device last_residency*/ | ||
| 980 | dev->last_residency = (int)idle_time; | ||
| 981 | |||
| 957 | /* Tell the scheduler how much we idled: */ | 982 | /* Tell the scheduler how much we idled: */ |
| 958 | sched_clock_idle_wakeup_event(idle_time_ns); | 983 | sched_clock_idle_wakeup_event(idle_time_ns); |
| 959 | 984 | ||
| @@ -965,7 +990,7 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, | |||
| 965 | 990 | ||
| 966 | lapic_timer_state_broadcast(pr, cx, 0); | 991 | lapic_timer_state_broadcast(pr, cx, 0); |
| 967 | cx->time += idle_time; | 992 | cx->time += idle_time; |
| 968 | return idle_time; | 993 | return index; |
| 969 | } | 994 | } |
| 970 | 995 | ||
| 971 | struct cpuidle_driver acpi_idle_driver = { | 996 | struct cpuidle_driver acpi_idle_driver = { |
| @@ -974,14 +999,16 @@ struct cpuidle_driver acpi_idle_driver = { | |||
| 974 | }; | 999 | }; |
| 975 | 1000 | ||
| 976 | /** | 1001 | /** |
| 977 | * acpi_processor_setup_cpuidle - prepares and configures CPUIDLE | 1002 | * acpi_processor_setup_cpuidle_cx - prepares and configures CPUIDLE |
| 1003 | * device i.e. per-cpu data | ||
| 1004 | * | ||
| 978 | * @pr: the ACPI processor | 1005 | * @pr: the ACPI processor |
| 979 | */ | 1006 | */ |
| 980 | static int acpi_processor_setup_cpuidle(struct acpi_processor *pr) | 1007 | static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr) |
| 981 | { | 1008 | { |
| 982 | int i, count = CPUIDLE_DRIVER_STATE_START; | 1009 | int i, count = CPUIDLE_DRIVER_STATE_START; |
| 983 | struct acpi_processor_cx *cx; | 1010 | struct acpi_processor_cx *cx; |
| 984 | struct cpuidle_state *state; | 1011 | struct cpuidle_state_usage *state_usage; |
| 985 | struct cpuidle_device *dev = &pr->power.dev; | 1012 | struct cpuidle_device *dev = &pr->power.dev; |
| 986 | 1013 | ||
| 987 | if (!pr->flags.power_setup_done) | 1014 | if (!pr->flags.power_setup_done) |
| @@ -992,9 +1019,62 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr) | |||
| 992 | } | 1019 | } |
| 993 | 1020 | ||
| 994 | dev->cpu = pr->id; | 1021 | dev->cpu = pr->id; |
| 1022 | |||
| 1023 | if (max_cstate == 0) | ||
| 1024 | max_cstate = 1; | ||
| 1025 | |||
| 1026 | for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) { | ||
| 1027 | cx = &pr->power.states[i]; | ||
| 1028 | state_usage = &dev->states_usage[count]; | ||
| 1029 | |||
| 1030 | if (!cx->valid) | ||
| 1031 | continue; | ||
| 1032 | |||
| 1033 | #ifdef CONFIG_HOTPLUG_CPU | ||
| 1034 | if ((cx->type != ACPI_STATE_C1) && (num_online_cpus() > 1) && | ||
| 1035 | !pr->flags.has_cst && | ||
| 1036 | !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED)) | ||
| 1037 | continue; | ||
| 1038 | #endif | ||
| 1039 | |||
| 1040 | cpuidle_set_statedata(state_usage, cx); | ||
| 1041 | |||
| 1042 | count++; | ||
| 1043 | if (count == CPUIDLE_STATE_MAX) | ||
| 1044 | break; | ||
| 1045 | } | ||
| 1046 | |||
| 1047 | dev->state_count = count; | ||
| 1048 | |||
| 1049 | if (!count) | ||
| 1050 | return -EINVAL; | ||
| 1051 | |||
| 1052 | return 0; | ||
| 1053 | } | ||
| 1054 | |||
| 1055 | /** | ||
| 1056 | * acpi_processor_setup_cpuidle states- prepares and configures cpuidle | ||
| 1057 | * global state data i.e. idle routines | ||
| 1058 | * | ||
| 1059 | * @pr: the ACPI processor | ||
| 1060 | */ | ||
| 1061 | static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr) | ||
| 1062 | { | ||
| 1063 | int i, count = CPUIDLE_DRIVER_STATE_START; | ||
| 1064 | struct acpi_processor_cx *cx; | ||
| 1065 | struct cpuidle_state *state; | ||
| 1066 | struct cpuidle_driver *drv = &acpi_idle_driver; | ||
| 1067 | |||
| 1068 | if (!pr->flags.power_setup_done) | ||
| 1069 | return -EINVAL; | ||
| 1070 | |||
| 1071 | if (pr->flags.power == 0) | ||
| 1072 | return -EINVAL; | ||
| 1073 | |||
| 1074 | drv->safe_state_index = -1; | ||
| 995 | for (i = 0; i < CPUIDLE_STATE_MAX; i++) { | 1075 | for (i = 0; i < CPUIDLE_STATE_MAX; i++) { |
| 996 | dev->states[i].name[0] = '\0'; | 1076 | drv->states[i].name[0] = '\0'; |
| 997 | dev->states[i].desc[0] = '\0'; | 1077 | drv->states[i].desc[0] = '\0'; |
| 998 | } | 1078 | } |
| 999 | 1079 | ||
| 1000 | if (max_cstate == 0) | 1080 | if (max_cstate == 0) |
| @@ -1002,7 +1082,6 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr) | |||
| 1002 | 1082 | ||
| 1003 | for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) { | 1083 | for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) { |
| 1004 | cx = &pr->power.states[i]; | 1084 | cx = &pr->power.states[i]; |
| 1005 | state = &dev->states[count]; | ||
| 1006 | 1085 | ||
| 1007 | if (!cx->valid) | 1086 | if (!cx->valid) |
| 1008 | continue; | 1087 | continue; |
| @@ -1013,8 +1092,8 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr) | |||
| 1013 | !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED)) | 1092 | !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED)) |
| 1014 | continue; | 1093 | continue; |
| 1015 | #endif | 1094 | #endif |
| 1016 | cpuidle_set_statedata(state, cx); | ||
| 1017 | 1095 | ||
| 1096 | state = &drv->states[count]; | ||
| 1018 | snprintf(state->name, CPUIDLE_NAME_LEN, "C%d", i); | 1097 | snprintf(state->name, CPUIDLE_NAME_LEN, "C%d", i); |
| 1019 | strncpy(state->desc, cx->desc, CPUIDLE_DESC_LEN); | 1098 | strncpy(state->desc, cx->desc, CPUIDLE_DESC_LEN); |
| 1020 | state->exit_latency = cx->latency; | 1099 | state->exit_latency = cx->latency; |
| @@ -1027,13 +1106,13 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr) | |||
| 1027 | state->flags |= CPUIDLE_FLAG_TIME_VALID; | 1106 | state->flags |= CPUIDLE_FLAG_TIME_VALID; |
| 1028 | 1107 | ||
| 1029 | state->enter = acpi_idle_enter_c1; | 1108 | state->enter = acpi_idle_enter_c1; |
| 1030 | dev->safe_state = state; | 1109 | drv->safe_state_index = count; |
| 1031 | break; | 1110 | break; |
| 1032 | 1111 | ||
| 1033 | case ACPI_STATE_C2: | 1112 | case ACPI_STATE_C2: |
| 1034 | state->flags |= CPUIDLE_FLAG_TIME_VALID; | 1113 | state->flags |= CPUIDLE_FLAG_TIME_VALID; |
| 1035 | state->enter = acpi_idle_enter_simple; | 1114 | state->enter = acpi_idle_enter_simple; |
| 1036 | dev->safe_state = state; | 1115 | drv->safe_state_index = count; |
| 1037 | break; | 1116 | break; |
| 1038 | 1117 | ||
| 1039 | case ACPI_STATE_C3: | 1118 | case ACPI_STATE_C3: |
| @@ -1049,7 +1128,7 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr) | |||
| 1049 | break; | 1128 | break; |
| 1050 | } | 1129 | } |
| 1051 | 1130 | ||
| 1052 | dev->state_count = count; | 1131 | drv->state_count = count; |
| 1053 | 1132 | ||
| 1054 | if (!count) | 1133 | if (!count) |
| 1055 | return -EINVAL; | 1134 | return -EINVAL; |
| @@ -1057,7 +1136,7 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr) | |||
| 1057 | return 0; | 1136 | return 0; |
| 1058 | } | 1137 | } |
| 1059 | 1138 | ||
| 1060 | int acpi_processor_cst_has_changed(struct acpi_processor *pr) | 1139 | int acpi_processor_hotplug(struct acpi_processor *pr) |
| 1061 | { | 1140 | { |
| 1062 | int ret = 0; | 1141 | int ret = 0; |
| 1063 | 1142 | ||
| @@ -1078,7 +1157,7 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr) | |||
| 1078 | cpuidle_disable_device(&pr->power.dev); | 1157 | cpuidle_disable_device(&pr->power.dev); |
| 1079 | acpi_processor_get_power_info(pr); | 1158 | acpi_processor_get_power_info(pr); |
| 1080 | if (pr->flags.power) { | 1159 | if (pr->flags.power) { |
| 1081 | acpi_processor_setup_cpuidle(pr); | 1160 | acpi_processor_setup_cpuidle_cx(pr); |
| 1082 | ret = cpuidle_enable_device(&pr->power.dev); | 1161 | ret = cpuidle_enable_device(&pr->power.dev); |
| 1083 | } | 1162 | } |
| 1084 | cpuidle_resume_and_unlock(); | 1163 | cpuidle_resume_and_unlock(); |
| @@ -1086,10 +1165,72 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr) | |||
| 1086 | return ret; | 1165 | return ret; |
| 1087 | } | 1166 | } |
| 1088 | 1167 | ||
| 1168 | int acpi_processor_cst_has_changed(struct acpi_processor *pr) | ||
| 1169 | { | ||
| 1170 | int cpu; | ||
| 1171 | struct acpi_processor *_pr; | ||
| 1172 | |||
| 1173 | if (disabled_by_idle_boot_param()) | ||
| 1174 | return 0; | ||
| 1175 | |||
| 1176 | if (!pr) | ||
| 1177 | return -EINVAL; | ||
| 1178 | |||
| 1179 | if (nocst) | ||
| 1180 | return -ENODEV; | ||
| 1181 | |||
| 1182 | if (!pr->flags.power_setup_done) | ||
| 1183 | return -ENODEV; | ||
| 1184 | |||
| 1185 | /* | ||
| 1186 | * FIXME: Design the ACPI notification to make it once per | ||
| 1187 | * system instead of once per-cpu. This condition is a hack | ||
| 1188 | * to make the code that updates C-States be called once. | ||
| 1189 | */ | ||
| 1190 | |||
| 1191 | if (smp_processor_id() == 0 && | ||
| 1192 | cpuidle_get_driver() == &acpi_idle_driver) { | ||
| 1193 | |||
| 1194 | cpuidle_pause_and_lock(); | ||
| 1195 | /* Protect against cpu-hotplug */ | ||
| 1196 | get_online_cpus(); | ||
| 1197 | |||
| 1198 | /* Disable all cpuidle devices */ | ||
| 1199 | for_each_online_cpu(cpu) { | ||
| 1200 | _pr = per_cpu(processors, cpu); | ||
| 1201 | if (!_pr || !_pr->flags.power_setup_done) | ||
| 1202 | continue; | ||
| 1203 | cpuidle_disable_device(&_pr->power.dev); | ||
| 1204 | } | ||
| 1205 | |||
| 1206 | /* Populate Updated C-state information */ | ||
| 1207 | acpi_processor_setup_cpuidle_states(pr); | ||
| 1208 | |||
| 1209 | /* Enable all cpuidle devices */ | ||
| 1210 | for_each_online_cpu(cpu) { | ||
| 1211 | _pr = per_cpu(processors, cpu); | ||
| 1212 | if (!_pr || !_pr->flags.power_setup_done) | ||
| 1213 | continue; | ||
| 1214 | acpi_processor_get_power_info(_pr); | ||
| 1215 | if (_pr->flags.power) { | ||
| 1216 | acpi_processor_setup_cpuidle_cx(_pr); | ||
| 1217 | cpuidle_enable_device(&_pr->power.dev); | ||
| 1218 | } | ||
| 1219 | } | ||
| 1220 | put_online_cpus(); | ||
| 1221 | cpuidle_resume_and_unlock(); | ||
| 1222 | } | ||
| 1223 | |||
| 1224 | return 0; | ||
| 1225 | } | ||
| 1226 | |||
| 1227 | static int acpi_processor_registered; | ||
| 1228 | |||
| 1089 | int __cpuinit acpi_processor_power_init(struct acpi_processor *pr, | 1229 | int __cpuinit acpi_processor_power_init(struct acpi_processor *pr, |
| 1090 | struct acpi_device *device) | 1230 | struct acpi_device *device) |
| 1091 | { | 1231 | { |
| 1092 | acpi_status status = 0; | 1232 | acpi_status status = 0; |
| 1233 | int retval; | ||
| 1093 | static int first_run; | 1234 | static int first_run; |
| 1094 | 1235 | ||
| 1095 | if (disabled_by_idle_boot_param()) | 1236 | if (disabled_by_idle_boot_param()) |
| @@ -1126,9 +1267,26 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr, | |||
| 1126 | * platforms that only support C1. | 1267 | * platforms that only support C1. |
| 1127 | */ | 1268 | */ |
| 1128 | if (pr->flags.power) { | 1269 | if (pr->flags.power) { |
| 1129 | acpi_processor_setup_cpuidle(pr); | 1270 | /* Register acpi_idle_driver if not already registered */ |
| 1130 | if (cpuidle_register_device(&pr->power.dev)) | 1271 | if (!acpi_processor_registered) { |
| 1131 | return -EIO; | 1272 | acpi_processor_setup_cpuidle_states(pr); |
| 1273 | retval = cpuidle_register_driver(&acpi_idle_driver); | ||
| 1274 | if (retval) | ||
| 1275 | return retval; | ||
| 1276 | printk(KERN_DEBUG "ACPI: %s registered with cpuidle\n", | ||
| 1277 | acpi_idle_driver.name); | ||
| 1278 | } | ||
| 1279 | /* Register per-cpu cpuidle_device. Cpuidle driver | ||
| 1280 | * must already be registered before registering device | ||
| 1281 | */ | ||
| 1282 | acpi_processor_setup_cpuidle_cx(pr); | ||
| 1283 | retval = cpuidle_register_device(&pr->power.dev); | ||
| 1284 | if (retval) { | ||
| 1285 | if (acpi_processor_registered == 0) | ||
| 1286 | cpuidle_unregister_driver(&acpi_idle_driver); | ||
| 1287 | return retval; | ||
| 1288 | } | ||
| 1289 | acpi_processor_registered++; | ||
| 1132 | } | 1290 | } |
| 1133 | return 0; | 1291 | return 0; |
| 1134 | } | 1292 | } |
| @@ -1139,8 +1297,13 @@ int acpi_processor_power_exit(struct acpi_processor *pr, | |||
| 1139 | if (disabled_by_idle_boot_param()) | 1297 | if (disabled_by_idle_boot_param()) |
| 1140 | return 0; | 1298 | return 0; |
| 1141 | 1299 | ||
| 1142 | cpuidle_unregister_device(&pr->power.dev); | 1300 | if (pr->flags.power) { |
| 1143 | pr->flags.power_setup_done = 0; | 1301 | cpuidle_unregister_device(&pr->power.dev); |
| 1302 | acpi_processor_registered--; | ||
| 1303 | if (acpi_processor_registered == 0) | ||
| 1304 | cpuidle_unregister_driver(&acpi_idle_driver); | ||
| 1305 | } | ||
| 1144 | 1306 | ||
| 1307 | pr->flags.power_setup_done = 0; | ||
| 1145 | return 0; | 1308 | return 0; |
| 1146 | } | 1309 | } |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 449c556274c0..8ab80bafe3f1 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
| @@ -1062,13 +1062,12 @@ static void acpi_add_id(struct acpi_device *device, const char *dev_id) | |||
| 1062 | if (!id) | 1062 | if (!id) |
| 1063 | return; | 1063 | return; |
| 1064 | 1064 | ||
| 1065 | id->id = kmalloc(strlen(dev_id) + 1, GFP_KERNEL); | 1065 | id->id = kstrdup(dev_id, GFP_KERNEL); |
| 1066 | if (!id->id) { | 1066 | if (!id->id) { |
| 1067 | kfree(id); | 1067 | kfree(id); |
| 1068 | return; | 1068 | return; |
| 1069 | } | 1069 | } |
| 1070 | 1070 | ||
| 1071 | strcpy(id->id, dev_id); | ||
| 1072 | list_add_tail(&id->list, &device->pnp.ids); | 1071 | list_add_tail(&id->list, &device->pnp.ids); |
| 1073 | } | 1072 | } |
| 1074 | 1073 | ||
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c index c538d0ef10ff..9f66181c814e 100644 --- a/drivers/acpi/sysfs.c +++ b/drivers/acpi/sysfs.c | |||
| @@ -706,11 +706,23 @@ static void __exit interrupt_stats_exit(void) | |||
| 706 | return; | 706 | return; |
| 707 | } | 707 | } |
| 708 | 708 | ||
| 709 | static ssize_t | ||
| 710 | acpi_show_profile(struct device *dev, struct device_attribute *attr, | ||
| 711 | char *buf) | ||
| 712 | { | ||
| 713 | return sprintf(buf, "%d\n", acpi_gbl_FADT.preferred_profile); | ||
| 714 | } | ||
| 715 | |||
| 716 | static const struct device_attribute pm_profile_attr = | ||
| 717 | __ATTR(pm_profile, S_IRUGO, acpi_show_profile, NULL); | ||
| 718 | |||
| 709 | int __init acpi_sysfs_init(void) | 719 | int __init acpi_sysfs_init(void) |
| 710 | { | 720 | { |
| 711 | int result; | 721 | int result; |
| 712 | 722 | ||
| 713 | result = acpi_tables_sysfs_init(); | 723 | result = acpi_tables_sysfs_init(); |
| 714 | 724 | if (result) | |
| 725 | return result; | ||
| 726 | result = sysfs_create_file(acpi_kobj, &pm_profile_attr.attr); | ||
| 715 | return result; | 727 | return result; |
| 716 | } | 728 | } |
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index d4c542372886..7a57b11eaa8d 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c | |||
| @@ -61,8 +61,9 @@ static int __cpuidle_register_device(struct cpuidle_device *dev); | |||
| 61 | int cpuidle_idle_call(void) | 61 | int cpuidle_idle_call(void) |
| 62 | { | 62 | { |
| 63 | struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices); | 63 | struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices); |
| 64 | struct cpuidle_driver *drv = cpuidle_get_driver(); | ||
| 64 | struct cpuidle_state *target_state; | 65 | struct cpuidle_state *target_state; |
| 65 | int next_state; | 66 | int next_state, entered_state; |
| 66 | 67 | ||
| 67 | if (off) | 68 | if (off) |
| 68 | return -ENODEV; | 69 | return -ENODEV; |
| @@ -83,45 +84,36 @@ int cpuidle_idle_call(void) | |||
| 83 | hrtimer_peek_ahead_timers(); | 84 | hrtimer_peek_ahead_timers(); |
| 84 | #endif | 85 | #endif |
| 85 | 86 | ||
| 86 | /* | ||
| 87 | * Call the device's prepare function before calling the | ||
| 88 | * governor's select function. ->prepare gives the device's | ||
| 89 | * cpuidle driver a chance to update any dynamic information | ||
| 90 | * of its cpuidle states for the current idle period, e.g. | ||
| 91 | * state availability, latencies, residencies, etc. | ||
| 92 | */ | ||
| 93 | if (dev->prepare) | ||
| 94 | dev->prepare(dev); | ||
| 95 | |||
| 96 | /* ask the governor for the next state */ | 87 | /* ask the governor for the next state */ |
| 97 | next_state = cpuidle_curr_governor->select(dev); | 88 | next_state = cpuidle_curr_governor->select(drv, dev); |
| 98 | if (need_resched()) { | 89 | if (need_resched()) { |
| 99 | local_irq_enable(); | 90 | local_irq_enable(); |
| 100 | return 0; | 91 | return 0; |
| 101 | } | 92 | } |
| 102 | 93 | ||
| 103 | target_state = &dev->states[next_state]; | 94 | target_state = &drv->states[next_state]; |
| 104 | |||
| 105 | /* enter the state and update stats */ | ||
| 106 | dev->last_state = target_state; | ||
| 107 | 95 | ||
| 108 | trace_power_start(POWER_CSTATE, next_state, dev->cpu); | 96 | trace_power_start(POWER_CSTATE, next_state, dev->cpu); |
| 109 | trace_cpu_idle(next_state, dev->cpu); | 97 | trace_cpu_idle(next_state, dev->cpu); |
| 110 | 98 | ||
| 111 | dev->last_residency = target_state->enter(dev, target_state); | 99 | entered_state = target_state->enter(dev, drv, next_state); |
| 112 | 100 | ||
| 113 | trace_power_end(dev->cpu); | 101 | trace_power_end(dev->cpu); |
| 114 | trace_cpu_idle(PWR_EVENT_EXIT, dev->cpu); | 102 | trace_cpu_idle(PWR_EVENT_EXIT, dev->cpu); |
| 115 | 103 | ||
| 116 | if (dev->last_state) | 104 | if (entered_state >= 0) { |
| 117 | target_state = dev->last_state; | 105 | /* Update cpuidle counters */ |
| 118 | 106 | /* This can be moved to within driver enter routine | |
| 119 | target_state->time += (unsigned long long)dev->last_residency; | 107 | * but that results in multiple copies of same code. |
| 120 | target_state->usage++; | 108 | */ |
| 109 | dev->states_usage[entered_state].time += | ||
| 110 | (unsigned long long)dev->last_residency; | ||
| 111 | dev->states_usage[entered_state].usage++; | ||
| 112 | } | ||
| 121 | 113 | ||
| 122 | /* give the governor an opportunity to reflect on the outcome */ | 114 | /* give the governor an opportunity to reflect on the outcome */ |
| 123 | if (cpuidle_curr_governor->reflect) | 115 | if (cpuidle_curr_governor->reflect) |
| 124 | cpuidle_curr_governor->reflect(dev); | 116 | cpuidle_curr_governor->reflect(dev, entered_state); |
| 125 | 117 | ||
| 126 | return 0; | 118 | return 0; |
| 127 | } | 119 | } |
| @@ -172,11 +164,11 @@ void cpuidle_resume_and_unlock(void) | |||
| 172 | EXPORT_SYMBOL_GPL(cpuidle_resume_and_unlock); | 164 | EXPORT_SYMBOL_GPL(cpuidle_resume_and_unlock); |
| 173 | 165 | ||
| 174 | #ifdef CONFIG_ARCH_HAS_CPU_RELAX | 166 | #ifdef CONFIG_ARCH_HAS_CPU_RELAX |
| 175 | static int poll_idle(struct cpuidle_device *dev, struct cpuidle_state *st) | 167 | static int poll_idle(struct cpuidle_device *dev, |
| 168 | struct cpuidle_driver *drv, int index) | ||
| 176 | { | 169 | { |
| 177 | ktime_t t1, t2; | 170 | ktime_t t1, t2; |
| 178 | s64 diff; | 171 | s64 diff; |
| 179 | int ret; | ||
| 180 | 172 | ||
| 181 | t1 = ktime_get(); | 173 | t1 = ktime_get(); |
| 182 | local_irq_enable(); | 174 | local_irq_enable(); |
| @@ -188,15 +180,14 @@ static int poll_idle(struct cpuidle_device *dev, struct cpuidle_state *st) | |||
| 188 | if (diff > INT_MAX) | 180 | if (diff > INT_MAX) |
| 189 | diff = INT_MAX; | 181 | diff = INT_MAX; |
| 190 | 182 | ||
| 191 | ret = (int) diff; | 183 | dev->last_residency = (int) diff; |
| 192 | return ret; | 184 | |
| 185 | return index; | ||
| 193 | } | 186 | } |
| 194 | 187 | ||
| 195 | static void poll_idle_init(struct cpuidle_device *dev) | 188 | static void poll_idle_init(struct cpuidle_driver *drv) |
| 196 | { | 189 | { |
| 197 | struct cpuidle_state *state = &dev->states[0]; | 190 | struct cpuidle_state *state = &drv->states[0]; |
| 198 | |||
| 199 | cpuidle_set_statedata(state, NULL); | ||
| 200 | 191 | ||
| 201 | snprintf(state->name, CPUIDLE_NAME_LEN, "POLL"); | 192 | snprintf(state->name, CPUIDLE_NAME_LEN, "POLL"); |
| 202 | snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE"); | 193 | snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE"); |
| @@ -207,7 +198,7 @@ static void poll_idle_init(struct cpuidle_device *dev) | |||
| 207 | state->enter = poll_idle; | 198 | state->enter = poll_idle; |
| 208 | } | 199 | } |
| 209 | #else | 200 | #else |
| 210 | static void poll_idle_init(struct cpuidle_device *dev) {} | 201 | static void poll_idle_init(struct cpuidle_driver *drv) {} |
| 211 | #endif /* CONFIG_ARCH_HAS_CPU_RELAX */ | 202 | #endif /* CONFIG_ARCH_HAS_CPU_RELAX */ |
| 212 | 203 | ||
| 213 | /** | 204 | /** |
| @@ -234,21 +225,20 @@ int cpuidle_enable_device(struct cpuidle_device *dev) | |||
| 234 | return ret; | 225 | return ret; |
| 235 | } | 226 | } |
| 236 | 227 | ||
| 237 | poll_idle_init(dev); | 228 | poll_idle_init(cpuidle_get_driver()); |
| 238 | 229 | ||
| 239 | if ((ret = cpuidle_add_state_sysfs(dev))) | 230 | if ((ret = cpuidle_add_state_sysfs(dev))) |
| 240 | return ret; | 231 | return ret; |
| 241 | 232 | ||
| 242 | if (cpuidle_curr_governor->enable && | 233 | if (cpuidle_curr_governor->enable && |
| 243 | (ret = cpuidle_curr_governor->enable(dev))) | 234 | (ret = cpuidle_curr_governor->enable(cpuidle_get_driver(), dev))) |
| 244 | goto fail_sysfs; | 235 | goto fail_sysfs; |
| 245 | 236 | ||
| 246 | for (i = 0; i < dev->state_count; i++) { | 237 | for (i = 0; i < dev->state_count; i++) { |
| 247 | dev->states[i].usage = 0; | 238 | dev->states_usage[i].usage = 0; |
| 248 | dev->states[i].time = 0; | 239 | dev->states_usage[i].time = 0; |
| 249 | } | 240 | } |
| 250 | dev->last_residency = 0; | 241 | dev->last_residency = 0; |
| 251 | dev->last_state = NULL; | ||
| 252 | 242 | ||
| 253 | smp_wmb(); | 243 | smp_wmb(); |
| 254 | 244 | ||
| @@ -282,7 +272,7 @@ void cpuidle_disable_device(struct cpuidle_device *dev) | |||
| 282 | dev->enabled = 0; | 272 | dev->enabled = 0; |
| 283 | 273 | ||
| 284 | if (cpuidle_curr_governor->disable) | 274 | if (cpuidle_curr_governor->disable) |
| 285 | cpuidle_curr_governor->disable(dev); | 275 | cpuidle_curr_governor->disable(cpuidle_get_driver(), dev); |
| 286 | 276 | ||
| 287 | cpuidle_remove_state_sysfs(dev); | 277 | cpuidle_remove_state_sysfs(dev); |
| 288 | enabled_devices--; | 278 | enabled_devices--; |
| @@ -310,26 +300,6 @@ static int __cpuidle_register_device(struct cpuidle_device *dev) | |||
| 310 | 300 | ||
| 311 | init_completion(&dev->kobj_unregister); | 301 | init_completion(&dev->kobj_unregister); |
| 312 | 302 | ||
| 313 | /* | ||
| 314 | * cpuidle driver should set the dev->power_specified bit | ||
| 315 | * before registering the device if the driver provides | ||
| 316 | * power_usage numbers. | ||
| 317 | * | ||
| 318 | * For those devices whose ->power_specified is not set, | ||
| 319 | * we fill in power_usage with decreasing values as the | ||
| 320 | * cpuidle code has an implicit assumption that state Cn | ||
| 321 | * uses less power than C(n-1). | ||
| 322 | * | ||
| 323 | * With CONFIG_ARCH_HAS_CPU_RELAX, C0 is already assigned | ||
| 324 | * an power value of -1. So we use -2, -3, etc, for other | ||
| 325 | * c-states. | ||
| 326 | */ | ||
| 327 | if (!dev->power_specified) { | ||
| 328 | int i; | ||
| 329 | for (i = CPUIDLE_DRIVER_STATE_START; i < dev->state_count; i++) | ||
| 330 | dev->states[i].power_usage = -1 - i; | ||
| 331 | } | ||
| 332 | |||
| 333 | per_cpu(cpuidle_devices, dev->cpu) = dev; | 303 | per_cpu(cpuidle_devices, dev->cpu) = dev; |
| 334 | list_add(&dev->device_list, &cpuidle_detected_devices); | 304 | list_add(&dev->device_list, &cpuidle_detected_devices); |
| 335 | if ((ret = cpuidle_add_sysfs(sys_dev))) { | 305 | if ((ret = cpuidle_add_sysfs(sys_dev))) { |
diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c index 3f7e3cedd133..284d7af5a9c8 100644 --- a/drivers/cpuidle/driver.c +++ b/drivers/cpuidle/driver.c | |||
| @@ -17,6 +17,30 @@ | |||
| 17 | static struct cpuidle_driver *cpuidle_curr_driver; | 17 | static struct cpuidle_driver *cpuidle_curr_driver; |
| 18 | DEFINE_SPINLOCK(cpuidle_driver_lock); | 18 | DEFINE_SPINLOCK(cpuidle_driver_lock); |
| 19 | 19 | ||
| 20 | static void __cpuidle_register_driver(struct cpuidle_driver *drv) | ||
| 21 | { | ||
| 22 | int i; | ||
| 23 | /* | ||
| 24 | * cpuidle driver should set the drv->power_specified bit | ||
| 25 | * before registering if the driver provides | ||
| 26 | * power_usage numbers. | ||
| 27 | * | ||
| 28 | * If power_specified is not set, | ||
| 29 | * we fill in power_usage with decreasing values as the | ||
| 30 | * cpuidle code has an implicit assumption that state Cn | ||
| 31 | * uses less power than C(n-1). | ||
| 32 | * | ||
| 33 | * With CONFIG_ARCH_HAS_CPU_RELAX, C0 is already assigned | ||
| 34 | * an power value of -1. So we use -2, -3, etc, for other | ||
| 35 | * c-states. | ||
| 36 | */ | ||
| 37 | if (!drv->power_specified) { | ||
| 38 | for (i = CPUIDLE_DRIVER_STATE_START; i < drv->state_count; i++) | ||
| 39 | drv->states[i].power_usage = -1 - i; | ||
| 40 | } | ||
| 41 | } | ||
| 42 | |||
| 43 | |||
| 20 | /** | 44 | /** |
| 21 | * cpuidle_register_driver - registers a driver | 45 | * cpuidle_register_driver - registers a driver |
| 22 | * @drv: the driver | 46 | * @drv: the driver |
| @@ -34,6 +58,7 @@ int cpuidle_register_driver(struct cpuidle_driver *drv) | |||
| 34 | spin_unlock(&cpuidle_driver_lock); | 58 | spin_unlock(&cpuidle_driver_lock); |
| 35 | return -EBUSY; | 59 | return -EBUSY; |
| 36 | } | 60 | } |
| 61 | __cpuidle_register_driver(drv); | ||
| 37 | cpuidle_curr_driver = drv; | 62 | cpuidle_curr_driver = drv; |
| 38 | spin_unlock(&cpuidle_driver_lock); | 63 | spin_unlock(&cpuidle_driver_lock); |
| 39 | 64 | ||
diff --git a/drivers/cpuidle/governors/ladder.c b/drivers/cpuidle/governors/ladder.c index 12c98900dcf8..ef6b9e4727a7 100644 --- a/drivers/cpuidle/governors/ladder.c +++ b/drivers/cpuidle/governors/ladder.c | |||
| @@ -60,9 +60,11 @@ static inline void ladder_do_selection(struct ladder_device *ldev, | |||
| 60 | 60 | ||
| 61 | /** | 61 | /** |
| 62 | * ladder_select_state - selects the next state to enter | 62 | * ladder_select_state - selects the next state to enter |
| 63 | * @drv: cpuidle driver | ||
| 63 | * @dev: the CPU | 64 | * @dev: the CPU |
| 64 | */ | 65 | */ |
| 65 | static int ladder_select_state(struct cpuidle_device *dev) | 66 | static int ladder_select_state(struct cpuidle_driver *drv, |
| 67 | struct cpuidle_device *dev) | ||
| 66 | { | 68 | { |
| 67 | struct ladder_device *ldev = &__get_cpu_var(ladder_devices); | 69 | struct ladder_device *ldev = &__get_cpu_var(ladder_devices); |
| 68 | struct ladder_device_state *last_state; | 70 | struct ladder_device_state *last_state; |
| @@ -77,15 +79,17 @@ static int ladder_select_state(struct cpuidle_device *dev) | |||
| 77 | 79 | ||
| 78 | last_state = &ldev->states[last_idx]; | 80 | last_state = &ldev->states[last_idx]; |
| 79 | 81 | ||
| 80 | if (dev->states[last_idx].flags & CPUIDLE_FLAG_TIME_VALID) | 82 | if (drv->states[last_idx].flags & CPUIDLE_FLAG_TIME_VALID) { |
| 81 | last_residency = cpuidle_get_last_residency(dev) - dev->states[last_idx].exit_latency; | 83 | last_residency = cpuidle_get_last_residency(dev) - \ |
| 84 | drv->states[last_idx].exit_latency; | ||
| 85 | } | ||
| 82 | else | 86 | else |
| 83 | last_residency = last_state->threshold.promotion_time + 1; | 87 | last_residency = last_state->threshold.promotion_time + 1; |
| 84 | 88 | ||
| 85 | /* consider promotion */ | 89 | /* consider promotion */ |
| 86 | if (last_idx < dev->state_count - 1 && | 90 | if (last_idx < drv->state_count - 1 && |
| 87 | last_residency > last_state->threshold.promotion_time && | 91 | last_residency > last_state->threshold.promotion_time && |
| 88 | dev->states[last_idx + 1].exit_latency <= latency_req) { | 92 | drv->states[last_idx + 1].exit_latency <= latency_req) { |
| 89 | last_state->stats.promotion_count++; | 93 | last_state->stats.promotion_count++; |
| 90 | last_state->stats.demotion_count = 0; | 94 | last_state->stats.demotion_count = 0; |
| 91 | if (last_state->stats.promotion_count >= last_state->threshold.promotion_count) { | 95 | if (last_state->stats.promotion_count >= last_state->threshold.promotion_count) { |
| @@ -96,11 +100,11 @@ static int ladder_select_state(struct cpuidle_device *dev) | |||
| 96 | 100 | ||
| 97 | /* consider demotion */ | 101 | /* consider demotion */ |
| 98 | if (last_idx > CPUIDLE_DRIVER_STATE_START && | 102 | if (last_idx > CPUIDLE_DRIVER_STATE_START && |
| 99 | dev->states[last_idx].exit_latency > latency_req) { | 103 | drv->states[last_idx].exit_latency > latency_req) { |
| 100 | int i; | 104 | int i; |
| 101 | 105 | ||
| 102 | for (i = last_idx - 1; i > CPUIDLE_DRIVER_STATE_START; i--) { | 106 | for (i = last_idx - 1; i > CPUIDLE_DRIVER_STATE_START; i--) { |
| 103 | if (dev->states[i].exit_latency <= latency_req) | 107 | if (drv->states[i].exit_latency <= latency_req) |
| 104 | break; | 108 | break; |
| 105 | } | 109 | } |
| 106 | ladder_do_selection(ldev, last_idx, i); | 110 | ladder_do_selection(ldev, last_idx, i); |
| @@ -123,9 +127,11 @@ static int ladder_select_state(struct cpuidle_device *dev) | |||
| 123 | 127 | ||
| 124 | /** | 128 | /** |
| 125 | * ladder_enable_device - setup for the governor | 129 | * ladder_enable_device - setup for the governor |
| 130 | * @drv: cpuidle driver | ||
| 126 | * @dev: the CPU | 131 | * @dev: the CPU |
| 127 | */ | 132 | */ |
| 128 | static int ladder_enable_device(struct cpuidle_device *dev) | 133 | static int ladder_enable_device(struct cpuidle_driver *drv, |
| 134 | struct cpuidle_device *dev) | ||
| 129 | { | 135 | { |
| 130 | int i; | 136 | int i; |
| 131 | struct ladder_device *ldev = &per_cpu(ladder_devices, dev->cpu); | 137 | struct ladder_device *ldev = &per_cpu(ladder_devices, dev->cpu); |
| @@ -134,8 +140,8 @@ static int ladder_enable_device(struct cpuidle_device *dev) | |||
| 134 | 140 | ||
| 135 | ldev->last_state_idx = CPUIDLE_DRIVER_STATE_START; | 141 | ldev->last_state_idx = CPUIDLE_DRIVER_STATE_START; |
| 136 | 142 | ||
| 137 | for (i = 0; i < dev->state_count; i++) { | 143 | for (i = 0; i < drv->state_count; i++) { |
| 138 | state = &dev->states[i]; | 144 | state = &drv->states[i]; |
| 139 | lstate = &ldev->states[i]; | 145 | lstate = &ldev->states[i]; |
| 140 | 146 | ||
| 141 | lstate->stats.promotion_count = 0; | 147 | lstate->stats.promotion_count = 0; |
| @@ -144,7 +150,7 @@ static int ladder_enable_device(struct cpuidle_device *dev) | |||
| 144 | lstate->threshold.promotion_count = PROMOTION_COUNT; | 150 | lstate->threshold.promotion_count = PROMOTION_COUNT; |
| 145 | lstate->threshold.demotion_count = DEMOTION_COUNT; | 151 | lstate->threshold.demotion_count = DEMOTION_COUNT; |
| 146 | 152 | ||
| 147 | if (i < dev->state_count - 1) | 153 | if (i < drv->state_count - 1) |
| 148 | lstate->threshold.promotion_time = state->exit_latency; | 154 | lstate->threshold.promotion_time = state->exit_latency; |
| 149 | if (i > 0) | 155 | if (i > 0) |
| 150 | lstate->threshold.demotion_time = state->exit_latency; | 156 | lstate->threshold.demotion_time = state->exit_latency; |
| @@ -153,11 +159,24 @@ static int ladder_enable_device(struct cpuidle_device *dev) | |||
| 153 | return 0; | 159 | return 0; |
| 154 | } | 160 | } |
| 155 | 161 | ||
| 162 | /** | ||
| 163 | * ladder_reflect - update the correct last_state_idx | ||
| 164 | * @dev: the CPU | ||
| 165 | * @index: the index of actual state entered | ||
| 166 | */ | ||
| 167 | static void ladder_reflect(struct cpuidle_device *dev, int index) | ||
| 168 | { | ||
| 169 | struct ladder_device *ldev = &__get_cpu_var(ladder_devices); | ||
| 170 | if (index > 0) | ||
| 171 | ldev->last_state_idx = index; | ||
| 172 | } | ||
| 173 | |||
| 156 | static struct cpuidle_governor ladder_governor = { | 174 | static struct cpuidle_governor ladder_governor = { |
| 157 | .name = "ladder", | 175 | .name = "ladder", |
| 158 | .rating = 10, | 176 | .rating = 10, |
| 159 | .enable = ladder_enable_device, | 177 | .enable = ladder_enable_device, |
| 160 | .select = ladder_select_state, | 178 | .select = ladder_select_state, |
| 179 | .reflect = ladder_reflect, | ||
| 161 | .owner = THIS_MODULE, | 180 | .owner = THIS_MODULE, |
| 162 | }; | 181 | }; |
| 163 | 182 | ||
diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c index c47f3d09c1ee..bcbe88142135 100644 --- a/drivers/cpuidle/governors/menu.c +++ b/drivers/cpuidle/governors/menu.c | |||
| @@ -182,7 +182,7 @@ static inline int performance_multiplier(void) | |||
| 182 | 182 | ||
| 183 | static DEFINE_PER_CPU(struct menu_device, menu_devices); | 183 | static DEFINE_PER_CPU(struct menu_device, menu_devices); |
| 184 | 184 | ||
| 185 | static void menu_update(struct cpuidle_device *dev); | 185 | static void menu_update(struct cpuidle_driver *drv, struct cpuidle_device *dev); |
| 186 | 186 | ||
| 187 | /* This implements DIV_ROUND_CLOSEST but avoids 64 bit division */ | 187 | /* This implements DIV_ROUND_CLOSEST but avoids 64 bit division */ |
| 188 | static u64 div_round64(u64 dividend, u32 divisor) | 188 | static u64 div_round64(u64 dividend, u32 divisor) |
| @@ -228,9 +228,10 @@ static void detect_repeating_patterns(struct menu_device *data) | |||
| 228 | 228 | ||
| 229 | /** | 229 | /** |
| 230 | * menu_select - selects the next idle state to enter | 230 | * menu_select - selects the next idle state to enter |
| 231 | * @drv: cpuidle driver containing state data | ||
| 231 | * @dev: the CPU | 232 | * @dev: the CPU |
| 232 | */ | 233 | */ |
| 233 | static int menu_select(struct cpuidle_device *dev) | 234 | static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev) |
| 234 | { | 235 | { |
| 235 | struct menu_device *data = &__get_cpu_var(menu_devices); | 236 | struct menu_device *data = &__get_cpu_var(menu_devices); |
| 236 | int latency_req = pm_qos_request(PM_QOS_CPU_DMA_LATENCY); | 237 | int latency_req = pm_qos_request(PM_QOS_CPU_DMA_LATENCY); |
| @@ -240,7 +241,7 @@ static int menu_select(struct cpuidle_device *dev) | |||
| 240 | struct timespec t; | 241 | struct timespec t; |
| 241 | 242 | ||
| 242 | if (data->needs_update) { | 243 | if (data->needs_update) { |
| 243 | menu_update(dev); | 244 | menu_update(drv, dev); |
| 244 | data->needs_update = 0; | 245 | data->needs_update = 0; |
| 245 | } | 246 | } |
| 246 | 247 | ||
| @@ -285,11 +286,9 @@ static int menu_select(struct cpuidle_device *dev) | |||
| 285 | * Find the idle state with the lowest power while satisfying | 286 | * Find the idle state with the lowest power while satisfying |
| 286 | * our constraints. | 287 | * our constraints. |
| 287 | */ | 288 | */ |
| 288 | for (i = CPUIDLE_DRIVER_STATE_START; i < dev->state_count; i++) { | 289 | for (i = CPUIDLE_DRIVER_STATE_START; i < drv->state_count; i++) { |
| 289 | struct cpuidle_state *s = &dev->states[i]; | 290 | struct cpuidle_state *s = &drv->states[i]; |
| 290 | 291 | ||
| 291 | if (s->flags & CPUIDLE_FLAG_IGNORE) | ||
| 292 | continue; | ||
| 293 | if (s->target_residency > data->predicted_us) | 292 | if (s->target_residency > data->predicted_us) |
| 294 | continue; | 293 | continue; |
| 295 | if (s->exit_latency > latency_req) | 294 | if (s->exit_latency > latency_req) |
| @@ -310,26 +309,30 @@ static int menu_select(struct cpuidle_device *dev) | |||
| 310 | /** | 309 | /** |
| 311 | * menu_reflect - records that data structures need update | 310 | * menu_reflect - records that data structures need update |
| 312 | * @dev: the CPU | 311 | * @dev: the CPU |
| 312 | * @index: the index of actual entered state | ||
| 313 | * | 313 | * |
| 314 | * NOTE: it's important to be fast here because this operation will add to | 314 | * NOTE: it's important to be fast here because this operation will add to |
| 315 | * the overall exit latency. | 315 | * the overall exit latency. |
| 316 | */ | 316 | */ |
| 317 | static void menu_reflect(struct cpuidle_device *dev) | 317 | static void menu_reflect(struct cpuidle_device *dev, int index) |
| 318 | { | 318 | { |
| 319 | struct menu_device *data = &__get_cpu_var(menu_devices); | 319 | struct menu_device *data = &__get_cpu_var(menu_devices); |
| 320 | data->needs_update = 1; | 320 | data->last_state_idx = index; |
| 321 | if (index >= 0) | ||
| 322 | data->needs_update = 1; | ||
| 321 | } | 323 | } |
| 322 | 324 | ||
| 323 | /** | 325 | /** |
| 324 | * menu_update - attempts to guess what happened after entry | 326 | * menu_update - attempts to guess what happened after entry |
| 327 | * @drv: cpuidle driver containing state data | ||
| 325 | * @dev: the CPU | 328 | * @dev: the CPU |
| 326 | */ | 329 | */ |
| 327 | static void menu_update(struct cpuidle_device *dev) | 330 | static void menu_update(struct cpuidle_driver *drv, struct cpuidle_device *dev) |
| 328 | { | 331 | { |
| 329 | struct menu_device *data = &__get_cpu_var(menu_devices); | 332 | struct menu_device *data = &__get_cpu_var(menu_devices); |
| 330 | int last_idx = data->last_state_idx; | 333 | int last_idx = data->last_state_idx; |
| 331 | unsigned int last_idle_us = cpuidle_get_last_residency(dev); | 334 | unsigned int last_idle_us = cpuidle_get_last_residency(dev); |
| 332 | struct cpuidle_state *target = &dev->states[last_idx]; | 335 | struct cpuidle_state *target = &drv->states[last_idx]; |
| 333 | unsigned int measured_us; | 336 | unsigned int measured_us; |
| 334 | u64 new_factor; | 337 | u64 new_factor; |
| 335 | 338 | ||
| @@ -383,9 +386,11 @@ static void menu_update(struct cpuidle_device *dev) | |||
| 383 | 386 | ||
| 384 | /** | 387 | /** |
| 385 | * menu_enable_device - scans a CPU's states and does setup | 388 | * menu_enable_device - scans a CPU's states and does setup |
| 389 | * @drv: cpuidle driver | ||
| 386 | * @dev: the CPU | 390 | * @dev: the CPU |
| 387 | */ | 391 | */ |
| 388 | static int menu_enable_device(struct cpuidle_device *dev) | 392 | static int menu_enable_device(struct cpuidle_driver *drv, |
| 393 | struct cpuidle_device *dev) | ||
| 389 | { | 394 | { |
| 390 | struct menu_device *data = &per_cpu(menu_devices, dev->cpu); | 395 | struct menu_device *data = &per_cpu(menu_devices, dev->cpu); |
| 391 | 396 | ||
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c index be7917ec40c9..1e756e160dca 100644 --- a/drivers/cpuidle/sysfs.c +++ b/drivers/cpuidle/sysfs.c | |||
| @@ -216,7 +216,8 @@ static struct kobj_type ktype_cpuidle = { | |||
| 216 | 216 | ||
| 217 | struct cpuidle_state_attr { | 217 | struct cpuidle_state_attr { |
| 218 | struct attribute attr; | 218 | struct attribute attr; |
| 219 | ssize_t (*show)(struct cpuidle_state *, char *); | 219 | ssize_t (*show)(struct cpuidle_state *, \ |
| 220 | struct cpuidle_state_usage *, char *); | ||
| 220 | ssize_t (*store)(struct cpuidle_state *, const char *, size_t); | 221 | ssize_t (*store)(struct cpuidle_state *, const char *, size_t); |
| 221 | }; | 222 | }; |
| 222 | 223 | ||
| @@ -224,19 +225,22 @@ struct cpuidle_state_attr { | |||
| 224 | static struct cpuidle_state_attr attr_##_name = __ATTR(_name, 0444, show, NULL) | 225 | static struct cpuidle_state_attr attr_##_name = __ATTR(_name, 0444, show, NULL) |
| 225 | 226 | ||
| 226 | #define define_show_state_function(_name) \ | 227 | #define define_show_state_function(_name) \ |
| 227 | static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ | 228 | static ssize_t show_state_##_name(struct cpuidle_state *state, \ |
| 229 | struct cpuidle_state_usage *state_usage, char *buf) \ | ||
| 228 | { \ | 230 | { \ |
| 229 | return sprintf(buf, "%u\n", state->_name);\ | 231 | return sprintf(buf, "%u\n", state->_name);\ |
| 230 | } | 232 | } |
| 231 | 233 | ||
| 232 | #define define_show_state_ull_function(_name) \ | 234 | #define define_show_state_ull_function(_name) \ |
| 233 | static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ | 235 | static ssize_t show_state_##_name(struct cpuidle_state *state, \ |
| 236 | struct cpuidle_state_usage *state_usage, char *buf) \ | ||
| 234 | { \ | 237 | { \ |
| 235 | return sprintf(buf, "%llu\n", state->_name);\ | 238 | return sprintf(buf, "%llu\n", state_usage->_name);\ |
| 236 | } | 239 | } |
| 237 | 240 | ||
| 238 | #define define_show_state_str_function(_name) \ | 241 | #define define_show_state_str_function(_name) \ |
| 239 | static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ | 242 | static ssize_t show_state_##_name(struct cpuidle_state *state, \ |
| 243 | struct cpuidle_state_usage *state_usage, char *buf) \ | ||
| 240 | { \ | 244 | { \ |
| 241 | if (state->_name[0] == '\0')\ | 245 | if (state->_name[0] == '\0')\ |
| 242 | return sprintf(buf, "<null>\n");\ | 246 | return sprintf(buf, "<null>\n");\ |
| @@ -269,16 +273,18 @@ static struct attribute *cpuidle_state_default_attrs[] = { | |||
| 269 | 273 | ||
| 270 | #define kobj_to_state_obj(k) container_of(k, struct cpuidle_state_kobj, kobj) | 274 | #define kobj_to_state_obj(k) container_of(k, struct cpuidle_state_kobj, kobj) |
| 271 | #define kobj_to_state(k) (kobj_to_state_obj(k)->state) | 275 | #define kobj_to_state(k) (kobj_to_state_obj(k)->state) |
| 276 | #define kobj_to_state_usage(k) (kobj_to_state_obj(k)->state_usage) | ||
| 272 | #define attr_to_stateattr(a) container_of(a, struct cpuidle_state_attr, attr) | 277 | #define attr_to_stateattr(a) container_of(a, struct cpuidle_state_attr, attr) |
| 273 | static ssize_t cpuidle_state_show(struct kobject * kobj, | 278 | static ssize_t cpuidle_state_show(struct kobject * kobj, |
| 274 | struct attribute * attr ,char * buf) | 279 | struct attribute * attr ,char * buf) |
| 275 | { | 280 | { |
| 276 | int ret = -EIO; | 281 | int ret = -EIO; |
| 277 | struct cpuidle_state *state = kobj_to_state(kobj); | 282 | struct cpuidle_state *state = kobj_to_state(kobj); |
| 283 | struct cpuidle_state_usage *state_usage = kobj_to_state_usage(kobj); | ||
| 278 | struct cpuidle_state_attr * cattr = attr_to_stateattr(attr); | 284 | struct cpuidle_state_attr * cattr = attr_to_stateattr(attr); |
| 279 | 285 | ||
| 280 | if (cattr->show) | 286 | if (cattr->show) |
| 281 | ret = cattr->show(state, buf); | 287 | ret = cattr->show(state, state_usage, buf); |
| 282 | 288 | ||
| 283 | return ret; | 289 | return ret; |
| 284 | } | 290 | } |
| @@ -316,13 +322,15 @@ int cpuidle_add_state_sysfs(struct cpuidle_device *device) | |||
| 316 | { | 322 | { |
| 317 | int i, ret = -ENOMEM; | 323 | int i, ret = -ENOMEM; |
| 318 | struct cpuidle_state_kobj *kobj; | 324 | struct cpuidle_state_kobj *kobj; |
| 325 | struct cpuidle_driver *drv = cpuidle_get_driver(); | ||
| 319 | 326 | ||
| 320 | /* state statistics */ | 327 | /* state statistics */ |
| 321 | for (i = 0; i < device->state_count; i++) { | 328 | for (i = 0; i < device->state_count; i++) { |
| 322 | kobj = kzalloc(sizeof(struct cpuidle_state_kobj), GFP_KERNEL); | 329 | kobj = kzalloc(sizeof(struct cpuidle_state_kobj), GFP_KERNEL); |
| 323 | if (!kobj) | 330 | if (!kobj) |
| 324 | goto error_state; | 331 | goto error_state; |
| 325 | kobj->state = &device->states[i]; | 332 | kobj->state = &drv->states[i]; |
| 333 | kobj->state_usage = &device->states_usage[i]; | ||
| 326 | init_completion(&kobj->kobj_unregister); | 334 | init_completion(&kobj->kobj_unregister); |
| 327 | 335 | ||
| 328 | ret = kobject_init_and_add(&kobj->kobj, &ktype_state_cpuidle, &device->kobj, | 336 | ret = kobject_init_and_add(&kobj->kobj, &ktype_state_cpuidle, &device->kobj, |
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index a46dddf61078..5be9d599ff6b 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c | |||
| @@ -81,7 +81,8 @@ static unsigned int mwait_substates; | |||
| 81 | static unsigned int lapic_timer_reliable_states = (1 << 1); /* Default to only C1 */ | 81 | static unsigned int lapic_timer_reliable_states = (1 << 1); /* Default to only C1 */ |
| 82 | 82 | ||
| 83 | static struct cpuidle_device __percpu *intel_idle_cpuidle_devices; | 83 | static struct cpuidle_device __percpu *intel_idle_cpuidle_devices; |
| 84 | static int intel_idle(struct cpuidle_device *dev, struct cpuidle_state *state); | 84 | static int intel_idle(struct cpuidle_device *dev, |
| 85 | struct cpuidle_driver *drv, int index); | ||
| 85 | 86 | ||
| 86 | static struct cpuidle_state *cpuidle_state_table; | 87 | static struct cpuidle_state *cpuidle_state_table; |
| 87 | 88 | ||
| @@ -109,7 +110,6 @@ static struct cpuidle_state nehalem_cstates[MWAIT_MAX_NUM_CSTATES] = { | |||
| 109 | { /* MWAIT C1 */ | 110 | { /* MWAIT C1 */ |
| 110 | .name = "C1-NHM", | 111 | .name = "C1-NHM", |
| 111 | .desc = "MWAIT 0x00", | 112 | .desc = "MWAIT 0x00", |
| 112 | .driver_data = (void *) 0x00, | ||
| 113 | .flags = CPUIDLE_FLAG_TIME_VALID, | 113 | .flags = CPUIDLE_FLAG_TIME_VALID, |
| 114 | .exit_latency = 3, | 114 | .exit_latency = 3, |
| 115 | .target_residency = 6, | 115 | .target_residency = 6, |
| @@ -117,7 +117,6 @@ static struct cpuidle_state nehalem_cstates[MWAIT_MAX_NUM_CSTATES] = { | |||
| 117 | { /* MWAIT C2 */ | 117 | { /* MWAIT C2 */ |
| 118 | .name = "C3-NHM", | 118 | .name = "C3-NHM", |
| 119 | .desc = "MWAIT 0x10", | 119 | .desc = "MWAIT 0x10", |
| 120 | .driver_data = (void *) 0x10, | ||
| 121 | .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, | 120 | .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, |
| 122 | .exit_latency = 20, | 121 | .exit_latency = 20, |
| 123 | .target_residency = 80, | 122 | .target_residency = 80, |
| @@ -125,7 +124,6 @@ static struct cpuidle_state nehalem_cstates[MWAIT_MAX_NUM_CSTATES] = { | |||
| 125 | { /* MWAIT C3 */ | 124 | { /* MWAIT C3 */ |
| 126 | .name = "C6-NHM", | 125 | .name = "C6-NHM", |
| 127 | .desc = "MWAIT 0x20", | 126 | .desc = "MWAIT 0x20", |
| 128 | .driver_data = (void *) 0x20, | ||
| 129 | .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, | 127 | .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, |
| 130 | .exit_latency = 200, | 128 | .exit_latency = 200, |
| 131 | .target_residency = 800, | 129 | .target_residency = 800, |
| @@ -137,7 +135,6 @@ static struct cpuidle_state snb_cstates[MWAIT_MAX_NUM_CSTATES] = { | |||
| 137 | { /* MWAIT C1 */ | 135 | { /* MWAIT C1 */ |
| 138 | .name = "C1-SNB", | 136 | .name = "C1-SNB", |
| 139 | .desc = "MWAIT 0x00", | 137 | .desc = "MWAIT 0x00", |
| 140 | .driver_data = (void *) 0x00, | ||
| 141 | .flags = CPUIDLE_FLAG_TIME_VALID, | 138 | .flags = CPUIDLE_FLAG_TIME_VALID, |
| 142 | .exit_latency = 1, | 139 | .exit_latency = 1, |
| 143 | .target_residency = 1, | 140 | .target_residency = 1, |
| @@ -145,7 +142,6 @@ static struct cpuidle_state snb_cstates[MWAIT_MAX_NUM_CSTATES] = { | |||
| 145 | { /* MWAIT C2 */ | 142 | { /* MWAIT C2 */ |
| 146 | .name = "C3-SNB", | 143 | .name = "C3-SNB", |
| 147 | .desc = "MWAIT 0x10", | 144 | .desc = "MWAIT 0x10", |
| 148 | .driver_data = (void *) 0x10, | ||
| 149 | .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, | 145 | .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, |
| 150 | .exit_latency = 80, | 146 | .exit_latency = 80, |
| 151 | .target_residency = 211, | 147 | .target_residency = 211, |
| @@ -153,7 +149,6 @@ static struct cpuidle_state snb_cstates[MWAIT_MAX_NUM_CSTATES] = { | |||
| 153 | { /* MWAIT C3 */ | 149 | { /* MWAIT C3 */ |
| 154 | .name = "C6-SNB", | 150 | .name = "C6-SNB", |
| 155 | .desc = "MWAIT 0x20", | 151 | .desc = "MWAIT 0x20", |
| 156 | .driver_data = (void *) 0x20, | ||
| 157 | .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, | 152 | .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, |
| 158 | .exit_latency = 104, | 153 | .exit_latency = 104, |
| 159 | .target_residency = 345, | 154 | .target_residency = 345, |
| @@ -161,7 +156,6 @@ static struct cpuidle_state snb_cstates[MWAIT_MAX_NUM_CSTATES] = { | |||
| 161 | { /* MWAIT C4 */ | 156 | { /* MWAIT C4 */ |
| 162 | .name = "C7-SNB", | 157 | .name = "C7-SNB", |
| 163 | .desc = "MWAIT 0x30", | 158 | .desc = "MWAIT 0x30", |
| 164 | .driver_data = (void *) 0x30, | ||
| 165 | .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, | 159 | .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, |
| 166 | .exit_latency = 109, | 160 | .exit_latency = 109, |
| 167 | .target_residency = 345, | 161 | .target_residency = 345, |
| @@ -173,7 +167,6 @@ static struct cpuidle_state atom_cstates[MWAIT_MAX_NUM_CSTATES] = { | |||
| 173 | { /* MWAIT C1 */ | 167 | { /* MWAIT C1 */ |
| 174 | .name = "C1-ATM", | 168 | .name = "C1-ATM", |
| 175 | .desc = "MWAIT 0x00", | 169 | .desc = "MWAIT 0x00", |
| 176 | .driver_data = (void *) 0x00, | ||
| 177 | .flags = CPUIDLE_FLAG_TIME_VALID, | 170 | .flags = CPUIDLE_FLAG_TIME_VALID, |
| 178 | .exit_latency = 1, | 171 | .exit_latency = 1, |
| 179 | .target_residency = 4, | 172 | .target_residency = 4, |
| @@ -181,7 +174,6 @@ static struct cpuidle_state atom_cstates[MWAIT_MAX_NUM_CSTATES] = { | |||
| 181 | { /* MWAIT C2 */ | 174 | { /* MWAIT C2 */ |
| 182 | .name = "C2-ATM", | 175 | .name = "C2-ATM", |
| 183 | .desc = "MWAIT 0x10", | 176 | .desc = "MWAIT 0x10", |
| 184 | .driver_data = (void *) 0x10, | ||
| 185 | .flags = CPUIDLE_FLAG_TIME_VALID, | 177 | .flags = CPUIDLE_FLAG_TIME_VALID, |
| 186 | .exit_latency = 20, | 178 | .exit_latency = 20, |
| 187 | .target_residency = 80, | 179 | .target_residency = 80, |
| @@ -190,7 +182,6 @@ static struct cpuidle_state atom_cstates[MWAIT_MAX_NUM_CSTATES] = { | |||
| 190 | { /* MWAIT C4 */ | 182 | { /* MWAIT C4 */ |
| 191 | .name = "C4-ATM", | 183 | .name = "C4-ATM", |
| 192 | .desc = "MWAIT 0x30", | 184 | .desc = "MWAIT 0x30", |
| 193 | .driver_data = (void *) 0x30, | ||
| 194 | .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, | 185 | .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, |
| 195 | .exit_latency = 100, | 186 | .exit_latency = 100, |
| 196 | .target_residency = 400, | 187 | .target_residency = 400, |
| @@ -199,23 +190,55 @@ static struct cpuidle_state atom_cstates[MWAIT_MAX_NUM_CSTATES] = { | |||
| 199 | { /* MWAIT C6 */ | 190 | { /* MWAIT C6 */ |
| 200 | .name = "C6-ATM", | 191 | .name = "C6-ATM", |
| 201 | .desc = "MWAIT 0x52", | 192 | .desc = "MWAIT 0x52", |
| 202 | .driver_data = (void *) 0x52, | ||
| 203 | .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, | 193 | .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, |
| 204 | .exit_latency = 140, | 194 | .exit_latency = 140, |
| 205 | .target_residency = 560, | 195 | .target_residency = 560, |
| 206 | .enter = &intel_idle }, | 196 | .enter = &intel_idle }, |
| 207 | }; | 197 | }; |
| 208 | 198 | ||
| 199 | static int get_driver_data(int cstate) | ||
| 200 | { | ||
| 201 | int driver_data; | ||
| 202 | switch (cstate) { | ||
| 203 | |||
| 204 | case 1: /* MWAIT C1 */ | ||
| 205 | driver_data = 0x00; | ||
| 206 | break; | ||
| 207 | case 2: /* MWAIT C2 */ | ||
| 208 | driver_data = 0x10; | ||
| 209 | break; | ||
| 210 | case 3: /* MWAIT C3 */ | ||
| 211 | driver_data = 0x20; | ||
| 212 | break; | ||
| 213 | case 4: /* MWAIT C4 */ | ||
| 214 | driver_data = 0x30; | ||
| 215 | break; | ||
| 216 | case 5: /* MWAIT C5 */ | ||
| 217 | driver_data = 0x40; | ||
| 218 | break; | ||
| 219 | case 6: /* MWAIT C6 */ | ||
| 220 | driver_data = 0x52; | ||
| 221 | break; | ||
| 222 | default: | ||
| 223 | driver_data = 0x00; | ||
| 224 | } | ||
| 225 | return driver_data; | ||
| 226 | } | ||
| 227 | |||
| 209 | /** | 228 | /** |
| 210 | * intel_idle | 229 | * intel_idle |
| 211 | * @dev: cpuidle_device | 230 | * @dev: cpuidle_device |
| 212 | * @state: cpuidle state | 231 | * @drv: cpuidle driver |
| 232 | * @index: index of cpuidle state | ||
| 213 | * | 233 | * |
| 214 | */ | 234 | */ |
| 215 | static int intel_idle(struct cpuidle_device *dev, struct cpuidle_state *state) | 235 | static int intel_idle(struct cpuidle_device *dev, |
| 236 | struct cpuidle_driver *drv, int index) | ||
| 216 | { | 237 | { |
| 217 | unsigned long ecx = 1; /* break on interrupt flag */ | 238 | unsigned long ecx = 1; /* break on interrupt flag */ |
| 218 | unsigned long eax = (unsigned long)cpuidle_get_statedata(state); | 239 | struct cpuidle_state *state = &drv->states[index]; |
| 240 | struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; | ||
| 241 | unsigned long eax = (unsigned long)cpuidle_get_statedata(state_usage); | ||
| 219 | unsigned int cstate; | 242 | unsigned int cstate; |
| 220 | ktime_t kt_before, kt_after; | 243 | ktime_t kt_before, kt_after; |
| 221 | s64 usec_delta; | 244 | s64 usec_delta; |
| @@ -256,7 +279,10 @@ static int intel_idle(struct cpuidle_device *dev, struct cpuidle_state *state) | |||
| 256 | if (!(lapic_timer_reliable_states & (1 << (cstate)))) | 279 | if (!(lapic_timer_reliable_states & (1 << (cstate)))) |
| 257 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &cpu); | 280 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &cpu); |
| 258 | 281 | ||
| 259 | return usec_delta; | 282 | /* Update cpuidle counters */ |
| 283 | dev->last_residency = (int)usec_delta; | ||
| 284 | |||
| 285 | return index; | ||
| 260 | } | 286 | } |
| 261 | 287 | ||
| 262 | static void __setup_broadcast_timer(void *arg) | 288 | static void __setup_broadcast_timer(void *arg) |
| @@ -397,6 +423,60 @@ static void intel_idle_cpuidle_devices_uninit(void) | |||
| 397 | return; | 423 | return; |
| 398 | } | 424 | } |
| 399 | /* | 425 | /* |
| 426 | * intel_idle_cpuidle_driver_init() | ||
| 427 | * allocate, initialize cpuidle_states | ||
| 428 | */ | ||
| 429 | static int intel_idle_cpuidle_driver_init(void) | ||
| 430 | { | ||
| 431 | int cstate; | ||
| 432 | struct cpuidle_driver *drv = &intel_idle_driver; | ||
| 433 | |||
| 434 | drv->state_count = 1; | ||
| 435 | |||
| 436 | for (cstate = 1; cstate < MWAIT_MAX_NUM_CSTATES; ++cstate) { | ||
| 437 | int num_substates; | ||
| 438 | |||
| 439 | if (cstate > max_cstate) { | ||
| 440 | printk(PREFIX "max_cstate %d reached\n", | ||
| 441 | max_cstate); | ||
| 442 | break; | ||
| 443 | } | ||
| 444 | |||
| 445 | /* does the state exist in CPUID.MWAIT? */ | ||
| 446 | num_substates = (mwait_substates >> ((cstate) * 4)) | ||
| 447 | & MWAIT_SUBSTATE_MASK; | ||
| 448 | if (num_substates == 0) | ||
| 449 | continue; | ||
| 450 | /* is the state not enabled? */ | ||
| 451 | if (cpuidle_state_table[cstate].enter == NULL) { | ||
| 452 | /* does the driver not know about the state? */ | ||
| 453 | if (*cpuidle_state_table[cstate].name == '\0') | ||
| 454 | pr_debug(PREFIX "unaware of model 0x%x" | ||
| 455 | " MWAIT %d please" | ||
| 456 | " contact lenb@kernel.org", | ||
| 457 | boot_cpu_data.x86_model, cstate); | ||
| 458 | continue; | ||
| 459 | } | ||
| 460 | |||
| 461 | if ((cstate > 2) && | ||
| 462 | !boot_cpu_has(X86_FEATURE_NONSTOP_TSC)) | ||
| 463 | mark_tsc_unstable("TSC halts in idle" | ||
| 464 | " states deeper than C2"); | ||
| 465 | |||
| 466 | drv->states[drv->state_count] = /* structure copy */ | ||
| 467 | cpuidle_state_table[cstate]; | ||
| 468 | |||
| 469 | drv->state_count += 1; | ||
| 470 | } | ||
| 471 | |||
| 472 | if (auto_demotion_disable_flags) | ||
| 473 | smp_call_function(auto_demotion_disable, NULL, 1); | ||
| 474 | |||
| 475 | return 0; | ||
| 476 | } | ||
| 477 | |||
| 478 | |||
| 479 | /* | ||
| 400 | * intel_idle_cpuidle_devices_init() | 480 | * intel_idle_cpuidle_devices_init() |
| 401 | * allocate, initialize, register cpuidle_devices | 481 | * allocate, initialize, register cpuidle_devices |
| 402 | */ | 482 | */ |
| @@ -430,22 +510,11 @@ static int intel_idle_cpuidle_devices_init(void) | |||
| 430 | continue; | 510 | continue; |
| 431 | /* is the state not enabled? */ | 511 | /* is the state not enabled? */ |
| 432 | if (cpuidle_state_table[cstate].enter == NULL) { | 512 | if (cpuidle_state_table[cstate].enter == NULL) { |
| 433 | /* does the driver not know about the state? */ | ||
| 434 | if (*cpuidle_state_table[cstate].name == '\0') | ||
| 435 | pr_debug(PREFIX "unaware of model 0x%x" | ||
| 436 | " MWAIT %d please" | ||
| 437 | " contact lenb@kernel.org", | ||
| 438 | boot_cpu_data.x86_model, cstate); | ||
| 439 | continue; | 513 | continue; |
| 440 | } | 514 | } |
| 441 | 515 | ||
| 442 | if ((cstate > 2) && | 516 | dev->states_usage[dev->state_count].driver_data = |
| 443 | !boot_cpu_has(X86_FEATURE_NONSTOP_TSC)) | 517 | (void *)get_driver_data(cstate); |
| 444 | mark_tsc_unstable("TSC halts in idle" | ||
| 445 | " states deeper than C2"); | ||
| 446 | |||
| 447 | dev->states[dev->state_count] = /* structure copy */ | ||
| 448 | cpuidle_state_table[cstate]; | ||
| 449 | 518 | ||
| 450 | dev->state_count += 1; | 519 | dev->state_count += 1; |
| 451 | } | 520 | } |
| @@ -458,8 +527,6 @@ static int intel_idle_cpuidle_devices_init(void) | |||
| 458 | return -EIO; | 527 | return -EIO; |
| 459 | } | 528 | } |
| 460 | } | 529 | } |
| 461 | if (auto_demotion_disable_flags) | ||
| 462 | smp_call_function(auto_demotion_disable, NULL, 1); | ||
| 463 | 530 | ||
| 464 | return 0; | 531 | return 0; |
| 465 | } | 532 | } |
| @@ -477,6 +544,7 @@ static int __init intel_idle_init(void) | |||
| 477 | if (retval) | 544 | if (retval) |
| 478 | return retval; | 545 | return retval; |
| 479 | 546 | ||
| 547 | intel_idle_cpuidle_driver_init(); | ||
| 480 | retval = cpuidle_register_driver(&intel_idle_driver); | 548 | retval = cpuidle_register_driver(&intel_idle_driver); |
| 481 | if (retval) { | 549 | if (retval) { |
| 482 | printk(KERN_DEBUG PREFIX "intel_idle yielding to %s", | 550 | printk(KERN_DEBUG PREFIX "intel_idle yielding to %s", |
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index bbf3edd85beb..5be4a392a3ae 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c | |||
| @@ -509,15 +509,12 @@ static __init void pnpacpi_parse_dma_option(struct pnp_dev *dev, | |||
| 509 | struct acpi_resource_dma *p) | 509 | struct acpi_resource_dma *p) |
| 510 | { | 510 | { |
| 511 | int i; | 511 | int i; |
| 512 | unsigned char map = 0, flags = 0; | 512 | unsigned char map = 0, flags; |
| 513 | |||
| 514 | if (p->channel_count == 0) | ||
| 515 | flags |= IORESOURCE_DISABLED; | ||
| 516 | 513 | ||
| 517 | for (i = 0; i < p->channel_count; i++) | 514 | for (i = 0; i < p->channel_count; i++) |
| 518 | map |= 1 << p->channels[i]; | 515 | map |= 1 << p->channels[i]; |
| 519 | 516 | ||
| 520 | flags |= dma_flags(dev, p->type, p->bus_master, p->transfer); | 517 | flags = dma_flags(dev, p->type, p->bus_master, p->transfer); |
| 521 | pnp_register_dma_resource(dev, option_flags, map, flags); | 518 | pnp_register_dma_resource(dev, option_flags, map, flags); |
| 522 | } | 519 | } |
| 523 | 520 | ||
| @@ -527,17 +524,14 @@ static __init void pnpacpi_parse_irq_option(struct pnp_dev *dev, | |||
| 527 | { | 524 | { |
| 528 | int i; | 525 | int i; |
| 529 | pnp_irq_mask_t map; | 526 | pnp_irq_mask_t map; |
| 530 | unsigned char flags = 0; | 527 | unsigned char flags; |
| 531 | |||
| 532 | if (p->interrupt_count == 0) | ||
| 533 | flags |= IORESOURCE_DISABLED; | ||
| 534 | 528 | ||
| 535 | bitmap_zero(map.bits, PNP_IRQ_NR); | 529 | bitmap_zero(map.bits, PNP_IRQ_NR); |
| 536 | for (i = 0; i < p->interrupt_count; i++) | 530 | for (i = 0; i < p->interrupt_count; i++) |
| 537 | if (p->interrupts[i]) | 531 | if (p->interrupts[i]) |
| 538 | __set_bit(p->interrupts[i], map.bits); | 532 | __set_bit(p->interrupts[i], map.bits); |
| 539 | 533 | ||
| 540 | flags |= irq_flags(p->triggering, p->polarity, p->sharable); | 534 | flags = irq_flags(p->triggering, p->polarity, p->sharable); |
| 541 | pnp_register_irq_resource(dev, option_flags, &map, flags); | 535 | pnp_register_irq_resource(dev, option_flags, &map, flags); |
| 542 | } | 536 | } |
| 543 | 537 | ||
| @@ -547,10 +541,7 @@ static __init void pnpacpi_parse_ext_irq_option(struct pnp_dev *dev, | |||
| 547 | { | 541 | { |
| 548 | int i; | 542 | int i; |
| 549 | pnp_irq_mask_t map; | 543 | pnp_irq_mask_t map; |
| 550 | unsigned char flags = 0; | 544 | unsigned char flags; |
| 551 | |||
| 552 | if (p->interrupt_count == 0) | ||
| 553 | flags |= IORESOURCE_DISABLED; | ||
| 554 | 545 | ||
| 555 | bitmap_zero(map.bits, PNP_IRQ_NR); | 546 | bitmap_zero(map.bits, PNP_IRQ_NR); |
| 556 | for (i = 0; i < p->interrupt_count; i++) { | 547 | for (i = 0; i < p->interrupt_count; i++) { |
| @@ -564,7 +555,7 @@ static __init void pnpacpi_parse_ext_irq_option(struct pnp_dev *dev, | |||
| 564 | } | 555 | } |
| 565 | } | 556 | } |
| 566 | 557 | ||
| 567 | flags |= irq_flags(p->triggering, p->polarity, p->sharable); | 558 | flags = irq_flags(p->triggering, p->polarity, p->sharable); |
| 568 | pnp_register_irq_resource(dev, option_flags, &map, flags); | 559 | pnp_register_irq_resource(dev, option_flags, &map, flags); |
| 569 | } | 560 | } |
| 570 | 561 | ||
| @@ -574,11 +565,8 @@ static __init void pnpacpi_parse_port_option(struct pnp_dev *dev, | |||
| 574 | { | 565 | { |
| 575 | unsigned char flags = 0; | 566 | unsigned char flags = 0; |
| 576 | 567 | ||
| 577 | if (io->address_length == 0) | ||
| 578 | flags |= IORESOURCE_DISABLED; | ||
| 579 | |||
| 580 | if (io->io_decode == ACPI_DECODE_16) | 568 | if (io->io_decode == ACPI_DECODE_16) |
| 581 | flags |= IORESOURCE_IO_16BIT_ADDR; | 569 | flags = IORESOURCE_IO_16BIT_ADDR; |
| 582 | pnp_register_port_resource(dev, option_flags, io->minimum, io->maximum, | 570 | pnp_register_port_resource(dev, option_flags, io->minimum, io->maximum, |
| 583 | io->alignment, io->address_length, flags); | 571 | io->alignment, io->address_length, flags); |
| 584 | } | 572 | } |
| @@ -587,13 +575,8 @@ static __init void pnpacpi_parse_fixed_port_option(struct pnp_dev *dev, | |||
| 587 | unsigned int option_flags, | 575 | unsigned int option_flags, |
| 588 | struct acpi_resource_fixed_io *io) | 576 | struct acpi_resource_fixed_io *io) |
| 589 | { | 577 | { |
| 590 | unsigned char flags = 0; | ||
| 591 | |||
| 592 | if (io->address_length == 0) | ||
| 593 | flags |= IORESOURCE_DISABLED; | ||
| 594 | |||
| 595 | pnp_register_port_resource(dev, option_flags, io->address, io->address, | 578 | pnp_register_port_resource(dev, option_flags, io->address, io->address, |
| 596 | 0, io->address_length, flags | IORESOURCE_IO_FIXED); | 579 | 0, io->address_length, IORESOURCE_IO_FIXED); |
| 597 | } | 580 | } |
| 598 | 581 | ||
| 599 | static __init void pnpacpi_parse_mem24_option(struct pnp_dev *dev, | 582 | static __init void pnpacpi_parse_mem24_option(struct pnp_dev *dev, |
| @@ -602,11 +585,8 @@ static __init void pnpacpi_parse_mem24_option(struct pnp_dev *dev, | |||
| 602 | { | 585 | { |
| 603 | unsigned char flags = 0; | 586 | unsigned char flags = 0; |
| 604 | 587 | ||
| 605 | if (p->address_length == 0) | ||
| 606 | flags |= IORESOURCE_DISABLED; | ||
| 607 | |||
| 608 | if (p->write_protect == ACPI_READ_WRITE_MEMORY) | 588 | if (p->write_protect == ACPI_READ_WRITE_MEMORY) |
| 609 | flags |= IORESOURCE_MEM_WRITEABLE; | 589 | flags = IORESOURCE_MEM_WRITEABLE; |
| 610 | pnp_register_mem_resource(dev, option_flags, p->minimum, p->maximum, | 590 | pnp_register_mem_resource(dev, option_flags, p->minimum, p->maximum, |
| 611 | p->alignment, p->address_length, flags); | 591 | p->alignment, p->address_length, flags); |
| 612 | } | 592 | } |
| @@ -617,11 +597,8 @@ static __init void pnpacpi_parse_mem32_option(struct pnp_dev *dev, | |||
| 617 | { | 597 | { |
| 618 | unsigned char flags = 0; | 598 | unsigned char flags = 0; |
| 619 | 599 | ||
| 620 | if (p->address_length == 0) | ||
| 621 | flags |= IORESOURCE_DISABLED; | ||
| 622 | |||
| 623 | if (p->write_protect == ACPI_READ_WRITE_MEMORY) | 600 | if (p->write_protect == ACPI_READ_WRITE_MEMORY) |
| 624 | flags |= IORESOURCE_MEM_WRITEABLE; | 601 | flags = IORESOURCE_MEM_WRITEABLE; |
| 625 | pnp_register_mem_resource(dev, option_flags, p->minimum, p->maximum, | 602 | pnp_register_mem_resource(dev, option_flags, p->minimum, p->maximum, |
| 626 | p->alignment, p->address_length, flags); | 603 | p->alignment, p->address_length, flags); |
| 627 | } | 604 | } |
| @@ -632,11 +609,8 @@ static __init void pnpacpi_parse_fixed_mem32_option(struct pnp_dev *dev, | |||
| 632 | { | 609 | { |
| 633 | unsigned char flags = 0; | 610 | unsigned char flags = 0; |
| 634 | 611 | ||
| 635 | if (p->address_length == 0) | ||
| 636 | flags |= IORESOURCE_DISABLED; | ||
| 637 | |||
| 638 | if (p->write_protect == ACPI_READ_WRITE_MEMORY) | 612 | if (p->write_protect == ACPI_READ_WRITE_MEMORY) |
| 639 | flags |= IORESOURCE_MEM_WRITEABLE; | 613 | flags = IORESOURCE_MEM_WRITEABLE; |
| 640 | pnp_register_mem_resource(dev, option_flags, p->address, p->address, | 614 | pnp_register_mem_resource(dev, option_flags, p->address, p->address, |
| 641 | 0, p->address_length, flags); | 615 | 0, p->address_length, flags); |
| 642 | } | 616 | } |
| @@ -656,19 +630,16 @@ static __init void pnpacpi_parse_address_option(struct pnp_dev *dev, | |||
| 656 | return; | 630 | return; |
| 657 | } | 631 | } |
| 658 | 632 | ||
| 659 | if (p->address_length == 0) | ||
| 660 | flags |= IORESOURCE_DISABLED; | ||
| 661 | |||
| 662 | if (p->resource_type == ACPI_MEMORY_RANGE) { | 633 | if (p->resource_type == ACPI_MEMORY_RANGE) { |
| 663 | if (p->info.mem.write_protect == ACPI_READ_WRITE_MEMORY) | 634 | if (p->info.mem.write_protect == ACPI_READ_WRITE_MEMORY) |
| 664 | flags |= IORESOURCE_MEM_WRITEABLE; | 635 | flags = IORESOURCE_MEM_WRITEABLE; |
| 665 | pnp_register_mem_resource(dev, option_flags, p->minimum, | 636 | pnp_register_mem_resource(dev, option_flags, p->minimum, |
| 666 | p->minimum, 0, p->address_length, | 637 | p->minimum, 0, p->address_length, |
| 667 | flags); | 638 | flags); |
| 668 | } else if (p->resource_type == ACPI_IO_RANGE) | 639 | } else if (p->resource_type == ACPI_IO_RANGE) |
| 669 | pnp_register_port_resource(dev, option_flags, p->minimum, | 640 | pnp_register_port_resource(dev, option_flags, p->minimum, |
| 670 | p->minimum, 0, p->address_length, | 641 | p->minimum, 0, p->address_length, |
| 671 | flags | IORESOURCE_IO_FIXED); | 642 | IORESOURCE_IO_FIXED); |
| 672 | } | 643 | } |
| 673 | 644 | ||
| 674 | static __init void pnpacpi_parse_ext_address_option(struct pnp_dev *dev, | 645 | static __init void pnpacpi_parse_ext_address_option(struct pnp_dev *dev, |
| @@ -678,19 +649,16 @@ static __init void pnpacpi_parse_ext_address_option(struct pnp_dev *dev, | |||
| 678 | struct acpi_resource_extended_address64 *p = &r->data.ext_address64; | 649 | struct acpi_resource_extended_address64 *p = &r->data.ext_address64; |
| 679 | unsigned char flags = 0; | 650 | unsigned char flags = 0; |
| 680 | 651 | ||
| 681 | if (p->address_length == 0) | ||
| 682 | flags |= IORESOURCE_DISABLED; | ||
| 683 | |||
| 684 | if (p->resource_type == ACPI_MEMORY_RANGE) { | 652 | if (p->resource_type == ACPI_MEMORY_RANGE) { |
| 685 | if (p->info.mem.write_protect == ACPI_READ_WRITE_MEMORY) | 653 | if (p->info.mem.write_protect == ACPI_READ_WRITE_MEMORY) |
| 686 | flags |= IORESOURCE_MEM_WRITEABLE; | 654 | flags = IORESOURCE_MEM_WRITEABLE; |
| 687 | pnp_register_mem_resource(dev, option_flags, p->minimum, | 655 | pnp_register_mem_resource(dev, option_flags, p->minimum, |
| 688 | p->minimum, 0, p->address_length, | 656 | p->minimum, 0, p->address_length, |
| 689 | flags); | 657 | flags); |
| 690 | } else if (p->resource_type == ACPI_IO_RANGE) | 658 | } else if (p->resource_type == ACPI_IO_RANGE) |
| 691 | pnp_register_port_resource(dev, option_flags, p->minimum, | 659 | pnp_register_port_resource(dev, option_flags, p->minimum, |
| 692 | p->minimum, 0, p->address_length, | 660 | p->minimum, 0, p->address_length, |
| 693 | flags | IORESOURCE_IO_FIXED); | 661 | IORESOURCE_IO_FIXED); |
| 694 | } | 662 | } |
| 695 | 663 | ||
| 696 | struct acpipnp_parse_option_s { | 664 | struct acpipnp_parse_option_s { |
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c index 708f8e92771a..dd9a5743fa99 100644 --- a/drivers/thermal/thermal_sys.c +++ b/drivers/thermal/thermal_sys.c | |||
| @@ -678,10 +678,10 @@ static void thermal_zone_device_set_polling(struct thermal_zone_device *tz, | |||
| 678 | return; | 678 | return; |
| 679 | 679 | ||
| 680 | if (delay > 1000) | 680 | if (delay > 1000) |
| 681 | schedule_delayed_work(&(tz->poll_queue), | 681 | queue_delayed_work(system_freezable_wq, &(tz->poll_queue), |
| 682 | round_jiffies(msecs_to_jiffies(delay))); | 682 | round_jiffies(msecs_to_jiffies(delay))); |
| 683 | else | 683 | else |
| 684 | schedule_delayed_work(&(tz->poll_queue), | 684 | queue_delayed_work(system_freezable_wq, &(tz->poll_queue), |
| 685 | msecs_to_jiffies(delay)); | 685 | msecs_to_jiffies(delay)); |
| 686 | } | 686 | } |
| 687 | 687 | ||
