Commit e561e472 authored by Jason A. Donenfeld's avatar Jason A. Donenfeld Committed by Michael Ellerman

powerpc/pseries: wire up rng during setup_arch()

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: a489043f ("powerpc/pseries: Implement arch_get_random_long() based on H_RANDOM")
Cc: stable@vger.kernel.org # v3.13+
Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220611151015.548325-4-Jason@zx2c4.com
parent 20a9689b
...@@ -122,4 +122,6 @@ void pseries_lpar_read_hblkrm_characteristics(void); ...@@ -122,4 +122,6 @@ void pseries_lpar_read_hblkrm_characteristics(void);
static inline void pseries_lpar_read_hblkrm_characteristics(void) { } static inline void pseries_lpar_read_hblkrm_characteristics(void) { }
#endif #endif
void pseries_rng_init(void);
#endif /* _PSERIES_PSERIES_H */ #endif /* _PSERIES_PSERIES_H */
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <asm/archrandom.h> #include <asm/archrandom.h>
#include <asm/machdep.h> #include <asm/machdep.h>
#include <asm/plpar_wrappers.h> #include <asm/plpar_wrappers.h>
#include "pseries.h"
static int pseries_get_random_long(unsigned long *v) static int pseries_get_random_long(unsigned long *v)
...@@ -24,19 +25,13 @@ static int pseries_get_random_long(unsigned long *v) ...@@ -24,19 +25,13 @@ static int pseries_get_random_long(unsigned long *v)
return 0; return 0;
} }
static __init int rng_init(void) void __init pseries_rng_init(void)
{ {
struct device_node *dn; struct device_node *dn;
dn = of_find_compatible_node(NULL, NULL, "ibm,random"); dn = of_find_compatible_node(NULL, NULL, "ibm,random");
if (!dn) if (!dn)
return -ENODEV; return;
pr_info("Registering arch random hook.\n");
ppc_md.get_random_seed = pseries_get_random_long; ppc_md.get_random_seed = pseries_get_random_long;
of_node_put(dn); of_node_put(dn);
return 0;
} }
machine_subsys_initcall(pseries, rng_init);
...@@ -839,6 +839,7 @@ static void __init pSeries_setup_arch(void) ...@@ -839,6 +839,7 @@ static void __init pSeries_setup_arch(void)
} }
ppc_md.pcibios_root_bridge_prepare = pseries_root_bridge_prepare; ppc_md.pcibios_root_bridge_prepare = pseries_root_bridge_prepare;
pseries_rng_init();
} }
static void pseries_panic(char *str) static void pseries_panic(char *str)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment