Move mutex_lock to v4l2_msg_read() to avoid the following warning: wait_event_interruptible_timeout will set task to TASK_INTERRUPT, if the first v4l2_msg_read() has not ended, and the second v4l2_msg_read() enters might_sleep, the following warning will be reported.
WARNING: CPU: 1 PID: 236 at kernel/sched/core.c:9859 __might_sleep+0x80/0xa4 ak4458 2-0011: supply AVDD not found, using dummy regulator CPU: 1 PID: 236 Comm: vsidaemon Not tainted 6.1.55-yocto-standard #1 Hardware name: NXP i.MX8MQ EVK (DT) cfg80211: Loading compiled-in X.509 certificates for regulatory database pstate: 60000005 (nZCv daif PAN -UAO -TCO -DIT -SSBS BTYPE=-) pc : __might_sleep+0x80/0xa4 lr : __might_sleep+0x80/0xa4 sp : ffffffc00a71bc10 x29: ffffffc00a71bc10 x28: ffffff8008db1c00 x27: 0000000000000000 x26: 0000000000000000 x25: ffffffc009bc1780 x24: ffffffc009bc1748 x23: 0000007fe23a9420 x22: 0000000000000430 x21: 0000007fe23a9420 x20: 00000000000003d3 x19: ffffffc009324670 x18: 0000000000000000 x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000 x14: 016feed34d55873c x13: ffffffc00903cda0 x12: 00000000fa83b2da x11: 00000000000002f2 x10: 00000000000009a0 x9 : ffffffc0090201f4 x8 : ffffff8008db2600 x7 : 0000000000000001 x6 : 000000000000b83b x5 : 00000000410fd030 x4 : 0000000000000002 x3 : ffffff800700fbc8 x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffffff8008db1c00 Call trace: __might_sleep+0x80/0xa4 mutex_lock_interruptible+0x2c/0x80 getMsg.constprop.0+0x4c/0x190 v4l2_msg_read+0xf8/0x174 vfs_read+0xc8/0x294 ksys_read+0x78/0x10c __arm64_sys_read+0x24/0x30 invoke_syscall+0x5c/0x130 el0_svc_common.constprop.0+0x4c/0xf4 do_el0_svc+0x34/0xc0 el0_svc+0x2c/0x84 el0t_64_sync_handler+0xf4/0x120 el0t_64_sync+0x18c/0x190 Signed-off-by: Xiaolei Wang <xiaolei.w...@windriver.com> --- drivers/mxc/hantro_v4l2/vsi-v4l2daemon.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/mxc/hantro_v4l2/vsi-v4l2daemon.c b/drivers/mxc/hantro_v4l2/vsi-v4l2daemon.c index 3221ddacb1df..569da9759b1a 100644 --- a/drivers/mxc/hantro_v4l2/vsi-v4l2daemon.c +++ b/drivers/mxc/hantro_v4l2/vsi-v4l2daemon.c @@ -164,13 +164,11 @@ static int getMsg(struct file *fh, char __user *buf, size_t size) int id, offset = 0; struct vsi_v4l2_msg *obj; - if (mutex_lock_interruptible(&cmd_lock)) - return -EBUSY; idr_for_each_entry(cmdarray, obj, id) { if (offset >= size) break; if (obj) { - if (copy_to_user((void __user *)buf + offset, (void *)obj, sizeof(struct vsi_v4l2_msg_hdr) + obj->size) != 0) + if (__copy_to_user_inatomic((void __user *)buf + offset, (void *)obj, sizeof(struct vsi_v4l2_msg_hdr) + obj->size) != 0) break; v4l2_klog(LOGLVL_VERBOSE, "%llx send msg id = %d", obj->inst_id, obj->cmd_id); offset += sizeof(struct vsi_v4l2_msg_hdr) + obj->size; @@ -180,7 +178,6 @@ static int getMsg(struct file *fh, char __user *buf, size_t size) break; } } - mutex_unlock(&cmd_lock); return offset; } @@ -626,7 +623,10 @@ static ssize_t v4l2_msg_read(struct file *fh, char __user *buf, size_t size, lof { int ret, r; + if (mutex_lock_interruptible(&cmd_lock)) + return -EBUSY; ret = wait_event_interruptible_timeout(cmd_queue, ((r = getMsg(fh, buf, size)) != 0), msecs_to_jiffies(100)); + mutex_unlock(&cmd_lock); if (ret == -ERESTARTSYS) return -EIO; else if (ret == 0) -- 2.25.1
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#13306): https://lists.yoctoproject.org/g/linux-yocto/message/13306 Mute This Topic: https://lists.yoctoproject.org/mt/102763090/21656 Group Owner: linux-yocto+ow...@lists.yoctoproject.org Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-