linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Thompson <daniel.thompson@linaro.org>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Lee Jones <lee.jones@linaro.org>, Matt Mackall <mpm@selenic.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Patch Tracking <patches@linaro.org>,
	Linaro Kernel Mailman List <linaro-kernel@lists.linaro.org>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>
Subject: Re: [PATCH 2/3] hwrng: stm32 - add support for STM32 HW RNG
Date: Sun, 11 Oct 2015 20:24:08 +0100	[thread overview]
Message-ID: <CAMTL27EoZRFBk+A5TA-knpmRoaqfyDD=L=+yqEXYX=ntR46xkw@mail.gmail.com> (raw)
In-Reply-To: <CAMTL27G9j8tR4WKQgj6HbVCTd-5Xx0HYs40Rij91GgT4D8PevA@mail.gmail.com>

On 5 October 2015 at 10:22, Daniel Thompson <daniel.thompson@linaro.org> wrote:
> On 4 October 2015 at 11:32, Linus Walleij <linus.walleij@linaro.org> wrote:
>> On Sat, Oct 3, 2015 at 10:35 PM, Daniel Thompson
>> <daniel.thompson@linaro.org> wrote:
>> Then this construct:
>>
>>> +static int stm32_rng_read(struct hwrng *rng, void *data, size_t max, bool wait)
>>> +{
>> (...)
>>> + /* enable random number generation */
>>> + clk_enable(priv->clk);
>>> + cr = readl(priv->base + RNG_CR);
>>> + writel(cr | RNG_CR_RNGEN, priv->base + RNG_CR);
>> (...)
>>> + /* disable the generator */
>>> + writel(cr, priv->base + RNG_CR);
>>> + clk_disable(priv->clk);
>>
>> This is in the hotpath where megabytes of data may be read out
>> by consecutive reads. I think it's wise to move the clock enable/disable
>> and also the write to cr to enable/disable the block to runtime PM
>> hooks, so that you can e.g. set some hysteresis around the disablement
>> with pm_runtime_set_autosuspend_delay(&dev->dev, 50);
>> pm_runtime_use_autosuspend(&dev->dev);pm_runtime_put_autosuspend().
>> For a primecell check the usage in drivers/mmc/host/mmci.c
>> for a complex usecase or e.g. drivers/hwtracing/coresight/coresight-tpiu.c
>> for a simpler usecase.
>>
>> For the performance hints I guess you can even test whether
>> what I'm saying makes sense or not by reading some megabytes
>> of random and timing it.
>
> I'll have to benchmark this. clk_enable/disable have pretty simple
> implementations on STM32 so there might not be much in it.

Well... I was extremely wrong about that!

Switching the driver over to autosuspend yielded a very significant
performance boost: ~1.1MiB/s to ~1.5MiB/s .

Very pleased with that!


Daniel.

  parent reply	other threads:[~2015-10-11 19:24 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-03 20:35 [PATCH 0/3] hwrng: stm32 - add support for STM32 HW RNG Daniel Thompson
2015-10-03 20:35 ` [PATCH 1/3] dt-bindings: Document the STM32 HW RNG bindings Daniel Thompson
2015-10-04  8:27   ` Maxime Coquelin
2015-10-05 15:34   ` Rob Herring
2015-10-03 20:35 ` [PATCH 2/3] hwrng: stm32 - add support for STM32 HW RNG Daniel Thompson
2015-10-03 21:02   ` [PATCH] hwrng: fix simple_return.cocci warnings kbuild test robot
2015-10-03 21:02   ` [PATCH 2/3] hwrng: stm32 - add support for STM32 HW RNG kbuild test robot
2015-10-04  8:52   ` Maxime Coquelin
2015-10-05  9:26     ` Daniel Thompson
2015-10-04 10:32   ` Linus Walleij
2015-10-05  9:22     ` Daniel Thompson
2015-10-11 19:15       ` Daniel Thompson
2015-10-11 19:24       ` Daniel Thompson [this message]
2015-10-03 20:35 ` [PATCH 3/3] ARM: dts: stm32f429: Adopt STM32 RNG driver Daniel Thompson
2015-10-04  9:09   ` Maxime Coquelin
2015-10-12  8:21 ` [PATCH 0/3] hwrng: stm32 - add support for STM32 HW RNG Daniel Thompson
2015-10-12  8:21   ` [PATCH 1/3] dt-bindings: Document the STM32 HW RNG bindings Daniel Thompson
2015-10-12  8:21   ` [PATCH 2/3] hwrng: stm32 - add support for STM32 HW RNG Daniel Thompson
2015-10-14  7:39     ` Linus Walleij
2015-10-12  8:21   ` [PATCH 3/3] ARM: dts: stm32f429: Adopt STM32 RNG driver Daniel Thompson
2015-10-14 14:28   ` [PATCH 0/3] hwrng: stm32 - add support for STM32 HW RNG Herbert Xu
2015-10-14 14:46     ` Maxime Coquelin
2015-10-14 15:55 ` [PATCH v3 " Daniel Thompson
2015-10-14 15:55   ` [PATCH v3 1/3] dt-bindings: Document the STM32 HW RNG bindings Daniel Thompson
2015-10-14 15:55   ` [PATCH v3 2/3] hwrng: stm32 - add support for STM32 HW RNG Daniel Thompson
2015-10-14 15:55   ` [PATCH v3 3/3] ARM: dts: stm32f429: Adopt STM32 RNG driver Daniel Thompson
2015-10-14 16:04 ` [PATCH] hwrng: stm32 - Fix build with CONFIG_PM Daniel Thompson
2015-10-15  2:00   ` Herbert Xu

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='CAMTL27EoZRFBk+A5TA-knpmRoaqfyDD=L=+yqEXYX=ntR46xkw@mail.gmail.com' \
    --to=daniel.thompson@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=lee.jones@linaro.org \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=mpm@selenic.com \
    --cc=patches@linaro.org \
    --cc=pawel.moll@arm.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).