usb: cdns3: optimize OUT transfer by copying only actual received data
authorFrank Li <Frank.Li@nxp.com>
Thu, 18 May 2023 20:49:46 +0000 (16:49 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 29 May 2023 14:52:37 +0000 (15:52 +0100)
Previously, the entire length of the request, which is equal to or greater
than the actual data, was dma synced and memcpy when using the bounce
buffer. Actually only the actual data indicated by request->actual need be
synced and copied.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20230518204947.3770236-2-Frank.Li@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/cdns3/cdns3-gadget.c

index d2cedd6..2719919 100644 (file)
@@ -809,10 +809,10 @@ void cdns3_gadget_giveback(struct cdns3_endpoint *priv_ep,
                /* Make DMA buffer CPU accessible */
                dma_sync_single_for_cpu(priv_dev->sysdev,
                        priv_req->aligned_buf->dma,
-                       priv_req->aligned_buf->size,
+                       request->actual,
                        priv_req->aligned_buf->dir);
                memcpy(request->buf, priv_req->aligned_buf->buf,
-                      request->length);
+                      request->actual);
        }
 
        priv_req->flags &= ~(REQUEST_PENDING | REQUEST_UNALIGNED);