1. 27 8月, 2020 1 次提交
  2. 11 8月, 2020 1 次提交
    • R
      cpufreq: intel_pstate: Implement passive mode with HWP enabled · f6ebbcf0
      Rafael J. Wysocki 提交于
      Allow intel_pstate to work in the passive mode with HWP enabled and
      make it set the HWP minimum performance limit (HWP floor) to the
      P-state value given by the target frequency supplied by the cpufreq
      governor, so as to prevent the HWP algorithm and the CPU scheduler
      from working against each other, at least when the schedutil governor
      is in use, and update the intel_pstate documentation accordingly.
      
      Among other things, this allows utilization clamps to be taken
      into account, at least to a certain extent, when intel_pstate is
      in use and makes it more likely that sufficient capacity for
      deadline tasks will be provided.
      
      After this change, the resulting behavior of an HWP system with
      intel_pstate in the passive mode should be close to the behavior
      of the analogous non-HWP system with intel_pstate in the passive
      mode, except that the HWP algorithm is generally allowed to make the
      CPU run at a frequency above the floor P-state set by intel_pstate in
      the entire available range of P-states, while without HWP a CPU can
      run in a P-state above the requested one if the latter falls into the
      range of turbo P-states (referred to as the turbo range) or if the
      P-states of all CPUs in one package are coordinated with each other
      at the hardware level.
      
      [Note that in principle the HWP floor may not be taken into account
       by the processor if it falls into the turbo range, in which case the
       processor has a license to choose any P-state, either below or above
       the HWP floor, just like a non-HWP processor in the case when the
       target P-state falls into the turbo range.]
      
      With this change applied, intel_pstate in the passive mode assumes
      complete control over the HWP request MSR and concurrent changes of
      that MSR (eg. via the direct MSR access interface) are overridden by
      it.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
      Reviewed-by: NFrancisco Jerez <currojerez@riseup.net>
      f6ebbcf0
  3. 30 7月, 2020 1 次提交
  4. 15 7月, 2020 1 次提交
    • L
      cpufreq: cpufreq: Demote lots of function headers unworthy of kerneldoc status · a9909c21
      Lee Jones 提交于
      Also provide missing function parameter description for 'cpu' and 'policy'.
      
      Fixes the following W=1 kernel build warning(s):
      
       drivers/cpufreq/cpufreq.c:60: warning: cannot understand function prototype: 'struct cpufreq_driver *cpufreq_driver; '
       drivers/cpufreq/cpufreq.c:90: warning: Function parameter or member 'cpufreq_policy_notifier_list' not described in 'BLOCKING_NOTIFIER_HEAD'
       drivers/cpufreq/cpufreq.c:312: warning: Function parameter or member 'val' not described in 'adjust_jiffies'
       drivers/cpufreq/cpufreq.c:312: warning: Function parameter or member 'ci' not described in 'adjust_jiffies'
       drivers/cpufreq/cpufreq.c:538: warning: Function parameter or member 'policy' not described in 'cpufreq_driver_resolve_freq'
       drivers/cpufreq/cpufreq.c:686: warning: Function parameter or member 'file_name' not described in 'show_one'
       drivers/cpufreq/cpufreq.c:686: warning: Function parameter or member 'object' not described in 'show_one'
       drivers/cpufreq/cpufreq.c:731: warning: Function parameter or member 'file_name' not described in 'store_one'
       drivers/cpufreq/cpufreq.c:731: warning: Function parameter or member 'object' not described in 'store_one'
       drivers/cpufreq/cpufreq.c:741: warning: Function parameter or member 'policy' not described in 'show_cpuinfo_cur_freq'
       drivers/cpufreq/cpufreq.c:741: warning: Function parameter or member 'buf' not described in 'show_cpuinfo_cur_freq'
       drivers/cpufreq/cpufreq.c:754: warning: Function parameter or member 'policy' not described in 'show_scaling_governor'
       drivers/cpufreq/cpufreq.c:754: warning: Function parameter or member 'buf' not described in 'show_scaling_governor'
       drivers/cpufreq/cpufreq.c:770: warning: Function parameter or member 'policy' not described in 'store_scaling_governor'
       drivers/cpufreq/cpufreq.c:770: warning: Function parameter or member 'buf' not described in 'store_scaling_governor'
       drivers/cpufreq/cpufreq.c:770: warning: Function parameter or member 'count' not described in 'store_scaling_governor'
       drivers/cpufreq/cpufreq.c:806: warning: Function parameter or member 'policy' not described in 'show_scaling_driver'
       drivers/cpufreq/cpufreq.c:806: warning: Function parameter or member 'buf' not described in 'show_scaling_driver'
       drivers/cpufreq/cpufreq.c:815: warning: Function parameter or member 'policy' not described in 'show_scaling_available_governors'
       drivers/cpufreq/cpufreq.c:815: warning: Function parameter or member 'buf' not described in 'show_scaling_available_governors'
       drivers/cpufreq/cpufreq.c:859: warning: Function parameter or member 'policy' not described in 'show_related_cpus'
       drivers/cpufreq/cpufreq.c:859: warning: Function parameter or member 'buf' not described in 'show_related_cpus'
       drivers/cpufreq/cpufreq.c:867: warning: Function parameter or member 'policy' not described in 'show_affected_cpus'
       drivers/cpufreq/cpufreq.c:867: warning: Function parameter or member 'buf' not described in 'show_affected_cpus'
       drivers/cpufreq/cpufreq.c:901: warning: Function parameter or member 'policy' not described in 'show_bios_limit'
       drivers/cpufreq/cpufreq.c:901: warning: Function parameter or member 'buf' not described in 'show_bios_limit'
       drivers/cpufreq/cpufreq.c:1625: warning: Function parameter or member 'dev' not described in 'cpufreq_remove_dev'
       drivers/cpufreq/cpufreq.c:1625: warning: Function parameter or member 'sif' not described in 'cpufreq_remove_dev'
       drivers/cpufreq/cpufreq.c:2380: warning: Function parameter or member 'cpu' not described in 'cpufreq_get_policy'
       drivers/cpufreq/cpufreq.c:2771: warning: Function parameter or member 'driver' not described in 'cpufreq_unregister_driver'
      Signed-off-by: NLee Jones <lee.jones@linaro.org>
      Acked-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      a9909c21
  5. 02 7月, 2020 3 次提交
    • V
      cpufreq: Remove the weakly defined cpufreq_default_governor() · 3a7e4fbb
      Viresh Kumar 提交于
      The default cpufreq governor is chosen with the help of a "choice"
      option in the Kconfig which will always end up selecting one of
      the governors and so the weakly defined definition of
      cpufreq_default_governor() will never get called.
      
      Moreover, this makes us skip the checking of the return value of
      that routine as it will always be non NULL.
      
      If the Kconfig option changes in future, then we will start getting
      a link error instead (and it won't go unnoticed as in the case of the
      weak definition).
      Suggested-by: NQuentin Perret <qperret@google.com>
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      3a7e4fbb
    • Q
      cpufreq: Specify default governor on command line · 8412b456
      Quentin Perret 提交于
      Currently, the only way to specify the default CPUfreq governor is
      via Kconfig options, which suits users who can build the kernel
      themselves perfectly.
      
      However, for those who use a distro-like kernel (such as Android,
      with the Generic Kernel Image project), the only way to use a
      non-default governor is to boot to userspace, and to then switch
      using the sysfs interface. Being able to specify the default governor
      on the command line, like is the case for cpuidle, would allow those
      users to specify their governor of choice earlier on, and to simplify
      the userspace boot procedure slighlty.
      
      To support this use-case, add a kernel command line parameter
      allowing the default governor for CPUfreq to be specified, which
      takes precedence over the built-in default.
      
      This implementation has one notable limitation: the default governor
      must be registered before the driver. This is solved for builtin
      governors and drivers using appropriate *_initcall() functions. And
      in the modular case, this must be reflected as a constraint on the
      module loading order.
      Signed-off-by: NQuentin Perret <qperret@google.com>
      [ Viresh: Converted 'default_governor' to a string and parsing it only
      	  at initcall level, and several updates to
      	  cpufreq_init_policy(). ]
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      [ rjw: Changelog ]
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      8412b456
    • V
      cpufreq: Fix locking issues with governors · 8cc46ae5
      Viresh Kumar 提交于
      The locking around governors handling isn't adequate currently.
      
      The list of governors should never be traversed without the locking
      in place. Also governor modules must not be removed while the code
      in them is still in use.
      Reported-by: NQuentin Perret <qperret@google.com>
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Cc: All applicable <stable@vger.kernel.org>
      [ rjw: Changelog ]
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      8cc46ae5
  6. 05 6月, 2020 1 次提交
  7. 18 5月, 2020 1 次提交
  8. 07 3月, 2020 1 次提交
  9. 27 2月, 2020 1 次提交
  10. 03 2月, 2020 1 次提交
  11. 27 1月, 2020 1 次提交
    • R
      cpufreq: Avoid creating excessively large stack frames · 1e4f63ae
      Rafael J. Wysocki 提交于
      In the process of modifying a cpufreq policy, the cpufreq core makes
      a copy of it including all of the internals which is stored on the
      CPU stack.  Because struct cpufreq_policy is relatively large, this
      may cause the size of the stack frame to exceed the 2 KB limit and
      so the GCC complains when -Wframe-larger-than= is used.
      
      In fact, it is not necessary to copy the entire policy structure
      in order to modify it, however.
      
      First, because cpufreq_set_policy() obtains the min and max policy
      limits from frequency QoS now, it is not necessary to pass the limits
      to it from the callers.  The only things that need to be passed to it
      from there are the new governor pointer or (if there is a built-in
      governor in the driver) the "policy" value representing the governor
      choice.  They both can be passed as individual arguments, though, so
      make cpufreq_set_policy() take them this way and rework its callers
      accordingly.  This avoids making copies of cpufreq policies in the
      callers of cpufreq_set_policy().
      
      Second, cpufreq_set_policy() still needs to pass the new policy
      data to the ->verify() callback of the cpufreq driver whose task
      is to sanitize the min and max policy limits.  It still does not
      need to make a full copy of struct cpufreq_policy for this purpose,
      but it needs to pass a few items from it to the driver in case they
      are needed (different drivers have different needs in that respect
      and all of them have to be covered).  For this reason, introduce
      struct cpufreq_policy_data to hold copies of the members of
      struct cpufreq_policy used by the existing ->verify() driver
      callbacks and pass a pointer to a temporary structure of that
      type to ->verify() (instead of passing a pointer to full struct
      cpufreq_policy to it).
      
      While at it, notice that intel_pstate and longrun don't really need
      to verify the "policy" value in struct cpufreq_policy, so drop those
      check from them to avoid copying "policy" into struct
      cpufreq_policy_data (which allows it to be slightly smaller).
      
      Also while at it fix up white space in a couple of places and make
      cpufreq_set_policy() static (as it can be so).
      
      Fixes: 3000ce3c ("cpufreq: Use per-policy frequency QoS")
      Link: https://lore.kernel.org/linux-pm/CAMuHMdX6-jb1W8uC2_237m8ctCpsnGp=JCxqt8pCWVqNXHmkVg@mail.gmail.comReported-by: Nkbuild test robot <lkp@intel.com>
      Reported-by: NGeert Uytterhoeven <geert@linux-m68k.org>
      Cc: 5.4+ <stable@vger.kernel.org> # 5.4+
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NViresh Kumar <viresh.kumar@linaro.org>
      1e4f63ae
  12. 21 11月, 2019 1 次提交
  13. 14 11月, 2019 1 次提交
  14. 08 11月, 2019 1 次提交
  15. 04 11月, 2019 1 次提交
  16. 29 10月, 2019 1 次提交
  17. 23 10月, 2019 1 次提交
    • S
      cpufreq: Cancel policy update work scheduled before freeing · 6941051d
      Sudeep Holla 提交于
      Scheduled policy update work may end up racing with the freeing of the
      policy and unregistering the driver.
      
      One possible race is as below, where the cpufreq_driver is unregistered,
      but the scheduled work gets executed at later stage when, cpufreq_driver
      is NULL (i.e. after freeing the policy and driver).
      
      Unable to handle kernel NULL pointer dereference at virtual address 0000001c
      pgd = (ptrval)
      [0000001c] *pgd=80000080204003, *pmd=00000000
      Internal error: Oops: 206 [#1] SMP THUMB2
      Modules linked in:
      CPU: 0 PID: 34 Comm: kworker/0:1 Not tainted 5.4.0-rc3-00006-g67f5a8081a4b #86
      Hardware name: ARM-Versatile Express
      Workqueue: events handle_update
      PC is at cpufreq_set_policy+0x58/0x228
      LR is at dev_pm_qos_read_value+0x77/0xac
      Control: 70c5387d  Table: 80203000  DAC: fffffffd
      Process kworker/0:1 (pid: 34, stack limit = 0x(ptrval))
      	(cpufreq_set_policy) from (refresh_frequency_limits.part.24+0x37/0x48)
      	(refresh_frequency_limits.part.24) from (handle_update+0x2f/0x38)
      	(handle_update) from (process_one_work+0x16d/0x3cc)
      	(process_one_work) from (worker_thread+0xff/0x414)
      	(worker_thread) from (kthread+0xff/0x100)
      	(kthread) from (ret_from_fork+0x11/0x28)
      
      Fixes: 67d874c3 ("cpufreq: Register notifiers with the PM QoS framework")
      Signed-off-by: NSudeep Holla <sudeep.holla@arm.com>
      [ rjw: Cancel the work before dropping the QoS requests ]
      Acked-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      6941051d
  18. 21 10月, 2019 1 次提交
  19. 10 10月, 2019 1 次提交
    • R
      cpufreq: Avoid cpufreq_suspend() deadlock on system shutdown · 65650b35
      Rafael J. Wysocki 提交于
      It is incorrect to set the cpufreq syscore shutdown callback pointer
      to cpufreq_suspend(), because that function cannot be run in the
      syscore stage of system shutdown for two reasons: (a) it may attempt
      to carry out actions depending on devices that have already been shut
      down at that point and (b) the RCU synchronization carried out by it
      may not be able to make progress then.
      
      The latter issue has been present since commit 45975c7d ("rcu:
      Define RCU-sched API in terms of RCU for Tree RCU PREEMPT builds"),
      but the former one has been there since commit 90de2a4a ("cpufreq:
      suspend cpufreq governors on shutdown") regardless.
      
      Fix that by dropping cpufreq_syscore_ops altogether and making
      device_shutdown() call cpufreq_suspend() directly before shutting
      down devices, which is along the lines of what system-wide power
      management does.
      
      Fixes: 45975c7d ("rcu: Define RCU-sched API in terms of RCU for Tree RCU PREEMPT builds")
      Fixes: 90de2a4a ("cpufreq: suspend cpufreq governors on shutdown")
      Reported-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Tested-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NViresh Kumar <viresh.kumar@linaro.org>
      Cc: 4.0+ <stable@vger.kernel.org> # 4.0+
      65650b35
  20. 03 9月, 2019 1 次提交
  21. 22 8月, 2019 1 次提交
  22. 21 8月, 2019 1 次提交
  23. 10 8月, 2019 2 次提交
  24. 16 7月, 2019 1 次提交
  25. 09 7月, 2019 3 次提交
  26. 28 6月, 2019 3 次提交
    • V
      cpufreq: Avoid calling cpufreq_verify_current_freq() from handle_update() · 70a59fde
      Viresh Kumar 提交于
      On some occasions cpufreq_verify_current_freq() schedules a work whose
      callback is handle_update(), which further calls cpufreq_update_policy()
      which may end up calling cpufreq_verify_current_freq() again.
      
      On the other hand, when cpufreq_update_policy() is called from
      handle_update(), the pointer to the cpufreq policy is already
      available, but cpufreq_cpu_acquire() is still called to get it in
      cpufreq_update_policy(), which should be avoided as well.
      
      To fix these issues, create a new helper, refresh_frequency_limits(),
      and make both handle_update() call it cpufreq_update_policy().
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      [ rjw: Rename reeval_frequency_limits() as refresh_frequency_limits() ]
      [ rjw: Changelog ]
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      70a59fde
    • V
      cpufreq: Consolidate cpufreq_update_current_freq() and __cpufreq_get() · 5980752e
      Viresh Kumar 提交于
      Their implementations are quite similar, so modify
      cpufreq_update_current_freq() somewhat and call it from
      __cpufreq_get().
      
      Also rename cpufreq_update_current_freq() to
      cpufreq_verify_current_freq(), as that's what it is doing.
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      [ rjw: Subject & changelog ]
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      5980752e
    • V
      cpufreq: Don't skip frequency validation for has_target() drivers · 98015228
      Viresh Kumar 提交于
      CPUFREQ_CONST_LOOPS was introduced in a very old commit from pre-2.6
      kernel release by commit 6a4a93f9c0d5 ("[CPUFREQ] Fix 'out of sync'
      issue").
      
      Basically, that commit does two things:
      
       - It adds the frequency verification code (which is quite similar to
         what we have today as well).
      
       - And it sets the CPUFREQ_CONST_LOOPS flag only for setpolicy drivers,
         rightly so based on the code we had then. The idea was to avoid
         frequency validation for setpolicy drivers as the cpufreq core doesn't
         know what frequency the hardware is running at and so no point in
         doing frequency verification.
      
      The problem happened when we started to use the same CPUFREQ_CONST_LOOPS
      flag for constant loops-per-jiffy thing as well and many has_target()
      drivers started using the same flag and unknowingly skipped the
      verification of frequency. There is no logical reason behind skipping
      frequency validation because of the presence of CPUFREQ_CONST_LOOPS
      flag otherwise.
      
      Fix this issue by skipping frequency validation only for setpolicy
      drivers and always doing it for has_target() drivers irrespective of
      the presence or absence of CPUFREQ_CONST_LOOPS flag.
      
      cpufreq_notify_transition() is only called for has_target() type driver
      and not for set_policy type, and the check is simply redundant. Remove
      it as well.
      
      Also remove () around freq comparison statement as they aren't required
      and checkpatch also warns for them.
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      98015228
  27. 26 6月, 2019 3 次提交
  28. 19 6月, 2019 1 次提交
  29. 13 5月, 2019 2 次提交
  30. 10 5月, 2019 1 次提交
    • V
      cpufreq: Call transition notifier only once for each policy · df24014a
      Viresh Kumar 提交于
      Currently, the notifiers are called once for each CPU of the policy->cpus
      cpumask. It would be more optimal if the notifier can be called only
      once and all the relevant information be provided to it. Out of the 23
      drivers that register for the transition notifiers today, only 4 of them
      do per-cpu updates and the callback for the rest can be called only once
      for the policy without any impact.
      
      This would also avoid multiple function calls to the notifier callbacks
      and reduce multiple iterations of notifier core's code (which does
      locking as well).
      
      This patch adds pointer to the cpufreq policy to the struct
      cpufreq_freqs, so the notifier callback has all the information
      available to it with a single call. The five drivers which perform
      per-cpu updates are updated to use the cpufreq policy. The freqs->cpu
      field is redundant now and is removed.
      
      Acked-by: David S. Miller <davem@davemloft.net> (sparc)
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      df24014a