Skip to contentSkip to conversation

clk: exynos5420: Keep aclk66_peric enabled during boot

PATCH Superseded Doug Anderson 5 participants 22 messages May 29, 2014 – Jun 30, 2014

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: exynos5420: Keep aclk66_peric enabled during boot

Right now if you've got earlyprintk enabled on exynos5420-peach-pit then you'll get a hang on boot. Here's why:

1. The i2c-s3c2410 driver will probe at subsys_initcall. It will enable its clock and disable it. This is the clock "i2c2".
2. The act of disabling "i2c2" will disable its parents. In this case the parent is "aclk66_peric". There are no other children of "aclk66_peric" officially enabled, so "aclk66_peric" will be turned off (despite being CLK_IGNORE_UNUSED, but that's by design).
3. The next time you try to earlyprintk you'll do so without the UART clock enabled. That's because the UART clocks are also children of "aclk66_peric". You'll hang.

There's no good place to put a clock enable for earlyprintk, which is handled by a bunch of assembly code. The best we can do is to handle this in the clock driver.

---
 drivers/clk/samsung/clk-exynos5420.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/clk/samsung/clk-exynos5420.c +24 -0
index 9d7d7ee..1e586be 100644
@@ -1172,11 +1172,17 @@ static struct of_device_id ext_clk_match[] __initdata = {
 	{ },
 };
 
+/* Keep these clocks on until late_initcall */
+static const char *boot_clocks[] __initconst = {
+	"aclk66_peric",
+};
+
 /* register exynos5420 clocks */
 static void __init exynos5x_clk_init(struct device_node *np,
 		enum exynos5x_soc soc)
 {
 	struct samsung_clk_provider *ctx;
+	int i;
 
 	if (np) {
 		reg_base = of_iomap(np, 0);
@@ -1226,6 +1232,12 @@ static void __init exynos5x_clk_init(struct device_node *np,
 	}
 
 	exynos5420_clk_sleep_init();
+
+	for (i = 0; i < ARRAY_SIZE(boot_clocks); i++) {
+		struct clk *to_enable = __clk_lookup(boot_clocks[i]);
+
+		clk_prepare_enable(to_enable);
+	}
 }
 
 static void __init exynos5420_clk_init(struct device_node *np)
@@ -1239,3 +1251,15 @@ static void __init exynos5800_clk_init(struct device_node *np)
 	exynos5x_clk_init(np, EXYNOS5800);
 }
 CLK_OF_DECLARE(exynos5800_clk, "samsung,exynos5800-clock", exynos5800_clk_init);
+
+static int __init exynos5420_clk_late_init(void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(boot_clocks); i++) {
+		struct clk *to_disable = __clk_lookup(boot_clocks[i]);
+
+		clk_disable_unprepare(to_disable);
+	}
+}
+late_initcall(exynos5420_clk_late_init);
Signature · 1 line
1.9.1.423.g4596e3a
#1 lore raw

Quoting Doug Anderson (2014-05-29 14:21:36)

Quoted 45 lines

Right now if you've got earlyprintk enabled on exynos5420-peach-pit then you'll get a hang on boot. Here's why:

