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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 384DAC433EF for ; Sat, 20 Nov 2021 16:49:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc: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=TpklEIyoB8haTkrnWUMWyQgOySjkHnhWaGZeukXkAf4=; b=SAyTsNcAcmrFtM ulGpvII8/smqmcVTRyIKIwdCQCXx1SjJAUVaof87q9v2M4ocUh17dN46rlSWrC3o0pb0ugbiyOOZC or7frjh/IgmjGf1McSbcHkxDHFAYkWF/7b1Y1CAEust4CJvtxHvRo4VKdj20DGfOte0QqhkA2zK4E ohtyp9SRq3R0+QzhiDStFXOIrljwCtDw5WjNjvhxktUtvsXHccQZOUCA1tbPyHGtuYyRL5gOD60z8 FrcdQ1De7i/pDaOmdLxJMbb31I5aPHOVbfZcm100TM7kNufDd8U6pq+4tudFNVUsuaio+vCAY9IOr qSWmFBJPZiuV1bGpp+yQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1moTWe-00Citm-LN; Sat, 20 Nov 2021 16:47:40 +0000 Received: from mail-ua1-x933.google.com ([2607:f8b0:4864:20::933]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1moTWb-00Ciqx-AT for linux-arm-kernel@lists.infradead.org; Sat, 20 Nov 2021 16:47:38 +0000 Received: by mail-ua1-x933.google.com with SMTP id n6so27699014uak.1 for ; Sat, 20 Nov 2021 08:47:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LcCNsIIRQmi9fqIEvnMibk8k3koK5l2JssJUcrk+fw4=; b=jMk5slXa/4KsCJddpQLCmcV5tk5cSqKLefCLDfjzI/NDwf1rfs467yGH8LzJI13EnG ou24tQkfC8FUptGLaI7Mv0/gS+5lrhA0lwpRXZvBp+6B2GDkypFjqhvrMdeMHvxb0pf0 wmI+uGEOJ6J1gkZrHuHMrhLQ7Jo41cT0Ur7Hmh1O7grj68xAG1iuOvg8542unhEcOcXT sIRSn0rjUDcWzdjWIi0MPtUq9rXWthBb435o6cw8lBiYO+59j5blge+qFHQFNkODtyLK CHKmkFpAu/bsVOLVx99VhHrzBqSzEOYi0mHhByEGx6uTUYTX1QWZ0IEtznKUTDCdKOCn rjog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LcCNsIIRQmi9fqIEvnMibk8k3koK5l2JssJUcrk+fw4=; b=M27Cmn7ZF2Lp+r2wS9e/tAFdEpOcL2apooJJiceo3NkPqkug586Os+cFDtXXPokhag QJ9O3NjIpoUW2Nu/gskk4QH8naEc2tnOiwnW7LQt9JUmXtz+cK5m7ugp0tKGnTID/QHW GHjpCl2eW7frABqQ6bck80i8LA4T8Zzs6UAAps5jM6KRBuM+NYGDMZaz9mYwcR+a25YA f1tdtS2HMGJcXujlsWTRyfNe4ES0GWtqJJ4aGrwcc+FS2hI62kKcIPziAQcXdo+7BAU7 cgrQrk7xqhPbW1Sbl/UuV8IyVqYxZM2Ra3FaFJtCuabYMZ8R/h9B1nDG01ApF3FXM85w UP6w== X-Gm-Message-State: AOAM531YStw1PJYWKh7a5sBTB9iojg+Yi8r0s4TMnS2Uk1pNtjWlZvzq h6SY4Zj5ITAFeYsclChRB7I7wB90k3QMiHan+zXXyw== X-Google-Smtp-Source: ABdhPJxDXdWLh4LgDoWZMOBx3ThJIN505varR1lJarijd9Ge+2680HEjBOkIgO6Pe4uBcHT+uXO6sYbVvra2L+6tbq0= X-Received: by 2002:a05:6102:4192:: with SMTP id cd18mr109091338vsb.35.1637426854968; Sat, 20 Nov 2021 08:47:34 -0800 (PST) MIME-Version: 1.0 References: <20211025161254.5575-1-semen.protsenko@linaro.org> In-Reply-To: From: Sam Protsenko Date: Sat, 20 Nov 2021 18:47:23 +0200 Message-ID: Subject: Re: [PATCH v2 1/1] clk: samsung: exynos850: Register clocks early To: Sylwester Nawrocki Cc: Sumit Semwal , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Krzysztof Kozlowski , =?UTF-8?Q?Pawe=C5=82_Chmiel?= , Chanwoo Choi , Tomasz Figa , Rob Herring , Stephen Boyd , Michael Turquette X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211120_084737_424437_9BCB1A24 X-CRM114-Status: GOOD ( 33.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 Sat, 20 Nov 2021 at 14:49, Sylwester Nawrocki wrote: > > On 25.10.2021 18:12, Sam Protsenko wrote: > > Some clocks must be registered before init calls. For example MCT clock > > (from CMU_PERI) is needed for MCT timer driver, which is registered > > with TIMER_OF_DECLARE(). By the time we get to core_initcall() used for > > clk-exynos850 platform driver init, it's already too late. Inability to > > get "mct" clock in MCT driver leads to kernel panic, as functions > > registered with *_OF_DECLARE() can't do deferred calls. MCT timer driver > > can't be fixed either, as it's acting as a clock source and it's > > essential to register it in start_kernel() -> time_init(). > > > > Let's register CMU_PERI clocks early, using CLK_OF_DECLARE_DRIVER(), and > > do all stuff relying on "struct dev" object (like runtime PM and > > enabling bus clock) later in platform driver probe. Basically > > CLK_OF_DECLARE_DRIVER() matches CMU compatible, but clears OF_POPULATED > > flag, which allows the same device to be matched again later. > > > Signed-off-by: Sam Protsenko > > > drivers/clk/samsung/clk-exynos850.c | 17 +++++++++++++++-- > > 1 file changed, 15 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/clk/samsung/clk-exynos850.c b/drivers/clk/samsung/clk-exynos850.c > > index 95e373d17b42..ecffa5c7a081 100644 > > --- a/drivers/clk/samsung/clk-exynos850.c > > +++ b/drivers/clk/samsung/clk-exynos850.c > > @@ -753,6 +753,15 @@ static const struct samsung_cmu_info peri_cmu_info __initconst = { > > .clk_name = "dout_peri_bus", > > }; > > > > +static void __init exynos850_cmu_peri_init(struct device_node *np) > > +{ > > + exynos850_init_clocks(np, peri_clk_regs, ARRAY_SIZE(peri_clk_regs)); > > + samsung_cmu_register_one(np, &peri_cmu_info); > > +} > > + > > +CLK_OF_DECLARE_DRIVER(exynos850_cmu_peri, "samsung,exynos850-cmu-peri", > > + exynos850_cmu_peri_init); > > + > > /* ---- CMU_CORE ------------------------------------------------------------ */ > > > > /* Register Offset definitions for CMU_CORE (0x12000000) */ > > @@ -920,8 +929,12 @@ static int __init exynos850_cmu_probe(struct platform_device *pdev) > > struct device_node *np = dev->of_node; > > > > info = of_device_get_match_data(dev); > > - exynos850_init_clocks(np, info->clk_regs, info->nr_clk_regs); > > - samsung_cmu_register_one(np, info); > > + > > + /* Early clocks are already registered using CLK_OF_DECLARE_DRIVER() */ > > + if (info != &peri_cmu_info) { > > + exynos850_init_clocks(np, info->clk_regs, info->nr_clk_regs); > > + samsung_cmu_register_one(np, info); > > + } > > Don't you also need to register early CMU_TOP, which provides clocks > for CMU_PERI? I'm afraid it might not work properly when you register > CMU_PERI clocks early and only later in probe() you enable parent clock > required for the already registered clocks to be usable. Good point, I'll do that in v2. Not sure how I missed that dependency point, but thank you for noticing that. Guess it only works for me because clocks are already enabled in bootloader, and I'm using "clk_ignore_unused" param for now. > How about registering also CMU_TOP early and enabling parent clock > also in OF_CLK_DECLARE init callback, i.e. using either OF_CLK_DECLARE > or platform driver for a CMU? > If you mean doing clk_prepare_enable() for "dout_peri_bus" clock in exynos850_cmu_peri_init(), I don't think it's possible. clk_get() needs "struct device *dev", and we only have that in platform driver probe. Trying to pass dev=NULL won't work, so that's why I'm enabling parent clocks in platform driver probe. I'm going to submit new patch series soon. It'll include all my recent patches, addressing all your comments. We can continue discussion there, in case I misunderstood you and those patches are still not correct. Thanks! > -- > Regards, > Sylwester _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel