1. 29 10月, 2019 1 次提交
  2. 16 8月, 2019 1 次提交
  3. 31 5月, 2019 5 次提交
    • W
      cpufreq: kirkwood: fix possible object reference leak · 9d8b1d5d
      Wen Yang 提交于
      [ Upstream commit 7c468966f05ac9c17bb5948275283d34e6fe0660 ]
      
      The call to of_get_child_by_name returns a node pointer with refcount
      incremented thus it must be explicitly decremented after the last
      usage.
      
      Detected by coccinelle with the following warnings:
      ./drivers/cpufreq/kirkwood-cpufreq.c:127:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 118, but without a corresponding object release within this function.
      ./drivers/cpufreq/kirkwood-cpufreq.c:133:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 118, but without a corresponding object release within this function.
      
      and also do some cleanup:
      - of_node_put(np);
      - np = NULL;
      ...
      of_node_put(np);
      Signed-off-by: NWen Yang <wen.yang99@zte.com.cn>
      Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
      Cc: Viresh Kumar <viresh.kumar@linaro.org>
      Cc: linux-pm@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      9d8b1d5d
    • W
      cpufreq: pmac32: fix possible object reference leak · f9ead9f4
      Wen Yang 提交于
      [ Upstream commit 8d10dc28a9ea6e8c02e825dab28699f3c72b02d9 ]
      
      The call to of_find_node_by_name returns a node pointer with refcount
      incremented thus it must be explicitly decremented after the last
      usage.
      
      Detected by coccinelle with the following warnings:
      ./drivers/cpufreq/pmac32-cpufreq.c:557:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 552, but without a corresponding object release within this function.
      ./drivers/cpufreq/pmac32-cpufreq.c:569:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 552, but without a corresponding object release within this function.
      ./drivers/cpufreq/pmac32-cpufreq.c:598:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 587, but without a corresponding object release within this function.
      Signed-off-by: NWen Yang <wen.yang99@zte.com.cn>
      Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
      Cc: Viresh Kumar <viresh.kumar@linaro.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: linux-pm@vger.kernel.org
      Cc: linuxppc-dev@lists.ozlabs.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      f9ead9f4
    • W
      cpufreq/pasemi: fix possible object reference leak · 513a7f8e
      Wen Yang 提交于
      [ Upstream commit a9acc26b75f652f697e02a9febe2ab0da648a571 ]
      
      The call to of_get_cpu_node returns a node pointer with refcount
      incremented thus it must be explicitly decremented after the last
      usage.
      
      Detected by coccinelle with the following warnings:
      ./drivers/cpufreq/pasemi-cpufreq.c:212:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 147, but without a corresponding object release within this function.
      ./drivers/cpufreq/pasemi-cpufreq.c:220:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 147, but without a corresponding object release within this function.
      Signed-off-by: NWen Yang <wen.yang99@zte.com.cn>
      Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
      Cc: Viresh Kumar <viresh.kumar@linaro.org>
      Cc: linuxppc-dev@lists.ozlabs.org
      Cc: linux-pm@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      513a7f8e
    • W
      cpufreq: ppc_cbe: fix possible object reference leak · 9612f404
      Wen Yang 提交于
      [ Upstream commit 233298032803f2802fe99892d0de4ab653bfece4 ]
      
      The call to of_get_cpu_node returns a node pointer with refcount
      incremented thus it must be explicitly decremented after the last
      usage.
      
      Detected by coccinelle with the following warnings:
      ./drivers/cpufreq/ppc_cbe_cpufreq.c:89:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 76, but without a corresponding object release within this function.
      ./drivers/cpufreq/ppc_cbe_cpufreq.c:89:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 76, but without a corresponding object release within this function.
      Signed-off-by: NWen Yang <wen.yang99@zte.com.cn>
      Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
      Cc: Viresh Kumar <viresh.kumar@linaro.org>
      Cc: linux-pm@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      9612f404
    • V
      sched/cpufreq: Fix kobject memleak · 73026db8
      Viresh Kumar 提交于
      [ Upstream commit 9a4f26cc98d81b67ecc23b890c28e2df324e29f3 ]
      
      Currently the error return path from kobject_init_and_add() is not
      followed by a call to kobject_put() - which means we are leaking
      the kobject.
      
      Fix it by adding a call to kobject_put() in the error path of
      kobject_init_and_add().
      Signed-off-by: NTobin C. Harding <tobin@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Tobin C. Harding <tobin@kernel.org>
      Cc: Vincent Guittot <vincent.guittot@linaro.org>
      Cc: Viresh Kumar <viresh.kumar@linaro.org>
      Link: http://lkml.kernel.org/r/20190430001144.24890-1-tobin@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      73026db8
  4. 15 5月, 2019 1 次提交
    • P
      x86/cpu: Sanitize FAM6_ATOM naming · 1f1bc822
      Peter Zijlstra 提交于
      commit f2c4db1bd80720cd8cb2a5aa220d9bc9f374f04e upstream
      
      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>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1f1bc822
  5. 10 5月, 2019 1 次提交
  6. 06 4月, 2019 1 次提交
  7. 24 3月, 2019 3 次提交
  8. 10 3月, 2019 1 次提交
    • V
      cpufreq: Use struct kobj_attribute instead of struct global_attr · 464b4279
      Viresh Kumar 提交于
      commit 625c85a62cb7d3c79f6e16de3cfa972033658250 upstream.
      
      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>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      464b4279
  9. 20 2月, 2019 1 次提交
    • S
      cpufreq: check if policy is inactive early in __cpufreq_get() · c6f27cdd
      Sudeep Holla 提交于
      [ Upstream commit 2f66196208c98b3d1b4294edffb2c5a8197be899 ]
      
      cpuinfo_cur_freq gets current CPU frequency as detected by hardware
      while scaling_cur_freq last known CPU frequency. Some platforms may not
      allow checking the CPU frequency of an offline CPU or the associated
      resources may have been released via cpufreq_exit when the CPU gets
      offlined, in which case the policy would have been invalidated already.
      If we attempt to get current frequency from the hardware, it may result
      in hang or crash.
      
      For example on Juno, I see:
      
      Unable to handle kernel NULL pointer dereference at virtual address 0000000000000188
      [0000000000000188] pgd=0000000000000000
      Internal error: Oops: 96000004 [#1] PREEMPT SMP
      Modules linked in:
      CPU: 5 PID: 4202 Comm: cat Not tainted 4.20.0-08251-ga0f2c0318a15-dirty #87
      Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development Platform
      pstate: 40000005 (nZcv daif -PAN -UAO)
      pc : scmi_cpufreq_get_rate+0x34/0xb0
      lr : scmi_cpufreq_get_rate+0x34/0xb0
      Call trace:
       scmi_cpufreq_get_rate+0x34/0xb0
       __cpufreq_get+0x34/0xc0
       show_cpuinfo_cur_freq+0x24/0x78
       show+0x40/0x60
       sysfs_kf_seq_show+0xc0/0x148
       kernfs_seq_show+0x44/0x50
       seq_read+0xd4/0x480
       kernfs_fop_read+0x15c/0x208
       __vfs_read+0x60/0x188
       vfs_read+0x94/0x150
       ksys_read+0x6c/0xd8
       __arm64_sys_read+0x24/0x30
       el0_svc_common+0x78/0x100
       el0_svc_handler+0x38/0x78
       el0_svc+0x8/0xc
      ---[ end trace 3d1024e58f77f6b2 ]---
      
      So fix the issue by checking if the policy is invalid early in
      __cpufreq_get before attempting to get the current frequency.
      Signed-off-by: NSudeep Holla <sudeep.holla@arm.com>
      Acked-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      c6f27cdd
  10. 17 1月, 2019 1 次提交
  11. 13 12月, 2018 1 次提交
  12. 01 12月, 2018 1 次提交
  13. 14 11月, 2018 2 次提交
  14. 29 9月, 2018 1 次提交
    • N
      cpufreq: qcom-kryo: Fix section annotations · d51aea13
      Nathan Chancellor 提交于
      There is currently a warning when building the Kryo cpufreq driver into
      the kernel image:
      
      WARNING: vmlinux.o(.text+0x8aa424): Section mismatch in reference from
      the function qcom_cpufreq_kryo_probe() to the function
      .init.text:qcom_cpufreq_kryo_get_msm_id()
      The function qcom_cpufreq_kryo_probe() references
      the function __init qcom_cpufreq_kryo_get_msm_id().
      This is often because qcom_cpufreq_kryo_probe lacks a __init
      annotation or the annotation of qcom_cpufreq_kryo_get_msm_id is wrong.
      
      Remove the '__init' annotation from qcom_cpufreq_kryo_get_msm_id
      so that there is no more mismatch warning.
      
      Additionally, Nick noticed that the remove function was marked as
      '__init' when it should really be marked as '__exit'.
      
      Fixes: 46e2856b (cpufreq: Add Kryo CPU scaling driver)
      Fixes: 5ad7346b (cpufreq: kryo: Add module remove and exit)
      Reported-by: NNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: NNathan Chancellor <natechancellor@gmail.com>
      Acked-by: NViresh Kumar <viresh.kumar@linaro.org>
      Cc: 4.18+ <stable@vger.kernel.org> # 4.18+
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      d51aea13
  15. 17 8月, 2018 1 次提交
  16. 06 8月, 2018 1 次提交
  17. 31 7月, 2018 1 次提交
  18. 26 7月, 2018 2 次提交
    • W
      cpufreq: Fix a circular lock dependency problem · 9b3d9bb3
      Waiman Long 提交于
      With lockdep turned on, the following circular lock dependency problem
      was reported:
      
      [   57.470040] ======================================================
      [   57.502900] WARNING: possible circular locking dependency detected
      [   57.535208] 4.18.0-0.rc3.1.el8+7.x86_64+debug #1 Tainted: G
      [   57.577761] ------------------------------------------------------
      [   57.609714] tuned/1505 is trying to acquire lock:
      [   57.633808] 00000000559deec5 (cpu_hotplug_lock.rw_sem){++++}, at: store+0x27/0x120
      [   57.672880]
      [   57.672880] but task is already holding lock:
      [   57.702184] 000000002136ca64 (kn->count#118){++++}, at: kernfs_fop_write+0x1d0/0x410
      [   57.742176]
      [   57.742176] which lock already depends on the new lock.
      [   57.742176]
      [   57.785220]
      [   57.785220] the existing dependency chain (in reverse order) is:
          :
      [   58.932512] other info that might help us debug this:
      [   58.932512]
      [   58.973344] Chain exists of:
      [   58.973344]   cpu_hotplug_lock.rw_sem --> subsys mutex#5 --> kn->count#118
      [   58.973344]
      [   59.030795]  Possible unsafe locking scenario:
      [   59.030795]
      [   59.061248]        CPU0                    CPU1
      [   59.085377]        ----                    ----
      [   59.108160]   lock(kn->count#118);
      [   59.124935]                                lock(subsys mutex#5);
      [   59.156330]                                lock(kn->count#118);
      [   59.186088]   lock(cpu_hotplug_lock.rw_sem);
      [   59.208541]
      [   59.208541]  *** DEADLOCK ***
      
      In the cpufreq_register_driver() function, the lock sequence is:
      
        cpus_read_lock --> kn->count
      
      For the cpufreq sysfs store method, the lock sequence is:
      
        kn->count --> cpus_read_lock
      
      These sequences are actually safe as they are taking a share lock on
      cpu_hotplug_lock. However, the current lockdep code doesn't check for
      share locking when detecting circular lock dependency.  Fixing that
      could be a substantial effort.
      
      Instead, we can work around this problem by using cpus_read_trylock()
      in the store method which is much simpler. The chance of not getting
      the read lock is very small. If that happens, the userspace application
      that writes the sysfs file will get an error.
      Signed-off-by: NWaiman Long <longman@redhat.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      9b3d9bb3
    • R
      cpufreq: trace frequency limits change · 601b2185
      Ruchi Kandoi 提交于
      systrace used for tracing for Android systems has carried a patch for
      many years in the Android tree that traces when the cpufreq limits
      change.  With the help of this information, systrace can know when the
      policy limits change and can visually display the data. Lets add
      upstream support for the same.
      Signed-off-by: NRuchi Kandoi <kandoiruchi@google.com>
      Signed-off-by: NJoel Fernandes (Google) <joel@joelfernandes.org>
      Acked-by: NViresh Kumar <viresh.kumar@linaro.org>
      Acked-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      601b2185
  19. 24 7月, 2018 1 次提交
  20. 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
  21. 18 7月, 2018 6 次提交
  22. 09 7月, 2018 1 次提交
  23. 02 7月, 2018 2 次提交
  24. 25 6月, 2018 1 次提交
  25. 19 6月, 2018 2 次提交
    • 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
    • I
      cpufreq: kryo: Add module remove and exit · 5ad7346b
      Ilia Lin 提交于
      Add device remove and module exit code to make the driver
      functioning as a loadable module.
      
      Fixes: ac289276 (cpufreq: kryo: allow building as a loadable module)
      Signed-off-by: NIlia Lin <ilia.lin@gmail.com>
      Acked-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      5ad7346b