All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/17] Blackfin arch conversion to asm-generic
@ 2009-06-14 12:01 Mike Frysinger
  2009-06-14 12:01 ` [PATCH 01/17] Blackfin: use common test_bit() rather than __test_bit() Mike Frysinger
                   ` (17 more replies)
  0 siblings, 18 replies; 33+ messages in thread
From: Mike Frysinger @ 2009-06-14 12:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: uclinux-dist-devel

With the new asm-generic code in place, we can convert the Blackfin arch
over to it.  This in turn fixes a few outdated headers and rather than
manually update them, just drop our version in favor of the asm-generic
one.  I've tried to group the changes somewhat logically so that if some
conversion did go bad, it'll be easier to narrow things down with bisect
rather than one large changeset.

Mike Frysinger (17):
  Blackfin: use common test_bit() rather than __test_bit()
  Blackfin: pull in asm/io.h in ksyms for prototypes
  Blackfin: only build irqpanic.c when needed
  Blackfin: convert asm/ioctls.h to asm-generic/ioctls.h
  Blackfin: convert to generic checksum code
  Blackfin: convert shm/sysv/ipc to asm-generic
  Blackfin: convert user/elf to asm-generic
  Blackfin: convert socket/poll to asm-generic
  Blackfin: convert simple headers to asm-generic
  Blackfin: convert dma/pci to asm-generic
  Blackfin: convert termios to asm-generic
  Blackfin: convert locking primitives to asm-generic
  Blackfin: convert signal/mmap to asm-generic
  Blackfin: convert irq/process to asm-generic
  Blackfin: convert types to asm-generic
  Blackfin: convert page/tlb to asm-generic
  Blackfin: convert uaccess to asm-generic

 arch/blackfin/Kconfig                         |    3 +
 arch/blackfin/include/asm/atomic.h            |  109 +----------
 arch/blackfin/include/asm/auxvec.h            |    5 +-
 arch/blackfin/include/asm/bitops.h            |  198 +------------------
 arch/blackfin/include/asm/bugs.h              |   17 +--
 arch/blackfin/include/asm/checksum.h          |   72 +-------
 arch/blackfin/include/asm/cputime.h           |    5 -
 arch/blackfin/include/asm/current.h           |   24 +---
 arch/blackfin/include/asm/device.h            |    6 -
 arch/blackfin/include/asm/dma-mapping.h       |   91 +--------
 arch/blackfin/include/asm/dma.h               |    5 +-
 arch/blackfin/include/asm/elf.h               |    2 +-
 arch/blackfin/include/asm/emergency-restart.h |    5 -
 arch/blackfin/include/asm/errno.h             |    7 +-
 arch/blackfin/include/asm/fb.h                |   13 +--
 arch/blackfin/include/asm/futex.h             |    5 -
 arch/blackfin/include/asm/hardirq.h           |   36 +---
 arch/blackfin/include/asm/hw_irq.h            |    7 +-
 arch/blackfin/include/asm/io.h                |    1 -
 arch/blackfin/include/asm/ioctls.h            |   84 +--------
 arch/blackfin/include/asm/ipcbuf.h            |   31 +---
 arch/blackfin/include/asm/irq.h               |    5 +-
 arch/blackfin/include/asm/kmap_types.h        |   22 +--
 arch/blackfin/include/asm/local.h             |    5 -
 arch/blackfin/include/asm/mman.h              |   44 +----
 arch/blackfin/include/asm/msgbuf.h            |   32 +---
 arch/blackfin/include/asm/mutex.h             |    2 +-
 arch/blackfin/include/asm/page.h              |   85 +--------
 arch/blackfin/include/asm/param.h             |   23 +--
 arch/blackfin/include/asm/pci.h               |  149 +--------------
 arch/blackfin/include/asm/percpu.h            |    5 -
 arch/blackfin/include/asm/pgalloc.h           |    9 +-
 arch/blackfin/include/asm/poll.h              |   21 +--
 arch/blackfin/include/asm/posix_types.h       |   56 +-----
 arch/blackfin/include/asm/processor.h         |   35 +---
 arch/blackfin/include/asm/resource.h          |    5 -
 arch/blackfin/include/asm/scatterlist.h       |   29 +---
 arch/blackfin/include/asm/segment.h           |    8 +-
 arch/blackfin/include/asm/sembuf.h            |   26 +---
 arch/blackfin/include/asm/serial.h            |    6 +-
 arch/blackfin/include/asm/setup.h             |   18 +--
 arch/blackfin/include/asm/shmbuf.h            |   43 +----
 arch/blackfin/include/asm/shmparam.h          |    7 +-
 arch/blackfin/include/asm/signal.h            |  159 +---------------
 arch/blackfin/include/asm/socket.h            |   60 +------
 arch/blackfin/include/asm/sockios.h           |   14 +--
 arch/blackfin/include/asm/spinlock.h          |    6 +
 arch/blackfin/include/asm/statfs.h            |    5 -
 arch/blackfin/include/asm/swab.h              |    6 +-
 arch/blackfin/include/asm/termbits.h          |  199 +------------------
 arch/blackfin/include/asm/termios.h           |   95 +---------
 arch/blackfin/include/asm/tlbflush.h          |   57 +------
 arch/blackfin/include/asm/topology.h          |    5 -
 arch/blackfin/include/asm/types.h             |   37 +----
 arch/blackfin/include/asm/uaccess.h           |  265 +------------------------
 arch/blackfin/include/asm/ucontext.h          |   18 +--
 arch/blackfin/include/asm/unaligned.h         |   12 +-
 arch/blackfin/include/asm/user.h              |   90 +---------
 arch/blackfin/kernel/bfin_ksyms.c             |    1 +
 arch/blackfin/kernel/process.c                |   23 +++
 arch/blackfin/lib/Makefile                    |    2 +-
 arch/blackfin/lib/checksum.c                  |  145 --------------
 arch/blackfin/mach-common/Makefile            |    3 +-
 arch/blackfin/mach-common/ints-priority.c     |    4 +-
 arch/blackfin/mach-common/irqpanic.c          |   11 +-
 65 files changed, 141 insertions(+), 2437 deletions(-)
 delete mode 100644 arch/blackfin/lib/checksum.c


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 01/17] Blackfin: use common test_bit() rather than __test_bit()
  2009-06-14 12:01 [PATCH 00/17] Blackfin arch conversion to asm-generic Mike Frysinger
@ 2009-06-14 12:01 ` Mike Frysinger
  2009-06-14 12:01 ` [PATCH 02/17] Blackfin: pull in asm/io.h in ksyms for prototypes Mike Frysinger
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Mike Frysinger @ 2009-06-14 12:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: uclinux-dist-devel

Convert to test_bit() as that is what pretty much everyone uses and allows
us to migrate asm/bitops.h to the asm-generic version.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 arch/blackfin/mach-common/ints-priority.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/blackfin/mach-common/ints-priority.c b/arch/blackfin/mach-common/ints-priority.c
index 351afd0..af70f09 100644
--- a/arch/blackfin/mach-common/ints-priority.c
+++ b/arch/blackfin/mach-common/ints-priority.c
@@ -472,7 +472,7 @@ static int bfin_gpio_irq_type(unsigned int irq, unsigned int type)
 
 	if (type == IRQ_TYPE_PROBE) {
 		/* only probe unenabled GPIO interrupt lines */
-		if (__test_bit(gpionr, gpio_enabled))
+		if (test_bit(gpionr, gpio_enabled))
 			return 0;
 		type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING;
 	}
@@ -782,7 +782,7 @@ static int bfin_gpio_irq_type(unsigned int irq, unsigned int type)
 
 	if (type == IRQ_TYPE_PROBE) {
 		/* only probe unenabled GPIO interrupt lines */
-		if (__test_bit(gpionr, gpio_enabled))
+		if (test_bit(gpionr, gpio_enabled))
 			return 0;
 		type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING;
 	}
-- 
1.6.3.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 02/17] Blackfin: pull in asm/io.h in ksyms for prototypes
  2009-06-14 12:01 [PATCH 00/17] Blackfin arch conversion to asm-generic Mike Frysinger
  2009-06-14 12:01 ` [PATCH 01/17] Blackfin: use common test_bit() rather than __test_bit() Mike Frysinger
@ 2009-06-14 12:01 ` Mike Frysinger
  2009-06-14 12:01 ` [PATCH 03/17] Blackfin: only build irqpanic.c when needed Mike Frysinger
                   ` (15 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Mike Frysinger @ 2009-06-14 12:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: uclinux-dist-devel

Make sure we pull in asm/io.h when exporting symbols for the I/O functions
so we don't end up with a build failure due to missing prototypes.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 arch/blackfin/kernel/bfin_ksyms.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/blackfin/kernel/bfin_ksyms.c b/arch/blackfin/kernel/bfin_ksyms.c
index aa05e63..ed8392c 100644
--- a/arch/blackfin/kernel/bfin_ksyms.c
+++ b/arch/blackfin/kernel/bfin_ksyms.c
@@ -10,6 +10,7 @@
 #include <linux/uaccess.h>
 
 #include <asm/cacheflush.h>
+#include <asm/io.h>
 
 /* Allow people to have their own Blackfin exception handler in a module */
 EXPORT_SYMBOL(bfin_return_from_exception);
-- 
1.6.3.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 03/17] Blackfin: only build irqpanic.c when needed
  2009-06-14 12:01 [PATCH 00/17] Blackfin arch conversion to asm-generic Mike Frysinger
  2009-06-14 12:01 ` [PATCH 01/17] Blackfin: use common test_bit() rather than __test_bit() Mike Frysinger
  2009-06-14 12:01 ` [PATCH 02/17] Blackfin: pull in asm/io.h in ksyms for prototypes Mike Frysinger
@ 2009-06-14 12:01 ` Mike Frysinger
  2009-06-14 12:01 ` [PATCH 04/17] Blackfin: convert asm/ioctls.h to asm-generic/ioctls.h Mike Frysinger
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Mike Frysinger @ 2009-06-14 12:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: uclinux-dist-devel

The irq_panic function is only used when CONFIG_DEBUG_ICACHE_CHECK is
enabled, so move the conditional build to the Makefile rather than
wrapping all of the contents of the file.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 arch/blackfin/mach-common/Makefile   |    3 ++-
 arch/blackfin/mach-common/irqpanic.c |   11 ++---------
 2 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/arch/blackfin/mach-common/Makefile b/arch/blackfin/mach-common/Makefile
index 1f3228e..dd8b2dc 100644
--- a/arch/blackfin/mach-common/Makefile
+++ b/arch/blackfin/mach-common/Makefile
@@ -4,7 +4,7 @@
 
 obj-y := \
 	cache.o cache-c.o entry.o head.o \
-	interrupt.o irqpanic.o arch_checks.o ints-priority.o
+	interrupt.o arch_checks.o ints-priority.o
 
 obj-$(CONFIG_BFIN_ICACHE_LOCK) += lock.o
 obj-$(CONFIG_PM)          += pm.o dpmc_modes.o
@@ -12,3 +12,4 @@ obj-$(CONFIG_CPU_FREQ)    += cpufreq.o
 obj-$(CONFIG_CPU_VOLTAGE) += dpmc.o
 obj-$(CONFIG_SMP)         += smp.o
 obj-$(CONFIG_BFIN_KERNEL_CLOCK) += clocks-init.o
+obj-$(CONFIG_DEBUG_ICACHE_CHECK) += irqpanic.o
diff --git a/arch/blackfin/mach-common/irqpanic.c b/arch/blackfin/mach-common/irqpanic.c
index 05004df..883e324 100644
--- a/arch/blackfin/mach-common/irqpanic.c
+++ b/arch/blackfin/mach-common/irqpanic.c
@@ -30,21 +30,17 @@
 #include <linux/module.h>
 #include <linux/kernel_stat.h>
 #include <linux/sched.h>
-#include <asm/traps.h>
 #include <asm/blackfin.h>
 
-#ifdef CONFIG_DEBUG_ICACHE_CHECK
 #define L1_ICACHE_START 0xffa10000
 #define L1_ICACHE_END   0xffa13fff
-void irq_panic(int reason, struct pt_regs *regs) __attribute__ ((l1_text));
-#endif
 
 /*
  * irq_panic - calls panic with string setup
  */
+__attribute__ ((l1_text))
 asmlinkage void irq_panic(int reason, struct pt_regs *regs)
 {
-#ifdef CONFIG_DEBUG_ICACHE_CHECK
 	unsigned int cmd, tag, ca, cache_hi, cache_lo, *pa;
 	unsigned short i, j, die;
 	unsigned int bad[10][6];
@@ -126,9 +122,6 @@ asmlinkage void irq_panic(int reason, struct pt_regs *regs)
 			     bad[j][3], bad[j][4], bad[j][5]);
 		}
 		panic("icache coherency error");
-	} else {
+	} else
 		printk(KERN_EMERG "icache checked, and OK\n");
-	}
-#endif
-
 }
-- 
1.6.3.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 04/17] Blackfin: convert asm/ioctls.h to asm-generic/ioctls.h
  2009-06-14 12:01 [PATCH 00/17] Blackfin arch conversion to asm-generic Mike Frysinger
                   ` (2 preceding siblings ...)
  2009-06-14 12:01 ` [PATCH 03/17] Blackfin: only build irqpanic.c when needed Mike Frysinger
@ 2009-06-14 12:01 ` Mike Frysinger
  2009-06-14 12:01 ` [PATCH 05/17] Blackfin: convert to generic checksum code Mike Frysinger
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Mike Frysinger @ 2009-06-14 12:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: uclinux-dist-devel

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 arch/blackfin/include/asm/ioctls.h |   84 +-----------------------------------
 1 files changed, 2 insertions(+), 82 deletions(-)

diff --git a/arch/blackfin/include/asm/ioctls.h b/arch/blackfin/include/asm/ioctls.h
index 895e317..eca8d75 100644
--- a/arch/blackfin/include/asm/ioctls.h
+++ b/arch/blackfin/include/asm/ioctls.h
@@ -1,87 +1,7 @@
 #ifndef __ARCH_BFIN_IOCTLS_H__
 #define __ARCH_BFIN_IOCTLS_H__
 
-#include <asm/ioctl.h>
-
-/* 0x54 is just a magic number to make these relatively unique ('T') */
-
-#define TCGETS		0x5401
-#define TCSETS		0x5402
-#define TCSETSW		0x5403
-#define TCSETSF		0x5404
-#define TCGETA		0x5405
-#define TCSETA		0x5406
-#define TCSETAW		0x5407
-#define TCSETAF		0x5408
-#define TCSBRK		0x5409
-#define TCXONC		0x540A
-#define TCFLSH		0x540B
-#define TIOCEXCL	0x540C
-#define TIOCNXCL	0x540D
-#define TIOCSCTTY	0x540E
-#define TIOCGPGRP	0x540F
-#define TIOCSPGRP	0x5410
-#define TIOCOUTQ	0x5411
-#define TIOCSTI		0x5412
-#define TIOCGWINSZ	0x5413
-#define TIOCSWINSZ	0x5414
-#define TIOCMGET	0x5415
-#define TIOCMBIS	0x5416
-#define TIOCMBIC	0x5417
-#define TIOCMSET	0x5418
-#define TIOCGSOFTCAR	0x5419
-#define TIOCSSOFTCAR	0x541A
-#define FIONREAD	0x541B
-#define TIOCINQ		FIONREAD
-#define TIOCLINUX	0x541C
-#define TIOCCONS	0x541D
-#define TIOCGSERIAL	0x541E
-#define TIOCSSERIAL	0x541F
-#define TIOCPKT		0x5420
-#define FIONBIO		0x5421
-#define TIOCNOTTY	0x5422
-#define TIOCSETD	0x5423
-#define TIOCGETD	0x5424
-#define TCSBRKP		0x5425	/* Needed for POSIX tcsendbreak() */
-#define TIOCTTYGSTRUCT	0x5426	/* For debugging only */
-#define TIOCSBRK	0x5427	/* BSD compatibility */
-#define TIOCCBRK	0x5428	/* BSD compatibility */
-#define TIOCGSID	0x5429	/* Return the session ID of FD */
-#define TCGETS2		_IOR('T', 0x2A, struct termios2)
-#define TCSETS2		_IOW('T', 0x2B, struct termios2)
-#define TCSETSW2	_IOW('T', 0x2C, struct termios2)
-#define TCSETSF2	_IOW('T', 0x2D, struct termios2)
-/* Get Pty Number (of pty-mux device) */
-#define TIOCGPTN	_IOR('T', 0x30, unsigned int)
-#define TIOCSPTLCK	_IOW('T', 0x31, int)	/* Lock/unlock Pty */
-
-#define FIONCLEX	0x5450	/* these numbers need to be adjusted. */
-#define FIOCLEX		0x5451
-#define FIOASYNC	0x5452
-#define TIOCSERCONFIG	0x5453
-#define TIOCSERGWILD	0x5454
-#define TIOCSERSWILD	0x5455
-#define TIOCGLCKTRMIOS	0x5456
-#define TIOCSLCKTRMIOS	0x5457
-#define TIOCSERGSTRUCT	0x5458	/* For debugging only */
-#define TIOCSERGETLSR   0x5459	/* Get line status register */
-#define TIOCSERGETMULTI 0x545A	/* Get multiport config  */
-#define TIOCSERSETMULTI 0x545B	/* Set multiport config */
-
-#define TIOCMIWAIT	0x545C	/* wait for a change on serial input line(s) */
-#define TIOCGICOUNT	0x545D	/* read serial port inline interrupt counts */
-
 #define FIOQSIZE	0x545E
+#include <asm-generic/ioctls.h>
 
-/* Used for packet mode */
-#define TIOCPKT_DATA		 0
-#define TIOCPKT_FLUSHREAD	 1
-#define TIOCPKT_FLUSHWRITE	 2
-#define TIOCPKT_STOP		 4
-#define TIOCPKT_START		 8
-#define TIOCPKT_NOSTOP		16
-#define TIOCPKT_DOSTOP		32
-
-#define TIOCSER_TEMT    0x01	/* Transmitter physically empty */
-
-#endif				/* __ARCH_BFIN_IOCTLS_H__ */
+#endif
-- 
1.6.3.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 05/17] Blackfin: convert to generic checksum code
  2009-06-14 12:01 [PATCH 00/17] Blackfin arch conversion to asm-generic Mike Frysinger
                   ` (3 preceding siblings ...)
  2009-06-14 12:01 ` [PATCH 04/17] Blackfin: convert asm/ioctls.h to asm-generic/ioctls.h Mike Frysinger
@ 2009-06-14 12:01 ` Mike Frysinger
  2009-06-15 11:04   ` Arnd Bergmann
  2009-06-14 12:01 ` [PATCH 06/17] Blackfin: convert shm/sysv/ipc to asm-generic Mike Frysinger
                   ` (12 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Mike Frysinger @ 2009-06-14 12:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: uclinux-dist-devel

The Blackfin port only implemented an optimized version of the
csum_tcpudp_nofold function, so convert everything else to the new
generic code.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 arch/blackfin/Kconfig                |    3 +
 arch/blackfin/include/asm/checksum.h |   72 +----------------
 arch/blackfin/lib/Makefile           |    2 +-
 arch/blackfin/lib/checksum.c         |  145 ----------------------------------
 4 files changed, 8 insertions(+), 214 deletions(-)
 delete mode 100644 arch/blackfin/lib/checksum.c

diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
index 26e4858..fef8209 100644
--- a/arch/blackfin/Kconfig
+++ b/arch/blackfin/Kconfig
@@ -28,6 +28,9 @@ config BLACKFIN
 	select HAVE_OPROFILE
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 
+config GENERIC_CSUM
+	def_bool y
+
 config GENERIC_BUG
 	def_bool y
 	depends on BUG
diff --git a/arch/blackfin/include/asm/checksum.h b/arch/blackfin/include/asm/checksum.h
index 793581f..44837a9 100644
--- a/arch/blackfin/include/asm/checksum.h
+++ b/arch/blackfin/include/asm/checksum.h
@@ -2,65 +2,12 @@
 #define _BFIN_CHECKSUM_H
 
 /*
- * MODIFIED FOR BFIN April 30, 2001 akbar.hussain@lineo.com
- *
- * computes the checksum of a memory block at buff, length len,
- * and adds in "sum" (32-bit)
- *
- * returns a 32-bit number suitable for feeding into itself
- * or csum_tcpudp_magic
- *
- * this function must be called with even lengths, except
- * for the last fragment, which may be odd
- *
- * it's best to have buff aligned on a 32-bit boundary
- */
-__wsum csum_partial(const void *buff, int len, __wsum sum);
-
-/*
- * the same as csum_partial, but copies from src while it
- * checksums
- *
- * here even more important to align src and dst on a 32-bit (or even
- * better 64-bit) boundary
- */
-
-__wsum csum_partial_copy(const void *src, void *dst,
-			       int len, __wsum sum);
-
-/*
- * the same as csum_partial_copy, but copies from user space.
- *
- * here even more important to align src and dst on a 32-bit (or even
- * better 64-bit) boundary
- */
-
-extern __wsum csum_partial_copy_from_user(const void __user *src, void *dst,
-					  int len, __wsum sum, int *csum_err);
-
-#define csum_partial_copy_nocheck(src, dst, len, sum)	\
-	csum_partial_copy((src), (dst), (len), (sum))
-
-__sum16 ip_fast_csum(unsigned char *iph, unsigned int ihl);
-
-/*
- *	Fold a partial checksum
- */
-
-static inline __sum16 csum_fold(__wsum sum)
-{
-	while (sum >> 16)
-		sum = (sum & 0xffff) + (sum >> 16);
-	return ((~(sum << 16)) >> 16);
-}
-
-/*
  * computes the checksum of the TCP/UDP pseudo-header
  * returns a 16-bit checksum, already complemented
  */
 
 static inline __wsum
-csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
+__csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
 		   unsigned short proto, __wsum sum)
 {
 	unsigned int carry;
@@ -83,19 +30,8 @@ csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
 
 	return (sum);
 }
+#define csum_tcpudp_nofold __csum_tcpudp_nofold
 
-static inline __sum16
-csum_tcpudp_magic(__be32 saddr, __be32 daddr, unsigned short len,
-		  unsigned short proto, __wsum sum)
-{
-	return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));
-}
-
-/*
- * this routine is used for miscellaneous IP-like checksums, mainly
- * in icmp.c
- */
-
-extern __sum16 ip_compute_csum(const void *buff, int len);
+#include <asm-generic/checksum.h>
 
-#endif				/* _BFIN_CHECKSUM_H */
+#endif
diff --git a/arch/blackfin/lib/Makefile b/arch/blackfin/lib/Makefile
index 635288f..42c47dc 100644
--- a/arch/blackfin/lib/Makefile
+++ b/arch/blackfin/lib/Makefile
@@ -5,7 +5,7 @@
 lib-y := \
 	ashldi3.o ashrdi3.o lshrdi3.o \
 	muldi3.o divsi3.o udivsi3.o modsi3.o umodsi3.o \
-	checksum.o memcpy.o memset.o memcmp.o memchr.o memmove.o \
+	memcpy.o memset.o memcmp.o memchr.o memmove.o \
 	strcmp.o strcpy.o strncmp.o strncpy.o \
 	umulsi3_highpart.o smulsi3_highpart.o \
 	ins.o outs.o
diff --git a/arch/blackfin/lib/checksum.c b/arch/blackfin/lib/checksum.c
deleted file mode 100644
index cd605e7..0000000
--- a/arch/blackfin/lib/checksum.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * File:         arch/blackfin/lib/checksum.c
- * Based on:     none - original work
- * Author:
- *
- * Created:
- * Description:  An implementation of the TCP/IP protocol suite for the LINUX
- *               operating system.  INET is implemented using the  BSD Socket
- *               interface as the means of communication with the user level.
- *
- * Modified:
- *               Copyright 2004-2006 Analog Devices Inc.
- *
- * Bugs:         Enter bugs at http://blackfin.uclinux.org/
- *
- * 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.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see the file COPYING, or write
- * to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include <linux/module.h>
-#include <net/checksum.h>
-#include <asm/checksum.h>
-
-#ifdef CONFIG_IP_CHECKSUM_L1
-static unsigned short do_csum(const unsigned char *buff, int len)__attribute__((l1_text));
-#endif
-
-static unsigned short do_csum(const unsigned char *buff, int len)
-{
-	register unsigned long sum = 0;
-	int swappem = 0;
-
-	if (1 & (unsigned long)buff) {
-		sum = *buff << 8;
-		buff++;
-		len--;
-		++swappem;
-	}
-
-	while (len > 1) {
-		sum += *(unsigned short *)buff;
-		buff += 2;
-		len -= 2;
-	}
-
-	if (len > 0)
-		sum += *buff;
-
-	/*  Fold 32-bit sum to 16 bits */
-	while (sum >> 16)
-		sum = (sum & 0xffff) + (sum >> 16);
-
-	if (swappem)
-		sum = ((sum & 0xff00) >> 8) + ((sum & 0x00ff) << 8);
-
-	return sum;
-
-}
-
-/*
- *	This is a version of ip_compute_csum() optimized for IP headers,
- *	which always checksum on 4 octet boundaries.
- */
-__sum16 ip_fast_csum(unsigned char *iph, unsigned int ihl)
-{
-	return (__force __sum16)~do_csum(iph, ihl * 4);
-}
-EXPORT_SYMBOL(ip_fast_csum);
-
-/*
- * computes the checksum of a memory block at buff, length len,
- * and adds in "sum" (32-bit)
- *
- * returns a 32-bit number suitable for feeding into itself
- * or csum_tcpudp_magic
- *
- * this function must be called with even lengths, except
- * for the last fragment, which may be odd
- *
- * it's best to have buff aligned on a 32-bit boundary
- */
-__wsum csum_partial(const void *buff, int len, __wsum sum)
-{
-	/*
-	 * Just in case we get nasty checksum data...
-	 * Like 0xffff6ec3 in the case of our IPv6 multicast header.
-	 * We fold to begin with, as well as at the end.
-	 */
-	sum = (sum & 0xffff) + (sum >> 16);
-
-	sum += do_csum(buff, len);
-
-	sum = (sum & 0xffff) + (sum >> 16);
-
-	return sum;
-}
-EXPORT_SYMBOL(csum_partial);
-
-/*
- * this routine is used for miscellaneous IP-like checksums, mainly
- * in icmp.c
- */
-__sum16 ip_compute_csum(const void *buff, int len)
-{
-	return (__force __sum16)~do_csum(buff, len);
-}
-EXPORT_SYMBOL(ip_compute_csum);
-
-/*
- * copy from fs while checksumming, otherwise like csum_partial
- */
-
-__wsum
-csum_partial_copy_from_user(const void __user *src, void *dst,
-			    int len, __wsum sum, int *csum_err)
-{
-	if (csum_err)
-		*csum_err = 0;
-	memcpy(dst, (__force void *)src, len);
-	return csum_partial(dst, len, sum);
-}
-EXPORT_SYMBOL(csum_partial_copy_from_user);
-
-/*
- * copy from ds while checksumming, otherwise like csum_partial
- */
-
-__wsum csum_partial_copy(const void *src, void *dst, int len, __wsum sum)
-{
-	memcpy(dst, src, len);
-	return csum_partial(dst, len, sum);
-}
-EXPORT_SYMBOL(csum_partial_copy);
-- 
1.6.3.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 06/17] Blackfin: convert shm/sysv/ipc to asm-generic
  2009-06-14 12:01 [PATCH 00/17] Blackfin arch conversion to asm-generic Mike Frysinger
                   ` (4 preceding siblings ...)
  2009-06-14 12:01 ` [PATCH 05/17] Blackfin: convert to generic checksum code Mike Frysinger
@ 2009-06-14 12:01 ` Mike Frysinger
  2009-06-14 12:01 ` [PATCH 07/17] Blackfin: convert user/elf " Mike Frysinger
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Mike Frysinger @ 2009-06-14 12:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: uclinux-dist-devel

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 arch/blackfin/include/asm/ipcbuf.h   |   31 +-----------------------
 arch/blackfin/include/asm/msgbuf.h   |   32 +------------------------
 arch/blackfin/include/asm/sembuf.h   |   26 +-------------------
 arch/blackfin/include/asm/shmbuf.h   |   43 +---------------------------------
 arch/blackfin/include/asm/shmparam.h |    7 +----
 5 files changed, 5 insertions(+), 134 deletions(-)

diff --git a/arch/blackfin/include/asm/ipcbuf.h b/arch/blackfin/include/asm/ipcbuf.h
index 8f0899c..84c7e51 100644
--- a/arch/blackfin/include/asm/ipcbuf.h
+++ b/arch/blackfin/include/asm/ipcbuf.h
@@ -1,30 +1 @@
-/* Changes origined from m68k version.    Lineo Inc.  May 2001   */
-
-#ifndef __BFIN_IPCBUF_H__
-#define __BFIN_IPCBUF_H__
-
-/*
- * The user_ipc_perm structure for m68k architecture.
- * Note extra padding because this structure is passed back and forth
- * between kernel and user space.
- *
- * Pad space is left for:
- * - 32-bit mode_t and seq
- * - 2 miscellaneous 32-bit values
- */
-
-struct ipc64_perm {
-	__kernel_key_t key;
-	__kernel_uid32_t uid;
-	__kernel_gid32_t gid;
-	__kernel_uid32_t cuid;
-	__kernel_gid32_t cgid;
-	__kernel_mode_t mode;
-	unsigned short __pad1;
-	unsigned short seq;
-	unsigned short __pad2;
-	unsigned long __unused1;
-	unsigned long __unused2;
-};
-
-#endif				/* __BFIN_IPCBUF_H__ */
+#include <asm-generic/ipcbuf.h>
diff --git a/arch/blackfin/include/asm/msgbuf.h b/arch/blackfin/include/asm/msgbuf.h
index 6fcbe8c..809134c 100644
--- a/arch/blackfin/include/asm/msgbuf.h
+++ b/arch/blackfin/include/asm/msgbuf.h
@@ -1,31 +1 @@
-#ifndef _BFIN_MSGBUF_H
-#define _BFIN_MSGBUF_H
-
-/*
- * The msqid64_ds structure for bfin architecture.
- * Note extra padding because this structure is passed back and forth
- * between kernel and user space.
- *
- * Pad space is left for:
- * - 64-bit time_t to solve y2038 problem
- * - 2 miscellaneous 32-bit values
- */
-
-struct msqid64_ds {
-	struct ipc64_perm msg_perm;
-	__kernel_time_t msg_stime;	/* last msgsnd time */
-	unsigned long __unused1;
-	__kernel_time_t msg_rtime;	/* last msgrcv time */
-	unsigned long __unused2;
-	__kernel_time_t msg_ctime;	/* last change time */
-	unsigned long __unused3;
-	unsigned long msg_cbytes;	/* current number of bytes on queue */
-	unsigned long msg_qnum;	/* number of messages in queue */
-	unsigned long msg_qbytes;	/* max number of bytes on queue */
-	__kernel_pid_t msg_lspid;	/* pid of last msgsnd */
-	__kernel_pid_t msg_lrpid;	/* last receive pid */
-	unsigned long __unused4;
-	unsigned long __unused5;
-};
-
-#endif				/* _BFIN_MSGBUF_H */
+#include <asm-generic/msgbuf.h>
diff --git a/arch/blackfin/include/asm/sembuf.h b/arch/blackfin/include/asm/sembuf.h
index 18deb5c..7673b83 100644
--- a/arch/blackfin/include/asm/sembuf.h
+++ b/arch/blackfin/include/asm/sembuf.h
@@ -1,25 +1 @@
-#ifndef _BFIN_SEMBUF_H
-#define _BFIN_SEMBUF_H
-
-/*
- * The semid64_ds structure for bfin architecture.
- * Note extra padding because this structure is passed back and forth
- * between kernel and user space.
- *
- * Pad space is left for:
- * - 64-bit time_t to solve y2038 problem
- * - 2 miscellaneous 32-bit values
- */
-
-struct semid64_ds {
-	struct ipc64_perm sem_perm;	/* permissions .. see ipc.h */
-	__kernel_time_t sem_otime;	/* last semop time */
-	unsigned long __unused1;
-	__kernel_time_t sem_ctime;	/* last change time */
-	unsigned long __unused2;
-	unsigned long sem_nsems;	/* no. of semaphores in array */
-	unsigned long __unused3;
-	unsigned long __unused4;
-};
-
-#endif				/* _BFIN_SEMBUF_H */
+#include <asm-generic/sembuf.h>
diff --git a/arch/blackfin/include/asm/shmbuf.h b/arch/blackfin/include/asm/shmbuf.h
index 6124363..83c05fc 100644
--- a/arch/blackfin/include/asm/shmbuf.h
+++ b/arch/blackfin/include/asm/shmbuf.h
@@ -1,42 +1 @@
-#ifndef _BFIN_SHMBUF_H
-#define _BFIN_SHMBUF_H
-
-/*
- * The shmid64_ds structure for bfin architecture.
- * Note extra padding because this structure is passed back and forth
- * between kernel and user space.
- *
- * Pad space is left for:
- * - 64-bit time_t to solve y2038 problem
- * - 2 miscellaneous 32-bit values
- */
-
-struct shmid64_ds {
-	struct ipc64_perm shm_perm;	/* operation perms */
-	size_t shm_segsz;	/* size of segment (bytes) */
-	__kernel_time_t shm_atime;	/* last attach time */
-	unsigned long __unused1;
-	__kernel_time_t shm_dtime;	/* last detach time */
-	unsigned long __unused2;
-	__kernel_time_t shm_ctime;	/* last change time */
-	unsigned long __unused3;
-	__kernel_pid_t shm_cpid;	/* pid of creator */
-	__kernel_pid_t shm_lpid;	/* pid of last operator */
-	unsigned long shm_nattch;	/* no. of current attaches */
-	unsigned long __unused4;
-	unsigned long __unused5;
-};
-
-struct shminfo64 {
-	unsigned long shmmax;
-	unsigned long shmmin;
-	unsigned long shmmni;
-	unsigned long shmseg;
-	unsigned long shmall;
-	unsigned long __unused1;
-	unsigned long __unused2;
-	unsigned long __unused3;
-	unsigned long __unused4;
-};
-
-#endif				/* _BFIN_SHMBUF_H */
+#include <asm-generic/shmbuf.h>
diff --git a/arch/blackfin/include/asm/shmparam.h b/arch/blackfin/include/asm/shmparam.h
index 3c03906..93f30de 100644
--- a/arch/blackfin/include/asm/shmparam.h
+++ b/arch/blackfin/include/asm/shmparam.h
@@ -1,6 +1 @@
-#ifndef _BFIN_SHMPARAM_H
-#define _BFIN_SHMPARAM_H
-
-#define	SHMLBA PAGE_SIZE	/* attach addr a multiple of this */
-
-#endif				/* _BFIN_SHMPARAM_H */
+#include <asm-generic/shmparam.h>
-- 
1.6.3.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 07/17] Blackfin: convert user/elf to asm-generic
  2009-06-14 12:01 [PATCH 00/17] Blackfin arch conversion to asm-generic Mike Frysinger
                   ` (5 preceding siblings ...)
  2009-06-14 12:01 ` [PATCH 06/17] Blackfin: convert shm/sysv/ipc to asm-generic Mike Frysinger
@ 2009-06-14 12:01 ` Mike Frysinger
  2009-06-14 12:01 ` [PATCH 08/17] Blackfin: convert socket/poll " Mike Frysinger
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Mike Frysinger @ 2009-06-14 12:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: uclinux-dist-devel

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 arch/blackfin/include/asm/elf.h  |    2 +-
 arch/blackfin/include/asm/user.h |   90 +-------------------------------------
 2 files changed, 2 insertions(+), 90 deletions(-)

diff --git a/arch/blackfin/include/asm/elf.h b/arch/blackfin/include/asm/elf.h
index 230e160..5a87baf 100644
--- a/arch/blackfin/include/asm/elf.h
+++ b/arch/blackfin/include/asm/elf.h
@@ -20,7 +20,7 @@
 
 typedef unsigned long elf_greg_t;
 
-#define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t))
+#define ELF_NGREG 40 /* (sizeof(struct user_regs_struct) / sizeof(elf_greg_t)) */
 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 
 typedef struct user_bfinfp_struct elf_fpregset_t;
diff --git a/arch/blackfin/include/asm/user.h b/arch/blackfin/include/asm/user.h
index afe6a0e..4792a60 100644
--- a/arch/blackfin/include/asm/user.h
+++ b/arch/blackfin/include/asm/user.h
@@ -1,89 +1 @@
-#ifndef _BFIN_USER_H
-#define _BFIN_USER_H
-
-/* Changes by Tony Kou   Lineo, Inc.  July, 2001
- *
- * Based include/asm-m68knommu/user.h
- *
- */
-
-/* Core file format: The core file is written in such a way that gdb
-   can understand it and provide useful information to the user (under
-   linux we use the 'trad-core' bfd).  There are quite a number of
-   obstacles to being able to view the contents of the floating point
-   registers, and until these are solved you will not be able to view the
-   contents of them.  Actually, you can read in the core file and look at
-   the contents of the user struct to find out what the floating point
-   registers contain.
-   The actual file contents are as follows:
-   UPAGE: 1 page consisting of a user struct that tells gdb what is present
-   in the file.  Directly after this is a copy of the task_struct, which
-   is currently not used by gdb, but it may come in useful at some point.
-   All of the registers are stored as part of the upage.  The upage should
-   always be only one page.
-   DATA: The data area is stored.  We use current->end_text to
-   current->brk to pick up all of the user variables, plus any memory
-   that may have been malloced.  No attempt is made to determine if a page
-   is demand-zero or if a page is totally unused, we just cover the entire
-   range.  All of the addresses are rounded in such a way that an integral
-   number of pages is written.
-   STACK: We need the stack information in order to get a meaningful
-   backtrace.  We need to write the data from (esp) to
-   current->start_stack, so we round each of these off in order to be able
-   to write an integer number of pages.
-   The minimum core file size is 3 pages, or 12288 bytes.
-*/
-struct user_bfinfp_struct {
-};
-
-/* This is the old layout of "struct pt_regs" as of Linux 1.x, and
-   is still the layout used by user (the new pt_regs doesn't have
-   all registers). */
-struct user_regs_struct {
-	long r0, r1, r2, r3, r4, r5, r6, r7;
-	long p0, p1, p2, p3, p4, p5, usp, fp;
-	long i0, i1, i2, i3;
-	long l0, l1, l2, l3;
-	long b0, b1, b2, b3;
-	long m0, m1, m2, m3;
-	long a0w, a1w;
-	long a0x, a1x;
-	unsigned long rets;
-	unsigned long astat;
-	unsigned long pc;
-	unsigned long orig_p0;
-};
-
-/* When the kernel dumps core, it starts by dumping the user struct -
-   this will be used by gdb to figure out where the data and stack segments
-   are within the file, and what virtual addresses to use. */
-
-struct user {
-/* We start with the registers, to mimic the way that "memory" is returned
-   from the ptrace(3,...) function.  */
-
-	struct user_regs_struct regs;	/* Where the registers are actually stored */
-
-/* The rest of this junk is to help gdb figure out what goes where */
-	unsigned long int u_tsize;	/* Text segment size (pages). */
-	unsigned long int u_dsize;	/* Data segment size (pages). */
-	unsigned long int u_ssize;	/* Stack segment size (pages). */
-	unsigned long start_code;	/* Starting virtual address of text. */
-	unsigned long start_stack;	/* Starting virtual address of stack area.
-					   This is actually the bottom of the stack,
-					   the top of the stack is always found in the
-					   esp register.  */
-	long int signal;	/* Signal that caused the core dump. */
-	int reserved;		/* No longer used */
-	unsigned long u_ar0;
-	/* Used by gdb to help find the values for */
-	/* the registers. */
-	unsigned long magic;	/* To uniquely identify a core file */
-	char u_comm[32];	/* User command that was responsible */
-};
-#define NBPG PAGE_SIZE
-#define UPAGES 1
-#define HOST_TEXT_START_ADDR (u.start_code)
-#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
-
-#endif
+#include <asm-generic/user.h>
-- 
1.6.3.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 08/17] Blackfin: convert socket/poll to asm-generic
  2009-06-14 12:01 [PATCH 00/17] Blackfin arch conversion to asm-generic Mike Frysinger
                   ` (6 preceding siblings ...)
  2009-06-14 12:01 ` [PATCH 07/17] Blackfin: convert user/elf " Mike Frysinger
@ 2009-06-14 12:01 ` Mike Frysinger
  2009-06-14 12:01 ` [PATCH 09/17] Blackfin: convert simple headers " Mike Frysinger
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Mike Frysinger @ 2009-06-14 12:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: uclinux-dist-devel

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 arch/blackfin/include/asm/poll.h    |   21 ++----------
 arch/blackfin/include/asm/socket.h  |   60 +----------------------------------
 arch/blackfin/include/asm/sockios.h |   14 +-------
 3 files changed, 5 insertions(+), 90 deletions(-)

diff --git a/arch/blackfin/include/asm/poll.h b/arch/blackfin/include/asm/poll.h
index 94cc263..a055667 100644
--- a/arch/blackfin/include/asm/poll.h
+++ b/arch/blackfin/include/asm/poll.h
@@ -1,24 +1,9 @@
 #ifndef __BFIN_POLL_H
 #define __BFIN_POLL_H
 
-#define POLLIN		  1
-#define POLLPRI		  2
-#define POLLOUT		  4
-#define POLLERR		  8
-#define POLLHUP		 16
-#define POLLNVAL	 32
-#define POLLRDNORM	 64
-#define POLLWRNORM	POLLOUT
-#define POLLRDBAND	128
+#define POLLWRNORM	4 /* POLLOUT */
 #define POLLWRBAND	256
-#define POLLMSG		0x0400
-#define POLLREMOVE	0x1000
-#define POLLRDHUP       0x2000
 
-struct pollfd {
-	int fd;
-	short events;
-	short revents;
-};
+#include <asm-generic/poll.h>
 
-#endif				/* __BFIN_POLL_H */
+#endif
diff --git a/arch/blackfin/include/asm/socket.h b/arch/blackfin/include/asm/socket.h
index fac7fe9..6b71384 100644
--- a/arch/blackfin/include/asm/socket.h
+++ b/arch/blackfin/include/asm/socket.h
@@ -1,59 +1 @@
-#ifndef _ASM_SOCKET_H
-#define _ASM_SOCKET_H
-
-#include <asm/sockios.h>
-
-/* For setsockoptions(2) */
-#define SOL_SOCKET	1
-
-#define SO_DEBUG	1
-#define SO_REUSEADDR	2
-#define SO_TYPE		3
-#define SO_ERROR	4
-#define SO_DONTROUTE	5
-#define SO_BROADCAST	6
-#define SO_SNDBUF	7
-#define SO_RCVBUF	8
-#define SO_SNDBUFFORCE	32
-#define SO_RCVBUFFORCE	33
-#define SO_KEEPALIVE	9
-#define SO_OOBINLINE	10
-#define SO_NO_CHECK	11
-#define SO_PRIORITY	12
-#define SO_LINGER	13
-#define SO_BSDCOMPAT	14
-/* To add :#define SO_REUSEPORT 15 */
-#define SO_PASSCRED	16
-#define SO_PEERCRED	17
-#define SO_RCVLOWAT	18
-#define SO_SNDLOWAT	19
-#define SO_RCVTIMEO	20
-#define SO_SNDTIMEO	21
-
-/* Security levels - as per NRL IPv6 - don't actually do anything */
-#define SO_SECURITY_AUTHENTICATION		22
-#define SO_SECURITY_ENCRYPTION_TRANSPORT	23
-#define SO_SECURITY_ENCRYPTION_NETWORK		24
-
-#define SO_BINDTODEVICE	25
-
-/* Socket filtering */
-#define SO_ATTACH_FILTER	26
-#define SO_DETACH_FILTER	27
-
-#define SO_PEERNAME		28
-#define SO_TIMESTAMP		29
-#define SCM_TIMESTAMP		SO_TIMESTAMP
-
-#define SO_ACCEPTCONN		30
-#define SO_PEERSEC		31
-#define SO_PASSSEC		34
-#define SO_TIMESTAMPNS		35
-#define SCM_TIMESTAMPNS		SO_TIMESTAMPNS
-
-#define SO_MARK			36
-
-#define SO_TIMESTAMPING		37
-#define SCM_TIMESTAMPING	SO_TIMESTAMPING
-
-#endif				/* _ASM_SOCKET_H */
+#include <asm-generic/socket.h>
diff --git a/arch/blackfin/include/asm/sockios.h b/arch/blackfin/include/asm/sockios.h
index 426b89b..def6d47 100644
--- a/arch/blackfin/include/asm/sockios.h
+++ b/arch/blackfin/include/asm/sockios.h
@@ -1,13 +1 @@
-#ifndef __ARCH_BFIN_SOCKIOS__
-#define __ARCH_BFIN_SOCKIOS__
-
-/* Socket-level I/O control calls. */
-#define FIOSETOWN 	0x8901
-#define SIOCSPGRP	0x8902
-#define FIOGETOWN	0x8903
-#define SIOCGPGRP	0x8904
-#define SIOCATMARK	0x8905
-#define SIOCGSTAMP	0x8906	/* Get stamp (timeval) */
-#define SIOCGSTAMPNS	0x8907	/* Get stamp (timespec) */
-
-#endif				/* __ARCH_BFIN_SOCKIOS__ */
+#include <asm-generic/sockios.h>
-- 
1.6.3.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 09/17] Blackfin: convert simple headers to asm-generic
  2009-06-14 12:01 [PATCH 00/17] Blackfin arch conversion to asm-generic Mike Frysinger
                   ` (7 preceding siblings ...)
  2009-06-14 12:01 ` [PATCH 08/17] Blackfin: convert socket/poll " Mike Frysinger
@ 2009-06-14 12:01 ` Mike Frysinger
  2009-06-14 12:01 ` [PATCH 10/17] Blackfin: convert dma/pci " Mike Frysinger
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Mike Frysinger @ 2009-06-14 12:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: uclinux-dist-devel

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 arch/blackfin/include/asm/auxvec.h            |    5 +----
 arch/blackfin/include/asm/bugs.h              |   17 +----------------
 arch/blackfin/include/asm/cputime.h           |    5 -----
 arch/blackfin/include/asm/current.h           |   24 +-----------------------
 arch/blackfin/include/asm/device.h            |    6 ------
 arch/blackfin/include/asm/emergency-restart.h |    5 -----
 arch/blackfin/include/asm/errno.h             |    7 +------
 arch/blackfin/include/asm/fb.h                |   13 +------------
 arch/blackfin/include/asm/futex.h             |    5 -----
 arch/blackfin/include/asm/hw_irq.h            |    7 +------
 arch/blackfin/include/asm/kmap_types.h        |   22 +---------------------
 arch/blackfin/include/asm/local.h             |    5 -----
 arch/blackfin/include/asm/param.h             |   23 +----------------------
 arch/blackfin/include/asm/percpu.h            |    5 -----
 arch/blackfin/include/asm/pgalloc.h           |    9 +--------
 arch/blackfin/include/asm/resource.h          |    5 -----
 arch/blackfin/include/asm/serial.h            |    6 +-----
 arch/blackfin/include/asm/setup.h             |   18 +-----------------
 arch/blackfin/include/asm/statfs.h            |    5 -----
 arch/blackfin/include/asm/topology.h          |    5 -----
 20 files changed, 11 insertions(+), 186 deletions(-)

diff --git a/arch/blackfin/include/asm/auxvec.h b/arch/blackfin/include/asm/auxvec.h
index 215506c..41fa68b 100644
--- a/arch/blackfin/include/asm/auxvec.h
+++ b/arch/blackfin/include/asm/auxvec.h
@@ -1,4 +1 @@
-#ifndef __ASMBFIN_AUXVEC_H
-#define __ASMBFIN_AUXVEC_H
-
-#endif
+#include <asm-generic/auxvec.h>
diff --git a/arch/blackfin/include/asm/bugs.h b/arch/blackfin/include/asm/bugs.h
index 9093c9c..61791e1 100644
--- a/arch/blackfin/include/asm/bugs.h
+++ b/arch/blackfin/include/asm/bugs.h
@@ -1,16 +1 @@
-/*
- *  include/asm-blackfin/bugs.h
- *
- *  Copyright (C) 1994  Linus Torvalds
- */
-
-/*
- * This is included by init/main.c to check for architecture-dependent bugs.
- *
- * Needs:
- *	void check_bugs(void);
- */
-
-static void check_bugs(void)
-{
-}
+#include <asm-generic/bugs.h>
diff --git a/arch/blackfin/include/asm/cputime.h b/arch/blackfin/include/asm/cputime.h
index 2b19705..6d68ad7 100644
--- a/arch/blackfin/include/asm/cputime.h
+++ b/arch/blackfin/include/asm/cputime.h
@@ -1,6 +1 @@
-#ifndef __BLACKFIN_CPUTIME_H
-#define __BLACKFIN_CPUTIME_H
-
 #include <asm-generic/cputime.h>
