Skip to content

Commit e29e92f

Browse files
zx2c4gregkh
authored andcommitted
powerpc/pseries: wire up rng during setup_arch()
commit e561e47 upstream. The platform's RNG must be available before random_init() in order to be useful for initial seeding, which in turn means that it needs to be called from setup_arch(), rather than from an init call. Fortunately, each platform already has a setup_arch function pointer, which means it's easy to wire this up. This commit also removes some noisy log messages that don't add much. Fixes: a489043 ("powerpc/pseries: Implement arch_get_random_long() based on H_RANDOM") Cc: [email protected] # v3.13+ Signed-off-by: Jason A. Donenfeld <[email protected]> Reviewed-by: Christophe Leroy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jason A. Donenfeld <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c8f4a15 commit e29e92f

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

arch/powerpc/platforms/pseries/pseries.h

+2
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,6 @@ void pseries_lpar_read_hblkrm_characteristics(void);
121121
static inline void pseries_lpar_read_hblkrm_characteristics(void) { }
122122
#endif
123123

124+
void pseries_rng_init(void);
125+
124126
#endif /* _PSERIES_PSERIES_H */

arch/powerpc/platforms/pseries/rng.c

+3-8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <asm/archrandom.h>
1111
#include <asm/machdep.h>
1212
#include <asm/plpar_wrappers.h>
13+
#include "pseries.h"
1314

1415

1516
static int pseries_get_random_long(unsigned long *v)
@@ -24,19 +25,13 @@ static int pseries_get_random_long(unsigned long *v)
2425
return 0;
2526
}
2627

27-
static __init int rng_init(void)
28+
void __init pseries_rng_init(void)
2829
{
2930
struct device_node *dn;
3031

3132
dn = of_find_compatible_node(NULL, NULL, "ibm,random");
3233
if (!dn)
33-
return -ENODEV;
34-
35-
pr_info("Registering arch random hook.\n");
36-
34+
return;
3735
ppc_md.get_random_seed = pseries_get_random_long;
38-
3936
of_node_put(dn);
40-
return 0;
4137
}
42-
machine_subsys_initcall(pseries, rng_init);

arch/powerpc/platforms/pseries/setup.c

+2
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,8 @@ static void __init pSeries_setup_arch(void)
852852

853853
if (swiotlb_force == SWIOTLB_FORCE)
854854
ppc_swiotlb_enable = 1;
855+
856+
pseries_rng_init();
855857
}
856858

857859
static void pseries_panic(char *str)

0 commit comments

Comments
 (0)