Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3333174pxf; Mon, 22 Mar 2021 04:08:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwStO1WZ8HPJ8hx3KUJbYuBHuIKpBY+mdh8nkyFw4K5noe4yUeYY3ScfiqHMGaPaO8+bNsJ X-Received: by 2002:a50:fd83:: with SMTP id o3mr25523999edt.90.1616411280053; Mon, 22 Mar 2021 04:08:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616411280; cv=none; d=google.com; s=arc-20160816; b=KI0tnNSPoP5nexY/yK60bOhZt1SRcZYmAE1RJEVw+14zFQ9ptGq/nyHBBiMIxMaQz3 0FfODqrG9rHfGzM8D+42NJMGxWwEL8CQcx8L+6f8NwoKQhySbSD2EYHz83CWogQniH9S E47KKCFs66wmfH5RW/+qnLs6LvrlTYidxe1FnPFcfyxPKoA0d7OtyrI6YMkgjfuOS1Gh Fn8lbEFNz81e1LHU3a8ZxWTEoTV+aZ5gq4f+fXjd+Wk6R3c/9tUcUfxifk3aFjppxsWf zugr1x1KG6d6q/TZVppTpeVx6ibWAt5of+qiX5yl1fOdv2utfkxLu7TeZKLiXHFjCvp4 aO2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=K9Sf3oJ6k0jD2ko0Gz0NL3EcHXCXKc3wCdgm00c4xP0=; b=zQs20FzLProhRc+kqZzu+nnnUJjF0u4woLujWwqPBSJTg7xOxf5BPV6J1on/DLV/Dz ynf8w8rbWK5IMy5JyFw5miLAujyTCKIF66NgC43Z/IG7s1H4u1wK7UbKIRjZGkxAckqJ N7SFC6cox25HOvFUFeexqP37LBRlYytycnmx1QCZI4tj1WWOAJ7hzo4APFho71OD53NW r8yJwcqzEhgEAS8T3tNMsHtrTRm42wBtDneqj4BhvnyaD0fRGWwbtJb+fTplKR3QGcMl eAFaI1r3YcTrmzhpC+bzH7KMlFYryHeSP6aPVjiX9f7eQuqDEeAmjuiYmstiLKrFT8QN XL1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=V59K6zDF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 40si10882802edq.26.2021.03.22.04.07.37; Mon, 22 Mar 2021 04:08:00 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=V59K6zDF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230377AbhCVLGG (ORCPT + 99 others); Mon, 22 Mar 2021 07:06:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:60558 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230209AbhCVLFc (ORCPT ); Mon, 22 Mar 2021 07:05:32 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A044E61879; Mon, 22 Mar 2021 11:05:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616411131; bh=9PoZ2UOAkMcPPEoghhVL5b7gkf7yE9xH1RgjLaPzkno=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=V59K6zDFWymyp9QUxzwsidE+vdao8WL9jfLDqvUnzP1Bw6NWUx8SoOCNYizS3o9ep j8EJhCp56mRpfs+cASmFJRUoxCofOcIuhRskcKo0beTF0nBD7Qb5fOqrGM0noW17d2 jjinYW3wnDZNoCxX7mV0o/rQtfVDjEPq9juhKOyuI13iTW8rbVUN9TEL0Q0vLf6oWV ps3SZQfAJosZCvVn/224d9O780yAAnfNIcFRiHfYrdvRZqmPYEgeF8uMe/PpE9qvGR wZgMgAEFN+I7t00zLsCLtY3K8VXWisHZo0l5XxA1xcRykgTfeMOAmKsQDqmLkTTPT3 ElWDyHmxaTYmw== Date: Mon, 22 Mar 2021 13:05:26 +0200 From: Abel Vesa To: Adam Ford Cc: Ahmad Fatoum , linux-clk , Aisheng Dong , Linus Walleij , Abel Vesa , Stephen Boyd , Fabio Estevam , Michael Turquette , Adam Ford-BE , Linux Kernel Mailing List , NXP Linux Team , Pengutronix Kernel Team , Shawn Guo , Sascha Hauer , arm-soc , Jerome Brunet Subject: Re: [PATCH V4] clk: imx: Fix reparenting of UARTs not associated with stdout Message-ID: References: <20210313122818.445228-1-aford173@gmail.com> <0361ab5b-a26e-7631-9bae-8909715f6354@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21-03-20 18:00:25, Adam Ford wrote: > On Sun, Mar 14, 2021 at 4:40 AM Ahmad Fatoum wrote: > > > > On 13.03.21 16:16, Ahmad Fatoum wrote: > > >> +/* i.MX boards use device trees now. For build tests without CONFIG_OF, do nothing */ > > >> +#ifdef CONFIG_OF > > >> 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]); > > >> + imx_uart_clocks = kcalloc(clk_count, sizeof(struct clk *), GFP_KERNEL); > > >> + > > >> + if (!of_stdout) > > >> + return; > > > > > > Memory leak. Just do if (imx_keep_uart_clocks && of_stdout) > > > > Please dismiss. I overlooked that you free it in a later initcall. > > Abel, > > Are you OK with this? I also have a V5 posted [1] which does what > Ahmad suggested. > I'm OK with this version. Applied it on my clk/imx branch: git://git.kernel.org/pub/scm/linux/kernel/git/abelvesa/linux.git Thanks a lot for all the effort. > Either of these will fix reparenting issues, but I need this for > Bluetooth to operate correctly, because both beacon imx8mn and imx8mn > kits switch the UART parent to an 80MHz clock in order to run at > 4Mbps. > > thank you, > > adam > > > > >> static int __init imx_clk_disable_uart(void) > > >> { > > >> - if (imx_keep_uart_clocks && imx_uart_clocks) { > > >> + if (imx_keep_uart_clocks && imx_enabled_uart_clocks) { > > >> int i; > > >> > > >> - for (i = 0; imx_uart_clocks[i]; i++) > > >> - clk_disable_unprepare(*imx_uart_clocks[i]); > > >> + for (i = 0; i < imx_enabled_uart_clocks; i++) { > > >> + clk_disable_unprepare(imx_uart_clocks[i]); > > >> + clk_put(imx_uart_clocks[i]); > > >> + }; > > >> + kfree(imx_uart_clocks); > > >> } > > > > -- > > 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 |