linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] powerpc: wire up rng during setup_arch
@ 2022-06-11 10:04 Jason A. Donenfeld
  2022-06-11 10:04 ` [PATCH v2 1/3] powerpc/microwatt: " Jason A. Donenfeld
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Jason A. Donenfeld @ 2022-06-11 10:04 UTC (permalink / raw)
  To: linuxppc-dev, linux-kernel, Michael Ellerman; +Cc: Jason A. Donenfeld

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. This series
wires that up properly on the three platforms that currently initialize
the RNG from the wrong place.

Jason A. Donenfeld (3):
  powerpc/microwatt: wire up rng during setup_arch
  powerpc/powernv: wire up rng during setup_arch
  powerpc/pseries: wire up rng during setup_arch

 arch/powerpc/platforms/microwatt/rng.c   |  9 ++-------
 arch/powerpc/platforms/microwatt/setup.c |  8 ++++++++
 arch/powerpc/platforms/powernv/rng.c     | 17 ++++-------------
 arch/powerpc/platforms/powernv/setup.c   |  4 ++++
 arch/powerpc/platforms/pseries/rng.c     | 11 ++---------
 arch/powerpc/platforms/pseries/setup.c   |  3 +++
 6 files changed, 23 insertions(+), 29 deletions(-)

-- 
2.35.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v2 1/3] powerpc/microwatt: wire up rng during setup_arch
  2022-06-11 10:04 [PATCH v2 0/3] powerpc: wire up rng during setup_arch Jason A. Donenfeld
@ 2022-06-11 10:04 ` Jason A. Donenfeld
  2022-06-11 14:40   ` Christophe Leroy
  2022-06-11 10:04 ` [PATCH v2 2/3] powerpc/powernv: " Jason A. Donenfeld
  2022-06-11 10:04 ` [PATCH v2 3/3] powerpc/pseries: " Jason A. Donenfeld
  2 siblings, 1 reply; 13+ messages in thread
From: Jason A. Donenfeld @ 2022-06-11 10:04 UTC (permalink / raw)
  To: linuxppc-dev, linux-kernel, Michael Ellerman
  Cc: Jason A. Donenfeld, stable, Christophe Leroy

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 for each of the three platforms that have an
RNG. This commit also removes some noisy log messages that don't add
much.

Cc: stable@vger.kernel.org
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Fixes: c25769fddaec ("powerpc/microwatt: Add support for hardware random number generator")
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/powerpc/platforms/microwatt/rng.c   | 9 ++-------
 arch/powerpc/platforms/microwatt/setup.c | 8 ++++++++
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/platforms/microwatt/rng.c b/arch/powerpc/platforms/microwatt/rng.c
index 7bc4d1cbfaf0..d13f656910ad 100644
--- a/arch/powerpc/platforms/microwatt/rng.c
+++ b/arch/powerpc/platforms/microwatt/rng.c
@@ -29,7 +29,7 @@ static int microwatt_get_random_darn(unsigned long *v)
 	return 1;
 }
 
-static __init int rng_init(void)
+__init void microwatt_rng_init(void)
 {
 	unsigned long val;
 	int i;
@@ -37,12 +37,7 @@ static __init int rng_init(void)
 	for (i = 0; i < 10; i++) {
 		if (microwatt_get_random_darn(&val)) {
 			ppc_md.get_random_seed = microwatt_get_random_darn;
-			return 0;
+			return;
 		}
 	}
-
-	pr_warn("Unable to use DARN for get_random_seed()\n");
-
-	return -EIO;
 }
-machine_subsys_initcall(, rng_init);
diff --git a/arch/powerpc/platforms/microwatt/setup.c b/arch/powerpc/platforms/microwatt/setup.c
index 0b02603bdb74..23c996dcc870 100644
--- a/arch/powerpc/platforms/microwatt/setup.c
+++ b/arch/powerpc/platforms/microwatt/setup.c
@@ -32,10 +32,18 @@ static int __init microwatt_populate(void)
 }
 machine_arch_initcall(microwatt, microwatt_populate);
 
+__init void microwatt_rng_init(void);
+
+static void __init microwatt_setup_arch(void)
+{
+	microwatt_rng_init();
+}
+
 define_machine(microwatt) {
 	.name			= "microwatt",
 	.probe			= microwatt_probe,
 	.init_IRQ		= microwatt_init_IRQ,
+	.setup_arch		= microwatt_setup_arch,
 	.progress		= udbg_progress,
 	.calibrate_decr		= generic_calibrate_decr,
 };
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 2/3] powerpc/powernv: wire up rng during setup_arch
  2022-06-11 10:04 [PATCH v2 0/3] powerpc: wire up rng during setup_arch Jason A. Donenfeld
  2022-06-11 10:04 ` [PATCH v2 1/3] powerpc/microwatt: " Jason A. Donenfeld
