Skip to contentSkip to conversation

MIPS: add initial cache support

RFC In review Antony Pavlov 2 participants 2 messages May 24, 2013 – May 28, 2013 MIPS

lore
Share & tools
lore
#0 lore raw

RFC 1/1 MIPS: add initial cache support

---
 arch/mips/include/asm/cache.h    |    8 +
 arch/mips/include/asm/cacheops.h |   78 +++++++
 arch/mips/include/asm/cpu-info.h |    1 +
 arch/mips/include/asm/io.h       |   66 ++++++
 arch/mips/include/asm/r4kcache.h |  443 ++++++++++++++++++++++++++++++++++++++
 arch/mips/lib/Makefile           |    1 +
 arch/mips/lib/c-r4k.c            |   97 +++++++++
 arch/mips/lib/dma.c              |   27 +++
 include/linux/const.h            |   24 +++
 9 files changed, 745 insertions(+)
 create mode 100644 arch/mips/include/asm/cache.h
 create mode 100644 arch/mips/include/asm/cacheops.h
 create mode 100644 arch/mips/include/asm/r4kcache.h
 create mode 100644 arch/mips/lib/dma.c
 create mode 100644 include/linux/const.h
arch/mips/include/asm/cache.h new file +8 -0
new file mode 100644
index 0000000..2f807d5
@@ -0,0 +1,8 @@
+#ifndef _ASM_MIPS_CACHE_H
+#define _ASM_MIPS_CACHE_H
+
+void flush_cache_all(void);
+void flush_dcache_all(void);
+void flush_icache_all(void);
+
+#endif /* _ASM_MIPS_CACHE_H */
arch/mips/include/asm/cacheops.h new file +78 -0

78 lines not on this page · raw message

arch/mips/include/asm/cpu-info.h +1 -0
index 6701730..cc1a3eb 100644
@@ -13,6 +13,7 @@
 #define __ASM_CPU_INFO_H
 
 #include <linux/types.h>
+#include <asm/cache.h>
 
 /*
  * Descriptor for a cache
arch/mips/include/asm/io.h +66 -0

73 lines not on this page · raw message

arch/mips/include/asm/r4kcache.h new file +443 -0

443 lines not on this page · raw message

arch/mips/lib/Makefile +1 -0
index 71c4f6b..f4aee2e 100644
@@ -6,6 +6,7 @@ obj-y += ashrdi3.o
 obj-y += cpu-probe.o
 obj-y += traps.o
 obj-y += genex.o
+obj-y += dma.o
 
 obj-$(CONFIG_CPU_MIPS32) += c-r4k.o
 obj-$(CONFIG_CPU_MIPS64) += c-r4k.o
arch/mips/lib/c-r4k.c +97 -0

106 lines not on this page · raw message

arch/mips/lib/dma.c new file +27 -0
new file mode 100644
index 0000000..0ca53f1
@@ -0,0 +1,27 @@
+#include <common.h>
+#include <asm/io.h>
+#include <asm/mipsregs.h>
+#include <malloc.h>
+
+static inline void __iomem *ioremap_nocache(phys_t offset, unsigned long size)
+{
+	return (void __iomem *) (unsigned long)CKSEG1ADDR(offset);
+}
+
+void *dma_alloc_coherent(size_t size)
+{
+	void *ret;
+
+	ret = xmemalign(4096, size);
+
+	dma_inv_range((unsigned long)ret, (unsigned long)ret + size);
+
+	ret = ioremap_nocache((phys_t)ret, size);
+
+	return ret;
+}
+
+void dma_free_coherent(void *mem, size_t size)
+{
+	free(mem);
+}
include/linux/const.h new file +24 -0
new file mode 100644
index 0000000..c22c707
@@ -0,0 +1,24 @@
+/* const.h: Macros for dealing with constants.  */
+
+#ifndef _LINUX_CONST_H
+#define _LINUX_CONST_H
+
+/* Some constant macros are used in both assembler and
+ * C code.  Therefore we cannot annotate them always with
+ * 'UL' and other type specifiers unilaterally.  We
+ * use the following macros to deal with this.
+ *
+ * Similarly, _AT() will cast an expression with a type in C, but
+ * leave it unchanged in asm.
+ */
+
+#ifdef __ASSEMBLY__
+#define _AC(X,Y)	X
+#define _AT(T,X)	X
+#else
+#define __AC(X,Y)	(X##Y)
+#define _AC(X,Y)	__AC(X,Y)
+#define _AT(T,X)	((T)(X))
+#endif
+
+#endif /* !(_LINUX_CONST_H) */
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

Hi Antony,

Quoted 31 lines · Antony Pavlov
---
 arch/mips/include/asm/cache.h    |    8 +
 arch/mips/include/asm/cacheops.h |   78 +++++++
 arch/mips/include/asm/cpu-info.h |    1 +
 arch/mips/include/asm/io.h       |   66 ++++++
 arch/mips/include/asm/r4kcache.h |  443 ++++++++++++++++++++++++++++++++++++++
 arch/mips/lib/Makefile           |    1 +
 arch/mips/lib/c-r4k.c            |   97 +++++++++
 arch/mips/lib/dma.c              |   27 +++
 include/linux/const.h            |   24 +++
 9 files changed, 745 insertions(+)
 create mode 100644 arch/mips/include/asm/cache.h
 create mode 100644 arch/mips/include/asm/cacheops.h
 create mode 100644 arch/mips/include/asm/r4kcache.h
 create mode 100644 arch/mips/lib/dma.c
 create mode 100644 include/linux/const.h
arch/mips/lib/dma.c new file +7 -0
new file mode 100644
index 0000000..0ca53f1
@@ -0,0 +1,27 @@
+#include <common.h>
+#include <asm/io.h>
+#include <asm/mipsregs.h>
+#include <malloc.h>
+
+static inline void __iomem *ioremap_nocache(phys_t offset, unsigned long size)
+{

arch/mips/lib/dma.c line 17

Quoted 10 lines
arch/mips/lib/dma.c new file +10 -0
+	return (void __iomem *) (unsigned long)CKSEG1ADDR(offset);
+}
+
+void *dma_alloc_coherent(size_t size)
+{
+	void *ret;
+
+	ret = xmemalign(4096, size);
+
+	dma_inv_range((unsigned long)ret, (unsigned long)ret + size);

Is this needed? I mean you return the corresponding CKSEG1ADDR anyway which should be coherent memory.

arch/mips/lib/dma.c line 27

Quoted 10 lines
arch/mips/lib/dma.c new file +10 -0
+
+	ret = ioremap_nocache((phys_t)ret, size);
+
+	return ret;
+}
+
+void dma_free_coherent(void *mem, size_t size)
+{
+	free(mem);
+}

I would expect to invalidate the cache here instead.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox