Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dd36b89a authored by Hemant Kumar's avatar Hemant Kumar
Browse files

usb: dwc3: Improve future uF number calculation



Since the controller interrupt is handled in a work context,
there is a delay between XfernotReady and START TRANSFER for
isoc ep. This is resulting into frequent xfer bus expiration.
Improve calculation by using latest uf number from DSTS and
align it to ep interval after adding 2 additional interval to
that. Update two MSB bits received from xferNotReady event in
case of a wrap-around condition.

Change-Id: If98abac1f2e9688f929bd27c5aef7e063a886d2b
Signed-off-by: default avatarHemant Kumar <hemantk@codeaurora.org>
parent 8c2f0b9b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -688,6 +688,8 @@ struct dwc3_ep_events {

#define DWC3_TRB_NUM		256

#define DWC3_FRAME_WRAP_AROUND_MASK (BIT(14) | BIT(15))

/**
 * struct dwc3_ep - device side endpoint representation
 * @endpoint: usb endpoint
+16 −1
Original line number Diff line number Diff line
@@ -1438,6 +1438,8 @@ static int __dwc3_gadget_get_frame(struct dwc3 *dwc)

static void __dwc3_gadget_start_isoc(struct dwc3_ep *dep)
{
	u16 wraparound_bits;

	if (list_empty(&dep->pending_list)) {
		dev_info(dep->dwc->dev, "%s: ran out of requests\n",
				dep->name);
@@ -1445,7 +1447,20 @@ static void __dwc3_gadget_start_isoc(struct dwc3_ep *dep)
		return;
	}

	dep->frame_number = DWC3_ALIGN_FRAME(dep);
	wraparound_bits = dep->frame_number & DWC3_FRAME_WRAP_AROUND_MASK;
	dep->frame_number = dep->frame_number & ~DWC3_FRAME_WRAP_AROUND_MASK;

	/* if frame wrapped-around update wrap-around bits to reflect that */
	if (__dwc3_gadget_get_frame(dep->dwc) < dep->frame_number)
		wraparound_bits += BIT(14);

	dep->frame_number = __dwc3_gadget_get_frame(dep->dwc) +
				2 * dep->interval;

	/* align uf to ep interval */
	dep->frame_number = (wraparound_bits | dep->frame_number) &
				~(dep->interval - 1);

	__dwc3_gadget_kick_transfer(dep);
}