Re: [PATCH v3 0/3] driver core: Add device link related sysfs files

From: Saravana Kannan
Date: Wed Jul 15 2020 - 04:54:01 EST


On Wed, Jul 15, 2020 at 1:22 AM Marek Szyprowski
<m.szyprowski@xxxxxxxxxxx> wrote:
>
> Hi Greg and Saravana,
>
> On 10.07.2020 15:23, Greg Kroah-Hartman wrote:
> > On Mon, Jul 06, 2020 at 03:45:02PM -0700, Saravana Kannan wrote:
> >> On Tue, Jun 16, 2020 at 8:45 PM Saravana Kannan <saravanak@xxxxxxxxxx> wrote:
> >>> On Fri, May 29, 2020 at 5:30 AM Greg Kroah-Hartman
> >>> <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
> >>>> Looks semi-sane, but it's too close to the merge window at the moment
> >>>> for me to take this. If there's no objections by the time 5.8-rc1 is
> >>>> out, I'll queue it up in my tree for 5.9-rc1.
> >>> Another friendly reminder :)
> >> *nudge* *nudge*
> > Looks sane, given no objections, let's see what linux-next thinks about
> > it...
>
> linux-next is not very happy from this patchset... Starting from
> next-20200713 I see a few new issues on various Samsung Exynos based
> boards. Here are examples from Exynos4412-based Odroid U3 board (ARM
> 32bit, kernel compiled from exynos_defconfig):

Thanks for the bug reports.

> BUG: sleeping function called from invalid context at
> kernel/locking/mutex.c:935
> in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 12, name: kworker/0:1
> 2 locks held by kworker/0:1/12:
> #0: ee8074a8 ((wq_completion)rcu_gp){+.+.}-{0:0}, at:
> process_one_work+0x174/0x7dc
> #1: ee921f20 ((work_completion)(&sdp->work)){+.+.}-{0:0}, at:
> process_one_work+0x174/0x7dc
> Preemption disabled at:
> [<c01b10f0>] srcu_invoke_callbacks+0xc0/0x154

Sigh... probably some SRCU screw up when the device link is deleted.
I'll look at it by the end of this week. If you don't mind, what SRCU
debug config caught this for you? That way, I can reproduce it on my
end.

-Saravana

