* [PATCH] MIPS: Refactor 'clear_page' and 'copy_page' functions.
@ 2012-05-24 20:38 Steven J. Hill
2012-05-30 18:10 ` David Daney
0 siblings, 1 reply; 4+ messages in thread
From: Steven J. Hill @ 2012-05-24 20:38 UTC (permalink / raw)
To: linux-mips, ralf; +Cc: Steven J. Hill
From: "Steven J. Hill" <sjhill@mips.com>
Remove usage of the '__attribute__((alias("...")))' hack that aliased
to integer arrays containing micro-assembled instructions. This hack
breaks when building a microMIPS kernel. It also makes the code much
easier to understand.
Signed-off-by: Steven J. Hill <sjhill@mips.com>
---
arch/mips/mm/Makefile | 4 +--
arch/mips/mm/page-funcs.S | 49 +++++++++++++++++++++++++++++++++
arch/mips/mm/page.c | 67 ++++++++++++---------------------------------
3 files changed, 69 insertions(+), 51 deletions(-)
create mode 100644 arch/mips/mm/page-funcs.S
diff --git a/arch/mips/mm/Makefile b/arch/mips/mm/Makefile
index 4aa2028..fd6203f 100644
--- a/arch/mips/mm/Makefile
+++ b/arch/mips/mm/Makefile
@@ -3,8 +3,8 @@
#
obj-y += cache.o dma-default.o extable.o fault.o \
- gup.o init.o mmap.o page.o tlbex.o \
- tlbex-fault.o uasm.o
+ gup.o init.o mmap.o page.o page-funcs.o \
+ tlbex.o tlbex-fault.o uasm.o
obj-$(CONFIG_32BIT) += ioremap.o pgtable-32.o
obj-$(CONFIG_64BIT) += pgtable-64.o
diff --git a/arch/mips/mm/page-funcs.S b/arch/mips/mm/page-funcs.S
new file mode 100644
index 0000000..901c2bc
--- /dev/null
+++ b/arch/mips/mm/page-funcs.S
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ *
+ * Micro-assembler generated clear_page/copy_page functions.
+ *
+ * Copyright (C) 2012 MIPS Technologies, Inc.
+ */
+#include <asm/asm.h>
+#include <asm/regdef.h>
+
+/*
+ * Maximum sizes:
+ *
+ * R4000 128 bytes S-cache: 0x058 bytes
+ * R4600 v1.7: 0x05c bytes
+ * R4600 v2.0: 0x060 bytes
+ * With prefetching, 16 word strides 0x120 bytes
+ */
+EXPORT(__clear_page_start)
+#ifdef CONFIG_SIBYTE_DMA_PAGEOPS
+LEAF(clear_page_cpu)
+#else
+LEAF(clear_page)
+#endif
+1: j 1b /* Dummy, will be replaced. */
+ .space 288
+END(clear_page)
+EXPORT(__clear_page_end)
+
+/*
+ * Maximum sizes:
+ *
+ * R4000 128 bytes S-cache: 0x11c bytes
+ * R4600 v1.7: 0x080 bytes
+ * R4600 v2.0: 0x07c bytes
+ * With prefetching, 16 word strides 0x540 bytes
+ */
+EXPORT(__copy_page_start)
+#ifdef CONFIG_SIBYTE_DMA_PAGEOPS
+LEAF(copy_page_cpu)
+#else
+LEAF(copy_page)
+#endif
+1: j 1b /* Dummy, will be replaced. */
+ .space 1344
+END(copy_page)
+EXPORT(__copy_page_end)
diff --git a/arch/mips/mm/page.c b/arch/mips/mm/page.c
index cc0b626..98f530e 100644
--- a/arch/mips/mm/page.c
+++ b/arch/mips/mm/page.c
@@ -6,6 +6,7 @@
* Copyright (C) 2003, 04, 05 Ralf Baechle (ralf@linux-mips.org)
* Copyright (C) 2007 Maciej W. Rozycki
* Copyright (C) 2008 Thiemo Seufer
+ * Copyright (C) 2012 MIPS Technologies, Inc.
*/
#include <linux/init.h>
#include <linux/kernel.h>
@@ -71,45 +72,6 @@ static struct uasm_reloc __cpuinitdata relocs[5];
#define cpu_is_r4600_v1_x() ((read_c0_prid() & 0xfffffff0) == 0x00002010)
#define cpu_is_r4600_v2_x() ((read_c0_prid() & 0xfffffff0) == 0x00002020)
-/*
- * Maximum sizes:
- *
- * R4000 128 bytes S-cache: 0x058 bytes
- * R4600 v1.7: 0x05c bytes
- * R4600 v2.0: 0x060 bytes
- * With prefetching, 16 word strides 0x120 bytes
- */
-
-static u32 clear_page_array[0x120 / 4];
-
-#ifdef CONFIG_SIBYTE_DMA_PAGEOPS
-void clear_page_cpu(void *page) __attribute__((alias("clear_page_array")));
-#else
-void clear_page(void *page) __attribute__((alias("clear_page_array")));
-#endif
-
-EXPORT_SYMBOL(clear_page);
-
-/*
- * Maximum sizes:
- *
- * R4000 128 bytes S-cache: 0x11c bytes
- * R4600 v1.7: 0x080 bytes
- * R4600 v2.0: 0x07c bytes
- * With prefetching, 16 word strides 0x540 bytes
- */
-static u32 copy_page_array[0x540 / 4];
-
-#ifdef CONFIG_SIBYTE_DMA_PAGEOPS
-void
-copy_page_cpu(void *to, void *from) __attribute__((alias("copy_page_array")));
-#else
-void copy_page(void *to, void *from) __attribute__((alias("copy_page_array")));
-#endif
-
-EXPORT_SYMBOL(copy_page);
-
-
static int pref_bias_clear_store __cpuinitdata;
static int pref_bias_copy_load __cpuinitdata;
static int pref_bias_copy_store __cpuinitdata;
@@ -282,10 +244,15 @@ static inline void __cpuinit build_clear_pref(u32 **buf, int off)
}
}
+extern u32 __clear_page_start;
+extern u32 __clear_page_end;
+extern u32 __copy_page_start;
+extern u32 __copy_page_end;
+
void __cpuinit build_clear_page(void)
{
int off;
- u32 *buf = (u32 *)&clear_page_array;
+ u32 *buf = &__clear_page_start;
struct uasm_label *l = labels;
struct uasm_reloc *r = relocs;
int i;
@@ -356,17 +323,17 @@ void __cpuinit build_clear_page(void)
uasm_i_jr(&buf, RA);
uasm_i_nop(&buf);
- BUG_ON(buf > clear_page_array + ARRAY_SIZE(clear_page_array));
+ BUG_ON(buf > &__clear_page_end);
uasm_resolve_relocs(relocs, labels);
pr_debug("Synthesized clear page handler (%u instructions).\n",
- (u32)(buf - clear_page_array));
+ (u32)(buf - &__clear_page_start));
pr_debug("\t.set push\n");
pr_debug("\t.set noreorder\n");
- for (i = 0; i < (buf - clear_page_array); i++)
- pr_debug("\t.word 0x%08x\n", clear_page_array[i]);
+ for (i = 0; i < (buf - &__clear_page_start); i++)
+ pr_debug("\t.word 0x%08x\n", (&__clear_page_start)[i]);
pr_debug("\t.set pop\n");
}
@@ -427,7 +394,7 @@ static inline void build_copy_store_pref(u32 **buf, int off)
void __cpuinit build_copy_page(void)
{
int off;
- u32 *buf = (u32 *)©_page_array;
+ u32 *buf = &__copy_page_start;
struct uasm_label *l = labels;
struct uasm_reloc *r = relocs;
int i;
@@ -595,21 +562,23 @@ void __cpuinit build_copy_page(void)
uasm_i_jr(&buf, RA);
uasm_i_nop(&buf);
- BUG_ON(buf > copy_page_array + ARRAY_SIZE(copy_page_array));
+ BUG_ON(buf > &__copy_page_end);
uasm_resolve_relocs(relocs, labels);
pr_debug("Synthesized copy page handler (%u instructions).\n",
- (u32)(buf - copy_page_array));
+ (u32)(buf - &__copy_page_start));
pr_debug("\t.set push\n");
pr_debug("\t.set noreorder\n");
- for (i = 0; i < (buf - copy_page_array); i++)
- pr_debug("\t.word 0x%08x\n", copy_page_array[i]);
+ for (i = 0; i < (buf - &__copy_page_start); i++)
+ pr_debug("\t.word 0x%08x\n", (&__copy_page_start)[i]);
pr_debug("\t.set pop\n");
}
#ifdef CONFIG_SIBYTE_DMA_PAGEOPS
+extern void clear_page_cpu(void *page);
+extern void copy_page_cpu(void *to, void *from);
/*
* Pad descriptors to cacheline, since each is exclusively owned by a
--
1.7.10
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] MIPS: Refactor 'clear_page' and 'copy_page' functions.
2012-05-24 20:38 [PATCH] MIPS: Refactor 'clear_page' and 'copy_page' functions Steven J. Hill
@ 2012-05-30 18:10 ` David Daney
2012-05-30 21:01 ` Ralf Baechle
0 siblings, 1 reply; 4+ messages in thread
From: David Daney @ 2012-05-30 18:10 UTC (permalink / raw)
To: Steven J. Hill, ralf; +Cc: linux-mips
On 05/24/2012 01:38 PM, Steven J. Hill wrote:
> From: "Steven J. Hill"<sjhill@mips.com>
>
> Remove usage of the '__attribute__((alias("...")))' hack that aliased
> to integer arrays containing micro-assembled instructions. This hack
> breaks when building a microMIPS kernel. It also makes the code much
> easier to understand.
>
> Signed-off-by: Steven J. Hill<sjhill@mips.com>
Looks good to (and even works for) me:
Acked-by: David Daney <david.daney@cavium.com>
> ---
> arch/mips/mm/Makefile | 4 +--
> arch/mips/mm/page-funcs.S | 49 +++++++++++++++++++++++++++++++++
> arch/mips/mm/page.c | 67 ++++++++++++---------------------------------
> 3 files changed, 69 insertions(+), 51 deletions(-)
> create mode 100644 arch/mips/mm/page-funcs.S
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] MIPS: Refactor 'clear_page' and 'copy_page' functions.
2012-05-30 18:10 ` David Daney
@ 2012-05-30 21:01 ` Ralf Baechle
2012-05-30 21:27 ` Ralf Baechle
0 siblings, 1 reply; 4+ messages in thread
From: Ralf Baechle @ 2012-05-30 21:01 UTC (permalink / raw)
To: David Daney; +Cc: Steven J. Hill, linux-mips
On Wed, May 30, 2012 at 11:10:23AM -0700, David Daney wrote:
> On 05/24/2012 01:38 PM, Steven J. Hill wrote:
> >From: "Steven J. Hill"<sjhill@mips.com>
> >
> >Remove usage of the '__attribute__((alias("...")))' hack that aliased
> >to integer arrays containing micro-assembled instructions. This hack
> >breaks when building a microMIPS kernel. It also makes the code much
> >easier to understand.
> >
> >Signed-off-by: Steven J. Hill<sjhill@mips.com>
>
> Looks good to (and even works for) me:
>
> Acked-by: David Daney <david.daney@cavium.com>
I have to admit that the attribute hack was a desperate attempt at
avoiding the last bit of assembler code for the page functions. But somehow
the patch isn't quite ripe yet. Building malta_defconfig from
7a3434a78b36be2d398a46fb505a3196a9df4a60 with this patch applied on top
I'm getting:
MODPOST 413 modules
ERROR: "copy_page" [fs/fuse/fuse.ko] undefined!
ERROR: "clear_page" [fs/fuse/fuse.ko] undefined!
ERROR: "clear_page" [drivers/net/ethernet/toshiba/tc35815.ko] undefined!
Ralf
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] MIPS: Refactor 'clear_page' and 'copy_page' functions.
2012-05-30 21:01 ` Ralf Baechle
@ 2012-05-30 21:27 ` Ralf Baechle
0 siblings, 0 replies; 4+ messages in thread
From: Ralf Baechle @ 2012-05-30 21:27 UTC (permalink / raw)
To: David Daney; +Cc: Steven J. Hill, linux-mips
On Wed, May 30, 2012 at 10:01:41PM +0100, Ralf Baechle wrote:
> > On 05/24/2012 01:38 PM, Steven J. Hill wrote:
> > >From: "Steven J. Hill"<sjhill@mips.com>
> > >
> > >Remove usage of the '__attribute__((alias("...")))' hack that aliased
> > >to integer arrays containing micro-assembled instructions. This hack
> > >breaks when building a microMIPS kernel. It also makes the code much
> > >easier to understand.
> > >
> > >Signed-off-by: Steven J. Hill<sjhill@mips.com>
> >
> > Looks good to (and even works for) me:
> >
> > Acked-by: David Daney <david.daney@cavium.com>
>
> I have to admit that the attribute hack was a desperate attempt at
> avoiding the last bit of assembler code for the page functions. But somehow
> the patch isn't quite ripe yet. Building malta_defconfig from
> 7a3434a78b36be2d398a46fb505a3196a9df4a60 with this patch applied on top
> I'm getting:
>
> MODPOST 413 modules
> ERROR: "copy_page" [fs/fuse/fuse.ko] undefined!
> ERROR: "clear_page" [fs/fuse/fuse.ko] undefined!
> ERROR: "clear_page" [drivers/net/ethernet/toshiba/tc35815.ko] undefined!
And with that fixed (trivial) I'm getting:
AS arch/mips/mm/page-funcs.o
arch/mips/mm/page-funcs.S: Assembler messages:
arch/mips/mm/page-funcs.S:29: Warning: .end symbol does not match .ent symbol.
arch/mips/mm/page-funcs.S:48: Warning: .end symbol does not match .ent symbol.
{standard input}: Error: .size expression for clear_page does not evaluate to a constant
{standard input}: Error: .size expression for copy_page does not evaluate to a constant
Ralf
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-05-30 21:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-24 20:38 [PATCH] MIPS: Refactor 'clear_page' and 'copy_page' functions Steven J. Hill
2012-05-30 18:10 ` David Daney
2012-05-30 21:01 ` Ralf Baechle
2012-05-30 21:27 ` Ralf Baechle
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.