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

Commit e53f9c37 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "usb: dwc3: dwc3-msm: optimize perf vote work"

parents 191df0c7 3015fd7f
Loading
Loading
Loading
Loading
+10 −9
Original line number Diff line number Diff line
@@ -341,6 +341,7 @@ struct dwc3_msm {
	u32			num_gsi_event_buffers;
	struct dwc3_event_buffer **gsi_ev_buff;
	int pm_qos_latency;
	bool			perf_mode;
	struct pm_qos_request pm_qos_req_dma;
	struct delayed_work perf_vote_work;
	struct delayed_work sdp_check;
@@ -2012,8 +2013,7 @@ static void dwc3_msm_notify_event(struct dwc3 *dwc, unsigned int event,
	switch (event) {
	case DWC3_CONTROLLER_ERROR_EVENT:
		dev_info(mdwc->dev,
			"DWC3_CONTROLLER_ERROR_EVENT received, irq cnt %lu\n",
			dwc->irq_cnt);
			"DWC3_CONTROLLER_ERROR_EVENT received\n");

		dwc3_gadget_disable_irq(dwc);

@@ -4114,6 +4114,7 @@ static int dwc3_msm_remove(struct platform_device *pdev)
	}

	cancel_delayed_work_sync(&mdwc->perf_vote_work);
	msm_dwc3_perf_vote_update(mdwc, false);
	cancel_delayed_work_sync(&mdwc->sm_work);

	if (mdwc->hs_phy)
@@ -4208,10 +4209,12 @@ static int dwc3_msm_host_notifier(struct notifier_block *nb,

static void msm_dwc3_perf_vote_update(struct dwc3_msm *mdwc, bool perf_mode)
{
	static bool curr_perf_mode;
	int latency = mdwc->pm_qos_latency;
	struct dwc3 *dwc = platform_get_drvdata(mdwc->dwc3);

	dwc->irq_cnt = 0;

	if ((curr_perf_mode == perf_mode) || !latency)
	if ((mdwc->perf_mode == perf_mode) || !latency)
		return;

	if (perf_mode)
@@ -4220,7 +4223,7 @@ static void msm_dwc3_perf_vote_update(struct dwc3_msm *mdwc, bool perf_mode)
		pm_qos_update_request(&mdwc->pm_qos_req_dma,
						PM_QOS_DEFAULT_VALUE);

	curr_perf_mode = perf_mode;
	mdwc->perf_mode = perf_mode;
	pr_debug("%s: latency updated to: %d\n", __func__,
			perf_mode ? latency : PM_QOS_DEFAULT_VALUE);
}
@@ -4230,16 +4233,14 @@ static void msm_dwc3_perf_vote_work(struct work_struct *w)
	struct dwc3_msm *mdwc = container_of(w, struct dwc3_msm,
						perf_vote_work.work);
	struct dwc3 *dwc = platform_get_drvdata(mdwc->dwc3);
	static unsigned long	last_irq_cnt;
	bool in_perf_mode = false;

	if (dwc->irq_cnt - last_irq_cnt >= PM_QOS_THRESHOLD)
	if (dwc->irq_cnt >= PM_QOS_THRESHOLD)
		in_perf_mode = true;

	pr_debug("%s: in_perf_mode:%u, interrupts in last sample:%lu\n",
		 __func__, in_perf_mode, (dwc->irq_cnt - last_irq_cnt));
		 __func__, in_perf_mode, dwc->irq_cnt);

	last_irq_cnt = dwc->irq_cnt;
	msm_dwc3_perf_vote_update(mdwc, in_perf_mode);
	schedule_delayed_work(&mdwc->perf_vote_work,
			msecs_to_jiffies(1000 * PM_QOS_SAMPLE_SEC));