All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
To: Krzysztof Kozlowski <krzk@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org,
	Kukjin Kim <kgene@kernel.org>,
	Javier Martinez Canillas <javier@osg.samsung.com>,
	Matt Mackall <mpm@selenic.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
	linux-crypto@vger.kernel.org, Olof Johansson <olof@lixom.net>,
	Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH 1/3] crypto: hw_random - Add new Exynos RNG driver
Date: Fri, 24 Mar 2017 16:26:47 +0100	[thread overview]
Message-ID: <3940941.n3qdgn1RbN@amdc3058> (raw)
In-Reply-To: <20170324142446.31129-2-krzk@kernel.org>


Hi,

Firstly, thanks for working on this.

The patch looks fine overall for me, some review comments below.

On Friday, March 24, 2017 05:24:44 PM Krzysztof Kozlowski wrote:
> Replace existing hw_ranndom/exynos-rng driver with a new, reworked one.
> This is a driver for pseudo random number generator block which on
> Exynos4 chipsets must be seeded with some value.  On newer Exynos5420
> chipsets it might seed itself from true random number generator block
> but this is not implemented yet.
> 
> New driver is a complete rework to use the crypto ALGAPI instead of
> hw_random API.  Rationale for the change:
> 1. hw_random interface is for true RNG devices.
> 2. The old driver was seeding itself with jiffies which is not a
>    reliable source for randomness.
> 3. Device generates five random numbers in each pass but old driver was
>    returning only one thus its performance was reduced.
> 
> Compatibility with DeviceTree bindings is preserved.
> 
> New driver does not use runtime power management but manually enables
> and disables the clock when needed.  This is preferred approach because
> using runtime PM just to toggle clock is huge overhead.  Another

I'm not entirely convinced that the new approach is better.

With the old approach exynos_rng_generate() can be called more
than once before PM autosuspend kicks in and thus clk_prepare_enable()/
clk_disable()_unprepare() operations will be done only once. This
would give better performance on the "burst" operations.

[ The above assumes that clock operations are more costly than
  going through PM core to check the current device state. ]

> +static int exynos_rng_get_random(struct exynos_rng_dev *rng,
> +				 u8 *dst, unsigned int dlen,
> +				 unsigned int *read)
> +{
> +	int retry = 100;

I know that this is copied verbatim from the old driver but please
use define for the maximum number of retries.

> +static int exynos_rng_probe(struct platform_device *pdev)
> +{
> +	struct exynos_rng_dev *rng;
> +	struct resource *res;
> +	int ret;
> +
> +	if (exynos_rng_dev)
> +		return -EEXIST;

How this condition could ever happen? 

The probe function will never be called twice.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

WARNING: multiple messages have this Message-ID (diff)
From: b.zolnierkie@samsung.com (Bartlomiej Zolnierkiewicz)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/3] crypto: hw_random - Add new Exynos RNG driver
Date: Fri, 24 Mar 2017 16:26:47 +0100	[thread overview]
Message-ID: <3940941.n3qdgn1RbN@amdc3058> (raw)
In-Reply-To: <20170324142446.31129-2-krzk@kernel.org>


Hi,

Firstly, thanks for working on this.

The patch looks fine overall for me, some review comments below.

On Friday, March 24, 2017 05:24:44 PM Krzysztof Kozlowski wrote:
> Replace existing hw_ranndom/exynos-rng driver with a new, reworked one.
> This is a driver for pseudo random number generator block which on
> Exynos4 chipsets must be seeded with some value.  On newer Exynos5420
> chipsets it might seed itself from true random number generator block
> but this is not implemented yet.
> 
> New driver is a complete rework to use the crypto ALGAPI instead of
> hw_random API.  Rationale for the change:
> 1. hw_random interface is for true RNG devices.
> 2. The old driver was seeding itself with jiffies which is not a
>    reliable source for randomness.
> 3. Device generates five random numbers in each pass but old driver was
>    returning only one thus its performance was reduced.
> 
> Compatibility with DeviceTree bindings is preserved.
> 
> New driver does not use runtime power management but manually enables
> and disables the clock when needed.  This is preferred approach because
> using runtime PM just to toggle clock is huge overhead.  Another

I'm not entirely convinced that the new approach is better.

With the old approach exynos_rng_generate() can be called more
than once before PM autosuspend kicks in and thus clk_prepare_enable()/
clk_disable()_unprepare() operations will be done only once. This
would give better performance on the "burst" operations.

[ The above assumes that clock operations are more costly than
  going through PM core to check the current device state. ]

> +static int exynos_rng_get_random(struct exynos_rng_dev *rng,
> +				 u8 *dst, unsigned int dlen,
> +				 unsigned int *read)
> +{
> +	int retry = 100;

I know that this is copied verbatim from the old driver but please
use define for the maximum number of retries.

> +static int exynos_rng_probe(struct platform_device *pdev)
> +{
> +	struct exynos_rng_dev *rng;
> +	struct resource *res;
> +	int ret;
> +
> +	if (exynos_rng_dev)
> +		return -EEXIST;

How this condition could ever happen? 

The probe function will never be called twice.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

  parent reply	other threads:[~2017-03-24 15:26 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-24 14:24 [PATCH 0/3] crypto: hw_random - Add new Exynos RNG driver Krzysztof Kozlowski
2017-03-24 14:24 ` Krzysztof Kozlowski
2017-03-24 14:24 ` [PATCH 1/3] " Krzysztof Kozlowski
2017-03-24 14:24   ` Krzysztof Kozlowski
2017-03-24 14:37   ` Stephan Müller
2017-03-24 14:37     ` Stephan Müller
2017-03-24 14:43     ` Krzysztof Kozlowski
2017-03-24 14:43       ` Krzysztof Kozlowski
2017-03-24 14:46       ` Stephan Müller
2017-03-24 14:46         ` Stephan Müller
2017-03-24 14:46         ` Stephan Müller
2017-03-24 14:51         ` Krzysztof Kozlowski
2017-03-24 14:51           ` Krzysztof Kozlowski
2017-03-24 14:55           ` Stephan Müller
2017-03-24 14:55             ` Stephan Müller
2017-03-24 14:58             ` Krzysztof Kozlowski
2017-03-24 14:58               ` Krzysztof Kozlowski
2017-03-24 15:26   ` Bartlomiej Zolnierkiewicz [this message]
2017-03-24 15:26     ` Bartlomiej Zolnierkiewicz
2017-03-24 15:46     ` Krzysztof Kozlowski
2017-03-24 15:46       ` Krzysztof Kozlowski
2017-03-24 16:11       ` Bartlomiej Zolnierkiewicz
2017-03-24 16:11         ` Bartlomiej Zolnierkiewicz
2017-03-24 16:11         ` Bartlomiej Zolnierkiewicz
2017-03-24 16:19         ` Krzysztof Kozlowski
2017-03-24 16:19           ` Krzysztof Kozlowski
2017-03-24 16:45           ` Bartlomiej Zolnierkiewicz
2017-03-24 16:45             ` Bartlomiej Zolnierkiewicz
2017-03-24 17:01             ` Krzysztof Kozlowski
2017-03-24 17:01               ` Krzysztof Kozlowski
2017-03-24 17:01               ` Krzysztof Kozlowski
2017-03-24 14:24 ` [PATCH 2/3] ARM: exynos_defconfig: Enable Exynos RNG and user-space crypto API Krzysztof Kozlowski
2017-03-24 14:24   ` Krzysztof Kozlowski
2017-03-24 14:24 ` [PATCH 3/3] ARM: multi_v7_defconfig: " Krzysztof Kozlowski
2017-03-24 14:24   ` Krzysztof Kozlowski

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=3940941.n3qdgn1RbN@amdc3058 \
    --to=b.zolnierkie@samsung.com \
    --cc=arnd@arndb.de \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=javier@osg.samsung.com \
    --cc=kgene@kernel.org \
    --cc=krzk@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=mpm@selenic.com \
    --cc=olof@lixom.net \
    /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.