From: David Laight <David.Laight@ACULAB.COM>
To: 'Petr Malat' <oss@malat.biz>
Cc: "linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
"Joern Engel" <joern@lazybastard.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: RE: [PATCH] mtd: phram: Map RAM using memremap instead of ioremap
Date: Mon, 23 May 2022 16:09:20 +0000 [thread overview]
Message-ID: <e33f91a3eacc4aa3a08e6465fef9265c@AcuMS.aculab.com> (raw)
In-Reply-To: <Youn9AmqY6/EExDw@ntb.petris.klfree.czf>
From: Petr Malat
> Sent: 23 May 2022 16:28
>
> Hi!
>
> On Mon, May 23, 2022 at 02:51:41PM +0000, David Laight wrote:
> > From: Petr Malat
> > > Sent: 23 May 2022 15:28
> > >
> > > One can't use memcpy on memory obtained by ioremap, because IO memory
> > > may have different alignment and size access restriction than the system
> > > memory. Use memremap as phram driver operates on RAM.
> >
> > Does that actually help?
> > The memcpy() is still likely to issue unaligned accesses
> > that the hardware can't handle.
>
> Yes, it solves the issue. Memcpy can cause unaligned access only on
> platforms, which can handle it. And on ARM64 it's handled only for
> RAM and not for a device memory (__pgprot(PROT_DEVICE_*)).
Does mapping it as memory cause it to be cached?
So the hardware only sees cache line reads (which are aligned)
and the cpu support for misaligned memory accesses then
stop the faults?
On x86 (which I know a lot more about) memcpy() has a nasty
habit of getting implemented as 'rep movsb' relying on the
cpu to speed it up.
But that doesn't happen for uncached addresses - so you get
very slow byte copies.
OTOH misaligned PCIe transfers generate TLP that have the
correct byte enables for the end words.
Provided the PCIe target isn't broken they are fine.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2022-05-23 16:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-23 14:28 [PATCH] mtd: phram: Map RAM using memremap instead of ioremap Petr Malat
2022-05-23 14:51 ` David Laight
2022-05-23 15:27 ` Petr Malat
2022-05-23 16:09 ` David Laight [this message]
2022-05-24 7:13 ` Petr Malat
2022-06-07 10:24 ` Petr Malat
2022-05-23 15:00 ` Greg KH
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=e33f91a3eacc4aa3a08e6465fef9265c@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=joern@lazybastard.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=oss@malat.biz \
--cc=stable@vger.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