================================================================ IPA v2.6L — power-save: dynamic clock scaling + ipa_rm graph ================================================================ Incremental patch. Apply ON TOP OF the 6.19 IPA port: patch -p1 < patches/sdm660-ipa-port-4.19-to-6.19.nosondy.patch patch -p1 < patches/sdm660-ipa-port-6.19-powersave.patch # <-- this WHAT IT DOES Re-enables the IPA core-clock dynamic scaling that the base port pinned off (ipa_ctx->enable_clock_scaling = 0), and couples it to the IPA Resource Manager (ipa_rm) graph. Finding vs POSTMARKETOS_X00TD_CELLULAR.md §3: ipa_rm is NOT stubbed — all five ipa_rm*.o are compiled (parent Makefile) and the graph is wired at runtime (q6_initialize_rm Q6_PROD/CONS, ipa_create_apps_resource APPS_CONS, rmnet TX -> WWAN_0_PROD). ipa_rm.c already calls ipa2_set_required_perf_profile(); it was inert only because enable_clock_scaling was 0 (so the engine always returned NOMINAL). So this patch is a single localised change in ipa_v2/ipa.c: 1. enable_clock_scaling = 1 -> RM votes now move the clock. 2. Keep the v2.0 bandwidth thresholds high (nominal 600, turbo 1000 Mbps -- the vendor values, set explicitly) so that even active data parks at SVS = 75 MHz. The base port DISABLED scaling fearing exactly this ("every check falls through to SVS, the slowest"), but HW measurement (X00TD, 2026-06-08) proved the fear unfounded: SVS at 75 MHz sustains the full link -- 100 MB DL = 2.51 MB/s (~20 Mbps), a 73 Mbps peak, IDENTICAL to NOMINAL and TURBO, the cell is the bottleneck not the IPA core clock. The aggregate cellular RM vote measured [150,250) Mbps, far below the 600 nominal threshold, so active rides SVS. Net: idle -> gated, any active data -> SVS=75 (half the NOMINAL core-clock power for zero throughput cost), NOMINAL/TURBO effectively unused on cellular. 3. Boot stays at TURBO (curr_ipa_clk_rate unchanged) for the Q6 handshake. RESULTING BEHAVIOUR (HW-measured, X00TD, 2026-06-08) - fully idle: clock gated off (active-clients refcount, already) - active data: SVS 75 MHz (RM vote [150,250) << nominal 600) - >600 Mbps: NOMINAL 150 MHz (never on cellular) - >1000 Mbps: TURBO 200 MHz (never on cellular) 100 MB DL at SVS: 2.51 MB/s (~20 Mbps), 73 Mbps peak -- identical to NOMINAL/TURBO. Latency under load ~37 ms vs ~31 ms at NOMINAL (~+5 ms, partly cellular jitter). Cold-start consistent: idle and active are both SVS, so there is no SVS->NOMINAL ramp on the first packet of a burst. CAVEATS / TUNING - This is the deepest power-save option (active = SVS = 75 MHz). The cost is ~+5 ms latency under sustained load; throughput is unchanged because the cell, not the IPA core clock, is the bottleneck. - VALIDATED FOR ~20 Mbps CELLULAR. SVS was measured to pass at least 73 Mbps (a burst peak), but its true ceiling above that is UNTESTED. Because scaling is coarse (next bullet) the clock will NOT auto-bump for a faster link -- it stays SVS regardless. So on a fast link (good signal + CA can hit 100+ Mbps on this modem) SVS could cap throughput at ~its ceiling. Fast-link users should verify with powersave-validate.sh + a real DL, or set nominal=50 to park active at NOMINAL (150 MHz, ~2x the SVS headroom), or skip the patch (keep the 200 MHz DT pin) for guaranteed full bandwidth. - Scaling is coarse: the RM perf profile is static, so the clock is effectively binary -- gated at idle, SVS when active -- not finely load-following (that would need IPACM/QMI to update RM profiles). - For the idle saving to show on the power rail, also drop the board DTS "assigned-clock-rates = <200000000>" pin so the driver owns the rate. - The rail power delta (mW) is UNMEASURED — only the clock-domain behaviour (gating + SVS-active) and throughput/latency were validated on HW. The absolute saving on the battery rail is future work (needs a discharging device + long current_now averaging); the IPA core-clock delta on one IP block may be near the fuel-gauge noise floor. - To trade a little power back for latency/headroom, lower clock_scaling_bw_threshold_nominal below the [150,250) vote (e.g. 50) to park active at NOMINAL (150 MHz) instead -- measured to cut warm latency ~5 ms at 2x the active core-clock power, no throughput gain. Generated: 2026-06-04 ================================================================ --- a/drivers/platform/msm/ipa/ipa_v2/ipa.c +++ b/drivers/platform/msm/ipa/ipa_v2/ipa.c @@ -3974,19 +3974,47 @@ static int ipa_init(const struct ipa_plat_drv_res *resource_p, if (result) goto fail_clk; - /* Mainline tuning: disable dynamic clock scaling. + /* Power-save: re-enable dynamic IPA core-clock scaling and let the + * IPA Resource Manager graph drive it. * - * Vendor enables scaling which picks IPA core_clk rate (75/150/200 MHz) - * from current bandwidth_mbps. At our LTE baseline ~0.5 Mbps, every - * threshold check falls through to SVS = 75 MHz — the slowest setting, - * which halves processing capacity for no reason. + * The ipa_rm* objects are compiled in and already wired: + * - q6_initialize_rm() creates Q6_PROD / Q6_CONS (perf 100 Mbps) + * - ipa_create_apps_resource() creates APPS_CONS + * - rmnet TX path requests WWAN_0_PROD via the inactivity timer + * ipa_rm aggregates the per-resource perf profiles and calls + * ipa2_set_required_perf_profile() (see ipa_rm.c). That call only moves + * the clock when enable_clock_scaling is set; with it cleared the engine + * pinned NOMINAL (150 MHz) and the RM votes were inert. Re-enabling it + * couples the RM graph to the core clock: gated off when idle (active- + * clients refcount) and SVS (75 MHz) whenever active — the static + * cellular RM vote never reaches the NOMINAL/TURBO thresholds. * - * With scaling disabled, ipa2_set_clock_plan_from_pm() lands in the - * else-branch that pins needed_voltage = IPA_VOLTAGE_NOMINAL (150 MHz). - * curr_ipa_clk_rate is still initialised to TURBO here, so init paths - * see full bandwidth before NOMINAL takes over. + * Thresholds. Keep the vendor v2.0 values (nominal 600 / turbo 1000 + * Mbps), set explicitly so the intent survives a vendor default change. + * The base port disabled scaling fearing these "always fall through to + * SVS = 75 MHz even under load" — but HW measurement (X00TD, 2026-06-08) + * proved that is exactly what we WANT: SVS sustains the full link. The + * aggregate cellular RM vote measured [150,250) Mbps, far below the 600 + * nominal threshold, so active data rides SVS. A 100 MB DL at SVS ran + * 2.51 MB/s (~20 Mbps) with a 73 Mbps peak — identical to NOMINAL and + * TURBO; the cell, not the 75 MHz core clock, is the bottleneck. So + * active = SVS halves the active core-clock power for zero throughput + * cost (~+5 ms latency under load, partly cellular jitter). To trade + * that back, lower nominal below 150 to park active at NOMINAL instead. + * + * curr_ipa_clk_rate stays initialised to TURBO so the boot / Q6 handshake + * runs at full clock before the RM-driven profile takes over. + * + * NOTE: throughput-proportional scaling needs IPACM/QMI to update the RM + * perf profiles at runtime; with the static profile the scaling is coarse + * (binary: gated at idle vs SVS when active, not load-following). For + * idle savings to show on the rail, also drop the board DTS + * "assigned-clock-rates = <200000000>" pin so the driver — not RPM — + * owns the rate. */ - ipa_ctx->enable_clock_scaling = 0; + ipa_ctx->enable_clock_scaling = 1; + ipa_ctx->ctrl->clock_scaling_bw_threshold_nominal = 600; + ipa_ctx->ctrl->clock_scaling_bw_threshold_turbo = 1000; ipa_ctx->curr_ipa_clk_rate = ipa_ctx->ctrl->ipa_clk_rate_turbo; /* enable IPA clocks explicitly to allow the initialization */