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 0D908C3DA7A for ; Mon, 2 Jan 2023 10:47:11 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F052E854F4; Mon, 2 Jan 2023 11:47:08 +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=1672656429; bh=V9DFMIbXQH/oeleUm72cGM/GRGilEnJx4vVZEu0vFHs=; h=Date:Subject:From:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Nu+BrA4y849EXiq/eFuRDYdxyK1AQ6y+/n0koZY4nwugfiQwi9geHItMP6UGWUt9m qwz3z5ZGIMFDQq4IPK6CB/4z458FPbZqwBDHCl9UPh7sjd+JbezhJWIeqRTlhw0OJX 2wgR0NfQsGfrCbcqCNzyAcISsO8XtMMEV04lBmMDZwNcdtjTtKagE7y7YSrjV5LYHo KgiKiz0Ak8Rw9UwMXd6/7Vm4Dr2NifWQcaWxNVtui+Mu85N6o8CTPfHUr4JGrQ7K1n UqERBO6y31ffcPzPdKUbkvkRJIBaGYHOhHerJJmvmwYKqX9r5A1J9ao1BL6DULqVRe 2tYAhE7V9CLxw== Received: by phobos.denx.de (Postfix, from userid 109) id 3D321854F4; Mon, 2 Jan 2023 11:47:07 +0100 (CET) Received: from mout-u-107.mailbox.org (mout-u-107.mailbox.org [80.241.59.207]) (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 EE4DD85398 for ; Mon, 2 Jan 2023 11:47:04 +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 [10.196.197.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-107.mailbox.org (Postfix) with ESMTPS id 4Nlsxf4XHnz9sVv; Mon, 2 Jan 2023 11:47:02 +0100 (CET) Message-ID: Date: Mon, 2 Jan 2023 11:47:01 +0100 MIME-Version: 1.0 Subject: Re: [PATCH] timer: orion-timer: Fix problem with early static variable Content-Language: en-US From: Stefan Roese To: u-boot@lists.denx.de Cc: =?UTF-8?Q?Pali_Roh=c3=a1r?= , Michael Walle , Tony Dinh References: <20221221091849.1018783-1-sr@denx.de> In-Reply-To: <20221221091849.1018783-1-sr@denx.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 12/21/22 10:18, Stefan Roese wrote: > We've noticed that at least one Kirkwood board (Pogo v4) has problems > with the new orion DM timer implementation. Debugging revealed that this > issue is related with the static variable "early_init_done" which does > not work correctly before relocation in all cases. > > This patch removes this static variable and replaces it's functionality > via a function that detects if the timer is already initialized. > > Signed-off-by: Stefan Roese > Cc: Pali Rohár > Cc: Michael Walle > Cc: Tony Dinh Applied to u-boot-marvell/master Thanks, Stefan > --- > drivers/timer/orion-timer.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/drivers/timer/orion-timer.c b/drivers/timer/orion-timer.c > index d0eab3ce781d..6804bf0fa2cb 100644 > --- a/drivers/timer/orion-timer.c > +++ b/drivers/timer/orion-timer.c > @@ -23,15 +23,19 @@ struct orion_timer_priv { > > #define MVEBU_TIMER_FIXED_RATE_25MHZ 25000000 > > -static bool early_init_done __section(".data") = false; > +static bool early_init_done(void *base) > +{ > + if (readl(base + TIMER_CTRL) & TIMER0_EN) > + return true; > + return false; > +} > > /* Common functions for early (boot) and DM based timer */ > static void orion_timer_init(void *base, enum input_clock_type type) > { > /* Only init the timer once */ > - if (early_init_done) > + if (early_init_done(base)) > return; > - early_init_done = true; > > writel(~0, base + TIMER0_VAL); > writel(~0, base + TIMER0_RELOAD); 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