-
-#endif				/* __BLACKFIN_CPUTIME_H */
diff --git a/arch/blackfin/include/asm/current.h b/arch/blackfin/include/asm/current.h
index 31918d2..4c51401 100644
--- a/arch/blackfin/include/asm/current.h
+++ b/arch/blackfin/include/asm/current.h
@@ -1,23 +1 @@
-#ifndef _BLACKFIN_CURRENT_H
-#define _BLACKFIN_CURRENT_H
-/*
- *	current.h
- *	(C) Copyright 2000, Lineo, David McCullough <davidm@lineo.com>
- *
- *	rather than dedicate a register (as the m68k source does), we
- *	just keep a global,  we should probably just change it all to be
- *	current and lose _current_task.
- */
-#include <linux/thread_info.h>
-
-struct task_struct;
-
-static inline struct task_struct *get_current(void) __attribute__ ((__const__));
-static inline struct task_struct *get_current(void)
-{
-	return (current_thread_info()->task);
-}
-
-#define	current	(get_current())
-
-#endif				/* _BLACKFIN_CURRENT_H */
+#include <asm-generic/current.h>
diff --git a/arch/blackfin/include/asm/device.h b/arch/blackfin/include/asm/device.h
index d8f9872..f0a4c25 100644
--- a/arch/blackfin/include/asm/device.h
+++ b/arch/blackfin/include/asm/device.h
@@ -1,7 +1 @@
-/*
- * Arch specific extensions to struct device
- *
- * This file is released under the GPLv2
- */
 #include <asm-generic/device.h>
-
diff --git a/arch/blackfin/include/asm/emergency-restart.h b/arch/blackfin/include/asm/emergency-restart.h
index 27f6c78..3711bd9 100644
--- a/arch/blackfin/include/asm/emergency-restart.h
+++ b/arch/blackfin/include/asm/emergency-restart.h
@@ -1,6 +1 @@
-#ifndef _ASM_EMERGENCY_RESTART_H
-#define _ASM_EMERGENCY_RESTART_H
-
 #include <asm-generic/emergency-restart.h>
-
-#endif				/* _ASM_EMERGENCY_RESTART_H */
diff --git a/arch/blackfin/include/asm/errno.h b/arch/blackfin/include/asm/errno.h
index 164e4f3..4c82b50 100644
--- a/arch/blackfin/include/asm/errno.h
+++ b/arch/blackfin/include/asm/errno.h
@@ -1,6 +1 @@
-#ifndef _BFIN_ERRNO_H
-#define _BFIN_ERRNO_H
-
-#include<asm-generic/errno.h>
-
-#endif				/* _BFIN_ERRNO_H */
+#include <asm-generic/errno.h>
diff --git a/arch/blackfin/include/asm/fb.h b/arch/blackfin/include/asm/fb.h
index c7df380..3a4988e 100644
--- a/arch/blackfin/include/asm/fb.h
+++ b/arch/blackfin/include/asm/fb.h
@@ -1,12 +1 @@
-#ifndef _ASM_FB_H_
-#define _ASM_FB_H_
-#include <linux/fb.h>
-
-#define fb_pgprotect(...) do {} while (0)
-
-static inline int fb_is_primary_device(struct fb_info *info)
-{
-	return 0;
-}
-
-#endif /* _ASM_FB_H_ */
+#include <asm-generic/fb.h>
diff --git a/arch/blackfin/include/asm/futex.h b/arch/blackfin/include/asm/futex.h
index 6a332a9..0b74582 100644
--- a/arch/blackfin/include/asm/futex.h
+++ b/arch/blackfin/include/asm/futex.h
@@ -1,6 +1 @@
-#ifndef _ASM_FUTEX_H
-#define _ASM_FUTEX_H
-
 #include <asm-generic/futex.h>
-
-#endif
diff --git a/arch/blackfin/include/asm/hw_irq.h b/arch/blackfin/include/asm/hw_irq.h
index 5b51eae..1f5ef7d 100644
--- a/arch/blackfin/include/asm/hw_irq.h
+++ b/arch/blackfin/include/asm/hw_irq.h
@@ -1,6 +1 @@
-#ifndef __ASM_BFIN_HW_IRQ_H
-#define __ASM_BFIN_HW_IRQ_H
-
-/* Dummy include. */
-
-#endif
+#include <asm-generic/hw_irq.h>
diff --git a/arch/blackfin/include/asm/kmap_types.h b/arch/blackfin/include/asm/kmap_types.h
index e215f71..3575c64 100644
--- a/arch/blackfin/include/asm/kmap_types.h
+++ b/arch/blackfin/include/asm/kmap_types.h
@@ -1,21 +1 @@
-#ifndef _ASM_KMAP_TYPES_H
-#define _ASM_KMAP_TYPES_H
-
-enum km_type {
-	KM_BOUNCE_READ,
-	KM_SKB_SUNRPC_DATA,
-	KM_SKB_DATA_SOFTIRQ,
-	KM_USER0,
-	KM_USER1,
-	KM_BIO_SRC_IRQ,
-	KM_BIO_DST_IRQ,
-	KM_PTE0,
-	KM_PTE1,
-	KM_IRQ0,
-	KM_IRQ1,
-	KM_SOFTIRQ0,
-	KM_SOFTIRQ1,
-	KM_TYPE_NR
-};
-
-#endif
+#include <asm-generic/kmap_types.h>
diff --git a/arch/blackfin/include/asm/local.h b/arch/blackfin/include/asm/local.h
index 75afffb..c11c530 100644
--- a/arch/blackfin/include/asm/local.h
+++ b/arch/blackfin/include/asm/local.h
@@ -1,6 +1 @@
-#ifndef __BLACKFIN_LOCAL_H
-#define __BLACKFIN_LOCAL_H
-
 #include <asm-generic/local.h>
-
-#endif				/* __BLACKFIN_LOCAL_H */
diff --git a/arch/blackfin/include/asm/param.h b/arch/blackfin/include/asm/param.h
index 41564a6..965d454 100644
--- a/arch/blackfin/include/asm/param.h
+++ b/arch/blackfin/include/asm/param.h
@@ -1,22 +1 @@
-#ifndef _BLACKFIN_PARAM_H
-#define _BLACKFIN_PARAM_H
-
-#ifdef __KERNEL__
-#define HZ 		CONFIG_HZ
-#define	USER_HZ		100
-#define	CLOCKS_PER_SEC	(USER_HZ)
-#endif
-
-#ifndef HZ
-#define HZ 100
-#endif
-
-#define EXEC_PAGESIZE	4096
-
-#ifndef NOGROUP
-#define NOGROUP		(-1)
-#endif
-
-#define MAXHOSTNAMELEN	64	/* max length of hostname */
-
-#endif				/* _BLACKFIN_PARAM_H */
+#include <asm-generic/param.h>
diff --git a/arch/blackfin/include/asm/percpu.h b/arch/blackfin/include/asm/percpu.h
index c94c7bc..06a959d 100644
--- a/arch/blackfin/include/asm/percpu.h
+++ b/arch/blackfin/include/asm/percpu.h
@@ -1,6 +1 @@
-#ifndef __ARCH_BLACKFIN_PERCPU__
-#define __ARCH_BLACKFIN_PERCPU__
-
 #include <asm-generic/percpu.h>
-
-#endif	/* __ARCH_BLACKFIN_PERCPU__ */
diff --git a/arch/blackfin/include/asm/pgalloc.h b/arch/blackfin/include/asm/pgalloc.h
index c686e05..f261cb7 100644
--- a/arch/blackfin/include/asm/pgalloc.h
+++ b/arch/blackfin/include/asm/pgalloc.h
@@ -1,8 +1 @@
-#ifndef _BLACKFIN_PGALLOC_H
-#define _BLACKFIN_PGALLOC_H
-
-#include <asm/setup.h>
-
-#define check_pgt_cache()	do { } while (0)
-
-#endif				/* _BLACKFIN_PGALLOC_H */
+#include <asm-generic/pgalloc.h>
diff --git a/arch/blackfin/include/asm/resource.h b/arch/blackfin/include/asm/resource.h
index 091355a..04bc4db 100644
--- a/arch/blackfin/include/asm/resource.h
+++ b/arch/blackfin/include/asm/resource.h
@@ -1,6 +1 @@
-#ifndef _BFIN_RESOURCE_H
-#define _BFIN_RESOURCE_H
-
 #include <asm-generic/resource.h>
-
-#endif				/* _BFIN_RESOURCE_H */
diff --git a/arch/blackfin/include/asm/serial.h b/arch/blackfin/include/asm/serial.h
index 3a47606..94a4a12 100644
--- a/arch/blackfin/include/asm/serial.h
+++ b/arch/blackfin/include/asm/serial.h
@@ -1,6 +1,2 @@
-/*
- * include/asm-blackfin/serial.h
- */
-
+#include <asm-generic/serial.h>
 #define SERIAL_EXTRA_IRQ_FLAGS IRQF_TRIGGER_HIGH
-#define BASE_BAUD (1843200 / 16)
diff --git a/arch/blackfin/include/asm/setup.h b/arch/blackfin/include/asm/setup.h
index 01c8c6c..552df83 100644
--- a/arch/blackfin/include/asm/setup.h
+++ b/arch/blackfin/include/asm/setup.h
@@ -1,17 +1 @@
-/*
-** asm/setup.h -- Definition of the Linux/bfin setup information
-**
-** 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.
-**
-** Copyright Lineo, Inc 2001          Tony Kou
-**
-*/
-
-#ifndef _BFIN_SETUP_H
-#define _BFIN_SETUP_H
-
-#define COMMAND_LINE_SIZE	512
-
-#endif				/* _BFIN_SETUP_H */
+#include <asm-generic/setup.h>
diff --git a/arch/blackfin/include/asm/statfs.h b/arch/blackfin/include/asm/statfs.h
index 3506720..0b91fe1 100644
--- a/arch/blackfin/include/asm/statfs.h
+++ b/arch/blackfin/include/asm/statfs.h
@@ -1,6 +1 @@
-#ifndef _BFIN_STATFS_H
-#define _BFIN_STATFS_H
-
 #include <asm-generic/statfs.h>
-
-#endif				/* _BFIN_STATFS_H */
diff --git a/arch/blackfin/include/asm/topology.h b/arch/blackfin/include/asm/topology.h
index acee239..5428f33 100644
--- a/arch/blackfin/include/asm/topology.h
+++ b/arch/blackfin/include/asm/topology.h
@@ -1,6 +1 @@
-#ifndef _ASM_BLACKFIN_TOPOLOGY_H
-#define _ASM_BLACKFIN_TOPOLOGY_H
-
 #include <asm-generic/topology.h>
-
-#endif				/* _ASM_BLACKFIN_TOPOLOGY_H */
-- 
1.6.3.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 10/17] Blackfin: convert dma/pci to asm-generic
  2009-06-14 12:01 [PATCH 00/17] Blackfin arch conversion to asm-generic Mike Frysinger
                   ` (8 preceding siblings ...)
  2009-06-14 12:01 ` [PATCH 09/17] Blackfin: convert simple headers " Mike Frysinger
@ 2009-06-14 12:01 ` Mike Frysinger
  2009-06-15 11:37   ` Arnd Bergmann
  2009-06-14 12:01 ` [PATCH 11/17] Blackfin: convert termios " Mike Frysinger
                   ` (7 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Mike Frysinger @ 2009-06-14 12:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: uclinux-dist-devel

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 arch/blackfin/include/asm/dma-mapping.h |   91 +++-----------------
 arch/blackfin/include/asm/dma.h         |    5 +-
 arch/blackfin/include/asm/pci.h         |  149 +------------------------------
 arch/blackfin/include/asm/scatterlist.h |   29 +------
 4 files changed, 14 insertions(+), 260 deletions(-)

diff --git a/arch/blackfin/include/asm/dma-mapping.h b/arch/blackfin/include/asm/dma-mapping.h
index d7d9148..c1f3010 100644
--- a/arch/blackfin/include/asm/dma-mapping.h
+++ b/arch/blackfin/include/asm/dma-mapping.h
@@ -2,97 +2,28 @@
 #define _BLACKFIN_DMA_MAPPING_H
 
 #include <asm/scatterlist.h>
+#include <asm-generic/dma-mapping-broken.h>
 
 void dma_alloc_init(unsigned long start, unsigned long end);
-void *dma_alloc_coherent(struct device *dev, size_t size,
-			 dma_addr_t *dma_handle, gfp_t gfp);
-void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
-		       dma_addr_t dma_handle);
-
-/*
- * Now for the API extensions over the pci_ one
- */
-#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
-#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
 
+#define dma_mapping_error __dma_mapping_error
 static inline
-int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
+int __dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
 {
 	return 0;
 }
 
-/*
- * Map a single buffer of the indicated size for DMA in streaming mode.
- * The 32-bit bus address to use is returned.
- *
- * Once the device is given the dma address, the device owns this memory
- * until either pci_unmap_single or pci_dma_sync_single is performed.
- */
-extern dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
-				 enum dma_data_direction direction);
-
-static inline dma_addr_t
-dma_map_page(struct device *dev, struct page *page,
-	     unsigned long offset, size_t size,
-	     enum dma_data_direction dir)
-{
-	return dma_map_single(dev, page_address(page) + offset, size, dir);
-}
-
-/*
- * Unmap a single streaming mode DMA translation.  The dma_addr and size
- * must match what was provided for in a previous pci_map_single call.  All
- * other usages are undefined.
- *
- * After this call, reads by the cpu to the buffer are guarenteed to see
- * whatever the device wrote there.
- */
-extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
-			  enum dma_data_direction direction);
+#define dma_map_page(dev, page, offset, size, dir) \
+	dma_map_single(dev, page_address(page) + offset, size, dir)
 
-static inline void
-dma_unmap_page(struct device *dev, dma_addr_t dma_addr, size_t size,
-	       enum dma_data_direction dir)
-{
+#define dma_unmap_page(dev, dma_addr, size, dir) \
 	dma_unmap_single(dev, dma_addr, size, dir);
-}
-
-/*
- * Map a set of buffers described by scatterlist in streaming
- * mode for DMA.  This is the scather-gather version of the
- * above pci_map_single interface.  Here the scatter gather list
- * elements are each tagged with the appropriate dma address
- * and length.  They are obtained via sg_dma_{address,length}(SG).
- *
- * NOTE: An implementation may be able to use a smaller number of
- *       DMA address/length pairs than there are SG table elements.
- *       (for example via virtual mapping capabilities)
- *       The routine returns the number of addr/length pairs actually
- *       used, at most nents.
- *
- * Device ownership issues as mentioned above for pci_map_single are
- * the same here.
- */
-extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
-		      enum dma_data_direction direction);
-
-/*
- * Unmap a set of streaming mode DMA translations.
- * Again, cpu read rules concerning calls here are the same as for
- * pci_unmap_single() above.
- */
-extern void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
-		      int nhwentries, enum dma_data_direction direction);
 
-static inline void dma_sync_single_for_cpu(struct device *dev,
-					dma_addr_t handle, size_t size,
-					enum dma_data_direction dir)
+#define dma_sync_single_for_cpu __dma_sync_single_for_cpu
+static inline
+void __dma_sync_single_for_cpu(struct device *dev, dma_addr_t handle,
+                               size_t size, enum dma_data_direction dir)
 {
 }
 
-static inline void dma_sync_single_for_device(struct device *dev,
-					dma_addr_t handle, size_t size,
-					enum dma_data_direction dir)
-{
-}
-#endif				/* _BLACKFIN_DMA_MAPPING_H */
+#endif
diff --git a/arch/blackfin/include/asm/dma.h b/arch/blackfin/include/asm/dma.h
index c9a5962..364ebb9 100644
--- a/arch/blackfin/include/asm/dma.h
+++ b/arch/blackfin/include/asm/dma.h
@@ -10,8 +10,7 @@
 
 #include <linux/interrupt.h>
 #include <mach/dma.h>
-#include <asm/blackfin.h>
-#include <asm/page.h>
+#include <asm-generic/dma.h>
 
 #define MAX_DMA_ADDRESS PAGE_OFFSET
 
@@ -239,8 +238,6 @@ static inline void enable_dma(unsigned int channel)
 	dma_ch[channel].regs->cfg |= DMAEN;
 	dma_ch[channel].chan_status = DMA_CHANNEL_ENABLED;
 }
-void free_dma(unsigned int channel);
-int request_dma(unsigned int channel, const char *device_id);
 int set_dma_callback(unsigned int channel, irq_handler_t callback, void *data);
 
 static inline void dma_disable_irq(unsigned int channel)
diff --git a/arch/blackfin/include/asm/pci.h b/arch/blackfin/include/asm/pci.h
index 6127735..9f0df5f 100644
--- a/arch/blackfin/include/asm/pci.h
+++ b/arch/blackfin/include/asm/pci.h
@@ -1,148 +1 @@
-/* Changed from asm-m68k version, Lineo Inc. 	May 2001	*/
-
-#ifndef _ASM_BFIN_PCI_H
-#define _ASM_BFIN_PCI_H
-
-#include <asm/scatterlist.h>
-
-/*
- *
- * Written by Wout Klaren.
- */
-
-/* Added by Chang Junxiao */
-#define PCIBIOS_MIN_IO 0x00001000
-#define PCIBIOS_MIN_MEM 0x10000000
-
-#define PCI_DMA_BUS_IS_PHYS       (1)
-struct pci_ops;
-
-/*
- * Structure with hardware dependent information and functions of the
- * PCI bus.
- */
-struct pci_bus_info {
-
-	/*
-	 * Resources of the PCI bus.
-	 */
-	struct resource mem_space;
-	struct resource io_space;
-
-	/*
-	 * System dependent functions.
-	 */
-	struct pci_ops *bfin_pci_ops;
-	void (*fixup) (int pci_modify);
-	void (*conf_device) (unsigned char bus, unsigned char device_fn);
-};
-
-#define pcibios_assign_all_busses()	0
-static inline void pcibios_set_master(struct pci_dev *dev)
-{
-
-	/* No special bus mastering setup handling */
-}
-static inline void pcibios_penalize_isa_irq(int irq)
-{
-
-	/* We don't do dynamic PCI IRQ allocation */
-}
-static inline dma_addr_t pci_map_single(struct pci_dev *hwdev, void *ptr,
-					size_t size, int direction)
-{
-	if (direction == PCI_DMA_NONE)
-		BUG();
-
-	 /* return virt_to_bus(ptr); */
-	return (dma_addr_t) ptr;
-}
-
-/* Unmap a single streaming mode DMA translation.  The dma_addr and size
- * must match what was provided for in a previous pci_map_single call.  All
- * other usages are undefined.
- *
- * After this call, reads by the cpu to the buffer are guarenteed to see
- * whatever the device wrote there.
- */
-static inline void pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
-				    size_t size, int direction)
-{
-	if (direction == PCI_DMA_NONE)
-		BUG();
-
-	/* Nothing to do */
-}
-
-/* Map a set of buffers described by scatterlist in streaming
- * mode for DMA.  This is the scather-gather version of the
- * above pci_map_single interface.  Here the scatter gather list
- * elements are each tagged with the appropriate dma address
- * and length.  They are obtained via sg_dma_{address,length}(SG).
- *
- * NOTE: An implementation may be able to use a smaller number of
- *       DMA address/length pairs than there are SG table elements.
- *       (for example via virtual mapping capabilities)
- *       The routine returns the number of addr/length pairs actually
- *       used, at most nents.
- *
- * Device ownership issues as mentioned above for pci_map_single are
- * the same here.
- */
-static inline int pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg,
-			     int nents, int direction)
-{
-	if (direction == PCI_DMA_NONE)
-		BUG();
-	return nents;
-}
-
-/* Unmap a set of streaming mode DMA translations.
- * Again, cpu read rules concerning calls here are the same as for
- * pci_unmap_single() above.
- */
-static inline void pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg,
-				int nents, int direction)
-{
-	if (direction == PCI_DMA_NONE)
-		BUG();
-
-	/* Nothing to do */
-}
-
-/* Make physical memory consistent for a single
- * streaming mode DMA translation after a transfer.
- *
- * If you perform a pci_map_single() but wish to interrogate the
- * buffer using the cpu, yet do not wish to teardown the PCI dma
- * mapping, you must call this function before doing so.  At the
- * next point you give the PCI dma address back to the card, the
- * device again owns the buffer.
- */
-static inline void pci_dma_sync_single(struct pci_dev *hwdev,
-				       dma_addr_t dma_handle, size_t size,
-				       int direction)
-{
-	if (direction == PCI_DMA_NONE)
-		BUG();
-
-	/* Nothing to do */
-}
-
-/* Make physical memory consistent for a set of streaming
- * mode DMA translations after a transfer.
- *
- * The same as pci_dma_sync_single but for a scatter-gather list,
- * same rules and usage.
- */
-static inline void pci_dma_sync_sg(struct pci_dev *hwdev,
-				   struct scatterlist *sg, int nelems,
-				   int direction)
-{
-	if (direction == PCI_DMA_NONE)
-		BUG();
-
-	/* Nothing to do */
-}
-
-#endif				/* _ASM_BFIN_PCI_H */
+#include <asm-generic/pci.h>
diff --git a/arch/blackfin/include/asm/scatterlist.h b/arch/blackfin/include/asm/scatterlist.h
index 04f4487..35d786f 100644
--- a/arch/blackfin/include/asm/scatterlist.h
+++ b/arch/blackfin/include/asm/scatterlist.h
@@ -1,28 +1 @@
-#ifndef _BLACKFIN_SCATTERLIST_H
-#define _BLACKFIN_SCATTERLIST_H
-
-#include <linux/mm.h>
-
-struct scatterlist {
-#ifdef CONFIG_DEBUG_SG
-	unsigned long sg_magic;
-#endif
-	unsigned long page_link;
-	unsigned int offset;
-	dma_addr_t dma_address;
-	unsigned int length;
-};
-
-/*
- * These macros should be used after a pci_map_sg call has been done
- * to get bus addresses of each of the SG entries and their lengths.
- * You should only work with the number of sg entries pci_map_sg
- * returns, or alternatively stop on the first sg_dma_len(sg) which
- * is 0.
- */
-#define sg_dma_address(sg)      ((sg)->dma_address)
-#define sg_dma_len(sg)          ((sg)->length)
-
-#define ISA_DMA_THRESHOLD	(0xffffffff)
-
-#endif				/* !(_BLACKFIN_SCATTERLIST_H) */
+#include <asm-generic/scatterlist.h>
-- 
1.6.3.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 11/17] Blackfin: convert termios to asm-generic
  2009-06-14 12:01 [PATCH 00/17] Blackfin arch conversion to asm-generic Mike Frysinger
                   ` (9 preceding siblings ...)
  2009-06-14 12:01 ` [PATCH 10/17] Blackfin: convert dma/pci " Mike Frysinger
@ 2009-06-14 12:01 ` Mike Frysinger
  2009-06-14 12:01 ` [PATCH 12/17] Blackfin: convert locking primitives " Mike Frysinger
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Mike Frysinger @ 2009-06-14 12:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: uclinux-dist-devel

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 arch/blackfin/include/asm/termbits.h |  199 +---------------------------------
 arch/blackfin/include/asm/termios.h  |   95 +----------------
 2 files changed, 2 insertions(+), 292 deletions(-)

