From c94093c84fb3c261b7ed84d6a1cd7131d10e978f Mon Sep 17 00:00:00 2001 From: William Wu Date: Thu, 25 Jan 2018 10:54:39 +0800 Subject: [PATCH] usb: dwc_otg_310: pcd: fix out short packet handle If there is more data in the request than we could fit into a single hardware request, then check both of the following conditions: - ep->dwc_ep.xfer_len < ep->dwc_ep.total_len; - deptsiz.b.xfersize == 0; If ep->dwc_ep.xfer_len < ep->dwc_ep.total_len and deptsiz.b.xfersize isn't zero, it means that we have received a short packet from host, then we shouldn't setup transfer for next portion of data. This patch can fix the following issue: Use MTP to transfer more than 4GB single file from PC to RK3368 tablet base on the follow conditions: - Increase the default Tx/Rx buf size to 64K or more in f_mtp.c - Set the core_params->max_transfer_size to 65535; Without this patch, it will fail to transfer the file at the end because the f_mtp driver is waiting for a short packet to signal EOF for file sizes > 4 gig, but the dwc2 driver doesn't handle the short packet. Change-Id: I172d48d727da4b75153705ce6b60728203dd35ca Signed-off-by: William Wu --- drivers/usb/dwc_otg_310/dwc_otg_pcd_intr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc_otg_310/dwc_otg_pcd_intr.c b/drivers/usb/dwc_otg_310/dwc_otg_pcd_intr.c index 46ba82353633..9837b49db273 100644 --- a/drivers/usb/dwc_otg_310/dwc_otg_pcd_intr.c +++ b/drivers/usb/dwc_otg_310/dwc_otg_pcd_intr.c @@ -2404,7 +2404,8 @@ static void complete_ep(dwc_otg_pcd_ep_t *ep) /* Check if the whole transfer was completed, * if no, setup transfer for next portion of data */ - if (ep->dwc_ep.xfer_len < ep->dwc_ep.total_len) { + if (ep->dwc_ep.xfer_len < ep->dwc_ep.total_len && + deptsiz.b.xfersize == 0) { dwc_otg_ep_start_transfer(core_if, &ep->dwc_ep); } else if (ep->dwc_ep.sent_zlp) {