Merge branch 'cpufreq/arm/linux-next' of git://git.kernel.org/pub/scm/linux/kernel...
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 4 Aug 2020 10:44:53 +0000 (12:44 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 4 Aug 2020 10:44:53 +0000 (12:44 +0200)
Pull ARM cpufreq driver changes for v5.9-rc1 from Viresh Kumar:

"Here are the details:

- Adaptive voltage scaling (AVS) support and minor cleanups for
  brcmstb driver (Florian Fainelli and Markus Mayer).

- A new tegra driver and cleanup for the existing one (Sumit Gupta and
  Jon Hunter).

- Bandwidth level support for Qcom driver along with OPP changes (Sibi
  Sankar).

- Cleanups to sti, cpufreq-dt, ap806, CPPC drivers (Viresh Kumar, Lee
  Jones, Ivan Kokshaysky, Sven Auhagen, and Xin Hao).

- Make schedutil default governor for ARM (Valentin Schneider).

- Fix dependency issues for imx (Walter Lozano).

- Cleanup around cached_resolved_idx in cpufreq core (Viresh Kumar)."

* 'cpufreq/arm/linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm:
  cpufreq: make schedutil the default for arm and arm64
  cpufreq: cached_resolved_idx can not be negative
  cpufreq: Add Tegra194 cpufreq driver
  dt-bindings: arm: Add NVIDIA Tegra194 CPU Complex binding
  cpufreq: imx: Select NVMEM_IMX_OCOTP
  cpufreq: sti-cpufreq: Fix some formatting and misspelling issues
  cpufreq: tegra186: Simplify probe return path
  cpufreq: CPPC: Reuse caps variable in few routines
  cpufreq: ap806: fix cpufreq driver needs ap cpu clk
  cpufreq: cppc: Reorder code and remove apply_hisi_workaround variable
  cpufreq: dt: fix oops on armada37xx
  cpufreq: brcmstb-avs-cpufreq: send S2_ENTER / S2_EXIT commands to AVS
  cpufreq: brcmstb-avs-cpufreq: Support polling AVS firmware
  cpufreq: brcmstb-avs-cpufreq: more flexible interface for __issue_avs_command()
  cpufreq: qcom: Disable fast switch when scaling DDR/L3
  cpufreq: qcom: Update the bandwidth levels on frequency change
  OPP: Add and export helper to set bandwidth
  cpufreq: blacklist SC7180 in cpufreq-dt-platdev
  cpufreq: blacklist SDM845 in cpufreq-dt-platdev

1  2 
drivers/cpufreq/Makefile
drivers/cpufreq/cpufreq.c
drivers/cpufreq/qcom-cpufreq-hw.c
drivers/opp/core.c
include/linux/cpufreq.h
include/linux/pm_opp.h

diff --combined drivers/cpufreq/Makefile
@@@ -83,6 -83,7 +83,7 @@@ obj-$(CONFIG_ARM_TANGO_CPUFREQ)               += tan
  obj-$(CONFIG_ARM_TEGRA20_CPUFREQ)     += tegra20-cpufreq.o
  obj-$(CONFIG_ARM_TEGRA124_CPUFREQ)    += tegra124-cpufreq.o
  obj-$(CONFIG_ARM_TEGRA186_CPUFREQ)    += tegra186-cpufreq.o
+ obj-$(CONFIG_ARM_TEGRA194_CPUFREQ)    += tegra194-cpufreq.o
  obj-$(CONFIG_ARM_TI_CPUFREQ)          += ti-cpufreq.o
  obj-$(CONFIG_ARM_VEXPRESS_SPC_CPUFREQ)        += vexpress-spc-cpufreq.o
  
@@@ -108,3 -109,4 +109,3 @@@ obj-$(CONFIG_LOONGSON1_CPUFREQ)            += loo
  obj-$(CONFIG_SH_CPU_FREQ)             += sh-cpufreq.o
  obj-$(CONFIG_SPARC_US2E_CPUFREQ)      += sparc-us2e-cpufreq.o
  obj-$(CONFIG_SPARC_US3_CPUFREQ)               += sparc-us3-cpufreq.o
 -obj-$(CONFIG_UNICORE32)                       += unicore2-cpufreq.o
@@@ -50,9 -50,7 +50,9 @@@ static LIST_HEAD(cpufreq_governor_list)
  #define for_each_governor(__governor)                         \
        list_for_each_entry(__governor, &cpufreq_governor_list, governor_list)
  
 -/**
 +static char default_governor[CPUFREQ_NAME_LEN];
 +
 +/*
   * The "cpufreq driver" - the arch- or hardware-dependent low
   * level driver of CPUFreq support, and its spinlock. This lock
   * also protects the cpufreq_cpu_data array.
@@@ -80,7 -78,7 +80,7 @@@ static int cpufreq_set_policy(struct cp
                              struct cpufreq_governor *new_gov,
                              unsigned int new_pol);
  
 -/**
 +/*
   * Two notifier lists: the "policy" list is involved in the
   * validation process for a new CPU frequency policy; the
   * "transition" list for kernel code that needs to handle
@@@ -300,7 -298,7 +300,7 @@@ struct cpufreq_policy *cpufreq_cpu_acqu
   *            EXTERNALLY AFFECTING FREQUENCY CHANGES                 *
   *********************************************************************/
  
 -/**
 +/*
   * adjust_jiffies - adjust the system "loops_per_jiffy"
   *
   * This function alters the system "loops_per_jiffy" for the clock
@@@ -526,7 -524,6 +526,7 @@@ EXPORT_SYMBOL_GPL(cpufreq_disable_fast_
  /**
   * cpufreq_driver_resolve_freq - Map a target frequency to a driver-supported
   * one.
 + * @policy: associated policy to interrogate
   * @target_freq: target frequency to resolve.
   *
   * The target to driver frequency mapping is cached in the policy.
@@@ -541,7 -538,7 +541,7 @@@ unsigned int cpufreq_driver_resolve_fre
        policy->cached_target_freq = target_freq;
  
        if (cpufreq_driver->target_index) {
-               int idx;
+               unsigned int idx;
  
                idx = cpufreq_frequency_table_target(policy, target_freq,
                                                     CPUFREQ_RELATION_L);
@@@ -624,24 -621,6 +624,24 @@@ static struct cpufreq_governor *find_go
        return NULL;
  }
  
 +static struct cpufreq_governor *get_governor(const char *str_governor)
 +{
 +      struct cpufreq_governor *t;
 +
 +      mutex_lock(&cpufreq_governor_mutex);
 +      t = find_governor(str_governor);
 +      if (!t)
 +              goto unlock;
 +
 +      if (!try_module_get(t->owner))
 +              t = NULL;
 +
 +unlock:
 +      mutex_unlock(&cpufreq_governor_mutex);
 +
 +      return t;
 +}
 +
  static unsigned int cpufreq_parse_policy(char *str_governor)
  {
        if (!strncasecmp(str_governor, "performance", CPUFREQ_NAME_LEN))
@@@ -661,17 -640,31 +661,17 @@@ static struct cpufreq_governor *cpufreq
  {
        struct cpufreq_governor *t;
  
 -      mutex_lock(&cpufreq_governor_mutex);
 -
 -      t = find_governor(str_governor);
 -      if (!t) {
 -              int ret;
 -
 -              mutex_unlock(&cpufreq_governor_mutex);
 -
 -              ret = request_module("cpufreq_%s", str_governor);
 -              if (ret)
 -                      return NULL;
 +      t = get_governor(str_governor);
 +      if (t)
 +              return t;
  
 -              mutex_lock(&cpufreq_governor_mutex);
 -
 -              t = find_governor(str_governor);
 -      }
 -      if (t && !try_module_get(t->owner))
 -              t = NULL;
 -
 -      mutex_unlock(&cpufreq_governor_mutex);
 +      if (request_module("cpufreq_%s", str_governor))
 +              return NULL;
  
 -      return t;
 +      return get_governor(str_governor);
  }
  
 -/**
 +/*
   * cpufreq_per_cpu_attr_read() / show_##file_name() -
   * print out cpufreq information
   *
@@@ -713,7 -706,7 +713,7 @@@ static ssize_t show_scaling_cur_freq(st
        return ret;
  }
  
 -/**
 +/*
   * cpufreq_per_cpu_attr_write() / store_##file_name() - sysfs write access
   */
  #define store_one(file_name, object)                  \
@@@ -734,7 -727,7 +734,7 @@@ static ssize_t store_##file_name                                   
  store_one(scaling_min_freq, min);
  store_one(scaling_max_freq, max);
  
 -/**
 +/*
   * show_cpuinfo_cur_freq - current CPU frequency as detected by hardware
   */
  static ssize_t show_cpuinfo_cur_freq(struct cpufreq_policy *policy,
        return sprintf(buf, "<unknown>\n");
  }
  
 -/**
 +/*
   * show_scaling_governor - show the current policy for the specified CPU
   */
  static ssize_t show_scaling_governor(struct cpufreq_policy *policy, char *buf)
        return -EINVAL;
  }
  
 -/**
 +/*
   * store_scaling_governor - store policy for the specified CPU
   */
  static ssize_t store_scaling_governor(struct cpufreq_policy *policy,
        return ret ? ret : count;
  }
  
 -/**
 +/*
   * show_scaling_driver - show the cpufreq driver currently loaded
   */
  static ssize_t show_scaling_driver(struct cpufreq_policy *policy, char *buf)
        return scnprintf(buf, CPUFREQ_NAME_PLEN, "%s\n", cpufreq_driver->name);
  }
  
 -/**
 +/*
   * show_scaling_available_governors - show the available CPUfreq governors
   */
  static ssize_t show_scaling_available_governors(struct cpufreq_policy *policy,
                goto out;
        }
  
 +      mutex_lock(&cpufreq_governor_mutex);
        for_each_governor(t) {
                if (i >= (ssize_t) ((PAGE_SIZE / sizeof(char))
                    - (CPUFREQ_NAME_LEN + 2)))
 -                      goto out;
 +                      break;
                i += scnprintf(&buf[i], CPUFREQ_NAME_PLEN, "%s ", t->name);
        }
 +      mutex_unlock(&cpufreq_governor_mutex);
  out:
        i += sprintf(&buf[i], "\n");
        return i;
@@@ -852,7 -843,7 +852,7 @@@ ssize_t cpufreq_show_cpus(const struct 
  }
  EXPORT_SYMBOL_GPL(cpufreq_show_cpus);
  
 -/**
 +/*
   * show_related_cpus - show the CPUs affected by each transition even if
   * hw coordination is in use
   */
@@@ -861,7 -852,7 +861,7 @@@ static ssize_t show_related_cpus(struc
        return cpufreq_show_cpus(policy->related_cpus, buf);
  }
  
 -/**
 +/*
   * show_affected_cpus - show the CPUs affected by each transition
   */
  static ssize_t show_affected_cpus(struct cpufreq_policy *policy, char *buf)
@@@ -895,7 -886,7 +895,7 @@@ static ssize_t show_scaling_setspeed(st
        return policy->governor->show_setspeed(policy, buf);
  }
  
 -/**
 +/*
   * show_bios_limit - show the current cpufreq HW/BIOS limitation
   */
  static ssize_t show_bios_limit(struct cpufreq_policy *policy, char *buf)
@@@ -1057,36 -1048,36 +1057,36 @@@ static int cpufreq_add_dev_interface(st
        return 0;
  }
  
 -__weak struct cpufreq_governor *cpufreq_default_governor(void)
 -{
 -      return NULL;
 -}
 -
  static int cpufreq_init_policy(struct cpufreq_policy *policy)
  {
 -      struct cpufreq_governor *def_gov = cpufreq_default_governor();
        struct cpufreq_governor *gov = NULL;
        unsigned int pol = CPUFREQ_POLICY_UNKNOWN;
 +      int ret;
  
        if (has_target()) {
                /* Update policy governor to the one used before hotplug. */
 -              gov = find_governor(policy->last_governor);
 +              gov = get_governor(policy->last_governor);
                if (gov) {
                        pr_debug("Restoring governor %s for cpu %d\n",
 -                               policy->governor->name, policy->cpu);
 -              } else if (def_gov) {
 -                      gov = def_gov;
 +                               gov->name, policy->cpu);
                } else {
 -                      return -ENODATA;
 +                      gov = get_governor(default_governor);
 +              }
 +
 +              if (!gov) {
 +                      gov = cpufreq_default_governor();
 +                      __module_get(gov->owner);
                }
 +
        } else {
 +
                /* Use the default policy if there is no last_policy. */
                if (policy->last_policy) {
                        pol = policy->last_policy;
 -              } else if (def_gov) {
 -                      pol = cpufreq_parse_policy(def_gov->name);
 +              } else {
 +                      pol = cpufreq_parse_policy(default_governor);
                        /*
 -                       * In case the default governor is neiter "performance"
 +                       * In case the default governor is neither "performance"
                         * nor "powersave", fall back to the initial policy
                         * value set by the driver.
                         */
                        return -ENODATA;
        }
  
 -      return cpufreq_set_policy(policy, gov, pol);
 +      ret = cpufreq_set_policy(policy, gov, pol);
 +      if (gov)
 +              module_put(gov->owner);
 +
 +      return ret;
  }
  
  static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, unsigned int cpu)
