03 Nov, 2022

1 commit

  • lx2160ardb and lx2162aqds failed to read out thermal zone when using
    Linux 5.15.71-lf-5.15.52-2.1.0-2798-g393a61ecb9db. This is because the
    IPBRR0s of lx2160ardb, lx2162aqds and i.MX93 have the same value
    0x01900201. It is wrong to use IPBRR0 to determine whether the current
    TMU belongs to i.MX93 or not, so that change to use compatible.

    Signed-off-by: Alice Guo
    Reviewed-by: Ye Li
    Acked-by: Jason Liu

    Alice Guo
     

21 Oct, 2022

1 commit


09 Oct, 2022

1 commit

  • The procedure to program the calibration table of i.MX93 TMU:
    1. disable monitoring mode
    2. configure TCMCFG
    3. write TTCFGR with TTCFGR[CAL_PT] = n
    4. write TSCFGR with the sensor value of the calibration point n
    5. write TTRCRn associated with the calibration point n
    Need to repeat steps 3—5 for all calibration points from the calibration
    table provided by the TMU device node.

    When TRITSR[V] = 1 and TRITSR[TP5] = 1, need to add 0.5K to
    TRITSR[TEMP].

    Signed-off-by: Alice Guo
    Reviewed-by: Jacky Bai
    Reviewed-by: Ye Li

    Alice Guo
     

27 Sep, 2022

1 commit

  • This is the 5.15.70 stable release

    * tag 'v5.15.70': (2444 commits)
    Linux 5.15.70
    ALSA: hda/sigmatel: Fix unused variable warning for beep power change
    cgroup: Add missing cpus_read_lock() to cgroup_attach_task_all()
    ...

    Signed-off-by: Jason Liu

    Conflicts:
    arch/arm/boot/dts/imx6ul.dtsi
    arch/arm/mm/mmu.c
    arch/arm64/boot/dts/freescale/imx8mp-evk.dts
    drivers/gpu/drm/imx/dcss/dcss-kms.c
    drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
    drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.h
    drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
    drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
    drivers/soc/fsl/Kconfig
    drivers/soc/imx/gpcv2.c
    drivers/usb/dwc3/host.c
    net/dsa/slave.c
    sound/soc/fsl/imx-card.c

    Jason Liu
     

17 Aug, 2022

1 commit

  • commit d5a8aa5d7d80d21ab6b266f1bed4194b61746199 upstream.

    If cooling_device_stats_setup() fails to create the stats object, it
    must clear the last slot in cooling_device_attr_groups that was
    initially empty (so as to make it possible to add stats attributes to
    the cooling device attribute groups).

    Failing to do so may cause the stats attributes to be created by
    mistake for a device that doesn't have a stats object, because the
    slot in question might be populated previously during the registration
    of another cooling device.

    Fixes: 8ea229511e06 ("thermal: Add cooling device's statistics in sysfs")
    Reported-by: Di Shen
    Tested-by: Di Shen
    Cc: 4.17+ # 4.17+
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     

30 Jun, 2022

2 commits

  • This is the 5.15.50 stable release

    * tag 'v5.15.50': (1395 commits)
    Linux 5.15.50
    arm64: mm: Don't invalidate FROM_DEVICE buffers at start of DMA transfer
    serial: core: Initialize rs485 RTS polarity already on probe
    ...

    Signed-off-by: Jason Liu

    Conflicts:
    drivers/bus/fsl-mc/fsl-mc-bus.c
    drivers/crypto/caam/ctrl.c
    drivers/pci/controller/dwc/pci-imx6.c
    drivers/spi/spi-fsl-qspi.c
    drivers/tty/serial/fsl_lpuart.c
    include/uapi/linux/dma-buf.h

    Jason Liu
     
  • This is the 5.15.41 stable release

    * tag 'v5.15.41': (1977 commits)
    Linux 5.15.41
    usb: gadget: uvc: allow for application to cleanly shutdown
    usb: gadget: uvc: rename function to be more consistent
    ...

    Signed-off-by: Jason Liu

    Conflicts:
    arch/arm64/boot/dts/freescale/fsl-ls1043a.dtsi
    arch/arm64/boot/dts/freescale/fsl-ls1046a.dtsi
    arch/arm64/configs/defconfig
    drivers/clk/imx/clk-imx8qxp-lpcg.c
    drivers/dma/imx-sdma.c
    drivers/gpu/drm/bridge/nwl-dsi.c
    drivers/mailbox/imx-mailbox.c
    drivers/net/phy/at803x.c
    drivers/tty/serial/fsl_lpuart.c
    security/keys/trusted-keys/trusted_core.c

    Jason Liu
     

