记录:RK3576 适配开源GPU驱动(panfrost)

1.内核dts修改:

复制代码
diff --git a/arch/arm64/boot/dts/rockchip/rk3576.dtsi b/arch/arm64/boot/dts/rockchip/rk3576.dtsi
index c1e0e7e525be..d3e018dd2a0e 100644
--- a/arch/arm64/boot/dts/rockchip/rk3576.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3576.dtsi
@@ -2376,7 +2376,9 @@ power-domain@RK3576_PD_NPU1 {
                        /* These power domains are grouped by VD_GPU */
                        power-domain@RK3576_PD_GPU {
                                reg = <RK3576_PD_GPU>;
+                               clocks = <&cru CLK_GPU>, <&cru PCLK_GPU_ROOT>;
                                pm_qos = <&qos_gpu>;
+                               #power-domain-cells = <0>;
                        };
                        /* These power domains are grouped by VD_LOGIC */
                        power-domain@RK3576_PD_NVM {
@@ -2767,13 +2769,15 @@ gpu: gpu@27800000 {
                interrupts = <GIC_SPI 349 IRQ_TYPE_LEVEL_HIGH>,
                        <GIC_SPI 348 IRQ_TYPE_LEVEL_HIGH>,
                        <GIC_SPI 347 IRQ_TYPE_LEVEL_HIGH>;
-               interrupt-names = "GPU", "MMU", "JOB";
+               interrupt-names = "gpu", "mmu", "job";

                upthreshold = <40>;
                downdifferential = <10>;

-               clocks = <&scmi_clk CLK_GPU>, <&cru CLK_GPU>;
-               clock-names = "clk_mali", "clk_gpu";
+               clocks = <&cru CLK_GPU>;
+               clock-names = "core";
+               //clocks = <&scmi_clk CLK_GPU>, <&cru CLK_GPU>;
+               //clock-names = "clk_mali", "clk_gpu";
                assigned-clocks = <&cru CLK_GPU>;
                assigned-clock-rates = <198000000>;
                power-domains = <&power RK3576_PD_GPU>;
@@ -2845,27 +2849,27 @@ gpu_opp_table: gpu-opp-table {
                rockchip,low-temp-min-volt = <750000>;

                opp-300000000 {
-                       opp-supported-hw = <0xf9 0xffff>;
+                       //opp-supported-hw = <0xf9 0xffff>;
                        opp-hz = /bits/ 64 <300000000>;
                        opp-microvolt = <712500 712500 875000>;
                };
                opp-400000000 {
-                       opp-supported-hw = <0xf9 0xffff>;
+                       //opp-supported-hw = <0xf9 0xffff>;
                        opp-hz = /bits/ 64 <400000000>;
                        opp-microvolt = <712500 712500 875000>;
                };
                opp-500000000 {
-                       opp-supported-hw = <0xf9 0xffff>;
+                       //opp-supported-hw = <0xf9 0xffff>;
                        opp-hz = /bits/ 64 <500000000>;
                        opp-microvolt = <712500 712500 875000>;
                };
                opp-600000000 {
-                       opp-supported-hw = <0xf9 0xffff>;
+                       //opp-supported-hw = <0xf9 0xffff>;
                        opp-hz = /bits/ 64 <600000000>;
                        opp-microvolt = <712500 712500 875000>;
                };
                opp-700000000 {
-                       opp-supported-hw = <0xf9 0xffff>;
+                       //opp-supported-hw = <0xf9 0xffff>;
                        opp-hz = /bits/ 64 <700000000>;
                        opp-microvolt = <712500 712500 875000>;
                        opp-microvolt-L0 = <750000 750000 875000>;
@@ -2891,7 +2895,7 @@ opp-s-800000000 {
                        opp-microvolt-L10 = <725000 725000 875000>;
                };
                opp-800000000 {
-                       opp-supported-hw = <0xf1 0xffff>;
+                       //opp-supported-hw = <0xf1 0xffff>;
                        opp-hz = /bits/ 64 <800000000>;
                        opp-microvolt = <812500 812500 875000>;
                        opp-microvolt-L1 = <812500 812500 875000>;
@@ -2906,7 +2910,7 @@ opp-800000000 {
                        opp-microvolt-L10 = <725000 725000 875000>;
                };
                opp-900000000 {
-                       opp-supported-hw = <0xf1 0xffff>;
+                       //opp-supported-hw = <0xf1 0xffff>;
                        opp-hz = /bits/ 64 <900000000>;
                        opp-microvolt = <875000 875000 875000>;
                        opp-microvolt-L1 = <875000 875000 875000>;

2.修改内核配置

复制代码
CONFIG_DRM_PANFROST=y
# CONFIG_DRM_IGNORE_IOTCL_PERMIT is not set

正常启动后内核log如下:

复制代码
[    3.887800] panfrost 27800000.gpu: clock rate = 198000000
[    3.890113] panfrost 27800000.gpu: EM: OPP:600000 is inefficient
[    3.890125] panfrost 27800000.gpu: EM: OPP:500000 is inefficient
[    3.890129] panfrost 27800000.gpu: EM: OPP:400000 is inefficient
[    3.890133] panfrost 27800000.gpu: EM: OPP:300000 is inefficient
[    3.890236] panfrost 27800000.gpu: EM: created perf domain
[    3.890689] panfrost 27800000.gpu: mali-g52 id 0x7402 major 0x1 minor 0x0 status 0x0
[    3.890700] panfrost 27800000.gpu: features: 00000000,00000cf7, issues: 00000000,00000400
[    3.890709] panfrost 27800000.gpu: Features: L2:0x07120206 Shader:0x00000002 Tiler:0x00000209 Mem:0x1 MMU:0x00002823 AS:0xff JS:0x7
[    3.890718] panfrost 27800000.gpu: shader_present=0x7 l2_present=0x1
[    3.892144] [drm] Initialized panfrost 1.2.0 20180908 for 27800000.gpu on minor 1
[    3.942584] I : [File] : drivers/gpu/arm/mali400/mali/linux/mali_kernel_linux.c; [Line] : 407; [Func] : mali_module_init(); svn_rev_string_from_arm of this mali_ko is '', rk_ko_ver is '5', built at '03:10:58', on 'Mar  5 2026'.

注意:CONFIG_DRM_IGNORE_IOTCL_PERMIT宏需要关闭,不然开机过程可能会出现下面错误,导致无法进入桌面。但是如果你用的是RK修改过的libdrm2库就不会出现这个问题。

复制代码
[   10.058566] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000018
[   10.067529] Mem abort info:
[   10.070426]   ESR = 0x0000000096000005
[   10.074247]   EC = 0x25: DABT (current EL), IL = 32 bits
[   10.079610]   SET = 0, FnV = 0
[   10.082701]   EA = 0, S1PTW = 0
[   10.085899]   FSC = 0x05: level 1 translation fault
[   10.090867] Data abort info:
[   10.093809]   ISV = 0, ISS = 0x00000005
[   10.097736]   CM = 0, WnR = 0
[   10.100769] user pgtable: 4k pages, 39-bit VAs, pgdp=000000010aa90000
[   10.107252] [0000000000000018] pgd=0000000000000000, p4d=0000000000000000, pud=0000000000000000
[   10.115985] Internal error: Oops: 0000000096000005 [#1] SMP
[   10.121559] Modules linked in:
[   10.124614] CPU: 3 PID: 1680 Comm: Xorg Not tainted 6.1.118 #27
[   10.130529] Hardware name: Rockchip RK3576 Rocktech MTB761 V10 Board (DT)
[   10.137313] pstate: 40000005 (nZcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[   10.144274] pc : drm_getunique+0x34/0xe0
[   10.148204] lr : drm_getunique+0x2c/0xe0
[   10.152129] sp : ffffffc00c8cbc30
[   10.155446] x29: ffffffc00c8cbc30 x28: 0000000000000010 x27: ffffffc00c8cbd48
[   10.162577] x26: 0000000000000010 x25: ffffff80c8d52c00 x24: 0000000000000001
[   10.169707] x23: 0000000000000000 x22: ffffff80c8d52c00 x21: 0000000000000000
[   10.176844] x20: ffffff80c57e9098 x19: ffffffc00c8cbd48 x18: 0000000000000000
[   10.183975] x17: 0000000000000000 x16: 0000000000000000 x15: 0000007fe9937c08
[   10.191107] x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000000
[   10.198240] x11: 0000000000000000 x10: 0000000000000000 x9 : ffffffc00949eeb4
[   10.205376] x8 : ffffffc00a81d000 x7 : ffffffc009a0b330 x6 : ffffffc00c8cbd58
[   10.212512] x5 : 0000000000000454 x4 : 0000000000000454 x3 : 0000000000000000
[   10.219646] x2 : ffffff80c359a940 x1 : 0000000000000000 x0 : 0000000000000000
[   10.226781] Call trace:
[   10.229232]  drm_getunique+0x34/0xe0
[   10.232819]  drm_ioctl_kernel+0xb4/0x100
[   10.236750]  drm_ioctl+0x208/0x440
[   10.240154]  __arm64_sys_ioctl+0xb4/0xdc
[   10.244086]  invoke_syscall+0x4c/0x114
[   10.247839]  el0_svc_common.constprop.0+0x54/0x180
[   10.252636]  do_el0_svc+0x20/0x2c
[   10.255955]  el0_svc+0x14/0x80
[   10.259014]  el0t_64_sync_handler+0xb0/0xb4
[   10.263202]  el0t_64_sync+0x158/0x15c

3.文件系统

这里是在rk提供的debian12系统中进行修改,如果debian系统过低需要升级mesa库。因为采用的是开源GPU驱动,所以需要卸载原来系统的mali库。

复制代码
sudo apt-get remove --purge libmali*

另外,xserver部分包也是根据闭源GPU驱动修改的,所以这里需要重新安装,切换回debian主线的软件包。

复制代码
$ sudo apt-get remove --purge xserver-xorg-core-dbgsym xserver-xorg-legacy-dbgsym xserver-common xserver-xorg-core xserver-xorg-legacy
$ sudo apt-get install xserver-common xserver-xorg-core xserver-xorg-legacy xserver-xorg-input-all 

4.测试验证。

glxinfo测试

复制代码
root@linaro-alip:/# glxinfo | grep -i opengl
OpenGL vendor string: Panfrost
OpenGL renderer string: Mali-G52 r1 (Panfrost)
OpenGL core profile version string: 3.1 Mesa 22.3.6
OpenGL core profile shading language version string: 1.40
OpenGL core profile context flags: (none)
OpenGL core profile extensions:
OpenGL version string: 3.1 Mesa 22.3.6
OpenGL shading language version string: 1.40
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.1 Mesa 22.3.6
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10
OpenGL ES profile extensions:

如果用glmark2进行跑分测试,需要卸载掉原有系统的glmark2重新安装。

复制代码
$ sudo apt-get remove --purge glmark2*
$ sudo apt-get install glmark2

查看GPU使用率

复制代码
$ cat /sys/devices/platform/*.gpu/devfreq/*.gpu/load
$ cat /sys/devices/platform/*.gpu/utilisation
相关推荐
Lentou2 小时前
部署项目之systemd部署
linux·运维·服务器
鄃鳕2 小时前
ubuntu下将DHCP动态分配改成静态ip
linux·tcp/ip·ubuntu
凭X而动2 小时前
CentOS7搭建SFTP
linux·运维·服务器
深邃-2 小时前
【Web安全】-Kali,Linux基础:Kali系统安装,Kali鼠标不显示(版本问题),Linux系统介绍(1)
linux·计算机网络·安全·web安全·网络安全·系统安全·网络攻击模型
蜡台2 小时前
Centos 安装Mysql
linux·mysql·centos·yum·mysql8
toooooop82 小时前
wsl系统无损迁移到ssd硬盘
linux·wsl
ShineSpark3 小时前
Ubuntu下SDL窗口偶发卡住问题深度分析
linux·运维·ubuntu
tobias.b3 小时前
Centos Linux 维护
linux·python·centos
深邃-3 小时前
【Web安全】-Kali,Linux基础:Linux终端介绍,Linux文件操作,Linux文件编辑(2)
linux·计算机网络·安全·web安全·网络安全·系统安全·安全威胁分析