Skip to contentSkip to conversation

clk: improve handling of orphan clocks

PATCH Applied Heiko Stuebner 8 participants 34 messages Apr 22, 2015 – Aug 12, 2015

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

v3 cover clk: improve handling of orphan clocks

Using orphan clocks can introduce strange behaviour as they don't have rate information at all and also of course don't track

This v2/v3 takes into account suggestions from Stephen Boyd to not try to walk the clock tree at runtime but instead keep track of orphan states on clock tree changes and making it mandatory for everybody from the start as orphaned clocks should not be used at all.

This fixes an issue on most rk3288 platforms, where some soc-clocks are supplied by a 32khz clock from an external i2c-chip which often is only probed later in the boot process and maybe even after the drivers using these soc-clocks like the tsadc temperature sensor. In this case the driver using the clock should of course defer probing until the clock is actually usable.

As this changes the behaviour for orphan clocks, it would of course benefit from more testing than on my Rockchip boards. To keep the recipent-list reasonable and not spam to much I selected one (the topmost) from the get_maintainer output of each drivers/clk entry. Hopefully some will provide Tested-by-tags :-)

Thanks
Heiko

changes since v2:
adapt to comments from Stephen Boyd
- rename to clk_core_update_orphan_status
- use bools instead of 0/1 for the status
- remove redundant check in clk_is_orphan
changes since v1:
- track orphan status on clock tree changes instead of walking the tree on clk_get operations
- make get-deferals mandatory for everybody

Cc Boris Brezillon <[email protected]>
Cc Alex Elder <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc Stephen Warren <[email protected]>
Cc Max Filippov <[email protected]>
Cc kernel at pengutronix.de
Cc Zhangfei Gao <[email protected]>
Cc Santosh Shilimkar <[email protected]>
Cc Chao Xie <[email protected]>
Cc Jason Cooper <[email protected]>
Cc Stefan Wahren <[email protected]>
Cc Andrew Bresticker <[email protected]>
Cc Robert Jarzmik <[email protected]>
Cc Georgi Djakov <[email protected]>
Cc Sylwester Nawrocki <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Barry Song <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Viresh Kumar <[email protected]>
Cc Gabriel FERNANDEZ <[email protected]>
Cc emilio at elopez.com.ar
Cc Peter De Schrijver <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Ulf Hansson <[email protected]>
Cc Pawel Moll <[email protected]>
Cc Michal Simek <[email protected]>

Heiko Stuebner (2):
clk: track the orphan status of clocks and their children
clk: prevent orphan clocks from being used

 drivers/clk/clk.c | 46 +++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 43 insertions(+), 3 deletions(-)
Signature · 1 line
2.1.4
#1 lore raw

PATCH v3 1/2 clk: track the orphan status of clocks and their children

While children of orphan clocks are not carried in the orphan-list itself, they're nevertheless orphans in their own right as they also don't have an input-rate available. To ease tracking if a clock is an orphan or has an orphan in its parent path introduce an orphan field into struct clk and update it and the fields in child-clocks when a clock gets added or removed from the orphan-list.

Cc Boris Brezillon <[email protected]>
Cc Alex Elder <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc Stephen Warren <[email protected]>
Cc Max Filippov <[email protected]>
Cc kernel at pengutronix.de
Cc Zhangfei Gao <[email protected]>
Cc Santosh Shilimkar <[email protected]>
Cc Chao Xie <[email protected]>
Cc Jason Cooper <[email protected]>
Cc Stefan Wahren <[email protected]>
Cc Andrew Bresticker <[email protected]>
Cc Robert Jarzmik <[email protected]>
Cc Georgi Djakov <[email protected]>
Cc Sylwester Nawrocki <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Barry Song <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Viresh Kumar <[email protected]>
Cc Gabriel FERNANDEZ <[email protected]>
Cc emilio at elopez.com.ar
Cc Peter De Schrijver <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Ulf Hansson <[email protected]>
Cc Pawel Moll <[email protected]>
Cc Michal Simek <[email protected]>
---
 drivers/clk/clk.c | 33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)
drivers/clk/clk.c +30 -3
index b2361d4..341904f 100644
@@ -62,6 +62,7 @@ struct clk_core {
 	struct clk_core		*new_parent;
 	struct clk_core		*new_child;
 	unsigned long		flags;
+	bool			orphan;
 	unsigned int		enable_count;
 	unsigned int		prepare_count;
 	unsigned long		accuracy;
@@ -1401,18 +1402,40 @@ static int clk_fetch_parent_index(struct clk_core *clk,
 	return -EINVAL;
 }
 
+/*
+ * Update the orphan status of @clk and all its children.
+ */
+static void clk_core_update_orphan_status(struct clk_core *clk, bool is_orphan)
+{
+	struct clk_core *child;
+
+	clk->orphan = is_orphan;
+
+	hlist_for_each_entry(child, &clk->children, child_node)
+		clk_core_update_orphan_status(child, is_orphan);
+}
+
 static void clk_reparent(struct clk_core *clk, struct clk_core *new_parent)
 {
+	bool was_orphan = clk->orphan;
+
 	hlist_del(&clk->child_node);
 
 	if (new_parent) {
+		bool becomes_orphan = new_parent->orphan;
+
 		/* avoid duplicate POST_RATE_CHANGE notifications */
 		if (new_parent->new_child == clk)
 			new_parent->new_child = NULL;
 
 		hlist_add_head(&clk->child_node, &new_parent->children);
+
+		if (was_orphan != becomes_orphan)
+			clk_core_update_orphan_status(clk, becomes_orphan);
 	} else {
 		hlist_add_head(&clk->child_node, &clk_orphan_list);
+		if (!was_orphan)
+			clk_core_update_orphan_status(clk, true);
 	}
 
 	clk->parent = new_parent;
@@ -2302,13 +2325,17 @@ static int __clk_init(struct device *dev, struct clk *clk_user)
 	 * clocks and re-parent any that are children of the clock currently
 	 * being clk_init'd.
 	 */
-	if (clk->parent)
+	if (clk->parent) {
 		hlist_add_head(&clk->child_node,
 				&clk->parent->children);
-	else if (clk->flags & CLK_IS_ROOT)
+		clk->orphan = clk->parent->orphan;
+	} else if (clk->flags & CLK_IS_ROOT) {
 		hlist_add_head(&clk->child_node, &clk_root_list);
-	else
+		clk->orphan = false;
+	} else {
 		hlist_add_head(&clk->child_node, &clk_orphan_list);
+		clk->orphan = true;
+	}
 
 	/*
 	 * Set clk's accuracy.  The preferred method is to use
Signature · 1 line
2.1.4
#2 lore raw

Re: [PATCH v3 1/2] clk: track the orphan status of clocks and their children

drivers/clk/clk.c static int clk_fetch_parent_index(struct clk_core *clk, · line 1408

Quoted 8 lines · Heiko Stuebner
drivers/clk/clk.c +4 -0
@@ -1401,18 +1402,40 @@ static int clk_fetch_parent_index(struct clk_core *clk,
 	return -EINVAL;
 }
 
+/*
+ * Update the orphan status of @clk and all its children.
+ */
+static void clk_core_update_orphan_status(struct clk_core *clk, bool is_orphan)

Missed s/clk/core/ here. I did it, no need to resend.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#3 lore raw

PATCH v3 2/2 clk: prevent orphan clocks from being used

In reply to Heiko Stuebner

Orphan clocks or children of orphan clocks don't have rate information at all and can produce strange results if they're allowed to be used and the parent becomes available later on.

So using the newly introduced orphan status bit defer __of_clk_get_from_provider calls for orphan clocks.

Cc Boris Brezillon <[email protected]>
Cc Alex Elder <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc Stephen Warren <[email protected]>
Cc Max Filippov <[email protected]>
Cc kernel at pengutronix.de
Cc Zhangfei Gao <[email protected]>
Cc Santosh Shilimkar <[email protected]>
Cc Chao Xie <[email protected]>
Cc Jason Cooper <[email protected]>
Cc Stefan Wahren <[email protected]>
Cc Andrew Bresticker <[email protected]>
Cc Robert Jarzmik <[email protected]>
Cc Georgi Djakov <[email protected]>
Cc Sylwester Nawrocki <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Barry Song <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Viresh Kumar <[email protected]>
Cc Gabriel FERNANDEZ <[email protected]>
Cc emilio at elopez.com.ar
Cc Peter De Schrijver <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Ulf Hansson <[email protected]>
Cc Pawel Moll <[email protected]>
Cc Michal Simek <[email protected]>
---
 drivers/clk/clk.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/clk/clk.c +13 -0
index 341904f..27d2d4b 100644
@@ -2226,6 +2226,14 @@ bool clk_is_match(const struct clk *p, const struct clk *q)
 }
 EXPORT_SYMBOL_GPL(clk_is_match);
 
+static bool clk_is_orphan(const struct clk *clk)
+{
+	if (!clk)
+		return false;
+
+	return clk->core->orphan;
+}
+
 /**
  * __clk_init - initialize the data structures in a struct clk
  * @dev:	device initializing this clk, placeholder for now
@@ -2968,6 +2976,11 @@ struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec,
 		if (provider->node == clkspec->np)
 			clk = provider->get(clkspec, provider->data);
 		if (!IS_ERR(clk)) {
+			if (clk_is_orphan(clk)) {
+				clk = ERR_PTR(-EPROBE_DEFER);
+				break;
+			}
+
 			clk = __clk_create_clk(__clk_get_hw(clk), dev_id,
 					       con_id);
 
Signature · 1 line
2.1.4
Applied
#4 lore raw

Re: [PATCH v3 2/2] clk: prevent orphan clocks from being used

Quoted 26 lines · Heiko Stuebner

Orphan clocks or children of orphan clocks don't have rate information at all and can produce strange results if they're allowed to be used and the parent becomes available later on.

So using the newly introduced orphan status bit defer __of_clk_get_from_provider calls for orphan clocks.

Cc Boris Brezillon <[email protected]>
Cc Alex Elder <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc Stephen Warren <[email protected]>
Cc Max Filippov <[email protected]>
Cc kernel at pengutronix.de
Cc Zhangfei Gao <[email protected]>
Cc Santosh Shilimkar <[email protected]>
Cc Chao Xie <[email protected]>
Cc Jason Cooper <[email protected]>
Cc Stefan Wahren <[email protected]>
Cc Andrew Bresticker <[email protected]>
Cc Robert Jarzmik <[email protected]>
Cc Georgi Djakov <[email protected]>
Cc Sylwester Nawrocki <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Barry Song <[email protected]>
Cc Dinh Nguyen <[email protected]>
Quoted 8 lines
Cc Viresh Kumar <[email protected]>
Cc Gabriel FERNANDEZ <[email protected]>
Cc emilio at elopez.com.ar
Cc Peter De Schrijver <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Ulf Hansson <[email protected]>
Cc Pawel Moll <[email protected]>
Cc Michal Simek <[email protected]>

Applied to clk-next.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#5 lore raw
In reply to Heiko Stuebner

Hi Heiko,

Quoted 6 lines

Heiko Stuebner <[email protected]> hat am 22. April 2015 um 22:53 geschrieben:

Using orphan clocks can introduce strange behaviour as they don't have rate information at all and also of course don't track

Quoted 9 lines

[...]

As this changes the behaviour for orphan clocks, it would of course benefit from more testing than on my Rockchip boards. To keep the recipent-list reasonable and not spam to much I selected one (the topmost) from the get_maintainer output of each drivers/clk entry. Hopefully some will provide Tested-by-tags :-)

excuse me for my naive question, but what kind of tests do you expect (beside applying the patches)?

Stefan

Quoted 4 lines

Thanks
Heiko

#6 lore raw

Hi Stefan,

Am Samstag, 25. April 2015, 14:23:39 schrieb Stefan Wahren:

Quoted 10 lines
Quoted 10 lines

Heiko Stuebner <[email protected]> hat am 22. April 2015 um 22:53 geschrieben:

Using orphan clocks can introduce strange behaviour as they don't have rate information at all and also of course don't track

[...]

Quoted 8 lines
Quoted 5 lines

As this changes the behaviour for orphan clocks, it would of course benefit from more testing than on my Rockchip boards. To keep the recipent-list reasonable and not spam to much I selected one (the topmost) from the get_maintainer output of each drivers/clk entry. Hopefully some will provide Tested-by-tags :-)

excuse me for my naive question, but what kind of tests do you expect (beside applying the patches)?

just a "everything that worked before still works" :-)

Using orphaned clocks should already produce strange issues most of the time - for example I see clk_disable mismatches when suspending a rk3288 board, before this patchset.

But nevertheless we now disallow the usage of orphaned clocks completely while before it was possible to knowingly/unknowingly use them.

And while hopefully most drivers should handle an EPROBE_DEFER from clk_get just fine, there may still be one or two lurking around that would need fixing then ;-)

Heiko

#7 lore raw
In reply to Heiko Stuebner
Quoted 2 lines · Heiko Stuebner

Using orphan clocks can introduce strange behaviour as they don't have rate information at all and also of course don't track

Ok, everything works as before on some pxa platforms.

As pxa clocks support is not even fully mainline, this test is not the best you could get.

Cheers.

Signature · 1 line
Robert
#8 lore raw
In reply to Heiko Stuebner
Quoted 17 lines · Heiko Stuebner

Using orphan clocks can introduce strange behaviour as they don't have rate information at all and also of course don't track

This v2/v3 takes into account suggestions from Stephen Boyd to not try to walk the clock tree at runtime but instead keep track of orphan states on clock tree changes and making it mandatory for everybody from the start as orphaned clocks should not be used at all.

This fixes an issue on most rk3288 platforms, where some soc-clocks are supplied by a 32khz clock from an external i2c-chip which often is only probed later in the boot process and maybe even after the drivers using these soc-clocks like the tsadc temperature sensor. In this case the driver using the clock should of course defer probing until the clock is actually usable.

Quoted 6 lines

As this changes the behaviour for orphan clocks, it would of course benefit from more testing than on my Rockchip boards. To keep the recipent-list reasonable and not spam to much I selected one (the topmost) from the get_maintainer output of each drivers/clk entry. Hopefully some will provide Tested-by-tags :-)

<grumble> I don't see any Tested-by: tags yet </grumble>. I've put these two patches on a separate branch "defer-orphans" and pushed it to clk-next so we can give it some more exposure.

Unfortunately this doesn't solve the orphan problem for non-OF providers. What if we did the orphan check in __clk_create_clk() instead and returned an error pointer for orphans? I suspect that will solve all cases, right?

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#9 lore raw

Am Donnerstag, 30. April 2015, 17:19:01 schrieb Stephen Boyd:

Quoted 24 lines · Heiko Stuebner
Quoted 17 lines

Using orphan clocks can introduce strange behaviour as they don't have rate information at all and also of course don't track

This v2/v3 takes into account suggestions from Stephen Boyd to not try to walk the clock tree at runtime but instead keep track of orphan states on clock tree changes and making it mandatory for everybody from the start as orphaned clocks should not be used at all.

This fixes an issue on most rk3288 platforms, where some soc-clocks are supplied by a 32khz clock from an external i2c-chip which often is only probed later in the boot process and maybe even after the drivers using these soc-clocks like the tsadc temperature sensor. In this case the driver using the clock should of course defer probing until the clock is actually usable.

Quoted 5 lines

As this changes the behaviour for orphan clocks, it would of course benefit from more testing than on my Rockchip boards. To keep the recipent-list reasonable and not spam to much I selected one (the topmost) from the get_maintainer output of each drivers/clk entry. Hopefully some will provide Tested-by-tags :-)

Quoted 8 lines

<grumble> I don't see any Tested-by: tags yet </grumble>. I've put these two patches on a separate branch "defer-orphans" and pushed it to clk-next so we can give it some more exposure.

Unfortunately this doesn't solve the orphan problem for non-OF providers. What if we did the orphan check in __clk_create_clk() instead and returned an error pointer for orphans? I suspect that will solve all cases, right?

hmm, clk_register also uses __clk_create_clk, which in turn would prevent registering orphan-clocks at all, I'd think.
As on my platform I'm dependant on orphan clocks (the soc-level clock gets registerted as part of the big clock controller way before the i2c-based supplying clock), I'd rather not touch this :-) .

Instead I guess we could hook it less deep into clk_get_sys, like in the following patch?

------------ 8< ------------------------- >8 -----------------
From: Heiko Stuebner <[email protected]>
Date: Fri, 1 May 2015 21:50:46 +0200
Subject: [PATCH] clk: prevent orphan access on non-devicetree platforms too

The orphan-check in __of_clk_get_from_provider only prevents orphan-access on devicetree platforms. To bring non-dt platforms to the same level of functionality let clk_get_sys (called from clk_get for non-dt platforms) also check for orphans and return -EPROBE_DEFER in that case.

---
 drivers/clk/clk.c    | 2 +-
 drivers/clk/clk.h    | 5 +++++
 drivers/clk/clkdev.c | 5 +++++
 3 files changed, 11 insertions(+), 1 deletion(-)
drivers/clk/clk.c +1 -1
index 36d1a01..167d0bf 100644
@@ -2220,7 +2220,7 @@ static inline void clk_debug_unregister(struct clk_core *core)
 }
 #endif
 
-static bool clk_is_orphan(const struct clk *clk)
+bool clk_is_orphan(const struct clk *clk)
 {
 	if (!clk)
 		return false;
drivers/clk/clk.h +5 -0
index 00b35a1..b8a6061 100644
@@ -20,6 +20,7 @@ struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec,
 struct clk *__clk_create_clk(struct clk_hw *hw, const char *dev_id,
 			     const char *con_id);
 void __clk_free_clk(struct clk *clk);
+bool clk_is_orphan(const struct clk *clk);
 #else
 /* All these casts to avoid ifdefs in clkdev... */
 static inline struct clk *
@@ -32,5 +33,9 @@ static struct clk_hw *__clk_get_hw(struct clk *clk)
 {
 	return (struct clk_hw *)clk;
 }
+static inline bool clk_is_orphan(const struct clk *clk)
+{
+	return false;
+}
 
 #endif
drivers/clk/clkdev.c +5 -0
index 1fcb6ef..ad96775 100644
@@ -177,6 +177,11 @@ struct clk *clk_get_sys(const char *dev_id, const char *con_id)
 	if (!cl)
 		goto out;
 
+	if (clk_is_orphan(cl->clk)) {
+		clk = ERR_PTR(-EPROBE_DEFER);
+		goto out;
+	}
+
 	clk = __clk_create_clk(__clk_get_hw(cl->clk), dev_id, con_id);
 	if (IS_ERR(clk))
 		goto out;
Signature · 1 line
2.1.4
#10 lore raw
Quoted 32 lines · Heiko St?bner

Am Donnerstag, 30. April 2015, 17:19:01 schrieb Stephen Boyd:

Quoted 23 lines · Heiko Stuebner
Quoted 17 lines

Using orphan clocks can introduce strange behaviour as they don't have rate information at all and also of course don't track

This v2/v3 takes into account suggestions from Stephen Boyd to not try to walk the clock tree at runtime but instead keep track of orphan states on clock tree changes and making it mandatory for everybody from the start as orphaned clocks should not be used at all.

This fixes an issue on most rk3288 platforms, where some soc-clocks are supplied by a 32khz clock from an external i2c-chip which often is only probed later in the boot process and maybe even after the drivers using these soc-clocks like the tsadc temperature sensor. In this case the driver using the clock should of course defer probing until the clock is actually usable.

Quoted 5 lines

As this changes the behaviour for orphan clocks, it would of course benefit from more testing than on my Rockchip boards. To keep the recipent-list reasonable and not spam to much I selected one (the topmost) from the get_maintainer output of each drivers/clk entry. Hopefully some will provide Tested-by-tags :-)

