From 5436047a0e1f32543042d6de9f1f6a3edcd47591 Mon Sep 17 00:00:00 2001 From: Marcin Juszkiewicz Date: Mon, 22 Apr 2024 17:27:56 +0200 Subject: [PATCH] refactor(qemu): do not hardcode counter frequency From QEMU change: > In previous versions of the Arm architecture, the frequency of the > generic timers as reported in CNTFRQ_EL0 could be any IMPDEF value, > and for QEMU we picked 62.5MHz, giving a timer tick period of 16ns. > In Armv8.6, the architecture standardized this frequency to 1GHz. This change stops TF-A from hardcoding 62.5MHz frequency. Instead value stored in CNTFRQ_EL0 would be used. As a result we get 62.5MHz on older cores and 1GHz on newer ones. Change-Id: I7d414ce6d3708e598bbb5a6f79eb2d4ec8e15ac4 Signed-off-by: Marcin Juszkiewicz --- plat/qemu/common/qemu_bl31_setup.c | 2 +- plat/qemu/qemu/include/platform_def.h | 5 ----- plat/qemu/qemu_sbsa/include/platform_def.h | 5 ----- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/plat/qemu/common/qemu_bl31_setup.c b/plat/qemu/common/qemu_bl31_setup.c index a627ed7ab..0a70cc298 100644 --- a/plat/qemu/common/qemu_bl31_setup.c +++ b/plat/qemu/common/qemu_bl31_setup.c @@ -161,7 +161,7 @@ void bl31_platform_setup(void) unsigned int plat_get_syscnt_freq2(void) { - return SYS_COUNTER_FREQ_IN_TICKS; + return read_cntfrq_el0(); } /******************************************************************************* diff --git a/plat/qemu/qemu/include/platform_def.h b/plat/qemu/qemu/include/platform_def.h index 4e0b50ad8..95620d3c6 100644 --- a/plat/qemu/qemu/include/platform_def.h +++ b/plat/qemu/qemu/include/platform_def.h @@ -301,11 +301,6 @@ #define PLAT_SDEI_NORMAL_PRI 0x70 #define PLAT_SDEI_SGI_PRIVATE QEMU_IRQ_SEC_SGI_0 -/* - * System counter - */ -#define SYS_COUNTER_FREQ_IN_TICKS ((1000 * 1000 * 1000) / 16) - /* * Maximum size of Event Log buffer used in Measured Boot Event Log driver */ diff --git a/plat/qemu/qemu_sbsa/include/platform_def.h b/plat/qemu/qemu_sbsa/include/platform_def.h index e8f0344ff..d23009543 100644 --- a/plat/qemu/qemu_sbsa/include/platform_def.h +++ b/plat/qemu/qemu_sbsa/include/platform_def.h @@ -266,11 +266,6 @@ #define PLAT_QEMU_DT_BASE NS_DRAM0_BASE #define PLAT_QEMU_DT_MAX_SIZE 0x100000 -/* - * System counter - */ -#define SYS_COUNTER_FREQ_IN_TICKS ((1000 * 1000 * 1000) / 16) - #if SPM_MM #define PLAT_QEMU_SP_IMAGE_BASE BL_RAM_BASE #define PLAT_QEMU_SP_IMAGE_SIZE ULL(0x300000)