Commit 19905240 authored by Michael Grzeschik's avatar Michael Grzeschik Committed by Greg Kroah-Hartman

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: default avatarMichael Grzeschik <m.grzeschik@pengutronix.de>
Cc: stable <stable@kernel.org>
Link: https://lore.kernel.org/r/20221017221141.3134818-1-m.grzeschik@pengutronix.deSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fb8f60dd
...@@ -84,12 +84,9 @@ static int uvc_buffer_prepare(struct vb2_buffer *vb) ...@@ -84,12 +84,9 @@ static int uvc_buffer_prepare(struct vb2_buffer *vb)
return -ENODEV; return -ENODEV;
buf->state = UVC_BUF_STATE_QUEUED; buf->state = UVC_BUF_STATE_QUEUED;
if (queue->use_sg) { buf->sgt = vb2_dma_sg_plane_desc(vb, 0);
buf->sgt = vb2_dma_sg_plane_desc(vb, 0); buf->sg = buf->sgt->sgl;
buf->sg = buf->sgt->sgl; buf->mem = vb2_plane_vaddr(vb, 0);
} else {
buf->mem = vb2_plane_vaddr(vb, 0);
}
buf->length = vb2_plane_size(vb, 0); buf->length = vb2_plane_size(vb, 0);
if (vb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) if (vb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
buf->bytesused = 0; buf->bytesused = 0;
......
...@@ -459,6 +459,9 @@ static void uvcg_video_pump(struct work_struct *work) ...@@ -459,6 +459,9 @@ static void uvcg_video_pump(struct work_struct *work)
*/ */
int uvcg_video_enable(struct uvc_video *video, int enable) int uvcg_video_enable(struct uvc_video *video, int enable)
{ {
struct uvc_device *uvc = video->uvc;
struct usb_composite_dev *cdev = uvc->func.config->cdev;
struct usb_gadget *gadget = cdev->gadget;
unsigned int i; unsigned int i;
int ret; int ret;
...@@ -490,9 +493,11 @@ int uvcg_video_enable(struct uvc_video *video, int enable) ...@@ -490,9 +493,11 @@ int uvcg_video_enable(struct uvc_video *video, int enable)
if (video->max_payload_size) { if (video->max_payload_size) {
video->encode = uvc_video_encode_bulk; video->encode = uvc_video_encode_bulk;
video->payload_size = 0; video->payload_size = 0;
} else } else {
video->encode = video->queue.use_sg ? video->encode = (video->queue.use_sg &&
!(gadget->speed <= USB_SPEED_HIGH)) ?
uvc_video_encode_isoc_sg : uvc_video_encode_isoc; uvc_video_encode_isoc_sg : uvc_video_encode_isoc;
}
video->req_int_count = 0; video->req_int_count = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment