thermal: Add hardware-binned trip point support
Subsystems (6)
v3 cover thermal: Add hardware-binned trip point support
Some SoCs are available in multiple thermal/package bins. The silicon is otherwise the same, but the package/bin determines which junction temperature limits are valid for a given part. This information is programmed in manufacturing fuses and needs to be reflected in the trip points used by the kernel.
At the moment this is difficult to describe cleanly. Board-specific trip overrides can handle individual cases, but they do not describe the real hardware property: the limit is selected by SoC fuse state, not by board identity. Duplicating thermal zones or adding vendor-specific trip properties would also make the binding harder to share across platforms.
This series adds generic hardware-binned trip point support to the thermal OF parser, following the same general model as the OPP framework's opp-supported-hw property. A thermal sensor driver provides the decoded hardware bin when registering a thermal zone, and the OF parser uses that information to select the applicable trip data.
Two generic trip-point properties are added:
- thermal-hw-bin:
one or more hardware-bin mask groups for which the trip is valid
- temperature-bin:
per-bin trip temperatures, selected by the matching thermal-hw-bin group
This topic was discussed at the Linux Plumbers Conference Power and Thermal Management microconference as "Thermal binning support". The discussion covered how to represent SoCs whose valid junction temperature limits depend on package/bin characteristics. The approach taken here is to keep the DT description generic and let the platform thermal driver provide the hardware-specific fuse decoding.
LPC discussion:
https://lpc.events/event/19/contributions/2245/
Qualcomm TSENS is added as the first user of the generic support. On SC7280/QCM6490-class platforms, TSENS reads the jtag-id and feat-id QFPROM cells and maps them to the thermal hardware bin. On X1E80100-class platforms, TSENS reads the i-temp QFPROM bit. The decoded bin is passed to the thermal OF registration path before trip points are parsed.
The DTS patches use the new properties for the affected Kodiak and Hamoa thermal zones. For the standard bin the passive trip remains at 95C; for the elevated bin it is selected as 105C.
---
Changes in v3:
- Add minItems/maxItems constraints for thermal-hw-bin. (Krzysztof)
- Return -EINVAL for invalid trip types so -ENODEV remains reserved for
skipped hw-bin trips. (Sashiko)
- Add Reviewed-by from Krzysztof for the qcom-tsens binding patch.
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Format temperature-bin as separate DT cells. (Konrad)
- Add min/max constraints for temperature-bin entries. (Sashiko)
- Drop the post-registration hardware-bin API. (Sashiko)
- Remove CONFIG_THERMAL_BIN and make hardware-bin trip parsing part of
the thermal OF registration path. (Sashiko)
- Keep hardware-bin selection registration-time only through devm_thermal_of_zone_register_with_bin(), because OF trips are parsed synchronously during zone registration. (Sashiko)
- Propagate -EPROBE_DEFER when TSENS cannot read the hardware-bin nvmem
cells yet. (Sashiko)
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Amit Kucheria (6):
dt-bindings: thermal: thermal-zones: add hardware-binning trip properties
thermal: add hardware-binning trip-point filtering support
dt-bindings: thermal: qcom-tsens: document qcm6490 tsens
thermal: qcom: tsens: add hardware-bin trip-point filtering
arm64: dts: qcom: kodiak: use thermal hw-bin trips
arm64: dts: qcom: hamoa: add thermal hw-bin support
.../devicetree/bindings/thermal/qcom-tsens.yaml | 8 + .../devicetree/bindings/thermal/thermal-zones.yaml | 60 ++++- .../driver-api/thermal/hardware-binning.rst | 112 +++++++++ Documentation/driver-api/thermal/index.rst | 1 + MAINTAINERS | 1 + arch/arm64/boot/dts/qcom/hamoa-iot-evk.dts | 66 ------ arch/arm64/boot/dts/qcom/hamoa.dtsi | 42 +++- arch/arm64/boot/dts/qcom/kodiak.dtsi | 58 +++-- drivers/thermal/qcom/tsens-v2.c | 16 ++ drivers/thermal/qcom/tsens.c | 190 +++++++++++++++- drivers/thermal/qcom/tsens.h | 29 +++ drivers/thermal/thermal_of.c | 253 +++++++++++++++++++-- include/linux/thermal.h | 32 +++ 13 files changed, 754 insertions(+), 114 deletions(-)
---
base-commit: 6d582d78fad9d828e575ca0cdcff8ea47a77220b
change-id: 20260917-thermal_bin-fe7becdf0e17
Best regards,
Signature · 1 line
Gaurav Kohli <[email protected]>
PATCH v3 1/6 dt-bindings: thermal: thermal-zones: add hardware-binning trip properties
From: Amit Kucheria <[email protected]>
Differences in SoC packaging can be used to provide multiple SoC SKUs at different thermal and performance characteristics. The underlying SoC remains the same except for how much heat the packaging can dissipate, thereby influencing the critical trip point at which an SoC SKU needs to be throttled. This SKU-specific data is typically burned into fuses during manufacturing and can be read back at runtime.
Add two optional trip-point properties to describe this:
- 'temperature-bin': an array of per-bin trip temperatures, used instead of 'temperature' when the trip depends on the hardware revision encoded in fuses.
- 'thermal-hw-bin': one or more bitmask groups describing the hardware revisions for which a trip point is valid, modeled on the 'opp-supported-hw' property of the OPP framework.
--- .../devicetree/bindings/thermal/thermal-zones.yaml | 60 +++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/thermal/thermal-zones.yaml +59 -1
@@ -152,6 +152,58 @@ patternProperties: situation where the trip gets constantly triggered soon after cooling action is removed. + temperature-bin: + $ref: /schemas/types.yaml#/definitions/int32-array + items: + minimum: -273000 + maximum: 200000 + description: | + An array of integers expressing trip temperatures in + millicelsius, one entry per hardware bin sub-group defined + in the thermal-hw-bin property. Each value is the trip + temperature for the corresponding hardware bin. + + Use this property instead of 'temperature' when the trip + temperature depends on the SoC hardware revision as encoded + in fuse values. The platform driver reads the fuse and + registers the hardware-version bitfields with the thermal + zone; the framework then selects the matching entry. + + Exactly one of 'temperature' or 'temperature-bin' must be + present in each trip node. + + thermal-hw-bin: + $ref: /schemas/types.yaml#/definitions/uint32-matrix + minItems: 1 + maxItems: 32 + description: | + Optional bitmask(s) describing the hardware revisions for + which this trip point is valid. + + Uses the same format and semantics as the opp-supported-hw + property in the OPP framework. The platform thermal driver + provides N 32-bit values describing the hardware it is + running on, in a platform-specific format. + Each trip node may provide one or more groups of N 32-bit + mask values. + + The total number of 32-bit cells must be a multiple of N. + Each contiguous group of N cells forms a sub-group. A + sub-group matches if, for all i in [0 .. N-1], the bitwise + AND of the i-th mask and the i-th platform hardware value + is non-zero. The trip point is enabled if any sub-group + matches. If multiple sub-groups match, the first matching + sub-group selects the corresponding temperature-bin entry. + + When used together with 'temperature-bin', the number of + sub-groups must equal the number of entries in + 'temperature-bin'. + + If absent, the trip point is valid for all hardware. + items: + minItems: 1 + maxItems: 4 + type: $ref: /schemas/types.yaml#/definitions/string enum:
@@ -179,8 +231,14 @@ patternProperties: The active trip type can be used to control other HW to help in cooling e.g. fans can be sped up or slowed down + oneOf: + - required: + - temperature + - required: + - temperature-bin + dependentRequired: + temperature-bin: [thermal-hw-bin] required: - - temperature - hysteresis - type
Signature · 1 line
2.34.1
Rob Herring
maintainerRe: [PATCH v3 1/6] dt-bindings: thermal: thermal-zones: add hardware-binning trip properties
Quoted 30 lines · Gaurav Kohli
From: Amit Kucheria <[email protected]>
Differences in SoC packaging can be used to provide multiple SoC SKUs at different thermal and performance characteristics. The underlying SoC remains the same except for how much heat the packaging can dissipate, thereby influencing the critical trip point at which an SoC SKU needs to be throttled. This SKU-specific data is typically burned into fuses during manufacturing and can be read back at runtime.
Add two optional trip-point properties to describe this:
- 'temperature-bin': an array of per-bin trip temperatures, used instead of 'temperature' when the trip depends on the hardware revision encoded in fuses.
- 'thermal-hw-bin': one or more bitmask groups describing the hardware revisions for which a trip point is valid, modeled on the 'opp-supported-hw' property of the OPP framework.
Signed-off-by Amit Kucheria <[email protected]>Signed-off-by Gaurav Kohli <[email protected]>--- .../devicetree/bindings/thermal/thermal-zones.yaml | 60 +++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/thermal/thermal-zones.yaml +0
-0
Documentation/devicetree/bindings/thermal/thermal-zones.yaml patternProperties: · line 155
Quoted 4 lines
Documentation/devicetree/bindings/thermal/thermal-zones.yaml +1
-0@@ -152,6 +152,58 @@ patternProperties: situation where the trip gets constantly triggered soon after cooling action is removed. + temperature-bin:
Use the standard unit suffix.
Documentation/devicetree/bindings/thermal/thermal-zones.yaml patternProperties: · line 159
Quoted 4 lines
Documentation/devicetree/bindings/thermal/thermal-zones.yaml +4
-0+ $ref: /schemas/types.yaml#/definitions/int32-array + items: + minimum: -273000 + maximum: 200000
minItems: 2
maxItems: 32 ?
Re: [PATCH v3 1/6] dt-bindings: thermal: thermal-zones: add hardware-binning trip properties
Quoted 34 lines · Rob Herring
Quoted 33 lines · Gaurav Kohli
From: Amit Kucheria <[email protected]>
Differences in SoC packaging can be used to provide multiple SoC SKUs at different thermal and performance characteristics. The underlying SoC remains the same except for how much heat the packaging can dissipate, thereby influencing the critical trip point at which an SoC SKU needs to be throttled. This SKU-specific data is typically burned into fuses during manufacturing and can be read back at runtime.
Add two optional trip-point properties to describe this:
- 'temperature-bin': an array of per-bin trip temperatures, used instead of 'temperature' when the trip depends on the hardware revision encoded in fuses.
- 'thermal-hw-bin': one or more bitmask groups describing the hardware revisions for which a trip point is valid, modeled on the 'opp-supported-hw' property of the OPP framework.
Signed-off-by Amit Kucheria <[email protected]>Signed-off-by Gaurav Kohli <[email protected]>--- .../devicetree/bindings/thermal/thermal-zones.yaml | 60 +++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/thermal/thermal-zones.yaml +0
-0@@ -152,6 +152,58 @@ patternProperties: situation where the trip gets constantly triggered soon after cooling action is removed.
Quoted 3 lines
Documentation/devicetree/bindings/thermal/thermal-zones.yaml patternProperties: · line 155
Quoted 1 line
Documentation/devicetree/bindings/thermal/thermal-zones.yaml +1
-0+ temperature-bin:Use the standard unit suffix.
Thanks Rob for the review.
Would temperature-bin-millicelsius work for the unit-suffixed name? I’ll also add minItems: 2 and maxItems: 32 in the next revision.
Quoted 8 lines
Documentation/devicetree/bindings/thermal/thermal-zones.yaml patternProperties: · line 159
Quoted 5 lines
Documentation/devicetree/bindings/thermal/thermal-zones.yaml +4
-0+ $ref: /schemas/types.yaml#/definitions/int32-array + items: + minimum: -273000 + maximum: 200000minItems: 2
maxItems: 32 ?
Re: [PATCH v3 1/6] dt-bindings: thermal: thermal-zones: add hardware-binning trip properties
In reply to Rob HerringQuoted 34 lines · Rob Herring
Quoted 33 lines · Gaurav Kohli
From: Amit Kucheria <[email protected]>
Differences in SoC packaging can be used to provide multiple SoC SKUs at different thermal and performance characteristics. The underlying SoC remains the same except for how much heat the packaging can dissipate, thereby influencing the critical trip point at which an SoC SKU needs to be throttled. This SKU-specific data is typically burned into fuses during manufacturing and can be read back at runtime.
Add two optional trip-point properties to describe this:
- 'temperature-bin': an array of per-bin trip temperatures, used instead of 'temperature' when the trip depends on the hardware revision encoded in fuses.
- 'thermal-hw-bin': one or more bitmask groups describing the hardware revisions for which a trip point is valid, modeled on the 'opp-supported-hw' property of the OPP framework.
Signed-off-by Amit Kucheria <[email protected]>Signed-off-by Gaurav Kohli <[email protected]>--- .../devicetree/bindings/thermal/thermal-zones.yaml | 60 +++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/thermal/thermal-zones.yaml +0
-0@@ -152,6 +152,58 @@ patternProperties: situation where the trip gets constantly triggered soon after cooling action is removed.
Quoted 3 lines
Documentation/devicetree/bindings/thermal/thermal-zones.yaml patternProperties: · line 155
Quoted 1 line
Documentation/devicetree/bindings/thermal/thermal-zones.yaml +1
-0+ temperature-bin:Use the standard unit suffix.
Sorry, my previous reply was sent only to linux-arm-msm by mistake. Resending to the full list.
Thanks Rob for the review.
Would temperature-bin-millicelsius work for the unit-suffixed name? I’ll also add minItems: 2 and maxItems: 32 in the next revision.
Quoted 8 lines
Documentation/devicetree/bindings/thermal/thermal-zones.yaml patternProperties: · line 159
Quoted 5 lines
Documentation/devicetree/bindings/thermal/thermal-zones.yaml +4
-0+ $ref: /schemas/types.yaml#/definitions/int32-array + items: + minimum: -273000 + maximum: 200000minItems: 2
maxItems: 32 ?
PATCH v3 2/6 thermal: add hardware-binning trip-point filtering support
In reply to Gaurav KohliFrom: Amit Kucheria <[email protected]>
Differences in SoC packaging can be used to provide multiple SoC SKUs at different thermal and performance characteristics. The underlying SoC remains the same except for how much heat the packaging can dissipate, thereby influencing what is the critical trip point at which the SoC SKU needs to be throttled. This is the basis for thermal-binning.
This SKU-specific data is typically burned into EFUSEs during manufacturing. We can read back this information at runtime to populate the appropriate trip points applicable to an SKU.
Linux support for this has been modeled along the lines of the opp-supported-hw property in the OPP framework that already allows similar mechanisms to allow/disallow certain operating frequencies for the processor. The thermal-hw-bin property allows multiple SKUs of an SoC to be configured for different critical trip points based on a fuse mask.
Add thermal OF support to parse the thermal-hw-bin and temperature-bin DT properties. Platform sensor drivers pass decoded hardware-version information to devm_thermal_of_zone_register_with_bin() before trip points are parsed, allowing the OF parser to filter trips and select per-bin temperatures during zone registration.
--- .../driver-api/thermal/hardware-binning.rst | 112 +++++++++ Documentation/driver-api/thermal/index.rst | 1 + MAINTAINERS | 1 + drivers/thermal/thermal_of.c | 253 +++++++++++++++++++-- include/linux/thermal.h | 32 +++ 5 files changed, 377 insertions(+), 22 deletions(-)
Documentation/driver-api/thermal/hardware-binning.rst new file +112 -0
@@ -0,0 +1,112 @@ +.. SPDX-License-Identifier: GPL-2.0 + +===================== +Thermal hardware bins +===================== + +:Author: Amit Kucheria + +Overview +======== + +Differences in SoC packaging let a vendor ship several SKUs built from the +same silicon but with different thermal characteristics. Better packaging +dissipates more heat, so the temperature at which a SKU must be throttled (or +shut down) differs between SKUs. This SKU-specific information is typically +burned into eFUSEs during manufacturing and can be read back at runtime. + +Thermal "hardware binning" lets a single device tree describe the trip points +for every SKU of an SoC and have the kernel pick the values that match the +silicon it is actually running on. The mechanism is modelled on the +``opp-supported-hw`` property used by the OPP framework: the platform supplies +one or more 32-bit hardware-version words decoded from fuses, and each trip +point declares the hardware bitmasks for which it is valid. + +Hardware-bin trip parsing is part of the thermal OF helpers. + +Device tree properties +======================= + +Two properties are added to a trip-point node (see +``Documentation/devicetree/bindings/thermal/thermal-zones.yaml`` for the +authoritative schema): + +``temperature-bin`` + An array of trip temperatures in millicelsius, one entry per + ``thermal-hw-bin`` sub-group. It is used *instead of* the plain + ``temperature`` property when the trip temperature depends on the hardware + bin. Exactly one of ``temperature`` or ``temperature-bin`` must be present + in a trip node. + +``thermal-hw-bin`` + One or more groups of N 32-bit masks describing the hardware revisions for + which the trip point is valid, where N is the number of hardware-version + words supplied by the platform (``supported_hw_bin_count``, see below). The + format and semantics match ``opp-supported-hw``: a sub-group matches when, + for every word ``i`` in ``[0 .. N-1]``, the bitwise AND of the ``i``-th mask + and the ``i``-th platform hardware value is non-zero. The trip is enabled if + any sub-group matches. When paired with ``temperature-bin`` the number of + sub-groups must equal the number of ``temperature-bin`` entries, and the + matching sub-group selects which ``temperature-bin`` entry is used. When + ``temperature-bin`` is present, ``thermal-hw-bin`` is required. + +Example:: + + trips { + cpu-critical { + /* bin 0 throttles at 95C, bin 1 at 105C */ + temperature-bin = <95000 105000>; + thermal-hw-bin = <0x1>, <0x2>; + hysteresis = <1000>; + type = "critical"; + }; + }; + +Here the platform registers a single hardware-version word (N = 1). If that +word ANDed with ``0x1`` is non-zero, the first sub-group matches and the trip +uses 95000 mC; if it ANDed with ``0x2`` is non-zero, the second sub-group +matches and the trip uses 105000 mC. If neither matches the trip is skipped. + +Platform driver API +=================== + +A platform driver decodes the SoC fuses into hardware-version words and hands +them to the thermal core, which makes them available to the OF trip parser. +The words are carried in ``struct thermal_hw_bin_info``:: + + struct thermal_hw_bin_info { + const u32 *supported_hw_bin; + unsigned int supported_hw_bin_count; + }; + +``supported_hw_bin`` + Array of N bitfields identifying the running hardware version. + +``supported_hw_bin_count`` + Number of valid entries in ``supported_hw_bin`` (the N above). Must be in + the range ``1 .. THERMAL_HW_BIN_MAX_LEVELS``. + +Pass a filled ``struct thermal_hw_bin_info`` to +``devm_thermal_of_zone_register_with_bin()`` when registering the thermal zone. +The hardware-version information must be available at registration time because +the OF trip points are parsed synchronously during zone registration:: + + struct thermal_zone_device * + devm_thermal_of_zone_register_with_bin(struct device *dev, int id, + void *data, + const struct thermal_zone_device_ops *ops, + const struct thermal_hw_bin_info *hw_bin_info); + +The caller owns the storage referenced by ``hw_bin_info``. It only needs to +remain valid for the duration of ``devm_thermal_of_zone_register_with_bin()``, +because the OF parser consumes the values before the function returns. + +If a trip uses ``temperature-bin`` but no bin info has been provided for the +zone, the core cannot select an entry; it warns once and falls back to the +first ``temperature-bin`` value. Platform drivers should therefore provide +the bin info before the zone's trips are parsed. + +The Qualcomm tsens driver is the reference user: it reads the named nvmem +cells described by a per-SoC ``struct tsens_hw_bin_desc``, converts the raw +fuse values into hardware-version words, and passes the result to +``devm_thermal_of_zone_register_with_bin()``.
Documentation/driver-api/thermal/index.rst +1 -0
@@ -11,6 +11,7 @@ Thermal cpu-idle-cooling sysfs-api power_allocator + hardware-binning exynos_thermal exynos_thermal_emulation
MAINTAINERS +1 -0
@@ -28003,6 +28003,7 @@ F: Documentation/ABI/testing/sysfs-class-thermal F: Documentation/admin-guide/thermal/ F: Documentation/devicetree/bindings/thermal/ F: Documentation/driver-api/thermal/ +F: Documentation/driver-api/thermal/hardware-binning.rst F: drivers/thermal/ F: include/dt-bindings/thermal/ F: include/linux/cpu_cooling.h
drivers/thermal/thermal_of.c +231 -22
314 lines not on this page · raw message
include/linux/thermal.h +32 -0
@@ -86,6 +86,23 @@ struct thermal_trip {#define THERMAL_TRIP_PRIV_TO_INT (_val_) (uintptr_t)(_val_)#define THERMAL_INT_TO_TRIP_PRIV (_val_) (void *)(uintptr_t)(_val_) +/* Matches the maxItems: 4 constraint on the thermal-hw-bin binding. */ +#define THERMAL_HW_BIN_MAX_LEVELS 4 + +/** +* struct thermal_hw_bin_info - platform-specific hardware binning description +* @supported_hw_bin: array of bitfields identifying the running hardware version +* @supported_hw_bin_count: number of valid entries in @supported_hw_bin +* +* Filled by platform code that decodes SoC revision / fuse information. +* Shared with the thermal OF parser to filter trip points and select +* per-bin temperatures via the thermal-hw-bin / temperature-bin DT properties. +*/ +struct thermal_hw_bin_info { +const u32 *supported_hw_bin; +unsigned int supported_hw_bin_count; +}; +struct cooling_spec {unsigned long upper;/* Highest cooling state */ unsigned long lower;/* Lowest cooling state */
@@ -216,6 +233,12 @@ devm_thermal_of_child_cooling_device_register(struct device *dev,struct device_node *np, const char *type, void *devdata, const struct thermal_cooling_device_ops *ops); + +struct thermal_zone_device * +devm_thermal_of_zone_register_with_bin (struct device *dev,int id,void *data, +const struct thermal_zone_device_ops *ops, +const struct thermal_hw_bin_info *hw_bin_info); +#else static inline
@@ -254,6 +277,15 @@ devm_thermal_of_child_cooling_device_register(struct device *dev, {return ERR_PTR (-ENODEV ); } + +static inline struct thermal_zone_device * +devm_thermal_of_zone_register_with_bin (struct device *dev,int id,void *data, +const struct thermal_zone_device_ops *ops, +const struct thermal_hw_bin_info *hw_bin_info) +{ +return ERR_PTR (-EOPNOTSUPP ); +} +#endif int for_each_thermal_trip(struct thermal_zone_device *tz,
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v3 2/6] thermal: add hardware-binning trip-point filtering support
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Low] thermal: dead code and masked errors in thermal_of_populate_trip() bin parsing - [Low] thermal…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Low] thermal: dead code and masked errors in thermal_of_populate_trip() bin parsing
- [Low] thermal: duplicated devres logic in devm_thermal_of_zone_register_with_bin()
--
commit 587b57fa5fb124fbca43f4241cacd250c0901807
Author: Amit Kucheria <[email protected]>
thermal: add hardware-binning trip-point filtering support
This commit adds Device Tree trip-point filtering and per-bin temperature selection via the thermal-hw-bin and temperature-bin properties, along with devm_thermal_of_zone_register_with_bin() for platform drivers to supply decoded fuse masks at zone registration time.
Quoted 5 lines
drivers/thermal/thermal_of.c +0
-0@@ -57,21 +57,168 @@ static int thermal_of_get_trip_type(struct device_node *np,
[ ... ]
Quoted 34 lines
drivers/thermal/thermal_of.c +34
-0+static bool thermal_of_trip_is_supported (struct device_node *np, +const struct thermal_hw_bin_info *hw) +{ +unsigned int levels, ngroups, i; +int count; + +if (!hw) +return true; + + levels = hw->supported_hw_bin_count; + + count =of_property_count_u32_elems (np,"thermal-hw-bin" ); +if (count == -EINVAL ) +return true; +if (count <0 ) { +pr_warn_once ("%pOF: error reading thermal-hw-bin: %d\n" , np, count); +return false; + } +if (count ==0 ) +return true; + +if (count % levels) { +pr_warn ("%pOF: thermal-hw-bin length %d not a multiple of supported_hw_bin_count %u; disabling trip\n" , + np, count, levels); +return false; + } + + ngroups = count / levels; +for (i =0 ; i < ngroups; i++) +if (thermal_of_match_hw_bin_group (np, hw, levels, i)) +return true; + +return false; +}
[ ... ]
Quoted 4 lines
drivers/thermal/thermal_of.c +4
-0+static int thermal_of_trip_read_temperature (struct device_node *np, +const struct thermal_hw_bin_info *hw, +s32 *temp) +{
[ ... ]
Quoted 34 lines
drivers/thermal/thermal_of.c +25
-1+ levels = hw->supported_hw_bin_count; + count_hw =of_property_count_u32_elems (np,"thermal-hw-bin" ); +if (count_hw <=0 || count_hw % levels) +return -EINVAL ; + + ngroups = count_hw / levels; +if (count_temp != (int )ngroups) +return -EINVAL ; + +for (i =0 ; i < ngroups; i++) { +if (thermal_of_match_hw_bin_group (np, hw, levels, i)) { +u32 utmp; + +if (of_property_read_u32_index (np,"temperature-bin" , + i, &utmp)) +return -EINVAL ; + *temp = (s32 )utmp; +return 0 ; + } + } + +pr_warn ("%pOF: no thermal-hw-bin sub-group matched for temperature-bin\n" , np); +return -ENODEV ; }static int thermal_of_populate_trip (struct device_node *np, -struct thermal_trip *trip) +struct thermal_trip *trip, +const struct thermal_hw_bin_info *hw) {u32 hysteresis;s32 temperature;int ret;
drivers/thermal/thermal_of.c static int thermal_of_get_trip_type(struct device_node *np,
Quoted 10 lines
drivers/thermal/thermal_of.c +5
-4- ret =of_property_read_s32 (np,"temperature" , &temperature); -if (ret <0 ) { -pr_err ("missing temperature property\n" ); -return ret; +if (!thermal_of_trip_is_supported (np, hw)) { +pr_debug ("%pOF: trip skipped: no thermal-hw-bin match\n" , np); +return -ENODEV ; } + + ret =thermal_of_trip_read_temperature (np, hw, &temperature);
[Severity: Low]
Does calling thermal_of_trip_is_supported() before thermal_of_trip_read_temperature() leave the no-match path in thermal_of_trip_read_temperature() unreachable and mask malformed Device Tree properties?
Whenever thermal_of_trip_read_temperature() reaches its sub-group loop with a non-NULL hw, thermal_of_trip_is_supported() has already verified that count_hw % levels == 0 and that a sub-group matches, so the second loop repeats the same property reads and the trailing warning and -ENODEV return in thermal_of_trip_read_temperature() cannot be reached.
Because thermal_of_trip_is_supported() returns false on count < 0 or count % levels != 0, a temperature-bin trip with a malformed thermal-hw-bin property returns -ENODEV and is silently skipped by thermal_of_trips_init() instead of failing registration with -EINVAL, and a count_temp != ngroups mismatch is likewise hidden when no sub-group matches. In addition, of_property_count_u32_elems() returns -EINVAL both when thermal-hw-bin is absent and when its byte length is not a multiple of 4, so returning true on count == -EINVAL (without checking of_property_present()) or count == 0 enables a scalar-temperature trip with a truncated or empty thermal-hw-bin property on all hardware.
[ ... ]
Quoted 33 lines
drivers/thermal/thermal_of.c +29
-0@@ -510,6 +679,46 @@ struct thermal_zone_device *devm_thermal_of_zone_register(struct device *dev, in }EXPORT_SYMBOL_GPL (devm_thermal_of_zone_register); +/** +* devm_thermal_of_zone_register_with_bin - register a thermal zone with hardware binning info +* +* Like devm_thermal_of_zone_register(), but passes @hw_bin_info to the trip-point +* parser so that trips can be filtered and per-bin temperatures selected at +* zone registration time. Use this when fuse values are read before zone +* registration (e.g. in a platform driver's probe function). +* +* @dev: device structure pointer to sensor +* @id: the sensor identifier +* @data: private data stored in the thermal zone 'devdata' field +* @ops: ops structure associated with the sensor +* @hw_bin_info: hardware binning info for trip filtering (may be NULL) +*/ +struct thermal_zone_device * +devm_thermal_of_zone_register_with_bin (struct device *dev,int id,void *data, +const struct thermal_zone_device_ops *ops, +const struct thermal_hw_bin_info *hw_bin_info) +{ +struct thermal_zone_device **ptr, *tzd; + + ptr =devres_alloc (devm_thermal_of_zone_release,sizeof (*ptr), +GFP_KERNEL ); +if (!ptr) +return ERR_PTR (-ENOMEM ); + + tzd =thermal_of_zone_register_with_bin (dev->of_node, id, data, + ops, hw_bin_info); +if (IS_ERR (tzd)) {
drivers/thermal/thermal_of.c struct thermal_zone_device *devm_thermal_of_zone_register(struct device *dev, in · line 720
Quoted 10 lines
drivers/thermal/thermal_of.c +10
-0+devres_free (ptr); +return tzd; + } + + *ptr = tzd; +devres_add (dev, ptr); + +return tzd; +} +EXPORT_SYMBOL_GPL (devm_thermal_of_zone_register_with_bin);
[Severity: Low]
This isn't a bug, but devm_thermal_of_zone_register_with_bin() duplicates the devres handling of devm_thermal_of_zone_register(); having devm_thermal_of_zone_register() call devm_thermal_of_zone_register_with_bin(dev, sensor_id, data, ops, NULL) directly would avoid the duplication and the extra static thermal_of_zone_register() wrapper.
Also, the kernel-doc comment above places the function description before the @argument list and omits a Return: section, which causes W=2 kernel-doc warnings. In thermal_of_trip_read_temperature(), the missing hw warning uses pr_warn() on every trip node whereas hardware-binning.rst states that it warns once. Finally, the new
F: Documentation/driver-api/thermal/hardware-binning.rst line in MAINTAINERS is already covered by F: Documentation/driver-api/thermal/.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
PATCH v3 3/6 dt-bindings: thermal: qcom-tsens: document qcm6490 tsens
In reply to Gaurav KohliFrom: Amit Kucheria <[email protected]>
QCM6490 uses a tsens-v2 IP block and supports hardware-binned critical trip points. Add its compatible to the tsens-v2 enum.
SoCs that support hardware-bin critical trips read their manufacturing bin from qfprom fuse cells rather than the usual calibration cells: a single "i-temp" bit on hamoa/purwa-class parts, and a "jtag-id"/ "feat-id" pair on sc7280/qcm6490. Extend nvmem-cell-names with two oneOf branches so these fuse-cell names validate.
--- Documentation/devicetree/bindings/thermal/qcom-tsens.yaml | 8 ++++++++ 1 file changed, 8 insertions(+)
Documentation/devicetree/bindings/thermal/qcom-tsens.yaml +8 -0
@@ -66,6 +66,7 @@ properties: - qcom,msm8996-tsens - qcom,msm8998-tsens - qcom,qcm2290-tsens + - qcom,qcm6490-tsens - qcom,qcs8300-tsens - qcom,qcs615-tsens - qcom,sa8255p-tsens
@@ -245,6 +246,13 @@ properties: - pattern: '^tsens_sens[0-9]+_off$' - pattern: '^tsens_sens[0-9]+_off$' - pattern: '^tsens_sens[0-9]+_off$' + # hardware-binning fuse cells: a single i-temp bit + - items: + - const: i-temp + # hardware-binning fuse cells: jtag-id and feature-id + - items: + - const: jtag-id + - const: feat-id "#qcom,sensors": description:
Signature · 1 line
2.34.1
PATCH v3 4/6 thermal: qcom: tsens: add hardware-bin trip-point filtering
In reply to Gaurav KohliFrom: Amit Kucheria <[email protected]>
Some Qualcomm SoCs are binned at manufacturing time and expose the bin in qfprom fuses. The thermal OF parser can filter trip points by hardware version; wire tsens up to feed it.
Add the per-SoC plumbing:
- struct tsens_hw_bin_desc names the nvmem cells to read and supplies a compute_hw_version() callback that turns the raw fuse values into the hw-version bitfields consumed by the thermal OF parser. A SoC opts in by pointing tsens_plat_data.hw_bin_desc at one of these descriptors; leaving it NULL disables the feature for that SoC.
- tsens_populate_hw_bin_info() reads the named cells at probe time, invokes the callback, and stashes the result in priv->hw_bin_info. When hw_bin_desc is NULL it is a no-op, so SoCs that do not bin are unaffected.
- tsens_register() now uses devm_thermal_of_zone_register_with_bin(), passing &priv->hw_bin_info only when a bin was actually read.
Two descriptors and their SoC wiring are provided:
- tsens_hw_bin_desc_i_temp reads a single i-temp bit and reports it directly as the hw-bin value; used by data_x1e80100.
- tsens_hw_bin_desc_qcm6490 reads the jtag-id and feat-id fuses and maps the known qcm6490/sc7280 ID pairs to a synthesized hw-bin value (0x1 for the standard profile, 0x2 for the elevated profile); used by data_sc7280, which serves both the sc7280 and qcm6490 compatibles.
Register the qcm6490, sc7280 and x1e80100 compatibles in tsens_table.
--- drivers/thermal/qcom/tsens-v2.c | 16 ++++ drivers/thermal/qcom/tsens.c | 190 +++++++++++++++++++++++++++++++++++++++- drivers/thermal/qcom/tsens.h | 29 ++++++ 3 files changed, 232 insertions(+), 3 deletions(-)
drivers/thermal/qcom/tsens-v2.c +16 -0
@@ -271,6 +271,22 @@ struct tsens_plat_data data_tsens_v2 = { .fields = tsens_v2_regfields, }; +/* x1e80100: tsens-v2 with i-temp hardware-bin trip filtering */ +const struct tsens_plat_data data_x1e80100 = { + .ops = &ops_generic_v2, + .feat = &tsens_v2_feat, + .fields = tsens_v2_regfields, + .hw_bin_desc = &tsens_hw_bin_desc_i_temp, +}; + +/* sc7280/qcm6490: tsens-v2 with jtag-id/feat-id hardware-bin trip filtering */ +const struct tsens_plat_data data_sc7280 = { + .ops = &ops_generic_v2, + .feat = &tsens_v2_feat, + .fields = tsens_v2_regfields, + .hw_bin_desc = &tsens_hw_bin_desc_qcm6490, +}; +struct tsens_plat_data data_ipq8074 = { .ops = &ops_generic_v2, .feat = &ipq8074_feat,
drivers/thermal/qcom/tsens.c +187 -3
223 lines not on this page · raw message
drivers/thermal/qcom/tsens.h +29 -0
@@ -40,6 +40,29 @@ enum tsens_ver { VER_2_X_NO_RPM, }; +/** +* struct tsens_hw_bin_desc - per-SoC descriptor for hardware-bin fuse reading +* @cell_names: NULL-terminated array of nvmem cell names to read +* @ncells: number of entries in @cell_names +* @compute_hw_version: callback that converts raw fuse values to hw-version +* bitfields for thermal OF trip filtering +* +* Embed a pointer to this struct in tsens_plat_data.hw_bin_desc to enable +* hardware-bin trip filtering for a given SoC. Set to NULL to disable. +*/ +struct tsens_hw_bin_desc { +const char *const *cell_names; +unsigned int ncells; +int (*compute_hw_version)(struct device *dev, +const u32 *fuse,unsigned int nfuse, +u32 *hw,unsigned int *count); +}; + +#define TSENS_HW_BIN_MAX_CELLS 8 + +extern const struct tsens_hw_bin_desc tsens_hw_bin_desc_qcm6490; +extern const struct tsens_hw_bin_desc tsens_hw_bin_desc_i_temp; +enum tsens_irq_type {LOWER ,UPPER ,
@@ -533,6 +556,7 @@ struct tsens_features {* @feat: features of the IP * @fields: bitfield locations * @no_irq_wake: if set, TSENS interrupts will not be configured as wakeup sources +* @hw_bin_desc: optional hardware-bin fuse descriptor for trip filtering */ struct tsens_plat_data {const u32 num_sensors;
@@ -541,6 +565,7 @@ struct tsens_plat_data {struct tsens_features *feat;const struct reg_field *fields;bool no_irq_wake; +const struct tsens_hw_bin_desc *hw_bin_desc; };/**
@@ -568,6 +593,7 @@ struct tsens_context {* @feat: features of the IP * @fields: bitfield locations * @ops: pointer to list of callbacks supported by this device +* @hw_bin_info: hardware binning info read from SoC fuse (populated at probe) * @debug_root: pointer to debugfs dentry for all tsens * @debug: pointer to debugfs dentry for tsens controller * @uplow_irq: IRQ number for uplow (upper/lower) threshold interrupts
@@ -591,6 +617,8 @@ struct tsens_priv {const struct reg_field *fields;const struct tsens_ops *ops; +struct thermal_hw_bin_info hw_bin_info; +struct dentry *debug_root;struct dentry *debug;
@@ -677,6 +705,7 @@ extern const struct tsens_plat_data data_ipq5018;/* TSENS v2 targets */ extern struct tsens_plat_data data_8996, data_ipq8074, data_tsens_v2;extern const struct tsens_plat_data data_ipq5332, data_ipq5424; +extern const struct tsens_plat_data data_x1e80100, data_sc7280;/* TSENS automotive targets */ extern struct tsens_plat_data data_automotive_v2;
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v3 4/6] thermal: qcom: tsens: add hardware-bin trip-point filtering
Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] thermal: qcom: tsens: broken error handling in tsens_populate_hw_bin_info() - [Low] thermal: qcom…
Thank you for your contribution! Sashiko AI review found 3 potential issues to consider:
- [Medium] thermal: qcom: tsens: broken error handling in tsens_populate_hw_bin_info()
- [Low] thermal: qcom: tsens: inaccurate cell_names kernel-doc in tsens_hw_bin_desc
- [Low] thermal: qcom: tsens: inaccurate i-temp description in commit message
--
commit 65356a4ab856b03d856c9e9331810962e03057df
Author: Amit Kucheria <[email protected]>
thermal: qcom: tsens: add hardware-bin trip-point filtering
This commit reads hardware-binning qfprom fuse cells at probe time and passes the computed hardware version bitfields to the thermal OF parser for qcm6490, sc7280, and x1e80100 TSENS controllers.
Quoted 2 lines
-
tsens_hw_bin_desc_i_tempreads a single i-temp bit and reports it directly as the hw-bin value; used bydata_x1e80100.
[Severity: Low]
Is this description of tsens_hw_bin_desc_i_temp accurate?
tsens_compute_hw_version_i_temp() maps bit 0 of the fuse to the bitmask values 0x1u (standard bin) or 0x2u (high-temp bin) rather than reporting the raw bit value directly.
Quoted 4 lines
drivers/thermal/qcom/tsens.c +0
-0
[ ... ]
Quoted 90 lines
drivers/thermal/qcom/tsens.c +90
-0+static const char *const tsens_cells_qcm6490[] = {"jtag-id" ,"feat-id" }; +static const char *const tsens_cells_i_temp[] = {"i-temp" }; + +const struct tsens_hw_bin_desc tsens_hw_bin_desc_qcm6490 = { + .cell_names = tsens_cells_qcm6490, + .ncells =ARRAY_SIZE (tsens_cells_qcm6490), + .compute_hw_version = tsens_compute_hw_version_qcm6490, +}; + +const struct tsens_hw_bin_desc tsens_hw_bin_desc_i_temp = { + .cell_names = tsens_cells_i_temp, + .ncells =ARRAY_SIZE (tsens_cells_i_temp), + .compute_hw_version = tsens_compute_hw_version_i_temp, +}; + +/** +* tsens_populate_hw_bin_info - read fuse cells and populate priv->hw_bin_info +* @priv: tsens private data +* @data: platform data containing the optional hw_bin_desc pointer +* +* If data->hw_bin_desc is NULL, this is a no-op and returns 0. Otherwise, +* reads the nvmem cells named in hw_bin_desc->cell_names, calls the +* compute_hw_version() callback, and stores the result in priv->hw_bin_info +* for later use by tsens_register(). +* +* Return: 0 on success, negative errno on failure. +*/ +static int tsens_populate_hw_bin_info (struct tsens_priv *priv, +const struct tsens_plat_data *data) +{ +const struct tsens_hw_bin_desc *desc; +u32 fuse_vals[TSENS_HW_BIN_MAX_CELLS ]; +u32 hw_versions[THERMAL_HW_BIN_MAX_LEVELS ] = {0 }; +unsigned int hw_count =0 ; +int i, ret; + +if (!data->hw_bin_desc) +return 0 ; + + desc = data->hw_bin_desc; + +if (!desc->ncells || desc->ncells >TSENS_HW_BIN_MAX_CELLS ) { +dev_err (priv->dev,"hw_bin_desc ncells %u out of range\n" , + desc->ncells); +return -EINVAL ; + } + +for (i =0 ; i < (int )desc->ncells; i++) { + ret =nvmem_cell_read_variable_le_u32 (priv->dev, + desc->cell_names[i], + &fuse_vals[i]); +if (ret <0 ) { +dev_err (priv->dev, +"failed to read nvmem cell '%s': %d\n" , + desc->cell_names[i], ret); +return ret; + } + } + + ret = desc->compute_hw_version (priv->dev, fuse_vals, desc->ncells, + hw_versions, &hw_count); +if (ret) { +dev_err (priv->dev,"compute_hw_version failed: %d\n" , ret); +return ret; + } + +if (!hw_count || hw_count >THERMAL_HW_BIN_MAX_LEVELS ) { +dev_err (priv->dev, +"compute_hw_version returned invalid hw_count %u\n" , + hw_count); +return -EINVAL ; + } + +/* +* Store a copy of the hw-version array in priv->hw_bin_info so +* tsens_register() can pass it to the thermal OF parser while trips are +* parsed. +* +* Use devm_kmemdup so the copy is freed when the device is unbound. +*/ + priv->hw_bin_info.supported_hw_bin =devm_kmemdup (priv->dev, hw_versions, + hw_count *sizeof (u32), +GFP_KERNEL ); +if (!priv->hw_bin_info.supported_hw_bin) +return -ENOMEM ; + + priv->hw_bin_info.supported_hw_bin_count = hw_count; + +return 0 ; +}
[ ... ]
Quoted 5 lines
drivers/thermal/qcom/tsens.c +1
-0@@ -1443,6 +1619,14 @@ static int tsens_probe_common(struct platform_device *pdev) priv->feat = data->feat; priv->fields = data->fields; + ret =tsens_populate_hw_bin_info (priv, data);
drivers/thermal/qcom/tsens.c static int tsens_probe_common(struct platform_device *pdev) · line 1632
Quoted 10 lines
drivers/thermal/qcom/tsens.c +7
-0+if (ret == -EPROBE_DEFER ) +return ret; +if (ret) +dev_warn (&pdev->dev, +"thermal-bin failed to read FUSE data (%d): trips with temperature-bin will use first entry\n" , + ret); +platform_set_drvdata (pdev, priv);device_init_wakeup (dev, !data->no_irq_wake);
[Severity: Medium]
Does tsens_populate_hw_bin_info() log a dev_err() on -EPROBE_DEFER before tsens_probe_common() checks for probe deferral?
When TSENS probes before the qfprom nvmem provider, nvmem_cell_read_variable_le_u32() returns -EPROBE_DEFER and tsens_populate_hw_bin_info() emits an error message on every deferred probe attempt. When booting with existing sc7280 or x1e80100 DTBs that do not define the optional nvmem-cells for hardware binning, nvmem_cell_read_variable_le_u32() returns -ENOENT, causing both the dev_err() in tsens_populate_hw_bin_info() and the dev_warn() in tsens_probe_common() (which also passes &pdev->dev instead of dev) to be printed. In addition, if devm_kmemdup() returns -ENOMEM, tsens_probe_common() treats it as a non-fatal fuse read warning instead of failing probe.
Quoted 15 lines
drivers/thermal/qcom/tsens.h +7
-0@@ -40,6 +40,29 @@ enum tsens_ver { VER_2_X_NO_RPM, }; +/** +* struct tsens_hw_bin_desc - per-SoC descriptor for hardware-bin fuse reading +* @cell_names: NULL-terminated array of nvmem cell names to read +* @ncells: number of entries in @cell_names +* @compute_hw_version: callback that converts raw fuse values to hw-version +* bitfields for thermal OF trip filtering +*
drivers/thermal/qcom/tsens.h enum tsens_ver { · line 59
Quoted 10 lines
drivers/thermal/qcom/tsens.h +10
-0+* Embed a pointer to this struct in tsens_plat_data.hw_bin_desc to enable +* hardware-bin trip filtering for a given SoC. Set to NULL to disable. +*/ +struct tsens_hw_bin_desc { +const char *const *cell_names; +unsigned int ncells; +int (*compute_hw_version)(struct device *dev, +const u32 *fuse,unsigned int nfuse, +u32 *hw,unsigned int *count); +};
[Severity: Low]
Should the kernel-doc for @cell_names drop "NULL-terminated"?
tsens_cells_qcm6490 and tsens_cells_i_temp are not NULL-terminated and size @ncells with ARRAY_SIZE(), while tsens_populate_hw_bin_info() iterates from 0 to desc->ncells - 1. If a future descriptor follows the comment and NULL-terminates cell_names while using ARRAY_SIZE() for ncells, the NULL sentinel will be passed as cell_id to nvmem_cell_read_variable_le_u32().
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
PATCH v3 5/6 arm64: dts: qcom: kodiak: use thermal hw-bin trips
In reply to Gaurav KohliFrom: Amit Kucheria <[email protected]>
kodiak-based SoCs are binned at manufacturing time, with the bin computed from the jtag-id and feat-id qfprom fuses. The tsens driver now reads these and feeds the resulting bin to the thermal core, which selects per-bin trip temperatures.
Add the jtag-id and feat-id nvmem cells to the tsens nodes and convert the passive mitigation trip points from a fixed 95C to per-bin values (95C for bin 0x1, 105C for bin 0x2) using the new temperature-bin/thermal-hw-bin properties.
--- arch/arm64/boot/dts/qcom/kodiak.dtsi | 58 +++++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 14 deletions(-)
arch/arm64/boot/dts/qcom/kodiak.dtsi +44 -14
@@ -1028,6 +1028,18 @@ gpu_speed_bin: gpu-speed-bin@1e9 { reg = <0x1e9 0x2>; bits = <5 8>; }; + + jtag_id: jtag-id@180 { + reg = <0x180 0x4>; + /* bits = <offset width>: 20 bits at offset 0 */ + bits = <0 20>; + }; + + feat_id: feat-id@180 { + reg = <0x180 0x4>; + /* bits = <offset width>: 8 bits at offset 20 */ + bits = <20 8>; + }; }; sdhc_1: mmc@7c4000 {
@@ -5810,6 +5822,8 @@ tsens0: thermal-sensor@c263000 { compatible = "qcom,sc7280-tsens","qcom,tsens-v2"; reg = <0 0x0c263000 0 0x1ff>, /* TM */ <0 0x0c222000 0 0x1ff>; /* SROT */ + nvmem-cells = <&jtag_id>, <&feat_id>; + nvmem-cell-names = "jtag-id", "feat-id"; #qcom,sensors = <15>; interrupts = <GIC_SPI 506 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 508 IRQ_TYPE_LEVEL_HIGH>;
@@ -5821,6 +5835,8 @@ tsens1: thermal-sensor@c265000 { compatible = "qcom,sc7280-tsens","qcom,tsens-v2"; reg = <0 0x0c265000 0 0x1ff>, /* TM */ <0 0x0c223000 0 0x1ff>; /* SROT */ + nvmem-cells = <&jtag_id>, <&feat_id>; + nvmem-cell-names = "jtag-id", "feat-id"; #qcom,sensors = <12>; interrupts = <GIC_SPI 507 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 509 IRQ_TYPE_LEVEL_HIGH>;
@@ -7164,7 +7180,8 @@ cpu0_alert0: trip-point0 { }; cpu0_alert1: trip-point1 { - temperature = <95000>; + temperature-bin = <95000>, <105000>; + thermal-hw-bin = <0x1>, <0x2>; hysteresis = <2000>; type = "passive"; };
@@ -7207,7 +7224,8 @@ cpu1_alert0: trip-point0 { }; cpu1_alert1: trip-point1 { - temperature = <95000>; + temperature-bin = <95000>, <105000>; + thermal-hw-bin = <0x1>, <0x2>; hysteresis = <2000>; type = "passive"; };
@@ -7250,7 +7268,8 @@ cpu2_alert0: trip-point0 { }; cpu2_alert1: trip-point1 { - temperature = <95000>; + temperature-bin = <95000>, <105000>; + thermal-hw-bin = <0x1>, <0x2>; hysteresis = <2000>; type = "passive"; };
@@ -7293,7 +7312,8 @@ cpu3_alert0: trip-point0 { }; cpu3_alert1: trip-point1 { - temperature = <95000>; + temperature-bin = <95000>, <105000>; + thermal-hw-bin = <0x1>, <0x2>; hysteresis = <2000>; type = "passive"; };
@@ -7336,7 +7356,8 @@ cpu4_alert0: trip-point0 { }; cpu4_alert1: trip-point1 { - temperature = <95000>; + temperature-bin = <95000>, <105000>; + thermal-hw-bin = <0x1>, <0x2>; hysteresis = <2000>; type = "passive"; };
@@ -7379,7 +7400,8 @@ cpu5_alert0: trip-point0 { }; cpu5_alert1: trip-point1 { - temperature = <95000>; + temperature-bin = <95000>, <105000>; + thermal-hw-bin = <0x1>, <0x2>; hysteresis = <2000>; type = "passive"; };
@@ -7422,7 +7444,8 @@ cpu6_alert0: trip-point0 { }; cpu6_alert1: trip-point1 { - temperature = <95000>; + temperature-bin = <95000>, <105000>; + thermal-hw-bin = <0x1>, <0x2>; hysteresis = <2000>; type = "passive"; };
@@ -7465,7 +7488,8 @@ cpu7_alert0: trip-point0 { }; cpu7_alert1: trip-point1 { - temperature = <95000>; + temperature-bin = <95000>, <105000>; + thermal-hw-bin = <0x1>, <0x2>; hysteresis = <2000>; type = "passive"; };
@@ -7508,7 +7532,8 @@ cpu8_alert0: trip-point0 { }; cpu8_alert1: trip-point1 { - temperature = <95000>; + temperature-bin = <95000>, <105000>; + thermal-hw-bin = <0x1>, <0x2>; hysteresis = <2000>; type = "passive"; };
@@ -7551,7 +7576,8 @@ cpu9_alert0: trip-point0 { }; cpu9_alert1: trip-point1 { - temperature = <95000>; + temperature-bin = <95000>, <105000>; + thermal-hw-bin = <0x1>, <0x2>; hysteresis = <2000>; type = "passive"; };
@@ -7594,7 +7620,8 @@ cpu10_alert0: trip-point0 { }; cpu10_alert1: trip-point1 { - temperature = <95000>; + temperature-bin = <95000>, <105000>; + thermal-hw-bin = <0x1>, <0x2>; hysteresis = <2000>; type = "passive"; };
@@ -7637,7 +7664,8 @@ cpu11_alert0: trip-point0 { }; cpu11_alert1: trip-point1 { - temperature = <95000>; + temperature-bin = <95000>, <105000>; + thermal-hw-bin = <0x1>, <0x2>; hysteresis = <2000>; type = "passive"; };
@@ -7752,7 +7780,8 @@ gpuss0-thermal { trips { gpuss0_alert0: trip-point0 { - temperature = <95000>; + temperature-bin = <95000>, <105000>; + thermal-hw-bin = <0x1>, <0x2>; hysteresis = <2000>; type = "passive"; };
@@ -7779,7 +7808,8 @@ gpuss1-thermal { trips { gpuss1_alert0: trip-point0 { - temperature = <95000>; + temperature-bin = <95000>, <105000>; + thermal-hw-bin = <0x1>, <0x2>; hysteresis = <2000>; type = "passive"; };
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v3 5/6] arm64: dts: qcom: kodiak: use thermal hw-bin trips
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] arm64: dts: qcom: kodiak: duplicate @180 unit-address in qfprom --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] arm64: dts: qcom: kodiak: duplicate @180 unit-address in qfprom --
commit e6d4eae865bd91c0bd0f76066337d957b0861f51
Author: Amit Kucheria <[email protected]>
arm64: dts: qcom: kodiak: use thermal hw-bin trips
This commit adds jtag-id and feat-id nvmem cells to the tsens nodes in kodiak.dtsi and converts passive mitigation trip points to per-bin temperature values.
Quoted 11 lines
arch/arm64/boot/dts/qcom/kodiak.dtsi +3
-0@@ -1028,6 +1028,18 @@ gpu_speed_bin: gpu-speed-bin@1e9 { reg = <0x1e9 0x2>; bits = <5 8>; }; + + jtag_id: jtag-id@180 { + reg = <0x180 0x4>;
arch/arm64/boot/dts/qcom/kodiak.dtsi gpu_speed_bin: gpu-speed-bin@1e9 { · line 1043
Quoted 10 lines
arch/arm64/boot/dts/qcom/kodiak.dtsi +9
-0+ /* bits = <offset width>: 20 bits at offset 0 */ + bits = <0 20>; + }; + + feat_id: feat-id@180 { + reg = <0x180 0x4>; + /* bits = <offset width>: 8 bits at offset 20 */ + bits = <20 8>; + }; };
[Severity: Low]
Does giving both jtag-id@180 and feat-id@180 the same @180 unit-address trigger a dtc unique_unit_address warning when building DTBs with W=1?
qfprom_fixup_dt_cell_info() aligns byte-addressed QFPROM cells to 4-byte words at runtime, so feat-id can be described at its starting byte offset (feat-id@182 with reg = <0x182 0x2> and bits = <4 8>, and jtag-id@180 with reg = <0x180 0x3>), placed before gpu-speed-bin@1e9 in ascending unit-address order.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
PATCH v3 6/6 arm64: dts: qcom: hamoa: add thermal hw-bin support
In reply to Gaurav KohliFrom: Amit Kucheria <[email protected]>
hamoa-based SoCs expose their manufacturing bin in a single i-temp bit of a qfprom fuse. Add the i-temp nvmem cell to the qfprom node and wire the tsens controllers to it so the tsens driver can feed the bin to the thermal core.
Use that bin for the GPU passive trip points so industrial-temp parts keep the higher 105C threshold without a board-specific override.
--- arch/arm64/boot/dts/qcom/hamoa-iot-evk.dts | 66 ------------------------------ arch/arm64/boot/dts/qcom/hamoa.dtsi | 42 +++++++++++++++---- 2 files changed, 34 insertions(+), 74 deletions(-)
arch/arm64/boot/dts/qcom/hamoa-iot-evk.dts +0 -66
@@ -1478,72 +1478,6 @@ &usb_mp_hsphy1 { phys = <&eusb6_repeater>; }; -&thermal_zones { - gpuss-0-thermal { - trips { - trip-point0 { - temperature = <105000>; - }; - }; - }; - - gpuss-1-thermal { - trips { - trip-point0 { - temperature = <105000>; - }; - }; - }; - - gpuss-2-thermal { - trips { - trip-point0 { - temperature = <105000>; - }; - }; - }; - - gpuss-3-thermal { - trips { - trip-point0 { - temperature = <105000>; - }; - }; - }; - - gpuss-4-thermal { - trips { - trip-point0 { - temperature = <105000>; - }; - }; - }; - - gpuss-5-thermal { - trips { - trip-point0 { - temperature = <105000>; - }; - }; - }; - - gpuss-6-thermal { - trips { - trip-point0 { - temperature = <105000>; - }; - }; - }; - - gpuss-7-thermal { - trips { - trip-point0 { - temperature = <105000>; - }; - }; - }; -}; - &nsp0_alert0 { temperature = <105000>; };
arch/arm64/boot/dts/qcom/hamoa.dtsi +34 -8
120 lines not on this page · raw message
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v3 6/6] arm64: dts: qcom: hamoa: add thermal hw-bin support
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] arm64: dts: qcom: hamoa: leftover temperature overrides shadow temperature-bin --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] arm64: dts: qcom: hamoa: leftover temperature overrides shadow temperature-bin
--
commit 35a11d22a7dfa97cb85bfddd513a803ab8607fca
Author: Amit Kucheria <[email protected]>
arm64: dts: qcom: hamoa: add thermal hw-bin support
This commit adds the i-temp nvmem cell to hamoa.dtsi, wires the tsens controllers to it, and switches the GPU passive trip points to use temperature-bin and thermal-hw-bin instead of board-specific overrides.
Quoted 4 lines
arch/arm64/boot/dts/qcom/hamoa.dtsi +0
-0
[ ... ]
arch/arm64/boot/dts/qcom/hamoa.dtsi map0 { · line 9776
Quoted 10 lines
arch/arm64/boot/dts/qcom/hamoa.dtsi +2
-1@@ -9751,7 +9769,8 @@ map0 { trips { gpuss0_alert0: trip-point0 { - temperature = <95000>; + temperature-bin = <95000>, <105000>; + thermal-hw-bin = <0x1>, <0x2>; hysteresis = <1000>; type = "passive"; };
[Severity: Medium]
Should the GPU trip-point0 temperature overrides also be removed from hamoa-advantech-som-db5830.dts, hamoa-som-db5830.dts, and purwa-iot-evk.dts?
Those boards include hamoa.dtsi and still set temperature = <105000> on their GPU trip-point0 nodes. Because temperature and temperature-bin are distinct properties, the compiled DTBs retain both on the same trip node, which violates the oneOf schema constraint in thermal-zones.yaml and causes thermal_of_trip_read_temperature() to read the scalar temperature property first, bypassing temperature-bin selection on standard-bin parts.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6