All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Grzeschik <mgr@pengutronix.de>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: paul.elder@ideasonboard.com, linux-usb@vger.kernel.org,
	caleb.connolly@ideasonboard.com, balbi@kernel.org,
	kernel@pengutronix.de
Subject: Re: [PATCH v2 3/3] usb: gadget: uvc: decrease the interrupt load to a quarter
Date: Tue, 22 Jun 2021 17:02:56 +0200	[thread overview]
Message-ID: <20210622150256.GD24215@pengutronix.de> (raw)
In-Reply-To: <YMgENcJoomZULu+J@pendragon.ideasonboard.com>

[-- Attachment #1: Type: text/plain, Size: 3848 bytes --]

Hi Laurent!

On Tue, Jun 15, 2021 at 04:36:53AM +0300, Laurent Pinchart wrote:
>Hi Michael,
>
>Thank you for the patch.
>
>On Mon, Jun 14, 2021 at 07:35:58PM +0900, paul.elder@ideasonboard.com wrote:
>> On Mon, May 31, 2021 at 12:30:41AM +0200, Michael Grzeschik wrote:
>> > With usb3 we handle much more requests. It only enables the interrupt on
>>
>> s/much/many/
>>
>> > every quarter of the allocated requests. This patch decreases the
>> > interrupt load.
>>
>> The last two sentences might be better combined, like:
>>
>> "Decrease the interrupt load by only enabling the interrupt every
>> quarter of the allocated requests."
>>
>> > Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
>>
>> Other than that, looks good to me.
>>
>> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
>>
>> > ---
>> >  drivers/usb/gadget/function/uvc.h       |  2 ++
>> >  drivers/usb/gadget/function/uvc_video.c | 12 ++++++++++++
>> >  2 files changed, 14 insertions(+)
>> >
>> > diff --git a/drivers/usb/gadget/function/uvc.h b/drivers/usb/gadget/function/uvc.h
>> > index c1f06d9df5820..5a76e9351b530 100644
>> > --- a/drivers/usb/gadget/function/uvc.h
>> > +++ b/drivers/usb/gadget/function/uvc.h
>> > @@ -101,6 +101,8 @@ struct uvc_video {
>> >  	struct list_head req_free;
>> >  	spinlock_t req_lock;
>> >
>> > +	int req_int_count;
>
>unsigned int.
>
>> > +
>> >  	void (*encode) (struct usb_request *req, struct uvc_video *video,
>> >  			struct uvc_buffer *buf);
>> >
>> > diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c
>> > index 240d361a45a44..66754687ce217 100644
>> > --- a/drivers/usb/gadget/function/uvc_video.c
>> > +++ b/drivers/usb/gadget/function/uvc_video.c
>> > @@ -357,6 +357,16 @@ static void uvcg_video_pump(struct work_struct *work)
>> >
>> >  		video->encode(req, video, buf);
>> >
>
>A comment to explain the logic would be useful.
>
>> > +		if (list_empty(&video->req_free) ||
>> > +		    (buf->state == UVC_BUF_STATE_DONE) ||
>
>No need for parentheses here.
>
>> > +		    (!(video->req_int_count %
>> > +		       DIV_ROUND_UP(video->uvc_num_requests, 4)))) {
>> > +			video->req_int_count = 0;
>> > +			req->no_interrupt = 0;
>> > +		} else {
>> > +			req->no_interrupt = 1;
>> > +		}
>> > +
>> >  		/* Queue the USB request */
>> >  		ret = uvcg_video_ep_queue(video, req);
>> >  		spin_unlock_irqrestore(&queue->irqlock, flags);
>> > @@ -365,6 +375,7 @@ static void uvcg_video_pump(struct work_struct *work)
>> >  			uvcg_queue_cancel(queue, 0);
>> >  			break;
>> >  		}
>> > +		video->req_int_count++;
>> >  	}
>> >
>> >  	spin_lock_irqsave(&video->req_lock, flags);
>> > @@ -437,6 +448,7 @@ int uvcg_video_init(struct uvc_video *video, struct uvc_device *uvc)
>> >  	video->width = 320;
>> >  	video->height = 240;
>> >  	video->imagesize = 320 * 240 * 2;
>> > +	video->req_int_count = 0;
>
>Should this be initialized to 0 in uvcg_video_enable() instead of
>uvcg_video_init(), to ensure that stop/start cycles will operate in a
>predictable way ?

This makes total sense. I don't see why it should not start by 0 on
every enable. I worked in yours and Paul's feedback and moved the
req_int_count initialization to uvcg_video_enable.

Thanks!

Michael Grzeschik

>> >
>> >  	/* Initialize the video buffers queue. */
>> >  	uvcg_queue_init(uvc->v4l2_dev.dev, &video->queue, V4L2_BUF_TYPE_VIDEO_OUTPUT,
>
>-- 
>Regards,
>
>Laurent Pinchart
>

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2021-06-22 15:03 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-30 22:30 [PATCH v2 0/3] usb: gadget: uvc: improve uvc gadget performance Michael Grzeschik
2021-05-30 22:30 ` [PATCH v2 1/3] usb: gadget: uvc: make uvc_num_requests depend on gadget speed Michael Grzeschik
2021-06-14 10:34   ` paul.elder
2021-06-15  1:28   ` Laurent Pinchart
2021-06-15  1:38     ` Laurent Pinchart
2021-06-22 15:00       ` Michael Grzeschik
2021-05-30 22:30 ` [PATCH v2 2/3] usb: gadget: uvc: add scatter gather support Michael Grzeschik
2021-05-31  1:33   ` kernel test robot
2021-05-31  1:33     ` kernel test robot
2021-05-31  6:30   ` kernel test robot
2021-05-31  6:30     ` kernel test robot
2021-06-15  2:10   ` Laurent Pinchart
2021-06-25  9:12     ` Michael Grzeschik
2021-06-28  7:37       ` Michael Grzeschik
2021-05-30 22:30 ` [PATCH v2 3/3] usb: gadget: uvc: decrease the interrupt load to a quarter Michael Grzeschik
2021-06-14 10:35   ` paul.elder
2021-06-15  1:36     ` Laurent Pinchart
2021-06-22 15:02       ` Michael Grzeschik [this message]
2021-06-09  8:17 ` [PATCH v2 0/3] usb: gadget: uvc: improve uvc gadget performance 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=20210622150256.GD24215@pengutronix.de \
    --to=mgr@pengutronix.de \
    --cc=balbi@kernel.org \
    --cc=caleb.connolly@ideasonboard.com \
    --cc=kernel@pengutronix.de \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=paul.elder@ideasonboard.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.