2008-06-13 13:10:17

by David Howells

[permalink] [raw]
Subject: [PATCH 1/2] MN10300: Export certain arch symbols required to build allmodconfig

Export kernel_thread() and empty_zero_page so that allmodconfig can be built
for MN10300.

Signed-off-by: David Howells <[email protected]>
---

arch/mn10300/kernel/mn10300_ksyms.c | 3 +++
arch/mn10300/kernel/process.c | 1 +
2 files changed, 4 insertions(+), 0 deletions(-)


diff --git a/arch/mn10300/kernel/mn10300_ksyms.c b/arch/mn10300/kernel/mn10300_ksyms.c
index 6d19628..544ee1a 100644
--- a/arch/mn10300/kernel/mn10300_ksyms.c
+++ b/arch/mn10300/kernel/mn10300_ksyms.c
@@ -10,8 +10,11 @@
*/
#include <linux/module.h>
#include <asm/uaccess.h>
+#include <asm/pgtable.h>


+EXPORT_SYMBOL(empty_zero_page);
+
EXPORT_SYMBOL(change_bit);
EXPORT_SYMBOL(test_and_change_bit);

diff --git a/arch/mn10300/kernel/process.c b/arch/mn10300/kernel/process.c
index 3b0d579..345dadb 100644
--- a/arch/mn10300/kernel/process.c
+++ b/arch/mn10300/kernel/process.c
@@ -154,6 +154,7 @@ int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, &regs, 0,
NULL, NULL);
}
+EXPORT_SYMBOL(kernel_thread);

