Page MenuHomeFreeBSD

D48124.id148176.diff
No OneTemporary

D48124.id148176.diff

diff --git a/sys/conf/files.riscv b/sys/conf/files.riscv
--- a/sys/conf/files.riscv
+++ b/sys/conf/files.riscv
@@ -4,6 +4,7 @@
cddl/dev/dtrace/riscv/instr_size.c optional dtrace compile-with "${DTRACE_C}"
cddl/dev/fbt/riscv/fbt_isa.c optional dtrace_fbt | dtraceall compile-with "${FBT_C}"
crypto/des/des_enc.c optional netsmb
+dev/cpufreq/cpufreq_dt.c optional cpufreq fdt
dev/ofw/ofw_cpu.c optional fdt
dev/ofw/ofw_pcib.c optional pci fdt
dev/pci/pci_dw.c optional pci fdt
diff --git a/sys/dev/cpufreq/cpufreq_dt.c b/sys/dev/cpufreq/cpufreq_dt.c
--- a/sys/dev/cpufreq/cpufreq_dt.c
+++ b/sys/dev/cpufreq/cpufreq_dt.c
@@ -401,7 +401,7 @@
if (opp_table == opp_xref)
return (ENXIO);
- if (!OF_hasprop(opp_table, "opp-shared")) {
+ if (!OF_hasprop(opp_table, "opp-shared") && mp_ncpus > 1) {
device_printf(sc->dev, "Only opp-shared is supported\n");
return (ENXIO);
}
diff --git a/sys/riscv/conf/GENERIC b/sys/riscv/conf/GENERIC
--- a/sys/riscv/conf/GENERIC
+++ b/sys/riscv/conf/GENERIC
@@ -90,6 +90,9 @@
device syscon_power
device riscv_syscon
+# CPU frequency control
+device cpufreq
+
# Bus drivers
device pci
diff --git a/sys/riscv/include/pcpu.h b/sys/riscv/include/pcpu.h
--- a/sys/riscv/include/pcpu.h
+++ b/sys/riscv/include/pcpu.h
@@ -46,7 +46,8 @@
struct pmap *pc_curpmap; /* Currently active pmap */ \
uint32_t pc_pending_ipis; /* IPIs pending to this CPU */ \
uint32_t pc_hart; /* Hart ID */ \
- char __pad[56] /* Pad to factor of PAGE_SIZE */
+ uint64_t pc_clock; \
+ char __pad[48] /* Pad to factor of PAGE_SIZE */
#ifdef _KERNEL
diff --git a/sys/riscv/riscv/machdep.c b/sys/riscv/riscv/machdep.c
--- a/sys/riscv/riscv/machdep.c
+++ b/sys/riscv/riscv/machdep.c
@@ -222,8 +222,18 @@
int
cpu_est_clockrate(int cpu_id, uint64_t *rate)
{
+ struct pcpu *pc;
- panic("cpu_est_clockrate");
+ pc = pcpu_find(cpu_id);
+ if (pc == NULL || rate == NULL)
+ return (EINVAL);
+
+ if (pc->pc_clock == 0)
+ return (EOPNOTSUPP);
+
+ *rate = pc->pc_clock;
+
+ return (0);
}
void

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 21, 7:28 AM (49 m, 53 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30070025
Default Alt Text
D48124.id148176.diff (2 KB)

Event Timeline