05 Sep, 2020

1 commit

  • Pull thermal fixes from Daniel Lezcano:

    - Fix bogus thermal shutdowns for omap4430 where bogus values resulting
    from an incorrect ADC conversion are too high and fire an emergency
    shutdown (Tony Lindgren)

    - Don't suppress negative temp for qcom spmi as they are valid and
    userspace needs them (Veera Vegivada)

    - Fix use-after-free in thermal_zone_device_unregister reported by
    Kasan (Dmitry Osipenko)

    * tag 'thermal-v5.9-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux:
    thermal: core: Fix use-after-free in thermal_zone_device_unregister()
    thermal: qcom-spmi-temp-alarm: Don't suppress negative temp
    thermal: ti-soc-thermal: Fix bogus thermal shutdowns for omap4430

    Linus Torvalds
     

04 Sep, 2020

1 commit

  • Currently driver is suppressing the negative temperature
    readings from the vadc. Consumers of the thermal zones need
    to read the negative temperature too. Don't suppress the
    readings.

    Fixes: c610afaa21d3c6e ("thermal: Add QPNP PMIC temperature alarm driver")
    Signed-off-by: Veera Vegivada
    Signed-off-by: Guru Das Srinagesh
    Reviewed-by: Stephen Boyd
    Signed-off-by: Daniel Lezcano
    Link: https://lore.kernel.org/r/944856eb819081268fab783236a916257de120e4.1596040416.git.gurus@codeaurora.org

    Veera Vegivada
     

24 Aug, 2020

1 commit

  • Replace the existing /* fall through */ comments and its variants with
    the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
    fall-through markings when it is the case.

    [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

07 Aug, 2020

1 commit

  • Pull thermal updates from Daniel Lezcano:

    - Add support to enable/disable the thermal zones resulting on core
    code and drivers cleanup (Andrzej Pietrasiewicz)

    - Add generic netlink support for userspace notifications: events,
    temperature and discovery commands (Daniel Lezcano)

    - Fix redundant initialization for a ret variable (Colin Ian King)

    - Remove the clock cooling code as it is used nowhere (Amit Kucheria)

    - Add the rcar_gen3_thermal's r8a774e1 support (Marian-Cristian
    Rotariu)

    - Replace all references to thermal.txt in the documentation to the
    corresponding yaml files (Amit Kucheria)

    - Add maintainer entry for the IPA (Lukasz Luba)

    - Add support for MSM8939 for the tsens (Shawn Guo)

    - Update power allocator and devfreq cooling to SPDX licensing (Lukasz
    Luba)

    - Add Cannon Lake Low Power PCH support (Sumeet Pawnikar)

    - Add tsensor support for V2 mediatek thermal system (Henry Yen)

    - Fix thermal zone lookup by ID for the core code (Thierry Reding)

    * tag 'thermal-v5.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux: (40 commits)
    thermal: intel: intel_pch_thermal: Add Cannon Lake Low Power PCH support
    thermal: mediatek: Add tsensor support for V2 thermal system
    thermal: mediatek: Prepare to add support for other platforms
    thermal: Update power allocator and devfreq cooling to SPDX licensing
    MAINTAINERS: update entry to thermal governors file name prefixing
    thermal: core: Add thermal zone enable/disable notification
    thermal: qcom: tsens-v0_1: Add support for MSM8939
    dt-bindings: tsens: qcom: Document MSM8939 compatible
    thermal: core: Fix thermal zone lookup by ID
    thermal: int340x: processor_thermal: fix: update Jasper Lake PCI id
    thermal: imx8mm: Support module autoloading
    thermal: ti-soc-thermal: Fix reversed condition in ti_thermal_expose_sensor()
    MAINTAINERS: Add maintenance information for IPA
    thermal: rcar_gen3_thermal: Do not shadow thcode variable
    dt-bindings: thermal: Get rid of thermal.txt and replace references
    thermal: core: Move initialization after core initcall
    thermal: netlink: Improve the initcall ordering
    net: genetlink: Move initialization to core_initcall
    thermal: rcar_gen3_thermal: Add r8a774e1 support
    thermal/drivers/clock_cooling: Remove clock_cooling code
    ...

    Linus Torvalds
     

27 Jul, 2020

1 commit

  • The TSENS integrated on MSM8939 is a v0_1 device with 10 sensors.
    Different from its predecessor MSM8916, where 'calib_sel' bits sit in
    separate qfprom word, MSM8939 has 'cailb' and 'calib_sel' bits mixed and
    spread on discrete offsets. That's why all qfprom bits are read as one
    go and later mapped to calibration data for MSM8939.

    Signed-off-by: Shawn Guo
    Acked-by: Amit Kucheria
    Tested-by: Konrad Dybcio /* on Asus Z00T smartphone */
    Acked-by: Konrad Dybcio
    Signed-off-by: Daniel Lezcano
    Link: https://lore.kernel.org/r/20200629144926.665-3-shawn.guo@linaro.org

    Shawn Guo
     

29 Jun, 2020

1 commit

  • After merging tsens-common.c into tsens.c, we can now mark some
    functions static so they don't need any prototype declarations. This
    fixes the following issue reported by lkp.

    >> drivers/thermal/qcom/tsens.c:385:13: warning: no previous prototype for 'tsens_critical_irq_thread' [-Wmissing-prototypes]
    385 | irqreturn_t tsens_critical_irq_thread(int irq, void *data)
    | ^~~~~~~~~~~~~~~~~~~~~~~~~
    >> drivers/thermal/qcom/tsens.c:455:13: warning: no previous prototype for 'tsens_irq_thread' [-Wmissing-prototypes]
    455 | irqreturn_t tsens_irq_thread(int irq, void *data)
    | ^~~~~~~~~~~~~~~~
    >> drivers/thermal/qcom/tsens.c:523:5: warning: no previous prototype for 'tsens_set_trips' [-Wmissing-prototypes]
    523 | int tsens_set_trips(void *_sensor, int low, int high)
    | ^~~~~~~~~~~~~~~
    >> drivers/thermal/qcom/tsens.c:560:5: warning: no previous prototype for 'tsens_enable_irq' [-Wmissing-prototypes]
    560 | int tsens_enable_irq(struct tsens_priv *priv)
    | ^~~~~~~~~~~~~~~~
    >> drivers/thermal/qcom/tsens.c:573:6: warning: no previous prototype for 'tsens_disable_irq' [-Wmissing-prototypes]
    573 | void tsens_disable_irq(struct tsens_priv *priv)
    | ^~~~~~~~~~~~~~~~~

    Signed-off-by: Amit Kucheria
    Reported-by: kbuild test robot
    Signed-off-by: Daniel Lezcano
    Link: https://lore.kernel.org/r/6757a26876b29922929abf64b1c11fa3b3033d03.1590579709.git.amit.kucheria@linaro.org

    Amit Kucheria
     

23 May, 2020

1 commit

  • tsens-common.c has outlived its usefuless. It was created expecting lots
    of custom routines per version of the TSENS IP. We haven't needed those,
    there is now only data in the version-specific files.

    Merge the code for tsens-common.c into tsens.c. As a result,
    - Remove any unnecessary forward declarations in tsens.h.
    - Add a Linaro copyright to tsens.c.
    - Fixup the Makefile to remove tsens-common.c.
    - Where it made sense, fix some 80-column alignments in the
    tsens-common.c code being copied over.

    There is no functional change with this patch.

    Signed-off-by: Amit Kucheria
    Reviewed-by: Bjorn Andersson
    Signed-off-by: Daniel Lezcano
    Link: https://lore.kernel.org/r/e30e2ba6fa5c007983afd4d7d4e0311c0b57917a.1588183879.git.amit.kucheria@linaro.org

    Amit Kucheria
     

23 Mar, 2020