diff --git a/arch/blackfin/include/asm/termbits.h b/arch/blackfin/include/asm/termbits.h
index f37feb7..3935b10 100644
--- a/arch/blackfin/include/asm/termbits.h
+++ b/arch/blackfin/include/asm/termbits.h
@@ -1,198 +1 @@
-#ifndef __ARCH_BFIN_TERMBITS_H__
-#define __ARCH_BFIN_TERMBITS_H__
-
-#include <linux/posix_types.h>
-
-typedef unsigned char cc_t;
-typedef unsigned int speed_t;
-typedef unsigned int tcflag_t;
-
-#define NCCS 19
-struct termios {
-	tcflag_t c_iflag;	/* input mode flags */
-	tcflag_t c_oflag;	/* output mode flags */
-	tcflag_t c_cflag;	/* control mode flags */
-	tcflag_t c_lflag;	/* local mode flags */
-	cc_t c_line;		/* line discipline */
-	cc_t c_cc[NCCS];	/* control characters */
-};
-
-struct termios2 {
-	tcflag_t c_iflag;               /* input mode flags */
-	tcflag_t c_oflag;               /* output mode flags */
-	tcflag_t c_cflag;               /* control mode flags */
-	tcflag_t c_lflag;               /* local mode flags */
-	cc_t c_line;                    /* line discipline */
-	cc_t c_cc[NCCS];                /* control characters */
-	speed_t c_ispeed;               /* input speed */
-	speed_t c_ospeed;               /* output speed */
-};
-
-struct ktermios {
-	tcflag_t c_iflag;               /* input mode flags */
-	tcflag_t c_oflag;               /* output mode flags */
-	tcflag_t c_cflag;               /* control mode flags */
-	tcflag_t c_lflag;               /* local mode flags */
-	cc_t c_line;                    /* line discipline */
-	cc_t c_cc[NCCS];                /* control characters */
-	speed_t c_ispeed;               /* input speed */
-	speed_t c_ospeed;               /* output speed */
-};
-
-/* c_cc characters */
-#define VINTR 0
-#define VQUIT 1
-#define VERASE 2
-#define VKILL 3
-#define VEOF 4
-#define VTIME 5
-#define VMIN 6
-#define VSWTC 7
-#define VSTART 8
-#define VSTOP 9
-#define VSUSP 10
-#define VEOL 11
-#define VREPRINT 12
-#define VDISCARD 13
-#define VWERASE 14
-#define VLNEXT 15
-#define VEOL2 16
-
-/* c_iflag bits */
-#define IGNBRK	0000001
-#define BRKINT	0000002
-#define IGNPAR	0000004
-#define PARMRK	0000010
-#define INPCK	0000020
-#define ISTRIP	0000040
-#define INLCR	0000100
-#define IGNCR	0000200
-#define ICRNL	0000400
-#define IUCLC	0001000
-#define IXON	0002000
-#define IXANY	0004000
-#define IXOFF	0010000
-#define IMAXBEL	0020000
-#define IUTF8	0040000
-
-/* c_oflag bits */
-#define OPOST	0000001
-#define OLCUC	0000002
-#define ONLCR	0000004
-#define OCRNL	0000010
-#define ONOCR	0000020
-#define ONLRET	0000040
-#define OFILL	0000100
-#define OFDEL	0000200
-#define NLDLY	0000400
-#define   NL0	0000000
-#define   NL1	0000400
-#define CRDLY	0003000
-#define   CR0	0000000
-#define   CR1	0001000
-#define   CR2	0002000
-#define   CR3	0003000
-#define TABDLY	0014000
-#define   TAB0	0000000
-#define   TAB1	0004000
-#define   TAB2	0010000
-#define   TAB3	0014000
-#define   XTABS	0014000
-#define BSDLY	0020000
-#define   BS0	0000000
-#define   BS1	0020000
-#define VTDLY	0040000
-#define   VT0	0000000
-#define   VT1	0040000
-#define FFDLY	0100000
-#define   FF0	0000000
-#define   FF1	0100000
-
-/* c_cflag bit meaning */
-#define CBAUD	0010017
-#define  B0	0000000		/* hang up */
-#define  B50	0000001
-#define  B75	0000002
-#define  B110	0000003
-#define  B134	0000004
-#define  B150	0000005
-#define  B200	0000006
-#define  B300	0000007
-#define  B600	0000010
-#define  B1200	0000011
-#define  B1800	0000012
-#define  B2400	0000013
-#define  B4800	0000014
-#define  B9600	0000015
-#define  B19200	0000016
-#define  B38400	0000017
-#define EXTA B19200
-#define EXTB B38400
-#define CSIZE	0000060
-#define   CS5	0000000
-#define   CS6	0000020
-#define   CS7	0000040
-#define   CS8	0000060
-#define CSTOPB	0000100
-#define CREAD	0000200
-#define PARENB	0000400
-#define PARODD	0001000
-#define HUPCL	0002000
-#define CLOCAL	0004000
-#define CBAUDEX 0010000
-#define BOTHER	0010000
-#define    B57600 0010001
-#define   B115200 0010002
-#define   B230400 0010003
-#define   B460800 0010004
-#define   B500000 0010005
-#define   B576000 0010006
-#define   B921600 0010007
-#define  B1000000 0010010
-#define  B1152000 0010011
-#define  B1500000 0010012
-#define  B2000000 0010013
-#define  B2500000 0010014
-#define  B3000000 0010015
-#define  B3500000 0010016
-#define  B4000000 0010017
-#define CIBAUD	  002003600000	/* input baud rate */
-#define CMSPAR	  010000000000	/* mark or space (stick) parity */
-#define CRTSCTS	  020000000000	/* flow control */
-
-#define IBSHIFT	16	/* Shift from CBAUD to CIBAUD */
-
-/* c_lflag bits */
-#define ISIG	0000001
-#define ICANON	0000002
-#define XCASE	0000004
-#define ECHO	0000010
-#define ECHOE	0000020
-#define ECHOK	0000040
-#define ECHONL	0000100
-#define NOFLSH	0000200
-#define TOSTOP	0000400
-#define ECHOCTL	0001000
-#define ECHOPRT	0002000
-#define ECHOKE	0004000
-#define FLUSHO	0010000
-#define PENDIN	0040000
-#define IEXTEN	0100000
-
-/* tcflow() and TCXONC use these */
-#define	TCOOFF		0
-#define	TCOON		1
-#define	TCIOFF		2
-#define	TCION		3
-
-/* tcflush() and TCFLSH use these */
-#define	TCIFLUSH	0
-#define	TCOFLUSH	1
-#define	TCIOFLUSH	2
-
-/* tcsetattr uses these */
-#define	TCSANOW		0
-#define	TCSADRAIN	1
-#define	TCSAFLUSH	2
-
-#endif				/* __ARCH_BFIN_TERMBITS_H__ */
+#include <asm-generic/termbits.h>
diff --git a/arch/blackfin/include/asm/termios.h b/arch/blackfin/include/asm/termios.h
index d50d063..280d78a 100644
--- a/arch/blackfin/include/asm/termios.h
+++ b/arch/blackfin/include/asm/termios.h
@@ -1,94 +1 @@
-#ifndef __BFIN_TERMIOS_H__
-#define __BFIN_TERMIOS_H__
-
-#include <asm/termbits.h>
-#include <asm/ioctls.h>
-
-struct winsize {
-	unsigned short ws_row;
-	unsigned short ws_col;
-	unsigned short ws_xpixel;
-	unsigned short ws_ypixel;
-};
-
-#define NCC 8
-struct termio {
-	unsigned short c_iflag;	/* input mode flags */
-	unsigned short c_oflag;	/* output mode flags */
-	unsigned short c_cflag;	/* control mode flags */
-	unsigned short c_lflag;	/* local mode flags */
-	unsigned char c_line;	/* line discipline */
-	unsigned char c_cc[NCC];	/* control characters */
-};
-
-/* modem lines */
-#define TIOCM_LE	0x001
-#define TIOCM_DTR	0x002
-#define TIOCM_RTS	0x004
-#define TIOCM_ST	0x008
-#define TIOCM_SR	0x010
-#define TIOCM_CTS	0x020
-#define TIOCM_CAR	0x040
-#define TIOCM_RNG	0x080
-#define TIOCM_DSR	0x100
-#define TIOCM_CD	TIOCM_CAR
-#define TIOCM_RI	TIOCM_RNG
-#define TIOCM_OUT1	0x2000
-#define TIOCM_OUT2	0x4000
-#define TIOCM_LOOP	0x8000
-
-/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
-
-#ifdef __KERNEL__
-
-/*	intr=^C		quit=^\		erase=del	kill=^U
-	eof=^D		vtime=\0	vmin=\1		sxtc=\0
-	start=^Q	stop=^S		susp=^Z		eol=\0
-	reprint=^R	discard=^U	werase=^W	lnext=^V
-	eol2=\0
-*/
-#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
-
-/*
- * Translate a "termio" structure into a "termios". Ugh.
- */
-#define SET_LOW_TERMIOS_BITS(termios, termio, x) { \
-	unsigned short __tmp; \
-	get_user(__tmp,&(termio)->x); \
-	*(unsigned short *) &(termios)->x = __tmp; \
-}
-
-#define user_termio_to_kernel_termios(termios, termio) \
-({ \
-	SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \
-	SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \
-	SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \
-	SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \
-	copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
-})
-
-/*
- * Translate a "termios" structure into a "termio". Ugh.
- */
-#define kernel_termios_to_user_termio(termio, termios) \
-({ \
-	put_user((termios)->c_iflag, &(termio)->c_iflag); \
-	put_user((termios)->c_oflag, &(termio)->c_oflag); \
-	put_user((termios)->c_cflag, &(termio)->c_cflag); \
-	put_user((termios)->c_lflag, &(termio)->c_lflag); \
-	put_user((termios)->c_line,  &(termio)->c_line); \
-	copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
-})
-
-#define user_termios_to_kernel_termios(k, u) \
-	copy_from_user(k, u, sizeof(struct termios2))
-#define kernel_termios_to_user_termios(u, k) \
-	copy_to_user(u, k, sizeof(struct termios2))
-#define user_termios_to_kernel_termios_1(k, u) \
-	copy_from_user(k, u, sizeof(struct termios))
-#define kernel_termios_to_user_termios_1(u, k) \
-	copy_to_user(u, k, sizeof(struct termios))
-
-#endif				/* __KERNEL__ */
-
-#endif				/* __BFIN_TERMIOS_H__ */
+#include <asm-generic/termios.h>
-- 
1.6.3.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 12/17] Blackfin: convert locking primitives to asm-generic
  2009-06-14 12:01 [PATCH 00/17] Blackfin arch conversion to asm-generic Mike Frysinger
                   ` (10 preceding siblings ...)
  2009-06-14 12:01 ` [PATCH 11/17] Blackfin: convert termios " Mike Frysinger
@ 2009-06-14 12:01 ` Mike Frysinger
  2009-06-14 12:01 ` [PATCH 13/17] Blackfin: convert signal/mmap " Mike Frysinger
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Mike Frysinger @ 2009-06-14 12:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: uclinux-dist-devel

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 arch/blackfin/include/asm/atomic.h    |  109 +-----------------
 arch/blackfin/include/asm/bitops.h    |  198 ++-------------------------------
 arch/blackfin/include/asm/mutex.h     |    2 +-
 arch/blackfin/include/asm/spinlock.h  |    6 +
 arch/blackfin/include/asm/swab.h      |    6 +-
 arch/blackfin/include/asm/unaligned.h |   12 +--
 6 files changed, 25 insertions(+), 308 deletions(-)

diff --git a/arch/blackfin/include/asm/atomic.h b/arch/blackfin/include/asm/atomic.h
index b1d92f1..88f36d5 100644
--- a/arch/blackfin/include/asm/atomic.h
+++ b/arch/blackfin/include/asm/atomic.h
@@ -1,24 +1,21 @@
 #ifndef __ARCH_BLACKFIN_ATOMIC__
 #define __ARCH_BLACKFIN_ATOMIC__
 
+#ifndef CONFIG_SMP
+# include <asm-generic/atomic.h>
+#else
+
 #include <linux/types.h>
 #include <asm/system.h>	/* local_irq_XXX() */
 
 /*
  * Atomic operations that C can't guarantee us.  Useful for
  * resource counting etc..
- *
- * Generally we do not concern about SMP BFIN systems, so we don't have
- * to deal with that.
- *
- * Tony Kou (tonyko@lineo.ca)   Lineo Inc.   2001
  */
 
 #define ATOMIC_INIT(i)	{ (i) }
 #define atomic_set(v, i)	(((v)->counter) = i)
 
-#ifdef CONFIG_SMP
-
 #define atomic_read(v)	__raw_uncached_fetch_asm(&(v)->counter)
 
 asmlinkage int __raw_uncached_fetch_asm(const volatile int *ptr);
@@ -84,100 +81,6 @@ static inline int atomic_test_mask(int mask, atomic_t *v)
 #define smp_mb__before_atomic_inc()    barrier()
 #define smp_mb__after_atomic_inc() barrier()
 
-#else /* !CONFIG_SMP */
-
-#define atomic_read(v)	((v)->counter)
-
-static inline void atomic_add(int i, atomic_t *v)
-{
-	unsigned long flags;
-
-	local_irq_save_hw(flags);
-	v->counter += i;
-	local_irq_restore_hw(flags);
-}
-
-static inline void atomic_sub(int i, atomic_t *v)
-{
-	unsigned long flags;
-
-	local_irq_save_hw(flags);
-	v->counter -= i;
-	local_irq_restore_hw(flags);
-
-}
-
-static inline int atomic_add_return(int i, atomic_t *v)
-{
-	int __temp = 0;
-	unsigned long flags;
-
-	local_irq_save_hw(flags);
-	v->counter += i;
-	__temp = v->counter;
-	local_irq_restore_hw(flags);
-
-
-	return __temp;
-}
-
-static inline int atomic_sub_return(int i, atomic_t *v)
-{
-	int __temp = 0;
-	unsigned long flags;
-
-	local_irq_save_hw(flags);
-	v->counter -= i;
-	__temp = v->counter;
-	local_irq_restore_hw(flags);
-
-	return __temp;
-}
-
-static inline void atomic_inc(volatile atomic_t *v)
-{
-	unsigned long flags;
-
-	local_irq_save_hw(flags);
-	v->counter++;
-	local_irq_restore_hw(flags);
-}
-
-static inline void atomic_dec(volatile atomic_t *v)
-{
-	unsigned long flags;
-
-	local_irq_save_hw(flags);
-	v->counter--;
-	local_irq_restore_hw(flags);
-}
-
-static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
-{
-	unsigned long flags;
-
-	local_irq_save_hw(flags);
-	v->counter &= ~mask;
-	local_irq_restore_hw(flags);
-}
-
-static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
-{
-	unsigned long flags;
-
-	local_irq_save_hw(flags);
-	v->counter |= mask;
-	local_irq_restore_hw(flags);
-}
-
-/* Atomic operations are already serializing */
-#define smp_mb__before_atomic_dec()    barrier()
-#define smp_mb__after_atomic_dec() barrier()
-#define smp_mb__before_atomic_inc()    barrier()
-#define smp_mb__after_atomic_inc() barrier()
-
-#endif /* !CONFIG_SMP */
-
 #define atomic_add_negative(a, v)	(atomic_add_return((a), (v)) < 0)
 #define atomic_dec_return(v) atomic_sub_return(1,(v))
 #define atomic_inc_return(v) atomic_add_return(1,(v))
@@ -210,4 +113,6 @@ static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
 
 #include <asm-generic/atomic-long.h>
 
-#endif				/* __ARCH_BLACKFIN_ATOMIC __ */
+#endif
+
+#endif
diff --git a/arch/blackfin/include/asm/bitops.h b/arch/blackfin/include/asm/bitops.h
index 75fee2f..daffa71 100644
--- a/arch/blackfin/include/asm/bitops.h
+++ b/arch/blackfin/include/asm/bitops.h
@@ -1,26 +1,22 @@
 #ifndef _BLACKFIN_BITOPS_H
 #define _BLACKFIN_BITOPS_H
 
-/*
- * Copyright 1992, Linus Torvalds.
- */
-
-#include <linux/compiler.h>
-#include <asm/byteorder.h>	/* swab32 */
-
-#ifdef __KERNEL__
+#ifndef CONFIG_SMP
+# include <asm-generic/bitops.h>
+#else
 
 #ifndef _LINUX_BITOPS_H
 #error only <linux/bitops.h> can be included directly
 #endif
 
+#include <linux/compiler.h>
+#include <asm/byteorder.h>	/* swab32 */
+
 #include <asm-generic/bitops/ffs.h>
 #include <asm-generic/bitops/__ffs.h>
 #include <asm-generic/bitops/sched.h>
 #include <asm-generic/bitops/ffz.h>
 
-#ifdef CONFIG_SMP
-
 #include <linux/linkage.h>
 
 asmlinkage int __raw_bit_set_asm(volatile unsigned long *addr, int nr);
@@ -79,189 +75,13 @@ static inline int test_and_change_bit(int nr, volatile unsigned long *addr)
 	return __raw_bit_test_toggle_asm(a, nr & 0x1f);
 }
 
-#else /* !CONFIG_SMP */
-
-#include <asm/system.h>		/* save_flags */
-
-static inline void set_bit(int nr, volatile unsigned long *addr)
-{
-	int *a = (int *)addr;
-	int mask;
-	unsigned long flags;
-	a += nr >> 5;
-	mask = 1 << (nr & 0x1f);
-	local_irq_save_hw(flags);
-	*a |= mask;
-	local_irq_restore_hw(flags);
-}
-
-static inline void clear_bit(int nr, volatile unsigned long *addr)
-{
-	int *a = (int *)addr;
-	int mask;
-	unsigned long flags;
-	a += nr >> 5;
-	mask = 1 << (nr & 0x1f);
-	local_irq_save_hw(flags);
-	*a &= ~mask;
-	local_irq_restore_hw(flags);
-}
-
-static inline void change_bit(int nr, volatile unsigned long *addr)
-{
-	int mask;
-	unsigned long flags;
-	unsigned long *ADDR = (unsigned long *)addr;
-
-	ADDR += nr >> 5;
-	mask = 1 << (nr & 31);
-	local_irq_save_hw(flags);
-	*ADDR ^= mask;
-	local_irq_restore_hw(flags);
-}
-
-static inline int test_and_set_bit(int nr, volatile unsigned long *addr)
-{
-	int mask, retval;
-	volatile unsigned int *a = (volatile unsigned int *)addr;
-	unsigned long flags;
-
-	a += nr >> 5;
-	mask = 1 << (nr & 0x1f);
-	local_irq_save_hw(flags);
-	retval = (mask & *a) != 0;
-	*a |= mask;
-	local_irq_restore_hw(flags);
-
-	return retval;
-}
-
-static inline int test_and_clear_bit(int nr, volatile unsigned long *addr)
-{
-	int mask, retval;
-	volatile unsigned int *a = (volatile unsigned int *)addr;
-	unsigned long flags;
-
-	a += nr >> 5;
-	mask = 1 << (nr & 0x1f);
-	local_irq_save_hw(flags);
-	retval = (mask & *a) != 0;
-	*a &= ~mask;
-	local_irq_restore_hw(flags);
-
-	return retval;
-}
-
-static inline int test_and_change_bit(int nr, volatile unsigned long *addr)
-{
-	int mask, retval;
-	volatile unsigned int *a = (volatile unsigned int *)addr;
-	unsigned long flags;
-
-	a += nr >> 5;
-	mask = 1 << (nr & 0x1f);
-	local_irq_save_hw(flags);
-	retval = (mask & *a) != 0;
-	*a ^= mask;
-	local_irq_restore_hw(flags);
-	return retval;
-}
-
-#endif /* CONFIG_SMP */
-
 /*
  * clear_bit() doesn't provide any barrier for the compiler.
  */
 #define smp_mb__before_clear_bit()	barrier()
 #define smp_mb__after_clear_bit()	barrier()
 
-static inline void __set_bit(int nr, volatile unsigned long *addr)
-{
-	int *a = (int *)addr;
-	int mask;
-
-	a += nr >> 5;
-	mask = 1 << (nr & 0x1f);
-	*a |= mask;
-}
-
-static inline void __clear_bit(int nr, volatile unsigned long *addr)
-{
-	int *a = (int *)addr;
-	int mask;
-
-	a += nr >> 5;
-	mask = 1 << (nr & 0x1f);
-	*a &= ~mask;
-}
-
-static inline void __change_bit(int nr, volatile unsigned long *addr)
-{
-	int mask;
-	unsigned long *ADDR = (unsigned long *)addr;
-
-	ADDR += nr >> 5;
-	mask = 1 << (nr & 31);
-	*ADDR ^= mask;
-}
-
-static inline int __test_and_set_bit(int nr, volatile unsigned long *addr)
-{
-	int mask, retval;
-	volatile unsigned int *a = (volatile unsigned int *)addr;
-
-	a += nr >> 5;
-	mask = 1 << (nr & 0x1f);
-	retval = (mask & *a) != 0;
-	*a |= mask;
-	return retval;
-}
-
-static inline int __test_and_clear_bit(int nr, volatile unsigned long *addr)
-{
-	int mask, retval;
-	volatile unsigned int *a = (volatile unsigned int *)addr;
-
-	a += nr >> 5;
-	mask = 1 << (nr & 0x1f);
-	retval = (mask & *a) != 0;
-	*a &= ~mask;
-	return retval;
-}
-
-static inline int __test_and_change_bit(int nr,
-					    volatile unsigned long *addr)
-{
-	int mask, retval;
-	volatile unsigned int *a = (volatile unsigned int *)addr;
-
-	a += nr >> 5;
-	mask = 1 << (nr & 0x1f);
-	retval = (mask & *a) != 0;
-	*a ^= mask;
-	return retval;
-}
-
-static inline int __test_bit(int nr, const void *addr)
-{
-	int *a = (int *)addr;
-	int mask;
-
-	a += nr >> 5;
-	mask = 1 << (nr & 0x1f);
-	return ((mask & *a) != 0);
-}
-
-#ifndef CONFIG_SMP
-/*
- * This routine doesn't need irq save and restore ops in UP
- * context.
- */
-static inline int test_bit(int nr, const void *addr)
-{
-	return __test_bit(nr, addr);
-}
-#endif
+#include <asm-generic/bitops/non-atomic.h>
 
 #include <asm-generic/bitops/find.h>
 #include <asm-generic/bitops/hweight.h>
@@ -272,10 +92,10 @@ static inline int test_bit(int nr, const void *addr)
 
 #include <asm-generic/bitops/minix.h>
 
-#endif				/* __KERNEL__ */
-
 #include <asm-generic/bitops/fls.h>
 #include <asm-generic/bitops/__fls.h>
 #include <asm-generic/bitops/fls64.h>
 
+#endif /* CONFIG_SMP */
+
 #endif				/* _BLACKFIN_BITOPS_H */
diff --git a/arch/blackfin/include/asm/mutex.h b/arch/blackfin/include/asm/mutex.h
index 5d39925..5cc641c 100644
--- a/arch/blackfin/include/asm/mutex.h
+++ b/arch/blackfin/include/asm/mutex.h
@@ -10,7 +10,7 @@
 #define _ASM_MUTEX_H
 
 #ifndef CONFIG_SMP
-#include <asm-generic/mutex-dec.h>
+#include <asm-generic/mutex.h>
 #else
 
 static inline void
diff --git a/arch/blackfin/include/asm/spinlock.h b/arch/blackfin/include/asm/spinlock.h
index 0249ac3..d6ff4b5 100644
--- a/arch/blackfin/include/asm/spinlock.h
+++ b/arch/blackfin/include/asm/spinlock.h
@@ -1,6 +1,10 @@
 #ifndef __BFIN_SPINLOCK_H
 #define __BFIN_SPINLOCK_H
 
+#ifndef CONFIG_SMP
+# include <asm-generic/spinlock.h>
+#else
+
 #include <asm/atomic.h>
 
 asmlinkage int __raw_spin_is_locked_asm(volatile int *ptr);
@@ -86,4 +90,6 @@ static inline void __raw_write_unlock(raw_rwlock_t *rw)
 #define _raw_read_relax(lock)	cpu_relax()
 #define _raw_write_relax(lock)	cpu_relax()
 
+#endif
+
 #endif /*  !__BFIN_SPINLOCK_H */
diff --git a/arch/blackfin/include/asm/swab.h b/arch/blackfin/include/asm/swab.h
index 6403ad2..d442113 100644
--- a/arch/blackfin/include/asm/swab.h
+++ b/arch/blackfin/include/asm/swab.h
@@ -2,11 +2,7 @@
 #define _BLACKFIN_SWAB_H
 
 #include <linux/types.h>
-#include <linux/compiler.h>
-
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__) || defined(__KERNEL__)
-#  define __SWAB_64_THRU_32__
-#endif
+#include <asm-generic/swab.h>
 
 #ifdef __GNUC__
 
