mbox series

[v3,0/3] Meson S4 HW RNG Support

Message ID 20230911101129.10604-1-avromanov@salutedevices.com
Headers show
Series Meson S4 HW RNG Support | expand

Message

Alexey Romanov Sept. 11, 2023, 10:11 a.m. UTC
Hello!

This patch series adds hwrng support for Amlogic S4-series.
Now, S4 uses a new random number generation algorithm.
This changes implemnents new algo and also adds description
to meson-s4.dtsi.

V2:

- Use readl_relaxed_poll_timeout_atomic() function instead of loop.
- Use two different functions: meson_rng_read() and meson_s4_rng_read().
- Fix naming in DT schema (meson-s4-hwrng instead of meson-hwrng-s4).
- A little code style fixes.

V3:

- Fix commit message in patch with dt-bindings schema changes.

Alexey Romanov (3):
  drivers: rng: meson: add support for S4
  dt-bindings: rng: meson: add meson-rng-s4 compatible
  arch/arm64: dts: meson-s4: add hwrng node

 .../bindings/rng/amlogic,meson-rng.yaml       |  1 +
 arch/arm64/boot/dts/amlogic/meson-s4.dtsi     |  5 ++
 drivers/char/hw_random/meson-rng.c            | 80 ++++++++++++++++++-
 3 files changed, 83 insertions(+), 3 deletions(-)

Comments

Neil Armstrong Sept. 11, 2023, 10:33 a.m. UTC | #1
On 11/09/2023 12:11, Alexey Romanov wrote:
> From: Alexey Romanov <avromanov@sberdevices.ru>
> 
> Using this node, we can obtain random numbers via
> hardware random number generator.
> 
> Signed-off-by: Alexey Romanov <avromanov@sberdevices.ru>
> ---
>   arch/arm64/boot/dts/amlogic/meson-s4.dtsi | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/amlogic/meson-s4.dtsi b/arch/arm64/boot/dts/amlogic/meson-s4.dtsi
> index f24460186d3d..b3a1ecf36467 100644
> --- a/arch/arm64/boot/dts/amlogic/meson-s4.dtsi
> +++ b/arch/arm64/boot/dts/amlogic/meson-s4.dtsi
> @@ -133,6 +133,11 @@ reset: reset-controller@2000 {
>   				reg = <0x0 0x2000 0x0 0x98>;
>   				#reset-cells = <1>;
>   			};
> +
> +			hwrng: rng@440788 {
> +				compatible = "amlogic,meson-s4-rng";
> +				reg = <0x0 0x440788 0x0 0x0c>;
> +			};
>   		};
>   	};
>   };

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Herbert Xu Sept. 20, 2023, 4:55 a.m. UTC | #2
On Mon, Sep 11, 2023 at 01:11:27PM +0300, Alexey Romanov wrote:
>
> +struct meson_rng_priv {
> +	int (*read)(struct hwrng *rng, void *buf, size_t max, bool wait);
> +};
>  
>  struct meson_rng_data {
>  	void __iomem *base;
>  	struct hwrng rng;
> +	struct device *dev;
> +	const struct meson_rng_priv *priv;
>  };

Is data->priv really necessary? It doesn't seem to be used anywhere
after the probe.

Thanks,
Alexey Romanov Sept. 22, 2023, 8:15 a.m. UTC | #3
Hi Herbert,

On Wed, Sep 20, 2023 at 12:55:33PM +0800, Herbert Xu wrote:
> On Mon, Sep 11, 2023 at 01:11:27PM +0300, Alexey Romanov wrote:
> >
> > +struct meson_rng_priv {
> > +	int (*read)(struct hwrng *rng, void *buf, size_t max, bool wait);
> > +};
> >  
> >  struct meson_rng_data {
> >  	void __iomem *base;
> >  	struct hwrng rng;
> > +	struct device *dev;
> > +	const struct meson_rng_priv *priv;
> >  };
> 
> Is data->priv really necessary? It doesn't seem to be used anywhere
> after the probe.
> 

Are you suggesting remove meson_rng_priv and putting a pointer to read
function in meson_rng_data?


> Thanks,
> -- 
> Email: Herbert Xu <herbert@gondor.apana.org.au>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Herbert Xu Sept. 26, 2023, 3:15 a.m. UTC | #4
On Fri, Sep 22, 2023 at 08:15:27AM +0000, Alexey Romanov wrote:
>
> Are you suggesting remove meson_rng_priv and putting a pointer to read
> function in meson_rng_data?

I just thought it was weird that you assign meson_rng_data->priv
and then never use it anywhere else in the driver.  Did I miss
something?

Cheers,