Re: [PATCH v2 8/9] cpufreq: tegra194: Add support for Tegra264

From: Zhongqiu Han

Date: Tue Nov 17 2026 - 22:47:42 EST


On 11/17/2026 11:49 PM, Sumit Gupta wrote:
Add 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.

Signed-off-by: Sumit Gupta <sumitg@xxxxxxxxxx>
---
drivers/cpufreq/Kconfig.arm | 4 +-
drivers/cpufreq/tegra194-cpufreq.c | 161 ++++++++++++++++++++++++++++-
2 files changed, 158 insertions(+), 7 deletions(-)
+}
+
+/*
+ * The AMU counters are per-CPU system registers, so this must run on the CPU
+ * it samples. tegra194_calculate_speed() queues it there with queue_work_on().
+ */
+static void tegra264_sample_counters(struct tegra194_cpufreq_data *data,
+ struct tegra_cpu_ctr *c)
+{
+ c->coreclk_cnt = read_sysreg_s(SYS_AMEVCNTR0_CORE_EL0);
+ c->refclk_cnt = read_sysreg_s(SYS_AMEVCNTR0_CONST_EL0);


The core cycle counter and the constant counter are read separately
here, with interrupts enabled. An interrupt, or a preemption after it,
between the two reads skews the pair, and the resulting error in the
computed frequency becomes more significant as the gap increases. How
about reading both with local_irq_save(), like arm64 does in
amu_read_core_const_ctrs()?





--
Thx and BRs,
Zhongqiu Han