Question about of_clk_put ?

From: Kuninori Morimoto
Date: Tue Mar 28 2017 - 21:16:58 EST



Hi Stephen

Now, I'm using devm_get_clk_from_child() (= linux/drivers/clk/clk-devres.c)
and I got Oops if I do bind/unbind driver several times.

[ 32.008847] Unable to handle kernel paging request at virtual address d503201faa1e03e0
[ 32.017124] pgd = ffff8006f9060000
[ 32.020883] [d503201faa1e03e0] *pgd=0000000000000000
[ 32.026243] Internal error: Oops: 96000004 [#1] PREEMPT SMP
[ 32.032198] CPU: 0 PID: 934 Comm: kworker/0:2 Not tainted 4.11.0-rc3+ #1259
[ 32.039573] Hardware name: Renesas Salvator-X board based on r8a7795 (DT)
[ 32.046814] Workqueue: events deferred_probe_work_func
[ 32.052405] task: ffff8006fad2d800 task.stack: ffff8006f90b8000
[ 32.058809] PC is at __of_clk_get_from_provider+0x174/0x1b0
[ 32.064878] LR is at __of_clk_get_from_provider+0x164/0x1b0
....
[ 32.746677] [<ffff0000083b581c>] __of_clk_get_from_provider+0x174/0x1b0
[ 32.754131] [<ffff0000083aded4>] __of_clk_get_by_name+0x104/0x140
[ 32.761058] [<ffff0000083adfd8>] of_clk_get_by_name+0x30/0x50
[ 32.767630] [<ffff0000083add1c>] devm_get_clk_from_child+0x54/0xb0
...

I tried to find the criminal point, but, I couldn't specify where it is.
Sometimes it is NULL pointer access crashed,
sometimes it is crashed on of_clk_src_onecell_get(),
sometimes there is no Oops.
I want to solve this issue, but I want to know about of_clk_put as 1st step.

In devm_clk_get() case, it is using clk_get() <-> clk_put() pair, this is OK.
In devm_get_clk_from_child() case, it is using of_clk_get_by_name() (= __of_clk_get())
<-> clk_put() pair.
If my understand was correct, __of_clk_get() uses __clk_create_clk(),
so, its pair should be __clk_free_clk() ?
I wonder I can find of_clk_get(), but couldn't find of_clk_put().
Is using of_clk_get() <-> clk_put() OK ?

Best regards
---
Kuninori Morimoto