1 commit

  • The current codebase makes use of the zero-length array language
    extension to the C90 standard, but the preferred mechanism to declare
    variable-length types such as these ones is a flexible array member[1][2],
    introduced in C99:

    struct foo {
    int stuff;
    struct boo array[];
    };

    By making use of the mechanism above, we will get a compiler warning
    in case the flexible array does not occur last in the structure, which
    will help us prevent some kind of undefined behavior bugs from being
    inadvertently introduced[3] to the codebase from now on.

    Also, notice that, dynamic memory allocations won't be affected by
    this change:

    "Flexible array members have incomplete type, and so the sizeof operator
    may not be applied. As a quirk of the original implementation of
    zero-length arrays, sizeof evaluates to zero."[1]

    This issue was found with the help of Coccinelle.

    [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
    [2] https://github.com/KSPP/linux/issues/21
    [3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

    Signed-off-by: Gustavo A. R. Silva
    Reviewed-by: Amit Kucheria
    Signed-off-by: Daniel Lezcano
    Link: https://lore.kernel.org/r/20200319184838.GA25767@embeddedor.com

    Gustavo A. R. Silva
     

20 Mar, 2020

8 commits

  • IRQF_TRIGGER_HIGH is already specified through devicetree interrupts
    property. Remove it from code.

    Signed-off-by: Amit Kucheria
    Reviewed-by: Bjorn Andersson
    Reviewed-by: Stephen Boyd
    Signed-off-by: Daniel Lezcano
    Link: https://lore.kernel.org/r/8ac92e45b65fe411f4aaf70dcde4e7e7c3169b2d.1584015867.git.amit.kucheria@linaro.org

    Amit Kucheria
     
  • Document ul_lock, threshold and control structure members and make
    the following kernel-doc invocation happy:

    $ scripts/kernel-doc -v -none drivers/thermal/qcom/*

    drivers/thermal/qcom/qcom-spmi-temp-alarm.c:105: info: Scanning doc for qpnp_tm_get_temp_stage
    drivers/thermal/qcom/tsens-common.c:18: info: Scanning doc for struct tsens_irq_data
    drivers/thermal/qcom/tsens-common.c:130: info: Scanning doc for tsens_hw_to_mC
    drivers/thermal/qcom/tsens-common.c:163: info: Scanning doc for tsens_mC_to_hw
    drivers/thermal/qcom/tsens-common.c:245: info: Scanning doc for tsens_set_interrupt
    drivers/thermal/qcom/tsens-common.c:268: info: Scanning doc for tsens_threshold_violated
    drivers/thermal/qcom/tsens-common.c:362: info: Scanning doc for tsens_critical_irq_thread
    drivers/thermal/qcom/tsens-common.c:438: info: Scanning doc for tsens_irq_thread
    drivers/thermal/qcom/tsens.h:41: info: Scanning doc for struct tsens_sensor
    drivers/thermal/qcom/tsens.h:59: info: Scanning doc for struct tsens_ops
    drivers/thermal/qcom/tsens.h:494: info: Scanning doc for struct tsens_features
    drivers/thermal/qcom/tsens.h:513: info: Scanning doc for struct tsens_plat_data
    drivers/thermal/qcom/tsens.h:529: info: Scanning doc for struct tsens_context

    Signed-off-by: Amit Kucheria
    Reviewed-by: Bjorn Andersson
    Reviewed-by: Stephen Boyd
    Signed-off-by: Daniel Lezcano
    Link: https://lore.kernel.org/r/7ea9c9ead90a91205a3f1717c0c86db9a51780ce.1584015867.git.amit.kucheria@linaro.org

    Amit Kucheria
     
  • TSENS IP v2.3 onwards adds support for a watchdog to detect if the TSENS
    HW FSM is stuck. Add support to detect and restart the FSM in the
    driver. The watchdog is configured by the bootloader, we just enable the
    watchdog bark as a debug feature in the kernel.

    Signed-off-by: Amit Kucheria
    Reviewed-by: Bjorn Andersson
    Reviewed-by: Stephen Boyd
    Signed-off-by: Daniel Lezcano
    Link: https://lore.kernel.org/r/a314747664a065db592ad77da7beae68128a5b6e.1584015867.git.amit.kucheria@linaro.org

    Amit Kucheria
     
  • TSENS IP v2.x adds critical threshold interrupt support for each sensor
    in addition to the upper/lower threshold interrupt. Add support in the
    driver.

    While the critical interrupts themselves aren't currently used by Linux,
    the HW line is also used by the TSENS watchdog. So this patch acts as
    infrastructure to enable watchdog functionality for the TSENS IP.

    Signed-off-by: Amit Kucheria
    Signed-off-by: Daniel Lezcano
    Link: https://lore.kernel.org/r/51b22461d4b5f85a817274568459db4579fd4298.1584015867.git.amit.kucheria@linaro.org

    Amit Kucheria
     
  • We don't currently call put_device in case of successfully initialising
    the device. So we hold the reference and keep the device pinned forever.

    Allow control to fall through so we can use same code for success and
    error paths to put_device.

    As a part of this fixup, change devm_ioremap_resource to act on the same
    device pointer as that used to allocate regmap memory. That ensures that
    we are free to release op->dev after examining its resources.

    Signed-off-by: Amit Kucheria
    Reviewed-by: Bjorn Andersson
    Signed-off-by: Daniel Lezcano
    Link: https://lore.kernel.org/r/d3996667e9f976bb30e97e301585cb1023be422e.1584015867.git.amit.kucheria@linaro.org

    Amit Kucheria
     
  • We already dereference the sensor and save it into a variable. Use the
    variable directly to make the code easier to read.

    Signed-off-by: Amit Kucheria
    Reviewed-by: Bjorn Andersson
    Reviewed-by: Stephen Boyd
    Signed-off-by: Daniel Lezcano
    Link: https://lore.kernel.org/r/5dc4356edfb8dffa377fb561359bf41a6f1fdf17.1584015867.git.amit.kucheria@linaro.org

    Amit Kucheria
     
  • All the sensor data is initialised at init time. Lock it down by passing
    it to functions as a constant.

    Signed-off-by: Amit Kucheria
    Reviewed-by: Bjorn Andersson
    Reviewed-by: Stephen Boyd
    Signed-off-by: Daniel Lezcano
    Link: https://lore.kernel.org/r/740f9254484c08d65869df578628eb523c0049ff.1584015867.git.amit.kucheria@linaro.org

    Amit Kucheria
     
  • struct tsens_features is currently initialized as part of platform data
    at compile-time and not modifiable. We now have some usecases in feature
    detection across IP versions where it is more flexible to update the
    features after probing registers.

    Remove const qualifier from tsens_features and the encapsulating
    tsens_plat_data.

    Signed-off-by: Amit Kucheria
    Reviewed-by: Stephen Boyd
    Signed-off-by: Daniel Lezcano
    Link: https://lore.kernel.org/r/2919a72220470366ae11e0bb5330a4ea39838f71.1584015867.git.amit.kucheria@linaro.org

    Amit Kucheria
     

07 Jan, 2020

1 commit

  • In order for the old DTBs to continue working, the new interrupt code
    must not return an error if interrupts are not defined. Don't return an
    error in case of -ENXIO.

    Fixes: 634e11d5b450a ("drivers: thermal: tsens: Add interrupt support")
    Suggested-by: Stephan Gerhold
    Signed-off-by: Amit Kucheria
    Reviewed-by: Bjorn Andersson
    Tested-by: Bjorn Andersson
    Signed-off-by: Daniel Lezcano
    Link: https://lore.kernel.org/r/cea3317c5d793db312064d68b261ad420a4a81b1.1576146898.git.amit.kucheria@linaro.org

    Amit Kucheria
     

07 Nov, 2019

9 commits

  • Currently a multiply operation is being performed on two int values
    and the result is being assigned to a u64, presumably because the
    end result is expected to be probably larger than an int. However,
    because the multiply is an int multiply one can get overflow. Avoid
    the overflow by casting degc to a u64 to force a u64 multiply.

    Also use div_u64 for the divide as suggested by Daniel Lezcano.

    Addresses-Coverity: ("Unintentional integer overflow")
    Fixes: fbfe1a042cfd ("drivers: thermal: tsens: Add interrupt support")
    Signed-off-by: Colin Ian King
    Signed-off-by: Daniel Lezcano
    Reviewed-by: Amit Kucheria
    Link: https://lore.kernel.org/r/20191101100035.25502-1-colin.king@canonical.com

    Colin Ian King
     
  • Currently the kfree of pointer qfprom_cdata is kfreeing an
    error value that has been cast to a pointer rather than a
    valid address. Fix this by removing the kfree.

    Fixes: 95ededc17e4e ("thermal: qcom: tsens-v1: Add support for MSM8956 and MSM8976")
    Signed-off-by: Colin Ian King
    Tested-by: AngeloGioacchino Del Regno
    Signed-off-by: Daniel Lezcano
    Link: https://lore.kernel.org/r/20191022111806.23143-1-colin.king@canonical.com

    Colin Ian King
     
  • Add support for reading calibrated value from thermistors in
    MSM8956, MSM8976 and their APQ variants.

    Signed-off-by: AngeloGioacchino Del Regno
    Reviewed-by: Amit Kucheria
    Signed-off-by: Daniel Lezcano
    Link: https://lore.kernel.org/r/20191005104133.30297-2-kholk11@gmail.com

    AngeloGioacchino Del Regno
     
  • Depending on the IP version, TSENS supports upper, lower and critical
    threshold interrupts. We only add support for upper and lower threshold
    interrupts for now.

    TSENSv2 has an irq [status|clear|mask] bit tuple for each sensor while
    earlier versions only have a single bit per sensor to denote status and
    clear. These differences are handled transparently by the interrupt
    handler. At each interrupt, we reprogram the new upper and lower threshold
    in the .set_trip callback.

    Signed-off-by: Amit Kucheria
    Reviewed-by: Stephen Boyd
    Signed-off-by: Daniel Lezcano
    Link: https://lore.kernel.org/r/7508ba143f144407e5dd546107ddae65c380a76f.1572526427.git.amit.kucheria@linaro.org

    Amit Kucheria
     
  • Hide the details of how to convert values read from TSENS HW to mCelsius
    behind a function. All versions of the IP can be supported as a result.

    Signed-off-by: Amit Kucheria
    Reviewed-by: Stephen Boyd
    Signed-off-by: Daniel Lezcano
    Link: https://lore.kernel.org/r/0689917475cf83b7e01f6978504fd37352a5e3ca.1572526427.git.amit.kucheria@linaro.org

    Amit Kucheria
     
  • Dump some basic version info and sensor details into debugfs. Example
    from qcs404 below:

    --(/sys/kernel/debug) $ ls tsens/
    4a9000.thermal-sensor version
    --(/sys/kernel/debug) $ cat tsens/version
    1.4.0
    --(/sys/kernel/debug) $ cat tsens/4a9000.thermal-sensor/sensors
    max: 11
    num: 10

    id slope offset
    ------------------------
    0 3200 404000
    1 3200 404000
    2 3200 404000
    3 3200 404000
    4 3200 404000
    5 3200 404000
    6 3200 404000
    7 3200 404000
    8 3200 404000
    9 3200 404000

    Signed-off-by: Amit Kucheria
    Reviewed-by: Stephen Boyd

    Signed-off-by: Daniel Lezcano
    Link: https://lore.kernel.org/r/16e39c1bbfc18b5cf6274620cd72cc63205f53a5.1572526427.git.amit.kucheria@linaro.org

    Amit Kucheria
     
  • Printing the function name when enabling debugging makes logs easier to
    read.

    Signed-off-by: Amit Kucheria
    Reviewed-by: Stephen Boyd
    Reviewed-by: Daniel Lezcano
    Signed-off-by: Daniel Lezcano
    Link: https://lore.kernel.org/r/18717de35f31098d3ebc12564c2767b6d54d37d8.1572526427.git.amit.kucheria@linaro.org

    Amit Kucheria
     
  • Move platform_set_drvdata up to avoid an extra 'if (ret)' check after
    the call to tsens_register.

    Signed-off-by: Amit Kucheria
    Reviewed-by: Stephen Boyd
    Reviewed-by: Daniel Lezcano
    Signed-off-by: Daniel Lezcano
    Link: https://lore.kernel.org/r/184422dcc1c12553e71a58c62e01425fd7d1172a.1572526427.git.amit.kucheria@linaro.org

    Amit Kucheria
     
  • There are two fields - id and hw_id - to track what sensor an action was
    to performed on. This was because the sensors connected to a TSENS IP
    might not be contiguous i.e. 1, 2, 4, 5 with 3 being skipped.

    This causes confusion in the code which uses hw_id sometimes and id
    other times (tsens_get_temp, tsens_get_trend).

    Switch to only using the hw_id field to track the physical ID of the
    sensor. When we iterate through all the sensors connected to an IP
    block, we use an index i to loop through the list of sensors, and then
    return the actual hw_id that is registered on that index.

    Signed-off-by: Amit Kucheria
    Reviewed-by: Stephen Boyd
    Reviewed-by: Daniel Lezcano
    Signed-off-by: Daniel Lezcano
    Link: https://lore.kernel.org/r/30206cd47d303d2dcaef87f4e3c7173481a0bddd.1572526427.git.amit.kucheria@linaro.org

    Amit Kucheria
     

28 Aug, 2019

1 commit

  • memory returned as part of nvmem_read via qfprom_read should be
    freed by the consumer once done.
    Existing code is not doing it so fix it.

    Below memory leak detected by kmemleak
    [] kmemleak_alloc+0x50/0x84
    [] __kmalloc+0xe8/0x168
    [] nvmem_cell_read+0x30/0x80
    [] qfprom_read+0x4c/0x7c
    [] calibrate_v1+0x34/0x204
    [] tsens_probe+0x164/0x258
    [] platform_drv_probe+0x80/0xa0
    [] really_probe+0x208/0x248
    [] driver_probe_device+0x98/0xc0
    [] __device_attach_driver+0x9c/0xac
    [] bus_for_each_drv+0x60/0x8c
    [] __device_attach+0x8c/0x100
    [] device_initial_probe+0x20/0x28
    [] bus_probe_device+0x34/0x7c
    [] deferred_probe_work_func+0x6c/0x98
    [] process_one_work+0x160/0x2f8

    Signed-off-by: Srinivas Kandagatla
    Acked-by: Amit Kucheria
    Signed-off-by: Zhang Rui

    Srinivas Kandagatla
     

05 Jun, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license version 2 and
    only version 2 as published by the free software foundation this
    program is distributed in the hope that it will be useful but
    without any warranty without even the implied warranty of
    merchantability or fitness for a particular purpose see the gnu
    general public license for more details

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 294 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Alexios Zavras
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190529141900.825281744@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

29 May, 2019

1 commit


21 May, 2019

1 commit


17 May, 2019

1 commit

  • Pull thermal management updates from Zhang Rui:

    - Remove the 'module' Kconfig option for thermal subsystem framework
    because the thermal framework are required to be ready as early as
    possible to avoid overheat at boot time (Daniel Lezcano)

    - Fix a bug that thermal framework pokes disabled thermal zones upon
    resume (Wei Wang)

    - A couple of cleanups and trivial fixes on int340x thermal drivers
    (Srinivas Pandruvada, Zhang Rui, Sumeet Pawnikar)

    * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux:
    drivers: thermal: processor_thermal: Downgrade error message
    mlxsw: Remove obsolete dependency on THERMAL=m
    hwmon/drivers/core: Simplify complex dependency
    thermal/drivers/core: Fix typo in the option name
    thermal/drivers/core: Remove depends on THERMAL in Kconfig
    thermal/drivers/core: Remove module unload code
    thermal/drivers/core: Remove the module Kconfig's option
    thermal: core: skip update disabled thermal zones after suspend
    thermal: make device_register's type argument const
    thermal: intel: int340x: processor_thermal_device: simplify to get driver data
    thermal/int3403_thermal: favor _TMP instead of PTYP

    Linus Torvalds
     

14 May, 2019

9 commits