aboutsummaryrefslogtreecommitdiff
path: root/arch/sh/mm/pg-dma.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 15:20:36 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 15:20:36 -0700
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/sh/mm/pg-dma.c
Linux-2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/sh/mm/pg-dma.c')
-rw-r--r--arch/sh/mm/pg-dma.c97
1 files changed, 97 insertions, 0 deletions
diff --git a/arch/sh/mm/pg-dma.c b/arch/sh/mm/pg-dma.c
new file mode 100644
index 00000000000..1406d2e348c
--- /dev/null
+++ b/arch/sh/mm/pg-dma.c
@@ -0,0 +1,97 @@
+/*
+ * arch/sh/mm/pg-dma.c
+ *
+ * Fast clear_page()/copy_page() implementation using the SH DMAC
+ *
+ * Copyright (C) 2003 Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <asm/semaphore.h>
+#include <asm/mmu_context.h>
+#include <asm/addrspace.h>
+#include <asm/atomic.h>
+#include <asm/page.h>
+#include <asm/dma.h>
+#include <asm/io.h>
+
+/* Channel to use for page ops, must be dual-address mode capable. */
+static int dma_channel = CONFIG_DMA_PAGE_OPS_CHANNEL;
+
+static void copy_page_dma(void *to, void *from)
+{
+ /*
+ * This doesn't seem to get triggered until further along in the
+ * boot process, at which point the DMAC is already initialized.
+ * Fix this in the same fashion as clear_page_dma() in the event
+ * that this crashes due to the DMAC not being initialized.
+ */
+
+ flush_icache_range((unsigned long)from, PAGE_SIZE);
+ dma_write_page(dma_channel, (unsigned long)from, (unsigned long)to);
+ dma_wait_for_completion(dma_channel);
+}
+
+static void clear_page_dma(void *to)
+{
+ extern unsigned long empty_zero_page[1024];
+
+ /*
+ * We get invoked quite early on, if the DMAC hasn't been initialized
+ * yet, fall back on the slow manual implementation.
+ */
+ if (dma_info[dma_channel].chan != dma_channel) {
+ clear_page_slow(to);
+ return;
+ }
+
+ dma_write_page(dma_channel, (unsigned long)empty_zero_page,
+ (unsigned long)to);
+
+ /*
+ * FIXME: Something is a bit racy here, if we poll the counter right
+ * away, we seem to lock. flushing the page from the dcache doesn't
+ * seem to make a difference one way or the other, though either a full
+ * icache or dcache flush does.
+ *
+ * The location of this is important as well, and must happen prior to
+ * the completion loop but after the transfer was initiated.
+ *
+ * Oddly enough, this doesn't appear to be an issue for copy_page()..
+ */
+ flush_icache_range((unsigned long)to, PAGE_SIZE);
+
+ dma_wait_for_completion(dma_channel);
+}
+
+static int __init pg_dma_init(void)
+{
+ int ret;
+
+ ret = request_dma(dma_channel, "page ops");
+ if (ret != 0)
+ return ret;
+
+ copy_page = copy_page_dma;
+ clear_page = clear_page_dma;
+
+ return ret;
+}
+
+static void __exit pg_dma_exit(void)
+{
+ free_dma(dma_channel);
+}
+
+module_init(pg_dma_init);
+module_exit(pg_dma_exit);
+
+MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>");
+MODULE_DESCRIPTION("Optimized page copy/clear routines using a dual-address mode capable DMAC channel");
+MODULE_LICENSE("GPL");
+