1. The i2c-s3c2410 driver will probe at subsys_initcall. It will enable its clock and disable it. This is the clock "i2c2".
2. The act of disabling "i2c2" will disable its parents. In this case the parent is "aclk66_peric". There are no other children of "aclk66_peric" officially enabled, so "aclk66_peric" will be turned off (despite being CLK_IGNORE_UNUSED, but that's by design).
3. The next time you try to earlyprintk you'll do so without the UART clock enabled. That's because the UART clocks are also children of "aclk66_peric". You'll hang.

There's no good place to put a clock enable for earlyprintk, which is handled by a bunch of assembly code. The best we can do is to handle this in the clock driver.

---
 drivers/clk/samsung/clk-exynos5420.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/clk/samsung/clk-exynos5420.c +6 -0
index 9d7d7ee..1e586be 100644
@@ -1172,11 +1172,17 @@ static struct of_device_id ext_clk_match[] __initdata = {
        { },
 };
 
+/* Keep these clocks on until late_initcall */
+static const char *boot_clocks[] __initconst = {
+       "aclk66_peric",
+};
+
 /* register exynos5420 clocks */
 static void __init exynos5x_clk_init(struct device_node *np,
                enum exynos5x_soc soc)
 {
        struct samsung_clk_provider *ctx;
+       int i;
 
        if (np) {
                reg_base = of_iomap(np, 0);

drivers/clk/samsung/clk-exynos5420.c static void __init exynos5x_clk_init(struct device_node *np, · line 1237

Quoted 6 lines
drivers/clk/samsung/clk-exynos5420.c +3 -0
@@ -1226,6 +1232,12 @@ static void __init exynos5x_clk_init(struct device_node *np,
        }
 
        exynos5420_clk_sleep_init();
+
+       for (i = 0; i < ARRAY_SIZE(boot_clocks); i++) {
+               struct clk *to_enable = __clk_lookup(boot_clocks[i]);

How about replacing __clk_lookup with clk_get? You can keep the struct clk object hanging around for later...

Quoted 9 lines
drivers/clk/samsung/clk-exynos5420.c +3 -0
+
+               clk_prepare_enable(to_enable);
+       }
 }
 
 static void __init exynos5420_clk_init(struct device_node *np)
@@ -1239,3 +1251,15 @@ static void __init exynos5800_clk_init(struct device_node *np)
        exynos5x_clk_init(np, EXYNOS5800);
 }

drivers/clk/samsung/clk-exynos5420.c static void __init exynos5800_clk_init(struct device_node *np) · line 1262

Quoted 10 lines
drivers/clk/samsung/clk-exynos5420.c +9 -0
 CLK_OF_DECLARE(exynos5800_clk, "samsung,exynos5800-clock", exynos5800_clk_init);
+
+static int __init exynos5420_clk_late_init(void)
+{
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(boot_clocks); i++) {
+               struct clk *to_disable = __clk_lookup(boot_clocks[i]);
+
+               clk_disable_unprepare(to_disable);

And then release it here with a clk_put.

Regards,
Mike

Quoted 6 lines
drivers/clk/samsung/clk-exynos5420.c +3 -0
+       }
+}
+late_initcall(exynos5420_clk_late_init);
Signature · 1 line
1.9.1.423.g4596e3a
#2 lore raw

Hi,

Quoted 48 lines · Mike Turquette

Quoting Doug Anderson (2014-05-29 14:21:36)

Quoted 47 lines

Right now if you've got earlyprintk enabled on exynos5420-peach-pit then you'll get a hang on boot. Here's why:

1. The i2c-s3c2410 driver will probe at subsys_initcall. It will enable its clock and disable it. This is the clock "i2c2".
2. The act of disabling "i2c2" will disable its parents. In this case the parent is "aclk66_peric". There are no other children of "aclk66_peric" officially enabled, so "aclk66_peric" will be turned off (despite being CLK_IGNORE_UNUSED, but that's by design).
3. The next time you try to earlyprintk you'll do so without the UART clock enabled. That's because the UART clocks are also children of "aclk66_peric". You'll hang.

There's no good place to put a clock enable for earlyprintk, which is handled by a bunch of assembly code. The best we can do is to handle this in the clock driver.

---
 drivers/clk/samsung/clk-exynos5420.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/clk/samsung/clk-exynos5420.c +6 -0
index 9d7d7ee..1e586be 100644
@@ -1172,11 +1172,17 @@ static struct of_device_id ext_clk_match[] __initdata = {
        { },
 };
 
+/* Keep these clocks on until late_initcall */
+static const char *boot_clocks[] __initconst = {
+       "aclk66_peric",
+};
+
 /* register exynos5420 clocks */
 static void __init exynos5x_clk_init(struct device_node *np,
                enum exynos5x_soc soc)
 {
        struct samsung_clk_provider *ctx;
+       int i;
 
        if (np) {
                reg_base = of_iomap(np, 0);
@@ -1226,6 +1232,12 @@ static void __init exynos5x_clk_init(struct device_node *np,
        }
 
Quoted 8 lines

drivers/clk/samsung/clk-exynos5420.c static void __init exynos5x_clk_init(struct device_node *np, · line 1237

Quoted 4 lines
drivers/clk/samsung/clk-exynos5420.c +3 -0
        exynos5420_clk_sleep_init();
+
+       for (i = 0; i < ARRAY_SIZE(boot_clocks); i++) {
+               struct clk *to_enable = __clk_lookup(boot_clocks[i]);

How about replacing __clk_lookup with clk_get? You can keep the struct clk object hanging around for later...

Mike, correct me if I'm wrong, but I thought you need clkdev look-up entry for clk_get() to find a clock. Here, this clock apparently don't have one and you don't even have a struct device * to pass to clk_get(), so even if you had a look-up entry, it would need to be a wildcard entry (with NULL device), which wouldn't be too elegant.

Doug, isn't a similar thing needed for PM debug as well? Maybe having this clock always ungated whenever DEBUG_LL is enabled would be enough?

Best regards,
Tomasz

#3 lore raw

Tomasz,

Quoted 60 lines · Tomasz Figa

Hi,

Quoted 48 lines · Mike Turquette

Quoting Doug Anderson (2014-05-29 14:21:36)

Quoted 47 lines

Right now if you've got earlyprintk enabled on exynos5420-peach-pit then you'll get a hang on boot. Here's why:

1. The i2c-s3c2410 driver will probe at subsys_initcall. It will enable its clock and disable it. This is the clock "i2c2".
2. The act of disabling "i2c2" will disable its parents. In this case the parent is "aclk66_peric". There are no other children of "aclk66_peric" officially enabled, so "aclk66_peric" will be turned off (despite being CLK_IGNORE_UNUSED, but that's by design).
3. The next time you try to earlyprintk you'll do so without the UART clock enabled. That's because the UART clocks are also children of "aclk66_peric". You'll hang.

There's no good place to put a clock enable for earlyprintk, which is handled by a bunch of assembly code. The best we can do is to handle this in the clock driver.

---
 drivers/clk/samsung/clk-exynos5420.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/clk/samsung/clk-exynos5420.c +6 -0
index 9d7d7ee..1e586be 100644
@@ -1172,11 +1172,17 @@ static struct of_device_id ext_clk_match[] __initdata = {
        { },
 };
 
+/* Keep these clocks on until late_initcall */
+static const char *boot_clocks[] __initconst = {
+       "aclk66_peric",
+};
+
 /* register exynos5420 clocks */
 static void __init exynos5x_clk_init(struct device_node *np,
                enum exynos5x_soc soc)
 {
        struct samsung_clk_provider *ctx;
+       int i;
 
        if (np) {
                reg_base = of_iomap(np, 0);
@@ -1226,6 +1232,12 @@ static void __init exynos5x_clk_init(struct device_node *np,
        }
 
Quoted 8 lines

drivers/clk/samsung/clk-exynos5420.c static void __init exynos5x_clk_init(struct device_node *np, · line 1237

Quoted 4 lines
drivers/clk/samsung/clk-exynos5420.c +3 -0
        exynos5420_clk_sleep_init();
+
+       for (i = 0; i < ARRAY_SIZE(boot_clocks); i++) {
+               struct clk *to_enable = __clk_lookup(boot_clocks[i]);

How about replacing __clk_lookup with clk_get? You can keep the struct clk object hanging around for later...

Quoted 5 lines

Mike, correct me if I'm wrong, but I thought you need clkdev look-up entry for clk_get() to find a clock. Here, this clock apparently don't have one and you don't even have a struct device * to pass to clk_get(), so even if you had a look-up entry, it would need to be a wildcard entry (with NULL device), which wouldn't be too elegant.

I'll send up the next patch changing this clock to "GATE_A" which will allow global lookups. ...then I'll use clk_get() as Mike requests. We can see if we like it better and can always move back to __clk_lookup().

Quoted 2 lines

Doug, isn't a similar thing needed for PM debug as well? Maybe having this clock always ungated whenever DEBUG_LL is enabled would be enough?

There may be a possible case where this is needed for PM debug, but I don't _think_ it's needed in all the common cases. It's also not sufficient, I think.

Specifically:

1. This patch only gets "aclk66_peric", not the UART clock itself. It makes the assumption (required for earlyprink) that the bootloader left enough clocks on to use the UART. That is roughly documented in Documentation/arm/Booting. Mostly this patch is making sure that we don't screw up the nice environment that the bootloader left for us. This solution has the nice side effect that we don't need to try to figure out which actual UART is active / grab the right clock.

2. Without grabbing the real UART clock then PM debug would start failing anyway when the system disables all unused clocks in late_init.

3. I would assume that if there was a problem here it would have surfaced in 5250. 5250 doesn't have the problem we're addressing here since there's no gate clock for "aclk66_peric" (or if there is one, it's not described in our clock tree).

4. Assuming that you've got the serial port specified as a console= port, I think the core will use s3c24xx_serial_pm to enable the clock and leave it on.

...I haven't got myself setup for PM debug upstream right now (would be good to get it configured / working locally eventually), but I think if we have problems to solve there then we should solve it in code related to PM debug. How does that sound?

Also note that on ChromeOS we always have DEBUG_LL enabled (though we usually don't have earlyprintk on the command line).

Tested-by on v1 1/1
#4 lore raw
In reply to Doug Anderson

Hello Doug,

Quoted 13 lines · Doug Anderson

Right now if you've got earlyprintk enabled on exynos5420-peach-pit then you'll get a hang on boot. Here's why:

1. The i2c-s3c2410 driver will probe at subsys_initcall. It will enable its clock and disable it. This is the clock "i2c2".
2. The act of disabling "i2c2" will disable its parents. In this case the parent is "aclk66_peric". There are no other children of "aclk66_peric" officially enabled, so "aclk66_peric" will be turned off (despite being CLK_IGNORE_UNUSED, but that's by design).
3. The next time you try to earlyprintk you'll do so without the UART clock enabled. That's because the UART clocks are also children of "aclk66_peric". You'll hang.

Quoted 9 lines

There's no good place to put a clock enable for earlyprintk, which is handled by a bunch of assembly code. The best we can do is to handle this in the clock driver.

---
 drivers/clk/samsung/clk-exynos5420.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

I tested your patch and it solves the issue for me, so feel free to add

Just one trivial comment below:

Quoted 42 lines
drivers/clk/samsung/clk-exynos5420.c +14 -0
index 9d7d7ee..1e586be 100644
@@ -1172,11 +1172,17 @@ static struct of_device_id ext_clk_match[] __initdata = {
 	{ },
 };
 
+/* Keep these clocks on until late_initcall */
+static const char *boot_clocks[] __initconst = {
+	"aclk66_peric",
+};
+
 /* register exynos5420 clocks */
 static void __init exynos5x_clk_init(struct device_node *np,
 		enum exynos5x_soc soc)
 {
 	struct samsung_clk_provider *ctx;
+	int i;
 
 	if (np) {
 		reg_base = of_iomap(np, 0);
@@ -1226,6 +1232,12 @@ static void __init exynos5x_clk_init(struct device_node *np,
 	}
 
 	exynos5420_clk_sleep_init();
+
+	for (i = 0; i < ARRAY_SIZE(boot_clocks); i++) {
+		struct clk *to_enable = __clk_lookup(boot_clocks[i]);
+
+		clk_prepare_enable(to_enable);
+	}
 }
 
 static void __init exynos5420_clk_init(struct device_node *np)
@@ -1239,3 +1251,15 @@ static void __init exynos5800_clk_init(struct device_node *np)
 	exynos5x_clk_init(np, EXYNOS5800);
 }
 CLK_OF_DECLARE(exynos5800_clk, "samsung,exynos5800-clock", exynos5800_clk_init);
+
+static int __init exynos5420_clk_late_init(void)

drivers/clk/samsung/clk-exynos5420.c static void __init exynos5800_clk_init(struct device_node *np) · line 1265

Quoted 10 lines
drivers/clk/samsung/clk-exynos5420.c +10 -0
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(boot_clocks); i++) {
+		struct clk *to_disable = __clk_lookup(boot_clocks[i]);
+
+		clk_disable_unprepare(to_disable);
+	}
+}
+late_initcall(exynos5420_clk_late_init);

You should return 0 here.

Best regards,
Javier

#5 lore raw

Javier,

Quoted 11 lines · Javier Martinez Canillas
Quoted 11 lines
drivers/clk/samsung/clk-exynos5420.c +7 -0
@@ -1239,3 +1251,15 @@ static void __init exynos5800_clk_init(struct device_node *np)
      exynos5x_clk_init(np, EXYNOS5800);
 }
 CLK_OF_DECLARE(exynos5800_clk, "samsung,exynos5800-clock", exynos5800_clk_init);
+
+static int __init exynos5420_clk_late_init(void)
+{
+     int i;
+
+     for (i = 0; i < ARRAY_SIZE(boot_clocks); i++) {
+             struct clk *to_disable = __clk_lookup(boot_clocks[i]);
Quoted 8 lines

drivers/clk/samsung/clk-exynos5420.c static void __init exynos5800_clk_init(struct device_node *np) · line 1265

Quoted 6 lines
drivers/clk/samsung/clk-exynos5420.c +5 -0
+
+             clk_disable_unprepare(to_disable);
+     }
+}
+late_initcall(exynos5420_clk_late_init);

You should return 0 here.

Duh. Done.

#6 lore raw

PATCH v2 1/1 clk: exynos5420: Keep aclk66_peric enabled during boot

In reply to Doug Anderson

Right now if you've got earlyprintk enabled on exynos5420-peach-pit then you'll get a hang on boot. Here's why:

1. The i2c-s3c2410 driver will probe at subsys_initcall. It will enable its clock and disable it. This is the clock "i2c2".
2. The act of disabling "i2c2" will disable its parents. In this case the parent is "aclk66_peric". There are no other children of "aclk66_peric" officially enabled, so "aclk66_peric" will be turned off (despite being CLK_IGNORE_UNUSED, but that's by design).
3. The next time you try to earlyprintk you'll do so without the UART clock enabled. That's because the UART clocks are also children of "aclk66_peric". You'll hang.

There's no good place to put a clock enable for earlyprintk, which is handled by a bunch of assembly code. The best we can do is to handle this in the clock driver.

---
Changes in v2:
- Use GATE_A and clk_get(). Save the clock for putting later.
- Return 0 from exynos5420_clk_late_init().

 drivers/clk/samsung/clk-exynos5420.c | 33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)
drivers/clk/samsung/clk-exynos5420.c +31 -2
index 9d7d7ee..70b607a 100644
@@ -890,8 +890,8 @@ static struct samsung_gate_clock exynos5x_gate_clks[] __initdata = {
 			GATE_BUS_TOP, 9, CLK_IGNORE_UNUSED, 0),
 	GATE(0, "aclk66_psgen", "mout_user_aclk66_psgen",
 			GATE_BUS_TOP, 10, CLK_IGNORE_UNUSED, 0),
-	GATE(CLK_ACLK66_PERIC, "aclk66_peric", "mout_user_aclk66_peric",
-			GATE_BUS_TOP, 11, CLK_IGNORE_UNUSED, 0),
+	GATE_A(CLK_ACLK66_PERIC, "aclk66_peric", "mout_user_aclk66_peric",
+			GATE_BUS_TOP, 11, CLK_IGNORE_UNUSED, 0, "aclk66_peric"),
 	GATE(0, "aclk266_isp", "mout_user_aclk266_isp",
 			GATE_BUS_TOP, 13, 0, 0),
 	GATE(0, "aclk166", "mout_user_aclk166",
@@ -1172,11 +1172,22 @@ static struct of_device_id ext_clk_match[] __initdata = {
 	{ },
 };
 
+/* Keep these clocks on until late_initcall */
+struct boot_clock {
+	char *name;
+	struct clk *clk;
+};
+
+static struct boot_clock boot_clocks[] __initdata = {
+	{ .name = "aclk66_peric", },
+};
+
 /* register exynos5420 clocks */
 static void __init exynos5x_clk_init(struct device_node *np,
 		enum exynos5x_soc soc)
 {
 	struct samsung_clk_provider *ctx;
+	int i;
 
 	if (np) {
 		reg_base = of_iomap(np, 0);
@@ -1226,6 +1237,11 @@ static void __init exynos5x_clk_init(struct device_node *np,
 	}
 
 	exynos5420_clk_sleep_init();
+
+	for (i = 0; i < ARRAY_SIZE(boot_clocks); i++) {
+		boot_clocks[i].clk = clk_get(NULL, boot_clocks[i].name);
+		clk_prepare_enable(boot_clocks[i].clk);
+	}
 }
 
 static void __init exynos5420_clk_init(struct device_node *np)
@@ -1239,3 +1255,16 @@ static void __init exynos5800_clk_init(struct device_node *np)
 	exynos5x_clk_init(np, EXYNOS5800);
 }
 CLK_OF_DECLARE(exynos5800_clk, "samsung,exynos5800-clock", exynos5800_clk_init);
+
+static int __init exynos5420_clk_late_init(void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(boot_clocks); i++) {
+		clk_disable_unprepare(boot_clocks[i].clk);
+		clk_put(boot_clocks[i].clk);
+	}
+
+	return 0;
+}
+late_initcall(exynos5420_clk_late_init);
Signature · 1 line
1.9.1.423.g4596e3a
#7 lore raw

Tomasz / Mike,

Quoted 19 lines · Doug Anderson

Right now if you've got earlyprintk enabled on exynos5420-peach-pit then you'll get a hang on boot. Here's why:

1. The i2c-s3c2410 driver will probe at subsys_initcall. It will enable its clock and disable it. This is the clock "i2c2".
2. The act of disabling "i2c2" will disable its parents. In this case the parent is "aclk66_peric". There are no other children of "aclk66_peric" officially enabled, so "aclk66_peric" will be turned off (despite being CLK_IGNORE_UNUSED, but that's by design).
3. The next time you try to earlyprintk you'll do so without the UART clock enabled. That's because the UART clocks are also children of "aclk66_peric". You'll hang.

There's no good place to put a clock enable for earlyprintk, which is handled by a bunch of assembly code. The best we can do is to handle this in the clock driver.

Quoted 7 lines

---
Changes in v2:
- Use GATE_A and clk_get(). Save the clock for putting later.
- Return 0 from exynos5420_clk_late_init().

 drivers/clk/samsung/clk-exynos5420.c | 33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)

Are there other changes you'd like me to make to this? It would be really nice to get this in for 3.16 so the system doesn't just mysteriously hang when you use earlyprintk.

-Doug

#8 lore raw
Quoted 27 lines · Doug Anderson

Tomasz / Mike,

Quoted 24 lines · Doug Anderson

Right now if you've got earlyprintk enabled on exynos5420-peach-pit then you'll get a hang on boot. Here's why:

1. The i2c-s3c2410 driver will probe at subsys_initcall. It will enable its clock and disable it. This is the clock "i2c2".
2. The act of disabling "i2c2" will disable its parents. In this case the parent is "aclk66_peric". There are no other children of "aclk66_peric" officially enabled, so "aclk66_peric" will be turned off (despite being CLK_IGNORE_UNUSED, but that's by design).
3. The next time you try to earlyprintk you'll do so without the UART clock enabled. That's because the UART clocks are also children of "aclk66_peric". You'll hang.

There's no good place to put a clock enable for earlyprintk, which is handled by a bunch of assembly code. The best we can do is to handle this in the clock driver.

---
Changes in v2:
- Use GATE_A and clk_get(). Save the clock for putting later.
- Return 0 from exynos5420_clk_late_init().

Quoted 6 lines
Quoted 2 lines
 drivers/clk/samsung/clk-exynos5420.c | 33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)

Are there other changes you'd like me to make to this? It would be really nice to get this in for 3.16 so the system doesn't just mysteriously hang when you use earlyprintk.

We can probably take this as an -rc fix, so it should be fine.

However I still don't see the point of exporting this clock and polluting the global clkdev namespace. Even the diffstat looks better in v1.

Best regards,
Tomasz

#9 lore raw

Tomasz,

Quoted 31 lines · Tomasz Figa
Quoted 30 lines · Doug Anderson

Tomasz / Mike,

Quoted 26 lines · Doug Anderson

Right now if you've got earlyprintk enabled on exynos5420-peach-pit then you'll get a hang on boot. Here's why:

1. The i2c-s3c2410 driver will probe at subsys_initcall. It will enable its clock and disable it. This is the clock "i2c2".
2. The act of disabling "i2c2" will disable its parents. In this case the parent is "aclk66_peric". There are no other children of "aclk66_peric" officially enabled, so "aclk66_peric" will be turned off (despite being CLK_IGNORE_UNUSED, but that's by design).
3. The next time you try to earlyprintk you'll do so without the UART clock enabled. That's because the UART clocks are also children of "aclk66_peric". You'll hang.

There's no good place to put a clock enable for earlyprintk, which is handled by a bunch of assembly code. The best we can do is to handle this in the clock driver.

---
Changes in v2:
- Use GATE_A and clk_get(). Save the clock for putting later.
- Return 0 from exynos5420_clk_late_init().

 drivers/clk/samsung/clk-exynos5420.c | 33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)
Quoted 8 lines
Quoted 3 lines

Are there other changes you'd like me to make to this? It would be really nice to get this in for 3.16 so the system doesn't just mysteriously hang when you use earlyprintk.

We can probably take this as an -rc fix, so it should be fine.

However I still don't see the point of exporting this clock and polluting the global clkdev namespace. Even the diffstat looks better in v1.

OK, I'm happy to go back to v1 with the addition of the "return 0".

Mike: are you OK with that?

#10 lore raw
Quoted 38 lines · Doug Anderson

Tomasz,

Quoted 35 lines · Tomasz Figa
Quoted 33 lines · Doug Anderson

Tomasz / Mike,

Quoted 19 lines · Doug Anderson

Right now if you've got earlyprintk enabled on exynos5420-peach-pit then you'll get a hang on boot. Here's why:

1. The i2c-s3c2410 driver will probe at subsys_initcall. It will enable its clock and disable it. This is the clock "i2c2".
2. The act of disabling "i2c2" will disable its parents. In this case the parent is "aclk66_peric". There are no other children of "aclk66_peric" officially enabled, so "aclk66_peric" will be turned off (despite being CLK_IGNORE_UNUSED, but that's by design).
3. The next time you try to earlyprintk you'll do so without the UART clock enabled. That's because the UART clocks are also children of "aclk66_peric". You'll hang.

There's no good place to put a clock enable for earlyprintk, which is handled by a bunch of assembly code. The best we can do is to handle this in the clock driver.

Quoted 7 lines

---
Changes in v2:
- Use GATE_A and clk_get(). Save the clock for putting later.
- Return 0 from exynos5420_clk_late_init().

 drivers/clk/samsung/clk-exynos5420.c | 33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)

Are there other changes you'd like me to make to this? It would be really nice to get this in for 3.16 so the system doesn't just mysteriously hang when you use earlyprintk.

Quoted 9 lines
Quoted 4 lines

We can probably take this as an -rc fix, so it should be fine.

However I still don't see the point of exporting this clock and polluting the global clkdev namespace. Even the diffstat looks better in v1.

OK, I'm happy to go back to v1 with the addition of the "return 0".

Mike: are you OK with that?

One more question that just came to my mind: Why it is just the aclk66_peri and not its children related to UARTs?

Exynos5420 clock driver still needs a little clean-up, so I'm okay with any fix for now and changing this later if needed, but is this gate clock for ACLK66_PERIC even needed? It seems to be marked with CLK_IGNORE_UNUSED which suggests that it is not needed in this driver at all, along with other similar clocks. AFAIK for power management purposes our fine-grained approach is fine and we shouldn't need to use the big gates.

Best regards,
Tomasz

#11 lore raw

Tomasz,

Quoted 2 lines · Tomasz Figa

One more question that just came to my mind: Why it is just the aclk66_peri and not its children related to UARTs?

Can you re-read out the original patch description and see if it answers that? Basically: the UART was left on by the bootloader and that's a requirement of earlyprintk but the common clock framework is messing with aclk66_peric which is what's killing us.

Quoted 7 lines

Exynos5420 clock driver still needs a little clean-up, so I'm okay with any fix for now and changing this later if needed, but is this gate clock for ACLK66_PERIC even needed? It seems to be marked with CLK_IGNORE_UNUSED which suggests that it is not needed in this driver at all, along with other similar clocks. AFAIK for power management purposes our fine-grained approach is fine and we shouldn't need to use the big gates.

Right, another option is to remove this gate from the clock tree (and reparent all children on the gate's parent) and that would also fix us. The main advantages of the "big gate" as I see it:

1. There's a reasonable chance that our clock tree description is not complete. Patches to add previously undocumented clocks seems to be a relatively common occurrence. If one of those undocumented clocks happens to be a child of aclk66_peric then we'll no longer be gating it.

2. There might be a small amount of power saved by gating the clock higher in the tree.

3. Having a more complete description of the clock tree is nice in case someone outside the kernel does something. If a stray pointer (or a nonstandard bootloader) gates the clock then our tree won't show problems, but the clock will still be gated.

Of course as soon as the first child of aclk66_peric is activated then points #1 and #2 are invalid. ...and #3 is a bit bogus because there are A LOT of gates that we already don't model.

Also: the CLK_IGNORE_UNUSED is a bit bogus here. That's not really a useful flag in the case that you've got children that are enabled and disabled. Once your first child is enabled and disabled you'll be disabled!

---

Hmmm, I think I've convinced myself that your suggestion of just removing this gate from the table is the right thing to do. Patch will be coming up soon.

-Doug

#12 lore raw

Hi,

Quoted 3 lines · Doug Anderson

Hmmm, I think I've convinced myself that your suggestion of just removing this gate from the table is the right thing to do. Patch will be coming up soon.

It's here <https://patchwork.kernel.org/patch/4308631/>

Ironically, that patch has a much worse diffstat and also changes devicetree bindings (!). ...but it does seem better.

-Doug

#13 lore raw

PATCH v3 1/1 clk: exynos5420: Remove aclk66_peric from the clock tree description

In reply to Doug Anderson

The "aclk66_peric" clock is a gate clock with a whole bunch of gates underneath it. This big gate isn't very useful to include in our clock tree. If any of the children need to be turned on then the big gate will need to be on anyway. ...and there are plenty of other "big gates" that aren't described in our clock tree, some of which shut off collections of clocks that have no relationship in the hierarchy so are hard to model.

"aclk66_peric" is causing earlyprintk problems since it gets disabled as part of the boot process, so let's just remove it.

Strangely (and for no good reason) this clock is exported as part of the common clock bindings. Remove it since there are no in-kernel device trees using it and no reason anyone out of tree should refer to it either.

---
Changes in v3:
- Now just remove aclk66_peric from the tree as suggested by Tomasz.

Changes in v2:
- Use GATE_A and clk_get(). Save the clock for putting later.
- Return 0 from exynos5420_clk_late_init().

 drivers/clk/samsung/clk-exynos5420.c   | 85 ++++++++++++++++++++++------------
 include/dt-bindings/clock/exynos5420.h |  1 -
 2 files changed, 55 insertions(+), 31 deletions(-)
drivers/clk/samsung/clk-exynos5420.c +55 -30
index 9d7d7ee..61eccf0 100644
@@ -890,8 +890,6 @@ static struct samsung_gate_clock exynos5x_gate_clks[] __initdata = {
 			GATE_BUS_TOP, 9, CLK_IGNORE_UNUSED, 0),
 	GATE(0, "aclk66_psgen", "mout_user_aclk66_psgen",
 			GATE_BUS_TOP, 10, CLK_IGNORE_UNUSED, 0),
-	GATE(CLK_ACLK66_PERIC, "aclk66_peric", "mout_user_aclk66_peric",
-			GATE_BUS_TOP, 11, CLK_IGNORE_UNUSED, 0),
 	GATE(0, "aclk266_isp", "mout_user_aclk266_isp",
 			GATE_BUS_TOP, 13, 0, 0),
 	GATE(0, "aclk166", "mout_user_aclk166",
@@ -994,34 +992,61 @@ static struct samsung_gate_clock exynos5x_gate_clks[] __initdata = {
 			SRC_MASK_FSYS, 24, CLK_SET_RATE_PARENT, 0),
 
 	/* PERIC Block */
-	GATE(CLK_UART0, "uart0", "aclk66_peric", GATE_IP_PERIC, 0, 0, 0),
-	GATE(CLK_UART1, "uart1", "aclk66_peric", GATE_IP_PERIC, 1, 0, 0),
-	GATE(CLK_UART2, "uart2", "aclk66_peric", GATE_IP_PERIC, 2, 0, 0),
-	GATE(CLK_UART3, "uart3", "aclk66_peric", GATE_IP_PERIC, 3, 0, 0),
-	GATE(CLK_I2C0, "i2c0", "aclk66_peric", GATE_IP_PERIC, 6, 0, 0),
-	GATE(CLK_I2C1, "i2c1", "aclk66_peric", GATE_IP_PERIC, 7, 0, 0),
-	GATE(CLK_I2C2, "i2c2", "aclk66_peric", GATE_IP_PERIC, 8, 0, 0),
-	GATE(CLK_I2C3, "i2c3", "aclk66_peric", GATE_IP_PERIC, 9, 0, 0),
-	GATE(CLK_USI0, "usi0", "aclk66_peric", GATE_IP_PERIC, 10, 0, 0),
-	GATE(CLK_USI1, "usi1", "aclk66_peric", GATE_IP_PERIC, 11, 0, 0),
-	GATE(CLK_USI2, "usi2", "aclk66_peric", GATE_IP_PERIC, 12, 0, 0),
-	GATE(CLK_USI3, "usi3", "aclk66_peric", GATE_IP_PERIC, 13, 0, 0),
-	GATE(CLK_I2C_HDMI, "i2c_hdmi", "aclk66_peric", GATE_IP_PERIC, 14, 0, 0),
-	GATE(CLK_TSADC, "tsadc", "aclk66_peric", GATE_IP_PERIC, 15, 0, 0),
-	GATE(CLK_SPI0, "spi0", "aclk66_peric", GATE_IP_PERIC, 16, 0, 0),
-	GATE(CLK_SPI1, "spi1", "aclk66_peric", GATE_IP_PERIC, 17, 0, 0),
-	GATE(CLK_SPI2, "spi2", "aclk66_peric", GATE_IP_PERIC, 18, 0, 0),
-	GATE(CLK_I2S1, "i2s1", "aclk66_peric", GATE_IP_PERIC, 20, 0, 0),
-	GATE(CLK_I2S2, "i2s2", "aclk66_peric", GATE_IP_PERIC, 21, 0, 0),
-	GATE(CLK_PCM1, "pcm1", "aclk66_peric", GATE_IP_PERIC, 22, 0, 0),
-	GATE(CLK_PCM2, "pcm2", "aclk66_peric", GATE_IP_PERIC, 23, 0, 0),
-	GATE(CLK_PWM, "pwm", "aclk66_peric", GATE_IP_PERIC, 24, 0, 0),
-	GATE(CLK_SPDIF, "spdif", "aclk66_peric", GATE_IP_PERIC, 26, 0, 0),
-	GATE(CLK_USI4, "usi4", "aclk66_peric", GATE_IP_PERIC, 28, 0, 0),
-	GATE(CLK_USI5, "usi5", "aclk66_peric", GATE_IP_PERIC, 30, 0, 0),
-	GATE(CLK_USI6, "usi6", "aclk66_peric", GATE_IP_PERIC, 31, 0, 0),
-
-	GATE(CLK_KEYIF, "keyif", "aclk66_peric", GATE_BUS_PERIC, 22, 0, 0),
+	GATE(CLK_UART0, "uart0", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 0, 0, 0),
+	GATE(CLK_UART1, "uart1", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 1, 0, 0),
+	GATE(CLK_UART2, "uart2", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 2, 0, 0),
+	GATE(CLK_UART3, "uart3", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 3, 0, 0),
+	GATE(CLK_I2C0, "i2c0", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 6, 0, 0),
+	GATE(CLK_I2C1, "i2c1", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 7, 0, 0),
+	GATE(CLK_I2C2, "i2c2", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 8, 0, 0),
+	GATE(CLK_I2C3, "i2c3", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 9, 0, 0),
+	GATE(CLK_USI0, "usi0", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 10, 0, 0),
+	GATE(CLK_USI1, "usi1", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 11, 0, 0),
+	GATE(CLK_USI2, "usi2", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 12, 0, 0),
+	GATE(CLK_USI3, "usi3", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 13, 0, 0),
+	GATE(CLK_I2C_HDMI, "i2c_hdmi", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 14, 0, 0),
+	GATE(CLK_TSADC, "tsadc", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 15, 0, 0),
+	GATE(CLK_SPI0, "spi0", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 16, 0, 0),
+	GATE(CLK_SPI1, "spi1", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 17, 0, 0),
+	GATE(CLK_SPI2, "spi2", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 18, 0, 0),
+	GATE(CLK_I2S1, "i2s1", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 20, 0, 0),
+	GATE(CLK_I2S2, "i2s2", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 21, 0, 0),
+	GATE(CLK_PCM1, "pcm1", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 22, 0, 0),
+	GATE(CLK_PCM2, "pcm2", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 23, 0, 0),
+	GATE(CLK_PWM, "pwm", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 24, 0, 0),
+	GATE(CLK_SPDIF, "spdif", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 26, 0, 0),
+	GATE(CLK_USI4, "usi4", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 28, 0, 0),
+	GATE(CLK_USI5, "usi5", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 30, 0, 0),
+	GATE(CLK_USI6, "usi6", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 31, 0, 0),
+
+	GATE(CLK_KEYIF, "keyif", "mout_user_aclk66_peric",
+			GATE_BUS_PERIC, 22, 0, 0),
 
 	/* PERIS Block */
 	GATE(CLK_CHIPID, "chipid", "aclk66_psgen",
include/dt-bindings/clock/exynos5420.h +0 -1
index 97dcb89..14e1c8f 100644
@@ -63,7 +63,6 @@
 #define CLK_SCLK_MPHY_IXTAL24	161
 
 /* gate clocks */
-#define CLK_ACLK66_PERIC	256
 #define CLK_UART0		257
 #define CLK_UART1		258
 #define CLK_UART2		259
Signature · 1 line
2.0.0.526.g5318336
Acked-by on v3 1/1
#14 lore raw

Re: [PATCH v3] clk: exynos5420: Remove aclk66_peric from the clock tree description

Quoted 21 lines · Doug Anderson

The "aclk66_peric" clock is a gate clock with a whole bunch of gates underneath it. This big gate isn't very useful to include in our clock tree. If any of the children need to be turned on then the big gate will need to be on anyway. ...and there are plenty of other "big gates" that aren't described in our clock tree, some of which shut off collections of clocks that have no relationship in the hierarchy so are hard to model.

"aclk66_peric" is causing earlyprintk problems since it gets disabled as part of the boot process, so let's just remove it.

Strangely (and for no good reason) this clock is exported as part of the common clock bindings. Remove it since there are no in-kernel device trees using it and no reason anyone out of tree should refer to it either.

---
Changes in v3:
- Now just remove aclk66_peric from the tree as suggested by Tomasz.

Quoted 8 lines

Changes in v2:
- Use GATE_A and clk_get(). Save the clock for putting later.
- Return 0 from exynos5420_clk_late_init().

 drivers/clk/samsung/clk-exynos5420.c   | 85 ++++++++++++++++++++++------------
 include/dt-bindings/clock/exynos5420.h |  1 -
 2 files changed, 55 insertions(+), 31 deletions(-)

Mike, I can take this patch to my tree as a fix for 3.16-rc, or if still possible and you don't mind, feel free to apply it directly with my ACK:

Best regards,
Tomasz

#15 lore raw

Re: [PATCH v3] clk: exynos5420: Remove aclk66_peric from the clock tree description

Quoting Tomasz Figa (2014-06-05 15:26:31)

Quoted 31 lines · Doug Anderson
Quoted 21 lines

The "aclk66_peric" clock is a gate clock with a whole bunch of gates underneath it. This big gate isn't very useful to include in our clock tree. If any of the children need to be turned on then the big gate will need to be on anyway. ...and there are plenty of other "big gates" that aren't described in our clock tree, some of which shut off collections of clocks that have no relationship in the hierarchy so are hard to model.

"aclk66_peric" is causing earlyprintk problems since it gets disabled as part of the boot process, so let's just remove it.

Strangely (and for no good reason) this clock is exported as part of the common clock bindings. Remove it since there are no in-kernel device trees using it and no reason anyone out of tree should refer to it either.

---
Changes in v3:
- Now just remove aclk66_peric from the tree as suggested by Tomasz.

Quoted 8 lines

Changes in v2:
- Use GATE_A and clk_get(). Save the clock for putting later.
- Return 0 from exynos5420_clk_late_init().

 drivers/clk/samsung/clk-exynos5420.c   | 85 ++++++++++++++++++++++------------
 include/dt-bindings/clock/exynos5420.h |  1 -
 2 files changed, 55 insertions(+), 31 deletions(-)
Quoted 4 lines

Mike, I can take this patch to my tree as a fix for 3.16-rc, or if still possible and you don't mind, feel free to apply it directly with my ACK:

I'll send a second PR next week that includes this.

Regards,
Mike

Quoted 3 lines

Best regards,
Tomasz

#16 lore raw

Re: [PATCH v3] clk: exynos5420: Remove aclk66_peric from the clock tree description

Tomasz,

Quoted 32 lines · Mike Turquette

Quoting Tomasz Figa (2014-06-05 15:26:31)

Quoted 31 lines · Doug Anderson
Quoted 29 lines

The "aclk66_peric" clock is a gate clock with a whole bunch of gates underneath it. This big gate isn't very useful to include in our clock tree. If any of the children need to be turned on then the big gate will need to be on anyway. ...and there are plenty of other "big gates" that aren't described in our clock tree, some of which shut off collections of clocks that have no relationship in the hierarchy so are hard to model.

"aclk66_peric" is causing earlyprintk problems since it gets disabled as part of the boot process, so let's just remove it.

Strangely (and for no good reason) this clock is exported as part of the common clock bindings. Remove it since there are no in-kernel device trees using it and no reason anyone out of tree should refer to it either.

---
Changes in v3:
- Now just remove aclk66_peric from the tree as suggested by Tomasz.

Changes in v2:
- Use GATE_A and clk_get(). Save the clock for putting later.
- Return 0 from exynos5420_clk_late_init().

 drivers/clk/samsung/clk-exynos5420.c   | 85 ++++++++++++++++++++++------------
 include/dt-bindings/clock/exynos5420.h |  1 -
 2 files changed, 55 insertions(+), 31 deletions(-)
Quoted 6 lines
Quoted 4 lines

Mike, I can take this patch to my tree as a fix for 3.16-rc, or if still possible and you don't mind, feel free to apply it directly with my ACK:

I'll send a second PR next week that includes this.

This doesn't apply cleanly to Mike's tree. Can you add it to your tree and send it out for 3.16? Mike said you should add his Ack and I've confirmed that the patch applies cleanly to the most recent linuxnext (next-20140606) as well as to the top of your 'samsung-clk-next' tree (2ce16c5 clk: samsung: exynos3250: Add clocks using common clock framework).

Thanks!

-Doug

#17 lore raw

Re: [PATCH v3] clk: exynos5420: Remove aclk66_peric from the clock tree description

In reply to Doug Anderson

Quoting Doug Anderson (2014-06-05 13:35:14)

Quoted 7 lines

The "aclk66_peric" clock is a gate clock with a whole bunch of gates underneath it. This big gate isn't very useful to include in our clock tree. If any of the children need to be turned on then the big gate will need to be on anyway. ...and there are plenty of other "big gates" that aren't described in our clock tree, some of which shut off collections of clocks that have no relationship in the hierarchy so are hard to model.

I think this is a common problem. On OMAP we have something similar to this called "clock domains" or "clkdm" and it has been historically handled outside of the Linux clock framework[1]. There is a relationship to the clock framework of course and in the future it might be worthwhile to see if there is a generic way to handle this stuff.

Quoted 8 lines

"aclk66_peric" is causing earlyprintk problems since it gets disabled as part of the boot process, so let's just remove it.

Strangely (and for no good reason) this clock is exported as part of the common clock bindings. Remove it since there are no in-kernel device trees using it and no reason anyone out of tree should refer to it either.

So Linux has no control over the big gate now, correct? You are dependent on the bootloader to ungate this thing?

Regards,
Mike

[1] http://deferred.io/images/clkdm.png

Quoted 132 lines

---
Changes in v3:
- Now just remove aclk66_peric from the tree as suggested by Tomasz.

Changes in v2:
- Use GATE_A and clk_get(). Save the clock for putting later.
- Return 0 from exynos5420_clk_late_init().

 drivers/clk/samsung/clk-exynos5420.c   | 85 ++++++++++++++++++++++------------
 include/dt-bindings/clock/exynos5420.h |  1 -
 2 files changed, 55 insertions(+), 31 deletions(-)
drivers/clk/samsung/clk-exynos5420.c +55 -30
index 9d7d7ee..61eccf0 100644
@@ -890,8 +890,6 @@ static struct samsung_gate_clock exynos5x_gate_clks[] __initdata = {
                        GATE_BUS_TOP, 9, CLK_IGNORE_UNUSED, 0),
        GATE(0, "aclk66_psgen", "mout_user_aclk66_psgen",
                        GATE_BUS_TOP, 10, CLK_IGNORE_UNUSED, 0),
-       GATE(CLK_ACLK66_PERIC, "aclk66_peric", "mout_user_aclk66_peric",
-                       GATE_BUS_TOP, 11, CLK_IGNORE_UNUSED, 0),
        GATE(0, "aclk266_isp", "mout_user_aclk266_isp",
                        GATE_BUS_TOP, 13, 0, 0),
        GATE(0, "aclk166", "mout_user_aclk166",
@@ -994,34 +992,61 @@ static struct samsung_gate_clock exynos5x_gate_clks[] __initdata = {
                        SRC_MASK_FSYS, 24, CLK_SET_RATE_PARENT, 0),
 
        /* PERIC Block */
-       GATE(CLK_UART0, "uart0", "aclk66_peric", GATE_IP_PERIC, 0, 0, 0),
-       GATE(CLK_UART1, "uart1", "aclk66_peric", GATE_IP_PERIC, 1, 0, 0),
-       GATE(CLK_UART2, "uart2", "aclk66_peric", GATE_IP_PERIC, 2, 0, 0),
-       GATE(CLK_UART3, "uart3", "aclk66_peric", GATE_IP_PERIC, 3, 0, 0),
-       GATE(CLK_I2C0, "i2c0", "aclk66_peric", GATE_IP_PERIC, 6, 0, 0),
-       GATE(CLK_I2C1, "i2c1", "aclk66_peric", GATE_IP_PERIC, 7, 0, 0),
-       GATE(CLK_I2C2, "i2c2", "aclk66_peric", GATE_IP_PERIC, 8, 0, 0),
-       GATE(CLK_I2C3, "i2c3", "aclk66_peric", GATE_IP_PERIC, 9, 0, 0),
-       GATE(CLK_USI0, "usi0", "aclk66_peric", GATE_IP_PERIC, 10, 0, 0),
-       GATE(CLK_USI1, "usi1", "aclk66_peric", GATE_IP_PERIC, 11, 0, 0),
-       GATE(CLK_USI2, "usi2", "aclk66_peric", GATE_IP_PERIC, 12, 0, 0),
-       GATE(CLK_USI3, "usi3", "aclk66_peric", GATE_IP_PERIC, 13, 0, 0),
-       GATE(CLK_I2C_HDMI, "i2c_hdmi", "aclk66_peric", GATE_IP_PERIC, 14, 0, 0),
-       GATE(CLK_TSADC, "tsadc", "aclk66_peric", GATE_IP_PERIC, 15, 0, 0),
-       GATE(CLK_SPI0, "spi0", "aclk66_peric", GATE_IP_PERIC, 16, 0, 0),
-       GATE(CLK_SPI1, "spi1", "aclk66_peric", GATE_IP_PERIC, 17, 0, 0),
-       GATE(CLK_SPI2, "spi2", "aclk66_peric", GATE_IP_PERIC, 18, 0, 0),
-       GATE(CLK_I2S1, "i2s1", "aclk66_peric", GATE_IP_PERIC, 20, 0, 0),
-       GATE(CLK_I2S2, "i2s2", "aclk66_peric", GATE_IP_PERIC, 21, 0, 0),
-       GATE(CLK_PCM1, "pcm1", "aclk66_peric", GATE_IP_PERIC, 22, 0, 0),
-       GATE(CLK_PCM2, "pcm2", "aclk66_peric", GATE_IP_PERIC, 23, 0, 0),
-       GATE(CLK_PWM, "pwm", "aclk66_peric", GATE_IP_PERIC, 24, 0, 0),
-       GATE(CLK_SPDIF, "spdif", "aclk66_peric", GATE_IP_PERIC, 26, 0, 0),
-       GATE(CLK_USI4, "usi4", "aclk66_peric", GATE_IP_PERIC, 28, 0, 0),
-       GATE(CLK_USI5, "usi5", "aclk66_peric", GATE_IP_PERIC, 30, 0, 0),
-       GATE(CLK_USI6, "usi6", "aclk66_peric", GATE_IP_PERIC, 31, 0, 0),
-
-       GATE(CLK_KEYIF, "keyif", "aclk66_peric", GATE_BUS_PERIC, 22, 0, 0),
+       GATE(CLK_UART0, "uart0", "mout_user_aclk66_peric",
+                       GATE_IP_PERIC, 0, 0, 0),
+       GATE(CLK_UART1, "uart1", "mout_user_aclk66_peric",
+                       GATE_IP_PERIC, 1, 0, 0),
+       GATE(CLK_UART2, "uart2", "mout_user_aclk66_peric",
+                       GATE_IP_PERIC, 2, 0, 0),
+       GATE(CLK_UART3, "uart3", "mout_user_aclk66_peric",
+                       GATE_IP_PERIC, 3, 0, 0),
+       GATE(CLK_I2C0, "i2c0", "mout_user_aclk66_peric",
+                       GATE_IP_PERIC, 6, 0, 0),
+       GATE(CLK_I2C1, "i2c1", "mout_user_aclk66_peric",
+                       GATE_IP_PERIC, 7, 0, 0),
+       GATE(CLK_I2C2, "i2c2", "mout_user_aclk66_peric",
+                       GATE_IP_PERIC, 8, 0, 0),
+       GATE(CLK_I2C3, "i2c3", "mout_user_aclk66_peric",
+                       GATE_IP_PERIC, 9, 0, 0),
+       GATE(CLK_USI0, "usi0", "mout_user_aclk66_peric",
+                       GATE_IP_PERIC, 10, 0, 0),
+       GATE(CLK_USI1, "usi1", "mout_user_aclk66_peric",
+                       GATE_IP_PERIC, 11, 0, 0),
+       GATE(CLK_USI2, "usi2", "mout_user_aclk66_peric",
+                       GATE_IP_PERIC, 12, 0, 0),
+       GATE(CLK_USI3, "usi3", "mout_user_aclk66_peric",
+                       GATE_IP_PERIC, 13, 0, 0),
+       GATE(CLK_I2C_HDMI, "i2c_hdmi", "mout_user_aclk66_peric",
+                       GATE_IP_PERIC, 14, 0, 0),
+       GATE(CLK_TSADC, "tsadc", "mout_user_aclk66_peric",
+                       GATE_IP_PERIC, 15, 0, 0),
+       GATE(CLK_SPI0, "spi0", "mout_user_aclk66_peric",
+                       GATE_IP_PERIC, 16, 0, 0),
+       GATE(CLK_SPI1, "spi1", "mout_user_aclk66_peric",
+                       GATE_IP_PERIC, 17, 0, 0),
+       GATE(CLK_SPI2, "spi2", "mout_user_aclk66_peric",
+                       GATE_IP_PERIC, 18, 0, 0),
+       GATE(CLK_I2S1, "i2s1", "mout_user_aclk66_peric",
+                       GATE_IP_PERIC, 20, 0, 0),
+       GATE(CLK_I2S2, "i2s2", "mout_user_aclk66_peric",
+                       GATE_IP_PERIC, 21, 0, 0),
+       GATE(CLK_PCM1, "pcm1", "mout_user_aclk66_peric",
+                       GATE_IP_PERIC, 22, 0, 0),
+       GATE(CLK_PCM2, "pcm2", "mout_user_aclk66_peric",
+                       GATE_IP_PERIC, 23, 0, 0),
+       GATE(CLK_PWM, "pwm", "mout_user_aclk66_peric",
+                       GATE_IP_PERIC, 24, 0, 0),
+       GATE(CLK_SPDIF, "spdif", "mout_user_aclk66_peric",
+                       GATE_IP_PERIC, 26, 0, 0),
+       GATE(CLK_USI4, "usi4", "mout_user_aclk66_peric",
+                       GATE_IP_PERIC, 28, 0, 0),
+       GATE(CLK_USI5, "usi5", "mout_user_aclk66_peric",
+                       GATE_IP_PERIC, 30, 0, 0),
+       GATE(CLK_USI6, "usi6", "mout_user_aclk66_peric",
+                       GATE_IP_PERIC, 31, 0, 0),
+
+       GATE(CLK_KEYIF, "keyif", "mout_user_aclk66_peric",
+                       GATE_BUS_PERIC, 22, 0, 0),
 
        /* PERIS Block */
        GATE(CLK_CHIPID, "chipid", "aclk66_psgen",
include/dt-bindings/clock/exynos5420.h +0 -1
index 97dcb89..14e1c8f 100644
@@ -63,7 +63,6 @@
 #define CLK_SCLK_MPHY_IXTAL24  161
 
 /* gate clocks */
-#define CLK_ACLK66_PERIC       256
 #define CLK_UART0              257
 #define CLK_UART1              258
 #define CLK_UART2              259
Signature · 1 line
2.0.0.526.g5318336
#18 lore raw

Re: [PATCH v3] clk: exynos5420: Remove aclk66_peric from the clock tree description

Mike,

Quoted 9 lines · Mike Turquette

Quoting Doug Anderson (2014-06-05 13:35:14)

Quoted 7 lines

The "aclk66_peric" clock is a gate clock with a whole bunch of gates underneath it. This big gate isn't very useful to include in our clock tree. If any of the children need to be turned on then the big gate will need to be on anyway. ...and there are plenty of other "big gates" that aren't described in our clock tree, some of which shut off collections of clocks that have no relationship in the hierarchy so are hard to model.

Quoted 5 lines

I think this is a common problem. On OMAP we have something similar to this called "clock domains" or "clkdm" and it has been historically handled outside of the Linux clock framework[1]. There is a relationship to the clock framework of course and in the future it might be worthwhile to see if there is a generic way to handle this stuff.

That sounds like something that would be nice to solve, but it's not going to happen now.

On the off chance that the user manual mentioned the existence of one of these "big gate" bits, it tends to not be very specific about _exactly_ which sets of clocks it disables.

Tracking down every one of these would be hugely time consuming.
Also: as Tomasz has indicated they don't provide a huge amount of benefit since we're already dealing with clocks on a more fine-grained level...

Quoted 10 lines
Quoted 7 lines

"aclk66_peric" is causing earlyprintk problems since it gets disabled as part of the boot process, so let's just remove it.

Strangely (and for no good reason) this clock is exported as part of the common clock bindings. Remove it since there are no in-kernel device trees using it and no reason anyone out of tree should refer to it either.

So Linux has no control over the big gate now, correct? You are dependent on the bootloader to ungate this thing?

A better way to put it is that you're dependent on the bootloader not to gate it.

...but that's also true for pretty much any clock marked IGNORE_UNUSED and not explicitly enabled anywhere.

Are you opposed to this landing as-is to unblock things and people can continue to work on the clock driver to make it even better?

-Doug

#19 lore raw

PATCH v3 1/1 clk: exynos5420: Remove aclk66_peric from the clock tree description

Quoting Doug Anderson (2014-06-05 17:46:23)

Quoted 21 lines

Mike,

Quoted 9 lines · Mike Turquette

Quoting Doug Anderson (2014-06-05 13:35:14)

Quoted 7 lines

The "aclk66_peric" clock is a gate clock with a whole bunch of gates underneath it. This big gate isn't very useful to include in our clock tree. If any of the children need to be turned on then the big gate will need to be on anyway. ...and there are plenty of other "big gates" that aren't described in our clock tree, some of which shut off collections of clocks that have no relationship in the hierarchy so are hard to model.

Quoted 5 lines

I think this is a common problem. On OMAP we have something similar to this called "clock domains" or "clkdm" and it has been historically handled outside of the Linux clock framework[1]. There is a relationship to the clock framework of course and in the future it might be worthwhile to see if there is a generic way to handle this stuff.

That sounds like something that would be nice to solve, but it's not going to happen now.

Quoted 8 lines

On the off chance that the user manual mentioned the existence of one of these "big gate" bits, it tends to not be very specific about _exactly_ which sets of clocks it disables.

Tracking down every one of these would be hugely time consuming.
Also: as Tomasz has indicated they don't provide a huge amount of benefit since we're already dealing with clocks on a more fine-grained level...

Sounds like you are dealing with crappy documentation :-(

Quoted 16 lines
Quoted 5 lines
Quoted 5 lines

"aclk66_peric" is causing earlyprintk problems since it gets disabled as part of the boot process, so let's just remove it.

Quoted 7 lines
Quoted 4 lines

Strangely (and for no good reason) this clock is exported as part of the common clock bindings. Remove it since there are no in-kernel device trees using it and no reason anyone out of tree should refer to it either.

So Linux has no control over the big gate now, correct? You are dependent on the bootloader to ungate this thing?

A better way to put it is that you're dependent on the bootloader not to gate it.

Quoted 6 lines

...but that's also true for pretty much any clock marked IGNORE_UNUSED and not explicitly enabled anywhere.

Are you opposed to this landing as-is to unblock things and people can continue to work on the clock driver to make it even better?

No. I'm just trying to understand how things work so that we can arrive to the right decision. I know what it is like to try and quickly unblock everyone else and the rush to do so often leads to less awesome solutions.

Anyways, getting back on point, Tomasz was right about the whole clk_get thing. So I'm happy to take either V1 or V3 of your patch. I will be submitting a second PR for 3.16 next week and it will include whichever version you and Tomasz agree is best.

Regards,
Mike

Quoted 2 lines

-Doug

#20 lore raw

Re: [PATCH v3] clk: exynos5420: Remove aclk66_peric from the clock tree description

Mike,

Quoted 4 lines · Mike Turquette

Anyways, getting back on point, Tomasz was right about the whole clk_get thing. So I'm happy to take either V1 or V3 of your patch. I will be submitting a second PR for 3.16 next week and it will include whichever version you and Tomasz agree is best.

I like V3 slightly better and it has Tomasz's Ack. Unless he emails and suggests that he really V1 better then I'd say go with V3. If we go back to V1 we'll need to add the "return 0", which I'm happy to do.

Thanks!

-Doug

Applied
#21 lore raw

Re: [PATCH v3] clk: exynos5420: Remove aclk66_peric from the clock tree description

In reply to Doug Anderson
Quoted 21 lines · Doug Anderson

The "aclk66_peric" clock is a gate clock with a whole bunch of gates underneath it. This big gate isn't very useful to include in our clock tree. If any of the children need to be turned on then the big gate will need to be on anyway. ...and there are plenty of other "big gates" that aren't described in our clock tree, some of which shut off collections of clocks that have no relationship in the hierarchy so are hard to model.

"aclk66_peric" is causing earlyprintk problems since it gets disabled as part of the boot process, so let's just remove it.

Strangely (and for no good reason) this clock is exported as part of the common clock bindings. Remove it since there are no in-kernel device trees using it and no reason anyone out of tree should refer to it either.

---
Changes in v3:
- Now just remove aclk66_peric from the tree as suggested by Tomasz.

Quoted 7 lines

Changes in v2:
- Use GATE_A and clk_get(). Save the clock for putting later.
- Return 0 from exynos5420_clk_late_init().

 drivers/clk/samsung/clk-exynos5420.c   | 85 ++++++++++++++++++++++------------
 include/dt-bindings/clock/exynos5420.h |  1 -
 2 files changed, 55 insertions(+), 31 deletions(-)

Applied as a fix for 3.16.

Best regards,
Tomasz