v4l2 driver oops when streamoff

HI, when I control camera by v4l2, program cannot terminated normally sometimes. I think maybe ioctl(STREAMOFF) encounter problems.

My cameras output image continuously and streamoff won’t stop it because of my design. I also try to make cameras powerdown and then do streamoff, but the result is the same.

I don’t know why, and thank you for you reply.

sdk version: JetPack 4.2.1 - L4T R32.2

cameras: 8 cameras connect to xavier through vc-id

test cmd: v4l2-ctl --set-fmt-video=width=1280,height=768,pixelformat=RG10 --set-ctrl bypass_mode=0 --stream-mmap --stream-count=1000 -d /dev/video1

result: dmesg log as follows

[ 114.610212] tegra194-vi5 15c10000.vi: no reply from camera processor
[ 114.610382] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[ 114.610535] Mem abort info:
[ 114.610590] ESR = 0x96000005
[ 114.610645] Exception class = DABT (current EL), IL = 32 bits
[ 114.610741] SET = 0, FnV = 0
[ 114.610794] EA = 0, S1PTW = 0
[ 114.610847] Data abort info:
[ 114.610899] ISV = 0, ISS = 0x00000005
[ 114.610964] CM = 0, WnR = 0
[ 114.611019] user pgtable: 4k pages, 39-bit VAs, pgd = ffffffc3bf1c6000
[ 114.611126] [0000000000000000] *pgd=0000000000000000, *pud=0000000000000000
[ 114.611268] Internal error: Oops: 96000005 [#1] PREEMPT SMP
[ 114.611367] Modules linked in:
[ 114.611443] CPU: 6 PID: 13219 Comm: sensor_isp_test Tainted: G W 4.9.140+ #3
[ 114.611831] Hardware name: Jetson-AGX (DT)
[ 114.612170] task: ffffffc3b433e200 task.stack: ffffffc3c3c88000
[ 114.612178] PC is at vi_capture_request_unpin+0x48/0xb8
[ 114.612181] LR is at vi_capture_request_unpin+0x38/0xb8
[ 114.612184] pc : [] lr : [] pstate: 20400045
[ 114.612186] sp : ffffffc3c3c8ba30
[ 114.612191] x29: ffffffc3c3c8ba30 x28: ffffffc3d8adf700
[ 114.612196] x27: 0000000000000001 x26: ffffffc3c3c8bd10
[ 114.612201] x25: 0000000000000000 x24: ffffffc3b8bd5a68
[ 114.612222] x23: ffffffc3b8bd5800 x22: ffffffc3ec206b58
[ 114.612227] x21: ffffffc3bfbc3680 x20: ffffffc3bfbc3680
[ 114.612231] x19: 0000000000000000 x18: 0000000000000010
[ 114.612236] x17: 0000000000000001 x16: 00000000000007be
[ 114.612241] x15: 0000000000000006 x14: 0a726f737365636f
[ 114.612245] x13: 7270206172656d61 x12: 63206d6f72662079
[ 114.612250] x11: 6c706572206f6e20 x10: 3a69762e30303030
[ 114.612256] x9 : 00000000000005b8 x8 : 000000000000004b
[ 114.612260] x7 : ffffff8009e84318 x6 : ffffffc3ffea0bf0
[ 114.612265] x5 : ffffffc3ffea0bf0 x4 : 0000000000000000
[ 114.612269] x3 : ffffffc3ffea67f8 x2 : 0000000000000000
[ 114.612274] x1 : 0000000000000000 x0 : 0000000000000000

[ 114.612289] Process sensor_isp_test (pid: 13219, stack limit = 0xffffffc3c3c88000)
[ 114.612292] Call trace:
[ 114.612297] [] vi_capture_request_unpin+0x48/0xb8
[ 114.612300] [] vi_capture_shutdown+0x8c/0x120
[ 114.612304] [] vi_channel_close_ex+0x2c/0x88
[ 114.612307] [] vi5_channel_stop_streaming+0x64/0xb0
[ 114.612329] [] tegra_channel_stop_streaming+0x34/0x48
[ 114.612333] [] __vb2_queue_cancel+0x3c/0x170
[ 114.612336] [] vb2_core_streamoff+0x58/0xc0
[ 114.612339] [] vb2_streamoff+0x54/0x78
[ 114.612342] [] vb2_ioctl_streamoff+0x58/0x68
[ 114.612347] [] v4l_streamoff+0x3c/0x50
[ 114.612350] [] __video_do_ioctl+0x1bc/0x288
[ 114.612353] [] video_usercopy+0x2cc/0x6a8
[ 114.612356] [] video_ioctl2+0x3c/0x50
[ 114.612359] [] v4l2_ioctl+0xf8/0x128
[ 114.612365] [] do_vfs_ioctl+0xb0/0x8f8
[ 114.612367] [] SyS_ioctl+0x94/0xa8
[ 114.612372] [] el0_svc_naked+0x34/0x38
[ 114.612379] —[ end trace 77ddb4da48e6ccd3 ]—

hello lisubin328719,

please configure your sensor driver to have correct power-on/off sequence.
VI engine expect the streaming coming with SoF/EoF/SoF/…/EoF, please check the sensor sending EoF before stream-off.
BTW,
you could check below kernel sources if you’re using v4l2 standard controls to access camera sensors.
thanks

$l4t-r32.2/public_sources/kernel/nvidia/drivers/media/platform/tegra/camera/vi/channel.c
$l4t-r32.2/public_sources/kernel/nvidia/drivers/media/platform/tegra/camera/vi/vi5_fops.c