From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8BAA0C54EE9 for ; Sun, 4 Sep 2022 08:54:18 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A190183FA1; Sun, 4 Sep 2022 10:54:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=walle.cc Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=walle.cc header.i=@walle.cc header.b="FR3G73QB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A201883FA1; Sun, 4 Sep 2022 10:54:15 +0200 (CEST) Received: from mail.3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E34C284001 for ; Sun, 4 Sep 2022 10:54:12 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=walle.cc Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=michael@walle.cc Received: from 3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id 00DE81D59; Sun, 4 Sep 2022 10:54:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1662281652; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tm8HfYFxbrhHX0VcBb70NM+i7r7y1yyDRrbBaffAPO0=; b=FR3G73QBxh3e9EJtwz/GzgZgStJPRPHbdRU4orZtBhefmjEcIsE/G2awx52CSGt7fgyA7B PCefSEdbJX3odx0gmfjFM5K2b7x2kuZlbAix0XVx3EjhBfG3U1WahfUOG/pnKuinnqUINB ac853JUKQonK3FBQFFyeRxv3ebO1fhVYB+eNeJawn5r1mA4T8ZANVbr/v4qAnCRZLRePYU 126wA/I6FfAdBUYi/r7yZqvVD4peQbWjirxzXEVpLAuvA1de8PDlIZDxfnmuPOQfmy87wH fG+81EOcZmGwe1HAlsD0AYh1iy+9oFCBISeaioSSa/WWF4qO+og4NE3aSIUUVw== MIME-Version: 1.0 Date: Sun, 04 Sep 2022 10:54:11 +0200 From: Michael Walle To: Tony Dinh Cc: Stefan Roese , U-Boot Mailing List , =?UTF-8?Q?Pali_Roh=C3=A1r?= , Simon Glass Subject: Re: [PATCH v2 3/8] timer: orion-timer: Add timer_get_boot_us() for BOOTSTAGE support In-Reply-To: References: <20220902062554.1197435-1-sr@denx.de> <20220902062554.1197435-4-sr@denx.de> <3e1fdcaf-2d9d-bcfb-3067-d8c723af52cb@denx.de> User-Agent: Roundcube Webmail/1.4.13 Message-ID: X-Sender: michael@walle.cc Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Am 2022-09-04 02:02, schrieb Tony Dinh: > Hi Stefan, > > Sorry, that message was prematurely sent (fat finger). Please see the > continuation below. > > On Sat, Sep 3, 2022 at 4:43 PM Tony Dinh wrote: >> >> Hi Stefan, >> >> On Sat, Sep 3, 2022 at 3:44 AM Stefan Roese wrote: >> > >> > Hi Tony, >> > >> > On 03.09.22 11:44, Tony Dinh wrote: >> > > Hi Stefan, >> > > >> > > On Thu, Sep 1, 2022 at 11:25 PM Stefan Roese wrote: >> > >> >> > >> Add timer_get_boot_us() to support boards, that have CONFIG_BOOTSTAGE >> > >> enabled, like pogo_v4. >> > >> >> > >> Signed-off-by: Stefan Roese >> > >> --- >> > >> v2: >> > >> - Change timer_get_boot_us() to use the timer_early functions >> > >> - Remove #if CONFIG_IS_ENABLED(BOOTSTAGE) >> > >> >> > >> Simon, I'm currently looking into this timer_get_boot_us() to using >> > >> timer_early_get_count() etc consolidation. >> > > >> > > Indeed, as you've mentioned above, I think timer_early_get_count() and >> > > timer_early_get_rate() do need to take into consideration what the >> > > input_clock_type is for Kirkwood boards with CONFIG_BOOTSTAGE such as >> > > the Pogo V4. >> > > >> > > I'm seeing on the Pogo V4 test, the timer command reports time about 6 >> > > times slower than it should. It does seem to jive with the fact that >> > > the Pogo V4 CONFIG_SYS_TCLK is 166Mhz, versus MVEBU 25MHz clock rate. >> > >> > Ah, I've missing updating the early functions to also differentiate >> > between fixed clocks and TCLK timer. >> > >> > Please give the attached patch a try - should be applied on top of this >> > latest patchset. >> > > That looks promising, but I think we are still missing something. > After applying the attached patch, I ran the test again and it behaved > the same way (clock rate 6 times slower). So I did another test. > > --- Test 1 > Pogo_V4> timer start; sleep 60; timer get; sleep 30; timer get > 60.000 > 90.000 > > So apparently the sleep cmd has reset the correct clock rate. > > --- Test 2 > > Pogo_V4> timer start; sleep 30; timer get; sleep 30; timer get > 30.000 > 60.000 > > And then wait for 30 seconds, do another "timer get" (I expected to > see about 90 to 95 seconds). > > Pogo_V4> timer get > 66.237 I've did the same test and can confirm it. But I think that is a drawback from the timer command. With a 32bit timer and a TCLK of 166MHz (on my board), the timer will wrap around about every 26s. So if you don't do a get_timer() call for that whole period, the overflow won't be counted in timer_conv_64(). For the sleep command it works correctly, because it will poll get_timer() every 100us. In summary, you cannot expect a "timer get" on the console to work if you cannot make sure, the you call it at least every "2^32 / TCLK" seconds. -michael