cpufreq: tegra194: add Tegra264 support
v3 cover cpufreq: tegra194: add Tegra264 support
This series adds cpufreq support for Tegra264, which joins the SoCs already supported by the tegra194-cpufreq driver.
Tegra264 keeps the existing model, where BPMP provides the NDIV limits. The driver derives the current frequency from the core clock and reference counters.
The main differences are:
- Frequency read: through system registers, as on Tegra194, but from the 64-bit architected AMU counters. The reference counter ticks at the system counter rate (CNTFRQ).
- Frequency request: through MMIO, as on Tegra234. The driver writes NDIV to a core_freq_req register in the CCPLEX register space. Each register controls a clock shared by two single-CPU clusters, so both CPUs form one cpufreq policy.
The patches fall into four groups:
- Fix (patch 1): read each CPU's MPIDR from a CPU hotplug callback instead of at probe. A CPU that is offline at probe then also gets valid cluster and core IDs.
- Preparation (patches 2 to 5): cleanups, mostly of the counter code, to make room for a 64-bit counter and for an MMIO mapping without ACTMON counters.
- Improvement (patches 6 and 7): group CPUs by the generic "performance-domains" property, which cluster-based grouping cannot express on Tegra264. Device trees without it keep the existing grouping.
- Tegra264 support (patches 8 and 9): the driver support, followed by the device tree changes it relies on.
v2[2] -> v3:
- Patch 8: read the AMU counters with interrupts disabled (Zhongqiu).
- Add Reviewed-by from Zhongqiu to patches 1-7 and 9.
v1[1] -> v2:
- Patch 1: drop the cpu argument of get_cpu_cluster_id() (Zhongqiu). Check for a bad MPIDR in tegra194_get_speed() (Sashiko).
- Patch 7: check the BPMP table in tegra194_get_speed() (Sashiko).
- Patch 8: fail probe if AMU is not available (Zhongqiu).
Sumit Gupta (9):
cpufreq: tegra194: move MPIDR read to CPU hotplug callback
cpufreq: tegra194: remove duplicate counter sampling loops
cpufreq: tegra194: add tegra_counter_delta helper
cpufreq: tegra194: add per-SoC counter mask
cpufreq: tegra194: split MMIO mapping from ACTMON offset
dt-bindings: arm: nvidia: Document the Tegra264 CCPLEX cluster
cpufreq: tegra194: derive frequency domain from device tree
cpufreq: tegra194: Add support for Tegra264
arm64: tegra: Add CCPLEX cluster node for Tegra264
.../tegra/nvidia,tegra-ccplex-cluster.yaml | 27 +- arch/arm64/boot/dts/nvidia/tegra264.dtsi | 21 + drivers/cpufreq/Kconfig.arm | 4 +- drivers/cpufreq/tegra194-cpufreq.c | 456 +++++++++++++----- 4 files changed, 387 insertions(+), 121 deletions(-)
[1] v1: https://lore.kernel.org/lkml/[email protected]/
[2] v2: https://lore.kernel.org/lkml/[email protected]/
base-commit: e8017d29067fd1310a65c3494ce1a1b492adbac6
Signature · 1 line
2.34.1
PATCH v3 1/9 cpufreq: tegra194: move MPIDR read to CPU hotplug callback
At probe the driver reads the MPIDR of every possible CPU with smp_call_function_single(). For a CPU that is offline at boot, the call fails and the error is ignored. The CPU's core and cluster IDs then come from an uninitialised variable, and the driver later uses them to pick the CPU's registers.
Read MPIDR from a CPU hotplug online callback instead. The callback runs on the target CPU and caches its core and cluster IDs and scratch register address. This covers CPUs online at probe and CPUs onlined later. get_cpu_cluster_id() then needs no CPU argument.
Probe now checks nr_cpu_ids against the SoC data, instead of checking each CPU. A CPU whose MPIDR does not fit the SoC data gets a warning and no scratch register address. The driver reports no frequency for it.
--- drivers/cpufreq/tegra194-cpufreq.c | 128 ++++++++++++++++++++--------- 1 file changed, 89 insertions(+), 39 deletions(-)
drivers/cpufreq/tegra194-cpufreq.c +89 -39
@@ -5,6 +5,7 @@#include <linux/cpu.h> #include <linux/cpufreq.h> +#include <linux/cpuhotplug.h> #include <linux/dma-mapping.h> #include <linux/module.h> #include <linux/of.h>
@@ -13,7 +14,7 @@#include <linux/slab.h> #include <linux/units.h> -#include <asm/smp_plat.h> +#include <asm/cputype.h> #include <soc/tegra/bpmp.h> #include <soc/tegra/bpmp-abi.h>
@@ -59,7 +60,7 @@ struct read_counters_work {struct tegra_cpufreq_ops {void (*read_counters)(struct tegra_cpu_ctr *c);void (*set_cpu_ndiv)(struct cpufreq_policy *policy,u64 ndiv); -void (*get_cpu_cluster_id)(u32 cpu,u32 *cpuid,u32 *clusterid); +void (*get_cpu_cluster_id)(u32 *cpuid,u32 *clusterid);int (*get_cpu_ndiv)(u32 cpu,u32 cpuid,u32 clusterid,u64 *ndiv); };
@@ -77,6 +78,8 @@ struct tegra194_cpufreq_data {const struct tegra_cpufreq_soc *soc;bool icc_dram_bw_scaling;struct tegra_cpu_data *cpu_data; +enum cpuhp_state cpuhp_state; +struct hlist_node cpuhp_node; };static struct workqueue_struct *read_counters_wq;
@@ -109,11 +112,11 @@ static void tegra_get_cpu_mpidr(void *mpidr) *((u64 *)mpidr) =read_cpuid_mpidr () &MPIDR_HWID_BITMASK ; } -static void tegra234_get_cpu_cluster_id (u32 cpu,u32 *cpuid,u32 *clusterid) +static void tegra234_get_cpu_cluster_id (u32 *cpuid,u32 *clusterid) {u64 mpidr; -smp_call_function_single (cpu, tegra_get_cpu_mpidr, &mpidr, true); +tegra_get_cpu_mpidr (&mpidr);if (cpuid) *cpuid =MPIDR_AFFINITY_LEVEL (mpidr,1 );
@@ -121,11 +124,45 @@ static void tegra234_get_cpu_cluster_id(u32 cpu, u32 *cpuid, u32 *clusterid) *clusterid =MPIDR_AFFINITY_LEVEL (mpidr,2 ); } +static int tegra_cpufreq_cpu_online (unsigned int cpu,struct hlist_node *node) +{ +struct tegra194_cpufreq_data *data; +u32 cpuid, clusterid; + + data = hlist_entry(node, struct tegra194_cpufreq_data, cpuhp_node); + + data->soc->ops->get_cpu_cluster_id (&cpuid, &clusterid); + + data->cpu_data[cpu].cpuid = cpuid; + data->cpu_data[cpu].clusterid = clusterid; + +if (clusterid >= data->soc->num_clusters || + cpuid >= data->soc->maxcpus_per_cluster) { +pr_warn_once ("cpufreq: cpu%u: bad MPIDR (cluster %u, core %u)\n" , + cpu, clusterid, cpuid); +return 0 ; + } + +/* Derive per-core register address only when ccplex MMIO is mapped. */ +if (data->regs) { +u32 index = clusterid * data->soc->maxcpus_per_cluster + cpuid; + + data->cpu_data[cpu].freq_core_reg = +SCRATCH_FREQ_CORE_REG (data, index); + } + +return 0 ; +} +static int tegra234_get_cpu_ndiv (u32 cpu,u32 cpuid,u32 clusterid,u64 *ndiv) {struct tegra194_cpufreq_data *data =cpufreq_get_driver_data (); +void __iomem *reg = data->cpu_data[cpu].freq_core_reg; + +if (!reg) +return -EINVAL ; - *ndiv =readl (data->cpu_data[cpu].freq_core_reg) &NDIV_MASK ; + *ndiv =readl (reg) &NDIV_MASK ;return 0 ; }
@@ -135,8 +172,12 @@ static void tegra234_set_cpu_ndiv(struct cpufreq_policy *policy, u64 ndiv)struct tegra194_cpufreq_data *data =cpufreq_get_driver_data ();u32 cpu; -for_each_cpu (cpu, policy->cpus) -writel (ndiv, data->cpu_data[cpu].freq_core_reg); +for_each_cpu (cpu, policy->cpus) { +void __iomem *reg = data->cpu_data[cpu].freq_core_reg; + +if (reg) +writel (ndiv, reg); + } }/*
@@ -204,11 +245,11 @@ static const struct tegra_cpufreq_soc tegra238_cpufreq_soc = { .refclk_delta_min = 16000, }; -static void tegra194_get_cpu_cluster_id (u32 cpu,u32 *cpuid,u32 *clusterid) +static void tegra194_get_cpu_cluster_id (u32 *cpuid,u32 *clusterid) {u64 mpidr; -smp_call_function_single (cpu, tegra_get_cpu_mpidr, &mpidr, true); +tegra_get_cpu_mpidr (&mpidr);if (cpuid) *cpuid =MPIDR_AFFINITY_LEVEL (mpidr,0 );
@@ -386,16 +427,21 @@ static unsigned int tegra194_get_speed(u32 cpu) {struct tegra194_cpufreq_data *data =cpufreq_get_driver_data ();u32 clusterid = data->cpu_data[cpu].clusterid; +u32 cpuid = data->cpu_data[cpu].cpuid;struct cpufreq_frequency_table *pos;unsigned int rate;u64 ndiv;int ret; +if (clusterid >= data->soc->num_clusters || + cpuid >= data->soc->maxcpus_per_cluster) +return 0 ; +/* reconstruct actual cpu freq using counters */ rate =tegra194_calculate_speed (cpu);/* get last written ndiv value */ - ret = data->soc->ops->get_cpu_ndiv (cpu, data->cpu_data[cpu].cpuid, clusterid, &ndiv); + ret = data->soc->ops->get_cpu_ndiv (cpu, cpuid, clusterid, &ndiv);if (WARN_ON_ONCE (ret))return rate;
@@ -681,28 +727,6 @@ tegra_cpufreq_bpmp_read_lut(struct platform_device *pdev, struct tegra_bpmp *bpmreturn freq_table; } -static int tegra194_cpufreq_store_physids (unsigned int cpu,struct tegra194_cpufreq_data *data) -{ -int num_cpus = data->soc->maxcpus_per_cluster * data->soc->num_clusters; -u32 cpuid, clusterid; -u64 mpidr_id; - -if (cpu > (num_cpus -1 )) { -pr_err ("cpufreq: wrong num of cpus or clusters in soc data\n" ); -return -EINVAL ; - } - - data->soc->ops->get_cpu_cluster_id (cpu, &cpuid, &clusterid); - - mpidr_id = (clusterid * data->soc->maxcpus_per_cluster) + cpuid; - - data->cpu_data[cpu].cpuid = cpuid; - data->cpu_data[cpu].clusterid = clusterid; - data->cpu_data[cpu].freq_core_reg =SCRATCH_FREQ_CORE_REG (data, mpidr_id); - -return 0 ; -} -static int tegra194_cpufreq_probe (struct platform_device *pdev) {const struct tegra_cpufreq_soc *soc;
@@ -710,7 +734,6 @@ static int tegra194_cpufreq_probe(struct platform_device *pdev)struct tegra_bpmp *bpmp;struct device *cpu_dev;int err, i; -u32 cpu; data =devm_kzalloc_obj (&pdev->dev, *data);if (!data)
@@ -737,6 +760,12 @@ static int tegra194_cpufreq_probe(struct platform_device *pdev)return PTR_ERR (data->regs); } +if (nr_cpu_ids > data->soc->num_clusters * + data->soc->maxcpus_per_cluster) { +dev_err (&pdev->dev,"wrong num of cpus or clusters in soc data\n" ); +return -EINVAL ; + } + data->cpu_data =devm_kzalloc_objs (&pdev->dev, *data->cpu_data, data->soc->num_clusters * data->soc->maxcpus_per_cluster);if (!data->cpu_data)
@@ -764,11 +793,24 @@ static int tegra194_cpufreq_probe(struct platform_device *pdev) } } -for_each_possible_cpu (cpu) { - err =tegra194_cpufreq_store_physids (cpu, data); -if (err) - goto err_free_res; - } +/* +* Install the hotplug state before cpufreq_register_driver(), so that +* cpu_data is filled in before cpufreq uses a CPU. This covers the +* CPUs online now and those onlined later. +* +* cpufreq_get_driver_data() returns NULL until the driver is +* registered. The _multi variant passes the callback its data +* through cpuhp_node instead. +*/ + err =cpuhp_setup_state_multi (CPUHP_AP_ONLINE_DYN ,"cpufreq/tegra194:online" , + tegra_cpufreq_cpu_online,NULL ); +if (err <0 ) + goto err_free_res; + data->cpuhp_state = err; + + err =cpuhp_state_add_instance (data->cpuhp_state, &data->cpuhp_node); +if (err) + goto remove_cpuhp_state; tegra194_cpufreq_driver.driver_data = data;
@@ -776,7 +818,7 @@ static int tegra194_cpufreq_probe(struct platform_device *pdev) cpu_dev =get_cpu_device (0 );if (!cpu_dev) { err = -EPROBE_DEFER ; - goto err_free_res; + goto remove_cpuhp_instance; }if (dev_pm_opp_of_get_opp_desc_node (cpu_dev)) {
@@ -789,6 +831,10 @@ static int tegra194_cpufreq_probe(struct platform_device *pdev)if (!err) goto put_bpmp; +remove_cpuhp_instance: +cpuhp_state_remove_instance (data->cpuhp_state, &data->cpuhp_node); +remove_cpuhp_state: +cpuhp_remove_multi_state (data->cpuhp_state); err_free_res:tegra194_cpufreq_free_resources (); put_bpmp:
@@ -798,7 +844,11 @@ static int tegra194_cpufreq_probe(struct platform_device *pdev)static void tegra194_cpufreq_remove (struct platform_device *pdev) { +struct tegra194_cpufreq_data *data =platform_get_drvdata (pdev); +cpufreq_unregister_driver (&tegra194_cpufreq_driver); +cpuhp_state_remove_instance (data->cpuhp_state, &data->cpuhp_node); +cpuhp_remove_multi_state (data->cpuhp_state);tegra194_cpufreq_free_resources (); }
Signature · 1 line
2.34.1
PATCH v3 2/9 cpufreq: tegra194: remove duplicate counter sampling loops
In reply to Sumit GuptaTegra194 and Tegra234 read their counters differently. Tegra194 reads a system register and Tegra234 reads its ACTMON registers through MMIO. Each SoC therefore has its own read_counters op. Both ops open-code the same sampling loop.
Move the loop to common code and replace read_counters with a sample_counters op that takes a single sample. The per-SoC op also prepares for Tegra264, which reads its counters from the AMU.
No functional change.
--- drivers/cpufreq/tegra194-cpufreq.c | 93 ++++++++++++------------------ 1 file changed, 37 insertions(+), 56 deletions(-)
drivers/cpufreq/tegra194-cpufreq.c +37 -56
@@ -57,8 +57,11 @@ struct read_counters_work {struct tegra_cpu_ctr c; }; +struct tegra194_cpufreq_data ; +struct tegra_cpufreq_ops { -void (*read_counters)(struct tegra_cpu_ctr *c); +void (*sample_counters)(struct tegra194_cpufreq_data *data, +struct tegra_cpu_ctr *c);void (*set_cpu_ndiv)(struct cpufreq_policy *policy,u64 ndiv);void (*get_cpu_cluster_id)(u32 *cpuid,u32 *clusterid);int (*get_cpu_ndiv)(u32 cpu,u32 cpuid,u32 clusterid,u64 *ndiv);
@@ -187,43 +190,22 @@ static void tegra234_set_cpu_ndiv(struct cpufreq_policy *policy, u64 ndiv)* [63:32] PLLP counter: Counts at fixed frequency (408 MHz) * [31:0] Core clock counter: Counts on every core clock cycle */ -static void tegra234_read_counters (struct tegra_cpu_ctr *c) +static void tegra234_sample_counters (struct tegra194_cpufreq_data *data, +struct tegra_cpu_ctr *c) { -struct tegra194_cpufreq_data *data =cpufreq_get_driver_data ();void __iomem *actmon_reg; -u32 delta_refcnt; -int cnt =0 ;u64 val; actmon_reg =CORE_ACTMON_CNTR_REG (data, data->cpu_data[c->cpu].clusterid, data->cpu_data[c->cpu].cpuid); val =readq (actmon_reg); - c->last_refclk_cnt =upper_32_bits (val); - c->last_coreclk_cnt =lower_32_bits (val); - -/* -* The sampling window is based on the minimum number of reference -* clock cycles which is known to give a stable value of CPU frequency. -*/ -do { - val =readq (actmon_reg); - c->refclk_cnt =upper_32_bits (val); - c->coreclk_cnt =lower_32_bits (val); -if (c->refclk_cnt < c->last_refclk_cnt) - delta_refcnt = c->refclk_cnt + (MAX_CNT - c->last_refclk_cnt); -else - delta_refcnt = c->refclk_cnt - c->last_refclk_cnt; -if (++cnt >=0xFFFF ) { -pr_warn ("cpufreq: problem with refclk on cpu:%d, delta_refcnt:%u, cnt:%d\n" , - c->cpu, delta_refcnt, cnt); -break ; - } - }while (delta_refcnt < data->soc->refclk_delta_min); + c->refclk_cnt =upper_32_bits (val); + c->coreclk_cnt =lower_32_bits (val); }static struct tegra_cpufreq_ops tegra234_cpufreq_ops = { - .read_counters = tegra234_read_counters, + .sample_counters = tegra234_sample_counters, .get_cpu_cluster_id = tegra234_get_cpu_cluster_id, .get_cpu_ndiv = tegra234_get_cpu_ndiv, .set_cpu_ndiv = tegra234_set_cpu_ndiv,
@@ -281,35 +263,13 @@ static inline u32 map_ndiv_to_freq(struct mrq_cpu_ndiv_limits_responsereturn nltbl->ref_clk_hz /KHZ * ndiv / (nltbl->pdiv * nltbl->mdiv); } -static void tegra194_read_counters (struct tegra_cpu_ctr *c) +static void tegra194_sample_counters (struct tegra194_cpufreq_data *data, +struct tegra_cpu_ctr *c) { -struct tegra194_cpufreq_data *data =cpufreq_get_driver_data (); -u32 delta_refcnt; -int cnt =0 ; -u64 val; +u64 val =read_freq_feedback (); - val =read_freq_feedback (); - c->last_refclk_cnt =lower_32_bits (val); - c->last_coreclk_cnt =upper_32_bits (val); - -/* -* The sampling window is based on the minimum number of reference -* clock cycles which is known to give a stable value of CPU frequency. -*/ -do { - val =read_freq_feedback (); - c->refclk_cnt =lower_32_bits (val); - c->coreclk_cnt =upper_32_bits (val); -if (c->refclk_cnt < c->last_refclk_cnt) - delta_refcnt = c->refclk_cnt + (MAX_CNT - c->last_refclk_cnt); -else - delta_refcnt = c->refclk_cnt - c->last_refclk_cnt; -if (++cnt >=0xFFFF ) { -pr_warn ("cpufreq: problem with refclk on cpu:%d, delta_refcnt:%u, cnt:%d\n" , - c->cpu, delta_refcnt, cnt); -break ; - } - }while (delta_refcnt < data->soc->refclk_delta_min); + c->refclk_cnt =lower_32_bits (val); + c->coreclk_cnt =upper_32_bits (val); }static void tegra_read_counters (struct work_struct *work)
@@ -317,6 +277,8 @@ static void tegra_read_counters(struct work_struct *work)struct tegra194_cpufreq_data *data =cpufreq_get_driver_data ();struct read_counters_work *read_counters_work;struct tegra_cpu_ctr *c; +u32 delta_refcnt; +int cnt =0 ;/* * ref_clk_counter(32 bit counter) runs on constant clk,
@@ -334,7 +296,26 @@ static void tegra_read_counters(struct work_struct *work) work); c = &read_counters_work->c; - data->soc->ops->read_counters (c); + data->soc->ops->sample_counters (data, c); + c->last_refclk_cnt = c->refclk_cnt; + c->last_coreclk_cnt = c->coreclk_cnt; + +/* +* The sampling window is based on the minimum number of reference +* clock cycles which is known to give a stable value of CPU frequency. +*/ +do { + data->soc->ops->sample_counters (data, c); +if (c->refclk_cnt < c->last_refclk_cnt) + delta_refcnt = c->refclk_cnt + (MAX_CNT - c->last_refclk_cnt); +else + delta_refcnt = c->refclk_cnt - c->last_refclk_cnt; +if (++cnt >=0xFFFF ) { +pr_warn ("cpufreq: problem with refclk on cpu:%d, delta_refcnt:%u, cnt:%d\n" , + c->cpu, delta_refcnt, cnt); +break ; + } + }while (delta_refcnt < data->soc->refclk_delta_min); }/*
@@ -638,7 +619,7 @@ static struct cpufreq_driver tegra194_cpufreq_driver = { };static struct tegra_cpufreq_ops tegra194_cpufreq_ops = { - .read_counters = tegra194_read_counters, + .sample_counters = tegra194_sample_counters, .get_cpu_cluster_id = tegra194_get_cpu_cluster_id, .get_cpu_ndiv = tegra194_get_cpu_ndiv, .set_cpu_ndiv = tegra194_set_cpu_ndiv,
Signature · 1 line
2.34.1
PATCH v3 3/9 cpufreq: tegra194: add tegra_counter_delta helper
In reply to Sumit GuptaFrequency readback open-codes the same counter wrap-around subtraction in three places. Move it into a single helper.
The helper works on u64 values, so the frequency multiply now runs in 64 bits. The old (unsigned long) cast applied to the result of the 32-bit multiply, not to its operands, so it had no effect. Drop it.
--- drivers/cpufreq/tegra194-cpufreq.c | 37 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 19 deletions(-)
drivers/cpufreq/tegra194-cpufreq.c +18 -19
@@ -110,6 +110,14 @@ static int tegra_cpufreq_set_bw(struct cpufreq_policy *policy, unsigned long frereturn ret; } +static u64 tegra_counter_delta (u64 after,u64 before,u64 mask) +{ +if (after < before) +return after + (mask - before); + +return after - before; +} +static void tegra_get_cpu_mpidr (void *mpidr) { *((u64 *)mpidr) =read_cpuid_mpidr () &MPIDR_HWID_BITMASK ;
@@ -277,7 +285,7 @@ static void tegra_read_counters(struct work_struct *work)struct tegra194_cpufreq_data *data =cpufreq_get_driver_data ();struct read_counters_work *read_counters_work;struct tegra_cpu_ctr *c; -u32 delta_refcnt; +u64 delta_refcnt;int cnt =0 ;/*
@@ -306,12 +314,10 @@ static void tegra_read_counters(struct work_struct *work)*/ do { data->soc->ops->sample_counters(data, c); - if (c->refclk_cnt < c->last_refclk_cnt) - delta_refcnt = c->refclk_cnt + (MAX_CNT - c->last_refclk_cnt); - else - delta_refcnt = c->refclk_cnt - c->last_refclk_cnt; + delta_refcnt = tegra_counter_delta(c->refclk_cnt, c->last_refclk_cnt, + MAX_CNT); if (++cnt >= 0xFFFF) { - pr_warn("cpufreq: problem with refclk on cpu:%d, delta_refcnt:%u, cnt:%d\n", + pr_warn("cpufreq: problem with refclk on cpu:%d, delta_refcnt:%llu, cnt:%d\n", c->cpu, delta_refcnt, cnt); break; }
@@ -343,9 +349,9 @@ static unsigned int tegra194_calculate_speed(u32 cpu) {struct read_counters_work read_counters_work;struct tegra_cpu_ctr c; -u32 delta_refcnt; -u32 delta_ccnt; -u32 rate_mhz; +u64 delta_refcnt; +u64 delta_ccnt; +u64 rate_mhz;/* * Reconstruct cpu frequency over an observation/sampling window.
@@ -357,23 +363,16 @@ static unsigned int tegra194_calculate_speed(u32 cpu)flush_work (&read_counters_work.work); c = read_counters_work.c; -if (c.coreclk_cnt < c.last_coreclk_cnt) - delta_ccnt = c.coreclk_cnt + (MAX_CNT - c.last_coreclk_cnt); -else - delta_ccnt = c.coreclk_cnt - c.last_coreclk_cnt; + delta_ccnt =tegra_counter_delta (c.coreclk_cnt, c.last_coreclk_cnt,MAX_CNT );if (!delta_ccnt)return 0 ; -/* ref clock is 32 bits */ -if (c.refclk_cnt < c.last_refclk_cnt) - delta_refcnt = c.refclk_cnt + (MAX_CNT - c.last_refclk_cnt); -else - delta_refcnt = c.refclk_cnt - c.last_refclk_cnt; + delta_refcnt =tegra_counter_delta (c.refclk_cnt, c.last_refclk_cnt,MAX_CNT );if (!delta_refcnt) {pr_debug ("cpufreq: %d is idle, delta_refcnt: 0\n" , cpu);return 0 ; } - rate_mhz = ((unsigned long )(delta_ccnt *REF_CLK_MHZ )) / delta_refcnt; + rate_mhz = delta_ccnt *REF_CLK_MHZ / delta_refcnt;return (rate_mhz *KHZ );/* in KHz */ }
Signature · 1 line
2.34.1
PATCH v3 4/9 cpufreq: tegra194: add per-SoC counter mask
In reply to Sumit GuptaFrequency readback handles counter wrap-around with MAX_CNT, which is hardcoded to 32 bits. Move the counter's maximum value into the SoC data, in preparation for adding support for Tegra264, whose AMU counters are 64-bit.
Add cnt_mask to tegra_cpufreq_soc and set it to U32_MAX on Tegra194/234/238, which matches MAX_CNT. Also widen tegra_cpu_ctr to u64, so it can hold counters of either width.
No functional change.
--- drivers/cpufreq/tegra194-cpufreq.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/cpufreq/tegra194-cpufreq.c +13 -7
@@ -22,7 +22,6 @@#define KHZ 1000#define REF_CLK_MHZ 408/* 408 MHz */ #define CPUFREQ_TBL_STEP_HZ (50 * KHZ * KHZ) -#define MAX_CNT ~0U#define MAX_DELTA_KHZ 115200
@@ -48,8 +47,8 @@ struct tegra_cpu_data {struct tegra_cpu_ctr {u32 cpu; -u32 coreclk_cnt, last_coreclk_cnt; -u32 refclk_cnt, last_refclk_cnt; +u64 coreclk_cnt, last_coreclk_cnt; +u64 refclk_cnt, last_refclk_cnt; };struct read_counters_work {
@@ -69,6 +68,7 @@ struct tegra_cpufreq_ops {struct tegra_cpufreq_soc {struct tegra_cpufreq_ops *ops; +u64 cnt_mask;int maxcpus_per_cluster;unsigned int num_clusters;phys_addr_t actmon_cntr_base;
@@ -221,6 +221,7 @@ static struct tegra_cpufreq_ops tegra234_cpufreq_ops = {static const struct tegra_cpufreq_soc tegra234_cpufreq_soc = { .ops = &tegra234_cpufreq_ops, + .cnt_mask =U32_MAX , .actmon_cntr_base =0x9000 , .maxcpus_per_cluster =4 , .num_clusters =3 ,
@@ -229,6 +230,7 @@ static const struct tegra_cpufreq_soc tegra234_cpufreq_soc = {static const struct tegra_cpufreq_soc tegra238_cpufreq_soc = { .ops = &tegra234_cpufreq_ops, + .cnt_mask =U32_MAX , .actmon_cntr_base =0x4000 , .maxcpus_per_cluster =8 , .num_clusters =1 ,
@@ -315,7 +317,7 @@ static void tegra_read_counters(struct work_struct *work) do { data->soc->ops->sample_counters(data, c); delta_refcnt = tegra_counter_delta(c->refclk_cnt, c->last_refclk_cnt, - MAX_CNT); + data->soc->cnt_mask); if (++cnt >= 0xFFFF) { pr_warn("cpufreq: problem with refclk on cpu:%d, delta_refcnt:%llu, cnt:%d\n", c->cpu, delta_refcnt, cnt);
@@ -347,8 +349,10 @@ static void tegra_read_counters(struct work_struct *work)*/ static unsigned int tegra194_calculate_speed (u32 cpu) { +struct tegra194_cpufreq_data *data =cpufreq_get_driver_data ();struct read_counters_work read_counters_work;struct tegra_cpu_ctr c; +u64 cnt_mask = data->soc->cnt_mask;u64 delta_refcnt;u64 delta_ccnt;u64 rate_mhz;
@@ -363,11 +367,11 @@ static unsigned int tegra194_calculate_speed(u32 cpu)flush_work (&read_counters_work.work); c = read_counters_work.c; - delta_ccnt =tegra_counter_delta (c.coreclk_cnt, c.last_coreclk_cnt,MAX_CNT ); + delta_ccnt =tegra_counter_delta (c.coreclk_cnt, c.last_coreclk_cnt, cnt_mask);if (!delta_ccnt)return 0 ; - delta_refcnt =tegra_counter_delta (c.refclk_cnt, c.last_refclk_cnt,MAX_CNT ); + delta_refcnt =tegra_counter_delta (c.refclk_cnt, c.last_refclk_cnt, cnt_mask);if (!delta_refcnt) {pr_debug ("cpufreq: %d is idle, delta_refcnt: 0\n" , cpu);return 0 ;
@@ -626,6 +630,7 @@ static struct tegra_cpufreq_ops tegra194_cpufreq_ops = {static const struct tegra_cpufreq_soc tegra194_cpufreq_soc = { .ops = &tegra194_cpufreq_ops, + .cnt_mask =U32_MAX , .maxcpus_per_cluster =2 , .num_clusters =4 , .refclk_delta_min =16000 ,
@@ -721,7 +726,8 @@ static int tegra194_cpufreq_probe(struct platform_device *pdev) soc =of_device_get_match_data (&pdev->dev); -if (soc->ops && soc->maxcpus_per_cluster && soc->num_clusters && soc->refclk_delta_min) { +if (soc->ops && soc->maxcpus_per_cluster && soc->num_clusters && + soc->refclk_delta_min && soc->cnt_mask) { data->soc = soc; }else {dev_err (&pdev->dev,"soc data missing\n" );
Signature · 1 line
2.34.1
PATCH v3 5/9 cpufreq: tegra194: split MMIO mapping from ACTMON offset
In reply to Sumit GuptaProbe maps the CCPLEX registers only when actmon_cntr_base is set. This has worked so far because each SoC uses one interface for both requesting and reading frequency. Tegra234/238 use MMIO, and Tegra194 uses system registers.
Tegra264 requests frequency through MMIO but reads its counters from system registers. It needs the mapping but has no ACTMON counters.
Add a needs_mmio flag so the mapping no longer depends on actmon_cntr_base.
No functional change.
--- drivers/cpufreq/tegra194-cpufreq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/cpufreq/tegra194-cpufreq.c +4 -2
@@ -71,6 +71,7 @@ struct tegra_cpufreq_soc {u64 cnt_mask;int maxcpus_per_cluster;unsigned int num_clusters; +bool needs_mmio;phys_addr_t actmon_cntr_base;u32 refclk_delta_min; };
@@ -222,6 +223,7 @@ static struct tegra_cpufreq_ops tegra234_cpufreq_ops = {static const struct tegra_cpufreq_soc tegra234_cpufreq_soc = { .ops = &tegra234_cpufreq_ops, .cnt_mask =U32_MAX , + .needs_mmio = true, .actmon_cntr_base =0x9000 , .maxcpus_per_cluster =4 , .num_clusters =3 ,
@@ -231,6 +233,7 @@ static const struct tegra_cpufreq_soc tegra234_cpufreq_soc = {static const struct tegra_cpufreq_soc tegra238_cpufreq_soc = { .ops = &tegra234_cpufreq_ops, .cnt_mask =U32_MAX , + .needs_mmio = true, .actmon_cntr_base =0x4000 , .maxcpus_per_cluster =8 , .num_clusters =1 ,
@@ -739,8 +742,7 @@ static int tegra194_cpufreq_probe(struct platform_device *pdev)if (!data->bpmp_luts)return -ENOMEM ; -if (soc->actmon_cntr_base) { -/* mmio registers are used for frequency request and re-construction */ +if (soc->needs_mmio) { data->regs =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (data->regs))return PTR_ERR (data->regs);
Signature · 1 line
2.34.1
PATCH v3 6/9 dt-bindings: arm: nvidia: Document the Tegra264 CCPLEX cluster
In reply to Sumit GuptaAdd a compatible string for the CCPLEX cluster on Tegra264.
On Tegra264, two CPU clusters share one clock. Add the generic "#performance-domain-cells" provider property so a CPU node can name its domain with "performance-domains = <&ccplex N>", where N is the index of the domain that clocks the CPU. The consumer side is already described in bindings/arm/cpus.yaml.
The property is required on Tegra264, where a domain spans two clusters.
--- .../tegra/nvidia,tegra-ccplex-cluster.yaml | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/arm/tegra/nvidia,tegra-ccplex-cluster.yaml +26 -1
@@ -25,6 +25,7 @@ properties: - nvidia,tegra186-ccplex-cluster - nvidia,tegra234-ccplex-cluster - nvidia,tegra238-ccplex-cluster + - nvidia,tegra264-ccplex-cluster reg: maxItems: 1
@@ -35,13 +36,29 @@ properties: Specifies the BPMP node that needs to be queried to get operating point data for all CPUs. -additionalProperties: false + '#performance-domain-cells': + const: 1 + description: + The cell is the index of the performance domain that clocks a CPU. + When present, every CPU names its domain with "performance-domains". required: - compatible - reg - nvidia,bpmp +allOf: + - if: + properties: + compatible: + contains: + const: nvidia,tegra264-ccplex-cluster + then: + required: + - '#performance-domain-cells' + +additionalProperties: false + examples: - | ccplex@e000000 {
@@ -49,3 +66,11 @@ examples: reg = <0x0e000000 0x5ffff>; nvidia,bpmp = <&bpmp>; }; + + - | + ccplex@30000000 { + compatible = "nvidia,tegra264-ccplex-cluster"; + reg = <0x30000000 0xcf0000>; + #performance-domain-cells = <1>; + nvidia,bpmp = <&bpmp>; + };
Signature · 1 line
2.34.1
Re: [PATCH v3 6/9] dt-bindings: arm: nvidia: Document the Tegra264 CCPLEX cluster
Documentation/devicetree/bindings/arm/tegra/nvidia,tegra-ccplex-cluster.yaml examples: · line 73
Quoted 12 lines · Sumit Gupta
examples:
- |ccplex@e000000 {Documentation/devicetree/bindings/arm/tegra/nvidia,tegra-ccplex-cluster.yaml +5
-0@@ -49,3 +66,11 @@ examples: reg = <0x0e000000 0x5ffff>; nvidia,bpmp = <&bpmp>; }; + + - | + ccplex@30000000 { + compatible = "nvidia,tegra264-ccplex-cluster"; + reg = <0x30000000 0xcf0000>;
Drop example, no need for difference in one new property.
Best regards,
Krzysztof
PATCH v3 7/9 cpufreq: tegra194: derive frequency domain from device tree
In reply to Sumit GuptaThe driver currently creates one policy per cluster, so a frequency domain that spans clusters cannot form a single policy.
Group CPUs by the generic "performance-domains" property instead. of_perf_domain_get_sharing_cpumask() adds to the policy each CPU that names the same domain, including offline ones. Without the property, CPUs keep the cluster grouping, so current Tegra194/234/238 device trees are unaffected.
Store the domain index as clkid for every CPU in the policy. It can then be used to select the domain's frequency register, whichever CPU manages the policy.
A policy can now span clusters. It still uses one cluster's BPMP frequency table. Clusters in a domain share a clock and report the same NDIV limits, so that table fits the whole domain.
policy->cpu can move to a CPU in another cluster. tegra194_get_speed() then uses that cluster's table, so check it as tegra194_cpufreq_init() does.
--- drivers/cpufreq/tegra194-cpufreq.c | 44 ++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 9 deletions(-)
drivers/cpufreq/tegra194-cpufreq.c +35 -9
@@ -42,6 +42,7 @@struct tegra_cpu_data {u32 cpuid;u32 clusterid; +u32 clkid;/* performance-domain id */ void __iomem *freq_core_reg; };
@@ -421,7 +422,8 @@ static unsigned int tegra194_get_speed(u32 cpu)int ret;if (clusterid >= data->soc->num_clusters || - cpuid >= data->soc->maxcpus_per_cluster) + cpuid >= data->soc->maxcpus_per_cluster || + !data->bpmp_luts[clusterid])return 0 ;/* reconstruct actual cpu freq using counters */
@@ -534,21 +536,45 @@ static int tegra194_cpufreq_init(struct cpufreq_policy *policy) {struct tegra194_cpufreq_data *data =cpufreq_get_driver_data ();int maxcpus_per_cluster = data->soc->maxcpus_per_cluster; -u32 clusterid = data->cpu_data[policy->cpu].clusterid;struct cpufreq_frequency_table *freq_table;struct cpufreq_frequency_table *bpmp_lut; -u32 start_cpu, cpu; +struct of_phandle_args args; +u32 start_cpu, cpu, clusterid;int ret; +/* Covers all possible CPUs, so offline siblings are grouped too. */ + ret =of_perf_domain_get_sharing_cpumask (policy->cpu,"performance-domains" , +"#performance-domain-cells" , + policy->cpus, &args); +if (!ret) { +if (args.args_count !=1 ) { +pr_err ("cpufreq: cpu%u: invalid #performance-domain-cells\n" , + policy->cpu); +of_node_put (args.np); +return -EINVAL ; + } + +for_each_cpu (cpu, policy->cpus) + data->cpu_data[cpu].clkid = args.args[0 ]; + +of_node_put (args.np); + }else if (ret == -ENOENT ) { +/* Legacy grouping for DTs without performance-domains. */ + start_cpu =rounddown (policy->cpu, maxcpus_per_cluster); +for (cpu = start_cpu; cpu < (start_cpu + maxcpus_per_cluster); cpu++) +if (cpu_possible (cpu)) +cpumask_set_cpu (cpu, policy->cpus); + }else { +pr_err ("cpufreq: cpu%u: failed to get performance domain: %d\n" , + policy->cpu, ret); +return ret; + } + +/* The BPMP LUT is indexed by the MPIDR cluster id, not clkid. */ + clusterid = data->cpu_data[policy->cpu].clusterid;if (clusterid >= data->soc->num_clusters || !data->bpmp_luts[clusterid])return -EINVAL ; - start_cpu =rounddown (policy->cpu, maxcpus_per_cluster); -/* set same policy for all cpus in a cluster */ -for (cpu = start_cpu; cpu < (start_cpu + maxcpus_per_cluster); cpu++) { -if (cpu_possible (cpu)) -cpumask_set_cpu (cpu, policy->cpus); - } policy->cpuinfo.transition_latency =TEGRA_CPUFREQ_TRANSITION_LATENCY ; bpmp_lut = data->bpmp_luts[clusterid];
Signature · 1 line
2.34.1
PATCH v3 8/9 cpufreq: tegra194: Add support for Tegra264
In reply to Sumit GuptaAdd cpufreq support for Tegra264. It requests and reads the CPU frequency differently from earlier SoCs.
To request a frequency, the driver writes NDIV to a core_freq_req register in the CCPLEX register space. Two clusters share a clock and its register, so they always run at the same frequency. The driver exposes each pair as one performance domain and one cpufreq policy. Each CPU's "performance-domains" property gives the domain index, which selects the register. If the CCPLEX node declares "#performance-domain-cells", probe fails if any CPU lacks the property.
To read the frequency, the driver samples the per-CPU 64-bit AMU counters through system registers. The AMU constant counter is the reference. It ticks at the system counter rate, so the driver takes the reference rate from CNTFRQ instead of the fixed 408 MHz clock. Probe fails if CONFIG_ARM64_AMU_EXTN is disabled or a CPU lacks AMU.
--- drivers/cpufreq/Kconfig.arm | 4 +- drivers/cpufreq/tegra194-cpufreq.c | 166 ++++++++++++++++++++++++++++- 2 files changed, 163 insertions(+), 7 deletions(-)
drivers/cpufreq/Kconfig.arm +2 -2
@@ -248,9 +248,9 @@ config ARM_TEGRA186_CPUFREQ config ARM_TEGRA194_CPUFREQ tristate "Tegra194 CPUFreq support" - depends on ARCH_TEGRA_194_SOC || ARCH_TEGRA_234_SOC + depends on ARCH_TEGRA_194_SOC || ARCH_TEGRA_234_SOC || ARCH_TEGRA_264_SOC depends on TEGRA_BPMP - default ARCH_TEGRA_194_SOC || ARCH_TEGRA_234_SOC + default ARCH_TEGRA_194_SOC || ARCH_TEGRA_234_SOC || ARCH_TEGRA_264_SOC help This adds CPU frequency driver support for Tegra194 SOCs.
drivers/cpufreq/tegra194-cpufreq.c +161 -5
245 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v3 9/9 arm64: tegra: Add CCPLEX cluster node for Tegra264
In reply to Sumit GuptaAdd the CCPLEX cluster node under bus@8100000000. The cpufreq driver uses it to request CPU frequencies.
Add the generic "performance-domains" property to each CPU, referencing this node. The driver uses the domain index to group CPUs that share a clock and to select their core_freq_req register. Each cluster has one CPU and two clusters share a clock, so each domain holds two CPUs.
--- arch/arm64/boot/dts/nvidia/tegra264.dtsi | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
arch/arm64/boot/dts/nvidia/tegra264.dtsi +21 -0
@@ -3964,6 +3964,13 @@ i2c12: i2c@c6d0000 { status = "disabled"; }; + ccplex: ccplex@30000000 { + compatible = "nvidia,tegra264-ccplex-cluster"; + reg = <0x00 0x30000000 0x0 0x00cf0000>; + #performance-domain-cells = <1>; + nvidia,bpmp = <&bpmp>; + }; + gic: interrupt-controller@46000000 { compatible = "arm,gic-v3"; reg = <0x00 0x46000000 0x0 0x010000>, /* GICD */
@@ -4382,6 +4389,7 @@ cpu0: cpu@0 { reg = <0x00000>; enable-method = "psci"; + performance-domains = <&ccplex 0>; i-cache-size = <65536>; i-cache-line-size = <64>;
@@ -4398,6 +4406,7 @@ cpu1: cpu@10000 { reg = <0x10000>; enable-method = "psci"; + performance-domains = <&ccplex 0>; i-cache-size = <65536>; i-cache-line-size = <64>;
@@ -4414,6 +4423,7 @@ cpu2: cpu@20000 { reg = <0x20000>; enable-method = "psci"; + performance-domains = <&ccplex 1>; i-cache-size = <65536>; i-cache-line-size = <64>;
@@ -4430,6 +4440,7 @@ cpu3: cpu@30000 { reg = <0x30000>; enable-method = "psci"; + performance-domains = <&ccplex 1>; i-cache-size = <65536>; i-cache-line-size = <64>;
@@ -4446,6 +4457,7 @@ cpu4: cpu@40000 { reg = <0x40000>; enable-method = "psci"; + performance-domains = <&ccplex 2>; i-cache-size = <65536>; i-cache-line-size = <64>;
@@ -4462,6 +4474,7 @@ cpu5: cpu@50000 { reg = <0x50000>; enable-method = "psci"; + performance-domains = <&ccplex 2>; i-cache-size = <65536>; i-cache-line-size = <64>;
@@ -4478,6 +4491,7 @@ cpu6: cpu@60000 { reg = <0x60000>; enable-method = "psci"; + performance-domains = <&ccplex 3>; i-cache-size = <65536>; i-cache-line-size = <64>;
@@ -4494,6 +4508,7 @@ cpu7: cpu@70000 { reg = <0x70000>; enable-method = "psci"; + performance-domains = <&ccplex 3>; i-cache-size = <65536>; i-cache-line-size = <64>;
@@ -4510,6 +4525,7 @@ cpu8: cpu@80000 { reg = <0x80000>; enable-method = "psci"; + performance-domains = <&ccplex 4>; i-cache-size = <65536>; i-cache-line-size = <64>;
@@ -4526,6 +4542,7 @@ cpu9: cpu@90000 { reg = <0x90000>; enable-method = "psci"; + performance-domains = <&ccplex 4>; i-cache-size = <65536>; i-cache-line-size = <64>;
@@ -4542,6 +4559,7 @@ cpu10: cpu@a0000 { reg = <0xa0000>; enable-method = "psci"; + performance-domains = <&ccplex 5>; i-cache-size = <65536>; i-cache-line-size = <64>;
@@ -4558,6 +4576,7 @@ cpu11: cpu@b0000 { reg = <0xb0000>; enable-method = "psci"; + performance-domains = <&ccplex 5>; i-cache-size = <65536>; i-cache-line-size = <64>;
@@ -4574,6 +4593,7 @@ cpu12: cpu@c0000 { reg = <0xc0000>; enable-method = "psci"; + performance-domains = <&ccplex 6>; i-cache-size = <65536>; i-cache-line-size = <64>;
@@ -4590,6 +4610,7 @@ cpu13: cpu@d0000 { reg = <0xd0000>; enable-method = "psci"; + performance-domains = <&ccplex 6>; i-cache-size = <65536>; i-cache-line-size = <64>;
Signature · 1 line
2.34.1
Quoted 31 lines · Sumit Gupta
This series adds cpufreq support for Tegra264, which joins the SoCs already supported by the tegra194-cpufreq driver.
Tegra264 keeps the existing model, where BPMP provides the NDIV limits. The driver derives the current frequency from the core clock and reference counters.
The main differences are:
- Frequency read: through system registers, as on Tegra194, but from the 64-bit architected AMU counters. The reference counter ticks at the system counter rate (CNTFRQ).- Frequency request: through MMIO, as on Tegra234. The driver writes NDIV to a
core_freq_reqregister in the CCPLEX register space. Each register controls a clock shared by two single-CPU clusters, so both CPUs form one cpufreq policy.The patches fall into four groups:
- Fix (patch 1): read each CPU's MPIDR from a CPU hotplug callback instead of at probe. A CPU that is offline at probe then also gets valid cluster and core IDs.- Preparation (patches 2 to 5): cleanups, mostly of the counter code, to make room for a 64-bit counter and for an MMIO mapping without ACTMON counters.
- Improvement (patches 6 and 7): group CPUs by the generic "performance-domains" property, which cluster-based grouping cannot express on Tegra264. Device trees without it keep the existing grouping.
Quoted 6 lines
- Tegra264 support (patches 8 and 9): the driver support, followed by the device tree changes it relies on.
v2[2] -> v3:
- Patch 8: read the AMU counters with interrupts disabled (Zhongqiu).
- Add Reviewed-by from Zhongqiu to patches 1-7 and 9.
For patch 8/9:
Quoted 28 lines
v1[1] -> v2:
- Patch 1: drop the cpu argument ofget_cpu_cluster_id()(Zhongqiu). Check for a bad MPIDR integra194_get_speed()(Sashiko).
- Patch 7: check the BPMP table integra194_get_speed()(Sashiko).
- Patch 8: fail probe if AMU is not available (Zhongqiu).Sumit Gupta (9):
cpufreq: tegra194: move MPIDR read to CPU hotplug callback
cpufreq: tegra194: remove duplicate counter sampling loops
cpufreq: tegra194: addtegra_counter_deltahelper
cpufreq: tegra194: add per-SoC counter mask
cpufreq: tegra194: split MMIO mapping from ACTMON offset
dt-bindings: arm: nvidia: Document the Tegra264 CCPLEX cluster
cpufreq: tegra194: derive frequency domain from device tree
cpufreq: tegra194: Add support for Tegra264
arm64: tegra: Add CCPLEX cluster node for Tegra264.../tegra/nvidia,tegra-ccplex-cluster.yaml | 27 +- arch/arm64/boot/dts/nvidia/tegra264.dtsi | 21 + drivers/cpufreq/Kconfig.arm | 4 +- drivers/cpufreq/tegra194-cpufreq.c | 456 +++++++++++++----- 4 files changed, 387 insertions(+), 121 deletions(-)[1] v1: https://lore.kernel.org/lkml/[email protected]/
[2] v2: https://lore.kernel.org/lkml/[email protected]/base-commit:
e8017d29067fd1310a65c3494ce1a1b492adbac6
Signature · 2 lines
Thx and BRs, Zhongqiu Han
Quoted 35 lines · Zhongqiu Han
Quoted 34 lines · Sumit Gupta
This series adds cpufreq support for Tegra264, which joins the SoCs already supported by the tegra194-cpufreq driver.
Tegra264 keeps the existing model, where BPMP provides the NDIV limits. The driver derives the current frequency from the core clock and reference counters.
The main differences are:
- Frequency read: through system registers, as on Tegra194, but from the 64-bit architected AMU counters. The reference counter ticks at the system counter rate (CNTFRQ).- Frequency request: through MMIO, as on Tegra234. The driver writes NDIV to a
core_freq_reqregister in the CCPLEX register space. Each register controls a clock shared by two single-CPU clusters, so both CPUs form one cpufreq policy.The patches fall into four groups:
- Fix (patch 1): read each CPU's MPIDR from a CPU hotplug callback instead of at probe. A CPU that is offline at probe then also gets valid cluster and core IDs.- Preparation (patches 2 to 5): cleanups, mostly of the counter code, to make room for a 64-bit counter and for an MMIO mapping without ACTMON counters.
- Improvement (patches 6 and 7): group CPUs by the generic "performance-domains" property, which cluster-based grouping cannot express on Tegra264. Device trees without it keep the existing grouping.
- Tegra264 support (patches 8 and 9): the driver support, followed by the device tree changes it relies on.
Quoted 7 lines
Quoted 3 lines
v2[2] -> v3:
- Patch 8: read the AMU counters with interrupts disabled (Zhongqiu).
- Add Reviewed-by from Zhongqiu to patches 1-7 and 9.For patch 8/9:
Reviewed-by Zhongqiu Han <[email protected]>
Why you cannot respond to specific patch? Tags applied to cover letter work completely different!
Best regards,
Krzysztof
Quoted 40 lines · Krzysztof Kozlowski
Quoted 39 lines · Zhongqiu Han
Quoted 37 lines · Sumit Gupta
This series adds cpufreq support for Tegra264, which joins the SoCs already supported by the tegra194-cpufreq driver.
Tegra264 keeps the existing model, where BPMP provides the NDIV limits. The driver derives the current frequency from the core clock and reference counters.
The main differences are:
- Frequency read: through system registers, as on Tegra194, but from the 64-bit architected AMU counters. The reference counter ticks at the system counter rate (CNTFRQ).- Frequency request: through MMIO, as on Tegra234. The driver writes NDIV to a
core_freq_reqregister in the CCPLEX register space. Each register controls a clock shared by two single-CPU clusters, so both CPUs form one cpufreq policy.The patches fall into four groups:
- Fix (patch 1): read each CPU's MPIDR from a CPU hotplug callback instead of at probe. A CPU that is offline at probe then also gets valid cluster and core IDs.- Preparation (patches 2 to 5): cleanups, mostly of the counter code, to make room for a 64-bit counter and for an MMIO mapping without ACTMON counters.
- Improvement (patches 6 and 7): group CPUs by the generic "performance-domains" property, which cluster-based grouping cannot express on Tegra264. Device trees without it keep the existing grouping.
- Tegra264 support (patches 8 and 9): the driver support, followed by the device tree changes it relies on.
v2[2] -> v3:
- Patch 8: read the AMU counters with interrupts disabled (Zhongqiu).
- Add Reviewed-by from Zhongqiu to patches 1-7 and 9.
Quoted 6 lines
Quoted 3 lines
For patch 8/9:
Reviewed-by Zhongqiu Han <[email protected]>Why you cannot respond to specific patch? Tags applied to cover letter work completely different!
Hi Krzysztof,
Thanks for pointing this out. I’ll reply to the individual patches with the Reviewed-by tags in future reviews.
Quoted 4 lines
Best regards,
Krzysztof
Signature · 2 lines
Thx and BRs, Zhongqiu Han
Viresh Kumar
maintainerQuoted 2 lines · Sumit Gupta
This series adds cpufreq support for Tegra264, which joins the SoCs already supported by the tegra194-cpufreq driver.
Please rebase over
git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm.git cpufreq/arm/linux-next
The current series doesn't apply cleanly anymore.
Signature · 1 line
viresh
Hi Viresh,
Quoted 7 lines · Viresh Kumar
External email: Use caution opening links or attachments
Quoted 2 lines · Sumit Gupta
This series adds cpufreq support for Tegra264, which joins the SoCs already supported by the tegra194-cpufreq driver.
Quoted 8 lines
Please rebase over
git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm.gitcpufreq/arm/linux-nextThe current series doesn't apply cleanly anymore.
--
viresh
v3 was on linux-next, which has commit 4dd10fbbeb9c ("treewide: Convert devm_kmalloc() family to the devm_kmalloc_obj() family") from v7.4-rc2.
Your branch seems to be on v7.4-rc1, so v4 on it would conflict with that commit in mainline. Should I send v4 on your branch, or would you prefer to move it to v7.4-rc2 or later first?
Best Regards,
Sumit Gupta
Quoted 6 lines · Sumit Gupta
v3 was on linux-next, which has commit
4dd10fbbeb9c("treewide: Convertdevm_kmalloc()family to thedevm_kmalloc_obj()family") from v7.4-rc2.Your branch seems to be on v7.4-rc1, so v4 on it would conflict with that commit in mainline. Should I send v4 on your branch, or would you prefer to move it to v7.4-rc2 or later first?
I moved to rc2.
Applied. Thanks.
Signature · 1 line
viresh