diff --git a/arch/blackfin/include/asm/unaligned.h b/arch/blackfin/include/asm/unaligned.h
index fd8a1d6..6cecbbb 100644
--- a/arch/blackfin/include/asm/unaligned.h
+++ b/arch/blackfin/include/asm/unaligned.h
@@ -1,11 +1 @@
-#ifndef _ASM_BLACKFIN_UNALIGNED_H
-#define _ASM_BLACKFIN_UNALIGNED_H
-
-#include <linux/unaligned/le_struct.h>
-#include <linux/unaligned/be_byteshift.h>
-#include <linux/unaligned/generic.h>
-
-#define get_unaligned	__get_unaligned_le
-#define put_unaligned	__put_unaligned_le
-
-#endif /* _ASM_BLACKFIN_UNALIGNED_H */
+#include <asm-generic/unaligned.h>
-- 
1.6.3.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 13/17] Blackfin: convert signal/mmap to asm-generic
  2009-06-14 12:01 [PATCH 00/17] Blackfin arch conversion to asm-generic Mike Frysinger
                   ` (11 preceding siblings ...)
  2009-06-14 12:01 ` [PATCH 12/17] Blackfin: convert locking primitives " Mike Frysinger
@ 2009-06-14 12:01 ` Mike Frysinger
  2009-06-14 12:01 ` [PATCH 14/17] Blackfin: convert irq/process " Mike Frysinger
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Mike Frysinger @ 2009-06-14 12:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: uclinux-dist-devel

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 arch/blackfin/include/asm/mman.h   |   44 +----------
 arch/blackfin/include/asm/signal.h |  159 +-----------------------------------
 2 files changed, 4 insertions(+), 199 deletions(-)

diff --git a/arch/blackfin/include/asm/mman.h b/arch/blackfin/include/asm/mman.h
index b58f5ad..8eebf89 100644
--- a/arch/blackfin/include/asm/mman.h
+++ b/arch/blackfin/include/asm/mman.h
@@ -1,43 +1 @@
-#ifndef __BFIN_MMAN_H__
-#define __BFIN_MMAN_H__
-
-#define PROT_READ	0x1	/* page can be read */
-#define PROT_WRITE	0x2	/* page can be written */
-#define PROT_EXEC	0x4	/* page can be executed */
-#define PROT_SEM	0x8	/* page may be used for atomic ops */
-#define PROT_NONE	0x0	/* page can not be accessed */
-#define PROT_GROWSDOWN	0x01000000	/* mprotect flag: extend change to start of growsdown vma */
-#define PROT_GROWSUP	0x02000000	/* mprotect flag: extend change to end of growsup vma */
-
-#define MAP_SHARED	0x01	/* Share changes */
-#define MAP_PRIVATE	0x02	/* Changes are private */
-#define MAP_TYPE	0x0f	/* Mask for type of mapping */
-#define MAP_FIXED	0x10	/* Interpret addr exactly */
-#define MAP_ANONYMOUS	0x20	/* don't use a file */
-
-#define MAP_GROWSDOWN	0x0100	/* stack-like segment */
-#define MAP_DENYWRITE	0x0800	/* ETXTBSY */
-#define MAP_EXECUTABLE	0x1000	/* mark it as an executable */
-#define MAP_LOCKED	0x2000	/* pages are locked */
-#define MAP_NORESERVE	0x4000	/* don't check for reservations */
-#define MAP_POPULATE	0x8000	/* populate (prefault) pagetables */
-#define MAP_NONBLOCK	0x10000	/* do not block on IO */
-
-#define MS_ASYNC	1	/* sync memory asynchronously */
-#define MS_INVALIDATE	2	/* invalidate the caches */
-#define MS_SYNC		4	/* synchronous memory sync */
-
-#define MCL_CURRENT	1	/* lock all current mappings */
-#define MCL_FUTURE	2	/* lock all future mappings */
-
-#define MADV_NORMAL	0x0	/* default page-in behavior */
-#define MADV_RANDOM	0x1	/* page-in minimum required */
-#define MADV_SEQUENTIAL	0x2	/* read-ahead aggressively */
-#define MADV_WILLNEED	0x3	/* pre-fault pages */
-#define MADV_DONTNEED	0x4	/* discard these pages */
-
-/* compatibility flags */
-#define MAP_ANON	MAP_ANONYMOUS
-#define MAP_FILE	0
-
-#endif				/* __BFIN_MMAN_H__ */
+#include <asm-generic/mman.h>
diff --git a/arch/blackfin/include/asm/signal.h b/arch/blackfin/include/asm/signal.h
index 2eea907..77a3bf3 100644
--- a/arch/blackfin/include/asm/signal.h
+++ b/arch/blackfin/include/asm/signal.h
@@ -1,160 +1,7 @@
 #ifndef _BLACKFIN_SIGNAL_H
 #define _BLACKFIN_SIGNAL_H
 
-#include <linux/types.h>
+#define SA_RESTORER 0x04000000
+#include <asm-generic/signal.h>
 
-/* Avoid too many header ordering problems.  */
-struct siginfo;
-
-#ifdef __KERNEL__
-/* Most things should be clean enough to redefine this at will, if care
-   is taken to make libc match.  */
-
-#define _NSIG		64
-#define _NSIG_BPW	32
-#define _NSIG_WORDS	(_NSIG / _NSIG_BPW)
-
-typedef unsigned long old_sigset_t;	/* at least 32 bits */
-
-typedef struct {
-	unsigned long sig[_NSIG_WORDS];
-} sigset_t;
-
-#else
-/* Here we must cater to libcs that poke about in kernel headers.  */
-
-#define NSIG		32
-typedef unsigned long sigset_t;
-
-#endif				/* __KERNEL__ */
-
-#define SIGHUP		 1
-#define SIGINT		 2
-#define SIGQUIT		 3
-#define SIGILL		 4
-#define SIGTRAP		 5
-#define SIGABRT		 6
-#define SIGIOT		 6
-#define SIGBUS		 7
-#define SIGFPE		 8
-#define SIGKILL		 9
-#define SIGUSR1		10
-#define SIGSEGV		11
-#define SIGUSR2		12
-#define SIGPIPE		13
-#define SIGALRM		14
-#define SIGTERM		15
-#define SIGSTKFLT	16
-#define SIGCHLD		17
-#define SIGCONT		18
-#define SIGSTOP		19
-#define SIGTSTP		20
-#define SIGTTIN		21
-#define SIGTTOU		22
-#define SIGURG		23
-#define SIGXCPU		24
-#define SIGXFSZ		25
-#define SIGVTALRM	26
-#define SIGPROF		27
-#define SIGWINCH	28
-#define SIGIO		29
-#define SIGPOLL		SIGIO
-/*
-#define SIGLOST		29
-*/
-#define SIGPWR		30
-#define SIGSYS		31
-#define	SIGUNUSED	31
-
-/* These should not be considered constants from userland.  */
-#define SIGRTMIN	32
-#define SIGRTMAX	_NSIG
-
-/*
- * SA_FLAGS values:
- *
- * SA_ONSTACK indicates that a registered stack_t will be used.
- * SA_INTERRUPT is a no-op, but left due to historical reasons. Use the
- * SA_RESTART flag to get restarting signals (which were the default long ago)
- * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
- * SA_RESETHAND clears the handler when the signal is delivered.
- * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
- * SA_NODEFER prevents the current signal from being masked in the handler.
- *
- * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
- * Unix names RESETHAND and NODEFER respectively.
- */
-#define SA_NOCLDSTOP	0x00000001
-#define SA_NOCLDWAIT	0x00000002	/* not supported yet */
-#define SA_SIGINFO	0x00000004
-#define SA_ONSTACK	0x08000000
-#define SA_RESTART	0x10000000
-#define SA_NODEFER	0x40000000
-#define SA_RESETHAND	0x80000000
-
-#define SA_NOMASK	SA_NODEFER
-#define SA_ONESHOT	SA_RESETHAND
-
-/*
- * sigaltstack controls
- */
-#define SS_ONSTACK	1
-#define SS_DISABLE	2
-
-#define MINSIGSTKSZ	2048
-#define SIGSTKSZ	8192
-
-#include <asm-generic/signal-defs.h>
-
-#ifdef __KERNEL__
-struct old_sigaction {
-	__sighandler_t sa_handler;
-	old_sigset_t sa_mask;
-	unsigned long sa_flags;
-	void (*sa_restorer) (void);
-};
-
-struct sigaction {
-	__sighandler_t sa_handler;
-	unsigned long sa_flags;
-	void (*sa_restorer) (void);
-	sigset_t sa_mask;	/* mask last for extensibility */
-};
-
-struct k_sigaction {
-	struct sigaction sa;
-};
-#else
-/* Here we must cater to libcs that poke about in kernel headers.  */
-
-struct sigaction {
-	union {
-		__sighandler_t _sa_handler;
-		void (*_sa_sigaction) (int, struct siginfo *, void *);
-	} _u;
-	sigset_t sa_mask;
-	unsigned long sa_flags;
-	void (*sa_restorer) (void);
-};
-
-#define sa_handler	_u._sa_handler
-#define sa_sigaction	_u._sa_sigaction
-
-#endif				/* __KERNEL__ */
-
-typedef struct sigaltstack {
-	void __user *ss_sp;
-	int ss_flags;
-	size_t ss_size;
-} stack_t;
-
-#ifdef __KERNEL__
-
-#include <asm/sigcontext.h>
-#undef __HAVE_ARCH_SIG_BITOPS
-
-#define ptrace_signal_deliver(regs, cookie) do { } while (0)
-
-#endif				/* __KERNEL__ */
-
-#endif				/* _BLACKFIN_SIGNAL_H */
+#endif
-- 
1.6.3.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 14/17] Blackfin: convert irq/process to asm-generic
  2009-06-14 12:01 [PATCH 00/17] Blackfin arch conversion to asm-generic Mike Frysinger
                   ` (12 preceding siblings ...)
  2009-06-14 12:01 ` [PATCH 13/17] Blackfin: convert signal/mmap " Mike Frysinger
@ 2009-06-14 12:01 ` Mike Frysinger
  2009-06-14 12:01 ` [PATCH 15/17] Blackfin: convert types " Mike Frysinger
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Mike Frysinger @ 2009-06-14 12:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: uclinux-dist-devel

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 arch/blackfin/include/asm/hardirq.h   |   36 ++------------------------------
 arch/blackfin/include/asm/irq.h       |    5 +---
 arch/blackfin/include/asm/processor.h |   35 ++-----------------------------
 arch/blackfin/kernel/process.c        |   23 +++++++++++++++++++++
 4 files changed, 30 insertions(+), 69 deletions(-)

diff --git a/arch/blackfin/include/asm/hardirq.h b/arch/blackfin/include/asm/hardirq.h
index 717181a..5a64084 100644
--- a/arch/blackfin/include/asm/hardirq.h
+++ b/arch/blackfin/include/asm/hardirq.h
@@ -1,47 +1,17 @@
 #ifndef __BFIN_HARDIRQ_H
 #define __BFIN_HARDIRQ_H
 
-#include <linux/cache.h>
-#include <linux/threads.h>
-#include <asm/irq.h>
-
-typedef struct {
-	unsigned int __softirq_pending;
-	unsigned int __syscall_count;
-	struct task_struct *__ksoftirqd_task;
-} ____cacheline_aligned irq_cpustat_t;
-
-#include <linux/irq_cpustat.h>	/* Standard mappings for irq_cpustat_t above */
-
-/*
- * We put the hardirq and softirq counter into the preemption
- * counter. The bitmask has the following meaning:
- *
- * - bits 0-7 are the preemption count (max preemption depth: 256)
- * - bits 8-15 are the softirq count (max # of softirqs: 256)
- * - bits 16-23 are the hardirq count (max # of hardirqs: 256)
- *
- * - ( bit 26 is the PREEMPT_ACTIVE flag. )
- *
- * PREEMPT_MASK: 0x000000ff
- * HARDIRQ_MASK: 0x0000ff00
- * SOFTIRQ_MASK: 0x00ff0000
- */
-
 #if NR_IRQS > 256
 #define HARDIRQ_BITS	9
 #else
 #define HARDIRQ_BITS	8
 #endif
 
-#ifdef NR_IRQS
-# if (1 << HARDIRQ_BITS) < NR_IRQS
-# error HARDIRQ_BITS is too low!
-# endif
-#endif
-
 #define __ARCH_IRQ_EXIT_IRQS_DISABLED	1
 
 extern void ack_bad_irq(unsigned int irq);
+#define ack_bad_irq ack_bad_irq
+
+#include <asm-generic/hardirq.h>
 
 #endif
diff --git a/arch/blackfin/include/asm/irq.h b/arch/blackfin/include/asm/irq.h
index 400bdd5..9a7f63a 100644
--- a/arch/blackfin/include/asm/irq.h
+++ b/arch/blackfin/include/asm/irq.h
@@ -45,9 +45,6 @@
 		: "d" (bfin_irq_flags) \
 	)
 
-static inline int irq_canonicalize(int irq)
-{
-	return irq;
-}
+#include <asm-generic/irq.h>
 
 #endif				/* _BFIN_IRQ_H_ */
diff --git a/arch/blackfin/include/asm/processor.h b/arch/blackfin/include/asm/processor.h
index 3040415..d0be99b 100644
--- a/arch/blackfin/include/asm/processor.h
+++ b/arch/blackfin/include/asm/processor.h
@@ -7,9 +7,8 @@
  */
 #define current_text_addr() ({ __label__ _l; _l: &&_l;})
 
+#include <asm/ptrace.h>
 #include <asm/blackfin.h>
-#include <asm/segment.h>
-#include <linux/compiler.h>
 
 static inline unsigned long rdusp(void)
 {
@@ -59,36 +58,8 @@ struct thread_struct {
 	PS_S, 0, 0						\
 }
 
-/*
- * Do necessary setup to start up a newly executed thread.
- *
- * pass the data segment into user programs if it exists,
- * it can't hurt anything as far as I can tell
- */
-#ifndef CONFIG_SMP
-#define start_thread(_regs, _pc, _usp)					\
-do {									\
-	set_fs(USER_DS);						\
-	(_regs)->pc = (_pc);						\
-	if (current->mm)						\
-		(_regs)->p5 = current->mm->start_data;			\
-	task_thread_info(current)->l1_task_info.stack_start		\
-		= (void *)current->mm->context.stack_start;		\
-	task_thread_info(current)->l1_task_info.lowest_sp = (void *)(_usp); \
-	memcpy(L1_SCRATCH_TASK_INFO, &task_thread_info(current)->l1_task_info, \
-		sizeof(*L1_SCRATCH_TASK_INFO));				\
-	wrusp(_usp);							\
-} while(0)
-#else
-#define start_thread(_regs, _pc, _usp)					\
-do {									\
-	set_fs(USER_DS);						\
-	(_regs)->pc = (_pc);						\
-	if (current->mm)						\
-		(_regs)->p5 = current->mm->start_data;			\
-	wrusp(_usp);							\
-} while (0)
-#endif
+extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
+					       unsigned long new_sp);
 
 /* Forward declaration, a strange C thing */
 struct task_struct;
diff --git a/arch/blackfin/kernel/process.c b/arch/blackfin/kernel/process.c
index 30d0843..3e1d86e 100644
--- a/arch/blackfin/kernel/process.c
+++ b/arch/blackfin/kernel/process.c
@@ -160,6 +160,29 @@ pid_t kernel_thread(int (*fn) (void *), void *arg, unsigned long flags)
 }
 EXPORT_SYMBOL(kernel_thread);
 
+/*
+ * Do necessary setup to start up a newly executed thread.
+ *
+ * pass the data segment into user programs if it exists,
+ * it can't hurt anything as far as I can tell
+ */
+void start_thread(struct pt_regs *regs, unsigned long new_ip, unsigned long new_sp)
+{
+	set_fs(USER_DS);
+	regs->pc = new_ip;
+	if (current->mm)
+		regs->p5 = current->mm->start_data;
+#ifdef CONFIG_SMP
+	task_thread_info(current)->l1_task_info.stack_start =
+		(void *)current->mm->context.stack_start;
+	task_thread_info(current)->l1_task_info.lowest_sp = (void *)new_sp;
+	memcpy(L1_SCRATCH_TASK_INFO, &task_thread_info(current)->l1_task_info,
+	       sizeof(*L1_SCRATCH_TASK_INFO));
+#endif
+	wrusp(new_sp);
+}
+EXPORT_SYMBOL_GPL(start_thread);
+
 void flush_thread(void)
 {
 }
-- 
1.6.3.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 15/17] Blackfin: convert types to asm-generic
  2009-06-14 12:01 [PATCH 00/17] Blackfin arch conversion to asm-generic Mike Frysinger
                   ` (13 preceding siblings ...)
  2009-06-14 12:01 ` [PATCH 14/17] Blackfin: convert irq/process " Mike Frysinger
@ 2009-06-14 12:01 ` Mike Frysinger
  2009-06-14 12:01 ` [PATCH 16/17] Blackfin: convert page/tlb " Mike Frysinger
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Mike Frysinger @ 2009-06-14 12:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: uclinux-dist-devel

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 arch/blackfin/include/asm/posix_types.h |   56 ++++++-------------------------
 arch/blackfin/include/asm/types.h       |   37 +--------------------
 2 files changed, 12 insertions(+), 81 deletions(-)

diff --git a/arch/blackfin/include/asm/posix_types.h b/arch/blackfin/include/asm/posix_types.h
index 23aa1f8..80c9d64 100644
--- a/arch/blackfin/include/asm/posix_types.h
+++ b/arch/blackfin/include/asm/posix_types.h
@@ -1,61 +1,27 @@
 #ifndef __ARCH_BFIN_POSIX_TYPES_H
 #define __ARCH_BFIN_POSIX_TYPES_H
 
-/*
- * This file is generally used by user-level software, so you need to
- * be a little careful about namespace pollution etc.  Also, we cannot
- * assume GCC is being used.
- */
-
-typedef unsigned long __kernel_ino_t;
 typedef unsigned short __kernel_mode_t;
+#define __kernel_mode_t __kernel_mode_t
+
 typedef unsigned short __kernel_nlink_t;
-typedef long __kernel_off_t;
-typedef int __kernel_pid_t;
+#define __kernel_nlink_t __kernel_nlink_t
+
 typedef unsigned int __kernel_ipc_pid_t;
-typedef unsigned int __kernel_uid_t;
-typedef unsigned int __kernel_gid_t;
+#define __kernel_ipc_pid_t __kernel_ipc_pid_t
+
 typedef unsigned long __kernel_size_t;
 typedef long __kernel_ssize_t;
 typedef int __kernel_ptrdiff_t;
-typedef long __kernel_time_t;
-typedef long __kernel_suseconds_t;
-typedef long __kernel_clock_t;
-typedef int __kernel_timer_t;
-typedef int __kernel_clockid_t;
-typedef int __kernel_daddr_t;
-typedef char *__kernel_caddr_t;
-typedef unsigned short __kernel_uid16_t;
-typedef unsigned short __kernel_gid16_t;
-typedef unsigned int __kernel_uid32_t;
-typedef unsigned int __kernel_gid32_t;
+#define __kernel_size_t __kernel_size_t
 
 typedef unsigned short __kernel_old_uid_t;
 typedef unsigned short __kernel_old_gid_t;
-typedef unsigned short __kernel_old_dev_t;
-
-#ifdef __GNUC__
-typedef long long __kernel_loff_t;
-#endif
+#define __kernel_old_uid_t __kernel_old_uid_t
 
-typedef struct {
-	int val[2];
-} __kernel_fsid_t;
-
-#if defined(__KERNEL__)
-
-#undef	__FD_SET
-#define	__FD_SET(d, set)	((set)->fds_bits[__FDELT(d)] |= __FDMASK(d))
-
-#undef	__FD_CLR
-#define	__FD_CLR(d, set)	((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d))
-
-#undef	__FD_ISSET
-#define	__FD_ISSET(d, set)	((set)->fds_bits[__FDELT(d)] & __FDMASK(d))
-
-#undef	__FD_ZERO
-#define __FD_ZERO(fdsetp) (memset (fdsetp, 0, sizeof(*(fd_set *)fdsetp)))
+typedef unsigned short __kernel_old_dev_t;
+#define __kernel_old_dev_t __kernel_old_dev_t
 
-#endif				/* defined(__KERNEL__) */
+#include <asm-generic/posix_types.h>
 
 #endif
diff --git a/arch/blackfin/include/asm/types.h b/arch/blackfin/include/asm/types.h
index 8441cbc..b9e79bc 100644
--- a/arch/blackfin/include/asm/types.h
+++ b/arch/blackfin/include/asm/types.h
@@ -1,36 +1 @@
-#ifndef _BFIN_TYPES_H
-#define _BFIN_TYPES_H
-
-/*
- * This file is never included by application software unless
- * explicitly requested (e.g., via linux/types.h) in which case the
- * application is Linux specific so (user-) name space pollution is
- * not a major issue.  However, for interoperability, libraries still
- * need to be careful to avoid a name clashes.
- */
-#include <asm-generic/int-ll64.h>
-
-#ifndef __ASSEMBLY__
-
-typedef unsigned short umode_t;
-
-#endif				/* __ASSEMBLY__ */
-/*
- * These aren't exported outside the kernel to avoid name space clashes
- */
-#ifdef __KERNEL__
-
-#define BITS_PER_LONG 32
-
-#ifndef __ASSEMBLY__
-
-/* Dma addresses are 32-bits wide.  */
-
-typedef u32 dma_addr_t;
-typedef u64 dma64_addr_t;
-
-#endif				/* __ASSEMBLY__ */
-
-#endif				/* __KERNEL__ */
-
-#endif				/* _BFIN_TYPES_H */
+#include <asm-generic/types.h>
-- 
1.6.3.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 16/17] Blackfin: convert page/tlb to asm-generic
  2009-06-14 12:01 [PATCH 00/17] Blackfin arch conversion to asm-generic Mike Frysinger
                   ` (14 preceding siblings ...)
  2009-06-14 12:01 ` [PATCH 15/17] Blackfin: convert types " Mike Frysinger
