Lima userspace drivers: Xorg/mesa/tools/etc for BPI-R2

Program received signal SIGSEGV, Segmentation fault.
0xb26af638 in ?? () from /usr/lib/arm-linux-gnueabihf/libEGL_mesa.so.0
(gdb) backtrace 
#0  0xb26af638 in ?? () from /usr/lib/arm-linux-gnueabihf/libEGL_mesa.so.0
#1  0xfffff998 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) 

cannot configure mesa to buildtype debug :frowning: also defined the env-variable before running gdb

root@bpi-r2:~# export MESA_DEBUG=1
root@bpi-r2:~# gdb /usr/lib/xorg/Xorg

did you really add only the 2 lines? i guess the entrypoint needs any further configuration…mhm, other values are also not further defined

i use my debian buster image (you need to install x-server after flashing…i use lxde and lightdm) for testing here with 5.4-lima kernel

maybe install kernel and

apt install xinit lxde

is enough to get x server running

if i remove only /usr/lib/dri/* x starts again with info

gbm: failed to open any driver (search paths /usr/lib/arm-linux-gnueabihf/dri:\$${ORIGIN}/dri:/usr/lib/dri)
gbm: Last dlopen error: /usr/lib/dri/mediatek_dri.so: cannot open shared object file: No such file or directory
failed to load driver: mediatek

so it looks like

I meant rebuild mesa with debug.

/usr/lib/arm-linux-gnueabihf/ I suppose it’s not a stansart path, so did you completely uninstalled previous from package meneger?

For 100% I can upload patched tar.gz with sources.

meson build/ --buildtype debug

Also tried this (after removin build folder),but summarization still says it is plain.

Why should i remove my crosscompile libs,imho they are part of system…But i see what you mean…imho some other binaries are linked to this lib too…

Do you need help setting up debian?

I think i can do it :slight_smile:, I just need some time, and a SD-card :).

I meant that, probably, old mesa, installed from official repo may have other path, and if it wasn’t properly removed, there are may be a duplicates of some libs, and Xorg may try to use old lib. You can see what files are installed from yours build and find if the same are present in your system in othel lin paths.

Found a SD with debian stretch, upgrading it to buster.

UPD: Done, trynig to build mesa.

Done! Works fine for me.

First - i’ve installed xorg and xfce4 (but i didn’t actually used it)

I’ve followed this instruction to prepare and get source.

Then patch,

Config:

 meson ./build --reconfigure --buildtype plain --libdir lib/arm-linux-gnueabihf --localstatedir /var/lib --prefix /usr --sysconfdir /etc --wrap-mode nodownload -Dplatforms=surfaceless,x11,drm -Dllvm=true -Dlmsensors=false -Dlibunwind=false -Dgallium-nine=false -Dgallium-va=false -Dgallium-vdpau=false -Dgallium-xa=false -Dgallium-xvmc=false -Dgallium-opencl=disabled -Dosmesa=none -Dbuild-tests=false -Dglx=dri -Dshared-glapi=true -Ddri3=true -Degl=true -Dgbm=true -Dgles1=false -Dgles2=true -Dglvnd=false -Dselinux=false -Dvalgrind=false -Ddri-drivers= -Dgallium-drivers=kmsro,lima

build+install

ninja -C build/ install

xorg: /etc/X11/xorg.conf.d/40-serverflags.conf (/etc/X11/xorg.conf is absent)

Section "ServerFlags"
        Option "AutoAddGPU" "off"
EndSection

xorg.log: xorg.txt (32.1 КБ)

I think you need to pay attention to --libdir lib/arm-linux-gnueabihf looks like it’s a default path for armhf libs

P.S. i’ve performed all tests under chroot’ed debian, but i think result should be the same when loaded directly into debian.

P.P.S. glxgears works, glxinfo too. I can test direct boot, but a bit later.

1 Like

Thank you,i try to build with changed libdir

:+1:

If everything works, the next step will be the documentation. Can we count on your wiki? :wink:

patch for mesa (for mesa git, but may work on others):

diff --git a/src/gallium/targets/dri/meson.build b/src/gallium/targets/dri/meson.build
index 954b2182ce4..87c11000bc1 100644
--- a/src/gallium/targets/dri/meson.build
+++ b/src/gallium/targets/dri/meson.build
@@ -75,6 +75,7 @@ foreach d : [[with_gallium_kmsro, [
                'imx-drm_dri.so',
                'ingenic-drm_dri.so',
                'mcde_dri.so',
+               'mediatek_dri.so',
                'meson_dri.so',
                'mi0283qt_dri.so',
                'mxsfb-drm_dri.so',
diff --git a/src/gallium/targets/dri/target.c b/src/gallium/targets/dri/target.c
index f71f690a70e..c7dd097f5ba 100644
--- a/src/gallium/targets/dri/target.c
+++ b/src/gallium/targets/dri/target.c
@@ -100,6 +100,7 @@ DEFINE_LOADER_DRM_ENTRYPOINT(ili9341)
 DEFINE_LOADER_DRM_ENTRYPOINT(imx_drm)
 DEFINE_LOADER_DRM_ENTRYPOINT(ingenic_drm)
 DEFINE_LOADER_DRM_ENTRYPOINT(mcde)
+DEFINE_LOADER_DRM_ENTRYPOINT(mediatek)
 DEFINE_LOADER_DRM_ENTRYPOINT(meson)
 DEFINE_LOADER_DRM_ENTRYPOINT(mi0283qt)
 DEFINE_LOADER_DRM_ENTRYPOINT(mxsfb_drm)
1 Like
[    24.340] (II) modeset(0): [DRI2] Setup complete
[    24.340] (II) modeset(0): [DRI2]   DRI driver: mediatek
[    24.340] (II) modeset(0): [DRI2]   VDPAU driver: mediatek
...
[    24.382] (II) Initializing extension GLX                                                                                                                   
[    24.406] (II) AIGLX: Loaded and initialized mediatek                                                                                                       
[    24.407] (II) GLX: Initialized DRI2 GL provider for screen 0                                                                                               
[    24.407] (II) AIGLX: Screen 1 is not DRI2 capable                                                                                                          
[    24.662] (II) IGLX: Loaded and initialized swrast                                                                                                          
[    24.662] (II) GLX: Initialized DRISWRAST GL provider for screen 1                                                                                          
[    24.662] (II) Initializing extension XFree86-VidModeExtension                                                                                              
[    24.663] (II) Initializing extension XFree86-DGA                                                                                                           
[    24.664] (II) Initializing extension XFree86-DRI                                                                                                           
[    24.664] (II) Initializing extension DRI2 

looks good so far, x-server was started.

glxinfo:

OpenGL vendor string: lima                                                                                                                                     
OpenGL renderer string: Mali450                                                                                                                                
OpenGL version string: 2.1 Mesa 19.3.2 (git-8734effe13)                                                                                                        
OpenGL shading language version string: 1.20                                                                                                                   
OpenGL extensions:                                                                                                                                             
OpenGL ES profile version string: OpenGL ES 2.0 Mesa 19.3.2 (git-8734effe13)                                                                                   
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 1.0.16                                                                                    
OpenGL ES profile extensions: 

but at least my onscreen-keyboard got messed up graphic and an assertion while running glxinfo about _mesa_make_current (_mesa_is_winsys_fbo(drawBuffer)) in src/mesa/context.c:1750

glxgears running with same ~60fps

all after direct boot (lima was initialized without errors, 5.4-lima branch)…

of course, if all works well and i find some time to write down the infos :wink:

i got same framebuffer errors in xorg.log

[    24.343] (EE) FBDEV(1): FBIOPUTCMAP: Device or resource busy

many times…

i got also some build-warnings like this:

[119/958] Compiling C object 'src/comp.../nir_lower_io_arrays_to_elements.c.o'.                                                                                
../src/compiler/nir/nir_lower_io_arrays_to_elements.c: In function ��‘nir_lower_io_arrays_to_elements_no_indirects��’:                                         
../src/compiler/nir/nir_lower_io_arrays_to_elements.c:352:4: warning: braces around scalar initializer                                                         
    BITSET_DECLARE(indirects, 4 * VARYING_SLOT_TESS_MAX) = {{0}};                                                                                              
    ^~~~~~~~~~~~~~                                                                                                                                             
../src/compiler/nir/nir_lower_io_arrays_to_elements.c:352:4: note: (near initialization for ��‘indirects[0]��’)                                                
../src/compiler/nir/nir_lower_io_arrays_to_elements.c: In function ��‘nir_lower_io_arrays_to_elements��’:                                                      
../src/compiler/nir/nir_lower_io_arrays_to_elements.c:390:4: warning: braces around scalar initializer                                                         
    BITSET_DECLARE(indirects, 4 * VARYING_SLOT_TESS_MAX) = {{0}};                                                                                              
    ^~~~~~~~~~~~~~                                                                                                                                             
../src/compiler/nir/nir_lower_io_arrays_to_elements.c:390:4: note: (near initialization for ��‘indirects[0]��’)                                                
[927/958] Compiling C object 'src/gall...lima/8cb9996@@lima@sta/ir_pp_nir.c.o'.                                                                                
../src/gallium/drivers/lima/ir/pp/nir.c: In function ��‘ppir_get_block��’:                                                                                     
../src/gallium/drivers/lima/ir/pp/nir.c:494:66: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]                                
    ppir_block *block = _mesa_hash_table_u64_search(comp->blocks, (uint64_t)nblock);                                                                           
                                                                  ^                                                                                            
../src/gallium/drivers/lima/ir/pp/nir.c: In function ��‘ppir_compile_nir��’:                                                                                   
../src/gallium/drivers/lima/ir/pp/nir.c:835:52: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]                                
          _mesa_hash_table_u64_insert(comp->blocks, (uint64_t)nblock, block);                                                                                  
                                                    ^                                                                                                          
[958/958] Linking target src/gallium/targets/dri/libgallium_dri.so.

maybe they are related…

Edit: i see you called glxgears like this to get higher fps

vblank_mode=0 glxgears

Need to test it this way…any idea about the issues (damaged graphic in onboard,errors/warnings in log)?

1 Like

with this i get ~500 frames per second…so lima is working well?

but cpu is 90% glxgears + 40% xorg + 10% pp + 10% gp

in my case it gives average 650fps: glxgears ~66% Xorg is about 45%. I’ve also tested my raspberry pi - the cpu usage is abuot the same 55+/-5 - glxgears ang 50+/-5 - Xorg.

Do looks like it works pretty well. (I’ve disabled drm debug)

i guess it’s caused by debug-symbols of mesa…removed build.dir, configured again (–buildtype plain), compiled, installed again…still with debug-symbols ;(

uploaded my current binaries (debian) here: https://drive.google.com/open?id=15Y5Y3NAOwg_IMmN3k6hdb7pAQj9oTVTl

Gentoo ebuilds with lima-enabled mesa are ready:

The repo is avaialible here.

Quick howto:

  • add the repo:

eselect repository add bpi-r2 git https://github.com/d3adme4t/bpi-r2-gentoo.git

  • sync repo: emerge --sync bpi-r2

  • Check for profiles: eselect profile list

    bpi-r2-gentoo ~ # eselect profile list
    Available profile symlink targets:
      [1]   default/linux/arm/17.0 (stable)
      ....
      [40]  default/linux/arm/17.0/uclibc/armv7a/hardened (exp)
      [41]  bpi-r2:lima (dev) *
    

bpi-r2:lima (dev) * should appear.

  • select new profile: eselect profile set bpi-r2:lima (It based on default/linux/arm/17.0/armv7a/desktop profile). After that lima videocard should me unmasked and lima USE-flag added to the mesa package.

  • (Re)Install mesa: emerge -av mesa. Check VIDEO_CARDS before confirm - lima should be in use.

Repo may have some issues/errors. Feel free to ask on any questions.

P.S. I’ve tested mesa-19.3.x and 20.0.0-rc2 by myself - looks good for me.

P.P.S. Any feedback will be appretiated :slight_smile:

UPD: mesa-git also tested (mesa-9999 in repo). As for me - broken buttons/icons in LXDE are fixed with it. @frank-w i think this repo is ready for use. Could you please add instructions to your wiki?

P.P.P.S git mesa (@11-feb-2020) gives ~807 fps in glxgears

P.P.P.P.S. I got glmark2 Score: 189 :slight_smile:

1 Like

What have you done to fix the graphics? Your repo is gentoo speciffic and i need to add changes to debian…have you tried it in your debian environment?

Nothing specific, just latest git version.

Not yet. There are still some menus “blinking” in xfce when effects are on, but LXDE looks much better. Just try latest git code.

P.S. Also i’ve updated whole system, but it’s likely that other software dosn’t affects screen.

Any idea why i see debug-symbols also after remove build-dir and set type to plain?

Did you cleaned souces before rebuilt? (e.g. make clean)

Sorry, didn’t mentioned it before.

Probably in my case libs was stripped by installation scripts.

try to use strip

there is no Makefile…i guess we need to use meson/ninja

tried git pull, but it seems there are no new commits on https://gitlab.freedesktop.org/mesa/mesa.git

8734effe13 (HEAD, tag: mesa-19.3.2) VERSION: bump for 19.3.2

Looks like you use mesa-19.3.2 tag, i meant latest sources:

bpi-r2-gentoo ~ # glxinfo | grep OpenGL
OpenGL vendor string: lima
OpenGL renderer string: Mali450
OpenGL version string: 2.1 Mesa 20.1.0-devel (git-286141197d)
OpenGL shading language version string: 1.20
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 2.0 Mesa 20.1.0-devel (git-286141197d)
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 1.0.16
OpenGL ES profile extensions:

seems like i have cloned only this tag (see no branches and find no way to get latest source as git always says all is up-to-date), making a new clone, configure and build…

btw. i have added lima-changes to 5.6-hdmi…with Patch from bibby warnings are gone, but i have a strange cursor-behaviour: i have touchscreen, and on click i see last cursor-position…not current…looks weired :stuck_out_tongue:

i have 540 fps (vblank_mode=0) with 5.6-hdmi and 20.1-devel…but no more glitches in onboard :wink: but my network does not work now…have not yet figured out why

1 Like