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=-0.7 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no 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 CE355C433E0 for ; Wed, 3 Feb 2021 21:23:50 +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 74A0064F5F for ; Wed, 3 Feb 2021 21:23:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 74A0064F5F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com 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:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=3Z3+fWeHHUg9AZrZUu1LKMZp4rb2pvZ6YoS8btetTso=; b=tCl4iN622KXU3eJDhh9UP36on LNeLkXHIyrNhvee/wkhk5ACu+PAck9Y316sEmPwmtOmQKbnAi5cjlbQPd2rOr8sJsY2CJQPQwiiUu ejSfnYvJV9KJWD1y42xOTFOTagmjoy+lVZf65B0P6JvSFPgu5v8UdyEzcX9kTEEK4aPOJ6knfwhgA Hy9F3I19Pp/kOh+AKiRNeKJRGam32K1H9EuQCEPHPBdF28r6o4JWMKkWwdnf7j+tgs5ZcZ1AbFhw2 hB6LnKuOVUCA8TyrW1BdgC2iynmi0S9gwVqlY0anhR0l4OveYkSpo4mEeOmBvCewil91Oq2Z0/71u SYxzGyk7Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l7Pba-0007rT-St; Wed, 03 Feb 2021 21:22:30 +0000 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l7PbX-0007r1-VR for linux-arm-kernel@lists.infradead.org; Wed, 03 Feb 2021 21:22:29 +0000 Received: by mail-pg1-x532.google.com with SMTP id n10so609539pgl.10 for ; Wed, 03 Feb 2021 13:22:25 -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=SZUYtJp0rsgLy0rx9RuYC7XFjnAKnl39dgmZ9uAYX/3m7QeXZkIOs8CQb1Q6PCTnie fwQtnoFHOtRt7+XX/imkhHmY+u9240fSCWcvJpTssJcHQ5IsO7pxvPhVpbH6hR3oyvm2 zK3D5Jp2phzO8jMTG7VJbuFt4BNQBDVCYPkD+52uUJIVLrMtFa0dcasbYO1A848ONODW duc8JzQPOCwdYCVLvEZT9jY2N8DbOc8knLGl0nAOaNvBw0WAOLTSONdm0dl+BJhEgmmM /oakr+FtMW2snqroECrlKSAipUOcW2AArNlkF5avYm78znR/XMVKok9hQdgDuvNfwAE0 pC2A== X-Gm-Message-State: AOAM530j3ElPYU/s2itXC+CDZppKhdQuq2faUhfNbstcTAXmlr/nqgUk pTuybScnxbjtHDmwo6pRNFvdcbNk5nZC2dUIJUA= X-Google-Smtp-Source: ABdhPJyjgKLsLDMiQKZhm/3dUiduA5WUTzetwtwlYpTEeR8ore5ECpNZtOPlRKLdoPELwntqIfz2g0Bok48UDCWCVGA= 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210203_162228_049991_E0E176C2 X-CRM114-Status: GOOD ( 39.39 ) 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 , linux-clk , NXP Linux Team , Pengutronix Kernel Team , Shawn Guo , Sascha Hauer , 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 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 control calls in drivers/serial/imx, > > > > > > > > > where they belong. > > > > > > > > > > > > > > > > That makes sense. > > > > > > > > > > > > > > > > > > > > > > Just a thought. The uart clock used for console remains on from u-boot, > > > > > > > so maybe it's enough to just add the CLK_IGNORE_UNUSED flag to 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, regardless of > > > > > > whether they are used for console or not. That doesn't sound very > > > > > > appealing. > > > > > > > > > > AFAIK, the only uart clock that is enabled by u-boot is the one used for > > > > > the console. Later on, when the serial driver probes, it will enable 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 the > > 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 register > and then disable the parent based on that instead of relying on the refcount. > 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 would > like to remove the special case of the uart clocks we have right now in all > 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.protection.outlook.com/?url=http%3A%2F%2Fwww.pengutronix.de%2F&data=04%7C01%7Cabel.vesa%40nxp.com%7Ceed68987c68f4aeaa63408d8bdf2d051%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637468197861821302%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=X1J8KgxFquNin80zKVz0Ao22vv1MuTMWf91BUTczh9Y%3D&reserved=0 | > > 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