[parisc-linux-cvs] linux willy

Ryan Bradetich rbrad@beavis.ybsoft.com
Wed, 11 Apr 2001 22:41:55 -0600


On Wed, Apr 11, 2001 at 01:12:51PM -0600, Matthew Wilcox wrote:
> CVSROOT:	/home/cvs/parisc
> Module name:	linux
> Changes by:	willy	01/04/11 13:12:51
> 
> Modified files:
> 	include/asm-parisc: io.h 
> 	arch/parisc/lib: Makefile 
> Added files:
> 	arch/parisc/lib: io.c 
> 
> Log message:
> Implement a more efficient (non-inline) memcpy_toio.
> Add memcpy_fromio and memset_io (untested).

Willy,

The memcpy_toio() broke scsi on my C200.  [Note: I was getting
unaligned data reference traps (28)]  I tracked it to down to
the memcpy_toio function.  The following patch fixed the
problem on my C200 for the memcpy_toio(). [Note: I fixed the
problem in the other two functions as well.]  I have not
committed this fix, because I'm not sure if it is correct for
the general case and wanted you to review it.

thanks,

- Ryan


Index: arch/parisc/lib/io.c
===================================================================
RCS file: /home/cvs/parisc/linux/arch/parisc/lib/io.c,v
retrieving revision 1.1
diff -u -p -r1.1 io.c
--- io.c	2001/04/11 19:12:50	1.1
+++ io.c	2001/04/12 04:28:55
@@ -14,14 +14,15 @@
  */
 void memcpy_toio(unsigned long dest, const void *src, int count)
 {
-	if (dest % 3 != (unsigned long)src % 3)
+	if (dest & 0x3 != (unsigned long)src & 0x3)
 		goto bytecopy;
-	while (dest % 3) {
+	while (dest & 0x3) {
 		writeb(*(char *)src++, dest++);
 		count--;
 	}
 	while (count > 3) {
-		writel(*(u32 *)src++, dest);
+		writel(*(u32 *)src, dest);
+		src += 4;
 		dest += 4;
 		count -= 4;
 	}
@@ -37,9 +38,9 @@ void memcpy_toio(unsigned long dest, con
  */
 void memcpy_fromio(const void *dest, unsigned long src, int count)
 {
-	if ((unsigned long)dest % 3 != src % 3)
+	if ((unsigned long)dest & 0x3 != src & 0x3)
 		goto bytecopy;
-	while (src % 3) {
+	while (src & 0x3) {
 		*(char *)dest = readb(src++);
 		((char *)dest)++;
 		count--;
@@ -63,7 +64,7 @@ void memcpy_fromio(const void *dest, uns
 void memset_io(unsigned long dest, char fill, int count)
 {
 	u32 fill32 = (fill << 24) | (fill << 16) | (fill << 8) | fill;
-	while (dest % 3) {
+	while (dest & 0x3) {
 		writeb(fill, dest++);
 		count--;
 	}