All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>,
	"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Michael Ellerman <mpe@ellerman.id.au>
Cc: "stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH v3 1/3] powerpc/microwatt: wire up rng during setup_arch
Date: Sat, 11 Jun 2022 16:25:17 +0000	[thread overview]
Message-ID: <709c9859-f8db-6f03-9cf5-50b7442953ae@csgroup.eu> (raw)
In-Reply-To: <20220611151015.548325-2-Jason@zx2c4.com>



Le 11/06/2022 à 17:10, 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. 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>

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>

> ---
>   arch/powerpc/platforms/microwatt/microwatt.h |  7 +++++++
>   arch/powerpc/platforms/microwatt/rng.c       | 10 +++-------
>   arch/powerpc/platforms/microwatt/setup.c     |  8 ++++++++
>   3 files changed, 18 insertions(+), 7 deletions(-)
>   create mode 100644 arch/powerpc/platforms/microwatt/microwatt.h
> 
> diff --git a/arch/powerpc/platforms/microwatt/microwatt.h b/arch/powerpc/platforms/microwatt/microwatt.h
> new file mode 100644
> index 000000000000..335417e95e66
> --- /dev/null
> +++ b/arch/powerpc/platforms/microwatt/microwatt.h
> @@ -0,0 +1,7 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _MICROWATT_H
> +#define _MICROWATT_H
> +
> +void microwatt_rng_init(void);
> +
> +#endif /* _MICROWATT_H */
> diff --git a/arch/powerpc/platforms/microwatt/rng.c b/arch/powerpc/platforms/microwatt/rng.c
> index 7bc4d1cbfaf0..8ece87d005c8 100644
> --- a/arch/powerpc/platforms/microwatt/rng.c
> +++ b/arch/powerpc/platforms/microwatt/rng.c
> @@ -11,6 +11,7 @@
>   #include <asm/archrandom.h>
>   #include <asm/cputable.h>
>   #include <asm/machdep.h>
> +#include "microwatt.h"
>   
>   #define DARN_ERR 0xFFFFFFFFFFFFFFFFul
>   
> @@ -29,7 +30,7 @@ static int microwatt_get_random_darn(unsigned long *v)
>   	return 1;
>   }
>   
> -static __init int rng_init(void)
> +void __init microwatt_rng_init(void)
>   {
>   	unsigned long val;
>   	int i;
> @@ -37,12 +38,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..6b32539395a4 100644
> --- a/arch/powerpc/platforms/microwatt/setup.c
> +++ b/arch/powerpc/platforms/microwatt/setup.c
> @@ -16,6 +16,8 @@
>   #include <asm/xics.h>
>   #include <asm/udbg.h>
>   
> +#include "microwatt.h"
> +
>   static void __init microwatt_init_IRQ(void)
>   {
>   	xics_init();
> @@ -32,10 +34,16 @@ static int __init microwatt_populate(void)
>   }
>   machine_arch_initcall(microwatt, microwatt_populate);
>   
> +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,
>   };

  reply	other threads:[~2022-06-11 16:25 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-11 15:10 [PATCH v3 0/3] powerpc: wire up rng during setup_arch Jason A. Donenfeld
2022-06-11 15:10 ` Jason A. Donenfeld
2022-06-11 15:10 ` [PATCH v3 1/3] powerpc/microwatt: " Jason A. Donenfeld
2022-06-11 15:10   ` Jason A. Donenfeld
2022-06-11 16:25   ` Christophe Leroy [this message]
2022-06-11 15:10 ` [PATCH v3 2/3] powerpc/powernv: " Jason A. Donenfeld
2022-06-11 15:10   ` Jason A. Donenfeld
2022-06-11 16:25   ` Christophe Leroy
2022-06-19 11:49   ` Michael Ellerman
2022-06-19 11:49     ` Michael Ellerman
2022-06-19 20:32     ` Jason A. Donenfeld
2022-06-19 20:32       ` Jason A. Donenfeld
2022-06-20 12:45       ` [PATCH v4] " Jason A. Donenfeld
2022-06-21 14:08         ` [PATCH v5] " Jason A. Donenfeld
2022-06-21 18:33           ` Christophe Leroy
2022-06-21 18:47             ` Jason A. Donenfeld
2022-06-21 18:47               ` Jason A. Donenfeld
2022-06-21 19:22               ` Christophe Leroy
2022-06-21 19:22                 ` Christophe Leroy
2022-06-22  2:27                 ` Michael Ellerman
2022-06-26  0:28           ` Michael Ellerman
2022-06-11 15:10 ` [PATCH v3 3/3] powerpc/pseries: " Jason A. Donenfeld
2022-06-11 15:10   ` Jason A. Donenfeld
2022-06-11 16:25   ` Christophe Leroy
2022-06-19 11:55 ` [PATCH v3 0/3] powerpc: " Michael Ellerman
2022-06-19 11:55   ` Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=709c9859-f8db-6f03-9cf5-50b7442953ae@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=Jason@zx2c4.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.