UPSTREAM: usb: gadget: uvc: decrease the interrupt load to a quarter
With usb3 we handle many more requests. Decrease the interrupt load by only enabling the interrupt every quarter of the allocated requests. Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> -- v1 -> v2: - edited patch description - removed extra parantheses - added a comment for the logic - using unsigned int instead of int - reinitializing req_int_count in uvcg_video_enable v2 -> v3: - Link: https://lore.kernel.org/r/20210628155311.16762-6-m.grzeschik@pengutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit fc78941d8169cba40e420eb24a88789b0406c738) Bug: 242344221 Bug: 325993121 Change-Id: I4b40c4bbd90b9b8ad85957a77589fb304e00a876 Signed-off-by: Avichal Rakesh <arakesh@google.com> Signed-off-by: Luca Stefani <luca@osomprivacy.com>
This commit is contained in:

committed by
Luca Stefani

parent
ad31e24641
commit
beecd97e3a
@@ -100,6 +100,8 @@ struct uvc_video {
|
|||||||
struct list_head req_free;
|
struct list_head req_free;
|
||||||
spinlock_t req_lock;
|
spinlock_t req_lock;
|
||||||
|
|
||||||
|
unsigned int req_int_count;
|
||||||
|
|
||||||
void (*encode) (struct usb_request *req, struct uvc_video *video,
|
void (*encode) (struct usb_request *req, struct uvc_video *video,
|
||||||
struct uvc_buffer *buf);
|
struct uvc_buffer *buf);
|
||||||
|
|
||||||
|
@@ -294,6 +294,19 @@ static void uvcg_video_pump(struct work_struct *work)
|
|||||||
|
|
||||||
video->encode(req, video, buf);
|
video->encode(req, video, buf);
|
||||||
|
|
||||||
|
/* With usb3 we have more requests. This will decrease the
|
||||||
|
* interrupt load to a quarter but also catches the corner
|
||||||
|
* cases, which needs to be handled */
|
||||||
|
if (list_empty(&video->req_free) ||
|
||||||
|
buf->state == UVC_BUF_STATE_DONE ||
|
||||||
|
!(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 */
|
/* Queue the USB request */
|
||||||
ret = uvcg_video_ep_queue(video, req);
|
ret = uvcg_video_ep_queue(video, req);
|
||||||
spin_unlock_irqrestore(&queue->irqlock, flags);
|
spin_unlock_irqrestore(&queue->irqlock, flags);
|
||||||
@@ -305,6 +318,7 @@ static void uvcg_video_pump(struct work_struct *work)
|
|||||||
|
|
||||||
/* Endpoint now owns the request */
|
/* Endpoint now owns the request */
|
||||||
req = NULL;
|
req = NULL;
|
||||||
|
video->req_int_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!req)
|
if (!req)
|
||||||
@@ -355,6 +369,8 @@ int uvcg_video_enable(struct uvc_video *video, int enable)
|
|||||||
} else
|
} else
|
||||||
video->encode = uvc_video_encode_isoc;
|
video->encode = uvc_video_encode_isoc;
|
||||||
|
|
||||||
|
video->req_int_count = 0;
|
||||||
|
|
||||||
schedule_work(&video->pump);
|
schedule_work(&video->pump);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Reference in New Issue
Block a user