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

Commit 558baca9 authored by Mayank Rana's avatar Mayank Rana
Browse files

dwc3: gadget: Use dbg_event() API to capture important events



This change uses dbg_event() API to capture important events to
improve debugging.

Change-Id: I6ccd9ceb586fd963359861151f9166eb80f9cf92
Signed-off-by: default avatarMayank Rana <mrana@codeaurora.org>
parent 861da2b5
Loading
Loading
Loading
Loading
+47 −3
Original line number Diff line number Diff line
@@ -505,6 +505,7 @@ static void dwc3_free_trb_pool(struct dwc3_ep *dep)
	if (dep->number > 1 && dep->trb_pool && dep->trb_pool_dma) {
		memset(&dep->trb_pool[0], 0,
			sizeof(struct dwc3_trb) * dep->num_trbs);
		dbg_event(dep->number, "Clr_TRB", 0);
		dev_dbg(dwc->dev, "Clr_TRB ring of %s\n", dep->name);

		dma_free_coherent(dwc->dev,
@@ -837,6 +838,7 @@ static int dwc3_gadget_ep_enable(struct usb_ep *ep,

	spin_lock_irqsave(&dwc->lock, flags);
	ret = __dwc3_gadget_ep_enable(dep, desc, ep->comp_desc, false, false);
	dbg_event(dep->number, "ENABLE", ret);
	spin_unlock_irqrestore(&dwc->lock, flags);

	return ret;
@@ -871,6 +873,7 @@ static int dwc3_gadget_ep_disable(struct usb_ep *ep)

	spin_lock_irqsave(&dwc->lock, flags);
	ret = __dwc3_gadget_ep_disable(dep);
	dbg_event(dep->number, "DISABLE", ret);
	spin_unlock_irqrestore(&dwc->lock, flags);

	return ret;
@@ -1124,6 +1127,7 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep, u16 cmd_param)
	req = next_request(&dep->started_list);
	if (!req) {
		dep->flags |= DWC3_EP_PENDING_REQUEST;
		dbg_event(dep->number, "NO REQ", 0);
		return 0;
	}

@@ -1166,6 +1170,7 @@ static void __dwc3_gadget_start_isoc(struct dwc3 *dwc,
		struct dwc3_ep *dep, u32 cur_uf)
{
	u32 uf;
	int ret;

	if (list_empty(&dep->pending_list)) {
		dwc3_trace(trace_dwc3_gadget,
@@ -1178,7 +1183,9 @@ static void __dwc3_gadget_start_isoc(struct dwc3 *dwc,
	/* 4 micro frames in the future */
	uf = cur_uf + dep->interval * 4;

	__dwc3_gadget_kick_transfer(dep, uf);
	ret = __dwc3_gadget_kick_transfer(dep, uf);
	if (ret < 0)
		dbg_event(dep->number, "ISOC QUEUE", ret);
}

static void dwc3_gadget_start_isoc(struct dwc3 *dwc,
@@ -1404,6 +1411,7 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
	}

out1:
	dbg_event(dep->number, "DEQUEUE", 0);
	/* giveback the request */
	dwc3_gadget_giveback(dep, req, -ECONNRESET);

@@ -1425,7 +1433,7 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol)
	}

	memset(&params, 0x00, sizeof(params));

	dbg_event(dep->number, "HALT", value);
	if (value) {
		struct dwc3_trb *trb;

@@ -1497,6 +1505,7 @@ static int dwc3_gadget_ep_set_wedge(struct usb_ep *ep)
	int				ret;

	spin_lock_irqsave(&dwc->lock, flags);
	dbg_event(dep->number, "WEDGE", 0);
	dep->flags |= DWC3_EP_WEDGE;

	if (dep->number == 0 || dep->number == 1)
@@ -1652,6 +1661,8 @@ static void dwc3_gadget_wakeup_work(struct work_struct *w)
		}
	}
	retry_count = 0;
	dbg_event(0xFF, "Gdgwake gsyn",
		atomic_read(&dwc->dev->power.usage_count));

	ret = dwc3_gadget_wakeup_int(dwc);

@@ -1661,6 +1672,8 @@ static void dwc3_gadget_wakeup_work(struct work_struct *w)
		pr_debug("Remote wakeup succeeded.\n");

	pm_runtime_put_noidle(dwc->dev);
	dbg_event(0xFF, "Gdgwake put",
		atomic_read(&dwc->dev->power.usage_count));
}

static int dwc3_gadget_wakeup_int(struct dwc3 *dwc)
@@ -1843,6 +1856,7 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend)

	reg = dwc3_readl(dwc->regs, DWC3_DCTL);
	if (is_on) {
		dbg_event(0xFF, "Pullup_enable", is_on);
		if (dwc->revision <= DWC3_REVISION_187A) {
			reg &= ~DWC3_DCTL_TRGTULST_MASK;
			reg |= DWC3_DCTL_TRGTULST_RX_DET;
@@ -1861,6 +1875,7 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend)

		dwc->pullups_connected = true;
	} else {
		dbg_event(0xFF, "Pullup_disable", is_on);
		dwc3_gadget_disable_irq(dwc);
		__dwc3_gadget_ep_disable(dwc->eps[0]);
		__dwc3_gadget_ep_disable(dwc->eps[1]);
@@ -1883,6 +1898,10 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend)
	if (!timeout) {
		dev_err(dwc->dev, "failed to %s controller\n",
				is_on ? "start" : "stop");
		if (is_on)
			dbg_event(0xFF, "STARTTOUT", reg);
		else
			dbg_event(0xFF, "STOPTOUT", reg);
		return -ETIMEDOUT;
	}

@@ -1900,6 +1919,7 @@ static int dwc3_gadget_vbus_draw(struct usb_gadget *g, unsigned int mA)

	dwc->vbus_draw = mA;
	dev_dbg(dwc->dev, "Notify controller from %s. mA = %u\n", __func__, mA);
	dbg_event(0xFF, "currentDraw", mA);
	dwc3_notify_event(dwc, DWC3_CONTROLLER_SET_CURRENT_DRAW_EVENT);
	return 0;
}
@@ -1917,10 +1937,13 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
		 * Need to wait for vbus_session(on) from otg driver or to
		 * the udc_start.
		 */
		dbg_event(0xFF, "WaitPullup", 0);
		return 0;
	}

	pm_runtime_get_sync(dwc->dev);
	dbg_event(0xFF, "Pullup gsync",
		atomic_read(&dwc->dev->power.usage_count));
	spin_lock_irqsave(&dwc->lock, flags);
	/*
	 * If we are here after bus suspend notify otg state machine to
@@ -1934,7 +1957,8 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)

	pm_runtime_mark_last_busy(dwc->dev);
	pm_runtime_put_autosuspend(dwc->dev);

	dbg_event(0xFF, "Pullup put",
		atomic_read(&dwc->dev->power.usage_count));
	return ret;
}

@@ -1942,6 +1966,7 @@ void dwc3_gadget_enable_irq(struct dwc3 *dwc)
{
	u32			reg;

	dbg_event(0xFF, "UnmaskINT", 0);
	/* Enable all but Start and End of Frame IRQs */
	reg = (DWC3_DEVTEN_VNDRDEVTSTRCVEDEN |
			DWC3_DEVTEN_EVNTOVERFLOWEN |
@@ -1966,6 +1991,7 @@ void dwc3_gadget_enable_irq(struct dwc3 *dwc)

void dwc3_gadget_disable_irq(struct dwc3 *dwc)
{
	dbg_event(0xFF, "MaskINT", 0);
	/* mask all interrupts */
	dwc3_writel(dwc->regs, DWC3_DEVTEN, 0x00);
}
@@ -2024,6 +2050,7 @@ static int dwc3_gadget_vbus_session(struct usb_gadget *_gadget, int is_active)

	is_active = !!is_active;

	dbg_event(0xFF, "VbusSess", is_active);
	spin_lock_irqsave(&dwc->lock, flags);

	/* Mark that the vbus was powered */
@@ -2064,6 +2091,7 @@ static int __dwc3_gadget_start(struct dwc3 *dwc)
	int			ret = 0;
	u32			reg;

	dbg_event(0xFF, "__Gadgetstart", 0);
	reg = dwc3_readl(dwc->regs, DWC3_DCFG);
	reg &= ~(DWC3_DCFG_SPEED_MASK);

@@ -2195,6 +2223,7 @@ static int dwc3_gadget_start(struct usb_gadget *g,

static void __dwc3_gadget_stop(struct dwc3 *dwc)
{
	dbg_event(0xFF, "__Gadgetstop", 0);
	dwc3_gadget_disable_irq(dwc);
	__dwc3_gadget_ep_disable(dwc->eps[0]);
	__dwc3_gadget_ep_disable(dwc->eps[1]);
@@ -2216,6 +2245,7 @@ static int dwc3_gadget_restart_usb_session(struct usb_gadget *g)
{
	struct dwc3		*dwc = gadget_to_dwc(g);

	dbg_event(0xFF, "RestartUSBSession", 0);
	return dwc3_notify_event(dwc, DWC3_CONTROLLER_RESTART_USB_SESSION);
}

@@ -2432,6 +2462,7 @@ static int __dwc3_cleanup_done_trbs(struct dwc3 *dwc, struct dwc3_ep *dep,
				 * request in the pending_list.
				 */
				dep->flags |= DWC3_EP_MISSED_ISOC;
				dbg_event(dep->number, "MISSED ISOC", status);
			} else {
				dev_err(dwc->dev, "incomplete IN transfer %s\n",
						dep->name);
@@ -2703,6 +2734,7 @@ static void dwc3_disconnect_gadget(struct dwc3 *dwc)
{
	if (dwc->gadget_driver && dwc->gadget_driver->disconnect) {
		spin_unlock(&dwc->lock);
		dbg_event(0xFF, "DISCONNECT", 0);
		dwc->gadget_driver->disconnect(&dwc->gadget);
		spin_lock(&dwc->lock);
	}
@@ -2712,6 +2744,7 @@ static void dwc3_suspend_gadget(struct dwc3 *dwc)
{
	if (dwc->gadget_driver && dwc->gadget_driver->suspend) {
		spin_unlock(&dwc->lock);
		dbg_event(0xFF, "SUSPEND", 0);
		dwc->gadget_driver->suspend(&dwc->gadget);
		spin_lock(&dwc->lock);
	}
@@ -2721,6 +2754,7 @@ static void dwc3_resume_gadget(struct dwc3 *dwc)
{
	if (dwc->gadget_driver && dwc->gadget_driver->resume) {
		spin_unlock(&dwc->lock);
		dbg_event(0xFF, "RESUME", 0);
		dwc->gadget_driver->resume(&dwc->gadget);
		spin_lock(&dwc->lock);
	}
@@ -2733,6 +2767,7 @@ static void dwc3_reset_gadget(struct dwc3 *dwc)

	if (dwc->gadget.speed != USB_SPEED_UNKNOWN) {
		spin_unlock(&dwc->lock);
		dbg_event(0xFF, "UDC RESET", 0);
		usb_gadget_udc_reset(&dwc->gadget, dwc->gadget_driver);
		spin_lock(&dwc->lock);
	}
@@ -2831,6 +2866,7 @@ static void dwc3_clear_stall_all_ep(struct dwc3 *dwc)
		dep->flags &= ~DWC3_EP_STALL;

		ret = dwc3_send_clear_stall_ep_cmd(dep);
		dbg_event(dep->number, "ECLRSTALL", ret);
		WARN_ON_ONCE(ret);
	}
}
@@ -2839,6 +2875,7 @@ static void dwc3_gadget_disconnect_interrupt(struct dwc3 *dwc)
{
	int			reg;

	dbg_event(0xFF, "DISCONNECT INT", 0);
	dev_dbg(dwc->dev, "Notify OTG from %s\n", __func__);
	dwc->b_suspend = false;
	dwc3_notify_event(dwc, DWC3_CONTROLLER_NOTIFY_OTG_EVENT);
@@ -2898,6 +2935,7 @@ static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc)
			dwc3_gadget_disconnect_interrupt(dwc);
	}

	dbg_event(0xFF, "BUS RESET", 0);
	dev_dbg(dwc->dev, "Notify OTG from %s\n", __func__);
	dwc->b_suspend = false;
	dwc3_notify_event(dwc, DWC3_CONTROLLER_NOTIFY_OTG_EVENT);
@@ -2961,6 +2999,7 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc)
	u32			reg;
	u8			speed;

	dbg_event(0xFF, "CONNECT DONE", 0);
	reg = dwc3_readl(dwc->regs, DWC3_DSTS);
	speed = reg & DWC3_DSTS_CONNECTSPD;
	dwc->speed = speed;
@@ -3084,6 +3123,7 @@ static void dwc3_gadget_wakeup_interrupt(struct dwc3 *dwc, bool remote_wakeup)

	dev_dbg(dwc->dev, "%s\n", __func__);

	dbg_event(0xFF, "WAKEUP", remote_wakeup);
	/*
	 * Identify if it is called from wakeup_interrupt() context for bus
	 * resume or as part of remote wakeup. And based on that check for
@@ -3224,6 +3264,7 @@ static void dwc3_gadget_suspend_interrupt(struct dwc3 *dwc,
{
	enum dwc3_link_state    next = evtinfo & DWC3_LINK_STATE_MASK;

	dbg_event(0xFF, "SUSPEND INT", 0);
	dev_dbg(dwc->dev, "%s Entry to %d\n", __func__, next);

	if (dwc->link_state != next && next == DWC3_LINK_STATE_U3) {
@@ -3313,6 +3354,7 @@ static void dwc3_gadget_interrupt(struct dwc3 *dwc,
			dwc->dbg_gadget_events.eopf++;
		} else {
			dwc3_trace(trace_dwc3_gadget, "U3/L1-L2 Suspend Event");
			dbg_event(0xFF, "GAD SUS", 0);
			dwc->dbg_gadget_events.suspend++;
			/*
			 * Ignore suspend event until the gadget enters into
@@ -3329,6 +3371,7 @@ static void dwc3_gadget_interrupt(struct dwc3 *dwc,
		break;
	case DWC3_DEVICE_EVENT_ERRATIC_ERROR:
		dwc3_trace(trace_dwc3_gadget, "Erratic Error");
		dbg_event(0xFF, "ERROR", 0);
		dwc->dbg_gadget_events.erratic_error++;
		break;
	case DWC3_DEVICE_EVENT_CMD_CMPL:
@@ -3479,6 +3522,7 @@ static irqreturn_t dwc3_check_event_buf(struct dwc3 *dwc)

	if (count > evt->length) {
		dev_err(dwc->dev, "HUGE_EVCNT(%d)", count);
		dbg_event(0xFF, "HUGE_EVCNT", count);
		evt->lpos = (evt->lpos + count) % DWC3_EVENT_BUFFERS_SIZE;
		dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), count);
		return IRQ_HANDLED;