Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp623822pxb; Wed, 3 Feb 2021 13:26:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJyyPmD1w/z6XWJZPUDTg6OIyx2d5qfWHR98u7hQO9fjaN/vZLKoI/ap4XYBau/9wmkH3xZw X-Received: by 2002:a05:6402:20e:: with SMTP id t14mr5174280edv.178.1612387563870; Wed, 03 Feb 2021 13:26:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612387563; cv=none; d=google.com; s=arc-20160816; b=bDuCKQIC/8FyMR4Bp+lJqvZG2MkXJxPYi6AyVRlPWKVRLxrJeEX1EMpHmA9zVI1zLe t156FBhdOZ9G1b9FOEleRwHY9fzWHuDLH8WEQwc3xezs518Az83AnrvUxptrlCcIwj/2 3xhLhc9Tj2TKh9nQ59f7EU6an/rMaw7FcNSwwZeseCz+qxvJS7x9FCWBHsFPMweDFRLq DjAu3h3Mrr0n52WuysSdFvzwbgbIfVraSjzPyBUoCaCcvbhOuPej451ytag/Tc8aWLS8 YOwdD5SQIvIk2Dhb3I8BMNRxl0emmpM56Yn8t+FO34EtRB96Nld8bUXXK9dKMW/5/9e9 f3gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=TFiTJoFvlaFYID17H7RoHT6hcb6k7KOcxSeH2rq/fng=; b=HiELoaFsdMS/IONRzmf0VuYBBNptFOqQntvqqmA/T7/ci4HEZ09VAIeKK2641OUhOm ebCG0JCueRwoZkdeTM1duZY03zTH+7HK1/E4NwgL/jdY/0i74zedV48ElXfzhWCuR7u2 9wCbdPuAri5DwHcutKTunF+wcKAJZl6ulBkcTv/J8/8E+60o16FbsaIHVPdef9Py2AkB kT31eNMqY0BGAkjogRKB3ZODNeuQx/KRRRtqHveFFw9HNqh29MvX6Vpn97PtVqbmCpK0 evA+jnlC0/oP39seuVizeVYEtFs2+7bwH0stJ2Nw6L6+E1YrQGt8UOlvGo+nGIKhihy4 Lskg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=S1+9liQo; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s18si2211015ejr.353.2021.02.03.13.25.38; Wed, 03 Feb 2021 13:26:03 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=S1+9liQo; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231350AbhBCVXJ (ORCPT + 99 others); Wed, 3 Feb 2021 16:23:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230139AbhBCVXE (ORCPT ); Wed, 3 Feb 2021 16:23:04 -0500 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FC97C061573; Wed, 3 Feb 2021 13:22:24 -0800 (PST) Received: by mail-pg1-x52d.google.com with SMTP id c132so634941pga.3; Wed, 03 Feb 2021 13:22:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=TFiTJoFvlaFYID17H7RoHT6hcb6k7KOcxSeH2rq/fng=; b=S1+9liQomwOL0dXTpJHZjK/3oCEze3UJv+GhpjQfT53/WCm+1QLAiYD6gNA9QvXLGH ez4lex81vs1tLNWL9qmUSHSJm0H3tU2JaAHyLyJK+N9PRQkX1qh7rEPaYys7dOmRIkFX p7zfiVsdxELZNyra/FGwYVWcDHmp1iMuEDlKlDmvBF36RrMN5mi66FJyDa6V85wjA56l P2weCJ1tTmdLehCZE2s1HG2KdhneoXqQvg6kGqHc5BEJYi7Ot1fvQtKaNTIwzriKG4bn 7qPqyZNzhEjZQ1V146lWvx9H6Ur5fmU+w3Ow/tX7ct74iug0ArEzKOm5YxUWlL5nuBdS kopQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=TFiTJoFvlaFYID17H7RoHT6hcb6k7KOcxSeH2rq/fng=; b=d7PGzy/blhDQ+slZXCN/nTLP7FqOX1mVygrJiF+Vr2/A3PysK0ixN6+uGd0jpfJJjs NDs6SWlyU+EIf+Btu4d4RTk0aSKyrdc7Blu0zZ0fXU9/x/vKv5AdzPDEEt4Tk/4VyOQc tllDtmawT+6t+i7e3DfpHikwF93SOvk+AQ2WKXX2sAkLj1N4kQ6uyeTQ2WcbWPu9uGHT 6fTCu3awxwcUFT9GjLOfWInk/Ce+1XGfigNp7N7DikqKNnhdx3irWRJBo29R7yHgQ3P0 5rFGSFt5Xbup3FsI4ygRq5ujCCwRigc9YflWbouN6ItkSmEOBBbmGzzzyrMewrl/YQSC UiwA== X-Gm-Message-State: AOAM53306wUP5JcKifSLqnINGdnSIAmCg1Q3NlL0uhsYLQtY+jwC8GBf eiPEYM6Px1zjNT9GrtZuk+BycFLq8u/gKtVbCQI= X-Received: by 2002:a62:2ac3:0:b029:1bc:4287:c0b3 with SMTP id q186-20020a622ac30000b02901bc4287c0b3mr4790030pfq.26.1612387343663; Wed, 03 Feb 2021 13:22:23 -0800 (PST) MIME-Version: 1.0 References: <20210115182909.314756-1-aford173@gmail.com> <20210118125204.hxsanoohwvdtdvym@fsr-ub1664-175> <20210120144454.f6b72lnasw4q3bde@fsr-ub1664-175> <20210120151305.GC19063@pengutronix.de> <20210120152813.x2pbs5vprevkly23@fsr-ub1664-175> <20210120155001.GD19063@pengutronix.de> <20210120161421.h3yng57m3fetwwih@fsr-ub1664-175> <20210121095617.GI19063@pengutronix.de> <20210121102450.lisl3mzqczdsmzda@fsr-ub1664-175> In-Reply-To: <20210121102450.lisl3mzqczdsmzda@fsr-ub1664-175> From: Adam Ford Date: Wed, 3 Feb 2021 15:22:12 -0600 Message-ID: Subject: Re: [PATCH V3] clk: imx: Fix reparenting of UARTs not associated with sdout To: Abel Vesa Cc: Sascha Hauer , arm-soc , Adam Ford-BE , Aisheng Dong , Michael Turquette , Stephen Boyd , Shawn Guo , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Linus Walleij , Jerome Brunet , linux-clk , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 21, 2021 at 4:24 AM Abel Vesa wrote: > > On 21-01-21 10:56:17, Sascha Hauer wrote: > > On Wed, Jan 20, 2021 at 06:14:21PM +0200, Abel Vesa wrote: > > > On 21-01-20 16:50:01, Sascha Hauer wrote: > > > > On Wed, Jan 20, 2021 at 05:28:13PM +0200, Abel Vesa wrote: > > > > > On 21-01-20 16:13:05, Sascha Hauer wrote: > > > > > > Hi Abel, > > > > > > > > > > > > On Wed, Jan 20, 2021 at 04:44:54PM +0200, Abel Vesa wrote: > > > > > > > On 21-01-18 08:00:43, Adam Ford wrote: > > > > > > > > On Mon, Jan 18, 2021 at 6:52 AM Abel Vesa wrote: > > > > > > > > > > ... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > TBH, I'm against the idea of having to call consumer API = from a clock provider driver. > > > > > > > > > I'm still investigating a way of moving the uart clock co= ntrol calls in drivers/serial/imx, > > > > > > > > > where they belong. > > > > > > > > > > > > > > > > That makes sense. > > > > > > > > > > > > > > > > > > > > > > Just a thought. The uart clock used for console remains on fr= om u-boot, > > > > > > > so maybe it's enough to just add the CLK_IGNORE_UNUSED flag t= o all the > > > > > > > uart root clocks and remove the prepare/enable calls for uart= clocks > > > > > > > for good. I don't really have a way to test it right now, but= maybe > > > > > > > you could give it a try. > > > > > > > > > > > > That would mean that UART clocks will never be disabled, regard= less of > > > > > > whether they are used for console or not. That doesn't sound ve= ry > > > > > > appealing. > > > > > > > > > > AFAIK, the only uart clock that is enabled by u-boot is the one u= sed for > > > > > the console. Later on, when the serial driver probes, it will ena= ble it itself. > > > > > > > > > > Unless I'm missing something, this is exactly what we need. > > > > > > > > It might enable it, but with CLK_IGNORE_UNUSED the clock won't be > > > > disabled again when a port is closed after usage > > > > > > OK, tell me what I'm getting wrong in the following scenario: > > > > > > U-boot leaves the console uart clock enabled. All the other ones are = disabled. > > > > > > Kernel i.MX clk driver registers the uart clocks with flag CLK_IGNORE= _UNUSED. > > > > I was wrong at that point. I originally thought the kernel will never > > disable these clocks, but in fact it only leaves them enabled during th= e > > clk_disable_unused call. > > > > However, when CLK_IGNORE_UNUSED becomes relevant it's too late already. > > I just chatted with Lucas and he told me what the original problem was > > that his patch solved. > > > > The problem comes when an unrelated device and the earlycon UART have > > the same parent clocks. The parent clock is enabled, but it's reference > > count is zero. Now when the unrelated device probes and toggles its > > clocks then the shared parent clock will be disabled due to the > > reference count being zero. Next time earlycon prints a character the > > system hangs because the UART gates are still enabled, but their parent > > clocks no longer are. > > > > Hmm, that is indeed a problem. That's why I think there should be some > kind of NOCACHE flag for almost all the types of clocks. For example, > in this case, it makes sense for the core to check the bit in the registe= r > and then disable the parent based on that instead of relying on the refco= unt. > Anyway, that's something that needs to be added in the CCF. > > > Overall I think Lucas' patches are still valid and relevant and with > > Adams patches we even no longer have to enable all UART clocks, but > > only the ones which are actually needed. > > Yeah, for now, I think we can go with Adam's patches. But longterm, I wou= ld > like to remove the special case of the uart clocks we have right now in a= ll > the i.MX clock drivers. > Is the patch I submitted good enough for someone's acked-by or reviewed-by, or are there changes I need to implement? adam > > > > Sascha > > > > > > -- > > Pengutronix e.K. | = | > > Steuerwalder Str. 21 | https://eur01.safelinks.pr= otection.outlook.com/?url=3Dhttp%3A%2F%2Fwww.pengutronix.de%2F&data=3D0= 4%7C01%7Cabel.vesa%40nxp.com%7Ceed68987c68f4aeaa63408d8bdf2d051%7C686ea1d3b= c2b4c6fa92cd99c5c301635%7C0%7C0%7C637468197861821302%7CUnknown%7CTWFpbGZsb3= d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000= &sdata=3DX1J8KgxFquNin80zKVz0Ao22vv1MuTMWf91BUTczh9Y%3D&reserved=3D= 0 | > > 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 = | > > Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-555= 5 |