Page 1 of 1

Graphic driver freeze

Posted: Tue Aug 21, 2018 10:23 pm
by hnide777
Hi,

I'm developing graphic application in C++ with SFML library.
I'm using Raspberri Pi 3 b+ with GL driver with fake KMS.

Everything is going well until I make some bigger reload of textures.
I think the graphic driver runs out of memory or there is some overflow.

After that mentioned reload, the whole screen isn't re-drawed anymore.
I didn't mean just my application screen, but it looks like whole system (including all other applications), except mouse.
So, I tried to kill Xorg but I just get a black screen with mouse. Only reboot helped.

On /var/logs/messages I found

Code: Select all

Aug 21 21:40:04 raspberrypi kernel: [  196.627196] [drm]                         kernel:   9000kb BOs (1)
Aug 21 21:40:04 raspberrypi kernel: [  196.627204] [drm]                            V3D: 219628kb BOs (92)
Aug 21 21:40:04 raspberrypi kernel: [  196.627210] [drm]                     V3D shader:    208kb BOs (50)
Aug 21 21:40:04 raspberrypi kernel: [  196.627217] [drm]                           dumb:     16kb BOs (1)
Aug 21 21:40:12 raspberrypi kernel: [  203.903494] Voltage normalised (0x00000000)
Aug 21 21:40:20 raspberrypi kernel: [  211.794425] [drm]                         kernel:   9000kb BOs (1)
Aug 21 21:40:20 raspberrypi kernel: [  211.794429] [drm]                            V3D: 222740kb BOs (109)
Aug 21 21:40:20 raspberrypi kernel: [  211.794432] [drm]                     V3D shader:    208kb BOs (50)
Aug 21 21:40:20 raspberrypi kernel: [  211.794435] [drm]                           dumb:     16kb BOs (1)
Aug 21 21:40:20 raspberrypi kernel: [  211.795019] [drm]                         kernel:   9000kb BOs (1)
Aug 21 21:40:20 raspberrypi kernel: [  211.795023] [drm]                            V3D: 221716kb BOs (108)
Aug 21 21:40:20 raspberrypi kernel: [  211.795026] [drm]                     V3D shader:    208kb BOs (50)
Aug 21 21:40:20 raspberrypi kernel: [  211.795029] [drm]                           dumb:     16kb BOs (1)
Aug 21 21:40:20 raspberrypi kernel: [  211.795296] [drm]                         kernel:   9000kb BOs (1)
Aug 21 21:40:20 raspberrypi kernel: [  211.795300] [drm]                            V3D: 221716kb BOs (108)
Aug 21 21:40:20 raspberrypi kernel: [  211.795303] [drm]                     V3D shader:    208kb BOs (50)
Aug 21 21:40:20 raspberrypi kernel: [  211.795306] [drm]                           dumb:     16kb BOs (1)
BTW setting memory split didn't make any change. I've tried 128,256,512 values.

Is there any other logs to check what is going wrong?
Is there a possibility to turn on some diagnostic logs or check memory allocations on GPU?

Thanks

Re: Graphic driver freeze

Posted: Thu Sep 06, 2018 9:23 am
by Joel_Mckay
Indeed, I put together a gpu mate desktop Raspbian Stretch pi3 kernel version with Overlay, AUFS, and the vc4 core bug fix.
https://sourceforge.net/projects/microm ... -pi/files/
(there is still that flash & gpu enabled VLC plug-in bug that requires restarting midori once)

The bug I encountered would hang X after the vc4 drm code would fault after about 8 hours when the dynamic gpu memory was allocated or freed.
Let me know if the patched kernel helps you out.

Cheers,
~J~

Re: Graphic driver freeze

Posted: Tue Sep 11, 2018 12:00 pm
by hnide777
Thanks for info, actually I'm on holiday and I will be able to check it sometime on next week.
Could you give me some reference to that fix/commit?
Or could you provide more information about that issue?
It is quite cumbersome to flash some distribution without prepared environment to just check if it is related fix.

Re: Graphic driver freeze

Posted: Wed Sep 12, 2018 1:27 am
by Joel_Mckay
The excellent "stschake" posted a workaround, which essentially stops the deallocation/fragmentation of gpu memory.

You can ignore the verbose pages of me trying to diagnose this apparently known issue, and get the small patch here.
https://github.com/anholt/linux/issues/135

The issue seems pi3/pi3B+ specific, but I can't prove that given a single pi2's normal behavior with the identical kernel.
(also running the identical gpu firmware image as well, but after 10 days I stopped the test)

Recall the OpenGL ES is a subset of the standard OpenGL, and some experimental features need partially crippled in the pi user's marco gpu compositor desktop config file as these feature can hang the kernel. I simply resorted to trial and error to enable the flags, as there is no clear documentation here. =/

I am just pleased Flash and WebGL seem relatively stable once the gpu memory has be forced into static allocation. We didn't want to create this Frankenstein binary blob laden distro fork, but the bug fixes and missing apps on Stretch were too numerous to get our group project on track. Note, the package "hold" flags with deprecated version numbers were used as much as we could, so that apt updates (OS in RW mode) to normal repo versions should become cleaner as the release matures.

Nothing is ever perfect, but at least we can actually use this classic gnome style desktop. :-)

Re: Graphic driver freeze

Posted: Wed Sep 12, 2018 3:15 am
by cjan
had this issue too, after 5-10 minutes all freeze except mouse moving.
how to patch this commit?

Re: Graphic driver freeze

Posted: Wed Sep 12, 2018 5:55 am
by Joel_Mckay
Need to re-compile your kernel after patching:
drivers/gpu/drm/vc4/vc4_v3d.c

I used the default build settings, and configured what we needed for the RT kernel, Overlayfs, and Aufs.
Building a new kernel can be a pain, but we also found the default Raspbian FAT partition too small to hold everything (need at least 64MB).
https://www.raspberrypi.org/documentati ... uilding.md

Such a fast crash usually is from a bad sdcard or file-system, check your log for io errors as these cards are easily permanently damaged by sudden power loss. I would suggest using a new 32GB class 10 San-disk micro sdcard, as these seem to suffer fewer problems,

Re: Graphic driver freeze

Posted: Wed Sep 12, 2018 7:34 am
by cjan
Joel_Mckay wrote:
Wed Sep 12, 2018 5:55 am
Need to re-compile your kernel after patching:
drivers/gpu/drm/vc4/vc4_v3d.c
can we just re-compile a module, vc4.ko?

Re: Graphic driver freeze

Posted: Wed Sep 12, 2018 7:12 pm
by Joel_Mckay
@cjan
Depends on your setup, as most users usually don't have the kernel source installed by default.
Also, we're not sure whether a DKMS version would cause dependency issues even if blacklisting the existing modules.
I am optimistic the vc4 bug will actually be repaired at some point in the future. ;-)

However, to build with aufs and RT scheduler support one must patch the kernel tree itself.
The specific modifications to Raspbian stretch we made are listed here, along with the specific repo pulls:
http://www.micrometer.xyz/cdn/node/27

Best of luck,
~J~

Re: Graphic driver freeze

Posted: Thu Sep 13, 2018 8:53 am
by cjan
ok, install source & headers and some google, here is Makefile

Code: Select all

# SPDX-License-Identifier: GPL-2.0
# Please keep these build lists sorted!
# core driver code
vc4-y := \
        vc4_bo.o \
        vc4_crtc.o \
        vc4_drv.o \
        vc4_dpi.o \
        vc4_dsi.o \
        vc4_fence.o \
        vc4_firmware_kms.o \
        vc4_kms.o \
        vc4_gem.o \
        vc4_hdmi.o \
        vc4_vec.o \
        vc4_hvs.o \
        vc4_irq.o \
        vc4_plane.o \
        vc4_render_cl.o \
        vc4_trace_points.o \
        vc4_v3d.o \
        vc4_validate.o \
        vc4_validate_shaders.o

vc4-$(CONFIG_DEBUG_FS) += vc4_debugfs.o
KERNEL_HEADERS=/lib/modules/$(shell uname -r)/build
obj-$(CONFIG_DRM_VC4)  += vc4.o
all:= @$(MAKE) -C $(KERNEL_HEADERS) M=$(PWD) modules
clean:= @$(MAKE) -C $(KERNEL_HEADERS) M=$(PWD) clean
get error --> make: *** No targets. Stop.
what next?

Re: Graphic driver freeze

Posted: Thu Sep 13, 2018 7:56 pm
by Joel_Mckay
This explains how to compile a single module in the kernel tree:
https://askubuntu.com/questions/168279/ ... ule#338403
Yet I never use this method as it seems less predictable than a clean build given Raspbian specific macros are involved. ;-)

The vc4 kernel patch is available here if the bug ticket is unavailable:
https://github.com/anholt/linux/files/2 ... .patch.txt

Best of luck,
~J~

Re: Graphic driver freeze

Posted: Fri Sep 14, 2018 12:44 am
by cjan
ok, from beginning the easier way.

Code: Select all

# get rpi-souree
rpi-source
cd ../source path to../vc4
# patch
make -j4 -C /lib/modules/$(uname -r)/build M=$(pwd) modules