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 8415AC636CC for ; Mon, 20 Feb 2023 16:11:39 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2BBD485103; Mon, 20 Feb 2023 17:11:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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; unprotected) header.d=gmail.com header.i=@gmail.com header.b="F/BDISdB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5DA28809A5; Mon, 20 Feb 2023 17:11:35 +0100 (CET) Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 503DA85103 for ; Mon, 20 Feb 2023 17:11:32 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qt1-x835.google.com with SMTP id w23so1215940qtn.6 for ; Mon, 20 Feb 2023 08:11:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=1+WfMhiBPmBfV6NDVK51MfEbwG0vdrHW19vLwsXvXz4=; b=F/BDISdBPGtcL2KFchWxQqQs1+DYvHsTzr2/0aMNRCZkVI/lnVyRdcbEH3K/7j6okO d1k6Q1PrAQWfDCerdRBbIF80E+ojToeVSlL80UOieX1cl0f4lp4OPFFtjNs73io02Kbi pVreXV9gWUQfqphkRjAT2LxZGszkr+9ZkLynhVhjrtKwxG9GZguJ19X7UhOSpLbBKplG t76acgzNLiopEGZpdM+jktI/jC8hdeuChROep943W5xoMfxL5eE8GMfEAsLHlcHJmRJA WaG589pd8Qh9fuXmGgnswSPv+IUB+u7/2dIK8MkRlB+K9e0ehHOZ1mJlJibwtfANSGWs 9vUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1+WfMhiBPmBfV6NDVK51MfEbwG0vdrHW19vLwsXvXz4=; b=El96fpG/WxImgMO2HTtSv+fR0AqozzQKtnz7uN54j+x6sW6xbbGZazt410hbA3p1Gr fQVo0WJ1mMoYzOE+BzUmp52zxTfFKafXX2t0dUPtOoimZGEr18d8NAAu/DgTeiRuiyZJ peBNXjhpfvbOK9YNU5K/prgPLdoQvmklHwgTh2erQXq/HiutwsHBG3URd7+slSRY+r3l MeOH5NNFAhpl+1FBhvBVbPhQUY4a0YWnnGI0JwjyNY/TebnGWuEXxyZ3j4ermuzsaJDB T8yaUUO6tZ7f9cINiwxGW7DFJouSlZeg70rYHu44d1QQE/evGZfN5nnl/cXygkTTr0tb dGNQ== X-Gm-Message-State: AO0yUKXlWVR9fYrH9ds9k0DlMJgcIlGRwQ8OuxrFMykAGNctNLl9GJO3 ViRwun0Bxulgw9R7rmBcrHA= X-Google-Smtp-Source: AK7set+NbREW+60uNLefwu6DlHI++fO1/7hVJnEM9iNqLt9VECbBQm/qsLRwsz9hpnAoYR9RZIyBbg== X-Received: by 2002:a05:622a:349:b0:3b9:bc8c:c1f9 with SMTP id r9-20020a05622a034900b003b9bc8cc1f9mr11199769qtw.4.1676909491088; Mon, 20 Feb 2023 08:11:31 -0800 (PST) Received: from [192.168.1.201] (pool-173-73-95-180.washdc.fios.verizon.net. [173.73.95.180]) by smtp.gmail.com with ESMTPSA id 13-20020a05620a040d00b0073b575f3603sm1028920qkp.101.2023.02.20.08.11.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 20 Feb 2023 08:11:30 -0800 (PST) Message-ID: Date: Mon, 20 Feb 2023 11:11:29 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH 4/6] clk: Fix rate caching in clk_get_parent_rate() Content-Language: en-US To: Samuel Holland , Lukasz Majewski , Simon Glass Cc: Dario Binacchi , Jean-Jacques Hiblot , Michal Suchanek , Neil Armstrong , Peng Fan , u-boot@lists.denx.de References: <20230220055940.41890-1-samuel@sholland.org> <20230220055940.41890-5-samuel@sholland.org> From: Sean Anderson In-Reply-To: <20230220055940.41890-5-samuel@sholland.org> Content-Type: text/plain; charset=UTF-8; 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 On 2/20/23 00:59, Samuel Holland wrote: > clk_get_rate() can return an error value. Recompute the rate if the > cached value is an error value. > > Fixes: 4aa78300a025 ("dm: clk: Define clk_get_parent_rate() for clk operations") > Signed-off-by: Samuel Holland > --- > > drivers/clk/clk-uclass.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c > index 5bce976b060..9d052e5a814 100644 > --- a/drivers/clk/clk-uclass.c > +++ b/drivers/clk/clk-uclass.c > @@ -520,7 +520,8 @@ ulong clk_get_parent_rate(struct clk *clk) > return -ENOSYS; > > /* Read the 'rate' if not already set or if proper flag set*/ > - if (!pclk->rate || pclk->flags & CLK_GET_RATE_NOCACHE) > + if (!pclk->rate || IS_ERR_VALUE(pclk->rate) || > + pclk->flags & CLK_GET_RATE_NOCACHE) > pclk->rate = clk_get_rate(pclk); > > return pclk->rate; The correct fix here is /* Read the 'rate' if not already set or if proper flag set*/ if (!pclk->rate || pclk->flags & CLK_GET_RATE_NOCACHE) { rate = clk_get_rate(pclk); if (!IS_ERR_VALUE(rate)) pclk->rate = rate; } return rate; No point caching errors. --Sean