linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Conor Dooley <conor@kernel.org>
To: Jia Jie Ho <jiajie.ho@starfivetech.com>
Cc: Olivia Mackall <olivia@selenic.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Emil Renner Berthing <kernel@esmil.dk>,
	Conor Dooley <conor.dooley@microchip.com>,
	linux-crypto@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org
Subject: Re: [PATCH v4 2/3] hwrng: starfive - Add TRNG driver for StarFive SoC
Date: Thu, 12 Jan 2023 19:16:51 +0000	[thread overview]
Message-ID: <Y8Bco7lBBj7CO9C5@spud> (raw)
In-Reply-To: <20230112043812.150393-3-jiajie.ho@starfivetech.com>

[-- Attachment #1: Type: text/plain, Size: 3486 bytes --]

On Thu, Jan 12, 2023 at 12:38:11PM +0800, Jia Jie Ho wrote:
> This adds driver support for the hardware random number generator in
> Starfive SoCs and adds StarFive TRNG entry to MAINTAINERS.
> 
> Co-developed-by: Jenny Zhang <jenny.zhang@starfivetech.com>
> Signed-off-by: Jenny Zhang <jenny.zhang@starfivetech.com>
> Signed-off-by: Jia Jie Ho <jiajie.ho@starfivetech.com>
> ---
>  MAINTAINERS                            |   6 +
>  drivers/char/hw_random/Kconfig         |  11 +
>  drivers/char/hw_random/Makefile        |   1 +
>  drivers/char/hw_random/starfive-trng.c | 397 +++++++++++++++++++++++++
>  4 files changed, 415 insertions(+)
>  create mode 100644 drivers/char/hw_random/starfive-trng.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 65140500d9f8..b91e3fc11fc6 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -19626,6 +19626,12 @@ F:	drivers/reset/reset-starfive.c
>  F:	include/linux/reset/starfive.h
>  F:	include/dt-bindings/reset/starfive*
>  
> +STARFIVE TRNG DRIVER
> +M:	Jia Jie Ho <jiajie.ho@starfivetech.com>
> +S:	Maintained
> +F:	Documentation/devicetree/bindings/rng/starfive*
> +F:	drivers/char/hw_random/starfive-trng.c

minor nit (so don't submit another version just to fix this):
This should be Supported, no?

> diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile
> index 3e948cf04476..f68ac370847f 100644
> --- a/drivers/char/hw_random/Makefile
> +++ b/drivers/char/hw_random/Makefile
> @@ -47,3 +47,4 @@ obj-$(CONFIG_HW_RANDOM_XIPHERA) += xiphera-trng.o
>  obj-$(CONFIG_HW_RANDOM_ARM_SMCCC_TRNG) += arm_smccc_trng.o
>  obj-$(CONFIG_HW_RANDOM_CN10K) += cn10k-rng.o
>  obj-$(CONFIG_HW_RANDOM_POLARFIRE_SOC) += mpfs-rng.o
> +obj-$(CONFIG_HW_RANDOM_STARFIVE) += starfive-trng.o

Is "STARFIVE" a bit too general of a name here and in the Kconfig entry?
I don't have a TRM for the JH7100, but this name (and the Kconfig text)
would give me the impression that I can use it there too.
Does this driver support both?

> +static int starfive_trng_probe(struct platform_device *pdev)

> +	clk_prepare_enable(trng->hclk);
> +	clk_prepare_enable(trng->ahb);
> +	reset_control_deassert(trng->rst);
> +
> +	trng->rng.name = dev_driver_string(&pdev->dev);
> +	trng->rng.init = starfive_trng_init;
> +	trng->rng.cleanup = starfive_trng_cleanup;
> +	trng->rng.read = starfive_trng_read;
> +
> +	trng->mode = PRNG_256BIT;
> +	trng->mission = 1;
> +	trng->reseed = RANDOM_RESEED;
> +
> +	ret = devm_hwrng_register(&pdev->dev, &trng->rng);
> +	if (ret) {
> +		dev_err_probe(&pdev->dev, ret, "Failed to register hwrng\n");
> +		goto err_fail_register;
> +	}
> +
> +	pm_runtime_use_autosuspend(&pdev->dev);
> +	pm_runtime_set_autosuspend_delay(&pdev->dev, 100);

> +	pm_runtime_enable(&pdev->dev);

> +
> +	return 0;
> +
> +err_fail_register:

> +	pm_runtime_disable(&pdev->dev);

This was only enabled after the only goto for this label, does it
serve a purpose?
I know little about runtime PM, it just caught my eye.
I looked at the other rng drivers that had calls to pm_runtime_enable(),
but they all seem to do their pm enablement _before_ calling
hwrng_register().
Again, I am not familiar with runtime PM, but curious why you are doing
things differently, that's all.

> +
> +	reset_control_assert(trng->rst);
> +	clk_disable_unprepare(trng->ahb);
> +	clk_disable_unprepare(trng->hclk);
> +
> +	return ret;
> +}

Thanks,
Conor.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2023-01-12 19:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-12  4:38 [PATCH v4 0/3] hwrng: starfive: Add driver for TRNG module Jia Jie Ho
2023-01-12  4:38 ` [PATCH v4 1/3] dt-bindings: rng: Add StarFive " Jia Jie Ho
2023-01-12  4:38 ` [PATCH v4 2/3] hwrng: starfive - Add TRNG driver for StarFive SoC Jia Jie Ho
2023-01-12 19:16   ` Conor Dooley [this message]
2023-01-13  2:30     ` JiaJie Ho
2023-01-12  4:38 ` [PATCH v4 3/3] riscv: dts: starfive: Add TRNG node for VisionFive 2 Jia Jie Ho

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=Y8Bco7lBBj7CO9C5@spud \
    --to=conor@kernel.org \
    --cc=conor.dooley@microchip.com \
    --cc=devicetree@vger.kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=jiajie.ho@starfivetech.com \
    --cc=kernel@esmil.dk \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=olivia@selenic.com \
    --cc=robh+dt@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 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).