From patchwork Tue Jan 6 05:20:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 425531 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 323D814009B for ; Tue, 6 Jan 2015 16:20:39 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A1C284B672; Tue, 6 Jan 2015 06:20:37 +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 xD+J6cusijoa; Tue, 6 Jan 2015 06:20:37 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 161094B667; Tue, 6 Jan 2015 06:20:37 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CEBD94B62A for ; Tue, 6 Jan 2015 06:20:29 +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 Sq16T8LCh7Ln for ; Tue, 6 Jan 2015 06:20:29 +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-pd0-f171.google.com (mail-pd0-f171.google.com [209.85.192.171]) by theia.denx.de (Postfix) with ESMTPS id 1DC934B627 for ; Tue, 6 Jan 2015 06:20:26 +0100 (CET) Received: by mail-pd0-f171.google.com with SMTP id y13so29619664pdi.16 for ; Mon, 05 Jan 2015 21:20:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=PbWLKo1CRiGi4FKvUlHI6HfZ4TfdKulmmmxJqfV1N0s=; b=sxc3pDxPvduoAhOut4uqzpQbxvAaISR+DpfIJmP0NRMNR78b5KmGS0xLoOkDAkOAXg 9x87w/KzVM1PJgeKEUXlfTnkBjZ28oGFUBNNlIW7e/Oc5G6kbJ9dIcN6VL2viO2Jr4MS Iu53r+JZbFGSQhhRl32qVxDheAFeZiZOxmt4sGPei16PfbLAxRL3E0YUUCEjiDQAznoE AlCk4TzALpTK4AWT+x/rRdSkKLQk2TaCLBuHEPpnI9pTYBljb6M6TMMCa/YZoKU92Kzm o5I7GYZJD0uvqcilYdGs5GihDGuqEQwyLdA0KcOQNF9+hNQP0xiR0BRjevcGYasfy4o3 /kMw== X-Received: by 10.70.33.177 with SMTP id s17mr91382437pdi.9.1420521624927; Mon, 05 Jan 2015 21:20:24 -0800 (PST) Received: from localhost ([106.120.101.38]) by mx.google.com with ESMTPSA id ds16sm55716924pdb.65.2015.01.05.21.20.23 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 05 Jan 2015 21:20:24 -0800 (PST) From: Bin Meng To: Simon Glass , U-Boot Mailing List Date: Tue, 6 Jan 2015 13:20:03 +0800 Message-Id: <1420521614-13175-2-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1420521614-13175-1-git-send-email-bmeng.cn@gmail.com> References: <1420521614-13175-1-git-send-email-bmeng.cn@gmail.com> Subject: [U-Boot] [PATCH v4 01/12] x86: coreboot: Set up 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. Sometimes even coreboot is built with CONFIG_COLLECT_TIMESTAMPS, 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 --- Changes in v4: None Changes in v3: None Changes in v2: - Fix the CONFIG_COLLECT_TIMESTAMPS typo in the comment block and commit message 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..0edee6b 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. + * + * Sometimes even coreboot is built with CONFIG_COLLECT_TIMESTAMPS, + * 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); }