patch-2.3.14 linux/arch/alpha/lib/io.c

Next file: linux/arch/alpha/mm/fault.c
Previous file: linux/arch/alpha/kernel/sys_rx164.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.13/linux/arch/alpha/lib/io.c linux/arch/alpha/lib/io.c
@@ -37,45 +37,96 @@
 	__outl(b, addr);
 }
 
+unsigned long ___raw_readb(unsigned long addr)
+{
+	return __readb(addr);
+}
+
+unsigned long ___raw_readw(unsigned long addr)
+{
+	return __readw(addr);
+}
+
+unsigned long ___raw_readl(unsigned long addr)
+{
+	return __readl(addr);
+}
+
+unsigned long ___raw_readq(unsigned long addr)
+{
+	return __readq(addr);
+}
 
 unsigned long _readb(unsigned long addr)
 {
-	return __readb(addr);
+	unsigned long r = __readb(addr);
+	mb();
+	return r;
 }
 
 unsigned long _readw(unsigned long addr)
 {
-	return __readw(addr);
+	unsigned long r = __readw(addr);
+	mb();
+	return r;
 }
 
 unsigned long _readl(unsigned long addr)
 {
-	return __readl(addr);
+	unsigned long r = __readl(addr);
+	mb();
+	return r;
 }
 
 unsigned long _readq(unsigned long addr)
 {
-	return __readq(addr);
+	unsigned long r = __readq(addr);
+	mb();
+	return r;
+}
+
+void ___raw_writeb(unsigned char b, unsigned long addr)
+{
+	__writeb(b, addr);
+}
+
+void ___raw_writeb(unsigned short b, unsigned long addr)
+{
+	__writew(b, addr);
+}
+
+void ___raw_writel(unsigned int b, unsigned long addr)
+{
+	__writel(b, addr);
+}
+
+void ___raw_writeq(unsigned long b, unsigned long addr)
+{
+	__writeq(b, addr);
 }
 
 void _writeb(unsigned char b, unsigned long addr)
 {
 	__writeb(b, addr);
+	mb();
 }
 
 void _writew(unsigned short b, unsigned long addr)
 {
 	__writew(b, addr);
+	mb();
 }
 
 void _writel(unsigned int b, unsigned long addr)
 {
 	__writel(b, addr);
+	mb();
 }
 
 void _writeq(unsigned long b, unsigned long addr)
 {
 	__writeq(b, addr);
+	mb();
 }
 
 /*
@@ -363,7 +414,7 @@
 	if (count >= 8 && ((long)to & 7) == (from & 7)) {
 		count -= 8;
 		do {
-			*(u64 *)to = readq(from);
+			*(u64 *)to = __raw_readq(from);
 			count -= 8;
 			to += 8;
 			from += 8;
@@ -374,7 +425,7 @@
 	if (count >= 4 && ((long)to & 3) == (from & 3)) {
 		count -= 4;
 		do {
-			*(u32 *)to = readl(from);
+			*(u32 *)to = __raw_readl(from);
 			count -= 4;
 			to += 4;
 			from += 4;
@@ -385,7 +436,7 @@
 	if (count >= 2 && ((long)to & 1) == (from & 1)) {
 		count -= 2;
 		do {
-			*(u16 *)to = readw(from);
+			*(u16 *)to = __raw_readw(from);
 			count -= 2;
 			to += 2;
 			from += 2;
@@ -394,7 +445,7 @@
 	}
 
 	while (count > 0) {
-		*(u8 *) to = readb(from);
+		*(u8 *) to = __raw_readb(from);
 		count--;
 		to++;
 		from++;
@@ -414,7 +465,7 @@
 	if (count >= 8 && (to & 7) == ((long)from & 7)) {
 		count -= 8;
 		do {
-			writeq(*(const u64 *)from, to);
+			__raw_writeq(*(const u64 *)from, to);
 			count -= 8;
 			to += 8;
 			from += 8;
@@ -425,7 +476,7 @@
 	if (count >= 4 && (to & 3) == ((long)from & 3)) {
 		count -= 4;
 		do {
-			writel(*(const u32 *)from, to);
+			__raw_writel(*(const u32 *)from, to);
 			count -= 4;
 			to += 4;
 			from += 4;
@@ -436,7 +487,7 @@
 	if (count >= 2 && (to & 1) == ((long)from & 1)) {
 		count -= 2;
 		do {
-			writew(*(const u16 *)from, to);
+			__raw_writeb(*(const u16 *)from, to);
 			count -= 2;
 			to += 2;
 			from += 2;
@@ -445,11 +496,12 @@
 	}
 
 	while (count > 0) {
-		writeb(*(const u8 *) from, to);
+		__raw_writeb(*(const u8 *) from, to);
 		count--;
 		to++;
 		from++;
 	}
+	mb();
 }
 
 /*
@@ -459,21 +511,21 @@
 {
 	/* Handle any initial odd byte */
 	if (count > 0 && (to & 1)) {
-		writeb(c, to);
+		__raw_writeb(c, to);
 		to++;
 		count--;
 	}
 
 	/* Handle any initial odd halfword */
 	if (count >= 2 && (to & 2)) {
-		writew(c, to);
+		__raw_writeb(c, to);
 		to += 2;
 		count -= 2;
 	}
 
 	/* Handle any initial odd word */
 	if (count >= 4 && (to & 4)) {
-		writel(c, to);
+		__raw_writel(c, to);
 		to += 4;
 		count -= 4;
 	}
@@ -483,7 +535,7 @@
 	count -= 8;
 	if (count >= 0) {
 		do {
-			writeq(c, to);
+			__raw_writeq(c, to);
 			to += 8;
 			count -= 8;
 		} while (count >= 0);
@@ -492,20 +544,21 @@
 
 	/* The tail is word-aligned if we still have count >= 4 */
 	if (count >= 4) {
-		writel(c, to);
+		__raw_writel(c, to);
 		to += 4;
 		count -= 4;
 	}
 
 	/* The tail is half-word aligned if we have count >= 2 */
 	if (count >= 2) {
-		writew(c, to);
+		__raw_writeb(c, to);
 		to += 2;
 		count -= 2;
 	}
 
 	/* And finally, one last byte.. */
 	if (count) {
-		writeb(c, to);
+		__raw_writeb(c, to);
 	}
+	mb();
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)