Re: WARNING: CPU: 0 PID: 1 at drivers/clk/clk.c:4156 __clk_put+0xfc/0x130
From: Stephen Boyd
Date: Mon Mar 16 2020 - 14:12:55 EST
Quoting Naresh Kamboju (2020-03-16 02:05:24)
> The following kernel warning noticed on linux-next on arm64 juno-r2 device.
>
> Linux version 5.6.0-rc5-next-20200316 (TuxBuild@ccdbe23f0d06) (gcc
> version 9.2.1 20191130 (Debian 9.2.1-21)) #1 SMP PREEMPT Mon Mar 16
> 07:40:45 UTC 2020
>
> [ 0.002822] ------------[ cut here ]------------
> [ 0.002840] WARNING: CPU: 0 PID: 1 at drivers/clk/clk.c:4156
> __clk_put+0xfc/0x130
> [ 0.002846] Modules linked in:
> [ 0.002859] CPU: 0 PID: 1 Comm: swapper/0 Not tainted
> 5.6.0-rc5-next-20200316 #1
> [ 0.002865] Hardware name: ARM Juno development board (r2) (DT)
> [ 0.002873] pstate: 20000005 (nzCv daif -PAN -UAO)
> [ 0.002882] pc : __clk_put+0xfc/0x130
> [ 0.002891] lr : clk_put+0xc/0x18
Looks like the code is wrong. It calls of_clk_get() and then
unconditionally calls clk_put() on whatever is returned, including an
error pointer which we warn about.
WARN_ON_ONCE(IS_ERR(clk))
in __clk_put().
> [ 0.002896] sp : ffff80001003bba0
> [ 0.002902] x29: ffff80001003bba0 x28: 0000000000000000
> [ 0.002911] x27: 0000000000000000 x26: ffff800011c56000
> [ 0.002919] x25: ffff800011c56490 x24: 0000000000000001
> [ 0.002928] x23: ffff00097effdae8 x22: 0000000000000001
> [ 0.002936] x21: ffff000975cc8000 x20: fffffffffffffdfb
> [ 0.002945] x19: fffffffffffffdfb x18: 0000000000000001
> [ 0.002953] x17: 00000000e80423fd x16: 00000000e66966f2
> [ 0.002961] x15: ffffffffffffffff x14: ffffffffff000000
> [ 0.002970] x13: ffffffffffffffff x12: 0000000000000018
> [ 0.002978] x11: 0000000000000028 x10: 0101010101010101
> [ 0.002987] x9 : ffffffffffffffff x8 : 7f7f7f7f7f7f7f7f
> [ 0.002995] x7 : 6b61ff726b6b6462 x6 : 000000000080636c
> [ 0.003003] x5 : ffff00097eff3d30 x4 : 0000000000000000
> [ 0.003011] x3 : 0000000000000001 x2 : 0000000000000001
> [ 0.003019] x1 : 1989cb6049749c00 x0 : fffffffffffffdfb
> [ 0.003028] Call trace:
> [ 0.003037] __clk_put+0xfc/0x130
> [ 0.003045] clk_put+0xc/0x18
> [ 0.003057] topology_parse_cpu_capacity+0x100/0x180
Looks like Greg picked up this patch[1] as commit b8fe128dad8f
("arch_topology: Adjust initial CPU capacities with current freq") from
the list. Not sure it's correct though and I haven't looked in any more
detail. At least, not calling clk_put() unless it is a valid pointer
will work to quiet this warning.
[1] https://lore.kernel.org/r/20200113034815.25924-1-jeffy.chen@xxxxxxxxxxxxxx