diff options
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 79 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_conservative.c | 50 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_ondemand.c | 54 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_stats.c | 6 | ||||
-rw-r--r-- | drivers/cpufreq/db8500-cpufreq.c | 6 |
5 files changed, 94 insertions, 101 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 987a165ede2..8c2df3499da 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -679,7 +679,7 @@ static struct kobj_type ktype_cpufreq = { | |||
679 | */ | 679 | */ |
680 | static int cpufreq_add_dev_policy(unsigned int cpu, | 680 | static int cpufreq_add_dev_policy(unsigned int cpu, |
681 | struct cpufreq_policy *policy, | 681 | struct cpufreq_policy *policy, |
682 | struct sys_device *sys_dev) | 682 | struct device *dev) |
683 | { | 683 | { |
684 | int ret = 0; | 684 | int ret = 0; |
685 | #ifdef CONFIG_SMP | 685 | #ifdef CONFIG_SMP |
@@ -728,7 +728,7 @@ static int cpufreq_add_dev_policy(unsigned int cpu, | |||
728 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 728 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); |
729 | 729 | ||
730 | pr_debug("CPU already managed, adding link\n"); | 730 | pr_debug("CPU already managed, adding link\n"); |
731 | ret = sysfs_create_link(&sys_dev->kobj, | 731 | ret = sysfs_create_link(&dev->kobj, |
732 | &managed_policy->kobj, | 732 | &managed_policy->kobj, |
733 | "cpufreq"); | 733 | "cpufreq"); |
734 | if (ret) | 734 | if (ret) |
@@ -761,7 +761,7 @@ static int cpufreq_add_dev_symlink(unsigned int cpu, | |||
761 | 761 | ||
762 | for_each_cpu(j, policy->cpus) { | 762 | for_each_cpu(j, policy->cpus) { |
763 | struct cpufreq_policy *managed_policy; | 763 | struct cpufreq_policy *managed_policy; |
764 | struct sys_device *cpu_sys_dev; | 764 | struct device *cpu_dev; |
765 | 765 | ||
766 | if (j == cpu) | 766 | if (j == cpu) |
767 | continue; | 767 | continue; |
@@ -770,8 +770,8 @@ static int cpufreq_add_dev_symlink(unsigned int cpu, | |||
770 | 770 | ||
771 | pr_debug("CPU %u already managed, adding link\n", j); | 771 | pr_debug("CPU %u already managed, adding link\n", j); |
772 | managed_policy = cpufreq_cpu_get(cpu); | 772 | managed_policy = cpufreq_cpu_get(cpu); |
773 | cpu_sys_dev = get_cpu_sysdev(j); | 773 | cpu_dev = get_cpu_device(j); |
774 | ret = sysfs_create_link(&cpu_sys_dev->kobj, &policy->kobj, | 774 | ret = sysfs_create_link(&cpu_dev->kobj, &policy->kobj, |
775 | "cpufreq"); | 775 | "cpufreq"); |
776 | if (ret) { | 776 | if (ret) { |
777 | cpufreq_cpu_put(managed_policy); | 777 | cpufreq_cpu_put(managed_policy); |
@@ -783,7 +783,7 @@ static int cpufreq_add_dev_symlink(unsigned int cpu, | |||
783 | 783 | ||
784 | static int cpufreq_add_dev_interface(unsigned int cpu, | 784 | static int cpufreq_add_dev_interface(unsigned int cpu, |
785 | struct cpufreq_policy *policy, | 785 | struct cpufreq_policy *policy, |
786 | struct sys_device *sys_dev) | 786 | struct device *dev) |
787 | { | 787 | { |
788 | struct cpufreq_policy new_policy; | 788 | struct cpufreq_policy new_policy; |
789 | struct freq_attr **drv_attr; | 789 | struct freq_attr **drv_attr; |
@@ -793,7 +793,7 @@ static int cpufreq_add_dev_interface(unsigned int cpu, | |||
793 | 793 | ||
794 | /* prepare interface data */ | 794 | /* prepare interface data */ |
795 | ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, | 795 | ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, |
796 | &sys_dev->kobj, "cpufreq"); | 796 | &dev->kobj, "cpufreq"); |
797 | if (ret) | 797 | if (ret) |
798 | return ret; | 798 | return ret; |
799 | 799 | ||
@@ -866,9 +866,9 @@ err_out_kobj_put: | |||
866 | * with with cpu hotplugging and all hell will break loose. Tried to clean this | 866 | * with with cpu hotplugging and all hell will break loose. Tried to clean this |
867 | * mess up, but more thorough testing is needed. - Mathieu | 867 | * mess up, but more thorough testing is needed. - Mathieu |
868 | */ | 868 | */ |
869 | static int cpufreq_add_dev(struct sys_device *sys_dev) | 869 | static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) |
870 | { | 870 | { |
871 | unsigned int cpu = sys_dev->id; | 871 | unsigned int cpu = dev->id; |
872 | int ret = 0, found = 0; | 872 | int ret = 0, found = 0; |
873 | struct cpufreq_policy *policy; | 873 | struct cpufreq_policy *policy; |
874 | unsigned long flags; | 874 | unsigned long flags; |
@@ -947,7 +947,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev) | |||
947 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, | 947 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, |
948 | CPUFREQ_START, policy); | 948 | CPUFREQ_START, policy); |
949 | 949 | ||
950 | ret = cpufreq_add_dev_policy(cpu, policy, sys_dev); | 950 | ret = cpufreq_add_dev_policy(cpu, policy, dev); |
951 | if (ret) { | 951 | if (ret) { |
952 | if (ret > 0) | 952 | if (ret > 0) |
953 | /* This is a managed cpu, symlink created, | 953 | /* This is a managed cpu, symlink created, |
@@ -956,7 +956,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev) | |||
956 | goto err_unlock_policy; | 956 | goto err_unlock_policy; |
957 | } | 957 | } |
958 | 958 | ||
959 | ret = cpufreq_add_dev_interface(cpu, policy, sys_dev); | 959 | ret = cpufreq_add_dev_interface(cpu, policy, dev); |
960 | if (ret) | 960 | if (ret) |
961 | goto err_out_unregister; | 961 | goto err_out_unregister; |
962 | 962 | ||
@@ -999,15 +999,15 @@ module_out: | |||
999 | * Caller should already have policy_rwsem in write mode for this CPU. | 999 | * Caller should already have policy_rwsem in write mode for this CPU. |
1000 | * This routine frees the rwsem before returning. | 1000 | * This routine frees the rwsem before returning. |
1001 | */ | 1001 | */ |
1002 | static int __cpufreq_remove_dev(struct sys_device *sys_dev) | 1002 | static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) |
1003 | { | 1003 | { |
1004 | unsigned int cpu = sys_dev->id; | 1004 | unsigned int cpu = dev->id; |
1005 | unsigned long flags; | 1005 | unsigned long flags; |
1006 | struct cpufreq_policy *data; | 1006 | struct cpufreq_policy *data; |
1007 | struct kobject *kobj; | 1007 | struct kobject *kobj; |
1008 | struct completion *cmp; | 1008 | struct completion *cmp; |
1009 | #ifdef CONFIG_SMP | 1009 | #ifdef CONFIG_SMP |
1010 | struct sys_device *cpu_sys_dev; | 1010 | struct device *cpu_dev; |
1011 | unsigned int j; | 1011 | unsigned int j; |
1012 | #endif | 1012 | #endif |
1013 | 1013 | ||
@@ -1032,7 +1032,7 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev) | |||
1032 | pr_debug("removing link\n"); | 1032 | pr_debug("removing link\n"); |
1033 | cpumask_clear_cpu(cpu, data->cpus); | 1033 | cpumask_clear_cpu(cpu, data->cpus); |
1034 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 1034 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); |
1035 | kobj = &sys_dev->kobj; | 1035 | kobj = &dev->kobj; |
1036 | cpufreq_cpu_put(data); | 1036 | cpufreq_cpu_put(data); |
1037 | unlock_policy_rwsem_write(cpu); | 1037 | unlock_policy_rwsem_write(cpu); |
1038 | sysfs_remove_link(kobj, "cpufreq"); | 1038 | sysfs_remove_link(kobj, "cpufreq"); |
@@ -1071,8 +1071,8 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev) | |||
1071 | strncpy(per_cpu(cpufreq_cpu_governor, j), | 1071 | strncpy(per_cpu(cpufreq_cpu_governor, j), |
1072 | data->governor->name, CPUFREQ_NAME_LEN); | 1072 | data->governor->name, CPUFREQ_NAME_LEN); |
1073 | #endif | 1073 | #endif |
1074 | cpu_sys_dev = get_cpu_sysdev(j); | 1074 | cpu_dev = get_cpu_device(j); |
1075 | kobj = &cpu_sys_dev->kobj; | 1075 | kobj = &cpu_dev->kobj; |
1076 | unlock_policy_rwsem_write(cpu); | 1076 | unlock_policy_rwsem_write(cpu); |
1077 | sysfs_remove_link(kobj, "cpufreq"); | 1077 | sysfs_remove_link(kobj, "cpufreq"); |
1078 | lock_policy_rwsem_write(cpu); | 1078 | lock_policy_rwsem_write(cpu); |
@@ -1112,11 +1112,11 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev) | |||
1112 | if (unlikely(cpumask_weight(data->cpus) > 1)) { | 1112 | if (unlikely(cpumask_weight(data->cpus) > 1)) { |
1113 | /* first sibling now owns the new sysfs dir */ | 1113 | /* first sibling now owns the new sysfs dir */ |
1114 | cpumask_clear_cpu(cpu, data->cpus); | 1114 | cpumask_clear_cpu(cpu, data->cpus); |
1115 | cpufreq_add_dev(get_cpu_sysdev(cpumask_first(data->cpus))); | 1115 | cpufreq_add_dev(get_cpu_device(cpumask_first(data->cpus)), NULL); |
1116 | 1116 | ||
1117 | /* finally remove our own symlink */ | 1117 | /* finally remove our own symlink */ |
1118 | lock_policy_rwsem_write(cpu); | 1118 | lock_policy_rwsem_write(cpu); |
1119 | __cpufreq_remove_dev(sys_dev); | 1119 | __cpufreq_remove_dev(dev, sif); |
1120 | } | 1120 | } |
1121 | #endif | 1121 | #endif |
1122 | 1122 | ||
@@ -1128,9 +1128,9 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev) | |||
1128 | } | 1128 | } |
1129 | 1129 | ||
1130 | 1130 | ||
1131 | static int cpufreq_remove_dev(struct sys_device *sys_dev) | 1131 | static int cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) |
1132 | { | 1132 | { |
1133 | unsigned int cpu = sys_dev->id; | 1133 | unsigned int cpu = dev->id; |
1134 | int retval; | 1134 | int retval; |
1135 | 1135 | ||
1136 | if (cpu_is_offline(cpu)) | 1136 | if (cpu_is_offline(cpu)) |
@@ -1139,7 +1139,7 @@ static int cpufreq_remove_dev(struct sys_device *sys_dev) | |||
1139 | if (unlikely(lock_policy_rwsem_write(cpu))) | 1139 | if (unlikely(lock_policy_rwsem_write(cpu))) |
1140 | BUG(); | 1140 | BUG(); |
1141 | 1141 | ||
1142 | retval = __cpufreq_remove_dev(sys_dev); | 1142 | retval = __cpufreq_remove_dev(dev, sif); |
1143 | return retval; | 1143 | return retval; |
1144 | } | 1144 | } |
1145 | 1145 | ||
@@ -1271,9 +1271,11 @@ out: | |||
1271 | } | 1271 | } |
1272 | EXPORT_SYMBOL(cpufreq_get); | 1272 | EXPORT_SYMBOL(cpufreq_get); |
1273 | 1273 | ||
1274 | static struct sysdev_driver cpufreq_sysdev_driver = { | 1274 | static struct subsys_interface cpufreq_interface = { |
1275 | .add = cpufreq_add_dev, | 1275 | .name = "cpufreq", |
1276 | .remove = cpufreq_remove_dev, | 1276 | .subsys = &cpu_subsys, |
1277 | .add_dev = cpufreq_add_dev, | ||
1278 | .remove_dev = cpufreq_remove_dev, | ||
1277 | }; | 1279 | }; |
1278 | 1280 | ||
1279 | 1281 | ||
@@ -1765,25 +1767,25 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb, | |||
1765 | unsigned long action, void *hcpu) | 1767 | unsigned long action, void *hcpu) |
1766 | { | 1768 | { |
1767 | unsigned int cpu = (unsigned long)hcpu; | 1769 | unsigned int cpu = (unsigned long)hcpu; |
1768 | struct sys_device *sys_dev; | 1770 | struct device *dev; |
1769 | 1771 | ||
1770 | sys_dev = get_cpu_sysdev(cpu); | 1772 | dev = get_cpu_device(cpu); |
1771 | if (sys_dev) { | 1773 | if (dev) { |
1772 | switch (action) { | 1774 | switch (action) { |
1773 | case CPU_ONLINE: | 1775 | case CPU_ONLINE: |
1774 | case CPU_ONLINE_FROZEN: | 1776 | case CPU_ONLINE_FROZEN: |
1775 | cpufreq_add_dev(sys_dev); | 1777 | cpufreq_add_dev(dev, NULL); |
1776 | break; | 1778 | break; |
1777 | case CPU_DOWN_PREPARE: | 1779 | case CPU_DOWN_PREPARE: |
1778 | case CPU_DOWN_PREPARE_FROZEN: | 1780 | case CPU_DOWN_PREPARE_FROZEN: |
1779 | if (unlikely(lock_policy_rwsem_write(cpu))) | 1781 | if (unlikely(lock_policy_rwsem_write(cpu))) |
1780 | BUG(); | 1782 | BUG(); |
1781 | 1783 | ||
1782 | __cpufreq_remove_dev(sys_dev); | 1784 | __cpufreq_remove_dev(dev, NULL); |
1783 | break; | 1785 | break; |
1784 | case CPU_DOWN_FAILED: | 1786 | case CPU_DOWN_FAILED: |
1785 | case CPU_DOWN_FAILED_FROZEN: | 1787 | case CPU_DOWN_FAILED_FROZEN: |
1786 | cpufreq_add_dev(sys_dev); | 1788 | cpufreq_add_dev(dev, NULL); |
1787 | break; | 1789 | break; |
1788 | } | 1790 | } |
1789 | } | 1791 | } |
@@ -1830,8 +1832,7 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) | |||
1830 | cpufreq_driver = driver_data; | 1832 | cpufreq_driver = driver_data; |
1831 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 1833 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); |
1832 | 1834 | ||
1833 | ret = sysdev_driver_register(&cpu_sysdev_class, | 1835 | ret = subsys_interface_register(&cpufreq_interface); |
1834 | &cpufreq_sysdev_driver); | ||
1835 | if (ret) | 1836 | if (ret) |
1836 | goto err_null_driver; | 1837 | goto err_null_driver; |
1837 | 1838 | ||
@@ -1850,7 +1851,7 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) | |||
1850 | if (ret) { | 1851 | if (ret) { |
1851 | pr_debug("no CPU initialized for driver %s\n", | 1852 | pr_debug("no CPU initialized for driver %s\n", |
1852 | driver_data->name); | 1853 | driver_data->name); |
1853 | goto err_sysdev_unreg; | 1854 | goto err_if_unreg; |
1854 | } | 1855 | } |
1855 | } | 1856 | } |
1856 | 1857 | ||
@@ -1858,9 +1859,8 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) | |||
1858 | pr_debug("driver %s up and running\n", driver_data->name); | 1859 | pr_debug("driver %s up and running\n", driver_data->name); |
1859 | 1860 | ||
1860 | return 0; | 1861 | return 0; |
1861 | err_sysdev_unreg: | 1862 | err_if_unreg: |
1862 | sysdev_driver_unregister(&cpu_sysdev_class, | 1863 | subsys_interface_unregister(&cpufreq_interface); |
1863 | &cpufreq_sysdev_driver); | ||
1864 | err_null_driver: | 1864 | err_null_driver: |
1865 | spin_lock_irqsave(&cpufreq_driver_lock, flags); | 1865 | spin_lock_irqsave(&cpufreq_driver_lock, flags); |
1866 | cpufreq_driver = NULL; | 1866 | cpufreq_driver = NULL; |
@@ -1887,7 +1887,7 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver) | |||
1887 | 1887 | ||
1888 | pr_debug("unregistering driver %s\n", driver->name); | 1888 | pr_debug("unregistering driver %s\n", driver->name); |
1889 | 1889 | ||
1890 | sysdev_driver_unregister(&cpu_sysdev_class, &cpufreq_sysdev_driver); | 1890 | subsys_interface_unregister(&cpufreq_interface); |
1891 | unregister_hotcpu_notifier(&cpufreq_cpu_notifier); | 1891 | unregister_hotcpu_notifier(&cpufreq_cpu_notifier); |
1892 | 1892 | ||
1893 | spin_lock_irqsave(&cpufreq_driver_lock, flags); | 1893 | spin_lock_irqsave(&cpufreq_driver_lock, flags); |
@@ -1907,8 +1907,7 @@ static int __init cpufreq_core_init(void) | |||
1907 | init_rwsem(&per_cpu(cpu_policy_rwsem, cpu)); | 1907 | init_rwsem(&per_cpu(cpu_policy_rwsem, cpu)); |
1908 | } | 1908 | } |
1909 | 1909 | ||
1910 | cpufreq_global_kobject = kobject_create_and_add("cpufreq", | 1910 | cpufreq_global_kobject = kobject_create_and_add("cpufreq", &cpu_subsys.dev_root->kobj); |
1911 | &cpu_sysdev_class.kset.kobj); | ||
1912 | BUG_ON(!cpufreq_global_kobject); | 1911 | BUG_ON(!cpufreq_global_kobject); |
1913 | register_syscore_ops(&cpufreq_syscore_ops); | 1912 | register_syscore_ops(&cpufreq_syscore_ops); |
1914 | 1913 | ||
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c index c97b468ee9f..235a340e81f 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c | |||
@@ -95,27 +95,26 @@ static struct dbs_tuners { | |||
95 | .freq_step = 5, | 95 | .freq_step = 5, |
96 | }; | 96 | }; |
97 | 97 | ||
98 | static inline cputime64_t get_cpu_idle_time_jiffy(unsigned int cpu, | 98 | static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall) |
99 | cputime64_t *wall) | ||
100 | { | 99 | { |
101 | cputime64_t idle_time; | 100 | u64 idle_time; |
102 | cputime64_t cur_wall_time; | 101 | u64 cur_wall_time; |
103 | cputime64_t busy_time; | 102 | u64 busy_time; |
104 | 103 | ||
105 | cur_wall_time = jiffies64_to_cputime64(get_jiffies_64()); | 104 | cur_wall_time = jiffies64_to_cputime64(get_jiffies_64()); |
106 | busy_time = cputime64_add(kstat_cpu(cpu).cpustat.user, | ||
107 | kstat_cpu(cpu).cpustat.system); | ||
108 | 105 | ||
109 | busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.irq); | 106 | busy_time = kcpustat_cpu(cpu).cpustat[CPUTIME_USER]; |
110 | busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.softirq); | 107 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SYSTEM]; |
111 | busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.steal); | 108 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_IRQ]; |
112 | busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.nice); | 109 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SOFTIRQ]; |
110 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_STEAL]; | ||
111 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_NICE]; | ||
113 | 112 | ||
114 | idle_time = cputime64_sub(cur_wall_time, busy_time); | 113 | idle_time = cur_wall_time - busy_time; |
115 | if (wall) | 114 | if (wall) |
116 | *wall = (cputime64_t)jiffies_to_usecs(cur_wall_time); | 115 | *wall = jiffies_to_usecs(cur_wall_time); |
117 | 116 | ||
118 | return (cputime64_t)jiffies_to_usecs(idle_time); | 117 | return jiffies_to_usecs(idle_time); |
119 | } | 118 | } |
120 | 119 | ||
121 | static inline cputime64_t get_cpu_idle_time(unsigned int cpu, cputime64_t *wall) | 120 | static inline cputime64_t get_cpu_idle_time(unsigned int cpu, cputime64_t *wall) |
@@ -272,7 +271,7 @@ static ssize_t store_ignore_nice_load(struct kobject *a, struct attribute *b, | |||
272 | dbs_info->prev_cpu_idle = get_cpu_idle_time(j, | 271 | dbs_info->prev_cpu_idle = get_cpu_idle_time(j, |
273 | &dbs_info->prev_cpu_wall); | 272 | &dbs_info->prev_cpu_wall); |
274 | if (dbs_tuners_ins.ignore_nice) | 273 | if (dbs_tuners_ins.ignore_nice) |
275 | dbs_info->prev_cpu_nice = kstat_cpu(j).cpustat.nice; | 274 | dbs_info->prev_cpu_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE]; |
276 | } | 275 | } |
277 | return count; | 276 | return count; |
278 | } | 277 | } |
@@ -353,20 +352,20 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
353 | 352 | ||
354 | cur_idle_time = get_cpu_idle_time(j, &cur_wall_time); | 353 | cur_idle_time = get_cpu_idle_time(j, &cur_wall_time); |
355 | 354 | ||
356 | wall_time = (unsigned int) cputime64_sub(cur_wall_time, | 355 | wall_time = (unsigned int) |
357 | j_dbs_info->prev_cpu_wall); | 356 | (cur_wall_time - j_dbs_info->prev_cpu_wall); |
358 | j_dbs_info->prev_cpu_wall = cur_wall_time; | 357 | j_dbs_info->prev_cpu_wall = cur_wall_time; |
359 | 358 | ||
360 | idle_time = (unsigned int) cputime64_sub(cur_idle_time, | 359 | idle_time = (unsigned int) |
361 | j_dbs_info->prev_cpu_idle); | 360 | (cur_idle_time - j_dbs_info->prev_cpu_idle); |
362 | j_dbs_info->prev_cpu_idle = cur_idle_time; | 361 | j_dbs_info->prev_cpu_idle = cur_idle_time; |
363 | 362 | ||
364 | if (dbs_tuners_ins.ignore_nice) { | 363 | if (dbs_tuners_ins.ignore_nice) { |
365 | cputime64_t cur_nice; | 364 | u64 cur_nice; |
366 | unsigned long cur_nice_jiffies; | 365 | unsigned long cur_nice_jiffies; |
367 | 366 | ||
368 | cur_nice = cputime64_sub(kstat_cpu(j).cpustat.nice, | 367 | cur_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE] - |
369 | j_dbs_info->prev_cpu_nice); | 368 | j_dbs_info->prev_cpu_nice; |
370 | /* | 369 | /* |
371 | * Assumption: nice time between sampling periods will | 370 | * Assumption: nice time between sampling periods will |
372 | * be less than 2^32 jiffies for 32 bit sys | 371 | * be less than 2^32 jiffies for 32 bit sys |
@@ -374,7 +373,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
374 | cur_nice_jiffies = (unsigned long) | 373 | cur_nice_jiffies = (unsigned long) |
375 | cputime64_to_jiffies64(cur_nice); | 374 | cputime64_to_jiffies64(cur_nice); |
376 | 375 | ||
377 | j_dbs_info->prev_cpu_nice = kstat_cpu(j).cpustat.nice; | 376 | j_dbs_info->prev_cpu_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE]; |
378 | idle_time += jiffies_to_usecs(cur_nice_jiffies); | 377 | idle_time += jiffies_to_usecs(cur_nice_jiffies); |
379 | } | 378 | } |
380 | 379 | ||
@@ -501,10 +500,9 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
501 | 500 | ||
502 | j_dbs_info->prev_cpu_idle = get_cpu_idle_time(j, | 501 | j_dbs_info->prev_cpu_idle = get_cpu_idle_time(j, |
503 | &j_dbs_info->prev_cpu_wall); | 502 | &j_dbs_info->prev_cpu_wall); |
504 | if (dbs_tuners_ins.ignore_nice) { | 503 | if (dbs_tuners_ins.ignore_nice) |
505 | j_dbs_info->prev_cpu_nice = | 504 | j_dbs_info->prev_cpu_nice = |
506 | kstat_cpu(j).cpustat.nice; | 505 | kcpustat_cpu(j).cpustat[CPUTIME_NICE]; |
507 | } | ||
508 | } | 506 | } |
509 | this_dbs_info->down_skip = 0; | 507 | this_dbs_info->down_skip = 0; |
510 | this_dbs_info->requested_freq = policy->cur; | 508 | this_dbs_info->requested_freq = policy->cur; |
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index fa8af4ebb1d..3d679eee70a 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c | |||
@@ -119,27 +119,26 @@ static struct dbs_tuners { | |||
119 | .powersave_bias = 0, | 119 | .powersave_bias = 0, |
120 | }; | 120 | }; |
121 | 121 | ||
122 | static inline cputime64_t get_cpu_idle_time_jiffy(unsigned int cpu, | 122 | static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall) |
123 | cputime64_t *wall) | ||
124 | { | 123 | { |
125 | cputime64_t idle_time; | 124 | u64 idle_time; |
126 | cputime64_t cur_wall_time; | 125 | u64 cur_wall_time; |
127 | cputime64_t busy_time; | 126 | u64 busy_time; |
128 | 127 | ||
129 | cur_wall_time = jiffies64_to_cputime64(get_jiffies_64()); | 128 | cur_wall_time = jiffies64_to_cputime64(get_jiffies_64()); |
130 | busy_time = cputime64_add(kstat_cpu(cpu).cpustat.user, | ||
131 | kstat_cpu(cpu).cpustat.system); | ||
132 | 129 | ||
133 | busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.irq); | 130 | busy_time = kcpustat_cpu(cpu).cpustat[CPUTIME_USER]; |
134 | busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.softirq); | 131 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SYSTEM]; |
135 | busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.steal); | 132 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_IRQ]; |
136 | busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.nice); | 133 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SOFTIRQ]; |
134 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_STEAL]; | ||
135 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_NICE]; | ||
137 | 136 | ||
138 | idle_time = cputime64_sub(cur_wall_time, busy_time); | 137 | idle_time = cur_wall_time - busy_time; |
139 | if (wall) | 138 | if (wall) |
140 | *wall = (cputime64_t)jiffies_to_usecs(cur_wall_time); | 139 | *wall = jiffies_to_usecs(cur_wall_time); |
141 | 140 | ||
142 | return (cputime64_t)jiffies_to_usecs(idle_time); | 141 | return jiffies_to_usecs(idle_time); |
143 | } | 142 | } |
144 | 143 | ||
145 | static inline cputime64_t get_cpu_idle_time(unsigned int cpu, cputime64_t *wall) | 144 | static inline cputime64_t get_cpu_idle_time(unsigned int cpu, cputime64_t *wall) |
@@ -345,7 +344,7 @@ static ssize_t store_ignore_nice_load(struct kobject *a, struct attribute *b, | |||
345 | dbs_info->prev_cpu_idle = get_cpu_idle_time(j, | 344 | dbs_info->prev_cpu_idle = get_cpu_idle_time(j, |
346 | &dbs_info->prev_cpu_wall); | 345 | &dbs_info->prev_cpu_wall); |
347 | if (dbs_tuners_ins.ignore_nice) | 346 | if (dbs_tuners_ins.ignore_nice) |
348 | dbs_info->prev_cpu_nice = kstat_cpu(j).cpustat.nice; | 347 | dbs_info->prev_cpu_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE]; |
349 | 348 | ||
350 | } | 349 | } |
351 | return count; | 350 | return count; |
@@ -442,24 +441,24 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
442 | cur_idle_time = get_cpu_idle_time(j, &cur_wall_time); | 441 | cur_idle_time = get_cpu_idle_time(j, &cur_wall_time); |
443 | cur_iowait_time = get_cpu_iowait_time(j, &cur_wall_time); | 442 | cur_iowait_time = get_cpu_iowait_time(j, &cur_wall_time); |
444 | 443 | ||
445 | wall_time = (unsigned int) cputime64_sub(cur_wall_time, | 444 | wall_time = (unsigned int) |
446 | j_dbs_info->prev_cpu_wall); | 445 | (cur_wall_time - j_dbs_info->prev_cpu_wall); |
447 | j_dbs_info->prev_cpu_wall = cur_wall_time; | 446 | j_dbs_info->prev_cpu_wall = cur_wall_time; |
448 | 447 | ||
449 | idle_time = (unsigned int) cputime64_sub(cur_idle_time, | 448 | idle_time = (unsigned int) |
450 | j_dbs_info->prev_cpu_idle); | 449 | (cur_idle_time - j_dbs_info->prev_cpu_idle); |
451 | j_dbs_info->prev_cpu_idle = cur_idle_time; | 450 | j_dbs_info->prev_cpu_idle = cur_idle_time; |
452 | 451 | ||
453 | iowait_time = (unsigned int) cputime64_sub(cur_iowait_time, | 452 | iowait_time = (unsigned int) |
454 | j_dbs_info->prev_cpu_iowait); | 453 | (cur_iowait_time - j_dbs_info->prev_cpu_iowait); |
455 | j_dbs_info->prev_cpu_iowait = cur_iowait_time; | 454 | j_dbs_info->prev_cpu_iowait = cur_iowait_time; |
456 | 455 | ||
457 | if (dbs_tuners_ins.ignore_nice) { | 456 | if (dbs_tuners_ins.ignore_nice) { |
458 | cputime64_t cur_nice; | 457 | u64 cur_nice; |
459 | unsigned long cur_nice_jiffies; | 458 | unsigned long cur_nice_jiffies; |
460 | 459 | ||
461 | cur_nice = cputime64_sub(kstat_cpu(j).cpustat.nice, | 460 | cur_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE] - |
462 | j_dbs_info->prev_cpu_nice); | 461 | j_dbs_info->prev_cpu_nice; |
463 | /* | 462 | /* |
464 | * Assumption: nice time between sampling periods will | 463 | * Assumption: nice time between sampling periods will |
465 | * be less than 2^32 jiffies for 32 bit sys | 464 | * be less than 2^32 jiffies for 32 bit sys |
@@ -467,7 +466,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
467 | cur_nice_jiffies = (unsigned long) | 466 | cur_nice_jiffies = (unsigned long) |
468 | cputime64_to_jiffies64(cur_nice); | 467 | cputime64_to_jiffies64(cur_nice); |
469 | 468 | ||
470 | j_dbs_info->prev_cpu_nice = kstat_cpu(j).cpustat.nice; | 469 | j_dbs_info->prev_cpu_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE]; |
471 | idle_time += jiffies_to_usecs(cur_nice_jiffies); | 470 | idle_time += jiffies_to_usecs(cur_nice_jiffies); |
472 | } | 471 | } |
473 | 472 | ||
@@ -646,10 +645,9 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
646 | 645 | ||
647 | j_dbs_info->prev_cpu_idle = get_cpu_idle_time(j, | 646 | j_dbs_info->prev_cpu_idle = get_cpu_idle_time(j, |
648 | &j_dbs_info->prev_cpu_wall); | 647 | &j_dbs_info->prev_cpu_wall); |
649 | if (dbs_tuners_ins.ignore_nice) { | 648 | if (dbs_tuners_ins.ignore_nice) |
650 | j_dbs_info->prev_cpu_nice = | 649 | j_dbs_info->prev_cpu_nice = |
651 | kstat_cpu(j).cpustat.nice; | 650 | kcpustat_cpu(j).cpustat[CPUTIME_NICE]; |
652 | } | ||
653 | } | 651 | } |
654 | this_dbs_info->cpu = cpu; | 652 | this_dbs_info->cpu = cpu; |
655 | this_dbs_info->rate_mult = 1; | 653 | this_dbs_info->rate_mult = 1; |
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index c5072a91e84..b40ee1403be 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c | |||
@@ -11,7 +11,6 @@ | |||
11 | 11 | ||
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
14 | #include <linux/sysdev.h> | ||
15 | #include <linux/cpu.h> | 14 | #include <linux/cpu.h> |
16 | #include <linux/sysfs.h> | 15 | #include <linux/sysfs.h> |
17 | #include <linux/cpufreq.h> | 16 | #include <linux/cpufreq.h> |
@@ -61,9 +60,8 @@ static int cpufreq_stats_update(unsigned int cpu) | |||
61 | spin_lock(&cpufreq_stats_lock); | 60 | spin_lock(&cpufreq_stats_lock); |
62 | stat = per_cpu(cpufreq_stats_table, cpu); | 61 | stat = per_cpu(cpufreq_stats_table, cpu); |
63 | if (stat->time_in_state) | 62 | if (stat->time_in_state) |
64 | stat->time_in_state[stat->last_index] = | 63 | stat->time_in_state[stat->last_index] += |
65 | cputime64_add(stat->time_in_state[stat->last_index], | 64 | cur_time - stat->last_time; |
66 | cputime_sub(cur_time, stat->last_time)); | ||
67 | stat->last_time = cur_time; | 65 | stat->last_time = cur_time; |
68 | spin_unlock(&cpufreq_stats_lock); | 66 | spin_unlock(&cpufreq_stats_lock); |
69 | return 0; | 67 | return 0; |
diff --git a/drivers/cpufreq/db8500-cpufreq.c b/drivers/cpufreq/db8500-cpufreq.c index edaa987621e..f5002015d82 100644 --- a/drivers/cpufreq/db8500-cpufreq.c +++ b/drivers/cpufreq/db8500-cpufreq.c | |||
@@ -109,7 +109,7 @@ static unsigned int db8500_cpufreq_getspeed(unsigned int cpu) | |||
109 | 109 | ||
110 | static int __cpuinit db8500_cpufreq_init(struct cpufreq_policy *policy) | 110 | static int __cpuinit db8500_cpufreq_init(struct cpufreq_policy *policy) |
111 | { | 111 | { |
112 | int res; | 112 | int i, res; |
113 | 113 | ||
114 | BUILD_BUG_ON(ARRAY_SIZE(idx2opp) + 1 != ARRAY_SIZE(freq_table)); | 114 | BUILD_BUG_ON(ARRAY_SIZE(idx2opp) + 1 != ARRAY_SIZE(freq_table)); |
115 | 115 | ||
@@ -120,8 +120,8 @@ static int __cpuinit db8500_cpufreq_init(struct cpufreq_policy *policy) | |||
120 | freq_table[3].frequency = 1000000; | 120 | freq_table[3].frequency = 1000000; |
121 | } | 121 | } |
122 | pr_info("db8500-cpufreq : Available frequencies:\n"); | 122 | pr_info("db8500-cpufreq : Available frequencies:\n"); |
123 | while (freq_table[i].frequency != CPUFREQ_TABLE_END) | 123 | for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) |
124 | pr_info(" %d Mhz\n", freq_table[i++].frequency/1000); | 124 | pr_info(" %d Mhz\n", freq_table[i].frequency/1000); |
125 | 125 | ||
126 | /* get policy fields based on the table */ | 126 | /* get policy fields based on the table */ |
127 | res = cpufreq_frequency_table_cpuinfo(policy, freq_table); | 127 | res = cpufreq_frequency_table_cpuinfo(policy, freq_table); |