Quoted 8 lines

<grumble> I don't see any Tested-by: tags yet </grumble>. I've put these two patches on a separate branch "defer-orphans" and pushed it to clk-next so we can give it some more exposure.

Unfortunately this doesn't solve the orphan problem for non-OF providers. What if we did the orphan check in __clk_create_clk() instead and returned an error pointer for orphans? I suspect that will solve all cases, right?

Quoted 5 lines

hmm, clk_register also uses __clk_create_clk, which in turn would prevent registering orphan-clocks at all, I'd think.
As on my platform I'm dependant on orphan clocks (the soc-level clock gets registerted as part of the big clock controller way before the i2c-based supplying clock), I'd rather not touch this :-) .

Have no fear! We should just change clk_register() to call a __clk_create_clk() type function that doesn't check for orphan status.

Quoted 3 lines

Instead I guess we could hook it less deep into clk_get_sys, like in the following patch?

It looks like it will work at least, but still I'd prefer to keep the orphan check contained to clk.c. How about this compile tested only patch?

This also brings up an existing problem with clk_unregister() where orphaned clocks are sitting out there useable by drivers when their parent is unregistered. That code could use some work to atomically switch all the orphaned clocks over to use the nodrv_ops.

----8<-----

drivers/clk/clk.c +16 -19
index 30d45c657a07..1d23daa42dd2 100644
@@ -2221,14 +2221,6 @@ static inline void clk_debug_unregister(struct clk_core *core)
 }
 #endif
 
-static bool clk_is_orphan(const struct clk *clk)
-{
-	if (!clk)
-		return false;
-
-	return clk->core->orphan;
-}
-
 /**
  * __clk_init - initialize the data structures in a struct clk
  * @dev:	device initializing this clk, placeholder for now
@@ -2420,15 +2412,11 @@ out:
 	return ret;
 }
 
-struct clk *__clk_create_clk(struct clk_hw *hw, const char *dev_id,
-			     const char *con_id)
+static struct clk *clk_hw_create_clk(struct clk_hw *hw, const char *dev_id,
+				     const char *con_id)
 {
 	struct clk *clk;
 
-	/* This is to allow this function to be chained to others */
-	if (!hw || IS_ERR(hw))
-		return (struct clk *) hw;
-
 	clk = kzalloc(sizeof(*clk), GFP_KERNEL);
 	if (!clk)
 		return ERR_PTR(-ENOMEM);
@@ -2445,6 +2433,19 @@ struct clk *__clk_create_clk(struct clk_hw *hw, const char *dev_id,
 	return clk;
 }
 
+struct clk *__clk_create_clk(struct clk_hw *hw, const char *dev_id,
+			     const char *con_id)
+{
+	/* This is to allow this function to be chained to others */
+	if (!hw || IS_ERR(hw))
+		return (struct clk *) hw;
+
+	if (hw->core->orphan)
+		return ERR_PTR(-EPROBE_DEFER);
+
+	return clk_hw_create_clk(hw, dev_id, con_id);
+}
+
 void __clk_free_clk(struct clk *clk)
 {
 	clk_prepare_lock();
@@ -2511,7 +2512,7 @@ struct clk *clk_register(struct device *dev, struct clk_hw *hw)
 
 	INIT_HLIST_HEAD(&core->clks);
 
-	hw->clk = __clk_create_clk(hw, NULL, NULL);
+	hw->clk = clk_hw_create_clk(hw, NULL, NULL);
 	if (IS_ERR(hw->clk)) {
 		ret = PTR_ERR(hw->clk);
 		goto fail_parent_names_copy;
@@ -2958,10 +2959,6 @@ struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec,
 		if (provider->node == clkspec->np)
 			clk = provider->get(clkspec, provider->data);
 		if (!IS_ERR(clk)) {
-			if (clk_is_orphan(clk)) {
-				clk = ERR_PTR(-EPROBE_DEFER);
-				break;
-			}
 
 			clk = __clk_create_clk(__clk_get_hw(clk), dev_id,
 					       con_id);
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
author Tested-by Reviewed-by
#11 lore raw

Am Freitag, 1. Mai 2015, 13:52:47 schrieb Stephen Boyd:

Quoted 37 lines · Heiko St?bner
Quoted 36 lines

Am Donnerstag, 30. April 2015, 17:19:01 schrieb Stephen Boyd:

Quoted 34 lines · Heiko Stuebner
Quoted 18 lines

Using orphan clocks can introduce strange behaviour as they don't have rate information at all and also of course don't track

This v2/v3 takes into account suggestions from Stephen Boyd to not try to
walk the clock tree at runtime but instead keep track of orphan states on clock tree changes and making it mandatory for everybody from the start as orphaned clocks should not be used at all.

This fixes an issue on most rk3288 platforms, where some soc-clocks are supplied by a 32khz clock from an external i2c-chip which often is only probed later in the boot process and maybe even after the drivers using these soc-clocks like the tsadc temperature sensor. In this case the driver using the clock should of course defer probing until the clock is actually usable.

Quoted 6 lines

As this changes the behaviour for orphan clocks, it would of course benefit from more testing than on my Rockchip boards. To keep the recipent-list reasonable and not spam to much I selected one (the topmost)
from the get_maintainer output of each drivers/clk entry. Hopefully some will provide Tested-by-tags :-)

<grumble> I don't see any Tested-by: tags yet </grumble>. I've put these two patches on a separate branch "defer-orphans" and pushed it to clk-next so we can give it some more exposure.

Unfortunately this doesn't solve the orphan problem for non-OF providers. What if we did the orphan check in __clk_create_clk() instead and returned an error pointer for orphans? I suspect that will solve all cases, right?

Quoted 8 lines
Quoted 5 lines

hmm, clk_register also uses __clk_create_clk, which in turn would prevent registering orphan-clocks at all, I'd think.
As on my platform I'm dependant on orphan clocks (the soc-level clock gets registerted as part of the big clock controller way before the i2c-based supplying clock), I'd rather not touch this :-) .

Have no fear! We should just change clk_register() to call a __clk_create_clk() type function that doesn't check for orphan status.

ok :-D

Quoted 5 lines
Quoted 2 lines

Instead I guess we could hook it less deep into clk_get_sys, like in the following patch?

It looks like it will work at least, but still I'd prefer to keep the orphan check contained to clk.c. How about this compile tested only patch?

I gave this a spin on my rk3288-firefly board. It still boots, the clock tree looks the same and it also still defers nicely in the scenario I needed it for. The implementation also looks nice - and of course much more compact than my check in two places :-) . I don't know if you want to put this as follow-up on top or fold it into the original orphan-check, so in any case

Quoted 4 lines

This also brings up an existing problem with clk_unregister() where orphaned clocks are sitting out there useable by drivers when their parent is unregistered. That code could use some work to atomically switch all the orphaned clocks over to use the nodrv_ops.

Not sure I understand this correctly yet, but when these children get orphaned, switched to the clk_nodrv_ops, they won't get their original ops back if the parent reappears.

So I guess we would need to store the original ops in secondary property of struct clk_core and I guess simply bind the ops-switch to the orphan state update?

Quoted 81 lines

----8<-----

drivers/clk/clk.c +16 -15
index 30d45c657a07..1d23daa42dd2 100644
@@ -2221,14 +2221,6 @@ static inline void clk_debug_unregister(struct
 clk_core *core) }
 #endif
 
-static bool clk_is_orphan(const struct clk *clk)
-{
-	if (!clk)
-		return false;
-
-	return clk->core->orphan;
-}
-
 /**
  * __clk_init - initialize the data structures in a struct clk
  * @dev:	device initializing this clk, placeholder for now
@@ -2420,15 +2412,11 @@ out:
 	return ret;
 }
 
-struct clk *__clk_create_clk(struct clk_hw *hw, const char *dev_id,
-			     const char *con_id)
+static struct clk *clk_hw_create_clk(struct clk_hw *hw, const char *dev_id,
+				     const char *con_id)
 {
 	struct clk *clk;
 
-	/* This is to allow this function to be chained to others */
-	if (!hw || IS_ERR(hw))
-		return (struct clk *) hw;
-
 	clk = kzalloc(sizeof(*clk), GFP_KERNEL);
 	if (!clk)
 		return ERR_PTR(-ENOMEM);
@@ -2445,6 +2433,19 @@ struct clk *__clk_create_clk(struct clk_hw *hw, const
 char *dev_id, return clk;
 }
 
