* [PATCH v1] clk: Probe defer clk_get() on orphans
@ 2019-02-11 18:57 Jeffrey Hugo
0 siblings, 0 replies; 1+ messages in thread
From: Jeffrey Hugo @ 2019-02-11 18:57 UTC (permalink / raw)
To: mturquette, sboyd
Cc: bjorn.andersson, georgi.djakov, linux-arm-msm, linux-clk,
linux-kernel, Jeffrey Hugo
If a parent to a clock comes from outside that clock's provider, the parent
may not be present at the time the clock is registered (ie the parent comes
from another driver that has not yet probed). The clock can still be
registered, and a reference to it obtained, however that clock may not be
fully functional - ie get_rate might return an invalid value.
This has been a problem that has resulted in the UART console breaking on
some Qualcomm SoCs, as the UART baud rate is based on a clock that is the
child of XO. Due to the large chain of dependencies, its possible that the
RPM has not provided XO by the time that the UART driver probes, gets the
baud rate clock, and calls get_rate - which returns 0 and results in a bad
An orphan clock is a clock that is missing a parent or some other ancestor.
Since the parent is defined, we can assume that it is expected to appear at
some point in a properly configured system (all bets are off if a required
driver is not compiled, etc), and it is unlikely that the clock can be
properly consumed during the time the clock is an orphan. Therefore,
return EPROBE_DEFER for orphan clocks so that consumers wait until the
parent chain is established, and proper clock operation can occur.
Signed-off-by: Jeffrey Hugo <firstname.lastname@example.org>
This is based upon the "Rewrite clk parent handling" series at , and assumes
that the suspected missing line commented on at  is added.
The idea for this solution came from  and .
drivers/clk/clk.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 34e9524ea25d..cf71e0614282 100644
@@ -3405,6 +3405,10 @@ struct clk *clk_hw_create_clk(struct device *dev, struct clk_hw *hw,
core = hw->core;
+ if (core->orphan)
+ return ERR_PTR(-EPROBE_DEFER);
clk = alloc_clk(core, dev_id, con_id);
Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
^ permalink raw reply [flat|nested] 1+ messages in thread
only message in thread, back to index
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-11 18:57 [PATCH v1] clk: Probe defer clk_get() on orphans Jeffrey Hugo
Linux-Clk Archive on lore.kernel.org
Archives are clonable:
git clone --mirror https://lore.kernel.org/linux-clk/0 linux-clk/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 linux-clk linux-clk/ https://lore.kernel.org/linux-clk \
Newsgroup available over NNTP:
AGPL code for this site: git clone https://public-inbox.org/ public-inbox