From patchwork Sat Jan 3 14:40:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 425115 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 758FE14007F for ; Sun, 4 Jan 2015 01:40:58 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E82564B67B; Sat, 3 Jan 2015 15:40:54 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id w0B347aSvop2; Sat, 3 Jan 2015 15:40:54 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0182F4B670; Sat, 3 Jan 2015 15:40:54 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5CF3D4B659 for ; Sat, 3 Jan 2015 15:40:51 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jkumsq7FQil5 for ; Sat, 3 Jan 2015 15:40:51 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pa0-f43.google.com (mail-pa0-f43.google.com [209.85.220.43]) by theia.denx.de (Postfix) with ESMTPS id 0A7F44B67F for ; Sat, 3 Jan 2015 15:40:42 +0100 (CET) Received: by mail-pa0-f43.google.com with SMTP id kx10so25783497pab.30 for ; Sat, 03 Jan 2015 06:40:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=t3d6lR7oxep+7G6cgnJFih6acox8Ew8437SfQZ12F30=; b=E7wgQj9tbD4V+LxxtPdferTHauhzgQODOMuWIebqGDWGAhcbeYRp6DmwjaO2cBipK1 g73hucHS0r0xfeox1F7SQTBBBrYVpXIPlT4Rw2X0KVuaQimRZjj2dsCz+Aatqj6pTIAs PCci7QzUSDKLJNJ3tnV58y3EVSNhxajSTBomWG41ZUtMgIWWGB27zl+j6zZxzb+eJ7dT A/Qq97EMoV4ehyjxRTsjsKH4XZU0pvCjxLfYbwzezXpIHiMC3GH4siPq3kVmhilAOfV+ 2x7c5zUfr4rPA0PTpOb+eoU+ZBAwNFHi5mHIrTTahjWoNlvwV2uxarucCzvbhpCtsuyk kurA== X-Received: by 10.66.251.167 with SMTP id zl7mr132763319pac.140.1420296040724; Sat, 03 Jan 2015 06:40:40 -0800 (PST) Received: from localhost ([106.120.101.38]) by mx.google.com with ESMTPSA id mb9sm20858632pdb.40.2015.01.03.06.40.38 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 03 Jan 2015 06:40:40 -0800 (PST) From: Bin Meng To: Simon Glass , U-Boot Mailing List Date: Sat, 3 Jan 2015 22:40:24 +0800 Message-Id: <1420296026-8764-2-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1420296026-8764-1-git-send-email-bmeng.cn@gmail.com> References: <1420296026-8764-1-git-send-email-bmeng.cn@gmail.com> Subject: [U-Boot] [PATCH 1/3] x86: coreboot: Setup timer base correctly X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.13 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de If coreboot is built with CONFIG_COLLECT_TIMESTAMPS, use the value of base_time in coreboot's timestamp table as our timer base, otherwise TSC counter value will be used. Note sometimes even coreboot is built with CONFIG_COLLECT_TIMES, the value of base_time in the timestamp table is still zero, so we must exclude this case too (this is currently seen on booting coreboot in qemu). Signed-off-by: Bin Meng Acked-by: Simon Glass --- arch/x86/cpu/coreboot/timestamp.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/arch/x86/cpu/coreboot/timestamp.c b/arch/x86/cpu/coreboot/timestamp.c index bd3558a..e6b8790 100644 --- a/arch/x86/cpu/coreboot/timestamp.c +++ b/arch/x86/cpu/coreboot/timestamp.c @@ -3,18 +3,7 @@ * * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA + * SPDX-License-Identifier: GPL-2.0+ */ #include @@ -38,9 +27,27 @@ static struct timestamp_table *ts_table __attribute__((section(".data"))); void timestamp_init(void) { +#ifdef CONFIG_SYS_X86_TSC_TIMER + uint64_t base_time; +#endif + ts_table = lib_sysinfo.tstamp_table; #ifdef CONFIG_SYS_X86_TSC_TIMER - timer_set_base(ts_table->base_time); + /* + * If coreboot is built with CONFIG_COLLECT_TIMESTAMPS, use the value + * of base_time in coreboot's timestamp table as our timer base, + * otherwise TSC counter value will be used. + * + * Note sometimes even coreboot is built with CONFIG_COLLECT_TIMES, + * the value of base_time in the timestamp table is still zero, so + * we must exclude this case too (this is currently seen on booting + * coreboot in qemu) + */ + if (ts_table && ts_table->base_time) + base_time = ts_table->base_time; + else + base_time = rdtsc(); + timer_set_base(base_time); #endif timestamp_add_now(TS_U_BOOT_INITTED); }