Skip to content

Commit 0b87cb1

Browse files
aescolarjhedberg
authored andcommitted
Revert "drivers: timer: tsc: retrieve clock frequency of system timer at runtime"
This reverts commit d82f4a9. #69705 Introduced a regression in main in which tests/subsys/logging/log_timestamp started failing. (See #72344 for more info). Let's revert the PR. It can be submitted after with the issue fixed. Signed-off-by: Alberto Escolar Piedras <[email protected]>
1 parent ba4bbe9 commit 0b87cb1

File tree

1 file changed

+1
-26
lines changed

1 file changed

+1
-26
lines changed

drivers/timer/apic_tsc.c

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,12 @@
88
#include <zephyr/spinlock.h>
99
#include <zephyr/drivers/interrupt_controller/loapic.h>
1010
#include <zephyr/irq.h>
11-
#include <cpuid.h>
1211

1312
#define IA32_TSC_DEADLINE_MSR 0x6e0
1413
#define IA32_TSC_ADJUST_MSR 0x03b
1514

16-
#ifdef CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME
17-
static uint64_t CYC_PER_TICK;
18-
extern int z_clock_hw_cycles_per_sec;
19-
#else
2015
#define CYC_PER_TICK (CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC \
2116
/ (uint64_t) CONFIG_SYS_CLOCK_TICKS_PER_SEC)
22-
#endif
2317

2418
struct apic_timer_lvt {
2519
uint8_t vector : 8;
@@ -164,11 +158,9 @@ static inline void cpuid(uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *
164158

165159
static int sys_clock_driver_init(void)
166160
{
167-
#if defined(CONFIG_ASSERT) || defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
161+
#ifdef CONFIG_ASSERT
168162
uint32_t eax, ebx, ecx, edx;
169-
#endif
170163

171-
#ifdef CONFIG_ASSERT
172164
eax = 1; ecx = 0;
173165
cpuid(&eax, &ebx, &ecx, &edx);
174166
__ASSERT((ecx & BIT(24)) != 0, "No TSC Deadline support");
@@ -182,23 +174,6 @@ static int sys_clock_driver_init(void)
182174
__ASSERT((ebx & BIT(1)) != 0, "No TSC_ADJUST MSR support");
183175
#endif
184176

185-
#ifdef CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME
186-
int tsc_freq;
187-
188-
eax = 0;
189-
ebx = 0;
190-
ecx = 0;
191-
if (!__get_cpuid(0x15, &eax, &ebx, &ecx, &edx)) {
192-
__ASSERT(false, "error cpuid leaf 0x15\n");
193-
}
194-
195-
__ASSERT((ebx != 0) && (ecx != 0), "No TSC/core crystal clock ratio is enumerated");
196-
197-
tsc_freq = (uint32_t)((ecx * (uint64_t)ebx) / eax);
198-
z_clock_hw_cycles_per_sec = tsc_freq;
199-
CYC_PER_TICK = tsc_freq/CONFIG_SYS_CLOCK_TICKS_PER_SEC;
200-
#endif
201-
202177
clear_tsc_adjust();
203178

204179
/* Timer interrupt number is runtime-fetched, so can't use

0 commit comments

Comments
 (0)