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@chromium.org>
Signed-off-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-on: https://review.coreboot.org/14086
Tested-by: build bot (Jenkins)
Reviewed-by: Martin Roth <martinroth@google.com>
Reviewed-by: Timothy Pearson <tpearson@raptorengineeringinc.com>
This commit is contained in:
Aaron Durbin 2016-03-12 08:41:34 +01:00 committed by Timothy Pearson
parent 15fca66bf0
commit 08e920e50d
1 changed files with 3 additions and 2 deletions

View File

@ -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);