09 Jun, 2022

5 commits

  • commit b947769b8f778db130aad834257fcaca25df2edc upstream.

    Fix access illegal address problem in following condition:

    There are multiple devfreq cooling devices in system, some of them has
    EM model but others do not. Energy model ops such as state2power will
    append to global devfreq_cooling_ops when the cooling device with
    EM model is registered. It makes the cooling device without EM model
    also use devfreq_cooling_ops after appending when registered later by
    of_devfreq_cooling_register_power() or of_devfreq_cooling_register().

    The IPA governor regards the cooling devices without EM model as a power
    actor, because they also have energy model ops, and will access illegal
    address at dfc->em_pd when execute cdev->ops->get_requested_power,
    cdev->ops->state2power or cdev->ops->power2state.

    Fixes: 615510fe13bd2 ("thermal: devfreq_cooling: remove old power model and use EM")
    Cc: 5.13+ # 5.13+
    Signed-off-by: Kant Fan
    Reviewed-by: Lukasz Luba
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Kant Fan
     
  • [ Upstream commit 09700c504d8e63faffd2a2235074e8c5d130cb8f ]

    of_find_node_by_name() returns a node pointer with refcount
    incremented, we should use of_node_put() on it when done.
    Add missing of_node_put() to avoid refcount leak.

    Fixes: e20db70dba1c ("thermal: imx_sc: add i.MX system controller thermal support")
    Signed-off-by: Miaoqian Lin
    Link: https://lore.kernel.org/r/20220517055121.18092-1-linmq006@gmail.com
    Signed-off-by: Daniel Lezcano
    Signed-off-by: Sasha Levin

    Miaoqian Lin
     
  • [ Upstream commit 98a160e898c0f4a979af9de3ab48b4b1d42d1dbb ]

    I got memory leak as follows when doing fault injection test:

    unreferenced object 0xffff888010080000 (size 264312):
    comm "182", pid 102533, jiffies 4296434960 (age 10.100s)
    hex dump (first 32 bytes):
    00 00 00 00 ad 4e ad de ff ff ff ff 00 00 00 00 .....N..........
    ff ff ff ff ff ff ff ff 40 7f 1f b9 ff ff ff ff ........@.......
    backtrace:
    [] kmalloc_order_trace+0x1d/0x110 mm/slab_common.c:969
    [] __kmalloc+0x373/0x420 include/linux/slab.h:510
    [] thermal_cooling_device_setup_sysfs+0x15d/0x2d0 include/linux/slab.h:586
    [] __thermal_cooling_device_register+0x332/0xa60 drivers/thermal/thermal_core.c:927
    [] devm_thermal_of_cooling_device_register+0x6b/0xf0 drivers/thermal/thermal_core.c:1041
    [] max6650_probe.cold+0x557/0x6aa drivers/hwmon/max6650.c:211
    [] i2c_device_probe+0x472/0xac0 drivers/i2c/i2c-core-base.c:561

    If device_register() fails, thermal_cooling_device_destroy_sysfs() need be called
    to free the memory allocated in thermal_cooling_device_setup_sysfs().

    Fixes: 8ea229511e06 ("thermal: Add cooling device's statistics in sysfs")
    Reported-by: Hulk Robot
    Signed-off-by: Yang Yingliang
    Link: https://lore.kernel.org/r/20220511020605.3096734-1-yangyingliang@huawei.com
    Signed-off-by: Daniel Lezcano
    Signed-off-by: Sasha Levin

    Yang Yingliang
     
  • [ Upstream commit e20d136ec7d6f309989c447638365840d3424c8e ]

    platform_get_resource() may return NULL, add proper check to
    avoid potential NULL dereferencing.

    Fixes: 250e211057c72 ("thermal: broadcom: Add Stingray thermal driver")
    Signed-off-by: Zheng Yongjun
    Link: https://lore.kernel.org/r/20220425092929.90412-1-zhengyongjun3@huawei.com
    Signed-off-by: Daniel Lezcano
    Signed-off-by: Sasha Levin

    Zheng Yongjun
     
  • [ Upstream commit 106e0121e243de4da7d634338089a68a8da2abe9 ]

    The thermal sensor on BCM2711 is capable of negative temperatures, so don't
    clamp the measurements at zero. Since this was the only use for variable t,
    drop it.

    This change based on a patch by Dom Cobley, who also tested the fix.

    Fixes: 59b781352dc4 ("thermal: Add BCM2711 thermal driver")
    Signed-off-by: Stefan Wahren
    Acked-by: Florian Fainelli
    Link: https://lore.kernel.org/r/20220412195423.104511-1-stefan.wahren@i2se.com
    Signed-off-by: Daniel Lezcano
    Signed-off-by: Sasha Levin

    Stefan Wahren
     

09 May, 2022

1 commit

  • commit d0f6cfb2bd165b0aa307750e07e03420859bd554 upstream.

    Control Flow Integrity (CFI) instrumentation of the kernel noticed that
    the caller, dev_attr_show(), and the callback, odvp_show(), did not have
    matching function prototypes, which would cause a CFI exception to be
    raised. Correct the prototype by using struct device_attribute instead
    of struct kobj_attribute.

    Reported-and-tested-by: Joao Moreira
    Link: https://lore.kernel.org/lkml/067ce8bd4c3968054509831fa2347f4f@overdrivepizza.com/
    Fixes: 006f006f1e5c ("thermal/int340x_thermal: Export OEM vendor variables")
    Cc: 5.8+ # 5.8+
    Signed-off-by: Kees Cook
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Kees Cook
     

08 Apr, 2022

2 commits

  • [ Upstream commit 38b16d6cfe54c820848bcfc999bc5e8a7da1cefb ]

    As the potential failure of the allocation, kmemdup() may return NULL.

    Then, 'bin_attr_data_vault.private' will be NULL, but
    'bin_attr_data_vault.size' is not 0, which is not consistent.

    Therefore, it is better to check the return value of kmemdup() to
    avoid the confusion.

    Fixes: 0ba13c763aac ("thermal/int340x_thermal: Export GDDV")
    Signed-off-by: Jiasheng Jiang
    [ rjw: Subject and changelog edits ]
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Sasha Levin

    Jiasheng Jiang
     
  • commit 668f69a5f863b877bc3ae129efe9a80b6f055141 upstream.

    The number of policies are 10, so can't be supported by the bitmap size
    of u8.

    Even though there are no platfoms with these many policies, but
    for correctness increase to u32.

    Signed-off-by: Srinivas Pandruvada
    Fixes: 16fc8eca1975 ("thermal/int340x_thermal: Add additional UUIDs")
    Cc: 5.1+ # 5.1+
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Srinivas Pandruvada
     

11 Mar, 2022

1 commit

  • This is the 5.15.27 stable release

    * tag 'v5.15.27': (3069 commits)
    Linux 5.15.27
    hamradio: fix macro redefine warning
    KVM: x86/mmu: Passing up the error state of mmu_alloc_shadow_roots()
    ...

    Signed-off-by: Jason Liu

    Conflicts:
    arch/arm/boot/dts/imx7ulp.dtsi
    arch/arm64/boot/dts/freescale/fsl-ls1028a-qds.dts
    arch/arm64/boot/dts/freescale/imx8mq.dtsi
    drivers/dma-buf/heaps/cma_heap.c
    drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
    drivers/gpu/drm/mxsfb/mxsfb_kms.c
    drivers/mmc/host/sdhci-esdhc-imx.c
    drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
    drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
    drivers/rpmsg/rpmsg_char.c
    drivers/soc/imx/gpcv2.c
    drivers/thermal/imx_thermal.c

    Jason Liu
     

09 Mar, 2022

1 commit

  • commit 5838a14832d447990827d85e90afe17e6fb9c175 upstream.

    Do not call get_trip_hyst() from thermal_genl_cmd_tz_get_trip() if
    the thermal zone does not define one.

    Fixes: 1ce50e7d408e ("thermal: core: genetlink support for events/cmd/sampling")
    Signed-off-by: Nicolas Cavallari
    Cc: 5.10+ # 5.10+
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Nicolas Cavallari
     

02 Mar, 2022

1 commit

  • commit 3abea10e6a8f0e7804ed4c124bea2d15aca977c8 upstream.

    It is easy to hit the below memory leaks in my TigerLake platform:

    unreferenced object 0xffff927c8b91dbc0 (size 32):
    comm "kworker/0:2", pid 112, jiffies 4294893323 (age 83.604s)
    hex dump (first 32 bytes):
    4e 41 4d 45 3d 49 4e 54 33 34 30 30 20 54 68 65 NAME=INT3400 The
    72 6d 61 6c 00 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b a5 rmal.kkkkkkkkkk.
    backtrace:
    [] __kmalloc_track_caller+0x2fe/0x4a0
    [] kvasprintf+0x65/0xd0
    [] kasprintf+0x4e/0x70
    [] int3400_notify+0x82/0x120 [int3400_thermal]
    [] acpi_ev_notify_dispatch+0x54/0x71
    [] acpi_os_execute_deferred+0x17/0x30
    [] process_one_work+0x21a/0x3f0
    [] worker_thread+0x4a/0x3b0
    [] kthread+0xfd/0x130
    [] ret_from_fork+0x1f/0x30

    Fix it by calling kfree() accordingly.

    Fixes: 38e44da59130 ("thermal: int3400_thermal: process "thermal table changed" event")
    Signed-off-by: Chuansheng Liu
    Cc: 4.14+ # 4.14+
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Chuansheng Liu
     

16 Feb, 2022

