> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 配置 DVFS 调节器

Qualcomm<sup>®</sup> Linux 使用动态电压和频率调节（DVFS）来平衡功耗和性能。CPU 频率调节器（governor）控制当前生效的 CPU OPP；BWMON 调节器根据测得的总线流量管理 LLCC 和 DDR 频率。

## 选择 CPU DVFS 调节器

您可以在更改 `CPUfreq` 调节器（`powersave/performance/schedutil`）时选择一个调节器，将系统调优为偏向功耗或性能。默认情况下，Qualcomm<sup>®</sup> Linux 内核上的 CPU 频率调节器设置为 `performance`。

**表：CPU DVFS 变量**

|       **变量**       |        **描述**        |                                     **路径**                                    |
| :----------------: | :------------------: | :---------------------------------------------------------------------------: |
|  scaling\_governor | 将调节器设置为 performance。 | echo performance > /sys/devices/system/cpu/cpufreq/policy\*/scaling\_governor |
| scaling\_max\_freq |    设置 CPU 集群的最大频率。   |          /sys/devices/system/cpu/cpufreq/policy\*/scaling\_max\_freq          |
| scaling\_min\_freq |    设置 CPU 集群的最小频率。   |          /sys/devices/system/cpu/cpufreq/policy\*/scaling\_min\_freq          |

有关 `CPUfreq` 的更多信息，请参阅 [CPU frequency and voltage scaling code in the Linux(TM) kernel](https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt)。

## 配置缓存和内存 DVFS 调节器

静态映射 DVFS 调节器将 CPU 工作频率与以下内容对齐：

* 三级缓存（L3）
* 末级缓存控制器（LLCC）
* DDR RAM

如果 CPU 频率处于最高级别——无论是通过将 CPU 频率调节器设置为 performance，还是由于系统负载——那么 L3、LLCC 和 DDR 也将以其最高频率运行。

该调节器的驱动位于 `drivers/cpufreq/qcom-cpufreq-hw.c` 文件中，静态映射位于 `arch/arm64/boot/dts/qcom/sc7280.dtsi` 文件中。

<Note>
  对于 Qualcomm SoC，请参阅特定于平台的 DTSI 文件以获取此信息。
</Note>

另一个带宽监控（BWMON）调节器用于根据测得的 CPU 到 LLCC 以及 CPU 到 DDR 之间的流量，为 LLCC 和 DDR 频率投票。该调节器的驱动位于 `drivers/soc/qcom/icc-bwmon.c` 文件中。

**CPU 频率**与 **L3/DDR 频率**之间的映射会根据功耗或性能需求进行调整。

在 DTSI 中，每个 CPUx 节点都有一个 `operating-points-v2 = <&cpux_opp_table>` 条目。`cpux_opp_table` 保存了 CPU、L3 和 DDR 频率之间的静态映射。

例如：

```text theme={null}
cpu0_opp_300mhz: opp-300000000 {
   opp-hz = /bits/ 64 <300000000>;
   opp-peak-kBps = <800000 9600000>;
};
```

当 CPU 0 以 300 MHz 运行时，它向 L3 投票 9600000 Hz，换算为 300,000 Hz（9600000/w）的 L3 频率。如果向 DDR 投票 800,000 Hz，则得到 200,000 Hz（800000 / w）的 DDR 频率。

在该等式中，"w" 表示单个周期内可以写入的字节数：

* 对于 DDR，"w" 为 4（每个通道每周期执行两次事务，每次事务 2 字节）。
* 对于 L3，"w" 为 32（每周期一次事务，每次事务 32 字节）。

<Note>
  这些值针对 DDR 按通道设置，该映射将 CPU 频率与内存控制器（MC）通道带宽相关联。调整此映射表可能会影响功耗和性能特性。
</Note>

有关工作性能点（OPP）框架和语法的更多信息，请参阅 [Generic OPP (Operating Performance Points) Bindings](https://www.kernel.org/doc/Documentation/devicetree/bindings/opp/opp.txt)。\\
