linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Vacura <w36195@motorola.com>
To: Daniel Scally <dan.scally@ideasonboard.com>
Cc: linux-usb@vger.kernel.org, laurent.pinchart@ideasonboard.com,
	kieran@linuxembedded.co.uk, balbi@kernel.org,
	gregkh@linuxfoundation.org, mgr@pengutronix.de
Subject: Re: [PATCH] uvc: gadget: uvc: Defer uvcg_complete_buffer() until .complete()
Date: Mon, 3 Oct 2022 10:26:22 -0500	[thread overview]
Message-ID: <Yzr/Htmws3eGa41v@p1g3> (raw)
In-Reply-To: <20221003101627.144026-1-dan.scally@ideasonboard.com>

Hi Dan,

Looks like I did a superset of your change here:
https://lore.kernel.org/all/20220926195307.110121-2-w36195@motorola.com/

I also included the uvc_video_encode_bulk() for consistency, even though
it seems to be unused code.

Out of curiosity, which setup did you test this on? I'm seeing issues on
my devices with the dwc3 controller with some of the recent performance
improvements (scatter/gather support and no_interrupt use). I've tried
to include all relevant changes in my setup, but the issues are still
present.

Any input is appreciated,

Dan


On Mon, Oct 03, 2022 at 11:16:27AM +0100, Daniel Scally wrote:
> Calling uvcg_complete_buffer() from uvc_video_encode_isoc() sometimes
> causes the final isoc packet for a video frame to be delayed long
> enough to cause the USB controller to drop it. The first isoc packet
> of the next video frame is then received by the host, which interprets
> the toggled FID bit correctly such that the stream continues without
> interruption, but the first frame will be missing the last isoc
> packet's worth of bytes.
> 
> To fix the issue delay the call to uvcg_complete_buffer() until the
> usb_request's .complete() callback, as already happens when the data
> is encoded via uvc_video_encode_isoc_sg().
> 
> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
> ---
>  drivers/usb/gadget/function/uvc_video.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c
> index c00ce0e91f5d..041819a655ed 100644
> --- a/drivers/usb/gadget/function/uvc_video.c
> +++ b/drivers/usb/gadget/function/uvc_video.c
> @@ -194,6 +194,7 @@ static void
>  uvc_video_encode_isoc(struct usb_request *req, struct uvc_video *video,
>  		struct uvc_buffer *buf)
>  {
> +	struct uvc_request *ureq = req->context;
>  	void *mem = req->buf;
>  	int len = video->req_size;
>  	int ret;
> @@ -213,7 +214,7 @@ uvc_video_encode_isoc(struct usb_request *req, struct uvc_video *video,
>  		video->queue.buf_used = 0;
>  		buf->state = UVC_BUF_STATE_DONE;
>  		list_del(&buf->queue);
> -		uvcg_complete_buffer(&video->queue, buf);
> +		ureq->last_buf = buf;
>  		video->fid ^= UVC_STREAM_FID;
>  	}
>  }
> -- 
> 2.34.1
> 

  parent reply	other threads:[~2022-10-03 15:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-03 10:16 [PATCH] uvc: gadget: uvc: Defer uvcg_complete_buffer() until .complete() Daniel Scally
2022-10-03 11:47 ` Michael Grzeschik
2022-10-03 15:26 ` Dan Vacura [this message]
2022-10-03 22:23   ` Dan Scally
2022-11-09 10:39 ` Greg KH

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=Yzr/Htmws3eGa41v@p1g3 \
    --to=w36195@motorola.com \
    --cc=balbi@kernel.org \
    --cc=dan.scally@ideasonboard.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kieran@linuxembedded.co.uk \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=mgr@pengutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).