From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
Will Deacon <will.deacon@arm.com>,
Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
Gregory CLEMENT <gregory.clement@free-electrons.com>,
Arnaud Ebalard <arno@natisbad.org>,
"linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: crypto: marvell/CESA: Issues with non cache-line aligned buffers
Date: Fri, 3 Jul 2015 10:58:07 +0100 [thread overview]
Message-ID: <20150703095807.GS7557@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <20150703114305.15611807@bbrezillon>
On Fri, Jul 03, 2015 at 11:43:05AM +0200, Boris Brezillon wrote:
> Which led us to think that this could be related to a non cache-line
> aligned buffer problem: if we share the cache line with someone
> modifying its data during the DMA transfer, we could experience data
> loss when the cpu decide to flush the data from this cache line to the
> memory.
There's really only two options when you have an overlapping cache line
and the cache line contains CPU-dirty data, but the memory contains
DMA-dirty data. One of those dirty data has to win out, and the other
has to be destroyed. (Either you invalidate the CPU cache line, loosing
the CPU-dirty data, or you write-back the cache line, overwriting the DMA-
dirty data.)
What that means is that it's a _bug_ to end up in this situation, nothing
more, nothing less. There's nothing that arch code can do about it, it's
a DMA-API user bug.
What you'll find is that this is well documented. See
Documentation/DMA-API.txt, part Id (Streaming DMA mappings):
Warnings: Memory coherency operates at a granularity called the cache
line width. In order for memory mapped by this API to operate
correctly, the mapped region must begin exactly on a cache line
boundary and end exactly on one (to prevent two separately mapped
regions from sharing a single cache line). Since the cache line size
may not be known at compile time, the API will not enforce this
requirement. Therefore, it is recommended that driver writers who
don't take special care to determine the cache line size at run time
only map virtual regions that begin and end on page boundaries (which
are guaranteed also to be cache line boundaries).
The behaviour you're seeing here is not ARM specific - any CPU which
uses cache lines and doesn't have hardware coherency will suffer from
this problem.
--
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
next prev parent reply other threads:[~2015-07-03 9:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-03 9:43 crypto: marvell/CESA: Issues with non cache-line aligned buffers Boris Brezillon
2015-07-03 9:58 ` Russell King - ARM Linux [this message]
2015-07-03 14:23 ` Boris Brezillon
2015-07-03 13:10 ` Russell King - ARM Linux
2015-07-03 14:19 ` Boris Brezillon
2015-07-03 14:41 ` Andrew Lunn
2015-07-04 7:33 ` Herbert Xu
2015-07-04 7:37 ` 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=20150703095807.GS7557@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=arno@natisbad.org \
--cc=boris.brezillon@free-electrons.com \
--cc=gregory.clement@free-electrons.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-crypto@vger.kernel.org \
--cc=thomas.petazzoni@free-electrons.com \
--cc=will.deacon@arm.com \
/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