Skip to content

base: AxThermal: Apply caps via sysfs when ax_atcm is unavailable - #66

Open
Zarathos30 wants to merge 278 commits into
AxionAOSP:lineage-23.2from
Zarathos30:lineage-23.2
Open

Zarathos30 wants to merge 278 commits into
AxionAOSP:lineage-23.2from
Zarathos30:lineage-23.2

Conversation

@Zarathos30

Copy link
Copy Markdown

Load the thermal config from system_ext, parse the mid cluster and, when /proc/ax_atcm is missing, write the CPU/GPU caps directly to the cpufreq and kgsl devfreq nodes.

Change-Id: I0cac965d899a839bb0b01d1c73198eb619a50bb8

rmp22 and others added 30 commits July 17, 2026 10:20
Change-Id: Ieec1869bac37104cd8733278865cf44e773b8971
Signed-off-by: rmp22 <195054967+rmp22@users.noreply.github.com>
Change-Id: I003b0ef78309bbf18f0c7bf3d877102108f9931f
Change-Id: Ibd33774d989760d9d8e9fc997c7452f0c5a0de93
Signed-off-by: rmp22 <195054967+rmp22@users.noreply.github.com>
Change-Id: I64d455835389acb2e591ff0b623797e1e122f06d
Signed-off-by: rmp22 <195054967+rmp22@users.noreply.github.com>
Change-Id: I0b0fde47bdd0936dff3fd6dc0289109e4a16b146
neobuddy89: Adapted for A14 QPR3

Change-Id: I03b93f04dcc49199a6cfaf9e5bd8b18512f679a3
Signed-off-by: cjybyjk <cjybyjk@zjnu.edu.cn>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
Signed-off-by: Saikrishna1504 <saikrishna26918@gmail.com>
removed systemui changes, not needed on axion dialog provider UX
Co-authored-by: rmp22 <195054967+rmp22@users.noreply.github.com>
Change-Id: Ib474f2c0e30ba749f38baec11b195e3fa921ddcc
Signed-off-by: rmp22 <195054967+rmp22@users.noreply.github.com>
Change-Id: I5d48dac62103e886a92789c8107f62f152dac7ba
Change-Id: I03e9a19d82e63ed27513ce78af108cf7346c12b0
Change-Id: I07877a13d3af39eea89423408c6a5d39b2ae5a6c
Change-Id: I975194e6b32beb3b7f05975201eedb16d5cf7671
Change-Id: Iae015cd4b5627c47fb0f1b0cb1e3e24e77f0834e
Change-Id: Idb82eb87493dc8820ce0753e5d9b866c85f9a965
Change-Id: I18e9e0210d9faed1e3d38f504453e6298f6c3ffe
Signed-off-by: rmp22 <195054967+rmp22@users.noreply.github.com>
Change-Id: Iaddb62979c2e23189432ba4c9884d8b568418ad9
Change-Id: Ib69186029632cca1e8252f1e4615170992b9420d
Change-Id: Idd080a378e47720b208d182e59efb1f514870fc4
Change-Id: I05bed71b667b0c8eef755747763d90cd745dda3d
Change-Id: I2eee52aefe7bac3a867af456860afa41608a6854
Signed-off-by: rmp22 <195054967+rmp22@users.noreply.github.com>
Change-Id: I6188ec32e0f893336a04b3632dd70f72fb312ca8
icons from: a799a35 "base: Refactor Wi-Fi standard icons"

rmp - rewrite from scratch - use MVVM - avoid memory leaks - add support for multiple instances (QS->StatusBar)

Change-Id: Ic2022153e3188e419c9a0be3bba51d6863ee89ae
Change-Id: I3870f7c88ec58725f045af04dc895fd50e9e6cf4
Change-Id: Ia54dbeadea712be50667891b4f29f40ae31ee3a1
Change-Id: I7efc0eec7596661e978f4a752168daad8ba9d864
Change-Id: Ie0e19f995f7e5d455d7e26689dc8428ff57685fe
Change-Id: Ib9420f5fb7dd0f249c6703a60b151b78fd6a5c24
Signed-off-by: rmp22 <195054967+rmp22@users.noreply.github.com>
Change-Id: I7beba5dda3d3e19e02a22b327591fef36dd7806e
Change-Id: Iaaf20bcbaa50c42dd6b7739ae233b245a2c5ad5c
Change-Id: Ibe120515b2a8c764c734f733fa8b9288e08e9c40
Signed-off-by: rmp22 <195054967+rmp22@users.noreply.github.com>
Change-Id: Ia754feadff534a29c08306f57afbc860ea8ef70b

credit
HMA OSS | Furkan Karcıoğlu

