Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp117178pxb; Mon, 25 Oct 2021 05:05:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybDTquTT7c9wdo4rZ8JLcNO8I7tBbIBqn0D9X4aHeSRudU0Z4ZEXTAe1UTz8QKt28SQ4Y3 X-Received: by 2002:a17:906:9b53:: with SMTP id ep19mr22718781ejc.66.1635163512749; Mon, 25 Oct 2021 05:05:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635163512; cv=none; d=google.com; s=arc-20160816; b=NzEEgRzGA2lulLW6dRARD/2a3EQuyRjgm4FeTeTG7IdCvu6evp5ti1n9Rywlnvque4 rTG1CAz6tIYDiQqwhKdRVuop9oED/xUqg9pEGo2giUMGojMxbxMvOAntMebLWG6b6I5w Wf27rUWKzBWQeWqagDuBwbDBzVpdG4IxGc16nUlD8jHL5r5+3HeWqsSHtccrxUBppfEQ JtSDXt+3wYXMl3ekhUluBRloL+jp/PGTt+DY1FCA7ouhRiGJ8poBiXqiPkbaZBUWjvEE I+wB9pR1WZxDSCp3j9Bv3iY3pHua73SezNh5Yy4EAgYzd35RFEFwqjjRA4ME8xkCwxN0 gDGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:references:cc :to:from:subject; bh=/Dy+hs+rxlhrsi3crr2p/d55wdRYL7y9A9qaO4pB6q0=; b=zvsAqr0TAc8MXbdaK+Eut8tJP4/D8LnDOI2ROWjk7WO2aLZHhxWJVhVqp3EbGiV9Na SD6o7F04k7VLlPtvMML4o38LJLzaSD1eBHMkJSAcrqDI1ZwPkpwMQgFRb9dAz3OeAg6K gcorgnZU4bAkEXIbo80b0++NckDgRpuGgHKROJzihAny4y69UtZiNtzbskgpeffQ0zjY 490J1qoIZT8PZ3JoAiGOtMnAQsvF6YFLU7zAQXVfunwNmyyIKdw//tDhI8iazE2ksEpW Xtv9ZYIjTONhEjitoCvUMX1dUy9LH76mBccMwCggDcNOHc92r3qTCWT6Ry+nsgteB9Yy p2IQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dz20si13115edb.535.2021.10.25.05.04.47; Mon, 25 Oct 2021 05:05:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231335AbhJYMBm (ORCPT + 99 others); Mon, 25 Oct 2021 08:01:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231166AbhJYMBk (ORCPT ); Mon, 25 Oct 2021 08:01:40 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4857EC061745 for ; Mon, 25 Oct 2021 04:59:18 -0700 (PDT) Received: from gallifrey.ext.pengutronix.de ([2001:67c:670:201:5054:ff:fe8d:eefb] helo=[IPv6:::1]) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1meydF-0007zT-Ky; Mon, 25 Oct 2021 13:59:13 +0200 Subject: Re: [PATCH V2] clk: imx: gate off peripheral clock slice From: Ahmad Fatoum To: "Peng Fan (OSS)" , sboyd@kernel.org, mturquette@baylibre.com, abel.vesa@nxp.com, s.hauer@pengutronix.de Cc: Peng Fan , linux-kernel@vger.kernel.org, linux-imx@nxp.com, kernel@pengutronix.de, festevam@gmail.com, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20211025122902.1151-1-peng.fan@oss.nxp.com> Message-ID: <3eda3c8b-636b-9b83-a2f5-434fd2bdc832@pengutronix.de> Date: Mon, 25 Oct 2021 13:59:13 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: a.fatoum@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 25.10.21 13:54, Ahmad Fatoum wrote: > On 25.10.21 14:29, Peng Fan (OSS) wrote: >> From: Peng Fan >> >> The Peripheral clocks are default enabled when SoC power on, and >> bootloader not gate off the clocks when booting Linux Kernel. >> >> So Linux Kernel is not aware the peripheral clocks are enabled and >> still take them as disabled because of enable count is zero. >> >> Then Peripheral clock's source without clock gated off could be >> changed when have assigned-parents in device tree >> >> However, per i.MX8M* reference mannual, "Peripheral clock slices must >> be stopped to change the clock source", so need to gate off the >> the peripheral clock when registering the clocks to avoid glitch. >> >> Tested boot on i.MX8MM/P-EVK board >> >> Fixes: d3ff9728134e ("clk: imx: Add imx composite clock") >> Signed-off-by: Peng Fan > > I've been running an i.MX8MM-based system with this patch for a few days > so far and no apparent issues: > > Tested-by: Ahmad Fatoum I see now that the duration of test isn't as important as the number of boots (as this is a probe-time change). Still, I booted it a dozen or so times and didn't notice anything different. > >> --- >> >> V2: >> Add Fixes tag >> >> drivers/clk/imx/clk-composite-8m.c | 9 ++++++++- >> 1 file changed, 8 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/clk/imx/clk-composite-8m.c b/drivers/clk/imx/clk-composite-8m.c >> index 2dfd6149e528..ee41fbf90589 100644 >> --- a/drivers/clk/imx/clk-composite-8m.c >> +++ b/drivers/clk/imx/clk-composite-8m.c >> @@ -184,6 +184,7 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name, >> struct clk_mux *mux = NULL; >> const struct clk_ops *divider_ops; >> const struct clk_ops *mux_ops; >> + u32 val; >> >> mux = kzalloc(sizeof(*mux), GFP_KERNEL); >> if (!mux) >> @@ -216,8 +217,14 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name, >> div->width = PCG_PREDIV_WIDTH; >> divider_ops = &imx8m_clk_composite_divider_ops; >> mux_ops = &clk_mux_ops; >> - if (!(composite_flags & IMX_COMPOSITE_FW_MANAGED)) >> + if (!(composite_flags & IMX_COMPOSITE_FW_MANAGED)) { >> flags |= CLK_SET_PARENT_GATE; >> + if (!(flags & CLK_IS_CRITICAL)) { >> + val = readl(reg); >> + val &= ~BIT(PCG_CGC_SHIFT); >> + writel(val, reg); >> + } >> + } >> } >> >> div->lock = &imx_ccm_lock; >> > > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |