qemu-ppc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 6/9] ppc440_bamboo.c: handle clock freq read error in load_de


From: Cédric Le Goater
Subject: Re: [PATCH 6/9] ppc440_bamboo.c: handle clock freq read error in load_device_tree
Date: Sat, 2 Jul 2022 08:23:03 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0

On 6/30/22 21:42, Daniel Henrique Barboza wrote:
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) {

may be report the error to the user ?

+            clock_freq = PPC440EP_CLOCK_FREQ;
+        }
      }
qemu_fdt_setprop_cell(fdt, "/cpus/cpu@0", "clock-frequency",




reply via email to

[Prev in Thread] Current Thread [Next in Thread]