@ 2009-06-14 12:01 ` Mike Frysinger
  2009-06-14 12:01 ` [PATCH 17/17] Blackfin: convert uaccess " Mike Frysinger
  2009-06-15 11:42 ` [PATCH 00/17] Blackfin arch conversion " Arnd Bergmann
  17 siblings, 0 replies; 33+ messages in thread
From: Mike Frysinger @ 2009-06-14 12:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: uclinux-dist-devel

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 arch/blackfin/include/asm/io.h       |    1 -
 arch/blackfin/include/asm/page.h     |   85 +---------------------------------
 arch/blackfin/include/asm/tlbflush.h |   57 +----------------------
 arch/blackfin/include/asm/ucontext.h |   18 +-------
 4 files changed, 4 insertions(+), 157 deletions(-)

diff --git a/arch/blackfin/include/asm/io.h b/arch/blackfin/include/asm/io.h
index 3022b5c..37053ec 100644
--- a/arch/blackfin/include/asm/io.h
+++ b/arch/blackfin/include/asm/io.h
@@ -222,7 +222,6 @@ extern void blkfin_inv_cache_all(void);
 #define	ioport_unmap(addr)
 
 /* Pages to physical address... */
-#define page_to_phys(page)      ((page - mem_map) << PAGE_SHIFT)
 #define page_to_bus(page)       ((page - mem_map) << PAGE_SHIFT)
 
 #define phys_to_virt(vaddr)	((void *) (vaddr))
diff --git a/arch/blackfin/include/asm/page.h b/arch/blackfin/include/asm/page.h
index 3ea2016..29dcf75 100644
--- a/arch/blackfin/include/asm/page.h
+++ b/arch/blackfin/include/asm/page.h
@@ -1,88 +1,7 @@
 #ifndef _BLACKFIN_PAGE_H
 #define _BLACKFIN_PAGE_H
 
-/* PAGE_SHIFT determines the page size */
+#include <asm-generic/page.h>
+#define MAP_NR(addr) (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)
 
-#define PAGE_SHIFT	12
-#ifdef __ASSEMBLY__
-#define PAGE_SIZE	(1 << PAGE_SHIFT)
-#else
-#define PAGE_SIZE	(1UL << PAGE_SHIFT)
 #endif
-#define PAGE_MASK	(~(PAGE_SIZE-1))
-
-#include <asm/setup.h>
-
-#ifndef __ASSEMBLY__
-
-#define get_user_page(vaddr)		__get_free_page(GFP_KERNEL)
-#define free_user_page(page, addr)	free_page(addr)
-
-#define clear_page(page)	memset((page), 0, PAGE_SIZE)
-#define copy_page(to,from)	memcpy((to), (from), PAGE_SIZE)
-
-#define clear_user_page(page, vaddr,pg)	clear_page(page)
-#define copy_user_page(to, from, vaddr,pg)	copy_page(to, from)
-
-/*
- * These are used to make use of C type-checking..
- */
-typedef struct {
-	unsigned long pte;
-} pte_t;
-typedef struct {
-	unsigned long pmd[16];
-} pmd_t;
-typedef struct {
-	unsigned long pgd;
-} pgd_t;
-typedef struct {
-	unsigned long pgprot;
-} pgprot_t;
-typedef struct page *pgtable_t;
-
-#define pte_val(x)	((x).pte)
-#define pmd_val(x)	((&x)->pmd[0])
-#define pgd_val(x)	((x).pgd)
-#define pgprot_val(x)	((x).pgprot)
-
-#define __pte(x)	((pte_t) { (x) } )
-#define __pmd(x)	((pmd_t) { (x) } )
-#define __pgd(x)	((pgd_t) { (x) } )
-#define __pgprot(x)	((pgprot_t) { (x) } )
-
-extern unsigned long memory_start;
-extern unsigned long memory_end;
-
-#endif				/* !__ASSEMBLY__ */
-
-#include <asm/page_offset.h>
-#include <asm/io.h>
-
-#define PAGE_OFFSET		(PAGE_OFFSET_RAW)
-
-#ifndef __ASSEMBLY__
-
-#define __pa(vaddr)		virt_to_phys((void *)(vaddr))
-#define __va(paddr)		phys_to_virt((unsigned long)(paddr))
-
-#define MAP_NR(addr)		(((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)
-
-#define virt_to_pfn(kaddr)	(__pa(kaddr) >> PAGE_SHIFT)
-#define pfn_to_virt(pfn)	__va((pfn) << PAGE_SHIFT)
-#define virt_to_page(addr)	(mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT))
-#define page_to_virt(page)	((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET)
-#define VALID_PAGE(page)	((page - mem_map) < max_mapnr)
-
-#define pfn_to_page(pfn)	virt_to_page(pfn_to_virt(pfn))
-#define page_to_pfn(page)	virt_to_pfn(page_to_virt(page))
-#define pfn_valid(pfn)	        ((pfn) < max_mapnr)
-
-#define	virt_addr_valid(kaddr)	(((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
-				((void *)(kaddr) < (void *)memory_end))
-
-#include <asm-generic/getorder.h>
-
-#endif				/* __ASSEMBLY__ */
-
-#endif				/* _BLACKFIN_PAGE_H */
diff --git a/arch/blackfin/include/asm/tlbflush.h b/arch/blackfin/include/asm/tlbflush.h
index 277b400..f1a06c0 100644
--- a/arch/blackfin/include/asm/tlbflush.h
+++ b/arch/blackfin/include/asm/tlbflush.h
@@ -1,56 +1 @@
-#ifndef _BLACKFIN_TLBFLUSH_H
-#define _BLACKFIN_TLBFLUSH_H
-
-/*
- * Copyright (C) 2000 Lineo, David McCullough <davidm@uclinux.org>
- * Copyright (C) 2000-2002, Greg Ungerer <gerg@snapgear.com>
- */
-
-#include <asm/setup.h>
-
-/*
- * flush all user-space atc entries.
- */
-static inline void __flush_tlb(void)
-{
-	BUG();
-}
-
-static inline void __flush_tlb_one(unsigned long addr)
-{
-	BUG();
-}
-
-#define flush_tlb() __flush_tlb()
-
-/*
- * flush all atc entries (both kernel and user-space entries).
- */
-static inline void flush_tlb_all(void)
-{
-	BUG();
-}
-
-static inline void flush_tlb_mm(struct mm_struct *mm)
-{
-	BUG();
-}
-
-static inline void flush_tlb_page(struct vm_area_struct *vma,
-				  unsigned long addr)
-{
-	BUG();
-}
-
-static inline void flush_tlb_range(struct mm_struct *mm,
-				   unsigned long start, unsigned long end)
-{
-	BUG();
-}
-
-static inline void flush_tlb_kernel_page(unsigned long addr)
-{
-	BUG();
-}
-
-#endif
+#include <asm-generic/tlbflush.h>
diff --git a/arch/blackfin/include/asm/ucontext.h b/arch/blackfin/include/asm/ucontext.h
index 4a4e385..9bc07b9 100644
--- a/arch/blackfin/include/asm/ucontext.h
+++ b/arch/blackfin/include/asm/ucontext.h
@@ -1,17 +1 @@
-/** Changes made by Tony Kou   Lineo Inc.    May 2001
- *
- *  Based on: include/m68knommu/ucontext.h
- */
-
-#ifndef _BLACKFIN_UCONTEXT_H
-#define _BLACKFIN_UCONTEXT_H
-
-struct ucontext {
-	unsigned long uc_flags;	/* the others are necessary */
-	struct ucontext *uc_link;
-	stack_t uc_stack;
-	struct sigcontext uc_mcontext;
-	sigset_t uc_sigmask;	/* mask last for extensibility */
-};
-
-#endif				/* _BLACKFIN_UCONTEXT_H */
+#include <asm-generic/ucontext.h>
-- 
1.6.3.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 17/17] Blackfin: convert uaccess to asm-generic
  2009-06-14 12:01 [PATCH 00/17] Blackfin arch conversion to asm-generic Mike Frysinger
                   ` (15 preceding siblings ...)
  2009-06-14 12:01 ` [PATCH 16/17] Blackfin: convert page/tlb " Mike Frysinger
@ 2009-06-14 12:01 ` Mike Frysinger
  2009-06-15 11:42 ` [PATCH 00/17] Blackfin arch conversion " Arnd Bergmann
  17 siblings, 0 replies; 33+ messages in thread
From: Mike Frysinger @ 2009-06-14 12:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: uclinux-dist-devel

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 arch/blackfin/include/asm/segment.h |    8 +-
 arch/blackfin/include/asm/uaccess.h |  265 ++---------------------------------
 2 files changed, 10 insertions(+), 263 deletions(-)

diff --git a/arch/blackfin/include/asm/segment.h b/arch/blackfin/include/asm/segment.h
index 02cfd09..f1b81e5 100644
--- a/arch/blackfin/include/asm/segment.h
+++ b/arch/blackfin/include/asm/segment.h
@@ -1,7 +1 @@
-#ifndef _BFIN_SEGMENT_H
-#define _BFIN_SEGMENT_H
-
-#define KERNEL_DS   (0x5)
-#define USER_DS     (0x1)
-
-#endif				/* _BFIN_SEGMENT_H */
+#include <asm-generic/segment.h>
diff --git a/arch/blackfin/include/asm/uaccess.h b/arch/blackfin/include/asm/uaccess.h
index 8894e9f..6f235e2 100644
--- a/arch/blackfin/include/asm/uaccess.h
+++ b/arch/blackfin/include/asm/uaccess.h
@@ -1,268 +1,21 @@
-/* Changes made by Lineo Inc.    May 2001
- *
- * Based on: include/asm-m68knommu/uaccess.h
+/*
+ * User space memory access functions
  */
 
 #ifndef __BLACKFIN_UACCESS_H
 #define __BLACKFIN_UACCESS_H
 
-/*
- * User space memory access functions
- */
-#include <linux/sched.h>
-#include <linux/mm.h>
-#include <linux/string.h>
+#define KERNEL_DS   (0x5)
+#define USER_DS     (0x1)
 
-#include <asm/segment.h>
 #ifdef CONFIG_ACCESS_CHECK
-# include <asm/bfin-global.h>
+# define __access_ok(ptr, size) _access_ok((unsigned long)(ptr), size)
+extern int _access_ok(unsigned long ptr, unsigned long size);
 #endif
 
-#define get_ds()        (KERNEL_DS)
-#define get_fs()        (current_thread_info()->addr_limit)
-
-static inline void set_fs(mm_segment_t fs)
-{
-	current_thread_info()->addr_limit = fs;
-}
-
-#define segment_eq(a,b) ((a) == (b))
+#include <asm-generic/uaccess.h>
 
-#define VERIFY_READ	0
-#define VERIFY_WRITE	1
-
-#define access_ok(type, addr, size) _access_ok((unsigned long)(addr), (size))
-
-static inline int is_in_rom(unsigned long addr)
-{
-	/*
-	 * What we are really trying to do is determine if addr is
-	 * in an allocated kernel memory region. If not then assume
-	 * we cannot free it or otherwise de-allocate it. Ideally
-	 * we could restrict this to really being in a ROM or flash,
-	 * but that would need to be done on a board by board basis,
-	 * not globally.
-	 */
-	if ((addr < _ramstart) || (addr >= _ramend))
-		return (1);
-
-	/* Default case, not in ROM */
-	return (0);
-}
-
-/*
- * The fs value determines whether argument validity checking should be
- * performed or not.  If get_fs() == USER_DS, checking is performed, with
- * get_fs() == KERNEL_DS, checking is bypassed.
- */
+#undef segment_eq
+#define segment_eq(a, b) ((a) == (b))
 
-#ifndef CONFIG_ACCESS_CHECK
-static inline int _access_ok(unsigned long addr, unsigned long size) { return 1; }
-#else
-extern int _access_ok(unsigned long addr, unsigned long size);
 #endif
-
-/*
- * The exception table consists of pairs of addresses: the first is the
- * address of an instruction that is allowed to fault, and the second is
- * the address at which the program should continue.  No registers are
- * modified, so it is entirely up to the continuation code to figure out
- * what to do.
- *
- * All the routines below use bits of fixup code that are out of line
- * with the main instruction path.  This means when everything is well,
- * we don't even have to jump over them.  Further, they do not intrude
- * on our cache or tlb entries.
- */
-
-struct exception_table_entry {
-	unsigned long insn, fixup;
-};
-
-/*
- * These are the main single-value transfer routines.  They automatically
- * use the right size if we just have the right pointer type.
- */
-
-#define put_user(x,p)						\
-	({							\
-		int _err = 0;					\
-		typeof(*(p)) _x = (x);				\
-		typeof(*(p)) *_p = (p);				\
-		if (!access_ok(VERIFY_WRITE, _p, sizeof(*(_p)))) {\
-			_err = -EFAULT;				\
-		}						\
-		else {						\
-		switch (sizeof (*(_p))) {			\
-		case 1:						\
-			__put_user_asm(_x, _p, B);		\
-			break;					\
-		case 2:						\
-			__put_user_asm(_x, _p, W);		\
-			break;					\
-		case 4:						\
-			__put_user_asm(_x, _p,  );		\
-			break;					\
-		case 8: {					\
-			long _xl, _xh;				\
-			_xl = ((long *)&_x)[0];			\
-			_xh = ((long *)&_x)[1];			\
-			__put_user_asm(_xl, ((long *)_p)+0, );	\
-			__put_user_asm(_xh, ((long *)_p)+1, );	\
-		} break;					\
-		default:					\
-			_err = __put_user_bad();		\
-			break;					\
-		}						\
-		}						\
-		_err;						\
-	})
-
-#define __put_user(x,p) put_user(x,p)
-static inline int bad_user_access_length(void)
-{
-	panic("bad_user_access_length");
-	return -1;
-}
-
-#define __put_user_bad() (printk(KERN_INFO "put_user_bad %s:%d %s\n",\
-                           __FILE__, __LINE__, __func__),\
-                           bad_user_access_length(), (-EFAULT))
-
-/*
- * Tell gcc we read from memory instead of writing: this is because
- * we do not write to any memory gcc knows about, so there are no
- * aliasing issues.
- */
-
-#define __ptr(x) ((unsigned long *)(x))
-
-#define __put_user_asm(x,p,bhw)				\
-	__asm__ (#bhw"[%1] = %0;\n\t"			\
-		 : /* no outputs */			\
-		 :"d" (x),"a" (__ptr(p)) : "memory")
-
-#define get_user(x, ptr)					\
-({								\
-	int _err = 0;						\
-	unsigned long _val = 0;					\
-	const typeof(*(ptr)) __user *_p = (ptr);		\
-	const size_t ptr_size = sizeof(*(_p));			\
-	if (likely(access_ok(VERIFY_READ, _p, ptr_size))) {	\
-		BUILD_BUG_ON(ptr_size >= 8);			\
-		switch (ptr_size) {				\
-		case 1:						\
-			__get_user_asm(_val, _p, B,(Z));	\
-			break;					\
-		case 2:						\
-			__get_user_asm(_val, _p, W,(Z));	\
-			break;					\
-		case 4:						\
-			__get_user_asm(_val, _p,  , );		\
-			break;					\
-		}						\
-	} else							\
-		_err = -EFAULT;					\
-	x = (typeof(*(ptr)))_val;				\
-	_err;							\
-})
-
-#define __get_user(x,p) get_user(x,p)
-
-#define __get_user_bad() (bad_user_access_length(), (-EFAULT))
-
-#define __get_user_asm(x, ptr, bhw, option)	\
-({						\
-	__asm__ __volatile__ (			\
-		"%0 =" #bhw "[%1]" #option ";"	\
-		: "=d" (x)			\
-		: "a" (__ptr(ptr)));		\
-})
-
-#define __copy_from_user(to, from, n) copy_from_user(to, from, n)
-#define __copy_to_user(to, from, n) copy_to_user(to, from, n)
-#define __copy_to_user_inatomic __copy_to_user
-#define __copy_from_user_inatomic __copy_from_user
-
-#define copy_to_user_ret(to,from,n,retval) ({ if (copy_to_user(to,from,n))\
-				                 return retval; })
-
-#define copy_from_user_ret(to,from,n,retval) ({ if (copy_from_user(to,from,n))\
-                                                   return retval; })
-
-static inline unsigned long __must_check
-copy_from_user(void *to, const void __user *from, unsigned long n)
-{
-	if (access_ok(VERIFY_READ, from, n))
-		memcpy(to, from, n);
-	else
-		return n;
-	return 0;
-}
-
-static inline unsigned long __must_check
-copy_to_user(void *to, const void __user *from, unsigned long n)
-{
-	if (access_ok(VERIFY_WRITE, to, n))
-		memcpy(to, from, n);
-	else
-		return n;
-	return 0;
-}
-
-/*
- * Copy a null terminated string from userspace.
- */
-
-static inline long __must_check
-strncpy_from_user(char *dst, const char *src, long count)
-{
-	char *tmp;
-	if (!access_ok(VERIFY_READ, src, 1))
-		return -EFAULT;
-	strncpy(dst, src, count);
-	for (tmp = dst; *tmp && count > 0; tmp++, count--) ;
-	return (tmp - dst);
-}
-
-/*
- * Get the size of a string in user space.
- *   src: The string to measure
- *     n: The maximum valid length
- *
- * Get the size of a NUL-terminated string in user space.
- *
- * Returns the size of the string INCLUDING the terminating NUL.
- * On exception, returns 0.
- * If the string is too long, returns a value greater than n.
- */
-static inline long __must_check strnlen_user(const char *src, long n)
-{
-	if (!access_ok(VERIFY_READ, src, 1))
-		return 0;
-	return strnlen(src, n) + 1;
-}
-
-static inline long __must_check strlen_user(const char *src)
-{
-	if (!access_ok(VERIFY_READ, src, 1))
-		return 0;
-	return strlen(src) + 1;
-}
-
-/*
- * Zero Userspace
- */
-
-static inline unsigned long __must_check
-__clear_user(void *to, unsigned long n)
-{
-	if (!access_ok(VERIFY_WRITE, to, n))
-		return n;
-	memset(to, 0, n);
-	return 0;
-}
-
-#define clear_user(to, n) __clear_user(to, n)
-
-#endif				/* _BLACKFIN_UACCESS_H */
-- 
1.6.3.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* Re: [PATCH 05/17] Blackfin: convert to generic checksum code
  2009-06-14 12:01 ` [PATCH 05/17] Blackfin: convert to generic checksum code Mike Frysinger
@ 2009-06-15 11:04   ` Arnd Bergmann
  2009-06-16 10:03     ` Mike Frysinger
  2009-06-19  1:19     ` Mike Frysinger
  0 siblings, 2 replies; 33+ messages in thread
From: Arnd Bergmann @ 2009-06-15 11:04 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: linux-kernel, uclinux-dist-devel

On Sunday 14 June 2009, Mike Frysinger wrote:
> The Blackfin port only implemented an optimized version of the
> csum_tcpudp_nofold function, so convert everything else to the new
> generic code.
> 
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>

Have you tested this one well? I was as careful as possible with the
version I added, but it was basically only tested on microblaze, which
has a different endianess from blackfin. Some areas of the code may be
sensitive to this.

	Arnd <><

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 10/17] Blackfin: convert dma/pci to asm-generic
  2009-06-14 12:01 ` [PATCH 10/17] Blackfin: convert dma/pci " Mike Frysinger
@ 2009-06-15 11:37   ` Arnd Bergmann
  2009-06-16 10:00     ` Mike Frysinger
  0 siblings, 1 reply; 33+ messages in thread
From: Arnd Bergmann @ 2009-06-15 11:37 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: linux-kernel, uclinux-dist-devel

On Sunday 14 June 2009, Mike Frysinger wrote:
> --- a/arch/blackfin/include/asm/dma-mapping.h
> +++ b/arch/blackfin/include/asm/dma-mapping.h
> @@ -2,97 +2,28 @@
>  #define _BLACKFIN_DMA_MAPPING_H
>  
>  #include <asm/scatterlist.h>
> +#include <asm-generic/dma-mapping-broken.h>

I would leave this one alone, I don't think that moving
to dma-mapping-broken.h helps here. I have a dma-mapping
branch in my asm-generic repository. While I could not
get an agreement on an approach for a common dma-mapping.h
file for asm-generic, I did a number of cleanups on a few
architectures. Feel free to take this patch as a base for
your work.

Completely untested, of course.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

diff --git a/arch/blackfin/include/asm/dma-mapping.h b/arch/blackfin/include/asm/dma-mapping.h
index d7d9148..3be8f93 100644
--- a/arch/blackfin/include/asm/dma-mapping.h
+++ b/arch/blackfin/include/asm/dma-mapping.h
@@ -3,63 +3,101 @@
 
 #include <asm/scatterlist.h>
 
-void dma_alloc_init(unsigned long start, unsigned long end);
-void *dma_alloc_coherent(struct device *dev, size_t size,
-			 dma_addr_t *dma_handle, gfp_t gfp);
-void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
-		       dma_addr_t dma_handle);
+/**
+ * dma_alloc_coherent - allocate consistent memory for DMA
+ * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
+ * @size: required memory size
+ * @handle: bus-specific DMA address
+ *
+ * Allocate some uncached, unbuffered memory for a device for
+ * performing DMA.  This function allocates pages, and will
+ * return the CPU-viewed address, and sets @handle to be the
+ * device-viewed address.
+ */
+extern void *
+dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
+		   gfp_t flag);
 
-/*
- * Now for the API extensions over the pci_ one
+/**
+ * dma_free_coherent - free memory allocated by dma_alloc_coherent
+ * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
+ * @size: size of memory originally requested in dma_alloc_coherent
+ * @cpu_addr: CPU-view address returned from dma_alloc_coherent
+ * @handle: device-view address returned from dma_alloc_coherent
+ *
+ * Free (and unmap) a DMA buffer previously allocated by
+ * dma_alloc_coherent().
+ *
+ * References to memory and mappings associated with cpu_addr/handle
+ * during and after this call executing are illegal.
  */
+extern void
+dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
+		  dma_addr_t dma_handle);
+
 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
 #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
 
-static inline
-int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
-{
-	return 0;
-}
-
-/*
- * Map a single buffer of the indicated size for DMA in streaming mode.
- * The 32-bit bus address to use is returned.
+/**
+ * dma_map_single - map a single buffer for streaming DMA
+ * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
+ * @cpu_addr: CPU direct mapped address of buffer
+ * @size: size of buffer to map
+ * @dir: DMA transfer direction
+ *
+ * Ensure that any data held in the cache is appropriately discarded
+ * or written back.
  *
- * Once the device is given the dma address, the device owns this memory
- * until either pci_unmap_single or pci_dma_sync_single is performed.
+ * The device owns this memory once this call has completed.  The CPU
+ * can regain ownership by calling dma_unmap_single() or dma_sync_single().
  */
-extern dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
-				 enum dma_data_direction direction);
-
 static inline dma_addr_t
-dma_map_page(struct device *dev, struct page *page,
-	     unsigned long offset, size_t size,
-	     enum dma_data_direction dir)
+dma_map_single(struct device *dev, void *ptr, size_t size,
+	       enum dma_data_direction direction)
 {
-	return dma_map_single(dev, page_address(page) + offset, size, dir);
+	dma_addr_t dma_addr = virt_to_bus(ptr);
+	BUG_ON(!valid_dma_direction(direction));
+
+	invalidate_dcache_range((unsigned long)ptr,
+			(unsigned long)ptr + size);
+
+	debug_dma_map_page(dev, virt_to_page(ptr),
+			   (unsigned long)ptr & ~PAGE_MASK, size,
+			   direction, dma_addr, true);
+
+	return dma_addr;
 }
 
-/*
- * Unmap a single streaming mode DMA translation.  The dma_addr and size
- * must match what was provided for in a previous pci_map_single call.  All
- * other usages are undefined.
+/**
+ * dma_unmap_single - unmap a single buffer previously mapped
+ * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
+ * @handle: DMA address of buffer
+ * @size: size of buffer to map
+ * @dir: DMA transfer direction
  *
- * After this call, reads by the cpu to the buffer are guarenteed to see
+ * Unmap a single streaming mode DMA translation.  The handle and size
+ * must match what was provided in the previous dma_map_single() call.
+ * All other usages are undefined.
+ *
+ * After this call, reads by the CPU to the buffer are guaranteed to see
  * whatever the device wrote there.
  */
-extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
-			  enum dma_data_direction direction);
-
 static inline void
-dma_unmap_page(struct device *dev, dma_addr_t dma_addr, size_t size,
-	       enum dma_data_direction dir)
+dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
+		 enum dma_data_direction direction)
 {
-	dma_unmap_single(dev, dma_addr, size, dir);
+	debug_dma_unmap_page(dev, dma_addr, size, direction, true);
 }
 
-/*
+/**
+ * dma_map_sg - map a set of SG buffers for streaming mode DMA
+ * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
+ * @sg: list of buffers
+ * @nents: number of buffers to map
+ * @dir: DMA transfer direction
+ *
  * Map a set of buffers described by scatterlist in streaming
- * mode for DMA.  This is the scather-gather version of the
+ * mode for DMA.  This is the scatter-gather version of the
  * above pci_map_single interface.  Here the scatter gather list
  * elements are each tagged with the appropriate dma address
  * and length.  They are obtained via sg_dma_{address,length}(SG).
@@ -73,26 +111,229 @@ dma_unmap_page(struct device *dev, dma_addr_t dma_addr, size_t size,
  * Device ownership issues as mentioned above for pci_map_single are
  * the same here.
  */
-extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
-		      enum dma_data_direction direction);
+static inline int
+dma_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
+	   enum dma_data_direction direction)
+{
+	struct scatterlist *sg;
+	int i, sync;
 
-/*
+	BUG_ON(!valid_dma_direction(direction));
+	WARN_ON(nents == 0 || sglist[0].length == 0);
+
+	for_each_sg(sglist, sg, nents, i) {
+		BUG_ON(!sg_page(sg));
+
+		sg->dma_address = page_to_bus(sg_page(sg)) + sg->offset;
+		sg_dma_len(sg) = sg->length;
+
+		invalidate_dcache_range(sg_dma_address(sg),
+					sg_dma_address(sg) +
+					sg_dma_len(sg));
+	}
+
+	debug_dma_map_sg(dev, sg, nents, i, direction);
+
+	return nents;
+}
+
+/**
+ * dma_unmap_sg - unmap a set of SG buffers mapped by dma_map_sg
+ * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
+ * @sg: list of buffers
+ * @nents: number of buffers to map
+ * @dir: DMA transfer direction
+ *
  * Unmap a set of streaming mode DMA translations.
- * Again, cpu read rules concerning calls here are the same as for
+ * Again, CPU read rules concerning calls here are the same as for
  * pci_unmap_single() above.
  */
-extern void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
-		      int nhwentries, enum dma_data_direction direction);
+static inline void
+dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
+	     enum dma_data_direction direction)
+{
+	debug_dma_unmap_sg(dev, sg, nhwentries, direction);
+}
 
