[coreboot-gerrit] Patch set updated for coreboot: util/cbmem: Scale time stamp values correctly

Paul Menzel (paulepanter@users.sourceforge.net) gerrit at coreboot.org
Mon Mar 14 19:03:04 CET 2016


Paul Menzel (paulepanter at users.sourceforge.net) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14086

-gerrit

commit 98544d6b4d694e03c8b8de899f9a87dfc2a19b70
Author: Aaron Durbin <adurbin at chromium.org>
Date:   Sat Mar 12 08:41:34 2016 +0100

    util/cbmem: Scale time stamp values correctly
    
    Commit c49014e (timestamp: add tick frequency to exported table)
    refactors the code, but forgets to correctly scale the frequency to
    megahertz, where the value is read from sysfs, so that printing time
    stamp information shows milliseconds instead of microseconds, as can be
    seen on the output `cbmem -t` for the ASRock E350M1 below.
    
    ```
       0:1st timestamp                                     515
      10:start of ramstage                                 515 (0)
      30:device enumeration                                515 (0)
      40:device configuration                              610 (94)
      50:device enable                                     614 (4)
      60:device initialization                             624 (9)
      70:device setup done                                 639 (14)
      75:cbmem post                                        844 (205)
      80:write tables                                      844 (0)
      90:load payload                                      849 (4)
      15:starting LZMA decompress (ignore for x86)         849 (0)
      16:finished LZMA decompress (ignore for x86)         869 (20)
      99:selfboot jump                                     869 (0)
    
    Total Time: 350
    ```
    
    So scale the return value correctly to megahertz, by dividing it with
    1000.
    
    ```
       0:1st timestamp                                     515,655
      10:start of ramstage                                 515,655 (0)
      30:device enumeration                                515,663 (7)
      40:device configuration                              610,620 (94,957)
      50:device enable                                     614,680 (4,059)
      60:device initialization                             624,618 (9,938)
      70:device setup done                                 639,553 (14,934)
      75:cbmem post                                        844,707 (205,154)
      80:write tables                                      844,710 (2)
      90:load payload                                      849,532 (4,821)
      15:starting LZMA decompress (ignore for x86)         849,655 (123)
      16:finished LZMA decompress (ignore for x86)         869,903 (20,247)
      99:selfboot jump                                     869,922 (19)
    
    Total Time: 354,261
    ```
    
    Change-Id: Iea032c62487c7946b6194a90268755034c6350df
    Signed-off-by: Aaron Durbin <adurbin at chromium.org>
    Signed-off-by: Paul Menzel <paulepanter at users.sourceforge.net>
---
 util/cbmem/cbmem.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/util/cbmem/cbmem.c b/util/cbmem/cbmem.c
index 4c563c8..5cc55da 100644
--- a/util/cbmem/cbmem.c
+++ b/util/cbmem/cbmem.c
@@ -362,7 +362,7 @@ static int parse_cbtable(u64 address, size_t table_size, uint8_t abort_on_failur
 
 #if defined(linux) && (defined(__i386__) || defined(__x86_64__))
 /*
- * read CPU frequency from a sysfs file, return an frequency in Kilohertz as
+ * read CPU frequency from a sysfs file, return an frequency in Megahertz as
  * an int or exit on any error.
  */
 static unsigned long arch_tick_frequency(void)
@@ -394,7 +394,8 @@ static unsigned long arch_tick_frequency(void)
 	rv = strtoull(freqs, &endp, 10);
 
 	if (*endp == '\0' || *endp == '\n')
-		return rv;
+	/* cpuinfo_max_freq is in kHz. Convert it to MHz. */
+		return rv / 1000;
 	fprintf(stderr, "Wrong formatted value ^%s^ read from %s\n",
 		freqs, freq_file);
 	exit(1);



More information about the coreboot-gerrit mailing list