[U-Boot] [PATCH v3 022/108] x86: timer: Use a separate flag for whether timer is inited

Park, Aiden aiden.park at intel.com
Mon Oct 21 19:15:58 UTC 2019


> -----Original Message-----
> From: Simon Glass [mailto:sjg at chromium.org]
> Sent: Sunday, October 20, 2019 8:38 PM
> To: U-Boot Mailing List <u-boot at lists.denx.de>
> Cc: Bin Meng <bmeng.cn at gmail.com>; Simon Glass <sjg at chromium.org>;
> Andy Shevchenko <andy.shevchenko at gmail.com>; Bernhard Messerklinger
> <bernhard.messerklinger at br-automation.com>; Park, Aiden
> <aiden.park at intel.com>; Simon Goldschmidt
> <simon.k.r.goldschmidt at gmail.com>; Stefan Roese <sr at denx.de>
> Subject: [PATCH v3 022/108] x86: timer: Use a separate flag for whether
> timer is inited
> 
> At present the value of the timer base is used to determine whether the
> timer has been set up or not. It is true that the timer is essentially never
> exactly 0 when it is read. However 'time 0' may indicate the time that the
> machine was reset so it is useful to be able to denote that.
> 
> Update the code to use a separate flag instead.
> 
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
> 
> Changes in v3: None
> Changes in v2: None
> 
>  arch/x86/include/asm/global_data.h | 1 +
>  drivers/timer/tsc_timer.c          | 3 ++-
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/include/asm/global_data.h
> b/arch/x86/include/asm/global_data.h
> index 17a4d344913..7f3ada06f61 100644
> --- a/arch/x86/include/asm/global_data.h
> +++ b/arch/x86/include/asm/global_data.h
> @@ -76,6 +76,7 @@ struct arch_global_data {
>  	uint8_t x86_mask;
>  	uint32_t x86_device;
>  	uint64_t tsc_base;		/* Initial value returned by rdtsc() */
> +	bool tsc_inited;		/* true if tsc is ready for use */
>  	unsigned long clock_rate;	/* Clock rate of timer in Hz */
>  	void *new_fdt;			/* Relocated FDT */
>  	uint32_t bist;			/* Built-in self test value */
> diff --git a/drivers/timer/tsc_timer.c b/drivers/timer/tsc_timer.c index
> f19d2237e4f..637c8ff25a5 100644
> --- a/drivers/timer/tsc_timer.c
> +++ b/drivers/timer/tsc_timer.c
> @@ -394,7 +394,7 @@ static int tsc_timer_get_count(struct udevice *dev,
> u64 *count)
> 
>  static void tsc_timer_ensure_setup(bool early)  {
> -	if (gd->arch.tsc_base)
> +	if (gd->arch.tsc_inited)
>  		return;
>  	gd->arch.tsc_base = rdtsc();
> 
> @@ -425,6 +425,7 @@ static void tsc_timer_ensure_setup(bool early)
>  done:
>  		gd->arch.clock_rate = fast_calibrate * 1000000;
>  	}
> +	gd->arch.tsc_inited = true;
>  }
> 
>  static int tsc_timer_probe(struct udevice *dev)
> --
> 2.23.0.866.gb869b98d4c-goog

Verified with slimbootloader on QEMU and an APL board

Tested-by: Aiden Park <aiden.park at intel.com> 
Reviewed-by: Aiden Park <aiden.park at intel.com>

Best Regards,
Aiden


More information about the U-Boot mailing list