From patchwork Mon May 22 11:05:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 765326 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3wWbYM4VVgz9s7p for ; Mon, 22 May 2017 21:10:31 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="qze21U99"; dkim-atps=neutral Received: by lists.denx.de (Postfix, from userid 105) id 34376C21C74; Mon, 22 May 2017 11:06:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 00D65C21C6D; Mon, 22 May 2017 11:05:47 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id AD01EC21C45; Mon, 22 May 2017 11:05:45 +0000 (UTC) Received: from mail-oi0-f54.google.com (mail-oi0-f54.google.com [209.85.218.54]) by lists.denx.de (Postfix) with ESMTPS id 29458C21C36 for ; Mon, 22 May 2017 11:05:45 +0000 (UTC) Received: by mail-oi0-f54.google.com with SMTP id b204so156462891oii.1 for ; Mon, 22 May 2017 04:05:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=PFJo2k1HFcxSs7eLUFDTbA7UXBttNHZU1Q1dY0e8csk=; b=qze21U997CPYI4jb/kluoy+jaFj4pQwH00Sim3dDMeSBuZ7V9tomv+6Z38R7LQvB3W SAwS3y1q7ZnSiTCOWqHpFcFE6YVDPCESYiTKdwK2lJgK3eraWzYWtRF/TZvCHQNfkUrg CD8Jqfqb710rF9GZI8hgAtS3Jc+J/RfaRjTMvWlBdQyCVP84HrCzwiWcP6PfW7+XsKqS SwXh+OzmC1R/QqEnvy8bEKvrYjMep2a9/ubUbUB2adZVpd+OXHeSQfyMZTVdX8sOKRvN hXSgswWSS2qoDBx4VBVa2eql9WByejc9+VC4FT7CrdM3G/shs2fHnXpujtNWluZ1VGXi bsKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=PFJo2k1HFcxSs7eLUFDTbA7UXBttNHZU1Q1dY0e8csk=; b=k3nayPFnZlPUAg3a4EoPI5eLdkXUBu5/wwYtXka4RbUoESOxgNa4fXvQRMb1BZqlPH zddqAx2wpOWTB9M/qvfJ8T5fV2T13Zp6aBHnXV5isgb33FmExZI2EN59fn3DXNZbp1SK FMsnTbJ8xMIxTDLE3zChaO1BTs7P2JJMq1aD2Mo5wEW2n77Dt3BCOOK0Ior9wIWHlNET 4oH2Lcg2WY1X8XFxDZJPQpxkjirzyqQw1JmIriVgiPeNze6AXjhRdDm19LHjT7iI2jFA 7dyCQ/MW+R14IJc1SRpcgABhFpD3MKCpyysYiXTdHyFdgMtbVa6nbPOs7kVKZnTq9nZQ bEgQ== X-Gm-Message-State: AODbwcDSMqEzKfg0q29HeWWM+huuwQ0dxv52p2bZBL4qBrqZog7FFWZF q81LT18SryEPdLaRyNJyHg== X-Received: by 10.202.242.84 with SMTP id q81mr11248306oih.47.1495451143899; Mon, 22 May 2017 04:05:43 -0700 (PDT) Received: from kaki.bld.corp.google.com ([100.100.184.96]) by smtp.gmail.com with ESMTPSA id d65sm4663273oia.17.2017.05.22.04.05.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 May 2017 04:05:43 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 5954A40564; Mon, 22 May 2017 05:05:41 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 22 May 2017 05:05:23 -0600 Message-Id: <20170522110536.6231-3-sjg@chromium.org> X-Mailer: git-send-email 2.13.0.303.g4ebf302169-goog In-Reply-To: <20170522110536.6231-1-sjg@chromium.org> References: <20170522110536.6231-1-sjg@chromium.org> Cc: Tom Rini Subject: [U-Boot] [PATCH 02/15] bootstage: Require timer_get_boot_us() to be defined X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" At present we provide a default version of this function for use by bootstage. However it uses the system timer and therefore likely requires driver model. This makes it impossible to time driver-model init. Drop the function and require boards to provide their own. Add a sandbox version also. There is a default implememtation in lib/time.c for boards which use CONFIG_SYS_TIMER_COUNTER. Signed-off-by: Simon Glass --- arch/sandbox/cpu/cpu.c | 11 +++++++++++ common/bootstage.c | 19 +------------------ include/bootstage.h | 3 ++- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c index 3fe99b853d..eefed2ebd9 100644 --- a/arch/sandbox/cpu/cpu.c +++ b/arch/sandbox/cpu/cpu.c @@ -139,3 +139,14 @@ done: return 0; } + +ulong timer_get_boot_us(void) +{ + static uint64_t base_count; + uint64_t count = os_get_nsec(); + + if (!base_count) + base_count = count; + + return (count - base_count) / 1000; +} diff --git a/common/bootstage.c b/common/bootstage.c index 35bce3d881..bcfbda99e5 100644 --- a/common/bootstage.c +++ b/common/bootstage.c @@ -8,7 +8,7 @@ /* * This module records the progress of boot and arbitrary commands, and * permits accurate timestamping of each. - * + * * TBD: Pass timings to kernel in the FDT */ @@ -292,23 +292,6 @@ void bootstage_report(void) } } -ulong __timer_get_boot_us(void) -{ - static ulong base_time; - - /* - * We can't implement this properly. Return 0 on the first call and - * larger values after that. - */ - if (base_time) - return get_timer(base_time) * 1000; - base_time = get_timer(0); - return 0; -} - -ulong timer_get_boot_us(void) - __attribute__((weak, alias("__timer_get_boot_us"))); - /** * Append data to a memory buffer * diff --git a/include/bootstage.h b/include/bootstage.h index a589be6316..6ee923c2eb 100644 --- a/include/bootstage.h +++ b/include/bootstage.h @@ -2,6 +2,7 @@ * This file implements recording of each stage of the boot process. It is * intended to implement timing of each stage, reporting this information * to the user and passing it to the OS for logging / further analysis. + * Note that it requires timer_get_boot_us() to be defined by the board * * Copyright (c) 2011 The Chromium OS Authors. * @@ -209,7 +210,7 @@ enum bootstage_id { /* * Return the time since boot in microseconds, This is needed for bootstage * and should be defined in CPU- or board-specific code. If undefined then - * millisecond resolution will be used (the standard get_timer()). + * you will get a link error. */ ulong timer_get_boot_us(void);