Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2150002pxu; Sun, 6 Dec 2020 21:28:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJxSvP34rU52eKhSL55ZgwmRpMoRcbFa0wNsZjU6j0awWPEO4Y2b6D9U2g+4dUp2acVwJrpm X-Received: by 2002:a05:6402:48d:: with SMTP id k13mr18174867edv.92.1607318890719; Sun, 06 Dec 2020 21:28:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607318890; cv=none; d=google.com; s=arc-20160816; b=yQN26h/t2OMd4mrLiLeAnUSYzCGVBmwLEaOAdaCPxqTT8XLHJGldZzMIHDCc+lswfI F+cDFv3kN01d+8RQBESPje8T7pdKv3AQM1GESLNC5nzbMCLi3s0cw1atW6JH2g+80W+f y78E9n6YI4aPr2m1YbpeCTbWsa1I9gzWG1BCRuDJ8Hi7tWq+MYkDvT56PFW2U1lrTS4r TxozORYoPeUDuqoDzr+4jC2k6x3qh0sg0Iv8ZQGSfl9BY6HQoHYxDhEi4at2kJypTwZp IG6PB+G7XAsfkXluvycSyNTVP1XyFXrE4kP1A+a1otUWNw70fPNoEz9W7gZop2Hrtb4Y IKjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=7oqJ1/qsLbtpCWTzizTnuE27hZsukbIDaHnsWojjk/U=; b=EcNypORB32vCSVnKofTq7d49sKn6w0f4KtafhRsqIS/VUmhs/l+Fcoip9vECIAxI6c 8722QNNeMpIVRYH16o/a+c9NwRZXhXNXYFW9U0oEjBoH1y7eVgbf52YVcEN6bsWirFMK RGuipxdDDFkcyeadGJ/cjCd2jYRRPrGIz8WP1Olg3j8xnsJwWyc/q2LxE05PuDc00m3o 0i6Tcitft3sUX2JQgJKajCdP38IUe0ZX9X5UIPBCqor44DTL2SrhO2nG6qbwuSfrg82w Ub8SZMKaRKZEaZEYfh6a5uwCibsgV34mkhMZLAX6n8O65MFoNbYYzwQhLDlCmejKSlsF zg7Q== 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 n11si5827897eja.511.2020.12.06.21.27.48; Sun, 06 Dec 2020 21:28:10 -0800 (PST) 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 S1725951AbgLGFZe (ORCPT + 99 others); Mon, 7 Dec 2020 00:25:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725773AbgLGFZd (ORCPT ); Mon, 7 Dec 2020 00:25:33 -0500 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 72F5FC0613D2 for ; Sun, 6 Dec 2020 21:24:53 -0800 (PST) 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 1km90p-0000C3-J3; Mon, 07 Dec 2020 06:24:39 +0100 Received: from sha by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1km90o-0000yR-6p; Mon, 07 Dec 2020 06:24:38 +0100 Date: Mon, 7 Dec 2020 06:24:38 +0100 From: Sascha Hauer To: Adam Ford Cc: linux-clk@vger.kernel.org, aford@beaconembedded.com, charles.steves@logicpd.com, Aisheng Dong , Michael Turquette , Stephen Boyd , Shawn Guo , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Linus Walleij , Jerome Brunet , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] clk: imx: Fix reparenting of UARTs not associated with sdout Message-ID: <20201207052438.GA3977@pengutronix.de> References: <20201204183154.94002-1-aford173@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201204183154.94002-1-aford173@gmail.com> 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: 06:13:56 up 4 days, 17:40, 32 users, load average: 0.04, 0.17, 0.17 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-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > + if (IS_ERR(uart_clk)) > + continue; > + clk_prepare_enable(uart_clk); > + clk_put(uart_clk); > + } > } > } > > -- > 2.25.1 > > -- 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 |