Bookworm hdmirx gstreamer kernel problems

The bookworm image seems to have broken a few (or lots of) things. I’m trying to display/record RGB hdmi input and this gstreamer pipeline used to work fine on the 5.10 debian image:

GST_VIDEO_CONVERT_USE_RGA=1 gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,format=BGR, width=1920, height=1080 ! mpph264enc ! h264parse ! mppvideodec ! waylandsink

It now shows
bgr_1

If I record the file same thing happens, in both cases the pipelines stutters so frames are getting stuck or one or more plugins is slow to process as well the colorspace problem. Same symptoms if I use the kmssink instead of waylandsink so its not a wayland issue.

HDMIRX input looks fine

v4l2-ctl -d /dev/video0 --get-fmt-video
Format Video Capture Multiplanar:
	Width/Height      : 1920/1080
	Pixel Format      : 'BGR3' (24-bit BGR 8-8-8)

The same symptons can be seen with this simple pipeline:

GST_VIDEO_CONVERT_USE_RGA=1 gst-launch-1.0 videotestsrc ! video/x-raw,format=BGR ! mpph264enc ! h264parse ! mppvideodec ! waylandsink

The Bookworm images seems to be a regression compared to the 5.10 image. Is anyone addressing these problems, as it seems to be a constant battle to get a usage image from Radxa (@ChenJaly @Nasca @RadxaYuntian) :frowning_face: ?

Furthermore “arm-afbc=true” longer works on mppvideodec again results in a green output when playing a video.

Occasionally getting RGA error, which should be also be fixed.

[  216.519112] rga_dma_buf: Failed to map attachment, ret[-12]                     
[  216.519125] rga_mm: rga_mm_map_dma_buffer core[1] map dma buffer error!      
[  216.519129] rga_mm: rga_mm_map_buffer map dma_buf error!                     
[  216.519132] rga_mm: job buffer map failed!                                   
[  216.519135] rga_mm: dst channel map job buffer failed!                       
[  216.519137] rga_mm: failed to map buffer                                     
[  216.519142] rga_job: rga_job_commit: failed to map job info                  
[  216.519195] rga_job: request[561] task[0] job_commit failed.                 
[  216.519199] rga_job: rga request[561] commit failed!                         
[  216.519202] rga: request[561] submit failed!

Lastly the kernel is randomly crashing

[ 6331.665039] BUG: Bad rss-counter state mm:000000003b3b1999 type:MM_ANONPAGES6
[ 6331.665166] Unable to handle kernel NULL pointer dereference at virtual addrc
[ 6331.665567] BUG: non-zero pgtables_bytes on freeing mm: 81920                
[ 6331.666118] Mem abort info:                                                  
[ 6331.666668] BUG: Bad rss-counter state mm:000000003b3b1999 type:MM_FILEPAGES2
[ 6331.667188]   ESR = 0x0000000096000004                                       
[ 6331.667723] BUG: Bad rss-counter state mm:000000003b3b1999 type:MM_ANONPAGES6
[ 6331.668265]   EC = 0x25: DABT (current EL), IL = 32 bits                     
[ 6331.668803] BUG: non-zero pgtables_bytes on freeing mm: 81920                
[ 6331.669344]   SET = 0, FnV = 0                                               
[ 6331.669888] BUG: Bad rss-counter state mm:000000003b3b1999 type:MM_FILEPAGES2
[ 6331.670423]   EA = 0, S1PTW = 0                                              
[ 6331.670970] BUG: Bad rss-counter state mm:000000003b3b1999 type:MM_ANONPAGES6
[ 6331.671514]   FSC = 0x04: level 0 translation fault                          
[ 6331.672069] BUG: non-zero pgtables_bytes on freeing mm: 81920                
[ 6331.672621] Data abort info:                                                 
[ 6331.679710] BUG: Bad rss-counter state mm:000000003b3b1999 type:MM_FILEPAGES2
[ 6331.679742]   ISV = 0, ISS = 0x00000004                                      
[ 6331.680326] BUG: Bad rss-counter state mm:000000003b3b1999 type:MM_ANONPAGES7
[ 6331.680919]   CM = 0, WnR = 0                                                
[ 6331.681533] BUG: non-zero pgtables_bytes on freeing mm: 94208                
[ 6331.682133] user pgtable: 4k pages, 48-bit VAs, pgdp=00000001048f8000        
[ 6331.682758] BUG: Bad rss-counter state mm:000000003b3b1999 type:MM_FILEPAGES2
[ 6331.683358] [00000000000001fc] pgd=0000000000000000                          
[ 6331.683969] BUG: Bad rss-counter state mm:000000003b3b1999 type:MM_ANONPAGES7
[ 6331.684640] , p4d=0000000000000000                                           
[ 6331.685248] BUG: non-zero pgtables_bytes on freeing mm: 94208                
[ 6331.685867]                                                                  
[ 6331.686517] BUG: Bad rss-counter state mm:000000003b3b1999 type:MM_FILEPAGES2
[ 6331.687109] Internal error: Oops: 0000000096000004 [#10] SMP                 
[ 6331.687727] BUG: Bad rss-counter state mm:000000003b3b1999 type:MM_ANONPAGES7
[ 6331.688360] Modules linked in: bnep                                          
[ 6331.688987] BUG: non-zero pgtables_bytes on freeing mm: 94208                
[ 6331.689619]  zram                                                            
[ 6331.690271] BUG: Bad rss-counter state mm:000000003b3b1999 type:MM_FILEPAGES2
[ 6331.690888]  zsmalloc vfat                                                   
[ 6331.691527] BUG: Bad rss-counter state mm:000000003b3b1999 type:MM_ANONPAGES7
[ 6331.692154]  fat                                                             
[ 6331.692785] BUG: non-zero pgtables_bytes on freeing mm: 94208                
[ 6331.693428]  binfmt_misc                                                     
[ 6331.694083] BUG: Bad rss-counter state mm:000000003b3b1999 type:MM_FILEPAGES2
[ 6331.694719]  hci_uart                                                        
[ 6331.695361] BUG: Bad rss-counter state mm:000000003b3b1999 type:MM_ANONPAGES7
[ 6331.696013]  btrtl                                                           
[ 6331.696638] BUG: non-zero pgtables_bytes on freeing mm: 94208                
[ 6331.697289]  pwm_fan                                                         
[ 6331.697949] BUG: Bad rss-counter state mm:000000003b3b1999 type:MM_FILEPAGES2
[ 6331.698595]  btbcm btintel snd_soc_es8316                                    
[ 6331.699258] BUG: Bad rss-counter state mm:000000003b3b1999 type:MM_ANONPAGES7
[ 6331.699928]  bluetooth                                                       
[ 6331.700582] BUG: non-zero pgtables_bytes on freeing mm: 94208                
[ 6331.701258]  panthor                                                         
[ 6331.701946] BUG: Bad rss-counter state mm:000000003b3b1999 type:MM_FILEPAGES2
[ 6331.702597]  drm_gpuvm                                                       
[ 6331.703275] BUG: Bad rss-counter state mm:000000003b3b1999 type:MM_ANONPAGES7
[ 6331.703950]  drm_exec                                                        
[ 6331.704620] BUG: non-zero pgtables_bytes on freeing mm: 94208                
[ 6331.705314]  drm_shmem_helper dw_hdmi_qp_cec gpu_sched                       
[ 6331.706013] BUG: Bad rss-counter state mm:000000003b3b1999 type:MM_FILEPAGES2
[ 6331.706681]  cpufreq_dt                                                      
[ 6331.707362] BUG: Bad rss-counter state mm:000000003b3b1999 type:MM_ANONPAGES7
[ 6331.708060]  rockchip_cpufreq                                                
[ 6331.708752] BUG: non-zero pgtables_bytes on freeing mm: 94208                
[ 6331.709452]  ledtrig_netdev fuse ledtrig_timer ledtrig_pattern ledtrig_heartc
[ 6331.734915] CPU: 4 PID: 401 Comm: systemd-udevd Tainted: G    B D W         c
[ 6331.736461] Hardware name: Radxa ROCK 5B (DT)                                
[ 6331.737552] pstate: 20400009 (nzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)  
[ 6331.738885] pc : kmem_cache_alloc+0x154/0x1b0                                
[ 6331.739993] lr : kmem_cache_alloc+0x7c/0x1b0                                 
[ 6331.741080] sp : ffff80000bb8bb40                                            
[ 6331.742079] x29: ffff80000bb8bb40 x28: ffff000102ff2e80 x27: 000000000000019d
[ 6331.743404] x26: 0000000000000000 x25: 00000000000003f0 x24: ffff8000080797dc
[ 6331.744733] x23: ffff00010011ce00 x22: 0000000000000cc0 x21: ffff8000080797dc
[ 6331.746055] x20: ffff80000981fc60 x19: ffff00010011ce00 x18: 0000000035195e4f
[ 6331.747356] x17: 000000003a00346a x16: 00000000bfa55da2 x15: 00000000000c8000
[ 6331.748675] x14: 00000000000c8000 x13: 00000000000c8000 x12: 00000000000c8000
[ 6331.749987] x11: ffffffffffffffff x10: ffffffffffffffff x9 : ffff80000825d16c
[ 6331.751299] x8 : 0000000000000000 x7 : 0000000000000000 x6 : 0000000000000000
[ 6331.752607] x5 : ffff0001045f9220 x4 : ffff0001feeb5c60 x3 : 0000000000000000
[ 6331.753910] x2 : ffff0001feeab400 x1 : 00000000000001f8 x0 : 0000000000000004
[ 6331.755212] Call trace:                                                      
[ 6331.756105]  kmem_cache_alloc+0x154/0x1b0                                    
[ 6331.757139]  dup_mm+0x30/0xe8                                                
[ 6331.758068]  copy_process+0xa0c/0x1248                                       
[ 6331.759055]  kernel_clone+0x9c/0x248                                         
[ 6331.760029]  __do_sys_clone+0x54/0x7c                                        
[ 6331.761007]  __arm64_sys_clone+0x20/0x28                                     
[ 6331.762005]  invoke_syscall+0x80/0x114                                       
[ 6331.762977]  el0_svc_common.constprop.0+0xd0/0x120                           
[ 6331.764018]  do_el0_svc+0x98/0xbc                                            
[ 6331.764947]  el0_svc+0x24/0x48                                               
[ 6331.765849]  el0t_64_sync_handler+0x90/0xf8                                  
[ 6331.766843]  el0t_64_sync+0x174/0x178                                        
[ 6331.767795]

It works for me using DMA. Note that there is no DMA32 with the latest kernel, and I am using Ubuntu, not Debian. hdmirx in my case is video20 (imx415 is attached to the board)

rock@rock5b:~$ uname -ra
Linux rock5b 6.1.43-rk3588-v4l2-cam #2 SMP Wed Nov 20 21:52:08 -03 2024 aarch64 aarch64 aarch64 GNU/Linux
rock@rock5b:~$ GST_VIDEO_CONVERT_USE_RGA=1 gst-launch-1.0 v4l2src device=/dev/video20 io-mode=dmabuf ! video/x-raw,format=BGR, width=1920, height=1080 ! mpph264enc ! h264parse ! mppvideodec ! glimagesink
Setting pipeline to PAUSED ...
arm_release_ver of this libmali is 'g6p0-01eac0', rk_so_ver is '6'.
Pipeline is live and does not need PREROLL ...
Got context from element 'sink': gst.gl.GLDisplay=context, gst.gl.GLDisplay=(GstGLDisplay)"\(GstGLDisplayWayland\)\ gldisplaywayland0";
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Redistribute latency...
^Chandling interrupt.
Interrupt: Stopping pipeline ...
Execution ended after 0:00:05.743210285
Setting pipeline to NULL ...
Freeing pipeline ...
rock@rock5b:~$ GST_VIDEO_CONVERT_USE_RGA=1 gst-launch-1.0 v4l2src device=/dev/video20 io-mode=dmabuf ! video/x-raw,format=BGR, width=1920, height=1080 ! mpph264enc ! h264parse ! mppvideodec ! waylandsink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Redistribute latency...
^Chandling interrupt.
Interrupt: Stopping pipeline ...
Execution ended after 0:00:07.167359700
Setting pipeline to NULL ...
Freeing pipeline ...
rock@rock5b:~$

rock@rock5b:~$ GST_VIDEO_CONVERT_USE_RGA=1 gst-launch-1.0 v4l2src device=/dev/video20 io-mode=dmabuf ! video/x-raw,format=BGR, width=1920, height=1080 ! mpph264enc ! h264parse ! mppvideodec arm-afbc=true ! waylandsink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Redistribute latency...
^Chandling interrupt.
Interrupt: Stopping pipeline ...
Execution ended after 0:00:06.844627451
Setting pipeline to NULL ...
Freeing pipeline ...

Setting io-mode=dmabuf doesn’t help (wasn’t expecting it too), the same problem exists. I’ve narrowed it down to the encoding as this pipeline fails with same symptoms:

gst-launch-1.0 videotestsrc ! video/x-raw,format=BGR, width=1920, height=1080,framerate=60/1 ! mpph264enc ! h264parse ! filesink location=~/test.mp4

May be some thing wrong with rga/mpp/gst packages on debian, @ChenJaly @Nasca @RadxaYuntian any update?

Also seeing this:

 RgaBlit(1471) RGA_BLIT fail: Cannot allocate memory
 RgaBlit(1472) RGA_BLIT fail: Cannot allocate memory
handl-fd-vir-phy-hnd-format[0, 59, (nil), (nil), 0, 0]
rect[0, 0, 1920, 1080, 1920, 1080, 1792, 0]
f-blend-size-rotation-col-log-mmu[0, 0, 0, 0, 0, 0, 1]
handl-fd-vir-phy-hnd-format[0, 302, (nil), (nil), 0, 0]
rect[0, 0, 1920, 1080, 5760, 1088, 2560, 0]
f-blend-size-rotation-col-log-mmu[0, 0, 0, 0, 0, 0, 1]
This output the user parameters when rga call blit fail

Please don’t spam ping multiple engineers. One @radxa and we will check your issue.

@ChenJaly please see if you can reproduce this.

mpph264enc slow efficiency and arm-afbc=true lose effectiveness are known issues.
The former can be replaced with rockchip-ffmpeg or wait for the new sdk software relsase on our apt repo. Or use xvimagesink to view hdmiin without going through the codec.
The latter requires switching back to libmali (the vendor driver only supports opengles) to solve the problem of: https://docs.radxa.com/rock5/rock5b/radxa-os/mali-gpu?Driver=Mali

@ChenJaly I built nyanmisaka rockchip-ffmpeg and although it records. when playing back the recorded video it has regular pauses again showing the encoding is still going wrong somewhere, so its not usable.

For xvimagesink whats the pipeline to try? Also whats the eta for the new sdk software release?

It would be useful if you document the know issues with your software releases otherwise how are users expected to know.

Please try this pipeline gst-launch-1.0 v4l2src device=/dev/video0 ! xvimagesink

@ChenJaly Since the video encoding seems to be totally broken on your 6.1 image, do you have an ETA of when a new SDK software release will be available with fixes?