From mboxrd@z Thu Jan 1 00:00:00 1970 From: will.deacon@arm.com (Will Deacon) Date: Fri, 28 Sep 2012 10:58:08 +0100 Subject: [PATCH] ARM: optimize memset_io()/memcpy_fromio()/memcpy_toio() In-Reply-To: References: Message-ID: <20120928095808.GB18125@mudshark.cambridge.arm.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Fri, Sep 28, 2012 at 05:17:53AM +0100, Nicolas Pitre wrote: > On Thu, 27 Sep 2012, Russell King wrote: > > > If we are building for a LE platform, and we haven't overriden the > > MMIO ops, then we can optimize the mem*io operations using the > > standard string functions. > > > > Signed-off-by: Russell King > > We presume that the IO space is able to cope with a mixture of access > width other than byte access which should be perfectly reasonable by > default. If so then... > > Acked-by: Nicolas Pitre This looks pretty scary to me, but maybe I'm worrying too much. The first thing to ensure is that the accesses are always aligned, which I believe is true for the string operations. However, a quick glance at memset shows that we do things like store multiple with writeback addressing modes. This is bad for a few reasons: 1. If an access other the first one generated by the instruction causes an abort, the CPU will ultimately re-execute the earlier accesses, which could be problematic to a device. 2. Writeback addressing modes when accessing MMIO peripherals causes serious performance problems with virtualisation, as I have described before. 3. We have to guarantee that no single instruction causes accesses that span a page boundary, as this leads to UNPREDICTABLE behaviour. So, unless we can guarantee that our accesses are all aligned, will never fault, do not cross a page boundary and we are not running as a guest then I'd be inclined to stick with byte-by-byte implementations for these functions. Will