How to use open source Panfrost GPU Driver on RZ/G2Lx

From Renesas.info

RZ-G

Note: This article is for experienced users only.

The Panforst driver is not part of official BSP, So some hacking/modification on BSP package is needed.

Introduction

The Panfrost driver stack is open source GPU driver for Midgard and Bifrost microarchitectures based Mali GPU. The RZ/G2Lx series included Mali G31 GPU inside is on the Panfrost support list as well.
This article is a tutorial to enable Panfrost driver support for RZ/G2Lx series Mali GPU based MPU.

Requirement

SOC: RZ/G2L, RZ/V2L, RZ/G2LC
BOARD: RZ/G2L SMARC board
Kernel: Linux kernel v5.10+(v5.16/mainline is also OK but some more patches is needed, let's focus on v5.10 in this article.)
Software package: MESA 21.3.x(v21.3.0 and v21.3.7 is tested and worked)

Device tree

In kernel-source/arch/arm64/boot/dts/renesas/r9a07g044.dtsi, please add the below GPU node in the RZ/G2L device tree.

                gpu: gpu@11840000 {
                        compatible = "renesas,r9a07g044-mali",
                                     "arm,mali-bifrost";
                        reg = <0x0 0x11840000 0x0 0x10000>;
                        interrupts = <GIC_SPI 154 IRQ_TYPE_LEVEL_HIGH>,
                                     <GIC_SPI 155 IRQ_TYPE_LEVEL_HIGH>,
                                     <GIC_SPI 153 IRQ_TYPE_LEVEL_HIGH>,
                                     <GIC_SPI 156 IRQ_TYPE_LEVEL_HIGH>;
                        interrupt-names = "job", "mmu", "gpu", "event";
                        clocks = <&cpg CPG_MOD R9A07G044_GPU_CLK>,
                                 <&cpg CPG_MOD R9A07G044_GPU_AXI_CLK>,
                                 <&cpg CPG_MOD R9A07G044_GPU_ACE_CLK>;
                        clock-names = "gpu", "bus", "bus_ace";
                        power-domains = <&cpg>;
                        resets = <&cpg R9A07G044_GPU_RESETN>,
                                 <&cpg R9A07G044_GPU_AXI_RESETN>,
                                 <&cpg R9A07G044_GPU_ACE_RESETN>;
                        reset-names = "rst", "axi_rst", "ace_rst";
                        operating-points-v2 = <&gpu_opp_table>;
                };

Kernel configuration

To enable the Panfrost kernel driver support, please make sure the kernel config is included in kernel configuration below.

CONFIG_DRM_PANFROST=y

Setup the yocto to re-build the runtime environment

In order to not conflict with the official Mali driver, please make sure the following package is not integrated into your yocto build folder.
RZ MPU Graphics Library Evaluation Version V0.81 for Board Support Package of RZ/G2L and RZ/G2LC

  1. Use the mesa v21.3.7 to replace the mesa folder in mera-rzg2/recipes-graphics or meta-renesas/recipes-graphics
  2. Download the kmsro support patch for mesa v21.3.7 and put the patch into the mesa/files folder.
  3. Modify the mesa_21.3.7.bb file, add the patch file name to the SRC_URI, like below
SRC_URI += "file://0001-kmsro-Add-rcar-du-entry-point-for-Renesas-RZ-G2Lx-se.patch \

Add some more configuration in your local.conf

In build/conf/local.conf, Please add the following config for your build config.

PACKAGECONFIG_append_pn-mesa = " egl kmsro panfrost"
IMAGE_INSTALL_append += " mesa weston kmscube glmark2"

And build your customized image

$ bitbake core-image-weston

Test the Panfrost driver with glmark2

  • Make sure the Panfrost kernel driver is ready

Kernel boot up log:

...
[    0.140409] panfrost 11840000.gpu: clock rate = 500000000
[    0.140456] panfrost 11840000.gpu: bus_clock rate = 200000000
[    0.141269] panfrost 11840000.gpu: [drm:panfrost_devfreq_init] Failed to register cooling device
[    0.141371] panfrost 11840000.gpu: mali-g31 id 0x7093 major 0x0 minor 0x0 status 0x0
[    0.141390] panfrost 11840000.gpu: features: 00000000,3fde77ff, issues: 00000000,00000400
[    0.141408] panfrost 11840000.gpu: Features: L2:0x070d0206 Shader:0x00000000 Tiler:0x00000209 Mem:0x1 MMU:0x00002821 AS:0xff JS:0x7
[    0.141425] panfrost 11840000.gpu: shader_present=0x1 l2_present=0x1
[    0.142475] [drm] Initialized panfrost 1.1.0 20180908 for 11840000.gpu on minor 0
...
  • add PAN_MESA_DEBUG="noafbc" in /etc/environment for your RZ/G2Lx runtime or export PAN_MESA_DEBUG="noafbc" before your run the glmark2-es2-wayland.(kernel v5.10 MUST required.)

Run glmark2-es2-wayland, you should see the Panfrost information like below and the glmark2 testing screen in the monitor.

root@smarc-rzg2l:~# glmark2-es2-wayland
=======================================================
    glm[10215.517141] panfrost 11840000.gpu: js fault, js=0, status=DATA_INVALID_FAULT, head=0x63c8140, tail=0x63c8140
ark2 2017.07
==[10215.528535] panfrost 11840000.gpu: gpu sched timeout, js=0, config=0x7300, status=0x58, head=0x63c8140, tail=0x63c8140, sched_job=0000000035c763e7
=====================================================
    OpenGL Information
    GL_VENDOR:     Panfrost
    GL_RENDERER:   Mali-G31 (Panfrost)
    GL_VERSION:    OpenGL ES 3.1 Mesa 21.3.7
=======================================================
  • kmscube is also available but stop the weston is needed before run it.

...


Have Fun~~
Show Liu