平台x2000
x2000使用ffmpeg解码视频,如果一直大压力向解码器发送h264帧数据,和从码器读取解压的数据,中间不加任何延时,用到的ffmpeg的所有api没有任何错误返回值,出现内核崩溃问题:
[ 1141.362613] reference picture missing during reorder
[ 1141.367776] reference picture missing during reorder
[ 1141.373364] Missing reference picture, default is 65676
[ 1141.378759] Missing reference picture, default is 65676
[ 1141.419894] reference picture missing during reorder
[ 1141.425096] Missing reference picture, default is 65684
[ 1141.446645] mmco: unref short failure
[ 1193.595006] reference picture missing during reorder
[ 1193.600978] reference picture missing during reorder
[ 1193.606139] Missing reference picture, default is 65548
[ 1193.616490] Missing reference picture, default is 65548
[ 1193.663804] reference picture missing during reorder
[ 1193.668970] Missing reference picture, default is 65556
[ 1193.701359] mmco: unref short failure
[ 1245.402945] reference picture missing during reorder
[ 1245.408073] reference picture missing during reorder
[ 1245.420093] Missing reference picture, default is 65668
[ 1245.425495] Missing reference picture, default is 65668
[ 1245.461174] reference picture missing during reorder
[ 1245.466343] Missing reference picture, default is 65676
[ 1245.485859] mmco: unref short failure
[ 1569.077944] cannot get AVframe from queued_list.decode_slice_header error
[h264_v4l2m2m @ 0x5d16e0] capture: driver decode error
[ 1569.103943] ------------[ cut here ]------------
[ 1569.108761] WARNING: CPU: 1 PID: 879 at drivers/media/v4l2-core/videobuf2-core.c:850 ingenic_vdec_worker+0x284/0x32c()
[h264_v4l2m2m @ 0x5d16e0] capture: driver decode error
[h264_v4l2m2m @ 0x5d16e0] capture: driver deco[ 1569.129597] Modules linked in:de error
[ 1569.138007] CPU: 1 PID: 879 Comm: kworker/u4:1 Not tainted 4.4.94 #7
[ 1569.144613] Workqueue: felix-vdec ingenic_vdec_worker
[ 1569.149856] Stack : 800765b4 80861a38 80960000 00000352 8048e904 00000000 8453e980 00000088
8554de00 800765a8 0000036f 80a34828 8453e980 00000000 808ab38c 81407d3c
8554de00 800a84d4 80861a38 800518a0 80866fac 81407d54 81407d3c 800a84d4
8554de00 8554de00 8554de00 8004db74 81407d54 81407d48 00000547 00000000
00000000 00000000 00000000 00000000 00000000 00000000 696c6566 64762d78
...
[ 1569.186912] Call Trace:
[ 1569.189449] [<8001f45c>] show_stack+0x70/0x8c
[ 1569.193946] [<8026b3c4>] dump_stack+0x94/0xd0
[ 1569.198440] [<80035f3c>] warn_slowpath_common+0xa0/0xd0
[ 1569.203831] [<80035ff4>] warn_slowpath_null+0x18/0x24
[ 1569.209045] [<8048e904>] ingenic_vdec_worker+0x284/0x32c
[ 1569.214521] [<8004b5d0>] process_one_work+0x1f0/0x320
[ 1569.219730] [<8004c5e0>] worker_thread+0x324/0x3f0
[ 1569.224673] [<80051334>] kthread+0xe4/0xec
[ 1569.228897] [<800191ac>] ret_from_kernel_thread+0x14/0x1c
[ 1569.234461]
[ 1569.236061] ---[ end trace 2a3a88865eff6287 ]---
[ 1569.284014] cannot get AVframe from queued_list.decode_slice_header error
[ 1569.291555] cannot get AVframe from queued_list.[h264_v4l2m2m @ 0x5d16e0] decode_slice_header error
capture: driver decode error
[ 1569.302886] co located POCs unavailable
[h264_v4l2m2m @ 0x5d16e0] capture: driver decode error
[h264_v4l2m2m @ 0x5d16e0] capture: driver deco[ 1569.318603] ------------[ cut here ]------------
de error
[h264_v4l2m2m @ 0x5d16e0][ 1569.326524] WARNING: CPU: 0 PID: 879 at drivers/media/v4l2-core/videobuf2-core.c:850 ingenic_vdec_worker+0x284/0x32c()
capture: driver decode error
[ 1569.341770] Modules linked in:
[ 1569.348686] CPU: 0 PID: 879 Comm: kworker/u4:1 Tainted: G W 4.4.94 #7
[ 1569.356505] Workqueue: felix-vdec ingenic_vdec_worker
[ 1569.361715] Stack : 800765b4 80861a38 80960000 00000352 8048e904 00000000 8453e980 00000088
8554de00 800765a8 0000036f 80a34828 8453e980 00000000 808ab38c 81407d3c
8554de00 800a84d4 80861a38 800518a0 80866fac 81407d54 81407d3c 800a84d4
8554de00 8554de00 8554de00 8004db74 81407d54 81407d48 000005d7 00000000
00000000 00000000 00000000 00000000 00000000 00000000 696c6566 64762d78
...
[ 1569.398471] Call Trace:
[ 1569.400999] [<8001f45c>] show_stack+0x70/0x8c
[ 1569.405498] [<8026b3c4>] dump_stack+0x94/0xd0
[ 1569.409993] [<80035f3c>] warn_slowpath_common+0xa0/0xd0
[ 1569.415383] [<80035ff4>] warn_slowpath_null+0x18/0x24
[ 1569.420594] [<8048e904>] ingenic_vdec_worker+0x284/0x32c
[ 1569.426075] [<8004b5d0>] process_one_work+0x1f0/0x320
[ 1569.431288] [<8004c5e0>] worker_thread+0x324/0x3f0
[ 1569.436232] [<80051334>] kthread+0xe4/0xec
[ 1569.440455] [<800191ac>] ret_from_kernel_thread+0x14/0x1c
[ 1569.446015]
[ 1569.447592] ---[ end trace 2a3a88865eff6288 ]---
[ 1569.478222] CPU 0 Unable to handle kernel paging request at virtual address 00000104, epc == 80475324, ra == 804752e4
[ 1569.489216] Oops[#1]:
[ 1569.491566] CPU: 0 PID: 879 Comm: kworker/u4:1 Tainted: G W 4.4.94 #7
[ 1569.499388] Workqueue: felix-vdec ingenic_vdec_worker
[ 1569.504596] task: 84432090 ti: 81406000 task.ti: 81406000
[ 1569.510163] $ 0 : 00000000 80a30000 00000200 00000100
[ 1569.515566] $ 4 : 80d6f2d0 00000001 0000453f 8404dc14
[ 1569.520961] $ 8 : 84072858 84072800 84158100 00000000
[ 1569.526365] $12 : 00000000 00000000 00000000 00000000
[ 1569.531765] $16 : 83e44d2c 80d6f008 80d6f2d0 821d0000
[ 1569.537170] $20 : 84072800 00000000 8453e980 00000088
[ 1569.542568] $24 : fa83b2da 80063cbc
[ 1569.547974] $28 : 81406000 81407de8 8554de00 804752e4
[ 1569.553376] Hi : 00000000
[ 1569.556339] Lo : 00005400
[ 1569.559311] epc : 80475324 v4l2_m2m_buf_remove+0x64/0x94
[ 1569.564968] ra : 804752e4 v4l2_m2m_buf_remove+0x24/0x94
[ 1569.570622] Status: 14001c02 KERNEL EXL
[ 1569.574675] Cause : 0880000c (ExcCode 03)
[ 1569.578804] BadVA : 00000104
[ 1569.581772] PrId : 00132000 (Ingenic XBurst@II.V2)
[ 1569.586801] Modules linked in:
[ 1569.589948] Process kworker/u4:1 (pid: 879, threadinfo=81406000, task=84432090, tls=00000000)
[ 1569.598739] Stack : 00000000 821d0000 84158100 8263d400 84158100 82f22800 8404dc00 8048e820
8094a7e0 8443235c 81407e24 00000088 86600000 06600000 000036d9 00000000
00000000 8094a7e0 8554de00 84158100 8404dc00 00000000 84072800 00000000
8554de18 8004b5d0 8404dc00 8404dc00 80865ac0 00000001 809e0000 8404dc14
8554de18 8404dc00 8404dc00 80865ac0 00000001 809e0000 8404dc14 8554de18
...
[ 1569.635482] Call Trace:
[ 1569.638005] [<80475324>] v4l2_m2m_buf_remove+0x64/0x94
[ 1569.643307] [<8048e820>] ingenic_vdec_worker+0x1a0/0x32c
[ 1569.648789] [<8004b5d0>] process_one_work+0x1f0/0x320
[ 1569.653997] [<8004c5e0>] worker_thread+0x324/0x3f0
[ 1569.658935] [<80051334>] kthread+0xe4/0xec
[ 1569.663160] [<800191ac>] ret_from_kernel_thread+0x14/0x1c
[ 1569.668726]
[ 1569.670255]
Code: 27bd0020 8e020004 8e030000 <ac620004> ac430000 24020100 ae020000 24020200 ae020004
[ 1569.680569] ---[ end trace 2a3a88865eff6289 ]---
[ 1569.685335] note: kworker/u4:1[879] exited with preempt_count 1
[ 1569.691517] CPU 0 Unable to handle kernel paging request at virtual address ffffffec, epc == 80051878, ra == 8004c92c
[ 1569.702467] Oops[#2]:
[ 1569.704805] CPU: 0 PID: 879 Comm: kworker/u4:1 Tainted: G D W 4.4.94 #7
[ 1569.712618] task: 84432090 ti: 81406000 task.ti: 81406000
[ 1569.718185] $ 0 : 00000000 00000001 00000000 81127760
[ 1569.723584] $ 4 : 84432090 00000000 00000000 00000000
[ 1569.728986] $ 8 : 00000040 b4a76490 00000000 000001eb
[ 1569.734384] $12 : 02de61ec 00000013 0000000e 00000007
[ 1569.739781] $16 : 00000000 81127760 00000000 80a22760
[ 1569.745181] $20 : 8094a7e0 84432360 00000000 84051450
[ 1569.750579] $24 : 00000001 80063cbc
[ 1569.755974] $28 : 81406000 81407b58 8554de00 8004c92c
[ 1569.761375] Hi : 00000000
[ 1569.764343] Lo : 0000f400
[ 1569.767311] epc : 80051878 kthread_data+0x4/0xc
[ 1569.772159] ra : 8004c92c wq_worker_sleeping+0x14/0xd0
[ 1569.777722] Status: 14001c02 KERNEL EXL
[ 1569.781775] Cause : 88800008 (ExcCode 02)
[ 1569.785903] BadVA : ffffffec
[ 1569.788871] PrId : 00132000 (Ingenic XBurst@II.V2)
[ 1569.793897] Modules linked in:
[ 1569.797047] Process kworker/u4:1 (pid: 879, threadinfo=81406000, task=84432090, tls=00000000)
[ 1569.805835] Stack : 8094a7e0 84432360 00000000 84051450 84432090 80704d88 81127760 800376b8
00000001 8006e494 00000001 00000001 84432090 814079ac 81407bd8 80940000
844322a0 00000001 00000001 84051450 8554de00 8070519c 844322a0 00000001
00000001 84051450 8554de00 80037d98 00000000 844323bc 0000036f 00000001
81407bd8 81407bd8 81407bfc 00000000 0000000b 80a30000 81407d30 80861c64
...
[ 1569.842563] Call Trace:
[ 1569.845081] [<80051878>] kthread_data+0x4/0xc
[ 1569.849573] [<8004c92c>] wq_worker_sleeping+0x14/0xd0
[ 1569.854785] [<80704d88>] __schedule+0x3bc/0x760
[ 1569.859454] [<8070519c>] schedule+0x70/0x94
[ 1569.863766] [<80037d98>] do_exit+0x61c/0x814
[ 1569.868169] [<8001f658>] default_cu2_call+0x0/0x44
[ 1569.873107]
[ 1569.874639]
Code: 08014563 00a22821 8c820268 <03e00008> 8c42ffec 27bdffe0 afbf001c 8c850268 24060004
解决办法:
调用avcodec_send_packet()向解码器扔包之后延时若干ms。虽然我觉得不应该这样,但是不这样大压力测试的时候就100%会出现内核崩溃。我猜测有可能解码线没有任何延时,一直抢占解码器(v4l2_m2m)。而驱动中的线程或者队列什么的得不到相关的资源,导致的这种问题。(只是猜测,我也不知道原理)