From: "Emilio López" <emilio.lopez@collabora.co.uk> To: mturquette@baylibre.com, sboyd@codeaurora.org, maxime.ripard@free-electrons.com, wens@csie.org, heiko@sntech.de Cc: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "Emilio López" <emilio.lopez@collabora.co.uk> Subject: [PATCH 1/2] clk: sunxi: delay protected clocks until arch initcall Date: Thu, 21 Jan 2016 11:10:38 -0300 [thread overview] Message-ID: <1453385439-10154-2-git-send-email-emilio.lopez@collabora.co.uk> (raw) In-Reply-To: <1453385439-10154-1-git-send-email-emilio.lopez@collabora.co.uk> Clocks are registered early on, and unused clocks get disabled on late initcall, so we can delay protecting important clocks a bit. If we do this too early, it may happen that some clocks are orphans and therefore enabling them may not work as intended. If we do this too late, a driver may reparent some clock and cause another important clock to be disabled as a byproduct. arch_initcall should be a good spot to do this, as clock drivers using the OF mechanisms will be all registered by then, and drivers won't have started probing yet. Signed-off-by: Emilio López <emilio.lopez@collabora.co.uk> --- drivers/clk/sunxi/clk-sunxi.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c index 5ba2188..285e8ee 100644 --- a/drivers/clk/sunxi/clk-sunxi.c +++ b/drivers/clk/sunxi/clk-sunxi.c @@ -1153,10 +1153,12 @@ static void __init of_sunxi_table_clock_setup(const struct of_device_id *clk_mat } } +/* By default, don't protect any clocks */ +static const char **protected_clocks __initdata; +static int protected_clocks_nr __initdata; + static void __init sunxi_init_clocks(const char *clocks[], int nclocks) { - unsigned int i; - /* Register divided output clocks */ of_sunxi_table_clock_setup(clk_divs_match, sunxi_divs_clk_setup); @@ -1169,14 +1171,26 @@ static void __init sunxi_init_clocks(const char *clocks[], int nclocks) /* Register mux clocks */ of_sunxi_table_clock_setup(clk_mux_match, sunxi_mux_clk_setup); + /* We shall protect these clocks when everything is ready */ + protected_clocks = clocks; + protected_clocks_nr = nclocks; +} + +static int __init sunxi_init_clock_protection(void) +{ + unsigned int i; + /* Protect the clocks that needs to stay on */ - for (i = 0; i < nclocks; i++) { - struct clk *clk = clk_get(NULL, clocks[i]); + for (i = 0; i < protected_clocks_nr; i++) { + struct clk *clk = clk_get(NULL, protected_clocks[i]); if (!IS_ERR(clk)) clk_prepare_enable(clk); } + + return 0; } +arch_initcall(sunxi_init_clock_protection); static const char *sun4i_a10_critical_clocks[] __initdata = { "pll5_ddr", -- 2.7.0
WARNING: multiple messages have this Message-ID (diff)
From: emilio.lopez@collabora.co.uk (Emilio López) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/2] clk: sunxi: delay protected clocks until arch initcall Date: Thu, 21 Jan 2016 11:10:38 -0300 [thread overview] Message-ID: <1453385439-10154-2-git-send-email-emilio.lopez@collabora.co.uk> (raw) In-Reply-To: <1453385439-10154-1-git-send-email-emilio.lopez@collabora.co.uk> Clocks are registered early on, and unused clocks get disabled on late initcall, so we can delay protecting important clocks a bit. If we do this too early, it may happen that some clocks are orphans and therefore enabling them may not work as intended. If we do this too late, a driver may reparent some clock and cause another important clock to be disabled as a byproduct. arch_initcall should be a good spot to do this, as clock drivers using the OF mechanisms will be all registered by then, and drivers won't have started probing yet. Signed-off-by: Emilio L?pez <emilio.lopez@collabora.co.uk> --- drivers/clk/sunxi/clk-sunxi.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c index 5ba2188..285e8ee 100644 --- a/drivers/clk/sunxi/clk-sunxi.c +++ b/drivers/clk/sunxi/clk-sunxi.c @@ -1153,10 +1153,12 @@ static void __init of_sunxi_table_clock_setup(const struct of_device_id *clk_mat } } +/* By default, don't protect any clocks */ +static const char **protected_clocks __initdata; +static int protected_clocks_nr __initdata; + static void __init sunxi_init_clocks(const char *clocks[], int nclocks) { - unsigned int i; - /* Register divided output clocks */ of_sunxi_table_clock_setup(clk_divs_match, sunxi_divs_clk_setup); @@ -1169,14 +1171,26 @@ static void __init sunxi_init_clocks(const char *clocks[], int nclocks) /* Register mux clocks */ of_sunxi_table_clock_setup(clk_mux_match, sunxi_mux_clk_setup); + /* We shall protect these clocks when everything is ready */ + protected_clocks = clocks; + protected_clocks_nr = nclocks; +} + +static int __init sunxi_init_clock_protection(void) +{ + unsigned int i; + /* Protect the clocks that needs to stay on */ - for (i = 0; i < nclocks; i++) { - struct clk *clk = clk_get(NULL, clocks[i]); + for (i = 0; i < protected_clocks_nr; i++) { + struct clk *clk = clk_get(NULL, protected_clocks[i]); if (!IS_ERR(clk)) clk_prepare_enable(clk); } + + return 0; } +arch_initcall(sunxi_init_clock_protection); static const char *sun4i_a10_critical_clocks[] __initdata = { "pll5_ddr", -- 2.7.0
next prev parent reply other threads:[~2016-01-21 14:10 UTC|newest] Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-01-21 14:10 [PATCH 0/2] defer clk_gets on orphan clocks Emilio López 2016-01-21 14:10 ` Emilio López 2016-01-21 14:10 ` Emilio López [this message] 2016-01-21 14:10 ` [PATCH 1/2] clk: sunxi: delay protected clocks until arch initcall Emilio López 2016-01-27 15:37 ` Maxime Ripard 2016-01-27 15:37 ` Maxime Ripard 2016-01-27 16:14 ` Heiko Stübner 2016-01-27 16:14 ` Heiko Stübner 2016-01-27 20:38 ` Maxime Ripard 2016-01-27 20:38 ` Maxime Ripard 2016-01-27 21:07 ` Heiko Stübner 2016-01-27 21:07 ` Heiko Stübner 2016-01-27 18:53 ` Emilio López 2016-01-27 18:53 ` Emilio López 2016-02-01 19:32 ` Maxime Ripard 2016-02-01 19:32 ` Maxime Ripard 2016-01-21 14:19 ` [PATCH 2/2] clk: defer clk_gets on orphan clocks Emilio López 2016-01-21 14:19 ` Emilio López 2016-01-28 8:23 ` Stephen Boyd 2016-01-28 8:23 ` Stephen Boyd 2016-01-28 9:03 ` Heiko Stübner 2016-01-28 9:03 ` Heiko Stübner 2016-01-29 19:54 ` Stephen Boyd 2016-01-29 19:54 ` Stephen Boyd
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1453385439-10154-2-git-send-email-emilio.lopez@collabora.co.uk \ --to=emilio.lopez@collabora.co.uk \ --cc=heiko@sntech.de \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-clk@vger.kernel.org \ --cc=maxime.ripard@free-electrons.com \ --cc=mturquette@baylibre.com \ --cc=sboyd@codeaurora.org \ --cc=wens@csie.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.