Re: [PATCH] usb: dwc3: Handle pending control data out correctly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 01, 2012 at 12:18:25PM +0530, Pratyush Anand wrote:
> If transfer not ready is received before ep queue is called for control
> out transfer then pending flag is set. Handling of this case was not
> correct.
> TRB size must be max packet for all control out transfer.
> dma sync function should also be called before start transfer.
> 
> Signed-off-by: Pratyush Anand <pratyush.anand@xxxxxx>

Here you go, please test this:

diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 8d41b6a..8122f21 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -141,6 +141,7 @@ static int __dwc3_gadget_ep0_queue(struct dwc3_ep *dep,
 	 * IRQ we were waiting for is long gone.
 	 */
 	if (dep->flags & DWC3_EP_PENDING_REQUEST) {
+		unsigned	transfer_size;
 		unsigned	direction;
 
 		direction = !!(dep->flags & DWC3_EP0_DIR_IN);
@@ -150,8 +151,19 @@ static int __dwc3_gadget_ep0_queue(struct dwc3_ep *dep,
 			return 0;
 		}
 
+		transfer_size = req->request.length;
+		transfer_size += transfer_size % dep->endpoint.maxpacket;
+
+		ret = usb_gadget_map_request(&dwc->gadget, &req->request,
+				direction);
+		if (ret) {
+			dev_dbg(dwc->dev, "failed to map request\n");
+			return ret;
+		}
+
 		ret = dwc3_ep0_start_trans(dwc, direction,
-				req->request.dma, req->request.length,
+				req->request.dma,
+				direction ? req->request.length : transfer_size,
 				DWC3_TRBCTL_CONTROL_DATA);
 		dep->flags &= ~(DWC3_EP_PENDING_REQUEST |
 				DWC3_EP0_DIR_IN);

> ---
>  drivers/usb/dwc3/ep0.c |   26 +++++++++++++++++++++++---
>  1 files changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
> index c6c9b8a..ad4062a 100644
> --- a/drivers/usb/dwc3/ep0.c
> +++ b/drivers/usb/dwc3/ep0.c
> @@ -150,9 +150,29 @@ static int __dwc3_gadget_ep0_queue(struct dwc3_ep *dep,
>  			return 0;
>  		}
>  
> -		ret = dwc3_ep0_start_trans(dwc, direction,
> -				req->request.dma, req->request.length,
> -				DWC3_TRBCTL_CONTROL_DATA);
> +		dwc3_map_buffer_to_dma(req);

btw, this function doesn't exist anymore. Which kernel version are you
using ?

-- 
balbi

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux