Starting with Linux Kernel 5.2, the Lima Driver has been added to the mainline. The Lima Driver is an open source kernel driver for the Mali-400 / 450. This article shows how to run the Lima Driver on linux-xlnx v2020.1 (based on Linux Kernel 5.4).
At the moment, we have only experimentally confirmed that the Lima Driver has started. Note that we didn't even run the Mesa Graphics Library that runs on it.
Lima is an open source graphics driver for the Mali-400 / 450. Lima includes the Linux kernel driver Lima Driver and the Mesa Graphics Library driver Mesa Lima.
Fig.1 Lima
For more information about Lima, please refer to the following URL.
It's confusing, but there is also a Mali Driver apart from the Lima Driver. The Mali Driver is an open source Mali Ulgard GPU Kernel Driver provided by ARM. To use the Mali Driver, you need to visit the ARM web page and accept the end-user license. Please refer to the following article for how to incorporate the Mali Driver into Ultra96 / Ultra96-V2.
Starting with Linux Kernel 5.2, the Lima Driver is included in the mainline. The driver source code can be found in drivers / gpu / drm / lima.
Since linux-xlnx v2020.1 is based on Linux Kernel 5.4, the Lima Driver has been added. However, the kernel configuration file (xilinx_zynqmp_defconfig) provided for Ultra96 / Ultra96-V2 does not include the Lima Driver. Add CONFIG_DRM_LIMA = y or CONFIG_DRM_LIMA = m to arch / arm64 / configs / xylinx_zynqmp_defconfig or select Device Drivers> Graphics support> LIMA (DRM support for ARM Mali 400/450 GPU) in make menuconfig.
The Device Tree for zynqmp on linux-xlnx v2020.1 has the following description:
arch/arm64/boot/dts/xilinx/zynqmp.dtsi
:
(Omission)
:
gpu: gpu@fd4b0000 {
status = "disabled";
compatible = "arm,mali-400", "arm,mali-utgard";
reg = <0x0 0xfd4b0000 0x0 0x10000>;
interrupt-parent = <&gic>;
interrupts = <0 132 4>, <0 132 4>, <0 132 4>, <0 132 4>, <0 132 4>, <0 132 4>;
interrupt-names = "IRQGP", "IRQGPMMU", "IRQPP0", "IRQPPMMU0", "IRQPP1", "IRQPPMMU1";
clock-names = "gpu", "gpu_pp0", "gpu_pp1";
power-domains = <&zynqmp_firmware PD_GPU>;
};
:
(Omission)
In addition, the Device Tree for Ultra96 has the following description.
arch/arm64/boot/dts/xilinx/zynqmp-zcu100-revC.dts
/dts-v1/;
#include "zynqmp.dtsi"
:
(Omission)
:
&gpu {
status = "okay";
};
:
(Omission)
From this, the GPU should be enabled on Ultra96. However, the Lima Driver will not work as it is. In fact, the Device Tree introduced above is for the Mali Driver, not the Lima Driver.
In order for the Device Tree to be compatible with the Lima Driver, you need to change the values of the interrupt-names and clock-names properties of the gpu node.
The interrupt names are different for the Mali Driver and Lima Driver. The Lima Driver makes the interrupt-names property as follows:
arch/arm64/boot/dts/xilinx/zynqmp.dtsi
interrupts = <0 132 4>, <0 132 4>, <0 132 4>, <0 132 4>, <0 132 4>, <0 132 4>;
interrupt-names = "gp", "gpmmu", "pp0", "ppmmu0", "pp1", "ppmmu1";
;
The assumed clock is different between Mali Driver and Lima Driver. The clocks assumed by the Mali Driver are "gpu", "gpu_pp0", and "gpu_pp1", but the clocks assumed by Lima are "bus" and "core".
Not only do they have different names, but they also assume different types of clocks, so simply renaming the clocks "usually" does not work. Changes are required at the source code level of the "normally" Lima Driver.
However, ZynqMP is a little tricky, but you can get it to work by just modifying the Device Tree. Specifically, change "gpu_pp0" to "core" and "gpu_pp1" to "bus" as follows.
arch/arm64/boot/dts/xilinx/zynqmp.dtsi
clock-names = "gpu", "core", "bus";
The Lima Driver first enables the clock with the name "bus". However, in this Device Tree, the clock of "gpu_pp1" is effectively enabled. Then enable the clock with the name "core". However, the clock of "gpu_pp0" is effectively enabled.
So what about the "gpu" clock? There is a question, but in the case of ZynqMP, there is no problem. Because in ZynqMP, "gpu_pp0", "gpu_pp1", "gpu" have a hierarchical structure, and "gpu" clock output is "gpu"-> "gpu_pp0", "gpu"-> "gpu_pp1". It is connected to the input of the "gpu_pp0" clock and the input of the "gpu_pp1" clock. The Linux Kernel clock driver enables a clock retroactively when it is enabled. Therefore, when the "gpu_pp0" clock is enabled, the "gpu" clock is also enabled.
When you start the Linux Kernel with the Lima Driver installed, the following log appears on the console (or dmesg).
shell$ dmesg
:
(Omission)
:
[ 7.269921] lima fd4b0000.gpu: IRQ pmu not found
[ 7.274750] lima fd4b0000.gpu: IRQ ppmmu2 not found
[ 7.279683] lima fd4b0000.gpu: IRQ ppmmu3 not found
[ 7.284718] lima fd4b0000.gpu: gp - mali400 version major 1 minor 1
[ 7.291112] lima fd4b0000.gpu: pp0 - mali400 version major 1 minor 1
[ 7.297575] lima fd4b0000.gpu: pp1 - mali400 version major 1 minor 1
[ 7.304059] lima fd4b0000.gpu: IRQ pp2 not found
[ 7.308708] lima fd4b0000.gpu: IRQ pp3 not found
[ 7.313368] lima fd4b0000.gpu: l2 cache 64K, 4-way, 64byte cache line, 128bit external bus
[ 7.330325] lima fd4b0000.gpu: bus rate = 499999995
[ 7.335463] lima fd4b0000.gpu: mod rate = 499999995
[ 7.360178] [drm] Initialized lima 1.0.0 20190217 for fd4b0000.gpu on minor 1
:
(Omission)
You can also create renderD128 under / dev / dri.
shell$ ls -la /dev/dri
total 0
drwxr-xr-x 3 root root 120 Feb 14 2019 .
drwxr-xr-x 14 root root 13820 Feb 14 2019 ..
drwxr-xr-x 2 root root 100 Feb 14 2019 by-path
crw-rw---- 1 root video 226, 0 Feb 14 2019 card0
crw-rw---- 1 root video 226, 1 Feb 14 2019 card1
crw-rw---- 1 root render 226, 128 Feb 14 2019 renderD128
I tried running linux-xlnx v2020.1 with the Lima Driver, but at the moment I have two problems.
zocl is a kernel module of XRT (Xilinx Runtime). See the following articles for zocl and XRT.
If you install zocl with the Lima Driver installed, the device file for zocl will be / dev / dri / renderD129 (renderD128 is already used by the lima driver). In this state, for example, when I try to start the sample program of [ZynqMP-XRT-Example-1-Ultra96], it says that the device cannot be found as follows.
shell$ ./streaming_lap_filter5.exe streaming_lap_filter5.xclbin
Using FPGA binary file specfied through the command line: streaming_lap_filter5.xclbin
XRT build version: 2.6.0
Build hash: 7104cc336e010e3e0755264ff832d811ff605e2c
Build date: 2020-03-24 21:07:36
Git branch: 2019.2_Ultra96
PID: 610
UID: 1000
[Tue Jun 23 10:12:10 2020]
HOST: debian-fpga
EXE: /home/fpga/examples/ZynqMP-FPGA-XRT-Example-1-Ultra96/streaming_lap_filter5.exe
[XRT] ERROR: No devices found
../src/krnl_streaming_lap_host3.cpp:71 Error calling err = cl::Platform::get(&platforms), error code is: -1
Apparently it doesn't work unless / dev / dri / renderD128 is assigned to zocl. I tried rmmoding the lima driver, then loading zocl and assigning / dev / dri / renderD128 to zocl and it worked fine.
If I rmmod the Lima Driver and then try to restart it with modprobe, the restart fails with the following log:
shell$ dmesg
:
(Omission)
:
[ 1758.651570] lima fd4b0000.gpu: IRQ pmu not found
[ 1758.656223] lima fd4b0000.gpu: mmu gpmmu dte write test fail
[ 1758.662084] lima: probe of fd4b0000.gpu failed with error -5
This matter is currently pending.
The author provides Debian GNU / Linux for Ultra96 / Ultra96-V2 (ZynqMP) [1]. However, at this time, the Lima Driver is not installed because of the problems mentioned in the previous section. We plan to incorporate Lima as soon as these issues are resolved. We are looking for some good ideas.
["Running XRT (Xilinx Runtime) on Debian GNU / Linux for Ultra96 / Ultra96-V2 (Overview)" @Qiita]: https://qiita.com/ikwzm/items/0d3a8adfe725cd17f932 "For Ultra96 / Ultra96-V2 Running XRT (Xilinx Runtime) on Debian GNU / Linux (Overview) "@Qiita" ["Running X Window on Debian GNU / Linux for Ultra96 / Ultra96-V2 (Mali Driver)" @Qiita]: https://qiita.com/ikwzm/items/8c96d75e03cdcb91e5b2 "" Debian GNU for Ultra96 / Ultra96-V2 / Running X Window on Linux (Mali Driver) ”@Qiita" [ZynqMP-XRT-Example-1-Ultra96]: https://github.com/ikwzm/ZynqMP-XRT-Example-1-Ultra96 "ZynqMP-XRT-Example-1-Ultra96" [1]: https://qiita.com/ikwzm/items/0c6f110aa19e368af03d "Debian GNU / Linux for UltraZed / Ultra96 / Ultra96-V2 (v2019.1 version) Boot image provided" @Qiita "
Recommended Posts