merged.
Bruce
In message: [linux-yocto][v6.1/standard/nxp-sdk-6.1/nxp-soc &
v6.1/standard/preempt-rt/nxp-sdk-6.1/nxp-soc] mxc: hantro_v4l2: Move mutex_lock
from getMsg to v4l2_msg_read()
on 23/11/2023 Xiaolei Wang wrote:
> 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: 6005 (nZCv daif PAN -UAO -TCO -DIT -SSBS BTYPE=-)
> pc : __might_sleep+0x80/0xa4
> lr : __might_sleep+0x80/0xa4
> sp : ffc00a71bc10
> x29: ffc00a71bc10 x28: ff8008db1c00 x27:
> x26: x25: ffc009bc1780 x24: ffc009bc1748
> x23: 007fe23a9420 x22: 0430 x21: 007fe23a9420
> x20: 03d3 x19: ffc009324670 x18:
> x17: x16: x15:
> x14: 016feed34d55873c x13: ffc00903cda0 x12: fa83b2da
> x11: 02f2 x10: 09a0 x9 : ffc0090201f4
> x8 : ff8008db2600 x7 : 0001 x6 : b83b
> x5 : 410fd030 x4 : 0002 x3 : ff800700fbc8
> x2 : x1 : x0 : ff8008db1c00
> 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
> ---
> 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(_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(_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(_lock))
> + return -EBUSY;
> ret = wait_event_interruptible_timeout(cmd_queue, ((r = getMsg(fh, buf,
> size)) != 0), msecs_to_jiffies(100));
> + mutex_unlock(_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 (#13307):
https://lists.yoctoproject.org/g/linux-yocto/message/13307
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/leave/6687884/21656/624485779/xyzzy
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-