4.3.23. QoS调试指南

4.3.23.1. 概述

X5芯片采用 NOC(Network on chip) 架构的 QoS(Quality of Service,服务质量),主要以下方面原因:

SoC发展需求

随着 SoC 不断发展,片上互联架构逐渐总线结构演变复杂网络拓扑,片上网络(NoC)的概念应运而生。不同模块之间需要高效通信资源分配,因此需要引入 QoS 机制保障系统性能稳定性。

解决带宽延迟分配问题

在X5芯片内部,众多模块(如 CPU、VIN、BPU、CODEC、GPU 等)都需要通过NOC进行数据交互,每个模块带宽延迟要求各不相同。例如,视频模块带宽实时性要求高,如果没有 QoS机制合理分配管理资源,很可能出现带宽竞争导致数据传输延迟、丢包问题,影响系统整体性能。采用 QoS 机制能够根据模块实际需求,优化带宽延迟分配,确保各个模块能够获得与其需求匹配资源。

应对数据流量均衡问题

不同应用场景下,芯片模块数据流量分布可能均衡。例如高清视频处理场景中,涉及图像采集、编解码、显示多个模块数据流量较大,但一些简单任务场景下,上述模块流量相对小。QoS 机制可以根据实际数据流量情况进行动态调整,灵活分配资源。在流量高峰优先保障关键模块资源需求,在流量低谷合理重新分配剩余资源,提高资源利用率,使得整个芯片系统不同工作场景保持高效稳定运行。

综上,X5 芯片采用 NOC 架构的 QoS,是为了适应片上系统发展、满足多元化服务需求、优化资源分配利用以及应对复杂多变数据流量情况,从而提升芯片整体性能稳定性,更好支持各种应用功能。

4.3.23.2. 特点

在 X5 芯片 NOC 中,QoS 呈现出一系列特性,显著提升网络服务质量,具体如下:

  • 实现流量差异化管理,以适应多样化应用场景需求。

  • 支持丰富模式支持,包括 Fixed 模式、Limiter 模式、Regulator 模式、Bypass 模式。

  • 涵盖众多模块,包括 CPU、VIN、BPU、CODEC、GPU、HSIO、HIFI5 等,且每个模块对应的 IP,例如 SIF2、SIF3、SIIF_DISP、BPU、VIDEO_CODEC等,都单独进行 QoS 配置,方便用户针对不同场景进行精细化调整。

  • 支持通过 sysfs 下节点配置 QoS

X5 QoS 支持模块及其 IP 如下

模块 IP
CPU cpu_ace / cpu_perif
VIN bt1120 / dc8000 / dw230_gdc / dw230_scalar2 / dw230_scalar3 / isp_axi5_hdr /
isp_axi4_mcm / isp_axi3_sp2 / isp_axi1_mp / sif0 / sif1 / sif2 / sif3 / sif_disp
BPU bpu
CODEC video / jpeg
GPU gpu2d / gpu3d
HSIO dma0 / emmc / gmac / sd / sdio / security / usb2 / usb3 / etr
HIFI5 hifi5

4.3.23.3. 功能描述

典型应用

X5 芯片的 QoS 功能多种场景发挥重要作用,以下一些典型应用场景:

  • 高分辨率显示场景

例如 2路4K场景,该场景分辨率要求高,对流程模块优先级要求高,如 HDMI 显示模块,通过调整显示输出 QoS 确保高分辨率显示优先级带宽,保证画面稳定显示

  • 多媒体处理场景

多媒体处理中,涉及多个模块协同工作,不同模块带宽优先级需求不同。如视频编解码、图像信号处理(ISP)等模块,通过 QoS 功能合理分配带宽设置优先级,可保障多媒体处理流畅性,避免出现帧、画面闪烁问题。

  • 复杂传感器接入场景

当X5芯片应用扫地机、割草机、家庭陪伴机器人设备,需要接入多路复杂传感器时,QoS 功能不同传感器数据传输进行优先级带宽分配。如重要传感器数据可能设置优先级,保证数据实时性准确性;对带宽需求传感器,也分配足够带宽,确保系统稳定运行,使机器人更好感知环境、进行决策行动。

功能原理

QoS 是发起者目标之间传输事务关于带宽延迟吞吐量延迟统计分配,QoS 类似银行 VIP 用户服务,对网络流量分类赋予不同服务质量,高优先级流量优先转发,低优先级流量尽力服务。

X5 QoS 驱动源码位于 drivers/soc/hobot/ddr_monitor/horizon_noc_qos.c,本章节主要介绍 QoS 基本原理以及使用方法,不驱动代码赘述。

QoS 支持 Fixed、Limiter、Regulator、Bypass 四种模式,下面分别介绍四种模式及其原理

Fixed 模式

Fixed 模式特性

  • 用于固定分配一个预定优先级级别

  • 可以分别设置事务优先级

Fixed 模式寄存器定义如下:

image-qos3

Limiter 模式

Limiter 模式特性

  • 达到预定带宽阈值进行流量控制

  • 可以分别设置事务优先级

  • 设置寄存器包括: Bandwidth Saturation 以及 ExtControl寄存器

  • 端口带宽超过 BW并且超出 threshold 字节,该端口限流(反压)。其中 Bandwidth寄存器值 = 256 * BW/FThreshold = Saturation寄存器 ×16

参数说明

  • BW : 预期内存带宽限制

  • threshold: 从 BW 到 QoS 限流之间门槛

  • F : 模块频率,各个模块对应频率查看 QoS寄存器默认配置表格

Limiter 模式寄存器定义如下

image-qos3

Regulator 模式

Regulator 模式特性

  • 用于确保启动器目标获得带宽

  • 可以分别设置事务优先级,此时事务优先级一致

  • 设置寄存器包括: Bandwidth Saturation 以及 ExtControl 寄存器。

  • Regulator 模式根据带宽调节读写优先级。

    • 带宽大于预期带宽时,即当端口带宽高于 BW + threshold,QoS 将读写优先级调小至 P0 优先级

    • 带宽小于预期带宽时,即当端口带宽低于 BW - threshold,QoS 将读写优先级调大至 P1 优先级

    • 其中 Bandwidth寄存器值 = 256 * BW/FThreshold = Saturation寄存器 ×16

参数说明

  • P0 : 读写优先级,高优先级

  • P1 : 读写优先级,低优先级

  • BW : 预期内存带宽限制

  • threshold : 从 BW 到 QoS 调节之间门槛

  • F : 模块频率,各个模块对应频率查看 QoS寄存器默认配置表格

Regulator 模式寄存器定义如下

image-qos3

Bypass 模式

Bypass 模式比较复杂,主要Socket qos signalsQos box 决定 Priority 寄存器值,

  • Socket qos signals是 QoS 内部调节值( AxQOSHurry 两者取其最大),其中

    • AxQos : 为 IP 本身调节

    • Hurry : Hurry 信号只有 SIF 支持信号,其可以提高长时间收到响应事务处理优先级。而 SIF Hurry 信号相关 FIFO 中的 almost-full 信号驱动

  • Qos box文中 priority 寄存器值。

主要包含以下几种情况

  • 当 SocketQosEn 寄存器值为 0,且当前不是 Bypass 模式,则通过 priority 寄存器设置优先级

  • 当 SocketQosEn 寄存器值为 0,且当前是 Bypass 模式,由 Socket qos signals 设置优先级

  • 当 SocketQosEn 寄存器值为 1,则Socket qos signalsQos box最大值作为优先级

优先级如下规则所示

image-qos3

4.3.23.4. QoS寄存器默认配置

Bandwidth、BW、F寄存器

image-qos9

image-qos9

Mode、P1、P0寄存器

image-qos9

image-qos9

注意事项

  • X5 芯片通常使用 Fixed 模式,如果调整为Limiter、Regulator以及Bypass模式,细节复杂模式配置章节

  • 各个模式 Priority 寄存器定义一样

    • Fixed 和 Limiter 模式: P0 代表 write 优先级,P1 代表 read 优先级

    • Mode 和 Regulator 模式: P0 代表低优先级,P1 代表优先级

  • write\P0 优先级 和 read\P1 优先级定义如下

    • write\P0 优先级由 Priority 寄存器 bit[0:2]决定,范围[0-7]

    • read\P1 优先级由 Priority 寄存器 bit[8:10]决定,范围[0-7]

    • 数值越大,优先级越高

image-qos3

4.3.23.5. 使用方法

X5 芯片 QoS 支持通过 sysfs 方式配置,用户无需关注复杂寄存器配置,可直接通过 sysfs 节点操作。其操作模式分为常见模式复杂模式,以下分别介绍使用方法

常见模式

X5 系统默认使用常见模式,即 Fixed 模式,当通过 sysfs 配置优先级时,QoS 将自动配置为 Fixed 模式。

读写 Priority 寄存器

QoS 模块所在目录/sys/bus/platform/drivers/noc_qos,该目录包含 X5 系统支持配置 QoS 的所有模块,每个模块子目录形式存在

image-qos8

对于 Fixed 模式,可以配置每个模块的 read priority 和 write priority,分别位于每个模块目录read_priority_qos_ctrl/prioritywrite_priority_qos_ctrl/priority 节点。

以 sif0 qos 为例,读取配置读写优先级

cd /sys/bus/platform/drivers/noc_qos    # 进入 qos 目录

cd 20510500.sif0_qos                    # 进入 sif0 qos 子目录

cat read_priority_qos_ctrl/priority     # 读取 read priority
# read_priority : 7                     # 显示当前 read priority 值为 7

echo 5 > read_priority_qos_ctrl/priority     # 设置 read priority 值为 5


cat write_priority_qos_ctrl/priority     # 读取 write priority
# write_priority : 7                     # 显示当前 write priority 值为 7

echo 5 > write_priority_qos_ctrl/priority     # 设置 write priority 值为 5

复杂模式

配置复杂模式

X5 QoS 默认常见模式,每次配置优先级时,驱动自动配置为 Fixed 模式,如果需要进入复杂模式,需要关闭自动配置。X5 QoS 通过每个模块目录mode_qos_ctrl/advanced 节点开启/关闭自动配置。

以 sif0 qos 为例

查看当前是否自动配置 Fixed 模式

cd /sys/bus/platform/drivers/noc_qos/20510500.sif0_qos

cat mode_qos_ctrl/advanced
qos_advanced : 0              # 0 表示当前自动设置 mode 为 Fixed 模式

关闭自动配置 Fixed 模式

echo 1 > mode_qos_ctrl/advanced

cat mode_qos_ctrl/advanced
qos_advanced : 1

配置优先级

复杂模式下,每个模块子目录,可配置寄存器目录主要

  • mode_qos_ctrl 目录: 包含 advanced bandwidth extcontrol mode saturation 寄存器

  • read_priority_qos_ctrl 目录: 包含 priority,对应 read / P1 优先级

  • write_priority_qos_ctrl 目录: 包含 priority,对应 write / P0 优先级

注意: 配置转换十进制

以 cpu_ace_qos 为例

设置 Limiter 模式,BW 为 1GB/s, threshold 为 2MB, 其中 F = 1.2GHZ (模块频率,各个模块对应频率查看 QoS寄存器默认配置表格 )。 Bandwidth 寄存器值为0xD5,则 Saturation 寄存器值为 0x80。

image-qos9

QoS 各模块参数展示脚本

X5 提供脚本 qos_show.sh 方便用户快速查看各个模块读写优先级。

脚本参数如下:

  • 默认不带参数: 只显示 write priorityread priority 参数信息

  • -a: 同时显示 advanced mode bandwidth saturation extcontrol 参数信息

注意: 该脚本板端固件集成,用户拷贝至板任意路径执行

脚本代码如下:

#!/bin/bash

# cd /sys/bus/platform/drivers/noc_qos
cd /sys/bus/platform/drivers/noc_qos || exit

for dir in */; do
    if [[ $dir == *qos* ]]; then
            cd "$dir" || continue
    fi
    echo "$dir: "

    val=$(cat write_priority_qos_ctrl/priority | awk '{print $NF}')
    printf "\t\t\t%-18s%-10s\n" "write priority:" $val

    val=$(cat read_priority_qos_ctrl/priority | awk '{print $NF}')
    printf "\t\t\t%-18s%-10s\n" "read priority:" $val

    if [ "$1" != "-a" ]; then
        cd ..
        continue
    fi

    val=$(cat mode_qos_ctrl/mode | awk '{print $NF}')
    printf "\t\t\t%-18s%-10s\n" "mode val:" $val

    val=$(cat mode_qos_ctrl/advanced | awk '{print $NF}')
    printf "\t\t\t%-18s%-10s\n" "advanced val:" $val

    val=$(cat mode_qos_ctrl/bandwidth | awk '{print $NF}')
    num=$((val))
    printf "\t\t\t%-18s%s%-10x\n" "bandwidth val:" "0x" $((val))

    val=$(cat mode_qos_ctrl/saturation | awk '{print $NF}')
    num=$((val))
    printf "\t\t\t%-18s%s%-10x\n" "saturation val:" "0x" $((val))

    val=$(cat mode_qos_ctrl/extcontrol | awk '{print $NF}')
    printf "\t\t\t%-18s%-10s\n" "extcontrol val:" $val

    cd ..

done

默认不带参数,仅显示读写优先级

image-qos9

带 -a 参数,显示所有寄存器

image-qos9

QoS 配置工具 qos_tool.sh

SDK 在板端提供 Shell 脚本 /usr/hobot/bin/qos_tool.sh,用于通过 sysfs 便捷配置 QoS,源码位于 hbre/hbutils/qos_tool/qos_tool.sh 。该工具支持 FixedLimiterRegulator 三种模式set 配置,并通过 apply / save 批量设置备份复杂模式配置。工具自动完成寄存器换算、写入顺序控制及读校验,无需手动操作各 sysfs 节点。

模块别名频率

module 参数使用完整 ID(如 20510500.sif0_qos)或下表 alias;亦支持模糊匹配(如输入 gdc匹配 *gdc*_qos)。频率 F 用于 calc / set limiter / set regulator / apply带宽寄存器换算,典型值如下(详见 QoS寄存器默认配置表格,请以板实际时钟为准):

模块 ID alias 分组 F (MHz)
20500000.cpu_ace_qos cpu_ace CPU 1200
20500100.cpu_perif_qos cpu_perif CPU 1200
20510000.bt1120_qos bt1120 VIN 600
20510080.dc8000_qos dc8000 VIN 600
20510100.dw230_gdc_qos gdc VIN 600
20510180.dw230_scalar2_qos vse_scalar2 VIN 600
20510200.dw230_scalar3_qos vse_scalar3 VIN 600
20510280.isp_axi5_hdr_qos isp_hdr VIN 600
20510300.isp_axi4_mcm_qos isp_mcm VIN 600
20510380.isp_axi3_sp2_qos isp_sp2 VIN 600
20510480.isp_axi1_mp_qos isp_mp VIN 600
20510500.sif0_qos sif0 VIN 600
20510580.sif1_qos sif1 VIN 600
20510600.sif2_qos sif2 VIN 600
20510680.sif3_qos sif3 VIN 600
20510700.sif_disp_qos sif_disp VIN 600
20520000.bpu_qos bpu BPU 1000
20530000.video_qos video CODEC 600
20530080.jpeg_qos jpeg CODEC 600
20540000.gpu2d_qos gpu2d GPU 1000
20540080.gpu3d_qos gpu3d GPU 1000
20550000.dma0_qos dma0 HSIO 600
20550080.emmc_qos emmc HSIO 200
20550100.gmac_qos gmac HSIO 400
20550180.sd_qos sd HSIO 200
20550200.sdio_qos sdio HSIO 200
20550280.security_qos security HSIO 600
20550300.usb2_qos usb2 HSIO 400
20550380.usb3_qos usb3 HSIO 400
20550400.etr_qos etr HSIO 600
20560000.hifi5_qos hifi5 HIFI5 432

脚本使用说明

# qos_tool.sh --help
Usage:
  qos_tool.sh list [-a]
  qos_tool.sh show [module...] [-a]
  qos_tool.sh set <module> fixed <read_p> <write_p>
  qos_tool.sh set <module> limiter <read_p> <write_p> <bw_mbps> <threshold_kb>
  qos_tool.sh set <module> regulator <p0_low> <p1_high> <bw_mbps> <threshold_kb>
  qos_tool.sh apply <profile.conf>
  qos_tool.sh save [-o file.conf] [module...]
  qos_tool.sh calc <module> <bw_mbps> [threshold_kb] [--freq mhz]

Profile format (pipe-separated, # for comments):
  module_id|mode|read_p|write_p|bw_mbps|threshold_kb|bw_reg|sat_reg

Notes:
  - module can be alias (e.g. sif0) or full id (20510500.sif0_qos)
  - Regulator: profile read_p=P1(high), write_p=P0(low)
  - set limiter/regulator requires threshold_kb; maps to saturation (bytes/16), max register 1023
  - save output may include an extra extcontrol field for backup; apply accepts it
  - Requires root to write sysfs under /sys/bus/platform/drivers/noc_qos

参数说明

命令 语法 说明
列出模块 list [-a] 列出所有 QoS 模块;-a 额外显示 advancedmodebandwidthsaturationextcontrol寄存器
查看配置 show [module...] [-a] 查看指定全部模块;module 支持 alias 如 cpu_ace完整 ID 20500000.cpu_ace_qos
设置 Fixed set {module} fixed {read_p} {write_p} 固定读写优先级;{read_p} 为读优先级 P1,{write_p}优先级 P0,取值 0~7,数值越大越优先。
设置 Limiter set {module} limiter {read_p} {write_p} {bw_mbps} {threshold_kb} 限制最大带宽; {bw_mbps} (MB/s)为期望带宽上限,{threshold_kb} (KB) 为调节阈值,当带宽超过 bw_mbps + threshold开始限流
设置 Regulator set {module} regulator {p0_low} {p1_high} {bw_mbps} {threshold_kb} 保障带宽;围绕目标带宽 {bw_mbps}(MB/s)动态调节读写优先级。{p0_low}低优先级 P0,{p1_high}优先级 P1,须 P1 ≥ P0;当带宽超过 bw_mbps + threshold 后降为 P0,低于 bw_mbps - threshold 后升为 P1,在调节区间保持当前优先级。
批量设置 apply {profile.conf} 指定配置文件批量写入 QoS 配置;支持 fixed / limiter / regulator / bypass
设置备份 save [-o file.conf] [module...] 导出当前硬件 QoS 到文件;不写 -o保存/tmp/qos_backup_时间戳.conf
寄存器换算 calc {module} {bw_mbps} [threshold_kb] [--freq mhz] 计算、不写硬件;根据 {bw_mbps}(MB/s)换算 bandwidth 寄存器;若提供 {threshold_kb}(KB)则一并换算 saturation 寄存器。频率 F 默认取自脚本内嵌模块表,可用 {--freq mhz} 手动指定。{threshold_kb}{--freq mhz}选。配置 Limiter / Regulator用于预览寄存器

参数补充说明:

  • module:模块别名完整 ID 可查看上表,或完整 ID 在 /sys/bus/platform/drivers/noc_qos/ 查看

  • threshold_kb:Limiter / Regulator 的带宽调节阈值,写入 saturation 寄存器,换算关系:saturation = threshold_kb × 1024 / 16 (即 threshold_bytes = saturation × 16)。寄存器取值 0~1023,对应 threshold 最大约 16368 字节(set / calc 的 KB 参数最大填 15)。常用 1~2。set limiter / set regulator 命令必填apply profile 可sat_reg 二选一。

  • bw_mbps 换算Bandwidth寄存器 = 256 × BW / F,F 取自脚本内嵌模块calc --freq

  • Regulator 模式:硬件分开read / write,而是根据带宽在 P0(低) 和 P1(高) 之间切换,读写用同一套优先级与 Fixed / Limiter 下 read/write 含义不同。

使用示例

查看模块列表配置

# qos_tool.sh list  # 列出所有 QoS 模块及当前 read/write 优先级
# qos_tool.sh list -a  # 同上,并额外显示 advanced、mode、bandwidth、saturation、extcontrol(full 能力模块)

# qos_tool.sh show sif0  # 查看指定模块;sif0 为脚本内 alias
# qos_tool.sh show -a cpu_ace # 查看 cpu_ace,并显示 mode、bandwidth 等寄存器详情

# 如列出全部模块及 read/write 优先级
# qos_tool.sh  list
20500000.cpu_ace_qos             read=7 write=4
20500100.cpu_perif_qos           read=4 write=0
20510000.bt1120_qos              read=7 write=7
20510080.dc8000_qos              read=7 write=7
20510100.dw230_gdc_qos           read=4 write=4
20510180.dw230_scalar2_qos       read=4 write=4
20510200.dw230_scalar3_qos       read=4 write=4
20510280.isp_axi5_hdr_qos        read=4 write=4
20510300.isp_axi4_mcm_qos        read=4 write=4
20510380.isp_axi3_sp2_qos        read=4 write=4
20510480.isp_axi1_mp_qos         read=4 write=4
20510500.sif0_qos                read=7 write=7
20510580.sif1_qos                read=7 write=7
20510600.sif2_qos                read=7 write=7
20510680.sif3_qos                read=7 write=7
20510700.sif_disp_qos            read=7 write=0
20520000.bpu_qos                 read=1 write=1
20530000.video_qos               read=0 write=0
20530080.jpeg_qos                read=0 write=0
20540000.gpu2d_qos               read=0 write=0
20540080.gpu3d_qos               read=0 write=0
20550000.dma0_qos                read=4 write=0
20550080.emmc_qos                read=4 write=0
20550100.gmac_qos                read=4 write=0
20550180.sd_qos                  read=4 write=0
20550200.sdio_qos                read=4 write=0
20550280.security_qos            read=4 write=0
20550300.usb2_qos                read=4 write=0
20550380.usb3_qos                read=4 write=0
20550400.etr_qos                 read=4 write=0
20560000.hifi5_qos               read=4 write=0

设置 Fixed 模式

# 设置 cpu_ace 读写优先级均为 7
# qos_tool.sh  set cpu_ace fixed  7 7
ok: 20500000.cpu_ace_qos mode=fixed read=7 write=7

设置 Limiter 模式

# BPU 读写优先级 0,带宽上限 500 MB/s,threshold 2 KB
# qos_tool.sh set bpu limiter 0 0 500 2
ok: 20520000.bpu_qos mode=limiter read=0 write=0 bw=128 sat=128 ext=0

设置 Regulator 模式

# cpu_ace:P0=4(低),P1=7(高),目标带宽 800 MB/s,threshold 2 KB
# qos_tool.sh set cpu_ace regulator 4 7 800 2
ok: 20500000.cpu_ace_qos mode=regulator read=7 write=4 bw=170 sat=128 ext=0

寄存器换算(不写硬件)

# 按脚本内嵌模块频率换算
# qos_tool.sh calc cpu_ace 800 2
module     : 20500000.cpu_ace_qos
freq_mhz   : 1200
bw_mbps    : 800
bandwidth  : 170 (0xaa)
threshold  : 2 KB (2*1024 bytes)
saturation : 128 (0x80)

# 手动指定频率 F(MHz)
# qos_tool.sh calc cpu_ace 1000 2 --freq 1200
module     : 20500000.cpu_ace_qos
freq_mhz   : 1200
bw_mbps    : 1000
bandwidth  : 213 (0xd5)
threshold  : 2 KB (2*1024 bytes)
saturation : 128 (0x80)

批量配置备份

# 备份当前硬件配置
# qos_tool.sh save -o /tmp/qos_backup.conf
saved to /tmp/qos_backup.conf

# 应用自定义 profile(格式见下文「配置文件格式」)
# qos_tool.sh apply /tmp/my_qos_profile.conf
ok: 20510500.sif0_qos mode=fixed read=7 write=7
ok: 20510580.sif1_qos mode=fixed read=7 write=7
ok: 20510280.isp_axi5_hdr_qos mode=fixed read=4 write=4
ok: 20510300.isp_axi4_mcm_qos mode=fixed read=4 write=4
ok: 20510380.isp_axi3_sp2_qos mode=fixed read=4 write=4
ok: 20510480.isp_axi1_mp_qos mode=fixed read=4 write=4
ok: 20510100.dw230_gdc_qos mode=fixed read=4 write=4
ok: 20510180.dw230_scalar2_qos mode=fixed read=4 write=4
ok: 20510200.dw230_scalar3_qos mode=fixed read=4 write=4
ok: 20520000.bpu_qos mode=limiter read=0 write=0 bw=128 sat=0 ext=0
ok: 20510000.bt1120_qos mode=fixed read=7 write=7
ok: 20510080.dc8000_qos mode=fixed read=7 write=7
ok: 20530000.video_qos mode=fixed read=0 write=0
ok: 20530080.jpeg_qos mode=fixed read=0 write=0
apply done: 14 entries, exit=0

# 查看配置是否生效
# qos_tool.sh show -a

注意: 批量 profile 需实际场景自行编写save 导出修改;不建议未经评估直接用于量产。

配置文件格式

applysave 使用的 profile 为管道符(|)分隔文本,每行一个模块# 开头注释。

定义

说明 Fixed Limiter Regulator Bypass
module_id 模块完整 ID(如 20510500.sif0_qos 必填 必填 必填 必填
mode fixed / limiter / regulator / bypass 必填 必填 必填 必填
read_p Fixed/Limiter:读优先级;Regulator:P1(高) 必填 必填 必填 必填
write_p Fixed/Limiter:写优先级;Regulator:P0(低) 必填 必填 必填 必填
bw_mbps 目标带宽(MB/s),工具自动换算 bandwidth 二选 二选
threshold_kb 调节阈值(KB),工具自动换算 saturation
bw_reg bandwidth 寄存器值(十进制) 二选 二选 必填
sat_reg saturation 寄存器值(十进制)
extcontrol 扩展控制寄存器

注意

  • Limiter / Regulator 带宽bw_mbpsbw_reg 至少一项。自行编写 profile 推荐bw_mbpssave 备份通常只含 bw_reg,可直接 apply 还原。已bw_reg直接使用寄存器值(适合 save 还原精细调参)。

  • Limiter / Regulator 阈值set 命令要求提供 threshold_kbapply profile 中 threshold_kbsat_reg 至少一项(二选一):自行编写 profile 建议threshold_kb(常用 1~2),由工具自动换算;save 备份通常sat_reg,可直接 apply 还原。两者填时 Limiter/Regulator 阈值行为可控,仅适合调试。Bypass 下 sat_reg省略,默认按 0 处理。

  • Bypass:工具 set 命令支持,通常save 导出后经 apply 还原,配置有限。

  • extcontrolsave 备份可能末尾一列;apply 兼容读取。自行编写 profile 可省略,默认按 0 处理。

  • 空字段:连续 | 表示该列留空,例如 Fixed 行 20510500.sif0_qos|fixed|7|7||||

示例:

# module_id|mode|read_p|write_p|bw_mbps|threshold_kb|bw_reg|sat_reg|extcontrol
# Fixed:仅 priority
20510500.sif0_qos|fixed|7|7||||

# Limiter:bw_mbps + threshold_kb 自动换算
20520000.bpu_qos|limiter|0|0|500|2|||

# Regulator:read_p=P1(高),write_p=P0(低)
20500000.cpu_ace_qos|regulator|7|4|800|2|||

# Bypass:通常由 save 导出,填 bw_reg / sat_reg
20500000.cpu_ace_qos|bypass|7|0|||426|64

模式选择建议

  • SIF、HDMI、ISP、GDC、VSE实时链路:使用 Fixed,设置高 priority

  • BPU、编解码后台模块:使用 Fixed 低 priority 或 Limiter 限制带宽上限

  • CPU需要动态带宽调节模块:可Regulator

注意事项

advanced 与 mode 可能一致(上电后常见)

# qos_tool.sh show cpu_ace -a
20500000.cpu_ace_qos             read=7 write=0
                        advanced=0 mode=2(bypass) bandwidth=426 saturation=64 extcontrol=0
节点 存储位置 取值 含义
mode 硬件寄存器 0~3 模块当前实际工作模式:0=Fixed,1=Limiter,2=Bypass,3=Regulator。判断模块怎么工作,看这个
advanced 驱动内存(默认 0) 0 简单模式:写 write_priority_qos_ctrl/read_priority_qos_ctrl priority 时,驱动同时把 mode 设为 Fixed(0)
advanced 驱动内存(默认 0) 1 高级模式:写 write_priority_qos_ctrl/read_priority_qos_ctrl priority 不会改 mode,Limiter / Regulator / Bypass 可继续生效
  • 上电后尚未主动配置时,advanced 通常为 0,而 mode 保留 SoC boot 默认

  • advanced=0 时,使用 set fixed写 priority 会mode 强制回 0(Fixed)

  • set limiter / set regulator自动设置 advanced=1

  • save硬件 mode 保存实际模式,不会advanced=0 误记fixedapply还原 bypass / limiter / regulator 配置

  • 脚本内嵌模块频率 F 由 QoS寄存器默认配置表格 整理获得;若板时钟默认值不符,请修改源码 hbre/hbutils/qos_tool/qos_tool.shQOS_MODULES_CONF_DATA,或calc使用 --freq 指定