1. 27 3月, 2020 1 次提交
    • R
      cpufreq: intel_pstate: Simplify intel_pstate_cpu_init() · 5ac54113
      Rafael J. Wysocki 提交于
      The initial policy value set by intel_pstate_cpu_init() depends on
      whether or not CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is set, but
      that is not necessary, because the core will set the policy to
      "performance" in cpufreq_init_policy() if the default governor is
      "performance" anyway.
      
      Accordingly, change intel_pstate_cpu_init() to always set policy
      to CPUFREQ_POLICY_POWERSAVE initially to provide a valid fallback
      value to cpufreq_init_policy() in case the default cpufreq governor
      is neither "powersave" nor "performance".
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      5ac54113
  2. 25 3月, 2020 2 次提交
  3. 14 3月, 2020 1 次提交
  4. 29 1月, 2020 1 次提交
  5. 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
  6. 13 1月, 2020 1 次提交
  7. 08 11月, 2019 1 次提交
  8. 06 11月, 2019 1 次提交
  9. 21 10月, 2019 1 次提交
  10. 28 8月, 2019 4 次提交
  11. 21 8月, 2019 1 次提交
    • V
      cpufreq: intel_pstate: Implement QoS supported freq constraints · da5c504c
      Viresh Kumar 提交于
      Intel pstate driver exposes min_perf_pct and max_perf_pct sysfs files,
      which can be used to force a limit on the min/max P state of the driver.
      Though these files eventually control the min/max frequencies that the
      CPUs will run at, they don't make a change to policy->min/max values.
      
      When the values of these files are changed (in passive mode of the
      driver), it leads to calling ->limits() callback of the cpufreq
      governors, like schedutil. On a call to it the governors shall
      forcefully update the frequency to come within the limits. Since the
      limits, i.e.  policy->min/max, aren't updated by the driver, the
      governors fails to get the target freq within limit and sometimes aborts
      the update believing that the frequency is already set to the target
      value.
      
      This patch implements the QoS supported frequency constraints to update
      policy->min/max values whenever min_perf_pct or max_perf_pct files are
      updated. This is only done for the passive mode as of now, as the driver
      is already working fine in active mode.
      
      Fixes: ecd28842 ("cpufreq: schedutil: Don't set next_freq to UINT_MAX")
      Reported-by: NDoug Smythies <dsmythies@telus.net>
      Tested-by: NDoug Smythies <dsmythies@telus.net>
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      da5c504c
  12. 09 7月, 2019 1 次提交
  13. 05 6月, 2019 1 次提交
  14. 08 4月, 2019 2 次提交
  15. 02 4月, 2019 2 次提交
  16. 26 3月, 2019 1 次提交
  17. 12 3月, 2019 1 次提交
    • R
      cpufreq: intel_pstate: Fix up iowait_boost computation · 8e3b4039
      Rafael J. Wysocki 提交于
      After commit b8bd1581 ("cpufreq: intel_pstate: Rework iowait
      boosting to be less aggressive") the handling of the case when
      the SCHED_CPUFREQ_IOWAIT flag is set again after a few iterations of
      intel_pstate_update_util() is a bit inconsistent, because the
      new value of cpu->iowait_boost may be lower than ONE_EIGHTH_FP
      if it was set before, but has not dropped down to zero just yet.
      
      Fix that up by ensuring that the new value of cpu->iowait_boost
      will always be at least ONE_EIGHTH_FP then.
      
      Fixes: b8bd1581 ("cpufreq: intel_pstate: Rework iowait boosting to be less aggressive")
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      8e3b4039
  18. 18 2月, 2019 3 次提交
  19. 13 2月, 2019 1 次提交
    • E
      cpufreq: intel_pstate: Add reasons for failure and debug messages · 076b862c
      Erwan Velu 提交于
      The init code path has several exceptions where the driver can
      decide not to load.
      
      As CONFIG_X86_INTEL_PSTATE is generally set to Y, the return code is
      not reachable.  The initialization code is neither verbose of the
      reason why it did choose to prematurely exit, so it is difficult for
      a user to determine, on a given platform, why the driver didn't load
      properly.
      
      This patch is about reporting to the user the reason/context of why
      the driver failed to load.  That is a precious hint when debugging
      a platform.
      Signed-off-by: NErwan Velu <e.velu@criteo.com>
      [ rjw: Subject & changelog, minor fixups ]
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      076b862c
  20. 29 1月, 2019 1 次提交
    • V
      cpufreq: Use struct kobj_attribute instead of struct global_attr · 625c85a6
      Viresh Kumar 提交于
      The cpufreq_global_kobject is created using kobject_create_and_add()
      helper, which assigns the kobj_type as dynamic_kobj_ktype and show/store
      routines are set to kobj_attr_show() and kobj_attr_store().
      
      These routines pass struct kobj_attribute as an argument to the
      show/store callbacks. But all the cpufreq files created using the
      cpufreq_global_kobject expect the argument to be of type struct
      attribute. Things work fine currently as no one accesses the "attr"
      argument. We may not see issues even if the argument is used, as struct
      kobj_attribute has struct attribute as its first element and so they
      will both get same address.
      
      But this is logically incorrect and we should rather use struct
      kobj_attribute instead of struct global_attr in the cpufreq core and
      drivers and the show/store callbacks should take struct kobj_attribute
      as argument instead.
      
      This bug is caught using CFI CLANG builds in android kernel which
      catches mismatch in function prototypes for such callbacks.
      Reported-by: NDonghee Han <dh.han@samsung.com>
      Reported-by: NSangkyu Kim <skwith.kim@samsung.com>
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      625c85a6
  21. 30 11月, 2018 1 次提交
  22. 28 11月, 2018 1 次提交
  23. 26 10月, 2018 1 次提交
  24. 16 10月, 2018 1 次提交
  25. 02 10月, 2018 1 次提交
    • P
      x86/cpu: Sanitize FAM6_ATOM naming · f2c4db1b
      Peter Zijlstra 提交于
      Going primarily by:
      
        https://en.wikipedia.org/wiki/List_of_Intel_Atom_microprocessors
      
      with additional information gleaned from other related pages; notably:
      
       - Bonnell shrink was called Saltwell
       - Moorefield is the Merriefield refresh which makes it Airmont
      
      The general naming scheme is: FAM6_ATOM_UARCH_SOCTYPE
      
        for i in `git grep -l FAM6_ATOM` ; do
      	sed -i  -e 's/ATOM_PINEVIEW/ATOM_BONNELL/g'		\
      		-e 's/ATOM_LINCROFT/ATOM_BONNELL_MID/'		\
      		-e 's/ATOM_PENWELL/ATOM_SALTWELL_MID/g'		\
      		-e 's/ATOM_CLOVERVIEW/ATOM_SALTWELL_TABLET/g'	\
      		-e 's/ATOM_CEDARVIEW/ATOM_SALTWELL/g'		\
      		-e 's/ATOM_SILVERMONT1/ATOM_SILVERMONT/g'	\
      		-e 's/ATOM_SILVERMONT2/ATOM_SILVERMONT_X/g'	\
      		-e 's/ATOM_MERRIFIELD/ATOM_SILVERMONT_MID/g'	\
      		-e 's/ATOM_MOOREFIELD/ATOM_AIRMONT_MID/g'	\
      		-e 's/ATOM_DENVERTON/ATOM_GOLDMONT_X/g'		\
      		-e 's/ATOM_GEMINI_LAKE/ATOM_GOLDMONT_PLUS/g' ${i}
        done
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: dave.hansen@linux.intel.com
      Cc: len.brown@intel.com
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      f2c4db1b
  26. 06 8月, 2018 1 次提交
  27. 31 7月, 2018 1 次提交
  28. 19 7月, 2018 1 次提交
    • S
      cpufreq: intel_pstate: Show different max frequency with turbo 3 and HWP · eea033d0
      Srinivas Pandruvada 提交于
      On HWP platforms with Turbo 3.0, the HWP capability max ratio shows the
      maximum ratio of that core, which can be different than other cores. If
      we show the correct maximum frequency in cpufreq sysfs via
      cpuinfo_max_freq and scaling_max_freq then, user can know which cores
      can run faster for pinning some high priority tasks.
      
      Currently the max turbo frequency is shown as max frequency, which is
      the max of all cores, even if some cores can't reach that frequency
      even for single threaded workload.
      
      But it is possible that max ratio in HWP capabilities is set as 0xFF or
      some high invalid value (E.g. One KBL NUC). Since the actual performance
      can never exceed 1 core turbo frequency from MSR TURBO_RATIO_LIMIT, we
      use this as a bound check.
      Signed-off-by: NSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      eea033d0
  29. 18 7月, 2018 1 次提交
  30. 02 7月, 2018 1 次提交
  31. 19 6月, 2018 1 次提交
    • S
      cpufreq: intel_pstate: Fix scaling max/min limits with Turbo 3.0 · ff7c9917
      Srinivas Pandruvada 提交于
      When scaling max/min settings are changed, internally they are converted
      to a ratio using the max turbo 1 core turbo frequency. This works fine
      when 1 core max is same irrespective of the core. But under Turbo 3.0,
      this will not be the case. For example:
      Core 0: max turbo pstate: 43 (4.3GHz)
      Core 1: max turbo pstate: 45 (4.5GHz)
      In this case 1 core turbo ratio will be maximum of all, so it will be
      45 (4.5GHz). Suppose scaling max is set to 4GHz (ratio 40) for all cores
      ,then on core one it will be
       = max_state * policy->max / max_freq;
       = 43 * (4000000/4500000) = 38 (3.8GHz)
       = 38
      which is 200MHz less than the desired.
      On core2, it will be correctly set to ratio 40 (4GHz). Same holds true
      for scaling min frequency limit. So this requires usage of correct turbo
      max frequency for core one, which in this case is 4.3GHz. So we need to
      adjust per CPU cpu->pstate.turbo_freq using the maximum HWP ratio of that
      core.
      
      This change uses the HWP capability of a core to adjust max turbo
      frequency. But since Broadwell HWP doesn't use ratios in the HWP
      capabilities, we have to use legacy max 1 core turbo ratio. This is not
      a problem as the HWP capabilities don't differ among cores in Broadwell.
      We need to check for non Broadwell CPU model for applying this change,
      though.
      Signed-off-by: NSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
      Cc: 4.6+ <stable@vger.kernel.org> # 4.6+
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      ff7c9917
  32. 13 6月, 2018 1 次提交
    • K
      treewide: Use array_size() in vzalloc() · fad953ce
      Kees Cook 提交于
      The vzalloc() function has no 2-factor argument form, so multiplication
      factors need to be wrapped in array_size(). This patch replaces cases of:
      
              vzalloc(a * b)
      
      with:
              vzalloc(array_size(a, b))
      
      as well as handling cases of:
      
              vzalloc(a * b * c)
      
      with:
      
              vzalloc(array3_size(a, b, c))
      
      This does, however, attempt to ignore constant size factors like:
      
              vzalloc(4 * 1024)
      
      though any constants defined via macros get caught up in the conversion.
      
      Any factors with a sizeof() of "unsigned char", "char", and "u8" were
      dropped, since they're redundant.
      
      The Coccinelle script used for this was:
      
      // Fix redundant parens around sizeof().
      @@
      type TYPE;
      expression THING, E;
      @@
      
      (
        vzalloc(
      -	(sizeof(TYPE)) * E
      +	sizeof(TYPE) * E
        , ...)
      |
        vzalloc(
      -	(sizeof(THING)) * E
      +	sizeof(THING) * E
        , ...)
      )
      
      // Drop single-byte sizes and redundant parens.
      @@
      expression COUNT;
      typedef u8;
      typedef __u8;
      @@
      
      (
        vzalloc(
      -	sizeof(u8) * (COUNT)
      +	COUNT
        , ...)
      |
        vzalloc(
      -	sizeof(__u8) * (COUNT)
      +	COUNT
        , ...)
      |
        vzalloc(
      -	sizeof(char) * (COUNT)
      +	COUNT
        , ...)
      |
        vzalloc(
      -	sizeof(unsigned char) * (COUNT)
      +	COUNT
        , ...)
      |
        vzalloc(
      -	sizeof(u8) * COUNT
      +	COUNT
        , ...)
      |
        vzalloc(
      -	sizeof(__u8) * COUNT
      +	COUNT
        , ...)
      |
        vzalloc(
      -	sizeof(char) * COUNT
      +	COUNT
        , ...)
      |
        vzalloc(
      -	sizeof(unsigned char) * COUNT
      +	COUNT
        , ...)
      )
      
      // 2-factor product with sizeof(type/expression) and identifier or constant.
      @@
      type TYPE;
      expression THING;
      identifier COUNT_ID;
      constant COUNT_CONST;
      @@
      
      (
        vzalloc(
      -	sizeof(TYPE) * (COUNT_ID)
      +	array_size(COUNT_ID, sizeof(TYPE))
        , ...)
      |
        vzalloc(
      -	sizeof(TYPE) * COUNT_ID
      +	array_size(COUNT_ID, sizeof(TYPE))
        , ...)
      |
        vzalloc(
      -	sizeof(TYPE) * (COUNT_CONST)
      +	array_size(COUNT_CONST, sizeof(TYPE))
        , ...)
      |
        vzalloc(
      -	sizeof(TYPE) * COUNT_CONST
      +	array_size(COUNT_CONST, sizeof(TYPE))
        , ...)
      |
        vzalloc(
      -	sizeof(THING) * (COUNT_ID)
      +	array_size(COUNT_ID, sizeof(THING))
        , ...)
      |
        vzalloc(
      -	sizeof(THING) * COUNT_ID
      +	array_size(COUNT_ID, sizeof(THING))
        , ...)
      |
        vzalloc(
      -	sizeof(THING) * (COUNT_CONST)
      +	array_size(COUNT_CONST, sizeof(THING))
        , ...)
      |
        vzalloc(
      -	sizeof(THING) * COUNT_CONST
      +	array_size(COUNT_CONST, sizeof(THING))
        , ...)
      )
      
      // 2-factor product, only identifiers.
      @@
      identifier SIZE, COUNT;
      @@
      
        vzalloc(
      -	SIZE * COUNT
      +	array_size(COUNT, SIZE)
        , ...)
      
      // 3-factor product with 1 sizeof(type) or sizeof(expression), with
      // redundant parens removed.
      @@
      expression THING;
      identifier STRIDE, COUNT;
      type TYPE;
      @@
      
      (
        vzalloc(
      -	sizeof(TYPE) * (COUNT) * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        vzalloc(
      -	sizeof(TYPE) * (COUNT) * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        vzalloc(
      -	sizeof(TYPE) * COUNT * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        vzalloc(
      -	sizeof(TYPE) * COUNT * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        vzalloc(
      -	sizeof(THING) * (COUNT) * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        vzalloc(
      -	sizeof(THING) * (COUNT) * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        vzalloc(
      -	sizeof(THING) * COUNT * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        vzalloc(
      -	sizeof(THING) * COUNT * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      )
      
      // 3-factor product with 2 sizeof(variable), with redundant parens removed.
      @@
      expression THING1, THING2;
      identifier COUNT;
      type TYPE1, TYPE2;
      @@
      
      (
        vzalloc(
      -	sizeof(TYPE1) * sizeof(TYPE2) * COUNT
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
        , ...)
      |
        vzalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
        , ...)
      |
        vzalloc(
      -	sizeof(THING1) * sizeof(THING2) * COUNT
      +	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
        , ...)
      |
        vzalloc(
      -	sizeof(THING1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
        , ...)
      |
        vzalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * COUNT
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
        , ...)
      |
        vzalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
        , ...)
      )
      
      // 3-factor product, only identifiers, with redundant parens removed.
      @@
      identifier STRIDE, SIZE, COUNT;
      @@
      
      (
        vzalloc(
      -	(COUNT) * STRIDE * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        vzalloc(
      -	COUNT * (STRIDE) * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        vzalloc(
      -	COUNT * STRIDE * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        vzalloc(
      -	(COUNT) * (STRIDE) * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        vzalloc(
      -	COUNT * (STRIDE) * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        vzalloc(
      -	(COUNT) * STRIDE * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        vzalloc(
      -	(COUNT) * (STRIDE) * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        vzalloc(
      -	COUNT * STRIDE * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      )
      
      // Any remaining multi-factor products, first at least 3-factor products
      // when they're not all constants...
      @@
      expression E1, E2, E3;
      constant C1, C2, C3;
      @@
      
      (
        vzalloc(C1 * C2 * C3, ...)
      |
        vzalloc(
      -	E1 * E2 * E3
      +	array3_size(E1, E2, E3)
        , ...)
      )
      
      // And then all remaining 2 factors products when they're not all constants.
      @@
      expression E1, E2;
      constant C1, C2;
      @@
      
      (
        vzalloc(C1 * C2, ...)
      |
        vzalloc(
      -	E1 * E2
      +	array_size(E1, E2)
        , ...)
      )
      Signed-off-by: NKees Cook <keescook@chromium.org>
      fad953ce