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

Commit c81b6442 authored by Mayank Rana's avatar Mayank Rana
Browse files

dwc3: Disable USB Link state(U1/U2) change events



Currently all USB Link state change events are enable which are
triggering huge number of interrupts to the cpu. Disable U1/U2 Link
state entry/exit events by using dwc_usb3_devten register. Below is
one of test results showing the same.
Test case: Run tethered RMNET UDP UL/DL Modem looback with 50M bandwidth
Test duration: 120 seconds
Test Results :
- with USB Link state change events enable:
CPU Idle : 42%, Number of USB Link state change events: 3769013
- with USB Link state change events disable:
CPU Idle : 51%, Number of USB Link state change events: 0
These numbers (cpu usage, number of interrupts) are taken for
120 seconds duration of test execution.

This change also does enable U3L2L1SuspEn event (BIT:6)  to get U3
notification and handling suspend part. Wakeup event is already enabled
which takes care of USB resuming.

CRs-Fixed: 610718
Change-Id: Ied6da6699849a3136a35de0b9a27ee18086daeab
Signed-off-by: default avatarMayank Rana <mrana@codeaurora.org>
parent 1ab4f819
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -71,6 +71,8 @@
#define DWC3_DEVICE_EVENT_WAKEUP		4
#define DWC3_DEVICE_EVENT_HIBER_REQ		5
#define DWC3_DEVICE_EVENT_EOPF			6
/* For version 2.30a and above */
#define DWC3_DEVICE_EVENT_SUSPEND		6
#define DWC3_DEVICE_EVENT_SOF			7
#define DWC3_DEVICE_EVENT_ERRATIC_ERROR		9
#define DWC3_DEVICE_EVENT_CMD_CMPL		10
@@ -289,6 +291,8 @@
#define DWC3_DEVTEN_ERRTICERREN		(1 << 9)
#define DWC3_DEVTEN_SOFEN		(1 << 7)
#define DWC3_DEVTEN_EOPFEN		(1 << 6)
/* For version 2.30a and above*/
#define DWC3_DEVTEN_SUSPEND		(1 << 6)
#define DWC3_DEVTEN_HIBERNATIONREQEVTEN	(1 << 5)
#define DWC3_DEVTEN_WKUPEVTEN		(1 << 4)
#define DWC3_DEVTEN_ULSTCNGEN		(1 << 3)
+9 −3
Original line number Diff line number Diff line
@@ -1115,13 +1115,19 @@ static void dwc3_block_reset_usb_work(struct work_struct *w)
			DWC3_DEVTEN_CMDCMPLTEN |
			DWC3_DEVTEN_ERRTICERREN |
			DWC3_DEVTEN_WKUPEVTEN |
			DWC3_DEVTEN_ULSTCNGEN |
			DWC3_DEVTEN_CONNECTDONEEN |
			DWC3_DEVTEN_USBRSTEN |
			DWC3_DEVTEN_DISCONNEVTEN);
	dwc3_msm_write_reg(mdwc->base, DWC3_DEVTEN, reg);

	/*
	 * Enable SUSPENDEVENT(BIT:6) for version 230A and above
	 * else enable USB Link change event (BIT:3) for older version
	 */
	if (dwc3_msm_read_reg(mdwc->base, DWC3_GSNPSID) < DWC3_REVISION_230A)
		reg |= DWC3_DEVTEN_ULSTCNGEN;
	else
		reg |= DWC3_DEVTEN_SUSPEND;

	dwc3_msm_write_reg(mdwc->base, DWC3_DEVTEN, reg);
}

static void dwc3_chg_enable_secondary_det(struct dwc3_msm *mdwc)
+28 −10
Original line number Diff line number Diff line
@@ -1725,11 +1725,19 @@ static void dwc3_gadget_enable_irq(struct dwc3 *dwc)
			DWC3_DEVTEN_CMDCMPLTEN |
			DWC3_DEVTEN_ERRTICERREN |
			DWC3_DEVTEN_WKUPEVTEN |
			DWC3_DEVTEN_ULSTCNGEN |
			DWC3_DEVTEN_CONNECTDONEEN |
			DWC3_DEVTEN_USBRSTEN |
			DWC3_DEVTEN_DISCONNEVTEN);

	/*
	 * Enable SUSPENDEVENT(BIT:6) for version 230A and above
	 * else enable USB Link change event (BIT:3) for older version
	 */
	if (dwc->revision < DWC3_REVISION_230A)
		reg |= DWC3_DEVTEN_ULSTCNGEN;
	else
		reg |= DWC3_DEVTEN_SUSPEND;

	dwc3_writel(dwc->regs, DWC3_DEVTEN, reg);
}

@@ -2801,18 +2809,22 @@ static void dwc3_gadget_linksts_change_interrupt(struct dwc3 *dwc,
		}
	}

	if (next == DWC3_LINK_STATE_U0) {
		if (dwc->link_state == DWC3_LINK_STATE_U3) {
			dbg_event(0xFF, "RESUME", 0);
			dwc->gadget_driver->resume(&dwc->gadget);
	dwc->link_state = next;

	dev_vdbg(dwc->dev, "%s link %d\n", __func__, dwc->link_state);
}
	} else if (next == DWC3_LINK_STATE_U3) {

static void dwc3_gadget_suspend_interrupt(struct dwc3 *dwc,
			unsigned int evtinfo)
{
	enum dwc3_link_state    next = evtinfo & DWC3_LINK_STATE_MASK;

	if (next == DWC3_LINK_STATE_U3) {
		dbg_event(0xFF, "SUSPEND", 0);
		dwc->gadget_driver->suspend(&dwc->gadget);
	}

	dwc->link_state = next;

	dev_vdbg(dwc->dev, "%s link %d\n", __func__, dwc->link_state);
}

@@ -2861,8 +2873,14 @@ static void dwc3_gadget_interrupt(struct dwc3 *dwc,
	case DWC3_DEVICE_EVENT_LINK_STATUS_CHANGE:
		dwc3_gadget_linksts_change_interrupt(dwc, event->event_info);
		break;
	case DWC3_DEVICE_EVENT_EOPF:
	case DWC3_DEVICE_EVENT_SUSPEND:
		if (dwc->revision < DWC3_REVISION_230A) {
			dev_vdbg(dwc->dev, "End of Periodic Frame\n");
		} else {
			dev_vdbg(dwc->dev, "U3/L1-L2 Suspend Event\n");
			dbg_event(0xFF, "SUSPEND", 0);
			dwc3_gadget_suspend_interrupt(dwc, event->event_info);
		}
		break;
	case DWC3_DEVICE_EVENT_SOF:
		dev_vdbg(dwc->dev, "Start of Periodic Frame\n");