/*
* free current thread data structures etc..


2008-06-13 13:10:35

by David Howells

[permalink] [raw]
Subject: [PATCH 2/2] MN10300: Provide __ucmpdi2() for MN10300

Provide __ucmpdi2() for MN10300 so that allmodconfig can be built.

Signed-off-by: David Howells <[email protected]>
---

arch/mn10300/kernel/mn10300_ksyms.c | 2 ++
arch/mn10300/lib/Makefile | 2 +-
arch/mn10300/lib/__ucmpdi2.S | 43 +++++++++++++++++++++++++++++++++++
3 files changed, 46 insertions(+), 1 deletions(-)
create mode 100644 arch/mn10300/lib/__ucmpdi2.S


diff --git a/arch/mn10300/kernel/mn10300_ksyms.c b/arch/mn10300/kernel/mn10300_ksyms.c
index 544ee1a..f9eb975 100644
--- a/arch/mn10300/kernel/mn10300_ksyms.c
+++ b/arch/mn10300/kernel/mn10300_ksyms.c
@@ -34,7 +34,9 @@ extern u64 __ashrdi3(u64, unsigned);
extern u64 __ashldi3(u64, unsigned);
extern u64 __lshrdi3(u64, unsigned);
extern s64 __negdi2(s64);
+extern int __ucmpdi2(u64, u64);
EXPORT_SYMBOL(__ashrdi3);
EXPORT_SYMBOL(__ashldi3);
EXPORT_SYMBOL(__lshrdi3);
EXPORT_SYMBOL(__negdi2);
+EXPORT_SYMBOL(__ucmpdi2);
diff --git a/arch/mn10300/lib/Makefile b/arch/mn10300/lib/Makefile
index fdfa9ec..0cd2346 100644
--- a/arch/mn10300/lib/Makefile
+++ b/arch/mn10300/lib/Makefile
@@ -4,4 +4,4 @@

lib-y = delay.o usercopy.o checksum.o bitops.o memcpy.o memmove.o memset.o
lib-y += do_csum.o
-lib-y += __ashldi3.o __ashrdi3.o __lshrdi3.o negdi2.o
+lib-y += __ashldi3.o __ashrdi3.o __lshrdi3.o negdi2.o __ucmpdi2.o
diff --git a/arch/mn10300/lib/__ucmpdi2.S b/arch/mn10300/lib/__ucmpdi2.S
new file mode 100644
index 0000000..29633fd
--- /dev/null
+++ b/arch/mn10300/lib/__ucmpdi2.S
@@ -0,0 +1,43 @@
+/* __ucmpdi2.S: 64-bit unsigned compare
+ *
+ * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells ([email protected])
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+
+ .text
+ .p2align 4
+
+###############################################################################
+#
+# int __ucmpdi2(unsigned long long a [D0:D1],
+# unsigned long long b [(SP,12),(SP,16)])
+#
+# - returns 0, 1, or 2 as a <, =, > b respectively.
+#
+###############################################################################
+ .globl __ucmpdi2
+ .type __ucmpdi2,@function
+__ucmpdi2:
+ mov (12,sp),a0 # b.lsw
+ mov (16,sp),a1 # b.msw
+
+ sub a0,d0
+ subc a1,d1 # may clear Z, never sets it
+ bne __ucmpdi2_differ # a.msw != b.msw
+ mov +1,d0
+ rets
+
+__ucmpdi2_differ:
+ # C flag is set if LE, clear if GE
+ subc d0,d0 # -1 if LE, 0 if GE
+ add +1,d0 # 0 if LE, 1 if GE
+ add d0,d0 # 0 if LE, 2 if GE
+ rets
+
+ .size __ucmpdi2, .-__ucmpdi2

2008-06-30 23:19:29

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH 2/2] MN10300: Provide __ucmpdi2() for MN10300

On Fri, 13 Jun 2008 14:09:58 +0100
David Howells <[email protected]> wrote:

> Provide __ucmpdi2() for MN10300 so that allmodconfig can be built.

Well... x86 has this problem as well, and when it pops up we address
it by going in and looking at the codesite which is generating the call
and fixing it. And I do mean "fixing", because it's often the case
that the caller was doing something silly and inefficient.

So are you sure that we should do this, rather than massaging the
callers?

2008-07-02 05:10:42

by Adrian Bunk

[permalink] [raw]
Subject: [RFC: 2.6 patch] remove the switch in b43legacy_dma_init()

On Mon, Jun 30, 2008 at 04:18:25PM -0700, Andrew Morton wrote:
> On Fri, 13 Jun 2008 14:09:58 +0100
> David Howells <[email protected]> wrote:
>
> > Provide __ucmpdi2() for MN10300 so that allmodconfig can be built.
>
> Well... x86 has this problem as well, and when it pops up we address
> it by going in and looking at the codesite which is generating the call
> and fixing it. And I do mean "fixing", because it's often the case
> that the caller was doing something silly and inefficient.

In this case I'd blame the gcc 3.4 fork used by MN10300.

> So are you sure that we should do this, rather than massaging the
> callers?

Patch to fix the callers (if wanted) is below.

cu
Adrian


<-- snip -->


The gcc 3.4 fork used to compile the MN10300 port emits unwanted
__ucmpdi2() calls for this switch on a 64bit value.

Fix it by transforming the switch to equivalent "if ... else if ..."
statements.

Signed-off-by: Adrian Bunk <[email protected]>

---
a89c72d736986777b2cc4e07589aa46e957c15a5
diff --git a/drivers/net/wireless/b43legacy/dma.c b/drivers/net/wireless/b43legacy/dma.c
index c990f87..794dc83 100644
--- a/drivers/net/wireless/b43legacy/dma.c
+++ b/drivers/net/wireless/b43legacy/dma.c
@@ -1028,19 +1028,15 @@ int b43legacy_dma_init(struct b43legacy_wldev *dev)
enum b43legacy_dmatype type;

dmamask = supported_dma_mask(dev);
- switch (dmamask) {
- default:
- B43legacy_WARN_ON(1);
- case DMA_30BIT_MASK:
+
+ if (dmamask == DMA_30BIT_MASK)
type = B43legacy_DMA_30BIT;
- break;
- case DMA_32BIT_MASK:
+ else if (dmamask == DMA_32BIT_MASK)
type = B43legacy_DMA_32BIT;
- break;
- case DMA_64BIT_MASK:
+ else if (dmamask == DMA_64BIT_MASK)
type = B43legacy_DMA_64BIT;
- break;
- }
+ else
+ B43legacy_WARN_ON(1);

err = ssb_dma_set_mask(dev->dev, dmamask);
if (err) {