Message ID | 04b7c48c-eb68-44bb-8bd3-b85647dbbf91@xs4all.nl (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [for,v6.10] Revert "media: v4l2-ctrls: show all owned controls in log_status" | expand |
Hi Hans, Thank you for the patch. On Fri, May 10, 2024 at 09:11:46AM +0200, Hans Verkuil wrote: > This reverts commit 9801b5b28c6929139d6fceeee8d739cc67bb2739. > > This patch introduced a potential deadlock scenario: > > [Wed May 8 10:02:06 2024] Possible unsafe locking scenario: > > [Wed May 8 10:02:06 2024] CPU0 CPU1 > [Wed May 8 10:02:06 2024] ---- ---- > [Wed May 8 10:02:06 2024] lock(vivid_ctrls:1620:(hdl_vid_cap)->_lock); > [Wed May 8 10:02:06 2024] lock(vivid_ctrls:1608:(hdl_user_vid)->_lock); > [Wed May 8 10:02:06 2024] lock(vivid_ctrls:1620:(hdl_vid_cap)->_lock); > [Wed May 8 10:02:06 2024] lock(vivid_ctrls:1608:(hdl_user_vid)->_lock); > > For now just revert. > > Fixes: 9801b5b28c69 ("media: v4l2-ctrls: show all owned controls in log_status") > Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > drivers/media/v4l2-core/v4l2-ctrls-core.c | 18 +++++------------- > 1 file changed, 5 insertions(+), 13 deletions(-) > > diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c > index c59dd691f79f6..eeab6a5eb7bac 100644 > --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c > +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c > @@ -2507,8 +2507,7 @@ int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl) > EXPORT_SYMBOL(v4l2_ctrl_handler_setup); > > /* Log the control name and value */ > -static void log_ctrl(const struct v4l2_ctrl_handler *hdl, > - struct v4l2_ctrl *ctrl, > +static void log_ctrl(const struct v4l2_ctrl *ctrl, > const char *prefix, const char *colon) > { > if (ctrl->flags & (V4L2_CTRL_FLAG_DISABLED | V4L2_CTRL_FLAG_WRITE_ONLY)) > @@ -2518,11 +2517,7 @@ static void log_ctrl(const struct v4l2_ctrl_handler *hdl, > > pr_info("%s%s%s: ", prefix, colon, ctrl->name); > > - if (ctrl->handler != hdl) > - v4l2_ctrl_lock(ctrl); > ctrl->type_ops->log(ctrl); > - if (ctrl->handler != hdl) > - v4l2_ctrl_unlock(ctrl); > > if (ctrl->flags & (V4L2_CTRL_FLAG_INACTIVE | > V4L2_CTRL_FLAG_GRABBED | > @@ -2541,7 +2536,7 @@ static void log_ctrl(const struct v4l2_ctrl_handler *hdl, > void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl, > const char *prefix) > { > - struct v4l2_ctrl_ref *ref; > + struct v4l2_ctrl *ctrl; > const char *colon = ""; > int len; > > @@ -2553,12 +2548,9 @@ void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl, > if (len && prefix[len - 1] != ' ') > colon = ": "; > mutex_lock(hdl->lock); > - list_for_each_entry(ref, &hdl->ctrl_refs, node) { > - if (ref->from_other_dev || > - (ref->ctrl->flags & V4L2_CTRL_FLAG_DISABLED)) > - continue; > - log_ctrl(hdl, ref->ctrl, prefix, colon); > - } > + list_for_each_entry(ctrl, &hdl->ctrls, node) > + if (!(ctrl->flags & V4L2_CTRL_FLAG_DISABLED)) > + log_ctrl(ctrl, prefix, colon); > mutex_unlock(hdl->lock); > } > EXPORT_SYMBOL(v4l2_ctrl_handler_log_status);
On Fri, May 10, 2024 at 11:25:09AM +0300, Laurent Pinchart wrote: > Hi Hans, > > Thank you for the patch. > > On Fri, May 10, 2024 at 09:11:46AM +0200, Hans Verkuil wrote: > > This reverts commit 9801b5b28c6929139d6fceeee8d739cc67bb2739. > > > > This patch introduced a potential deadlock scenario: > > > > [Wed May 8 10:02:06 2024] Possible unsafe locking scenario: > > > > [Wed May 8 10:02:06 2024] CPU0 CPU1 > > [Wed May 8 10:02:06 2024] ---- ---- > > [Wed May 8 10:02:06 2024] lock(vivid_ctrls:1620:(hdl_vid_cap)->_lock); > > [Wed May 8 10:02:06 2024] lock(vivid_ctrls:1608:(hdl_user_vid)->_lock); > > [Wed May 8 10:02:06 2024] lock(vivid_ctrls:1620:(hdl_vid_cap)->_lock); > > [Wed May 8 10:02:06 2024] lock(vivid_ctrls:1608:(hdl_user_vid)->_lock); > > > > For now just revert. > > > > Fixes: 9801b5b28c69 ("media: v4l2-ctrls: show all owned controls in log_status") > > Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> > > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> There should be a Cc: stable@vger.kernel.org too, as this should be backported to v6.9.x. > > --- > > drivers/media/v4l2-core/v4l2-ctrls-core.c | 18 +++++------------- > > 1 file changed, 5 insertions(+), 13 deletions(-) > > > > diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c > > index c59dd691f79f6..eeab6a5eb7bac 100644 > > --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c > > +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c > > @@ -2507,8 +2507,7 @@ int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl) > > EXPORT_SYMBOL(v4l2_ctrl_handler_setup); > > > > /* Log the control name and value */ > > -static void log_ctrl(const struct v4l2_ctrl_handler *hdl, > > - struct v4l2_ctrl *ctrl, > > +static void log_ctrl(const struct v4l2_ctrl *ctrl, > > const char *prefix, const char *colon) > > { > > if (ctrl->flags & (V4L2_CTRL_FLAG_DISABLED | V4L2_CTRL_FLAG_WRITE_ONLY)) > > @@ -2518,11 +2517,7 @@ static void log_ctrl(const struct v4l2_ctrl_handler *hdl, > > > > pr_info("%s%s%s: ", prefix, colon, ctrl->name); > > > > - if (ctrl->handler != hdl) > > - v4l2_ctrl_lock(ctrl); > > ctrl->type_ops->log(ctrl); > > - if (ctrl->handler != hdl) > > - v4l2_ctrl_unlock(ctrl); > > > > if (ctrl->flags & (V4L2_CTRL_FLAG_INACTIVE | > > V4L2_CTRL_FLAG_GRABBED | > > @@ -2541,7 +2536,7 @@ static void log_ctrl(const struct v4l2_ctrl_handler *hdl, > > void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl, > > const char *prefix) > > { > > - struct v4l2_ctrl_ref *ref; > > + struct v4l2_ctrl *ctrl; > > const char *colon = ""; > > int len; > > > > @@ -2553,12 +2548,9 @@ void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl, > > if (len && prefix[len - 1] != ' ') > > colon = ": "; > > mutex_lock(hdl->lock); > > - list_for_each_entry(ref, &hdl->ctrl_refs, node) { > > - if (ref->from_other_dev || > > - (ref->ctrl->flags & V4L2_CTRL_FLAG_DISABLED)) > > - continue; > > - log_ctrl(hdl, ref->ctrl, prefix, colon); > > - } > > + list_for_each_entry(ctrl, &hdl->ctrls, node) > > + if (!(ctrl->flags & V4L2_CTRL_FLAG_DISABLED)) > > + log_ctrl(ctrl, prefix, colon); > > mutex_unlock(hdl->lock); > > } > > EXPORT_SYMBOL(v4l2_ctrl_handler_log_status);
On 10/05/2024 10:26, Laurent Pinchart wrote: > On Fri, May 10, 2024 at 11:25:09AM +0300, Laurent Pinchart wrote: >> Hi Hans, >> >> Thank you for the patch. >> >> On Fri, May 10, 2024 at 09:11:46AM +0200, Hans Verkuil wrote: >>> This reverts commit 9801b5b28c6929139d6fceeee8d739cc67bb2739. >>> >>> This patch introduced a potential deadlock scenario: >>> >>> [Wed May 8 10:02:06 2024] Possible unsafe locking scenario: >>> >>> [Wed May 8 10:02:06 2024] CPU0 CPU1 >>> [Wed May 8 10:02:06 2024] ---- ---- >>> [Wed May 8 10:02:06 2024] lock(vivid_ctrls:1620:(hdl_vid_cap)->_lock); >>> [Wed May 8 10:02:06 2024] lock(vivid_ctrls:1608:(hdl_user_vid)->_lock); >>> [Wed May 8 10:02:06 2024] lock(vivid_ctrls:1620:(hdl_vid_cap)->_lock); >>> [Wed May 8 10:02:06 2024] lock(vivid_ctrls:1608:(hdl_user_vid)->_lock); >>> >>> For now just revert. >>> >>> Fixes: 9801b5b28c69 ("media: v4l2-ctrls: show all owned controls in log_status") >>> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> >> >> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > > There should be a > > Cc: stable@vger.kernel.org Isn't that automatic if there is a Fixes tag? I thought the stable team automatically processes commits with that tag. Regards, Hans > > too, as this should be backported to v6.9.x. > >>> --- >>> drivers/media/v4l2-core/v4l2-ctrls-core.c | 18 +++++------------- >>> 1 file changed, 5 insertions(+), 13 deletions(-) >>> >>> diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c >>> index c59dd691f79f6..eeab6a5eb7bac 100644 >>> --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c >>> +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c >>> @@ -2507,8 +2507,7 @@ int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl) >>> EXPORT_SYMBOL(v4l2_ctrl_handler_setup); >>> >>> /* Log the control name and value */ >>> -static void log_ctrl(const struct v4l2_ctrl_handler *hdl, >>> - struct v4l2_ctrl *ctrl, >>> +static void log_ctrl(const struct v4l2_ctrl *ctrl, >>> const char *prefix, const char *colon) >>> { >>> if (ctrl->flags & (V4L2_CTRL_FLAG_DISABLED | V4L2_CTRL_FLAG_WRITE_ONLY)) >>> @@ -2518,11 +2517,7 @@ static void log_ctrl(const struct v4l2_ctrl_handler *hdl, >>> >>> pr_info("%s%s%s: ", prefix, colon, ctrl->name); >>> >>> - if (ctrl->handler != hdl) >>> - v4l2_ctrl_lock(ctrl); >>> ctrl->type_ops->log(ctrl); >>> - if (ctrl->handler != hdl) >>> - v4l2_ctrl_unlock(ctrl); >>> >>> if (ctrl->flags & (V4L2_CTRL_FLAG_INACTIVE | >>> V4L2_CTRL_FLAG_GRABBED | >>> @@ -2541,7 +2536,7 @@ static void log_ctrl(const struct v4l2_ctrl_handler *hdl, >>> void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl, >>> const char *prefix) >>> { >>> - struct v4l2_ctrl_ref *ref; >>> + struct v4l2_ctrl *ctrl; >>> const char *colon = ""; >>> int len; >>> >>> @@ -2553,12 +2548,9 @@ void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl, >>> if (len && prefix[len - 1] != ' ') >>> colon = ": "; >>> mutex_lock(hdl->lock); >>> - list_for_each_entry(ref, &hdl->ctrl_refs, node) { >>> - if (ref->from_other_dev || >>> - (ref->ctrl->flags & V4L2_CTRL_FLAG_DISABLED)) >>> - continue; >>> - log_ctrl(hdl, ref->ctrl, prefix, colon); >>> - } >>> + list_for_each_entry(ctrl, &hdl->ctrls, node) >>> + if (!(ctrl->flags & V4L2_CTRL_FLAG_DISABLED)) >>> + log_ctrl(ctrl, prefix, colon); >>> mutex_unlock(hdl->lock); >>> } >>> EXPORT_SYMBOL(v4l2_ctrl_handler_log_status); >
On 10/05/2024 10:40, Hans Verkuil wrote: > On 10/05/2024 10:26, Laurent Pinchart wrote: >> On Fri, May 10, 2024 at 11:25:09AM +0300, Laurent Pinchart wrote: >>> Hi Hans, >>> >>> Thank you for the patch. >>> >>> On Fri, May 10, 2024 at 09:11:46AM +0200, Hans Verkuil wrote: >>>> This reverts commit 9801b5b28c6929139d6fceeee8d739cc67bb2739. >>>> >>>> This patch introduced a potential deadlock scenario: >>>> >>>> [Wed May 8 10:02:06 2024] Possible unsafe locking scenario: >>>> >>>> [Wed May 8 10:02:06 2024] CPU0 CPU1 >>>> [Wed May 8 10:02:06 2024] ---- ---- >>>> [Wed May 8 10:02:06 2024] lock(vivid_ctrls:1620:(hdl_vid_cap)->_lock); >>>> [Wed May 8 10:02:06 2024] lock(vivid_ctrls:1608:(hdl_user_vid)->_lock); >>>> [Wed May 8 10:02:06 2024] lock(vivid_ctrls:1620:(hdl_vid_cap)->_lock); >>>> [Wed May 8 10:02:06 2024] lock(vivid_ctrls:1608:(hdl_user_vid)->_lock); >>>> >>>> For now just revert. >>>> >>>> Fixes: 9801b5b28c69 ("media: v4l2-ctrls: show all owned controls in log_status") >>>> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> >>> >>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> >> >> There should be a >> >> Cc: stable@vger.kernel.org > > Isn't that automatic if there is a Fixes tag? I thought the stable team > automatically processes commits with that tag. Ah, I read up on it and: "Note: Attaching a Fixes: tag does not subvert the stable kernel rules process nor the requirement to Cc: stable@vger.kernel.org on all stable patch candidates. For more information, please read Documentation/process/stable-kernel-rules.rst." So you are right, and I will also update my check ensuring that if there is a fixes tag, then there should be a CC stable as well. Regards, Hans > > Regards, > > Hans > >> >> too, as this should be backported to v6.9.x. >> >>>> --- >>>> drivers/media/v4l2-core/v4l2-ctrls-core.c | 18 +++++------------- >>>> 1 file changed, 5 insertions(+), 13 deletions(-) >>>> >>>> diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c >>>> index c59dd691f79f6..eeab6a5eb7bac 100644 >>>> --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c >>>> +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c >>>> @@ -2507,8 +2507,7 @@ int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl) >>>> EXPORT_SYMBOL(v4l2_ctrl_handler_setup); >>>> >>>> /* Log the control name and value */ >>>> -static void log_ctrl(const struct v4l2_ctrl_handler *hdl, >>>> - struct v4l2_ctrl *ctrl, >>>> +static void log_ctrl(const struct v4l2_ctrl *ctrl, >>>> const char *prefix, const char *colon) >>>> { >>>> if (ctrl->flags & (V4L2_CTRL_FLAG_DISABLED | V4L2_CTRL_FLAG_WRITE_ONLY)) >>>> @@ -2518,11 +2517,7 @@ static void log_ctrl(const struct v4l2_ctrl_handler *hdl, >>>> >>>> pr_info("%s%s%s: ", prefix, colon, ctrl->name); >>>> >>>> - if (ctrl->handler != hdl) >>>> - v4l2_ctrl_lock(ctrl); >>>> ctrl->type_ops->log(ctrl); >>>> - if (ctrl->handler != hdl) >>>> - v4l2_ctrl_unlock(ctrl); >>>> >>>> if (ctrl->flags & (V4L2_CTRL_FLAG_INACTIVE | >>>> V4L2_CTRL_FLAG_GRABBED | >>>> @@ -2541,7 +2536,7 @@ static void log_ctrl(const struct v4l2_ctrl_handler *hdl, >>>> void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl, >>>> const char *prefix) >>>> { >>>> - struct v4l2_ctrl_ref *ref; >>>> + struct v4l2_ctrl *ctrl; >>>> const char *colon = ""; >>>> int len; >>>> >>>> @@ -2553,12 +2548,9 @@ void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl, >>>> if (len && prefix[len - 1] != ' ') >>>> colon = ": "; >>>> mutex_lock(hdl->lock); >>>> - list_for_each_entry(ref, &hdl->ctrl_refs, node) { >>>> - if (ref->from_other_dev || >>>> - (ref->ctrl->flags & V4L2_CTRL_FLAG_DISABLED)) >>>> - continue; >>>> - log_ctrl(hdl, ref->ctrl, prefix, colon); >>>> - } >>>> + list_for_each_entry(ctrl, &hdl->ctrls, node) >>>> + if (!(ctrl->flags & V4L2_CTRL_FLAG_DISABLED)) >>>> + log_ctrl(ctrl, prefix, colon); >>>> mutex_unlock(hdl->lock); >>>> } >>>> EXPORT_SYMBOL(v4l2_ctrl_handler_log_status); >> > >
diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c index c59dd691f79f6..eeab6a5eb7bac 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c @@ -2507,8 +2507,7 @@ int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl) EXPORT_SYMBOL(v4l2_ctrl_handler_setup); /* Log the control name and value */ -static void log_ctrl(const struct v4l2_ctrl_handler *hdl, - struct v4l2_ctrl *ctrl, +static void log_ctrl(const struct v4l2_ctrl *ctrl, const char *prefix, const char *colon) { if (ctrl->flags & (V4L2_CTRL_FLAG_DISABLED | V4L2_CTRL_FLAG_WRITE_ONLY)) @@ -2518,11 +2517,7 @@ static void log_ctrl(const struct v4l2_ctrl_handler *hdl, pr_info("%s%s%s: ", prefix, colon, ctrl->name); - if (ctrl->handler != hdl) - v4l2_ctrl_lock(ctrl); ctrl->type_ops->log(ctrl); - if (ctrl->handler != hdl) - v4l2_ctrl_unlock(ctrl); if (ctrl->flags & (V4L2_CTRL_FLAG_INACTIVE | V4L2_CTRL_FLAG_GRABBED | @@ -2541,7 +2536,7 @@ static void log_ctrl(const struct v4l2_ctrl_handler *hdl, void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl, const char *prefix) { - struct v4l2_ctrl_ref *ref; + struct v4l2_ctrl *ctrl; const char *colon = ""; int len; @@ -2553,12 +2548,9 @@ void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl, if (len && prefix[len - 1] != ' ') colon = ": "; mutex_lock(hdl->lock); - list_for_each_entry(ref, &hdl->ctrl_refs, node) { - if (ref->from_other_dev || - (ref->ctrl->flags & V4L2_CTRL_FLAG_DISABLED)) - continue; - log_ctrl(hdl, ref->ctrl, prefix, colon); - } + list_for_each_entry(ctrl, &hdl->ctrls, node) + if (!(ctrl->flags & V4L2_CTRL_FLAG_DISABLED)) + log_ctrl(ctrl, prefix, colon); mutex_unlock(hdl->lock); } EXPORT_SYMBOL(v4l2_ctrl_handler_log_status);
This reverts commit 9801b5b28c6929139d6fceeee8d739cc67bb2739. This patch introduced a potential deadlock scenario: [Wed May 8 10:02:06 2024] Possible unsafe locking scenario: [Wed May 8 10:02:06 2024] CPU0 CPU1 [Wed May 8 10:02:06 2024] ---- ---- [Wed May 8 10:02:06 2024] lock(vivid_ctrls:1620:(hdl_vid_cap)->_lock); [Wed May 8 10:02:06 2024] lock(vivid_ctrls:1608:(hdl_user_vid)->_lock); [Wed May 8 10:02:06 2024] lock(vivid_ctrls:1620:(hdl_vid_cap)->_lock); [Wed May 8 10:02:06 2024] lock(vivid_ctrls:1608:(hdl_user_vid)->_lock); For now just revert. Fixes: 9801b5b28c69 ("media: v4l2-ctrls: show all owned controls in log_status") Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> --- drivers/media/v4l2-core/v4l2-ctrls-core.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-)