@@@ -1617,7 -1604,7 +1617,7 @@@ unlock
        return 0;
  }
  
 -/**
 +/*
   * cpufreq_remove_dev - remove a CPU device
   *
   * Removes the cpufreq interface for a CPU device.
@@@ -2374,7 -2361,6 +2374,7 @@@ EXPORT_SYMBOL_GPL(cpufreq_unregister_go
   * cpufreq_get_policy - get the current cpufreq_policy
   * @policy: struct cpufreq_policy into which the current cpufreq_policy
   *    is written
 + * @cpu: CPU to find the policy for
   *
   * Reads the current cpufreq policy.
   */
@@@ -2761,7 -2747,7 +2761,7 @@@ out
  }
  EXPORT_SYMBOL_GPL(cpufreq_register_driver);
  
 -/**
 +/*
   * cpufreq_unregister_driver - unregister the current CPUFreq driver
   *
   * Unregister the current CPUFreq driver. Only call this if you have
@@@ -2797,19 -2783,13 +2797,19 @@@ EXPORT_SYMBOL_GPL(cpufreq_unregister_dr
  
  static int __init cpufreq_core_init(void)
  {
 +      struct cpufreq_governor *gov = cpufreq_default_governor();
 +
        if (cpufreq_disabled())
                return -ENODEV;
  
        cpufreq_global_kobject = kobject_create_and_add("cpufreq", &cpu_subsys.dev_root->kobj);
        BUG_ON(!cpufreq_global_kobject);
  
 +      if (!strlen(default_governor))
 +              strncpy(default_governor, gov->name, CPUFREQ_NAME_LEN);
 +
        return 0;
  }
  module_param(off, int, 0444);
 +module_param_string(default_governor, default_governor, CPUFREQ_NAME_LEN, 0444);
  core_initcall(cpufreq_core_init);
@@@ -6,6 -6,7 +6,7 @@@
  #include <linux/bitfield.h>
  #include <linux/cpufreq.h>
  #include <linux/init.h>
+ #include <linux/interconnect.h>
  #include <linux/kernel.h>
  #include <linux/module.h>
  #include <linux/of_address.h>
  
  static unsigned long cpu_hw_rate, xo_rate;
  static struct platform_device *global_pdev;
+ static bool icc_scaling_enabled;
+ static int qcom_cpufreq_set_bw(struct cpufreq_policy *policy,
+                              unsigned long freq_khz)
+ {
+       unsigned long freq_hz = freq_khz * 1000;
+       struct dev_pm_opp *opp;
+       struct device *dev;
+       int ret;
+       dev = get_cpu_device(policy->cpu);
+       if (!dev)
+               return -ENODEV;
+       opp = dev_pm_opp_find_freq_exact(dev, freq_hz, true);
+       if (IS_ERR(opp))
+               return PTR_ERR(opp);
+       ret = dev_pm_opp_set_bw(dev, opp);
+       dev_pm_opp_put(opp);
+       return ret;
+ }
+ static int qcom_cpufreq_update_opp(struct device *cpu_dev,
+                                  unsigned long freq_khz,
+                                  unsigned long volt)
+ {
+       unsigned long freq_hz = freq_khz * 1000;
+       int ret;
+       /* Skip voltage update if the opp table is not available */
+       if (!icc_scaling_enabled)
+               return dev_pm_opp_add(cpu_dev, freq_hz, volt);
+       ret = dev_pm_opp_adjust_voltage(cpu_dev, freq_hz, volt, volt, volt);
+       if (ret) {
+               dev_err(cpu_dev, "Voltage update failed freq=%ld\n", freq_khz);
+               return ret;
+       }
+       return dev_pm_opp_enable(cpu_dev, freq_hz);
+ }
  
  static int qcom_cpufreq_hw_target_index(struct cpufreq_policy *policy,
                                        unsigned int index)
