Mali OpenGL support on Allwinner platforms with mainline Linux

As most people know, getting GPU-based 3D acceleration to work on ARM platforms has always been difficult, due to the closed nature of the support for such GPUs. Most vendors provide closed-source binary-only OpenGL implementations in the form of binary blobs, whose quality depend on the vendor.

This situation is getting better and better through vendor-funded initiatives like for the Broadcom VC4 and VC5, or through reverse engineering projects like Nouveau on Tegra SoCs, Etnaviv on Vivante GPUs, Freedreno on Qualcomm’s. However there are still GPUs where you do not have the option to use a free software stack: PowerVR from Imagination Technologies and Mali from ARM (even though there is some progress on the reverse engineering effort).

Allwinner SoCs are using either a Mali GPU from ARM or a PowerVR from Imagination Technologies, and therefore, support for OpenGL on those platforms using a mainline Linux kernel has always been a problem. This is also further complicated by the fact that Allwinner is mostly interested in Android, which uses a different C library that avoids its use in traditional glibc-based systems (or through the use of libhybris).

However, we are happy to announce that Allwinner gave us clearance to publish the userspace binary blobs that allows to get OpenGL supported on Allwinner platforms that use a Mali GPU from ARM, using a recent mainline Linux kernel. Of course, those are closed source binary blobs and not a nice fully open-source solution, but it nonetheless allows everyone to have OpenGL support working, while taking advantage of all the benefits of a recent mainline Linux kernel. We have successfully used those binary blobs on customer projects involving the Allwinner A33 SoCs, and they should work on all Allwinner SoCs using the Mali GPU.

In order to get GPU support to work on your Allwinner platform, you will need:

  • The kernel-side driver, available on Maxime Ripard’s Github repository. This is essentially the Mali kernel-side driver from ARM, plus a number of build and bug fixes to make it work with recent mainline Linux kernels.
  • The Device Tree description of the GPU. We introduced Device Tree bindings for Mali GPUs in the mainline kernel a while ago, so that Device Trees can describe such GPUs. Such description has been added for the Allwinner A23 and A33 SoCs as part of this commit.
  • The userspace blob, which is available on Free Electrons GitHub repository. It currently provides the r6p2 version of the driver, with support for both fbdev and X11 systems. Hopefully, we’ll gain access to newer versions in the future, with additional features (such as GBM support).

If you want to use it in your system, the first step is to have the GPU definition in your device tree if it’s not already there. Then, you need to compile the kernel module:

git clone https://github.com/mripard/sunxi-mali.git
cd sunxi-mali
export CROSS_COMPILE=$TOOLCHAIN_PREFIX
export KDIR=$KERNEL_BUILD_DIR
export INSTALL_MOD_PATH=$TARGET_DIR
./build.sh -r r6p2 -b
./build.sh -r r6p2 -i

It should install the mali.ko Linux kernel module into the target filesystem.

Now, you can copy the OpenGL userspace blobs that match your setup, most likely the fbdev or X11-dma-buf variant. For example, for fbdev:

git clone https://github.com/free-electrons/mali-blobs.git
cd mali-blobs
cp -a r6p2/fbdev/lib/lib_fb_dev/lib* $TARGET_DIR/usr/lib

You should be all set. Of course, you will have to link your OpenGL applications or libraries against those user-space blobs. You can check that everything works using OpenGL test programs such as es2_gears for example.

About Maxime Ripard

Maxime Ripard is an embedded Linux engineer at Free Electrons, which he joined in March 2011. In the past, Maxime has worked at France Telecom on embedded Linux systems, and at Archos on Android-based tablets. At Free Electrons, Maxime is in charge of Android projects and training, and also handles various embedded Linux and kernel projects. More details...
This entry was posted in Technical and tagged , , , . Bookmark the permalink.

24 Responses to Mali OpenGL support on Allwinner platforms with mainline Linux

  1. Luca Ceresoli says:

    Another small step ahead to ease the GPU pain! Thanks for the detailed explanation.

    Note the 2nd link in the 2nd bullet is broken (extra quotes). The correct URL is: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/arch/arm/boot/dts/sun8i-a23-a33.dtsi?id=9af684efc74e6a9ac56047461f3f424d03942d88

  2. Rogan says:

    Is there a reason that this is limited to only Allwinner boards?

    • Giulio Benetti says:

      It’s limited to Allwinner Chips because Mali implementation varies througout every different Soc producer.
      Mali can be the same, but bus, interrupts, features etc. can be different.
      Someone correct me if I’m wrong.

  3. Timo says:

    Nice work !!!

    I tried to build against kernel 4.9.20 but got compiler error:

    /home/build/test-mail/sunxi-mali/r6p2/src/devicedrv/mali/platform/sunxi/sunxi.c: In function ‘mali_platform_device_register’:
    /home/build/test-mail/sunxi-mali/r6p2/src/devicedrv/mali/platform/sunxi/sunxi.c:221:11: error: ‘struct device’ has no member named ‘cma_area’
    cma = dev->cma_area;
    ^
    make[2]: *** [/home/build/test-mail/sunxi-mali/r6p2/src/devicedrv/mali/platform/sunxi/sunxi.o] Error 1

    Any idea what can be the clue ??

    Thanks,
    Timo
    http://www.openvario.org

  4. Sergey says:

    Thank you, Maxime!
    Can you provide any hint about configuring dts for h3/sun8i, please ? I found only example for a20/sun7i and I am not too good with dts yet (;

    • Sergey says:

      Thanks anyone for not-answering!
      The problem is resolved by Armbian guys – I found a new patch for “next” to add the required DT node for sun8i.

      • Giulio Benetti says:

        Hi Sergey,

        first of all, please be patient, Maxime did this work for open source.
        You can’t expect it to be answered in 5 days…
        Anyway, if you join linux-sunxi google group,
        you will find my patch that supports A20/Dts and a patch for mali clock.
        Anyway, everything ends with error 0x3003 on malitest,
        so it takes some more time to fix this.
        Let’s cooperate all together.

        Thanks

  5. Giulio Benetti says:

    Hi Maxime,

    with kernel 4.13.4, trying to insmod mali.ko,
    it gives me “Couldn’t reserve our memory region”.
    So I’ve seen you’ve released a patch time ago to define a memory-region in dts.
    But now it’s not there anymore.
    Am I on right path?
    I’ve also tried to extend cma with bootargs “cma=128M”

    Thanks in advance

    • Giulio Benetti says:

      Ok, added memory-region for mali 128M to keep large.
      Driver insmod works.
      But then malitest and Qt5 gives me:
      Error: eglCreateWindowSurface failed: 0x00003003

      What could it be?
      Thanks

      • Sergey says:

        Getting the same error from Qt5 built with EGLFS support.
        EGL_BAD_ALLOC = 0x3003
        But seems like nobody is answering in this thread…

      • Sergey says:

        Hello Giulio
        any findings on that ?

      • Sergey says:

        Here is my dmesg output regarding mali on orangepi pc:
        ——————————————————-
        [ 8.301918] mali: loading out-of-tree module taints kernel.
        [ 8.305874] Linux cec interface: v0.10
        [ 8.307287] mali-utgard: assigned reserved memory node linux,cma
        [ 8.307867] Allwinner sunXi mali glue initialized
        [ 8.308464] Mali:
        [ 8.308472] Found Mali GPU Mali-400 MP r1p1
        [ 8.309163] Mali:
        [ 8.309170] 2+0 PP cores initialized
        [ 8.309800] Mali:
        [ 8.309806] Mali device driver loaded

        • Is it a syscall failing? If so, which one? You should be able to tell using strace.

          • Giulio Benetti says:

            This is strace with malitest:

            insmod mali.ko
            [ 84.957002] mali: loading out-of-tree module taints kernel.
            [ 84.968459] mali-utgard: assigned reserved memory node cma
            [ 84.975101] Allwinner sunXi mali glue initialized
            [ 84.980940] Mali:
            [ 84.980953] Found Mali GPU Mali-400 MP r1p1
            [ 84.987907] Mali:
            [ 84.987919] 2+0 PP cores initialized
            [ 84.994620] Mali:
            [ 84.994635] Mali device driver loaded
            # strace -v -C /root/
            .ash_history mali.ko
            # strace -v -C malitest
            execve(“/usr/bin/malitest”, [“malitest”], [“USER=root”, “SHLVL=1”, “HOME=/root”, “PAGER=/bin/more “, “PS1=# “, “LOGNAME=root”, “TERM=vt100”, “PATH=/bin:/sbin:/usr/bin:/usr/sb”…, “SHELL=/bin/sh”, “PWD=/root”, “EDITOR=/bin/vi”]) = 0
            brk(NULL) = 0x23000
            uname({sysname=”Linux”, nodename=”micronova”, release=”4.13.4″, version=”#1 SMP Sat Oct 14 15:19:06 CEST 2017″, machine=”armv7l”, domainname=”(none)”}) = 0
            mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f21000
            access(“/etc/ld.so.preload”, R_OK) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/etc/ld.so.cache”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/lib/tls/v7l/neon/vfp/libm.so.6”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/lib/tls/v7l/neon/vfp”, 0xbedb0680) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/lib/tls/v7l/neon/libm.so.6”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/lib/tls/v7l/neon”, 0xbedb0680) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/lib/tls/v7l/vfp/libm.so.6”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/lib/tls/v7l/vfp”, 0xbedb0680) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/lib/tls/v7l/libm.so.6”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/lib/tls/v7l”, 0xbedb0680) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/lib/tls/neon/vfp/libm.so.6”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/lib/tls/neon/vfp”, 0xbedb0680) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/lib/tls/neon/libm.so.6”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/lib/tls/neon”, 0xbedb0680) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/lib/tls/vfp/libm.so.6”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/lib/tls/vfp”, 0xbedb0680) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/lib/tls/libm.so.6”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/lib/tls”, 0xbedb0680) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/lib/v7l/neon/vfp/libm.so.6”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/lib/v7l/neon/vfp”, 0xbedb0680) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/lib/v7l/neon/libm.so.6”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/lib/v7l/neon”, 0xbedb0680) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/lib/v7l/vfp/libm.so.6”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/lib/v7l/vfp”, 0xbedb0680) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/lib/v7l/libm.so.6”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/lib/v7l”, 0xbedb0680) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/lib/neon/vfp/libm.so.6”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/lib/neon/vfp”, 0xbedb0680) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/lib/neon/libm.so.6”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/lib/neon”, 0xbedb0680) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/lib/vfp/libm.so.6”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/lib/vfp”, 0xbedb0680) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/lib/libm.so.6”, O_RDONLY|O_CLOEXEC) = 3
            read(3, “\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\300E\0\0004\0\0\0″…, 512) = 512
            fstat64(3, {st_dev=makedev(179, 1), st_ino=191, st_mode=S_IFREG|0755, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=896, st_size=456100, st_atime=116 /* 1970-01-01T00:01:56.880000050+0000 */, st_atime_nsec=880000050, st_mtime=1507987156 /* 2017-10-14T13:19:16+0000 */, st_mtime_nsec=0, st_ctime=1507987178 /* 2017-10-14T13:19:38.548217606+0000 */, st_ctime_nsec=548217606}) = 0
            mmap2(NULL, 520316, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6e73000
            mprotect(0xb6ee2000, 61440, PROT_NONE) = 0
            mmap2(0xb6ef1000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6e000) = 0xb6ef1000
            close(3) = 0
            openat(AT_FDCWD, “/lib/libdl.so.2”, O_RDONLY|O_CLOEXEC) = 3
            read(3, “\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\230\t\0\0004\0\0\0″…, 512) = 512
            fstat64(3, {st_dev=makedev(179, 1), st_ino=187, st_mode=S_IFREG|0755, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=24, st_size=9660, st_atime=117 /* 1970-01-01T00:01:57.210000050+0000 */, st_atime_nsec=210000050, st_mtime=1507987156 /* 2017-10-14T13:19:16+0000 */, st_mtime_nsec=0, st_ctime=1507987178 /* 2017-10-14T13:19:38.548217606+0000 */, st_ctime_nsec=548217606}) = 0
            mmap2(NULL, 73920, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6e60000
            mprotect(0xb6e62000, 61440, PROT_NONE) = 0
            mmap2(0xb6e71000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1000) = 0xb6e71000
            close(3) = 0
            openat(AT_FDCWD, “/lib/libpthread.so.0”, O_RDONLY|O_CLOEXEC) = 3
            read(3, “\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0`I\0\0004\0\0\0″…, 512) = 512
            fstat64(3, {st_dev=makedev(179, 1), st_ino=201, st_mode=S_IFREG|0755, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=256, st_size=128784, st_atime=117 /* 1970-01-01T00:01:57.210000050+0000 */, st_atime_nsec=210000050, st_mtime=1507987156 /* 2017-10-14T13:19:16+0000 */, st_mtime_nsec=0, st_ctime=1507987178 /* 2017-10-14T13:19:38.548217606+0000 */, st_ctime_nsec=548217606}) = 0
            mmap2(NULL, 168524, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6e36000
            mprotect(0xb6e4c000, 65536, PROT_NONE) = 0
            mmap2(0xb6e5c000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0xb6e5c000
            mmap2(0xb6e5e000, 4684, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6e5e000
            close(3) = 0
            openat(AT_FDCWD, “/lib/libEGL.so”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/usr/lib/tls/v7l/neon/vfp/libEGL.so”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/usr/lib/tls/v7l/neon/vfp”, 0xbedb0638) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/usr/lib/tls/v7l/neon/libEGL.so”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/usr/lib/tls/v7l/neon”, 0xbedb0638) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/usr/lib/tls/v7l/vfp/libEGL.so”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/usr/lib/tls/v7l/vfp”, 0xbedb0638) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/usr/lib/tls/v7l/libEGL.so”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/usr/lib/tls/v7l”, 0xbedb0638) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/usr/lib/tls/neon/vfp/libEGL.so”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/usr/lib/tls/neon/vfp”, 0xbedb0638) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/usr/lib/tls/neon/libEGL.so”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/usr/lib/tls/neon”, 0xbedb0638) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/usr/lib/tls/vfp/libEGL.so”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/usr/lib/tls/vfp”, 0xbedb0638) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/usr/lib/tls/libEGL.so”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/usr/lib/tls”, 0xbedb0638) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/usr/lib/v7l/neon/vfp/libEGL.so”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/usr/lib/v7l/neon/vfp”, 0xbedb0638) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/usr/lib/v7l/neon/libEGL.so”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/usr/lib/v7l/neon”, 0xbedb0638) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/usr/lib/v7l/vfp/libEGL.so”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/usr/lib/v7l/vfp”, 0xbedb0638) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/usr/lib/v7l/libEGL.so”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/usr/lib/v7l”, 0xbedb0638) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/usr/lib/neon/vfp/libEGL.so”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/usr/lib/neon/vfp”, 0xbedb0638) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/usr/lib/neon/libEGL.so”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/usr/lib/neon”, 0xbedb0638) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/usr/lib/vfp/libEGL.so”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            stat64(“/usr/lib/vfp”, 0xbedb0638) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/usr/lib/libEGL.so”, O_RDONLY|O_CLOEXEC) = 3
            read(3, “\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\30\202\2\0004\0\0\0″…, 512) = 512
            fstat64(3, {st_dev=makedev(179, 1), st_ino=555, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=2232, st_size=1141720, st_atime=117 /* 1970-01-01T00:01:57.550000051+0000 */, st_atime_nsec=550000051, st_mtime=1507987156 /* 2017-10-14T13:19:16+0000 */, st_mtime_nsec=0, st_ctime=1507987178 /* 2017-10-14T13:19:38.576217689+0000 */, st_ctime_nsec=576217689}) = 0
            mmap2(NULL, 1176880, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6d16000
            mprotect(0xb6e27000, 32768, PROT_NONE) = 0
            mmap2(0xb6e2f000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x111000) = 0xb6e2f000
            mmap2(0xb6e35000, 1328, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6e35000
            mprotect(0xbedb0000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC|PROT_GROWSDOWN) = 0
            close(3) = 0
            openat(AT_FDCWD, “/lib/libGLESv2.so”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/usr/lib/libGLESv2.so”, O_RDONLY|O_CLOEXEC) = 3
            read(3, “\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\30\202\2\0004\0\0\0″…, 512) = 512
            fstat64(3, {st_dev=makedev(179, 1), st_ino=555, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=2232, st_size=1141720, st_atime=117 /* 1970-01-01T00:01:57.560000051+0000 */, st_atime_nsec=560000051, st_mtime=1507987156 /* 2017-10-14T13:19:16+0000 */, st_mtime_nsec=0, st_ctime=1507987178 /* 2017-10-14T13:19:38.576217689+0000 */, st_ctime_nsec=576217689}) = 0
            close(3) = 0
            openat(AT_FDCWD, “/lib/libc.so.6”, O_RDONLY|O_CLOEXEC) = 3
            read(3, “\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0lm\1\0004\0\0\0″…, 512) = 512
            fstat64(3, {st_dev=makedev(179, 1), st_ino=183, st_mode=S_IFREG|0755, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=2400, st_size=1226452, st_atime=117 /* 1970-01-01T00:01:57.560000051+0000 */, st_atime_nsec=560000051, st_mtime=1507987156 /* 2017-10-14T13:19:16+0000 */, st_mtime_nsec=0, st_ctime=1507987178 /* 2017-10-14T13:19:38.544217594+0000 */, st_ctime_nsec=544217594}) = 0
            mmap2(NULL, 1295748, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6bd9000
            mprotect(0xb6d01000, 61440, PROT_NONE) = 0
            mmap2(0xb6d10000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x127000) = 0xb6d10000
            mmap2(0xb6d13000, 9604, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6d13000
            close(3) = 0
            openat(AT_FDCWD, “/lib/librt.so.1”, O_RDONLY|O_CLOEXEC) = 3
            read(3, “\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0`\27\0\0004\0\0\0″…, 512) = 512
            fstat64(3, {st_dev=makedev(179, 1), st_ino=205, st_mode=S_IFREG|0755, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=56, st_size=26492, st_atime=117 /* 1970-01-01T00:01:57.570000051+0000 */, st_atime_nsec=570000051, st_mtime=1507987156 /* 2017-10-14T13:19:16+0000 */, st_mtime_nsec=0, st_ctime=1507987178 /* 2017-10-14T13:19:38.548217606+0000 */, st_ctime_nsec=548217606}) = 0
            mmap2(NULL, 90648, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6bc2000
            mprotect(0xb6bc8000, 61440, PROT_NONE) = 0
            mmap2(0xb6bd7000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x5000) = 0xb6bd7000
            close(3) = 0
            mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f1f000
            set_tls(0xb6f1f4d0, 0xb6f1fbc0, 0xb6f24058, 0xb6f1f4d0, 0xb6f24058) = 0
            mprotect(0xb6d10000, 8192, PROT_READ) = 0
            mprotect(0xb6e5c000, 4096, PROT_READ) = 0
            mprotect(0xb6bd7000, 4096, PROT_READ) = 0
            mprotect(0xb6ef1000, 4096, PROT_READ) = 0
            mprotect(0xb6e71000, 4096, PROT_READ) = 0
            mprotect(0xb6e2f000, 12288, PROT_READ) = 0
            mprotect(0x21000, 4096, PROT_READ) = 0
            mprotect(0xb6f23000, 4096, PROT_READ) = 0
            set_tid_address(0xb6f1f078) = 207
            set_robust_list(0xb6f1f080, 12) = 0
            rt_sigaction(SIGRTMIN, {sa_handler=0xb6e3a2ec, sa_mask=[], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0xb6c04fc0}, NULL, 8) = 0
            rt_sigaction(SIGRT_1, {sa_handler=0xb6e3a3cc, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART|SA_SIGINFO, sa_restorer=0xb6c04fc0}, NULL, 8) = 0
            rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
            ugetrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0
            brk(NULL) = 0x23000
            brk(0x44000) = 0x44000
            futex(0xb6e720b4, FUTEX_WAKE_PRIVATE, 2147483647) = 0
            openat(AT_FDCWD, “/lib/libGLESv1_CM.so”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/usr/lib/libGLESv1_CM.so”, O_RDONLY|O_CLOEXEC) = 3
            read(3, “\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\30\202\2\0004\0\0\0″…, 512) = 512
            fstat64(3, {st_dev=makedev(179, 1), st_ino=555, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=2232, st_size=1141720, st_atime=117 /* 1970-01-01T00:01:57.930000051+0000 */, st_atime_nsec=930000051, st_mtime=1507987156 /* 2017-10-14T13:19:16+0000 */, st_mtime_nsec=0, st_ctime=1507987178 /* 2017-10-14T13:19:38.576217689+0000 */, st_ctime_nsec=576217689}) = 0
            close(3) = 0
            openat(AT_FDCWD, “/lib/libMali.so”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/usr/lib/libMali.so”, O_RDONLY|O_CLOEXEC) = 3
            read(3, “\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\30\202\2\0004\0\0\0″…, 512) = 512
            fstat64(3, {st_dev=makedev(179, 1), st_ino=555, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=2232, st_size=1141720, st_atime=117 /* 1970-01-01T00:01:57.940000051+0000 */, st_atime_nsec=940000051, st_mtime=1507987156 /* 2017-10-14T13:19:16+0000 */, st_mtime_nsec=0, st_ctime=1507987178 /* 2017-10-14T13:19:38.576217689+0000 */, st_ctime_nsec=576217689}) = 0
            close(3) = 0
            openat(AT_FDCWD, “/dev/mali”, O_RDWR) = 3
            fstat64(3, {st_dev=makedev(0, 6), st_ino=3971, st_mode=S_IFCHR|0600, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_rdev=makedev(10, 59), st_atime=93 /* 1970-01-01T00:01:33.720000039+0000 */, st_atime_nsec=720000039, st_mtime=93 /* 1970-01-01T00:01:33.720000039+0000 */, st_mtime_nsec=720000039, st_ctime=93 /* 1970-01-01T00:01:33.720000039+0000 */, st_ctime_nsec=720000039}) = 0
            ioctl(3, _IOC(_IOC_READ|_IOC_WRITE, 0x82, 0x3, 0x10), 0xbedb0be0) = 0
            ioctl(3, _IOC(_IOC_READ|_IOC_WRITE, 0x82, 0x6, 0x38), 0xbedb0ba0) = 0
            mmap2(NULL, 8388608, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0xb63c2000
            mprotect(0xb63c3000, 8384512, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
            clone(child_stack=0xb6bc0f98, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0xb6bc14c8, tls=0xb6bc1920, child_tidptr=0xb6bc14c8) = 208
            ioctl(3, _IOC(_IOC_READ, 0x84, 0x2, 0x10), 0xbedb0c20) = 0
            rt_sigprocmask(SIG_SETMASK, ~[RT_1], [], 8) = 0
            mmap2(NULL, 26336, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0xb6f18000
            mprotect(0xb6f19000, 22240, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
            clone(child_stack=0xb6f1d678, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0xb6f1dba8, tls=0xb6f1e000, child_tidptr=0xb6f1dba8) = 209
            rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
            futex(0xb6bd8210, FUTEX_WAKE_PRIVATE, 2147483647) = 0
            timer_create(CLOCK_MONOTONIC, {sigev_value={sival_int=156024, sival_ptr=0x26178}, sigev_signo=SIGRTMIN, sigev_notify=SIGEV_THREAD_ID, sigev_notify_thread_id=209}, [0]) = 0
            openat(AT_FDCWD, “/tmp/enable_mali_userspace_cinstr”, O_RDONLY) = -1 ENOENT (No such file or directory)
            openat(AT_FDCWD, “/dev/fb0″, O_RDWR) = 4
            ioctl(4, FBIOGET_VSCREENINFO, 0xbedb0b10) = 0
            mmap2(NULL, 8294400, PROT_WRITE, MAP_SHARED, 4, 0) = 0xb5bd9000
            ioctl(4, FBIOGET_VSCREENINFO, 0x26364) = 0
            ioctl(4, FBIOGET_FSCREENINFO, 0x26404) = 0
            fstat64(1, {st_dev=makedev(0, 6), st_ino=1035, st_mode=S_IFCHR|0600, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_rdev=makedev(5, 1), st_atime=112 /* 1970-01-01T00:01:52.510000000+0000 */, st_atime_nsec=510000000, st_mtime=112 /* 1970-01-01T00:01:52.510000000+0000 */, st_mtime_nsec=510000000, st_ctime=88 /* 1970-01-01T00:01:28.940000037+0000 */, st_ctime_nsec=940000037}) = 0
            ioctl(1, TCGETS, {c_iflags=0x1500, c_oflags=0x5, c_cflags=0x1cb2, c_lflags=0xa3b, c_line=0, c_cc=”\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x0a\x12\x0f\x17\x16\x00\x00\x00”}) = 0
            write(1, “EGL Version: \”1.4 Linux-r6p2-01r”…, 37EGL Version: “1.4 Linux-r6p2-01rel0”
            ) = 37
            write(1, “EGL Vendor: \”ARM\”\n”, 18EGL Vendor: “ARM”
            ) = 18
            write(1, “EGL Extensions: \”EGL_KHR_image E”…, 383EGL Extensions: “EGL_KHR_image EGL_KHR_image_base EGL_KHR_image_pixmap EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_cubemap_image EGL_KHR_gl_renderbuffer_image EGL_KHR_reusable_sync EGL_KHR_fence_sync EGL_KHR_lock_surface EGL_KHR_lock_surface2 EGL_EXT_create_context_robustness EGL_ANDROID_blob_cache EGL_KHR_create_context EGL_KHR_partial_update EGL_KHR_create_context_no_error ”
            ) = 383
            ioctl(3, _IOC(_IOC_READ, 0x84, 0x2, 0x10), 0xbedb0bc0) = 0
            ioctl(3, _IOC(_IOC_READ|_IOC_WRITE, 0x83, 0, 0x28), 0xbedb0a40) = 0
            mmap2(NULL, 262144, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0x10000000) = 0xb5b99000
            write(2, “Error: eglCreateWindowSurface fa”…, 49Error: eglCreateWindowSurface failed: 0x00003003
            ) = 49
            munmap(0xb5b99000, 262144) = 0
            ioctl(3, _IOC(_IOC_READ|_IOC_WRITE, 0x83, 0x1, 0x10), 0xbedb0b18) = 0
            munmap(0xb5bd9000, 8294400) = 0
            close(4) = 0
            timer_delete(0) = 0
            ioctl(3, _IOC(_IOC_READ|_IOC_WRITE, 0x82, 0x4, 0x10), 0xbedb0bc0) = 0
            close(3) = 0
            exit_group(-1) = ?
            +++ exited with 255 +++
            % time seconds usecs/call calls errors syscall
            —— ———– ———– ——— ——— —————-
            30.75 0.001976 42 47 36 openat
            16.63 0.001069 51 21 mmap2
            14.08 0.000905 82 11 ioctl
            9.10 0.000585 65 9 read
            7.16 0.000460 27 17 mprotect
            6.75 0.000434 39 11 close
            5.12 0.000329 165 2 munmap
            2.16 0.000139 70 2 clone
            1.99 0.000128 4 30 30 stat64
            1.42 0.000091 8 11 fstat64
            0.86 0.000055 18 3 brk
            0.81 0.000052 13 4 write
            0.68 0.000044 44 1 timer_create
            0.59 0.000038 38 1 1 access
            0.45 0.000029 15 2 futex
            0.28 0.000018 9 2 rt_sigaction
            0.28 0.000018 6 3 rt_sigprocmask
            0.22 0.000014 14 1 timer_delete
            0.19 0.000012 12 1 execve
            0.14 0.000009 9 1 uname
            0.12 0.000008 8 1 ugetrlimit
            0.08 0.000005 5 1 set_tid_address
            0.08 0.000005 5 1 set_robust_list
            0.06 0.000004 4 1 set_tls
            —— ———– ———– ——— ——— —————-
            100.00 0.006427 184 67 total
            # [ 147.111360] random: crng init done

          • Giulio Benetti says:

            But on fd = 4(/dev/mali) don’t seem to be syscalls with errors.
            The only thing strange to me is mmap2 on mali with offset 0x10000000.
            But it returns a valid virtual memory address and I don’t how normally works Mali.

          • Giulio Benetti says:

            Sorry I meant fd==3 not 4

        • Giulio Benetti says:

          Try to recompile r6p2 kernel driver mali.ko with BUILD=debug instead of release.
          At least it is more verbose and can give more informations.
          I have to give it a try before debugging into mali.so assembly tomorrow.

          • Giulio Benetti says:

            With driver compiled in debug nothing new.
            I’m debugging Mali.so through malitest in assembler.
            At the moment found where it gets to error 0x3003.
            Now I have to dig more.

Leave a Reply to Rogan Cancel reply

Your email address will not be published. Required fields are marked *