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=-15.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable 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 A0916C4361B for ; Mon, 7 Dec 2020 16:55:16 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3B45123877 for ; Mon, 7 Dec 2020 16:55:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B45123877 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=fJe0JS3Qu68fg/krooCe7HMzCFqeL5YqMnJHhehMpVM=; b=mNr7s7qHAzXOcU8LBivkviIE9 NGoZSAYsw2snnkee/ac6DvLjAIq5AnqhRJW9YZe0iDkZ+e3rHg9dIj2W3Tw68jQvcdCX8Qs+47wIu RCI3Lz4SBcuhx6BPrVZFoDHs6CW06IzrbNOf7d/h1lLEySuUX3Bagqa6JWePOiHlKp4iuQKe1cN96 F9+Ytd6JM8pm6HbPtiu42/iAU/nJdwGSblnuKuZk7nPdfNPdocUHMK5o0T0c9xqWdMcZjyjQ88lCT IWHcYWXUa6bFH06r1zHuwL61VhuRYIysT82JMyH28NV2ZlTUdZ52PlWITIKYG6fxih/SPdYO7y+9K GWI0yAgaA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kmJlv-000569-7B; Mon, 07 Dec 2020 16:53:59 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kmJls-00055I-7c for linux-arm-kernel@lists.infradead.org; Mon, 07 Dec 2020 16:53:57 +0000 Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kmJli-0007Sk-Es; Mon, 07 Dec 2020 17:53:46 +0100 Received: from sha by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kmJlg-0000Ti-Qr; Mon, 07 Dec 2020 17:53:44 +0100 Date: Mon, 7 Dec 2020 17:53:44 +0100 From: Sascha Hauer To: Adam Ford Subject: Re: [PATCH] clk: imx: Fix reparenting of UARTs not associated with sdout Message-ID: <20201207165344.GP3977@pengutronix.de> References: <20201204183154.94002-1-aford173@gmail.com> <20201207052438.GA3977@pengutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 17:50:33 up 5 days, 5:17, 69 users, load average: 0.36, 0.16, 0.16 User-Agent: Mutt/1.10.1 (2018-07-13) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201207_115356_303461_9A8C0CDD X-CRM114-Status: GOOD ( 37.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Aisheng Dong , Linus Walleij , Linux Kernel Mailing List , Stephen Boyd , Fabio Estevam , Michael Turquette , Adam Ford-BE , charles.steves@logicpd.com, NXP Linux Team , Pengutronix Kernel Team , Shawn Guo , linux-clk , arm-soc , Jerome Brunet Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Adam, On Mon, Dec 07, 2020 at 09:51:33AM -0600, Adam Ford wrote: > On Sun, Dec 6, 2020 at 11:24 PM Sascha Hauer wrote: > > > > Hi Adam, > > > > On Fri, Dec 04, 2020 at 12:31:54PM -0600, Adam Ford wrote: > > > The default clock source on i.MX8M Mini and Nano boards use a 24MHz clock, > > > but users who need to re-parent the clock source run into issues because > > > all the UART clocks are enabled whether or not they're needed by sdout. > > > > > > Any attempt to change the parent results in an busy error because the > > > clocks have been enabled already. > > > > > > clk: failed to reparent uart1 to sys_pll1_80m: -16 > > > > > > Instead of pre-initializing all UARTS, scan the device tree to see if UART > > > clock is used as stdout before initializing it. Only enable the UART clock > > > if it's needed in order to delay the clock initialization until after the > > > re-parenting of the clocks. > > > > > > Fixes: 9461f7b33d11c ("clk: fix CLK_SET_RATE_GATE with clock rate protection") > > > Suggested-by: Aisheng Dong > > > Signed-off-by: Adam Ford > > > > > > diff --git a/drivers/clk/imx/clk.c b/drivers/clk/imx/clk.c > > > index 47882c51cb85..6dcc5fbd8f3f 100644 > > > --- a/drivers/clk/imx/clk.c > > > +++ b/drivers/clk/imx/clk.c > > > @@ -163,12 +163,18 @@ __setup_param("earlyprintk", imx_keep_uart_earlyprintk, > > > > > > void imx_register_uart_clocks(struct clk ** const clks[]) > > > { > > > + struct clk *uart_clk; > > > if (imx_keep_uart_clocks) { > > > int i; > > > > > > imx_uart_clocks = clks; > > > - for (i = 0; imx_uart_clocks[i]; i++) > > > - clk_prepare_enable(*imx_uart_clocks[i]); > > > + for (i = 0; imx_uart_clocks[i]; i++) { > > > + uart_clk = of_clk_get(of_stdout, i); > > > > This looks wrong. imx_uart_clocks is an array containing all clocks that > > could possibly be used for an UART. With of_clk_get(of_stdout, i) you > > get the nth clock for one specific UART. > > What you have to do here is: For each of imx_uart_clocks[] you have to > > iterate over all clocks of the of_stdout node. > > Sascha, > > Thanks for the review. > > I agree that I'm using the wrong index when checking of_stdout, but I > am not sure we need to loop through imx_uart_clocks at all. > I looked at the NXP repo, and they just focus on looping through > of_stdout and don't reference the imx_uart_clocks. Can't we just loop > through the of_stdout and enable any clocks found in that? This sounds good. That way we could get rid of the imx_uart_clocks array entirely. Note that right below imx_register_uart_clocks() there is imx_clk_disable_uart() which disables the previously enabled clocks again later when the real driver has taken over. You'll have to change that as well accordingly. Sascha -- 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 | _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel