From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Thu, 23 Nov 2023 08:23:31 +0100 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1r643e-005U6c-30 for lore@lore.pengutronix.de; Thu, 23 Nov 2023 08:23:31 +0100 Received: from bombadil.infradead.org ([2607:7c80:54:3::133]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r643e-0006Tl-NL for lore@pengutronix.de; Thu, 23 Nov 2023 08:23:31 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:From:In-Reply-To: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=u8sycjDZiodVwCMPCFYbWo5S8tSKTQLxKpOgm+VD3uw=; b=NA/48tSzpyvP6LiUwEV26ywu54 18mCWwv4rGdOtxUYtQ1+ttHk0dofJotHQDs2PlVgIi51eg+wwcbn620BOXY8RgtYFzrpCwdUU8lpu EdftDSZMqiopmrZhZctn07ZnRpHmjCqeK8B99iiLBH9gg3KeGPmdRSKUm+mDrf295qinSvkqqhhpL P9gMEy/xDLRlZ6E3pNyUDnnKbg77LDTa/7zZQ9tW5LPPosq0ryZLiEREeh4C4piW057Q0NEOZROHo 2pZ9zLq7a30iDc63hrVCs4HRlu0xnOmhPDtTCycbFmhKLM5NduCUyWEmLfy+ykeej/iRRksyueU2Y ftjywvmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r642V-0040zt-0H; Thu, 23 Nov 2023 07:22:19 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r642R-0040z5-2D for barebox@lists.infradead.org; Thu, 23 Nov 2023 07:22:17 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r642Q-0006Gk-HJ; Thu, 23 Nov 2023 08:22:14 +0100 Received: from [2a0a:edc0:2:b01:1d::c0] (helo=ptx.whiteo.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r642Q-00AzPF-4r; Thu, 23 Nov 2023 08:22:14 +0100 Received: from sha by ptx.whiteo.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1r642Q-003QCp-2U; Thu, 23 Nov 2023 08:22:14 +0100 Date: Thu, 23 Nov 2023 08:22:14 +0100 To: Ahmad Fatoum Cc: barebox@lists.infradead.org Message-ID: <20231123072214.GE3359458@pengutronix.de> References: <20231122171320.1714868-1-a.fatoum@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231122171320.1714868-1-a.fatoum@pengutronix.de> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-Accept-Language: de,en X-Accept-Content-Type: text/plain User-Agent: Mutt/1.10.1 (2018-07-13) From: Sascha Hauer X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231122_232215_725336_6F6DB86E X-CRM114-Status: GOOD ( 31.41 ) X-BeenThere: barebox@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "barebox" X-SA-Exim-Connect-IP: 2607:7c80:54:3::133 X-SA-Exim-Mail-From: barebox-bounces+lore=pengutronix.de@lists.infradead.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.whiteo.stw.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-5.0 required=4.0 tests=AWL,BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Subject: Re: [PATCH v2 1/2] console: provide best-effort clk_get_for_console helper X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.whiteo.stw.pengutronix.de) On Wed, Nov 22, 2023 at 06:13:19PM +0100, Ahmad Fatoum wrote: > From: Ahmad Fatoum > > clk_get will return -EPROBE_DEFER if clock provider hasn't yet been > probed. In a system with deep probe enabled, dependencies are probed > on demand, so a -EPROBE_DEFER return is final and the console probe > will never succeed. > > CONFIG_DEBUG_LL is often used to debug this, but because the low-level > console is not interactive, it's a bit cumbersome. Improve upon this a > bit, by providing a clk_get_for_console helper that returns NULL if and > only if we are sure that a clock provider will not be probed. > > In that case, the driver can skip code paths initialization code and > baud rate setting dependent on having access to the clock and still > register a console that reuses what was set up by CONFIG_DEBUG_LL. > > Signed-off-by: Ahmad Fatoum > --- > v1 -> v2: > - restrict new mechanism to stdout console (Sascha) > --- > include/console.h | 27 +++++++++++++++++++++++++++ > include/linux/clk.h | 21 +++++++++++++++++++++ > 2 files changed, 48 insertions(+) Applied, thanks Sascha > > diff --git a/include/console.h b/include/console.h > index d7cbdfa99207..69c0ec144b31 100644 > --- a/include/console.h > +++ b/include/console.h > @@ -8,6 +8,7 @@ > #define _CONSOLE_H_ > > #include > +#include > #include > #include > #include > @@ -228,4 +229,30 @@ static inline void console_ctrlc_allow(void) { } > static inline void console_ctrlc_forbid(void) { } > #endif > > +/** > + * clk_get_for_console - get clock, ignoring known unavailable clock controller > + * @dev: device for clock "consumer" > + * @id: clock consumer ID > + * > + * Return: a struct clk corresponding to the clock producer, a > + * valid IS_ERR() condition containing errno or NULL if it could > + * be determined that the clock producer will never be probed in > + * absence of modules. The NULL return allows serial drivers to > + * skip clock handling for the stdout console and rely on CONFIG_DEBUG_LL. > + */ > +static inline struct clk *clk_get_for_console(struct device *dev, const char *id) > +{ > + __always_unused unsigned baudrate; > + struct clk *clk; > + > + if (!IS_ENABLED(CONFIG_DEBUG_LL) || !of_device_is_stdout_path(dev, &baudrate)) > + return clk_get(dev, id); > + > + clk = clk_get_if_available(dev, id); > + if (clk == NULL) > + dev_warn(dev, "couldn't get clock (ignoring)\n"); > + > + return clk; > +} > + > #endif > diff --git a/include/linux/clk.h b/include/linux/clk.h > index 61b4ff3127cf..f505f18a75c0 100644 > --- a/include/linux/clk.h > +++ b/include/linux/clk.h > @@ -14,6 +14,7 @@ > #include > #include > #include > +#include > #include > > struct device; > @@ -982,4 +983,24 @@ static inline struct clk *clk_get_enabled(struct device *dev, const char *id) > return clk; > } > > +/** > + * clk_get_if_available - get clock, ignoring known unavailable clock controller > + * @dev: device for clock "consumer" > + * @id: clock consumer ID > + * > + * Return: a struct clk corresponding to the clock producer, a > + * valid IS_ERR() condition containing errno or NULL if it could > + * be determined that the clock producer will never be probed in > + * absence of modules. > + */ > +static inline struct clk *clk_get_if_available(struct device *dev, const char *id) > +{ > + struct clk *clk = clk_get(dev, id); > + > + if (clk == ERR_PTR(-EPROBE_DEFER) && deep_probe_is_supported()) > + return NULL; > + > + return clk; > +} > + > #endif > -- > 2.39.2 > > > -- 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 |