1. 23 11月, 2016 5 次提交
  2. 27 9月, 2016 3 次提交
  3. 08 8月, 2016 1 次提交
    • M
      thermal: fix race condition when updating cooling device · d0b7306d
      Michele Di Giorgio 提交于
      When multiple thermal zones are bound to the same cooling device, multiple
      kernel threads may want to update the cooling device state by calling
      thermal_cdev_update(). Having cdev not protected by a mutex can lead to a race
      condition. Consider the following situation with two kernel threads k1 and k2:
      
      	    Thread k1				Thread k2
                                          ||
                                          ||  call thermal_cdev_update()
                                          ||      ...
                                          ||      set_cur_state(cdev, target);
          call power_actor_set_power()    ||
              ...                         ||
              instance->target = state;   ||
              cdev->updated = false;      ||
                                          ||      cdev->updated = true;
                                          ||      // completes execution
          call thermal_cdev_update()      ||
              // cdev->updated == true    ||
              return;                     ||
                                          \/
                                          time
      
      k2 has already looped through the thermal instances looking for the deepest
      cooling device state and is preempted right before setting cdev->updated to
      true. Now, k1 runs, modifies the thermal instance state and sets cdev->updated
      to false. Then, k1 is preempted and k2 continues the execution by setting
      cdev->updated to true, therefore preventing k1 from performing the update.
      Notice that this is not an issue if k2 looks at the instance->target modified by
      k1 "after" it is assigned by k1. In fact, in this case the update will happen
      anyway and k1 can safely return immediately from thermal_cdev_update().
      
      This may lead to a situation where a thermal governor never updates the cooling
      device. For example, this is the case for the step_wise governor: when calling
      the function thermal_zone_trip_update(), the governor may always get a new state
      equal to the old one (which, however, wasn't notified to the cooling device) and
      will therefore skip the update.
      
      CC: Zhang Rui <rui.zhang@intel.com>
      CC: Eduardo Valentin <edubezval@gmail.com>
      CC: Peter Feuerer <peter@piie.net>
      Reported-by: NToby Huang <toby.huang@arm.com>
      Signed-off-by: NMichele Di Giorgio <michele.digiorgio@arm.com>
      Reviewed-by: NJavi Merino <javi.merino@arm.com>
      Signed-off-by: NZhang Rui <rui.zhang@intel.com>
      d0b7306d
  4. 28 4月, 2016 1 次提交
  5. 21 4月, 2016 1 次提交
  6. 18 3月, 2016 1 次提交
  7. 07 1月, 2016 1 次提交
  8. 29 12月, 2015 3 次提交
  9. 14 9月, 2015 1 次提交
  10. 03 8月, 2015 7 次提交
    • S
      thermal: Add comment explaining test for critical temperature · 934c93b8
      Sascha Hauer 提交于
      The code testing if a temperature should be emulated or not is
      not obvious. Add a comment explaining why this test is done.
      Signed-off-by: NSascha Hauer <s.hauer@pengutronix.de>
      Reviewed-by: NMikko Perttunen <mperttunen@nvidia.com>
      Signed-off-by: NZhang Rui <rui.zhang@intel.com>
      934c93b8
    • S
      thermal: Use IS_ENABLED instead of #ifdef · 79e5421c
      Sascha Hauer 提交于
      Use IS_ENABLED(CONFIG_THERMAL_EMULATION) to make the code more readable
      and to get rid of the addtional #ifdef around the variable definitions
      in thermal_zone_get_temp().
      Signed-off-by: NSascha Hauer <s.hauer@pengutronix.de>
      Reviewed-by: NLukasz Majewski <l.majewski@samsung.com>
      Signed-off-by: NZhang Rui <rui.zhang@intel.com>
      79e5421c
    • S
      thermal: remove unnecessary call to thermal_zone_device_set_polling · dbdf2532
      Sascha Hauer 提交于
      When the thermal zone has no get_temp callback then thermal_zone_device_register()
      calls thermal_zone_device_set_polling() with a polling delay of 0. This
      only cancels the poll_queue. Since the poll_queue hasn't been scheduled this
      is a no-op. Remove it.
      Signed-off-by: NSascha Hauer <s.hauer@pengutronix.de>
      Acked-by: NEduardo Valentin <edubezval@gmail.com>
      Signed-off-by: NZhang Rui <rui.zhang@intel.com>
      dbdf2532
    • S
      f6be0584
    • S
      thermal: consistently use int for temperatures · 17e8351a
      Sascha Hauer 提交于
      The thermal code uses int, long and unsigned long for temperatures
      in different places.
      
      Using an unsigned type limits the thermal framework to positive
      temperatures without need. Also several drivers currently will report
      temperatures near UINT_MAX for temperatures below 0°C. This will probably
      immediately shut the machine down due to overtemperature if started below
      0°C.
      
      'long' is 64bit on several architectures. This is not needed since INT_MAX °mC
      is above the melting point of all known materials.
      
      Consistently use a plain 'int' for temperatures throughout the thermal code and
      the drivers. This only changes the places in the drivers where the temperature
      is passed around as pointer, when drivers internally use another type this is
      not changed.
      Signed-off-by: NSascha Hauer <s.hauer@pengutronix.de>
      Acked-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Reviewed-by: NJean Delvare <jdelvare@suse.de>
      Reviewed-by: NLukasz Majewski <l.majewski@samsung.com>
      Reviewed-by: NDarren Hart <dvhart@linux.intel.com>
      Reviewed-by: NHeiko Stuebner <heiko@sntech.de>
      Reviewed-by: NPeter Feuerer <peter@piie.net>
      Cc: Punit Agrawal <punit.agrawal@arm.com>
      Cc: Zhang Rui <rui.zhang@intel.com>
      Cc: Eduardo Valentin <edubezval@gmail.com>
      Cc: linux-pm@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: Jean Delvare <jdelvare@suse.de>
      Cc: Peter Feuerer <peter@piie.net>
      Cc: Heiko Stuebner <heiko@sntech.de>
      Cc: Lukasz Majewski <l.majewski@samsung.com>
      Cc: Stephen Warren <swarren@wwwdotorg.org>
      Cc: Thierry Reding <thierry.reding@gmail.com>
      Cc: linux-acpi@vger.kernel.org
      Cc: platform-driver-x86@vger.kernel.org
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-omap@vger.kernel.org
      Cc: linux-samsung-soc@vger.kernel.org
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Rafael J. Wysocki <rjw@rjwysocki.net>
      Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
      Cc: Darren Hart <dvhart@infradead.org>
      Cc: lm-sensors@lm-sensors.org
      Signed-off-by: NZhang Rui <rui.zhang@intel.com>
      17e8351a
    • N
      thermal: add available policies sysfs attribute · 25a0a5ce
      Ni Wade 提交于
      The Linux thermal framework support to change thermal governor
      policy in userspace, but it can't show what available policies
      supported.
      
      This patch adds available_policies attribute to the thermal
      framework, it can list the thermal governors which can be
      used for a particular zone. This attribute is read only.
      Signed-off-by: NWei Ni <wni@nvidia.com>
      Reviewed-by: NJavi Merino <javi.merino@arm.com>
      Signed-off-by: NZhang Rui <rui.zhang@intel.com>
      25a0a5ce
    • V
      thermal: remove dangling 'weight_attr' device file · 528464ea
      Viresh Kumar 提交于
      This file isn't getting removed while we unbind a device from thermal
      zone. And this causes following messages when the device is registered
      again:
      
      WARNING: CPU: 0 PID: 2228 at /home/viresh/linux/fs/sysfs/dir.c:31 sysfs_warn_dup+0x60/0x70()
      sysfs: cannot create duplicate filename '/devices/virtual/thermal/thermal_zone0/cdev0_weight'
      Modules linked in: cpufreq_dt(+) [last unloaded: cpufreq_dt]
      CPU: 0 PID: 2228 Comm: insmod Not tainted 4.2.0-rc3-00059-g44fffd9473eb #272
      Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
      [<c00153e8>] (unwind_backtrace) from [<c0012368>] (show_stack+0x10/0x14)
      [<c0012368>] (show_stack) from [<c053a684>] (dump_stack+0x84/0xc4)
      [<c053a684>] (dump_stack) from [<c002284c>] (warn_slowpath_common+0x80/0xb0)
      [<c002284c>] (warn_slowpath_common) from [<c00228ac>] (warn_slowpath_fmt+0x30/0x40)
      [<c00228ac>] (warn_slowpath_fmt) from [<c012d524>] (sysfs_warn_dup+0x60/0x70)
      [<c012d524>] (sysfs_warn_dup) from [<c012d244>] (sysfs_add_file_mode_ns+0x13c/0x190)
      [<c012d244>] (sysfs_add_file_mode_ns) from [<c012d2d4>] (sysfs_create_file_ns+0x3c/0x48)
      [<c012d2d4>] (sysfs_create_file_ns) from [<c03c04a8>] (thermal_zone_bind_cooling_device+0x260/0x358)
      [<c03c04a8>] (thermal_zone_bind_cooling_device) from [<c03c2e70>] (of_thermal_bind+0x88/0xb4)
      [<c03c2e70>] (of_thermal_bind) from [<c03c10d0>] (__thermal_cooling_device_register+0x17c/0x2e0)
      [<c03c10d0>] (__thermal_cooling_device_register) from [<c03c3f50>] (__cpufreq_cooling_register+0x3a0/0x51c)
      [<c03c3f50>] (__cpufreq_cooling_register) from [<bf00505c>] (cpufreq_ready+0x44/0x88 [cpufreq_dt])
      [<bf00505c>] (cpufreq_ready [cpufreq_dt]) from [<c03d6c30>] (cpufreq_add_dev+0x4a0/0x7dc)
      [<c03d6c30>] (cpufreq_add_dev) from [<c02cd3ec>] (subsys_interface_register+0x94/0xd8)
      [<c02cd3ec>] (subsys_interface_register) from [<c03d785c>] (cpufreq_register_driver+0x10c/0x1f0)
      [<c03d785c>] (cpufreq_register_driver) from [<bf0057d4>] (dt_cpufreq_probe+0x60/0x8c [cpufreq_dt])
      [<bf0057d4>] (dt_cpufreq_probe [cpufreq_dt]) from [<c02d03e4>] (platform_drv_probe+0x44/0xa4)
      [<c02d03e4>] (platform_drv_probe) from [<c02cead8>] (driver_probe_device+0x174/0x2b4)
      [<c02cead8>] (driver_probe_device) from [<c02ceca4>] (__driver_attach+0x8c/0x90)
      [<c02ceca4>] (__driver_attach) from [<c02cd078>] (bus_for_each_dev+0x68/0x9c)
      [<c02cd078>] (bus_for_each_dev) from [<c02ce2f0>] (bus_add_driver+0x19c/0x214)
      [<c02ce2f0>] (bus_add_driver) from [<c02cf490>] (driver_register+0x78/0xf8)
      [<c02cf490>] (driver_register) from [<c0009710>] (do_one_initcall+0x8c/0x1d4)
      [<c0009710>] (do_one_initcall) from [<c05396b0>] (do_init_module+0x5c/0x1b8)
      [<c05396b0>] (do_init_module) from [<c0086490>] (load_module+0xd34/0xed8)
      [<c0086490>] (load_module) from [<c0086704>] (SyS_init_module+0xd0/0x120)
      [<c0086704>] (SyS_init_module) from [<c000f480>] (ret_fast_syscall+0x0/0x3c)
      ---[ end trace 3be0e7b7dc6e3c4f ]---
      
      Fixes: db916513 ("thermal: export weight to sysfs")
      Acked-by: NJavi Merino <javi.merino@arm.com>
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NEduardo Valentin <edubezval@gmail.com>
      528464ea
  11. 12 5月, 2015 1 次提交
    • E
      thermal: support slope and offset coefficients · 9d0be7f4
      Eduardo Valentin 提交于
      It is common to have a linear extrapolation from
      the current sensor readings and the actual temperature
      value. This is specially the case when the sensor
      is in use to extrapolate hotspots.
      
      This patch adds slope and offset constants for
      single sensor linear extrapolation equation. Because
      the same sensor can be use in different locations,
      from board to board, these constants are added
      as part of thermal_zone_params.
      
      The constants are available through sysfs.
      
      It is up to the device driver to determine
      the usage of these values.
      Signed-off-by: NEduardo Valentin <edubezval@gmail.com>
      9d0be7f4
  12. 05 5月, 2015 7 次提交
    • J
      thermal: export thermal_zone_parameters to sysfs · 9f38271c
      Javi Merino 提交于
      It's useful for tuning to be able to edit thermal_zone_parameters from
      userspace.  Export them to the thermal_zone sysfs so that they can be
      easily changed.
      
      Cc: Zhang Rui <rui.zhang@intel.com>
      Cc: Eduardo Valentin <edubezval@gmail.com>
      Signed-off-by: NJavi Merino <javi.merino@arm.com>
      Signed-off-by: NEduardo Valentin <edubezval@gmail.com>
      9f38271c
    • P
      thermal: core: Add Kconfig option to enable writable trips · 35e94644
      Punit Agrawal 提交于
      Add a Kconfig option to allow system integrators to control whether
      userspace tools can change trip temperatures. This option overrides
      the thermal zone setup in the driver code and must be enabled for
      platform specified writable trips to come into effect.
      
      The original behaviour of requiring root privileges to change trip
      temperatures remains unchanged.
      
      Cc: Eduardo Valentin <edubezval@gmail.com>
      Cc: Zhang Rui <rui.zhang@intel.com>
      Signed-off-by: NPunit Agrawal <punit.agrawal@arm.com>
      Signed-off-by: NEduardo Valentin <edubezval@gmail.com>
      35e94644
    • J
      thermal: introduce the Power Allocator governor · 6b775e87
      Javi Merino 提交于
      The power allocator governor is a thermal governor that controls system
      and device power allocation to control temperature.  Conceptually, the
      implementation divides the sustainable power of a thermal zone among
      all the heat sources in that zone.
      
      This governor relies on "power actors", entities that represent heat
      sources.  They can report current and maximum power consumption and
      can set a given maximum power consumption, usually via a cooling
      device.
      
      The governor uses a Proportional Integral Derivative (PID) controller
      driven by the temperature of the thermal zone.  The output of the
      controller is a power budget that is then allocated to each power
      actor that can have bearing on the temperature we are trying to
      control.  It decides how much power to give each cooling device based
      on the performance they are requesting.  The PID controller ensures
      that the total power budget does not exceed the control temperature.
      
      Cc: Zhang Rui <rui.zhang@intel.com>
      Cc: Eduardo Valentin <edubezval@gmail.com>
      Signed-off-by: NPunit Agrawal <punit.agrawal@arm.com>
      Signed-off-by: NJavi Merino <javi.merino@arm.com>
      Signed-off-by: NEduardo Valentin <edubezval@gmail.com>
      6b775e87
    • J
      thermal: extend the cooling device API to include power information · 35b11d2e
      Javi Merino 提交于
      Add three optional callbacks to the cooling device interface to allow
      them to express power.  In addition to the callbacks, add helpers to
      identify cooling devices that implement the power cooling device API.
      
      Cc: Zhang Rui <rui.zhang@intel.com>
      Cc: Eduardo Valentin <edubezval@gmail.com>
      Signed-off-by: NJavi Merino <javi.merino@arm.com>
      Signed-off-by: NEduardo Valentin <edubezval@gmail.com>
      35b11d2e
    • J
      thermal: let governors have private data for each thermal zone · e33df1d2
      Javi Merino 提交于
      A governor may need to store its current state between calls to
      throttle().  That state depends on the thermal zone, so store it as
      private data in struct thermal_zone_device.
      
      The governors may have two new ops: bind_to_tz() and unbind_from_tz().
      When provided, these functions let governors do some initialization
      and teardown when they are bound/unbound to a tz and possibly store that
      information in the governor_data field of the struct
      thermal_zone_device.
      
      Cc: Zhang Rui <rui.zhang@intel.com>
      Cc: Eduardo Valentin <edubezval@gmail.com>
      Signed-off-by: NJavi Merino <javi.merino@arm.com>
      Signed-off-by: NEduardo Valentin <edubezval@gmail.com>
      e33df1d2
    • J
      thermal: export weight to sysfs · db916513
      Javi Merino 提交于
      It's useful to have access to the weights for the cooling devices for
      thermal zones and change them if needed.  Export them to sysfs.
      
      Cc: Zhang Rui <rui.zhang@intel.com>
      Cc: Eduardo Valentin <edubezval@gmail.com>
      Signed-off-by: NJavi Merino <javi.merino@arm.com>
      Signed-off-by: NEduardo Valentin <edubezval@gmail.com>
      db916513
    • K
      thermal: of: fix cooling device weights in device tree · 6cd9e9f6
      Kapileshwar Singh 提交于
      Currently you can specify the weight of the cooling device in the device
      tree but that information is not populated to the
      thermal_bind_params where the fair share governor expects it to
      be.  The of thermal zone device doesn't have a thermal_bind_params
      structure and arguably it's better to pass the weight inside the
      thermal_instance as it is specific to the bind of a cooling device to a
      thermal zone parameter.
      
      Core thermal code is fixed to populate the weight in the instance from
      the thermal_bind_params, so platform code that was passing the weight
      inside the thermal_bind_params continue to work seamlessly.
      
      While we are at it, create a default value for the weight parameter for
      those thermal zones that currently don't define it and remove the
      hardcoded default in of-thermal.
      
      Cc: Zhang Rui <rui.zhang@intel.com>
      Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
      Cc: Len Brown <lenb@kernel.org>
      Cc: Peter Feuerer <peter@piie.net>
      Cc: Darren Hart <dvhart@infradead.org>
      Cc: Eduardo Valentin <edubezval@gmail.com>
      Cc: Kukjin Kim <kgene@kernel.org>
      Cc: Durgadoss R <durgadoss.r@intel.com>
      Signed-off-by: NKapileshwar Singh <kapileshwar.singh@arm.com>
      Signed-off-by: NEduardo Valentin <edubezval@gmail.com>
      6cd9e9f6
  13. 08 4月, 2015 1 次提交
  14. 05 3月, 2015 1 次提交
  15. 18 1月, 2015 1 次提交
    • J
      netlink: make nlmsg_end() and genlmsg_end() void · 053c095a
      Johannes Berg 提交于
      Contrary to common expectations for an "int" return, these functions
      return only a positive value -- if used correctly they cannot even
      return 0 because the message header will necessarily be in the skb.
      
      This makes the very common pattern of
      
        if (genlmsg_end(...) < 0) { ... }
      
      be a whole bunch of dead code. Many places also simply do
      
        return nlmsg_end(...);
      
      and the caller is expected to deal with it.
      
      This also commonly (at least for me) causes errors, because it is very
      common to write
      
        if (my_function(...))
          /* error condition */
      
      and if my_function() does "return nlmsg_end()" this is of course wrong.
      
      Additionally, there's not a single place in the kernel that actually
      needs the message length returned, and if anyone needs it later then
      it'll be very easy to just use skb->len there.
      
      Remove this, and make the functions void. This removes a bunch of dead
      code as described above. The patch adds lines because I did
      
      -	return nlmsg_end(...);
      +	nlmsg_end(...);
      +	return 0;
      
      I could have preserved all the function's return values by returning
      skb->len, but instead I've audited all the places calling the affected
      functions and found that none cared. A few places actually compared
      the return value with <= 0 in dump functionality, but that could just
      be changed to < 0 with no change in behaviour, so I opted for the more
      efficient version.
      
      One instance of the error I've made numerous times now is also present
      in net/phonet/pn_netlink.c in the route_dumpit() function - it didn't
      check for <0 or <=0 and thus broke out of the loop every single time.
      I've preserved this since it will (I think) have caused the messages to
      userspace to be formatted differently with just a single message for
      every SKB returned to userspace. It's possible that this isn't needed
      for the tools that actually use this, but I don't even know what they
      are so couldn't test that changing this behaviour would be acceptable.
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      053c095a
  16. 09 12月, 2014 1 次提交
  17. 08 12月, 2014 3 次提交
  18. 04 11月, 2014 1 次提交