Rockchip's proprietary Mali userspace driver (libmali, g29p1 for the G610 in the RK3588), packaged for a stock distro next to Mesa, with a hook library that fixes up libmali's EGL and GBM, the Vulkan WSI layer and a switch between the vendor stack and Panthor. glvnd and the Vulkan loader stay unmodified.
On Armbian with the edge kernel, built with the kernel patches from mali-dkms (at least 0002, the display controller's render node, and 0003, the system-uncached dma-buf heap), one script installs the vendor stack from the latest GitHub releases of its four parts and switches to it:
| Package | Repository | What |
|---|---|---|
mali-valhall-g610-dkms |
ginkage/mali-dkms | the Mali kernel driver (valhall_kbase, DKMS) |
libmali-valhall-g610-g29p1 |
this one | libmali, the hook library, the Vulkan WSI layer |
the installed Mesa packages, +cix |
ginkage/mesa-cix (branch cix) |
Armbian's Mesa plus zink on libmali (desktop GL 4.6) |
xwayland, +cixmali |
ginkage/xserver (branch 24.1.10) |
Xwayland with glamor on libmali |
curl -fsSLO https://raw.githubusercontent.com/ginkage/libmali-rockchip/master/scripts/install-rk-gpu.sh
sh install-rk-gpu.sh -n # dry run: what would be downloaded and installed
sh install-rk-gpu.sh # install (asks for sudo and for apt's confirmation), then rebootIt replaces every installed package built from Mesa's source with the +cix build (they are version-locked together), installs the kernel headers DKMS needs if they are missing, pins the Mesa and Xwayland builds (/etc/apt/preferences.d/rk-gpu.pref), and runs mali-switch mali.
The WSI layer reports the Mali driver as it is, because mesa-cix's Mesa trusts it to pass rendering fences on to the compositor. With a stock Mesa, set WSI_REPORT_LAYERED_DRIVER=1, or zink waits for every frame before presenting it.
libmali has only GLES, and its X11 platform hangs: it sends DRI3 PixmapFromBuffer with fd -1 instead of the window buffer's dma-buf. So libmali is not installed as libEGL.so.1. The hook library, libmali-hook.so.1, is a glvnd EGL vendor (/usr/share/glvnd/egl_vendor.d/10_mali.json), and glvnd's libEGL, libGLESv1_CM and libGLESv2 pick libmali or Mesa for each process and display:
| Condition | Result |
|---|---|
no /dev/mali0 (kernel runs Panthor) |
Mesa |
app listed under "mesa" |
Mesa EGL with zink on libmali's Vulkan (MESA_LOADER_DRIVER_OVERRIDE=zink) |
app listed under "swrast" (when enabled) |
Mesa software rendering (LIBGL_ALWAYS_SOFTWARE=1) |
app listed under "mali", or unlisted |
libmali on Wayland and GBM; X11 and the default display go to Mesa (zink) |
Applications that need desktop GL on Wayland go under "mesa". GLX always reaches Mesa.
The routing file is /etc/mali/app.json, in CIX's format (JSON with comments, arrays of executable names, the basename of argv[0]), the same as libmali-cix's. Environment variables:
MALI_EGL=mali|mesa|swrast|offoverrides the decision.MALI_EGL_CONFIG=<file>uses another routing file.MALI_EGL_DEBUG=1logs the decisions to stderr.
Variables the hook sets are never overwritten if already set.
mali-switch {mali|panthor|status} switches between the vendor stack (valhall_kbase + libmali) and the upstream one (panthor + Mesa). libmali's Vulkan and OpenCL ICDs, its GBM (libgbm.so.1) and the WSI layer are installed into /usr/lib/aarch64-linux-gnu/mali, and their manifests name bare sonames that resolve only from there. mali-switch owns the two files that turn the vendor stack on, which no package ships, so upgrades never change the mode:
/etc/ld.so.conf.d/00-aarch64-mali.conf: themalidirectory on the linker path./etc/modprobe.d/blacklist-rk-gpu.conf: blacklistspanthor(vendor mode) orvalhall_kbase.
It then runs ldconfig (and update-initramfs -u if a GPU driver is in the initramfs); the switch takes effect after a reboot. Until a mode is chosen, the package puts the mali directory on the linker path and leaves the kernel drivers alone, as before. Removing the package forgets the vendor stack.
meson setup build -Dgpu=valhall-g610 -Dglvnd=true && ninja -C build && meson test -C build
debuild -us -uc -b # every target in debian/targets-Dglvnd=true makes the hook library the glvnd vendor instead of installing EGL and GLES wrappers, and -Dmali-switch=true leaves the vendor directory off the linker path for mali-switch; the Debian package uses both (with -Dvendor-package=true). Without them the build installs libmali as before. scripts/update_wsi.sh downloads the pinned WSI layer release, and CI runs it before building and publishes the packages as a GitHub release for every push to master.