4 commits

  • commit 2685c77b80a80c57e2a25a726b82fb31e6e212ab upstream.

    The existing mail mechanism only supports writing of workload types.

    However, mailbox command for RFIM (cmd = 0x08) also requires write
    operation which is ignored. This results in failing to store RFI
    restriction.

    Fixint this requires enhancing mailbox writes for non workload
    commands too, so remove the check for MBOX_CMD_WORKLOAD_TYPE_WRITE
    in mailbox write to allow this other write commands to be supoorted.

    At the same time, however, we have to make sure that there is no
    impact on read commands, by avoiding to write anything into the
    mailbox data register.

    To properly implement that, add two separate functions for mbox read
    and write commands for the processor thermal workload command type.
    This helps to distinguish the read and write workload command types
    from each other while sending mbox commands.

    Fixes: 5d6fbc96bd36 ("thermal/drivers/int340x: processor_thermal: Export additional attributes")
    Signed-off-by: Sumeet Pawnikar
    Cc: 5.14+ # 5.14+
    Acked-by: Srinivas Pandruvada
    [ rjw: Changelog edits ]
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Sumeet Pawnikar
     
  • commit 994a04a20b03128838ec0250a0e266aab24d23f1 upstream.

    32-bit processors cannot generally access 64-bit MMIO registers
    atomically, and it is unknown in which order the two halves of
    this registers would need to be read:

    drivers/thermal/intel/int340x_thermal/processor_thermal_mbox.c: In function 'send_mbox_cmd':
    drivers/thermal/intel/int340x_thermal/processor_thermal_mbox.c:79:37: error: implicit declaration of function 'readq'; did you mean 'readl'? [-Werror=implicit-function-declaration]
    79 | *cmd_resp = readq((void __iomem *) (proc_priv->mmio_base + MBOX_OFFSET_DATA));
    | ^~~~~
    | readl

    The driver already does not build for anything other than x86,
    so limit it further to x86-64.

    Fixes: aeb58c860dc5 ("thermal/drivers/int340x: processor_thermal: Suppot 64 bit RFIM responses")
    Signed-off-by: Arnd Bergmann
    Reviewed-by: Srinivas Pandruvada
    Reviewed-by: Randy Dunlap
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Sumeet Pawnikar
    Signed-off-by: Greg Kroah-Hartman

    Arnd Bergmann
     
  • commit aeb58c860dc516794fdf7ff89d96ead2644d5889 upstream.

    Some of the RFIM mail box command returns 64 bit values. So enhance
    mailbox interface to return 64 bit values and use them for RFIM
    commands.

    Signed-off-by: Srinivas Pandruvada
    Fixes: 5d6fbc96bd36 ("thermal/drivers/int340x: processor_thermal: Export additional attributes")
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Sumeet Pawnikar
    Signed-off-by: Greg Kroah-Hartman

    Srinivas Pandruvada
     
  • commit c4fcf1ada4ae63e0aab6afd19ca2e7d16833302c upstream.

    When the driver resumes, the tcc offset is set back to its previous
    value. But this only works if the value was user defined as otherwise
    the offset isn't saved. This asymmetric logic is harder to maintain and
    introduced some issues.

    Improve the logic by saving the tcc offset in a suspend op, so the right
    value is always restored after a resume.

    Signed-off-by: Antoine Tenart
    Reviewed-by: Srinivas Pandruvada
    Tested-by: Srinivas Pandruvada
    Link: https://lore.kernel.org/r/20210909085613.5577-3-atenart@kernel.org
    Signed-off-by: Daniel Lezcano
    Signed-off-by: Sumeet Pawnikar
    Signed-off-by: Greg Kroah-Hartman

    Antoine Tenart
     

27 Jan, 2022

2 commits

  • [ Upstream commit 3de89d8842a2b5d3dd22ebf97dd561ae0a330948 ]

    The i.MX 8MP has a ADC_PD bit in the TMU_TER register that controls the
    operating mode of the ADC:
    * 0 means normal operating mode
    * 1 means power down mode

    When enabling/disabling the TMU, the ADC operating mode must be set
    accordingly.

    i.MX 8M Mini & Nano are lacking this bit.

    Signed-off-by: Paul Gerber
    Signed-off-by: Alexander Stein
    Fixes: 2b8f1f0337c5 ("thermal: imx8mm: Add i.MX8MP support")
    Link: https://lore.kernel.org/r/20211122114225.196280-1-alexander.stein@ew.tq-group.com
    Signed-off-by: Daniel Lezcano
    Signed-off-by: Sasha Levin

    Paul Gerber
     
  • [ Upstream commit 4cf2ddf16e175ee18c5c29865c32da7d6269cf44 ]

    Starting with commit d92ed2c9d3ff ("thermal: imx: Use driver's local
    data to decide whether to run a measurement") this driver stared using
    irq_enabled flag to make decision to power on/off the thermal
    core. This triggered a regression, where after reaching critical
    temperature, alarm IRQ handler set irq_enabled to false, disabled
    thermal core and was not able read temperature and disable cooling
    sequence.

    In case the cooling device is "CPU/GPU freq", the system will run with
    reduce performance until next reboot.

    To solve this issue, we need to move all parts implementing hand made
    runtime power management and let it handle actual runtime PM framework.

    Fixes: d92ed2c9d3ff ("thermal: imx: Use driver's local data to decide whether to run a measurement")
    Signed-off-by: Oleksij Rempel
    Tested-by: Petr Beneš
    Link: https://lore.kernel.org/r/20211117103426.81813-1-o.rempel@pengutronix.de
    Signed-off-by: Daniel Lezcano
    Signed-off-by: Sasha Levin

    Oleksij Rempel
     

14 Dec, 2021

1 commit

  • commit f872f73601b92c86f3da8bdf3e19abd0f1780eb9 upstream.

    The VCoRefLow CPU FIVR register definition for Tiger Lake is incorrect.

    Current implementation reads it from MMIO offset 0x5A18 and bit
    offset [12:14], but the actual correct register definition is from
    bit offset [11:13].

    Update to fix the bit offset.

    Fixes: 473be51142ad ("thermal: int340x: processor_thermal: Add RFIM driver")
    Signed-off-by: Sumeet Pawnikar
    Cc: 5.14+ # 5.14+
    [ rjw: New subject, changelog edits ]
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Sumeet Pawnikar
     

08 Dec, 2021

1 commit

  • [ Upstream commit 99b63316c39988039965693f5f43d8b4ccb1c86c ]

    During the suspend is in process, thermal_zone_device_update bails out
    thermal zone re-evaluation for any sensor trip violation without
    setting next valid trip to that sensor. It assumes during resume
    it will re-evaluate same thermal zone and update trip. But when it is
    in suspend temperature goes down and on resume path while updating
    thermal zone if temperature is less than previously violated trip,
    thermal zone set trip function evaluates the same previous high and
    previous low trip as new high and low trip. Since there is no change
    in high/low trip, it bails out from thermal zone set trip API without
    setting any trip. It leads to a case where sensor high trip or low
    trip is disabled forever even though thermal zone has a valid high
    or low trip.

    During thermal zone device init, reset thermal zone previous high
    and low trip. It resolves above mentioned scenario.

    Signed-off-by: Manaf Meethalavalappu Pallikunhi
    Reviewed-by: Thara Gopinath
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Sasha Levin

    Manaf Meethalavalappu Pallikunhi
     

01 Dec, 2021

1 commit

  • This is the 5.15.5 stable release

    * tag 'v5.15.5': (1261 commits)
    Linux 5.15.5
    ALSA: hda: hdac_stream: fix potential locking issue in snd_hdac_stream_assign()
    ALSA: hda: hdac_ext_stream: fix potential locking issues
    ...

    Conflicts:
    arch/powerpc/platforms/85xx/Makefile
    drivers/crypto/caam/caampkc.c
    drivers/gpu/drm/bridge/nwl-dsi.c
    drivers/gpu/drm/imx/imx-drm-core.c
    drivers/remoteproc/imx_rproc.c
    drivers/soc/imx/gpcv2.c
    include/linux/rpmsg.h

    Jason Liu
     

21 Nov, 2021

1 commit

  • commit 96cfe05051fd8543cdedd6807ec59a0e6c409195 upstream.

    of_parse_thermal_zones() parses the thermal-zones node and registers a
    thermal_zone device for each subnode. However, if a thermal zone is
    consuming a thermal sensor and that thermal sensor device hasn't probed
    yet, an attempt to set trip_point_*_temp for that thermal zone device
    can cause a NULL pointer dereference. Fix it.

    console:/sys/class/thermal/thermal_zone87 # echo 120000 > trip_point_0_temp
    ...
    Unable to handle kernel NULL pointer dereference at virtual address 0000000000000020
    ...
    Call trace:
    of_thermal_set_trip_temp+0x40/0xc4
    trip_point_temp_store+0xc0/0x1dc
    dev_attr_store+0x38/0x88
    sysfs_kf_write+0x64/0xc0
    kernfs_fop_write_iter+0x108/0x1d0
    vfs_write+0x2f4/0x368
    ksys_write+0x7c/0xec
    __arm64_sys_write+0x20/0x30
    el0_svc_common.llvm.7279915941325364641+0xbc/0x1bc
    do_el0_svc+0x28/0xa0
    el0_svc+0x14/0x24
    el0_sync_handler+0x88/0xec
    el0_sync+0x1c0/0x200

    While at it, fix the possible NULL pointer dereference in other
    functions as well: of_thermal_get_temp(), of_thermal_set_emul_temp(),
    of_thermal_get_trend().

    Suggested-by: David Collins
    Signed-off-by: Subbaraman Narayanamurthy
    Acked-by: Daniel Lezcano
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Subbaraman Narayanamurthy
     

19 Nov, 2021

5 commits

  • [ Upstream commit d9c8e52ff9e84ff1a406330f9ea4de7c5eb40282 ]

    Commit aeb58c860dc5 ("thermal/drivers/int340x: processor_thermal: Suppot
    64 bit RFIM responses") started using 'readq()' to read 64-bit status
    responses from the int340x hardware.

    That's all fine and good, but on 32-bit targets a 64-bit 'readq()' is
    ambiguous, since it's no longer an atomic access. Some hardware might
    require 64-bit accesses, and other hardware might want low word first or
    high word first.

    It's quite likely that the driver isn't relevant in a 32-bit environment
    any more, and there's a patch floating around to just make it depend on
    X86_64, but let's make it buildable on x86-32 anyway.

    The driver previously just read the low 32 bits, so the hardware
    certainly is ok with 32-bit reads, and in a little-endian environment
    the low word first model is the natural one.

    So just add the include for the 'io-64-nonatomic-lo-hi.h' version.

    Fixes: aeb58c860dc5 ("thermal/drivers/int340x: processor_thermal: Suppot 64 bit RFIM responses")
    Reported-by: Jakub Kicinski
    Cc: Srinivas Pandruvada
    Cc: Rafael J. Wysocki
    Signed-off-by: Linus Torvalds
    Signed-off-by: Sasha Levin

    Linus Torvalds
     
  • [ Upstream commit 9e5a4fb8423081d0efbf165c71c7f4abdf5f918c ]

    Without QCOM_SCM, build failed, avoid like below:

    aarch64-linux-gnu-ld: Unexpected GOT/PLT entries detected!
    aarch64-linux-gnu-ld: Unexpected run-time procedure linkages detected!
    aarch64-linux-gnu-ld: drivers/thermal/qcom/lmh.o: in function `lmh_probe':
    /data/arm/workspace/kernel-build/linux/build/../drivers/thermal/qcom/lmh.c:141: undefined reference to `qcom_scm_lmh_dcvsh_available'
    aarch64-linux-gnu-ld: /data/arm/workspace/kernel-build/linux/build/../drivers/thermal/qcom/lmh.c:144: undefined reference to `qcom_scm_lmh_dcvsh'
    aarch64-linux-gnu-ld: /data/arm/workspace/kernel-build/linux/build/../drivers/thermal/qcom/lmh.c:149: undefined reference to `qcom_scm_lmh_dcvsh'
    aarch64-linux-gnu-ld: /data/arm/workspace/kernel-build/linux/build/../drivers/thermal/qcom/lmh.c:154: undefined reference to `qcom_scm_lmh_dcvsh'
    aarch64-linux-gnu-ld: /data/arm/workspace/kernel-build/linux/build/../drivers/thermal/qcom/lmh.c:159: undefined reference to `qcom_scm_lmh_dcvsh'
    aarch64-linux-gnu-ld: /data/arm/workspace/kernel-build/linux/build/../drivers/thermal/qcom/lmh.c:166: undefined reference to `qcom_scm_lmh_profile_change'
    aarch64-linux-gnu-ld: /data/arm/workspace/kernel-build/linux/build/../drivers/thermal/qcom/lmh.c:173: undefined reference to `qcom_scm_lmh_dcvsh'
    aarch64-linux-gnu-ld: /data/arm/workspace/kernel-build/linux/build/../drivers/thermal/qcom/lmh.c:180: undefined reference to `qcom_scm_lmh_dcvsh'
    aarch64-linux-gnu-ld: /data/arm/workspace/kernel-build/linux/build/../drivers/thermal/qcom/lmh.c:187: undefined reference to `qcom_scm_lmh_dcvsh'
    make[1]: *** [/data/arm/workspace/kernel-build/linux/Makefile:1183: vmlinux] Error 1
    make[1]: Leaving directory '/data/arm/workspace/kernel-build/linux/build'
    make: *** [Makefile:219: __sub-make] Error 2
    make: Leaving directory '/data/arm/workspace/kernel-build/linux'

    Fixes: 53bca371cdf7 ("thermal/drivers/qcom: Add support for LMh driver")
    Signed-off-by: Jackie Liu
    Link: https://lore.kernel.org/r/20211009015853.3509559-1-liu.yun@linux.dev
    Signed-off-by: Daniel Lezcano
    Signed-off-by: Sasha Levin

    Jackie Liu
     
  • [ Upstream commit 0a5c26712f963f0500161a23e0ffff8d29f742ab ]

    When device_register() return failed, program will goto out_kfree_type
    to release 'cdev->device' by put_device(). That will call thermal_release()
    to free 'cdev'. But the follow-up processes access 'cdev' continually.
    That trggers the UAF bug.

    ====================================================================
    BUG: KASAN: use-after-free in __thermal_cooling_device_register+0x75b/0xa90
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014
    Call Trace:
    dump_stack_lvl+0xe2/0x152
    print_address_description.constprop.0+0x21/0x140
    ? __thermal_cooling_device_register+0x75b/0xa90
    kasan_report.cold+0x7f/0x11b
    ? __thermal_cooling_device_register+0x75b/0xa90
    __thermal_cooling_device_register+0x75b/0xa90
    ? memset+0x20/0x40
    ? __sanitizer_cov_trace_pc+0x1d/0x50
    ? __devres_alloc_node+0x130/0x180
    devm_thermal_of_cooling_device_register+0x67/0xf0
    max6650_probe.cold+0x557/0x6aa
    ......

    Freed by task 258:
    kasan_save_stack+0x1b/0x40
    kasan_set_track+0x1c/0x30
    kasan_set_free_info+0x20/0x30
    __kasan_slab_free+0x109/0x140
    kfree+0x117/0x4c0
    thermal_release+0xa0/0x110
    device_release+0xa7/0x240
    kobject_put+0x1ce/0x540
    put_device+0x20/0x30
    __thermal_cooling_device_register+0x731/0xa90
    devm_thermal_of_cooling_device_register+0x67/0xf0
    max6650_probe.cold+0x557/0x6aa [max6650]

    Do not use 'cdev' again after put_device() to fix the problem like doing
    in thermal_zone_device_register().

    [dlezcano]: as requested by Rafael, change the affectation into two statements.

    Fixes: 584837618100 ("thermal/drivers/core: Use a char pointer for the cooling device name")
    Signed-off-by: Ziyang Xuan
    Reported-by: kernel test robot
    Link: https://lore.kernel.org/r/20211015024504.947520-1-william.xuanziyang@huawei.com
    Signed-off-by: Daniel Lezcano
    Signed-off-by: Sasha Levin

    Ziyang Xuan
     
  • [ Upstream commit d012f9189fda0f3a1b303780ba0bbc7298d0d349 ]

    The function can loop and lock the system if for whatever reason the bit
    for the target sensor is NEVER valid. This is the case if a sensor is
    disabled by the factory and the valid bit is never reported as actually
    valid. Add a timeout check and exit if a timeout occurs. As this is
    a very rare condition, handle the timeout only if the first read fails.
    While at it also rework the function to improve readability and convert
    to poll_timeout generic macro.

    Signed-off-by: Ansuel Smith
    Reviewed-by: Bjorn Andersson
    Link: https://lore.kernel.org/r/20211007172859.583-1-ansuelsmth@gmail.com
    Signed-off-by: Daniel Lezcano
    Signed-off-by: Sasha Levin

    Ansuel Smith
     
  • [ Upstream commit 1dd7128b839f631b31a9e9dce3aaf639bef74e9d ]

    If both dev_set_name() and device_register() failed, then null pointer
    dereference occurs in thermal_release() which will use strncmp() to
    compare the name.

    So fix it by adding dev_set_name() return value check.

    Signed-off-by: Yuanzheng Song
    Link: https://lore.kernel.org/r/20211015083230.67658-1-songyuanzheng@huawei.com
    Signed-off-by: Daniel Lezcano
    Signed-off-by: Sasha Levin

    Yuanzheng Song
     

02 Nov, 2021

7 commits