diff options
author | Aaron Durbin <adurbin@chromium.org> | 2016-02-10 11:01:49 -0600 |
---|---|---|
committer | Martin Roth <martinroth@google.com> | 2016-02-19 19:50:25 +0100 |
commit | 152e5a03a130cea3009685cbf7eb0ea354d9fd1c (patch) | |
tree | d84669468988416d9d37f15c54d5db3343363cd5 /payloads/libpayload/libc | |
parent | e0969aec2573872b9f528e33edd2cf3fb84c5948 (diff) | |
download | coreboot-152e5a03a130cea3009685cbf7eb0ea354d9fd1c.tar.xz |
libpayload: honor TSC information under CONFIG_LP_TIMER_RDTSC
When CONFIG_LP_TIMER_RDTSC is enabled honor the TSC information
exported in the coreboot tables as the cpu_khz frequency. That
allows get_cpu_speed() not to be called which currently relies
on the 8254 PIT. As certain x86 platforms allow that device
to be optional or turned off for power saving reasons, allow
a path where get_cpu_speed() is no longer called. Additionally,
this approach also allows the libpayload to not duplicate logic
that already exists in coreboot.
BUG=chrome-os-partner:50214
BRANCH=glados
TEST=Confirmed in payload TSC frequency is honored instead of
using get_cpu_speed().
Change-Id: Ib8993afdfb49065d43de705d6dbbdb9174b6f2c4
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://review.coreboot.org/13671
Tested-by: build bot (Jenkins)
Reviewed-by: Martin Roth <martinroth@google.com>
Reviewed-by: Andrey Petrov <andrey.petrov@intel.com>
Diffstat (limited to 'payloads/libpayload/libc')
-rw-r--r-- | payloads/libpayload/libc/coreboot.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/payloads/libpayload/libc/coreboot.c b/payloads/libpayload/libc/coreboot.c index 3e248e19c3..3abd610be2 100644 --- a/payloads/libpayload/libc/coreboot.c +++ b/payloads/libpayload/libc/coreboot.c @@ -231,6 +231,19 @@ static void cb_parse_boot_media_params(unsigned char *ptr, info->boot_media_size = bmp->boot_media_size; } +#if IS_ENABLED(CONFIG_LP_TIMER_RDTSC) +static void cb_parse_tsc_info(void *ptr, struct sysinfo_t *info) +{ + const struct cb_tsc_info *tsc_info = ptr; + + if (tsc_info->freq_khz == 0) + return; + + /* Honor the TSC frequency passed to the payload. */ + info->cpu_khz = tsc_info->freq_khz; +} +#endif + int cb_parse_header(void *addr, int len, struct sysinfo_t *info) { struct cb_header *header; @@ -386,6 +399,11 @@ int cb_parse_header(void *addr, int len, struct sysinfo_t *info) case CB_TAG_BOOT_MEDIA_PARAMS: cb_parse_boot_media_params(ptr, info); break; +#if IS_ENABLED(CONFIG_LP_TIMER_RDTSC) + case CB_TAG_TSC_INFO: + cb_parse_tsc_info(ptr, info); + break; +#endif default: cb_parse_arch_specific(rec, info); break; |