From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Hans Verkuil <hverkuil+cisco@kernel.org>
Cc: linux-media@vger.kernel.org, Mauricio Faria de Oliveira <mfo@igalia.com>
Subject: Re: [PATCHv3 1/6] media: core: v4l2-async.c: unreg subdev if asc_list is empty
Date: Tue, 30 Jun 2026 11:45:40 +0300 [thread overview]
Message-ID: <akOCNKRVeRlebCI1@kekkonen.localdomain> (raw)
In-Reply-To: <3fc7cf62-c7eb-45c0-a961-af2e47f0b589@kernel.org>
Hi Hans,
On the subject -- I'd write this as, to align with the existing practice:
media: v4l2-async: Unregister sub-device if asc_list is empty
On Tue, Jun 30, 2026 at 10:32:20AM +0200, Hans Verkuil wrote:
> On 6/30/26 09:58, Sakari Ailus wrote:
> > Hi Hans,
> >
> > Thanks for the patch.
> >
> > On Mon, Jun 29, 2026 at 08:55:49AM +0200, Hans Verkuil wrote:
> >> In v4l2_device_unregister_subdev(), if sd->asc_list is empty,
s/device/async/
?
> >> then v4l2_device_unregister_subdev() is never called, but that
> >> should still happen.
> >>
> >> This causes crashes with em28xx that uses tvp5150: that i2c
> >> module uses v4l2_async, but em28xx does not as it predates
> >> v4l2_async.
> >
> > Isn't the sub-device unregistered via v4l2_device_unregister() or do I miss
> > something? em28xx_v4l2_fini() calls it.
> >
> > Or do you mean the issue happens at tvp5150 unbind time?
>
> Yes, that's when it happens. The tvp5150 driver is removed, it calls
> v4l2_async_unregister_subdev(), but that never calls
> v4l2_device_unregister_subdev() since em28xx doesn't use v4l2-async
> and so sd->asc_list is empty.
>
> This happens when unplugging the USB device.
Ack.
Could you add this to the commit message? It'd help understanding what
really goes on here. I'd also add a comment, see below.
>
> >
> >>
> >> So if sd->asc_list is empty, then just call
> >> v4l2_device_unregister_subdev().
> >>
> >> Fixes: 28a1295795d8 ("media: v4l: async: Allow multiple connections between entities")
>
> It was introduced by commit 28a1295795d8, before that commit this was done correctly.
>
> Regards,
>
> Hans
>
> >> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
> >> ---
> >> drivers/media/v4l2-core/v4l2-async.c | 10 +++++++---
> >> 1 file changed, 7 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
> >> index 888a2e213b08..d7437c958028 100644
> >> --- a/drivers/media/v4l2-core/v4l2-async.c
> >> +++ b/drivers/media/v4l2-core/v4l2-async.c
> >> @@ -898,9 +898,13 @@ void v4l2_async_unregister_subdev(struct v4l2_subdev *sd)
> >> sd->subdev_notifier = NULL;
> >>
> >> if (sd->asc_list.next) {
> >> - list_for_each_entry_safe(asc, asc_tmp, &sd->asc_list,
> >> - asc_subdev_entry) {
> >> - v4l2_async_unbind_subdev_one(asc->notifier, asc);
> >> + if (list_empty(&sd->asc_list)) {
How about:
/*
* If the sub-device was registered through other means
* than v4l2-async, there are no async connections but
* the sub-device may still well be registered.
* Unregister it now.
*/
> >> + v4l2_device_unregister_subdev(sd);
> >> + } else {
> >> + list_for_each_entry_safe(asc, asc_tmp, &sd->asc_list,
> >> + asc_subdev_entry) {
> >> + v4l2_async_unbind_subdev_one(asc->notifier, asc);
> >> + }
These braces are redundant.
> >> }
> >> }
> >>
> >
>
--
Regards,
Sakari Ailus
next prev parent reply other threads:[~2026-06-30 8:45 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 6:55 [PATCHv3 0/6] media: em28xx: fix lifecycle issues Hans Verkuil
2026-06-29 6:55 ` [PATCHv3 1/6] media: core: v4l2-async.c: unreg subdev if asc_list is empty Hans Verkuil
2026-06-30 7:58 ` Sakari Ailus
2026-06-30 8:32 ` Hans Verkuil
2026-06-30 8:45 ` Sakari Ailus [this message]
2026-06-30 9:38 ` Hans Verkuil
2026-06-30 10:02 ` [PATCHv4 1/6] media: core: v4l2-async.c: unreg subdev if asc_list is, empty Hans Verkuil
2026-06-30 10:13 ` Sakari Ailus
2026-06-30 12:52 ` Hans Verkuil
2026-06-29 6:55 ` [PATCHv3 2/6] media: em28xx: use v4l2_device release callback Hans Verkuil
2026-06-29 6:55 ` [PATCHv3 3/6] media: em28xx: drop 'users' field Hans Verkuil
2026-06-29 6:55 ` [PATCHv3 4/6] media: em28xx: use vb2_video_unregister_device Hans Verkuil
2026-06-29 6:55 ` [PATCHv3 5/6] media: em28xx: dev_info->pr_info since dev has been freed Hans Verkuil
2026-06-30 12:57 ` Sakari Ailus
2026-06-29 6:55 ` [PATCHv3 6/6] media: em28xx: requeue buffers if start_streaming fails Hans Verkuil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=akOCNKRVeRlebCI1@kekkonen.localdomain \
--to=sakari.ailus@linux.intel.com \
--cc=hverkuil+cisco@kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mfo@igalia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox