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));