@ 2022-06-11 10:04 ` Jason A. Donenfeld
  2022-06-11 14:42   ` Christophe Leroy
  2022-06-11 10:04 ` [PATCH v2 3/3] powerpc/pseries: " Jason A. Donenfeld
  2 siblings, 1 reply; 13+ messages in thread
From: Jason A. Donenfeld @ 2022-06-11 10:04 UTC (permalink / raw)
  To: linuxppc-dev, linux-kernel, Michael Ellerman
  Cc: Jason A. Donenfeld, stable, Christophe Leroy

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 for each of the three platforms that have an
RNG. This commit also removes some noisy log messages that don't add
much.

Cc: stable@vger.kernel.org
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Fixes: a4da0d50b2a0 ("powerpc: Implement arch_get_random_long/int() for powernv")
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/powerpc/platforms/powernv/rng.c   | 17 ++++-------------
 arch/powerpc/platforms/powernv/setup.c |  4 ++++
 2 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/rng.c b/arch/powerpc/platforms/powernv/rng.c
index e3d44b36ae98..ef24e72a1b69 100644
--- a/arch/powerpc/platforms/powernv/rng.c
+++ b/arch/powerpc/platforms/powernv/rng.c
@@ -84,24 +84,20 @@ static int powernv_get_random_darn(unsigned long *v)
 	return 1;
 }
 
-static int __init initialise_darn(void)
+static void __init initialise_darn(void)
 {
 	unsigned long val;
 	int i;
 
 	if (!cpu_has_feature(CPU_FTR_ARCH_300))
-		return -ENODEV;
+		return;
 
 	for (i = 0; i < 10; i++) {
 		if (powernv_get_random_darn(&val)) {
 			ppc_md.get_random_seed = powernv_get_random_darn;
-			return 0;
+			return;
 		}
 	}
-
-	pr_warn("Unable to use DARN for get_random_seed()\n");
-
-	return -EIO;
 }
 
 int powernv_get_random_long(unsigned long *v)
@@ -163,14 +159,12 @@ static __init int rng_create(struct device_node *dn)
 
 	rng_init_per_cpu(rng, dn);
 
-	pr_info_once("Registering arch random hook.\n");
-
 	ppc_md.get_random_seed = powernv_get_random_long;
 
 	return 0;
 }
 
-static __init int rng_init(void)
+__init void powernv_rng_init(void)
 {
 	struct device_node *dn;
 	int rc;
@@ -188,7 +182,4 @@ static __init int rng_init(void)
 	}
 
 	initialise_darn();
-
-	return 0;
 }
-machine_subsys_initcall(powernv, rng_init);
diff --git a/arch/powerpc/platforms/powernv/setup.c b/arch/powerpc/platforms/powernv/setup.c
index 824c3ad7a0fa..a0c5217bc5c0 100644
--- a/arch/powerpc/platforms/powernv/setup.c
+++ b/arch/powerpc/platforms/powernv/setup.c
@@ -184,6 +184,8 @@ static void __init pnv_check_guarded_cores(void)
 	}
 }
 
+__init void powernv_rng_init(void);
+
 static void __init pnv_setup_arch(void)
 {
 	set_arch_panic_timeout(10, ARCH_PANIC_TIMEOUT);
@@ -203,6 +205,8 @@ static void __init pnv_setup_arch(void)
 	pnv_check_guarded_cores();
 
 	/* XXX PMCS */
+
+	powernv_rng_init();
 }
 
 static void __init pnv_init(void)
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 3/3] powerpc/pseries: wire up rng during setup_arch
  2022-06-11 10:04 [PATCH v2 0/3] powerpc: wire up rng during setup_arch Jason A. Donenfeld
  2022-06-11 10:04 ` [PATCH v2 1/3] powerpc/microwatt: " Jason A. Donenfeld
  2022-06-11 10:04 ` [PATCH v2 2/3] powerpc/powernv: " Jason A. Donenfeld
@ 2022-06-11 10:04 ` Jason A. Donenfeld
  2022-06-11 14:45   ` Christophe Leroy
  2 siblings, 1 reply; 13+ messages in thread
From: Jason A. Donenfeld @ 2022-06-11 10:04 UTC (permalink / raw)
  To: linuxppc-dev, linux-kernel, Michael Ellerman
  Cc: Jason A. Donenfeld, stable, Christophe Leroy

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 for each of the three platforms that have an
RNG. This commit also removes some noisy log messages that don't add
much.

Cc: stable@vger.kernel.org
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Fixes: a489043f4626 ("powerpc/pseries: Implement arch_get_random_long() based on H_RANDOM")
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/powerpc/platforms/pseries/rng.c   | 11 ++---------
 arch/powerpc/platforms/pseries/setup.c |  3 +++
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/rng.c b/arch/powerpc/platforms/pseries/rng.c
index 6268545947b8..d39bfce39aa1 100644
--- a/arch/powerpc/platforms/pseries/rng.c
+++ b/arch/powerpc/platforms/pseries/rng.c
@@ -24,19 +24,12 @@ static int pseries_get_random_long(unsigned long *v)
 	return 0;
 }
 
-static __init int rng_init(void)
+__init void pseries_rng_init(void)
 {
 	struct device_node *dn;
-
 	dn = of_find_compatible_node(NULL, NULL, "ibm,random");
 	if (!dn)
-		return -ENODEV;
-
-	pr_info("Registering arch random hook.\n");
-
+		return;
 	ppc_md.get_random_seed = pseries_get_random_long;
-
 	of_node_put(dn);
-	return 0;
 }
-machine_subsys_initcall(pseries, rng_init);
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index afb074269b42..7f3ee2658163 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -779,6 +779,8 @@ static resource_size_t pseries_pci_iov_resource_alignment(struct pci_dev *pdev,
 }
 #endif
 
+__init void pseries_rng_init(void);
+
 static void __init pSeries_setup_arch(void)
 {
 	set_arch_panic_timeout(10, ARCH_PANIC_TIMEOUT);
@@ -839,6 +841,7 @@ static void __init pSeries_setup_arch(void)
 	}
 
 	ppc_md.pcibios_root_bridge_prepare = pseries_root_bridge_prepare;
+	pseries_rng_init();
 }
 
 static void pseries_panic(char *str)
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 1/3] powerpc/microwatt: wire up rng during setup_arch
  2022-06-11 10:04 ` [PATCH v2 1/3] powerpc/microwatt: " Jason A. Donenfeld
@ 2022-06-11 14:40   ` Christophe Leroy
  2022-06-11 14:41     ` Jason A. Donenfeld
  0 siblings, 1 reply; 13+ messages in thread
From: Christophe Leroy @ 2022-06-11 14:40 UTC (permalink / raw)
  To: Jason A. Donenfeld, linuxppc-dev, linux-kernel, Michael Ellerman; +Cc: stable



Le 11/06/2022 à 12:04, Jason A. Donenfeld a écrit :
> 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 for each of the three platforms that have an
> RNG. This commit also removes some noisy log messages that don't add
> much.
> 
> Cc: stable@vger.kernel.org
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
> Fixes: c25769fddaec ("powerpc/microwatt: Add support for hardware random number generator")
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
> ---
>   arch/powerpc/platforms/microwatt/rng.c   | 9 ++-------
>   arch/powerpc/platforms/microwatt/setup.c | 8 ++++++++
>   2 files changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/microwatt/rng.c b/arch/powerpc/platforms/microwatt/rng.c
> index 7bc4d1cbfaf0..d13f656910ad 100644
> --- a/arch/powerpc/platforms/microwatt/rng.c
> +++ b/arch/powerpc/platforms/microwatt/rng.c
> @@ -29,7 +29,7 @@ static int microwatt_get_random_darn(unsigned long *v)
>   	return 1;
>   }
>   
> -static __init int rng_init(void)
> +__init void microwatt_rng_init(void)
>   {
>   	unsigned long val;
>   	int i;
> @@ -37,12 +37,7 @@ static __init int rng_init(void)
>   	for (i = 0; i < 10; i++) {
>   		if (microwatt_get_random_darn(&val)) {
>   			ppc_md.get_random_seed = microwatt_get_random_darn;
> -			return 0;
> +			return;
>   		}
>   	}
> -
> -	pr_warn("Unable to use DARN for get_random_seed()\n");
> -
> -	return -EIO;
>   }
> -machine_subsys_initcall(, rng_init);
> diff --git a/arch/powerpc/platforms/microwatt/setup.c b/arch/powerpc/platforms/microwatt/setup.c
> index 0b02603bdb74..23c996dcc870 100644
> --- a/arch/powerpc/platforms/microwatt/setup.c
> +++ b/arch/powerpc/platforms/microwatt/setup.c
> @@ -32,10 +32,18 @@ static int __init microwatt_populate(void)
>   }
>   machine_arch_initcall(microwatt, microwatt_populate);
>   
> +__init void microwatt_rng_init(void);

This prototype should be declared in a header file, for instance asm/setup.h

checkpatch.pl returns the following warning:

WARNING:AVOID_EXTERNS: externs should be avoided in .c files
#59: FILE: arch/powerpc/platforms/microwatt/setup.c:35:
+__init void microwatt_rng_init(void);

And I think the __init keyword usually goes after the type, so should be 
'void __init'.

> +
> +static void __init microwatt_setup_arch(void)
> +{
> +	microwatt_rng_init();
> +}
> +
>   define_machine(microwatt) {
>   	.name			= "microwatt",
>   	.probe			= microwatt_probe,
>   	.init_IRQ		= microwatt_init_IRQ,
> +	.setup_arch		= microwatt_setup_arch,
>   	.progress		= udbg_progress,
>   	.calibrate_decr		= generic_calibrate_decr,
>   };

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 1/3] powerpc/microwatt: wire up rng during setup_arch
  2022-06-11 14:40   ` Christophe Leroy
@ 2022-06-11 14:41     ` Jason A. Donenfeld
  2022-06-11 14:46       ` Jason A. Donenfeld
  0 siblings, 1 reply; 13+ messages in thread
From: Jason A. Donenfeld @ 2022-06-11 14:41 UTC (permalink / raw)
  To: Christophe Leroy; +Cc: linuxppc-dev, linux-kernel, Michael Ellerman, stable

Hi Christophe,

On Sat, Jun 11, 2022 at 4:40 PM Christophe Leroy
<christophe.leroy@csgroup.eu> wrote:
> >
> > +__init void microwatt_rng_init(void);
>
> This prototype should be declared in a header file, for instance asm/setup.h

Alright.

> And I think the __init keyword usually goes after the type, so should be
> 'void __init'.

Indeed I thought so too. It just wasn't like this before, but that
doesn't mean I shouldn't fix it.

v3 coming right up.

Jason

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 2/3] powerpc/powernv: wire up rng during setup_arch
  2022-06-11 10:04 ` [PATCH v2 2/3] powerpc/powernv: " Jason A. Donenfeld
@ 2022-06-11 14:42   ` Christophe Leroy
  2022-06-11 14:47     ` Jason A. Donenfeld
  0 siblings, 1 reply; 13+ messages in thread
From: Christophe Leroy @ 2022-06-11 14:42 UTC (permalink / raw)
  To: Jason A. Donenfeld, linuxppc-dev, linux-kernel, Michael Ellerman; +Cc: stable



Le 11/06/2022 à 12:04, Jason A. Donenfeld a écrit :
> 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 for each of the three platforms that have an
> RNG. This commit also removes some noisy log messages that don't add
> much.
> 
> Cc: stable@vger.kernel.org
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
> Fixes: a4da0d50b2a0 ("powerpc: Implement arch_get_random_long/int() for powernv")
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
> ---
>   arch/powerpc/platforms/powernv/rng.c   | 17 ++++-------------
>   arch/powerpc/platforms/powernv/setup.c |  4 ++++
>   2 files changed, 8 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/powernv/rng.c b/arch/powerpc/platforms/powernv/rng.c
> index e3d44b36ae98..ef24e72a1b69 100644
> --- a/arch/powerpc/platforms/powernv/rng.c
> +++ b/arch/powerpc/platforms/powernv/rng.c
> @@ -84,24 +84,20 @@ static int powernv_get_random_darn(unsigned long *v)
>   	return 1;
>   }
>   
> -static int __init initialise_darn(void)
> +static void __init initialise_darn(void)
>   {
>   	unsigned long val;
>   	int i;
>   
>   	if (!cpu_has_feature(CPU_FTR_ARCH_300))
> -		return -ENODEV;
> +		return;
>   
>   	for (i = 0; i < 10; i++) {
>   		if (powernv_get_random_darn(&val)) {
>   			ppc_md.get_random_seed = powernv_get_random_darn;
> -			return 0;
> +			return;
>   		}
>   	}
> -
> -	pr_warn("Unable to use DARN for get_random_seed()\n");
> -
> -	return -EIO;
>   }
>   
>   int powernv_get_random_long(unsigned long *v)
> @@ -163,14 +159,12 @@ static __init int rng_create(struct device_node *dn)
>   
>   	rng_init_per_cpu(rng, dn);
>   
> -	pr_info_once("Registering arch random hook.\n");
> -
>   	ppc_md.get_random_seed = powernv_get_random_long;
>   
>   	return 0;
>   }
>   
> -static __init int rng_init(void)
> +__init void powernv_rng_init(void)
>   {
>   	struct device_node *dn;
>   	int rc;
> @@ -188,7 +182,4 @@ static __init int rng_init(void)
>   	}
>   
>   	initialise_darn();
> -
> -	return 0;
>   }
> -machine_subsys_initcall(powernv, rng_init);
> diff --git a/arch/powerpc/platforms/powernv/setup.c b/arch/powerpc/platforms/powernv/setup.c
> index 824c3ad7a0fa..a0c5217bc5c0 100644
> --- a/arch/powerpc/platforms/powernv/setup.c
> +++ b/arch/powerpc/platforms/powernv/setup.c
> @@ -184,6 +184,8 @@ static void __init pnv_check_guarded_cores(void)
>   	}
>   }
>   
> +__init void powernv_rng_init(void);
> +

Same here, the prototype should go in a header file., should be 'void 
__init' (and indeed the __init is pointless in the prototype, only 
matters in the function definition).

Maybe the name should be pnv_rng_init() like the setup arch below.

>   static void __init pnv_setup_arch(void)
>   {
>   	set_arch_panic_timeout(10, ARCH_PANIC_TIMEOUT);
> @@ -203,6 +205,8 @@ static void __init pnv_setup_arch(void)
>   	pnv_check_guarded_cores();
>   
>   	/* XXX PMCS */
> +
> +	powernv_rng_init();
>   }
>   
>   static void __init pnv_init(void)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 3/3] powerpc/pseries: wire up rng during setup_arch
  2022-06-11 10:04 ` [PATCH v2 3/3] powerpc/pseries: " Jason A. Donenfeld
@ 2022-06-11 14:45   ` Christophe Leroy
  2022-06-11 14:53     ` Jason A. Donenfeld
  0 siblings, 1 reply; 13+ messages in thread
From: Christophe Leroy @ 2022-06-11 14:45 UTC (permalink / raw)
  To: Jason A. Donenfeld, linuxppc-dev, linux-kernel, Michael Ellerman; +Cc: stable



Le 11/06/2022 à 12:04, Jason A. Donenfeld a écrit :
> 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 for each of the three platforms that have an
> RNG. This commit also removes some noisy log messages that don't add
> much.
> 
> Cc: stable@vger.kernel.org
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
> Fixes: a489043f4626 ("powerpc/pseries: Implement arch_get_random_long() based on H_RANDOM")
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
> ---
>   arch/powerpc/platforms/pseries/rng.c   | 11 ++---------
>   arch/powerpc/platforms/pseries/setup.c |  3 +++
>   2 files changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/pseries/rng.c b/arch/powerpc/platforms/pseries/rng.c
> index 6268545947b8..d39bfce39aa1 100644
> --- a/arch/powerpc/platforms/pseries/rng.c
> +++ b/arch/powerpc/platforms/pseries/rng.c
> @@ -24,19 +24,12 @@ static int pseries_get_random_long(unsigned long *v)
>   	return 0;
>   }
>   
> -static __init int rng_init(void)
> +__init void pseries_rng_init(void)
>   {
>   	struct device_node *dn;
> -

There must be a empty line between declarations and code.

>   	dn = of_find_compatible_node(NULL, NULL, "ibm,random");
>   	if (!dn)
> -		return -ENODEV;
> -
> -	pr_info("Registering arch random hook.\n");
> -
> +		return;
>   	ppc_md.get_random_seed = pseries_get_random_long;
> -
>   	of_node_put(dn);
> -	return 0;
>   }
> -machine_subsys_initcall(pseries, rng_init);
> diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
> index afb074269b42..7f3ee2658163 100644
> --- a/arch/powerpc/platforms/pseries/setup.c
> +++ b/arch/powerpc/platforms/pseries/setup.c
> @@ -779,6 +779,8 @@ static resource_size_t pseries_pci_iov_resource_alignment(struct pci_dev *pdev,
>   }
>   #endif
>   
> +__init void pseries_rng_init(void);
> +

Prototype has to go in a header file, and should be pSeries maybe 
allthough camelCase in throw up on.

>   static void __init pSeries_setup_arch(void)
>   {
>   	set_arch_panic_timeout(10, ARCH_PANIC_TIMEOUT);
> @@ -839,6 +841,7 @@ static void __init pSeries_setup_arch(void)
>   	}
>   
>   	ppc_md.pcibios_root_bridge_prepare = pseries_root_bridge_prepare;
> +	pseries_rng_init();
>   }
>   
>   static void pseries_panic(char *str)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 1/3] powerpc/microwatt: wire up rng during setup_arch
  2022-06-11 14:41     ` Jason A. Donenfeld
@ 2022-06-11 14:46       ` Jason A. Donenfeld
  2022-06-11 14:48         ` Christophe Leroy
  0 siblings, 1 reply; 13+ messages in thread
From: Jason A. Donenfeld @ 2022-06-11 14:46 UTC (permalink / raw)
  To: Christophe Leroy; +Cc: linuxppc-dev, linux-kernel, Michael Ellerman, stable

Hi again,

On Sat, Jun 11, 2022 at 04:41:58PM +0200, Jason A. Donenfeld wrote:
> Hi Christophe,
> 
> On Sat, Jun 11, 2022 at 4:40 PM Christophe Leroy
> <christophe.leroy@csgroup.eu> wrote:
> > >
> > > +__init void microwatt_rng_init(void);
> >
> > This prototype should be declared in a header file, for instance asm/setup.h
> 
> Alright.

Actually, on second thought, I don't think this part is worth doing.
These are per-platform functions, not powerpc-wide.

Jason

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 2/3] powerpc/powernv: wire up rng during setup_arch
  2022-06-11 14:42   ` Christophe Leroy
@ 2022-06-11 14:47     ` Jason A. Donenfeld
  0 siblings, 0 replies; 13+ messages in thread
From: Jason A. Donenfeld @ 2022-06-11 14:47 UTC (permalink / raw)
  To: Christophe Leroy; +Cc: linuxppc-dev, linux-kernel, Michael Ellerman, stable

Hi Christophe,

On Sat, Jun 11, 2022 at 4:42 PM Christophe Leroy
<christophe.leroy@csgroup.eu> wrote:
> Same here, the prototype should go in a header file., should be 'void
> __init' (and indeed the __init is pointless in the prototype, only
> matters in the function definition).

I'll change the order, but I don't see a good place for the prototype
other than the .c file. It's not a big deal to keep it there.

>
> Maybe the name should be pnv_rng_init() like the setup arch below.

All the rng.c files are powernv_ prefixed, not pnv_ prefixed.

Jason

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 1/3] powerpc/microwatt: wire up rng during setup_arch
  2022-06-11 14:46       ` Jason A. Donenfeld
@ 2022-06-11 14:48         ` Christophe Leroy
  2022-06-11 14:53           ` Jason A. Donenfeld
  0 siblings, 1 reply; 13+ messages in thread
From: Christophe Leroy @ 2022-06-11 14:48 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: linuxppc-dev, linux-kernel, Michael Ellerman, stable



Le 11/06/2022 à 16:46, Jason A. Donenfeld a écrit :
> Hi again,
> 
> On Sat, Jun 11, 2022 at 04:41:58PM +0200, Jason A. Donenfeld wrote:
>> Hi Christophe,
>>
>> On Sat, Jun 11, 2022 at 4:40 PM Christophe Leroy
>> <christophe.leroy@csgroup.eu> wrote:
>>>>
>>>> +__init void microwatt_rng_init(void);
>>>
>>> This prototype should be declared in a header file, for instance asm/setup.h
>>
>> Alright.
> 
> Actually, on second thought, I don't think this part is worth doing.
> These are per-platform functions, not powerpc-wide.
> 

Then you have:

arch/powerpc/platforms/powernv/powernv.h
arch/powerpc/platforms/pseries/pseries.h

and you can add

arch/powerpc/platforms/microwatt/microwatt.h

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 3/3] powerpc/pseries: wire up rng during setup_arch
  2022-06-11 14:45   ` Christophe Leroy
@ 2022-06-11 14:53     ` Jason A. Donenfeld
  0 siblings, 0 replies; 13+ messages in thread
From: Jason A. Donenfeld @ 2022-06-11 14:53 UTC (permalink / raw)
  To: Christophe Leroy; +Cc: linuxppc-dev, linux-kernel, Michael Ellerman, stable

Hi Christophe,

On Sat, Jun 11, 2022 at 4:45 PM Christophe Leroy
<christophe.leroy@csgroup.eu> wrote:
>
> There must be a empty line between declarations and code.

Ack.

> Prototype has to go in a header file

Already voiced disagreement about this in the other thread.

> and should be pSeries maybe
> allthough camelCase in throw up on.

All the rng.c functions use pseries_ in lower case, so I'll stick with
that, as that's where the function is defined.

Jason

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 1/3] powerpc/microwatt: wire up rng during setup_arch
  2022-06-11 14:48         ` Christophe Leroy
@ 2022-06-11 14:53           ` Jason A. Donenfeld
  0 siblings, 0 replies; 13+ messages in thread
From: Jason A. Donenfeld @ 2022-06-11 14:53 UTC (permalink / raw)
  To: Christophe Leroy; +Cc: linuxppc-dev, linux-kernel, Michael Ellerman, stable

Hi Christophe,

On Sat, Jun 11, 2022 at 4:49 PM Christophe Leroy
<christophe.leroy@csgroup.eu> wrote:
> Then you have:
>
> arch/powerpc/platforms/powernv/powernv.h
> arch/powerpc/platforms/pseries/pseries.h
>
> and you can add
>
> arch/powerpc/platforms/microwatt/microwatt.h

Oh, terrific, thanks. I'll do that.

Jason

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-06-11 14:54 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-11 10:04 [PATCH v2 0/3] powerpc: wire up rng during setup_arch Jason A. Donenfeld
2022-06-11 10:04 ` [PATCH v2 1/3] powerpc/microwatt: " Jason A. Donenfeld
2022-06-11 14:40   ` Christophe Leroy
2022-06-11 14:41     ` Jason A. Donenfeld
2022-06-11 14:46       ` Jason A. Donenfeld
2022-06-11 14:48         ` Christophe Leroy
2022-06-11 14:53           ` Jason A. Donenfeld
2022-06-11 10:04 ` [PATCH v2 2/3] powerpc/powernv: " Jason A. Donenfeld
2022-06-11 14:42   ` Christophe Leroy
2022-06-11 14:47     ` Jason A. Donenfeld
2022-06-11 10:04 ` [PATCH v2 3/3] powerpc/pseries: " Jason A. Donenfeld
2022-06-11 14:45   ` Christophe Leroy
2022-06-11 14:53     ` Jason A. Donenfeld

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).