Merge branch 'android-4.14-p' into android-exynos-4.14-ww-9610-minor_up-dev
[GitHub/LineageOS/android_kernel_motorola_exynos9610.git] / drivers / cpufreq / cpufreq.c
index 55fa42807221ad30216590878bd378407fff7e00..88f77e6bb931d2acda86cf803f43a14a0f30a4a2 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <linux/cpu.h>
 #include <linux/cpufreq.h>
+#include <linux/cpufreq_times.h>
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/init.h>
@@ -339,6 +340,7 @@ static void __cpufreq_notify_transition(struct cpufreq_policy *policy,
                         (unsigned long)freqs->new, (unsigned long)freqs->cpu);
                trace_cpu_frequency(freqs->new, freqs->cpu);
                cpufreq_stats_record_transition(policy, freqs->new);
+               cpufreq_times_record_transition(freqs);
                srcu_notifier_call_chain(&cpufreq_transition_notifier_list,
                                CPUFREQ_POSTCHANGE, freqs);
                if (likely(policy) && likely(policy->cpu == freqs->cpu))
@@ -554,13 +556,21 @@ EXPORT_SYMBOL_GPL(cpufreq_policy_transition_delay_us);
  *                          SYSFS INTERFACE                          *
  *********************************************************************/
 static ssize_t show_boost(struct kobject *kobj,
-                                struct attribute *attr, char *buf)
+<<<<<<< HEAD
+                                struct kobj_attribute *attr, char *buf)
+=======
+                         struct kobj_attribute *attr, char *buf)
+>>>>>>> android-4.14-p
 {
        return sprintf(buf, "%d\n", cpufreq_driver->boost_enabled);
 }
 
-static ssize_t store_boost(struct kobject *kobj, struct attribute *attr,
+static ssize_t store_boost(struct kobject *kobj, struct kobj_attribute *attr,
+<<<<<<< HEAD
                                  const char *buf, size_t count)
+=======
+                          const char *buf, size_t count)
+>>>>>>> android-4.14-p
 {
        int ret, enable;
 
@@ -631,8 +641,6 @@ static int cpufreq_parse_governor(char *str_governor, unsigned int *policy,
                        *governor = t;
                        err = 0;
                }
-               if (t && !try_module_get(t->owner))
-                       t = NULL;
 
                mutex_unlock(&cpufreq_governor_mutex);
        }
@@ -695,6 +703,8 @@ static ssize_t store_##file_name                                    \
        struct cpufreq_policy new_policy;                               \
                                                                        \
        memcpy(&new_policy, policy, sizeof(*policy));                   \
+       new_policy.min = policy->user_policy.min;                       \
+       new_policy.max = policy->user_policy.max;                       \
                                                                        \
        ret = sscanf(buf, "%u", &new_policy.object);                    \
        if (ret != 1)                                                   \
@@ -761,10 +771,6 @@ static ssize_t store_scaling_governor(struct cpufreq_policy *policy,
                return -EINVAL;
 
        ret = cpufreq_set_policy(policy, &new_policy);
-
-       if (new_policy.governor)
-               module_put(new_policy.governor->owner);
-
        return ret ? ret : count;
 }
 
@@ -1335,6 +1341,7 @@ static int cpufreq_online(unsigned int cpu)
                        goto out_exit_policy;
 
                cpufreq_stats_create_table(policy);
+               cpufreq_times_create_policy(policy);
 
                write_lock_irqsave(&cpufreq_driver_lock, flags);
                list_add(&policy->policy_list, &cpufreq_policy_list);
@@ -1363,14 +1370,14 @@ static int cpufreq_online(unsigned int cpu)
        return 0;
 
 out_exit_policy:
+       for_each_cpu(j, policy->real_cpus)
+               remove_cpu_dev_symlink(policy, get_cpu_device(j));
+
        up_write(&policy->rwsem);
 
        if (cpufreq_driver->exit)
                cpufreq_driver->exit(policy);
 
-       for_each_cpu(j, policy->real_cpus)
-               remove_cpu_dev_symlink(policy, get_cpu_device(j));
-
 out_free_policy:
        cpufreq_policy_free(policy);
        return ret;
@@ -1603,17 +1610,16 @@ static unsigned int __cpufreq_get(struct cpufreq_policy *policy)
 {
        unsigned int ret_freq = 0;
 
-       if (!cpufreq_driver->get)
+       if (unlikely(policy_is_inactive(policy)) || !cpufreq_driver->get)
                return ret_freq;
 
        ret_freq = cpufreq_driver->get(policy->cpu);
 
        /*
-        * Updating inactive policies is invalid, so avoid doing that.  Also
-        * if fast frequency switching is used with the given policy, the check
+        * If fast frequency switching is used with the given policy, the check
         * against policy->cur is pointless, so skip it in that case too.
         */
-       if (unlikely(policy_is_inactive(policy)) || policy->fast_switch_enabled)
+       if (policy->fast_switch_enabled)
                return ret_freq;
 
        if (ret_freq && policy->cur &&
@@ -1642,10 +1648,7 @@ unsigned int cpufreq_get(unsigned int cpu)
 
        if (policy) {
                down_read(&policy->rwsem);
-
-               if (!policy_is_inactive(policy))
-                       ret_freq = __cpufreq_get(policy);
-
+               ret_freq = __cpufreq_get(policy);
                up_read(&policy->rwsem);
 
                cpufreq_cpu_put(policy);
@@ -2022,7 +2025,7 @@ static int __target_index(struct cpufreq_policy *policy, int index)
        return retval;
 }
 
-int __cpufreq_driver_target(struct cpufreq_policy *policy,
+int __weak __cpufreq_driver_target(struct cpufreq_policy *policy,
                            unsigned int target_freq,
                            unsigned int relation)
 {
@@ -2314,6 +2317,9 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
 
        policy->min = new_policy->min;
        policy->max = new_policy->max;
+
+       arch_set_max_freq_scale(policy->cpus, policy->max);
+
        trace_cpu_frequency_limits(policy->max, policy->min, policy->cpu);
 
        policy->cached_target_freq = UINT_MAX;
@@ -2524,6 +2530,12 @@ __weak void arch_set_freq_scale(struct cpumask *cpus,
 }
 EXPORT_SYMBOL_GPL(arch_set_freq_scale);
 
+__weak void arch_set_max_freq_scale(struct cpumask *cpus,
+                                   unsigned long policy_max_freq)
+{
+}
+EXPORT_SYMBOL_GPL(arch_set_max_freq_scale);
+
 /*********************************************************************
  *               REGISTER / UNREGISTER CPUFREQ DRIVER                *
  *********************************************************************/