@@@ -39,6 -82,9 +82,9 @@@
  
        writel_relaxed(index, perf_state_reg);
  
+       if (icc_scaling_enabled)
+               qcom_cpufreq_set_bw(policy, freq);
        arch_set_freq_scale(policy->related_cpus, freq,
                            policy->cpuinfo.max_freq);
        return 0;
@@@ -66,13 -112,10 +112,10 @@@ static unsigned int qcom_cpufreq_hw_fas
                                                unsigned int target_freq)
  {
        void __iomem *perf_state_reg = policy->driver_data;
-       int index;
+       unsigned int index;
        unsigned long freq;
  
        index = policy->cached_resolved_idx;
-       if (index < 0)
-               return 0;
        writel_relaxed(index, perf_state_reg);
  
        freq = policy->freq_table[index].frequency;
@@@ -89,11 -132,34 +132,34 @@@ static int qcom_cpufreq_hw_read_lut(str
        u32 data, src, lval, i, core_count, prev_freq = 0, freq;
        u32 volt;
        struct cpufreq_frequency_table  *table;
+       struct dev_pm_opp *opp;
+       unsigned long rate;
+       int ret;
  
        table = kcalloc(LUT_MAX_ENTRIES + 1, sizeof(*table), GFP_KERNEL);
        if (!table)
                return -ENOMEM;
  
+       ret = dev_pm_opp_of_add_table(cpu_dev);
+       if (!ret) {
+               /* Disable all opps and cross-validate against LUT later */
+               icc_scaling_enabled = true;
+               for (rate = 0; ; rate++) {
+                       opp = dev_pm_opp_find_freq_ceil(cpu_dev, &rate);
+                       if (IS_ERR(opp))
+                               break;
+                       dev_pm_opp_put(opp);
+                       dev_pm_opp_disable(cpu_dev, rate);
+               }
+       } else if (ret != -ENODEV) {
+               dev_err(cpu_dev, "Invalid opp table in device tree\n");
+               return ret;
+       } else {
+               policy->fast_switch_possible = true;
+               icc_scaling_enabled = false;
+       }
        for (i = 0; i < LUT_MAX_ENTRIES; i++) {
                data = readl_relaxed(base + REG_FREQ_LUT +
                                      i * LUT_ROW_SIZE);
  
                if (freq != prev_freq && core_count != LUT_TURBO_IND) {
                        table[i].frequency = freq;
-                       dev_pm_opp_add(cpu_dev, freq * 1000, volt);
+                       qcom_cpufreq_update_opp(cpu_dev, freq, volt);
                        dev_dbg(cpu_dev, "index=%d freq=%d, core_count %d\n", i,
                                freq, core_count);
                } else if (core_count == LUT_TURBO_IND) {
                        if (prev->frequency == CPUFREQ_ENTRY_INVALID) {
                                prev->frequency = prev_freq;
                                prev->flags = CPUFREQ_BOOST_FREQ;
-                               dev_pm_opp_add(cpu_dev, prev_freq * 1000, volt);
+                               qcom_cpufreq_update_opp(cpu_dev, prev_freq, volt);
                        }
  
                        break;
@@@ -238,10 -304,8 +304,8 @@@ static int qcom_cpufreq_hw_cpu_init(str
                goto error;
        }
  
 -      dev_pm_opp_of_register_em(policy->cpus);
 +      dev_pm_opp_of_register_em(cpu_dev, policy->cpus);
  
-       policy->fast_switch_possible = true;
        return 0;
  error:
        devm_iounmap(dev, base);
@@@ -254,6 -318,7 +318,7 @@@ static int qcom_cpufreq_hw_cpu_exit(str
        void __iomem *base = policy->driver_data - REG_PERF_STATE;
  
        dev_pm_opp_remove_all_dynamic(cpu_dev);
+       dev_pm_opp_of_cpumask_remove_table(policy->related_cpus);
        kfree(policy->freq_table);
        devm_iounmap(&global_pdev->dev, base);
  
@@@ -282,6 -347,7 +347,7 @@@ static struct cpufreq_driver cpufreq_qc
  
  static int qcom_cpufreq_hw_driver_probe(struct platform_device *pdev)
  {
+       struct device *cpu_dev;
        struct clk *clk;
        int ret;
  
  
        global_pdev = pdev;
  
+       /* Check for optional interconnect paths on CPU0 */
+       cpu_dev = get_cpu_device(0);
+       if (!cpu_dev)
+               return -EPROBE_DEFER;
+       ret = dev_pm_opp_of_find_icc_paths(cpu_dev, NULL);
+       if (ret)
+               return ret;
        ret = cpufreq_register_driver(&cpufreq_qcom_hw_driver);
        if (ret)
                dev_err(&pdev->dev, "CPUFreq HW driver failed to register\n");
diff --combined drivers/opp/core.c
@@@ -118,7 -118,7 +118,7 @@@ EXPORT_SYMBOL_GPL(dev_pm_opp_get_voltag
   */
  unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
  {
 -      if (IS_ERR_OR_NULL(opp) || !opp->available) {
 +      if (IS_ERR_OR_NULL(opp)) {
                pr_err("%s: Invalid parameters\n", __func__);
                return 0;
        }
@@@ -831,6 -831,37 +831,37 @@@ static int _set_required_opps(struct de
        return ret;
  }
  
+ /**
+  * dev_pm_opp_set_bw() - sets bandwidth levels corresponding to an opp
+  * @dev:      device for which we do this operation
+  * @opp:      opp based on which the bandwidth levels are to be configured
+  *
+  * This configures the bandwidth to the levels specified by the OPP. However
+  * if the OPP specified is NULL the bandwidth levels are cleared out.
+  *
+  * Return: 0 on success or a negative error value.
+  */
+ int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp)
+ {
+       struct opp_table *opp_table;
+       int ret;
+       opp_table = _find_opp_table(dev);
+       if (IS_ERR(opp_table)) {
+               dev_err(dev, "%s: device opp table doesn't exist\n", __func__);
+               return PTR_ERR(opp_table);
+       }
+       if (opp)
+               ret = _set_opp_bw(opp_table, opp, dev, false);
+       else
+               ret = _set_opp_bw(opp_table, NULL, dev, true);
+       dev_pm_opp_put_opp_table(opp_table);
+       return ret;
+ }
+ EXPORT_SYMBOL_GPL(dev_pm_opp_set_bw);
  /**
   * dev_pm_opp_set_rate() - Configure new OPP based on frequency
   * @dev:       device for which we do this operation
@@@ -2271,7 -2302,6 +2302,7 @@@ adjust_put_table
        dev_pm_opp_put_opp_table(opp_table);
        return r;
  }
 +EXPORT_SYMBOL_GPL(dev_pm_opp_adjust_voltage);
  
  /**
   * dev_pm_opp_enable() - Enable a specific OPP
diff --combined include/linux/cpufreq.h
@@@ -127,7 -127,7 +127,7 @@@ struct cpufreq_policy 
  
         /* Cached frequency lookup from cpufreq_driver_resolve_freq. */
        unsigned int cached_target_freq;
-       int cached_resolved_idx;
+       unsigned int cached_resolved_idx;
  
        /* Synchronization for frequency transitions */
        bool                    transition_ongoing; /* Tracks transition status */
@@@ -577,20 -577,6 +577,20 @@@ unsigned int cpufreq_policy_transition_
  int cpufreq_register_governor(struct cpufreq_governor *governor);
  void cpufreq_unregister_governor(struct cpufreq_governor *governor);
  
 +#define cpufreq_governor_init(__governor)                     \
 +static int __init __governor##_init(void)                     \
 +{                                                             \
 +      return cpufreq_register_governor(&__governor);  \
 +}                                                             \
 +core_initcall(__governor##_init)
 +
 +#define cpufreq_governor_exit(__governor)                     \
 +static void __exit __governor##_exit(void)                    \
 +{                                                             \
 +      return cpufreq_unregister_governor(&__governor);        \
 +}                                                             \
 +module_exit(__governor##_exit)
 +
  struct cpufreq_governor *cpufreq_default_governor(void);
  struct cpufreq_governor *cpufreq_fallback_governor(void);
  
diff --combined include/linux/pm_opp.h
@@@ -11,7 -11,6 +11,7 @@@
  #ifndef __LINUX_OPP_H__
  #define __LINUX_OPP_H__
  
 +#include <linux/energy_model.h>
  #include <linux/err.h>
  #include <linux/notifier.h>
  
@@@ -152,6 -151,7 +152,7 @@@ struct opp_table *dev_pm_opp_attach_gen
  void dev_pm_opp_detach_genpd(struct opp_table *opp_table);
  int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate);
  int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq);
+ int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp);
  int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask);
  int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask);
  void dev_pm_opp_remove_table(struct device *dev);
@@@ -343,6 -343,11 +344,11 @@@ static inline int dev_pm_opp_set_rate(s
        return -ENOTSUPP;
  }
  
+ static inline int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp)
+ {
+       return -EOPNOTSUPP;
+ }
  static inline int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask)
  {
        return -ENOTSUPP;
@@@ -374,11 -379,7 +380,11 @@@ struct device_node *dev_pm_opp_of_get_o
  struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp);
  int of_get_required_opp_performance_state(struct device_node *np, int index);
  int dev_pm_opp_of_find_icc_paths(struct device *dev, struct opp_table *opp_table);
 -void dev_pm_opp_of_register_em(struct cpumask *cpus);
 +int dev_pm_opp_of_register_em(struct device *dev, struct cpumask *cpus);
 +static inline void dev_pm_opp_of_unregister_em(struct device *dev)
 +{
 +      em_dev_unregister_perf_domain(dev);
 +}
  #else
  static inline int dev_pm_opp_of_add_table(struct device *dev)
  {
@@@ -418,13 -419,7 +424,13 @@@ static inline struct device_node *dev_p
        return NULL;
  }
  
 -static inline void dev_pm_opp_of_register_em(struct cpumask *cpus)
 +static inline int dev_pm_opp_of_register_em(struct device *dev,
 +                                          struct cpumask *cpus)
 +{
 +      return -ENOTSUPP;
 +}
 +
 +static inline void dev_pm_opp_of_unregister_em(struct device *dev)
  {
  }