mripard / sunxi-mali

GNU General Public License v2.0
100 stars 54 forks source link

Mali test app fails with 0x00003003 #15

Closed sergey-suloev closed 6 years ago

sergey-suloev commented 6 years ago

Hello guys I was able to compile mali driver with "debug" and also the test application. Below you can see the console output:

     root@aapi-5z6nizb:~/mali_test/build# ./mali_test 
     EGL Version: "1.4 Linux-r6p2-01rel0"
     EGL Vendor: "ARM"
     EGL 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 "
     Error: eglCreateWindowSurface failed: 0x00003003

dmesg log contains only typical boot output:

    root@aapi-5z6nizb:~/mali_test/build# dmesg | grep "mali"
    [    8.940525] mali: loading out-of-tree module taints kernel.
    [    8.990414] mali_module_init() registering device
    [    8.992767] platform mali-utgard: assigned reserved memory node linux,cma
    [    8.993340] Allwinner sunXi mali glue initialized
    [    8.993351] mali_module_init() registering driver
    [    8.993525] mali_probe(): Called for platform device mali-utgard
    [    8.999887] mali_mmu_probe_irq_acknowledge: intstat 0x3
    [    9.003946] mali_mmu_probe_irq_acknowledge: intstat 0x3
    [    9.005443] mali_mmu_probe_irq_acknowledge: intstat 0x3
    [    9.007249] mali_probe(): Successfully initialized driver for platform device mali-utgard

    root@aapi-5z6nizb:~/mali_test/build# dmesg | grep "cma"
    [    0.000000] OF: reserved mem: initialized node linux,cma, compatible id shared-dma-pool
    [    0.000000] Memory: 887008K/1048576K available (8192K kernel code, 944K rwdata, 2340K rodata, 
    1024K init, 346K bss, 30496K reserved, 131072K cma-reserved, 131060K highmem)
    [    8.957232] sun4i-drm display-engine: assigned reserved memory node linux,cma
    [    8.992767] platform mali-utgard: assigned reserved memory node linux,cma
giuliobenetti commented 6 years ago

@sergey-suloev load driver in this way:

insmod mali.ko mali_debug_level=5

So it is more verbose. After launch malitest. Then launch:

dmesg

and post it here. You're very very close to have it working.

Did you set CONFIG_DRM_FBDEV_OVERALLOC option or the drm_kms_helper.drm_fbdev_overalloc parameter to 200?

sergey-suloev commented 6 years ago

http://sprunge.us/JKDY

sergey-suloev commented 6 years ago

I didn't set CONFIG_DRM_FBDEV_OVERALLOC at compile time but I am using the kernel boot parameter .

sergey-suloev commented 6 years ago

[ 0.000000] Kernel command line: root=UUID=60742261-81da-41a8-bba5-5362f83e9a94 rootwait rootfstype=ext4 console= console=ttyS0,115200 hdmi.audio=EDID:0 disp.screen0_output_mode=1920x1080p60 panic=10 consoleblank=0 loglevel=1 ubootpart=b1daacee-01 ubootsource=mmc usb-storage.quirks=0x2537:0x1066:u,0x2537:0x1068:u drm_kms_helper.edid_firmware=HDMI-A-1:edid/720x480.bin video=HDMI-A-1:720x480-24@60 drm_kms_helper.drm_fbdev_overalloc=200 mali.mali_debug_level=5 sunxi_ve_mem_reserve=0 sunxi_g2d_mem_reserve=0 sunxi_fb_mem_reserve=16 cgroup_enable=memory swapaccount=1

giuliobenetti commented 6 years ago

It seems everything correct! Please try set CONFIG_DRM_FBDEV_OVERALLOC=200 and recompile kernel. Because I've never tried it with drm_kms_helper.drm_fbdev_overalloc=200 as bootargs. Really you're almost there. But doesn't show up a triagle on screen?

Anyway with this dmesg you can be helped for sure!

sergey-suloev commented 6 years ago

no. it is not showing anything

sergey-suloev commented 6 years ago

ok, I'll try to recompile

sergey-suloev commented 6 years ago

After recompile http://sprunge.us/NgeA Able to see the reason of the issue from the debug log ? Me not.

giuliobenetti commented 6 years ago

Two possibility come into my mind:

Another useful thing you could do is executing malitest with strace and pastebin it. At least we can check syscalls. For the rest I don't have other ideas and I leave answer to more expert people! @mripard @net147

sergey-suloev commented 6 years ago

@giuliobenetti thanks But why do we always think the problem is in the driver itself ? We have another important component, libMali.so, which is opaque. We have no idea what's going on there - no source, no debug logs, etc. It may be even binary incompatible with my system.

sergey-suloev commented 6 years ago

@giuliobenetti thermal thermal_zone0: failed to read out thermal zone (-110): but it should be a "soft-error" It seems like a minor one, AFAIK

sergey-suloev commented 6 years ago

@giuliobenetti tried with Waveshare-compatible 3.5 inch SPI display to exclude possible HDMI issues - same error. i.e. problem either in the driver code or in libMali.so

Qt5 says:

qt.qpa.egldeviceintegration: EGL device integration plugin keys: ("eglfs_emu", "eglfs_mali") qt.qpa.egldeviceintegration: EGL device integration plugin keys (sorted): ("eglfs_mali", "eglfs_emu") qt.qpa.egldeviceintegration: Trying to load device EGL integration "eglfs_mali" qt.qpa.egldeviceintegration: Using EGL device integration "eglfs_mali"

Unable to query physical screen size, defaulting to 100 dpi. To override, set QT_QPA_EGLFS_PHYSICAL_WIDTH and QT_QPA_EGLFS_PHYSICAL_HEIGHT (in millimeters).

EGL Error : Could not create the egl surface: error = 0x3003

giuliobenetti commented 6 years ago

At this point I would dig into dts or kernel drm. At least another step Has been done

sergey-suloev commented 6 years ago

@giuliobenetti so you don't think the problem can be in the user-mode library ? As driver does not show any error the only component that may fail is libMali.so. is there source code anywhere ?

giuliobenetti commented 6 years ago

@sergey-suloev I would say almost impossible, and if it is that way, the only chance we have is to set some environment variable to make it work.

sergey-suloev commented 6 years ago

@giuliobenetti my point is that we don't know how this binary was built and for what platform and compilation flags. how can we be sure that it is going to work on any Soc?

giuliobenetti commented 6 years ago

There is a build configuration here: https://github.com/free-electrons/mali-blobs/blob/master/r6p2/fbdev/information

For the rest only testing will tell us the truth. Maybe @net147 can help with this also.

sergey-suloev commented 6 years ago

@giuliobenetti GCC 4.8. so old version.

giuliobenetti commented 6 years ago

@sergey-suloev yes I know, but I've compiled with 6.4 and works correctly.

sergey-suloev commented 6 years ago

@giuliobenetti I am pretty much unsure about following flags:

--with-fpu=vfpv3-d16 --with-mode=thumb

giuliobenetti commented 6 years ago

@sergey-suloev that's a good point, do you compiler support vfp-d16? I can tell you that if it supports neon too, it's ok, because it's not used by libMali.so But check for fpu. Even if I expect more a segmentation fault than an a "clear" error 0x3003 that means BAD_ALLOC from opengl ES

sergey-suloev commented 6 years ago

@giuliobenetti are you talking about user-mode flags or kernel ? what are your flags for kernel ?

hor63 commented 6 years ago

vfp-d16 is the lowest denominator of the VFP FPUs, VFP with 3w Registers and VFP 4 will work with this setting.

Cheers, Kai

Sent from my iPad

On Dec 2, 2017, at 13:53, Giulio Benetti notifications@github.com<mailto:notifications@github.com> wrote:

@sergey-suloevhttps://github.com/sergey-suloev that's a good point, do you compiler support vfp-d16? I can tell you that if it supports neon too, it's ok, because it's not used by libMali.so But check for fpu. Even if I expect more a segmentation fault than an a "clear" error 0x3003 that means BAD_ALLOC from opengl ES

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/mripard/sunxi-mali/issues/15#issuecomment-348690321, or mute the threadhttps://github.com/notifications/unsubscribe-auth/APbi3dpD4AflHk6_-DY-vDCA7clvxNKGks5s8UhSgaJpZM4Qyodb.

sergey-suloev commented 6 years ago

@hor63 thanks what do you think about "thumb" option ?

hor63 commented 6 years ago

Should not be a problem. Thumb and Arm instruction set mix , particularly between shared libraries is supported. Otherwise the user-space Blob would not work at all because you invoke from your application.

Sent from my iPad

On Dec 2, 2017, at 14:04, orpaltech notifications@github.com<mailto:notifications@github.com> wrote:

@hor63https://github.com/hor63 thanks what do you think about "thumb" option ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/mripard/sunxi-mali/issues/15#issuecomment-348690898, or mute the threadhttps://github.com/notifications/unsubscribe-auth/APbi3QN7xlKL0HVFjZvL6I3ASRIzMCCMks5s8Ur0gaJpZM4Qyodb.

paolosabatino commented 6 years ago

Some issues I had with eglCreateWindowSurface():

hor63 commented 6 years ago

@paolosabatino @sergey-suloev To rule out access issues run the test program as root, i.e. run sudo If that works hash out access issues to /dev/fb0 and/or /dev/mali. Otherwise ugh!@#$$%^

hor63 commented 6 years ago

@sergey-suloev I lost track somehow. Did the kernel module load properly? Here's from /var/log/syslog from my Cubieboard where I named the memory region "cma": Dec 5 20:45:03 horOV kernel: [ 4.371525] mali: loading out-of-tree module taints kernel. Dec 5 20:45:03 horOV kernel: [ 4.376006] platform mali-utgard: assigned reserved memory node cma Dec 5 20:45:03 horOV kernel: [ 4.376449] Allwinner sunXi mali glue initialized Dec 5 20:45:03 horOV kernel: [ 4.387117] Mali: Dec 5 20:45:03 horOV kernel: [ 4.387131] Found Mali GPU Mali-400 MP r1p1 Dec 5 20:45:03 horOV kernel: [ 4.388471] Mali: Dec 5 20:45:03 horOV kernel: [ 4.388483] 2+0 PP cores initialized Dec 5 20:45:03 horOV kernel: [ 4.389560] Mali: Dec 5 20:45:03 horOV kernel: [ 4.389572] Mali device driver loaded

Does it look like that on your device?

sergey-suloev commented 6 years ago

@hor63 yeah, the module is loaded fine. I have all the messages in place.

hor63 commented 6 years ago

Next try sudo.

sergey-suloev commented 6 years ago

@hor63 working as root on device

hor63 commented 6 years ago

Yeah!!!! Now things should be easier. Do a ls /dev/fb0 /dev/mali I am asking about the access rights.

sergey-suloev commented 6 years ago

@hor63 got both

hor63 commented 6 years ago

Please post the output from: ls -l /dev/fb0 /dev/mali

hor63 commented 6 years ago

@sergey-suloev ?? YOU ARE SO CLOSE!!!! :)

sergey-suloev commented 6 years ago

@hor63 sry for delay, had to finish other stuff

root@aapi-ujhnevn:~# ls -la /dev/fb0 crw-rw---- 1 root video 29, 0 Dec 5 20:58 /dev/fb0

root@aapi-ujhnevn:~# ls -la /dev/mali crw------- 1 root root 10, 57 Dec 5 20:58 /dev/mali

sergey-suloev commented 6 years ago

@hor63 here is also my dmesg and system info http://sprunge.us/eZKQ

mripard commented 6 years ago

Only root has access to /dev/mali. Change the permissions so that your user can access it.

sergey-suloev commented 6 years ago

@mripard the only user on this device is root

sergey-suloev commented 6 years ago

root@aapi-ujhnevn:~/mali_test/build# ./mali_test EGL Version: "1.4 Linux-r6p2-01rel0" EGL Vendor: "ARM" EGL 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 " Error: eglCreateWindowSurface failed: 0x00003003

source code is here https://github.com/sergey-suloev/sunxi-mali/tree/master/examples/mali_test there is no error at driver level ... I think that there is no call to driver before the error happens. I can see that there is no single message after running test app in dmesg.

giuliobenetti commented 6 years ago

@sergey-suloev But what I see from your dmesg is: [ 9.808359] Mali<2>: [ 9.808361] Driver revision: r8p0-01rel0-3f06e9c

Why r8p0-01rel0-3f06e9c??? It has to be r6p2! That's the point!

Because only r6p2 user space blobs are provided, so recompile with r6p2 kernel driver, use r6p2 user space blobs and it has to work this time!

sergey-suloev commented 6 years ago

@giuliobenetti no matter which version it is.. the error is the same I tested r6p2 long time till now. this is my own compilation, but error is the same

giuliobenetti commented 6 years ago

@sergey-suloev For sure it's not a good thing mix versions up. Please go back to r6p2 in any case. If you use r8p0 it can work or not, and if it does, it works in a unpredictable way.

sergey-suloev commented 6 years ago

@giuliobenetti i will get back to r6p2. but again it's not gonna change anything I am almost sure that my problem is in blobs, because there is no messages in dmesg during test app run.

giuliobenetti commented 6 years ago

@sergey-suloev it's incredible it doesn't work, you're 1cm from the end... @net147 I know had H3 working if I'm not wrong. @net147 can you help @sergey-suloev to solve this problem?

sergey-suloev commented 6 years ago

@giuliobenetti if problem was in kernel that would be at least 1 debug message.. but there is nothing. no actions taken on driver.. no memory allocations.. nothing same for r6p2

giuliobenetti commented 6 years ago

@sergey-suloev only "fail" I see in your dmesg is "thermal thermal_zone0: failed to read out thermal zone (-110)" Can you pastebin your dts and dtsi?

net147 commented 6 years ago

@giuliobenetti I have only used Mali on A20

giuliobenetti commented 6 years ago

@net147 ooh ok thank you. I was almost sure you've used H3 when we've spoken on IRC and you helped me to get it working on A20. Does it come into your mind something else for @sergey-suloev ? Or do you know anyone else who tested r6p2 on H3 succesfully? Thanks

paolosabatino commented 6 years ago

@sergey-suloev do not mix the kernel driver version and the userland drivers. I understand that you may guess the newest the better, but the kernel driver interface may be different and userland drivers may not be able to communicate with the hardware correctly if you mix the versions.

This is the output of my dmesg (kernel 4.13.16, OrangePi PC running armbian):

[   15.404732]  mali-utgard: assigned reserved memory node linux,cma
[   15.405275] Allwinner sunXi mali glue initialized
[   15.407087] sun4i-codec 1c22c00.codec: Codec <-> 1c22c00.codec mapping ok
[   15.410328] Mali: 
[   15.410338] Found Mali GPU Mali-400 MP r1p1
[   15.411478] Mali: 
[   15.411487] 2+0 PP cores initialized
[   15.412290] Mali: 
[   15.412297] Mali device driver loaded

so yours looks fine to me.

Do you have a display connected to your HDMI connector? Also, which kernel and distro are you running?

@giuliobenetti my orangepi pc is an H3 and it is running fine