-static inline void dma_sync_single_for_cpu(struct device *dev,
-					dma_addr_t handle, size_t size,
-					enum dma_data_direction dir)
+/**
+ * dma_map_page - map a portion of a page for streaming DMA
+ * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
+ * @page: page that buffer resides in
+ * @offset: offset into page for start of buffer
+ * @size: size of buffer to map
+ * @dir: DMA transfer direction
+ *
+ * Ensure that any data held in the cache is appropriately discarded
+ * or written back.
+ *
+ * The device owns this memory once this call has completed.  The CPU
+ * can regain ownership by calling dma_unmap_page() or dma_sync_single().
+ */
+static inline dma_addr_t
+dma_map_page(struct device *dev, struct page *page, unsigned long offset,
+	     size_t size, enum dma_data_direction direction)
 {
+	return dma_map_single(dev, page_address(page) + offset,
+			      size, direction);
 }
 
-static inline void dma_sync_single_for_device(struct device *dev,
-					dma_addr_t handle, size_t size,
-					enum dma_data_direction dir)
+/**
+ * dma_unmap_page - unmap a buffer previously mapped through dma_map_page()
+ * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
+ * @handle: DMA address of buffer
+ * @size: size of buffer to map
+ * @dir: DMA transfer direction
+ *
+ * Unmap a single streaming mode DMA translation.  The handle and size
+ * must match what was provided in the previous dma_map_single() call.
+ * All other usages are undefined.
+ *
+ * After this call, reads by the CPU to the buffer are guaranteed to see
+ * whatever the device wrote there.
+ */
+static inline void
+dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
+	       enum dma_data_direction direction)
 {
+	dma_unmap_single(dev, dma_address, size, direction);
 }
+
+/**
+ * dma_sync_single_for_cpu
+ * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
+ * @handle: DMA address of buffer
+ * @size: size of buffer to map
+ * @dir: DMA transfer direction
+ *
+ * Make physical memory consistent for a single streaming mode DMA
+ * translation after a transfer.
+ *
+ * If you perform a dma_map_single() but wish to interrogate the
+ * buffer using the cpu, yet do not wish to teardown the DMA mapping,
+ * you must call this function before doing so.  At the next point you
+ * give the DMA address back to the card, you must first perform a
+ * dma_sync_single_for_device, and then the device again owns the
+ * buffer.
+ */
+static inline void
+dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
+			enum dma_data_direction direction)
+{
+	debug_dma_sync_single_for_cpu(dev, dma_handle, size, direction);
+}
+
+static inline void
+dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,
+			      unsigned long offset, size_t size,
+			      enum dma_data_direction direction)
+{
+	debug_dma_sync_single_range_for_cpu(dev, dma_handle,
+					    offset, size, direction);
+}
+
+/**
+ * dma_sync_sg_for_cpu
+ * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
+ * @sg: list of buffers
+ * @nents: number of buffers to map
+ * @dir: DMA transfer direction
+ *
+ * Make physical memory consistent for a set of streaming
+ * mode DMA translations after a transfer.
+ *
+ * The same as dma_sync_single_for_* but for a scatter-gather list,
+ * same rules and usage.
+ */
+static inline void
+dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nents,
+		    enum dma_data_direction direction)
+{
+	debug_dma_sync_sg_for_cpu(dev, sg, nents, direction);
+}
+
+static inline void
+dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle,
+			   size_t size, enum dma_data_direction direction)
+{
+	invalidate_dcache_range(bus_to_virt(dma_handle),
+			bus_to_virt(dma_handle) + size);
+
+	debug_dma_sync_single_for_device(dev, dma_handle, size, direction);
+}
+
+static inline void
+dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
+				 unsigned long offset, size_t size,
+				 enum dma_data_direction direction)
+{
+	invalidate_dcache_range(bus_to_virt(dma_handle),
+			bus_to_virt(dma_handle) + size);
+
+	debug_dma_sync_single_range_for_device(dev, dma_handle,
+					       offset, size, direction);
+}
+
+static inline void
+dma_sync_sg_for_device(struct device *dev, struct scatterlist *sglist,
+		       int nents, enum dma_data_direction direction)
+{
+	struct scatterlist *sg;
+	int i;
+
+	for_each_sg(sglist, sg, nents, i)
+		invalidate_dcache_range(sg_virt(sg), sg_virt(sg) + sg->length);
+
+	debug_dma_sync_sg_for_device(dev, sg, nents, direction);
+}
+
+static inline int
+dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
+{
+	return 0;
+}
+
+/*
+ * Return whether the given device DMA address mask can be supported
+ * properly.  For example, if your device can only drive the low 24-bits
+ * during bus mastering, then you would pass 0x00ffffff as the mask
+ * to this function.
+ */
+static inline int
+dma_supported(struct device *dev, u64 mask)
+{
+	return 1;
+}
+
+static inline int
+dma_set_mask(struct device *dev, u64 dma_mask)
+{
+	if (!dev->dma_mask || !dma_supported(dev, dma_mask))
+		return -EIO;
+
+	*dev->dma_mask = dma_mask;
+
+	return 0;
+}
+
+static inline int
+dma_get_cache_alignment(void)
+{
+	return L1_CACHE_BYTES;
+}
+
+static inline int
+dma_is_consistent(struct device *dev, dma_addr_t dma_addr)
+{
+	return 0;
+}
+
+static inline void
+dma_cache_sync(struct device *dev, void *cpu_addr, size_t size,
+	       enum dma_data_direction direction)
+{
+	invalidate_dcache_range(cpu_addr, cpu_addr + size);
+}
+
+void dma_alloc_init(unsigned long start, unsigned long end);
+
 #endif				/* _BLACKFIN_DMA_MAPPING_H */
diff --git a/arch/blackfin/kernel/dma-mapping.c b/arch/blackfin/kernel/dma-mapping.c
index 2f62a9f..bbd4874 100644
--- a/arch/blackfin/kernel/dma-mapping.c
+++ b/arch/blackfin/kernel/dma-mapping.c
@@ -134,54 +134,3 @@ dma_free_coherent(struct device *dev, size_t size, void *vaddr,
 	__free_dma_pages((unsigned long)vaddr, get_pages(size));
 }
 EXPORT_SYMBOL(dma_free_coherent);
-
-/*
- * Dummy functions defined for some existing drivers
- */
-
-dma_addr_t
-dma_map_single(struct device *dev, void *ptr, size_t size,
-	       enum dma_data_direction direction)
-{
-	BUG_ON(direction == DMA_NONE);
-
-	invalidate_dcache_range((unsigned long)ptr,
-			(unsigned long)ptr + size);
-
-	return (dma_addr_t) ptr;
-}
-EXPORT_SYMBOL(dma_map_single);
-
-int
-dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
-	   enum dma_data_direction direction)
-{
-	int i;
-
-	BUG_ON(direction == DMA_NONE);
-
-	for (i = 0; i < nents; i++, sg++) {
-		sg->dma_address = (dma_addr_t) sg_virt(sg);
-
-		invalidate_dcache_range(sg_dma_address(sg),
-					sg_dma_address(sg) +
-					sg_dma_len(sg));
-	}
-
-	return nents;
-}
-EXPORT_SYMBOL(dma_map_sg);
-
-void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
-		enum dma_data_direction direction)
-{
-	BUG_ON(direction == DMA_NONE);
-}
-EXPORT_SYMBOL(dma_unmap_single);
-
-void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
-		int nhwentries, enum dma_data_direction direction)
-{
-	BUG_ON(direction == DMA_NONE);
-}
-EXPORT_SYMBOL(dma_unmap_sg);

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* Re: [PATCH 00/17] Blackfin arch conversion to asm-generic
  2009-06-14 12:01 [PATCH 00/17] Blackfin arch conversion to asm-generic Mike Frysinger
                   ` (16 preceding siblings ...)
  2009-06-14 12:01 ` [PATCH 17/17] Blackfin: convert uaccess " Mike Frysinger
@ 2009-06-15 11:42 ` Arnd Bergmann
  17 siblings, 0 replies; 33+ messages in thread
From: Arnd Bergmann @ 2009-06-15 11:42 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: linux-kernel, uclinux-dist-devel

On Sunday 14 June 2009, Mike Frysinger wrote:
> 
> With the new asm-generic code in place, we can convert the Blackfin arch
> over to it.  This in turn fixes a few outdated headers and rather than
> manually update them, just drop our version in favor of the asm-generic
> one.  I've tried to group the changes somewhat logically so that if some
> conversion did go bad, it'll be easier to narrow things down with bisect
> rather than one large changeset.
...
>  65 files changed, 141 insertions(+), 2437 deletions(-)
>  delete mode 100644 arch/blackfin/lib/checksum.c

Very nice!

I've reviewed your patches based on my experience of working on the
asm-generic files and it all looks good to me, except for the dma-mapping.h,
for which I've sent you a replacement patch.

	Arnd <><

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 10/17] Blackfin: convert dma/pci to asm-generic
  2009-06-15 11:37   ` Arnd Bergmann
@ 2009-06-16 10:00     ` Mike Frysinger
  0 siblings, 0 replies; 33+ messages in thread
From: Mike Frysinger @ 2009-06-16 10:00 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-kernel, uclinux-dist-devel

On Mon, Jun 15, 2009 at 07:37, Arnd Bergmann wrote:
> On Sunday 14 June 2009, Mike Frysinger wrote:
>> --- a/arch/blackfin/include/asm/dma-mapping.h
>> +++ b/arch/blackfin/include/asm/dma-mapping.h
>> @@ -2,97 +2,28 @@
>>  #define _BLACKFIN_DMA_MAPPING_H
>>
>>  #include <asm/scatterlist.h>
>> +#include <asm-generic/dma-mapping-broken.h>
>
> I would leave this one alone, I don't think that moving
> to dma-mapping-broken.h helps here.

just trying to punt as much as possible from arch/blackfin/ as it
means less stuff for me to worry about :).  i'll drop the
dma-mapping.h change from this patch.

> I have a dma-mapping
> branch in my asm-generic repository. While I could not
> get an agreement on an approach for a common dma-mapping.h
> file for asm-generic, I did a number of cleanups on a few
> architectures. Feel free to take this patch as a base for
> your work.

once i get most of my local queue settled, i'll look at integrating
this.  thanks!
-mike

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 05/17] Blackfin: convert to generic checksum code
  2009-06-15 11:04   ` Arnd Bergmann
@ 2009-06-16 10:03     ` Mike Frysinger
  2009-06-19  1:19     ` Mike Frysinger
  1 sibling, 0 replies; 33+ messages in thread
From: Mike Frysinger @ 2009-06-16 10:03 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-kernel, uclinux-dist-devel

On Mon, Jun 15, 2009 at 07:04, Arnd Bergmann wrote:
> On Sunday 14 June 2009, Mike Frysinger wrote:
>> The Blackfin port only implemented an optimized version of the
>> csum_tcpudp_nofold function, so convert everything else to the new
>> generic code.
>
> Have you tested this one well? I was as careful as possible with the
> version I added, but it was basically only tested on microblaze, which
> has a different endianess from blackfin. Some areas of the code may be
> sensitive to this.

networking still worked on my BF537-STAMP, but that isnt a very big
test.  i'll keep it locally until we can regression test it harder.

although these kind of issues sounds like a good reason to add some
internal testing code for people to optionally enable ... make sure
things work across endians/bit sizes/assorted changes & improvements
...
-mike

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 05/17] Blackfin: convert to generic checksum code
  2009-06-15 11:04   ` Arnd Bergmann
  2009-06-16 10:03     ` Mike Frysinger
@ 2009-06-19  1:19     ` Mike Frysinger
  2009-06-19  9:05       ` Arnd Bergmann
  1 sibling, 1 reply; 33+ messages in thread
From: Mike Frysinger @ 2009-06-19  1:19 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-kernel, uclinux-dist-devel

