* [PATCH 2.6] Cobalt fixes [5 of 6]
@ 2005-02-20 15:01 Peter Horton
2005-02-21 16:33 ` Ralf Baechle
0 siblings, 1 reply; 2+ messages in thread
From: Peter Horton @ 2005-02-20 15:01 UTC (permalink / raw)
To: linux-mips; +Cc: ralf
Fix Qube/RaQ PIO IDE to prevent D-cache aliasing problems.
P.
--- linux-cvs/include/asm-mips/cobalt/ide.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-wip/include/asm-mips/cobalt/ide.h 2005-02-20 14:00:49.000000000 +0000
@@ -0,0 +1,83 @@
+
+/*
+ * PIO "in" transfers can cause D-cache lines to be allocated
+ * to the data being read. If the target is the page cache then
+ * the kernel can create a user space mapping of the same page
+ * without flushing it from the D-cache. This has large potential
+ * to create cache aliases. The Cobalts seem to trigger this
+ * problem easily.
+ *
+ * MIPs doesn't have a flush_dcache_range() so we roll
+ * our own.
+ *
+ * -- pdh
+ */
+
+#define MAX_HWIFS 2
+
+#include <asm/r4kcache.h>
+
+static inline void __flush_dcache(void)
+{
+ unsigned long dc_size, dc_line, addr, end;
+
+ dc_size = current_cpu_data.dcache.ways << current_cpu_data.dcache.waybit;
+ dc_line = current_cpu_data.dcache.linesz;
+
+ addr = CKSEG0;
+ end = addr + dc_size;
+
+ for (; addr < end; addr += dc_line)
+ flush_dcache_line_indexed(addr);
+}
+
+static inline void __flush_dcache_range(unsigned long start, unsigned long end)
+{
+ unsigned long dc_size, dc_line, addr;
+
+ dc_size = current_cpu_data.dcache.ways << current_cpu_data.dcache.waybit;
+ dc_line = current_cpu_data.dcache.linesz;
+
+ addr = start & ~(dc_line - 1);
+ end += dc_line - 1;
+
+ if (end - addr < dc_size)
+ for (; addr < end; addr += dc_line)
+ flush_dcache_line(addr);
+ else
+ __flush_dcache();
+}
+
+static inline void __ide_insw(unsigned long port, void *addr, unsigned int count)
+{
+ insw(port, addr, count);
+
+ __flush_dcache_range((unsigned long) addr, (unsigned long) addr + count * 2);
+}
+
+static inline void __ide_insl(unsigned long port, void *addr, unsigned int count)
+{
+ insl(port, addr, count);
+
+ __flush_dcache_range((unsigned long) addr, (unsigned long) addr + count * 4);
+}
+
+static inline void __ide_mm_insw(volatile void __iomem *port, void *addr, unsigned int count)
+{
+ readsw(port, addr, count);
+
+ __flush_dcache_range((unsigned long) addr, (unsigned long) addr + count * 2);
+}
+
+static inline void __ide_mm_insl(volatile void __iomem *port, void *addr, unsigned int count)
+{
+ readsl(port, addr, count);
+
+ __flush_dcache_range((unsigned long) addr, (unsigned long) addr + count * 4);
+}
+
+#define insw __ide_insw
+#define insl __ide_insl
+
+#define __ide_mm_outsw writesw
+#define __ide_mm_outsl writesl
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-02-21 16:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-20 15:01 [PATCH 2.6] Cobalt fixes [5 of 6] Peter Horton
2005-02-21 16:33 ` Ralf Baechle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox