[RFC 1/6] usb/dwc3: fix resource_index

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

 



We are clearing resource_index when we issue END TRANSFER command.
Consider a situation, when we have executed END TRANSFER, core has
generated xfernotready, but gadget is too slow and have not queued
any request. So we set PENDING flag. Now application queues another
request. Software does not have notion for current microframe to submit
isoc TRBs. So, it will issue END TRANSFER again. If we have forced
resource_index to zero during first END TRANSFER, then second END
TRANSFER will be issued with wrong resource_index (0), which is not
correct and confusing for core. I have observed that core does generate
xfernotready even if END TRANSFER is issued with resource_index 0, but
then it is not able to start transfer again.

Moreover I have observed that START TRANSFER returns a new
resource_index only if SET XFER RESOURCE is issued again.

Signed-off-by: Pratyush Anand <pratyush.anand@xxxxxx>
---
 drivers/usb/dwc3/gadget.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index f13daa2..0f6874c 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -530,6 +530,7 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
 		if (ret)
 			return ret;
 
+		dep->resource_index = 0;
 		dep->endpoint.desc = desc;
 		dep->comp_desc = comp_desc;
 		dep->type = usb_endpoint_type(desc);
@@ -1919,16 +1920,12 @@ static void dwc3_stop_active_transfer(struct dwc3 *dwc, u32 epnum)
 
 	dep = dwc->eps[epnum];
 
-	if (!dep->resource_index)
-		return;
-
 	cmd = DWC3_DEPCMD_ENDTRANSFER;
 	cmd |= DWC3_DEPCMD_HIPRI_FORCERM | DWC3_DEPCMD_CMDIOC;
 	cmd |= DWC3_DEPCMD_PARAM(dep->resource_index);
 	memset(&params, 0, sizeof(params));
 	ret = dwc3_send_gadget_ep_cmd(dwc, dep->number, cmd, &params);
 	WARN_ON_ONCE(ret);
-	dep->resource_index = 0;
 
 	/*
 	 * notice: we are violating what the databook says about the
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

  Powered by Linux