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>,
Marek Szyprowski <m.szyprowski@samsung.com>
Subject: Re: [PATCH 1/3] crypto: hw_random - Add new Exynos RNG driver
Date: Fri, 24 Mar 2017 17:11:25 +0100 [thread overview]
Message-ID: <9265537.P6AeF50kg8@amdc3058> (raw)
In-Reply-To: <20170324154600.lavc22dbw7rtioli@kozik-lap>
On Friday, March 24, 2017 06:46:00 PM Krzysztof Kozlowski wrote:
> On Fri, Mar 24, 2017 at 04:26:47PM +0100, Bartlomiej Zolnierkiewicz wrote:
> >
> > 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. ]
>
> I agree that we loose the "burst" mode but:
> 1. At least on Exynso4 SSS is part of TOP power domain so it will not
> help to reduce any more power consumption (on Exynos5422 it is
> mentioned in G2D... which seems incorrect).
> 2. I think the overhead of clk operations is much smaller. These are only
> two locks (prepare mutex + enable spin), simple tree traversal and
> play with few SFRs.
>
> The power domain code in comparison to that is huge and complicated
> with inter-device links and dependencies. Also the actual runtime PM
> suspend would anyway fall back at then end to clk prepare/enable
> locks and paths.
>
> We've been talking about this a lot with Marek Szyprowski (cc'ed) and
> he was always (AFAIR) against attempts of runtime power
> management of a single clock...
OK, thanks for explanation.
> > > +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.
>
> I really do not like global or file-scope variables. I do not like
> drivers using them. Actually I hate them.
>
> From time to time I encounter a driver which was designed with that
> approach - static fields and hidden assumption that there will be only
> one instance. Usually that assumption is really hidden...
>
> ... and then it happens that I want to use two instances which of course
> fails.
>
> This code serves as a clear documentation for this assumption - only one
> instance is allowed. You can look at it as a self-documenting
> requirement.
For me it looks as needless case of defensive programming and when
I see the code like this it always raises questions about the real
intentions of the code. I find it puzzling and not helpful.
> And I think the probe might be called twice, for example in case of
> mistake in DTB.
Even if this is possible resource allocation code in the driver will
take take care of handling it just fine,
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
next prev parent reply other threads:[~2017-03-24 16:12 UTC|newest]
Thread overview: 16+ 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 ` [PATCH 1/3] " Krzysztof Kozlowski
2017-03-24 14:37 ` Stephan Müller
2017-03-24 14:43 ` Krzysztof Kozlowski
2017-03-24 14:46 ` Stephan Müller
2017-03-24 14:51 ` Krzysztof Kozlowski
2017-03-24 14:55 ` Stephan Müller
2017-03-24 14:58 ` Krzysztof Kozlowski
2017-03-24 15:26 ` Bartlomiej Zolnierkiewicz
2017-03-24 15:46 ` Krzysztof Kozlowski
2017-03-24 16:11 ` Bartlomiej Zolnierkiewicz [this message]
2017-03-24 16:19 ` Krzysztof Kozlowski
2017-03-24 16:45 ` Bartlomiej Zolnierkiewicz
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 ` [PATCH 3/3] ARM: multi_v7_defconfig: " 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=9265537.P6AeF50kg8@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=m.szyprowski@samsung.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox