Blackfin arch conversion to asm-generic
Subsystems (6)
cover Blackfin arch conversion to asm-generic
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
PATCH 1/17 Blackfin: use common test_bit() rather than __test_bit()
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.
--- arch/blackfin/mach-common/ints-priority.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
arch/blackfin/mach-common/ints-priority.c +2 -2
@@ -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 ; }
Signature · 1 line
1.6.3.1
PATCH 2/17 Blackfin: pull in asm/io.h in ksyms for prototypes
In reply to Mike FrysingerMake 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.
--- arch/blackfin/kernel/bfin_ksyms.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
arch/blackfin/kernel/bfin_ksyms.c +1 -0
@@ -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);
Signature · 1 line
1.6.3.1
PATCH 3/17 Blackfin: only build irqpanic.c when needed
In reply to Mike FrysingerThe 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.
--- arch/blackfin/mach-common/Makefile | 3 ++- arch/blackfin/mach-common/irqpanic.c | 11 ++--------- 2 files changed, 4 insertions(+), 10 deletions(-)
arch/blackfin/mach-common/Makefile +2 -1
@@ -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
arch/blackfin/mach-common/irqpanic.c +2 -9
@@ -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 - }
Signature · 1 line
1.6.3.1
PATCH 4/17 Blackfin: convert asm/ioctls.h to asm-generic/ioctls.h
In reply to Mike Frysinger--- arch/blackfin/include/asm/ioctls.h | 84 +----------------------------------- 1 files changed, 2 insertions(+), 82 deletions(-)
arch/blackfin/include/asm/ioctls.h +2 -82
@@ -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
Signature · 1 line
1.6.3.1
PATCH 5/17 Blackfin: convert to generic checksum code
In reply to Mike FrysingerThe Blackfin port only implemented an optimized version of the csum_tcpudp_nofold function, so convert everything else to the new generic code.
--- 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
arch/blackfin/Kconfig +3 -0
@@ -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
arch/blackfin/include/asm/checksum.h +4 -68
88 lines not on this page · raw message
arch/blackfin/lib/Makefile +1 -1
@@ -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
arch/blackfin/lib/checksum.c deleted +0 -145
145 lines not on this page · raw message
Signature · 1 line
1.6.3.1
Re: [PATCH 05/17] Blackfin: convert to generic checksum code
Quoted 5 lines · Mike Frysinger
The Blackfin port only implemented an optimized version of the
csum_tcpudp_nofoldfunction, so convert everything else to the new generic code.Signed-off-by Mike Frysinger <[email protected]>
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 <><
Re: [PATCH 05/17] Blackfin: convert to generic checksum code
Quoted 9 lines · Arnd Bergmann
Quoted 3 lines · Mike Frysinger
The Blackfin port only implemented an optimized version of the
csum_tcpudp_nofoldfunction, 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
Re: [PATCH 05/17] Blackfin: convert to generic checksum code
In reply to Arnd BergmannQuoted 11 lines · Arnd Bergmann
Quoted 5 lines · Mike Frysinger
The Blackfin port only implemented an optimized version of the
csum_tcpudp_nofoldfunction, so convert everything else to the new generic code.Signed-off-by Mike Frysinger <[email protected]>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
#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;
}Re: [PATCH 05/17] Blackfin: convert to generic checksum code
Quoted 6 lines · Mike Frysinger
Quoted 5 lines · Arnd Bergmann
Quoted 4 lines · Mike Frysinger
The Blackfin port only implemented an optimized version of the
csum_tcpudp_nofoldfunction, so convert everything else to the new generic code.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Signed-off-by Mike Frysinger <[email protected]>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:
Quoted 10 lines
here's the input:
do_csum({ 0xff 0xfb 0x01 }, 3)and here's the output:
Blackfin:0xfc00
generic:0xfcffif i run the two funcs on my x86, i see similar behavior. the attached
csum-test.ccontains the csum code fromlib/checksum.candarch/blackfin/lib/checksum.cand 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.
Quoted 13 lines
-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; }
Quoted 5 lines
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;
Quoted 5 lines
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 <><
---
Quoted 1 line
From
e01fed86629737809c46dcb8b807347e84640b70Mon Sep 17 00:00:00 2001
From: Arnd Bergmann <[email protected]>
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.
--- lib/checksum.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
lib/checksum.c +5 -1
@@ -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 );
Signature · 1 line
1.6.3.1
Re: [PATCH 05/17] Blackfin: convert to generic checksum code
Quoted 3 lines · Arnd Bergmann
x86 and blackfin are both little-endian, so your variant is correct there. They add the
0x01to 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 ?
Quoted 1 line
I've committed the patch below now.
closer, but not quite just yet ...do_csum: mismatch 0x1700 != 0xa0d len:2do_csum: { 0xd, 0xa }do_csum: mismatch 0x6f76 != 0x4f96 len:255do_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:32csum_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
Re: [PATCH 05/17] Blackfin: convert to generic checksum code
Quoted 7 lines · Mike Frysinger
Quoted 3 lines · Arnd Bergmann
x86 and blackfin are both little-endian, so your variant is correct there. They add the
0x01to 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.
Quoted 5 lines
Quoted 1 line
I've committed the patch below now.
closer, but not quite just yet ...
do_csum: mismatch0x1700!=0xa0dlen:2do_csum: {0xd,0xa}
I've compared the code again with Paul's sh version and found another difference in the handling of unaligned data.
Quoted 5 lines
when
do_csumdoes return correct values,csum_partialsometimes does not:csum_partial: mismatch0x1101eefe!=0xfffflen:32csum_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.
Quoted 10 lines
btw, would it make sense to change
do_csumlike so:(quoted diff) +1
-1-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 optimizeddo_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.
Quoted 5 lines
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:
#ifndefdo_csum
static inline unsigned short from32to16(unsigned long x)
Quoted 8 lines
{ ... } 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.
lib/checksum.c +4 -0
@@ -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++; }
Re: [PATCH 05/17] Blackfin: convert to generic checksum code
Quoted 10 lines · Arnd Bergmann
Quoted 7 lines · Mike Frysinger
Quoted 3 lines · Arnd Bergmann
x86 and blackfin are both little-endian, so your variant is correct there. They add the
0x01to 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
Quoted 1 line
lib/checksum.c: Fix another endianess bug
hrm, still not quite :/
the attached test code shows failures in every case -mike
/*
* 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);
Re: [PATCH 05/17] Blackfin: convert to generic checksum code
I missed your mail last week and only now stumbled over it after Linus has pulled my tree.
Quoted 4 lines · Mike Frysinger
Quoted 2 lines
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.
Quoted 5 lines
Quoted 1 line
lib/checksum.c: Fix another endianess bughrm, 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.
lib/checksum.c +2 -2
@@ -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++;
---
Quoted 2 lines
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.
Quoted 7 lines
static unsigned char __initdata do_csum_data2[] = { 0x0d, 0x0a, }; static unsigned char __initdata do_csum_data3[] = { 0xff, 0xfb, 0x01, };...
Quoted 8 lines
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 <><
Re: [PATCH 05/17] Blackfin: convert to generic checksum code
Quoted 5 lines · Arnd Bergmann
lib/checksum.c +0
-0@@ -57,9 +57,9 @@ static unsigned int do_csum(const unsigned char *buff, int len) odd = 1 & (unsigned long) buff; if (odd) {
lib/checksum.c static unsigned int do_csum(const unsigned char *buff, int len)
Quoted 10 lines
lib/checksum.c +2
-3#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.
Quoted 5 lines
Quoted 1 line
extern unsigned short
do_csum(const unsigned char *buff, int len);
do_csumis really an internal function. IMHO we should better checkcsum_partial(),ip_fast_csum(),csum_fold(),csum_tcpudp_magic()andip_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.
Quoted 16 lines
Quoted 7 lines
static unsigned char
__initdatado_csum_data2[] = {0x0d,0x0a,
};
static unsigned char__initdatado_csum_data3[] = {0xff,0xfb,0x01,
};
...Quoted 8 lines
static struct
do_csum_data__initdatado_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),
};
Quoted 2 lines
You mixed up
do_csum_data2anddo_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
Quoted 3 lines
Also, the expected checksum is endian-dependent.
The test module should either be modified to expect0xffffto be returned in every case, or should usele16_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
Re: [PATCH 05/17] Blackfin: convert to generic checksum code
Quoted 10 lines · Mike Frysinger
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_csumindirectly would be detrimental to the people who would want to use this -- arch maintainers looking to implementdo_csum()themselves. otherwise they need to step through the surrounding functions a bit to find the exact values given todo_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.
Review
Quoted 5 lines
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 ?
(quoted diff) +1
-1- if (tret != do_csum_data[i].ret) { + if (tret != le16_to_cpu(do_csum_data[i].ret)) {
yes, that should work.
Quoted 5 lines
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 <><
Re: [PATCH 05/17] Blackfin: convert to generic checksum code
Quoted 12 lines · Arnd Bergmann
Quoted 10 lines · Mike Frysinger
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_csumindirectly would be detrimental to the people who would want to use this -- arch maintainers looking to implementdo_csum()themselves. otherwise they need to step through the surrounding functions a bit to find the exact values given todo_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.
Quoted 4 lines
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
Re: [PATCH 05/17] Blackfin: convert to generic checksum code
In reply to Arnd BergmannQuoted 20 lines · Arnd Bergmann
Quoted 4 lines · Mike Frysinger
Quoted 2 lines
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.
Quoted 5 lines
Quoted 1 line
lib/checksum.c: Fix another endianess bughrm, 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
Quoted 8 lines
When
do_csumgets 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 <[email protected]>Signed-off-by Arnd Bergmann <[email protected]>
shouldnt this fix have been in 2.6.31 ? doesnt seem to be even in latest git ...
-mike
PATCH 6/17 Blackfin: convert shm/sysv/ipc to asm-generic
In reply to Mike Frysinger--- 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(-)
arch/blackfin/include/asm/ipcbuf.h +1 -30
@@ -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>
arch/blackfin/include/asm/msgbuf.h +1 -31
@@ -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>
arch/blackfin/include/asm/sembuf.h +1 -25
@@ -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>
arch/blackfin/include/asm/shmbuf.h +1 -42
43 lines not on this page · raw message
arch/blackfin/include/asm/shmparam.h +1 -6
@@ -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>
Signature · 1 line
1.6.3.1
PATCH 7/17 Blackfin: convert user/elf to asm-generic
In reply to Mike Frysinger--- arch/blackfin/include/asm/elf.h | 2 +- arch/blackfin/include/asm/user.h | 90 +------------------------------------- 2 files changed, 2 insertions(+), 90 deletions(-)
arch/blackfin/include/asm/elf.h +1 -1
@@ -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 ;
arch/blackfin/include/asm/user.h +1 -89
90 lines not on this page · raw message
Signature · 1 line
1.6.3.1
PATCH 8/17 Blackfin: convert socket/poll to asm-generic
In reply to Mike Frysinger--- 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(-)
arch/blackfin/include/asm/poll.h +3 -18
@@ -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
arch/blackfin/include/asm/socket.h +1 -59
60 lines not on this page · raw message
arch/blackfin/include/asm/sockios.h +1 -13
@@ -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>
Signature · 1 line
1.6.3.1
PATCH 9/17 Blackfin: convert simple headers to asm-generic
In reply to Mike Frysinger--- 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(-)
arch/blackfin/include/asm/auxvec.h +1 -4
@@ -1,4 +1 @@ -#ifndef __ASMBFIN_AUXVEC_H -#define __ASMBFIN_AUXVEC_H - -#endif +#include <asm-generic/auxvec.h>
arch/blackfin/include/asm/bugs.h +1 -16
@@ -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>
arch/blackfin/include/asm/cputime.h +0 -5
@@ -1,6 +1 @@ -#ifndef __BLACKFIN_CPUTIME_H -#define __BLACKFIN_CPUTIME_H -#include <asm-generic/cputime.h> - -#endif /* __BLACKFIN_CPUTIME_H */
arch/blackfin/include/asm/current.h +1 -23
@@ -1,23 +1 @@ -#ifndef _BLACKFIN_CURRENT_H -#define _BLACKFIN_CURRENT_H -/* -* current.h -* (C) Copyright 2000, Lineo, David McCullough <[email protected]> -* -* 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>
arch/blackfin/include/asm/device.h +0 -6
@@ -1,7 +1 @@ -/* -* Arch specific extensions to struct device -* -* This file is released under the GPLv2 -*/ #include <asm-generic/device.h> -
arch/blackfin/include/asm/emergency-restart.h +0 -5
@@ -1,6 +1 @@ -#ifndef _ASM_EMERGENCY_RESTART_H -#define _ASM_EMERGENCY_RESTART_H -#include <asm-generic/emergency-restart.h> - -#endif /* _ASM_EMERGENCY_RESTART_H */
arch/blackfin/include/asm/errno.h +1 -6
@@ -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>
arch/blackfin/include/asm/fb.h +1 -12
@@ -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>
arch/blackfin/include/asm/futex.h +0 -5
@@ -1,6 +1 @@ -#ifndef _ASM_FUTEX_H -#define _ASM_FUTEX_H -#include <asm-generic/futex.h> - -#endif
arch/blackfin/include/asm/hw_irq.h +1 -6
@@ -1,6 +1 @@ -#ifndef __ASM_BFIN_HW_IRQ_H -#define __ASM_BFIN_HW_IRQ_H - -/* Dummy include. */ - -#endif +#include <asm-generic/hw_irq.h>
arch/blackfin/include/asm/kmap_types.h +1 -21
@@ -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>
arch/blackfin/include/asm/local.h +0 -5
@@ -1,6 +1 @@ -#ifndef __BLACKFIN_LOCAL_H -#define __BLACKFIN_LOCAL_H -#include <asm-generic/local.h> - -#endif /* __BLACKFIN_LOCAL_H */
arch/blackfin/include/asm/param.h +1 -22
@@ -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>
arch/blackfin/include/asm/percpu.h +0 -5
@@ -1,6 +1 @@ -#ifndef __ARCH_BLACKFIN_PERCPU__ -#define __ARCH_BLACKFIN_PERCPU__ -#include <asm-generic/percpu.h> - -#endif /* __ARCH_BLACKFIN_PERCPU__ */
arch/blackfin/include/asm/pgalloc.h +1 -8
@@ -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>
arch/blackfin/include/asm/resource.h +0 -5
@@ -1,6 +1 @@ -#ifndef _BFIN_RESOURCE_H -#define _BFIN_RESOURCE_H -#include <asm-generic/resource.h> - -#endif /* _BFIN_RESOURCE_H */
arch/blackfin/include/asm/serial.h +1 -5
@@ -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)
arch/blackfin/include/asm/setup.h +1 -17
@@ -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>
arch/blackfin/include/asm/statfs.h +0 -5
@@ -1,6 +1 @@ -#ifndef _BFIN_STATFS_H -#define _BFIN_STATFS_H -#include <asm-generic/statfs.h> - -#endif /* _BFIN_STATFS_H */
arch/blackfin/include/asm/topology.h +0 -5
@@ -1,6 +1 @@ -#ifndef _ASM_BLACKFIN_TOPOLOGY_H -#define _ASM_BLACKFIN_TOPOLOGY_H -#include <asm-generic/topology.h> - -#endif /* _ASM_BLACKFIN_TOPOLOGY_H */
Signature · 1 line
1.6.3.1
PATCH 10/17 Blackfin: convert dma/pci to asm-generic
In reply to Mike Frysinger--- 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(-)
arch/blackfin/include/asm/dma-mapping.h +11 -80
@@ -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_errorstatic 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
arch/blackfin/include/asm/dma.h +1 -4
@@ -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)
arch/blackfin/include/asm/pci.h +1 -148
149 lines not on this page · raw message
arch/blackfin/include/asm/scatterlist.h +1 -28
@@ -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>
Signature · 1 line
1.6.3.1
Re: [PATCH 10/17] Blackfin: convert dma/pci to asm-generic
arch/blackfin/include/asm/dma-mapping.h line 5
Quoted 7 lines · Mike Frysinger
arch/blackfin/include/asm/dma-mapping.h +1
-0@@ -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.
arch/blackfin/include/asm/dma-mapping.h +291 -50
@@ -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 */
arch/blackfin/kernel/dma-mapping.c +0 -51
54 lines not on this page · raw message
Re: [PATCH 10/17] Blackfin: convert dma/pci to asm-generic
Quoted 11 lines · Arnd Bergmann
arch/blackfin/include/asm/dma-mapping.h line 5
Quoted 7 lines · Mike Frysinger
arch/blackfin/include/asm/dma-mapping.h +1
-0@@ -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.hhelps 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.
Quoted 6 lines
I have a dma-mapping
branch in my asm-generic repository. While I could not get an agreement on an approach for a commondma-mapping.hfile 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
PATCH 11/17 Blackfin: convert termios to asm-generic
In reply to Mike Frysinger--- arch/blackfin/include/asm/termbits.h | 199 +--------------------------------- arch/blackfin/include/asm/termios.h | 95 +---------------- 2 files changed, 2 insertions(+), 292 deletions(-)
arch/blackfin/include/asm/termbits.h +1 -198
@@ -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>
arch/blackfin/include/asm/termios.h +1 -94
95 lines not on this page · raw message
Signature · 1 line
1.6.3.1
PATCH 12/17 Blackfin: convert locking primitives to asm-generic
In reply to Mike Frysinger--- 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(-)
arch/blackfin/include/asm/atomic.h +7 -102
@@ -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 ([email protected]) 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
arch/blackfin/include/asm/bitops.h +9 -189
234 lines not on this page · raw message
arch/blackfin/include/asm/mutex.h +1 -1
@@ -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
arch/blackfin/include/asm/spinlock.h +6 -0
@@ -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 */
arch/blackfin/include/asm/swab.h +1 -5
@@ -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__
arch/blackfin/include/asm/unaligned.h +1 -11
@@ -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>
Signature · 1 line
1.6.3.1
PATCH 13/17 Blackfin: convert signal/mmap to asm-generic
In reply to Mike Frysinger--- arch/blackfin/include/asm/mman.h | 44 +---------- arch/blackfin/include/asm/signal.h | 159 +----------------------------------- 2 files changed, 4 insertions(+), 199 deletions(-)
arch/blackfin/include/asm/mman.h +1 -43
@@ -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>
arch/blackfin/include/asm/signal.h +3 -156
163 lines not on this page · raw message
Signature · 1 line
1.6.3.1
PATCH 14/17 Blackfin: convert irq/process to asm-generic
In reply to Mike Frysinger--- 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(-)
arch/blackfin/include/asm/hardirq.h +3 -33
@@ -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 1extern void ack_bad_irq (unsigned int irq); +#define ack_bad_irq ack_bad_irq + +#include <asm-generic/hardirq.h> #endif
arch/blackfin/include/asm/irq.h +1 -4
@@ -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_ */
arch/blackfin/include/asm/processor.h +3 -32
@@ -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 ;
arch/blackfin/kernel/process.c +23 -0
@@ -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 ) { }
Signature · 1 line
1.6.3.1
PATCH 15/17 Blackfin: convert types to asm-generic
In reply to Mike Frysinger--- arch/blackfin/include/asm/posix_types.h | 56 ++++++------------------------- arch/blackfin/include/asm/types.h | 37 +-------------------- 2 files changed, 12 insertions(+), 81 deletions(-)
arch/blackfin/include/asm/posix_types.h +11 -45
@@ -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_ttypedef 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
arch/blackfin/include/asm/types.h +1 -36
@@ -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>
Signature · 1 line
1.6.3.1
PATCH 16/17 Blackfin: convert page/tlb to asm-generic
In reply to Mike Frysinger--- 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(-)
arch/blackfin/include/asm/io.h +0 -1
@@ -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))
arch/blackfin/include/asm/page.h +2 -83
90 lines not on this page · raw message
arch/blackfin/include/asm/tlbflush.h +1 -56
57 lines not on this page · raw message
arch/blackfin/include/asm/ucontext.h +1 -17
@@ -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>
Signature · 1 line
1.6.3.1
PATCH 17/17 Blackfin: convert uaccess to asm-generic
In reply to Mike Frysinger--- arch/blackfin/include/asm/segment.h | 8 +- arch/blackfin/include/asm/uaccess.h | 265 ++--------------------------------- 2 files changed, 10 insertions(+), 263 deletions(-)
arch/blackfin/include/asm/segment.h +1 -7
@@ -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>
arch/blackfin/include/asm/uaccess.h +9 -256
277 lines not on this page · raw message
Signature · 1 line
1.6.3.1
Quoted 7 lines · Mike Frysinger
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.
...
Quoted 2 lines
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 <><