[OpenBIOS] [PATCH 2/7] PPC: Get timebase and clock speed from fw_cfg

Alexander Graf agraf at suse.de
Mon Feb 22 17:14:43 CET 2010


When running on Qemu (TCG) time goes by at a constant frequency which
accidently happens to match with Linux's fallback value.

As soon as we go to KVM, the time base suddenly starts going as fast as
the host CPU's time base. So we need to make sure Linux knows about
it, so it can do its timekeeping properly.

Signed-off-by: Alexander Graf <agraf at suse.de>
---
 arch/ppc/qemu/init.c      |   10 ++++++++++
 include/openbios/fw_cfg.h |    6 ++++++
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/arch/ppc/qemu/init.c b/arch/ppc/qemu/init.c
index 07fbd30..0363689 100644
--- a/arch/ppc/qemu/init.c
+++ b/arch/ppc/qemu/init.c
@@ -194,6 +194,16 @@ cpu_generic_init(const struct cpudef *cpu)
     push_str("icache-block-size");
     fword("property");
 
+    PUSH(fw_cfg_read_i32(FW_CFG_PPC_TBFREQ));
+    fword("encode-int");
+    push_str("timebase-frequency");
+    fword("property");
+
+    PUSH(fw_cfg_read_i32(FW_CFG_PPC_CPUFREQ));
+    fword("encode-int");
+    push_str("clock-frequency");
+    fword("property");
+
     push_str("running");
     fword("encode-string");
     push_str("state");
diff --git a/include/openbios/fw_cfg.h b/include/openbios/fw_cfg.h
index 72a67f6..7f8fa74 100644
--- a/include/openbios/fw_cfg.h
+++ b/include/openbios/fw_cfg.h
@@ -36,6 +36,12 @@
 #define FW_CFG_ARCH_LOCAL       0x8000
 #define FW_CFG_ENTRY_MASK       ~(FW_CFG_WRITE_CHANNEL | FW_CFG_ARCH_LOCAL)
 
+#define FW_CFG_PPC_WIDTH        (FW_CFG_ARCH_LOCAL + 0x00)
+#define FW_CFG_PPC_HEIGHT       (FW_CFG_ARCH_LOCAL + 0x01)
+#define FW_CFG_PPC_DEPTH        (FW_CFG_ARCH_LOCAL + 0x02)
+#define FW_CFG_PPC_TBFREQ       (FW_CFG_ARCH_LOCAL + 0x03)
+#define FW_CFG_PPC_CPUFREQ      (FW_CFG_ARCH_LOCAL + 0x04)
+
 #define FW_CFG_INVALID          0xffff
 
 #ifndef NO_QEMU_PROTOS
-- 
1.6.0.2




More information about the OpenBIOS mailing list