+struct clk *__clk_create_clk(struct clk_hw *hw, const char *dev_id,
+			     const char *con_id)
+{
+	/* This is to allow this function to be chained to others */
+	if (!hw || IS_ERR(hw))
+		return (struct clk *) hw;
+
+	if (hw->core->orphan)
+		return ERR_PTR(-EPROBE_DEFER);
+
+	return clk_hw_create_clk(hw, dev_id, con_id);
+}
+
 void __clk_free_clk(struct clk *clk)
 {
 	clk_prepare_lock();
@@ -2511,7 +2512,7 @@ struct clk *clk_register(struct device *dev, struct
 clk_hw *hw)
 
 	INIT_HLIST_HEAD(&core->clks);
 
-	hw->clk = __clk_create_clk(hw, NULL, NULL);
+	hw->clk = clk_hw_create_clk(hw, NULL, NULL);
 	if (IS_ERR(hw->clk)) {
 		ret = PTR_ERR(hw->clk);
drivers/clk/clk.c +0 -4
 		goto fail_parent_names_copy;
@@ -2958,10 +2959,6 @@ struct clk *__of_clk_get_from_provider(struct
 of_phandle_args *clkspec, if (provider->node == clkspec->np)
 			clk = provider->get(clkspec, provider->data);
 		if (!IS_ERR(clk)) {
-			if (clk_is_orphan(clk)) {
-				clk = ERR_PTR(-EPROBE_DEFER);
-				break;
-			}
 
 			clk = __clk_create_clk(__clk_get_hw(clk), dev_id,
 					       con_id);
#12 lore raw
Quoted 6 lines · Heiko St?bner

Am Freitag, 1. Mai 2015, 13:52:47 schrieb Stephen Boyd:

Quoted 4 lines
Quoted 2 lines

Instead I guess we could hook it less deep into clk_get_sys, like in the following patch?

It looks like it will work at least, but still I'd prefer to keep the orphan check contained to clk.c. How about this compile tested only patch?

Quoted 8 lines

I gave this a spin on my rk3288-firefly board. It still boots, the clock tree looks the same and it also still defers nicely in the scenario I needed it for. The implementation also looks nice - and of course much more compact than my check in two places :-) . I don't know if you want to put this as follow-up on top or fold it into the original orphan-check, so in any case

Thanks. I'm leaning towards tossing your patch 2/2 and replacing it with my patch and a note that it's based on an earlier patch from you.

Quoted 6 lines
Quoted 6 lines

This also brings up an existing problem with clk_unregister() where orphaned clocks are sitting out there useable by drivers when their parent is unregistered. That code could use some work to atomically switch all the orphaned clocks over to use the nodrv_ops.

Quoted 7 lines

Not sure I understand this correctly yet, but when these children get orphaned, switched to the clk_nodrv_ops, they won't get their original ops back if the parent reappears.

So I guess we would need to store the original ops in secondary property of struct clk_core and I guess simply bind the ops-switch to the orphan state update?

Yep. We'll need to store away the original ops in case we need to put them back. Don't feel obligated to fix this either. It would certainly be nice if someone tried to fix this case at some point, but it's not like things are any worse off right now.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
Tested-by
#13 lore raw
Quoted 13 lines · Stephen Boyd
Quoted 12 lines · Heiko St?bner

Am Freitag, 1. Mai 2015, 13:52:47 schrieb Stephen Boyd:

Quoted 4 lines
Quoted 2 lines

Instead I guess we could hook it less deep into clk_get_sys, like in the following patch?

It looks like it will work at least, but still I'd prefer to keep the orphan check contained to clk.c. How about this compile tested only patch?

I gave this a spin on my rk3288-firefly board. It still boots, the clock tree looks the same and it also still defers nicely in the scenario I needed it for. The implementation also looks nice - and of course much more compact than my check in two places :-) . I don't know if you want to put this as follow-up on top or fold it into the original orphan-check, so in any case

Quoted 5 lines
Quoted 2 lines

Thanks. I'm leaning towards tossing your patch 2/2 and replacing it with my patch and a note that it's based on an earlier patch from you.

FWIW, just gave a try for these two patches on all TI boards I have access to.

I didn't try your evolved patch though, as you don't seem to have made your mind yet.

-Tero

Quoted 20 lines
Quoted 7 lines
Quoted 7 lines

This also brings up an existing problem with clk_unregister() where orphaned clocks are sitting out there useable by drivers when their parent is unregistered. That code could use some work to atomically switch all the orphaned clocks over to use the nodrv_ops.

Quoted 7 lines

Not sure I understand this correctly yet, but when these children get orphaned, switched to the clk_nodrv_ops, they won't get their original ops back if the parent reappears.

So I guess we would need to store the original ops in secondary property of struct clk_core and I guess simply bind the ops-switch to the orphan state update?

Yep. We'll need to store away the original ops in case we need to put them back. Don't feel obligated to fix this either. It would certainly be nice if someone tried to fix this case at some point, but it's not like things are any worse off right now.

#14 lore raw
Quoted 26 lines · Tero Kristo
Quoted 19 lines · Stephen Boyd
Quoted 18 lines · Heiko St?bner

Am Freitag, 1. Mai 2015, 13:52:47 schrieb Stephen Boyd:

Quoted 6 lines
Quoted 3 lines

Instead I guess we could hook it less deep into clk_get_sys, like in the
following patch?

It looks like it will work at least, but still I'd prefer to keep the orphan check contained to clk.c. How about this compile tested only patch?

I gave this a spin on my rk3288-firefly board. It still boots, the clock tree
looks the same and it also still defers nicely in the scenario I needed it
for. The implementation also looks nice - and of course much more compact than
my check in two places :-) . I don't know if you want to put this as follow-up
on top or fold it into the original orphan-check, so in any case

Quoted 5 lines
Quoted 2 lines

Thanks. I'm leaning towards tossing your patch 2/2 and replacing it with my patch and a note that it's based on an earlier patch from you.

Quoted 8 lines

FWIW, just gave a try for these two patches on all TI boards I have access to.

I didn't try your evolved patch though, as you don't seem to have made your mind yet.

Thanks. Can you try the evolved patch? It's in linux-next now as commit 882667c1fcf1, and it seems to at least break sunxi boot. I'd be interested if it broke TI boards.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#15 lore raw
Quoted 32 lines · Stephen Boyd
Quoted 31 lines · Tero Kristo
Quoted 19 lines · Stephen Boyd
Quoted 18 lines · Heiko St?bner

Am Freitag, 1. Mai 2015, 13:52:47 schrieb Stephen Boyd:

Quoted 6 lines
Quoted 3 lines

Instead I guess we could hook it less deep into clk_get_sys, like in the
following patch?

It looks like it will work at least, but still I'd prefer to keep the orphan check contained to clk.c. How about this compile tested only patch?

I gave this a spin on my rk3288-firefly board. It still boots, the clock tree
looks the same and it also still defers nicely in the scenario I needed it
for. The implementation also looks nice - and of course much more compact than
my check in two places :-) . I don't know if you want to put this as follow-up
on top or fold it into the original orphan-check, so in any case

Quoted 5 lines
Quoted 2 lines

Thanks. I'm leaning towards tossing your patch 2/2 and replacing it with my patch and a note that it's based on an earlier patch from you.

FWIW, just gave a try for these two patches on all TI boards I have access to.

Quoted 7 lines
Quoted 3 lines

I didn't try your evolved patch though, as you don't seem to have made your mind yet.

Thanks. Can you try the evolved patch? It's in linux-next now as commit 882667c1fcf1, and it seems to at least break sunxi boot. I'd be interested if it broke TI boards.

Just tried it out, boots fine on all these:

   : Board           : Boot commit                    log
  1: am335x-evm      : PASS 4.1.0-rc2-next-20150507   am335x-evm.txt
  2: am335x-evmsk    : PASS 4.1.0-rc2-next-20150507   am335x-sk.txt
  3: am3517-evm      : PASS 4.1.0-rc2-next-20150507   am3517-evm.txt
  4: am43x-epos-evm  : PASS 4.1.0-rc2-next-20150507   am43xx-epos.txt
  5: am437x-gp-evm   : PASS 4.1.0-rc2-next-20150507   am43xx-gpevm.txt
  6: am57xx-evm      : PASS 4.1.0-rc2-next-20150507   am57xx-evm.txt
  7: omap3-beagle-xm : PASS 4.1.0-rc2-next-20150507   beagleboard.txt
  8: omap3-beagle    : PASS 4.1.0-rc2-next-20150507 
beagleboard-vanilla.txt
  9: am335x-boneblack: PASS 4.1.0-rc2-next-20150507   beaglebone-black.txt
10: am335x-bone     : PASS 4.1.0-rc2-next-20150507   beaglebone.txt
11: dra7xx-evm      : PASS 4.1.0-rc2-next-20150507   dra7xx-evm.txt
12: omap3-n900      : PASS 4.1.0-rc2-next-20150507   n900.txt
13: omap5-uevm      : PASS 4.1.0-rc2-next-20150507   omap5-evm.txt
14: omap4-panda-es  : PASS 4.1.0-rc2-next-20150507   pandaboard-es.txt
15: omap4-panda     : PASS 4.1.0-rc2-next-20150507   pandaboard-vanilla.txt
16: omap2430-sdp    : PASS 4.1.0-rc2-next-20150507   sdp2430.txt
17: omap3430-sdp    : PASS 4.1.0-rc2-next-20150507   sdp3430.txt

18: omap4-sdp-es23plus: PASS 4.1.0-rc2-next-20150507 sdp4430.txt
TOTAL = 18 boards, Booted Boards = 18, No Boot boards = 0

TI boards do not have any orphan clocks.

-Tero

#16 lore raw
In reply to Stephen Boyd
Quoted 13 lines · Stephen Boyd
Quoted 12 lines · Heiko St?bner

Am Freitag, 1. Mai 2015, 13:52:47 schrieb Stephen Boyd:

Quoted 4 lines
Quoted 2 lines

Instead I guess we could hook it less deep into clk_get_sys, like in the following patch?

It looks like it will work at least, but still I'd prefer to keep the orphan check contained to clk.c. How about this compile tested only patch?

I gave this a spin on my rk3288-firefly board. It still boots, the clock tree looks the same and it also still defers nicely in the scenario I needed it for. The implementation also looks nice - and of course much more compact than my check in two places :-) . I don't know if you want to put this as follow-up on top or fold it into the original orphan-check, so in any case

Quoted 5 lines
Quoted 2 lines

Thanks. I'm leaning towards tossing your patch 2/2 and replacing it with my patch and a note that it's based on an earlier patch from you.

It appears this has landed in linux-next in the form of 882667c1fcf1
clk: prevent orphan clocks from being used. A bunch of boot failures for sunxi in today's linux-next[1] were bisected down to that patch.

I confirmed that reverting that commit on top of next/master gets sunxi booting again.

Kevin

[1] http://kernelci.org/boot/all/job/next/kernel/next-20150507/

#17 lore raw
Quoted 16 lines · Kevin Hilman
Quoted 15 lines · Stephen Boyd
Quoted 14 lines · Heiko St?bner

Am Freitag, 1. Mai 2015, 13:52:47 schrieb Stephen Boyd:

Quoted 4 lines
Quoted 2 lines

Instead I guess we could hook it less deep into clk_get_sys, like in the following patch?

It looks like it will work at least, but still I'd prefer to keep the orphan check contained to clk.c. How about this compile tested only patch?

I gave this a spin on my rk3288-firefly board. It still boots, the clock tree looks the same and it also still defers nicely in the scenario I needed it for. The implementation also looks nice - and of course much more compact than my check in two places :-) . I don't know if you want to put this as follow-up on top or fold it into the original orphan-check, so in any case

Quoted 10 lines
Quoted 2 lines

Thanks. I'm leaning towards tossing your patch 2/2 and replacing it with my patch and a note that it's based on an earlier patch from you.

It appears this has landed in linux-next in the form of 882667c1fcf1
clk: prevent orphan clocks from being used. A bunch of boot failures for sunxi in today's linux-next[1] were bisected down to that patch.

I confirmed that reverting that commit on top of next/master gets sunxi booting again.

Thanks for the report. I've removed the two clk orphan patches from clk-next. Would it be possible to try with next-20150507 and clk_ignore_unused on the command line? Also we can try to see if critical clocks aren't being forced on by applying this patch and looking for clk_get() failures

------8<------

drivers/clk/sunxi/clk-sunxi.c +3 -0
index 7e1e2bd189b6..d88585b680bb 100644
@@ -1347,6 +1347,9 @@ static void __init sunxi_init_clocks(const char *clocks[], int nclocks)
 
 		if (!IS_ERR(clk))
 			clk_prepare_enable(clk);
+		else
+			pr_err("Failed to enable critical clock %s\n",
+					clocks[i]);
 	}
 }
 
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#18 lore raw
Quoted 23 lines · Stephen Boyd
Quoted 22 lines · Kevin Hilman
Quoted 13 lines · Stephen Boyd
Quoted 12 lines · Heiko St?bner

Am Freitag, 1. Mai 2015, 13:52:47 schrieb Stephen Boyd:

Quoted 4 lines
Quoted 2 lines

Instead I guess we could hook it less deep into clk_get_sys, like in the following patch?

It looks like it will work at least, but still I'd prefer to keep the orphan check contained to clk.c. How about this compile tested only patch?

I gave this a spin on my rk3288-firefly board. It still boots, the clock tree looks the same and it also still defers nicely in the scenario I needed it for. The implementation also looks nice - and of course much more compact than my check in two places :-) . I don't know if you want to put this as follow-up on top or fold it into the original orphan-check, so in any case

Quoted 4 lines
Quoted 2 lines

Thanks. I'm leaning towards tossing your patch 2/2 and replacing it with my patch and a note that it's based on an earlier patch from you.

It appears this has landed in linux-next in the form of 882667c1fcf1
clk: prevent orphan clocks from being used. A bunch of boot failures for sunxi in today's linux-next[1] were bisected down to that patch.

Quoted 8 lines
Quoted 4 lines

I confirmed that reverting that commit on top of next/master gets sunxi booting again.

Thanks for the report. I've removed the two clk orphan patches from clk-next. Would it be possible to try with next-20150507 and clk_ignore_unused on the command line?

That doesn't help. I tried on cubieboard2 and bananapi.

Quoted 5 lines

Also we can try to see if
critical clocks aren't being forced on by applying this patch and looking for clk_get() failures

From cubieboard2, there's a few that look rather important:

[    0.000000] Additional per-CPU info printed with stalls.
[    0.000000] Build-time adjustment of leaf fanout to 32.
[    0.000000] RCU restricting CPUs from NR_CPUS=16 to nr_cpu_ids=2.
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=32, nr_cpu_ids=2
[    0.000000] NR_IRQS:16 nr_irqs:16 16
[    0.000000] clk: couldn't get parent clock 0 for /clocks/ahb at 01c20054
[    0.000000] Failed to enable critical clock cpu
[    0.000000] Failed to enable critical clock pll5_ddr
[    0.000000] Failed to enable critical clock ahb_sdram
[    0.000000] Architected cp15 timer(s) running at 24.00MHz (virt).

Kevin

#19 lore raw
Quoted 29 lines · Kevin Hilman
Quoted 28 lines · Stephen Boyd
Quoted 26 lines · Kevin Hilman
Quoted 13 lines · Stephen Boyd
Quoted 12 lines · Heiko St?bner

Am Freitag, 1. Mai 2015, 13:52:47 schrieb Stephen Boyd:

Quoted 4 lines
Quoted 2 lines

Instead I guess we could hook it less deep into clk_get_sys, like in the following patch?

It looks like it will work at least, but still I'd prefer to keep the orphan check contained to clk.c. How about this compile tested only patch?

I gave this a spin on my rk3288-firefly board. It still boots, the clock tree looks the same and it also still defers nicely in the scenario I needed it for. The implementation also looks nice - and of course much more compact than my check in two places :-) . I don't know if you want to put this as follow-up on top or fold it into the original orphan-check, so in any case

Quoted 4 lines
Quoted 2 lines

Thanks. I'm leaning towards tossing your patch 2/2 and replacing it with my patch and a note that it's based on an earlier patch from you.

It appears this has landed in linux-next in the form of 882667c1fcf1
clk: prevent orphan clocks from being used. A bunch of boot failures for sunxi in today's linux-next[1] were bisected down to that patch.

I confirmed that reverting that commit on top of next/master gets sunxi booting again.

Quoted 5 lines
Quoted 3 lines

Thanks for the report. I've removed the two clk orphan patches from clk-next. Would it be possible to try with next-20150507 and clk_ignore_unused on the command line?

That doesn't help. I tried on cubieboard2 and bananapi.

Thanks for trying.

Quoted 7 lines
Quoted 4 lines

Also we can try to see if
critical clocks aren't being forced on by applying this patch and looking for clk_get() failures

From cubieboard2, there's a few that look rather important:

Quoted 10 lines
[    0.000000] Additional per-CPU info printed with stalls.
[    0.000000] Build-time adjustment of leaf fanout to 32.
[    0.000000] RCU restricting CPUs from NR_CPUS=16 to nr_cpu_ids=2.
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=32, nr_cpu_ids=2
[    0.000000] NR_IRQS:16 nr_irqs:16 16
[    0.000000] clk: couldn't get parent clock 0 for /clocks/ahb at 01c20054
[    0.000000] Failed to enable critical clock cpu
[    0.000000] Failed to enable critical clock pll5_ddr
[    0.000000] Failed to enable critical clock ahb_sdram
[    0.000000] Architected cp15 timer(s) running at 24.00MHz (virt).

Ok. So it seems we need to come up with some solution to the "critical clocks" problem that doesn't require the individual clock drivers to call clk_prepare_enable().

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#20 lore raw
Quoted 56 lines · Stephen Boyd
Quoted 29 lines · Kevin Hilman
Quoted 28 lines · Stephen Boyd
Quoted 26 lines · Kevin Hilman
Quoted 13 lines · Stephen Boyd
Quoted 12 lines · Heiko St?bner

Am Freitag, 1. Mai 2015, 13:52:47 schrieb Stephen Boyd:

Quoted 4 lines
Quoted 2 lines

Instead I guess we could hook it less deep into clk_get_sys, like in the following patch?

It looks like it will work at least, but still I'd prefer to keep the orphan check contained to clk.c. How about this compile tested only patch?

I gave this a spin on my rk3288-firefly board. It still boots, the clock tree looks the same and it also still defers nicely in the scenario I needed it for. The implementation also looks nice - and of course much more compact than my check in two places :-) . I don't know if you want to put this as follow-up on top or fold it into the original orphan-check, so in any case

Quoted 4 lines
Quoted 2 lines

Thanks. I'm leaning towards tossing your patch 2/2 and replacing it with my patch and a note that it's based on an earlier patch from you.

It appears this has landed in linux-next in the form of 882667c1fcf1
clk: prevent orphan clocks from being used. A bunch of boot failures for sunxi in today's linux-next[1] were bisected down to that patch.

I confirmed that reverting that commit on top of next/master gets sunxi booting again.

Quoted 5 lines
Quoted 3 lines

Thanks for the report. I've removed the two clk orphan patches from clk-next. Would it be possible to try with next-20150507 and clk_ignore_unused on the command line?

That doesn't help. I tried on cubieboard2 and bananapi.

Thanks for trying.

Quoted 7 lines
Quoted 4 lines

Also we can try to see if
critical clocks aren't being forced on by applying this patch and looking for clk_get() failures

From cubieboard2, there's a few that look rather important:

Quoted 10 lines
[    0.000000] Additional per-CPU info printed with stalls.
[    0.000000] Build-time adjustment of leaf fanout to 32.
[    0.000000] RCU restricting CPUs from NR_CPUS=16 to nr_cpu_ids=2.
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=32, nr_cpu_ids=2
[    0.000000] NR_IRQS:16 nr_irqs:16 16
[    0.000000] clk: couldn't get parent clock 0 for /clocks/ahb at 01c20054
[    0.000000] Failed to enable critical clock cpu
[    0.000000] Failed to enable critical clock pll5_ddr
[    0.000000] Failed to enable critical clock ahb_sdram
[    0.000000] Architected cp15 timer(s) running at 24.00MHz (virt).
Quoted 3 lines

Ok. So it seems we need to come up with some solution to the "critical clocks" problem that doesn't require the individual clock drivers to call clk_prepare_enable().

I'm getting more and more unsure if we can really handle the complexity we get by allowing to register orphaned clocks. On one hand we can't handle the orphaned clocks properly when we do a clk_prepare/enable on them, on the other hand we run into trouble when we forbid to prepare/enable them. The fact that clocks can become orphans by reparenting them makes it even more complicated.
Maybe allowing orphans is something that has to be revisited.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#21 lore raw

