1. 24 8月, 2022 1 次提交
  2. 18 7月, 2022 1 次提交
  3. 16 7月, 2022 1 次提交
    • V
      cpufreq: Warn users while freeing active policy · a2f6a7ac
      Viresh Kumar 提交于
      With the new design in place, the show() and store() callbacks check if
      the policy is active or not before proceeding any further to avoid
      potential races. And in order to guarantee that cpufreq_policy_free()
      must be called after clearing the policy->cpus mask, i.e. by marking the
      policy inactive.
      
      In order to avoid introducing a bug around this later, print a warning
      message if we end up freeing an active policy.
      
      Also update cpufreq_online() a bit to make sure we clear the cpus mask
      for each error case before calling cpufreq_policy_free().
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      a2f6a7ac
  4. 14 6月, 2022 2 次提交
  5. 18 5月, 2022 2 次提交
  6. 12 5月, 2022 4 次提交
  7. 10 5月, 2022 1 次提交
  8. 07 5月, 2022 1 次提交
  9. 23 4月, 2022 1 次提交
    • schspa's avatar
      cpufreq: Fix possible race in cpufreq online error path · f346e962
      schspa 提交于
      When cpufreq online fails, the policy->cpus mask is not cleared and
      policy->rwsem is released too early, so the driver can be invoked
      via the cpuinfo_cur_freq sysfs attribute while its ->offline() or
      ->exit() callbacks are being run.
      
      Take policy->clk as an example:
      
      static int cpufreq_online(unsigned int cpu)
      {
        ...
        // policy->cpus != 0 at this time
        down_write(&policy->rwsem);
        ret = cpufreq_add_dev_interface(policy);
        up_write(&policy->rwsem);
      
        return 0;
      
      out_destroy_policy:
      	for_each_cpu(j, policy->real_cpus)
      		remove_cpu_dev_symlink(policy, get_cpu_device(j));
          up_write(&policy->rwsem);
      ...
      out_exit_policy:
        if (cpufreq_driver->exit)
          cpufreq_driver->exit(policy);
            clk_put(policy->clk);
            // policy->clk is a wild pointer
      ...
                                          ^
                                          |
                                  Another process access
                                  __cpufreq_get
                                    cpufreq_verify_current_freq
                                      cpufreq_generic_get
                                        // acces wild pointer of policy->clk;
                                          |
                                          |
      out_offline_policy:                 |
        cpufreq_policy_free(policy);      |
          // deleted here, and will wait for no body reference
          cpufreq_policy_put_kobj(policy);
      }
      
      Address this by modifying cpufreq_online() to release policy->rwsem
      in the error path after the driver callbacks have run and to clear
      policy->cpus before releasing the semaphore.
      
      Fixes: 7106e02b ("cpufreq: release policy->rwsem on error")
      Signed-off-by: schspa's avatarSchspa Shi <schspa@gmail.com>
      [ rjw: Subject and changelog edits ]
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      f346e962
  10. 09 2月, 2022 1 次提交
  11. 29 12月, 2021 1 次提交
  12. 17 12月, 2021 1 次提交
  13. 02 12月, 2021 2 次提交
  14. 05 10月, 2021 3 次提交
  15. 03 9月, 2021 1 次提交
  16. 12 8月, 2021 1 次提交
    • V
      cpufreq: Add callback to register with energy model · c17495b0
      Viresh Kumar 提交于
      Many cpufreq drivers register with the energy model for each policy and
      do exactly the same thing. Follow the footsteps of thermal-cooling, to
      get it done from the cpufreq core itself.
      
      Provide a new callback, which will be called, if present, by the cpufreq
      core at the right moment (more on that in the code's comment). Also
      provide a generic implementation that uses dev_pm_opp_of_register_em().
      
      This also allows us to register with the EM at a later point of time,
      compared to ->init(), from where the EM core can access cpufreq policy
      directly using cpufreq_cpu_get() type of helpers and perform other work,
      like marking few frequencies inefficient, this will be done separately.
      Reviewed-by: NQuentin Perret <qperret@google.com>
      Reviewed-by: NLukasz Luba <lukasz.luba@arm.com>
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      c17495b0
  17. 05 8月, 2021 1 次提交
  18. 01 7月, 2021 3 次提交
  19. 24 6月, 2021 1 次提交
  20. 09 4月, 2021 1 次提交
  21. 19 2月, 2021 1 次提交
  22. 05 2月, 2021 1 次提交
  23. 16 12月, 2020 1 次提交
    • R
      cpufreq: Add special-purpose fast-switching callback for drivers · ee2cc427
      Rafael J. Wysocki 提交于
      First off, some cpufreq drivers (eg. intel_pstate) can pass hints
      beyond the current target frequency to the hardware and there are no
      provisions for doing that in the cpufreq framework.  In particular,
      today the driver has to assume that it should not allow the frequency
      to fall below the one requested by the governor (or the required
      capacity may not be provided) which may not be the case and which may
      lead to excessive energy usage in some scenarios.
      
      Second, the hints passed by these drivers to the hardware need not be
      in terms of the frequency, so representing the utilization numbers
      coming from the scheduler as frequency before passing them to those
      drivers is not really useful.
      
      Address the two points above by adding a special-purpose replacement
      for the ->fast_switch callback, called ->adjust_perf, allowing the
      governor to pass abstract performance level (rather than frequency)
      values for the minimum (required) and target (desired) performance
      along with the CPU capacity to compare them to.
      
      Also update the schedutil governor to use the new callback instead
      of ->fast_switch if present and if the utilization mertics are
      frequency-invariant (that is requisite for the direct mapping
      between the utilization and the CPU performance levels to be a
      reasonable approximation).
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NViresh Kumar <viresh.kumar@linaro.org>
      ee2cc427
  24. 12 12月, 2020 2 次提交
  25. 11 11月, 2020 2 次提交
  26. 03 11月, 2020 1 次提交
  27. 29 10月, 2020 1 次提交
  28. 28 10月, 2020 1 次提交
    • R
      cpufreq: Introduce CPUFREQ_NEED_UPDATE_LIMITS driver flag · 1c534352
      Rafael J. Wysocki 提交于
      Generally, a cpufreq driver may need to update some internal upper
      and lower frequency boundaries on policy max and min changes,
      respectively, but currently this does not work if the target
      frequency does not change along with the policy limit.
      
      Namely, if the target frequency does not change along with the
      policy min or max, the "target_freq == policy->cur" check in
      __cpufreq_driver_target() prevents driver callbacks from being
      invoked and they do not even have a chance to update the
      corresponding internal boundary.
      
      This particularly affects the "powersave" and "performance"
      governors that always set the target frequency to one of the
      policy limits and it never changes when the other limit is updated.
      
      To allow cpufreq the drivers needing to update internal frequency
      boundaries on policy limits changes to avoid this issue, introduce
      a new driver flag, CPUFREQ_NEED_UPDATE_LIMITS, that (when set) will
      neutralize the check mentioned above.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NViresh Kumar <viresh.kumar@linaro.org>
      1c534352