Segmentation fault if running a Qt application on kernel built out of tree

Our kernel sources are based on toradex_4.9-1.0.x-imx. We added a custom device tree to match our hardware and added some custom kernel drivers which are not related to graphics.

If the Qt app is running on our custom kernel built with yocto everything works as expected. However, if the same kernel sources are build out of tree using the SDK generated by yocto it segfaults:

  /usr/bin/my-qt-app -platform eglfs --embedded
 [warning] default (unknown:0) - QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
 [warning] default (unknown:0) - QEglFSVivIntegration will set environment variable FB_MULTI_BUFFER=2 to enable double buffering and vsync.
  If this is not desired, you can override this via: export QT_EGLFS_IMX6_NO_FB_MULTI_BUFFER=1
  Segmentation fault

dmesg shows:

 [  590.588547] Unable to handle kernel paging request at virtual address afebd410
 [  590.599444] pgd = 8da50000
 [  590.605703] [afebd410] *pgd=00000000
 [  590.612826] Internal error: Oops: 5 [#4] SMP ARM
 [  590.620976] Modules linked in: hid_multitouch uio_pdrv_genirq gpio_beeper uio my_module(C) industrialio_triggered_bufs
 [  590.642812] CPU: 1 PID: 933 Comm: my-qt-ui Tainted: G      D  C      4.9.87-00163-gb1ac2f8e4fc2-dirty #13
 [  590.656848] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
 [  590.667250] task: 8d7fe880 task.stack: 8dc6e000
 [  590.675664] PC is at gckDEVICE_Dispatch+0x38/0x124
 [  590.684329] LR is at drv_ioctl+0x134/0x288
 [  590.692262] pc : [<80689128>]    lr : [<80682e10>]    psr: 80080013
 [  590.692262] sp : 8dc6fd10  ip : 752c5ae5  fp : 8dc6fd1c
 [  590.711390] r10: 8c4c07d8  r9 : 8dc6e000  r8 : 00000051
 [  590.720407] r7 : 8dc6fd28  r6 : 8d4e8680  r5 : 8c4eac00  r4 : 00000051
 [  590.730713] r3 : afebd36c  r2 : 0000000b  r1 : 8dc6fd48  r0 : 8c4c3400
 [  590.740988] Flags: Nzcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
 [  590.751884] Control: 10c5387d  Table: 1da5004a  DAC: 00000051
 [  590.761380] Process my-qt-ui (pid: 933, stack limit = 0x8dc6e210)
 [  590.771844] Stack: (0x8dc6fd10 to 0x8dc70000)
 [  590.779937] fd00:                                     8dc6fefc 8dc6fd20 80682e10 806890fc
 [  590.791903] fd20: 8dc6fd84 8dc6fd30 7e9865e0 00000000 00000190 00000000 7e9865e0 00000000
 [  590.803873] fd40: 00000190 00000000 00000028 752c5ae5 00000004 7e986e24 01959c28 74355194
 [  590.815848] fd60: 0195b020 00000002 00000001 7556fbb8 0d696914 76f24d80 74fbf7a8 7e986688
 [  590.827811] fd80: 000002fc 74e5e8a4 00000000 76f10d15 00000001 74e5e8a4 000002fc 74e5f764
 [  590.839774] fda0: 74fbf7a8 7e98668c 7e986688 7e9866b8 00000000 bb797b34 74e5f764 74e5fc67
 [  590.851732] fdc0: 05dbcbd9 74e5b8e4 74e5e8a4 7e9866f4 76f31908 76f31fa4 aaaaaaab 74851498
 [  590.863696] fde0: 00000033 76f31908 00000033 76f31908 00000000 00000000 74e5cca4 bb797b34
 [  590.875668] fe00: 00000000 00000000 74e5fc67 7e986754 7e9866f4 7e9866fc 74fbf7a8 76f113b9
 [  590.887646] fe20: 7e9866fc 76f32a70 00000025 00000000 00000001 00000000 00000001 74fbf7a8
 [  590.899642] fe40: 74fbf964 74fbf964 00000000 76f113b9 7e98672c 76f32a70 00000025 037fd108
 [  590.911649] fe60: 00000001 74e5e8a4 74fbf7a8 74fbf7a8 74fbf964 74fbf964 00000000 00000000
 [  590.923643] fe80: 00000001 74fbf7a8 74f4d518 744a65b0 744a6a70 00000000 00000001 74f3c8e0
 [  590.935629] fea0: 74f3c8f0 76f14c83 00000000 00000001 00000001 00000000 74f4d218 74e5e8a4
 [  590.947621] fec0: 744a6a70 01960bc8 74f680f4 00000000 7e9867c4 01960900 00000000 8d5eb900
 [  590.959644] fee0: 7e986590 00000007 00007530 00000007 8dc6ff7c 8dc6ff00 80229140 80682ce8
 [  590.971648] ff00: 00000020 8dc6ff10 80235af0 8c4c07d8 8d109100 00000007 8cc63000 8d5eb900
 [  590.983657] ff20: 8cc63000 00000020 8dc6ff4c 8dc6ff38 80225ea8 8020f458 00000007 8d5eb900
 [  590.995655] ff40: 8dc6ff94 8dc6ff50 802156b8 80225e54 00002710 8d5eb900 8d5eb900 00000007
 [  591.007639] ff60: 00007530 7e986590 8dc6e000 00000000 8dc6ffa4 8dc6ff80 802299bc 802290a4
 [  591.019612] ff80: 00002710 00007530 74f680f4 00000036 80108ae4 8dc6e000 00000000 8dc6ffa8
 [  591.031575] ffa0: 80108920 8022998c 00002710 00007530 00000007 00007530 7e986590 01960900
 [  591.043532] ffc0: 00002710 00007530 74f680f4 00000036 00000000 7e9865e0 00000190 74f3c8f0
 [  591.055474] ffe0: 755f5d61 7e98657c 74f35e30 755f5d68 80080030 00000007 00000000 00000000
 [  591.067396] Backtrace:
 [  591.073556] [<806890f0>] (gckDEVICE_Dispatch) from [<80682e10>] (drv_ioctl+0x134/0x288)
 [  591.085335] [<80682cdc>] (drv_ioctl) from [<80229140>] (do_vfs_ioctl+0xa8/0x8e8)
 [  591.096484]  r8:00000007 r7:00007530 r6:00000007 r5:7e986590 r4:8d5eb900
 [  591.106923] [<80229098>] (do_vfs_ioctl) from [<802299bc>] (SyS_ioctl+0x3c/0x68)
 [  591.117990]  r10:00000000 r9:8dc6e000 r8:7e986590 r7:00007530 r6:00000007 r5:8d5eb900
 [  591.129588]  r4:8d5eb900
 [  591.135836] [<80229980>] (SyS_ioctl) from [<80108920>] (ret_fast_syscall+0x0/0x48)
 [  591.147219]  r9:8dc6e000 r8:80108ae4 r7:00000036 r6:74f680f4 r5:00007530 r4:00002710
 [  591.158816] Code: e5913008 e3a0200b e0233c92 e0803103 (e593c0a4)
 [  591.168666] ---[ end trace 8c9335606996665b ]---

The point where the nullpointer exception occurs is gc_hal_kernel.c:

 Reading symbols from vmlinux...
 (gdb) l *gckDEVICE_Dispatch+0x38
 0x80689128 is in gckDEVICE_Dispatch (drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.c:5948).
 5943            Interface->status = status;
 5944        }
 5945        else
 5946        {
 5947            /* Need go through gckKERNEL dispatch. */
 5948            kernel = Device->map[type].kernels[coreIndex];
 5949
 5950
 5951    #if gcdENABLE_VG
 5952            if (kernel->vg)

After reading @marcel.tx answer to galcore module probing error -22 and @max.tx answer to Error compiling Real time linux kernel I came to the conclusion that we have to set in our machine config:

 MACHINE_USES_VIVANTE_KERNEL_DRIVER_MODULE = "0"

But now we get the same error with the kernel built in tree (with yocto).

How can we get our UI run on our kernel built out of tree (with the SDK)?

Please note that the toradex_4.9-1.0.x-imx branch was only ever used for beta releases and as such is long since obsolete and no longer supported, sorry.

May I suggest for you to upgrade to our latest stable BSP 2.8b6 using the toradex_4.9-2.3.x-imx branch or alternatively the latest beta BSP 3.0b2 using the toradex_4.14-2.0.x-imx branch at your earliest convenience.

As we did a lot of customization to uboot, we only updated the kernel sources to 4.9-2.3.x which solved this issue.
@marcel.tx, thank you for the support!

Perfect that it works. Thanks for the feedback.