sfc: PIO:Restrict to 64bit arch and use 64-bit writes.
authorJon Cooper <jcooper@solarflare.com>
Wed, 11 Jun 2014 13:33:08 +0000 (14:33 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 26 Jun 2014 19:15:40 +0000 (15:15 -0400)
commit7c9a26c2c40b732a3886c4ee55a8a5e7437d46bf
tree52580916dccc108c950d6d7c7562357e3df37a37
parenta7b791bc2b6fcc29f7c56a375823d436f7f233ce
sfc: PIO:Restrict to 64bit arch and use 64-bit writes.

[ Upstream commit daf37b556e437ec1ea1a597dcfeff338068380e1 ]

Fixes:ee45fd92c739
("sfc: Use TX PIO for sufficiently small packets")

The linux net driver uses memcpy_toio() in order to copy into
the PIO buffers.
Even on a 64bit machine this causes 32bit accesses to a write-
combined memory region.
There are hardware limitations that mean that only 64bit
naturally aligned accesses are safe in all cases.
Due to being write-combined memory region two 32bit accesses
may be coalesced to form a 64bit non 64bit aligned access.
Solution was to open-code the memory copy routines using pointers
and to only enable PIO for x86_64 machines.

Not tested on platforms other than x86_64 because this patch
disables the PIO feature on other platforms.
Compile-tested on x86 to ensure that works.

The WARN_ON_ONCE() code in the previous version of this patch
has been moved into the internal sfc debug driver as the
assertion was unnecessary in the upstream kernel code.

This bug fix applies to v3.13 and v3.14 stable branches.

Signed-off-by: Shradha Shah <sshah@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/sfc/io.h
drivers/net/ethernet/sfc/tx.c