Skip to content

Commit 642639b

Browse files
geertugregkh
authored andcommitted
staging: board: Fix uninitialized spinlock when attaching genpd
[ Upstream commit df00609 ] On Armadillo-800-EVA with CONFIG_DEBUG_SPINLOCK=y: BUG: spinlock bad magic on CPU#0, swapper/1 lock: lcdc0_device+0x10c/0x308, .magic: 00000000, .owner: <none>/-1, .owner_cpu: 0 CPU: 0 PID: 1 Comm: swapper Not tainted 5.11.0-rc5-armadillo-00036-gbbca04be7a80-dirty Freescale#287 Hardware name: Generic R8A7740 (Flattened Device Tree) [<c010c3c8>] (unwind_backtrace) from [<c010a49c>] (show_stack+0x10/0x14) [<c010a49c>] (show_stack) from [<c0159534>] (do_raw_spin_lock+0x20/0x94) [<c0159534>] (do_raw_spin_lock) from [<c040858c>] (dev_pm_get_subsys_data+0x8c/0x11c) [<c040858c>] (dev_pm_get_subsys_data) from [<c05fbcac>] (genpd_add_device+0x78/0x2b8) [<c05fbcac>] (genpd_add_device) from [<c0412db4>] (of_genpd_add_device+0x34/0x4c) [<c0412db4>] (of_genpd_add_device) from [<c0a1ea74>] (board_staging_register_device+0x11c/0x148) [<c0a1ea74>] (board_staging_register_device) from [<c0a1eac4>] (board_staging_register_devices+0x24/0x28) of_genpd_add_device() is called before platform_device_register(), as it needs to attach the genpd before the device is probed. But the spinlock is only initialized when the device is registered. Fix this by open-coding the spinlock initialization, cfr. device_pm_init_common() in the internal drivers/base code, and in the SuperH early platform code. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/r/57783ece7ddae55f2bda2f59f452180bff744ea0.1626257398.git.geert+renesas@glider.be Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 03f4492 commit 642639b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/staging/board/board.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ int __init board_staging_register_clock(const struct board_staging_clk *bsc)
136136
static int board_staging_add_dev_domain(struct platform_device *pdev,
137137
const char *domain)
138138
{
139+
struct device *dev = &pdev->dev;
139140
struct of_phandle_args pd_args;
140141
struct device_node *np;
141142

@@ -148,7 +149,11 @@ static int board_staging_add_dev_domain(struct platform_device *pdev,
148149
pd_args.np = np;
149150
pd_args.args_count = 0;
150151

151-
return of_genpd_add_device(&pd_args, &pdev->dev);
152+
/* Initialization similar to device_pm_init_common() */
153+
spin_lock_init(&dev->power.lock);
154+
dev->power.early_init = true;
155+
156+
return of_genpd_add_device(&pd_args, dev);
152157
}
153158
#else
154159
static inline int board_staging_add_dev_domain(struct platform_device *pdev,

0 commit comments

Comments
 (0)