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

Commit 07e8d9ef authored by Vamsi Krishna's avatar Vamsi Krishna
Browse files

dwc3: gadget: Fix incorrect handling of zlp when sg is enabled



Driver inserts zlp (zero length packet) in the middle of chained
trbs resulting in invalid packet. This is observed during rndis
data transfers when scatter and gather is enabled. It results
in invalid ip packet followed by stall.

Change-Id: I5731b5952f683c069772b4552a53d8c388521ff7
Signed-off-by: default avatarVamsi Krishna <vskrishn@codeaurora.org>
parent f849fcfc
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -862,6 +862,8 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep,
{
	struct dwc3		*dwc = dep->dwc;
	struct dwc3_trb		*trb;
	bool			zlp_appended = false;
	unsigned		rlen;

	dev_vdbg(dwc->dev, "%s: req %p dma %08llx length %d%s%s\n",
			dep->name, req, (unsigned long long) dma,
@@ -929,13 +931,18 @@ update_trb:

	trb->ctrl |= DWC3_TRB_CTRL_HWO;

	if (req->request.zero && length &&
			(length % usb_endpoint_maxp(dep->endpoint.desc) == 0)) {
	rlen = req->request.length;
	if (!zlp_appended && !chain &&
		req->request.zero && rlen &&
		(rlen % usb_endpoint_maxp(dep->endpoint.desc) == 0)) {

		zlp_appended = true;
		/* Skip the LINK-TRB on ISOC */
		if (((dep->free_slot & DWC3_TRB_MASK) == DWC3_TRB_NUM - 1) &&
			usb_endpoint_xfer_isoc(dep->endpoint.desc))
			dep->free_slot++;

		trb->ctrl |= DWC3_TRB_CTRL_CHN;
		trb = &dep->trb_pool[dep->free_slot & DWC3_TRB_MASK];
		dep->free_slot++;