[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 6/9] ppc440_bamboo.c: handle clock freq read error in load_device
From: |
Daniel Henrique Barboza |
Subject: |
[PATCH 6/9] ppc440_bamboo.c: handle clock freq read error in load_device_tree |
Date: |
Thu, 30 Jun 2022 16:42:46 -0300 |
Let's put the default clock and timebase freq value in macros for better
readability. Use PPC440EP_CLOCK_FREQ as the default value of
'clock_freq' if kvmppc_get_clockfreq() throws an error.
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
hw/ppc/ppc440_bamboo.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c
index d23f881d9d..6318112393 100644
--- a/hw/ppc/ppc440_bamboo.c
+++ b/hw/ppc/ppc440_bamboo.c
@@ -50,6 +50,10 @@
#define PPC440EP_SDRAM_NR_BANKS 4
+#define PPC440EP_TB_FREQ 400000000
+#define PPC440EP_CLOCK_FREQ 400000000
+
+
static const ram_addr_t ppc440ep_sdram_bank_sizes[] = {
256 * MiB, 128 * MiB, 64 * MiB, 32 * MiB, 16 * MiB, 8 * MiB, 0
};
@@ -67,8 +71,8 @@ static int bamboo_load_device_tree(hwaddr addr,
char *filename;
int fdt_size;
void *fdt;
- uint32_t tb_freq = 400000000;
- uint32_t clock_freq = 400000000;
+ uint32_t tb_freq = PPC440EP_TB_FREQ;
+ uint32_t clock_freq = PPC440EP_CLOCK_FREQ;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
if (!filename) {
@@ -106,8 +110,15 @@ static int bamboo_load_device_tree(hwaddr addr,
* directly access the timebase without host involvement, we must expose
* the correct frequencies. */
if (kvm_enabled()) {
+ Error *local_err = NULL;
+
tb_freq = kvmppc_get_tbfreq();
- clock_freq = kvmppc_get_clockfreq(NULL);
+ clock_freq = kvmppc_get_clockfreq(&local_err);
+
+ /* Use default clock if we're unable to read it from the DT */
+ if (local_err) {
+ clock_freq = PPC440EP_CLOCK_FREQ;
+ }
}
qemu_fdt_setprop_cell(fdt, "/cpus/cpu@0", "clock-frequency",
--
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, 2022/06/30
- [PATCH 6/9] ppc440_bamboo.c: handle clock freq read error in load_device_tree,
Daniel Henrique Barboza <=
- [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