From b67959cb83dd96df13c16234390b4199a0cfbe46 Mon Sep 17 00:00:00 2001 From: Vivek Aknurwar Date: Thu, 3 Mar 2022 11:08:37 -0800 Subject: [PATCH] cpufreq: qcom-hw: Add trace for irq and throttle freq polling Add trace events in irq handler and throttle frequency polling to capture DCVSH updates to sched and or when lmh irq is high. Change-Id: I96c1af1abeb24971b8d060457feee1dbadcdb028 Signed-off-by: Vivek Aknurwar Signed-off-by: Mike Tipton --- drivers/cpufreq/qcom-cpufreq-hw.c | 14 ++++++- include/trace/events/dcvsh.h | 63 +++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 include/trace/events/dcvsh.h diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index 3d077c644624..a63c58cf8408 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -17,6 +17,9 @@ #include #include +#define CREATE_TRACE_POINTS +#include + #define LUT_MAX_ENTRIES 40U #define LUT_SRC GENMASK(31, 30) #define LUT_L_VAL GENMASK(7, 0) @@ -379,6 +382,8 @@ static void qcom_lmh_dcvs_notify(struct qcom_cpufreq_data *data) } else { throttled_freq = freq_hz / HZ_PER_KHZ; + trace_dcvsh_freq(cpu, qcom_cpufreq_hw_get(cpu), throttled_freq); + /* Update thermal pressure (the boost frequencies are accepted) */ arch_update_thermal_pressure(policy->related_cpus, throttled_freq); @@ -397,11 +402,13 @@ static void qcom_lmh_dcvs_notify(struct qcom_cpufreq_data *data) * If h/w throttled frequency is higher than what cpufreq has requested * for, then stop polling and switch back to interrupt mechanism. */ - if (throttled_freq >= qcom_cpufreq_hw_get(cpu)) + if (throttled_freq >= qcom_cpufreq_hw_get(cpu)) { enable_irq(data->throttle_irq); - else + trace_dcvsh_throttle(cpu, 0); + } else { mod_delayed_work(system_highpri_wq, &data->throttle_work, msecs_to_jiffies(10)); + } out: mutex_unlock(&data->throttle_lock); @@ -418,9 +425,11 @@ static void qcom_lmh_dcvs_poll(struct work_struct *work) static irqreturn_t qcom_lmh_dcvs_handle_irq(int irq, void *data) { struct qcom_cpufreq_data *c_data = data; + struct cpufreq_policy *policy = c_data->policy; /* Disable interrupt and enable polling */ disable_irq_nosync(c_data->throttle_irq); + trace_dcvsh_throttle(cpumask_first(policy->cpus), 1); schedule_delayed_work(&c_data->throttle_work, 0); if (c_data->soc_data->reg_intr_clr) @@ -532,6 +541,7 @@ static int qcom_cpufreq_hw_cpu_offline(struct cpufreq_policy *policy) irq_set_affinity_hint(data->throttle_irq, NULL); arch_update_thermal_pressure(policy->related_cpus, U32_MAX); + trace_dcvsh_throttle(cpumask_first(policy->related_cpus), 0); return 0; } diff --git a/include/trace/events/dcvsh.h b/include/trace/events/dcvsh.h new file mode 100644 index 000000000000..54c72bbc7aca --- /dev/null +++ b/include/trace/events/dcvsh.h @@ -0,0 +1,63 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved. + */ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM dcvsh + +#if !defined(_TRACE_DCVSH_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_DCVSH_H + +#include + +TRACE_EVENT(dcvsh_freq, + + TP_PROTO(unsigned long cpu, unsigned long req_freq, + unsigned long throttled_freq), + + TP_ARGS(cpu, req_freq, throttled_freq), + + TP_STRUCT__entry( + __field(unsigned long, cpu) + __field(unsigned long, req_freq) + __field(unsigned long, throttled_freq) + ), + + TP_fast_assign( + __entry->cpu = cpu; + __entry->req_freq = req_freq; + __entry->throttled_freq = throttled_freq; + ), + + TP_printk("cpu:%lu requested_freq:%lu throttled_freq:%lu", + __entry->cpu, + __entry->req_freq, + __entry->throttled_freq) +); + +TRACE_EVENT(dcvsh_throttle, + + TP_PROTO(unsigned long cpu, bool state), + + TP_ARGS(cpu, state), + + TP_STRUCT__entry( + __field(unsigned long, cpu) + __field(bool, state) + ), + + TP_fast_assign( + __entry->cpu = cpu; + __entry->state = state; + ), + + TP_printk("cpu:%lu throttle_%s", + __entry->cpu, + __entry->state ? "begin" : "end") +); + +#endif /* _TRACE_DCVSH_H */ + +/* This part must be outside protection */ +#include