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 X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91DE5C48BD1 for ; Fri, 11 Jun 2021 08:48:00 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 0F90D60FE9 for ; Fri, 11 Jun 2021 08:48:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0F90D60FE9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BCA1880F28; Fri, 11 Jun 2021 10:46:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org 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=kernel.org header.i=@kernel.org header.b="k/cLRjLs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0A724803B2; Fri, 11 Jun 2021 10:45:58 +0200 (CEST) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 87407801D7 for ; Fri, 11 Jun 2021 10:45:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=kristo@kernel.org Received: by mail.kernel.org (Postfix) with ESMTPSA id 70000613C3; Fri, 11 Jun 2021 08:45:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623401152; bh=tGN0tZdWtcM2IzOMoNY2DgIYT5WQK4mKHR2shbr4d9o=; h=From:To:Subject:Date:In-Reply-To:References:From; b=k/cLRjLscCcC3DqLF6QUS0kEMfY2yNWF5XoLH/gzo+5Dps00+jxaZFClTRqoJ8EDW jrT+Gl9hPVfr61i2ctOoCmsWdxgSfQ39TY/hbbXusTv0z0tkcREsAfFRIIwA70bSD0 m4eCQB6jlV7PYfxrQ0j+gX1moOPB9UDNm6DXtcQzD/LBdV8elwO45xwn4wTrGUHh4S U70uFKSeaK8znjSyr/atubcmOoIqdT+xMyXSY1HH3bBwveMkrLME+VVa09rTlxY4tt medEMN+XSppHkEDsSc7ScAxauEQP+BYXqilJjixS29txBCy+xpalf012bhs2GTKXdW hpFgQjTNyMksA== From: Tero Kristo To: lokeshvutla@ti.com, trini@konsulko.com, u-boot@lists.denx.de Subject: [PATCHv6 11/26] clk: fix set_rate to clean up cached rates for the hierarchy Date: Fri, 11 Jun 2021 11:45:12 +0300 Message-Id: <20210611084527.7048-12-kristo@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210611084527.7048-1-kristo@kernel.org> References: <20210611084527.7048-1-kristo@kernel.org> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean From: Tero Kristo Clock rates are cached within the individual clock nodes, and right now if one changes a clock rate somewhere in the middle of the tree, none of its child clocks notice the change. To fix this, clear up all the cached rates for us and our child clocks. Signed-off-by: Tero Kristo Signed-off-by: Tero Kristo --- drivers/clk/clk-uclass.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c index 815f7bfe98..3d2344f009 100644 --- a/drivers/clk/clk-uclass.c +++ b/drivers/clk/clk-uclass.c @@ -568,6 +568,22 @@ ulong clk_round_rate(struct clk *clk, ulong rate) return ops->round_rate(clk, rate); } +static void clk_clean_rate_cache(struct clk *clk) +{ + struct udevice *child_dev; + struct clk *clkp; + + if (!clk) + return; + + clk->rate = 0; + + list_for_each_entry(child_dev, &clk->dev->child_head, sibling_node) { + clkp = dev_get_clk_ptr(child_dev); + clk_clean_rate_cache(clkp); + } +} + ulong clk_set_rate(struct clk *clk, ulong rate) { const struct clk_ops *ops; @@ -580,6 +596,9 @@ ulong clk_set_rate(struct clk *clk, ulong rate) if (!ops->set_rate) return -ENOSYS; + /* Clean up cached rates for us and all child clocks */ + clk_clean_rate_cache(clk); + return ops->set_rate(clk, rate); } -- 2.17.1