[PATCH] ARM: optimize memset_io()/memcpy_fromio()/memcpy_toio()
From: Will Deacon <hidden>
Date: 2012-09-28 09:58:08
On Fri, Sep 28, 2012 at 05:17:53AM +0100, Nicolas Pitre wrote:
On Thu, 27 Sep 2012, Russell King wrote:quoted
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 <redacted>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 <redacted>
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