From 74fd4e30fc565dfbce5b0ce1ce56c0c42696338a Mon Sep 17 00:00:00 2001 From: Vijayavardhan Vennapusa Date: Wed, 26 Apr 2017 11:10:15 +0530 Subject: [PATCH] USB:dwc3-msm: Don't schedule work if pm_qos_latency is zero Currently driver is scheduling pm_qos_work again even though pm_qos_latency is not passed from dts file. Add a check for pm_qos_latency and don't schedule work if pm_qos_latency value is zero. Also remove use of static variable for last_irq_count and add the variable for the same in dwc3 structure for the case where multi DWC3 usages are used. Change-Id: I55e1e3a7d48fbea0a421802aae176ac57a48869f Signed-off-by: Vijayavardhan Vennapusa --- drivers/usb/dwc3/core.h | 2 ++ drivers/usb/dwc3/dwc3-msm.c | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 453eee734b23..1b4fb562ce4b 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -840,6 +840,7 @@ struct dwc3_scratchpad_array { * @irq: irq number * @bh: tasklet which handles the interrupt * @irq_cnt: total irq count + * @last_irq_cnt: last irq count * @bh_completion_time: time taken for taklet completion * @bh_handled_evt_cnt: no. of events handled by tasklet per interrupt * @bh_dbg_index: index for capturing bh_completion_time and bh_handled_evt_cnt @@ -1028,6 +1029,7 @@ struct dwc3 { /* IRQ timing statistics */ int irq; unsigned long irq_cnt; + unsigned long last_irq_cnt; unsigned long ep_cmd_timeout_cnt; unsigned bh_completion_time[MAX_INTR_STATS]; unsigned bh_handled_evt_cnt[MAX_INTR_STATS]; diff --git a/drivers/usb/dwc3/dwc3-msm.c b/drivers/usb/dwc3/dwc3-msm.c index a80fb34cdce8..7bfbbf4f96ec 100644 --- a/drivers/usb/dwc3/dwc3-msm.c +++ b/drivers/usb/dwc3/dwc3-msm.c @@ -3320,16 +3320,19 @@ 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; + int latency = mdwc->pm_qos_latency; - if (dwc->irq_cnt - last_irq_cnt >= PM_QOS_THRESHOLD) + if (!latency) + return; + + if (dwc->irq_cnt - dwc->last_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 - dwc->last_irq_cnt)); - last_irq_cnt = dwc->irq_cnt; + dwc->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));