public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ioremap_cached()
@ 2006-03-30 16:41 Matthew Wilcox
  2006-03-30 18:27 ` Andi Kleen
  2006-03-31 11:20 ` Arjan van de Ven
  0 siblings, 2 replies; 9+ messages in thread
From: Matthew Wilcox @ 2006-03-30 16:41 UTC (permalink / raw)
  To: linux-kernel


We currently have three ways for getting access to device memory --
ioremap(), ioremap_nocache() and pci_iomap().  99% of the callers of
ioremap() are doing it to access device registers, and really, really
want to use ioremap_nocache() instead.  I presume nobody notices on PCs
because they have write-through caches, but it ought to trip up people
trying to flush writes.

pci_iomap() gets this right -- it calls ioremap() if the resource is
tagged with IORESOURCE_CACHEABLE and ioremap_nocache() if it isn't.
Unfortunately, the only resources tagged with IORESOURCE_CACHEABLE
are PCI ROM resources, so even frame buffers and similar that could be
cached aren't.

It seems clear to me that ioremap() and ioremap_nocache() are the
wrong way around.  The default needs to be uncached -- and the obvious
(rare) alternative becomes ioremap_cached().

So here's a patch for i386 to add ioremap_cached() and make ioremap()
uncached.  ioremap_nocache() remains as an alias for ioremap() so we
don't needlessly break old drivers.  Architecture maintainers will need
to fix up their ports if this patch is accepted.


Index: include/asm-i386/io.h
===================================================================
RCS file: /var/cvs/linux-2.6/include/asm-i386/io.h,v
retrieving revision 1.10
diff -u -p -r1.10 io.h
--- a/include/asm-i386/io.h	17 Jan 2006 14:52:36 -0000	1.10
+++ b/include/asm-i386/io.h	30 Mar 2006 16:39:22 -0000
@@ -115,12 +115,13 @@ extern void __iomem * __ioremap(unsigned
  * address. 
  */
 
-static inline void __iomem * ioremap(unsigned long offset, unsigned long size)
+static inline void __iomem * ioremap_cached(unsigned long offset, unsigned long size)
 {
 	return __ioremap(offset, size, 0);
 }
 
-extern void __iomem * ioremap_nocache(unsigned long offset, unsigned long size);
+#define ioremap_nocache(a, b) ioremap(a, b)
+extern void __iomem * ioremap(unsigned long offset, unsigned long size);
 extern void iounmap(volatile void __iomem *addr);
 
 /*
Index: arch/i386/mm/ioremap.c
===================================================================
RCS file: /var/cvs/linux-2.6/arch/i386/mm/ioremap.c,v
retrieving revision 1.13
diff -u -p -r1.13 ioremap.c
--- a/arch/i386/mm/ioremap.c	19 Dec 2005 12:42:12 -0000	1.13
+++ b/arch/i386/mm/ioremap.c	30 Mar 2006 16:39:22 -0000
@@ -167,11 +167,11 @@ void __iomem * __ioremap(unsigned long p
 EXPORT_SYMBOL(__ioremap);
 
 /**
- * ioremap_nocache     -   map bus memory into CPU space
+ * ioremap     -   map bus memory into CPU space
  * @offset:    bus address of the memory
  * @size:      size of the resource to map
  *
- * ioremap_nocache performs a platform specific sequence of operations to
+ * ioremap performs a platform specific sequence of operations to
  * make bus memory CPU accessible via the readb/readw/readl/writeb/
  * writew/writel functions and the other mmio helpers. The returned
  * address is not guaranteed to be usable directly as a virtual
@@ -188,7 +188,7 @@ EXPORT_SYMBOL(__ioremap);
  * Must be freed with iounmap.
  */
 
-void __iomem *ioremap_nocache (unsigned long phys_addr, unsigned long size)
+void __iomem *ioremap(unsigned long phys_addr, unsigned long size)
 {
 	unsigned long last_addr;
 	void __iomem *p = __ioremap(phys_addr, size, _PAGE_PCD);
@@ -221,7 +221,7 @@ void __iomem *ioremap_nocache (unsigned 
 
 	return p;					
 }
-EXPORT_SYMBOL(ioremap_nocache);
+EXPORT_SYMBOL(ioremap);
 
 /**
  * iounmap - Free a IO remapping

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2006-03-31 11:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-30 16:41 [PATCH] ioremap_cached() Matthew Wilcox
2006-03-30 18:27 ` Andi Kleen
2006-03-30 19:34   ` Matthew Wilcox
2006-03-30 19:50     ` Andi Kleen
2006-03-30 20:14       ` Matthew Wilcox
2006-03-30 20:17         ` Andi Kleen
2006-03-30 20:21           ` Kumar Gala
2006-03-30 20:27             ` Andi Kleen
2006-03-31 11:20 ` Arjan van de Ven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox