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 6B062C63797 for ; Tue, 17 Jan 2023 11:47:20 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1840F853BE; Tue, 17 Jan 2023 12:47:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1673956038; bh=29ExD2tQw+U8s1DTXMRmAG+e29oJebavV8nJVE8A36Q=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ONQ8LGQa/IyYPPaac4aAMWLNsc1mgvFXPr9GUtxUmTPiYxZYkr5j1QtcEGUXAHHwV dsJofqT8XhttioL5fSIZoEOwGujw6oHUoJfm7Gem9tXktNJB8TpVnfmgsno/iNPqGD 5t3B5esY7B+1VXFtOOFNZRrB6mmw2WPHS9GePL8YE2PunZg+axxTHBnzhm8L9CY4dv pbkEWxNOgPiuiYAtvPDP/+iMe9XW+Dn9x9GJNE7nw9ezfuCexdzaMgN5XhzMF5qI+o CDNEl6fzaKwbPUxmpssr0gSOuJE6uJHW3b9YMn7wi+S7/Negx5Ey78GuokqJw+nhLi 1Z1x8iT/Z/hvA== Received: by phobos.denx.de (Postfix, from userid 109) id 47C908559B; Tue, 17 Jan 2023 12:47:17 +0100 (CET) Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [IPv6:2001:67c:2050:101:465::204]) (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 D7E5785103 for ; Tue, 17 Jan 2023 12:47:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4Nx6Z74Twtz9sTF; Tue, 17 Jan 2023 12:47:11 +0100 (CET) Message-ID: <376498b6-9ded-9809-2873-ca8bca75c9ab@denx.de> Date: Tue, 17 Jan 2023 12:47:10 +0100 MIME-Version: 1.0 Subject: Re: [PATCH] timer: orion-timer: Fix problem in early_init_done() Content-Language: en-US To: =?UTF-8?Q?Pali_Roh=c3=a1r?= Cc: u-boot@lists.denx.de, Martin Rowe , Tony Dinh , Michael Walle References: <20230116153445.145580-1-sr@denx.de> <20230116175421.okfslfs3phjbzdvs@pali> From: Stefan Roese In-Reply-To: <20230116175421.okfslfs3phjbzdvs@pali> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4Nx6Z74Twtz9sTF 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 On 1/16/23 18:54, Pali Rohár wrote: > On Monday 16 January 2023 16:34:45 Stefan Roese wrote: >> It was noticed that Clearfog is currently broken with this newly >> introduced early_init_done() function. Apparently the timer is enabled >> here when U-Boot is run but not configured - at least not correctly. >> Resulting in a hangup in the timer reading functions. >> >> To fix this, also read the value of the reload register and check it's >> value with the one written to by U-Boot. Only if this matches, the >> init has already been done. >> >> Signed-off-by: Stefan Roese >> Cc: Martin Rowe >> Cc: Tony Dinh >> Cc: Pali Rohár >> Cc: Michael Walle > > Looks good. > > Acked-by: Pali Rohár > > Maybe you should also fixed line: > > Fixes: 5387b093cb79 ("timer: orion-timer: Fix problem with early static variable") Applied to u-boot-marvell/master Thanks, Stefan >> --- >> drivers/timer/orion-timer.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/timer/orion-timer.c b/drivers/timer/orion-timer.c >> index 810a03d54960..9cab27f2e48b 100644 >> --- a/drivers/timer/orion-timer.c >> +++ b/drivers/timer/orion-timer.c >> @@ -25,7 +25,8 @@ struct orion_timer_priv { >> >> static bool early_init_done(void *base) >> { >> - if (readl(base + TIMER_CTRL) & TIMER0_EN) >> + if ((readl(base + TIMER_CTRL) & TIMER0_EN) && >> + (readl(base + TIMER0_RELOAD) == ~0)) >> return true; >> return false; >> } >> -- >> 2.39.0 >> Viele Grüße, Stefan Roese -- DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de