1
0
Fork 0

LF-135 media: mx6s_capture: fix kernel dump when start two instances of capture

the driver can't support two instances capturing, but should not have dump even
run two instances.
fix the kernel dump as below by using open counts.

[   59.147670] Mem abort info:
[   59.150480]   ESR = 0x96000006
[   59.153580]   EC = 0x25: DABT (current EL), IL = 32 bits
[   59.158928]   SET = 0, FnV = 0
[   59.162271]   EA = 0, S1PTW = 0
[   59.165431] Data abort info:
[   59.171168]   ISV = 0, ISS = 0x00000006
[   59.175031]   CM = 0, WnR = 0
[   59.180852] user pgtable: 4k pages, 48-bit VAs, pgdp=00000000b9a61000
[   59.187317] [0000000000000008] pgd=00000000b84d8003, pud=00000000b857f003, pmd=0000000000000000
[   59.198708] Internal error: Oops: 96000006 [#1] PREEMPT SMP
[   59.204282] Modules linked in:
[   59.207343] CPU: 1 PID: 642 Comm: mx6s_v4l2_captu Not tainted 5.4.0-03538-gd9bad5b71b42 #5
Message from syslogd@imx8mme[   59.218379] Hardware name: FSL i.MX8MM EVK board (DT)
[   59.223430] pstate: 60000005 (nZCv daif -PAN -UAO)
[   59.228228] pc : put_vaddr_frames+0x10/0xf0
[   59.232412] lr : vb2_destroy_framevec+0x14/0x28
[   59.236940] sp : ffff80001266bc10
[   59.240251] x29: ffff80001266bc10 x28: ffff0000746b8dc0
[   59.245562] x27: 0000000000000000 x26: 0000000000000030
[   59.250872] x25: 0000000000000060 x24: 0000000000000003
[   59.256181] x23: 0000000000000000 x22: 0000000000000000
[   59.261491] x21: 0000000000000001 x20: 0000000000000000
[   59.266801] x19: 0000000000000000 x18: 0000000000000000
[   59.272112] x17: 0000000000000000 x16: 0000000000000000
[   59.277423] x15: 0000000000000000 x14: 0000000000000000
[   59.282733] x13: 0000000000000000 x12: 0000000000000000
[   59.288043] x11: 0000000000000000 x10: 0000000000000001
[   59.293354] x9 : 0000000000000020 x8 : ffff00007dba5af8
[   59.298665] x7 : 0000000000000001 x6 : ffff00007a5ca300
[   59.303973] x5 : ffff80001266bc60 x4 : 0000000000000000
[   59.309283] x3 : 0000000000000002 x2 : ffff0000747b7600
[   59.314593] x1 : ffff800010cba6a8 x0 : 0000000000000000
[   59.319906] Call trace:
[   59.322354]  put_vaddr_frames+0x10/0xf0
[   59.326189]  vb2_destroy_framevec+0x14/0x28
[   59.330371]  vb2_dc_put_userptr+0xac/0x120
[   59.334468]  __vb2_queue_free+0x118/0x240
[   59.338476]  vb2_core_queue_release+0x34/0x48
[   59.342832]  vb2_queue_release+0xc/0x18
[   59.346668]  mx6s_csi_close+0x34/0xfc
[   59.350329]  v4l2_release+0xb4/0xe8
[   59.353817]  __fput+0x88/0x228
[   59.356868]  ____fput+0xc/0x18
[   59.359925]  task_work_run+0x80/0x130
[   59.363589]  do_notify_resume+0x1f0/0x460
[   59.367597]  work_pending+0x8/0x10
[   59.371001] Code: a9bd7bfd 910003fd a90153f3 aa0003f4 (39402001)
[   59.377094] ---[ end trace 57c60e9205cdecb0 ]---

reproduce steps:
1. v4l_emma.sh 1 4
2. enter ctrl+z when systrem start capturing
3. v4l_emma.sh 1 4

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: Guoniu.zhou <guoniu.zhou@nxp.com>
(cherry picked from commit 1a7af0123bd0677ce1a2a12f333c79552885eca9)
5.4-rM2-2.2.x-imx-squashed
Robby Cai 2019-12-04 20:06:15 +08:00
parent ec6ff73b55
commit d40637cc8c
1 changed files with 29 additions and 23 deletions

View File

@ -305,6 +305,8 @@ struct mx6s_csi_dev {
struct mutex lock;
spinlock_t slock;
int open_count;
/* clock */
struct clk *clk_disp_axi;
struct clk *clk_disp_dcic;
@ -1181,26 +1183,28 @@ static int mx6s_csi_open(struct file *file)
if (mutex_lock_interruptible(&csi_dev->lock))
return -ERESTARTSYS;
q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
q->io_modes = VB2_MMAP | VB2_USERPTR;
q->drv_priv = csi_dev;
q->ops = &mx6s_videobuf_ops;
q->mem_ops = &vb2_dma_contig_memops;
q->buf_struct_size = sizeof(struct mx6s_buffer);
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->lock = &csi_dev->lock;
if (csi_dev->open_count++ == 0) {
q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
q->io_modes = VB2_MMAP | VB2_USERPTR;
q->drv_priv = csi_dev;
q->ops = &mx6s_videobuf_ops;
q->mem_ops = &vb2_dma_contig_memops;
q->buf_struct_size = sizeof(struct mx6s_buffer);
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->lock = &csi_dev->lock;
ret = vb2_queue_init(q);
if (ret < 0)
goto unlock;
ret = vb2_queue_init(q);
if (ret < 0)
goto unlock;
pm_runtime_get_sync(csi_dev->dev);
pm_runtime_get_sync(csi_dev->dev);
request_bus_freq(BUS_FREQ_HIGH);
request_bus_freq(BUS_FREQ_HIGH);
v4l2_subdev_call(sd, core, s_power, 1);
mx6s_csi_init(csi_dev);
v4l2_subdev_call(sd, core, s_power, 1);
mx6s_csi_init(csi_dev);
}
mutex_unlock(&csi_dev->lock);
return ret;
@ -1216,18 +1220,20 @@ static int mx6s_csi_close(struct file *file)
mutex_lock(&csi_dev->lock);
vb2_queue_release(&csi_dev->vb2_vidq);
if (--csi_dev->open_count == 0) {
vb2_queue_release(&csi_dev->vb2_vidq);
mx6s_csi_deinit(csi_dev);
v4l2_subdev_call(sd, core, s_power, 0);
mx6s_csi_deinit(csi_dev);
v4l2_subdev_call(sd, core, s_power, 0);
file->private_data = NULL;
release_bus_freq(BUS_FREQ_HIGH);
pm_runtime_put_sync_suspend(csi_dev->dev);
}
mutex_unlock(&csi_dev->lock);
file->private_data = NULL;
release_bus_freq(BUS_FREQ_HIGH);
pm_runtime_put_sync_suspend(csi_dev->dev);
return 0;
}