[-- Attachment #1: Type: text/plain, Size: 905 bytes --]

On Mon, Jun 15, 2009 at 07:04, Arnd Bergmann wrote:
> On Sunday 14 June 2009, Mike Frysinger wrote:
>> The Blackfin port only implemented an optimized version of the
>> csum_tcpudp_nofold function, so convert everything else to the new
>> generic code.
>>
>> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
>
> Have you tested this one well? I was as careful as possible with the
> version I added, but it was basically only tested on microblaze, which
> has a different endianess from blackfin. Some areas of the code may be
> sensitive to this.

i did some tests and it looks like do_csum() is broken :(

here's the input:
do_csum({ 0xff 0xfb 0x01 }, 3)

and here's the output:
Blackfin: 0xfc00
generic: 0xfcff

if i run the two funcs on my x86, i see similar behavior.  the
attached csum-test.c contains the csum code from lib/checksum.c and
arch/blackfin/lib/checksum.c and shows the problem.
-mike

[-- Attachment #2: csum-test.c --]
[-- Type: text/x-csrc, Size: 1891 bytes --]

#include <stdio.h>

static inline unsigned short gen_from32to16(unsigned long x)
{
	/* add up 16-bit and 16-bit for 16+c bit */
	x = (x & 0xffff) + (x >> 16);
	/* add up carry.. */
	x = (x & 0xffff) + (x >> 16);
	return x;
}

static unsigned int gen_do_csum(const unsigned char *buff, int len)
{
	int odd, count;
	unsigned long result = 0;

	if (len <= 0)
		goto out;
	odd = 1 & (unsigned long) buff;
	if (odd) {
		result = *buff;
		len--;
		buff++;
	}
	count = len >> 1;		/* nr of 16-bit words.. */
	if (count) {
		if (2 & (unsigned long) buff) {
			result += *(unsigned short *) buff;
			count--;
			len -= 2;
			buff += 2;
		}
		count >>= 1;		/* nr of 32-bit words.. */
		if (count) {
			unsigned long carry = 0;
			do {
				unsigned long w = *(unsigned long *) buff;
				count--;
				buff += 4;
				result += carry;
				result += w;
				carry = (w > result);
			} while (count);
			result += carry;
			result = (result & 0xffff) + (result >> 16);
		}
		if (len & 2) {
			result += *(unsigned short *) buff;
			buff += 2;
		}
	}
	if (len & 1)
		result += (*buff << 8);
	result = gen_from32to16(result);
	if (odd)
		result = ((result >> 8) & 0xff) | ((result & 0xff) << 8);
out:
	return result;
}

static unsigned short bf_do_csum(const unsigned char *buff, int len)
{
	register unsigned long sum = 0;
	int swappem = 0;

	if (1 & (unsigned long)buff) {
		sum = *buff << 8;
		buff++;
		len--;
		++swappem;
	}

	while (len > 1) {
		sum += *(unsigned short *)buff;
		buff += 2;
		len -= 2;
	}

	if (len > 0)
		sum += *buff;

	/*  Fold 32-bit sum to 16 bits */
	while (sum >> 16)
		sum = (sum & 0xffff) + (sum >> 16);

	if (swappem)
		sum = ((sum & 0xff00) >> 8) + ((sum & 0x00ff) << 8);

	return sum;

}

int main()
{
	unsigned char buf[] = { 0xff, 0xfb, 0x01 };
	unsigned short gen = gen_do_csum(buf, 3);
	unsigned short bf = bf_do_csum(buf, 3);
	printf("%x vs %x\n", gen, bf);
	return 0;
}

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 05/17] Blackfin: convert to generic checksum code
  2009-06-19  1:19     ` Mike Frysinger
@ 2009-06-19  9:05       ` Arnd Bergmann
  2009-06-19 10:42         ` Mike Frysinger
  0 siblings, 1 reply; 33+ messages in thread
From: Arnd Bergmann @ 2009-06-19  9:05 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: linux-kernel, uclinux-dist-devel, Michal Simek, Paul Mundt

On Friday 19 June 2009, Mike Frysinger wrote:
> On Mon, Jun 15, 2009 at 07:04, Arnd Bergmann wrote:
> > On Sunday 14 June 2009, Mike Frysinger wrote:
> >> The Blackfin port only implemented an optimized version of the
> >> csum_tcpudp_nofold function, so convert everything else to the new
> >> generic code.
> >>
> >> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
> >
> > Have you tested this one well? I was as careful as possible with the
> > version I added, but it was basically only tested on microblaze, which
> > has a different endianess from blackfin. Some areas of the code may be
> > sensitive to this.
> 
> i did some tests and it looks like do_csum() is broken :(

Thanks for testing. Indeed it turns out to be an endian-problem with
the handling of the last byte:

> here's the input:
> do_csum({ 0xff 0xfb 0x01 }, 3)
> 
> and here's the output:
> Blackfin: 0xfc00
> generic: 0xfcff
>
> if i run the two funcs on my x86, i see similar behavior.  the
> attached csum-test.c contains the csum code from lib/checksum.c and
> arch/blackfin/lib/checksum.c and shows the problem.

x86 and blackfin are both little-endian, so your variant is correct
there. They add the 0x01 to the low byte of the 16-bit word, while
on big-endian machines, you have to add it to the high byte.

> -mike
> csum-test.c
>   #include <stdio.h>
> 
> static inline unsigned short gen_from32to16(unsigned long x)
> {
>         /* add up 16-bit and 16-bit for 16+c bit */
>         x = (x & 0xffff) + (x >> 16);
>         /* add up carry.. */
>         x = (x & 0xffff) + (x >> 16);
>         return x;
> }
> 
> static unsigned int gen_do_csum(const unsigned char *buff, int len)
> {
> ...
>         if (len & 1)
>                 result += (*buff << 8);

On little-endian, this needs to be

	if (len & 1)
		result += *buff;

> static unsigned short bf_do_csum(const unsigned char *buff, int len)
> {
> ...
>         if (len > 0)
>                 sum += *buff;

Same problem, on big-endian this would need to be
	if (len > 0)
		sum += (*buff << 8);

The bug potentially also exists in arch/sh/lib64/c-checksum.c, which only
works on little-endian machines, while the sh architecture code appears
dual-endian. Paul, is your lib64/c-checksum.c implementation potentially
run on big-endian machines, or is sh64 guaranteed to be little-endian?

I've committed the patch below now.

	Arnd <><

---
>From e01fed86629737809c46dcb8b807347e84640b70 Mon Sep 17 00:00:00 2001
From: Arnd Bergmann <arnd@arndb.de>
Date: Fri, 19 Jun 2009 10:41:19 +0200
Subject: [PATCH] lib/checksum.c: fix endianess bug

The new generic checksum code has a small dependency on endianess and
worked only on big-endian systems. I could not find a nice efficient
way to express this, so I added an #ifdef. Using
'result += le16_to_cpu(*buff);' would have worked as well, but
would be slightly less efficient on big-endian systems and IMHO
would not be clearer.

Also fix a bug that prevents this from working on 64-bit machines.
If you have a 64-bit CPU and want to use the generic checksum
code, you should probably do some more optimizations anyway, but
at least the code should not break.

Reported-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 lib/checksum.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/lib/checksum.c b/lib/checksum.c
index 12e5a1c..4a1c84a 100644
--- a/lib/checksum.c
+++ b/lib/checksum.c
@@ -71,7 +71,7 @@ static unsigned int do_csum(const unsigned char *buff, int len)
 		if (count) {
 			unsigned long carry = 0;
 			do {
-				unsigned long w = *(unsigned long *) buff;
+				unsigned long w = *(unsigned int *) buff;
 				count--;
 				buff += 4;
 				result += carry;
@@ -87,7 +87,11 @@ static unsigned int do_csum(const unsigned char *buff, int len)
 		}
 	}
 	if (len & 1)
+#ifdef __LITTLE_ENDIAN
+		result += *buff;
+#else
 		result += (*buff << 8);
+#endif
 	result = from32to16(result);
 	if (odd)
 		result = ((result >> 8) & 0xff) | ((result & 0xff) << 8);
-- 
1.6.3.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* Re: [PATCH 05/17] Blackfin: convert to generic checksum code
  2009-06-19  9:05       ` Arnd Bergmann
@ 2009-06-19 10:42         ` Mike Frysinger
  2009-06-19 12:33           ` Arnd Bergmann
  0 siblings, 1 reply; 33+ messages in thread
From: Mike Frysinger @ 2009-06-19 10:42 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-kernel, uclinux-dist-devel, Michal Simek, Paul Mundt

On Fri, Jun 19, 2009 at 05:05, Arnd Bergmann wrote:
> x86 and blackfin are both little-endian, so your variant is correct
> there. They add the 0x01 to the low byte of the 16-bit word, while
> on big-endian machines, you have to add it to the high byte.

can we think of enough simple examples to through together an optional
boot-time self test ?

> I've committed the patch below now.

closer, but not quite just yet ...
do_csum: mismatch 0x1700 != 0xa0d len:2
do_csum: {  0xd, 0xa }
do_csum: mismatch 0x6f76 != 0x4f96 len:255
do_csum: {  0x20, 0x34, 0x34, 0x34, 0x20, 0x53, 0x20, 0x20, 0x20,
0x20, 0x2d, 0x2f, 0x62, 0x69, 0x6e, 0x2f, 0x73, 0x68, 0x20, 0xd, 0xa,
0x20, 0x20, 0x31, 0x30, 0x35, 0x20, 0x72, 0x6f, 0x6f, 0x74, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x34, 0x34, 0x20, 0x53,
0x20, 0x20, 0x20, 0x20, 0x2f, 0x73, 0x62, 0x69, 0x6e, 0x2f, 0x69,
0x6e, 0x65, 0x74, 0x64, 0x20, 0xd, 0xa, 0x20, 0x20, 0x31, 0x30, 0x36,
0x20, 0x72, 0x6f, 0x6f, 0x74, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x34, 0x33, 0x36, 0x20, 0x53, 0x20, 0x20, 0x20, 0x20, 0x2f,
0x73, 0x62, 0x69, 0x6e, 0x2f, 0x73, 0x79, 0x73, 0x6c, 0x6f, 0x67,
0x64, 0x20, 0x2d, 0x6e, 0x20, 0xd, 0xa, 0x20, 0x20, 0x31, 0x30, 0x37,
0x20, 0x72, 0x6f, 0x6f, 0x74, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x34, 0x33, 0x32, 0x20, 0x52, 0x20, 0x20, 0x20, 0x20, 0x2f,
0x73, 0x62, 0x69, 0x6e, 0x2f, 0x6b, 0x6c, 0x6f, 0x67, 0x64, 0x20,
0x2d, 0x6e, 0x20, 0xd, 0xa, 0x20, 0x20, 0x31, 0x30, 0x38, 0x20, 0x72,
0x6f, 0x6f, 0x74, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x33, 0x32, 0x20, 0x53, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x62, 0x69,
0x6e, 0x2f, 0x77, 0x61, 0x7
4, 0x63, 0x68, 0x64, 0x6f, 0x67, 0x64, 0x20, 0x2d, 0x66, 0x20, 0x2d,
0x73, 0x20, 0xd, 0xa, 0x20, 0x20, 0x31, 0x30, 0x39, 0x20, 0x72, 0x6f,
0x6f, 0x74, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x35,
0x36, 0x20, 0x52, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x62, 0x69, 0x6e,
0x2f, 0x74, 0x65, 0x6c, 0x6e, 0x65, 0x74, 0x64, 0x20, 0xd, 0xa, 0x20,
0x20, 0x31, 0x31, 0x30, 0x20, 0x72, 0x6f, 0x6f, 0x74, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20 }

when do_csum does return correct values, csum_partial sometimes does not:
csum_partial: mismatch 0x1101eefe != 0xffff len:32
csum_partial: {  0x92, 0x3b, 0x0, 0x17, 0xcf, 0xc1, 0x90, 0xec, 0x1c,
0x3f, 0xff, 0x99, 0x80, 0x10, 0x0, 0x5c, 0x22, 0xfa, 0x0, 0x0, 0x1,
0x1, 0x8, 0xa, 0x6, 0x83, 0xdd, 0x50, 0xff, 0xfe, 0xdf, 0x58 }

btw, would it make sense to change do_csum like so:
-static unsigned int do_csum(const unsigned char *buff, int len)
+__weak unsigned int do_csum(const unsigned char *buff, int len)

after all, it looks like that's really the function most arches would
want to hand optimize.  all the rest are simple standard wrappers are
do_csum().  forcing an arch to copy & paste all the other functions
just so they can implement an optimized do_csum() seems pretty
unfriendly.  plus, it isnt like being static here makes any optimized
difference -- it isnt going to get inlined anywhere in this file.

or rather than weaks (in case some toolchains force indirect pointer
loading all the time), use the same interface as the rest of the
generic checksum code:
#ifndef do_csum
static inline unsigned short from32to16(unsigned long x)
{
    ...
}
static unsigned int do_csum(const unsigned char *buff, int len)
{
    ...
}
#endif
-mike

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 05/17] Blackfin: convert to generic checksum code
  2009-06-19 10:42         ` Mike Frysinger
@ 2009-06-19 12:33           ` Arnd Bergmann
  2009-06-19 13:12             ` Mike Frysinger
  0 siblings, 1 reply; 33+ messages in thread
From: Arnd Bergmann @ 2009-06-19 12:33 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: linux-kernel, uclinux-dist-devel, Michal Simek, Paul Mundt

On Friday 19 June 2009, Mike Frysinger wrote:
> On Fri, Jun 19, 2009 at 05:05, Arnd Bergmann wrote:
> > x86 and blackfin are both little-endian, so your variant is correct
> > there. They add the 0x01 to the low byte of the 16-bit word, while
> > on big-endian machines, you have to add it to the high byte.
> 
> can we think of enough simple examples to through together an optional
> boot-time self test ?

sounds like a good idea.

> > I've committed the patch below now.
> 
> closer, but not quite just yet ...
> do_csum: mismatch 0x1700 != 0xa0d len:2
> do_csum: {  0xd, 0xa }

I've compared the code again with Paul's sh version and found another
difference in the handling of unaligned data.

> when do_csum does return correct values, csum_partial sometimes does not:
> csum_partial: mismatch 0x1101eefe != 0xffff len:32
> csum_partial: {  0x92, 0x3b, 0x0, 0x17, 0xcf, 0xc1, 0x90, 0xec, 0x1c,
> 0x3f, 0xff, 0x99, 0x80, 0x10, 0x0, 0x5c, 0x22, 0xfa, 0x0, 0x0, 0x1,
> 0x1, 0x8, 0xa, 0x6, 0x83, 0xdd, 0x50, 0xff, 0xfe, 0xdf, 0x58 }

That looks like it's both valid output. csum_partial returns a 32 bit
value that always needs to get passed to csum_fold in order to get
checked. 0x1101eefe and 0xffff both evaluate to 0xffff in csum_fold,
so this would just be an implementation detail, not a bug.

> btw, would it make sense to change do_csum like so:
> -static unsigned int do_csum(const unsigned char *buff, int len)
> +__weak unsigned int do_csum(const unsigned char *buff, int len)
> 
> after all, it looks like that's really the function most arches would
> want to hand optimize.  all the rest are simple standard wrappers are
> do_csum().  forcing an arch to copy & paste all the other functions
> just so they can implement an optimized do_csum() seems pretty
> unfriendly.  plus, it isnt like being static here makes any optimized
> difference -- it isnt going to get inlined anywhere in this file.

Agreed, this should be overridable by the architecture, I'll submit a patch
once we found out what caused the bugs.

> or rather than weaks (in case some toolchains force indirect pointer
> loading all the time), use the same interface as the rest of the
> generic checksum code:
> #ifndef do_csum
> static inline unsigned short from32to16(unsigned long x)
> {
>     ...
> }
> static unsigned int do_csum(const unsigned char *buff, int len)
> {
>     ...
> }
> #endif

I'd prefer the second version, I've done it that way all over
include/asm-generic, and weak functions tend to cause more trouble.

---
lib/checksum.c: Fix another endianess bug

will fold this patch into the previous one.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
--- a/lib/checksum.c
+++ b/lib/checksum.c
@@ -55,7 +55,11 @@ static unsigned int do_csum(const unsigned char *buff, int len)
 		goto out;
 	odd = 1 & (unsigned long) buff;
 	if (odd) {
+#ifdef __LITTLE_ENDIAN
 		result = *buff;
+#else
+		result += (*buff << 8);
+#endif
 		len--;
 		buff++;
 	}

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 05/17] Blackfin: convert to generic checksum code
  2009-06-19 12:33           ` Arnd Bergmann
@ 2009-06-19 13:12             ` Mike Frysinger
  2009-06-23 21:14               ` Arnd Bergmann
  0 siblings, 1 reply; 33+ messages in thread
From: Mike Frysinger @ 2009-06-19 13:12 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-kernel, uclinux-dist-devel, Michal Simek, Paul Mundt

[-- Attachment #1: Type: text/plain, Size: 650 bytes --]

On Fri, Jun 19, 2009 at 08:33, Arnd Bergmann wrote:
> On Friday 19 June 2009, Mike Frysinger wrote:
>> On Fri, Jun 19, 2009 at 05:05, Arnd Bergmann wrote:
>> > x86 and blackfin are both little-endian, so your variant is correct
>> > there. They add the 0x01 to the low byte of the 16-bit word, while
>> > on big-endian machines, you have to add it to the high byte.
>>
>> can we think of enough simple examples to through together an optional
>> boot-time self test ?
>
> sounds like a good idea.

how about the attached

> lib/checksum.c: Fix another endianess bug

hrm, still not quite :/

the attached test code shows failures in every case
-mike

[-- Attachment #2: checksum-selftest.c --]
[-- Type: text/x-csrc, Size: 3194 bytes --]

/*
 * Networking checksum self checks.
 *
 * Licensed under the GPL-2.
 */

#define pr_fmt(fmt) "csum-selftest: " fmt

#include <linux/kernel.h>
#include <net/checksum.h>

extern unsigned short do_csum(const unsigned char *buff, int len);

struct do_csum_data {
	unsigned short ret;
	unsigned char *buf;
	int len;
};
#define DO_CSUM_DATA(_num, _ret) \
{	\
	.ret = _ret, \
	.buf = do_csum_data##_num, \
	.len = ARRAY_SIZE(do_csum_data##_num), \
}
static unsigned char __initdata do_csum_data1[] = {
	0x20,
};
static unsigned char __initdata do_csum_data2[] = {
	0x0d, 0x0a,
};
static unsigned char __initdata do_csum_data3[] = {
	0xff, 0xfb, 0x01,
};
static unsigned char __initdata do_csum_data5[] = {
	0x67, 0x72, 0x5d, 0x0d, 0x00,
};
static unsigned char __initdata do_csum_data7[] = {
	0x20, 0x20, 0x20, 0x35, 0x37, 0x20, 0x20,
};
static unsigned char __initdata do_csum_data255[] = {
	0x20, 0x34, 0x34, 0x34, 0x20, 0x53, 0x20, 0x20, 0x20, 0x20, 0x2d,
	0x2f, 0x62, 0x69, 0x6e, 0x2f, 0x73, 0x68, 0x20, 0x0d, 0x0a, 0x20,
	0x20, 0x31, 0x30, 0x35, 0x20, 0x72, 0x6f, 0x6f, 0x74, 0x20, 0x20,
	0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x34, 0x34, 0x20, 0x53, 0x20,
	0x20, 0x20, 0x20, 0x2f, 0x73, 0x62, 0x69, 0x6e, 0x2f, 0x69, 0x6e,
	0x65, 0x74, 0x64, 0x20, 0x0d, 0x0a, 0x20, 0x20, 0x31, 0x30, 0x36,
	0x20, 0x72, 0x6f, 0x6f, 0x74, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
	0x20, 0x34, 0x33, 0x36, 0x20, 0x53, 0x20, 0x20, 0x20, 0x20, 0x2f,
	0x73, 0x62, 0x69, 0x6e, 0x2f, 0x73, 0x79, 0x73, 0x6c, 0x6f, 0x67,
	0x64, 0x20, 0x2d, 0x6e, 0x20, 0x0d, 0x0a, 0x20, 0x20, 0x31, 0x30,
	0x37, 0x20, 0x72, 0x6f, 0x6f, 0x74, 0x20, 0x20, 0x20, 0x20, 0x20,
	0x20, 0x20, 0x34, 0x33, 0x32, 0x20, 0x52, 0x20, 0x20, 0x20, 0x20,
	0x2f, 0x73, 0x62, 0x69, 0x6e, 0x2f, 0x6b, 0x6c, 0x6f, 0x67, 0x64,
	0x20, 0x2d, 0x6e, 0x20, 0x0d, 0x0a, 0x20, 0x20, 0x31, 0x30, 0x38,
	0x20, 0x72, 0x6f, 0x6f, 0x74, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
	0x20, 0x20, 0x33, 0x32, 0x20, 0x53, 0x20, 0x20, 0x20, 0x20, 0x2f,
	0x62, 0x69, 0x6e, 0x2f, 0x77, 0x61, 0x74, 0x63, 0x68, 0x64, 0x6f,
	0x67, 0x64, 0x20, 0x2d, 0x66, 0x20, 0x2d, 0x73, 0x20, 0x0d, 0x0a,
	0x20, 0x20, 0x31, 0x30, 0x39, 0x20, 0x72, 0x6f, 0x6f, 0x74, 0x20,
	0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x35, 0x36, 0x20, 0x52,
	0x20, 0x20, 0x20, 0x20, 0x2f, 0x62, 0x69, 0x6e, 0x2f, 0x74, 0x65,
	0x6c, 0x6e, 0x65, 0x74, 0x64, 0x20, 0x0d, 0x0a, 0x20, 0x20, 0x31,
	0x31, 0x30, 0x20, 0x72, 0x6f, 0x6f, 0x74, 0x20, 0x20, 0x20, 0x20,
	0x20, 0x20
};
static struct do_csum_data __initdata do_csum_data[] = {
	DO_CSUM_DATA(1, 0x0020),
	DO_CSUM_DATA(2, 0xfc00),
	DO_CSUM_DATA(3, 0x0a0d),
	DO_CSUM_DATA(5, 0x7fc4),
	DO_CSUM_DATA(7, 0x7597),
	DO_CSUM_DATA(255, 0x4f96),
};

static int __init do_csum_selftest(void)
{
	int i, ret;
	unsigned short tret;

	ret = 0;
	for (i = 0; i < ARRAY_SIZE(do_csum_data); ++i) {
		tret = do_csum(do_csum_data[i].buf, do_csum_data[i].len);
		if (tret != do_csum_data[i].ret) {
			pr_err("%s: test %i: %#x != %#x: FAIL\n",
				__func__, i, tret, do_csum_data[i].ret);
			ret = 1;
		}
	}

	return ret;
}

static int __init csum_selftest_init(void)
{
	int ret = do_csum_selftest();

	if (!ret)
		pr_info("all tests passed!\n");

	return 0;
}
module_init(csum_selftest_init);

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 05/17] Blackfin: convert to generic checksum code
  2009-06-19 13:12             ` Mike Frysinger
@ 2009-06-23 21:14               ` Arnd Bergmann
  2009-06-23 21:53                 ` Mike Frysinger
  2009-09-19 19:08                 ` Mike Frysinger
  0 siblings, 2 replies; 33+ messages in thread
From: Arnd Bergmann @ 2009-06-23 21:14 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: linux-kernel, uclinux-dist-devel, Michal Simek, Paul Mundt

I missed your mail last week and only now stumbled over it after Linus
has pulled my tree.

On Friday 19 June 2009, Mike Frysinger wrote:
> >
> > sounds like a good idea.
> 
> how about the attached

Mostly good, but needs some improvements. At least it helped me
track down the last problem.

> > lib/checksum.c: Fix another endianess bug
> 
> hrm, still not quite :/
> 
> the attached test code shows failures in every case

When I tried running it on x86-64, it only showed failures for
numbers 1, 2 and 4. I fixed them with this patch:
---
lib/checksum: fix one more thinko

When do_csum gets unaligned data, we really need to treat
the first byte as an even byte, not an odd byte, because
we swap the two halves later.

Found by Mike's checksum-selftest module.

Reported-by: Mike Frysinger <vapier.adi@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

diff --git a/lib/checksum.c b/lib/checksum.c
index b08c2d0..0975087 100644
--- a/lib/checksum.c
+++ b/lib/checksum.c
@@ -57,9 +57,9 @@ static unsigned int do_csum(const unsigned char *buff, int len)
 	odd = 1 & (unsigned long) buff;
 	if (odd) {
 #ifdef __LITTLE_ENDIAN
-		result = *buff;
-#else
 		result += (*buff << 8);
+#else
+		result = *buff;
 #endif
 		len--;
 		buff++;
---

>extern unsigned short do_csum(const unsigned char *buff, int len);
>

do_csum is really an internal function. IMHO we should better check
csum_partial(), ip_fast_csum(), csum_fold(), csum_tcpudp_magic()
and ip_compute_csum(), or at least a subset of them.

>static unsigned char __initdata do_csum_data2[] = {
>        0x0d, 0x0a,
>};
>static unsigned char __initdata do_csum_data3[] = {
>        0xff, 0xfb, 0x01,
>};
> ...
>static struct do_csum_data __initdata do_csum_data[] = {
>        DO_CSUM_DATA(1, 0x0020),
>        DO_CSUM_DATA(2, 0xfc00),
>        DO_CSUM_DATA(3, 0x0a0d),
>        DO_CSUM_DATA(5, 0x7fc4),
>        DO_CSUM_DATA(7, 0x7597),
>        DO_CSUM_DATA(255, 0x4f96),
>};

You mixed up do_csum_data2 and do_csum_data3, so they will always
show up as incorrect. Also, the expected checksum is endian-dependent.
The test module should either be modified to expect 0xffff to be
returned in every case, or should use le16_to_cpu(0x0020) etc.

	Arnd <><

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* Re: [PATCH 05/17] Blackfin: convert to generic checksum code
  2009-06-23 21:14               ` Arnd Bergmann
@ 2009-06-23 21:53                 ` Mike Frysinger
  2009-06-23 22:06                   ` Arnd Bergmann
  2009-09-19 19:08                 ` Mike Frysinger
  1 sibling, 1 reply; 33+ messages in thread
From: Mike Frysinger @ 2009-06-23 21:53 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-kernel, uclinux-dist-devel, Michal Simek, Paul Mundt

On Tue, Jun 23, 2009 at 17:14, Arnd Bergmann wrote:
> --- a/lib/checksum.c
> +++ b/lib/checksum.c
> @@ -57,9 +57,9 @@ static unsigned int do_csum(const unsigned char *buff, int len)
>        odd = 1 & (unsigned long) buff;
>        if (odd) {
>  #ifdef __LITTLE_ENDIAN
> -               result = *buff;
> -#else
>                result += (*buff << 8);
> +#else
> +               result = *buff;
>  #endif
>                len--;
>                buff++;
> ---

thanks, my tests seem to work now ... i was doing telnet/rsh stuff as
well as icmp/udp/tcp flooding.  i'll convert Blackfin to generic
checksum post 2.6.31 so we can test it some more in the meantime.

>>extern unsigned short do_csum(const unsigned char *buff, int len);
>
> do_csum is really an internal function. IMHO we should better check
> csum_partial(), ip_fast_csum(), csum_fold(), csum_tcpudp_magic()
> and ip_compute_csum(), or at least a subset of them.

and this is an internal tester ... if we're going to let arches
override it, then its function signature are pretty much set in stone.
 i agree we should test every checksum function, but i think only
testing do_csum indirectly would be detrimental to the people who
would want to use this -- arch maintainers looking to implement
do_csum() themselves.  otherwise they need to step through the
surrounding functions a bit to find the exact values given to
do_csum() and the exact value expected back such that the calling
function still works.  and every arch guy is going to do this same
thing.

>>static unsigned char __initdata do_csum_data2[] = {
>>        0x0d, 0x0a,
>>};
>>static unsigned char __initdata do_csum_data3[] = {
>>        0xff, 0xfb, 0x01,
>>};
>> ...
>>static struct do_csum_data __initdata do_csum_data[] = {
>>        DO_CSUM_DATA(1, 0x0020),
>>        DO_CSUM_DATA(2, 0xfc00),
>>        DO_CSUM_DATA(3, 0x0a0d),
>>        DO_CSUM_DATA(5, 0x7fc4),
>>        DO_CSUM_DATA(7, 0x7597),
>>        DO_CSUM_DATA(255, 0x4f96),
>>};
>
> You mixed up do_csum_data2 and do_csum_data3, so they will always
> show up as incorrect.

i was going through different ways of formatting the data and looks
like i messed that up, thanks

> Also, the expected checksum is endian-dependent.
> The test module should either be modified to expect 0xffff to be
> returned in every case, or should use le16_to_cpu(0x0020) etc

i'm a bit of a nub here wrt checksuming.  the test module i came up
with by simply flooding my board and copying & pasting mismatched
buffers ;).  are you saying the following should be OK ?
-    if (tret != do_csum_data[i].ret) {
+    if (tret != le16_to_cpu(do_csum_data[i].ret)) {

unless there is a macro i could use that'd do the expansion at CPP
time so i'd write the test data as:
static struct do_csum_data __initdata do_csum_data[] = {
        DO_CSUM_DATA(1, le16_to_cpu(0x0020)),
...
-mike

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 05/17] Blackfin: convert to generic checksum code
  2009-06-23 21:53                 ` Mike Frysinger
@ 2009-06-23 22:06                   ` Arnd Bergmann
  2009-06-23 22:11                     ` Mike Frysinger
  0 siblings, 1 reply; 33+ messages in thread
From: Arnd Bergmann @ 2009-06-23 22:06 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: linux-kernel, uclinux-dist-devel, Michal Simek, Paul Mundt

On Tuesday 23 June 2009, Mike Frysinger wrote:
> and this is an internal tester ... if we're going to let arches
> override it, then its function signature are pretty much set in stone.
> i agree we should test every checksum function, but i think only
> testing do_csum indirectly would be detrimental to the people who
> would want to use this -- arch maintainers looking to implement
> do_csum() themselves.  otherwise they need to step through the
> surrounding functions a bit to find the exact values given to
> do_csum() and the exact value expected back such that the calling
> function still works.  and every arch guy is going to do this same
> thing.

It depends on how we want to use it. If it's only for testing architecture
that have moved to the generic checksum code, that's fine. I was
thinking we could also use it for architectures that want to keep
their own code, but we don't have to.

> i'm a bit of a nub here wrt checksuming.  the test module i came up
> with by simply flooding my board and copying & pasting mismatched
> buffers ;).  are you saying the following should be OK ?
> -    if (tret != do_csum_data[i].ret) {
> +    if (tret != le16_to_cpu(do_csum_data[i].ret)) {

yes, that should work.

> unless there is a macro i could use that'd do the expansion at CPP
> time so i'd write the test data as:
> static struct do_csum_data __initdata do_csum_data[] = {
>         DO_CSUM_DATA(1, le16_to_cpu(0x0020)),
> ...

Ah, right that won't. I tested only on x86 (little-endian), so
le16_to_cpu() is an identity function that can be evaluated for
constants, but on big-endian that would break.

	Arnd <><

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 05/17] Blackfin: convert to generic checksum code
  2009-06-23 22:06                   ` Arnd Bergmann
@ 2009-06-23 22:11                     ` Mike Frysinger
  0 siblings, 0 replies; 33+ messages in thread
From: Mike Frysinger @ 2009-06-23 22:11 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-kernel, uclinux-dist-devel, Michal Simek, Paul Mundt

On Tue, Jun 23, 2009 at 18:06, Arnd Bergmann wrote:
> On Tuesday 23 June 2009, Mike Frysinger wrote:
>> and this is an internal tester ... if we're going to let arches
>> override it, then its function signature are pretty much set in stone.
>> i agree we should test every checksum function, but i think only
>> testing do_csum indirectly would be detrimental to the people who
>> would want to use this -- arch maintainers looking to implement
>> do_csum() themselves.  otherwise they need to step through the
>> surrounding functions a bit to find the exact values given to
>> do_csum() and the exact value expected back such that the calling
>> function still works.  and every arch guy is going to do this same
>> thing.
>
> It depends on how we want to use it. If it's only for testing architecture
> that have moved to the generic checksum code, that's fine. I was
> thinking we could also use it for architectures that want to keep
> their own code, but we don't have to.

ah, i see what you're going for.  how about we make testing of
do_csum() dependent upon GENERIC_CSUM.  that way we can satisfy
everyone.

any other suggestions for coming up with test vectors ?  or i just
extract a few more examples from flooding my board and call it a day.
if someone complains a bug existed and current test vectors didnt
cover it, then they should submit a new one.
-mike

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 05/17] Blackfin: convert to generic checksum code
  2009-06-23 21:14               ` Arnd Bergmann
  2009-06-23 21:53                 ` Mike Frysinger
@ 2009-09-19 19:08                 ` Mike Frysinger
  1 sibling, 0 replies; 33+ messages in thread
From: Mike Frysinger @ 2009-09-19 19:08 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-kernel, uclinux-dist-devel, Michal Simek, Paul Mundt

On Tue, Jun 23, 2009 at 17:14, Arnd Bergmann wrote:
> On Friday 19 June 2009, Mike Frysinger wrote:
>> >
>> > sounds like a good idea.
>>
>> how about the attached
>
> Mostly good, but needs some improvements. At least it helped me
> track down the last problem.
>
>> > lib/checksum.c: Fix another endianess bug
>>
>> hrm, still not quite :/
>>
>> the attached test code shows failures in every case
>
> When I tried running it on x86-64, it only showed failures for
> numbers 1, 2 and 4. I fixed them with this patch:
> ---
> lib/checksum: fix one more thinko
>
> When do_csum gets unaligned data, we really need to treat
> the first byte as an even byte, not an odd byte, because
> we swap the two halves later.
>
> Found by Mike's checksum-selftest module.
>
> Reported-by: Mike Frysinger <vapier.adi@gmail.com>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

shouldnt this fix have been in 2.6.31 ?  doesnt seem to be even in
latest git ...
-mike

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2009-09-19 19:08 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-14 12:01 [PATCH 00/17] Blackfin arch conversion to asm-generic Mike Frysinger
2009-06-14 12:01 ` [PATCH 01/17] Blackfin: use common test_bit() rather than __test_bit() Mike Frysinger
2009-06-14 12:01 ` [PATCH 02/17] Blackfin: pull in asm/io.h in ksyms for prototypes Mike Frysinger
2009-06-14 12:01 ` [PATCH 03/17] Blackfin: only build irqpanic.c when needed Mike Frysinger
2009-06-14 12:01 ` [PATCH 04/17] Blackfin: convert asm/ioctls.h to asm-generic/ioctls.h Mike Frysinger
2009-06-14 12:01 ` [PATCH 05/17] Blackfin: convert to generic checksum code Mike Frysinger
2009-06-15 11:04   ` Arnd Bergmann
2009-06-16 10:03     ` Mike Frysinger
2009-06-19  1:19     ` Mike Frysinger
2009-06-19  9:05       ` Arnd Bergmann
2009-06-19 10:42         ` Mike Frysinger
2009-06-19 12:33           ` Arnd Bergmann
2009-06-19 13:12             ` Mike Frysinger
2009-06-23 21:14               ` Arnd Bergmann
2009-06-23 21:53                 ` Mike Frysinger
2009-06-23 22:06                   ` Arnd Bergmann
2009-06-23 22:11                     ` Mike Frysinger
2009-09-19 19:08                 ` Mike Frysinger
2009-06-14 12:01 ` [PATCH 06/17] Blackfin: convert shm/sysv/ipc to asm-generic Mike Frysinger
2009-06-14 12:01 ` [PATCH 07/17] Blackfin: convert user/elf " Mike Frysinger
2009-06-14 12:01 ` [PATCH 08/17] Blackfin: convert socket/poll " Mike Frysinger
2009-06-14 12:01 ` [PATCH 09/17] Blackfin: convert simple headers " Mike Frysinger
2009-06-14 12:01 ` [PATCH 10/17] Blackfin: convert dma/pci " Mike Frysinger
2009-06-15 11:37   ` Arnd Bergmann
2009-06-16 10:00     ` Mike Frysinger
2009-06-14 12:01 ` [PATCH 11/17] Blackfin: convert termios " Mike Frysinger
2009-06-14 12:01 ` [PATCH 12/17] Blackfin: convert locking primitives " Mike Frysinger
2009-06-14 12:01 ` [PATCH 13/17] Blackfin: convert signal/mmap " Mike Frysinger
2009-06-14 12:01 ` [PATCH 14/17] Blackfin: convert irq/process " Mike Frysinger
2009-06-14 12:01 ` [PATCH 15/17] Blackfin: convert types " Mike Frysinger
2009-06-14 12:01 ` [PATCH 16/17] Blackfin: convert page/tlb " Mike Frysinger
2009-06-14 12:01 ` [PATCH 17/17] Blackfin: convert uaccess " Mike Frysinger
2009-06-15 11:42 ` [PATCH 00/17] Blackfin arch conversion " Arnd Bergmann

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.