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 <quic_viveka@quicinc.com>
Signed-off-by: Mike Tipton <quic_mdtipton@quicinc.com>
This commit is contained in:
Vivek Aknurwar 2022-03-03 11:08:37 -08:00 committed by Mike Tipton
parent 0785922904
commit b67959cb83
2 changed files with 75 additions and 2 deletions

View File

@ -17,6 +17,9 @@
#include <linux/spinlock.h>
#include <linux/qcom-cpufreq-hw.h>
#define CREATE_TRACE_POINTS
#include <trace/events/dcvsh.h>
#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;
}

View File

@ -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 <linux/tracepoint.h>
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 <trace/define_trace.h>