Skip to content

Commit 1990524

Browse files
mgrzeschikgregkh
authored andcommitted
usb: gadget: uvc: limit isoc_sg to super speed gadgets
The overhead of preparing sg data is high for transfers with limited payload. When transferring isoc over high-speed usb the maximum payload is rather small which is a good argument no to use sg. This patch is changing the uvc_video_encode_isoc_sg encode function only to be used for super speed gadgets. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Cc: stable <stable@kernel.org> Link: https://lore.kernel.org/r/20221017221141.3134818-1-m.grzeschik@pengutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent fb8f60d commit 1990524

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

drivers/usb/gadget/function/uvc_queue.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,9 @@ static int uvc_buffer_prepare(struct vb2_buffer *vb)
8484
return -ENODEV;
8585

8686
buf->state = UVC_BUF_STATE_QUEUED;
87-
if (queue->use_sg) {
88-
buf->sgt = vb2_dma_sg_plane_desc(vb, 0);
89-
buf->sg = buf->sgt->sgl;
90-
} else {
91-
buf->mem = vb2_plane_vaddr(vb, 0);
92-
}
87+
buf->sgt = vb2_dma_sg_plane_desc(vb, 0);
88+
buf->sg = buf->sgt->sgl;
89+
buf->mem = vb2_plane_vaddr(vb, 0);
9390
buf->length = vb2_plane_size(vb, 0);
9491
if (vb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
9592
buf->bytesused = 0;

drivers/usb/gadget/function/uvc_video.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,9 @@ static void uvcg_video_pump(struct work_struct *work)
459459
*/
460460
int uvcg_video_enable(struct uvc_video *video, int enable)
461461
{
462+
struct uvc_device *uvc = video->uvc;
463+
struct usb_composite_dev *cdev = uvc->func.config->cdev;
464+
struct usb_gadget *gadget = cdev->gadget;
462465
unsigned int i;
463466
int ret;
464467

@@ -490,9 +493,11 @@ int uvcg_video_enable(struct uvc_video *video, int enable)
490493
if (video->max_payload_size) {
491494
video->encode = uvc_video_encode_bulk;
492495
video->payload_size = 0;
493-
} else
494-
video->encode = video->queue.use_sg ?
496+
} else {
497+
video->encode = (video->queue.use_sg &&
498+
!(gadget->speed <= USB_SPEED_HIGH)) ?
495499
uvc_video_encode_isoc_sg : uvc_video_encode_isoc;
500+
}
496501

497502
video->req_int_count = 0;
498503

0 commit comments

Comments
 (0)