Re: [PATCH] I/O helpers rework

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 22 Jan 2005, Atsushi Nemoto wrote:

> Revised.
> 
> 1. How about using 'const void *' for outs*()/reads*() ?  This will
>    remove some compiler warnings too.  Also, it seems 'volatile' for
>    memory buffer are unneeded.
> 
> 2. In *in*()/*out*(), it would be better to call __swizzle_addr*()
>    AFTER adding mips_io_port_base.  This unifies the meaning of the
>    argument of __swizzle_addr*() (always virtual address).  Then,
>    mach-specific __swizzle_addr*() can to every evil thing based on
>    the argument.
> 
> 3. How about Moving generic ioswab*() to mangle-port.h ?  Also how
>    about passing virtual address to *ioswab*() ?  Then we can provide
>    mach-specific ioswab*() and can do every evil thing based on its
>    argument.  It is usefull on machines which have regions with
>    different endian conversion scheme.

 Thanks for your insight -- your comments are not lost and I am working on 
taking them into account.  But meanwhile a confusion around the semantics 
of these operations arose (there is no documentation on them and some 
drivers expect some of these functions to swap, while others expect them 
not to) and changes were made to the tree that invalidated some of the 
fixes.  That needs to be addressed first and I expect another update to 
the file.  Here's a patch I'm going to start with.  Functions it adds have 
been named dma_* to indicate they are meant to preserve memory byte 
ordering.

  Maciej

patch-mips-2.6.11-rc1-20050120-mips-io-0
--- linux-mips-2.6.11-rc1-20050120.macro/include/asm-mips/io.h	19 Jan 2005 17:00:32 -0000	1.81
+++ linux-mips-2.6.11-rc1-20050120/include/asm-mips/io.h	20 Jan 2005 01:44:07 -0000
@@ -34,7 +34,7 @@
 #undef CONF_SLOWDOWN_IO
 
 /*
- * Raw operations are never swapped in software.  Otoh values that raw
+ * Raw operations are never swapped in software.  OTOH values that raw
  * operations are working on may or may not have been swapped by the bus
  * hardware.  An example use would be for flash memory that's used for
  * execute in place.
@@ -43,6 +43,7 @@
 # define __raw_ioswabw(x)	(x)
 # define __raw_ioswabl(x)	(x)
 # define __raw_ioswabq(x)	(x)
+# define ____raw_ioswabq(x)	(x)
 
 /*
  * Sane hardware offers swapping of PCI/ISA I/O space accesses in hardware;
@@ -51,37 +52,36 @@
 #if defined(CONFIG_SWAP_IO_SPACE)
 
 # define ioswabb(x)		(x)
+# define dma_ioswabb(x)		(x)
 # ifdef CONFIG_SGI_IP22
 /*
  * IP22 seems braindead enough to swap 16bits values in hardware, but
  * not 32bits.  Go figure... Can't tell without documentation.
  */
 #  define ioswabw(x)		(x)
+#  define dma_ioswabw(x)	le16_to_cpu(x)
 # else
 #  define ioswabw(x)		le16_to_cpu(x)
+#  define dma_ioswabw(x)	(x)
 # endif
 # define ioswabl(x)		le32_to_cpu(x)
+# define dma_ioswabl(x)		(x)
 # define ioswabq(x)		le64_to_cpu(x)
+# define dma_ioswabq(x)		(x)
 
 #else
 
 # define ioswabb(x)		(x)
+# define dma_ioswabb(x)		(x)
 # define ioswabw(x)		(x)
+# define dma_ioswabw(x)		cpu_to_le16(x)
 # define ioswabl(x)		(x)
+# define dma_ioswabl(x)		cpu_to_le32(x)
 # define ioswabq(x)		(x)
+# define dma_ioswabq(x)		cpu_to_le32(x)
 
 #endif
 
-/*
- * Native bus accesses never swapped.
- */
-#define bus_ioswabb(x)		(x)
-#define bus_ioswabw(x)		(x)
-#define bus_ioswabl(x)		(x)
-#define bus_ioswabq(x)		(x)
-
-#define __bus_ioswabq		bus_ioswabq
-
 #define IO_SPACE_LIMIT 0xffff
 
 /*
@@ -386,15 +386,15 @@ __BUILD_IOPORT_SINGLE(bus, bwlq, type, _
 
 #define BUILDIO(bwlq, type)						\
 									\
-__BUILD_MEMORY_PFX(, bwlq, type)					\
 __BUILD_MEMORY_PFX(__raw_, bwlq, type)					\
-__BUILD_MEMORY_PFX(bus_, bwlq, type)					\
+__BUILD_MEMORY_PFX(, bwlq, type)					\
+__BUILD_MEMORY_PFX(dma_, bwlq, type)					\
 __BUILD_IOPORT_PFX(, bwlq, type)					\
-__BUILD_IOPORT_PFX(__raw_, bwlq, type)
+__BUILD_IOPORT_PFX(dma_, bwlq, type)
 
 #define __BUILDIO(bwlq, type)						\
 									\
-__BUILD_MEMORY_SINGLE(__bus_, bwlq, type, 0)
+__BUILD_MEMORY_SINGLE(____raw_, bwlq, type, 0)
 
 BUILDIO(b, u8)
 BUILDIO(w, u16)
@@ -422,7 +422,7 @@ static inline void writes##bwlq(volatile
 	volatile type *__addr = addr;					\
 									\
 	while (count--) {						\
-		__raw_write##bwlq(*__addr, mem);			\
+		dma_write##bwlq(*__addr, mem);				\
 		__addr++;						\
 	}								\
 }									\
@@ -433,7 +433,7 @@ static inline void reads##bwlq(volatile 
 	volatile type *__addr = addr;					\
 									\
 	while (count--) {						\
-		*__addr = __raw_read##bwlq(mem);			\
+		*__addr = dma_read##bwlq(mem);				\
 		__addr++;						\
 	}								\
 }
@@ -446,7 +446,7 @@ static inline void outs##bwlq(unsigned l
 	volatile type *__addr = addr;					\
 									\
 	while (count--) {						\
-		__raw_out##bwlq(*__addr, port);				\
+		dma_out##bwlq(*__addr, port);				\
 		__addr++;						\
 	}								\
 }									\
@@ -457,7 +457,7 @@ static inline void ins##bwlq(unsigned lo
 	volatile type *__addr = addr;					\
 									\
 	while (count--) {						\
-		*__addr = __raw_in##bwlq(port);				\
+		*__addr = dma_in##bwlq(port);				\
 		__addr++;						\
 	}								\
 }


[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux