1. May 20, 2022
    • Pierre Gondois's avatar
      cpufreq: CPPC: Enable fast_switch · 3cc30dd0
      Pierre Gondois authored
      The communication mean of the _CPC desired performance can be
      PCC, System Memory, System IO, or Functional Fixed Hardware.
      
      commit b7898fda
      
       ("cpufreq: Support for fast frequency switching")
      fast_switching is 'for switching CPU frequencies from interrupt
      context'.
      Writes to SystemMemory and SystemIo are fast and suitable this.
      This is not the case for PCC and might not be the case for FFH.
      
      Enable fast_switching for the cppc_cpufreq driver in above cases.
      
      Add cppc_allow_fast_switch() to check the desired performance
      register address space and set fast_switching accordingly.
      
      Signed-off-by: default avatarPierre Gondois <pierre.gondois@arm.com>
      Reviewed-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      3cc30dd0
    • Pierre Gondois's avatar
      ACPI: CPPC: Assume no transition latency if no PCCT · 6380b7b2
      Pierre Gondois authored
      The transition_delay_us (struct cpufreq_policy) is currently defined
      as:
        Preferred average time interval between consecutive invocations of
        the driver to set the frequency for this policy.  To be set by the
        scaling driver (0, which is the default, means no preference).
      The transition_latency represents the amount of time necessary for a
      CPU to change its frequency.
      
      A PCCT table advertises mutliple values:
      - pcc_nominal: Expected latency to process a command, in microseconds
      - pcc_mpar: The maximum number of periodic requests that the subspace
        channel can support, reported in commands per minute. 0 indicates no
        limitation.
      - pcc_mrtt: The minimum amount of time that OSPM must wait after the
        completion of a command before issuing the next command,
        in microseconds.
      cppc_get_transition_latency() allows to get the max of them.
      
      commit d4f3388a
      
       ("cpufreq / CPPC: Set platform specific
      transition_delay_us") allows to select transition_delay_us based on
      the platform, and fallbacks to cppc_get_transition_latency()
      otherwise.
      
      If _CPC objects are not using PCC channels (no PPCT table), the
      transition_delay_us is set to CPUFREQ_ETERNAL, leading to really long
      periods between frequency updates (~4s).
      
      If the desired_reg, where performance requests are written, is in
      SystemMemory or SystemIo ACPI address space, there is no delay
      in requests. So return 0 instead of CPUFREQ_ETERNAL, leading to
      transition_delay_us being set to LATENCY_MULTIPLIER us (1000 us).
      
      This patch also adds two macros to check the address spaces.
      
      Signed-off-by: default avatarPierre Gondois <pierre.gondois@arm.com>
      Reviewed-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      6380b7b2
    • Pierre Gondois's avatar
      ACPI: bus: Set CPPC _OSC bits for all and when CPPC_LIB is supported · 72f2ecb7
      Pierre Gondois authored
      
      
      The _OSC method allows the OS and firmware to communicate about
      supported features/capabitlities. It also allows the OS to take
      control of some features.
      
      In ACPI 6.4, s6.2.11.2 Platform-Wide OSPM Capabilities, the CPPC
      (resp. v2) bit should be set by the OS if it 'supports controlling
      processor performance via the interfaces described in the _CPC
      object'.
      
      The OS supports CPPC and parses the _CPC object only if
      CONFIG_ACPI_CPPC_LIB is set. Replace the x86 specific
      boot_cpu_has(X86_FEATURE_HWP) dynamic check with an arch
      generic CONFIG_ACPI_CPPC_LIB build-time check.
      
      Note:
      CONFIG_X86_INTEL_PSTATE selects CONFIG_ACPI_CPPC_LIB.
      
      Signed-off-by: default avatarPierre Gondois <pierre.gondois@arm.com>
      Reviewed-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      72f2ecb7
    • Pierre Gondois's avatar
      ACPI: CPPC: Check _OSC for flexible address space · 0651ab90
      Pierre Gondois authored
      
      
      ACPI 6.2 Section 6.2.11.2 'Platform-Wide OSPM Capabilities':
        Starting with ACPI Specification 6.2, all _CPC registers can be in
        PCC, System Memory, System IO, or Functional Fixed Hardware address
        spaces. OSPM support for this more flexible register space scheme is
        indicated by the “Flexible Address Space for CPPC Registers” _OSC bit
      
      Otherwise (cf ACPI 6.1, s8.4.7.1.1.X), _CPC registers must be in:
      - PCC or Functional Fixed Hardware address space if defined
      - SystemMemory address space (NULL register) if not defined
      
      Add the corresponding _OSC bit and check it when parsing _CPC objects.
      
      Signed-off-by: default avatarPierre Gondois <pierre.gondois@arm.com>
      Reviewed-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      0651ab90
  2. May 18, 2022
  3. May 12, 2022
  4. May 10, 2022
  5. May 07, 2022
    • Pierre Gondois's avatar
      cpufreq: CPPC: Register EM based on efficiency class information · 740fcdc2
      Pierre Gondois authored
      
      
      Performance states and energy consumption values are not advertised
      in ACPI. In the GicC structure of the MADT table, the "Processor
      Power Efficiency Class field" (called efficiency class from now)
      allows to describe the relative energy efficiency of CPUs.
      
      To leverage the EM and EAS, the CPPC driver creates a set of
      artificial performance states and registers them in the Energy Model
      (EM), such as:
      - Every 20 capacity unit, a performance state is created.
      - The energy cost of each performance state gradually increases.
      No power value is generated as only the cost is used in the EM.
      
      During task placement, a task can raise the frequency of its whole
      pd. This can make EAS place a task on a pd with CPUs that are
      individually less energy efficient.
      As cost values are artificial, and to place tasks on CPUs with the
      lower efficiency class, a gap in cost values is generated for adjacent
      efficiency classes.
      E.g.:
      - efficiency class = 0, capacity is in [0-1024], so cost values
        are in [0: 51] (one performance state every 20 capacity unit)
      - efficiency class = 1, capacity is in [0-1024], cost values
        are in [1*gap+0: 1*gap+51].
      
      The value of the cost gap is chosen to absorb a the energy of 4 CPUs
      at their maximum capacity. This means that between:
      1- a pd of 4 CPUs, each of them being used at almost their full
         capacity. Their efficiency class is N.
      2- a CPU using almost none of its capacity. Its efficiency class is
         N+1
      EAS will choose the first option.
      
      This patch also populates the (struct cpufreq_driver).register_em
      callback if the valid efficiency_class ACPI values are provided.
      
      Signed-off-by: default avatarPierre Gondois <Pierre.Gondois@arm.com>
      Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      740fcdc2
    • Pierre Gondois's avatar
      cpufreq: CPPC: Add per_cpu efficiency_class · d3c3db41
      Pierre Gondois authored
      
      
      In ACPI, describing power efficiency of CPUs can be done through the
      following arm specific field:
      ACPI 6.4, s5.2.12.14 'GIC CPU Interface (GICC) Structure',
      'Processor Power Efficiency Class field':
        Describes the relative power efficiency of the associated pro-
        cessor. Lower efficiency class numbers are more efficient than
        higher ones (e.g. efficiency class 0 should be treated as more
        efficient than efficiency class 1). However, absolute values
        of this number have no meaning: 2 isn’t necessarily half as
        efficient as 1.
      
      The efficiency_class field is stored in the GicC structure of the
      ACPI MADT table and it's currently supported in Linux for arm64 only.
      Thus, this new functionality is introduced for arm64 only.
      
      To allow the cppc_cpufreq driver to know and preprocess the
      efficiency_class values of all the CPUs, add a per_cpu efficiency_class
      variable to store them.
      
      At least 2 different efficiency classes must be present,
      otherwise there is no use in creating an Energy Model.
      
      The efficiency_class values are squeezed in [0:#efficiency_class-1]
      while conserving the order. For instance, efficiency classes of:
        [111, 212, 250]
      will be mapped to:
        [0 (was 111), 1 (was 212), 2 (was 250)].
      
      Each policy being independently registered in the driver, populating
      the per_cpu efficiency_class is done only once at the driver
      initialization. This prevents from having each policy re-searching the
      efficiency_class values of other CPUs. The EM will be registered in a
      following patch.
      
      The patch also exports acpi_cpu_get_madt_gicc() to fetch the GicC
      structure of the ACPI MADT table for each CPU.
      
      Acked-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarPierre Gondois <Pierre.Gondois@arm.com>
      Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      d3c3db41
    • Rafael J. Wysocki's avatar
    • Viresh Kumar's avatar
      cpufreq: Avoid unnecessary frequency updates due to mismatch · f55ae08c
      Viresh Kumar authored
      
      
      For some platforms, the frequency returned by hardware may be slightly
      different from what is provided in the frequency table. For example,
      hardware may return 499 MHz instead of 500 MHz. In such cases it is
      better to avoid getting into unnecessary frequency updates, as we may
      end up switching policy->cur between the two and sending unnecessary
      pre/post update notifications, etc.
      
      This patch has chosen allows the hardware frequency and table frequency
      to deviate by 1 MHz for now, we may want to increase it a bit later on
      if someone still complains.
      
      Reported-by: default avatarRex-BC Chen <rex-bc.chen@mediatek.com>
      Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
      Tested-by: default avatarJia-wei Chang <jia-wei.chang@mediatek.com>
      Reviewed-by: default avatarMatthias Brugger <matthias.bgg@gmail.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      f55ae08c
  6. May 05, 2022
  7. Apr 28, 2022
    • Rafael J. Wysocki's avatar
      Merge tag 'cpufreq-arm-fixes-5.18-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm · 0f03610b
      Rafael J. Wysocki authored
      Pull ARM cpufreq fixes for 5.18-rc5 from Viresh Kumar:
      
      "- Fix issues with the Qualcomm's cpufreq driver (Dmitry Baryshkov and
         Vladimir Zapolskiy).
       - Fix memory leak with the Sun501 driver (Xiaobing Luo)."
      
      * tag 'cpufreq-arm-fixes-5.18-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm:
        cpufreq: qcom-cpufreq-hw: Clear dcvs interrupts
        cpufreq: fix memory leak in sun50i_cpufreq_nvmem_probe
        cpufreq: qcom-cpufreq-hw: Fix throttle frequency value on EPSS platforms
        cpufreq: qcom-hw: provide online/offline operations
        cpufreq: qcom-hw: fix the opp entries refcounting
        cpufreq: qcom-hw: fix the race between LMH worker and cpuhp
        cpufreq: qcom-hw: drop affinity hint before freeing the IRQ
      0f03610b
  8. Apr 26, 2022
  9. Apr 25, 2022
  10. Apr 24, 2022
  11. Apr 23, 2022