summaryrefslogtreecommitdiffstats
path: root/drivers/thermal
Commit message (Collapse)AuthorAgeFilesLines
...
| * | thermal: exynos: add exynos*_tmu_set_[trip,hyst]() helpersBartlomiej Zolnierkiewicz2018-05-071-142/+140Star
| | | | | | | | | | | | | | | | | | | | | | | | Add exynos*_tmu_set_[trip,hyst]() helpers and convert all ->tmu_initialize implementations accordingly. Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: exynos: move IRQs clearing to exynos_tmu_initialize()Bartlomiej Zolnierkiewicz2018-05-071-10/+4Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move ->tmu_clear_irqs call from ->tmu_initialize method to exynos_tmu_initialize(). There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: exynos: clear IRQs later in exynos4412_tmu_initialize()Bartlomiej Zolnierkiewicz2018-05-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Clear IRQs after enabling thermal tripping (it should make no difference in driver operation). This prepares the driver code to moving IRQs clearing call from ->tmu_initialize method to exynos_tmu_initialize(). Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: exynos: make ->tmu_initialize method voidBartlomiej Zolnierkiewicz2018-05-071-18/+10Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All implementations of ->tmu_initialize always return 0 so make the method void and convert all implementations accordingly. There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: exynos: remove threshold_code checking from exynos4210_tmu_initialize()Bartlomiej Zolnierkiewicz2018-05-071-5/+1Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On Exynos4210 one-point trimming is always used and data->temp_error1 is equal to 75. Therefore temp_to_code() will never return negative value for the reference temperature conversion. There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: exynos: fix trips limit checking in get_th_reg()Bartlomiej Zolnierkiewicz2018-05-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | of_thermal_get_ntrips() may return value bigger than supported by a given SoC (i.e. on Exynos5422/5800) so fix the code to not iterate the loop for i values >= data->ntrip. There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: exynos: use sanitize_temp_error() in exynos7_tmu_initialize()Bartlomiej Zolnierkiewicz2018-05-071-7/+6Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix sanitize_temp_error() to handle Exynos7 SoCs and then use it in exynos7_tmu_initialize(). There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: exynos: check STATUS register in exynos_tmu_initialize()Bartlomiej Zolnierkiewicz2018-05-071-32/+13Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | STATUS register is present on all SoCs so move its checking into exynos_tmu_initialize(). There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: exynos: always check for critical trip points existenceBartlomiej Zolnierkiewicz2018-05-071-9/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Check for critical trip point existence in exynos_tmu_initialize() so it is checked on all SoCs (except Exynos5433 for now). * Use dev_err() instead of pr_err(). * Fix dev_err() to reference "device tree" not "of-thermal.c". * Remove no longer needed check from exynos4412_tmu_initialize(). Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: exynos: always check for trips points existenceBartlomiej Zolnierkiewicz2018-05-071-15/+11Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Check for trip points existence in exynos_tmu_initialize() so it is checked on all SoCs. * Use dev_err() instead of pr_err(). * Fix dev_err() to reference "device tree" not "of-thermal.c". * Remove no longer needed checks from exynos4210_tmu_initialize() and get_th_reg(). Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: exynos: fix setting rising_threshold for Exynos5433Bartlomiej Zolnierkiewicz2018-05-071-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Add missing clearing of the previous value when setting rising temperature threshold. Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: samsung: Remove support for Exynos5440Krzysztof Kozlowski2018-05-071-158/+3Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Exynos5440 is not actively developed, there are no development boards available and probably there are no real products with it. Remove wide-tree support for Exynos5440. Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> [b.zolnierkie: ported over driver changes] Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Reviewed-by: Rob Herring <robh@kernel.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: rcar_gen3_thermal: add r8a77965 supportNiklas Söderlund2018-05-071-0/+1
| | | | | | | | | | | | | | | | | | | | | Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Simon Horman <horms+renesas@verge.net.au> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: rcar_gen3_thermal: update max temperature clampNiklas Söderlund2018-05-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Change the upper limit to clamp the high temperature value to 120C when setting trip points. Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Reviewed-by: Simon Horman <horms+renesas@verge.net.au> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: rcar_gen3_thermal: Update calculation formula due to HW evaluationHien Dang2018-05-071-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Due to hardware evaluation result, Max temperature is changed from 96 to 116 degree Celsius. Also, calculation formula and pseudo FUSE values are changed accordingly. Signed-off-by: Dien Pham <dien.pham.ry@renesas.com> Signed-off-by: Hien Dang <hien.dang.eb@renesas.com> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Reviewed-by: Simon Horman <horms+renesas@verge.net.au> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: tegra: Nuke clk_{readl,writel} helpersEzequiel Garcia2018-05-061-27/+2Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Naming driver-specific register accessors with generic names, such as clk_writel and clk_readl, is bad. Moreover, clk_writel and clk_readl are part of the common clock framework api, so readers and code grep'ers get confused by this collision. The helpers are used once, so just remove them. Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com> Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: uniphier: add UniPhier PXs3 supportKunihiko Hayashi2018-05-061-0/+4
| | | | | | | | | | | | | | | | | | | | | Add support for UniPhier PXs3 SoC. It is equivalent to LD20. Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: exynos: remove separate exynos_tmu.h header fileBartlomiej Zolnierkiewicz2018-05-062-42/+16Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | exynos_tmu.h is used only by exynos_tmu.c so there is no need for a separate include file. Also while at it remove no longer needed cpu_cooling.h include. There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: exynos: remove parsing of samsung, tmu_cal_type propertyBartlomiej Zolnierkiewicz2018-05-062-44/+9Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since calibration type for temperature is SoC (not platform) specific just move it from platform data to struct exynos_tmu_data instance. Then remove parsing of samsung,tmu_cal_type property. Also remove no longer needed platform data structure. There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: exynos: remove parsing of samsung,tmu_gain propertyBartlomiej Zolnierkiewicz2018-05-062-13/+9Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since pdata gain values are SoC (not platform) specific just move it from platform data to struct exynos_tmu_data instance. Then remove parsing of samsung,tmu_gain property. There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: exynos: remove parsing of samsung, tmu_reference_voltage propertyBartlomiej Zolnierkiewicz2018-05-062-7/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since pdata reference_voltage values are SoC (not platform) specific just move it from platform data to struct exynos_tmu_data instance. Then remove parsing of samsung,tmu_reference_voltage property. There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: exynos: remove parsing of samsung, tmu[_min, _max]_efuse_value ↵Bartlomiej Zolnierkiewicz2018-05-062-24/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | properties Since pdata efuse values are SoC (not platform) specific just move them from platform data to struct exynos_tmu_data instance. Then remove parsing of samsung,tmu[_,min_,max]_efuse_value properties. There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: exynos: remove parsing of samsung, tmu_noise_cancel_mode propertyBartlomiej Zolnierkiewicz2018-05-062-9/+4Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All SoCs use the same value (4) for the noise cancel mode so just make it explicit and remove parsing of samsung,tmu_noise_cancel_mode property. There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: exynos: remove parsing of samsung, tmu_[first, second]_point_trim ↵Bartlomiej Zolnierkiewicz2018-05-062-13/+9Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | properties All SoCs use the same values (25, 85) for trim points (except Exynos5440 which currently specifices value 70 for the second trim point -> it seems to be a mistake because documentation uses value 85 and two points based trimming has never been used by the driver for this SoC anyway) so just make it explicit and remove parsing of samsung,tmu_[first,second]_point_trim properties. There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: exynos: remove parsing of samsung, tmu_default_temp_offset propertyBartlomiej Zolnierkiewicz2018-05-062-37/+13Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Trimming (one point based or two points based) is always used for the temperature calibration and the default non-trimming code is never reached. Remove it and then remove no longer needed parsing of samsung,tmu_default_temp_offset property. There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: exynos: remove unused "type" field from struct exynos_tmu_platform_dataBartlomiej Zolnierkiewicz2018-05-061-2/+0Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove unused "type" field from struct exynos_tmu_platform_data. There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: exynos: Read soc_type from match dataMaciej Purski2018-05-061-40/+34Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Device context's field data->soc is currently obtained by comparing of_compatible's. Provide soc_type as .data field in device's match table, as it is done in most drivers. Signed-off-by: Maciej Purski <m.purski@samsung.com> Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: exynos: Propagate error value from tmu_read()Marek Szyprowski2018-05-061-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tmu_read() in case of Exynos4210 might return error for out of bound values. Current code ignores such value, what leads to reporting critical temperature value. Add proper error code propagation to exynos_get_temp() function. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> CC: stable@vger.kernel.org # v4.6+ Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: exynos: Reading temperature makes sense only when TMU is turned onMarek Szyprowski2018-05-061-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When thermal sensor is not yet enabled, reading temperature might return random value. This might even result in stopping system booting when such temperature is higher than the critical value. Fix this by checking if TMU has been actually enabled before reading the temperature. This change fixes booting of Exynos4210-based board with TMU enabled (for example Samsung Trats board), which was broken since v4.4 kernel release. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Fixes: 9e4249b40340 ("thermal: exynos: Fix first temperature read after registering sensor") CC: stable@vger.kernel.org # v4.6+ Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: imx: add i.MX7 thermal sensor supportAnson Huang2018-05-061-63/+232
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds i.MX7 thermal sensor support, most of the i.MX7 thermal sensor functions are same with i.MX6 except the registers offset/layout, so we move those registers offset/layout definitions to soc data structure. i.MX7 uses single calibration data @25C, the calibration data is located at OCOTP offset 0x4F0, bit[17:9], the formula is as below: Tmeas = (Nmeas - n1) + 25; n1 is the fuse value for 25C. Signed-off-by: Anson Huang <Anson.Huang@nxp.com> Signed-off-by: Bai Ping <ping.bai@nxp.com> Acked-by: Dong Aisheng <aisheng.dong@nxp.com> Acked-by: Shawn Guo <shawnguo@kernel.org> Reviewed-by: Rob Herring <robh@kernel.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | thermal: mediatek: add support for MT7622 SoCSean Wang2018-05-061-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MT7622 SoC has built-in thermal controller with one sensing point, the patch just is to extend the functionality of the existing logic. Changes v1 -> v2: rebase to 4.16-rc1 Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Shunli Wang <shunli.wang@mediatek.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
* | | Merge branch 'next' of ↵Linus Torvalds2018-06-129-141/+49Star
|\ \ \ | |_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux Pull thermal updates from Zhang Rui: "Thermal core and intel thermal drivers: - convert thermal sysfs attributes to use DEVICE_ATTR_{RO|RW|WO}() variants (Viresh Kumar) - update license to SPDX format (Lina Iyer) - add GeminiLake support for int340x processor_thermal driver (Sumeet Pawnikar) - prevent error in reading trip hysteresis attribute for int340x thermal driver (Srinivas Pandruvada)" * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux: thermal: int340x: processor_thermal: Add GeminiLake support drivers: thermal: Update license to SPDX format thermal: int340x: Prevent error in reading trip hysteresis attribute thermal: Use DEVICE_ATTR_{RO|RW|WO}() variants thermal: Shorten name of sysfs callbacks
| * | Merge branches 'thermal-core' and 'thermal-intel' into nextZhang Rui2018-05-302-3/+7
| |\ \
| | * | thermal: int340x: processor_thermal: Add GeminiLake supportSumeet Pawnikar2018-05-301-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Added PCI device id of GeminiLake thermal device. Signed-off-by: Sumeet Pawnikar <sumeet.r.pawnikar@intel.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
| | * | thermal: int340x: Prevent error in reading trip hysteresis attributeSrinivas Pandruvada2018-05-301-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some of the INT340X devices may not have hysteresis defined in the ACPI definition. In that case reading trip hysteresis results in error. This spams logs of user space utilities. In this case instead of returning error, just return hysteresis as 0, which is correct as there is no hysteresis defined for the device. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
| * | | drivers: thermal: Update license to SPDX formatLina Iyer2018-05-307-78/+7Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Update licences format for core thermal files. Signed-off-by: Lina Iyer <ilina@codeaurora.org> Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
| * | | thermal: Use DEVICE_ATTR_{RO|RW|WO}() variantsViresh Kumar2018-05-221-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Use the DEVICE_ATTR_{RO|RW|WO}() variants instead of DEVICE_ATTR(). Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
| * | | thermal: Shorten name of sysfs callbacksViresh Kumar2018-05-223-59/+34Star
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The naming isn't consistent across all sysfs callbacks in the thermal core, some have a short name like type_show() and others have long names like thermal_cooling_device_weight_show(). This patch tries to make it consistent by shortening the name of sysfs callbacks. Some of the sysfs files are named similarly for both thermal zone and cooling device (like: type) and to avoid name clash between their show/store routines, the cooling device specific sysfs callbacks are prefixed with "cdev_". Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
* | | Merge tag 'overflow-v4.18-rc1' of ↵Linus Torvalds2018-06-071-3/+3
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux Pull overflow updates from Kees Cook: "This adds the new overflow checking helpers and adds them to the 2-factor argument allocators. And this adds the saturating size helpers and does a treewide replacement for the struct_size() usage. Additionally this adds the overflow testing modules to make sure everything works. I'm still working on the treewide replacements for allocators with "simple" multiplied arguments: *alloc(a * b, ...) -> *alloc_array(a, b, ...) and *zalloc(a * b, ...) -> *calloc(a, b, ...) as well as the more complex cases, but that's separable from this portion of the series. I expect to have the rest sent before -rc1 closes; there are a lot of messy cases to clean up. Summary: - Introduce arithmetic overflow test helper functions (Rasmus) - Use overflow helpers in 2-factor allocators (Kees, Rasmus) - Introduce overflow test module (Rasmus, Kees) - Introduce saturating size helper functions (Matthew, Kees) - Treewide use of struct_size() for allocators (Kees)" * tag 'overflow-v4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: treewide: Use struct_size() for devm_kmalloc() and friends treewide: Use struct_size() for vmalloc()-family treewide: Use struct_size() for kmalloc()-family device: Use overflow helpers for devm_kmalloc() mm: Use overflow helpers in kvmalloc() mm: Use overflow helpers in kmalloc_array*() test_overflow: Add memory allocation overflow tests overflow.h: Add allocation size calculation helpers test_overflow: Report test failures test_overflow: macrofy some more, do more tests for free lib: add runtime test of check_*_overflow functions compiler.h: enable builtin overflow checkers and add fallback code
| * | | treewide: Use struct_size() for devm_kmalloc() and friendsKees Cook2018-06-061-3/+3
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replaces open-coded struct size calculations with struct_size() for devm_*, f2fs_*, and sock_* allocations. Automatically generated (and manually adjusted) from the following Coccinelle script: // Direct reference to struct field. @@ identifier alloc =~ "devm_kmalloc|devm_kzalloc|sock_kmalloc|f2fs_kmalloc|f2fs_kzalloc"; expression HANDLE; expression GFP; identifier VAR, ELEMENT; expression COUNT; @@ - alloc(HANDLE, sizeof(*VAR) + COUNT * sizeof(*VAR->ELEMENT), GFP) + alloc(HANDLE, struct_size(VAR, ELEMENT, COUNT), GFP) // mr = kzalloc(sizeof(*mr) + m * sizeof(mr->map[0]), GFP_KERNEL); @@ identifier alloc =~ "devm_kmalloc|devm_kzalloc|sock_kmalloc|f2fs_kmalloc|f2fs_kzalloc"; expression HANDLE; expression GFP; identifier VAR, ELEMENT; expression COUNT; @@ - alloc(HANDLE, sizeof(*VAR) + COUNT * sizeof(VAR->ELEMENT[0]), GFP) + alloc(HANDLE, struct_size(VAR, ELEMENT, COUNT), GFP) // Same pattern, but can't trivially locate the trailing element name, // or variable name. @@ identifier alloc =~ "devm_kmalloc|devm_kzalloc|sock_kmalloc|f2fs_kmalloc|f2fs_kzalloc"; expression HANDLE; expression GFP; expression SOMETHING, COUNT, ELEMENT; @@ - alloc(HANDLE, sizeof(SOMETHING) + COUNT * sizeof(ELEMENT), GFP) + alloc(HANDLE, CHECKME_struct_size(&SOMETHING, ELEMENT, COUNT), GFP) Signed-off-by: Kees Cook <keescook@chromium.org>
* | | Merge tag 'printk-for-4.18' of ↵Linus Torvalds2018-06-071-2/+2
|\ \ \ | |_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk Pull printk updates from Petr Mladek: - Help userspace log daemons to catch up with a flood of messages. They will get woken after each message even if the console is far behind and handled by another process. - Flush printk safe buffers safely even when panic() happens in the normal context. - Fix possible va_list reuse when race happened in printk_safe(). - Remove %pCr printf format to prevent sleeping in the atomic context. - Misc vsprintf code cleanup. * tag 'printk-for-4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk: printk: drop in_nmi check from printk_safe_flush_on_panic() lib/vsprintf: Remove atomic-unsafe support for %pCr serial: sh-sci: Stop using printk format %pCr thermal: bcm2835: Stop using printk format %pCr clk: renesas: cpg-mssr: Stop using printk format %pCr printk: fix possible reuse of va_list variable printk: wake up klogd in vprintk_emit vsprintf: Tweak pF/pf comment lib/vsprintf: Mark expected switch fall-through lib/vsprintf: Replace space with '_' before crng is ready lib/vsprintf: Deduplicate pointer_string() lib/vsprintf: Move pointer_string() upper lib/vsprintf: Make flag_spec global lib/vsprintf: Make strspec global lib/vsprintf: Make dec_spec global lib/test_printf: Mark big constant with UL
| * | thermal: bcm2835: Stop using printk format %pCrGeert Uytterhoeven2018-06-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Printk format "%pCr" will be removed soon, as clk_get_rate() must not be called in atomic context. Replace it by printing the variable that already holds the clock rate. Note that calling clk_get_rate() is safe here, as the code runs in task context. Link: http://lkml.kernel.org/r/1527845302-12159-3-git-send-email-geert+renesas@glider.be To: Jia-Ju Bai <baijiaju1990@gmail.com> To: Jonathan Corbet <corbet@lwn.net> To: Michael Turquette <mturquette@baylibre.com> To: Stephen Boyd <sboyd@kernel.org> To: Zhang Rui <rui.zhang@intel.com> To: Eduardo Valentin <edubezval@gmail.com> To: Eric Anholt <eric@anholt.net> To: Stefan Wahren <stefan.wahren@i2se.com> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> Cc: Petr Mladek <pmladek@suse.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: linux-doc@vger.kernel.org Cc: linux-clk@vger.kernel.org Cc: linux-pm@vger.kernel.org Cc: linux-serial@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org # 4.12+ Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Petr Mladek <pmladek@suse.com>
* | | Merge branch 'thermal-soc' into nextZhang Rui2018-05-111-3/+11
|\ \ \
| * | | thermal: exynos: Propagate error value from tmu_read()Marek Szyprowski2018-04-271-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tmu_read() in case of Exynos4210 might return error for out of bound values. Current code ignores such value, what leads to reporting critical temperature value. Add proper error code propagation to exynos_get_temp() function. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> CC: stable@vger.kernel.org # v4.6+ Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
| * | | thermal: exynos: Reading temperature makes sense only when TMU is turned onMarek Szyprowski2018-04-271-1/+4
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When thermal sensor is not yet enabled, reading temperature might return random value. This might even result in stopping system booting when such temperature is higher than the critical value. Fix this by checking if TMU has been actually enabled before reading the temperature. This change fixes booting of Exynos4210-based board with TMU enabled (for example Samsung Trats board), which was broken since v4.4 kernel release. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Fixes: 9e4249b40340 ("thermal: exynos: Fix first temperature read after registering sensor") CC: stable@vger.kernel.org # v4.6+ Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
* / | thermal: int3403_thermal: Fix NULL pointer deref on module load / probeHans de Goede2018-04-241-2/+1Star
|/ / | | | | | | | | | | | | | | | | | | | | Starting with kernel 4.17 thermal_cooling_device_register() will call the get_max_state() op during register. Since we deref priv->priv in int3403_get_max_state() this means we must set priv->priv before calling thermal_cooling_device_register(). Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
* | Merge branches 'thermal-core' and 'thermal-soc' into nextZhang Rui2018-04-131-3/+3
|\ \
| * | thermal: imx: Fix race condition in imx_thermal_probe()Mikhail Lappo2018-03-141-3/+3
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When device boots with T > T_trip_1 and requests interrupt, the race condition takes place. The interrupt comes before THERMAL_DEVICE_ENABLED is set. This leads to an attempt to reading sensor value from irq and disabling the sensor, based on the data->mode field, which expected to be THERMAL_DEVICE_ENABLED, but still stays as THERMAL_DEVICE_DISABLED. Afher this issue sensor is never re-enabled, as the driver state is wrong. Fix this problem by setting the 'data' members prior to requesting the interrupts. Fixes: 37713a1e8e4c ("thermal: imx: implement thermal alarm interrupt handling") Cc: <stable@vger.kernel.org> Signed-off-by: Mikhail Lappo <mikhail.lappo@esrlabs.com> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Acked-by: Dong Aisheng <aisheng.dong@nxp.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
* / thermal: Add cooling device's statistics in sysfsViresh Kumar2018-04-025-2/+248
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This extends the sysfs interface for thermal cooling devices and exposes some pretty useful statistics. These statistics have proven to be quite useful specially while doing benchmarks related to the task scheduler, where we want to make sure that nothing has disrupted the test, specially the cooling device which may have put constraints on the CPUs. The information exposed here tells us to what extent the CPUs were constrained by the thermal framework. The write-only "reset" file is used to reset the statistics. The read-only "time_in_state_ms" file shows the time (in msec) spent by the device in the respective cooling states, and it prints one line per cooling state. The read-only "total_trans" file shows single positive integer value showing the total number of cooling state transitions the device has gone through since the time the cooling device is registered or the time when statistics were reset last. The read-only "trans_table" file shows a two dimensional matrix, where an entry <i,j> (row i, column j) represents the number of transitions from State_i to State_j. This is how the directory structure looks like for a single cooling device: $ ls -R /sys/class/thermal/cooling_device0/ /sys/class/thermal/cooling_device0/: cur_state max_state power stats subsystem type uevent /sys/class/thermal/cooling_device0/power: autosuspend_delay_ms runtime_active_time runtime_suspended_time control runtime_status /sys/class/thermal/cooling_device0/stats: reset time_in_state_ms total_trans trans_table This is tested on ARM 64-bit Hisilicon hikey620 board running Ubuntu and ARM 64-bit Hisilicon hikey960 board running Android. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
* Merge branch 'next' of ↵Linus Torvalds2018-02-0711-198/+286
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux Pull thermal management updates from Zhang Rui: - fix a race condition issue in power allocator governor (Yi Zeng). - add support for AP806 and CP110 in armada thermal driver, together with several improvements (Baruch Siach, Miquel Raynal) - add support for r8z7743 in rcar thermal driver (Biju Das) - convert thermal core to use new hwmon API to avoid warning (Fabio Estevam) - small fixes and cleanups in thermal core and x86_pkg_thermal, int3400_thermal, hisi_thermal, mtk_thermal and imx_thermal drivers (Pravin Shedge, Geert Uytterhoeven, Alexey Khoroshilov, Brian Bian, Matthias Brugger, Nicolin Chen, Uwe Kleine-König) * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux: (25 commits) thermal: thermal_hwmon: Convert to hwmon_device_register_with_info() thermal/x86 pkg temp: Remove debugfs_create_u32() casts thermal: int3400_thermal: fix error handling in int3400_thermal_probe() thermal/drivers/hisi: Remove bogus const from function return type thermal: armada: Give meaningful names to the thermal zones thermal: armada: Wait sensors validity before exiting the init callback thermal: armada: Change sensors trim default value thermal: armada: Update Kconfig and module description thermal: armada: Add support for Armada CP110 thermal: armada: Add support for Armada AP806 thermal: armada: Use real status register name thermal: armada: Clarify control registers accesses thermal: armada: Simplify the check of the validity bit thermal: armada: Use msleep for long delays dt-bindings: thermal: Describe Armada AP806 and CP110 dt-bindings: thermal: rcar: Add device tree support for r8a7743 thermal: mtk: Cleanup unused defines thermal: imx: update to new formula according to NXP AN5215 thermal: imx: use consistent style to write temperatures thermal: imx: improve comments describing algorithm for temp calculation ...