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

Commit a43f2494 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "usb: dwc3: Allocate TRB pool upon enabling endpoint"

parents 63d0d695 ac5594b0
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -738,6 +738,8 @@ static int dwc3_ep_trbs_show(struct seq_file *s, void *unused)

	spin_lock_irqsave(&dwc->lock, flags);
	dep = dwc->eps[ep_num];
	if (!dep->trb_pool)
		return 0;

	seq_printf(s, "%s trb pool: flags:0x%x freeslot:%d busyslot:%d\n",
		dep->name, dep->flags, dep->free_slot, dep->busy_slot);
+9 −15
Original line number Diff line number Diff line
@@ -392,7 +392,7 @@ static int dwc3_alloc_trb_pool(struct dwc3_ep *dep)

	dep->trb_pool = dma_zalloc_coherent(dwc->dev,
			sizeof(struct dwc3_trb) * DWC3_TRB_NUM,
			&dep->trb_pool_dma, GFP_KERNEL);
			&dep->trb_pool_dma, GFP_ATOMIC);
	if (!dep->trb_pool) {
		dev_err(dep->dwc->dev, "failed to allocate trb pool for %s\n",
				dep->name);
@@ -642,13 +642,6 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep)
	dep->type = 0;
	dep->flags = 0;

	/*
	 * Clean up ep ring to avoid getting xferInProgress due to stale trbs
	 * with HWO bit set from previous composition when update transfer cmd
	 * is issued.
	 */
	memset(&dep->trb_pool[0], 0, sizeof(struct dwc3_trb) * DWC3_TRB_NUM);
	dbg_event(dep->number, "Clr_TRB", 0);
	return 0;
}

@@ -712,6 +705,10 @@ static int dwc3_gadget_ep_enable(struct usb_ep *ep,
		dev_err(dwc->dev, "invalid endpoint transfer type\n");
	}

	ret = dwc3_alloc_trb_pool(dep);
	if (ret)
		return ret;

	spin_lock_irqsave(&dwc->lock, flags);
	ret = __dwc3_gadget_ep_enable(dep, desc, ep->comp_desc, false, false);
	dbg_event(dep->number, "ENABLE", ret);
@@ -750,6 +747,8 @@ static int dwc3_gadget_ep_disable(struct usb_ep *ep)
	dbg_event(dep->number, "DISABLE", ret);
	spin_unlock_irqrestore(&dwc->lock, flags);

	dwc3_free_trb_pool(dep);

	return ret;
}

@@ -2257,17 +2256,11 @@ static int dwc3_gadget_init_hw_endpoints(struct dwc3 *dwc,
			if (!epnum)
				dwc->gadget.ep0 = &dep->endpoint;
		} else {
			int		ret;

			usb_ep_set_maxpacket_limit(&dep->endpoint, 1024);
			dep->endpoint.max_streams = 15;
			dep->endpoint.ops = &dwc3_gadget_ep_ops;
			list_add_tail(&dep->endpoint.ep_list,
					&dwc->gadget.ep_list);

			ret = dwc3_alloc_trb_pool(dep);
			if (ret)
				return ret;
		}

		INIT_LIST_HEAD(&dep->request_list);
@@ -2317,6 +2310,7 @@ static void dwc3_gadget_free_endpoints(struct dwc3 *dwc)
		 * with all sorts of bugs when removing dwc3.ko.
		 */
		if (epnum != 0 && epnum != 1) {
			if (dep->trb_pool)
				dwc3_free_trb_pool(dep);
			list_del(&dep->endpoint.ep_list);
		}