Kernel crash using AVE-10 for encoding

I experienced a kernel crash when trying to encode a video.
Source is the Big Buck Bunny FHD video, and I am deliberately trying to force 4K encoding.
Causes an immediate oops.

Does anyone have the documentation to the AVE-10 (HVEC) encoder/decoder?
I could find the programmers manual for the various SoC chips but not the AVE-10 parts.

bash script to force the crash:

$ wget https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/1080/Big_Buck_Bunny_1080_10s_1MB.mp4 -O BBB.mp4

$ ffmpeg -c:v h264_v4l2m2m -i BBB.mp4 -vf scale=3840x2560 -c:v h264_v4l2m2m output.mp4

Resulting in this oops:

[ 2438.034338] Unable to handle kernel NULL pointer dereference at virtual address 000000000000000c
[ 2438.037625] Mem abort info:
[ 2438.040290]   ESR = 0x0000000096000004
[ 2438.044026]   EC = 0x25: DABT (current EL), IL = 32 bits
[ 2438.049301]   SET = 0, FnV = 0
[ 2438.052317]   EA = 0, S1PTW = 0
[ 2438.055381]   FSC = 0x04: level 0 translation fault
[ 2438.060253] Data abort info:
[ 2438.063041]   ISV = 0, ISS = 0x00000004
[ 2438.066885]   CM = 0, WnR = 0
[ 2438.069805] user pgtable: 4k pages, 48-bit VAs, pgdp=0000000032a77000
[ 2438.076225] [000000000000000c] pgd=0000000000000000, p4d=0000000000000000
[ 2438.082954] Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP
[ 2438.089121] Modules linked in: tls snd_hrtimer snd_seq_dummy snd_seq_oss snd_seq_midi snd_seq_midi_event snd_rawmidi snd_seq snd_seq_device binfmt_misc bluetooth ecdh_generic rfkill ecc meson_rng rng_core meson_ir scpi_hwmon snd_soc_hdmi_codec snd_soc_meson_aiu snd_soc_meson_codec_glue ao_cec meson_vdec(C) videobuf2_dma_contig v4l2_mem2mem amlogic_gxl_crypto snd_soc_meson_gx_sound_card snd_soc_meson_card_utils crypto_engine videobuf2_memops snd_soc_meson_t9015 videobuf2_v4l2 videobuf2_common videodev snd_soc_simple_amplifier mc sch_fq_codel dm_multipath dm_mod scsi_dh_rdac scsi_dh_emc scsi_dh_alua pkcs8_key_parser fuse efi_pstore pstore ip_tables x_tables ipv6 crc_ccitt raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx raid1 raid0 md_mod dw_hdmi_i2s_audio dwmac_generic lima gpu_sched dwmac_meson8b meson_dw_hdmi dw_hdmi drm_display_helper meson_drm stmmac_platform meson_canvas cec stmmac drm_dma_helper pcs_xpcs rc_core crct10dif_ce polyval_ce polyval_generic
[ 2438.089366]  simpledrm drm_shmem_helper display_connector drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops
[ 2438.186024] CPU: 1 PID: 1513 Comm: ffmpeg Tainted: G         C         6.1.26-05272-g26c406245a2c #1
[ 2438.195061] Hardware name: libre-computer aml-s905x-cc/aml-s905x-cc, BIOS 2022.07+ 07/01/2022
[ 2438.203509] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 2438.212326] pc : vdec_try_fmt_common+0xdc/0x280 [meson_vdec]
[ 2438.217923] lr : vdec_try_fmt+0x24/0x38 [meson_vdec]
[ 2438.222831] sp : ffff800009ee3b90
[ 2438.226056] x29: ffff800009ee3b90 x28: ffffd2f697c10a38 x27: ffff722ac3b11808
[ 2438.233136] x26: 00000000c0d05640 x25: ffff722b36dd5570 x24: ffff722ac2e44800
[ 2438.240218] x23: ffff722ac3b11808 x22: ffffd2f697c8b790 x21: ffff722ac44cad00
[ 2438.247300] x20: ffff722ac2d5b100 x19: 000000000000000a x18: 0000000000000000
[ 2438.254377] x17: 0000000000000000 x16: ffffd2f6cacfac48 x15: 0000aaaadba96660
[ 2438.261458] x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000000
[ 2438.268543] x11: 0000000000000000 x10: 0000000000000000 x9 : ffffd2f697c8bde0
[ 2438.275603] x8 : 000000003231564e x7 : ffff722ac2d5b108 x6 : 000000003247504d
[ 2438.282683] x5 : 0000000034363248 x4 : 0000000000000000 x3 : 0000000000000000
[ 2438.289764] x2 : ffff722ac2d5b100 x1 : 0000000000000100 x0 : ffff722ac3b11800
[ 2438.296847] Call trace:
[ 2438.299228]  vdec_try_fmt_common+0xdc/0x280 [meson_vdec]
[ 2438.304506]  v4l_try_fmt+0x370/0x540 [videodev]
[ 2438.308980]  __video_do_ioctl+0x17c/0x3d0 [videodev]
[ 2438.313872]  video_usercopy+0x2d0/0x658 [videodev]
[ 2438.318582]  video_ioctl2+0x18/0x28 [videodev]
[ 2438.322936]  v4l2_ioctl+0x40/0x60 [videodev]
[ 2438.327121]  __arm64_sys_ioctl+0xa8/0xe8
[ 2438.330957]  invoke_syscall+0x44/0x108
[ 2438.334621]  el0_svc_common.constprop.3+0x94/0xf8
[ 2438.339249]  do_el0_svc+0x2c/0xc8
[ 2438.342476]  el0_svc+0x20/0x50
[ 2438.345444]  el0t_64_sync_handler+0x98/0xc0
[ 2438.349550]  el0t_64_sync+0x170/0x174
[ 2438.353123] Code: aa0903e4 b4fffd84 b9400843 52802001 (b9400c85)
[ 2438.359158] ---[ end trace 0000000000000000 ]---

The hardware decoders are there but the software support upstream is still a work in progress. Hardware encoders are not supported upstream yet but there’s plans to do so over the next 2 years.

Is there any way to encode JPEG/h.264/265 at the moment using the AVE-10?

I noticed a great deal of similarity in the Qualcomm Venus block to the AVE-10; is it also sharing commonality with the allwinner VPU?

Also do you have access to documentation where I could help speed up this V4L driver work?

Most of the code is confined to Amlogic’s SDKs for either buildroot or Android. If you want to help contribute to upstream, you can find the following source code. The problem is that there’s a general lack of documentation so you have to follow the code and the bare notes within it.

We do not know what IP it is exactly. The LibreELEC forum/slack would be a great source for this information.

Buildroot (not sure if the encode is supported in this BSP):
http://share.loverpi.com/board/libre-computer-project/libre-computer-board-aml-s905x-cc/soc-amlogic/buildroot/

Android 9 BSP from 2019 with build instructions (Request Needed):

Android 9 BSP from 2020 (Request Needed):

You may also find people working on the encoders in GitHub. They’re usually using Amlogic’s BSP and an old kernel.

If you want to have a go at upstream, you can reach out to us through our website and we will provide you with the necessary contacts.