TL;DR version: Amlogic has fixed this issue in their driver, Fire CUBE OS needs to include the latest or more recent driver updates/fixes. i.e. a Fire OS 7 update for the Cube 2nd gen.
Technical Narrative:
Device: Fire TV Cube 2nd gen (AFTR / raven, Amlogic S922X), Fire OS 7.6.9.0 (PS7690/4716), kernel 4.9.113.
Symptom: after a day or two of uptime, starting MPEG-2 video often fails, typically when changing live TV channels. Other codecs keep working. A reboot fixes it for a while, then it comes back. It isn’t specific to one app. I reproduced it in a Media3/ExoPlayer app and in the stock Jellyfin Android TV client, and Channels DVR users have reported the same pattern on this model for years. MPEG-2 is the standard codec for US broadcast (ATSC) and cable TV, so any live-TV app on this device is affected.
What the device logs on each failure:
I/amcodec: codec_h_ioctl failed,handle=21,cmd=401053c2,subcmd=111, paramter=0, t=ffffffff errno=19
E/AmlogicVideoDecoderAwesome: codec init failed, ret=-0x100000a
E/AmlogicVideoDecoderAwesome: not enough mem for decoder
E/ACodec: [OMX.amlogic.mpeg2.decoder.awesome] ERROR(0x80001000)
What I found:
- Kernel trace. I traced 14 failures with Perfetto. Every one coincided with a kernel direct reclaim for an order-4 (64 KB)
GFP_KERNEL|__GFP_ZEROallocation that recovered about one page and gave up. Snapshots of/proc/pagetypeinfotaken from bugreports at failure time show no free blocks of 16 KB or larger in the Unmovable or Movable pools, and anextfragunusable index of about 0.93 at order 4. Free memory isn’t low; it’s fragmented. HEVC starts never triggered this allocation. - Which code makes the request.
cmd=401053c2, subcmd=111isAMSTREAM_IOC_SETwithAMSTREAM_PORT_INIT. It goes throughamstream_port_init→video_port_init→vdec_init, which registers theammvdec_mpeg12device. In Amlogic’s media_modules from that period,ammvdec_mpeg12_probeallocates its per-instance state withdevm_kzalloc(&pdev->dev, sizeof(struct vdec_mpeg12_hw_s), GFP_KERNEL). That struct embeds a pool of 32struct vframe_sand comes to roughly 38–40 KB, so it lands in an order-4 page allocation. Order 4 is abovePAGE_ALLOC_COSTLY_ORDER, so the 4.9 allocator makes no retries (mm/page_alloc.c, “Do not retry costly high order allocations”). The probe returns-ENOMEM, andvdec_initlogs “driver probe failed” and returns-ENODEV. That’s theerrno=19above. The HEVC, H.264, VP9 and MPEG-4 drivers allocate the same state withvmalloc, which is why only MPEG-2 fails. - The upstream fix. Amlogic fixed this on 9 April 2019 in media_modules commit
bd39fead6(“media_module: fix kasan check issue [1/2]”, PD#SWPL-6847). The commit message reads: “mpeg2/mjpeg multi instance alloc issue … use valloc instead of kzalloc”. It changesdevm_kzalloctovzallocinammvdec_mpeg12_probe. It’s public in CoreELEC/media_modules-aml, branchamlogic-4.9.269. - Evidence the Cube has the pre-fix driver. On 7.6.9.0,
/sys/module/amvdec_mmpeg12/parameters/listsdebug_enable dec_control decode_timeout_val error_frame_skip_level max_process_time pre_decode_buf_level radr rval udebug_flag. That set matches onlyvmpeg12_multi.crevisions from August 2018 to March 2019. Every revision from 28 March 2019 onwards, including the fix, addsagain_threshold. I can’t read the.koon a retail build to confirm directly.