Am Freitag, 8. Mai 2015, 10:13:55 schrieb Sascha Hauer:

Quoted 3 lines · Stephen Boyd
Quoted 2 lines · Kevin Hilman
Quoted 1 line

On Thu, May 7, 2015 at 2:03 PM, Stephen Boyd <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines · Kevin Hilman
Quoted 1 line

On Fri, May 1, 2015 at 4:40 PM, Stephen Boyd <[email protected]>

Quoted 62 lines · wrote:
Quoted 58 lines
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 18 lines · Heiko St?bner
Quoted 17 lines

Am Freitag, 1. Mai 2015, 13:52:47 schrieb Stephen Boyd:

Quoted 8 lines
Quoted 3 lines

Instead I guess we could hook it less deep into clk_get_sys, like in the
following patch?

It looks like it will work at least, but still I'd prefer to keep the
orphan check contained to clk.c. How about this compile tested only patch?

I gave this a spin on my rk3288-firefly board. It still boots, the clock tree looks the same and it also still defers nicely in the scenario I needed it for. The implementation also looks nice - and of course much more compact than my check in two places :-) . I don't know if you want to put this as follow-up on top or fold it into the original orphan-check, so in any case

Quoted 6 lines
Quoted 2 lines

Thanks. I'm leaning towards tossing your patch 2/2 and replacing it with
my patch and a note that it's based on an earlier patch from you.

It appears this has landed in linux-next in the form of 882667c1fcf1
clk: prevent orphan clocks from being used. A bunch of boot failures for sunxi in today's linux-next[1] were bisected down to that patch.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

I confirmed that reverting that commit on top of next/master gets sunxi booting again.

Thanks for the report. I've removed the two clk orphan patches from clk-next. Would it be possible to try with next-20150507 and clk_ignore_unused on the command line?

That doesn't help. I tried on cubieboard2 and bananapi.

Thanks for trying.

Quoted 6 lines
Quoted 3 lines

Also we can try to see if
critical clocks aren't being forced on by applying this patch and looking for clk_get() failures

From cubieboard2, there's a few that look rather important:

Quoted 11 lines
[    0.000000] Additional per-CPU info printed with stalls.
[    0.000000] Build-time adjustment of leaf fanout to 32.
[    0.000000] RCU restricting CPUs from NR_CPUS=16 to nr_cpu_ids=2.
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=32,
nr_cpu_ids=2
[    0.000000] NR_IRQS:16 nr_irqs:16 16
[    0.000000] clk: couldn't get parent clock 0 for /clocks/ahb at 01c20054
[    0.000000] Failed to enable critical clock cpu
[    0.000000] Failed to enable critical clock pll5_ddr
[    0.000000] Failed to enable critical clock ahb_sdram
[    0.000000] Architected cp15 timer(s) running at 24.00MHz (virt).
Quoted 3 lines

Ok. So it seems we need to come up with some solution to the "critical clocks" problem that doesn't require the individual clock drivers to call clk_prepare_enable().

Quoted 7 lines

I'm getting more and more unsure if we can really handle the complexity we get by allowing to register orphaned clocks. On one hand we can't handle the orphaned clocks properly when we do a clk_prepare/enable on them, on the other hand we run into trouble when we forbid to prepare/enable them. The fact that clocks can become orphans by reparenting them makes it even more complicated.
Maybe allowing orphans is something that has to be revisited.

hmm, I don't see it this drastic. I was expecting a lot more fallout from changing the behaviour of orphaned clocks over all arches using the CCF.

Quoted 1 line

From the kernelci-boards only the Sunxi-ones seem to have been affected at all

and also only because they need a "regulator-always-on" equivalent in the CCF, which currently hijacks prepare/enable inside the clock driver to achive this.

On the Rockchip clocks we have something similar, with the only difference that it is done after all clocks are registered and does not need to access the 3 orphans we have at this point due to their source clock coming from an external i2c-connected chip that gets probed a lot later.

#22 lore raw
Quoted 78 lines · Heiko St?bner

Am Freitag, 8. Mai 2015, 10:13:55 schrieb Sascha Hauer:

Quoted 3 lines · Stephen Boyd
Quoted 2 lines · Kevin Hilman
Quoted 1 line

On Thu, May 7, 2015 at 2:03 PM, Stephen Boyd <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines · Kevin Hilman
Quoted 1 line

On Fri, May 1, 2015 at 4:40 PM, Stephen Boyd <[email protected]>

Quoted 62 lines · wrote:
Quoted 58 lines
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 18 lines · Heiko St?bner
Quoted 17 lines

Am Freitag, 1. Mai 2015, 13:52:47 schrieb Stephen Boyd:

Quoted 8 lines
Quoted 3 lines

Instead I guess we could hook it less deep into clk_get_sys, like in the
following patch?

It looks like it will work at least, but still I'd prefer to keep the
orphan check contained to clk.c. How about this compile tested only patch?

I gave this a spin on my rk3288-firefly board. It still boots, the clock tree looks the same and it also still defers nicely in the scenario I needed it for. The implementation also looks nice - and of course much more compact than my check in two places :-) . I don't know if you want to put this as follow-up on top or fold it into the original orphan-check, so in any case

Quoted 6 lines
Quoted 2 lines

Thanks. I'm leaning towards tossing your patch 2/2 and replacing it with
my patch and a note that it's based on an earlier patch from you.

It appears this has landed in linux-next in the form of 882667c1fcf1
clk: prevent orphan clocks from being used. A bunch of boot failures for sunxi in today's linux-next[1] were bisected down to that patch.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

I confirmed that reverting that commit on top of next/master gets sunxi booting again.

Thanks for the report. I've removed the two clk orphan patches from clk-next. Would it be possible to try with next-20150507 and clk_ignore_unused on the command line?

That doesn't help. I tried on cubieboard2 and bananapi.

Thanks for trying.

Quoted 6 lines
Quoted 3 lines

Also we can try to see if
critical clocks aren't being forced on by applying this patch and looking for clk_get() failures

From cubieboard2, there's a few that look rather important:

Quoted 11 lines
[    0.000000] Additional per-CPU info printed with stalls.
[    0.000000] Build-time adjustment of leaf fanout to 32.
[    0.000000] RCU restricting CPUs from NR_CPUS=16 to nr_cpu_ids=2.
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=32,
nr_cpu_ids=2
[    0.000000] NR_IRQS:16 nr_irqs:16 16
[    0.000000] clk: couldn't get parent clock 0 for /clocks/ahb at 01c20054
[    0.000000] Failed to enable critical clock cpu
[    0.000000] Failed to enable critical clock pll5_ddr
[    0.000000] Failed to enable critical clock ahb_sdram
[    0.000000] Architected cp15 timer(s) running at 24.00MHz (virt).
Quoted 3 lines

Ok. So it seems we need to come up with some solution to the "critical clocks" problem that doesn't require the individual clock drivers to call clk_prepare_enable().

Quoted 7 lines

I'm getting more and more unsure if we can really handle the complexity we get by allowing to register orphaned clocks. On one hand we can't handle the orphaned clocks properly when we do a clk_prepare/enable on them, on the other hand we run into trouble when we forbid to prepare/enable them. The fact that clocks can become orphans by reparenting them makes it even more complicated.
Maybe allowing orphans is something that has to be revisited.

Quoted 6 lines

hmm, I don't see it this drastic. I was expecting a lot more fallout from changing the behaviour of orphaned clocks over all arches using the CCF.

From the kernelci-boards only the Sunxi-ones seem to have been affected at all and also only because they need a "regulator-always-on" equivalent in the CCF, which currently hijacks prepare/enable inside the clock driver to achive this.

Mediatek has the same case. Here we needs some clock to stay always on and these clocks get registered before the PLLs they depend on. This means they can't be enabled right after registration.

Keeping the prepare/enable count correct and syncing the software state with the hardware state is made quite complicated with orphaned clocks and I suspect more bugs here. Even now it's hard to move in the clock framework without breaking other stuff, this won't get easier with more bug fixes.

So I think asking what allowing orphaned clocks really buys us is valid. Of course we would need to find a way to get the initialisation order straight which will probably cause some pain.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#23 lore raw
In reply to Stephen Boyd
Quoted 23 lines · Stephen Boyd
Quoted 22 lines · Kevin Hilman
Quoted 13 lines · Stephen Boyd
Quoted 12 lines · Heiko St?bner

Am Freitag, 1. Mai 2015, 13:52:47 schrieb Stephen Boyd:

Quoted 4 lines
Quoted 2 lines

Instead I guess we could hook it less deep into clk_get_sys, like in the following patch?

It looks like it will work at least, but still I'd prefer to keep the orphan check contained to clk.c. How about this compile tested only patch?

I gave this a spin on my rk3288-firefly board. It still boots, the clock tree looks the same and it also still defers nicely in the scenario I needed it for. The implementation also looks nice - and of course much more compact than my check in two places :-) . I don't know if you want to put this as follow-up on top or fold it into the original orphan-check, so in any case

Quoted 4 lines
Quoted 2 lines

Thanks. I'm leaning towards tossing your patch 2/2 and replacing it with my patch and a note that it's based on an earlier patch from you.

It appears this has landed in linux-next in the form of 882667c1fcf1
clk: prevent orphan clocks from being used. A bunch of boot failures for sunxi in today's linux-next[1] were bisected down to that patch.

Quoted 8 lines
Quoted 4 lines

I confirmed that reverting that commit on top of next/master gets sunxi booting again.

Thanks for the report. I've removed the two clk orphan patches from clk-next. Would it be possible to try with next-20150507 and clk_ignore_unused on the command line?

This makes it work, but it's not really an option.

Quoted 2 lines

Also we can try to see if critical clocks aren't being forced on by applying this patch and looking for clk_get() failures

