[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 9/9] spapr.c: handle clock freq read errors in spapr_dt_cpu()
From: |
Daniel Henrique Barboza |
Subject: |
[PATCH 9/9] spapr.c: handle clock freq read errors in spapr_dt_cpu() |
Date: |
Thu, 30 Jun 2022 16:42:49 -0300 |
Let's put the default spapr clock value in a SPAPR_CLOCK_FREQ for better
readability.
After that, make 'cpufreq' default to SPAPR_CLOCK_FREQ if
kvmppc_get_clockfreq() fails to read the clock from the DT.
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
hw/ppc/spapr.c | 12 +++++++++++-
include/hw/ppc/spapr.h | 1 +
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index f66e3cbe38..80189c78be 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -654,7 +654,7 @@ static void spapr_dt_cpu(CPUState *cs, void *fdt, int
offset,
0xffffffff, 0xffffffff};
uint32_t tbfreq = kvm_enabled() ? kvmppc_get_tbfreq()
: SPAPR_TIMEBASE_FREQ;
- uint32_t cpufreq = kvm_enabled() ? kvmppc_get_clockfreq(NULL) : 1000000000;
+ uint32_t cpufreq = SPAPR_CLOCK_FREQ;
uint32_t page_sizes_prop[64];
size_t page_sizes_prop_size;
unsigned int smp_threads = ms->smp.threads;
@@ -699,6 +699,16 @@ static void spapr_dt_cpu(CPUState *cs, void *fdt, int
offset,
}
_FDT((fdt_setprop_cell(fdt, offset, "timebase-frequency", tbfreq)));
+
+ if (kvm_enabled()) {
+ Error *local_err = NULL;
+
+ cpufreq = kvmppc_get_clockfreq(&local_err);
+ if (local_err) {
+ cpufreq = SPAPR_CLOCK_FREQ;
+ }
+ }
+
_FDT((fdt_setprop_cell(fdt, offset, "clock-frequency", cpufreq)));
_FDT((fdt_setprop_cell(fdt, offset, "slb-size",
cpu->hash64_opts->slb_size)));
_FDT((fdt_setprop_cell(fdt, offset, "ibm,slb-size",
cpu->hash64_opts->slb_size)));
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 072dda2c72..ed579635ca 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -26,6 +26,7 @@ typedef struct SpaprPendingHpt SpaprPendingHpt;
#define SPAPR_ENTRY_POINT 0x100
#define SPAPR_TIMEBASE_FREQ 512000000ULL
+#define SPAPR_CLOCK_FREQ 1000000000ULL
#define TYPE_SPAPR_RTC "spapr-rtc"
--
2.36.1
- [PATCH 0/9] cleanup error handling in kvmppc_read_int_cpu_dt(), Daniel Henrique Barboza, 2022/06/30
- [PATCH 1/9] target/ppc/kvm.c: do not return -1 on uint64_t return, Daniel Henrique Barboza, 2022/06/30
- [PATCH 4/9] target/ppc: use g_autofree in kvmppc_read_int_cpu_dt(), Daniel Henrique Barboza, 2022/06/30
- [PATCH 2/9] target/ppc: add errp to kvmppc_read_int_cpu_dt(), Daniel Henrique Barboza, 2022/06/30
- [PATCH 9/9] spapr.c: handle clock freq read errors in spapr_dt_cpu(),
Daniel Henrique Barboza <=
- [PATCH 6/9] ppc440_bamboo.c: handle clock freq read error in load_device_tree, Daniel Henrique Barboza, 2022/06/30
- [PATCH 3/9] target/ppc: Add error reporting when opening file fails, Daniel Henrique Barboza, 2022/06/30
- [PATCH 5/9] target/ppc: use Error pointer in kvmppc_get_clockfreq(), Daniel Henrique Barboza, 2022/06/30
- [PATCH 7/9] sam460ex.c: use CPU_FREQ if unable to read DT clock, Daniel Henrique Barboza, 2022/06/30
- [PATCH 8/9] e500.c: use PLATFORM_CLK_FREQ_HZ if unable to read clock freq from DT, Daniel Henrique Barboza, 2022/06/30