Skip to content

Commit 8875028

Browse files
zx2c4mpe
authored andcommitted
powerpc/powernv: delay rng platform device creation until later in boot
The platform device for the rng must be created much later in boot. Otherwise it tries to connect to a parent that doesn't yet exist, resulting in this splat: [ 0.000478] kobject: '(null)' ((____ptrval____)): is not initialized, yet kobject_get() is being called. [ 0.002925] [c000000002a0fb30] [c00000000073b0bc] kobject_get+0x8c/0x100 (unreliable) [ 0.003071] [c000000002a0fba0] [c00000000087e464] device_add+0xf4/0xb00 [ 0.003194] [c000000002a0fc80] [c000000000a7f6e4] of_device_add+0x64/0x80 [ 0.003321] [c000000002a0fcb0] [c000000000a800d0] of_platform_device_create_pdata+0xd0/0x1b0 [ 0.003476] [c000000002a0fd00] [c00000000201fa44] pnv_get_random_long_early+0x240/0x2e4 [ 0.003623] [c000000002a0fe20] [c000000002060c38] random_init+0xc0/0x214 This patch fixes the issue by doing the platform device creation inside of machine_subsys_initcall. Fixes: f3eac42 ("powerpc/powernv: wire up rng during setup_arch") Cc: stable@vger.kernel.org Reported-by: Sachin Sant <sachinp@linux.ibm.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Tested-by: Sachin Sant <sachinp@linux.ibm.com> [mpe: Change "of node" to "platform device" in change log] Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20220630121654.1939181-1-Jason@zx2c4.com
1 parent ac790d0 commit 8875028

File tree

1 file changed

+10
-6
lines changed
  • arch/powerpc/platforms/powernv

1 file changed

+10
-6
lines changed

arch/powerpc/platforms/powernv/rng.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,8 @@ static int __init pnv_get_random_long_early(unsigned long *v)
176176
NULL) != pnv_get_random_long_early)
177177
return 0;
178178

179-
for_each_compatible_node(dn, NULL, "ibm,power-rng") {
180-
if (rng_create(dn))
181-
continue;
182-
/* Create devices for hwrng driver */
183-
of_platform_device_create(dn, NULL, NULL);
184-
}
179+
for_each_compatible_node(dn, NULL, "ibm,power-rng")
180+
rng_create(dn);
185181

186182
if (!ppc_md.get_random_seed)
187183
return 0;
@@ -205,10 +201,18 @@ void __init pnv_rng_init(void)
205201

206202
static int __init pnv_rng_late_init(void)
207203
{
204+
struct device_node *dn;
208205
unsigned long v;
206+
209207
/* In case it wasn't called during init for some other reason. */
210208
if (ppc_md.get_random_seed == pnv_get_random_long_early)
211209
pnv_get_random_long_early(&v);
210+
211+
if (ppc_md.get_random_seed == powernv_get_random_long) {
212+
for_each_compatible_node(dn, NULL, "ibm,power-rng")
213+
of_platform_device_create(dn, NULL, NULL);
214+
}
215+
212216
return 0;
213217
}
214218
machine_subsys_initcall(powernv, pnv_rng_late_init);

0 commit comments

Comments
 (0)