And that shows that the CPU and DDR clocks are not protected, which obviously is pretty mad.

I've mass converted all our probing code to use OF_CLK_DECLARE, and make things work again.

http://code.bulix.org/5goa5j-88345?raw

Is this an acceptable solution?

We were already moving to this, I'm not really fond of doing this like that, but I guess this whole debacle makes it necessary.

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150508/634989ca/attachment.sig>
#24 lore raw
Quoted 24 lines · Maxime Ripard
Quoted 23 lines · Stephen Boyd
Quoted 22 lines · Kevin Hilman
Quoted 13 lines · Stephen Boyd
Quoted 12 lines · Heiko St?bner

Am Freitag, 1. Mai 2015, 13:52:47 schrieb Stephen Boyd:

Quoted 4 lines
Quoted 2 lines

Instead I guess we could hook it less deep into clk_get_sys, like in the following patch?

It looks like it will work at least, but still I'd prefer to keep the orphan check contained to clk.c. How about this compile tested only patch?

I gave this a spin on my rk3288-firefly board. It still boots, the clock tree looks the same and it also still defers nicely in the scenario I needed it for. The implementation also looks nice - and of course much more compact than my check in two places :-) . I don't know if you want to put this as follow-up on top or fold it into the original orphan-check, so in any case

Quoted 4 lines
Quoted 2 lines

Thanks. I'm leaning towards tossing your patch 2/2 and replacing it with my patch and a note that it's based on an earlier patch from you.

It appears this has landed in linux-next in the form of 882667c1fcf1
clk: prevent orphan clocks from being used. A bunch of boot failures for sunxi in today's linux-next[1] were bisected down to that patch.

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines

I confirmed that reverting that commit on top of next/master gets sunxi booting again.

Thanks for the report. I've removed the two clk orphan patches from clk-next. Would it be possible to try with next-20150507 and clk_ignore_unused on the command line?

This makes it work, but it's not really an option.

Hmm.. I thought it didn't fix it for Kevin. Confused.

Quoted 8 lines
Quoted 2 lines

Also we can try to see if critical clocks aren't being forced on by applying this patch and looking for clk_get() failures

And that shows that the CPU and DDR clocks are not protected, which obviously is pretty mad.

I've mass converted all our probing code to use OF_CLK_DECLARE, and make things work again.

Quoted 7 lines

http://code.bulix.org/5goa5j-88345?raw

Is this an acceptable solution?

We were already moving to this, I'm not really fond of doing this like that, but I guess this whole debacle makes it necessary.

I wonder why we can't switch out the clk_ops on the affected platforms + clocks to be read-only (at least for the enable/disable part)? That would fix it just the same right? I wasn't around for the original discussion regarding this always-on stuff so perhaps I've missed something.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#25 lore raw
Quoted 29 lines · Stephen Boyd
Quoted 28 lines · Maxime Ripard
Quoted 27 lines · Stephen Boyd
Quoted 26 lines · Kevin Hilman
Quoted 13 lines · Stephen Boyd
Quoted 12 lines · Heiko St?bner

Am Freitag, 1. Mai 2015, 13:52:47 schrieb Stephen Boyd:

Quoted 4 lines
Quoted 2 lines

Instead I guess we could hook it less deep into clk_get_sys, like in the following patch?

It looks like it will work at least, but still I'd prefer to keep the orphan check contained to clk.c. How about this compile tested only patch?

I gave this a spin on my rk3288-firefly board. It still boots, the clock tree looks the same and it also still defers nicely in the scenario I needed it for. The implementation also looks nice - and of course much more compact than my check in two places :-) . I don't know if you want to put this as follow-up on top or fold it into the original orphan-check, so in any case

Quoted 4 lines
Quoted 2 lines

Thanks. I'm leaning towards tossing your patch 2/2 and replacing it with my patch and a note that it's based on an earlier patch from you.

It appears this has landed in linux-next in the form of 882667c1fcf1
clk: prevent orphan clocks from being used. A bunch of boot failures for sunxi in today's linux-next[1] were bisected down to that patch.

I confirmed that reverting that commit on top of next/master gets sunxi booting again.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Thanks for the report. I've removed the two clk orphan patches from clk-next. Would it be possible to try with next-20150507 and clk_ignore_unused on the command line?

This makes it work, but it's not really an option.

Hmm.. I thought it didn't fix it for Kevin. Confused.

I'm too, but it does fix things here.

Quoted 12 lines
Quoted 12 lines
Quoted 2 lines

Also we can try to see if critical clocks aren't being forced on by applying this patch and looking for clk_get() failures

And that shows that the CPU and DDR clocks are not protected, which obviously is pretty mad.

I've mass converted all our probing code to use OF_CLK_DECLARE, and make things work again.

http://code.bulix.org/5goa5j-88345?raw

Is this an acceptable solution?

Quoted 8 lines
Quoted 3 lines

We were already moving to this, I'm not really fond of doing this like that, but I guess this whole debacle makes it necessary.

I wonder why we can't switch out the clk_ops on the affected platforms + clocks to be read-only (at least for the enable/disable part)? That would fix it just the same right? I wasn't around for the original discussion regarding this always-on stuff so perhaps I've missed something.

We're using clk-gate, so that would require to recode our own driver. That change seemed less invasive, while fixing the issue and ensuring that we wouldn't have any orphan clock, which seems to be hunted down these days...

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150513/34503f2b/attachment-0001.sig>
#26 lore raw
Quoted 33 lines · Maxime Ripard
Quoted 32 lines · Stephen Boyd
Quoted 31 lines · Maxime Ripard
Quoted 30 lines · Stephen Boyd
Quoted 16 lines · Kevin Hilman
Quoted 15 lines · Stephen Boyd
Quoted 14 lines · Heiko St?bner

Am Freitag, 1. Mai 2015, 13:52:47 schrieb Stephen Boyd:

Quoted 4 lines
Quoted 2 lines

Instead I guess we could hook it less deep into clk_get_sys, like in the following patch?

It looks like it will work at least, but still I'd prefer to keep the orphan check contained to clk.c. How about this compile tested only patch?

I gave this a spin on my rk3288-firefly board. It still boots, the clock tree looks the same and it also still defers nicely in the scenario I needed it for. The implementation also looks nice - and of course much more compact than my check in two places :-) . I don't know if you want to put this as follow-up on top or fold it into the original orphan-check, so in any case

Quoted 10 lines
Quoted 2 lines

Thanks. I'm leaning towards tossing your patch 2/2 and replacing it with my patch and a note that it's based on an earlier patch from you.

It appears this has landed in linux-next in the form of 882667c1fcf1
clk: prevent orphan clocks from being used. A bunch of boot failures for sunxi in today's linux-next[1] were bisected down to that patch.

I confirmed that reverting that commit on top of next/master gets sunxi booting again.

Thanks for the report. I've removed the two clk orphan patches from clk-next. Would it be possible to try with next-20150507 and clk_ignore_unused on the command line?

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

This makes it work, but it's not really an option.

Hmm.. I thought it didn't fix it for Kevin. Confused.

I'm too, but it does fix things here.

To be more precise on what I tested. I used next-20150507 and tested on 4 different sunxi platforms. First test was "normal" commandline, second was with clk_ignore_unused appended:

- cubie: fail, fail
- cubie2: fail, fail
- bananpi: fail, pass
- cubietruck: fail, pass

So it seems to have some effect, but by itself, doesn't fix the issue.

Kevin

#27 lore raw
Quoted 46 lines · Kevin Hilman
Quoted 33 lines · Maxime Ripard
Quoted 32 lines · Stephen Boyd
Quoted 31 lines · Maxime Ripard
Quoted 30 lines · Stephen Boyd
Quoted 16 lines · Kevin Hilman
Quoted 15 lines · Stephen Boyd
Quoted 14 lines · Heiko St?bner

Am Freitag, 1. Mai 2015, 13:52:47 schrieb Stephen Boyd:

Quoted 4 lines
Quoted 2 lines

Instead I guess we could hook it less deep into clk_get_sys, like in the following patch?

It looks like it will work at least, but still I'd prefer to keep the orphan check contained to clk.c. How about this compile tested only patch?

I gave this a spin on my rk3288-firefly board. It still boots, the clock tree looks the same and it also still defers nicely in the scenario I needed it for. The implementation also looks nice - and of course much more compact than my check in two places :-) . I don't know if you want to put this as follow-up on top or fold it into the original orphan-check, so in any case

Quoted 10 lines
Quoted 2 lines

Thanks. I'm leaning towards tossing your patch 2/2 and replacing it with my patch and a note that it's based on an earlier patch from you.

It appears this has landed in linux-next in the form of 882667c1fcf1
clk: prevent orphan clocks from being used. A bunch of boot failures for sunxi in today's linux-next[1] were bisected down to that patch.

I confirmed that reverting that commit on top of next/master gets sunxi booting again.

Thanks for the report. I've removed the two clk orphan patches from clk-next. Would it be possible to try with next-20150507 and clk_ignore_unused on the command line?

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

This makes it work, but it's not really an option.

Hmm.. I thought it didn't fix it for Kevin. Confused.

I'm too, but it does fix things here.

To be more precise on what I tested. I used next-20150507 and tested on 4 different sunxi platforms. First test was "normal" commandline, second was with clk_ignore_unused appended:

Quoted 6 lines

- cubie: fail, fail
- cubie2: fail, fail
- bananpi: fail, pass
- cubietruck: fail, pass

So it seems to have some effect, but by itself, doesn't fix the issue.

It's very odd, I actually tried with a cubie2 here...

