From: Hans de Goede <hansg@kernel.org>
To: Ricardo Ribalda <ribalda@chromium.org>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Yunke Cao <yunkec@google.com>,
stable@kernel.org
Subject: Re: [PATCH v3 2/2] media: uvcvideo: Fix sequence number when no EOF
Date: Fri, 20 Mar 2026 13:17:17 +0100 [thread overview]
Message-ID: <19945fe0-fb8e-4c20-a2d8-2fc8273b0978@kernel.org> (raw)
In-Reply-To: <20260316-uvc-fid-v3-2-c793354469b5@chromium.org>
Hi,
On 16-Mar-26 14:30, Ricardo Ribalda wrote:
> If the driver could not detect the EOF, the sequence number is increased
> twice:
> 1) When we enter uvc_video_decode_start() with the old buffer and FID has
> fliped => We return -EAGAIN and last_fid is not flipped
> 2) When we enter uvc_video_decode_start() with the new buffer.
>
> Fix this issue by saving last_fid on the first FID flip.
>
> Cc: stable@kernel.org
> Fixes: 650b95feee35 ("[media] uvcvideo: Generate discontinuous sequence numbers when frames are lost")
> Reported-by: Hans de Goede <hansg@kernel.org>
> Closes: https://lore.kernel.org/linux-media/CANiDSCuj4cPuB5_v2xyvAagA5FjoN8V5scXiFFOeD3aKDMqkCg@mail.gmail.com/T/#me39fb134e8c2c085567a31548c3403eb639625e4
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
> drivers/media/usb/uvc/uvc_video.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
> index 9e06b1d0f0f9..3e6ded69388f 100644
> --- a/drivers/media/usb/uvc/uvc_video.c
> +++ b/drivers/media/usb/uvc/uvc_video.c
> @@ -1254,6 +1254,12 @@ static int uvc_video_decode_start(struct uvc_streaming *stream,
> uvc_dbg(stream->dev, FRAME,
> "Frame complete (FID bit toggled)\n");
> buf->state = UVC_BUF_STATE_READY;
> +
> + /*
> + * If the EOF detection has failed, we need to save the last_fid
> + * to avoid increasing the sequence number twice.
> + */
> + stream->last_fid = fid;
AFAICT, there is still a problem after this patch:
1. We have an incomplete frame, so no EOF, first run through
uvc_video_decode_start()
2. We hit the first if (stream->last_fid != fid) check do
stream->sequence++ . And after patch 1/2 we do NOT update
"buf->buf.sequence = stream->sequence" because buf->bytesused != 0
(which is good, the incomplete frame should not get the new
sequence-no).
3. Still first run through uvc_video_decode_start() we hit the:
if (fid != stream->last_fid && buf->bytesused != 0) check further
down, update "stream->last_fid = fid" (after this patch) and
return -EAGAIN.
4. Second run through uvc_video_decode_start() the first
if (stream->last_fid != fid) check no longer triggers, we
don't increase the sequence-no (good) but we also do not
set "buf->buf.sequence = stream->sequence" for the new buffer
we are called with on the second run!
So the combination of these 2 fixes is broken.
Regards,
Hans
next prev parent reply other threads:[~2026-03-20 12:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-16 13:30 [PATCH v3 0/2] media: uvcvideo: Fixes for frame sequence number Ricardo Ribalda
2026-03-16 13:30 ` [PATCH v3 1/2] media: uvcvideo: Fix buffer sequence in frame gaps Ricardo Ribalda
2026-03-16 13:30 ` [PATCH v3 2/2] media: uvcvideo: Fix sequence number when no EOF Ricardo Ribalda
2026-03-20 12:17 ` Hans de Goede [this message]
2026-03-20 13:12 ` Ricardo Ribalda
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=19945fe0-fb8e-4c20-a2d8-2fc8273b0978@kernel.org \
--to=hansg@kernel.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=ribalda@chromium.org \
--cc=stable@kernel.org \
--cc=yunkec@google.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