Kyösti Mälkki has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/36529 )
Change subject: arch/x86: Use TSC_MONOTONIC_TIMER for timestamps ......................................................................
arch/x86: Use TSC_MONOTONIC_TIMER for timestamps
Implementations with monotonic_timer can take benefit of the generic implementations of timestamp_get() and timestamp_freq_tick_mhz() in lib/timestamp.c.
Change-Id: I0adfbdeb456fbd6769fbd7f39421f797369876a8 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- M src/arch/x86/Kconfig M src/arch/x86/Makefile.inc M src/cpu/x86/tsc/Makefile.inc R src/cpu/x86/tsc/timestamp.c M src/soc/amd/stoneyridge/Kconfig M src/soc/amd/stoneyridge/monotonic_timer.c 6 files changed, 12 insertions(+), 33 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/29/36529/1
diff --git a/src/arch/x86/Kconfig b/src/arch/x86/Kconfig index 502e774..6c1dd48 100644 --- a/src/arch/x86/Kconfig +++ b/src/arch/x86/Kconfig @@ -291,21 +291,6 @@ the acpigen function. Default is _PR.CPxx. Note that you need the \ escape character in the string.
-config COLLECT_TIMESTAMPS_NO_TSC - bool - default n - depends on COLLECT_TIMESTAMPS - help - Use a non-TSC platform-dependent source for timestamps. - -config COLLECT_TIMESTAMPS_TSC - bool - default y if !COLLECT_TIMESTAMPS_NO_TSC - default n - depends on COLLECT_TIMESTAMPS - help - Use the TSC as the timestamp source. - config PAGING_IN_CACHE_AS_RAM bool default n diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc index 8d00174..ffbf0f3 100644 --- a/src/arch/x86/Makefile.inc +++ b/src/arch/x86/Makefile.inc @@ -110,7 +110,6 @@
bootblock-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c bootblock-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S -bootblock-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c bootblock-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
bootblock-y += id.S @@ -198,8 +197,6 @@ # which just calls verstage(). verstage-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += verstage.c
-verstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c - verstage-libs ?=
$(eval $(call early_x86_assembly_entry_rule,verstage)) @@ -230,7 +227,6 @@ romstage-y += memmove.c romstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c romstage-y += postcar_loader.c -romstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c romstage-$(CONFIG_ARCH_ROMSTAGE_X86_32) += walkcbfs.S
romstage-srcs += $(wildcard $(src)/mainboard/$(MAINBOARDDIR)/romstage.c) @@ -268,7 +264,6 @@ postcar-y += memlayout.ld postcar-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c postcar-y += postcar.c -postcar-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
LDFLAGS_postcar += -Map $(objcbfs)/postcar.map
@@ -316,7 +311,6 @@ ramstage-y += tables.c ramstage-$(CONFIG_COOP_MULTITASKING) += thread.c ramstage-$(CONFIG_COOP_MULTITASKING) += thread_switch.S -ramstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c ramstage-$(CONFIG_HAVE_ACPI_RESUME) += wakeup.S
ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y) diff --git a/src/cpu/x86/tsc/Makefile.inc b/src/cpu/x86/tsc/Makefile.inc index b3925b5..0afd05b 100644 --- a/src/cpu/x86/tsc/Makefile.inc +++ b/src/cpu/x86/tsc/Makefile.inc @@ -4,3 +4,9 @@ verstage-$(CONFIG_UDELAY_TSC) += delay_tsc.c postcar-$(CONFIG_UDELAY_TSC) += delay_tsc.c smm-$(CONFIG_UDELAY_TSC) += delay_tsc.c + +bootblock-$(CONFIG_LAPIC_MONOTONIC_TIMER) += timestamp.c +ramstage-$(CONFIG_LAPIC_MONOTONIC_TIMER) += timestamp.c +romstage-$(CONFIG_LAPIC_MONOTONIC_TIMER) += timestamp.c +verstage-$(CONFIG_LAPIC_MONOTONIC_TIMER) += timestamp.c +postcar-$(CONFIG_LAPIC_MONOTONIC_TIMER) += timestamp.c diff --git a/src/arch/x86/timestamp.c b/src/cpu/x86/tsc/timestamp.c similarity index 86% rename from src/arch/x86/timestamp.c rename to src/cpu/x86/tsc/timestamp.c index 8cf0f96..0100021 100644 --- a/src/arch/x86/timestamp.c +++ b/src/cpu/x86/tsc/timestamp.c @@ -21,10 +21,6 @@
int timestamp_tick_freq_mhz(void) { - /* Chipsets that have a constant TSC provide this value correctly. */ - if (tsc_constant_rate()) - return tsc_freq_mhz(); - /* Filling tick_freq_mhz = 0 in timestamps-table will trigger * userspace utility to try deduce it from the running system. */ diff --git a/src/soc/amd/stoneyridge/Kconfig b/src/soc/amd/stoneyridge/Kconfig index 0d6f2ff..1db6d55 100644 --- a/src/soc/amd/stoneyridge/Kconfig +++ b/src/soc/amd/stoneyridge/Kconfig @@ -46,7 +46,6 @@ select ARCH_RAMSTAGE_X86_32 select X86_AMD_FIXED_MTRRS select ACPI_AMD_HARDWARE_SLEEP_VALUES - select COLLECT_TIMESTAMPS_NO_TSC select DRIVERS_I2C_DESIGNWARE select GENERIC_GPIO_LIB select GENERIC_UDELAY diff --git a/src/soc/amd/stoneyridge/monotonic_timer.c b/src/soc/amd/stoneyridge/monotonic_timer.c index 7ea571f..00514da 100644 --- a/src/soc/amd/stoneyridge/monotonic_timer.c +++ b/src/soc/amd/stoneyridge/monotonic_timer.c @@ -15,17 +15,11 @@
#include <cpu/x86/msr.h> #include <timer.h> -#include <timestamp.h>
#define CU_PTSC_MSR 0xc0010280 #define PTSC_FREQ_MHZ 100
-void timer_monotonic_get(struct mono_time *mt) -{ - mono_time_set_usecs(mt, timestamp_get()); -} - -uint64_t timestamp_get(void) +static uint64_t ptsc_get(void) { unsigned long long val; msr_t msr; @@ -36,3 +30,8 @@
return val / PTSC_FREQ_MHZ; } + +void timer_monotonic_get(struct mono_time *mt) +{ + mono_time_set_usecs(mt, ptsc_get()); +}