I'm booting on an initramfs and not MMC though, but I can't see how that can be related to our issue...

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150513/f7533541/attachment-0001.sig>
#28 lore raw
Quoted 52 lines · Maxime Ripard
Quoted 51 lines · Kevin Hilman
Quoted 33 lines · Maxime Ripard
Quoted 32 lines · Stephen Boyd
Quoted 31 lines · Maxime Ripard
Quoted 30 lines · Stephen Boyd
Quoted 16 lines · Kevin Hilman
Quoted 15 lines · Stephen Boyd
Quoted 14 lines · Heiko St?bner

Am Freitag, 1. Mai 2015, 13:52:47 schrieb Stephen Boyd:

Quoted 4 lines
Quoted 2 lines

Instead I guess we could hook it less deep into clk_get_sys, like in the following patch?

It looks like it will work at least, but still I'd prefer to keep the orphan check contained to clk.c. How about this compile tested only patch?

I gave this a spin on my rk3288-firefly board. It still boots, the clock tree looks the same and it also still defers nicely in the scenario I needed it for. The implementation also looks nice - and of course much more compact than my check in two places :-) . I don't know if you want to put this as follow-up on top or fold it into the original orphan-check, so in any case

Quoted 10 lines
Quoted 2 lines

Thanks. I'm leaning towards tossing your patch 2/2 and replacing it with my patch and a note that it's based on an earlier patch from you.

It appears this has landed in linux-next in the form of 882667c1fcf1
clk: prevent orphan clocks from being used. A bunch of boot failures for sunxi in today's linux-next[1] were bisected down to that patch.

I confirmed that reverting that commit on top of next/master gets sunxi booting again.

Thanks for the report. I've removed the two clk orphan patches from clk-next. Would it be possible to try with next-20150507 and clk_ignore_unused on the command line?

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

This makes it work, but it's not really an option.

Hmm.. I thought it didn't fix it for Kevin. Confused.

I'm too, but it does fix things here.

To be more precise on what I tested. I used next-20150507 and tested on 4 different sunxi platforms. First test was "normal" commandline, second was with clk_ignore_unused appended:

- cubie: fail, fail
- cubie2: fail, fail
- bananpi: fail, pass
- cubietruck: fail, pass

Quoted 6 lines
Quoted 1 line

So it seems to have some effect, but by itself, doesn't fix the issue.

It's very odd, I actually tried with a cubie2 here...

I'm booting on an initramfs and not MMC though, but I can't see how that can be related to our issue...

I'm booting an initramfs too.

Kevin

#29 lore raw
Quoted 54 lines · Kevin Hilman
Quoted 52 lines · Maxime Ripard
Quoted 51 lines · Kevin Hilman
Quoted 33 lines · Maxime Ripard
Quoted 32 lines · Stephen Boyd
Quoted 31 lines · Maxime Ripard
Quoted 30 lines · Stephen Boyd
Quoted 16 lines · Kevin Hilman
Quoted 15 lines · Stephen Boyd
Quoted 14 lines · Heiko St?bner

Am Freitag, 1. Mai 2015, 13:52:47 schrieb Stephen Boyd:

Quoted 4 lines
Quoted 2 lines

Instead I guess we could hook it less deep into clk_get_sys, like in the following patch?

It looks like it will work at least, but still I'd prefer to keep the orphan check contained to clk.c. How about this compile tested only patch?

I gave this a spin on my rk3288-firefly board. It still boots, the clock tree looks the same and it also still defers nicely in the scenario I needed it for. The implementation also looks nice - and of course much more compact than my check in two places :-) . I don't know if you want to put this as follow-up on top or fold it into the original orphan-check, so in any case

Quoted 10 lines
Quoted 2 lines

Thanks. I'm leaning towards tossing your patch 2/2 and replacing it with my patch and a note that it's based on an earlier patch from you.

It appears this has landed in linux-next in the form of 882667c1fcf1
clk: prevent orphan clocks from being used. A bunch of boot failures for sunxi in today's linux-next[1] were bisected down to that patch.

I confirmed that reverting that commit on top of next/master gets sunxi booting again.

Thanks for the report. I've removed the two clk orphan patches from clk-next. Would it be possible to try with next-20150507 and clk_ignore_unused on the command line?

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

This makes it work, but it's not really an option.

Hmm.. I thought it didn't fix it for Kevin. Confused.

I'm too, but it does fix things here.

To be more precise on what I tested. I used next-20150507 and tested on 4 different sunxi platforms. First test was "normal" commandline, second was with clk_ignore_unused appended:

- cubie: fail, fail
- cubie2: fail, fail
- bananpi: fail, pass
- cubietruck: fail, pass

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

So it seems to have some effect, but by itself, doesn't fix the issue.

It's very odd, I actually tried with a cubie2 here...

I'm booting on an initramfs and not MMC though, but I can't see how that can be related to our issue...

I'm booting an initramfs too.

Then I don't know :)

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150513/31eee124/attachment.sig>
#30 lore raw
In reply to Maxime Ripard

Hi Maxime, Stephen,

Am Freitag, 8. Mai 2015, 12:02:47 schrieb Maxime Ripard:

Quoted 3 lines · Stephen Boyd
Quoted 2 lines · Kevin Hilman
Quoted 1 line

On Fri, May 1, 2015 at 4:40 PM, Stephen Boyd <[email protected]>

Quoted 46 lines · wrote:
Quoted 28 lines
Quoted 28 lines
Quoted 17 lines · Heiko St?bner
Quoted 16 lines

Am Freitag, 1. Mai 2015, 13:52:47 schrieb Stephen Boyd:

Quoted 7 lines
Quoted 3 lines

Instead I guess we could hook it less deep into clk_get_sys, like in the
following patch?

It looks like it will work at least, but still I'd prefer to keep the orphan check contained to clk.c. How about this compile tested only patch?

I gave this a spin on my rk3288-firefly board. It still boots, the clock tree looks the same and it also still defers nicely in the scenario I needed it for. The implementation also looks nice - and of course much more compact than my check in two places :-) . I don't know if you want to put this as follow-up on top or fold it into the original orphan-check, so in any case

Quoted 6 lines
Quoted 2 lines

Thanks. I'm leaning towards tossing your patch 2/2 and replacing it with
my patch and a note that it's based on an earlier patch from you.

It appears this has landed in linux-next in the form of 882667c1fcf1
clk: prevent orphan clocks from being used. A bunch of boot failures for sunxi in today's linux-next[1] were bisected down to that patch.

Quoted 6 lines
Quoted 2 lines

I confirmed that reverting that commit on top of next/master gets sunxi booting again.

Thanks for the report. I've removed the two clk orphan patches from clk-next. Would it be possible to try with next-20150507 and clk_ignore_unused on the command line?

This makes it work, but it's not really an option.

Quoted 2 lines

Also we can try to see if critical clocks aren't being forced on by applying this patch and looking for clk_get() failures

And that shows that the CPU and DDR clocks are not protected, which obviously is pretty mad.

I've mass converted all our probing code to use OF_CLK_DECLARE, and make things work again.

Quoted 6 lines

http://code.bulix.org/5goa5j-88345?raw

Is this an acceptable solution?

We were already moving to this, I'm not really fond of doing this like that, but I guess this whole debacle makes it necessary.

did this lead anywhere meanwhile.

Last I remember the change to orphan handling made sunxi fail, but I'm still hoping to get this usable at some point :-)

Thanks
Heiko

#31 lore raw

Hi Heiko,

Quoted 13 lines · Heiko St?bner
Quoted 13 lines
Quoted 2 lines

Also we can try to see if critical clocks aren't being forced on by applying this patch and looking for clk_get() failures

And that shows that the CPU and DDR clocks are not protected, which obviously is pretty mad.

I've mass converted all our probing code to use OF_CLK_DECLARE, and make things work again.

http://code.bulix.org/5goa5j-88345?raw

Is this an acceptable solution?

Quoted 8 lines
Quoted 2 lines

We were already moving to this, I'm not really fond of doing this like that, but I guess this whole debacle makes it necessary.

did this lead anywhere meanwhile.

Last I remember the change to orphan handling made sunxi fail, but I'm still hoping to get this usable at some point :-)

To be honest, I don't know what the current status is. I haven't get any news since that mail.

I started to move a significant portion of our clocks to CLK_OF_DECLARE, but not all of them are (which probably make the situation worse for the time being).

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150730/6f3d5af2/attachment.sig>
#32 lore raw
Quoted 7 lines · Maxime Ripard
Quoted 5 lines · Heiko St?bner

did this lead anywhere meanwhile.

Last I remember the change to orphan handling made sunxi fail, but I'm still hoping to get this usable at some point :-)

Quoted 7 lines

To be honest, I don't know what the current status is. I haven't get any news since that mail.

I started to move a significant portion of our clocks to CLK_OF_DECLARE, but not all of them are (which probably make the situation worse for the time being).

Sorry, I think we're still waiting for the critical clocks stuff to settle down so that Sunxi can use that instead of calling clk_prepare_enable() in init code. For now, I've put the first patch of the two into clk-next so that we can have proper orphan tracking. Hopefully we resolve critical clocks soon so that we can merge the defer part.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#33 lore raw

Am Dienstag, 11. August 2015, 15:34:09 schrieb Stephen Boyd:

Quoted 14 lines · Maxime Ripard
Quoted 6 lines · Heiko St?bner
Quoted 4 lines

did this lead anywhere meanwhile.

Last I remember the change to orphan handling made sunxi fail, but I'm still hoping to get this usable at some point :-)

Quoted 6 lines

To be honest, I don't know what the current status is. I haven't get any news since that mail.

I started to move a significant portion of our clocks to CLK_OF_DECLARE, but not all of them are (which probably make the situation worse for the time being).

Quoted 6 lines

Sorry, I think we're still waiting for the critical clocks stuff to settle down so that Sunxi can use that instead of calling clk_prepare_enable() in init code. For now, I've put the first patch of the two into clk-next so that we can have proper orphan tracking. Hopefully we resolve critical clocks soon so that we can merge the defer part.

great :-)

For the defer-part you came up with a better solution than mine anyway, if I remember correctly.