linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: On __raw_readl readl_relaxed and readl nocheinmal
Date: Fri, 27 May 2011 19:04:56 +0100	[thread overview]
Message-ID: <20110527180456.GR24876@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <C832F8F5D375BD43BFA11E82E0FE9FE00AFDABA5E2@EXDCVYMBSTM005.EQ1STM.local>

On Fri, May 27, 2011 at 04:14:18PM +0200, Joakim BECH wrote:
> write(a, reg1); // Setup hardware
> write(a, reg2); // Setup hardware
> write(a, reg3); // Write bulk data
> write(a, reg3); // Write bulk data ...
> 
> Some of you wrote that the only way to be sure that the data has been
> written is to read the value after writing it. Here we have another problem.
> Since it's a cryptographic device some registers on the hardware are
> write-only, and some registers are actually implemented as a stack in the
> hardware itself. If you write a value to a register it will be pushed onto a
> stack in the hardware and if you read the same register you pop the value
> from the stack in the hardware.

Whichever interface you use on ARM, you will get the writes occuring in
order provided the registers are local to each other.  What you can't
guarantee is the relative ordering of those writes with respect to other
memory accesses, nor when the writes will actually hit the hardware.

(There is hardware which has weird partitioning and allows writes to the
same _device_ to bypass each other and I personally consider this insane.)

> Do you understand my problems and do you have any suggestions for me how to
> handle it? The initial problem, looking at using __raw_writel, was actually
> to improve performance. I noticed about 50% better throughput when I was
> using __raw_writel/readl instead writel/readl, but Linus warned me about the
> problems he mentioned in the initial message in this thread.

If you're writing a stream of data to a register, rather than coding a
for() loop and writel/readl, use readsl or writesl.  These pre-calculate
the cookie->address conversion, and then just get on with writing the
stream to the register.  They don't intersperse a barrier either (and
we don't currently add any barrier to them as we don't expect there to
be any ordering issues with memory accesses.)

  parent reply	other threads:[~2011-05-27 18:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-20 10:04 On __raw_readl readl_relaxed and readl nocheinmal Linus Walleij
2011-05-20 10:42 ` Russell King - ARM Linux
2011-05-20 10:50 ` Arnd Bergmann
2011-05-20 10:55 ` Catalin Marinas
2011-05-27 12:07   ` Jamie Lokier
2011-05-27 14:37     ` Catalin Marinas
2011-05-27 14:14   ` Joakim BECH
2011-05-27 15:02     ` Catalin Marinas
2011-05-27 16:16       ` Arnd Bergmann
2011-05-27 16:38         ` Catalin Marinas
2011-05-27 17:10           ` Arnd Bergmann
2011-05-27 18:06       ` Russell King - ARM Linux
2011-05-29  9:24         ` Catalin Marinas
2011-05-27 18:04     ` Russell King - ARM Linux [this message]
2011-05-31  7:12   ` viresh kumar
2011-05-31  8:53     ` Catalin Marinas

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=20110527180456.GR24876@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.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).