From 6297328964024b288d1d8a2e8752bad048d72acb Mon Sep 17 00:00:00 2001 From: Ram Chandrasekar Date: Tue, 26 Feb 2019 12:42:08 -0700 Subject: [PATCH 1/2] cpufreq: qcom-hw: Add ready callback to register CPU cooling device Add a ready callback, which will be called when a CPU policy is ready. As a part of this callback, register the corresponding CPU cooling device. Change-Id: Ic12e0a8f7cd13fda583844454e3a0eb600a2cad3 Signed-off-by: Ram Chandrasekar --- drivers/cpufreq/qcom-cpufreq-hw.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index 612b878692ad..e37d049be849 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -12,6 +12,7 @@ #include #include #include +#include #define LUT_MAX_ENTRIES 40U #define CORE_COUNT_VAL(val) (((val) & (GENMASK(18, 16))) >> 16) @@ -178,6 +179,35 @@ static struct freq_attr *qcom_cpufreq_hw_attr[] = { NULL }; +static void qcom_cpufreq_ready(struct cpufreq_policy *policy) +{ + static struct thermal_cooling_device *cdev[NR_CPUS]; + struct device_node *np; + unsigned int cpu = policy->cpu; + + if (cdev[cpu]) + return; + + np = of_cpu_device_node_get(cpu); + if (WARN_ON(!np)) + return; + + /* + * For now, just loading the cooling device; + * thermal DT code takes care of matching them. + */ + if (of_find_property(np, "#cooling-cells", NULL)) { + cdev[cpu] = of_cpufreq_cooling_register(policy); + if (IS_ERR(cdev[cpu])) { + pr_err("running cpufreq for CPU%d without cooling dev: %ld\n", + cpu, PTR_ERR(cdev[cpu])); + cdev[cpu] = NULL; + } + } + + of_node_put(np); +} + static struct cpufreq_driver cpufreq_qcom_hw_driver = { .flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK | CPUFREQ_HAVE_GOVERNOR_PER_POLICY, @@ -189,6 +219,7 @@ static struct cpufreq_driver cpufreq_qcom_hw_driver = { .name = "qcom-cpufreq-hw", .attr = qcom_cpufreq_hw_attr, .boost_enabled = true, + .ready = qcom_cpufreq_ready, }; static int qcom_cpufreq_hw_read_lut(struct platform_device *pdev, From 614bbc4d3bf9d521c3e9a5e2fda69de4b1296563 Mon Sep 17 00:00:00 2001 From: David Dai Date: Mon, 1 Apr 2019 16:08:45 -0700 Subject: [PATCH 2/2] cpufreq: qcom-hw: use no_log when reading cpu counter val Use the no_log version of readl_relaxed when reading out the counter values for CPUs to reduce the amount of logging in RTB Logs. Scheduler activity is very frequent and clogs up the buffer, which can potentially reduce the amount of useful logs. Change-Id: Ib5c7595c8bae1822837c3b1f1ae56fdc3c612933 Signed-off-by: David Dai --- drivers/cpufreq/qcom-cpufreq-hw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index e37d049be849..61af15e3ae2a 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -71,7 +71,8 @@ static u64 qcom_cpufreq_get_cpu_cycle_counter(int cpu) spin_lock_irqsave(&cpu_counter->lock, flags); offset = CYCLE_CNTR_OFFSET(cpu, &cpu_domain->related_cpus); - val = readl_relaxed(cpu_domain->reg_bases[REG_CYCLE_CNTR] + offset); + val = readl_relaxed_no_log(cpu_domain->reg_bases[REG_CYCLE_CNTR] + + offset); if (val < cpu_counter->prev_cycle_counter) { /* Handle counter overflow */