Co-authored-by: Furkan Karcıoğlu <45714956+frknkrc44@users.noreply.github.com>
Co-auhtored-by: Saikrishna1504 <saikrishna26918@gmail.com>
Change-Id: I4531975e10894b46807db7c3fdebf0203ffbca77
Signed-off-by: rmp22 <195054967+rmp22@users.noreply.github.com>
rmp22 and others added 24 commits July 19, 2026 11:35
Change-Id: I243e9da4c3fa7bcc973ad97d50d2e79384aaa4b0
Change-Id: I56bd6d4d7164eaff8850e1f079b6a9bd4de84e89
Signed-off-by: rmp22 <195054967+rmp22@users.noreply.github.com>
QS: add Reset button in Axion QS editor
Change-Id: Ie70428a45e121f9c2169218b19e2b1a9fa2a02a0
Change-Id: I00f690d794a797cc0cea2455eb06af5b1fbc8afe
Signed-off-by: rmp22 <195054967+rmp22@users.noreply.github.com>
Change-Id: I12e7051e07eb7aab6ef0d963dd2e0149a0f5c032
Signed-off-by: Saikrishna1504 <saikrishna26918@gmail.com>
Signed-off-by: Saikrishna1504 <saikrishna26918@gmail.com>
Signed-off-by: Saikrishna1504 <saikrishna26918@gmail.com>
Change-Id: I804d2d4dc55e459a85bf87e18c6ad771c051cc87
Signed-off-by: Saikrishna1504 <saikrishna26918@gmail.com>
* Similar to IOS ...we can control flashbangs a bit.
* Only works for devices which supports variable strengths ..older devices with binary straight away fallback to standard way.

Change-Id: I42e9f39d6cf14d4e986db959333b46a1584cf422
Signed-off-by: Saikrishna1504 <saikrishna26918@gmail.com>
Change-Id: Iebc6bb89d9431dde8f418c21ea70389b925ec2a1
Change-Id: If2df64342d3d3b6af3e98884e3e6baafda549af8
Change-Id: Id0babaa9d7afcbc811c8448eeb1a40722eaadeb3
Change-Id: Ib51fbca873460b40762feee195bfb27a1e92f8eb
Change-Id: Ia2f8c699ef3d3dc07fb56b8f0dcfe3e5f9b33777
…pecs

Change-Id: I607ac1dca5979538402b110fb6030ba0e3138078
adding split shade scene | qs scenes recoil animation | fixing scroll issues | fixing ui issues
Change-Id: Ib5c7841dff88e758adb14c5049d5566ee734e497
Change-Id: Ia8c0c40c149c426e9503e670d6ae141428948ba5
Signed-off-by: Saikrishna1504 <saikrishna26918@gmail.com>
* Original commit gutted out entire codes in shouldBlockDirectoryFromTree
  which could be lead to major privacy leakage
  due to those invasive apps' behavior

* Add toggle instead so that users could opt in/out

Original commit msg:
    ExternalStorageProvider: Remove SAF restrictions

    * Inspired by https://github.com/DanGLES3/NoStorageRestrict

    Change-Id: I073d9bb8edd49224e17c76a43683365a64686768
    Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
    Signed-off-by: Gustavo Mendes <gusttavo.me@outlook.com>

Change-Id: I9f987b7dae80af95275f743cfbc935582ff2129e
Signed-off-by: someone5678 <someone5678@users.noreply.github.com>
Signed-off-by: Ghosuto <clash.raja10@gmail.com>
Signed-off-by: Saikrishna1504 <saikrishna26918@gmail.com>
Signed-off-by: Varakumar <varakumar7000@gmail.com>
Signed-off-by: Saikrishna1504 <saikrishna26918@gmail.com>
Change-Id: Ie58c13e6db7d23a87ae48902b5eb4302aa453f2d
Signed-off-by: Saikrishna1504 <saikrishna26918@gmail.com>
Load the thermal config from system_ext, parse the mid cluster and,
when /proc/ax_atcm is missing, write the CPU/GPU caps directly to the
cpufreq and kgsl devfreq nodes.

Change-Id: I0cac965d899a839bb0b01d1c73198eb619a50bb8
Signed-off-by: Zarathos30 <vale.rigni@gmail.com>
Copilot AI lite review requested due to automatic review settings September 14, 2026 09:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

One or more issues must be addressed before approval.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Extends AxThermal configuration with mid-cluster support and adds direct CPU/GPU sysfs fallback when ax_atcm is unavailable.

Changes:

  • Adds mid-cluster parsing and policy handling.
  • Loads thermal configuration from system_ext.
  • Applies and restores CPU/GPU frequency caps through sysfs.
File summaries
File Description
services/core/java/com/android/server/thermal/AxAdvancedThermalMitigationConfig.java Updated as part of this pull request.
services/core/java/com/android/server/am/AxThermalBoostPolicy.java Updated as part of this pull request.
services/core/java/com/android/server/am/AxThermalApplier.java Updated as part of this pull request.
services/core/java/com/android/server/am/AxPerfConfig.java Updated as part of this pull request.
Review details

Suppressed comments (9)

services/core/java/com/android/server/am/AxPerfConfig.java:95

  • Because these loads are short-circuited, any existing /vendor/etc/ax_perf_thermal.xml prevents the new system_ext file from being parsed. That makes device-specific system_ext mid-cluster settings ineffective; the existing kernel configuration loader gives system_ext precedence over vendor (AxKernelManagerService.java:83-86), so this order should be reversed.
        boolean loaded = loadFrom(VENDOR_THERMAL_CONFIG, ATMC_TAG)
                || loadFrom(SYSTEM_EXT_THERMAL_CONFIG, ATMC_TAG)
                || loadFrom(SYSTEM_THERMAL_CONFIG, ATMC_TAG);

services/core/java/com/android/server/am/AxThermalApplier.java:86

  • If the direct sink handled an update while /proc/ax_atcm/state was absent, a later update that sees the file appear switches to writeStateLocked() without restoring the nodes recorded in mSavedValues. The direct CPU/GPU caps then remain active in addition to the kernel-module state; restore the direct sink before switching modes (and handle the reverse transition as well).
            if (new File(ATCM_STATE_PATH).exists()) {
                writeStateLocked(level, cpuCap, gpuCap, boostCap);
            } else {
                applyCpuCapsLocked(cpuCap);
                applyGpuCapsLocked(gpuCap);
            }

services/core/java/com/android/server/am/AxThermalApplier.java:167

  • When the applied floor was clamped down to the ceiling above, restoring min_freq before max_freq can violate the cpufreq min<=max constraint (for example, when the user's original minimum exceeds the thermal maximum). Restore the maximum first, just as the apply path does, so the original minimum can be accepted.
                restoreNode(sink.minPath, userMin);
                restoreNode(sink.maxPath, userMax);

services/core/java/com/android/server/am/AxThermalApplier.java:196

  • The GPU restore has the same ordering problem: if the thermal floor was clamped to a lower ceiling, writing the saved minimum while the saved maximum is still restricted can fail. Restore max_freq before min_freq here as well.
            restoreNode(minPath, userFrequency(minPath));
            restoreNode(maxPath, userFrequency(maxPath));

services/core/java/com/android/server/am/AxThermalApplier.java:287

  • The saved entry is removed before the sysfs write. A transient restore failure therefore makes all later no-cap updates return at the containsKey check, leaving the thermal value in the node permanently; retain the entry until the write succeeds so restoration is retried.
        final String saved = mSavedValues.remove(path);
        mAppliedValues.remove(path);

services/core/java/com/android/server/am/AxThermalApplier.java:194

  • CPU cap 0 is treated as inactive in applyCpuCapsLocked(), but GPU cap 0 is treated as an active level here. Since the dispatcher considers every status other than -1 valid, a configuration with a level-0 GPU entry can apply that entry instead of clearing the fallback cap; use the same inactive condition as the CPU path.
        if (gpuCap < 0 || (thermalMin <= 0L && thermalMax <= 0L)) {

services/core/java/com/android/server/am/AxThermalApplier.java:288

  • userFrequency() reads a persist.sys.km.<hash> property, but AxKernelManagerService.setControlValue() records frequency changes in Settings.Secure and never writes that property. A user change made while this cap is active is therefore not seen here, so removing the cap restores the old snapshot over the user's selection. Persist and read the user target through one shared source before restoring.
        final long value = userValue > 0L ? userValue : parseLong(saved);

services/core/java/com/android/server/am/AxThermalApplier.java:179

  • When a later CPU level supplies only one bound (or the discovered sink has no base bound), the other computed bound is 0 and no write occurs. That leaves the value written by the previous thermal level in sysfs, so a removed max/min cap remains active; restore the corresponding node when its computed bound is absent.
            if (ceiling > 0L) {
                writeNode(sink.maxPath, ceiling);
            }
            if (floor > 0L) {
                writeNode(sink.minPath, floor);

services/core/java/com/android/server/am/AxThermalApplier.java:208

  • The same missing-bound case exists for GPU caps: if a subsequent GPU level omits max or min, this code does not restore the value previously written by an earlier level. The old devfreq limit can therefore remain in force after the configuration removes it; restore each node when its computed bound is non-positive.
        if (ceiling > 0L) {
            writeNode(maxPath, ceiling);
        }
        if (floor > 0L) {
            writeNode(minPath, floor);
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +164 to +165
if (cpuCap <= 0 || (sink.baseMin <= 0L && sink.baseMax <= 0L
&& thermalMin <= 0L && thermalMax <= 0L)) {
@rmp22
rmp22 force-pushed the lineage-23.2 branch 2 times, most recently from 6420f01 to 90f0522 Compare September 17, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.