The purpose of this page is to describe how the ARM MALI driver is integrated into Xilinx
Table of Contents
Overview
Xilinx ZynqMPSoC has the MALI 400MP GPU from ARM. The ARM MALI 400MP is an OpenGLES 2.0 capable GPU.Driver access and license
The driver for MALI 400MP consists of Linux kernel driver and user library. The user space library is proprietary licensed and will have to be distributed as binaries. The user space library will be provided through Xilinx PetaLinux release. The Linux kernel driver is GPL licensed, and downloadable from http://malideveloper.arm.com/. Until 2016.4, the kernel driver was hosted on Xilinx github. From 2017.1, the kernel driver hosted on Xilinx github is deprecated. This will now be downloaded from ARM website and packaged into the PetaLinux BSP.The driver is released periodically by ARM. Thus there can be multiple versions available. The default version in Kconfig points to the latest working release.
Device tree binding
The DT binding documentation is included in the driver release. Download the kernel driver tarball from http://malideveloper.arm.com/., unzip it and the DT binding documentation is available at the folder path."driver/documentation/devicetree/bindings/arm/mali-utgard.txt"
Runtime power management
The MALI driver supports fine grained runtime power management based on Linux runtime PM APIs, with its own scheduler. This section describes the flow of specific driver version, r7p0-00rel0, to give an overview.First the driver implements the Linux runtime PM callbacks (in mali_kernel_linux.c), and the runtime pm is enabled in device initialization (arm.c)
static const struct dev_pm_ops mali_dev_pm_ops = { #ifdef CONFIG_PM_RUNTIME .runtime_suspend = mali_driver_runtime_suspend, .runtime_resume = mali_driver_runtime_resume, .runtime_idle = mali_driver_runtime_idle, #endif .suspend = mali_driver_suspend_scheduler, .resume = mali_driver_resume_scheduler, .freeze = mali_driver_suspend_scheduler, .thaw = mali_driver_resume_scheduler, .poweroff = mali_driver_suspend_scheduler, }; #endif
mali_platform_device_register() { ... pm_runtime_set_autosuspend_delay(&&(mali_gpu_device.dev), 1000); pm_runtime_use_autosuspend(&&(mali_gpu_device.dev)); #endif pm_runtime_enable(&&(mali_gpu_device.dev)); ... }
Then, the driver has its own scheduler (mali_scheduler.c) that tracks any activities of all GPU processors (GP: geometry processor, PP: pixel processor). All activities on those processors are created as a job (ex, gp job / pp job) and scheduled through this scheduler. The scheduler tracks the completion of the job as well. Based on the status, the scheduler sets the runtime pm reference count accordingly (mali_scheduler.c). Below is an example for GP. Equivalent functions exist for PP.
mali_scheduler_queue_gp_job() { ... _mali_osk_pm_dev_ref_get_async() ... } mali_scheduler_complete_gp_job() { ... _mali_osk_pm_dev_ref_pet_async() ... }
When the reference count reaches to 0, the runtime_suspend callback will be triggered: runtime_suspend callback -> mali_driver_runtime_suspend() -> mali_pm_runtime_suspend() -> mali_pm_common_suspend(). mali_pm_common_suspend() performs a series of operations to put all relevant modules, ex, l2 cache and mmu, in idle state. Reverse operations is performed when resuming.
mali_pm_common_suspend() { ... if (0 < num_groups_down) { mali_executor_group_power_down(groups_down, num_groups_down); } for (i = 0; i < num_l2_down; i++) { mali_l2_cache_power_down(l2_down[i]); } ... }
Changelog
- 2019.1
- Summary
- The variable to toggle different backend has been decoupled from DISTRO_FEATURES. A new variable "MALI_BACKEND_DEFAULT" is used to select backend.
- Customer can now toggle libMali backend at runtime using update-alternatives. (details can be found below)
- User space driver has some bug fixes ( API: gbm_bo_import)
- Mali kernel space patches: https://github.com/Xilinx/meta-xilinx/tree/rel-v2019.1/meta-xilinx-bsp/recipes-graphics/mali/kernel-module-mali
- Summary
- 2018.3
- Summary
- In addition to fbdev and X11, Mali now supports wayland/GBM and Headless-EGL backend. (details can be found below)
- Mali kernel driver patches can be found https://github.com/Xilinx/meta-xilinx/tree/rel-v2018.3/meta-xilinx-bsp/recipes-graphics/mali/kernel-module-mali
- Summary
- 2018.1
- Summary
- Upgrade to r8p0-01rel0: https://developer.arm.com/products/software/mali-drivers/utgard-kernel
- Fix for compatibility with 4.14 Linux kernel
- Patches available in https://github.com/Xilinx/meta-xilinx/tree/rel-v2018.1/meta-xilinx-bsp/recipes-graphics/mali/kernel-module-mali
- Summary
- 2017.3
- Summary
- No change in kernel module
- Fixed the linker issue in the user space library
- Summary
- 2017.1
- Summary
- The in-tree source code has been deprecated
- Upgrade to r7pp: https://developer.arm.com/products/software/mali-drivers/utgard-kernel#
- Fix for compatibility with 4.9 Linux kernel
- Patches available in https://github.com/Xilinx/meta-xilinx/tree/rel-v2017.1/recipes-graphics/mali/kernel-module-mali
- Summary
- 2016.3
- Summary
- Remove compilation warning
- Fix build error when profiling is enabled
- Commits
- 51056e4 staging: mali: r5p1-01rel0: Don't include mali_read_phys() for zynq/zynqmp
dadb5e4 staging: mali: r5p1-01rel0: Remove unused trace macros
- 51056e4 staging: mali: r5p1-01rel0: Don't include mali_read_phys() for zynq/zynqmp
- Summary
Selecting particular backends:
Wayland/GBM backend:
2019.1:
From 2019.1 release, selecting Mali backend is decoupled from 'DISTRO_FEATURES', another variable is introduced 'MALI_BACKEND_DEFAULT' to create proper link. By default, plnx build system will try to package all the backends in the rootfs and depending upon the value of 'MALI_BACKEND_DEFAULT' we create a link to the correct backend. Fbdev, X11, wayland and headless are the choices we have, assigning incorrect name would yield a link to headless.
For example: Once you have selected libmali through 'petalinux-config -c rootfs', add following parameters to <plnx-proj-root>/project-spec/meta-user/conf/petalinuxbsp.conf to select wayland.
MALI_BACKEND_DEFAULT = "wayland"
Users can still modify DISTRO_FEATURES, in order to reduce the size of rootfs, but remember selecting Mali backend wont be impacted.
2018.3:
From 2018.3 release, Mali will support wayland/GBM backend in addition to fbdev and X11.
For example: Once you have selected libmali through 'petalinux-config -c rootfs' unselect 'packagegroup-petalinux-matchbox' and 'packagegroup-petalinux-x11' and add following parameters to <plnx-proj-root>/project-spec/meta-user/conf/petalinuxbsp.conf
DISTRO_FEATURES_append = " wayland" IMAGE_INSTALL_append = " packagegroup-petalinux-weston"
This packagegroup ensures all the essential wayland/weston packages are packaged into the rootfs for having a wayland/weston application work out of the box. On boot, export following parameter in your terminal console.
export XDG_RUNTIME_DIR=/run/user/0/
Now, you can run sample benchmarking application glmark2-es2-wayland and glmark2-es2-drm.
X11 backend:
By default, Mali supports X11 backend. Just select libmali-xlnx package from 'petalinux-config -c rootfs'. The root filesystem should now have libmali with X11 support. Also, please select at least one window manager.
For example: packagegroup-petalinux-matchbox.
Fbdev backend:
2019.1:
From 2019.1 release,to select fbdev, Just select libmali-xlnx package from 'petalinux-config -c rootfs' and add the following lines to <plnx-proj-root>/project-spec/meta-user/conf/petalinuxbsp.conf
MALI_BACKEND_DEFAULT = "fbdev"
2018.3:
Up to 2018.3, in order to have Mali fbdev backend, please add following lines to <plnx-proj-root>/project-spec/meta-user/conf/petalinuxbsp.conf
DISTRO_FEATURES_remove = "x11"
Headless-EGL backend:
2019.1:
From 2019.1 onwards, please add following lines to <plnx-proj-root>/project-spec/meta-user/conf/petalinuxbsp.conf.
MALI_BACKEND_DEFAULT = "headless"
2018.3:
This backend is available from 2018.3 release, please add following lines to <plnx-proj-root>/project-spec/meta-user/conf/petalinuxbsp.conf.
DISTRO_FEATURES_remove = "x11 fbdev"
Benchmark:
To run a benchmark example for any backend (except headless-egl) please add below lines to build/conf/local.conf
IMAGE_INSTALL_append = " glmark2"
QT wayland/KMS/GBM plugin:
In addition to enable Wayland Mali backend support above, select 'packagegroup-petalinux-qt' in 'petalinux-config -c rootfs' and perform a petalinux-build.
Wayland plugin:
Once weston shows up, export the following environment variables for wayland plugins.
export XDG_RUNTIME_DIR=/run/user/0/ && export QT_QPA_PLATFORM=wayland && export QT_WAYLAND_SHELL_INTEGRATION=wl-shell
Now you can run any example applications like /usr/share/qt5/examples/opengl/textures/textures
KMS/GBM plugin:
For this plugin ensure that weston is not running and export the following environment variables
export QT_QPA_PLATFORM=eglfs && EGLFS_DEVICE_INTEGRATION=eglfs_kms
Now you can run any example applications like /usr/share/qt5/examples/opengl/textures/textures.
Update-alternatives:
2019.1:
If DISTRO_FEATURES are not modified you should have all backends packaged in the rootfs. Now, you can switch between muliple backends using update-alternatives commands as follows:
To Update a link:
update-alternatives --install /usr/lib/libMali.so.8.0 libmali /usr/lib/fbdev/libMali.so.8.0 90
To remove a link:
update-alternatives --remove libmali /usr/lib/fbdev/libMali.so.8.0
For more info, perform update-alternatives --help
Alternate solution: Users can always modify links using "ln" commands
Related Links
- Linux Drivers
- Adding MALI userpace binaries in Yocto builds
- Zynq UltraScale+MPSoC Graphics- GPU application debugging using ARM Mali Graphics Debugger tool
- Zynq UltraScale+MPSoC Graphics- GPU Profiling using ARM Streamline performance analyzer
- Mali 400 optimization guide
- Xilinx ARM MALI 400 Support
- MALI developers