> CPU: 0 PID: 12 Comm: kworker/0:1 Tainted: G W
> 5.8.0-rc3-00022-g287905e68dd2 #8753
> Hardware name: Samsung Exynos (Flattened Device Tree)
> Workqueue: rcu_gp srcu_invoke_callbacks
> [<c011184c>] (unwind_backtrace) from [<c010d250>] (show_stack+0x10/0x14)
> [<c010d250>] (show_stack) from [<c0517f04>] (dump_stack+0xbc/0xe8)
> [<c0517f04>] (dump_stack) from [<c0159188>] (___might_sleep+0x288/0x2d8)
> [<c0159188>] (___might_sleep) from [<c0abbd1c>] (__mutex_lock+0x48/0xb18)
> [<c0abbd1c>] (__mutex_lock) from [<c0abc808>] (mutex_lock_nested+0x1c/0x24)
> [<c0abc808>] (mutex_lock_nested) from [<c064590c>] (device_del+0x30/0x39c)
> [<c064590c>] (device_del) from [<c0645c9c>] (device_unregister+0x24/0x64)
> [<c0645c9c>] (device_unregister) from [<c01b10fc>]
> (srcu_invoke_callbacks+0xcc/0x154)
> [<c01b10fc>] (srcu_invoke_callbacks) from [<c01493c4>]
> (process_one_work+0x234/0x7dc)
> [<c01493c4>] (process_one_work) from [<c01499b0>] (worker_thread+0x44/0x51c)
> [<c01499b0>] (worker_thread) from [<c0150bf4>] (kthread+0x158/0x1a0)
> [<c0150bf4>] (kthread) from [<c0100114>] (ret_from_fork+0x14/0x20)
> Exception stack(0xee921fb0 to 0xee921ff8)
>
>
> BUG: scheduling while atomic: kworker/0:0/5/0x00000201
> 3 locks held by kworker/0:0/5:
> #0: ee8074a8 ((wq_completion)rcu_gp){+.+.}-{0:0}, at:
> process_one_work+0x174/0x7dc
> #1: ee907f20 ((work_completion)(&sdp->work)){+.+.}-{0:0}, at:
> process_one_work+0x174/0x7dc
> #2: c11367e4 (kernfs_mutex){+.+.}-{3:3}, at:
> kernfs_remove_by_name_ns+0x24/0x94
> Modules linked in:
> Preemption disabled at:
> [<c01b10f0>] srcu_invoke_callbacks+0xc0/0x154
> CPU: 0 PID: 5 Comm: kworker/0:0 Tainted: G W
> 5.8.0-rc3-00022-g287905e68dd2 #8753
> Hardware name: Samsung Exynos (Flattened Device Tree)
> Workqueue: rcu_gp srcu_invoke_callbacks
> [<c011184c>] (unwind_backtrace) from [<c010d250>] (show_stack+0x10/0x14)
> [<c010d250>] (show_stack) from [<c0517f04>] (dump_stack+0xbc/0xe8)
> [<c0517f04>] (dump_stack) from [<c0158da0>] (__schedule_bug+0x88/0xe0)
> [<c0158da0>] (__schedule_bug) from [<c0ab7f88>] (__schedule+0x5d0/0x83c)
> [<c0ab7f88>] (__schedule) from [<c0ab8258>] (schedule+0x64/0x124)
> [<c0ab8258>] (schedule) from [<c0ab8768>]
> (schedule_preempt_disabled+0x14/0x20)
> [<c0ab8768>] (schedule_preempt_disabled) from [<c0abc1ec>]
> (__mutex_lock+0x518/0xb18)
> [<c0abc1ec>] (__mutex_lock) from [<c0abc808>] (mutex_lock_nested+0x1c/0x24)
> [<c0abc808>] (mutex_lock_nested) from [<c0362fc0>]
> (kernfs_remove_by_name_ns+0x24/0x94)
> [<c0362fc0>] (kernfs_remove_by_name_ns) from [<c0644eac>]
> (device_remove_class_symlinks+0x70/0x94)
> [<c0644eac>] (device_remove_class_symlinks) from [<c0645994>]
> (device_del+0xb8/0x39c)
> [<c0645994>] (device_del) from [<c0645c9c>] (device_unregister+0x24/0x64)
> [<c0645c9c>] (device_unregister) from [<c01b10fc>]
> (srcu_invoke_callbacks+0xcc/0x154)
> [<c01b10fc>] (srcu_invoke_callbacks) from [<c01493c4>]
> (process_one_work+0x234/0x7dc)
> [<c01493c4>] (process_one_work) from [<c01499b0>] (worker_thread+0x44/0x51c)
> [<c01499b0>] (worker_thread) from [<c0150bf4>] (kthread+0x158/0x1a0)
> [<c0150bf4>] (kthread) from [<c0100114>] (ret_from_fork+0x14/0x20)
> Exception stack(0xee907fb0 to 0xee907ff8)
> sysfs: cannot create duplicate filename
> '/devices/virtual/devlink/regulator.28:cpu0'
>
> ------------[ cut here ]------------
> WARNING: CPU: 0 PID: 5 at kernel/sched/core.c:3897
> preempt_count_sub+0x104/0x108
> DEBUG_LOCKS_WARN_ON(val > preempt_count())
> Modules linked in:
> CPU: 0 PID: 5 Comm: kworker/0:0 Tainted: G W
> 5.8.0-rc3-00022-g287905e68dd2 #8753
> Hardware name: Samsung Exynos (Flattened Device Tree)
> Workqueue: rcu_gp srcu_invoke_callbacks
> [<c011184c>] (unwind_backtrace) from [<c010d250>] (show_stack+0x10/0x14)
> [<c010d250>] (show_stack) from [<c0517f04>] (dump_stack+0xbc/0xe8)
> [<c0517f04>] (dump_stack) from [<c01270a8>] (__warn+0xf0/0x108)
> [<c01270a8>] (__warn) from [<c0127134>] (warn_slowpath_fmt+0x74/0xb8)
> [<c0127134>] (warn_slowpath_fmt) from [<c0158efc>]
> (preempt_count_sub+0x104/0x108)
> [<c0158efc>] (preempt_count_sub) from [<c012fee4>]
> (__local_bh_enable_ip+0x74/0x16c)
> [<c012fee4>] (__local_bh_enable_ip) from [<c01b1108>]
> (srcu_invoke_callbacks+0xd8/0x154)
> [<c01b1108>] (srcu_invoke_callbacks) from [<c01493c4>]
> (process_one_work+0x234/0x7dc)
> [<c01493c4>] (process_one_work) from [<c01499b0>] (worker_thread+0x44/0x51c)
> [<c01499b0>] (worker_thread) from [<c0150bf4>] (kthread+0x158/0x1a0)
> [<c0150bf4>] (kthread) from [<c0100114>] (ret_from_fork+0x14/0x20)
> Exception stack(0xee907fb0 to 0xee907ff8)
> 7fa0: 00000000 00000000 00000000
> 00000000
> 7fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000
> 00000000
> 7fe0: 00000000 00000000 00000000 00000000 00000013 00000000
> irq event stamp: 2274
> hardirqs last enabled at (2273): [<c02b3274>] __slab_free+0x2b0/0x480
> hardirqs last disabled at (2274): [<c012fecc>]
> __local_bh_enable_ip+0x5c/0x16c
> softirqs last enabled at (2184): [<c010174c>] __do_softirq+0x50c/0x608
> softirqs last disabled at (2056): [<c01b10e4>]
> srcu_invoke_callbacks+0xb4/0x154
> ---[ end trace eaa99e7b5e453175 ]---
>
> PU: 0 PID: 1 Comm: swapper/0 Tainted: G W
> 5.8.0-rc3-00022-g287905e68dd2 #8753
> Hardware name: Samsung Exynos (Flattened Device Tree)
> [<c011184c>] (unwind_backtrace) from [<c010d250>] (show_stack+0x10/0x14)
> [<c010d250>] (show_stack) from [<c0517f04>] (dump_stack+0xbc/0xe8)
> [<c0517f04>] (dump_stack) from [<c0365474>] (sysfs_warn_dup+0x58/0x64)
> [<c0365474>] (sysfs_warn_dup) from [<c03655a8>]
> (sysfs_create_dir_ns+0xe0/0xf4)
> [<c03655a8>] (sysfs_create_dir_ns) from [<c051f218>]
> (kobject_add_internal+0xb8/0x370)
> [<c051f218>] (kobject_add_internal) from [<c051f69c>]
> (kobject_add+0x5c/0xbc)
> [<c051f69c>] (kobject_add) from [<c0647338>] (device_add+0x100/0x744)
> [<c0647338>] (device_add) from [<c0647b88>] (device_link_add+0x1f4/0x5d0)
> [<c0647b88>] (device_link_add) from [<c0582f60>] (_regulator_get+0xf4/0x280)
> [<c0582f60>] (_regulator_get) from [<c0803da4>]
> (dev_pm_opp_set_regulators+0xf8/0x210)
> [<c0803da4>] (dev_pm_opp_set_regulators) from [<c080df80>]
> (cpufreq_init+0xb8/0x304)
> [<c080df80>] (cpufreq_init) from [<c080aae0>] (cpufreq_online+0x2c8/0x9f8)
> [<c080aae0>] (cpufreq_online) from [<c080b2ac>] (cpufreq_add_dev+0x8c/0xc0)
> [<c080b2ac>] (cpufreq_add_dev) from [<c0649854>]
> (subsys_interface_register+0xa8/0xf4)
> [<c0649854>] (subsys_interface_register) from [<c0808184>]
> (cpufreq_register_driver+0x178/0x294)
> [<c0808184>] (cpufreq_register_driver) from [<c080ddac>]
> (dt_cpufreq_probe+0xd8/0x1f4)
> [<c080ddac>] (dt_cpufreq_probe) from [<c064e048>]
> (platform_drv_probe+0x6c/0xa4)
> [<c064e048>] (platform_drv_probe) from [<c064b664>]
> (really_probe+0x200/0x48c)
> [<c064b664>] (really_probe) from [<c064ba58>]
> (driver_probe_device+0x78/0x1fc)
> [<c064ba58>] (driver_probe_device) from [<c064be40>]
> (device_driver_attach+0x58/0x60)
> [<c064be40>] (device_driver_attach) from [<c064bf24>]
> (__driver_attach+0xdc/0x174)
> [<c064bf24>] (__driver_attach) from [<c0649470>]
> (bus_for_each_dev+0x68/0xb4)
> [<c0649470>] (bus_for_each_dev) from [<c064a7a4>]
> (bus_add_driver+0x158/0x214)
> [<c064a7a4>] (bus_add_driver) from [<c064cdf8>] (driver_register+0x78/0x110)
> [<c064cdf8>] (driver_register) from [<c0102378>]
> (do_one_initcall+0x8c/0x424)
> [<c0102378>] (do_one_initcall) from [<c1001158>]
> (kernel_init_freeable+0x190/0x204)
> [<c1001158>] (kernel_init_freeable) from [<c0ab7104>]
> (kernel_init+0x8/0x118)
> [<c0ab7104>] (kernel_init) from [<c0100114>] (ret_from_fork+0x14/0x20)
> Exception stack(0xee8f1fb0 to 0xee8f1ff8)
> ...
> BUG: sleeping function called from invalid context at
> kernel/locking/mutex.c:935
> in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 5, name: kworker/0:0
> INFO: lockdep is turned off.
> Preemption disabled at:
> [<c01b10f0>] srcu_invoke_callbacks+0xc0/0x154
> CPU: 0 PID: 5 Comm: kworker/0:0 Tainted: G W
> 5.8.0-rc3-00022-g287905e68dd2 #8753
> Hardware name: Samsung Exynos (Flattened Device Tree)
> Workqueue: rcu_gp srcu_invoke_callbacks
> [<c011184c>] (unwind_backtrace) from [<c010d250>] (show_stack+0x10/0x14)
> [<c010d250>] (show_stack) from [<c0517f04>] (dump_stack+0xbc/0xe8)
> [<c0517f04>] (dump_stack) from [<c0159188>] (___might_sleep+0x288/0x2d8)
> [<c0159188>] (___might_sleep) from [<c0abbd1c>] (__mutex_lock+0x48/0xb18)
> [<c0abbd1c>] (__mutex_lock) from [<c0abc808>] (mutex_lock_nested+0x1c/0x24)
> [<c0abc808>] (mutex_lock_nested) from [<c064590c>] (device_del+0x30/0x39c)
> [<c064590c>] (device_del) from [<c0645c9c>] (device_unregister+0x24/0x64)
> [<c0645c9c>] (device_unregister) from [<c01b10fc>]
> (srcu_invoke_callbacks+0xcc/0x154)
> [<c01b10fc>] (srcu_invoke_callbacks) from [<c01493c4>]
> (process_one_work+0x234/0x7dc)
> [<c01493c4>] (process_one_work) from [<c01499b0>] (worker_thread+0x44/0x51c)
> [<c01499b0>] (worker_thread) from [<c0150bf4>] (kthread+0x158/0x1a0)
> [<c0150bf4>] (kthread) from [<c0100114>] (ret_from_fork+0x14/0x20)
> Exception stack(0xee907fb0 to 0xee907ff8)
> ...
> kobject_add_internal failed for regulator.28:cpu0 with -EEXIST, don't
> try to register things with the same name in the same directory.
>
> Best regards
> --
> Marek Szyprowski, PhD
> Samsung R&D Institute Poland
>