aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/SubmittingPatches5
-rw-r--r--Documentation/dontdiff1
-rw-r--r--Documentation/fb/vesafb.txt16
-rw-r--r--Documentation/kprobes.txt588
-rw-r--r--Documentation/networking/bonding.txt978
-rw-r--r--Documentation/video4linux/CARDLIST.cx881
-rw-r--r--Documentation/video4linux/CARDLIST.tuner2
-rw-r--r--Documentation/video4linux/bttv/Insmod-options3
-rw-r--r--MAINTAINERS6
-rw-r--r--Makefile2
-rw-r--r--arch/arm/mach-ixp4xx/coyote-setup.c2
-rw-r--r--arch/arm/mach-ixp4xx/gtwx5715-setup.c2
-rw-r--r--arch/arm/mach-ixp4xx/ixdp425-setup.c4
-rw-r--r--arch/arm/mach-s3c2410/mach-bast.c16
-rw-r--r--arch/arm/mach-sa1100/jornada720.c1
-rw-r--r--arch/arm/mm/fault.c6
-rw-r--r--arch/arm/mm/proc-xscale.S136
-rw-r--r--arch/arm/nwfpe/double_cpdo.c24
-rw-r--r--arch/arm/nwfpe/extended_cpdo.c24
-rw-r--r--arch/arm/nwfpe/fpa11.c30
-rw-r--r--arch/arm/nwfpe/fpa11.h11
-rw-r--r--arch/arm/nwfpe/fpa11_cpdo.c28
-rw-r--r--arch/arm/nwfpe/fpa11_cpdt.c22
-rw-r--r--arch/arm/nwfpe/fpa11_cprt.c28
-rw-r--r--arch/arm/nwfpe/fpmodule.c15
-rw-r--r--arch/arm/nwfpe/single_cpdo.c24
-rw-r--r--arch/arm/nwfpe/softfloat.c334
-rw-r--r--arch/arm/nwfpe/softfloat.h68
-rw-r--r--arch/arm/oprofile/backtrace.c2
-rw-r--r--arch/arm/vfp/vfpdouble.c3
-rw-r--r--arch/arm26/mm/fault.c17
-rw-r--r--arch/cris/mm/fault.c6
-rw-r--r--arch/frv/mm/fault.c6
-rw-r--r--arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c7
-rw-r--r--arch/i386/kernel/cpu/transmeta.c6
-rw-r--r--arch/i386/kernel/syscall_table.S2
-rw-r--r--arch/i386/pci/acpi.c1
-rw-r--r--arch/i386/pci/common.c6
-rw-r--r--arch/i386/pci/irq.c1
-rw-r--r--arch/i386/pci/pci.h1
-rw-r--r--arch/ia64/kernel/entry.S2
-rw-r--r--arch/m32r/kernel/time.c13
-rw-r--r--arch/m68k/mm/fault.c6
-rw-r--r--arch/parisc/mm/fault.c12
-rw-r--r--arch/ppc/Kconfig2
-rw-r--r--arch/ppc/boot/simple/Makefile6
-rw-r--r--arch/ppc/boot/simple/pibs.c4
-rw-r--r--arch/ppc/configs/bamboo_defconfig943
-rw-r--r--arch/ppc/kernel/cputable.c20
-rw-r--r--arch/ppc/kernel/entry.S1
-rw-r--r--arch/ppc/kernel/head_44x.S24
-rw-r--r--arch/ppc/kernel/misc.S4
-rw-r--r--arch/ppc/platforms/4xx/Kconfig20
-rw-r--r--arch/ppc/platforms/4xx/Makefile2
-rw-r--r--arch/ppc/platforms/4xx/bamboo.c427
-rw-r--r--arch/ppc/platforms/4xx/bamboo.h136
-rw-r--r--arch/ppc/platforms/4xx/ebony.c6
-rw-r--r--arch/ppc/platforms/4xx/ebony.h13
-rw-r--r--arch/ppc/platforms/4xx/ibm440ep.c220
-rw-r--r--arch/ppc/platforms/4xx/ibm440ep.h76
-rw-r--r--arch/ppc/platforms/4xx/ocotea.c4
-rw-r--r--arch/ppc/platforms/4xx/ocotea.h13
-rw-r--r--arch/ppc/syslib/Makefile2
-rw-r--r--arch/ppc/syslib/ibm440gx_common.c15
-rw-r--r--arch/ppc/syslib/ibm44x_common.h4
-rw-r--r--arch/ppc64/kernel/head.S2
-rw-r--r--arch/ppc64/kernel/machine_kexec.c12
-rw-r--r--arch/ppc64/kernel/misc.S6
-rw-r--r--arch/ppc64/kernel/mpic.c4
-rw-r--r--arch/ppc64/kernel/mpic.h2
-rw-r--r--arch/ppc64/kernel/prom.c2
-rw-r--r--arch/ppc64/kernel/xics.c31
-rw-r--r--arch/ppc64/mm/numa.c7
-rw-r--r--arch/ppc64/xmon/xmon.c3
-rw-r--r--arch/s390/kernel/compat_wrapper.S26
-rw-r--r--arch/s390/kernel/machine_kexec.c7
-rw-r--r--arch/s390/kernel/relocate_kernel.S41
-rw-r--r--arch/s390/kernel/relocate_kernel64.S45
-rw-r--r--arch/s390/kernel/smp.c6
-rw-r--r--arch/s390/kernel/syscalls.S5
-rw-r--r--arch/s390/kernel/traps.c15
-rw-r--r--arch/sh64/mm/fault.c6
-rw-r--r--arch/x86_64/kernel/mpparse.c17
-rw-r--r--arch/x86_64/lib/csum-copy.S2
-rw-r--r--arch/x86_64/mm/fault.c6
-rw-r--r--drivers/acpi/Kconfig5
-rw-r--r--drivers/acpi/button.c206
-rw-r--r--drivers/acpi/dispatcher/dswload.c6
-rw-r--r--drivers/acpi/ec.c907
-rw-r--r--drivers/acpi/hotkey.c690
-rw-r--r--drivers/acpi/motherboard.c2
-rw-r--r--drivers/acpi/osl.c6
-rw-r--r--drivers/acpi/pci_irq.c85
-rw-r--r--drivers/acpi/pci_link.c127
-rw-r--r--drivers/acpi/processor_idle.c32
-rw-r--r--drivers/block/cfq-iosched.c1
-rw-r--r--drivers/char/watchdog/sa1100_wdt.c49
-rw-r--r--drivers/i2c/busses/i2c-mpc.c94
-rw-r--r--drivers/ide/ide-probe.c16
-rw-r--r--drivers/ide/legacy/ide-cs.c2
-rw-r--r--drivers/infiniband/include/ib_cm.h3
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c5
-rw-r--r--drivers/md/bitmap.c75
-rw-r--r--drivers/md/dm-raid1.c2
-rw-r--r--drivers/md/md.c4
-rw-r--r--drivers/md/raid1.c29
-rw-r--r--drivers/md/raid5.c1
-rw-r--r--drivers/md/raid6main.c1
-rw-r--r--drivers/media/video/bttv-cards.c8
-rw-r--r--drivers/media/video/bttv-driver.c33
-rw-r--r--drivers/media/video/bttv.h6
-rw-r--r--drivers/media/video/bttvp.h4
-rw-r--r--drivers/media/video/cx88/cx88-cards.c33
-rw-r--r--drivers/media/video/cx88/cx88-video.c4
-rw-r--r--drivers/media/video/cx88/cx88.h3
-rw-r--r--drivers/media/video/msp3400.c4
-rw-r--r--drivers/media/video/saa7134/saa7134-i2c.c4
-rw-r--r--drivers/media/video/saa7134/saa7134.h4
-rw-r--r--drivers/media/video/tea5767.c26
-rw-r--r--drivers/media/video/tuner-core.c29
-rw-r--r--drivers/media/video/tuner-simple.c8
-rw-r--r--drivers/media/video/tveeprom.c2
-rw-r--r--drivers/net/cs89x0.c12
-rw-r--r--drivers/net/cs89x0.h1
-rw-r--r--drivers/net/hamradio/Kconfig2
-rw-r--r--drivers/net/sk98lin/skge.c80
-rw-r--r--drivers/net/sk98lin/skgeinit.c2
-rw-r--r--drivers/net/sk98lin/skxmac2.c8
-rw-r--r--drivers/net/skge.c233
-rw-r--r--drivers/net/skge.h41
-rw-r--r--drivers/net/smc91x.h2
-rw-r--r--drivers/pci/bus.c4
-rw-r--r--drivers/pcmcia/ds.c2
-rw-r--r--drivers/pcmcia/yenta_socket.c12
-rw-r--r--drivers/scsi/Kconfig2
-rw-r--r--drivers/scsi/aacraid/aacraid.h6
-rw-r--r--drivers/scsi/aacraid/linit.c3
-rw-r--r--drivers/scsi/aic7xxx/aicasm/aicasm.c4
-rw-r--r--drivers/scsi/aic7xxx/aicasm/aicasm_insformat.h8
-rw-r--r--drivers/video/fbsysfs.c8
-rw-r--r--drivers/video/tridentfb.c28
-rw-r--r--fs/hfs/bnode.c2
-rw-r--r--fs/hfs/extent.c3
-rw-r--r--fs/hfsplus/bnode.c2
-rw-r--r--fs/hfsplus/extents.c4
-rw-r--r--fs/inotify.c5
-rw-r--r--fs/namei.c2
-rw-r--r--include/acpi/acpi_drivers.h3
-rw-r--r--include/asm-i386/pci.h4
-rw-r--r--include/asm-ppc/ibm44x.h34
-rw-r--r--include/asm-ppc/ibm4xx.h4
-rw-r--r--include/asm-ppc/ibm_ocp.h12
-rw-r--r--include/asm-ppc/ppc_asm.h6
-rw-r--r--include/asm-ppc/unistd.h5
-rw-r--r--include/asm-ppc64/machdep.h2
-rw-r--r--include/asm-ppc64/topology.h5
-rw-r--r--include/asm-ppc64/unistd.h5
-rw-r--r--include/asm-ppc64/xics.h2
-rw-r--r--include/asm-s390/unistd.h7
-rw-r--r--include/asm-x86_64/pci.h4
-rw-r--r--include/linux/acpi.h4
-rw-r--r--include/linux/dcookies.h4
-rw-r--r--include/linux/fsnotify.h7
-rw-r--r--include/linux/mm.h22
-rw-r--r--include/linux/raid/bitmap.h1
-rw-r--r--include/media/tuner.h4
-rw-r--r--include/net/tcp.h2
-rw-r--r--ipc/shm.c2
-rw-r--r--kernel/module.c15
-rw-r--r--kernel/softirq.c4
-rw-r--r--kernel/sys.c2
-rw-r--r--kernel/sys_ni.c1
-rw-r--r--mm/memory.c48
-rw-r--r--mm/mempolicy.c2
-rw-r--r--mm/page_alloc.c21
-rw-r--r--net/core/dst.c15
-rw-r--r--net/ipv4/ip_gre.c21
-rw-r--r--net/ipv4/ipip.c20
-rw-r--r--net/ipv4/ipmr.c6
-rw-r--r--net/ipv4/netfilter/ip_conntrack_core.c5
-rw-r--r--net/ipv6/sit.c21
-rw-r--r--security/keys/keyctl.c11
-rw-r--r--security/keys/request_key.c2
-rw-r--r--sound/pci/intel8x0.c7
184 files changed, 6092 insertions, 1895 deletions
diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches
index 6761a7b241a5..7f43b040311e 100644
--- a/Documentation/SubmittingPatches
+++ b/Documentation/SubmittingPatches
@@ -149,6 +149,11 @@ USB, framebuffer devices, the VFS, the SCSI subsystem, etc. See the
149MAINTAINERS file for a mailing list that relates specifically to 149MAINTAINERS file for a mailing list that relates specifically to
150your change. 150your change.
151 151
152If changes affect userland-kernel interfaces, please send
153the MAN-PAGES maintainer (as listed in the MAINTAINERS file)
154a man-pages patch, or at least a notification of the change,
155so that some information makes its way into the manual pages.
156
152Even if the maintainer did not respond in step #4, make sure to ALWAYS 157Even if the maintainer did not respond in step #4, make sure to ALWAYS
153copy the maintainer when you change their code. 158copy the maintainer when you change their code.
154 159
diff --git a/Documentation/dontdiff b/Documentation/dontdiff
index b974cf595d01..96bea278bbf6 100644
--- a/Documentation/dontdiff
+++ b/Documentation/dontdiff
@@ -104,6 +104,7 @@ logo_*.c
104logo_*_clut224.c 104logo_*_clut224.c
105logo_*_mono.c 105logo_*_mono.c
106lxdialog 106lxdialog
107mach-types
107mach-types.h 108mach-types.h
108make_times_h 109make_times_h
109map 110map
diff --git a/Documentation/fb/vesafb.txt b/Documentation/fb/vesafb.txt
index 814e2f56a6ad..62db6758d1c1 100644
--- a/Documentation/fb/vesafb.txt
+++ b/Documentation/fb/vesafb.txt
@@ -144,7 +144,21 @@ vgapal Use the standard vga registers for palette changes.
144 This is the default. 144 This is the default.
145pmipal Use the protected mode interface for palette changes. 145pmipal Use the protected mode interface for palette changes.
146 146
147mtrr setup memory type range registers for the vesafb framebuffer. 147mtrr:n setup memory type range registers for the vesafb framebuffer
148 where n:
149 0 - disabled (equivalent to nomtrr)
150 1 - uncachable
151 2 - write-back
152 3 - write-combining (default)
153 4 - write-through
154
155 If you see the following in dmesg, choose the type that matches the
156 old one. In this example, use "mtrr:2".
157...
158mtrr: type mismatch for e0000000,8000000 old: write-back new: write-combining
159...
160
161nomtrr disable mtrr
148 162
149vremap:n 163vremap:n
150 remap 'n' MiB of video RAM. If 0 or not specified, remap memory 164 remap 'n' MiB of video RAM. If 0 or not specified, remap memory
diff --git a/Documentation/kprobes.txt b/Documentation/kprobes.txt
new file mode 100644
index 000000000000..0541fe1de704
--- /dev/null
+++ b/Documentation/kprobes.txt
@@ -0,0 +1,588 @@
1Title : Kernel Probes (Kprobes)
2Authors : Jim Keniston <jkenisto@us.ibm.com>
3 : Prasanna S Panchamukhi <prasanna@in.ibm.com>
4
5CONTENTS
6
71. Concepts: Kprobes, Jprobes, Return Probes
82. Architectures Supported
93. Configuring Kprobes
104. API Reference
115. Kprobes Features and Limitations
126. Probe Overhead
137. TODO
148. Kprobes Example
159. Jprobes Example
1610. Kretprobes Example
17
181. Concepts: Kprobes, Jprobes, Return Probes
19
20Kprobes enables you to dynamically break into any kernel routine and
21collect debugging and performance information non-disruptively. You
22can trap at almost any kernel code address, specifying a handler
23routine to be invoked when the breakpoint is hit.
24
25There are currently three types of probes: kprobes, jprobes, and
26kretprobes (also called return probes). A kprobe can be inserted
27on virtually any instruction in the kernel. A jprobe is inserted at
28the entry to a kernel function, and provides convenient access to the
29function's arguments. A return probe fires when a specified function
30returns.
31
32In the typical case, Kprobes-based instrumentation is packaged as
33a kernel module. The module's init function installs ("registers")
34one or more probes, and the exit function unregisters them. A
35registration function such as register_kprobe() specifies where
36the probe is to be inserted and what handler is to be called when
37the probe is hit.
38
39The next three subsections explain how the different types of
40probes work. They explain certain things that you'll need to
41know in order to make the best use of Kprobes -- e.g., the
42difference between a pre_handler and a post_handler, and how
43to use the maxactive and nmissed fields of a kretprobe. But
44if you're in a hurry to start using Kprobes, you can skip ahead
45to section 2.
46
471.1 How Does a Kprobe Work?
48
49When a kprobe is registered, Kprobes makes a copy of the probed
50instruction and replaces the first byte(s) of the probed instruction
51with a breakpoint instruction (e.g., int3 on i386 and x86_64).
52
53When a CPU hits the breakpoint instruction, a trap occurs, the CPU's
54registers are saved, and control passes to Kprobes via the
55notifier_call_chain mechanism. Kprobes executes the "pre_handler"
56associated with the kprobe, passing the handler the addresses of the
57kprobe struct and the saved registers.
58
59Next, Kprobes single-steps its copy of the probed instruction.
60(It would be simpler to single-step the actual instruction in place,
61but then Kprobes would have to temporarily remove the breakpoint
62instruction. This would open a small time window when another CPU
63could sail right past the probepoint.)
64
65After the instruction is single-stepped, Kprobes executes the
66"post_handler," if any, that is associated with the kprobe.
67Execution then continues with the instruction following the probepoint.
68
691.2 How Does a Jprobe Work?
70
71A jprobe is implemented using a kprobe that is placed on a function's
72entry point. It employs a simple mirroring principle to allow
73seamless access to the probed function's arguments. The jprobe
74handler routine should have the same signature (arg list and return
75type) as the function being probed, and must always end by calling
76the Kprobes function jprobe_return().
77
78Here's how it works. When the probe is hit, Kprobes makes a copy of
79the saved registers and a generous portion of the stack (see below).
80Kprobes then points the saved instruction pointer at the jprobe's
81handler routine, and returns from the trap. As a result, control
82passes to the handler, which is presented with the same register and
83stack contents as the probed function. When it is done, the handler
84calls jprobe_return(), which traps again to restore the original stack
85contents and processor state and switch to the probed function.
86
87By convention, the callee owns its arguments, so gcc may produce code
88that unexpectedly modifies that portion of the stack. This is why
89Kprobes saves a copy of the stack and restores it after the jprobe
90handler has run. Up to MAX_STACK_SIZE bytes are copied -- e.g.,
9164 bytes on i386.
92
93Note that the probed function's args may be passed on the stack
94or in registers (e.g., for x86_64 or for an i386 fastcall function).
95The jprobe will work in either case, so long as the handler's
96prototype matches that of the probed function.
97
981.3 How Does a Return Probe Work?
99
100When you call register_kretprobe(), Kprobes establishes a kprobe at
101the entry to the function. When the probed function is called and this
102probe is hit, Kprobes saves a copy of the return address, and replaces
103the return address with the address of a "trampoline." The trampoline
104is an arbitrary piece of code -- typically just a nop instruction.
105At boot time, Kprobes registers a kprobe at the trampoline.
106
107When the probed function executes its return instruction, control
108passes to the trampoline and that probe is hit. Kprobes' trampoline
109handler calls the user-specified handler associated with the kretprobe,
110then sets the saved instruction pointer to the saved return address,
111and that's where execution resumes upon return from the trap.
112
113While the probed function is executing, its return address is
114stored in an object of type kretprobe_instance. Before calling
115register_kretprobe(), the user sets the maxactive field of the
116kretprobe struct to specify how many instances of the specified
117function can be probed simultaneously. register_kretprobe()
118pre-allocates the indicated number of kretprobe_instance objects.
119
120For example, if the function is non-recursive and is called with a
121spinlock held, maxactive = 1 should be enough. If the function is
122non-recursive and can never relinquish the CPU (e.g., via a semaphore
123or preemption), NR_CPUS should be enough. If maxactive <= 0, it is
124set to a default value. If CONFIG_PREEMPT is enabled, the default
125is max(10, 2*NR_CPUS). Otherwise, the default is NR_CPUS.
126
127It's not a disaster if you set maxactive too low; you'll just miss
128some probes. In the kretprobe struct, the nmissed field is set to
129zero when the return probe is registered, and is incremented every
130time the probed function is entered but there is no kretprobe_instance
131object available for establishing the return probe.
132
1332. Architectures Supported
134
135Kprobes, jprobes, and return probes are implemented on the following
136architectures:
137
138- i386
139- x86_64 (AMD-64, E64MT)
140- ppc64
141- ia64 (Support for probes on certain instruction types is still in progress.)
142- sparc64 (Return probes not yet implemented.)
143
1443. Configuring Kprobes
145
146When configuring the kernel using make menuconfig/xconfig/oldconfig,
147ensure that CONFIG_KPROBES is set to "y". Under "Kernel hacking",
148look for "Kprobes". You may have to enable "Kernel debugging"
149(CONFIG_DEBUG_KERNEL) before you can enable Kprobes.
150
151You may also want to ensure that CONFIG_KALLSYMS and perhaps even
152CONFIG_KALLSYMS_ALL are set to "y", since kallsyms_lookup_name()
153is a handy, version-independent way to find a function's address.
154
155If you need to insert a probe in the middle of a function, you may find
156it useful to "Compile the kernel with debug info" (CONFIG_DEBUG_INFO),
157so you can use "objdump -d -l vmlinux" to see the source-to-object
158code mapping.
159
1604. API Reference
161
162The Kprobes API includes a "register" function and an "unregister"
163function for each type of probe. Here are terse, mini-man-page
164specifications for these functions and the associated probe handlers
165that you'll write. See the latter half of this document for examples.
166
1674.1 register_kprobe
168
169#include <linux/kprobes.h>
170int register_kprobe(struct kprobe *kp);
171
172Sets a breakpoint at the address kp->addr. When the breakpoint is
173hit, Kprobes calls kp->pre_handler. After the probed instruction
174is single-stepped, Kprobe calls kp->post_handler. If a fault
175occurs during execution of kp->pre_handler or kp->post_handler,
176or during single-stepping of the probed instruction, Kprobes calls
177kp->fault_handler. Any or all handlers can be NULL.
178
179register_kprobe() returns 0 on success, or a negative errno otherwise.
180
181User's pre-handler (kp->pre_handler):
182#include <linux/kprobes.h>
183#include <linux/ptrace.h>
184int pre_handler(struct kprobe *p, struct pt_regs *regs);
185
186Called with p pointing to the kprobe associated with the breakpoint,
187and regs pointing to the struct containing the registers saved when
188the breakpoint was hit. Return 0 here unless you're a Kprobes geek.
189
190User's post-handler (kp->post_handler):
191#include <linux/kprobes.h>
192#include <linux/ptrace.h>
193void post_handler(struct kprobe *p, struct pt_regs *regs,
194 unsigned long flags);
195
196p and regs are as described for the pre_handler. flags always seems
197to be zero.
198
199User's fault-handler (kp->fault_handler):
200#include <linux/kprobes.h>
201#include <linux/ptrace.h>
202int fault_handler(struct kprobe *p, struct pt_regs *regs, int trapnr);
203
204p and regs are as described for the pre_handler. trapnr is the
205architecture-specific trap number associated with the fault (e.g.,
206on i386, 13 for a general protection fault or 14 for a page fault).
207Returns 1 if it successfully handled the exception.
208
2094.2 register_jprobe
210
211#include <linux/kprobes.h>
212int register_jprobe(struct jprobe *jp)
213
214Sets a breakpoint at the address jp->kp.addr, which must be the address
215of the first instruction of a function. When the breakpoint is hit,
216Kprobes runs the handler whose address is jp->entry.
217
218The handler should have the same arg list and return type as the probed
219function; and just before it returns, it must call jprobe_return().
220(The handler never actually returns, since jprobe_return() returns
221control to Kprobes.) If the probed function is declared asmlinkage,
222fastcall, or anything else that affects how args are passed, the
223handler's declaration must match.
224
225register_jprobe() returns 0 on success, or a negative errno otherwise.
226
2274.3 register_kretprobe
228
229#include <linux/kprobes.h>
230int register_kretprobe(struct kretprobe *rp);
231
232Establishes a return probe for the function whose address is
233rp->kp.addr. When that function returns, Kprobes calls rp->handler.
234You must set rp->maxactive appropriately before you call
235register_kretprobe(); see "How Does a Return Probe Work?" for details.
236
237register_kretprobe() returns 0 on success, or a negative errno
238otherwise.
239
240User's return-probe handler (rp->handler):
241#include <linux/kprobes.h>
242#include <linux/ptrace.h>
243int kretprobe_handler(struct kretprobe_instance *ri, struct pt_regs *regs);
244
245regs is as described for kprobe.pre_handler. ri points to the
246kretprobe_instance object, of which the following fields may be
247of interest:
248- ret_addr: the return address
249- rp: points to the corresponding kretprobe object
250- task: points to the corresponding task struct
251The handler's return value is currently ignored.
252
2534.4 unregister_*probe
254
255#include <linux/kprobes.h>
256void unregister_kprobe(struct kprobe *kp);
257void unregister_jprobe(struct jprobe *jp);
258void unregister_kretprobe(struct kretprobe *rp);
259
260Removes the specified probe. The unregister function can be called
261at any time after the probe has been registered.
262
2635. Kprobes Features and Limitations
264
265As of Linux v2.6.12, Kprobes allows multiple probes at the same
266address. Currently, however, there cannot be multiple jprobes on
267the same function at the same time.
268
269In general, you can install a probe anywhere in the kernel.
270In particular, you can probe interrupt handlers. Known exceptions
271are discussed in this section.
272
273For obvious reasons, it's a bad idea to install a probe in
274the code that implements Kprobes (mostly kernel/kprobes.c and
275arch/*/kernel/kprobes.c). A patch in the v2.6.13 timeframe instructs
276Kprobes to reject such requests.
277
278If you install a probe in an inline-able function, Kprobes makes
279no attempt to chase down all inline instances of the function and
280install probes there. gcc may inline a function without being asked,
281so keep this in mind if you're not seeing the probe hits you expect.
282
283A probe handler can modify the environment of the probed function
284-- e.g., by modifying kernel data structures, or by modifying the
285contents of the pt_regs struct (which are restored to the registers
286upon return from the breakpoint). So Kprobes can be used, for example,
287to install a bug fix or to inject faults for testing. Kprobes, of
288course, has no way to distinguish the deliberately injected faults
289from the accidental ones. Don't drink and probe.
290
291Kprobes makes no attempt to prevent probe handlers from stepping on
292each other -- e.g., probing printk() and then calling printk() from a
293probe handler. As of Linux v2.6.12, if a probe handler hits a probe,
294that second probe's handlers won't be run in that instance.
295
296In Linux v2.6.12 and previous versions, Kprobes' data structures are
297protected by a single lock that is held during probe registration and
298unregistration and while handlers are run. Thus, no two handlers
299can run simultaneously. To improve scalability on SMP systems,
300this restriction will probably be removed soon, in which case
301multiple handlers (or multiple instances of the same handler) may
302run concurrently on different CPUs. Code your handlers accordingly.
303
304Kprobes does not use semaphores or allocate memory except during
305registration and unregistration.
306
307Probe handlers are run with preemption disabled. Depending on the
308architecture, handlers may also run with interrupts disabled. In any
309case, your handler should not yield the CPU (e.g., by attempting to
310acquire a semaphore).
311
312Since a return probe is implemented by replacing the return
313address with the trampoline's address, stack backtraces and calls
314to __builtin_return_address() will typically yield the trampoline's
315address instead of the real return address for kretprobed functions.
316(As far as we can tell, __builtin_return_address() is used only
317for instrumentation and error reporting.)
318
319If the number of times a function is called does not match the
320number of times it returns, registering a return probe on that
321function may produce undesirable results. We have the do_exit()
322and do_execve() cases covered. do_fork() is not an issue. We're
323unaware of other specific cases where this could be a problem.
324
3256. Probe Overhead
326
327On a typical CPU in use in 2005, a kprobe hit takes 0.5 to 1.0
328microseconds to process. Specifically, a benchmark that hits the same
329probepoint repeatedly, firing a simple handler each time, reports 1-2
330million hits per second, depending on the architecture. A jprobe or
331return-probe hit typically takes 50-75% longer than a kprobe hit.
332When you have a return probe set on a function, adding a kprobe at
333the entry to that function adds essentially no overhead.
334
335Here are sample overhead figures (in usec) for different architectures.
336k = kprobe; j = jprobe; r = return probe; kr = kprobe + return probe
337on same function; jr = jprobe + return probe on same function
338
339i386: Intel Pentium M, 1495 MHz, 2957.31 bogomips
340k = 0.57 usec; j = 1.00; r = 0.92; kr = 0.99; jr = 1.40
341
342x86_64: AMD Opteron 246, 1994 MHz, 3971.48 bogomips
343k = 0.49 usec; j = 0.76; r = 0.80; kr = 0.82; jr = 1.07
344
345ppc64: POWER5 (gr), 1656 MHz (SMT disabled, 1 virtual CPU per physical CPU)
346k = 0.77 usec; j = 1.31; r = 1.26; kr = 1.45; jr = 1.99
347
3487. TODO
349
350a. SystemTap (http://sourceware.org/systemtap): Work in progress
351to provide a simplified programming interface for probe-based
352instrumentation.
353b. Improved SMP scalability: Currently, work is in progress to handle
354multiple kprobes in parallel.
355c. Kernel return probes for sparc64.
356d. Support for other architectures.
357e. User-space probes.
358
3598. Kprobes Example
360
361Here's a sample kernel module showing the use of kprobes to dump a
362stack trace and selected i386 registers when do_fork() is called.
363----- cut here -----
364/*kprobe_example.c*/
365#include <linux/kernel.h>
366#include <linux/module.h>
367#include <linux/kprobes.h>
368#include <linux/kallsyms.h>
369#include <linux/sched.h>
370
371/*For each probe you need to allocate a kprobe structure*/
372static struct kprobe kp;
373
374/*kprobe pre_handler: called just before the probed instruction is executed*/
375int handler_pre(struct kprobe *p, struct pt_regs *regs)
376{
377 printk("pre_handler: p->addr=0x%p, eip=%lx, eflags=0x%lx\n",
378 p->addr, regs->eip, regs->eflags);
379 dump_stack();
380 return 0;
381}
382
383/*kprobe post_handler: called after the probed instruction is executed*/
384void handler_post(struct kprobe *p, struct pt_regs *regs, unsigned long flags)
385{
386 printk("post_handler: p->addr=0x%p, eflags=0x%lx\n",
387 p->addr, regs->eflags);
388}
389
390/* fault_handler: this is called if an exception is generated for any
391 * instruction within the pre- or post-handler, or when Kprobes
392 * single-steps the probed instruction.
393 */
394int handler_fault(struct kprobe *p, struct pt_regs *regs, int trapnr)
395{
396 printk("fault_handler: p->addr=0x%p, trap #%dn",
397 p->addr, trapnr);
398 /* Return 0 because we don't handle the fault. */
399 return 0;
400}
401
402int init_module(void)
403{
404 int ret;
405 kp.pre_handler = handler_pre;
406 kp.post_handler = handler_post;
407 kp.fault_handler = handler_fault;
408 kp.addr = (kprobe_opcode_t*) kallsyms_lookup_name("do_fork");
409 /* register the kprobe now */
410 if (!kp.addr) {
411 printk("Couldn't find %s to plant kprobe\n", "do_fork");
412 return -1;
413 }
414 if ((ret = register_kprobe(&kp) < 0)) {
415 printk("register_kprobe failed, returned %d\n", ret);
416 return -1;
417 }
418 printk("kprobe registered\n");
419 return 0;
420}
421
422void cleanup_module(void)
423{
424 unregister_kprobe(&kp);
425 printk("kprobe unregistered\n");
426}
427
428MODULE_LICENSE("GPL");
429----- cut here -----
430
431You can build the kernel module, kprobe-example.ko, using the following
432Makefile:
433----- cut here -----
434obj-m := kprobe-example.o
435KDIR := /lib/modules/$(shell uname -r)/build
436PWD := $(shell pwd)
437default:
438 $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
439clean:
440 rm -f *.mod.c *.ko *.o
441----- cut here -----
442
443$ make
444$ su -
445...
446# insmod kprobe-example.ko
447
448You will see the trace data in /var/log/messages and on the console
449whenever do_fork() is invoked to create a new process.
450
4519. Jprobes Example
452
453Here's a sample kernel module showing the use of jprobes to dump
454the arguments of do_fork().
455----- cut here -----
456/*jprobe-example.c */
457#include <linux/kernel.h>
458#include <linux/module.h>
459#include <linux/fs.h>
460#include <linux/uio.h>
461#include <linux/kprobes.h>
462#include <linux/kallsyms.h>
463
464/*
465 * Jumper probe for do_fork.
466 * Mirror principle enables access to arguments of the probed routine
467 * from the probe handler.
468 */
469
470/* Proxy routine having the same arguments as actual do_fork() routine */
471long jdo_fork(unsigned long clone_flags, unsigned long stack_start,
472 struct pt_regs *regs, unsigned long stack_size,
473 int __user * parent_tidptr, int __user * child_tidptr)
474{
475 printk("jprobe: clone_flags=0x%lx, stack_size=0x%lx, regs=0x%p\n",
476 clone_flags, stack_size, regs);
477 /* Always end with a call to jprobe_return(). */
478 jprobe_return();
479 /*NOTREACHED*/
480 return 0;
481}
482
483static struct jprobe my_jprobe = {
484 .entry = (kprobe_opcode_t *) jdo_fork
485};
486
487int init_module(void)
488{
489 int ret;
490 my_jprobe.kp.addr = (kprobe_opcode_t *) kallsyms_lookup_name("do_fork");
491 if (!my_jprobe.kp.addr) {
492 printk("Couldn't find %s to plant jprobe\n", "do_fork");
493 return -1;
494 }
495
496 if ((ret = register_jprobe(&my_jprobe)) <0) {
497 printk("register_jprobe failed, returned %d\n", ret);
498 return -1;
499 }
500 printk("Planted jprobe at %p, handler addr %p\n",
501 my_jprobe.kp.addr, my_jprobe.entry);
502 return 0;
503}
504
505void cleanup_module(void)
506{
507 unregister_jprobe(&my_jprobe);
508 printk("jprobe unregistered\n");
509}
510
511MODULE_LICENSE("GPL");
512----- cut here -----
513
514Build and insert the kernel module as shown in the above kprobe
515example. You will see the trace data in /var/log/messages and on
516the console whenever do_fork() is invoked to create a new process.
517(Some messages may be suppressed if syslogd is configured to
518eliminate duplicate messages.)
519
52010. Kretprobes Example
521
522Here's a sample kernel module showing the use of return probes to
523report failed calls to sys_open().
524----- cut here -----
525/*kretprobe-example.c*/
526#include <linux/kernel.h>
527#include <linux/module.h>
528#include <linux/kprobes.h>
529#include <linux/kallsyms.h>
530
531static const char *probed_func = "sys_open";
532
533/* Return-probe handler: If the probed function fails, log the return value. */
534static int ret_handler(struct kretprobe_instance *ri, struct pt_regs *regs)
535{
536 // Substitute the appropriate register name for your architecture --
537 // e.g., regs->rax for x86_64, regs->gpr[3] for ppc64.
538 int retval = (int) regs->eax;
539 if (retval < 0) {
540 printk("%s returns %d\n", probed_func, retval);
541 }
542 return 0;
543}
544
545static struct kretprobe my_kretprobe = {
546 .handler = ret_handler,
547 /* Probe up to 20 instances concurrently. */
548 .maxactive = 20
549};
550
551int init_module(void)
552{
553 int ret;
554 my_kretprobe.kp.addr =
555 (kprobe_opcode_t *) kallsyms_lookup_name(probed_func);
556 if (!my_kretprobe.kp.addr) {
557 printk("Couldn't find %s to plant return probe\n", probed_func);
558 return -1;
559 }
560 if ((ret = register_kretprobe(&my_kretprobe)) < 0) {
561 printk("register_kretprobe failed, returned %d\n", ret);
562 return -1;
563 }
564 printk("Planted return probe at %p\n", my_kretprobe.kp.addr);
565 return 0;
566}
567
568void cleanup_module(void)
569{
570 unregister_kretprobe(&my_kretprobe);
571 printk("kretprobe unregistered\n");
572 /* nmissed > 0 suggests that maxactive was set too low. */
573 printk("Missed probing %d instances of %s\n",
574 my_kretprobe.nmissed, probed_func);
575}
576
577MODULE_LICENSE("GPL");
578----- cut here -----
579
580Build and insert the kernel module as shown in the above kprobe
581example. You will see the trace data in /var/log/messages and on the
582console whenever sys_open() returns a negative value. (Some messages
583may be suppressed if syslogd is configured to eliminate duplicate
584messages.)
585
586For additional information on Kprobes, refer to the following URLs:
587http://www-106.ibm.com/developerworks/library/l-kprobes.html?ca=dgr-lnxw42Kprobe
588http://www.redhat.com/magazine/005mar05/features/kprobes/
diff --git a/Documentation/networking/bonding.txt b/Documentation/networking/bonding.txt
index 0bc2ed136a38..24d029455baa 100644
--- a/Documentation/networking/bonding.txt
+++ b/Documentation/networking/bonding.txt
@@ -1,5 +1,7 @@
1 1
2 Linux Ethernet Bonding Driver HOWTO 2 Linux Ethernet Bonding Driver HOWTO
3
4 Latest update: 21 June 2005
3 5
4Initial release : Thomas Davis <tadavis at lbl.gov> 6Initial release : Thomas Davis <tadavis at lbl.gov>
5Corrections, HA extensions : 2000/10/03-15 : 7Corrections, HA extensions : 2000/10/03-15 :
@@ -11,15 +13,22 @@ Corrections, HA extensions : 2000/10/03-15 :
11 13
12Reorganized and updated Feb 2005 by Jay Vosburgh 14Reorganized and updated Feb 2005 by Jay Vosburgh
13 15
14Note : 16Introduction
15------ 17============
18
19 The Linux bonding driver provides a method for aggregating
20multiple network interfaces into a single logical "bonded" interface.
21The behavior of the bonded interfaces depends upon the mode; generally
22speaking, modes provide either hot standby or load balancing services.
23Additionally, link integrity monitoring may be performed.
16 24
17The bonding driver originally came from Donald Becker's beowulf patches for 25 The bonding driver originally came from Donald Becker's
18kernel 2.0. It has changed quite a bit since, and the original tools from 26beowulf patches for kernel 2.0. It has changed quite a bit since, and
19extreme-linux and beowulf sites will not work with this version of the driver. 27the original tools from extreme-linux and beowulf sites will not work
28with this version of the driver.
20 29
21For new versions of the driver, patches for older kernels and the updated 30 For new versions of the driver, updated userspace tools, and
22userspace tools, please follow the links at the end of this file. 31who to ask for help, please follow the links at the end of this file.
23 32
24Table of Contents 33Table of Contents
25================= 34=================
@@ -30,9 +39,13 @@ Table of Contents
30 39
313. Configuring Bonding Devices 403. Configuring Bonding Devices
323.1 Configuration with sysconfig support 413.1 Configuration with sysconfig support
423.1.1 Using DHCP with sysconfig
433.1.2 Configuring Multiple Bonds with sysconfig
333.2 Configuration with initscripts support 443.2 Configuration with initscripts support
453.2.1 Using DHCP with initscripts
463.2.2 Configuring Multiple Bonds with initscripts
343.3 Configuring Bonding Manually 473.3 Configuring Bonding Manually
353.4 Configuring Multiple Bonds 483.3.1 Configuring Multiple Bonds Manually
36 49
375. Querying Bonding Configuration 505. Querying Bonding Configuration
385.1 Bonding Configuration 515.1 Bonding Configuration
@@ -56,21 +69,30 @@ Table of Contents
56 69
5711. Promiscuous mode 7011. Promiscuous mode
58 71
5912. High Availability Information 7212. Configuring Bonding for High Availability
6012.1 High Availability in a Single Switch Topology 7312.1 High Availability in a Single Switch Topology
6112.1.1 Bonding Mode Selection for Single Switch Topology
6212.1.2 Link Monitoring for Single Switch Topology
6312.2 High Availability in a Multiple Switch Topology 7412.2 High Availability in a Multiple Switch Topology
6412.2.1 Bonding Mode Selection for Multiple Switch Topology 7512.2.1 HA Bonding Mode Selection for Multiple Switch Topology
6512.2.2 Link Monitoring for Multiple Switch Topology 7612.2.2 HA Link Monitoring for Multiple Switch Topology
6612.3 Switch Behavior Issues for High Availability 77
7813. Configuring Bonding for Maximum Throughput
7913.1 Maximum Throughput in a Single Switch Topology
8013.1.1 MT Bonding Mode Selection for Single Switch Topology
8113.1.2 MT Link Monitoring for Single Switch Topology
8213.2 Maximum Throughput in a Multiple Switch Topology
8313.2.1 MT Bonding Mode Selection for Multiple Switch Topology
8413.2.2 MT Link Monitoring for Multiple Switch Topology
67 85
6813. Hardware Specific Considerations 8614. Switch Behavior Issues
6913.1 IBM BladeCenter 8714.1 Link Establishment and Failover Delays
8814.2 Duplicated Incoming Packets
70 89
7114. Frequently Asked Questions 9015. Hardware Specific Considerations
9115.1 IBM BladeCenter
72 92
7315. Resources and Links 9316. Frequently Asked Questions
94
9517. Resources and Links
74 96
75 97
761. Bonding Driver Installation 981. Bonding Driver Installation
@@ -86,16 +108,10 @@ the following steps:
861.1 Configure and build the kernel with bonding 1081.1 Configure and build the kernel with bonding
87----------------------------------------------- 109-----------------------------------------------
88 110
89 The latest version of the bonding driver is available in the 111 The current version of the bonding driver is available in the
90drivers/net/bonding subdirectory of the most recent kernel source 112drivers/net/bonding subdirectory of the most recent kernel source
91(which is available on http://kernel.org). 113(which is available on http://kernel.org). Most users "rolling their
92 114own" will want to use the most recent kernel from kernel.org.
93 Prior to the 2.4.11 kernel, the bonding driver was maintained
94largely outside the kernel tree; patches for some earlier kernels are
95available on the bonding sourceforge site, although those patches are
96still several years out of date. Most users will want to use either
97the most recent kernel from kernel.org or whatever kernel came with
98their distro.
99 115
100 Configure kernel with "make menuconfig" (or "make xconfig" or 116 Configure kernel with "make menuconfig" (or "make xconfig" or
101"make config"), then select "Bonding driver support" in the "Network 117"make config"), then select "Bonding driver support" in the "Network
@@ -103,8 +119,8 @@ device support" section. It is recommended that you configure the
103driver as module since it is currently the only way to pass parameters 119driver as module since it is currently the only way to pass parameters
104to the driver or configure more than one bonding device. 120to the driver or configure more than one bonding device.
105 121
106 Build and install the new kernel and modules, then proceed to 122 Build and install the new kernel and modules, then continue
107step 2. 123below to install ifenslave.
108 124
1091.2 Install ifenslave Control Utility 1251.2 Install ifenslave Control Utility
110------------------------------------- 126-------------------------------------
@@ -147,9 +163,9 @@ default kernel source include directory.
147 Options for the bonding driver are supplied as parameters to 163 Options for the bonding driver are supplied as parameters to
148the bonding module at load time. They may be given as command line 164the bonding module at load time. They may be given as command line
149arguments to the insmod or modprobe command, but are usually specified 165arguments to the insmod or modprobe command, but are usually specified
150in either the /etc/modprobe.conf configuration file, or in a 166in either the /etc/modules.conf or /etc/modprobe.conf configuration
151distro-specific configuration file (some of which are detailed in the 167file, or in a distro-specific configuration file (some of which are
152next section). 168detailed in the next section).
153 169
154 The available bonding driver parameters are listed below. If a 170 The available bonding driver parameters are listed below. If a
155parameter is not specified the default value is used. When initially 171parameter is not specified the default value is used. When initially
@@ -162,34 +178,34 @@ degradation will occur during link failures. Very few devices do not
162support at least miimon, so there is really no reason not to use it. 178support at least miimon, so there is really no reason not to use it.
163 179
164 Options with textual values will accept either the text name 180 Options with textual values will accept either the text name
165 or, for backwards compatibility, the option value. E.g., 181or, for backwards compatibility, the option value. E.g.,
166 "mode=802.3ad" and "mode=4" set the same mode. 182"mode=802.3ad" and "mode=4" set the same mode.
167 183
168 The parameters are as follows: 184 The parameters are as follows:
169 185
170arp_interval 186arp_interval
171 187
172 Specifies the ARP monitoring frequency in milli-seconds. If 188 Specifies the ARP link monitoring frequency in milliseconds.
173 ARP monitoring is used in a load-balancing mode (mode 0 or 2), 189 If ARP monitoring is used in an etherchannel compatible mode
174 the switch should be configured in a mode that evenly 190 (modes 0 and 2), the switch should be configured in a mode
175 distributes packets across all links - such as round-robin. If 191 that evenly distributes packets across all links. If the
176 the switch is configured to distribute the packets in an XOR 192 switch is configured to distribute the packets in an XOR
177 fashion, all replies from the ARP targets will be received on 193 fashion, all replies from the ARP targets will be received on
178 the same link which could cause the other team members to 194 the same link which could cause the other team members to
179 fail. ARP monitoring should not be used in conjunction with 195 fail. ARP monitoring should not be used in conjunction with
180 miimon. A value of 0 disables ARP monitoring. The default 196 miimon. A value of 0 disables ARP monitoring. The default
181 value is 0. 197 value is 0.
182 198
183arp_ip_target 199arp_ip_target
184 200
185 Specifies the ip addresses to use when arp_interval is > 0. 201 Specifies the IP addresses to use as ARP monitoring peers when
186 These are the targets of the ARP request sent to determine the 202 arp_interval is > 0. These are the targets of the ARP request
187 health of the link to the targets. Specify these values in 203 sent to determine the health of the link to the targets.
188 ddd.ddd.ddd.ddd format. Multiple ip adresses must be 204 Specify these values in ddd.ddd.ddd.ddd format. Multiple IP
189 seperated by a comma. At least one IP address must be given 205 addresses must be separated by a comma. At least one IP
190 for ARP monitoring to function. The maximum number of targets 206 address must be given for ARP monitoring to function. The
191 that can be specified is 16. The default value is no IP 207 maximum number of targets that can be specified is 16. The
192 addresses. 208 default value is no IP addresses.
193 209
194downdelay 210downdelay
195 211
@@ -207,11 +223,13 @@ lacp_rate
207 are: 223 are:
208 224
209 slow or 0 225 slow or 0
210 Request partner to transmit LACPDUs every 30 seconds (default) 226 Request partner to transmit LACPDUs every 30 seconds
211 227
212 fast or 1 228 fast or 1
213 Request partner to transmit LACPDUs every 1 second 229 Request partner to transmit LACPDUs every 1 second
214 230
231 The default is slow.
232
215max_bonds 233max_bonds
216 234
217 Specifies the number of bonding devices to create for this 235 Specifies the number of bonding devices to create for this
@@ -221,10 +239,11 @@ max_bonds
221 239
222miimon 240miimon
223 241
224 Specifies the frequency in milli-seconds that MII link 242 Specifies the MII link monitoring frequency in milliseconds.
225 monitoring will occur. A value of zero disables MII link 243 This determines how often the link state of each slave is
226 monitoring. A value of 100 is a good starting point. The 244 inspected for link failures. A value of zero disables MII
227 use_carrier option, below, affects how the link state is 245 link monitoring. A value of 100 is a good starting point.
246 The use_carrier option, below, affects how the link state is
228 determined. See the High Availability section for additional 247 determined. See the High Availability section for additional
229 information. The default value is 0. 248 information. The default value is 0.
230 249
@@ -246,17 +265,31 @@ mode
246 active. A different slave becomes active if, and only 265 active. A different slave becomes active if, and only
247 if, the active slave fails. The bond's MAC address is 266 if, the active slave fails. The bond's MAC address is
248 externally visible on only one port (network adapter) 267 externally visible on only one port (network adapter)
249 to avoid confusing the switch. This mode provides 268 to avoid confusing the switch.
250 fault tolerance. The primary option affects the 269
251 behavior of this mode. 270 In bonding version 2.6.2 or later, when a failover
271 occurs in active-backup mode, bonding will issue one
272 or more gratuitous ARPs on the newly active slave.
273 One gratutious ARP is issued for the bonding master
274 interface and each VLAN interfaces configured above
275 it, provided that the interface has at least one IP
276 address configured. Gratuitous ARPs issued for VLAN
277 interfaces are tagged with the appropriate VLAN id.
278
279 This mode provides fault tolerance. The primary
280 option, documented below, affects the behavior of this
281 mode.
252 282
253 balance-xor or 2 283 balance-xor or 2
254 284
255 XOR policy: Transmit based on [(source MAC address 285 XOR policy: Transmit based on the selected transmit
256 XOR'd with destination MAC address) modulo slave 286 hash policy. The default policy is a simple [(source
257 count]. This selects the same slave for each 287 MAC address XOR'd with destination MAC address) modulo
258 destination MAC address. This mode provides load 288 slave count]. Alternate transmit policies may be
259 balancing and fault tolerance. 289 selected via the xmit_hash_policy option, described
290 below.
291
292 This mode provides load balancing and fault tolerance.
260 293
261 broadcast or 3 294 broadcast or 3
262 295
@@ -270,7 +303,17 @@ mode
270 duplex settings. Utilizes all slaves in the active 303 duplex settings. Utilizes all slaves in the active
271 aggregator according to the 802.3ad specification. 304 aggregator according to the 802.3ad specification.
272 305
273 Pre-requisites: 306 Slave selection for outgoing traffic is done according
307 to the transmit hash policy, which may be changed from
308 the default simple XOR policy via the xmit_hash_policy
309 option, documented below. Note that not all transmit
310 policies may be 802.3ad compliant, particularly in
311 regards to the packet mis-ordering requirements of
312 section 43.2.4 of the 802.3ad standard. Differing
313 peer implementations will have varying tolerances for
314 noncompliance.
315
316 Prerequisites:
274 317
275 1. Ethtool support in the base drivers for retrieving 318 1. Ethtool support in the base drivers for retrieving
276 the speed and duplex of each slave. 319 the speed and duplex of each slave.
@@ -333,7 +376,7 @@ mode
333 376
334 When a link is reconnected or a new slave joins the 377 When a link is reconnected or a new slave joins the
335 bond the receive traffic is redistributed among all 378 bond the receive traffic is redistributed among all
336 active slaves in the bond by intiating ARP Replies 379 active slaves in the bond by initiating ARP Replies
337 with the selected mac address to each of the 380 with the selected mac address to each of the
338 clients. The updelay parameter (detailed below) must 381 clients. The updelay parameter (detailed below) must
339 be set to a value equal or greater than the switch's 382 be set to a value equal or greater than the switch's
@@ -396,6 +439,60 @@ use_carrier
396 0 will use the deprecated MII / ETHTOOL ioctls. The default 439 0 will use the deprecated MII / ETHTOOL ioctls. The default
397 value is 1. 440 value is 1.
398 441
442xmit_hash_policy
443
444 Selects the transmit hash policy to use for slave selection in
445 balance-xor and 802.3ad modes. Possible values are:
446
447 layer2
448
449 Uses XOR of hardware MAC addresses to generate the
450 hash. The formula is
451
452 (source MAC XOR destination MAC) modulo slave count
453
454 This algorithm will place all traffic to a particular
455 network peer on the same slave.
456
457 This algorithm is 802.3ad compliant.
458
459 layer3+4
460
461 This policy uses upper layer protocol information,
462 when available, to generate the hash. This allows for
463 traffic to a particular network peer to span multiple
464 slaves, although a single connection will not span
465 multiple slaves.
466
467 The formula for unfragmented TCP and UDP packets is
468
469 ((source port XOR dest port) XOR
470 ((source IP XOR dest IP) AND 0xffff)
471 modulo slave count
472
473 For fragmented TCP or UDP packets and all other IP
474 protocol traffic, the source and destination port
475 information is omitted. For non-IP traffic, the
476 formula is the same as for the layer2 transmit hash
477 policy.
478
479 This policy is intended to mimic the behavior of
480 certain switches, notably Cisco switches with PFC2 as
481 well as some Foundry and IBM products.
482
483 This algorithm is not fully 802.3ad compliant. A
484 single TCP or UDP conversation containing both
485 fragmented and unfragmented packets will see packets
486 striped across two interfaces. This may result in out
487 of order delivery. Most traffic types will not meet
488 this criteria, as TCP rarely fragments traffic, and
489 most UDP traffic is not involved in extended
490 conversations. Other implementations of 802.3ad may
491 or may not tolerate this noncompliance.
492
493 The default value is layer2. This option was added in bonding
494version 2.6.3. In earlier versions of bonding, this parameter does
495not exist, and the layer2 policy is the only policy.
399 496
400 497
4013. Configuring Bonding Devices 4983. Configuring Bonding Devices
@@ -448,8 +545,9 @@ Bonding devices can be managed by hand, however, as follows.
448slave devices. On SLES 9, this is most easily done by running the 545slave devices. On SLES 9, this is most easily done by running the
449yast2 sysconfig configuration utility. The goal is for to create an 546yast2 sysconfig configuration utility. The goal is for to create an
450ifcfg-id file for each slave device. The simplest way to accomplish 547ifcfg-id file for each slave device. The simplest way to accomplish
451this is to configure the devices for DHCP. The name of the 548this is to configure the devices for DHCP (this is only to get the
452configuration file for each device will be of the form: 549file ifcfg-id file created; see below for some issues with DHCP). The
550name of the configuration file for each device will be of the form:
453 551
454ifcfg-id-xx:xx:xx:xx:xx:xx 552ifcfg-id-xx:xx:xx:xx:xx:xx
455 553
@@ -459,7 +557,7 @@ the device's permanent MAC address.
459 Once the set of ifcfg-id-xx:xx:xx:xx:xx:xx files has been 557 Once the set of ifcfg-id-xx:xx:xx:xx:xx:xx files has been
460created, it is necessary to edit the configuration files for the slave 558created, it is necessary to edit the configuration files for the slave
461devices (the MAC addresses correspond to those of the slave devices). 559devices (the MAC addresses correspond to those of the slave devices).
462Before editing, the file will contain muliple lines, and will look 560Before editing, the file will contain multiple lines, and will look
463something like this: 561something like this:
464 562
465BOOTPROTO='dhcp' 563BOOTPROTO='dhcp'
@@ -496,16 +594,11 @@ STARTMODE="onboot"
496BONDING_MASTER="yes" 594BONDING_MASTER="yes"
497BONDING_MODULE_OPTS="mode=active-backup miimon=100" 595BONDING_MODULE_OPTS="mode=active-backup miimon=100"
498BONDING_SLAVE0="eth0" 596BONDING_SLAVE0="eth0"
499BONDING_SLAVE1="eth1" 597BONDING_SLAVE1="bus-pci-0000:06:08.1"
500 598
501 Replace the sample BROADCAST, IPADDR, NETMASK and NETWORK 599 Replace the sample BROADCAST, IPADDR, NETMASK and NETWORK
502values with the appropriate values for your network. 600values with the appropriate values for your network.
503 601
504 Note that configuring the bonding device with BOOTPROTO='dhcp'
505does not work; the scripts attempt to obtain the device address from
506DHCP prior to adding any of the slave devices. Without active slaves,
507the DHCP requests are not sent to the network.
508
509 The STARTMODE specifies when the device is brought online. 602 The STARTMODE specifies when the device is brought online.
510The possible values are: 603The possible values are:
511 604
@@ -531,9 +624,17 @@ for the bonding mode, link monitoring, and so on here. Do not include
531the max_bonds bonding parameter; this will confuse the configuration 624the max_bonds bonding parameter; this will confuse the configuration
532system if you have multiple bonding devices. 625system if you have multiple bonding devices.
533 626
534 Finally, supply one BONDING_SLAVEn="ethX" for each slave, 627 Finally, supply one BONDING_SLAVEn="slave device" for each
535where "n" is an increasing value, one for each slave, and "ethX" is 628slave. where "n" is an increasing value, one for each slave. The
536the name of the slave device (eth0, eth1, etc). 629"slave device" is either an interface name, e.g., "eth0", or a device
630specifier for the network device. The interface name is easier to
631find, but the ethN names are subject to change at boot time if, e.g.,
632a device early in the sequence has failed. The device specifiers
633(bus-pci-0000:06:08.1 in the example above) specify the physical
634network device, and will not change unless the device's bus location
635changes (for example, it is moved from one PCI slot to another). The
636example above uses one of each type for demonstration purposes; most
637configurations will choose one or the other for all slave devices.
537 638
538 When all configuration files have been modified or created, 639 When all configuration files have been modified or created,
539networking must be restarted for the configuration changes to take 640networking must be restarted for the configuration changes to take
@@ -544,7 +645,7 @@ effect. This can be accomplished via the following:
544 Note that the network control script (/sbin/ifdown) will 645 Note that the network control script (/sbin/ifdown) will
545remove the bonding module as part of the network shutdown processing, 646remove the bonding module as part of the network shutdown processing,
546so it is not necessary to remove the module by hand if, e.g., the 647so it is not necessary to remove the module by hand if, e.g., the
547module paramters have changed. 648module parameters have changed.
548 649
549 Also, at this writing, YaST/YaST2 will not manage bonding 650 Also, at this writing, YaST/YaST2 will not manage bonding
550devices (they do not show bonding interfaces on its list of network 651devices (they do not show bonding interfaces on its list of network
@@ -559,12 +660,37 @@ format can be found in an example ifcfg template file:
559 Note that the template does not document the various BONDING_ 660 Note that the template does not document the various BONDING_
560settings described above, but does describe many of the other options. 661settings described above, but does describe many of the other options.
561 662
6633.1.1 Using DHCP with sysconfig
664-------------------------------
665
666 Under sysconfig, configuring a device with BOOTPROTO='dhcp'
667will cause it to query DHCP for its IP address information. At this
668writing, this does not function for bonding devices; the scripts
669attempt to obtain the device address from DHCP prior to adding any of
670the slave devices. Without active slaves, the DHCP requests are not
671sent to the network.
672
6733.1.2 Configuring Multiple Bonds with sysconfig
674-----------------------------------------------
675
676 The sysconfig network initialization system is capable of
677handling multiple bonding devices. All that is necessary is for each
678bonding instance to have an appropriately configured ifcfg-bondX file
679(as described above). Do not specify the "max_bonds" parameter to any
680instance of bonding, as this will confuse sysconfig. If you require
681multiple bonding devices with identical parameters, create multiple
682ifcfg-bondX files.
683
684 Because the sysconfig scripts supply the bonding module
685options in the ifcfg-bondX file, it is not necessary to add them to
686the system /etc/modules.conf or /etc/modprobe.conf configuration file.
687
5623.2 Configuration with initscripts support 6883.2 Configuration with initscripts support
563------------------------------------------ 689------------------------------------------
564 690
565 This section applies to distros using a version of initscripts 691 This section applies to distros using a version of initscripts
566with bonding support, for example, Red Hat Linux 9 or Red Hat 692with bonding support, for example, Red Hat Linux 9 or Red Hat
567Enterprise Linux version 3. On these systems, the network 693Enterprise Linux version 3 or 4. On these systems, the network
568initialization scripts have some knowledge of bonding, and can be 694initialization scripts have some knowledge of bonding, and can be
569configured to control bonding devices. 695configured to control bonding devices.
570 696
@@ -614,10 +740,11 @@ USERCTL=no
614 Be sure to change the networking specific lines (IPADDR, 740 Be sure to change the networking specific lines (IPADDR,
615NETMASK, NETWORK and BROADCAST) to match your network configuration. 741NETMASK, NETWORK and BROADCAST) to match your network configuration.
616 742
617 Finally, it is necessary to edit /etc/modules.conf to load the 743 Finally, it is necessary to edit /etc/modules.conf (or
618bonding module when the bond0 interface is brought up. The following 744/etc/modprobe.conf, depending upon your distro) to load the bonding
619sample lines in /etc/modules.conf will load the bonding module, and 745module with your desired options when the bond0 interface is brought
620select its options: 746up. The following lines in /etc/modules.conf (or modprobe.conf) will
747load the bonding module, and select its options:
621 748
622alias bond0 bonding 749alias bond0 bonding
623options bond0 mode=balance-alb miimon=100 750options bond0 mode=balance-alb miimon=100
@@ -629,6 +756,33 @@ options for your configuration.
629will restart the networking subsystem and your bond link should be now 756will restart the networking subsystem and your bond link should be now
630up and running. 757up and running.
631 758
7593.2.1 Using DHCP with initscripts
760---------------------------------
761
762 Recent versions of initscripts (the version supplied with
763Fedora Core 3 and Red Hat Enterprise Linux 4 is reported to work) do
764have support for assigning IP information to bonding devices via DHCP.
765
766 To configure bonding for DHCP, configure it as described
767above, except replace the line "BOOTPROTO=none" with "BOOTPROTO=dhcp"
768and add a line consisting of "TYPE=Bonding". Note that the TYPE value
769is case sensitive.
770
7713.2.2 Configuring Multiple Bonds with initscripts
772-------------------------------------------------
773
774 At this writing, the initscripts package does not directly
775support loading the bonding driver multiple times, so the process for
776doing so is the same as described in the "Configuring Multiple Bonds
777Manually" section, below.
778
779 NOTE: It has been observed that some Red Hat supplied kernels
780are apparently unable to rename modules at load time (the "-obonding1"
781part). Attempts to pass that option to modprobe will produce an
782"Operation not permitted" error. This has been reported on some
783Fedora Core kernels, and has been seen on RHEL 4 as well. On kernels
784exhibiting this problem, it will be impossible to configure multiple
785bonds with differing parameters.
632 786
6333.3 Configuring Bonding Manually 7873.3 Configuring Bonding Manually
634-------------------------------- 788--------------------------------
@@ -638,10 +792,11 @@ scripts (the sysconfig or initscripts package) do not have specific
638knowledge of bonding. One such distro is SuSE Linux Enterprise Server 792knowledge of bonding. One such distro is SuSE Linux Enterprise Server
639version 8. 793version 8.
640 794
641 The general methodology for these systems is to place the 795 The general method for these systems is to place the bonding
642bonding module parameters into /etc/modprobe.conf, then add modprobe 796module parameters into /etc/modules.conf or /etc/modprobe.conf (as
643and/or ifenslave commands to the system's global init script. The 797appropriate for the installed distro), then add modprobe and/or
644name of the global init script differs; for sysconfig, it is 798ifenslave commands to the system's global init script. The name of
799the global init script differs; for sysconfig, it is
645/etc/init.d/boot.local and for initscripts it is /etc/rc.d/rc.local. 800/etc/init.d/boot.local and for initscripts it is /etc/rc.d/rc.local.
646 801
647 For example, if you wanted to make a simple bond of two e100 802 For example, if you wanted to make a simple bond of two e100
@@ -649,7 +804,7 @@ devices (presumed to be eth0 and eth1), and have it persist across
649reboots, edit the appropriate file (/etc/init.d/boot.local or 804reboots, edit the appropriate file (/etc/init.d/boot.local or
650/etc/rc.d/rc.local), and add the following: 805/etc/rc.d/rc.local), and add the following:
651 806
652modprobe bonding -obond0 mode=balance-alb miimon=100 807modprobe bonding mode=balance-alb miimon=100
653modprobe e100 808modprobe e100
654ifconfig bond0 192.168.1.1 netmask 255.255.255.0 up 809ifconfig bond0 192.168.1.1 netmask 255.255.255.0 up
655ifenslave bond0 eth0 810ifenslave bond0 eth0
@@ -657,11 +812,7 @@ ifenslave bond0 eth1
657 812
658 Replace the example bonding module parameters and bond0 813 Replace the example bonding module parameters and bond0
659network configuration (IP address, netmask, etc) with the appropriate 814network configuration (IP address, netmask, etc) with the appropriate
660values for your configuration. The above example loads the bonding 815values for your configuration.
661module with the name "bond0," this simplifies the naming if multiple
662bonding modules are loaded (each successive instance of the module is
663given a different name, and the module instance names match the
664bonding interface names).
665 816
666 Unfortunately, this method will not provide support for the 817 Unfortunately, this method will not provide support for the
667ifup and ifdown scripts on the bond devices. To reload the bonding 818ifup and ifdown scripts on the bond devices. To reload the bonding
@@ -684,20 +835,23 @@ appropriate device driver modules. For our example above, you can do
684the following: 835the following:
685 836
686# ifconfig bond0 down 837# ifconfig bond0 down
687# rmmod bond0 838# rmmod bonding
688# rmmod e100 839# rmmod e100
689 840
690 Again, for convenience, it may be desirable to create a script 841 Again, for convenience, it may be desirable to create a script
691with these commands. 842with these commands.
692 843
693 844
6943.4 Configuring Multiple Bonds 8453.3.1 Configuring Multiple Bonds Manually
695------------------------------ 846-----------------------------------------
696 847
697 This section contains information on configuring multiple 848 This section contains information on configuring multiple
698bonding devices with differing options. If you require multiple 849bonding devices with differing options for those systems whose network
699bonding devices, but all with the same options, see the "max_bonds" 850initialization scripts lack support for configuring multiple bonds.
700module paramter, documented above. 851
852 If you require multiple bonding devices, but all with the same
853options, you may wish to use the "max_bonds" module parameter,
854documented above.
701 855
702 To create multiple bonding devices with differing options, it 856 To create multiple bonding devices with differing options, it
703is necessary to load the bonding driver multiple times. Note that 857is necessary to load the bonding driver multiple times. Note that
@@ -724,11 +878,16 @@ named "bond0" and creates the bond0 device in balance-rr mode with an
724miimon of 100. The second instance is named "bond1" and creates the 878miimon of 100. The second instance is named "bond1" and creates the
725bond1 device in balance-alb mode with an miimon of 50. 879bond1 device in balance-alb mode with an miimon of 50.
726 880
881 In some circumstances (typically with older distributions),
882the above does not work, and the second bonding instance never sees
883its options. In that case, the second options line can be substituted
884as follows:
885
886install bonding1 /sbin/modprobe bonding -obond1 mode=balance-alb miimon=50
887
727 This may be repeated any number of times, specifying a new and 888 This may be repeated any number of times, specifying a new and
728unique name in place of bond0 or bond1 for each instance. 889unique name in place of bond1 for each subsequent instance.
729 890
730 When the appropriate module paramters are in place, then
731configure bonding according to the instructions for your distro.
732 891
7335. Querying Bonding Configuration 8925. Querying Bonding Configuration
734================================= 893=================================
@@ -846,8 +1005,8 @@ tagged internally by bonding itself. As a result, bonding must
846self generated packets. 1005self generated packets.
847 1006
848 For reasons of simplicity, and to support the use of adapters 1007 For reasons of simplicity, and to support the use of adapters
849that can do VLAN hardware acceleration offloding, the bonding 1008that can do VLAN hardware acceleration offloading, the bonding
850interface declares itself as fully hardware offloaing capable, it gets 1009interface declares itself as fully hardware offloading capable, it gets
851the add_vid/kill_vid notifications to gather the necessary 1010the add_vid/kill_vid notifications to gather the necessary
852information, and it propagates those actions to the slaves. In case 1011information, and it propagates those actions to the slaves. In case
853of mixed adapter types, hardware accelerated tagged packets that 1012of mixed adapter types, hardware accelerated tagged packets that
@@ -880,7 +1039,7 @@ bond interface:
880matches the hardware address of the VLAN interfaces. 1039matches the hardware address of the VLAN interfaces.
881 1040
882 Note that changing a VLAN interface's HW address would set the 1041 Note that changing a VLAN interface's HW address would set the
883underlying device -- i.e. the bonding interface -- to promiscouos 1042underlying device -- i.e. the bonding interface -- to promiscuous
884mode, which might not be what you want. 1043mode, which might not be what you want.
885 1044
886 1045
@@ -923,7 +1082,7 @@ down or have a problem making it unresponsive to ARP requests. Having
923an additional target (or several) increases the reliability of the ARP 1082an additional target (or several) increases the reliability of the ARP
924monitoring. 1083monitoring.
925 1084
926 Multiple ARP targets must be seperated by commas as follows: 1085 Multiple ARP targets must be separated by commas as follows:
927 1086
928# example options for ARP monitoring with three targets 1087# example options for ARP monitoring with three targets
929alias bond0 bonding 1088alias bond0 bonding
@@ -1045,7 +1204,7 @@ install bonding /sbin/modprobe tg3; /sbin/modprobe e1000;
1045 This will, when loading the bonding module, rather than 1204 This will, when loading the bonding module, rather than
1046performing the normal action, instead execute the provided command. 1205performing the normal action, instead execute the provided command.
1047This command loads the device drivers in the order needed, then calls 1206This command loads the device drivers in the order needed, then calls
1048modprobe with --ingore-install to cause the normal action to then take 1207modprobe with --ignore-install to cause the normal action to then take
1049place. Full documentation on this can be found in the modprobe.conf 1208place. Full documentation on this can be found in the modprobe.conf
1050and modprobe manual pages. 1209and modprobe manual pages.
1051 1210
@@ -1130,14 +1289,14 @@ association.
1130common to enable promiscuous mode on the device, so that all traffic 1289common to enable promiscuous mode on the device, so that all traffic
1131is seen (instead of seeing only traffic destined for the local host). 1290is seen (instead of seeing only traffic destined for the local host).
1132The bonding driver handles promiscuous mode changes to the bonding 1291The bonding driver handles promiscuous mode changes to the bonding
1133master device (e.g., bond0), and propogates the setting to the slave 1292master device (e.g., bond0), and propagates the setting to the slave
1134devices. 1293devices.
1135 1294
1136 For the balance-rr, balance-xor, broadcast, and 802.3ad modes, 1295 For the balance-rr, balance-xor, broadcast, and 802.3ad modes,
1137the promiscuous mode setting is propogated to all slaves. 1296the promiscuous mode setting is propagated to all slaves.
1138 1297
1139 For the active-backup, balance-tlb and balance-alb modes, the 1298 For the active-backup, balance-tlb and balance-alb modes, the
1140promiscuous mode setting is propogated only to the active slave. 1299promiscuous mode setting is propagated only to the active slave.
1141 1300
1142 For balance-tlb mode, the active slave is the slave currently 1301 For balance-tlb mode, the active slave is the slave currently
1143receiving inbound traffic. 1302receiving inbound traffic.
@@ -1148,46 +1307,182 @@ sending to peers that are unassigned or if the load is unbalanced.
1148 1307
1149 For the active-backup, balance-tlb and balance-alb modes, when 1308 For the active-backup, balance-tlb and balance-alb modes, when
1150the active slave changes (e.g., due to a link failure), the 1309the active slave changes (e.g., due to a link failure), the
1151promiscuous setting will be propogated to the new active slave. 1310promiscuous setting will be propagated to the new active slave.
1152 1311
115312. High Availability Information 131212. Configuring Bonding for High Availability
1154================================= 1313=============================================
1155 1314
1156 High Availability refers to configurations that provide 1315 High Availability refers to configurations that provide
1157maximum network availability by having redundant or backup devices, 1316maximum network availability by having redundant or backup devices,
1158links and switches between the host and the rest of the world. 1317links or switches between the host and the rest of the world. The
1159 1318goal is to provide the maximum availability of network connectivity
1160 There are currently two basic methods for configuring to 1319(i.e., the network always works), even though other configurations
1161maximize availability. They are dependent on the network topology and 1320could provide higher throughput.
1162the primary goal of the configuration, but in general, a configuration
1163can be optimized for maximum available bandwidth, or for maximum
1164network availability.
1165 1321
116612.1 High Availability in a Single Switch Topology 132212.1 High Availability in a Single Switch Topology
1167-------------------------------------------------- 1323--------------------------------------------------
1168 1324
1169 If two hosts (or a host and a switch) are directly connected 1325 If two hosts (or a host and a single switch) are directly
1170via multiple physical links, then there is no network availability 1326connected via multiple physical links, then there is no availability
1171penalty for optimizing for maximum bandwidth: there is only one switch 1327penalty to optimizing for maximum bandwidth. In this case, there is
1172(or peer), so if it fails, you have no alternative access to fail over 1328only one switch (or peer), so if it fails, there is no alternative
1173to. 1329access to fail over to. Additionally, the bonding load balance modes
1330support link monitoring of their members, so if individual links fail,
1331the load will be rebalanced across the remaining devices.
1332
1333 See Section 13, "Configuring Bonding for Maximum Throughput"
1334for information on configuring bonding with one peer device.
1335
133612.2 High Availability in a Multiple Switch Topology
1337----------------------------------------------------
1338
1339 With multiple switches, the configuration of bonding and the
1340network changes dramatically. In multiple switch topologies, there is
1341a trade off between network availability and usable bandwidth.
1342
1343 Below is a sample network, configured to maximize the
1344availability of the network:
1174 1345
1175Example 1 : host to switch (or other host) 1346 | |
1347 |port3 port3|
1348 +-----+----+ +-----+----+
1349 | |port2 ISL port2| |
1350 | switch A +--------------------------+ switch B |
1351 | | | |
1352 +-----+----+ +-----++---+
1353 |port1 port1|
1354 | +-------+ |
1355 +-------------+ host1 +---------------+
1356 eth0 +-------+ eth1
1176 1357
1177 +----------+ +----------+ 1358 In this configuration, there is a link between the two
1178 | |eth0 eth0| switch | 1359switches (ISL, or inter switch link), and multiple ports connecting to
1179 | Host A +--------------------------+ or | 1360the outside world ("port3" on each switch). There is no technical
1180 | +--------------------------+ other | 1361reason that this could not be extended to a third switch.
1181 | |eth1 eth1| host |
1182 +----------+ +----------+
1183 1362
136312.2.1 HA Bonding Mode Selection for Multiple Switch Topology
1364-------------------------------------------------------------
1184 1365
118512.1.1 Bonding Mode Selection for single switch topology 1366 In a topology such as the example above, the active-backup and
1186-------------------------------------------------------- 1367broadcast modes are the only useful bonding modes when optimizing for
1368availability; the other modes require all links to terminate on the
1369same peer for them to behave rationally.
1370
1371active-backup: This is generally the preferred mode, particularly if
1372 the switches have an ISL and play together well. If the
1373 network configuration is such that one switch is specifically
1374 a backup switch (e.g., has lower capacity, higher cost, etc),
1375 then the primary option can be used to insure that the
1376 preferred link is always used when it is available.
1377
1378broadcast: This mode is really a special purpose mode, and is suitable
1379 only for very specific needs. For example, if the two
1380 switches are not connected (no ISL), and the networks beyond
1381 them are totally independent. In this case, if it is
1382 necessary for some specific one-way traffic to reach both
1383 independent networks, then the broadcast mode may be suitable.
1384
138512.2.2 HA Link Monitoring Selection for Multiple Switch Topology
1386----------------------------------------------------------------
1387
1388 The choice of link monitoring ultimately depends upon your
1389switch. If the switch can reliably fail ports in response to other
1390failures, then either the MII or ARP monitors should work. For
1391example, in the above example, if the "port3" link fails at the remote
1392end, the MII monitor has no direct means to detect this. The ARP
1393monitor could be configured with a target at the remote end of port3,
1394thus detecting that failure without switch support.
1395
1396 In general, however, in a multiple switch topology, the ARP
1397monitor can provide a higher level of reliability in detecting end to
1398end connectivity failures (which may be caused by the failure of any
1399individual component to pass traffic for any reason). Additionally,
1400the ARP monitor should be configured with multiple targets (at least
1401one for each switch in the network). This will insure that,
1402regardless of which switch is active, the ARP monitor has a suitable
1403target to query.
1404
1405
140613. Configuring Bonding for Maximum Throughput
1407==============================================
1408
140913.1 Maximizing Throughput in a Single Switch Topology
1410------------------------------------------------------
1411
1412 In a single switch configuration, the best method to maximize
1413throughput depends upon the application and network environment. The
1414various load balancing modes each have strengths and weaknesses in
1415different environments, as detailed below.
1416
1417 For this discussion, we will break down the topologies into
1418two categories. Depending upon the destination of most traffic, we
1419categorize them into either "gatewayed" or "local" configurations.
1420
1421 In a gatewayed configuration, the "switch" is acting primarily
1422as a router, and the majority of traffic passes through this router to
1423other networks. An example would be the following:
1424
1425
1426 +----------+ +----------+
1427 | |eth0 port1| | to other networks
1428 | Host A +---------------------+ router +------------------->
1429 | +---------------------+ | Hosts B and C are out
1430 | |eth1 port2| | here somewhere
1431 +----------+ +----------+
1432
1433 The router may be a dedicated router device, or another host
1434acting as a gateway. For our discussion, the important point is that
1435the majority of traffic from Host A will pass through the router to
1436some other network before reaching its final destination.
1437
1438 In a gatewayed network configuration, although Host A may
1439communicate with many other systems, all of its traffic will be sent
1440and received via one other peer on the local network, the router.
1441
1442 Note that the case of two systems connected directly via
1443multiple physical links is, for purposes of configuring bonding, the
1444same as a gatewayed configuration. In that case, it happens that all
1445traffic is destined for the "gateway" itself, not some other network
1446beyond the gateway.
1447
1448 In a local configuration, the "switch" is acting primarily as
1449a switch, and the majority of traffic passes through this switch to
1450reach other stations on the same network. An example would be the
1451following:
1452
1453 +----------+ +----------+ +--------+
1454 | |eth0 port1| +-------+ Host B |
1455 | Host A +------------+ switch |port3 +--------+
1456 | +------------+ | +--------+
1457 | |eth1 port2| +------------------+ Host C |
1458 +----------+ +----------+port4 +--------+
1459
1460
1461 Again, the switch may be a dedicated switch device, or another
1462host acting as a gateway. For our discussion, the important point is
1463that the majority of traffic from Host A is destined for other hosts
1464on the same local network (Hosts B and C in the above example).
1465
1466 In summary, in a gatewayed configuration, traffic to and from
1467the bonded device will be to the same MAC level peer on the network
1468(the gateway itself, i.e., the router), regardless of its final
1469destination. In a local configuration, traffic flows directly to and
1470from the final destinations, thus, each destination (Host B, Host C)
1471will be addressed directly by their individual MAC addresses.
1472
1473 This distinction between a gatewayed and a local network
1474configuration is important because many of the load balancing modes
1475available use the MAC addresses of the local network source and
1476destination to make load balancing decisions. The behavior of each
1477mode is described below.
1478
1479
148013.1.1 MT Bonding Mode Selection for Single Switch Topology
1481-----------------------------------------------------------
1187 1482
1188 This configuration is the easiest to set up and to understand, 1483 This configuration is the easiest to set up and to understand,
1189although you will have to decide which bonding mode best suits your 1484although you will have to decide which bonding mode best suits your
1190needs. The tradeoffs for each mode are detailed below: 1485needs. The trade offs for each mode are detailed below:
1191 1486
1192balance-rr: This mode is the only mode that will permit a single 1487balance-rr: This mode is the only mode that will permit a single
1193 TCP/IP connection to stripe traffic across multiple 1488 TCP/IP connection to stripe traffic across multiple
@@ -1206,6 +1501,23 @@ balance-rr: This mode is the only mode that will permit a single
1206 interface's worth of throughput, even after adjusting 1501 interface's worth of throughput, even after adjusting
1207 tcp_reordering. 1502 tcp_reordering.
1208 1503
1504 Note that this out of order delivery occurs when both the
1505 sending and receiving systems are utilizing a multiple
1506 interface bond. Consider a configuration in which a
1507 balance-rr bond feeds into a single higher capacity network
1508 channel (e.g., multiple 100Mb/sec ethernets feeding a single
1509 gigabit ethernet via an etherchannel capable switch). In this
1510 configuration, traffic sent from the multiple 100Mb devices to
1511 a destination connected to the gigabit device will not see
1512 packets out of order. However, traffic sent from the gigabit
1513 device to the multiple 100Mb devices may or may not see
1514 traffic out of order, depending upon the balance policy of the
1515 switch. Many switches do not support any modes that stripe
1516 traffic (instead choosing a port based upon IP or MAC level
1517 addresses); for those devices, traffic flowing from the
1518 gigabit device to the many 100Mb devices will only utilize one
1519 interface.
1520
1209 If you are utilizing protocols other than TCP/IP, UDP for 1521 If you are utilizing protocols other than TCP/IP, UDP for
1210 example, and your application can tolerate out of order 1522 example, and your application can tolerate out of order
1211 delivery, then this mode can allow for single stream datagram 1523 delivery, then this mode can allow for single stream datagram
@@ -1220,16 +1532,21 @@ active-backup: There is not much advantage in this network topology to
1220 connected to the same peer as the primary. In this case, a 1532 connected to the same peer as the primary. In this case, a
1221 load balancing mode (with link monitoring) will provide the 1533 load balancing mode (with link monitoring) will provide the
1222 same level of network availability, but with increased 1534 same level of network availability, but with increased
1223 available bandwidth. On the plus side, it does not require 1535 available bandwidth. On the plus side, active-backup mode
1224 any configuration of the switch. 1536 does not require any configuration of the switch, so it may
1537 have value if the hardware available does not support any of
1538 the load balance modes.
1225 1539
1226balance-xor: This mode will limit traffic such that packets destined 1540balance-xor: This mode will limit traffic such that packets destined
1227 for specific peers will always be sent over the same 1541 for specific peers will always be sent over the same
1228 interface. Since the destination is determined by the MAC 1542 interface. Since the destination is determined by the MAC
1229 addresses involved, this may be desirable if you have a large 1543 addresses involved, this mode works best in a "local" network
1230 network with many hosts. It is likely to be suboptimal if all 1544 configuration (as described above), with destinations all on
1231 your traffic is passed through a single router, however. As 1545 the same local network. This mode is likely to be suboptimal
1232 with balance-rr, the switch ports need to be configured for 1546 if all your traffic is passed through a single router (i.e., a
1547 "gatewayed" network configuration, as described above).
1548
1549 As with balance-rr, the switch ports need to be configured for
1233 "etherchannel" or "trunking." 1550 "etherchannel" or "trunking."
1234 1551
1235broadcast: Like active-backup, there is not much advantage to this 1552broadcast: Like active-backup, there is not much advantage to this
@@ -1241,122 +1558,131 @@ broadcast: Like active-backup, there is not much advantage to this
1241 protocol includes automatic configuration of the aggregates, 1558 protocol includes automatic configuration of the aggregates,
1242 so minimal manual configuration of the switch is needed 1559 so minimal manual configuration of the switch is needed
1243 (typically only to designate that some set of devices is 1560 (typically only to designate that some set of devices is
1244 usable for 802.3ad). The 802.3ad standard also mandates that 1561 available for 802.3ad). The 802.3ad standard also mandates
1245 frames be delivered in order (within certain limits), so in 1562 that frames be delivered in order (within certain limits), so
1246 general single connections will not see misordering of 1563 in general single connections will not see misordering of
1247 packets. The 802.3ad mode does have some drawbacks: the 1564 packets. The 802.3ad mode does have some drawbacks: the
1248 standard mandates that all devices in the aggregate operate at 1565 standard mandates that all devices in the aggregate operate at
1249 the same speed and duplex. Also, as with all bonding load 1566 the same speed and duplex. Also, as with all bonding load
1250 balance modes other than balance-rr, no single connection will 1567 balance modes other than balance-rr, no single connection will
1251 be able to utilize more than a single interface's worth of 1568 be able to utilize more than a single interface's worth of
1252 bandwidth. Additionally, the linux bonding 802.3ad 1569 bandwidth.
1253 implementation distributes traffic by peer (using an XOR of 1570
1254 MAC addresses), so in general all traffic to a particular 1571 Additionally, the linux bonding 802.3ad implementation
1255 destination will use the same interface. Finally, the 802.3ad 1572 distributes traffic by peer (using an XOR of MAC addresses),
1256 mode mandates the use of the MII monitor, therefore, the ARP 1573 so in a "gatewayed" configuration, all outgoing traffic will
1257 monitor is not available in this mode. 1574 generally use the same device. Incoming traffic may also end
1258 1575 up on a single device, but that is dependent upon the
1259balance-tlb: This mode is also a good choice for this type of 1576 balancing policy of the peer's 8023.ad implementation. In a
1260 topology. It has no special switch configuration 1577 "local" configuration, traffic will be distributed across the
1261 requirements, and balances outgoing traffic by peer, in a 1578 devices in the bond.
1262 vaguely intelligent manner (not a simple XOR as in balance-xor 1579
1263 or 802.3ad mode), so that unlucky MAC addresses will not all 1580 Finally, the 802.3ad mode mandates the use of the MII monitor,
1264 "bunch up" on a single interface. Interfaces may be of 1581 therefore, the ARP monitor is not available in this mode.
1265 differing speeds. On the down side, in this mode all incoming 1582
1266 traffic arrives over a single interface, this mode requires 1583balance-tlb: The balance-tlb mode balances outgoing traffic by peer.
1267 certain ethtool support in the network device driver of the 1584 Since the balancing is done according to MAC address, in a
1268 slave interfaces, and the ARP monitor is not available. 1585 "gatewayed" configuration (as described above), this mode will
1269 1586 send all traffic across a single device. However, in a
1270balance-alb: This mode is everything that balance-tlb is, and more. It 1587 "local" network configuration, this mode balances multiple
1271 has all of the features (and restrictions) of balance-tlb, and 1588 local network peers across devices in a vaguely intelligent
1272 will also balance incoming traffic from peers (as described in 1589 manner (not a simple XOR as in balance-xor or 802.3ad mode),
1273 the Bonding Module Options section, above). The only extra 1590 so that mathematically unlucky MAC addresses (i.e., ones that
1274 down side to this mode is that the network device driver must 1591 XOR to the same value) will not all "bunch up" on a single
1275 support changing the hardware address while the device is 1592 interface.
1276 open. 1593
1277 1594 Unlike 802.3ad, interfaces may be of differing speeds, and no
127812.1.2 Link Monitoring for Single Switch Topology 1595 special switch configuration is required. On the down side,
1279------------------------------------------------- 1596 in this mode all incoming traffic arrives over a single
1597 interface, this mode requires certain ethtool support in the
1598 network device driver of the slave interfaces, and the ARP
1599 monitor is not available.
1600
1601balance-alb: This mode is everything that balance-tlb is, and more.
1602 It has all of the features (and restrictions) of balance-tlb,
1603 and will also balance incoming traffic from local network
1604 peers (as described in the Bonding Module Options section,
1605 above).
1606
1607 The only additional down side to this mode is that the network
1608 device driver must support changing the hardware address while
1609 the device is open.
1610
161113.1.2 MT Link Monitoring for Single Switch Topology
1612----------------------------------------------------
1280 1613
1281 The choice of link monitoring may largely depend upon which 1614 The choice of link monitoring may largely depend upon which
1282mode you choose to use. The more advanced load balancing modes do not 1615mode you choose to use. The more advanced load balancing modes do not
1283support the use of the ARP monitor, and are thus restricted to using 1616support the use of the ARP monitor, and are thus restricted to using
1284the MII monitor (which does not provide as high a level of assurance 1617the MII monitor (which does not provide as high a level of end to end
1285as the ARP monitor). 1618assurance as the ARP monitor).
1286 1619
1287 162013.2 Maximum Throughput in a Multiple Switch Topology
128812.2 High Availability in a Multiple Switch Topology 1621-----------------------------------------------------
1289---------------------------------------------------- 1622
1290 1623 Multiple switches may be utilized to optimize for throughput
1291 With multiple switches, the configuration of bonding and the 1624when they are configured in parallel as part of an isolated network
1292network changes dramatically. In multiple switch topologies, there is 1625between two or more systems, for example:
1293a tradeoff between network availability and usable bandwidth. 1626
1294 1627 +-----------+
1295 Below is a sample network, configured to maximize the 1628 | Host A |
1296availability of the network: 1629 +-+---+---+-+
1297 1630 | | |
1298 | | 1631 +--------+ | +---------+
1299 |port3 port3| 1632 | | |
1300 +-----+----+ +-----+----+ 1633 +------+---+ +-----+----+ +-----+----+
1301 | |port2 ISL port2| | 1634 | Switch A | | Switch B | | Switch C |
1302 | switch A +--------------------------+ switch B | 1635 +------+---+ +-----+----+ +-----+----+
1303 | | | | 1636 | | |
1304 +-----+----+ +-----++---+ 1637 +--------+ | +---------+
1305 |port1 port1| 1638 | | |
1306 | +-------+ | 1639 +-+---+---+-+
1307 +-------------+ host1 +---------------+ 1640 | Host B |
1308 eth0 +-------+ eth1 1641 +-----------+
1309 1642
1310 In this configuration, there is a link between the two 1643 In this configuration, the switches are isolated from one
1311switches (ISL, or inter switch link), and multiple ports connecting to 1644another. One reason to employ a topology such as this is for an
1312the outside world ("port3" on each switch). There is no technical 1645isolated network with many hosts (a cluster configured for high
1313reason that this could not be extended to a third switch. 1646performance, for example), using multiple smaller switches can be more
1314 1647cost effective than a single larger switch, e.g., on a network with 24
131512.2.1 Bonding Mode Selection for Multiple Switch Topology 1648hosts, three 24 port switches can be significantly less expensive than
1316---------------------------------------------------------- 1649a single 72 port switch.
1317 1650
1318 In a topology such as this, the active-backup and broadcast 1651 If access beyond the network is required, an individual host
1319modes are the only useful bonding modes; the other modes require all 1652can be equipped with an additional network device connected to an
1320links to terminate on the same peer for them to behave rationally. 1653external network; this host then additionally acts as a gateway.
1321 1654
1322active-backup: This is generally the preferred mode, particularly if 165513.2.1 MT Bonding Mode Selection for Multiple Switch Topology
1323 the switches have an ISL and play together well. If the
1324 network configuration is such that one switch is specifically
1325 a backup switch (e.g., has lower capacity, higher cost, etc),
1326 then the primary option can be used to insure that the
1327 preferred link is always used when it is available.
1328
1329broadcast: This mode is really a special purpose mode, and is suitable
1330 only for very specific needs. For example, if the two
1331 switches are not connected (no ISL), and the networks beyond
1332 them are totally independant. In this case, if it is
1333 necessary for some specific one-way traffic to reach both
1334 independent networks, then the broadcast mode may be suitable.
1335
133612.2.2 Link Monitoring Selection for Multiple Switch Topology
1337------------------------------------------------------------- 1656-------------------------------------------------------------
1338 1657
1339 The choice of link monitoring ultimately depends upon your 1658 In actual practice, the bonding mode typically employed in
1340switch. If the switch can reliably fail ports in response to other 1659configurations of this type is balance-rr. Historically, in this
1341failures, then either the MII or ARP monitors should work. For 1660network configuration, the usual caveats about out of order packet
1342example, in the above example, if the "port3" link fails at the remote 1661delivery are mitigated by the use of network adapters that do not do
1343end, the MII monitor has no direct means to detect this. The ARP 1662any kind of packet coalescing (via the use of NAPI, or because the
1344monitor could be configured with a target at the remote end of port3, 1663device itself does not generate interrupts until some number of
1345thus detecting that failure without switch support. 1664packets has arrived). When employed in this fashion, the balance-rr
1665mode allows individual connections between two hosts to effectively
1666utilize greater than one interface's bandwidth.
1346 1667
1347 In general, however, in a multiple switch topology, the ARP 166813.2.2 MT Link Monitoring for Multiple Switch Topology
1348monitor can provide a higher level of reliability in detecting link 1669------------------------------------------------------
1349failures. Additionally, it should be configured with multiple targets
1350(at least one for each switch in the network). This will insure that,
1351regardless of which switch is active, the ARP monitor has a suitable
1352target to query.
1353 1670
1671 Again, in actual practice, the MII monitor is most often used
1672in this configuration, as performance is given preference over
1673availability. The ARP monitor will function in this topology, but its
1674advantages over the MII monitor are mitigated by the volume of probes
1675needed as the number of systems involved grows (remember that each
1676host in the network is configured with bonding).
1354 1677
135512.3 Switch Behavior Issues for High Availability 167814. Switch Behavior Issues
1356------------------------------------------------- 1679==========================
1357 1680
1358 You may encounter issues with the timing of link up and down 168114.1 Link Establishment and Failover Delays
1359reporting by the switch. 1682-------------------------------------------
1683
1684 Some switches exhibit undesirable behavior with regard to the
1685timing of link up and down reporting by the switch.
1360 1686
1361 First, when a link comes up, some switches may indicate that 1687 First, when a link comes up, some switches may indicate that
1362the link is up (carrier available), but not pass traffic over the 1688the link is up (carrier available), but not pass traffic over the
@@ -1370,30 +1696,70 @@ relevant interface(s).
1370 Second, some switches may "bounce" the link state one or more 1696 Second, some switches may "bounce" the link state one or more
1371times while a link is changing state. This occurs most commonly while 1697times while a link is changing state. This occurs most commonly while
1372the switch is initializing. Again, an appropriate updelay value may 1698the switch is initializing. Again, an appropriate updelay value may
1373help, but note that if all links are down, then updelay is ignored 1699help.
1374when any link becomes active (the slave closest to completing its
1375updelay is chosen).
1376 1700
1377 Note that when a bonding interface has no active links, the 1701 Note that when a bonding interface has no active links, the
1378driver will immediately reuse the first link that goes up, even if 1702driver will immediately reuse the first link that goes up, even if the
1379updelay parameter was specified. If there are slave interfaces 1703updelay parameter has been specified (the updelay is ignored in this
1380waiting for the updelay timeout to expire, the interface that first 1704case). If there are slave interfaces waiting for the updelay timeout
1381went into that state will be immediately reused. This reduces down 1705to expire, the interface that first went into that state will be
1382time of the network if the value of updelay has been overestimated. 1706immediately reused. This reduces down time of the network if the
1707value of updelay has been overestimated, and since this occurs only in
1708cases with no connectivity, there is no additional penalty for
1709ignoring the updelay.
1383 1710
1384 In addition to the concerns about switch timings, if your 1711 In addition to the concerns about switch timings, if your
1385switches take a long time to go into backup mode, it may be desirable 1712switches take a long time to go into backup mode, it may be desirable
1386to not activate a backup interface immediately after a link goes down. 1713to not activate a backup interface immediately after a link goes down.
1387Failover may be delayed via the downdelay bonding module option. 1714Failover may be delayed via the downdelay bonding module option.
1388 1715
138913. Hardware Specific Considerations 171614.2 Duplicated Incoming Packets
1717--------------------------------
1718
1719 It is not uncommon to observe a short burst of duplicated
1720traffic when the bonding device is first used, or after it has been
1721idle for some period of time. This is most easily observed by issuing
1722a "ping" to some other host on the network, and noticing that the
1723output from ping flags duplicates (typically one per slave).
1724
1725 For example, on a bond in active-backup mode with five slaves
1726all connected to one switch, the output may appear as follows:
1727
1728# ping -n 10.0.4.2
1729PING 10.0.4.2 (10.0.4.2) from 10.0.3.10 : 56(84) bytes of data.
173064 bytes from 10.0.4.2: icmp_seq=1 ttl=64 time=13.7 ms
173164 bytes from 10.0.4.2: icmp_seq=1 ttl=64 time=13.8 ms (DUP!)
173264 bytes from 10.0.4.2: icmp_seq=1 ttl=64 time=13.8 ms (DUP!)
173364 bytes from 10.0.4.2: icmp_seq=1 ttl=64 time=13.8 ms (DUP!)
173464 bytes from 10.0.4.2: icmp_seq=1 ttl=64 time=13.8 ms (DUP!)
173564 bytes from 10.0.4.2: icmp_seq=2 ttl=64 time=0.216 ms
173664 bytes from 10.0.4.2: icmp_seq=3 ttl=64 time=0.267 ms
173764 bytes from 10.0.4.2: icmp_seq=4 ttl=64 time=0.222 ms
1738
1739 This is not due to an error in the bonding driver, rather, it
1740is a side effect of how many switches update their MAC forwarding
1741tables. Initially, the switch does not associate the MAC address in
1742the packet with a particular switch port, and so it may send the
1743traffic to all ports until its MAC forwarding table is updated. Since
1744the interfaces attached to the bond may occupy multiple ports on a
1745single switch, when the switch (temporarily) floods the traffic to all
1746ports, the bond device receives multiple copies of the same packet
1747(one per slave device).
1748
1749 The duplicated packet behavior is switch dependent, some
1750switches exhibit this, and some do not. On switches that display this
1751behavior, it can be induced by clearing the MAC forwarding table (on
1752most Cisco switches, the privileged command "clear mac address-table
1753dynamic" will accomplish this).
1754
175515. Hardware Specific Considerations
1390==================================== 1756====================================
1391 1757
1392 This section contains additional information for configuring 1758 This section contains additional information for configuring
1393bonding on specific hardware platforms, or for interfacing bonding 1759bonding on specific hardware platforms, or for interfacing bonding
1394with particular switches or other devices. 1760with particular switches or other devices.
1395 1761
139613.1 IBM BladeCenter 176215.1 IBM BladeCenter
1397-------------------- 1763--------------------
1398 1764
1399 This applies to the JS20 and similar systems. 1765 This applies to the JS20 and similar systems.
@@ -1407,12 +1773,12 @@ JS20 network adapter information
1407-------------------------------- 1773--------------------------------
1408 1774
1409 All JS20s come with two Broadcom Gigabit Ethernet ports 1775 All JS20s come with two Broadcom Gigabit Ethernet ports
1410integrated on the planar. In the BladeCenter chassis, the eth0 port 1776integrated on the planar (that's "motherboard" in IBM-speak). In the
1411of all JS20 blades is hard wired to I/O Module #1; similarly, all eth1 1777BladeCenter chassis, the eth0 port of all JS20 blades is hard wired to
1412ports are wired to I/O Module #2. An add-on Broadcom daughter card 1778I/O Module #1; similarly, all eth1 ports are wired to I/O Module #2.
1413can be installed on a JS20 to provide two more Gigabit Ethernet ports. 1779An add-on Broadcom daughter card can be installed on a JS20 to provide
1414These ports, eth2 and eth3, are wired to I/O Modules 3 and 4, 1780two more Gigabit Ethernet ports. These ports, eth2 and eth3, are
1415respectively. 1781wired to I/O Modules 3 and 4, respectively.
1416 1782
1417 Each I/O Module may contain either a switch or a passthrough 1783 Each I/O Module may contain either a switch or a passthrough
1418module (which allows ports to be directly connected to an external 1784module (which allows ports to be directly connected to an external
@@ -1432,29 +1798,30 @@ BladeCenter networking configuration
1432of ways, this discussion will be confined to describing basic 1798of ways, this discussion will be confined to describing basic
1433configurations. 1799configurations.
1434 1800
1435 Normally, Ethernet Switch Modules (ESM) are used in I/O 1801 Normally, Ethernet Switch Modules (ESMs) are used in I/O
1436modules 1 and 2. In this configuration, the eth0 and eth1 ports of a 1802modules 1 and 2. In this configuration, the eth0 and eth1 ports of a
1437JS20 will be connected to different internal switches (in the 1803JS20 will be connected to different internal switches (in the
1438respective I/O modules). 1804respective I/O modules).
1439 1805
1440 An optical passthru module (OPM) connects the I/O module 1806 A passthrough module (OPM or CPM, optical or copper,
1441directly to an external switch. By using OPMs in I/O module #1 and 1807passthrough module) connects the I/O module directly to an external
1442#2, the eth0 and eth1 interfaces of a JS20 can be redirected to the 1808switch. By using PMs in I/O module #1 and #2, the eth0 and eth1
1443outside world and connected to a common external switch. 1809interfaces of a JS20 can be redirected to the outside world and
1444 1810connected to a common external switch.
1445 Depending upon the mix of ESM and OPM modules, the network 1811
1446will appear to bonding as either a single switch topology (all OPM 1812 Depending upon the mix of ESMs and PMs, the network will
1447modules) or as a multiple switch topology (one or more ESM modules, 1813appear to bonding as either a single switch topology (all PMs) or as a
1448zero or more OPM modules). It is also possible to connect ESM modules 1814multiple switch topology (one or more ESMs, zero or more PMs). It is
1449together, resulting in a configuration much like the example in "High 1815also possible to connect ESMs together, resulting in a configuration
1450Availability in a multiple switch topology." 1816much like the example in "High Availability in a Multiple Switch
1451 1817Topology," above.
1452Requirements for specifc modes 1818
1453------------------------------ 1819Requirements for specific modes
1454 1820-------------------------------
1455 The balance-rr mode requires the use of OPM modules for 1821
1456devices in the bond, all connected to an common external switch. That 1822 The balance-rr mode requires the use of passthrough modules
1457switch must be configured for "etherchannel" or "trunking" on the 1823for devices in the bond, all connected to an common external switch.
1824That switch must be configured for "etherchannel" or "trunking" on the
1458appropriate ports, as is usual for balance-rr. 1825appropriate ports, as is usual for balance-rr.
1459 1826
1460 The balance-alb and balance-tlb modes will function with 1827 The balance-alb and balance-tlb modes will function with
@@ -1484,17 +1851,18 @@ connected to the JS20 system.
1484Other concerns 1851Other concerns
1485-------------- 1852--------------
1486 1853
1487 The Serial Over LAN link is established over the primary 1854 The Serial Over LAN (SoL) link is established over the primary
1488ethernet (eth0) only, therefore, any loss of link to eth0 will result 1855ethernet (eth0) only, therefore, any loss of link to eth0 will result
1489in losing your SoL connection. It will not fail over with other 1856in losing your SoL connection. It will not fail over with other
1490network traffic. 1857network traffic, as the SoL system is beyond the control of the
1858bonding driver.
1491 1859
1492 It may be desirable to disable spanning tree on the switch 1860 It may be desirable to disable spanning tree on the switch
1493(either the internal Ethernet Switch Module, or an external switch) to 1861(either the internal Ethernet Switch Module, or an external switch) to
1494avoid fail-over delays issues when using bonding. 1862avoid fail-over delay issues when using bonding.
1495 1863
1496 1864
149714. Frequently Asked Questions 186516. Frequently Asked Questions
1498============================== 1866==============================
1499 1867
15001. Is it SMP safe? 18681. Is it SMP safe?
@@ -1505,8 +1873,8 @@ The new driver was designed to be SMP safe from the start.
15052. What type of cards will work with it? 18732. What type of cards will work with it?
1506 1874
1507 Any Ethernet type cards (you can even mix cards - a Intel 1875 Any Ethernet type cards (you can even mix cards - a Intel
1508EtherExpress PRO/100 and a 3com 3c905b, for example). They need not 1876EtherExpress PRO/100 and a 3com 3c905b, for example). For most modes,
1509be of the same speed. 1877devices need not be of the same speed.
1510 1878
15113. How many bonding devices can I have? 18793. How many bonding devices can I have?
1512 1880
@@ -1524,11 +1892,12 @@ system.
1524disabled. The active-backup mode will fail over to a backup link, and 1892disabled. The active-backup mode will fail over to a backup link, and
1525other modes will ignore the failed link. The link will continue to be 1893other modes will ignore the failed link. The link will continue to be
1526monitored, and should it recover, it will rejoin the bond (in whatever 1894monitored, and should it recover, it will rejoin the bond (in whatever
1527manner is appropriate for the mode). See the section on High 1895manner is appropriate for the mode). See the sections on High
1528Availability for additional information. 1896Availability and the documentation for each mode for additional
1897information.
1529 1898
1530 Link monitoring can be enabled via either the miimon or 1899 Link monitoring can be enabled via either the miimon or
1531arp_interval paramters (described in the module paramters section, 1900arp_interval parameters (described in the module parameters section,
1532above). In general, miimon monitors the carrier state as sensed by 1901above). In general, miimon monitors the carrier state as sensed by
1533the underlying network device, and the arp monitor (arp_interval) 1902the underlying network device, and the arp monitor (arp_interval)
1534monitors connectivity to another host on the local network. 1903monitors connectivity to another host on the local network.
@@ -1536,7 +1905,7 @@ monitors connectivity to another host on the local network.
1536 If no link monitoring is configured, the bonding driver will 1905 If no link monitoring is configured, the bonding driver will
1537be unable to detect link failures, and will assume that all links are 1906be unable to detect link failures, and will assume that all links are
1538always available. This will likely result in lost packets, and a 1907always available. This will likely result in lost packets, and a
1539resulting degredation of performance. The precise performance loss 1908resulting degradation of performance. The precise performance loss
1540depends upon the bonding mode and network configuration. 1909depends upon the bonding mode and network configuration.
1541 1910
15426. Can bonding be used for High Availability? 19116. Can bonding be used for High Availability?
@@ -1550,12 +1919,12 @@ depends upon the bonding mode and network configuration.
1550 In the basic balance modes (balance-rr and balance-xor), it 1919 In the basic balance modes (balance-rr and balance-xor), it
1551works with any system that supports etherchannel (also called 1920works with any system that supports etherchannel (also called
1552trunking). Most managed switches currently available have such 1921trunking). Most managed switches currently available have such
1553support, and many unmananged switches as well. 1922support, and many unmanaged switches as well.
1554 1923
1555 The advanced balance modes (balance-tlb and balance-alb) do 1924 The advanced balance modes (balance-tlb and balance-alb) do
1556not have special switch requirements, but do need device drivers that 1925not have special switch requirements, but do need device drivers that
1557support specific features (described in the appropriate section under 1926support specific features (described in the appropriate section under
1558module paramters, above). 1927module parameters, above).
1559 1928
1560 In 802.3ad mode, it works with with systems that support IEEE 1929 In 802.3ad mode, it works with with systems that support IEEE
1561802.3ad Dynamic Link Aggregation. Most managed and many unmanaged 1930802.3ad Dynamic Link Aggregation. Most managed and many unmanaged
@@ -1565,17 +1934,19 @@ switches currently available support 802.3ad.
1565 1934
15668. Where does a bonding device get its MAC address from? 19358. Where does a bonding device get its MAC address from?
1567 1936
1568 If not explicitly configured with ifconfig, the MAC address of 1937 If not explicitly configured (with ifconfig or ip link), the
1569the bonding device is taken from its first slave device. This MAC 1938MAC address of the bonding device is taken from its first slave
1570address is then passed to all following slaves and remains persistent 1939device. This MAC address is then passed to all following slaves and
1571(even if the the first slave is removed) until the bonding device is 1940remains persistent (even if the the first slave is removed) until the
1572brought down or reconfigured. 1941bonding device is brought down or reconfigured.
1573 1942
1574 If you wish to change the MAC address, you can set it with 1943 If you wish to change the MAC address, you can set it with
1575ifconfig: 1944ifconfig or ip link:
1576 1945
1577# ifconfig bond0 hw ether 00:11:22:33:44:55 1946# ifconfig bond0 hw ether 00:11:22:33:44:55
1578 1947
1948# ip link set bond0 address 66:77:88:99:aa:bb
1949
1579 The MAC address can be also changed by bringing down/up the 1950 The MAC address can be also changed by bringing down/up the
1580device and then changing its slaves (or their order): 1951device and then changing its slaves (or their order):
1581 1952
@@ -1591,23 +1962,28 @@ from the bond (`ifenslave -d bond0 eth0'). The bonding driver will
1591then restore the MAC addresses that the slaves had before they were 1962then restore the MAC addresses that the slaves had before they were
1592enslaved. 1963enslaved.
1593 1964
159415. Resources and Links 196516. Resources and Links
1595======================= 1966=======================
1596 1967
1597The latest version of the bonding driver can be found in the latest 1968The latest version of the bonding driver can be found in the latest
1598version of the linux kernel, found on http://kernel.org 1969version of the linux kernel, found on http://kernel.org
1599 1970
1971The latest version of this document can be found in either the latest
1972kernel source (named Documentation/networking/bonding.txt), or on the
1973bonding sourceforge site:
1974
1975http://www.sourceforge.net/projects/bonding
1976
1600Discussions regarding the bonding driver take place primarily on the 1977Discussions regarding the bonding driver take place primarily on the
1601bonding-devel mailing list, hosted at sourceforge.net. If you have 1978bonding-devel mailing list, hosted at sourceforge.net. If you have
1602questions or problems, post them to the list. 1979questions or problems, post them to the list. The list address is:
1603 1980
1604bonding-devel@lists.sourceforge.net 1981bonding-devel@lists.sourceforge.net
1605 1982
1606https://lists.sourceforge.net/lists/listinfo/bonding-devel 1983 The administrative interface (to subscribe or unsubscribe) can
1607 1984be found at:
1608There is also a project site on sourceforge.
1609 1985
1610http://www.sourceforge.net/projects/bonding 1986https://lists.sourceforge.net/lists/listinfo/bonding-devel
1611 1987
1612Donald Becker's Ethernet Drivers and diag programs may be found at : 1988Donald Becker's Ethernet Drivers and diag programs may be found at :
1613 - http://www.scyld.com/network/ 1989 - http://www.scyld.com/network/
diff --git a/Documentation/video4linux/CARDLIST.cx88 b/Documentation/video4linux/CARDLIST.cx88
index 6d44958289de..03deb0726aa4 100644
--- a/Documentation/video4linux/CARDLIST.cx88
+++ b/Documentation/video4linux/CARDLIST.cx88
@@ -29,3 +29,4 @@ card=27 - PixelView PlayTV Ultra Pro (Stereo)
29card=28 - DViCO FusionHDTV 3 Gold-T 29card=28 - DViCO FusionHDTV 3 Gold-T
30card=29 - ADS Tech Instant TV DVB-T PCI 30card=29 - ADS Tech Instant TV DVB-T PCI
31card=30 - TerraTec Cinergy 1400 DVB-T 31card=30 - TerraTec Cinergy 1400 DVB-T
32card=31 - DViCO FusionHDTV 5 Gold
diff --git a/Documentation/video4linux/CARDLIST.tuner b/Documentation/video4linux/CARDLIST.tuner
index d1b9d21ffd89..f3302e1b1b9c 100644
--- a/Documentation/video4linux/CARDLIST.tuner
+++ b/Documentation/video4linux/CARDLIST.tuner
@@ -62,3 +62,5 @@ tuner=60 - Thomson DDT 7611 (ATSC/NTSC)
62tuner=61 - Tena TNF9533-D/IF/TNF9533-B/DF 62tuner=61 - Tena TNF9533-D/IF/TNF9533-B/DF
63tuner=62 - Philips TEA5767HN FM Radio 63tuner=62 - Philips TEA5767HN FM Radio
64tuner=63 - Philips FMD1216ME MK3 Hybrid Tuner 64tuner=63 - Philips FMD1216ME MK3 Hybrid Tuner
65tuner=64 - LG TDVS-H062F/TUA6034
66tuner=65 - Ymec TVF66T5-B/DFF
diff --git a/Documentation/video4linux/bttv/Insmod-options b/Documentation/video4linux/bttv/Insmod-options
index 7bb5a50b0779..fc94ff235ffa 100644
--- a/Documentation/video4linux/bttv/Insmod-options
+++ b/Documentation/video4linux/bttv/Insmod-options
@@ -44,6 +44,9 @@ bttv.o
44 push used by bttv. bttv will disable overlay 44 push used by bttv. bttv will disable overlay
45 by default on this hardware to avoid crashes. 45 by default on this hardware to avoid crashes.
46 With this insmod option you can override this. 46 With this insmod option you can override this.
47 no_overlay=1 Disable overlay. It should be used by broken
48 hardware that doesn't support PCI2PCI direct
49 transfers.
47 automute=0/1 Automatically mutes the sound if there is 50 automute=0/1 Automatically mutes the sound if there is
48 no TV signal, on by default. You might try 51 no TV signal, on by default. You might try
49 to disable this if you have bad input signal 52 to disable this if you have bad input signal
diff --git a/MAINTAINERS b/MAINTAINERS
index ec8433c39dee..c31ddc4bcdd6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1521,6 +1521,12 @@ P: Zach Brown
1521M: zab@zabbo.net 1521M: zab@zabbo.net
1522S: Odd Fixes 1522S: Odd Fixes
1523 1523
1524MAN-PAGES: MANUAL PAGES FOR LINUX -- Sections 2, 3, 4, 5, and 7
1525P: Michael Kerrisk
1526M: mtk-manpages@gmx.net
1527W: ftp://ftp.kernel.org/pub/linux/docs/manpages
1528S: Maintained
1529
1524MARVELL MV64340 ETHERNET DRIVER 1530MARVELL MV64340 ETHERNET DRIVER
1525P: Manish Lachwani 1531P: Manish Lachwani
1526M: Manish_Lachwani@pmc-sierra.com 1532M: Manish_Lachwani@pmc-sierra.com
diff --git a/Makefile b/Makefile
index 717b9b9192d5..0196b209bb19 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 2 1VERSION = 2
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 13 3SUBLEVEL = 13
4EXTRAVERSION =-rc4 4EXTRAVERSION =-rc5
5NAME=Woozy Numbat 5NAME=Woozy Numbat
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arm/mach-ixp4xx/coyote-setup.c b/arch/arm/mach-ixp4xx/coyote-setup.c
index 4ff4393ef0ea..7f58afb27e71 100644
--- a/arch/arm/mach-ixp4xx/coyote-setup.c
+++ b/arch/arm/mach-ixp4xx/coyote-setup.c
@@ -61,7 +61,7 @@ static struct plat_serial8250_port coyote_uart_data[] = {
61 .mapbase = IXP4XX_UART2_BASE_PHYS, 61 .mapbase = IXP4XX_UART2_BASE_PHYS,
62 .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET, 62 .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
63 .irq = IRQ_IXP4XX_UART2, 63 .irq = IRQ_IXP4XX_UART2,
64 .flags = UPF_BOOT_AUTOCONF, 64 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
65 .iotype = UPIO_MEM, 65 .iotype = UPIO_MEM,
66 .regshift = 2, 66 .regshift = 2,
67 .uartclk = IXP4XX_UART_XTAL, 67 .uartclk = IXP4XX_UART_XTAL,
diff --git a/arch/arm/mach-ixp4xx/gtwx5715-setup.c b/arch/arm/mach-ixp4xx/gtwx5715-setup.c
index 8ba1cd9406e7..65e356bd10d6 100644
--- a/arch/arm/mach-ixp4xx/gtwx5715-setup.c
+++ b/arch/arm/mach-ixp4xx/gtwx5715-setup.c
@@ -83,7 +83,7 @@ static struct plat_serial8250_port gtwx5715_uart_platform_data[] = {
83 .mapbase = IXP4XX_UART2_BASE_PHYS, 83 .mapbase = IXP4XX_UART2_BASE_PHYS,
84 .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET, 84 .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
85 .irq = IRQ_IXP4XX_UART2, 85 .irq = IRQ_IXP4XX_UART2,
86 .flags = UPF_BOOT_AUTOCONF, 86 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
87 .iotype = UPIO_MEM, 87 .iotype = UPIO_MEM,
88 .regshift = 2, 88 .regshift = 2,
89 .uartclk = IXP4XX_UART_XTAL, 89 .uartclk = IXP4XX_UART_XTAL,
diff --git a/arch/arm/mach-ixp4xx/ixdp425-setup.c b/arch/arm/mach-ixp4xx/ixdp425-setup.c
index c2ba759e9946..4633470a6a37 100644
--- a/arch/arm/mach-ixp4xx/ixdp425-setup.c
+++ b/arch/arm/mach-ixp4xx/ixdp425-setup.c
@@ -82,7 +82,7 @@ static struct plat_serial8250_port ixdp425_uart_data[] = {
82 .mapbase = IXP4XX_UART1_BASE_PHYS, 82 .mapbase = IXP4XX_UART1_BASE_PHYS,
83 .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET, 83 .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
84 .irq = IRQ_IXP4XX_UART1, 84 .irq = IRQ_IXP4XX_UART1,
85 .flags = UPF_BOOT_AUTOCONF, 85 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
86 .iotype = UPIO_MEM, 86 .iotype = UPIO_MEM,
87 .regshift = 2, 87 .regshift = 2,
88 .uartclk = IXP4XX_UART_XTAL, 88 .uartclk = IXP4XX_UART_XTAL,
@@ -91,7 +91,7 @@ static struct plat_serial8250_port ixdp425_uart_data[] = {
91 .mapbase = IXP4XX_UART2_BASE_PHYS, 91 .mapbase = IXP4XX_UART2_BASE_PHYS,
92 .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET, 92 .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
93 .irq = IRQ_IXP4XX_UART1, 93 .irq = IRQ_IXP4XX_UART1,
94 .flags = UPF_BOOT_AUTOCONF, 94 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
95 .iotype = UPIO_MEM, 95 .iotype = UPIO_MEM,
96 .regshift = 2, 96 .regshift = 2,
97 .uartclk = IXP4XX_UART_XTAL, 97 .uartclk = IXP4XX_UART_XTAL,
diff --git a/arch/arm/mach-s3c2410/mach-bast.c b/arch/arm/mach-s3c2410/mach-bast.c
index 1e7f343822d0..e9182242da95 100644
--- a/arch/arm/mach-s3c2410/mach-bast.c
+++ b/arch/arm/mach-s3c2410/mach-bast.c
@@ -30,6 +30,7 @@
30 * 28-Jun-2005 BJD Moved pm functionality out to common code 30 * 28-Jun-2005 BJD Moved pm functionality out to common code
31 * 17-Jul-2005 BJD Changed to platform device for SuperIO 16550s 31 * 17-Jul-2005 BJD Changed to platform device for SuperIO 16550s
32 * 25-Jul-2005 BJD Removed ASIX static mappings 32 * 25-Jul-2005 BJD Removed ASIX static mappings
33 * 27-Jul-2005 BJD Ensure maximum frequency of i2c bus
33*/ 34*/
34 35
35#include <linux/kernel.h> 36#include <linux/kernel.h>
@@ -60,6 +61,7 @@
60#include <asm/arch/regs-mem.h> 61#include <asm/arch/regs-mem.h>
61#include <asm/arch/regs-lcd.h> 62#include <asm/arch/regs-lcd.h>
62#include <asm/arch/nand.h> 63#include <asm/arch/nand.h>
64#include <asm/arch/iic.h>
63 65
64#include <linux/mtd/mtd.h> 66#include <linux/mtd/mtd.h>
65#include <linux/mtd/nand.h> 67#include <linux/mtd/nand.h>
@@ -304,7 +306,7 @@ static void bast_nand_select(struct s3c2410_nand_set *set, int slot)
304} 306}
305 307
306static struct s3c2410_platform_nand bast_nand_info = { 308static struct s3c2410_platform_nand bast_nand_info = {
307 .tacls = 80, 309 .tacls = 40,
308 .twrph0 = 80, 310 .twrph0 = 80,
309 .twrph1 = 80, 311 .twrph1 = 80,
310 .nr_sets = ARRAY_SIZE(bast_nand_sets), 312 .nr_sets = ARRAY_SIZE(bast_nand_sets),
@@ -385,6 +387,17 @@ static struct platform_device bast_sio = {
385 }, 387 },
386}; 388};
387 389
390/* we have devices on the bus which cannot work much over the
391 * standard 100KHz i2c bus frequency
392*/
393
394static struct s3c2410_platform_i2c bast_i2c_info = {
395 .flags = 0,
396 .slave_addr = 0x10,
397 .bus_freq = 100*1000,
398 .max_freq = 130*1000,
399};
400
388/* Standard BAST devices */ 401/* Standard BAST devices */
389 402
390static struct platform_device *bast_devices[] __initdata = { 403static struct platform_device *bast_devices[] __initdata = {
@@ -431,6 +444,7 @@ void __init bast_map_io(void)
431 s3c24xx_uclk.parent = &s3c24xx_clkout1; 444 s3c24xx_uclk.parent = &s3c24xx_clkout1;
432 445
433 s3c_device_nand.dev.platform_data = &bast_nand_info; 446 s3c_device_nand.dev.platform_data = &bast_nand_info;
447 s3c_device_i2c.dev.platform_data = &bast_i2c_info;
434 448
435 s3c24xx_init_io(bast_iodesc, ARRAY_SIZE(bast_iodesc)); 449 s3c24xx_init_io(bast_iodesc, ARRAY_SIZE(bast_iodesc));
436 s3c24xx_init_clocks(0); 450 s3c24xx_init_clocks(0);
diff --git a/arch/arm/mach-sa1100/jornada720.c b/arch/arm/mach-sa1100/jornada720.c
index eee3cbc5ec4f..2f497112c96a 100644
--- a/arch/arm/mach-sa1100/jornada720.c
+++ b/arch/arm/mach-sa1100/jornada720.c
@@ -97,6 +97,7 @@ static void __init jornada720_map_io(void)
97} 97}
98 98
99MACHINE_START(JORNADA720, "HP Jornada 720") 99MACHINE_START(JORNADA720, "HP Jornada 720")
100 /* Maintainer: Michael Gernoth <michael@gernoth.net> */
100 .phys_ram = 0xc0000000, 101 .phys_ram = 0xc0000000,
101 .phys_io = 0x80000000, 102 .phys_io = 0x80000000,
102 .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc, 103 .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc,
diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
index 65bfe84b6d67..0b6c4db44e08 100644
--- a/arch/arm/mm/fault.c
+++ b/arch/arm/mm/fault.c
@@ -238,9 +238,9 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
238 up_read(&mm->mmap_sem); 238 up_read(&mm->mmap_sem);
239 239
240 /* 240 /*
241 * Handle the "normal" case first 241 * Handle the "normal" case first - VM_FAULT_MAJOR / VM_FAULT_MINOR
242 */ 242 */
243 if (fault > 0) 243 if (fault >= VM_FAULT_MINOR)
244 return 0; 244 return 0;
245 245
246 /* 246 /*
@@ -261,7 +261,7 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
261 do_exit(SIGKILL); 261 do_exit(SIGKILL);
262 return 0; 262 return 0;
263 263
264 case 0: 264 case VM_FAULT_SIGBUS:
265 /* 265 /*
266 * We had some memory, but were unable to 266 * We had some memory, but were unable to
267 * successfully fix up this page fault. 267 * successfully fix up this page fault.
diff --git a/arch/arm/mm/proc-xscale.S b/arch/arm/mm/proc-xscale.S
index 2d977b4eeeab..b88de2700146 100644
--- a/arch/arm/mm/proc-xscale.S
+++ b/arch/arm/mm/proc-xscale.S
@@ -370,142 +370,6 @@ ENTRY(cpu_xscale_dcache_clean_area)
370 bhi 1b 370 bhi 1b
371 mov pc, lr 371 mov pc, lr
372 372
373/* ================================ CACHE LOCKING============================
374 *
375 * The XScale MicroArchitecture implements support for locking entries into
376 * the data and instruction cache. The following functions implement the core
377 * low level instructions needed to accomplish the locking. The developer's
378 * manual states that the code that performs the locking must be in non-cached
379 * memory. To accomplish this, the code in xscale-cache-lock.c copies the
380 * following functions from the cache into a non-cached memory region that
381 * is allocated through consistent_alloc().
382 *
383 */
384 .align 5
385/*
386 * xscale_icache_lock
387 *
388 * r0: starting address to lock
389 * r1: end address to lock
390 */
391ENTRY(xscale_icache_lock)
392
393iLockLoop:
394 bic r0, r0, #CACHELINESIZE - 1
395 mcr p15, 0, r0, c9, c1, 0 @ lock into cache
396 cmp r0, r1 @ are we done?
397 add r0, r0, #CACHELINESIZE @ advance to next cache line
398 bls iLockLoop
399 mov pc, lr
400
401/*
402 * xscale_icache_unlock
403 */
404ENTRY(xscale_icache_unlock)
405 mcr p15, 0, r0, c9, c1, 1 @ Unlock icache
406 mov pc, lr
407
408/*
409 * xscale_dcache_lock
410 *
411 * r0: starting address to lock
412 * r1: end address to lock
413 */
414ENTRY(xscale_dcache_lock)
415 mcr p15, 0, ip, c7, c10, 4 @ Drain Write (& Fill) Buffer
416 mov r2, #1
417 mcr p15, 0, r2, c9, c2, 0 @ Put dcache in lock mode
418 cpwait ip @ Wait for completion
419
420 mrs r2, cpsr
421 orr r3, r2, #PSR_F_BIT | PSR_I_BIT
422dLockLoop:
423 msr cpsr_c, r3
424 mcr p15, 0, r0, c7, c10, 1 @ Write back line if it is dirty
425 mcr p15, 0, r0, c7, c6, 1 @ Flush/invalidate line
426 msr cpsr_c, r2
427 ldr ip, [r0], #CACHELINESIZE @ Preload 32 bytes into cache from
428 @ location [r0]. Post-increment
429 @ r3 to next cache line
430 cmp r0, r1 @ Are we done?
431 bls dLockLoop
432
433 mcr p15, 0, ip, c7, c10, 4 @ Drain Write (& Fill) Buffer
434 mov r2, #0
435 mcr p15, 0, r2, c9, c2, 0 @ Get out of lock mode
436 cpwait_ret lr, ip
437
438/*
439 * xscale_dcache_unlock
440 */
441ENTRY(xscale_dcache_unlock)
442 mcr p15, 0, ip, c7, c10, 4 @ Drain Write (& Fill) Buffer
443 mcr p15, 0, ip, c9, c2, 1 @ Unlock cache
444 mov pc, lr
445
446/*
447 * Needed to determine the length of the code that needs to be copied.
448 */
449 .align 5
450ENTRY(xscale_cache_dummy)
451 mov pc, lr
452
453/* ================================ TLB LOCKING==============================
454 *
455 * The XScale MicroArchitecture implements support for locking entries into
456 * the Instruction and Data TLBs. The following functions provide the
457 * low level support for supporting these under Linux. xscale-lock.c
458 * implements some higher level management code. Most of the following
459 * is taken straight out of the Developer's Manual.
460 */
461
462/*
463 * Lock I-TLB entry
464 *
465 * r0: Virtual address to translate and lock
466 */
467 .align 5
468ENTRY(xscale_itlb_lock)
469 mrs r2, cpsr
470 orr r3, r2, #PSR_F_BIT | PSR_I_BIT
471 msr cpsr_c, r3 @ Disable interrupts
472 mcr p15, 0, r0, c8, c5, 1 @ Invalidate I-TLB entry
473 mcr p15, 0, r0, c10, c4, 0 @ Translate and lock
474 msr cpsr_c, r2 @ Restore interrupts
475 cpwait_ret lr, ip
476
477/*
478 * Lock D-TLB entry
479 *
480 * r0: Virtual address to translate and lock
481 */
482 .align 5
483ENTRY(xscale_dtlb_lock)
484 mrs r2, cpsr
485 orr r3, r2, #PSR_F_BIT | PSR_I_BIT
486 msr cpsr_c, r3 @ Disable interrupts
487 mcr p15, 0, r0, c8, c6, 1 @ Invalidate D-TLB entry
488 mcr p15, 0, r0, c10, c8, 0 @ Translate and lock
489 msr cpsr_c, r2 @ Restore interrupts
490 cpwait_ret lr, ip
491
492/*
493 * Unlock all I-TLB entries
494 */
495 .align 5
496ENTRY(xscale_itlb_unlock)
497 mcr p15, 0, ip, c10, c4, 1 @ Unlock I-TLB
498 mcr p15, 0, ip, c8, c5, 0 @ Invalidate I-TLB
499 cpwait_ret lr, ip
500
501/*
502 * Unlock all D-TLB entries
503 */
504ENTRY(xscale_dtlb_unlock)
505 mcr p15, 0, ip, c10, c8, 1 @ Unlock D-TBL
506 mcr p15, 0, ip, c8, c6, 0 @ Invalidate D-TLB
507 cpwait_ret lr, ip
508
509/* =============================== PageTable ============================== */ 373/* =============================== PageTable ============================== */
510 374
511#define PTE_CACHE_WRITE_ALLOCATE 0 375#define PTE_CACHE_WRITE_ALLOCATE 0
diff --git a/arch/arm/nwfpe/double_cpdo.c b/arch/arm/nwfpe/double_cpdo.c
index 7ffd8cb9bc96..c51d1386a97c 100644
--- a/arch/arm/nwfpe/double_cpdo.c
+++ b/arch/arm/nwfpe/double_cpdo.c
@@ -40,17 +40,17 @@ float64 float64_arccos(float64 rFm);
40float64 float64_pow(float64 rFn, float64 rFm); 40float64 float64_pow(float64 rFn, float64 rFm);
41float64 float64_pol(float64 rFn, float64 rFm); 41float64 float64_pol(float64 rFn, float64 rFm);
42 42
43static float64 float64_rsf(float64 rFn, float64 rFm) 43static float64 float64_rsf(struct roundingData *roundData, float64 rFn, float64 rFm)
44{ 44{
45 return float64_sub(rFm, rFn); 45 return float64_sub(roundData, rFm, rFn);
46} 46}
47 47
48static float64 float64_rdv(float64 rFn, float64 rFm) 48static float64 float64_rdv(struct roundingData *roundData, float64 rFn, float64 rFm)
49{ 49{
50 return float64_div(rFm, rFn); 50 return float64_div(roundData, rFm, rFn);
51} 51}
52 52
53static float64 (*const dyadic_double[16])(float64 rFn, float64 rFm) = { 53static float64 (*const dyadic_double[16])(struct roundingData*, float64 rFn, float64 rFm) = {
54 [ADF_CODE >> 20] = float64_add, 54 [ADF_CODE >> 20] = float64_add,
55 [MUF_CODE >> 20] = float64_mul, 55 [MUF_CODE >> 20] = float64_mul,
56 [SUF_CODE >> 20] = float64_sub, 56 [SUF_CODE >> 20] = float64_sub,
@@ -65,12 +65,12 @@ static float64 (*const dyadic_double[16])(float64 rFn, float64 rFm) = {
65 [FRD_CODE >> 20] = float64_rdv, 65 [FRD_CODE >> 20] = float64_rdv,
66}; 66};
67 67
68static float64 float64_mvf(float64 rFm) 68static float64 float64_mvf(struct roundingData *roundData,float64 rFm)
69{ 69{
70 return rFm; 70 return rFm;
71} 71}
72 72
73static float64 float64_mnf(float64 rFm) 73static float64 float64_mnf(struct roundingData *roundData,float64 rFm)
74{ 74{
75 union float64_components u; 75 union float64_components u;
76 76
@@ -84,7 +84,7 @@ static float64 float64_mnf(float64 rFm)
84 return u.f64; 84 return u.f64;
85} 85}
86 86
87static float64 float64_abs(float64 rFm) 87static float64 float64_abs(struct roundingData *roundData,float64 rFm)
88{ 88{
89 union float64_components u; 89 union float64_components u;
90 90
@@ -98,7 +98,7 @@ static float64 float64_abs(float64 rFm)
98 return u.f64; 98 return u.f64;
99} 99}
100 100
101static float64 (*const monadic_double[16])(float64 rFm) = { 101static float64 (*const monadic_double[16])(struct roundingData *, float64 rFm) = {
102 [MVF_CODE >> 20] = float64_mvf, 102 [MVF_CODE >> 20] = float64_mvf,
103 [MNF_CODE >> 20] = float64_mnf, 103 [MNF_CODE >> 20] = float64_mnf,
104 [ABS_CODE >> 20] = float64_abs, 104 [ABS_CODE >> 20] = float64_abs,
@@ -108,7 +108,7 @@ static float64 (*const monadic_double[16])(float64 rFm) = {
108 [NRM_CODE >> 20] = float64_mvf, 108 [NRM_CODE >> 20] = float64_mvf,
109}; 109};
110 110
111unsigned int DoubleCPDO(const unsigned int opcode, FPREG * rFd) 111unsigned int DoubleCPDO(struct roundingData *roundData, const unsigned int opcode, FPREG * rFd)
112{ 112{
113 FPA11 *fpa11 = GET_FPA11(); 113 FPA11 *fpa11 = GET_FPA11();
114 float64 rFm; 114 float64 rFm;
@@ -151,13 +151,13 @@ unsigned int DoubleCPDO(const unsigned int opcode, FPREG * rFd)
151 } 151 }
152 152
153 if (dyadic_double[opc_mask_shift]) { 153 if (dyadic_double[opc_mask_shift]) {
154 rFd->fDouble = dyadic_double[opc_mask_shift](rFn, rFm); 154 rFd->fDouble = dyadic_double[opc_mask_shift](roundData, rFn, rFm);
155 } else { 155 } else {
156 return 0; 156 return 0;
157 } 157 }
158 } else { 158 } else {
159 if (monadic_double[opc_mask_shift]) { 159 if (monadic_double[opc_mask_shift]) {
160 rFd->fDouble = monadic_double[opc_mask_shift](rFm); 160 rFd->fDouble = monadic_double[opc_mask_shift](roundData, rFm);
161 } else { 161 } else {
162 return 0; 162 return 0;
163 } 163 }
diff --git a/arch/arm/nwfpe/extended_cpdo.c b/arch/arm/nwfpe/extended_cpdo.c
index c39f68a3449e..65a279ba927f 100644
--- a/arch/arm/nwfpe/extended_cpdo.c
+++ b/arch/arm/nwfpe/extended_cpdo.c
@@ -35,17 +35,17 @@ floatx80 floatx80_arccos(floatx80 rFm);
35floatx80 floatx80_pow(floatx80 rFn, floatx80 rFm); 35floatx80 floatx80_pow(floatx80 rFn, floatx80 rFm);
36floatx80 floatx80_pol(floatx80 rFn, floatx80 rFm); 36floatx80 floatx80_pol(floatx80 rFn, floatx80 rFm);
37 37
38static floatx80 floatx80_rsf(floatx80 rFn, floatx80 rFm) 38static floatx80 floatx80_rsf(struct roundingData *roundData, floatx80 rFn, floatx80 rFm)
39{ 39{
40 return floatx80_sub(rFm, rFn); 40 return floatx80_sub(roundData, rFm, rFn);
41} 41}
42 42
43static floatx80 floatx80_rdv(floatx80 rFn, floatx80 rFm) 43static floatx80 floatx80_rdv(struct roundingData *roundData, floatx80 rFn, floatx80 rFm)
44{ 44{
45 return floatx80_div(rFm, rFn); 45 return floatx80_div(roundData, rFm, rFn);
46} 46}
47 47
48static floatx80 (*const dyadic_extended[16])(floatx80 rFn, floatx80 rFm) = { 48static floatx80 (*const dyadic_extended[16])(struct roundingData*, floatx80 rFn, floatx80 rFm) = {
49 [ADF_CODE >> 20] = floatx80_add, 49 [ADF_CODE >> 20] = floatx80_add,
50 [MUF_CODE >> 20] = floatx80_mul, 50 [MUF_CODE >> 20] = floatx80_mul,
51 [SUF_CODE >> 20] = floatx80_sub, 51 [SUF_CODE >> 20] = floatx80_sub,
@@ -60,24 +60,24 @@ static floatx80 (*const dyadic_extended[16])(floatx80 rFn, floatx80 rFm) = {
60 [FRD_CODE >> 20] = floatx80_rdv, 60 [FRD_CODE >> 20] = floatx80_rdv,
61}; 61};
62 62
63static floatx80 floatx80_mvf(floatx80 rFm) 63static floatx80 floatx80_mvf(struct roundingData *roundData, floatx80 rFm)
64{ 64{
65 return rFm; 65 return rFm;
66} 66}
67 67
68static floatx80 floatx80_mnf(floatx80 rFm) 68static floatx80 floatx80_mnf(struct roundingData *roundData, floatx80 rFm)
69{ 69{
70 rFm.high ^= 0x8000; 70 rFm.high ^= 0x8000;
71 return rFm; 71 return rFm;
72} 72}
73 73
74static floatx80 floatx80_abs(floatx80 rFm) 74static floatx80 floatx80_abs(struct roundingData *roundData, floatx80 rFm)
75{ 75{
76 rFm.high &= 0x7fff; 76 rFm.high &= 0x7fff;
77 return rFm; 77 return rFm;
78} 78}
79 79
80static floatx80 (*const monadic_extended[16])(floatx80 rFm) = { 80static floatx80 (*const monadic_extended[16])(struct roundingData*, floatx80 rFm) = {
81 [MVF_CODE >> 20] = floatx80_mvf, 81 [MVF_CODE >> 20] = floatx80_mvf,
82 [MNF_CODE >> 20] = floatx80_mnf, 82 [MNF_CODE >> 20] = floatx80_mnf,
83 [ABS_CODE >> 20] = floatx80_abs, 83 [ABS_CODE >> 20] = floatx80_abs,
@@ -87,7 +87,7 @@ static floatx80 (*const monadic_extended[16])(floatx80 rFm) = {
87 [NRM_CODE >> 20] = floatx80_mvf, 87 [NRM_CODE >> 20] = floatx80_mvf,
88}; 88};
89 89
90unsigned int ExtendedCPDO(const unsigned int opcode, FPREG * rFd) 90unsigned int ExtendedCPDO(struct roundingData *roundData, const unsigned int opcode, FPREG * rFd)
91{ 91{
92 FPA11 *fpa11 = GET_FPA11(); 92 FPA11 *fpa11 = GET_FPA11();
93 floatx80 rFm; 93 floatx80 rFm;
@@ -138,13 +138,13 @@ unsigned int ExtendedCPDO(const unsigned int opcode, FPREG * rFd)
138 } 138 }
139 139
140 if (dyadic_extended[opc_mask_shift]) { 140 if (dyadic_extended[opc_mask_shift]) {
141 rFd->fExtended = dyadic_extended[opc_mask_shift](rFn, rFm); 141 rFd->fExtended = dyadic_extended[opc_mask_shift](roundData, rFn, rFm);
142 } else { 142 } else {
143 return 0; 143 return 0;
144 } 144 }
145 } else { 145 } else {
146 if (monadic_extended[opc_mask_shift]) { 146 if (monadic_extended[opc_mask_shift]) {
147 rFd->fExtended = monadic_extended[opc_mask_shift](rFm); 147 rFd->fExtended = monadic_extended[opc_mask_shift](roundData, rFm);
148 } else { 148 } else {
149 return 0; 149 return 0;
150 } 150 }
diff --git a/arch/arm/nwfpe/fpa11.c b/arch/arm/nwfpe/fpa11.c
index bf61696865ec..7690f731ee87 100644
--- a/arch/arm/nwfpe/fpa11.c
+++ b/arch/arm/nwfpe/fpa11.c
@@ -51,48 +51,42 @@ static void resetFPA11(void)
51 fpa11->fpsr = FP_EMULATOR | BIT_AC; 51 fpa11->fpsr = FP_EMULATOR | BIT_AC;
52} 52}
53 53
54void SetRoundingMode(const unsigned int opcode) 54int8 SetRoundingMode(const unsigned int opcode)
55{ 55{
56 switch (opcode & MASK_ROUNDING_MODE) { 56 switch (opcode & MASK_ROUNDING_MODE) {
57 default: 57 default:
58 case ROUND_TO_NEAREST: 58 case ROUND_TO_NEAREST:
59 float_rounding_mode = float_round_nearest_even; 59 return float_round_nearest_even;
60 break;
61 60
62 case ROUND_TO_PLUS_INFINITY: 61 case ROUND_TO_PLUS_INFINITY:
63 float_rounding_mode = float_round_up; 62 return float_round_up;
64 break;
65 63
66 case ROUND_TO_MINUS_INFINITY: 64 case ROUND_TO_MINUS_INFINITY:
67 float_rounding_mode = float_round_down; 65 return float_round_down;
68 break;
69 66
70 case ROUND_TO_ZERO: 67 case ROUND_TO_ZERO:
71 float_rounding_mode = float_round_to_zero; 68 return float_round_to_zero;
72 break;
73 } 69 }
74} 70}
75 71
76void SetRoundingPrecision(const unsigned int opcode) 72int8 SetRoundingPrecision(const unsigned int opcode)
77{ 73{
78#ifdef CONFIG_FPE_NWFPE_XP 74#ifdef CONFIG_FPE_NWFPE_XP
79 switch (opcode & MASK_ROUNDING_PRECISION) { 75 switch (opcode & MASK_ROUNDING_PRECISION) {
80 case ROUND_SINGLE: 76 case ROUND_SINGLE:
81 floatx80_rounding_precision = 32; 77 return 32;
82 break;
83 78
84 case ROUND_DOUBLE: 79 case ROUND_DOUBLE:
85 floatx80_rounding_precision = 64; 80 return 64;
86 break;
87 81
88 case ROUND_EXTENDED: 82 case ROUND_EXTENDED:
89 floatx80_rounding_precision = 80; 83 return 80;
90 break;
91 84
92 default: 85 default:
93 floatx80_rounding_precision = 80; 86 return 80;
94 } 87 }
95#endif 88#endif
89 return 80;
96} 90}
97 91
98void nwfpe_init_fpa(union fp_state *fp) 92void nwfpe_init_fpa(union fp_state *fp)
@@ -103,8 +97,6 @@ void nwfpe_init_fpa(union fp_state *fp)
103#endif 97#endif
104 memset(fpa11, 0, sizeof(FPA11)); 98 memset(fpa11, 0, sizeof(FPA11));
105 resetFPA11(); 99 resetFPA11();
106 SetRoundingMode(ROUND_TO_NEAREST);
107 SetRoundingPrecision(ROUND_EXTENDED);
108 fpa11->initflag = 1; 100 fpa11->initflag = 1;
109} 101}
110 102
diff --git a/arch/arm/nwfpe/fpa11.h b/arch/arm/nwfpe/fpa11.h
index e4a61aea534b..93523ae4b7a1 100644
--- a/arch/arm/nwfpe/fpa11.h
+++ b/arch/arm/nwfpe/fpa11.h
@@ -37,6 +37,13 @@
37/* includes */ 37/* includes */
38#include "fpsr.h" /* FP control and status register definitions */ 38#include "fpsr.h" /* FP control and status register definitions */
39#include "milieu.h" 39#include "milieu.h"
40
41struct roundingData {
42 int8 mode;
43 int8 precision;
44 signed char exception;
45};
46
40#include "softfloat.h" 47#include "softfloat.h"
41 48
42#define typeNone 0x00 49#define typeNone 0x00
@@ -84,8 +91,8 @@ typedef struct tagFPA11 {
84 initialised. */ 91 initialised. */
85} FPA11; 92} FPA11;
86 93
87extern void SetRoundingMode(const unsigned int); 94extern int8 SetRoundingMode(const unsigned int);
88extern void SetRoundingPrecision(const unsigned int); 95extern int8 SetRoundingPrecision(const unsigned int);
89extern void nwfpe_init_fpa(union fp_state *fp); 96extern void nwfpe_init_fpa(union fp_state *fp);
90 97
91#endif 98#endif
diff --git a/arch/arm/nwfpe/fpa11_cpdo.c b/arch/arm/nwfpe/fpa11_cpdo.c
index 1bea67437b6f..4a31dfd94068 100644
--- a/arch/arm/nwfpe/fpa11_cpdo.c
+++ b/arch/arm/nwfpe/fpa11_cpdo.c
@@ -24,15 +24,16 @@
24#include "fpa11.h" 24#include "fpa11.h"
25#include "fpopcode.h" 25#include "fpopcode.h"
26 26
27unsigned int SingleCPDO(const unsigned int opcode, FPREG * rFd); 27unsigned int SingleCPDO(struct roundingData *roundData, const unsigned int opcode, FPREG * rFd);
28unsigned int DoubleCPDO(const unsigned int opcode, FPREG * rFd); 28unsigned int DoubleCPDO(struct roundingData *roundData, const unsigned int opcode, FPREG * rFd);
29unsigned int ExtendedCPDO(const unsigned int opcode, FPREG * rFd); 29unsigned int ExtendedCPDO(struct roundingData *roundData, const unsigned int opcode, FPREG * rFd);
30 30
31unsigned int EmulateCPDO(const unsigned int opcode) 31unsigned int EmulateCPDO(const unsigned int opcode)
32{ 32{
33 FPA11 *fpa11 = GET_FPA11(); 33 FPA11 *fpa11 = GET_FPA11();
34 FPREG *rFd; 34 FPREG *rFd;
35 unsigned int nType, nDest, nRc; 35 unsigned int nType, nDest, nRc;
36 struct roundingData roundData;
36 37
37 /* Get the destination size. If not valid let Linux perform 38 /* Get the destination size. If not valid let Linux perform
38 an invalid instruction trap. */ 39 an invalid instruction trap. */
@@ -40,7 +41,9 @@ unsigned int EmulateCPDO(const unsigned int opcode)
40 if (typeNone == nDest) 41 if (typeNone == nDest)
41 return 0; 42 return 0;
42 43
43 SetRoundingMode(opcode); 44 roundData.mode = SetRoundingMode(opcode);
45 roundData.precision = SetRoundingPrecision(opcode);
46 roundData.exception = 0;
44 47
45 /* Compare the size of the operands in Fn and Fm. 48 /* Compare the size of the operands in Fn and Fm.
46 Choose the largest size and perform operations in that size, 49 Choose the largest size and perform operations in that size,
@@ -63,14 +66,14 @@ unsigned int EmulateCPDO(const unsigned int opcode)
63 66
64 switch (nType) { 67 switch (nType) {
65 case typeSingle: 68 case typeSingle:
66 nRc = SingleCPDO(opcode, rFd); 69 nRc = SingleCPDO(&roundData, opcode, rFd);
67 break; 70 break;
68 case typeDouble: 71 case typeDouble:
69 nRc = DoubleCPDO(opcode, rFd); 72 nRc = DoubleCPDO(&roundData, opcode, rFd);
70 break; 73 break;
71#ifdef CONFIG_FPE_NWFPE_XP 74#ifdef CONFIG_FPE_NWFPE_XP
72 case typeExtended: 75 case typeExtended:
73 nRc = ExtendedCPDO(opcode, rFd); 76 nRc = ExtendedCPDO(&roundData, opcode, rFd);
74 break; 77 break;
75#endif 78#endif
76 default: 79 default:
@@ -93,9 +96,9 @@ unsigned int EmulateCPDO(const unsigned int opcode)
93 case typeSingle: 96 case typeSingle:
94 { 97 {
95 if (typeDouble == nType) 98 if (typeDouble == nType)
96 rFd->fSingle = float64_to_float32(rFd->fDouble); 99 rFd->fSingle = float64_to_float32(&roundData, rFd->fDouble);
97 else 100 else
98 rFd->fSingle = floatx80_to_float32(rFd->fExtended); 101 rFd->fSingle = floatx80_to_float32(&roundData, rFd->fExtended);
99 } 102 }
100 break; 103 break;
101 104
@@ -104,7 +107,7 @@ unsigned int EmulateCPDO(const unsigned int opcode)
104 if (typeSingle == nType) 107 if (typeSingle == nType)
105 rFd->fDouble = float32_to_float64(rFd->fSingle); 108 rFd->fDouble = float32_to_float64(rFd->fSingle);
106 else 109 else
107 rFd->fDouble = floatx80_to_float64(rFd->fExtended); 110 rFd->fDouble = floatx80_to_float64(&roundData, rFd->fExtended);
108 } 111 }
109 break; 112 break;
110 113
@@ -121,12 +124,15 @@ unsigned int EmulateCPDO(const unsigned int opcode)
121#else 124#else
122 if (nDest != nType) { 125 if (nDest != nType) {
123 if (nDest == typeSingle) 126 if (nDest == typeSingle)
124 rFd->fSingle = float64_to_float32(rFd->fDouble); 127 rFd->fSingle = float64_to_float32(&roundData, rFd->fDouble);
125 else 128 else
126 rFd->fDouble = float32_to_float64(rFd->fSingle); 129 rFd->fDouble = float32_to_float64(rFd->fSingle);
127 } 130 }
128#endif 131#endif
129 } 132 }
130 133
134 if (roundData.exception)
135 float_raise(roundData.exception);
136
131 return nRc; 137 return nRc;
132} 138}
diff --git a/arch/arm/nwfpe/fpa11_cpdt.c b/arch/arm/nwfpe/fpa11_cpdt.c
index 95fb63fa9d18..b0db5cbcc3b1 100644
--- a/arch/arm/nwfpe/fpa11_cpdt.c
+++ b/arch/arm/nwfpe/fpa11_cpdt.c
@@ -96,7 +96,7 @@ static inline void loadMultiple(const unsigned int Fn, const unsigned int __user
96 } 96 }
97} 97}
98 98
99static inline void storeSingle(const unsigned int Fn, unsigned int __user *pMem) 99static inline void storeSingle(struct roundingData *roundData, const unsigned int Fn, unsigned int __user *pMem)
100{ 100{
101 FPA11 *fpa11 = GET_FPA11(); 101 FPA11 *fpa11 = GET_FPA11();
102 union { 102 union {
@@ -106,12 +106,12 @@ static inline void storeSingle(const unsigned int Fn, unsigned int __user *pMem)
106 106
107 switch (fpa11->fType[Fn]) { 107 switch (fpa11->fType[Fn]) {
108 case typeDouble: 108 case typeDouble:
109 val.f = float64_to_float32(fpa11->fpreg[Fn].fDouble); 109 val.f = float64_to_float32(roundData, fpa11->fpreg[Fn].fDouble);
110 break; 110 break;
111 111
112#ifdef CONFIG_FPE_NWFPE_XP 112#ifdef CONFIG_FPE_NWFPE_XP
113 case typeExtended: 113 case typeExtended:
114 val.f = floatx80_to_float32(fpa11->fpreg[Fn].fExtended); 114 val.f = floatx80_to_float32(roundData, fpa11->fpreg[Fn].fExtended);
115 break; 115 break;
116#endif 116#endif
117 117
@@ -122,7 +122,7 @@ static inline void storeSingle(const unsigned int Fn, unsigned int __user *pMem)
122 put_user(val.i[0], pMem); 122 put_user(val.i[0], pMem);
123} 123}
124 124
125static inline void storeDouble(const unsigned int Fn, unsigned int __user *pMem) 125static inline void storeDouble(struct roundingData *roundData, const unsigned int Fn, unsigned int __user *pMem)
126{ 126{
127 FPA11 *fpa11 = GET_FPA11(); 127 FPA11 *fpa11 = GET_FPA11();
128 union { 128 union {
@@ -137,7 +137,7 @@ static inline void storeDouble(const unsigned int Fn, unsigned int __user *pMem)
137 137
138#ifdef CONFIG_FPE_NWFPE_XP 138#ifdef CONFIG_FPE_NWFPE_XP
139 case typeExtended: 139 case typeExtended:
140 val.f = floatx80_to_float64(fpa11->fpreg[Fn].fExtended); 140 val.f = floatx80_to_float64(roundData, fpa11->fpreg[Fn].fExtended);
141 break; 141 break;
142#endif 142#endif
143 143
@@ -259,8 +259,11 @@ unsigned int PerformSTF(const unsigned int opcode)
259{ 259{
260 unsigned int __user *pBase, *pAddress, *pFinal; 260 unsigned int __user *pBase, *pAddress, *pFinal;
261 unsigned int nRc = 1, write_back = WRITE_BACK(opcode); 261 unsigned int nRc = 1, write_back = WRITE_BACK(opcode);
262 struct roundingData roundData;
262 263
263 SetRoundingMode(ROUND_TO_NEAREST); 264 roundData.mode = SetRoundingMode(opcode);
265 roundData.precision = SetRoundingPrecision(opcode);
266 roundData.exception = 0;
264 267
265 pBase = (unsigned int __user *) readRegister(getRn(opcode)); 268 pBase = (unsigned int __user *) readRegister(getRn(opcode));
266 if (REG_PC == getRn(opcode)) { 269 if (REG_PC == getRn(opcode)) {
@@ -281,10 +284,10 @@ unsigned int PerformSTF(const unsigned int opcode)
281 284
282 switch (opcode & MASK_TRANSFER_LENGTH) { 285 switch (opcode & MASK_TRANSFER_LENGTH) {
283 case TRANSFER_SINGLE: 286 case TRANSFER_SINGLE:
284 storeSingle(getFd(opcode), pAddress); 287 storeSingle(&roundData, getFd(opcode), pAddress);
285 break; 288 break;
286 case TRANSFER_DOUBLE: 289 case TRANSFER_DOUBLE:
287 storeDouble(getFd(opcode), pAddress); 290 storeDouble(&roundData, getFd(opcode), pAddress);
288 break; 291 break;
289#ifdef CONFIG_FPE_NWFPE_XP 292#ifdef CONFIG_FPE_NWFPE_XP
290 case TRANSFER_EXTENDED: 293 case TRANSFER_EXTENDED:
@@ -295,6 +298,9 @@ unsigned int PerformSTF(const unsigned int opcode)
295 nRc = 0; 298 nRc = 0;
296 } 299 }
297 300
301 if (roundData.exception)
302 float_raise(roundData.exception);
303
298 if (write_back) 304 if (write_back)
299 writeRegister(getRn(opcode), (unsigned long) pFinal); 305 writeRegister(getRn(opcode), (unsigned long) pFinal);
300 return nRc; 306 return nRc;
diff --git a/arch/arm/nwfpe/fpa11_cprt.c b/arch/arm/nwfpe/fpa11_cprt.c
index db01fbc97216..adf8d3000540 100644
--- a/arch/arm/nwfpe/fpa11_cprt.c
+++ b/arch/arm/nwfpe/fpa11_cprt.c
@@ -33,8 +33,6 @@ extern flag floatx80_is_nan(floatx80);
33extern flag float64_is_nan(float64); 33extern flag float64_is_nan(float64);
34extern flag float32_is_nan(float32); 34extern flag float32_is_nan(float32);
35 35
36void SetRoundingMode(const unsigned int opcode);
37
38unsigned int PerformFLT(const unsigned int opcode); 36unsigned int PerformFLT(const unsigned int opcode);
39unsigned int PerformFIX(const unsigned int opcode); 37unsigned int PerformFIX(const unsigned int opcode);
40 38
@@ -77,14 +75,17 @@ unsigned int EmulateCPRT(const unsigned int opcode)
77unsigned int PerformFLT(const unsigned int opcode) 75unsigned int PerformFLT(const unsigned int opcode)
78{ 76{
79 FPA11 *fpa11 = GET_FPA11(); 77 FPA11 *fpa11 = GET_FPA11();
80 SetRoundingMode(opcode); 78 struct roundingData roundData;
81 SetRoundingPrecision(opcode); 79
80 roundData.mode = SetRoundingMode(opcode);
81 roundData.precision = SetRoundingPrecision(opcode);
82 roundData.exception = 0;
82 83
83 switch (opcode & MASK_ROUNDING_PRECISION) { 84 switch (opcode & MASK_ROUNDING_PRECISION) {
84 case ROUND_SINGLE: 85 case ROUND_SINGLE:
85 { 86 {
86 fpa11->fType[getFn(opcode)] = typeSingle; 87 fpa11->fType[getFn(opcode)] = typeSingle;
87 fpa11->fpreg[getFn(opcode)].fSingle = int32_to_float32(readRegister(getRd(opcode))); 88 fpa11->fpreg[getFn(opcode)].fSingle = int32_to_float32(&roundData, readRegister(getRd(opcode)));
88 } 89 }
89 break; 90 break;
90 91
@@ -108,6 +109,9 @@ unsigned int PerformFLT(const unsigned int opcode)
108 return 0; 109 return 0;
109 } 110 }
110 111
112 if (roundData.exception)
113 float_raise(roundData.exception);
114
111 return 1; 115 return 1;
112} 116}
113 117
@@ -115,26 +119,29 @@ unsigned int PerformFIX(const unsigned int opcode)
115{ 119{
116 FPA11 *fpa11 = GET_FPA11(); 120 FPA11 *fpa11 = GET_FPA11();
117 unsigned int Fn = getFm(opcode); 121 unsigned int Fn = getFm(opcode);
122 struct roundingData roundData;
118 123
119 SetRoundingMode(opcode); 124 roundData.mode = SetRoundingMode(opcode);
125 roundData.precision = SetRoundingPrecision(opcode);
126 roundData.exception = 0;
120 127
121 switch (fpa11->fType[Fn]) { 128 switch (fpa11->fType[Fn]) {
122 case typeSingle: 129 case typeSingle:
123 { 130 {
124 writeRegister(getRd(opcode), float32_to_int32(fpa11->fpreg[Fn].fSingle)); 131 writeRegister(getRd(opcode), float32_to_int32(&roundData, fpa11->fpreg[Fn].fSingle));
125 } 132 }
126 break; 133 break;
127 134
128 case typeDouble: 135 case typeDouble:
129 { 136 {
130 writeRegister(getRd(opcode), float64_to_int32(fpa11->fpreg[Fn].fDouble)); 137 writeRegister(getRd(opcode), float64_to_int32(&roundData, fpa11->fpreg[Fn].fDouble));
131 } 138 }
132 break; 139 break;
133 140
134#ifdef CONFIG_FPE_NWFPE_XP 141#ifdef CONFIG_FPE_NWFPE_XP
135 case typeExtended: 142 case typeExtended:
136 { 143 {
137 writeRegister(getRd(opcode), floatx80_to_int32(fpa11->fpreg[Fn].fExtended)); 144 writeRegister(getRd(opcode), floatx80_to_int32(&roundData, fpa11->fpreg[Fn].fExtended));
138 } 145 }
139 break; 146 break;
140#endif 147#endif
@@ -143,6 +150,9 @@ unsigned int PerformFIX(const unsigned int opcode)
143 return 0; 150 return 0;
144 } 151 }
145 152
153 if (roundData.exception)
154 float_raise(roundData.exception);
155
146 return 1; 156 return 1;
147} 157}
148 158
diff --git a/arch/arm/nwfpe/fpmodule.c b/arch/arm/nwfpe/fpmodule.c
index 12885f31d347..2dfe1ac42ee8 100644
--- a/arch/arm/nwfpe/fpmodule.c
+++ b/arch/arm/nwfpe/fpmodule.c
@@ -116,8 +116,6 @@ fpmodule.c to integrate with the NetBSD kernel (I hope!).
116code to access data in user space in some other source files at the 116code to access data in user space in some other source files at the
117moment (grep for get_user / put_user calls). --philb] 117moment (grep for get_user / put_user calls). --philb]
118 118
119float_exception_flags is a global variable in SoftFloat.
120
121This function is called by the SoftFloat routines to raise a floating 119This function is called by the SoftFloat routines to raise a floating
122point exception. We check the trap enable byte in the FPSR, and raise 120point exception. We check the trap enable byte in the FPSR, and raise
123a SIGFPE exception if necessary. If not the relevant bits in the 121a SIGFPE exception if necessary. If not the relevant bits in the
@@ -129,15 +127,14 @@ void float_raise(signed char flags)
129 register unsigned int fpsr, cumulativeTraps; 127 register unsigned int fpsr, cumulativeTraps;
130 128
131#ifdef CONFIG_DEBUG_USER 129#ifdef CONFIG_DEBUG_USER
132 printk(KERN_DEBUG 130 /* Ignore inexact errors as there are far too many of them to log */
133 "NWFPE: %s[%d] takes exception %08x at %p from %08lx\n", 131 if (flags & ~BIT_IXC)
134 current->comm, current->pid, flags, 132 printk(KERN_DEBUG
135 __builtin_return_address(0), GET_USERREG()->ARM_pc); 133 "NWFPE: %s[%d] takes exception %08x at %p from %08lx\n",
134 current->comm, current->pid, flags,
135 __builtin_return_address(0), GET_USERREG()->ARM_pc);
136#endif 136#endif
137 137
138 /* Keep SoftFloat exception flags up to date. */
139 float_exception_flags |= flags;
140
141 /* Read fpsr and initialize the cumulativeTraps. */ 138 /* Read fpsr and initialize the cumulativeTraps. */
142 fpsr = readFPSR(); 139 fpsr = readFPSR();
143 cumulativeTraps = 0; 140 cumulativeTraps = 0;
diff --git a/arch/arm/nwfpe/single_cpdo.c b/arch/arm/nwfpe/single_cpdo.c
index 705808e88d9d..c66981d682cf 100644
--- a/arch/arm/nwfpe/single_cpdo.c
+++ b/arch/arm/nwfpe/single_cpdo.c
@@ -36,17 +36,17 @@ float32 float32_arccos(float32 rFm);
36float32 float32_pow(float32 rFn, float32 rFm); 36float32 float32_pow(float32 rFn, float32 rFm);
37float32 float32_pol(float32 rFn, float32 rFm); 37float32 float32_pol(float32 rFn, float32 rFm);
38 38
39static float32 float32_rsf(float32 rFn, float32 rFm) 39static float32 float32_rsf(struct roundingData *roundData, float32 rFn, float32 rFm)
40{ 40{
41 return float32_sub(rFm, rFn); 41 return float32_sub(roundData, rFm, rFn);
42} 42}
43 43
44static float32 float32_rdv(float32 rFn, float32 rFm) 44static float32 float32_rdv(struct roundingData *roundData, float32 rFn, float32 rFm)
45{ 45{
46 return float32_div(rFm, rFn); 46 return float32_div(roundData, rFm, rFn);
47} 47}
48 48
49static float32 (*const dyadic_single[16])(float32 rFn, float32 rFm) = { 49static float32 (*const dyadic_single[16])(struct roundingData *, float32 rFn, float32 rFm) = {
50 [ADF_CODE >> 20] = float32_add, 50 [ADF_CODE >> 20] = float32_add,
51 [MUF_CODE >> 20] = float32_mul, 51 [MUF_CODE >> 20] = float32_mul,
52 [SUF_CODE >> 20] = float32_sub, 52 [SUF_CODE >> 20] = float32_sub,
@@ -60,22 +60,22 @@ static float32 (*const dyadic_single[16])(float32 rFn, float32 rFm) = {
60 [FRD_CODE >> 20] = float32_rdv, 60 [FRD_CODE >> 20] = float32_rdv,
61}; 61};
62 62
63static float32 float32_mvf(float32 rFm) 63static float32 float32_mvf(struct roundingData *roundData, float32 rFm)
64{ 64{
65 return rFm; 65 return rFm;
66} 66}
67 67
68static float32 float32_mnf(float32 rFm) 68static float32 float32_mnf(struct roundingData *roundData, float32 rFm)
69{ 69{
70 return rFm ^ 0x80000000; 70 return rFm ^ 0x80000000;
71} 71}
72 72
73static float32 float32_abs(float32 rFm) 73static float32 float32_abs(struct roundingData *roundData, float32 rFm)
74{ 74{
75 return rFm & 0x7fffffff; 75 return rFm & 0x7fffffff;
76} 76}
77 77
78static float32 (*const monadic_single[16])(float32 rFm) = { 78static float32 (*const monadic_single[16])(struct roundingData*, float32 rFm) = {
79 [MVF_CODE >> 20] = float32_mvf, 79 [MVF_CODE >> 20] = float32_mvf,
80 [MNF_CODE >> 20] = float32_mnf, 80 [MNF_CODE >> 20] = float32_mnf,
81 [ABS_CODE >> 20] = float32_abs, 81 [ABS_CODE >> 20] = float32_abs,
@@ -85,7 +85,7 @@ static float32 (*const monadic_single[16])(float32 rFm) = {
85 [NRM_CODE >> 20] = float32_mvf, 85 [NRM_CODE >> 20] = float32_mvf,
86}; 86};
87 87
88unsigned int SingleCPDO(const unsigned int opcode, FPREG * rFd) 88unsigned int SingleCPDO(struct roundingData *roundData, const unsigned int opcode, FPREG * rFd)
89{ 89{
90 FPA11 *fpa11 = GET_FPA11(); 90 FPA11 *fpa11 = GET_FPA11();
91 float32 rFm; 91 float32 rFm;
@@ -108,13 +108,13 @@ unsigned int SingleCPDO(const unsigned int opcode, FPREG * rFd)
108 if (fpa11->fType[Fn] == typeSingle && 108 if (fpa11->fType[Fn] == typeSingle &&
109 dyadic_single[opc_mask_shift]) { 109 dyadic_single[opc_mask_shift]) {
110 rFn = fpa11->fpreg[Fn].fSingle; 110 rFn = fpa11->fpreg[Fn].fSingle;
111 rFd->fSingle = dyadic_single[opc_mask_shift](rFn, rFm); 111 rFd->fSingle = dyadic_single[opc_mask_shift](roundData, rFn, rFm);
112 } else { 112 } else {
113 return 0; 113 return 0;
114 } 114 }
115 } else { 115 } else {
116 if (monadic_single[opc_mask_shift]) { 116 if (monadic_single[opc_mask_shift]) {
117 rFd->fSingle = monadic_single[opc_mask_shift](rFm); 117 rFd->fSingle = monadic_single[opc_mask_shift](roundData, rFm);
118 } else { 118 } else {
119 return 0; 119 return 0;
120 } 120 }
diff --git a/arch/arm/nwfpe/softfloat.c b/arch/arm/nwfpe/softfloat.c
index e038dd3be9b3..8b75a6e7cb3a 100644
--- a/arch/arm/nwfpe/softfloat.c
+++ b/arch/arm/nwfpe/softfloat.c
@@ -36,16 +36,6 @@ this code that are retained.
36 36
37/* 37/*
38------------------------------------------------------------------------------- 38-------------------------------------------------------------------------------
39Floating-point rounding mode, extended double-precision rounding precision,
40and exception flags.
41-------------------------------------------------------------------------------
42*/
43int8 float_rounding_mode = float_round_nearest_even;
44int8 floatx80_rounding_precision = 80;
45int8 float_exception_flags;
46
47/*
48-------------------------------------------------------------------------------
49Primitive arithmetic functions, including multi-word arithmetic, and 39Primitive arithmetic functions, including multi-word arithmetic, and
50division and square root approximations. (Can be specialized to target if 40division and square root approximations. (Can be specialized to target if
51desired.) 41desired.)
@@ -77,14 +67,14 @@ input is too large, however, the invalid exception is raised and the largest
77positive or negative integer is returned. 67positive or negative integer is returned.
78------------------------------------------------------------------------------- 68-------------------------------------------------------------------------------
79*/ 69*/
80static int32 roundAndPackInt32( flag zSign, bits64 absZ ) 70static int32 roundAndPackInt32( struct roundingData *roundData, flag zSign, bits64 absZ )
81{ 71{
82 int8 roundingMode; 72 int8 roundingMode;
83 flag roundNearestEven; 73 flag roundNearestEven;
84 int8 roundIncrement, roundBits; 74 int8 roundIncrement, roundBits;
85 int32 z; 75 int32 z;
86 76
87 roundingMode = float_rounding_mode; 77 roundingMode = roundData->mode;
88 roundNearestEven = ( roundingMode == float_round_nearest_even ); 78 roundNearestEven = ( roundingMode == float_round_nearest_even );
89 roundIncrement = 0x40; 79 roundIncrement = 0x40;
90 if ( ! roundNearestEven ) { 80 if ( ! roundNearestEven ) {
@@ -107,10 +97,10 @@ static int32 roundAndPackInt32( flag zSign, bits64 absZ )
107 z = absZ; 97 z = absZ;
108 if ( zSign ) z = - z; 98 if ( zSign ) z = - z;
109 if ( ( absZ>>32 ) || ( z && ( ( z < 0 ) ^ zSign ) ) ) { 99 if ( ( absZ>>32 ) || ( z && ( ( z < 0 ) ^ zSign ) ) ) {
110 float_exception_flags |= float_flag_invalid; 100 roundData->exception |= float_flag_invalid;
111 return zSign ? 0x80000000 : 0x7FFFFFFF; 101 return zSign ? 0x80000000 : 0x7FFFFFFF;
112 } 102 }
113 if ( roundBits ) float_exception_flags |= float_flag_inexact; 103 if ( roundBits ) roundData->exception |= float_flag_inexact;
114 return z; 104 return z;
115 105
116} 106}
@@ -224,14 +214,14 @@ The handling of underflow and overflow follows the IEC/IEEE Standard for
224Binary Floating-point Arithmetic. 214Binary Floating-point Arithmetic.
225------------------------------------------------------------------------------- 215-------------------------------------------------------------------------------
226*/ 216*/
227static float32 roundAndPackFloat32( flag zSign, int16 zExp, bits32 zSig ) 217static float32 roundAndPackFloat32( struct roundingData *roundData, flag zSign, int16 zExp, bits32 zSig )
228{ 218{
229 int8 roundingMode; 219 int8 roundingMode;
230 flag roundNearestEven; 220 flag roundNearestEven;
231 int8 roundIncrement, roundBits; 221 int8 roundIncrement, roundBits;
232 flag isTiny; 222 flag isTiny;
233 223
234 roundingMode = float_rounding_mode; 224 roundingMode = roundData->mode;
235 roundNearestEven = ( roundingMode == float_round_nearest_even ); 225 roundNearestEven = ( roundingMode == float_round_nearest_even );
236 roundIncrement = 0x40; 226 roundIncrement = 0x40;
237 if ( ! roundNearestEven ) { 227 if ( ! roundNearestEven ) {
@@ -254,7 +244,7 @@ static float32 roundAndPackFloat32( flag zSign, int16 zExp, bits32 zSig )
254 || ( ( zExp == 0xFD ) 244 || ( ( zExp == 0xFD )
255 && ( (sbits32) ( zSig + roundIncrement ) < 0 ) ) 245 && ( (sbits32) ( zSig + roundIncrement ) < 0 ) )
256 ) { 246 ) {
257 float_raise( float_flag_overflow | float_flag_inexact ); 247 roundData->exception |= float_flag_overflow | float_flag_inexact;
258 return packFloat32( zSign, 0xFF, 0 ) - ( roundIncrement == 0 ); 248 return packFloat32( zSign, 0xFF, 0 ) - ( roundIncrement == 0 );
259 } 249 }
260 if ( zExp < 0 ) { 250 if ( zExp < 0 ) {
@@ -265,10 +255,10 @@ static float32 roundAndPackFloat32( flag zSign, int16 zExp, bits32 zSig )
265 shift32RightJamming( zSig, - zExp, &zSig ); 255 shift32RightJamming( zSig, - zExp, &zSig );
266 zExp = 0; 256 zExp = 0;
267 roundBits = zSig & 0x7F; 257 roundBits = zSig & 0x7F;
268 if ( isTiny && roundBits ) float_raise( float_flag_underflow ); 258 if ( isTiny && roundBits ) roundData->exception |= float_flag_underflow;
269 } 259 }
270 } 260 }
271 if ( roundBits ) float_exception_flags |= float_flag_inexact; 261 if ( roundBits ) roundData->exception |= float_flag_inexact;
272 zSig = ( zSig + roundIncrement )>>7; 262 zSig = ( zSig + roundIncrement )>>7;
273 zSig &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven ); 263 zSig &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven );
274 if ( zSig == 0 ) zExp = 0; 264 if ( zSig == 0 ) zExp = 0;
@@ -287,12 +277,12 @@ point exponent.
287------------------------------------------------------------------------------- 277-------------------------------------------------------------------------------
288*/ 278*/
289static float32 279static float32
290 normalizeRoundAndPackFloat32( flag zSign, int16 zExp, bits32 zSig ) 280 normalizeRoundAndPackFloat32( struct roundingData *roundData, flag zSign, int16 zExp, bits32 zSig )
291{ 281{
292 int8 shiftCount; 282 int8 shiftCount;
293 283
294 shiftCount = countLeadingZeros32( zSig ) - 1; 284 shiftCount = countLeadingZeros32( zSig ) - 1;
295 return roundAndPackFloat32( zSign, zExp - shiftCount, zSig<<shiftCount ); 285 return roundAndPackFloat32( roundData, zSign, zExp - shiftCount, zSig<<shiftCount );
296 286
297} 287}
298 288
@@ -395,14 +385,14 @@ The handling of underflow and overflow follows the IEC/IEEE Standard for
395Binary Floating-point Arithmetic. 385Binary Floating-point Arithmetic.
396------------------------------------------------------------------------------- 386-------------------------------------------------------------------------------
397*/ 387*/
398static float64 roundAndPackFloat64( flag zSign, int16 zExp, bits64 zSig ) 388static float64 roundAndPackFloat64( struct roundingData *roundData, flag zSign, int16 zExp, bits64 zSig )
399{ 389{
400 int8 roundingMode; 390 int8 roundingMode;
401 flag roundNearestEven; 391 flag roundNearestEven;
402 int16 roundIncrement, roundBits; 392 int16 roundIncrement, roundBits;
403 flag isTiny; 393 flag isTiny;
404 394
405 roundingMode = float_rounding_mode; 395 roundingMode = roundData->mode;
406 roundNearestEven = ( roundingMode == float_round_nearest_even ); 396 roundNearestEven = ( roundingMode == float_round_nearest_even );
407 roundIncrement = 0x200; 397 roundIncrement = 0x200;
408 if ( ! roundNearestEven ) { 398 if ( ! roundNearestEven ) {
@@ -427,7 +417,7 @@ static float64 roundAndPackFloat64( flag zSign, int16 zExp, bits64 zSig )
427 ) { 417 ) {
428 //register int lr = __builtin_return_address(0); 418 //register int lr = __builtin_return_address(0);
429 //printk("roundAndPackFloat64 called from 0x%08x\n",lr); 419 //printk("roundAndPackFloat64 called from 0x%08x\n",lr);
430 float_raise( float_flag_overflow | float_flag_inexact ); 420 roundData->exception |= float_flag_overflow | float_flag_inexact;
431 return packFloat64( zSign, 0x7FF, 0 ) - ( roundIncrement == 0 ); 421 return packFloat64( zSign, 0x7FF, 0 ) - ( roundIncrement == 0 );
432 } 422 }
433 if ( zExp < 0 ) { 423 if ( zExp < 0 ) {
@@ -438,10 +428,10 @@ static float64 roundAndPackFloat64( flag zSign, int16 zExp, bits64 zSig )
438 shift64RightJamming( zSig, - zExp, &zSig ); 428 shift64RightJamming( zSig, - zExp, &zSig );
439 zExp = 0; 429 zExp = 0;
440 roundBits = zSig & 0x3FF; 430 roundBits = zSig & 0x3FF;
441 if ( isTiny && roundBits ) float_raise( float_flag_underflow ); 431 if ( isTiny && roundBits ) roundData->exception |= float_flag_underflow;
442 } 432 }
443 } 433 }
444 if ( roundBits ) float_exception_flags |= float_flag_inexact; 434 if ( roundBits ) roundData->exception |= float_flag_inexact;
445 zSig = ( zSig + roundIncrement )>>10; 435 zSig = ( zSig + roundIncrement )>>10;
446 zSig &= ~ ( ( ( roundBits ^ 0x200 ) == 0 ) & roundNearestEven ); 436 zSig &= ~ ( ( ( roundBits ^ 0x200 ) == 0 ) & roundNearestEven );
447 if ( zSig == 0 ) zExp = 0; 437 if ( zSig == 0 ) zExp = 0;
@@ -460,12 +450,12 @@ point exponent.
460------------------------------------------------------------------------------- 450-------------------------------------------------------------------------------
461*/ 451*/
462static float64 452static float64
463 normalizeRoundAndPackFloat64( flag zSign, int16 zExp, bits64 zSig ) 453 normalizeRoundAndPackFloat64( struct roundingData *roundData, flag zSign, int16 zExp, bits64 zSig )
464{ 454{
465 int8 shiftCount; 455 int8 shiftCount;
466 456
467 shiftCount = countLeadingZeros64( zSig ) - 1; 457 shiftCount = countLeadingZeros64( zSig ) - 1;
468 return roundAndPackFloat64( zSign, zExp - shiftCount, zSig<<shiftCount ); 458 return roundAndPackFloat64( roundData, zSign, zExp - shiftCount, zSig<<shiftCount );
469 459
470} 460}
471 461
@@ -572,14 +562,15 @@ Floating-point Arithmetic.
572*/ 562*/
573static floatx80 563static floatx80
574 roundAndPackFloatx80( 564 roundAndPackFloatx80(
575 int8 roundingPrecision, flag zSign, int32 zExp, bits64 zSig0, bits64 zSig1 565 struct roundingData *roundData, flag zSign, int32 zExp, bits64 zSig0, bits64 zSig1
576 ) 566 )
577{ 567{
578 int8 roundingMode; 568 int8 roundingMode, roundingPrecision;
579 flag roundNearestEven, increment, isTiny; 569 flag roundNearestEven, increment, isTiny;
580 int64 roundIncrement, roundMask, roundBits; 570 int64 roundIncrement, roundMask, roundBits;
581 571
582 roundingMode = float_rounding_mode; 572 roundingMode = roundData->mode;
573 roundingPrecision = roundData->precision;
583 roundNearestEven = ( roundingMode == float_round_nearest_even ); 574 roundNearestEven = ( roundingMode == float_round_nearest_even );
584 if ( roundingPrecision == 80 ) goto precision80; 575 if ( roundingPrecision == 80 ) goto precision80;
585 if ( roundingPrecision == 64 ) { 576 if ( roundingPrecision == 64 ) {
@@ -623,8 +614,8 @@ static floatx80
623 shift64RightJamming( zSig0, 1 - zExp, &zSig0 ); 614 shift64RightJamming( zSig0, 1 - zExp, &zSig0 );
624 zExp = 0; 615 zExp = 0;
625 roundBits = zSig0 & roundMask; 616 roundBits = zSig0 & roundMask;
626 if ( isTiny && roundBits ) float_raise( float_flag_underflow ); 617 if ( isTiny && roundBits ) roundData->exception |= float_flag_underflow;
627 if ( roundBits ) float_exception_flags |= float_flag_inexact; 618 if ( roundBits ) roundData->exception |= float_flag_inexact;
628 zSig0 += roundIncrement; 619 zSig0 += roundIncrement;
629 if ( (sbits64) zSig0 < 0 ) zExp = 1; 620 if ( (sbits64) zSig0 < 0 ) zExp = 1;
630 roundIncrement = roundMask + 1; 621 roundIncrement = roundMask + 1;
@@ -635,7 +626,7 @@ static floatx80
635 return packFloatx80( zSign, zExp, zSig0 ); 626 return packFloatx80( zSign, zExp, zSig0 );
636 } 627 }
637 } 628 }
638 if ( roundBits ) float_exception_flags |= float_flag_inexact; 629 if ( roundBits ) roundData->exception |= float_flag_inexact;
639 zSig0 += roundIncrement; 630 zSig0 += roundIncrement;
640 if ( zSig0 < roundIncrement ) { 631 if ( zSig0 < roundIncrement ) {
641 ++zExp; 632 ++zExp;
@@ -672,7 +663,7 @@ static floatx80
672 ) { 663 ) {
673 roundMask = 0; 664 roundMask = 0;
674 overflow: 665 overflow:
675 float_raise( float_flag_overflow | float_flag_inexact ); 666 roundData->exception |= float_flag_overflow | float_flag_inexact;
676 if ( ( roundingMode == float_round_to_zero ) 667 if ( ( roundingMode == float_round_to_zero )
677 || ( zSign && ( roundingMode == float_round_up ) ) 668 || ( zSign && ( roundingMode == float_round_up ) )
678 || ( ! zSign && ( roundingMode == float_round_down ) ) 669 || ( ! zSign && ( roundingMode == float_round_down ) )
@@ -689,8 +680,8 @@ static floatx80
689 || ( zSig0 < LIT64( 0xFFFFFFFFFFFFFFFF ) ); 680 || ( zSig0 < LIT64( 0xFFFFFFFFFFFFFFFF ) );
690 shift64ExtraRightJamming( zSig0, zSig1, 1 - zExp, &zSig0, &zSig1 ); 681 shift64ExtraRightJamming( zSig0, zSig1, 1 - zExp, &zSig0, &zSig1 );
691 zExp = 0; 682 zExp = 0;
692 if ( isTiny && zSig1 ) float_raise( float_flag_underflow ); 683 if ( isTiny && zSig1 ) roundData->exception |= float_flag_underflow;
693 if ( zSig1 ) float_exception_flags |= float_flag_inexact; 684 if ( zSig1 ) roundData->exception |= float_flag_inexact;
694 if ( roundNearestEven ) { 685 if ( roundNearestEven ) {
695 increment = ( (sbits64) zSig1 < 0 ); 686 increment = ( (sbits64) zSig1 < 0 );
696 } 687 }
@@ -710,7 +701,7 @@ static floatx80
710 return packFloatx80( zSign, zExp, zSig0 ); 701 return packFloatx80( zSign, zExp, zSig0 );
711 } 702 }
712 } 703 }
713 if ( zSig1 ) float_exception_flags |= float_flag_inexact; 704 if ( zSig1 ) roundData->exception |= float_flag_inexact;
714 if ( increment ) { 705 if ( increment ) {
715 ++zSig0; 706 ++zSig0;
716 if ( zSig0 == 0 ) { 707 if ( zSig0 == 0 ) {
@@ -740,7 +731,7 @@ normalized.
740*/ 731*/
741static floatx80 732static floatx80
742 normalizeRoundAndPackFloatx80( 733 normalizeRoundAndPackFloatx80(
743 int8 roundingPrecision, flag zSign, int32 zExp, bits64 zSig0, bits64 zSig1 734 struct roundingData *roundData, flag zSign, int32 zExp, bits64 zSig0, bits64 zSig1
744 ) 735 )
745{ 736{
746 int8 shiftCount; 737 int8 shiftCount;
@@ -754,7 +745,7 @@ static floatx80
754 shortShift128Left( zSig0, zSig1, shiftCount, &zSig0, &zSig1 ); 745 shortShift128Left( zSig0, zSig1, shiftCount, &zSig0, &zSig1 );
755 zExp -= shiftCount; 746 zExp -= shiftCount;
756 return 747 return
757 roundAndPackFloatx80( roundingPrecision, zSign, zExp, zSig0, zSig1 ); 748 roundAndPackFloatx80( roundData, zSign, zExp, zSig0, zSig1 );
758 749
759} 750}
760 751
@@ -767,14 +758,14 @@ the single-precision floating-point format. The conversion is performed
767according to the IEC/IEEE Standard for Binary Floating-point Arithmetic. 758according to the IEC/IEEE Standard for Binary Floating-point Arithmetic.
768------------------------------------------------------------------------------- 759-------------------------------------------------------------------------------
769*/ 760*/
770float32 int32_to_float32( int32 a ) 761float32 int32_to_float32(struct roundingData *roundData, int32 a)
771{ 762{
772 flag zSign; 763 flag zSign;
773 764
774 if ( a == 0 ) return 0; 765 if ( a == 0 ) return 0;
775 if ( a == 0x80000000 ) return packFloat32( 1, 0x9E, 0 ); 766 if ( a == 0x80000000 ) return packFloat32( 1, 0x9E, 0 );
776 zSign = ( a < 0 ); 767 zSign = ( a < 0 );
777 return normalizeRoundAndPackFloat32( zSign, 0x9C, zSign ? - a : a ); 768 return normalizeRoundAndPackFloat32( roundData, zSign, 0x9C, zSign ? - a : a );
778 769
779} 770}
780 771
@@ -840,7 +831,7 @@ positive integer is returned. Otherwise, if the conversion overflows, the
840largest integer with the same sign as `a' is returned. 831largest integer with the same sign as `a' is returned.
841------------------------------------------------------------------------------- 832-------------------------------------------------------------------------------
842*/ 833*/
843int32 float32_to_int32( float32 a ) 834int32 float32_to_int32( struct roundingData *roundData, float32 a )
844{ 835{
845 flag aSign; 836 flag aSign;
846 int16 aExp, shiftCount; 837 int16 aExp, shiftCount;
@@ -856,7 +847,7 @@ int32 float32_to_int32( float32 a )
856 zSig = aSig; 847 zSig = aSig;
857 zSig <<= 32; 848 zSig <<= 32;
858 if ( 0 < shiftCount ) shift64RightJamming( zSig, shiftCount, &zSig ); 849 if ( 0 < shiftCount ) shift64RightJamming( zSig, shiftCount, &zSig );
859 return roundAndPackInt32( aSign, zSig ); 850 return roundAndPackInt32( roundData, aSign, zSig );
860 851
861} 852}
862 853
@@ -889,13 +880,13 @@ int32 float32_to_int32_round_to_zero( float32 a )
889 return 0x80000000; 880 return 0x80000000;
890 } 881 }
891 else if ( aExp <= 0x7E ) { 882 else if ( aExp <= 0x7E ) {
892 if ( aExp | aSig ) float_exception_flags |= float_flag_inexact; 883 if ( aExp | aSig ) float_raise( float_flag_inexact );
893 return 0; 884 return 0;
894 } 885 }
895 aSig = ( aSig | 0x00800000 )<<8; 886 aSig = ( aSig | 0x00800000 )<<8;
896 z = aSig>>( - shiftCount ); 887 z = aSig>>( - shiftCount );
897 if ( (bits32) ( aSig<<( shiftCount & 31 ) ) ) { 888 if ( (bits32) ( aSig<<( shiftCount & 31 ) ) ) {
898 float_exception_flags |= float_flag_inexact; 889 float_raise( float_flag_inexact );
899 } 890 }
900 return aSign ? - z : z; 891 return aSign ? - z : z;
901 892
@@ -973,7 +964,7 @@ operation is performed according to the IEC/IEEE Standard for Binary
973Floating-point Arithmetic. 964Floating-point Arithmetic.
974------------------------------------------------------------------------------- 965-------------------------------------------------------------------------------
975*/ 966*/
976float32 float32_round_to_int( float32 a ) 967float32 float32_round_to_int( struct roundingData *roundData, float32 a )
977{ 968{
978 flag aSign; 969 flag aSign;
979 int16 aExp; 970 int16 aExp;
@@ -988,11 +979,12 @@ float32 float32_round_to_int( float32 a )
988 } 979 }
989 return a; 980 return a;
990 } 981 }
982 roundingMode = roundData->mode;
991 if ( aExp <= 0x7E ) { 983 if ( aExp <= 0x7E ) {
992 if ( (bits32) ( a<<1 ) == 0 ) return a; 984 if ( (bits32) ( a<<1 ) == 0 ) return a;
993 float_exception_flags |= float_flag_inexact; 985 roundData->exception |= float_flag_inexact;
994 aSign = extractFloat32Sign( a ); 986 aSign = extractFloat32Sign( a );
995 switch ( float_rounding_mode ) { 987 switch ( roundingMode ) {
996 case float_round_nearest_even: 988 case float_round_nearest_even:
997 if ( ( aExp == 0x7E ) && extractFloat32Frac( a ) ) { 989 if ( ( aExp == 0x7E ) && extractFloat32Frac( a ) ) {
998 return packFloat32( aSign, 0x7F, 0 ); 990 return packFloat32( aSign, 0x7F, 0 );
@@ -1009,7 +1001,6 @@ float32 float32_round_to_int( float32 a )
1009 lastBitMask <<= 0x96 - aExp; 1001 lastBitMask <<= 0x96 - aExp;
1010 roundBitsMask = lastBitMask - 1; 1002 roundBitsMask = lastBitMask - 1;
1011 z = a; 1003 z = a;
1012 roundingMode = float_rounding_mode;
1013 if ( roundingMode == float_round_nearest_even ) { 1004 if ( roundingMode == float_round_nearest_even ) {
1014 z += lastBitMask>>1; 1005 z += lastBitMask>>1;
1015 if ( ( z & roundBitsMask ) == 0 ) z &= ~ lastBitMask; 1006 if ( ( z & roundBitsMask ) == 0 ) z &= ~ lastBitMask;
@@ -1020,7 +1011,7 @@ float32 float32_round_to_int( float32 a )
1020 } 1011 }
1021 } 1012 }
1022 z &= ~ roundBitsMask; 1013 z &= ~ roundBitsMask;
1023 if ( z != a ) float_exception_flags |= float_flag_inexact; 1014 if ( z != a ) roundData->exception |= float_flag_inexact;
1024 return z; 1015 return z;
1025 1016
1026} 1017}
@@ -1034,7 +1025,7 @@ addition is performed according to the IEC/IEEE Standard for Binary
1034Floating-point Arithmetic. 1025Floating-point Arithmetic.
1035------------------------------------------------------------------------------- 1026-------------------------------------------------------------------------------
1036*/ 1027*/
1037static float32 addFloat32Sigs( float32 a, float32 b, flag zSign ) 1028static float32 addFloat32Sigs( struct roundingData *roundData, float32 a, float32 b, flag zSign )
1038{ 1029{
1039 int16 aExp, bExp, zExp; 1030 int16 aExp, bExp, zExp;
1040 bits32 aSig, bSig, zSig; 1031 bits32 aSig, bSig, zSig;
@@ -1093,7 +1084,7 @@ static float32 addFloat32Sigs( float32 a, float32 b, flag zSign )
1093 ++zExp; 1084 ++zExp;
1094 } 1085 }
1095 roundAndPack: 1086 roundAndPack:
1096 return roundAndPackFloat32( zSign, zExp, zSig ); 1087 return roundAndPackFloat32( roundData, zSign, zExp, zSig );
1097 1088
1098} 1089}
1099 1090
@@ -1106,7 +1097,7 @@ result is a NaN. The subtraction is performed according to the IEC/IEEE
1106Standard for Binary Floating-point Arithmetic. 1097Standard for Binary Floating-point Arithmetic.
1107------------------------------------------------------------------------------- 1098-------------------------------------------------------------------------------
1108*/ 1099*/
1109static float32 subFloat32Sigs( float32 a, float32 b, flag zSign ) 1100static float32 subFloat32Sigs( struct roundingData *roundData, float32 a, float32 b, flag zSign )
1110{ 1101{
1111 int16 aExp, bExp, zExp; 1102 int16 aExp, bExp, zExp;
1112 bits32 aSig, bSig, zSig; 1103 bits32 aSig, bSig, zSig;
@@ -1123,7 +1114,7 @@ static float32 subFloat32Sigs( float32 a, float32 b, flag zSign )
1123 if ( expDiff < 0 ) goto bExpBigger; 1114 if ( expDiff < 0 ) goto bExpBigger;
1124 if ( aExp == 0xFF ) { 1115 if ( aExp == 0xFF ) {
1125 if ( aSig | bSig ) return propagateFloat32NaN( a, b ); 1116 if ( aSig | bSig ) return propagateFloat32NaN( a, b );
1126 float_raise( float_flag_invalid ); 1117 roundData->exception |= float_flag_invalid;
1127 return float32_default_nan; 1118 return float32_default_nan;
1128 } 1119 }
1129 if ( aExp == 0 ) { 1120 if ( aExp == 0 ) {
@@ -1132,7 +1123,7 @@ static float32 subFloat32Sigs( float32 a, float32 b, flag zSign )
1132 } 1123 }
1133 if ( bSig < aSig ) goto aBigger; 1124 if ( bSig < aSig ) goto aBigger;
1134 if ( aSig < bSig ) goto bBigger; 1125 if ( aSig < bSig ) goto bBigger;
1135 return packFloat32( float_rounding_mode == float_round_down, 0, 0 ); 1126 return packFloat32( roundData->mode == float_round_down, 0, 0 );
1136 bExpBigger: 1127 bExpBigger:
1137 if ( bExp == 0xFF ) { 1128 if ( bExp == 0xFF ) {
1138 if ( bSig ) return propagateFloat32NaN( a, b ); 1129 if ( bSig ) return propagateFloat32NaN( a, b );
@@ -1169,7 +1160,7 @@ static float32 subFloat32Sigs( float32 a, float32 b, flag zSign )
1169 zExp = aExp; 1160 zExp = aExp;
1170 normalizeRoundAndPack: 1161 normalizeRoundAndPack:
1171 --zExp; 1162 --zExp;
1172 return normalizeRoundAndPackFloat32( zSign, zExp, zSig ); 1163 return normalizeRoundAndPackFloat32( roundData, zSign, zExp, zSig );
1173 1164
1174} 1165}
1175 1166
@@ -1180,17 +1171,17 @@ and `b'. The operation is performed according to the IEC/IEEE Standard for
1180Binary Floating-point Arithmetic. 1171Binary Floating-point Arithmetic.
1181------------------------------------------------------------------------------- 1172-------------------------------------------------------------------------------
1182*/ 1173*/
1183float32 float32_add( float32 a, float32 b ) 1174float32 float32_add( struct roundingData *roundData, float32 a, float32 b )
1184{ 1175{
1185 flag aSign, bSign; 1176 flag aSign, bSign;
1186 1177
1187 aSign = extractFloat32Sign( a ); 1178 aSign = extractFloat32Sign( a );
1188 bSign = extractFloat32Sign( b ); 1179 bSign = extractFloat32Sign( b );
1189 if ( aSign == bSign ) { 1180 if ( aSign == bSign ) {
1190 return addFloat32Sigs( a, b, aSign ); 1181 return addFloat32Sigs( roundData, a, b, aSign );
1191 } 1182 }
1192 else { 1183 else {
1193 return subFloat32Sigs( a, b, aSign ); 1184 return subFloat32Sigs( roundData, a, b, aSign );
1194 } 1185 }
1195 1186
1196} 1187}
@@ -1202,17 +1193,17 @@ Returns the result of subtracting the single-precision floating-point values
1202for Binary Floating-point Arithmetic. 1193for Binary Floating-point Arithmetic.
1203------------------------------------------------------------------------------- 1194-------------------------------------------------------------------------------
1204*/ 1195*/
1205float32 float32_sub( float32 a, float32 b ) 1196float32 float32_sub( struct roundingData *roundData, float32 a, float32 b )
1206{ 1197{
1207 flag aSign, bSign; 1198 flag aSign, bSign;
1208 1199
1209 aSign = extractFloat32Sign( a ); 1200 aSign = extractFloat32Sign( a );
1210 bSign = extractFloat32Sign( b ); 1201 bSign = extractFloat32Sign( b );
1211 if ( aSign == bSign ) { 1202 if ( aSign == bSign ) {
1212 return subFloat32Sigs( a, b, aSign ); 1203 return subFloat32Sigs( roundData, a, b, aSign );
1213 } 1204 }
1214 else { 1205 else {
1215 return addFloat32Sigs( a, b, aSign ); 1206 return addFloat32Sigs( roundData, a, b, aSign );
1216 } 1207 }
1217 1208
1218} 1209}
@@ -1224,7 +1215,7 @@ Returns the result of multiplying the single-precision floating-point values
1224for Binary Floating-point Arithmetic. 1215for Binary Floating-point Arithmetic.
1225------------------------------------------------------------------------------- 1216-------------------------------------------------------------------------------
1226*/ 1217*/
1227float32 float32_mul( float32 a, float32 b ) 1218float32 float32_mul( struct roundingData *roundData, float32 a, float32 b )
1228{ 1219{
1229 flag aSign, bSign, zSign; 1220 flag aSign, bSign, zSign;
1230 int16 aExp, bExp, zExp; 1221 int16 aExp, bExp, zExp;
@@ -1244,7 +1235,7 @@ float32 float32_mul( float32 a, float32 b )
1244 return propagateFloat32NaN( a, b ); 1235 return propagateFloat32NaN( a, b );
1245 } 1236 }
1246 if ( ( bExp | bSig ) == 0 ) { 1237 if ( ( bExp | bSig ) == 0 ) {
1247 float_raise( float_flag_invalid ); 1238 roundData->exception |= float_flag_invalid;
1248 return float32_default_nan; 1239 return float32_default_nan;
1249 } 1240 }
1250 return packFloat32( zSign, 0xFF, 0 ); 1241 return packFloat32( zSign, 0xFF, 0 );
@@ -1252,7 +1243,7 @@ float32 float32_mul( float32 a, float32 b )
1252 if ( bExp == 0xFF ) { 1243 if ( bExp == 0xFF ) {
1253 if ( bSig ) return propagateFloat32NaN( a, b ); 1244 if ( bSig ) return propagateFloat32NaN( a, b );
1254 if ( ( aExp | aSig ) == 0 ) { 1245 if ( ( aExp | aSig ) == 0 ) {
1255 float_raise( float_flag_invalid ); 1246 roundData->exception |= float_flag_invalid;
1256 return float32_default_nan; 1247 return float32_default_nan;
1257 } 1248 }
1258 return packFloat32( zSign, 0xFF, 0 ); 1249 return packFloat32( zSign, 0xFF, 0 );
@@ -1274,7 +1265,7 @@ float32 float32_mul( float32 a, float32 b )
1274 zSig <<= 1; 1265 zSig <<= 1;
1275 --zExp; 1266 --zExp;
1276 } 1267 }
1277 return roundAndPackFloat32( zSign, zExp, zSig ); 1268 return roundAndPackFloat32( roundData, zSign, zExp, zSig );
1278 1269
1279} 1270}
1280 1271
@@ -1285,7 +1276,7 @@ by the corresponding value `b'. The operation is performed according to the
1285IEC/IEEE Standard for Binary Floating-point Arithmetic. 1276IEC/IEEE Standard for Binary Floating-point Arithmetic.
1286------------------------------------------------------------------------------- 1277-------------------------------------------------------------------------------
1287*/ 1278*/
1288float32 float32_div( float32 a, float32 b ) 1279float32 float32_div( struct roundingData *roundData, float32 a, float32 b )
1289{ 1280{
1290 flag aSign, bSign, zSign; 1281 flag aSign, bSign, zSign;
1291 int16 aExp, bExp, zExp; 1282 int16 aExp, bExp, zExp;
@@ -1302,7 +1293,7 @@ float32 float32_div( float32 a, float32 b )
1302 if ( aSig ) return propagateFloat32NaN( a, b ); 1293 if ( aSig ) return propagateFloat32NaN( a, b );
1303 if ( bExp == 0xFF ) { 1294 if ( bExp == 0xFF ) {
1304 if ( bSig ) return propagateFloat32NaN( a, b ); 1295 if ( bSig ) return propagateFloat32NaN( a, b );
1305 float_raise( float_flag_invalid ); 1296 roundData->exception |= float_flag_invalid;
1306 return float32_default_nan; 1297 return float32_default_nan;
1307 } 1298 }
1308 return packFloat32( zSign, 0xFF, 0 ); 1299 return packFloat32( zSign, 0xFF, 0 );
@@ -1314,10 +1305,10 @@ float32 float32_div( float32 a, float32 b )
1314 if ( bExp == 0 ) { 1305 if ( bExp == 0 ) {
1315 if ( bSig == 0 ) { 1306 if ( bSig == 0 ) {
1316 if ( ( aExp | aSig ) == 0 ) { 1307 if ( ( aExp | aSig ) == 0 ) {
1317 float_raise( float_flag_invalid ); 1308 roundData->exception |= float_flag_invalid;
1318 return float32_default_nan; 1309 return float32_default_nan;
1319 } 1310 }
1320 float_raise( float_flag_divbyzero ); 1311 roundData->exception |= float_flag_divbyzero;
1321 return packFloat32( zSign, 0xFF, 0 ); 1312 return packFloat32( zSign, 0xFF, 0 );
1322 } 1313 }
1323 normalizeFloat32Subnormal( bSig, &bExp, &bSig ); 1314 normalizeFloat32Subnormal( bSig, &bExp, &bSig );
@@ -1341,7 +1332,7 @@ float32 float32_div( float32 a, float32 b )
1341 if ( ( zSig & 0x3F ) == 0 ) { 1332 if ( ( zSig & 0x3F ) == 0 ) {
1342 zSig |= ( ( (bits64) bSig ) * zSig != ( (bits64) aSig )<<32 ); 1333 zSig |= ( ( (bits64) bSig ) * zSig != ( (bits64) aSig )<<32 );
1343 } 1334 }
1344 return roundAndPackFloat32( zSign, zExp, zSig ); 1335 return roundAndPackFloat32( roundData, zSign, zExp, zSig );
1345 1336
1346} 1337}
1347 1338
@@ -1352,7 +1343,7 @@ with respect to the corresponding value `b'. The operation is performed
1352according to the IEC/IEEE Standard for Binary Floating-point Arithmetic. 1343according to the IEC/IEEE Standard for Binary Floating-point Arithmetic.
1353------------------------------------------------------------------------------- 1344-------------------------------------------------------------------------------
1354*/ 1345*/
1355float32 float32_rem( float32 a, float32 b ) 1346float32 float32_rem( struct roundingData *roundData, float32 a, float32 b )
1356{ 1347{
1357 flag aSign, bSign, zSign; 1348 flag aSign, bSign, zSign;
1358 int16 aExp, bExp, expDiff; 1349 int16 aExp, bExp, expDiff;
@@ -1372,7 +1363,7 @@ float32 float32_rem( float32 a, float32 b )
1372 if ( aSig || ( ( bExp == 0xFF ) && bSig ) ) { 1363 if ( aSig || ( ( bExp == 0xFF ) && bSig ) ) {
1373 return propagateFloat32NaN( a, b ); 1364 return propagateFloat32NaN( a, b );
1374 } 1365 }
1375 float_raise( float_flag_invalid ); 1366 roundData->exception |= float_flag_invalid;
1376 return float32_default_nan; 1367 return float32_default_nan;
1377 } 1368 }
1378 if ( bExp == 0xFF ) { 1369 if ( bExp == 0xFF ) {
@@ -1381,7 +1372,7 @@ float32 float32_rem( float32 a, float32 b )
1381 } 1372 }
1382 if ( bExp == 0 ) { 1373 if ( bExp == 0 ) {
1383 if ( bSig == 0 ) { 1374 if ( bSig == 0 ) {
1384 float_raise( float_flag_invalid ); 1375 roundData->exception |= float_flag_invalid;
1385 return float32_default_nan; 1376 return float32_default_nan;
1386 } 1377 }
1387 normalizeFloat32Subnormal( bSig, &bExp, &bSig ); 1378 normalizeFloat32Subnormal( bSig, &bExp, &bSig );
@@ -1444,7 +1435,7 @@ float32 float32_rem( float32 a, float32 b )
1444 } 1435 }
1445 zSign = ( (sbits32) aSig < 0 ); 1436 zSign = ( (sbits32) aSig < 0 );
1446 if ( zSign ) aSig = - aSig; 1437 if ( zSign ) aSig = - aSig;
1447 return normalizeRoundAndPackFloat32( aSign ^ zSign, bExp, aSig ); 1438 return normalizeRoundAndPackFloat32( roundData, aSign ^ zSign, bExp, aSig );
1448 1439
1449} 1440}
1450 1441
@@ -1455,7 +1446,7 @@ The operation is performed according to the IEC/IEEE Standard for Binary
1455Floating-point Arithmetic. 1446Floating-point Arithmetic.
1456------------------------------------------------------------------------------- 1447-------------------------------------------------------------------------------
1457*/ 1448*/
1458float32 float32_sqrt( float32 a ) 1449float32 float32_sqrt( struct roundingData *roundData, float32 a )
1459{ 1450{
1460 flag aSign; 1451 flag aSign;
1461 int16 aExp, zExp; 1452 int16 aExp, zExp;
@@ -1468,12 +1459,12 @@ float32 float32_sqrt( float32 a )
1468 if ( aExp == 0xFF ) { 1459 if ( aExp == 0xFF ) {
1469 if ( aSig ) return propagateFloat32NaN( a, 0 ); 1460 if ( aSig ) return propagateFloat32NaN( a, 0 );
1470 if ( ! aSign ) return a; 1461 if ( ! aSign ) return a;
1471 float_raise( float_flag_invalid ); 1462 roundData->exception |= float_flag_invalid;
1472 return float32_default_nan; 1463 return float32_default_nan;
1473 } 1464 }
1474 if ( aSign ) { 1465 if ( aSign ) {
1475 if ( ( aExp | aSig ) == 0 ) return a; 1466 if ( ( aExp | aSig ) == 0 ) return a;
1476 float_raise( float_flag_invalid ); 1467 roundData->exception |= float_flag_invalid;
1477 return float32_default_nan; 1468 return float32_default_nan;
1478 } 1469 }
1479 if ( aExp == 0 ) { 1470 if ( aExp == 0 ) {
@@ -1499,7 +1490,7 @@ float32 float32_sqrt( float32 a )
1499 } 1490 }
1500 } 1491 }
1501 shift32RightJamming( zSig, 1, &zSig ); 1492 shift32RightJamming( zSig, 1, &zSig );
1502 return roundAndPackFloat32( 0, zExp, zSig ); 1493 return roundAndPackFloat32( roundData, 0, zExp, zSig );
1503 1494
1504} 1495}
1505 1496
@@ -1661,7 +1652,7 @@ positive integer is returned. Otherwise, if the conversion overflows, the
1661largest integer with the same sign as `a' is returned. 1652largest integer with the same sign as `a' is returned.
1662------------------------------------------------------------------------------- 1653-------------------------------------------------------------------------------
1663*/ 1654*/
1664int32 float64_to_int32( float64 a ) 1655int32 float64_to_int32( struct roundingData *roundData, float64 a )
1665{ 1656{
1666 flag aSign; 1657 flag aSign;
1667 int16 aExp, shiftCount; 1658 int16 aExp, shiftCount;
@@ -1674,7 +1665,7 @@ int32 float64_to_int32( float64 a )
1674 if ( aExp ) aSig |= LIT64( 0x0010000000000000 ); 1665 if ( aExp ) aSig |= LIT64( 0x0010000000000000 );
1675 shiftCount = 0x42C - aExp; 1666 shiftCount = 0x42C - aExp;
1676 if ( 0 < shiftCount ) shift64RightJamming( aSig, shiftCount, &aSig ); 1667 if ( 0 < shiftCount ) shift64RightJamming( aSig, shiftCount, &aSig );
1677 return roundAndPackInt32( aSign, aSig ); 1668 return roundAndPackInt32( roundData, aSign, aSig );
1678 1669
1679} 1670}
1680 1671
@@ -1705,7 +1696,7 @@ int32 float64_to_int32_round_to_zero( float64 a )
1705 goto invalid; 1696 goto invalid;
1706 } 1697 }
1707 else if ( 52 < shiftCount ) { 1698 else if ( 52 < shiftCount ) {
1708 if ( aExp || aSig ) float_exception_flags |= float_flag_inexact; 1699 if ( aExp || aSig ) float_raise( float_flag_inexact );
1709 return 0; 1700 return 0;
1710 } 1701 }
1711 aSig |= LIT64( 0x0010000000000000 ); 1702 aSig |= LIT64( 0x0010000000000000 );
@@ -1715,11 +1706,11 @@ int32 float64_to_int32_round_to_zero( float64 a )
1715 if ( aSign ) z = - z; 1706 if ( aSign ) z = - z;
1716 if ( ( z < 0 ) ^ aSign ) { 1707 if ( ( z < 0 ) ^ aSign ) {
1717 invalid: 1708 invalid:
1718 float_exception_flags |= float_flag_invalid; 1709 float_raise( float_flag_invalid );
1719 return aSign ? 0x80000000 : 0x7FFFFFFF; 1710 return aSign ? 0x80000000 : 0x7FFFFFFF;
1720 } 1711 }
1721 if ( ( aSig<<shiftCount ) != savedASig ) { 1712 if ( ( aSig<<shiftCount ) != savedASig ) {
1722 float_exception_flags |= float_flag_inexact; 1713 float_raise( float_flag_inexact );
1723 } 1714 }
1724 return z; 1715 return z;
1725 1716
@@ -1736,7 +1727,7 @@ positive integer is returned. Otherwise, if the conversion overflows, the
1736largest positive integer is returned. 1727largest positive integer is returned.
1737------------------------------------------------------------------------------- 1728-------------------------------------------------------------------------------
1738*/ 1729*/
1739int32 float64_to_uint32( float64 a ) 1730int32 float64_to_uint32( struct roundingData *roundData, float64 a )
1740{ 1731{
1741 flag aSign; 1732 flag aSign;
1742 int16 aExp, shiftCount; 1733 int16 aExp, shiftCount;
@@ -1749,7 +1740,7 @@ int32 float64_to_uint32( float64 a )
1749 if ( aExp ) aSig |= LIT64( 0x0010000000000000 ); 1740 if ( aExp ) aSig |= LIT64( 0x0010000000000000 );
1750 shiftCount = 0x42C - aExp; 1741 shiftCount = 0x42C - aExp;
1751 if ( 0 < shiftCount ) shift64RightJamming( aSig, shiftCount, &aSig ); 1742 if ( 0 < shiftCount ) shift64RightJamming( aSig, shiftCount, &aSig );
1752 return roundAndPackInt32( aSign, aSig ); 1743 return roundAndPackInt32( roundData, aSign, aSig );
1753} 1744}
1754 1745
1755/* 1746/*
@@ -1778,7 +1769,7 @@ int32 float64_to_uint32_round_to_zero( float64 a )
1778 goto invalid; 1769 goto invalid;
1779 } 1770 }
1780 else if ( 52 < shiftCount ) { 1771 else if ( 52 < shiftCount ) {
1781 if ( aExp || aSig ) float_exception_flags |= float_flag_inexact; 1772 if ( aExp || aSig ) float_raise( float_flag_inexact );
1782 return 0; 1773 return 0;
1783 } 1774 }
1784 aSig |= LIT64( 0x0010000000000000 ); 1775 aSig |= LIT64( 0x0010000000000000 );
@@ -1788,11 +1779,11 @@ int32 float64_to_uint32_round_to_zero( float64 a )
1788 if ( aSign ) z = - z; 1779 if ( aSign ) z = - z;
1789 if ( ( z < 0 ) ^ aSign ) { 1780 if ( ( z < 0 ) ^ aSign ) {
1790 invalid: 1781 invalid:
1791 float_exception_flags |= float_flag_invalid; 1782 float_raise( float_flag_invalid );
1792 return aSign ? 0x80000000 : 0x7FFFFFFF; 1783 return aSign ? 0x80000000 : 0x7FFFFFFF;
1793 } 1784 }
1794 if ( ( aSig<<shiftCount ) != savedASig ) { 1785 if ( ( aSig<<shiftCount ) != savedASig ) {
1795 float_exception_flags |= float_flag_inexact; 1786 float_raise( float_flag_inexact );
1796 } 1787 }
1797 return z; 1788 return z;
1798} 1789}
@@ -1805,7 +1796,7 @@ performed according to the IEC/IEEE Standard for Binary Floating-point
1805Arithmetic. 1796Arithmetic.
1806------------------------------------------------------------------------------- 1797-------------------------------------------------------------------------------
1807*/ 1798*/
1808float32 float64_to_float32( float64 a ) 1799float32 float64_to_float32( struct roundingData *roundData, float64 a )
1809{ 1800{
1810 flag aSign; 1801 flag aSign;
1811 int16 aExp; 1802 int16 aExp;
@@ -1825,7 +1816,7 @@ float32 float64_to_float32( float64 a )
1825 zSig |= 0x40000000; 1816 zSig |= 0x40000000;
1826 aExp -= 0x381; 1817 aExp -= 0x381;
1827 } 1818 }
1828 return roundAndPackFloat32( aSign, aExp, zSig ); 1819 return roundAndPackFloat32( roundData, aSign, aExp, zSig );
1829 1820
1830} 1821}
1831 1822
@@ -1872,7 +1863,7 @@ operation is performed according to the IEC/IEEE Standard for Binary
1872Floating-point Arithmetic. 1863Floating-point Arithmetic.
1873------------------------------------------------------------------------------- 1864-------------------------------------------------------------------------------
1874*/ 1865*/
1875float64 float64_round_to_int( float64 a ) 1866float64 float64_round_to_int( struct roundingData *roundData, float64 a )
1876{ 1867{
1877 flag aSign; 1868 flag aSign;
1878 int16 aExp; 1869 int16 aExp;
@@ -1889,9 +1880,9 @@ float64 float64_round_to_int( float64 a )
1889 } 1880 }
1890 if ( aExp <= 0x3FE ) { 1881 if ( aExp <= 0x3FE ) {
1891 if ( (bits64) ( a<<1 ) == 0 ) return a; 1882 if ( (bits64) ( a<<1 ) == 0 ) return a;
1892 float_exception_flags |= float_flag_inexact; 1883 roundData->exception |= float_flag_inexact;
1893 aSign = extractFloat64Sign( a ); 1884 aSign = extractFloat64Sign( a );
1894 switch ( float_rounding_mode ) { 1885 switch ( roundData->mode ) {
1895 case float_round_nearest_even: 1886 case float_round_nearest_even:
1896 if ( ( aExp == 0x3FE ) && extractFloat64Frac( a ) ) { 1887 if ( ( aExp == 0x3FE ) && extractFloat64Frac( a ) ) {
1897 return packFloat64( aSign, 0x3FF, 0 ); 1888 return packFloat64( aSign, 0x3FF, 0 );
@@ -1909,7 +1900,7 @@ float64 float64_round_to_int( float64 a )
1909 lastBitMask <<= 0x433 - aExp; 1900 lastBitMask <<= 0x433 - aExp;
1910 roundBitsMask = lastBitMask - 1; 1901 roundBitsMask = lastBitMask - 1;
1911 z = a; 1902 z = a;
1912 roundingMode = float_rounding_mode; 1903 roundingMode = roundData->mode;
1913 if ( roundingMode == float_round_nearest_even ) { 1904 if ( roundingMode == float_round_nearest_even ) {
1914 z += lastBitMask>>1; 1905 z += lastBitMask>>1;
1915 if ( ( z & roundBitsMask ) == 0 ) z &= ~ lastBitMask; 1906 if ( ( z & roundBitsMask ) == 0 ) z &= ~ lastBitMask;
@@ -1920,7 +1911,7 @@ float64 float64_round_to_int( float64 a )
1920 } 1911 }
1921 } 1912 }
1922 z &= ~ roundBitsMask; 1913 z &= ~ roundBitsMask;
1923 if ( z != a ) float_exception_flags |= float_flag_inexact; 1914 if ( z != a ) roundData->exception |= float_flag_inexact;
1924 return z; 1915 return z;
1925 1916
1926} 1917}
@@ -1934,7 +1925,7 @@ addition is performed according to the IEC/IEEE Standard for Binary
1934Floating-point Arithmetic. 1925Floating-point Arithmetic.
1935------------------------------------------------------------------------------- 1926-------------------------------------------------------------------------------
1936*/ 1927*/
1937static float64 addFloat64Sigs( float64 a, float64 b, flag zSign ) 1928static float64 addFloat64Sigs( struct roundingData *roundData, float64 a, float64 b, flag zSign )
1938{ 1929{
1939 int16 aExp, bExp, zExp; 1930 int16 aExp, bExp, zExp;
1940 bits64 aSig, bSig, zSig; 1931 bits64 aSig, bSig, zSig;
@@ -1993,7 +1984,7 @@ static float64 addFloat64Sigs( float64 a, float64 b, flag zSign )
1993 ++zExp; 1984 ++zExp;
1994 } 1985 }
1995 roundAndPack: 1986 roundAndPack:
1996 return roundAndPackFloat64( zSign, zExp, zSig ); 1987 return roundAndPackFloat64( roundData, zSign, zExp, zSig );
1997 1988
1998} 1989}
1999 1990
@@ -2006,7 +1997,7 @@ result is a NaN. The subtraction is performed according to the IEC/IEEE
2006Standard for Binary Floating-point Arithmetic. 1997Standard for Binary Floating-point Arithmetic.
2007------------------------------------------------------------------------------- 1998-------------------------------------------------------------------------------
2008*/ 1999*/
2009static float64 subFloat64Sigs( float64 a, float64 b, flag zSign ) 2000static float64 subFloat64Sigs( struct roundingData *roundData, float64 a, float64 b, flag zSign )
2010{ 2001{
2011 int16 aExp, bExp, zExp; 2002 int16 aExp, bExp, zExp;
2012 bits64 aSig, bSig, zSig; 2003 bits64 aSig, bSig, zSig;
@@ -2023,7 +2014,7 @@ static float64 subFloat64Sigs( float64 a, float64 b, flag zSign )
2023 if ( expDiff < 0 ) goto bExpBigger; 2014 if ( expDiff < 0 ) goto bExpBigger;
2024 if ( aExp == 0x7FF ) { 2015 if ( aExp == 0x7FF ) {
2025 if ( aSig | bSig ) return propagateFloat64NaN( a, b ); 2016 if ( aSig | bSig ) return propagateFloat64NaN( a, b );
2026 float_raise( float_flag_invalid ); 2017 roundData->exception |= float_flag_invalid;
2027 return float64_default_nan; 2018 return float64_default_nan;
2028 } 2019 }
2029 if ( aExp == 0 ) { 2020 if ( aExp == 0 ) {
@@ -2032,7 +2023,7 @@ static float64 subFloat64Sigs( float64 a, float64 b, flag zSign )
2032 } 2023 }
2033 if ( bSig < aSig ) goto aBigger; 2024 if ( bSig < aSig ) goto aBigger;
2034 if ( aSig < bSig ) goto bBigger; 2025 if ( aSig < bSig ) goto bBigger;
2035 return packFloat64( float_rounding_mode == float_round_down, 0, 0 ); 2026 return packFloat64( roundData->mode == float_round_down, 0, 0 );
2036 bExpBigger: 2027 bExpBigger:
2037 if ( bExp == 0x7FF ) { 2028 if ( bExp == 0x7FF ) {
2038 if ( bSig ) return propagateFloat64NaN( a, b ); 2029 if ( bSig ) return propagateFloat64NaN( a, b );
@@ -2069,7 +2060,7 @@ static float64 subFloat64Sigs( float64 a, float64 b, flag zSign )
2069 zExp = aExp; 2060 zExp = aExp;
2070 normalizeRoundAndPack: 2061 normalizeRoundAndPack:
2071 --zExp; 2062 --zExp;
2072 return normalizeRoundAndPackFloat64( zSign, zExp, zSig ); 2063 return normalizeRoundAndPackFloat64( roundData, zSign, zExp, zSig );
2073 2064
2074} 2065}
2075 2066
@@ -2080,17 +2071,17 @@ and `b'. The operation is performed according to the IEC/IEEE Standard for
2080Binary Floating-point Arithmetic. 2071Binary Floating-point Arithmetic.
2081------------------------------------------------------------------------------- 2072-------------------------------------------------------------------------------
2082*/ 2073*/
2083float64 float64_add( float64 a, float64 b ) 2074float64 float64_add( struct roundingData *roundData, float64 a, float64 b )
2084{ 2075{
2085 flag aSign, bSign; 2076 flag aSign, bSign;
2086 2077
2087 aSign = extractFloat64Sign( a ); 2078 aSign = extractFloat64Sign( a );
2088 bSign = extractFloat64Sign( b ); 2079 bSign = extractFloat64Sign( b );
2089 if ( aSign == bSign ) { 2080 if ( aSign == bSign ) {
2090 return addFloat64Sigs( a, b, aSign ); 2081 return addFloat64Sigs( roundData, a, b, aSign );
2091 } 2082 }
2092 else { 2083 else {
2093 return subFloat64Sigs( a, b, aSign ); 2084 return subFloat64Sigs( roundData, a, b, aSign );
2094 } 2085 }
2095 2086
2096} 2087}
@@ -2102,17 +2093,17 @@ Returns the result of subtracting the double-precision floating-point values
2102for Binary Floating-point Arithmetic. 2093for Binary Floating-point Arithmetic.
2103------------------------------------------------------------------------------- 2094-------------------------------------------------------------------------------
2104*/ 2095*/
2105float64 float64_sub( float64 a, float64 b ) 2096float64 float64_sub( struct roundingData *roundData, float64 a, float64 b )
2106{ 2097{
2107 flag aSign, bSign; 2098 flag aSign, bSign;
2108 2099
2109 aSign = extractFloat64Sign( a ); 2100 aSign = extractFloat64Sign( a );
2110 bSign = extractFloat64Sign( b ); 2101 bSign = extractFloat64Sign( b );
2111 if ( aSign == bSign ) { 2102 if ( aSign == bSign ) {
2112 return subFloat64Sigs( a, b, aSign ); 2103 return subFloat64Sigs( roundData, a, b, aSign );
2113 } 2104 }
2114 else { 2105 else {
2115 return addFloat64Sigs( a, b, aSign ); 2106 return addFloat64Sigs( roundData, a, b, aSign );
2116 } 2107 }
2117 2108
2118} 2109}
@@ -2124,7 +2115,7 @@ Returns the result of multiplying the double-precision floating-point values
2124for Binary Floating-point Arithmetic. 2115for Binary Floating-point Arithmetic.
2125------------------------------------------------------------------------------- 2116-------------------------------------------------------------------------------
2126*/ 2117*/
2127float64 float64_mul( float64 a, float64 b ) 2118float64 float64_mul( struct roundingData *roundData, float64 a, float64 b )
2128{ 2119{
2129 flag aSign, bSign, zSign; 2120 flag aSign, bSign, zSign;
2130 int16 aExp, bExp, zExp; 2121 int16 aExp, bExp, zExp;
@@ -2142,7 +2133,7 @@ float64 float64_mul( float64 a, float64 b )
2142 return propagateFloat64NaN( a, b ); 2133 return propagateFloat64NaN( a, b );
2143 } 2134 }
2144 if ( ( bExp | bSig ) == 0 ) { 2135 if ( ( bExp | bSig ) == 0 ) {
2145 float_raise( float_flag_invalid ); 2136 roundData->exception |= float_flag_invalid;
2146 return float64_default_nan; 2137 return float64_default_nan;
2147 } 2138 }
2148 return packFloat64( zSign, 0x7FF, 0 ); 2139 return packFloat64( zSign, 0x7FF, 0 );
@@ -2150,7 +2141,7 @@ float64 float64_mul( float64 a, float64 b )
2150 if ( bExp == 0x7FF ) { 2141 if ( bExp == 0x7FF ) {
2151 if ( bSig ) return propagateFloat64NaN( a, b ); 2142 if ( bSig ) return propagateFloat64NaN( a, b );
2152 if ( ( aExp | aSig ) == 0 ) { 2143 if ( ( aExp | aSig ) == 0 ) {
2153 float_raise( float_flag_invalid ); 2144 roundData->exception |= float_flag_invalid;
2154 return float64_default_nan; 2145 return float64_default_nan;
2155 } 2146 }
2156 return packFloat64( zSign, 0x7FF, 0 ); 2147 return packFloat64( zSign, 0x7FF, 0 );
@@ -2172,7 +2163,7 @@ float64 float64_mul( float64 a, float64 b )
2172 zSig0 <<= 1; 2163 zSig0 <<= 1;
2173 --zExp; 2164 --zExp;
2174 } 2165 }
2175 return roundAndPackFloat64( zSign, zExp, zSig0 ); 2166 return roundAndPackFloat64( roundData, zSign, zExp, zSig0 );
2176 2167
2177} 2168}
2178 2169
@@ -2183,7 +2174,7 @@ by the corresponding value `b'. The operation is performed according to
2183the IEC/IEEE Standard for Binary Floating-point Arithmetic. 2174the IEC/IEEE Standard for Binary Floating-point Arithmetic.
2184------------------------------------------------------------------------------- 2175-------------------------------------------------------------------------------
2185*/ 2176*/
2186float64 float64_div( float64 a, float64 b ) 2177float64 float64_div( struct roundingData *roundData, float64 a, float64 b )
2187{ 2178{
2188 flag aSign, bSign, zSign; 2179 flag aSign, bSign, zSign;
2189 int16 aExp, bExp, zExp; 2180 int16 aExp, bExp, zExp;
@@ -2202,7 +2193,7 @@ float64 float64_div( float64 a, float64 b )
2202 if ( aSig ) return propagateFloat64NaN( a, b ); 2193 if ( aSig ) return propagateFloat64NaN( a, b );
2203 if ( bExp == 0x7FF ) { 2194 if ( bExp == 0x7FF ) {
2204 if ( bSig ) return propagateFloat64NaN( a, b ); 2195 if ( bSig ) return propagateFloat64NaN( a, b );
2205 float_raise( float_flag_invalid ); 2196 roundData->exception |= float_flag_invalid;
2206 return float64_default_nan; 2197 return float64_default_nan;
2207 } 2198 }
2208 return packFloat64( zSign, 0x7FF, 0 ); 2199 return packFloat64( zSign, 0x7FF, 0 );
@@ -2214,10 +2205,10 @@ float64 float64_div( float64 a, float64 b )
2214 if ( bExp == 0 ) { 2205 if ( bExp == 0 ) {
2215 if ( bSig == 0 ) { 2206 if ( bSig == 0 ) {
2216 if ( ( aExp | aSig ) == 0 ) { 2207 if ( ( aExp | aSig ) == 0 ) {
2217 float_raise( float_flag_invalid ); 2208 roundData->exception |= float_flag_invalid;
2218 return float64_default_nan; 2209 return float64_default_nan;
2219 } 2210 }
2220 float_raise( float_flag_divbyzero ); 2211 roundData->exception |= float_flag_divbyzero;
2221 return packFloat64( zSign, 0x7FF, 0 ); 2212 return packFloat64( zSign, 0x7FF, 0 );
2222 } 2213 }
2223 normalizeFloat64Subnormal( bSig, &bExp, &bSig ); 2214 normalizeFloat64Subnormal( bSig, &bExp, &bSig );
@@ -2243,7 +2234,7 @@ float64 float64_div( float64 a, float64 b )
2243 } 2234 }
2244 zSig |= ( rem1 != 0 ); 2235 zSig |= ( rem1 != 0 );
2245 } 2236 }
2246 return roundAndPackFloat64( zSign, zExp, zSig ); 2237 return roundAndPackFloat64( roundData, zSign, zExp, zSig );
2247 2238
2248} 2239}
2249 2240
@@ -2254,7 +2245,7 @@ with respect to the corresponding value `b'. The operation is performed
2254according to the IEC/IEEE Standard for Binary Floating-point Arithmetic. 2245according to the IEC/IEEE Standard for Binary Floating-point Arithmetic.
2255------------------------------------------------------------------------------- 2246-------------------------------------------------------------------------------
2256*/ 2247*/
2257float64 float64_rem( float64 a, float64 b ) 2248float64 float64_rem( struct roundingData *roundData, float64 a, float64 b )
2258{ 2249{
2259 flag aSign, bSign, zSign; 2250 flag aSign, bSign, zSign;
2260 int16 aExp, bExp, expDiff; 2251 int16 aExp, bExp, expDiff;
@@ -2272,7 +2263,7 @@ float64 float64_rem( float64 a, float64 b )
2272 if ( aSig || ( ( bExp == 0x7FF ) && bSig ) ) { 2263 if ( aSig || ( ( bExp == 0x7FF ) && bSig ) ) {
2273 return propagateFloat64NaN( a, b ); 2264 return propagateFloat64NaN( a, b );
2274 } 2265 }
2275 float_raise( float_flag_invalid ); 2266 roundData->exception |= float_flag_invalid;
2276 return float64_default_nan; 2267 return float64_default_nan;
2277 } 2268 }
2278 if ( bExp == 0x7FF ) { 2269 if ( bExp == 0x7FF ) {
@@ -2281,7 +2272,7 @@ float64 float64_rem( float64 a, float64 b )
2281 } 2272 }
2282 if ( bExp == 0 ) { 2273 if ( bExp == 0 ) {
2283 if ( bSig == 0 ) { 2274 if ( bSig == 0 ) {
2284 float_raise( float_flag_invalid ); 2275 roundData->exception |= float_flag_invalid;
2285 return float64_default_nan; 2276 return float64_default_nan;
2286 } 2277 }
2287 normalizeFloat64Subnormal( bSig, &bExp, &bSig ); 2278 normalizeFloat64Subnormal( bSig, &bExp, &bSig );
@@ -2329,7 +2320,7 @@ float64 float64_rem( float64 a, float64 b )
2329 } 2320 }
2330 zSign = ( (sbits64) aSig < 0 ); 2321 zSign = ( (sbits64) aSig < 0 );
2331 if ( zSign ) aSig = - aSig; 2322 if ( zSign ) aSig = - aSig;
2332 return normalizeRoundAndPackFloat64( aSign ^ zSign, bExp, aSig ); 2323 return normalizeRoundAndPackFloat64( roundData, aSign ^ zSign, bExp, aSig );
2333 2324
2334} 2325}
2335 2326
@@ -2340,7 +2331,7 @@ The operation is performed according to the IEC/IEEE Standard for Binary
2340Floating-point Arithmetic. 2331Floating-point Arithmetic.
2341------------------------------------------------------------------------------- 2332-------------------------------------------------------------------------------
2342*/ 2333*/
2343float64 float64_sqrt( float64 a ) 2334float64 float64_sqrt( struct roundingData *roundData, float64 a )
2344{ 2335{
2345 flag aSign; 2336 flag aSign;
2346 int16 aExp, zExp; 2337 int16 aExp, zExp;
@@ -2354,12 +2345,12 @@ float64 float64_sqrt( float64 a )
2354 if ( aExp == 0x7FF ) { 2345 if ( aExp == 0x7FF ) {
2355 if ( aSig ) return propagateFloat64NaN( a, a ); 2346 if ( aSig ) return propagateFloat64NaN( a, a );
2356 if ( ! aSign ) return a; 2347 if ( ! aSign ) return a;
2357 float_raise( float_flag_invalid ); 2348 roundData->exception |= float_flag_invalid;
2358 return float64_default_nan; 2349 return float64_default_nan;
2359 } 2350 }
2360 if ( aSign ) { 2351 if ( aSign ) {
2361 if ( ( aExp | aSig ) == 0 ) return a; 2352 if ( ( aExp | aSig ) == 0 ) return a;
2362 float_raise( float_flag_invalid ); 2353 roundData->exception |= float_flag_invalid;
2363 return float64_default_nan; 2354 return float64_default_nan;
2364 } 2355 }
2365 if ( aExp == 0 ) { 2356 if ( aExp == 0 ) {
@@ -2390,7 +2381,7 @@ float64 float64_sqrt( float64 a )
2390 } 2381 }
2391 } 2382 }
2392 shift64RightJamming( zSig, 1, &zSig ); 2383 shift64RightJamming( zSig, 1, &zSig );
2393 return roundAndPackFloat64( 0, zExp, zSig ); 2384 return roundAndPackFloat64( roundData, 0, zExp, zSig );
2394 2385
2395} 2386}
2396 2387
@@ -2554,7 +2545,7 @@ largest positive integer is returned. Otherwise, if the conversion
2554overflows, the largest integer with the same sign as `a' is returned. 2545overflows, the largest integer with the same sign as `a' is returned.
2555------------------------------------------------------------------------------- 2546-------------------------------------------------------------------------------
2556*/ 2547*/
2557int32 floatx80_to_int32( floatx80 a ) 2548int32 floatx80_to_int32( struct roundingData *roundData, floatx80 a )
2558{ 2549{
2559 flag aSign; 2550 flag aSign;
2560 int32 aExp, shiftCount; 2551 int32 aExp, shiftCount;
@@ -2567,7 +2558,7 @@ int32 floatx80_to_int32( floatx80 a )
2567 shiftCount = 0x4037 - aExp; 2558 shiftCount = 0x4037 - aExp;
2568 if ( shiftCount <= 0 ) shiftCount = 1; 2559 if ( shiftCount <= 0 ) shiftCount = 1;
2569 shift64RightJamming( aSig, shiftCount, &aSig ); 2560 shift64RightJamming( aSig, shiftCount, &aSig );
2570 return roundAndPackInt32( aSign, aSig ); 2561 return roundAndPackInt32( roundData, aSign, aSig );
2571 2562
2572} 2563}
2573 2564
@@ -2598,7 +2589,7 @@ int32 floatx80_to_int32_round_to_zero( floatx80 a )
2598 goto invalid; 2589 goto invalid;
2599 } 2590 }
2600 else if ( 63 < shiftCount ) { 2591 else if ( 63 < shiftCount ) {
2601 if ( aExp || aSig ) float_exception_flags |= float_flag_inexact; 2592 if ( aExp || aSig ) float_raise( float_flag_inexact );
2602 return 0; 2593 return 0;
2603 } 2594 }
2604 savedASig = aSig; 2595 savedASig = aSig;
@@ -2607,11 +2598,11 @@ int32 floatx80_to_int32_round_to_zero( floatx80 a )
2607 if ( aSign ) z = - z; 2598 if ( aSign ) z = - z;
2608 if ( ( z < 0 ) ^ aSign ) { 2599 if ( ( z < 0 ) ^ aSign ) {
2609 invalid: 2600 invalid:
2610 float_exception_flags |= float_flag_invalid; 2601 float_raise( float_flag_invalid );
2611 return aSign ? 0x80000000 : 0x7FFFFFFF; 2602 return aSign ? 0x80000000 : 0x7FFFFFFF;
2612 } 2603 }
2613 if ( ( aSig<<shiftCount ) != savedASig ) { 2604 if ( ( aSig<<shiftCount ) != savedASig ) {
2614 float_exception_flags |= float_flag_inexact; 2605 float_raise( float_flag_inexact );
2615 } 2606 }
2616 return z; 2607 return z;
2617 2608
@@ -2625,7 +2616,7 @@ conversion is performed according to the IEC/IEEE Standard for Binary
2625Floating-point Arithmetic. 2616Floating-point Arithmetic.
2626------------------------------------------------------------------------------- 2617-------------------------------------------------------------------------------
2627*/ 2618*/
2628float32 floatx80_to_float32( floatx80 a ) 2619float32 floatx80_to_float32( struct roundingData *roundData, floatx80 a )
2629{ 2620{
2630 flag aSign; 2621 flag aSign;
2631 int32 aExp; 2622 int32 aExp;
@@ -2642,7 +2633,7 @@ float32 floatx80_to_float32( floatx80 a )
2642 } 2633 }
2643 shift64RightJamming( aSig, 33, &aSig ); 2634 shift64RightJamming( aSig, 33, &aSig );
2644 if ( aExp || aSig ) aExp -= 0x3F81; 2635 if ( aExp || aSig ) aExp -= 0x3F81;
2645 return roundAndPackFloat32( aSign, aExp, aSig ); 2636 return roundAndPackFloat32( roundData, aSign, aExp, aSig );
2646 2637
2647} 2638}
2648 2639
@@ -2654,7 +2645,7 @@ conversion is performed according to the IEC/IEEE Standard for Binary
2654Floating-point Arithmetic. 2645Floating-point Arithmetic.
2655------------------------------------------------------------------------------- 2646-------------------------------------------------------------------------------
2656*/ 2647*/
2657float64 floatx80_to_float64( floatx80 a ) 2648float64 floatx80_to_float64( struct roundingData *roundData, floatx80 a )
2658{ 2649{
2659 flag aSign; 2650 flag aSign;
2660 int32 aExp; 2651 int32 aExp;
@@ -2671,7 +2662,7 @@ float64 floatx80_to_float64( floatx80 a )
2671 } 2662 }
2672 shift64RightJamming( aSig, 1, &zSig ); 2663 shift64RightJamming( aSig, 1, &zSig );
2673 if ( aExp || aSig ) aExp -= 0x3C01; 2664 if ( aExp || aSig ) aExp -= 0x3C01;
2674 return roundAndPackFloat64( aSign, aExp, zSig ); 2665 return roundAndPackFloat64( roundData, aSign, aExp, zSig );
2675 2666
2676} 2667}
2677 2668
@@ -2683,7 +2674,7 @@ value. The operation is performed according to the IEC/IEEE Standard for
2683Binary Floating-point Arithmetic. 2674Binary Floating-point Arithmetic.
2684------------------------------------------------------------------------------- 2675-------------------------------------------------------------------------------
2685*/ 2676*/
2686floatx80 floatx80_round_to_int( floatx80 a ) 2677floatx80 floatx80_round_to_int( struct roundingData *roundData, floatx80 a )
2687{ 2678{
2688 flag aSign; 2679 flag aSign;
2689 int32 aExp; 2680 int32 aExp;
@@ -2703,9 +2694,9 @@ floatx80 floatx80_round_to_int( floatx80 a )
2703 && ( (bits64) ( extractFloatx80Frac( a )<<1 ) == 0 ) ) { 2694 && ( (bits64) ( extractFloatx80Frac( a )<<1 ) == 0 ) ) {
2704 return a; 2695 return a;
2705 } 2696 }
2706 float_exception_flags |= float_flag_inexact; 2697 roundData->exception |= float_flag_inexact;
2707 aSign = extractFloatx80Sign( a ); 2698 aSign = extractFloatx80Sign( a );
2708 switch ( float_rounding_mode ) { 2699 switch ( roundData->mode ) {
2709 case float_round_nearest_even: 2700 case float_round_nearest_even:
2710 if ( ( aExp == 0x3FFE ) && (bits64) ( extractFloatx80Frac( a )<<1 ) 2701 if ( ( aExp == 0x3FFE ) && (bits64) ( extractFloatx80Frac( a )<<1 )
2711 ) { 2702 ) {
@@ -2729,7 +2720,7 @@ floatx80 floatx80_round_to_int( floatx80 a )
2729 lastBitMask <<= 0x403E - aExp; 2720 lastBitMask <<= 0x403E - aExp;
2730 roundBitsMask = lastBitMask - 1; 2721 roundBitsMask = lastBitMask - 1;
2731 z = a; 2722 z = a;
2732 roundingMode = float_rounding_mode; 2723 roundingMode = roundData->mode;
2733 if ( roundingMode == float_round_nearest_even ) { 2724 if ( roundingMode == float_round_nearest_even ) {
2734 z.low += lastBitMask>>1; 2725 z.low += lastBitMask>>1;
2735 if ( ( z.low & roundBitsMask ) == 0 ) z.low &= ~ lastBitMask; 2726 if ( ( z.low & roundBitsMask ) == 0 ) z.low &= ~ lastBitMask;
@@ -2744,7 +2735,7 @@ floatx80 floatx80_round_to_int( floatx80 a )
2744 ++z.high; 2735 ++z.high;
2745 z.low = LIT64( 0x8000000000000000 ); 2736 z.low = LIT64( 0x8000000000000000 );
2746 } 2737 }
2747 if ( z.low != a.low ) float_exception_flags |= float_flag_inexact; 2738 if ( z.low != a.low ) roundData->exception |= float_flag_inexact;
2748 return z; 2739 return z;
2749 2740
2750} 2741}
@@ -2758,7 +2749,7 @@ The addition is performed according to the IEC/IEEE Standard for Binary
2758Floating-point Arithmetic. 2749Floating-point Arithmetic.
2759------------------------------------------------------------------------------- 2750-------------------------------------------------------------------------------
2760*/ 2751*/
2761static floatx80 addFloatx80Sigs( floatx80 a, floatx80 b, flag zSign ) 2752static floatx80 addFloatx80Sigs( struct roundingData *roundData, floatx80 a, floatx80 b, flag zSign )
2762{ 2753{
2763 int32 aExp, bExp, zExp; 2754 int32 aExp, bExp, zExp;
2764 bits64 aSig, bSig, zSig0, zSig1; 2755 bits64 aSig, bSig, zSig0, zSig1;
@@ -2814,7 +2805,7 @@ static floatx80 addFloatx80Sigs( floatx80 a, floatx80 b, flag zSign )
2814 roundAndPack: 2805 roundAndPack:
2815 return 2806 return
2816 roundAndPackFloatx80( 2807 roundAndPackFloatx80(
2817 floatx80_rounding_precision, zSign, zExp, zSig0, zSig1 ); 2808 roundData, zSign, zExp, zSig0, zSig1 );
2818 2809
2819} 2810}
2820 2811
@@ -2827,7 +2818,7 @@ result is a NaN. The subtraction is performed according to the IEC/IEEE
2827Standard for Binary Floating-point Arithmetic. 2818Standard for Binary Floating-point Arithmetic.
2828------------------------------------------------------------------------------- 2819-------------------------------------------------------------------------------
2829*/ 2820*/
2830static floatx80 subFloatx80Sigs( floatx80 a, floatx80 b, flag zSign ) 2821static floatx80 subFloatx80Sigs( struct roundingData *roundData, floatx80 a, floatx80 b, flag zSign )
2831{ 2822{
2832 int32 aExp, bExp, zExp; 2823 int32 aExp, bExp, zExp;
2833 bits64 aSig, bSig, zSig0, zSig1; 2824 bits64 aSig, bSig, zSig0, zSig1;
@@ -2845,7 +2836,7 @@ static floatx80 subFloatx80Sigs( floatx80 a, floatx80 b, flag zSign )
2845 if ( (bits64) ( ( aSig | bSig )<<1 ) ) { 2836 if ( (bits64) ( ( aSig | bSig )<<1 ) ) {
2846 return propagateFloatx80NaN( a, b ); 2837 return propagateFloatx80NaN( a, b );
2847 } 2838 }
2848 float_raise( float_flag_invalid ); 2839 roundData->exception |= float_flag_invalid;
2849 z.low = floatx80_default_nan_low; 2840 z.low = floatx80_default_nan_low;
2850 z.high = floatx80_default_nan_high; 2841 z.high = floatx80_default_nan_high;
2851 return z; 2842 return z;
@@ -2857,7 +2848,7 @@ static floatx80 subFloatx80Sigs( floatx80 a, floatx80 b, flag zSign )
2857 zSig1 = 0; 2848 zSig1 = 0;
2858 if ( bSig < aSig ) goto aBigger; 2849 if ( bSig < aSig ) goto aBigger;
2859 if ( aSig < bSig ) goto bBigger; 2850 if ( aSig < bSig ) goto bBigger;
2860 return packFloatx80( float_rounding_mode == float_round_down, 0, 0 ); 2851 return packFloatx80( roundData->mode == float_round_down, 0, 0 );
2861 bExpBigger: 2852 bExpBigger:
2862 if ( bExp == 0x7FFF ) { 2853 if ( bExp == 0x7FFF ) {
2863 if ( (bits64) ( bSig<<1 ) ) return propagateFloatx80NaN( a, b ); 2854 if ( (bits64) ( bSig<<1 ) ) return propagateFloatx80NaN( a, b );
@@ -2883,7 +2874,7 @@ static floatx80 subFloatx80Sigs( floatx80 a, floatx80 b, flag zSign )
2883 normalizeRoundAndPack: 2874 normalizeRoundAndPack:
2884 return 2875 return
2885 normalizeRoundAndPackFloatx80( 2876 normalizeRoundAndPackFloatx80(
2886 floatx80_rounding_precision, zSign, zExp, zSig0, zSig1 ); 2877 roundData, zSign, zExp, zSig0, zSig1 );
2887 2878
2888} 2879}
2889 2880
@@ -2894,17 +2885,17 @@ values `a' and `b'. The operation is performed according to the IEC/IEEE
2894Standard for Binary Floating-point Arithmetic. 2885Standard for Binary Floating-point Arithmetic.
2895------------------------------------------------------------------------------- 2886-------------------------------------------------------------------------------
2896*/ 2887*/
2897floatx80 floatx80_add( floatx80 a, floatx80 b ) 2888floatx80 floatx80_add( struct roundingData *roundData, floatx80 a, floatx80 b )
2898{ 2889{
2899 flag aSign, bSign; 2890 flag aSign, bSign;
2900 2891
2901 aSign = extractFloatx80Sign( a ); 2892 aSign = extractFloatx80Sign( a );
2902 bSign = extractFloatx80Sign( b ); 2893 bSign = extractFloatx80Sign( b );
2903 if ( aSign == bSign ) { 2894 if ( aSign == bSign ) {
2904 return addFloatx80Sigs( a, b, aSign ); 2895 return addFloatx80Sigs( roundData, a, b, aSign );
2905 } 2896 }
2906 else { 2897 else {
2907 return subFloatx80Sigs( a, b, aSign ); 2898 return subFloatx80Sigs( roundData, a, b, aSign );
2908 } 2899 }
2909 2900
2910} 2901}
@@ -2916,17 +2907,17 @@ point values `a' and `b'. The operation is performed according to the
2916IEC/IEEE Standard for Binary Floating-point Arithmetic. 2907IEC/IEEE Standard for Binary Floating-point Arithmetic.
2917------------------------------------------------------------------------------- 2908-------------------------------------------------------------------------------
2918*/ 2909*/
2919floatx80 floatx80_sub( floatx80 a, floatx80 b ) 2910floatx80 floatx80_sub( struct roundingData *roundData, floatx80 a, floatx80 b )
2920{ 2911{
2921 flag aSign, bSign; 2912 flag aSign, bSign;
2922 2913
2923 aSign = extractFloatx80Sign( a ); 2914 aSign = extractFloatx80Sign( a );
2924 bSign = extractFloatx80Sign( b ); 2915 bSign = extractFloatx80Sign( b );
2925 if ( aSign == bSign ) { 2916 if ( aSign == bSign ) {
2926 return subFloatx80Sigs( a, b, aSign ); 2917 return subFloatx80Sigs( roundData, a, b, aSign );
2927 } 2918 }
2928 else { 2919 else {
2929 return addFloatx80Sigs( a, b, aSign ); 2920 return addFloatx80Sigs( roundData, a, b, aSign );
2930 } 2921 }
2931 2922
2932} 2923}
@@ -2938,7 +2929,7 @@ point values `a' and `b'. The operation is performed according to the
2938IEC/IEEE Standard for Binary Floating-point Arithmetic. 2929IEC/IEEE Standard for Binary Floating-point Arithmetic.
2939------------------------------------------------------------------------------- 2930-------------------------------------------------------------------------------
2940*/ 2931*/
2941floatx80 floatx80_mul( floatx80 a, floatx80 b ) 2932floatx80 floatx80_mul( struct roundingData *roundData, floatx80 a, floatx80 b )
2942{ 2933{
2943 flag aSign, bSign, zSign; 2934 flag aSign, bSign, zSign;
2944 int32 aExp, bExp, zExp; 2935 int32 aExp, bExp, zExp;
@@ -2964,7 +2955,7 @@ floatx80 floatx80_mul( floatx80 a, floatx80 b )
2964 if ( (bits64) ( bSig<<1 ) ) return propagateFloatx80NaN( a, b ); 2955 if ( (bits64) ( bSig<<1 ) ) return propagateFloatx80NaN( a, b );
2965 if ( ( aExp | aSig ) == 0 ) { 2956 if ( ( aExp | aSig ) == 0 ) {
2966 invalid: 2957 invalid:
2967 float_raise( float_flag_invalid ); 2958 roundData->exception |= float_flag_invalid;
2968 z.low = floatx80_default_nan_low; 2959 z.low = floatx80_default_nan_low;
2969 z.high = floatx80_default_nan_high; 2960 z.high = floatx80_default_nan_high;
2970 return z; 2961 return z;
@@ -2987,7 +2978,7 @@ floatx80 floatx80_mul( floatx80 a, floatx80 b )
2987 } 2978 }
2988 return 2979 return
2989 roundAndPackFloatx80( 2980 roundAndPackFloatx80(
2990 floatx80_rounding_precision, zSign, zExp, zSig0, zSig1 ); 2981 roundData, zSign, zExp, zSig0, zSig1 );
2991 2982
2992} 2983}
2993 2984
@@ -2998,7 +2989,7 @@ value `a' by the corresponding value `b'. The operation is performed
2998according to the IEC/IEEE Standard for Binary Floating-point Arithmetic. 2989according to the IEC/IEEE Standard for Binary Floating-point Arithmetic.
2999------------------------------------------------------------------------------- 2990-------------------------------------------------------------------------------
3000*/ 2991*/
3001floatx80 floatx80_div( floatx80 a, floatx80 b ) 2992floatx80 floatx80_div( struct roundingData *roundData, floatx80 a, floatx80 b )
3002{ 2993{
3003 flag aSign, bSign, zSign; 2994 flag aSign, bSign, zSign;
3004 int32 aExp, bExp, zExp; 2995 int32 aExp, bExp, zExp;
@@ -3029,12 +3020,12 @@ floatx80 floatx80_div( floatx80 a, floatx80 b )
3029 if ( bSig == 0 ) { 3020 if ( bSig == 0 ) {
3030 if ( ( aExp | aSig ) == 0 ) { 3021 if ( ( aExp | aSig ) == 0 ) {
3031 invalid: 3022 invalid:
3032 float_raise( float_flag_invalid ); 3023 roundData->exception |= float_flag_invalid;
3033 z.low = floatx80_default_nan_low; 3024 z.low = floatx80_default_nan_low;
3034 z.high = floatx80_default_nan_high; 3025 z.high = floatx80_default_nan_high;
3035 return z; 3026 return z;
3036 } 3027 }
3037 float_raise( float_flag_divbyzero ); 3028 roundData->exception |= float_flag_divbyzero;
3038 return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) ); 3029 return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
3039 } 3030 }
3040 normalizeFloatx80Subnormal( bSig, &bExp, &bSig ); 3031 normalizeFloatx80Subnormal( bSig, &bExp, &bSig );
@@ -3068,7 +3059,7 @@ floatx80 floatx80_div( floatx80 a, floatx80 b )
3068 } 3059 }
3069 return 3060 return
3070 roundAndPackFloatx80( 3061 roundAndPackFloatx80(
3071 floatx80_rounding_precision, zSign, zExp, zSig0, zSig1 ); 3062 roundData, zSign, zExp, zSig0, zSig1 );
3072 3063
3073} 3064}
3074 3065
@@ -3079,7 +3070,7 @@ Returns the remainder of the extended double-precision floating-point value
3079according to the IEC/IEEE Standard for Binary Floating-point Arithmetic. 3070according to the IEC/IEEE Standard for Binary Floating-point Arithmetic.
3080------------------------------------------------------------------------------- 3071-------------------------------------------------------------------------------
3081*/ 3072*/
3082floatx80 floatx80_rem( floatx80 a, floatx80 b ) 3073floatx80 floatx80_rem( struct roundingData *roundData, floatx80 a, floatx80 b )
3083{ 3074{
3084 flag aSign, bSign, zSign; 3075 flag aSign, bSign, zSign;
3085 int32 aExp, bExp, expDiff; 3076 int32 aExp, bExp, expDiff;
@@ -3107,7 +3098,7 @@ floatx80 floatx80_rem( floatx80 a, floatx80 b )
3107 if ( bExp == 0 ) { 3098 if ( bExp == 0 ) {
3108 if ( bSig == 0 ) { 3099 if ( bSig == 0 ) {
3109 invalid: 3100 invalid:
3110 float_raise( float_flag_invalid ); 3101 roundData->exception |= float_flag_invalid;
3111 z.low = floatx80_default_nan_low; 3102 z.low = floatx80_default_nan_low;
3112 z.high = floatx80_default_nan_high; 3103 z.high = floatx80_default_nan_high;
3113 return z; 3104 return z;
@@ -3164,9 +3155,10 @@ floatx80 floatx80_rem( floatx80 a, floatx80 b )
3164 aSig1 = alternateASig1; 3155 aSig1 = alternateASig1;
3165 zSign = ! zSign; 3156 zSign = ! zSign;
3166 } 3157 }
3158
3167 return 3159 return
3168 normalizeRoundAndPackFloatx80( 3160 normalizeRoundAndPackFloatx80(
3169 80, zSign, bExp + expDiff, aSig0, aSig1 ); 3161 roundData, zSign, bExp + expDiff, aSig0, aSig1 );
3170 3162
3171} 3163}
3172 3164
@@ -3177,7 +3169,7 @@ value `a'. The operation is performed according to the IEC/IEEE Standard
3177for Binary Floating-point Arithmetic. 3169for Binary Floating-point Arithmetic.
3178------------------------------------------------------------------------------- 3170-------------------------------------------------------------------------------
3179*/ 3171*/
3180floatx80 floatx80_sqrt( floatx80 a ) 3172floatx80 floatx80_sqrt( struct roundingData *roundData, floatx80 a )
3181{ 3173{
3182 flag aSign; 3174 flag aSign;
3183 int32 aExp, zExp; 3175 int32 aExp, zExp;
@@ -3197,7 +3189,7 @@ floatx80 floatx80_sqrt( floatx80 a )
3197 if ( aSign ) { 3189 if ( aSign ) {
3198 if ( ( aExp | aSig0 ) == 0 ) return a; 3190 if ( ( aExp | aSig0 ) == 0 ) return a;
3199 invalid: 3191 invalid:
3200 float_raise( float_flag_invalid ); 3192 roundData->exception |= float_flag_invalid;
3201 z.low = floatx80_default_nan_low; 3193 z.low = floatx80_default_nan_low;
3202 z.high = floatx80_default_nan_high; 3194 z.high = floatx80_default_nan_high;
3203 return z; 3195 return z;
@@ -3242,7 +3234,7 @@ floatx80 floatx80_sqrt( floatx80 a )
3242 } 3234 }
3243 return 3235 return
3244 roundAndPackFloatx80( 3236 roundAndPackFloatx80(
3245 floatx80_rounding_precision, 0, zExp, zSig0, zSig1 ); 3237 roundData, 0, zExp, zSig0, zSig1 );
3246 3238
3247} 3239}
3248 3240
@@ -3264,7 +3256,7 @@ flag floatx80_eq( floatx80 a, floatx80 b )
3264 ) { 3256 ) {
3265 if ( floatx80_is_signaling_nan( a ) 3257 if ( floatx80_is_signaling_nan( a )
3266 || floatx80_is_signaling_nan( b ) ) { 3258 || floatx80_is_signaling_nan( b ) ) {
3267 float_raise( float_flag_invalid ); 3259 roundData->exception |= float_flag_invalid;
3268 } 3260 }
3269 return 0; 3261 return 0;
3270 } 3262 }
@@ -3294,7 +3286,7 @@ flag floatx80_le( floatx80 a, floatx80 b )
3294 || ( ( extractFloatx80Exp( b ) == 0x7FFF ) 3286 || ( ( extractFloatx80Exp( b ) == 0x7FFF )
3295 && (bits64) ( extractFloatx80Frac( b )<<1 ) ) 3287 && (bits64) ( extractFloatx80Frac( b )<<1 ) )
3296 ) { 3288 ) {
3297 float_raise( float_flag_invalid ); 3289 roundData->exception |= float_flag_invalid;
3298 return 0; 3290 return 0;
3299 } 3291 }
3300 aSign = extractFloatx80Sign( a ); 3292 aSign = extractFloatx80Sign( a );
@@ -3328,7 +3320,7 @@ flag floatx80_lt( floatx80 a, floatx80 b )
3328 || ( ( extractFloatx80Exp( b ) == 0x7FFF ) 3320 || ( ( extractFloatx80Exp( b ) == 0x7FFF )
3329 && (bits64) ( extractFloatx80Frac( b )<<1 ) ) 3321 && (bits64) ( extractFloatx80Frac( b )<<1 ) )
3330 ) { 3322 ) {
3331 float_raise( float_flag_invalid ); 3323 roundData->exception |= float_flag_invalid;
3332 return 0; 3324 return 0;
3333 } 3325 }
3334 aSign = extractFloatx80Sign( a ); 3326 aSign = extractFloatx80Sign( a );
@@ -3361,7 +3353,7 @@ flag floatx80_eq_signaling( floatx80 a, floatx80 b )
3361 || ( ( extractFloatx80Exp( b ) == 0x7FFF ) 3353 || ( ( extractFloatx80Exp( b ) == 0x7FFF )
3362 && (bits64) ( extractFloatx80Frac( b )<<1 ) ) 3354 && (bits64) ( extractFloatx80Frac( b )<<1 ) )
3363 ) { 3355 ) {
3364 float_raise( float_flag_invalid ); 3356 roundData->exception |= float_flag_invalid;
3365 return 0; 3357 return 0;
3366 } 3358 }
3367 return 3359 return
@@ -3392,7 +3384,7 @@ flag floatx80_le_quiet( floatx80 a, floatx80 b )
3392 ) { 3384 ) {
3393 if ( floatx80_is_signaling_nan( a ) 3385 if ( floatx80_is_signaling_nan( a )
3394 || floatx80_is_signaling_nan( b ) ) { 3386 || floatx80_is_signaling_nan( b ) ) {
3395 float_raise( float_flag_invalid ); 3387 roundData->exception |= float_flag_invalid;
3396 } 3388 }
3397 return 0; 3389 return 0;
3398 } 3390 }
@@ -3429,7 +3421,7 @@ flag floatx80_lt_quiet( floatx80 a, floatx80 b )
3429 ) { 3421 ) {
3430 if ( floatx80_is_signaling_nan( a ) 3422 if ( floatx80_is_signaling_nan( a )
3431 || floatx80_is_signaling_nan( b ) ) { 3423 || floatx80_is_signaling_nan( b ) ) {
3432 float_raise( float_flag_invalid ); 3424 roundData->exception |= float_flag_invalid;
3433 } 3425 }
3434 return 0; 3426 return 0;
3435 } 3427 }
diff --git a/arch/arm/nwfpe/softfloat.h b/arch/arm/nwfpe/softfloat.h
index 1e1743173899..1c8799b9ee4d 100644
--- a/arch/arm/nwfpe/softfloat.h
+++ b/arch/arm/nwfpe/softfloat.h
@@ -74,7 +74,7 @@ enum {
74Software IEC/IEEE floating-point rounding mode. 74Software IEC/IEEE floating-point rounding mode.
75------------------------------------------------------------------------------- 75-------------------------------------------------------------------------------
76*/ 76*/
77extern signed char float_rounding_mode; 77//extern int8 float_rounding_mode;
78enum { 78enum {
79 float_round_nearest_even = 0, 79 float_round_nearest_even = 0,
80 float_round_to_zero = 1, 80 float_round_to_zero = 1,
@@ -86,7 +86,6 @@ enum {
86------------------------------------------------------------------------------- 86-------------------------------------------------------------------------------
87Software IEC/IEEE floating-point exception flags. 87Software IEC/IEEE floating-point exception flags.
88------------------------------------------------------------------------------- 88-------------------------------------------------------------------------------
89extern signed char float_exception_flags;
90enum { 89enum {
91 float_flag_inexact = 1, 90 float_flag_inexact = 1,
92 float_flag_underflow = 2, 91 float_flag_underflow = 2,
@@ -99,7 +98,6 @@ ScottB: November 4, 1998
99Changed the enumeration to match the bit order in the FPA11. 98Changed the enumeration to match the bit order in the FPA11.
100*/ 99*/
101 100
102extern signed char float_exception_flags;
103enum { 101enum {
104 float_flag_invalid = 1, 102 float_flag_invalid = 1,
105 float_flag_divbyzero = 2, 103 float_flag_divbyzero = 2,
@@ -121,7 +119,7 @@ void float_raise( signed char );
121Software IEC/IEEE integer-to-floating-point conversion routines. 119Software IEC/IEEE integer-to-floating-point conversion routines.
122------------------------------------------------------------------------------- 120-------------------------------------------------------------------------------
123*/ 121*/
124float32 int32_to_float32( signed int ); 122float32 int32_to_float32( struct roundingData *, signed int );
125float64 int32_to_float64( signed int ); 123float64 int32_to_float64( signed int );
126#ifdef FLOATX80 124#ifdef FLOATX80
127floatx80 int32_to_floatx80( signed int ); 125floatx80 int32_to_floatx80( signed int );
@@ -132,7 +130,7 @@ floatx80 int32_to_floatx80( signed int );
132Software IEC/IEEE single-precision conversion routines. 130Software IEC/IEEE single-precision conversion routines.
133------------------------------------------------------------------------------- 131-------------------------------------------------------------------------------
134*/ 132*/
135signed int float32_to_int32( float32 ); 133signed int float32_to_int32( struct roundingData *, float32 );
136signed int float32_to_int32_round_to_zero( float32 ); 134signed int float32_to_int32_round_to_zero( float32 );
137float64 float32_to_float64( float32 ); 135float64 float32_to_float64( float32 );
138#ifdef FLOATX80 136#ifdef FLOATX80
@@ -144,13 +142,13 @@ floatx80 float32_to_floatx80( float32 );
144Software IEC/IEEE single-precision operations. 142Software IEC/IEEE single-precision operations.
145------------------------------------------------------------------------------- 143-------------------------------------------------------------------------------
146*/ 144*/
147float32 float32_round_to_int( float32 ); 145float32 float32_round_to_int( struct roundingData*, float32 );
148float32 float32_add( float32, float32 ); 146float32 float32_add( struct roundingData *, float32, float32 );
149float32 float32_sub( float32, float32 ); 147float32 float32_sub( struct roundingData *, float32, float32 );
150float32 float32_mul( float32, float32 ); 148float32 float32_mul( struct roundingData *, float32, float32 );
151float32 float32_div( float32, float32 ); 149float32 float32_div( struct roundingData *, float32, float32 );
152float32 float32_rem( float32, float32 ); 150float32 float32_rem( struct roundingData *, float32, float32 );
153float32 float32_sqrt( float32 ); 151float32 float32_sqrt( struct roundingData*, float32 );
154char float32_eq( float32, float32 ); 152char float32_eq( float32, float32 );
155char float32_le( float32, float32 ); 153char float32_le( float32, float32 );
156char float32_lt( float32, float32 ); 154char float32_lt( float32, float32 );
@@ -164,9 +162,9 @@ char float32_is_signaling_nan( float32 );
164Software IEC/IEEE double-precision conversion routines. 162Software IEC/IEEE double-precision conversion routines.
165------------------------------------------------------------------------------- 163-------------------------------------------------------------------------------
166*/ 164*/
167signed int float64_to_int32( float64 ); 165signed int float64_to_int32( struct roundingData *, float64 );
168signed int float64_to_int32_round_to_zero( float64 ); 166signed int float64_to_int32_round_to_zero( float64 );
169float32 float64_to_float32( float64 ); 167float32 float64_to_float32( struct roundingData *, float64 );
170#ifdef FLOATX80 168#ifdef FLOATX80
171floatx80 float64_to_floatx80( float64 ); 169floatx80 float64_to_floatx80( float64 );
172#endif 170#endif
@@ -176,13 +174,13 @@ floatx80 float64_to_floatx80( float64 );
176Software IEC/IEEE double-precision operations. 174Software IEC/IEEE double-precision operations.
177------------------------------------------------------------------------------- 175-------------------------------------------------------------------------------
178*/ 176*/
179float64 float64_round_to_int( float64 ); 177float64 float64_round_to_int( struct roundingData *, float64 );
180float64 float64_add( float64, float64 ); 178float64 float64_add( struct roundingData *, float64, float64 );
181float64 float64_sub( float64, float64 ); 179float64 float64_sub( struct roundingData *, float64, float64 );
182float64 float64_mul( float64, float64 ); 180float64 float64_mul( struct roundingData *, float64, float64 );
183float64 float64_div( float64, float64 ); 181float64 float64_div( struct roundingData *, float64, float64 );
184float64 float64_rem( float64, float64 ); 182float64 float64_rem( struct roundingData *, float64, float64 );
185float64 float64_sqrt( float64 ); 183float64 float64_sqrt( struct roundingData *, float64 );
186char float64_eq( float64, float64 ); 184char float64_eq( float64, float64 );
187char float64_le( float64, float64 ); 185char float64_le( float64, float64 );
188char float64_lt( float64, float64 ); 186char float64_lt( float64, float64 );
@@ -198,31 +196,23 @@ char float64_is_signaling_nan( float64 );
198Software IEC/IEEE extended double-precision conversion routines. 196Software IEC/IEEE extended double-precision conversion routines.
199------------------------------------------------------------------------------- 197-------------------------------------------------------------------------------
200*/ 198*/
201signed int floatx80_to_int32( floatx80 ); 199signed int floatx80_to_int32( struct roundingData *, floatx80 );
202signed int floatx80_to_int32_round_to_zero( floatx80 ); 200signed int floatx80_to_int32_round_to_zero( floatx80 );
203float32 floatx80_to_float32( floatx80 ); 201float32 floatx80_to_float32( struct roundingData *, floatx80 );
204float64 floatx80_to_float64( floatx80 ); 202float64 floatx80_to_float64( struct roundingData *, floatx80 );
205
206/*
207-------------------------------------------------------------------------------
208Software IEC/IEEE extended double-precision rounding precision. Valid
209values are 32, 64, and 80.
210-------------------------------------------------------------------------------
211*/
212extern signed char floatx80_rounding_precision;
213 203
214/* 204/*
215------------------------------------------------------------------------------- 205-------------------------------------------------------------------------------
216Software IEC/IEEE extended double-precision operations. 206Software IEC/IEEE extended double-precision operations.
217------------------------------------------------------------------------------- 207-------------------------------------------------------------------------------
218*/ 208*/
219floatx80 floatx80_round_to_int( floatx80 ); 209floatx80 floatx80_round_to_int( struct roundingData *, floatx80 );
220floatx80 floatx80_add( floatx80, floatx80 ); 210floatx80 floatx80_add( struct roundingData *, floatx80, floatx80 );
221floatx80 floatx80_sub( floatx80, floatx80 ); 211floatx80 floatx80_sub( struct roundingData *, floatx80, floatx80 );
222floatx80 floatx80_mul( floatx80, floatx80 ); 212floatx80 floatx80_mul( struct roundingData *, floatx80, floatx80 );
223floatx80 floatx80_div( floatx80, floatx80 ); 213floatx80 floatx80_div( struct roundingData *, floatx80, floatx80 );
224floatx80 floatx80_rem( floatx80, floatx80 ); 214floatx80 floatx80_rem( struct roundingData *, floatx80, floatx80 );
225floatx80 floatx80_sqrt( floatx80 ); 215floatx80 floatx80_sqrt( struct roundingData *, floatx80 );
226char floatx80_eq( floatx80, floatx80 ); 216char floatx80_eq( floatx80, floatx80 );
227char floatx80_le( floatx80, floatx80 ); 217char floatx80_le( floatx80, floatx80 );
228char floatx80_lt( floatx80, floatx80 ); 218char floatx80_lt( floatx80, floatx80 );
diff --git a/arch/arm/oprofile/backtrace.c b/arch/arm/oprofile/backtrace.c
index ec58d3e2eb8b..df35c452a8bf 100644
--- a/arch/arm/oprofile/backtrace.c
+++ b/arch/arm/oprofile/backtrace.c
@@ -115,7 +115,7 @@ static int valid_kernel_stack(struct frame_tail *tail, struct pt_regs *regs)
115 return (tailaddr > stack) && (tailaddr < stack_base); 115 return (tailaddr > stack) && (tailaddr < stack_base);
116} 116}
117 117
118void arm_backtrace(struct pt_regs const *regs, unsigned int depth) 118void arm_backtrace(struct pt_regs * const regs, unsigned int depth)
119{ 119{
120 struct frame_tail *tail; 120 struct frame_tail *tail;
121 unsigned long last_address = 0; 121 unsigned long last_address = 0;
diff --git a/arch/arm/vfp/vfpdouble.c b/arch/arm/vfp/vfpdouble.c
index b801cd66b6ea..9b367a65cb4d 100644
--- a/arch/arm/vfp/vfpdouble.c
+++ b/arch/arm/vfp/vfpdouble.c
@@ -770,6 +770,9 @@ vfp_double_add(struct vfp_double *vdd, struct vfp_double *vdn,
770 if ((s64)m_sig < 0) { 770 if ((s64)m_sig < 0) {
771 vdd->sign = vfp_sign_negate(vdd->sign); 771 vdd->sign = vfp_sign_negate(vdd->sign);
772 m_sig = -m_sig; 772 m_sig = -m_sig;
773 } else if (m_sig == 0) {
774 vdd->sign = (fpscr & FPSCR_RMODE_MASK) ==
775 FPSCR_ROUND_MINUSINF ? 0x8000 : 0;
773 } 776 }
774 } else { 777 } else {
775 m_sig += vdn->significand; 778 m_sig += vdn->significand;
diff --git a/arch/arm26/mm/fault.c b/arch/arm26/mm/fault.c
index dacca8bb7744..bd6f2db608b7 100644
--- a/arch/arm26/mm/fault.c
+++ b/arch/arm26/mm/fault.c
@@ -176,12 +176,12 @@ survive:
176 * Handle the "normal" cases first - successful and sigbus 176 * Handle the "normal" cases first - successful and sigbus
177 */ 177 */
178 switch (fault) { 178 switch (fault) {
179 case 2: 179 case VM_FAULT_MAJOR:
180 tsk->maj_flt++; 180 tsk->maj_flt++;
181 return fault; 181 return fault;
182 case 1: 182 case VM_FAULT_MINOR:
183 tsk->min_flt++; 183 tsk->min_flt++;
184 case 0: 184 case VM_FAULT_SIGBUS:
185 return fault; 185 return fault;
186 } 186 }
187 187
@@ -226,14 +226,11 @@ int do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
226 /* 226 /*
227 * Handle the "normal" case first 227 * Handle the "normal" case first
228 */ 228 */
229 if (fault > 0) 229 switch (fault) {
230 case VM_FAULT_MINOR:
231 case VM_FAULT_MAJOR:
230 return 0; 232 return 0;
231 233 case VM_FAULT_SIGBUS:
232 /*
233 * We had some memory, but were unable to
234 * successfully fix up this page fault.
235 */
236 if (fault == 0){
237 goto do_sigbus; 234 goto do_sigbus;
238 } 235 }
239 236
diff --git a/arch/cris/mm/fault.c b/arch/cris/mm/fault.c
index fe1cc36b5aca..934c51078cce 100644
--- a/arch/cris/mm/fault.c
+++ b/arch/cris/mm/fault.c
@@ -284,13 +284,13 @@ do_page_fault(unsigned long address, struct pt_regs *regs,
284 */ 284 */
285 285
286 switch (handle_mm_fault(mm, vma, address, writeaccess & 1)) { 286 switch (handle_mm_fault(mm, vma, address, writeaccess & 1)) {
287 case 1: 287 case VM_FAULT_MINOR:
288 tsk->min_flt++; 288 tsk->min_flt++;
289 break; 289 break;
290 case 2: 290 case VM_FAULT_MAJOR:
291 tsk->maj_flt++; 291 tsk->maj_flt++;
292 break; 292 break;
293 case 0: 293 case VM_FAULT_SIGBUS:
294 goto do_sigbus; 294 goto do_sigbus;
295 default: 295 default:
296 goto out_of_memory; 296 goto out_of_memory;
diff --git a/arch/frv/mm/fault.c b/arch/frv/mm/fault.c
index 41d02ac48233..8b3eb50c5105 100644
--- a/arch/frv/mm/fault.c
+++ b/arch/frv/mm/fault.c
@@ -163,13 +163,13 @@ asmlinkage void do_page_fault(int datammu, unsigned long esr0, unsigned long ear
163 * the fault. 163 * the fault.
164 */ 164 */
165 switch (handle_mm_fault(mm, vma, ear0, write)) { 165 switch (handle_mm_fault(mm, vma, ear0, write)) {
166 case 1: 166 case VM_FAULT_MINOR:
167 current->min_flt++; 167 current->min_flt++;
168 break; 168 break;
169 case 2: 169 case VM_FAULT_MAJOR:
170 current->maj_flt++; 170 current->maj_flt++;
171 break; 171 break;
172 case 0: 172 case VM_FAULT_SIGBUS:
173 goto do_sigbus; 173 goto do_sigbus;
174 default: 174 default:
175 goto out_of_memory; 175 goto out_of_memory;
diff --git a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
index 963e17aa205d..60a9e54dd20e 100644
--- a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
+++ b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -442,6 +442,13 @@ acpi_cpufreq_cpu_init (
442 (u32) data->acpi_data.states[i].transition_latency); 442 (u32) data->acpi_data.states[i].transition_latency);
443 443
444 cpufreq_frequency_table_get_attr(data->freq_table, policy->cpu); 444 cpufreq_frequency_table_get_attr(data->freq_table, policy->cpu);
445
446 /*
447 * the first call to ->target() should result in us actually
448 * writing something to the appropriate registers.
449 */
450 data->resume = 1;
451
445 return (result); 452 return (result);
446 453
447 err_freqfree: 454 err_freqfree:
diff --git a/arch/i386/kernel/cpu/transmeta.c b/arch/i386/kernel/cpu/transmeta.c
index f57e5ee94943..fc426380366b 100644
--- a/arch/i386/kernel/cpu/transmeta.c
+++ b/arch/i386/kernel/cpu/transmeta.c
@@ -76,6 +76,12 @@ static void __init init_transmeta(struct cpuinfo_x86 *c)
76#define USER686 (X86_FEATURE_TSC|X86_FEATURE_CX8|X86_FEATURE_CMOV) 76#define USER686 (X86_FEATURE_TSC|X86_FEATURE_CX8|X86_FEATURE_CMOV)
77 if ( c->x86 == 5 && (c->x86_capability[0] & USER686) == USER686 ) 77 if ( c->x86 == 5 && (c->x86_capability[0] & USER686) == USER686 )
78 c->x86 = 6; 78 c->x86 = 6;
79
80#ifdef CONFIG_SYSCTL
81 /* randomize_va_space slows us down enormously;
82 it probably triggers retranslation of x86->native bytecode */
83 randomize_va_space = 0;
84#endif
79} 85}
80 86
81static void transmeta_identify(struct cpuinfo_x86 * c) 87static void transmeta_identify(struct cpuinfo_x86 * c)
diff --git a/arch/i386/kernel/syscall_table.S b/arch/i386/kernel/syscall_table.S
index 468500a7e894..9b21a31d4f4e 100644
--- a/arch/i386/kernel/syscall_table.S
+++ b/arch/i386/kernel/syscall_table.S
@@ -251,7 +251,7 @@ ENTRY(sys_call_table)
251 .long sys_io_submit 251 .long sys_io_submit
252 .long sys_io_cancel 252 .long sys_io_cancel
253 .long sys_fadvise64 /* 250 */ 253 .long sys_fadvise64 /* 250 */
254 .long sys_set_zone_reclaim 254 .long sys_ni_syscall
255 .long sys_exit_group 255 .long sys_exit_group
256 .long sys_lookup_dcookie 256 .long sys_lookup_dcookie
257 .long sys_epoll_create 257 .long sys_epoll_create
diff --git a/arch/i386/pci/acpi.c b/arch/i386/pci/acpi.c
index 2db65ec45dc3..42913f43feb0 100644
--- a/arch/i386/pci/acpi.c
+++ b/arch/i386/pci/acpi.c
@@ -30,6 +30,7 @@ static int __init pci_acpi_init(void)
30 acpi_irq_penalty_init(); 30 acpi_irq_penalty_init();
31 pcibios_scanned++; 31 pcibios_scanned++;
32 pcibios_enable_irq = acpi_pci_irq_enable; 32 pcibios_enable_irq = acpi_pci_irq_enable;
33 pcibios_disable_irq = acpi_pci_irq_disable;
33 34
34 if (pci_routeirq) { 35 if (pci_routeirq) {
35 /* 36 /*
diff --git a/arch/i386/pci/common.c b/arch/i386/pci/common.c
index 70bcd53451f6..ade5bc57c34c 100644
--- a/arch/i386/pci/common.c
+++ b/arch/i386/pci/common.c
@@ -254,3 +254,9 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
254 254
255 return pcibios_enable_irq(dev); 255 return pcibios_enable_irq(dev);
256} 256}
257
258void pcibios_disable_device (struct pci_dev *dev)
259{
260 if (pcibios_disable_irq)
261 pcibios_disable_irq(dev);
262}
diff --git a/arch/i386/pci/irq.c b/arch/i386/pci/irq.c
index d291fb7f1357..86348b68fda1 100644
--- a/arch/i386/pci/irq.c
+++ b/arch/i386/pci/irq.c
@@ -56,6 +56,7 @@ struct irq_router_handler {
56}; 56};
57 57
58int (*pcibios_enable_irq)(struct pci_dev *dev) = NULL; 58int (*pcibios_enable_irq)(struct pci_dev *dev) = NULL;
59void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
59 60
60/* 61/*
61 * Check passed address for the PCI IRQ Routing Table signature 62 * Check passed address for the PCI IRQ Routing Table signature
diff --git a/arch/i386/pci/pci.h b/arch/i386/pci/pci.h
index a80f0f55ff51..127d53ad16be 100644
--- a/arch/i386/pci/pci.h
+++ b/arch/i386/pci/pci.h
@@ -73,3 +73,4 @@ extern int pcibios_scanned;
73extern spinlock_t pci_config_lock; 73extern spinlock_t pci_config_lock;
74 74
75extern int (*pcibios_enable_irq)(struct pci_dev *dev); 75extern int (*pcibios_enable_irq)(struct pci_dev *dev);
76extern void (*pcibios_disable_irq)(struct pci_dev *dev);
diff --git a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S
index 66946f3fdac7..9be53e1ea404 100644
--- a/arch/ia64/kernel/entry.S
+++ b/arch/ia64/kernel/entry.S
@@ -1573,7 +1573,7 @@ sys_call_table:
1573 data8 sys_keyctl 1573 data8 sys_keyctl
1574 data8 sys_ioprio_set 1574 data8 sys_ioprio_set
1575 data8 sys_ioprio_get // 1275 1575 data8 sys_ioprio_get // 1275
1576 data8 sys_set_zone_reclaim 1576 data8 sys_ni_syscall
1577 data8 sys_inotify_init 1577 data8 sys_inotify_init
1578 data8 sys_inotify_add_watch 1578 data8 sys_inotify_add_watch
1579 data8 sys_inotify_rm_watch 1579 data8 sys_inotify_rm_watch
diff --git a/arch/m32r/kernel/time.c b/arch/m32r/kernel/time.c
index 3c4707280a52..8a2b77bc5749 100644
--- a/arch/m32r/kernel/time.c
+++ b/arch/m32r/kernel/time.c
@@ -205,8 +205,7 @@ static long last_rtc_update = 0;
205 * timer_interrupt() needs to keep up the real-time clock, 205 * timer_interrupt() needs to keep up the real-time clock,
206 * as well as call the "do_timer()" routine every clocktick 206 * as well as call the "do_timer()" routine every clocktick
207 */ 207 */
208static inline void 208irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
209do_timer_interrupt(int irq, void *dev_id, struct pt_regs * regs)
210{ 209{
211#ifndef CONFIG_SMP 210#ifndef CONFIG_SMP
212 profile_tick(CPU_PROFILING, regs); 211 profile_tick(CPU_PROFILING, regs);
@@ -221,6 +220,7 @@ do_timer_interrupt(int irq, void *dev_id, struct pt_regs * regs)
221 * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be 220 * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
222 * called as close as possible to 500 ms before the new second starts. 221 * called as close as possible to 500 ms before the new second starts.
223 */ 222 */
223 write_seqlock(&xtime_lock);
224 if ((time_status & STA_UNSYNC) == 0 224 if ((time_status & STA_UNSYNC) == 0
225 && xtime.tv_sec > last_rtc_update + 660 225 && xtime.tv_sec > last_rtc_update + 660
226 && (xtime.tv_nsec / 1000) >= 500000 - ((unsigned)TICK_SIZE) / 2 226 && (xtime.tv_nsec / 1000) >= 500000 - ((unsigned)TICK_SIZE) / 2
@@ -231,6 +231,7 @@ do_timer_interrupt(int irq, void *dev_id, struct pt_regs * regs)
231 else /* do it again in 60 s */ 231 else /* do it again in 60 s */
232 last_rtc_update = xtime.tv_sec - 600; 232 last_rtc_update = xtime.tv_sec - 600;
233 } 233 }
234 write_sequnlock(&xtime_lock);
234 /* As we return to user mode fire off the other CPU schedulers.. 235 /* As we return to user mode fire off the other CPU schedulers..
235 this is basically because we don't yet share IRQ's around. 236 this is basically because we don't yet share IRQ's around.
236 This message is rigged to be safe on the 386 - basically it's 237 This message is rigged to be safe on the 386 - basically it's
@@ -238,14 +239,8 @@ do_timer_interrupt(int irq, void *dev_id, struct pt_regs * regs)
238 239
239#ifdef CONFIG_SMP 240#ifdef CONFIG_SMP
240 smp_local_timer_interrupt(regs); 241 smp_local_timer_interrupt(regs);
242 smp_send_timer();
241#endif 243#endif
242}
243
244irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
245{
246 write_seqlock(&xtime_lock);
247 do_timer_interrupt(irq, NULL, regs);
248 write_sequnlock(&xtime_lock);
249 244
250 return IRQ_HANDLED; 245 return IRQ_HANDLED;
251} 246}
diff --git a/arch/m68k/mm/fault.c b/arch/m68k/mm/fault.c
index ac48b6d2aff6..aec15270d334 100644
--- a/arch/m68k/mm/fault.c
+++ b/arch/m68k/mm/fault.c
@@ -160,13 +160,13 @@ good_area:
160 printk("handle_mm_fault returns %d\n",fault); 160 printk("handle_mm_fault returns %d\n",fault);
161#endif 161#endif
162 switch (fault) { 162 switch (fault) {
163 case 1: 163 case VM_FAULT_MINOR:
164 current->min_flt++; 164 current->min_flt++;
165 break; 165 break;
166 case 2: 166 case VM_FAULT_MAJOR:
167 current->maj_flt++; 167 current->maj_flt++;
168 break; 168 break;
169 case 0: 169 case VM_FAULT_SIGBUS:
170 goto bus_err; 170 goto bus_err;
171 default: 171 default:
172 goto out_of_memory; 172 goto out_of_memory;
diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
index eaa701479f5f..0ad945d4c0a4 100644
--- a/arch/parisc/mm/fault.c
+++ b/arch/parisc/mm/fault.c
@@ -178,17 +178,17 @@ good_area:
178 */ 178 */
179 179
180 switch (handle_mm_fault(mm, vma, address, (acc_type & VM_WRITE) != 0)) { 180 switch (handle_mm_fault(mm, vma, address, (acc_type & VM_WRITE) != 0)) {
181 case 1: 181 case VM_FAULT_MINOR:
182 ++current->min_flt; 182 ++current->min_flt;
183 break; 183 break;
184 case 2: 184 case VM_FAULT_MAJOR:
185 ++current->maj_flt; 185 ++current->maj_flt;
186 break; 186 break;
187 case 0: 187 case VM_FAULT_SIGBUS:
188 /* 188 /*
189 * We ran out of memory, or some other thing happened 189 * We hit a hared mapping outside of the file, or some
190 * to us that made us unable to handle the page fault 190 * other thing happened to us that made us unable to
191 * gracefully. 191 * handle the page fault gracefully.
192 */ 192 */
193 goto bad_area; 193 goto bad_area;
194 default: 194 default:
diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig
index 2c2da9b43b7a..f6db3b385fea 100644
--- a/arch/ppc/Kconfig
+++ b/arch/ppc/Kconfig
@@ -558,6 +558,7 @@ config PPC_MULTIPLATFORM
558 558
559config APUS 559config APUS
560 bool "Amiga-APUS" 560 bool "Amiga-APUS"
561 depends on BROKEN
561 help 562 help
562 Select APUS if configuring for a PowerUP Amiga. 563 Select APUS if configuring for a PowerUP Amiga.
563 More information is available at: 564 More information is available at:
@@ -647,6 +648,7 @@ config PAL4
647 648
648config GEMINI 649config GEMINI
649 bool "Synergy-Gemini" 650 bool "Synergy-Gemini"
651 depends on BROKEN
650 help 652 help
651 Select Gemini if configuring for a Synergy Microsystems' Gemini 653 Select Gemini if configuring for a Synergy Microsystems' Gemini
652 series Single Board Computer. More information is available at: 654 series Single Board Computer. More information is available at:
diff --git a/arch/ppc/boot/simple/Makefile b/arch/ppc/boot/simple/Makefile
index 991b4cbb83c8..d4dc4fa79647 100644
--- a/arch/ppc/boot/simple/Makefile
+++ b/arch/ppc/boot/simple/Makefile
@@ -61,6 +61,12 @@ zimageinitrd-$(CONFIG_IBM_OPENBIOS) := zImage.initrd-TREE
61 end-$(CONFIG_EMBEDDEDBOOT) := embedded 61 end-$(CONFIG_EMBEDDEDBOOT) := embedded
62 misc-$(CONFIG_EMBEDDEDBOOT) := misc-embedded.o 62 misc-$(CONFIG_EMBEDDEDBOOT) := misc-embedded.o
63 63
64 zimage-$(CONFIG_BAMBOO) := zImage-TREE
65zimageinitrd-$(CONFIG_BAMBOO) := zImage.initrd-TREE
66 end-$(CONFIG_BAMBOO) := bamboo
67 entrypoint-$(CONFIG_BAMBOO) := 0x01000000
68 extra.o-$(CONFIG_BAMBOO) := pibs.o
69
64 zimage-$(CONFIG_EBONY) := zImage-TREE 70 zimage-$(CONFIG_EBONY) := zImage-TREE
65zimageinitrd-$(CONFIG_EBONY) := zImage.initrd-TREE 71zimageinitrd-$(CONFIG_EBONY) := zImage.initrd-TREE
66 end-$(CONFIG_EBONY) := ebony 72 end-$(CONFIG_EBONY) := ebony
diff --git a/arch/ppc/boot/simple/pibs.c b/arch/ppc/boot/simple/pibs.c
index 1348740e503f..67222d57c345 100644
--- a/arch/ppc/boot/simple/pibs.c
+++ b/arch/ppc/boot/simple/pibs.c
@@ -91,9 +91,11 @@ load_kernel(unsigned long load_addr, int num_words, unsigned long cksum,
91 91
92 mac64 = simple_strtoull((char *)PIBS_MAC_BASE, 0, 16); 92 mac64 = simple_strtoull((char *)PIBS_MAC_BASE, 0, 16);
93 memcpy(hold_residual->bi_enetaddr, (char *)&mac64+2, 6); 93 memcpy(hold_residual->bi_enetaddr, (char *)&mac64+2, 6);
94#ifdef CONFIG_440GX 94#if defined(CONFIG_440GX) || defined(CONFIG_440EP)
95 mac64 = simple_strtoull((char *)(PIBS_MAC_BASE+PIBS_MAC_OFFSET), 0, 16); 95 mac64 = simple_strtoull((char *)(PIBS_MAC_BASE+PIBS_MAC_OFFSET), 0, 16);
96 memcpy(hold_residual->bi_enet1addr, (char *)&mac64+2, 6); 96 memcpy(hold_residual->bi_enet1addr, (char *)&mac64+2, 6);
97#endif
98#ifdef CONFIG_440GX
97 mac64 = simple_strtoull((char *)(PIBS_MAC_BASE+PIBS_MAC_OFFSET*2), 0, 16); 99 mac64 = simple_strtoull((char *)(PIBS_MAC_BASE+PIBS_MAC_OFFSET*2), 0, 16);
98 memcpy(hold_residual->bi_enet2addr, (char *)&mac64+2, 6); 100 memcpy(hold_residual->bi_enet2addr, (char *)&mac64+2, 6);
99 mac64 = simple_strtoull((char *)(PIBS_MAC_BASE+PIBS_MAC_OFFSET*3), 0, 16); 101 mac64 = simple_strtoull((char *)(PIBS_MAC_BASE+PIBS_MAC_OFFSET*3), 0, 16);
diff --git a/arch/ppc/configs/bamboo_defconfig b/arch/ppc/configs/bamboo_defconfig
new file mode 100644
index 000000000000..0ba4e70d50b6
--- /dev/null
+++ b/arch/ppc/configs/bamboo_defconfig
@@ -0,0 +1,943 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.12
4# Tue Jun 28 15:24:25 2005
5#
6CONFIG_MMU=y
7CONFIG_GENERIC_HARDIRQS=y
8CONFIG_RWSEM_XCHGADD_ALGORITHM=y
9CONFIG_GENERIC_CALIBRATE_DELAY=y
10CONFIG_HAVE_DEC_LOCK=y
11CONFIG_PPC=y
12CONFIG_PPC32=y
13CONFIG_GENERIC_NVRAM=y
14CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
15
16#
17# Code maturity level options
18#
19CONFIG_EXPERIMENTAL=y
20CONFIG_CLEAN_COMPILE=y
21CONFIG_BROKEN_ON_SMP=y
22CONFIG_INIT_ENV_ARG_LIMIT=32
23
24#
25# General setup
26#
27CONFIG_LOCALVERSION=""
28CONFIG_SWAP=y
29CONFIG_SYSVIPC=y
30# CONFIG_POSIX_MQUEUE is not set
31# CONFIG_BSD_PROCESS_ACCT is not set
32CONFIG_SYSCTL=y
33# CONFIG_AUDIT is not set
34# CONFIG_HOTPLUG is not set
35CONFIG_KOBJECT_UEVENT=y
36# CONFIG_IKCONFIG is not set
37CONFIG_EMBEDDED=y
38CONFIG_KALLSYMS=y
39# CONFIG_KALLSYMS_ALL is not set
40# CONFIG_KALLSYMS_EXTRA_PASS is not set
41CONFIG_PRINTK=y
42CONFIG_BUG=y
43CONFIG_BASE_FULL=y
44CONFIG_FUTEX=y
45CONFIG_EPOLL=y
46# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
47CONFIG_SHMEM=y
48CONFIG_CC_ALIGN_FUNCTIONS=0
49CONFIG_CC_ALIGN_LABELS=0
50CONFIG_CC_ALIGN_LOOPS=0
51CONFIG_CC_ALIGN_JUMPS=0
52# CONFIG_TINY_SHMEM is not set
53CONFIG_BASE_SMALL=0
54
55#
56# Loadable module support
57#
58CONFIG_MODULES=y
59CONFIG_MODULE_UNLOAD=y
60# CONFIG_MODULE_FORCE_UNLOAD is not set
61CONFIG_OBSOLETE_MODPARM=y
62# CONFIG_MODVERSIONS is not set
63# CONFIG_MODULE_SRCVERSION_ALL is not set
64CONFIG_KMOD=y
65
66#
67# Processor
68#
69# CONFIG_6xx is not set
70# CONFIG_40x is not set
71CONFIG_44x=y
72# CONFIG_POWER3 is not set
73# CONFIG_POWER4 is not set
74# CONFIG_8xx is not set
75# CONFIG_E200 is not set
76# CONFIG_E500 is not set
77CONFIG_PPC_FPU=y
78CONFIG_BOOKE=y
79CONFIG_PTE_64BIT=y
80CONFIG_PHYS_64BIT=y
81# CONFIG_MATH_EMULATION is not set
82# CONFIG_KEXEC is not set
83# CONFIG_CPU_FREQ is not set
84CONFIG_4xx=y
85
86#
87# IBM 4xx options
88#
89CONFIG_BAMBOO=y
90# CONFIG_EBONY is not set
91# CONFIG_LUAN is not set
92# CONFIG_OCOTEA is not set
93CONFIG_440EP=y
94CONFIG_440=y
95CONFIG_IBM440EP_ERR42=y
96CONFIG_IBM_OCP=y
97# CONFIG_PPC4xx_DMA is not set
98CONFIG_PPC_GEN550=y
99# CONFIG_PM is not set
100CONFIG_NOT_COHERENT_CACHE=y
101
102#
103# Platform options
104#
105# CONFIG_PC_KEYBOARD is not set
106# CONFIG_SMP is not set
107# CONFIG_PREEMPT is not set
108# CONFIG_HIGHMEM is not set
109CONFIG_SELECT_MEMORY_MODEL=y
110CONFIG_FLATMEM_MANUAL=y
111# CONFIG_DISCONTIGMEM_MANUAL is not set
112# CONFIG_SPARSEMEM_MANUAL is not set
113CONFIG_FLATMEM=y
114CONFIG_FLAT_NODE_MEM_MAP=y
115CONFIG_BINFMT_ELF=y
116# CONFIG_BINFMT_MISC is not set
117CONFIG_CMDLINE_BOOL=y
118CONFIG_CMDLINE="ip=on"
119CONFIG_SECCOMP=y
120CONFIG_ISA_DMA_API=y
121
122#
123# Bus options
124#
125CONFIG_PCI=y
126CONFIG_PCI_DOMAINS=y
127# CONFIG_PCI_LEGACY_PROC is not set
128# CONFIG_PCI_NAMES is not set
129# CONFIG_PCI_DEBUG is not set
130
131#
132# PCCARD (PCMCIA/CardBus) support
133#
134# CONFIG_PCCARD is not set
135
136#
137# Advanced setup
138#
139# CONFIG_ADVANCED_OPTIONS is not set
140
141#
142# Default settings for advanced configuration options are used
143#
144CONFIG_HIGHMEM_START=0xfe000000
145CONFIG_LOWMEM_SIZE=0x30000000
146CONFIG_KERNEL_START=0xc0000000
147CONFIG_TASK_SIZE=0x80000000
148CONFIG_CONSISTENT_START=0xff100000
149CONFIG_CONSISTENT_SIZE=0x00200000
150CONFIG_BOOT_LOAD=0x01000000
151
152#
153# Device Drivers
154#
155
156#
157# Generic Driver Options
158#
159# CONFIG_STANDALONE is not set
160CONFIG_PREVENT_FIRMWARE_BUILD=y
161# CONFIG_FW_LOADER is not set
162# CONFIG_DEBUG_DRIVER is not set
163
164#
165# Memory Technology Devices (MTD)
166#
167# CONFIG_MTD is not set
168
169#
170# Parallel port support
171#
172# CONFIG_PARPORT is not set
173
174#
175# Plug and Play support
176#
177
178#
179# Block devices
180#
181# CONFIG_BLK_DEV_FD is not set
182# CONFIG_BLK_CPQ_DA is not set
183# CONFIG_BLK_CPQ_CISS_DA is not set
184# CONFIG_BLK_DEV_DAC960 is not set
185# CONFIG_BLK_DEV_UMEM is not set
186# CONFIG_BLK_DEV_COW_COMMON is not set
187# CONFIG_BLK_DEV_LOOP is not set
188# CONFIG_BLK_DEV_NBD is not set
189# CONFIG_BLK_DEV_SX8 is not set
190# CONFIG_BLK_DEV_UB is not set
191# CONFIG_BLK_DEV_RAM is not set
192CONFIG_BLK_DEV_RAM_COUNT=16
193CONFIG_INITRAMFS_SOURCE=""
194# CONFIG_LBD is not set
195# CONFIG_CDROM_PKTCDVD is not set
196
197#
198# IO Schedulers
199#
200CONFIG_IOSCHED_NOOP=y
201CONFIG_IOSCHED_AS=y
202CONFIG_IOSCHED_DEADLINE=y
203CONFIG_IOSCHED_CFQ=y
204# CONFIG_ATA_OVER_ETH is not set
205
206#
207# ATA/ATAPI/MFM/RLL support
208#
209CONFIG_IDE=y
210CONFIG_BLK_DEV_IDE=y
211
212#
213# Please see Documentation/ide.txt for help/info on IDE drives
214#
215# CONFIG_BLK_DEV_IDE_SATA is not set
216CONFIG_BLK_DEV_IDEDISK=y
217# CONFIG_IDEDISK_MULTI_MODE is not set
218# CONFIG_BLK_DEV_IDECD is not set
219# CONFIG_BLK_DEV_IDETAPE is not set
220# CONFIG_BLK_DEV_IDEFLOPPY is not set
221# CONFIG_BLK_DEV_IDESCSI is not set
222# CONFIG_IDE_TASK_IOCTL is not set
223
224#
225# IDE chipset support/bugfixes
226#
227CONFIG_IDE_GENERIC=y
228CONFIG_BLK_DEV_IDEPCI=y
229# CONFIG_IDEPCI_SHARE_IRQ is not set
230# CONFIG_BLK_DEV_OFFBOARD is not set
231# CONFIG_BLK_DEV_GENERIC is not set
232# CONFIG_BLK_DEV_OPTI621 is not set
233# CONFIG_BLK_DEV_SL82C105 is not set
234CONFIG_BLK_DEV_IDEDMA_PCI=y
235# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
236# CONFIG_IDEDMA_PCI_AUTO is not set
237# CONFIG_BLK_DEV_AEC62XX is not set
238# CONFIG_BLK_DEV_ALI15X3 is not set
239# CONFIG_BLK_DEV_AMD74XX is not set
240CONFIG_BLK_DEV_CMD64X=y
241# CONFIG_BLK_DEV_TRIFLEX is not set
242# CONFIG_BLK_DEV_CY82C693 is not set
243# CONFIG_BLK_DEV_CS5520 is not set
244# CONFIG_BLK_DEV_CS5530 is not set
245# CONFIG_BLK_DEV_HPT34X is not set
246# CONFIG_BLK_DEV_HPT366 is not set
247# CONFIG_BLK_DEV_SC1200 is not set
248# CONFIG_BLK_DEV_PIIX is not set
249# CONFIG_BLK_DEV_IT821X is not set
250# CONFIG_BLK_DEV_NS87415 is not set
251# CONFIG_BLK_DEV_PDC202XX_OLD is not set
252# CONFIG_BLK_DEV_PDC202XX_NEW is not set
253# CONFIG_BLK_DEV_SVWKS is not set
254# CONFIG_BLK_DEV_SIIMAGE is not set
255# CONFIG_BLK_DEV_SLC90E66 is not set
256# CONFIG_BLK_DEV_TRM290 is not set
257# CONFIG_BLK_DEV_VIA82CXXX is not set
258# CONFIG_IDE_ARM is not set
259CONFIG_BLK_DEV_IDEDMA=y
260# CONFIG_IDEDMA_IVB is not set
261# CONFIG_IDEDMA_AUTO is not set
262# CONFIG_BLK_DEV_HD is not set
263
264#
265# SCSI device support
266#
267CONFIG_SCSI=y
268CONFIG_SCSI_PROC_FS=y
269
270#
271# SCSI support type (disk, tape, CD-ROM)
272#
273# CONFIG_BLK_DEV_SD is not set
274CONFIG_CHR_DEV_ST=y
275# CONFIG_CHR_DEV_OSST is not set
276# CONFIG_BLK_DEV_SR is not set
277# CONFIG_CHR_DEV_SG is not set
278# CONFIG_CHR_DEV_SCH is not set
279
280#
281# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
282#
283# CONFIG_SCSI_MULTI_LUN is not set
284# CONFIG_SCSI_CONSTANTS is not set
285# CONFIG_SCSI_LOGGING is not set
286
287#
288# SCSI Transport Attributes
289#
290CONFIG_SCSI_SPI_ATTRS=y
291# CONFIG_SCSI_FC_ATTRS is not set
292# CONFIG_SCSI_ISCSI_ATTRS is not set
293
294#
295# SCSI low-level drivers
296#
297# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
298# CONFIG_SCSI_3W_9XXX is not set
299# CONFIG_SCSI_ACARD is not set
300# CONFIG_SCSI_AACRAID is not set
301# CONFIG_SCSI_AIC7XXX is not set
302# CONFIG_SCSI_AIC7XXX_OLD is not set
303# CONFIG_SCSI_AIC79XX is not set
304# CONFIG_SCSI_DPT_I2O is not set
305# CONFIG_MEGARAID_NEWGEN is not set
306# CONFIG_MEGARAID_LEGACY is not set
307# CONFIG_SCSI_SATA is not set
308# CONFIG_SCSI_BUSLOGIC is not set
309# CONFIG_SCSI_DMX3191D is not set
310# CONFIG_SCSI_EATA is not set
311# CONFIG_SCSI_FUTURE_DOMAIN is not set
312# CONFIG_SCSI_GDTH is not set
313# CONFIG_SCSI_IPS is not set
314# CONFIG_SCSI_INITIO is not set
315# CONFIG_SCSI_INIA100 is not set
316CONFIG_SCSI_SYM53C8XX_2=y
317CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=1
318CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
319CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64
320# CONFIG_SCSI_SYM53C8XX_IOMAPPED is not set
321# CONFIG_SCSI_IPR is not set
322# CONFIG_SCSI_QLOGIC_FC is not set
323# CONFIG_SCSI_QLOGIC_1280 is not set
324CONFIG_SCSI_QLA2XXX=y
325# CONFIG_SCSI_QLA21XX is not set
326# CONFIG_SCSI_QLA22XX is not set
327# CONFIG_SCSI_QLA2300 is not set
328# CONFIG_SCSI_QLA2322 is not set
329# CONFIG_SCSI_QLA6312 is not set
330# CONFIG_SCSI_LPFC is not set
331# CONFIG_SCSI_DC395x is not set
332# CONFIG_SCSI_DC390T is not set
333# CONFIG_SCSI_NSP32 is not set
334# CONFIG_SCSI_DEBUG is not set
335
336#
337# Multi-device support (RAID and LVM)
338#
339# CONFIG_MD is not set
340
341#
342# Fusion MPT device support
343#
344# CONFIG_FUSION is not set
345# CONFIG_FUSION_SPI is not set
346# CONFIG_FUSION_FC is not set
347
348#
349# IEEE 1394 (FireWire) support
350#
351# CONFIG_IEEE1394 is not set
352
353#
354# I2O device support
355#
356# CONFIG_I2O is not set
357
358#
359# Macintosh device drivers
360#
361
362#
363# Networking support
364#
365CONFIG_NET=y
366
367#
368# Networking options
369#
370CONFIG_PACKET=y
371# CONFIG_PACKET_MMAP is not set
372CONFIG_UNIX=y
373# CONFIG_NET_KEY is not set
374CONFIG_INET=y
375# CONFIG_IP_MULTICAST is not set
376# CONFIG_IP_ADVANCED_ROUTER is not set
377CONFIG_IP_FIB_HASH=y
378CONFIG_IP_PNP=y
379# CONFIG_IP_PNP_DHCP is not set
380CONFIG_IP_PNP_BOOTP=y
381# CONFIG_IP_PNP_RARP is not set
382# CONFIG_NET_IPIP is not set
383# CONFIG_NET_IPGRE is not set
384# CONFIG_ARPD is not set
385# CONFIG_SYN_COOKIES is not set
386# CONFIG_INET_AH is not set
387# CONFIG_INET_ESP is not set
388# CONFIG_INET_IPCOMP is not set
389# CONFIG_INET_TUNNEL is not set
390CONFIG_IP_TCPDIAG=y
391# CONFIG_IP_TCPDIAG_IPV6 is not set
392# CONFIG_TCP_CONG_ADVANCED is not set
393CONFIG_TCP_CONG_BIC=y
394
395#
396# IP: Virtual Server Configuration
397#
398# CONFIG_IP_VS is not set
399# CONFIG_IPV6 is not set
400CONFIG_NETFILTER=y
401# CONFIG_NETFILTER_DEBUG is not set
402
403#
404# IP: Netfilter Configuration
405#
406# CONFIG_IP_NF_CONNTRACK is not set
407# CONFIG_IP_NF_CONNTRACK_MARK is not set
408# CONFIG_IP_NF_QUEUE is not set
409# CONFIG_IP_NF_IPTABLES is not set
410# CONFIG_IP_NF_ARPTABLES is not set
411
412#
413# SCTP Configuration (EXPERIMENTAL)
414#
415# CONFIG_IP_SCTP is not set
416# CONFIG_ATM is not set
417# CONFIG_BRIDGE is not set
418# CONFIG_VLAN_8021Q is not set
419# CONFIG_DECNET is not set
420# CONFIG_LLC2 is not set
421# CONFIG_IPX is not set
422# CONFIG_ATALK is not set
423# CONFIG_X25 is not set
424# CONFIG_LAPB is not set
425# CONFIG_NET_DIVERT is not set
426# CONFIG_ECONET is not set
427# CONFIG_WAN_ROUTER is not set
428
429#
430# QoS and/or fair queueing
431#
432# CONFIG_NET_SCHED is not set
433# CONFIG_NET_CLS_ROUTE is not set
434
435#
436# Network testing
437#
438# CONFIG_NET_PKTGEN is not set
439# CONFIG_NETPOLL is not set
440# CONFIG_NET_POLL_CONTROLLER is not set
441# CONFIG_HAMRADIO is not set
442# CONFIG_IRDA is not set
443# CONFIG_BT is not set
444CONFIG_NETDEVICES=y
445# CONFIG_DUMMY is not set
446# CONFIG_BONDING is not set
447# CONFIG_EQUALIZER is not set
448# CONFIG_TUN is not set
449
450#
451# ARCnet devices
452#
453# CONFIG_ARCNET is not set
454
455#
456# Ethernet (10 or 100Mbit)
457#
458CONFIG_NET_ETHERNET=y
459CONFIG_MII=y
460# CONFIG_HAPPYMEAL is not set
461# CONFIG_SUNGEM is not set
462# CONFIG_NET_VENDOR_3COM is not set
463
464#
465# Tulip family network device support
466#
467# CONFIG_NET_TULIP is not set
468# CONFIG_HP100 is not set
469CONFIG_IBM_EMAC=y
470# CONFIG_IBM_EMAC_ERRMSG is not set
471CONFIG_IBM_EMAC_RXB=64
472CONFIG_IBM_EMAC_TXB=8
473CONFIG_IBM_EMAC_FGAP=8
474CONFIG_IBM_EMAC_SKBRES=0
475CONFIG_NET_PCI=y
476# CONFIG_PCNET32 is not set
477# CONFIG_AMD8111_ETH is not set
478# CONFIG_ADAPTEC_STARFIRE is not set
479# CONFIG_B44 is not set
480# CONFIG_FORCEDETH is not set
481# CONFIG_DGRS is not set
482CONFIG_EEPRO100=y
483# CONFIG_E100 is not set
484# CONFIG_FEALNX is not set
485CONFIG_NATSEMI=y
486# CONFIG_NE2K_PCI is not set
487# CONFIG_8139CP is not set
488# CONFIG_8139TOO is not set
489# CONFIG_SIS900 is not set
490# CONFIG_EPIC100 is not set
491# CONFIG_SUNDANCE is not set
492# CONFIG_TLAN is not set
493# CONFIG_VIA_RHINE is not set
494
495#
496# Ethernet (1000 Mbit)
497#
498# CONFIG_ACENIC is not set
499# CONFIG_DL2K is not set
500CONFIG_E1000=y
501# CONFIG_E1000_NAPI is not set
502# CONFIG_NS83820 is not set
503# CONFIG_HAMACHI is not set
504# CONFIG_YELLOWFIN is not set
505# CONFIG_R8169 is not set
506# CONFIG_SKGE is not set
507# CONFIG_SK98LIN is not set
508# CONFIG_VIA_VELOCITY is not set
509# CONFIG_TIGON3 is not set
510# CONFIG_BNX2 is not set
511
512#
513# Ethernet (10000 Mbit)
514#
515# CONFIG_IXGB is not set
516# CONFIG_S2IO is not set
517
518#
519# Token Ring devices
520#
521# CONFIG_TR is not set
522
523#
524# Wireless LAN (non-hamradio)
525#
526# CONFIG_NET_RADIO is not set
527
528#
529# Wan interfaces
530#
531# CONFIG_WAN is not set
532# CONFIG_FDDI is not set
533# CONFIG_HIPPI is not set
534# CONFIG_PPP is not set
535# CONFIG_SLIP is not set
536# CONFIG_NET_FC is not set
537# CONFIG_SHAPER is not set
538# CONFIG_NETCONSOLE is not set
539
540#
541# ISDN subsystem
542#
543# CONFIG_ISDN is not set
544
545#
546# Telephony Support
547#
548# CONFIG_PHONE is not set
549
550#
551# Input device support
552#
553CONFIG_INPUT=y
554
555#
556# Userland interfaces
557#
558CONFIG_INPUT_MOUSEDEV=y
559CONFIG_INPUT_MOUSEDEV_PSAUX=y
560CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
561CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
562# CONFIG_INPUT_JOYDEV is not set
563# CONFIG_INPUT_TSDEV is not set
564# CONFIG_INPUT_EVDEV is not set
565# CONFIG_INPUT_EVBUG is not set
566
567#
568# Input Device Drivers
569#
570# CONFIG_INPUT_KEYBOARD is not set
571# CONFIG_INPUT_MOUSE is not set
572# CONFIG_INPUT_JOYSTICK is not set
573# CONFIG_INPUT_TOUCHSCREEN is not set
574# CONFIG_INPUT_MISC is not set
575
576#
577# Hardware I/O ports
578#
579CONFIG_SERIO=y
580# CONFIG_SERIO_I8042 is not set
581# CONFIG_SERIO_SERPORT is not set
582# CONFIG_SERIO_PCIPS2 is not set
583# CONFIG_SERIO_LIBPS2 is not set
584# CONFIG_SERIO_RAW is not set
585# CONFIG_GAMEPORT is not set
586
587#
588# Character devices
589#
590# CONFIG_VT is not set
591# CONFIG_SERIAL_NONSTANDARD is not set
592
593#
594# Serial drivers
595#
596CONFIG_SERIAL_8250=y
597CONFIG_SERIAL_8250_CONSOLE=y
598CONFIG_SERIAL_8250_NR_UARTS=4
599CONFIG_SERIAL_8250_EXTENDED=y
600# CONFIG_SERIAL_8250_MANY_PORTS is not set
601CONFIG_SERIAL_8250_SHARE_IRQ=y
602# CONFIG_SERIAL_8250_DETECT_IRQ is not set
603# CONFIG_SERIAL_8250_RSA is not set
604
605#
606# Non-8250 serial port support
607#
608CONFIG_SERIAL_CORE=y
609CONFIG_SERIAL_CORE_CONSOLE=y
610# CONFIG_SERIAL_JSM is not set
611CONFIG_UNIX98_PTYS=y
612CONFIG_LEGACY_PTYS=y
613CONFIG_LEGACY_PTY_COUNT=256
614
615#
616# IPMI
617#
618# CONFIG_IPMI_HANDLER is not set
619
620#
621# Watchdog Cards
622#
623# CONFIG_WATCHDOG is not set
624# CONFIG_NVRAM is not set
625# CONFIG_GEN_RTC is not set
626# CONFIG_DTLK is not set
627# CONFIG_R3964 is not set
628# CONFIG_APPLICOM is not set
629
630#
631# Ftape, the floppy tape device driver
632#
633# CONFIG_AGP is not set
634# CONFIG_DRM is not set
635# CONFIG_RAW_DRIVER is not set
636
637#
638# TPM devices
639#
640# CONFIG_TCG_TPM is not set
641
642#
643# I2C support
644#
645# CONFIG_I2C is not set
646
647#
648# Dallas's 1-wire bus
649#
650# CONFIG_W1 is not set
651
652#
653# Misc devices
654#
655
656#
657# Multimedia devices
658#
659# CONFIG_VIDEO_DEV is not set
660
661#
662# Digital Video Broadcasting Devices
663#
664# CONFIG_DVB is not set
665
666#
667# Graphics support
668#
669# CONFIG_FB is not set
670
671#
672# Sound
673#
674# CONFIG_SOUND is not set
675
676#
677# USB support
678#
679CONFIG_USB_ARCH_HAS_HCD=y
680CONFIG_USB_ARCH_HAS_OHCI=y
681CONFIG_USB=y
682CONFIG_USB_DEBUG=y
683
684#
685# Miscellaneous USB options
686#
687# CONFIG_USB_DEVICEFS is not set
688# CONFIG_USB_BANDWIDTH is not set
689# CONFIG_USB_DYNAMIC_MINORS is not set
690# CONFIG_USB_OTG is not set
691
692#
693# USB Host Controller Drivers
694#
695# CONFIG_USB_EHCI_HCD is not set
696# CONFIG_USB_ISP116X_HCD is not set
697# CONFIG_USB_OHCI_HCD is not set
698# CONFIG_USB_UHCI_HCD is not set
699# CONFIG_USB_SL811_HCD is not set
700
701#
702# USB Device Class drivers
703#
704# CONFIG_USB_BLUETOOTH_TTY is not set
705# CONFIG_USB_ACM is not set
706# CONFIG_USB_PRINTER is not set
707
708#
709# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
710#
711# CONFIG_USB_STORAGE is not set
712
713#
714# USB Input Devices
715#
716# CONFIG_USB_HID is not set
717
718#
719# USB HID Boot Protocol drivers
720#
721# CONFIG_USB_KBD is not set
722# CONFIG_USB_MOUSE is not set
723# CONFIG_USB_AIPTEK is not set
724# CONFIG_USB_WACOM is not set
725# CONFIG_USB_ACECAD is not set
726# CONFIG_USB_KBTAB is not set
727# CONFIG_USB_POWERMATE is not set
728# CONFIG_USB_MTOUCH is not set
729# CONFIG_USB_ITMTOUCH is not set
730# CONFIG_USB_EGALAX is not set
731# CONFIG_USB_XPAD is not set
732# CONFIG_USB_ATI_REMOTE is not set
733
734#
735# USB Imaging devices
736#
737# CONFIG_USB_MDC800 is not set
738# CONFIG_USB_MICROTEK is not set
739
740#
741# USB Multimedia devices
742#
743# CONFIG_USB_DABUSB is not set
744
745#
746# Video4Linux support is needed for USB Multimedia device support
747#
748
749#
750# USB Network Adapters
751#
752# CONFIG_USB_CATC is not set
753# CONFIG_USB_KAWETH is not set
754CONFIG_USB_PEGASUS=y
755# CONFIG_USB_RTL8150 is not set
756# CONFIG_USB_USBNET is not set
757CONFIG_USB_MON=y
758
759#
760# USB port drivers
761#
762
763#
764# USB Serial Converter support
765#
766# CONFIG_USB_SERIAL is not set
767
768#
769# USB Miscellaneous drivers
770#
771# CONFIG_USB_EMI62 is not set
772# CONFIG_USB_EMI26 is not set
773# CONFIG_USB_AUERSWALD is not set
774# CONFIG_USB_RIO500 is not set
775# CONFIG_USB_LEGOTOWER is not set
776# CONFIG_USB_LCD is not set
777# CONFIG_USB_LED is not set
778# CONFIG_USB_CYTHERM is not set
779# CONFIG_USB_PHIDGETKIT is not set
780# CONFIG_USB_PHIDGETSERVO is not set
781# CONFIG_USB_IDMOUSE is not set
782
783#
784# USB DSL modem support
785#
786
787#
788# USB Gadget Support
789#
790# CONFIG_USB_GADGET is not set
791
792#
793# MMC/SD Card support
794#
795# CONFIG_MMC is not set
796
797#
798# InfiniBand support
799#
800# CONFIG_INFINIBAND is not set
801
802#
803# SN Devices
804#
805
806#
807# File systems
808#
809# CONFIG_EXT2_FS is not set
810# CONFIG_EXT3_FS is not set
811# CONFIG_JBD is not set
812# CONFIG_REISERFS_FS is not set
813# CONFIG_JFS_FS is not set
814
815#
816# XFS support
817#
818# CONFIG_XFS_FS is not set
819# CONFIG_MINIX_FS is not set
820# CONFIG_ROMFS_FS is not set
821# CONFIG_QUOTA is not set
822CONFIG_DNOTIFY=y
823# CONFIG_AUTOFS_FS is not set
824# CONFIG_AUTOFS4_FS is not set
825
826#
827# CD-ROM/DVD Filesystems
828#
829# CONFIG_ISO9660_FS is not set
830# CONFIG_UDF_FS is not set
831
832#
833# DOS/FAT/NT Filesystems
834#
835# CONFIG_MSDOS_FS is not set
836# CONFIG_VFAT_FS is not set
837# CONFIG_NTFS_FS is not set
838
839#
840# Pseudo filesystems
841#
842CONFIG_PROC_FS=y
843CONFIG_PROC_KCORE=y
844CONFIG_SYSFS=y
845# CONFIG_DEVPTS_FS_XATTR is not set
846# CONFIG_TMPFS is not set
847# CONFIG_HUGETLB_PAGE is not set
848CONFIG_RAMFS=y
849
850#
851# Miscellaneous filesystems
852#
853# CONFIG_ADFS_FS is not set
854# CONFIG_AFFS_FS is not set
855# CONFIG_HFS_FS is not set
856# CONFIG_HFSPLUS_FS is not set
857# CONFIG_BEFS_FS is not set
858# CONFIG_BFS_FS is not set
859# CONFIG_EFS_FS is not set
860# CONFIG_CRAMFS is not set
861# CONFIG_VXFS_FS is not set
862# CONFIG_HPFS_FS is not set
863# CONFIG_QNX4FS_FS is not set
864# CONFIG_SYSV_FS is not set
865# CONFIG_UFS_FS is not set
866
867#
868# Network File Systems
869#
870CONFIG_NFS_FS=y
871# CONFIG_NFS_V3 is not set
872# CONFIG_NFS_V4 is not set
873# CONFIG_NFS_DIRECTIO is not set
874# CONFIG_NFSD is not set
875CONFIG_ROOT_NFS=y
876CONFIG_LOCKD=y
877CONFIG_NFS_COMMON=y
878CONFIG_SUNRPC=y
879# CONFIG_RPCSEC_GSS_KRB5 is not set
880# CONFIG_RPCSEC_GSS_SPKM3 is not set
881# CONFIG_SMB_FS is not set
882# CONFIG_CIFS is not set
883# CONFIG_NCP_FS is not set
884# CONFIG_CODA_FS is not set
885# CONFIG_AFS_FS is not set
886
887#
888# Partition Types
889#
890# CONFIG_PARTITION_ADVANCED is not set
891CONFIG_MSDOS_PARTITION=y
892
893#
894# Native Language Support
895#
896# CONFIG_NLS is not set
897
898#
899# Library routines
900#
901# CONFIG_CRC_CCITT is not set
902CONFIG_CRC32=y
903# CONFIG_LIBCRC32C is not set
904
905#
906# Profiling support
907#
908# CONFIG_PROFILING is not set
909
910#
911# Kernel hacking
912#
913# CONFIG_PRINTK_TIME is not set
914CONFIG_DEBUG_KERNEL=y
915CONFIG_MAGIC_SYSRQ=y
916CONFIG_LOG_BUF_SHIFT=14
917# CONFIG_SCHEDSTATS is not set
918# CONFIG_DEBUG_SLAB is not set
919# CONFIG_DEBUG_SPINLOCK is not set
920# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
921# CONFIG_DEBUG_KOBJECT is not set
922CONFIG_DEBUG_INFO=y
923# CONFIG_DEBUG_FS is not set
924# CONFIG_KGDB is not set
925# CONFIG_XMON is not set
926CONFIG_BDI_SWITCH=y
927# CONFIG_SERIAL_TEXT_DEBUG is not set
928CONFIG_PPC_OCP=y
929
930#
931# Security options
932#
933# CONFIG_KEYS is not set
934# CONFIG_SECURITY is not set
935
936#
937# Cryptographic options
938#
939# CONFIG_CRYPTO is not set
940
941#
942# Hardware crypto devices
943#
diff --git a/arch/ppc/kernel/cputable.c b/arch/ppc/kernel/cputable.c
index 50936cda0af9..8a3d74f2531e 100644
--- a/arch/ppc/kernel/cputable.c
+++ b/arch/ppc/kernel/cputable.c
@@ -852,6 +852,26 @@ struct cpu_spec cpu_specs[] = {
852 852
853#endif /* CONFIG_40x */ 853#endif /* CONFIG_40x */
854#ifdef CONFIG_44x 854#ifdef CONFIG_44x
855 {
856 .pvr_mask = 0xf0000fff,
857 .pvr_value = 0x40000850,
858 .cpu_name = "440EP Rev. A",
859 .cpu_features = CPU_FTR_SPLIT_ID_CACHE |
860 CPU_FTR_USE_TB,
861 .cpu_user_features = COMMON_PPC, /* 440EP has an FPU */
862 .icache_bsize = 32,
863 .dcache_bsize = 32,
864 },
865 {
866 .pvr_mask = 0xf0000fff,
867 .pvr_value = 0x400008d3,
868 .cpu_name = "440EP Rev. B",
869 .cpu_features = CPU_FTR_SPLIT_ID_CACHE |
870 CPU_FTR_USE_TB,
871 .cpu_user_features = COMMON_PPC, /* 440EP has an FPU */
872 .icache_bsize = 32,
873 .dcache_bsize = 32,
874 },
855 { /* 440GP Rev. B */ 875 { /* 440GP Rev. B */
856 .pvr_mask = 0xf0000fff, 876 .pvr_mask = 0xf0000fff,
857 .pvr_value = 0x40000440, 877 .pvr_value = 0x40000440,
diff --git a/arch/ppc/kernel/entry.S b/arch/ppc/kernel/entry.S
index d4df68629cc6..cb83045e2edf 100644
--- a/arch/ppc/kernel/entry.S
+++ b/arch/ppc/kernel/entry.S
@@ -215,6 +215,7 @@ syscall_dotrace_cont:
215 lwzx r10,r10,r0 /* Fetch system call handler [ptr] */ 215 lwzx r10,r10,r0 /* Fetch system call handler [ptr] */
216 mtlr r10 216 mtlr r10
217 addi r9,r1,STACK_FRAME_OVERHEAD 217 addi r9,r1,STACK_FRAME_OVERHEAD
218 PPC440EP_ERR42
218 blrl /* Call handler */ 219 blrl /* Call handler */
219 .globl ret_from_syscall 220 .globl ret_from_syscall
220ret_from_syscall: 221ret_from_syscall:
diff --git a/arch/ppc/kernel/head_44x.S b/arch/ppc/kernel/head_44x.S
index 6c7ae6052464..69ff3a9961e8 100644
--- a/arch/ppc/kernel/head_44x.S
+++ b/arch/ppc/kernel/head_44x.S
@@ -179,24 +179,26 @@ skpinv: addi r4,r4,1 /* Increment */
1794: 1794:
180#ifdef CONFIG_SERIAL_TEXT_DEBUG 180#ifdef CONFIG_SERIAL_TEXT_DEBUG
181 /* 181 /*
182 * Add temporary UART mapping for early debug. This 182 * Add temporary UART mapping for early debug.
183 * mapping must be identical to that used by the early 183 * We can map UART registers wherever we want as long as they don't
184 * bootloader code since the same asm/serial.h parameters 184 * interfere with other system mappings (e.g. with pinned entries).
185 * are used for polled operation. 185 * For an example of how we handle this - see ocotea.h. --ebs
186 */ 186 */
187 /* pageid fields */ 187 /* pageid fields */
188 lis r3,UART0_IO_BASE@h 188 lis r3,UART0_IO_BASE@h
189 ori r3,r3,PPC44x_TLB_VALID | PPC44x_TLB_256M 189 ori r3,r3,PPC44x_TLB_VALID | PPC44x_TLB_4K
190 190
191 /* xlat fields */ 191 /* xlat fields */
192 lis r4,UART0_PHYS_IO_BASE@h /* RPN depends on SoC */ 192 lis r4,UART0_PHYS_IO_BASE@h /* RPN depends on SoC */
193#ifndef CONFIG_440EP
193 ori r4,r4,0x0001 /* ERPN is 1 for second 4GB page */ 194 ori r4,r4,0x0001 /* ERPN is 1 for second 4GB page */
195#endif
194 196
195 /* attrib fields */ 197 /* attrib fields */
196 li r5,0 198 li r5,0
197 ori r5,r5,(PPC44x_TLB_SW | PPC44x_TLB_SR | PPC44x_TLB_I | PPC44x_TLB_G) 199 ori r5,r5,(PPC44x_TLB_SW | PPC44x_TLB_SR | PPC44x_TLB_I | PPC44x_TLB_G)
198 200
199 li r0,1 /* TLB slot 1 */ 201 li r0,0 /* TLB slot 0 */
200 202
201 tlbwe r3,r0,PPC44x_TLB_PAGEID /* Load the pageid fields */ 203 tlbwe r3,r0,PPC44x_TLB_PAGEID /* Load the pageid fields */
202 tlbwe r4,r0,PPC44x_TLB_XLAT /* Load the translation fields */ 204 tlbwe r4,r0,PPC44x_TLB_XLAT /* Load the translation fields */
@@ -228,6 +230,16 @@ skpinv: addi r4,r4,1 /* Increment */
228 lis r4,interrupt_base@h /* IVPR only uses the high 16-bits */ 230 lis r4,interrupt_base@h /* IVPR only uses the high 16-bits */
229 mtspr SPRN_IVPR,r4 231 mtspr SPRN_IVPR,r4
230 232
233#ifdef CONFIG_440EP
234 /* Clear DAPUIB flag in CCR0 (enable APU between CPU and FPU) */
235 mfspr r2,SPRN_CCR0
236 lis r3,0xffef
237 ori r3,r3,0xffff
238 and r2,r2,r3
239 mtspr SPRN_CCR0,r2
240 isync
241#endif
242
231 /* 243 /*
232 * This is where the main kernel code starts. 244 * This is where the main kernel code starts.
233 */ 245 */
diff --git a/arch/ppc/kernel/misc.S b/arch/ppc/kernel/misc.S
index 191a8def3bdb..ce71b4a01585 100644
--- a/arch/ppc/kernel/misc.S
+++ b/arch/ppc/kernel/misc.S
@@ -1145,6 +1145,7 @@ _GLOBAL(kernel_thread)
1145 stwu r0,-16(r1) 1145 stwu r0,-16(r1)
1146 mtlr r30 /* fn addr in lr */ 1146 mtlr r30 /* fn addr in lr */
1147 mr r3,r31 /* load arg and call fn */ 1147 mr r3,r31 /* load arg and call fn */
1148 PPC440EP_ERR42
1148 blrl 1149 blrl
1149 li r0,__NR_exit /* exit if function returns */ 1150 li r0,__NR_exit /* exit if function returns */
1150 li r3,0 1151 li r3,0
@@ -1451,3 +1452,6 @@ _GLOBAL(sys_call_table)
1451 .long sys_waitid 1452 .long sys_waitid
1452 .long sys_ioprio_set 1453 .long sys_ioprio_set
1453 .long sys_ioprio_get 1454 .long sys_ioprio_get
1455 .long sys_inotify_init /* 275 */
1456 .long sys_inotify_add_watch
1457 .long sys_inotify_rm_watch
diff --git a/arch/ppc/platforms/4xx/Kconfig b/arch/ppc/platforms/4xx/Kconfig
index a0612a86455a..f7c045764e04 100644
--- a/arch/ppc/platforms/4xx/Kconfig
+++ b/arch/ppc/platforms/4xx/Kconfig
@@ -68,6 +68,11 @@ choice
68 depends on 44x 68 depends on 44x
69 default EBONY 69 default EBONY
70 70
71config BAMBOO
72 bool "Bamboo"
73 help
74 This option enables support for the IBM PPC440EP evaluation board.
75
71config EBONY 76config EBONY
72 bool "Ebony" 77 bool "Ebony"
73 help 78 help
@@ -98,6 +103,12 @@ config NP405H
98 depends on ASH 103 depends on ASH
99 default y 104 default y
100 105
106config 440EP
107 bool
108 depends on BAMBOO
109 select PPC_FPU
110 default y
111
101config 440GP 112config 440GP
102 bool 113 bool
103 depends on EBONY 114 depends on EBONY
@@ -115,7 +126,7 @@ config 440SP
115 126
116config 440 127config 440
117 bool 128 bool
118 depends on 440GP || 440SP 129 depends on 440GP || 440SP || 440EP
119 default y 130 default y
120 131
121config 440A 132config 440A
@@ -123,6 +134,11 @@ config 440A
123 depends on 440GX 134 depends on 440GX
124 default y 135 default y
125 136
137config IBM440EP_ERR42
138 bool
139 depends on 440EP
140 default y
141
126# All 405-based cores up until the 405GPR and 405EP have this errata. 142# All 405-based cores up until the 405GPR and 405EP have this errata.
127config IBM405_ERR77 143config IBM405_ERR77
128 bool 144 bool
@@ -142,7 +158,7 @@ config BOOKE
142 158
143config IBM_OCP 159config IBM_OCP
144 bool 160 bool
145 depends on ASH || BUBINGA || CPCI405 || EBONY || EP405 || LUAN || OCOTEA || REDWOOD_5 || REDWOOD_6 || SYCAMORE || WALNUT 161 depends on ASH || BAMBOO || BUBINGA || CPCI405 || EBONY || EP405 || LUAN || OCOTEA || REDWOOD_5 || REDWOOD_6 || SYCAMORE || WALNUT
146 default y 162 default y
147 163
148config XILINX_OCP 164config XILINX_OCP
diff --git a/arch/ppc/platforms/4xx/Makefile b/arch/ppc/platforms/4xx/Makefile
index ea470c6adbb6..844c3b5066e8 100644
--- a/arch/ppc/platforms/4xx/Makefile
+++ b/arch/ppc/platforms/4xx/Makefile
@@ -2,6 +2,7 @@
2# Makefile for the PowerPC 4xx linux kernel. 2# Makefile for the PowerPC 4xx linux kernel.
3 3
4obj-$(CONFIG_ASH) += ash.o 4obj-$(CONFIG_ASH) += ash.o
5obj-$(CONFIG_BAMBOO) += bamboo.o
5obj-$(CONFIG_CPCI405) += cpci405.o 6obj-$(CONFIG_CPCI405) += cpci405.o
6obj-$(CONFIG_EBONY) += ebony.o 7obj-$(CONFIG_EBONY) += ebony.o
7obj-$(CONFIG_EP405) += ep405.o 8obj-$(CONFIG_EP405) += ep405.o
@@ -19,6 +20,7 @@ obj-$(CONFIG_405GP) += ibm405gp.o
19obj-$(CONFIG_REDWOOD_5) += ibmstb4.o 20obj-$(CONFIG_REDWOOD_5) += ibmstb4.o
20obj-$(CONFIG_NP405H) += ibmnp405h.o 21obj-$(CONFIG_NP405H) += ibmnp405h.o
21obj-$(CONFIG_REDWOOD_6) += ibmstbx25.o 22obj-$(CONFIG_REDWOOD_6) += ibmstbx25.o
23obj-$(CONFIG_440EP) += ibm440ep.o
22obj-$(CONFIG_440GP) += ibm440gp.o 24obj-$(CONFIG_440GP) += ibm440gp.o
23obj-$(CONFIG_440GX) += ibm440gx.o 25obj-$(CONFIG_440GX) += ibm440gx.o
24obj-$(CONFIG_440SP) += ibm440sp.o 26obj-$(CONFIG_440SP) += ibm440sp.o
diff --git a/arch/ppc/platforms/4xx/bamboo.c b/arch/ppc/platforms/4xx/bamboo.c
new file mode 100644
index 000000000000..f116787b0b76
--- /dev/null
+++ b/arch/ppc/platforms/4xx/bamboo.c
@@ -0,0 +1,427 @@
1/*
2 * arch/ppc/platforms/4xx/bamboo.c
3 *
4 * Bamboo board specific routines
5 *
6 * Wade Farnsworth <wfarnsworth@mvista.com>
7 * Copyright 2004 MontaVista Software Inc.
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 */
14
15#include <linux/config.h>
16#include <linux/stddef.h>
17#include <linux/kernel.h>
18#include <linux/init.h>
19#include <linux/errno.h>
20#include <linux/reboot.h>
21#include <linux/pci.h>
22#include <linux/kdev_t.h>
23#include <linux/types.h>
24#include <linux/major.h>
25#include <linux/blkdev.h>
26#include <linux/console.h>
27#include <linux/delay.h>
28#include <linux/ide.h>
29#include <linux/initrd.h>
30#include <linux/irq.h>
31#include <linux/seq_file.h>
32#include <linux/root_dev.h>
33#include <linux/tty.h>
34#include <linux/serial.h>
35#include <linux/serial_core.h>
36#include <linux/ethtool.h>
37
38#include <asm/system.h>
39#include <asm/pgtable.h>
40#include <asm/page.h>
41#include <asm/dma.h>
42#include <asm/io.h>
43#include <asm/machdep.h>
44#include <asm/ocp.h>
45#include <asm/pci-bridge.h>
46#include <asm/time.h>
47#include <asm/todc.h>
48#include <asm/bootinfo.h>
49#include <asm/ppc4xx_pic.h>
50#include <asm/ppcboot.h>
51
52#include <syslib/gen550.h>
53#include <syslib/ibm440gx_common.h>
54
55/*
56 * This is a horrible kludge, we eventually need to abstract this
57 * generic PHY stuff, so the standard phy mode defines can be
58 * easily used from arch code.
59 */
60#include "../../../../drivers/net/ibm_emac/ibm_emac_phy.h"
61
62bd_t __res;
63
64static struct ibm44x_clocks clocks __initdata;
65
66/*
67 * Bamboo external IRQ triggering/polarity settings
68 */
69unsigned char ppc4xx_uic_ext_irq_cfg[] __initdata = {
70 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ0: Ethernet transceiver */
71 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* IRQ1: Expansion connector */
72 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ2: PCI slot 0 */
73 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ3: PCI slot 1 */
74 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ4: PCI slot 2 */
75 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ5: PCI slot 3 */
76 (IRQ_SENSE_EDGE | IRQ_POLARITY_NEGATIVE), /* IRQ6: SMI pushbutton */
77 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ7: EXT */
78 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ8: EXT */
79 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ9: EXT */
80};
81
82static void __init
83bamboo_calibrate_decr(void)
84{
85 unsigned int freq;
86
87 if (mfspr(SPRN_CCR1) & CCR1_TCS)
88 freq = BAMBOO_TMRCLK;
89 else
90 freq = clocks.cpu;
91
92 ibm44x_calibrate_decr(freq);
93
94}
95
96static int
97bamboo_show_cpuinfo(struct seq_file *m)
98{
99 seq_printf(m, "vendor\t\t: IBM\n");
100 seq_printf(m, "machine\t\t: PPC440EP EVB (Bamboo)\n");
101
102 return 0;
103}
104
105static inline int
106bamboo_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
107{
108 static char pci_irq_table[][4] =
109 /*
110 * PCI IDSEL/INTPIN->INTLINE
111 * A B C D
112 */
113 {
114 { 28, 28, 28, 28 }, /* IDSEL 1 - PCI Slot 0 */
115 { 27, 27, 27, 27 }, /* IDSEL 2 - PCI Slot 1 */
116 { 26, 26, 26, 26 }, /* IDSEL 3 - PCI Slot 2 */
117 { 25, 25, 25, 25 }, /* IDSEL 4 - PCI Slot 3 */
118 };
119
120 const long min_idsel = 1, max_idsel = 4, irqs_per_slot = 4;
121 return PCI_IRQ_TABLE_LOOKUP;
122}
123
124static void __init bamboo_set_emacdata(void)
125{
126 unsigned char * selection1_base;
127 struct ocp_def *def;
128 struct ocp_func_emac_data *emacdata;
129 u8 selection1_val;
130 int mode;
131
132 selection1_base = ioremap64(BAMBOO_FPGA_SELECTION1_REG_ADDR, 16);
133 selection1_val = readb(selection1_base);
134 iounmap((void *) selection1_base);
135 if (BAMBOO_SEL_MII(selection1_val))
136 mode = PHY_MODE_MII;
137 else if (BAMBOO_SEL_RMII(selection1_val))
138 mode = PHY_MODE_RMII;
139 else
140 mode = PHY_MODE_SMII;
141
142 /* Set mac_addr and phy mode for each EMAC */
143
144 def = ocp_get_one_device(OCP_VENDOR_IBM, OCP_FUNC_EMAC, 0);
145 emacdata = def->additions;
146 memcpy(emacdata->mac_addr, __res.bi_enetaddr, 6);
147 emacdata->phy_mode = mode;
148
149 def = ocp_get_one_device(OCP_VENDOR_IBM, OCP_FUNC_EMAC, 1);
150 emacdata = def->additions;
151 memcpy(emacdata->mac_addr, __res.bi_enet1addr, 6);
152 emacdata->phy_mode = mode;
153}
154
155static int
156bamboo_exclude_device(unsigned char bus, unsigned char devfn)
157{
158 return (bus == 0 && devfn == 0);
159}
160
161#define PCI_READW(offset) \
162 (readw((void *)((u32)pci_reg_base+offset)))
163
164#define PCI_WRITEW(value, offset) \
165 (writew(value, (void *)((u32)pci_reg_base+offset)))
166
167#define PCI_WRITEL(value, offset) \
168 (writel(value, (void *)((u32)pci_reg_base+offset)))
169
170static void __init
171bamboo_setup_pci(void)
172{
173 void *pci_reg_base;
174 unsigned long memory_size;
175 memory_size = ppc_md.find_end_of_memory();
176
177 pci_reg_base = ioremap64(BAMBOO_PCIL0_BASE, BAMBOO_PCIL0_SIZE);
178
179 /* Enable PCI I/O, Mem, and Busmaster cycles */
180 PCI_WRITEW(PCI_READW(PCI_COMMAND) |
181 PCI_COMMAND_MEMORY |
182 PCI_COMMAND_MASTER, PCI_COMMAND);
183
184 /* Disable region first */
185 PCI_WRITEL(0, BAMBOO_PCIL0_PMM0MA);
186
187 /* PLB starting addr: 0x00000000A0000000 */
188 PCI_WRITEL(BAMBOO_PCI_PHY_MEM_BASE, BAMBOO_PCIL0_PMM0LA);
189
190 /* PCI start addr, 0xA0000000 (PCI Address) */
191 PCI_WRITEL(BAMBOO_PCI_MEM_BASE, BAMBOO_PCIL0_PMM0PCILA);
192 PCI_WRITEL(0, BAMBOO_PCIL0_PMM0PCIHA);
193
194 /* Enable no pre-fetch, enable region */
195 PCI_WRITEL(((0xffffffff -
196 (BAMBOO_PCI_UPPER_MEM - BAMBOO_PCI_MEM_BASE)) | 0x01),
197 BAMBOO_PCIL0_PMM0MA);
198
199 /* Disable region one */
200 PCI_WRITEL(0, BAMBOO_PCIL0_PMM1MA);
201 PCI_WRITEL(0, BAMBOO_PCIL0_PMM1LA);
202 PCI_WRITEL(0, BAMBOO_PCIL0_PMM1PCILA);
203 PCI_WRITEL(0, BAMBOO_PCIL0_PMM1PCIHA);
204 PCI_WRITEL(0, BAMBOO_PCIL0_PMM1MA);
205
206 /* Disable region two */
207 PCI_WRITEL(0, BAMBOO_PCIL0_PMM2MA);
208 PCI_WRITEL(0, BAMBOO_PCIL0_PMM2LA);
209 PCI_WRITEL(0, BAMBOO_PCIL0_PMM2PCILA);
210 PCI_WRITEL(0, BAMBOO_PCIL0_PMM2PCIHA);
211 PCI_WRITEL(0, BAMBOO_PCIL0_PMM2MA);
212
213 /* Now configure the PCI->PLB windows, we only use PTM1
214 *
215 * For Inbound flow, set the window size to all available memory
216 * This is required because if size is smaller,
217 * then Eth/PCI DD would fail as PCI card not able to access
218 * the memory allocated by DD.
219 */
220
221 PCI_WRITEL(0, BAMBOO_PCIL0_PTM1MS); /* disabled region 1 */
222 PCI_WRITEL(0, BAMBOO_PCIL0_PTM1LA); /* begin of address map */
223
224 memory_size = 1 << fls(memory_size - 1);
225
226 /* Size low + Enabled */
227 PCI_WRITEL((0xffffffff - (memory_size - 1)) | 0x1, BAMBOO_PCIL0_PTM1MS);
228
229 eieio();
230 iounmap(pci_reg_base);
231}
232
233static void __init
234bamboo_setup_hose(void)
235{
236 unsigned int bar_response, bar;
237 struct pci_controller *hose;
238
239 bamboo_setup_pci();
240
241 hose = pcibios_alloc_controller();
242
243 if (!hose)
244 return;
245
246 hose->first_busno = 0;
247 hose->last_busno = 0xff;
248
249 hose->pci_mem_offset = BAMBOO_PCI_MEM_OFFSET;
250
251 pci_init_resource(&hose->io_resource,
252 BAMBOO_PCI_LOWER_IO,
253 BAMBOO_PCI_UPPER_IO,
254 IORESOURCE_IO,
255 "PCI host bridge");
256
257 pci_init_resource(&hose->mem_resources[0],
258 BAMBOO_PCI_LOWER_MEM,
259 BAMBOO_PCI_UPPER_MEM,
260 IORESOURCE_MEM,
261 "PCI host bridge");
262
263 ppc_md.pci_exclude_device = bamboo_exclude_device;
264
265 hose->io_space.start = BAMBOO_PCI_LOWER_IO;
266 hose->io_space.end = BAMBOO_PCI_UPPER_IO;
267 hose->mem_space.start = BAMBOO_PCI_LOWER_MEM;
268 hose->mem_space.end = BAMBOO_PCI_UPPER_MEM;
269 isa_io_base =
270 (unsigned long)ioremap64(BAMBOO_PCI_IO_BASE, BAMBOO_PCI_IO_SIZE);
271 hose->io_base_virt = (void *)isa_io_base;
272
273 setup_indirect_pci(hose,
274 BAMBOO_PCI_CFGA_PLB32,
275 BAMBOO_PCI_CFGD_PLB32);
276 hose->set_cfg_type = 1;
277
278 /* Zero config bars */
279 for (bar = PCI_BASE_ADDRESS_1; bar <= PCI_BASE_ADDRESS_2; bar += 4) {
280 early_write_config_dword(hose, hose->first_busno,
281 PCI_FUNC(hose->first_busno), bar,
282 0x00000000);
283 early_read_config_dword(hose, hose->first_busno,
284 PCI_FUNC(hose->first_busno), bar,
285 &bar_response);
286 }
287
288 hose->last_busno = pciauto_bus_scan(hose, hose->first_busno);
289
290 ppc_md.pci_swizzle = common_swizzle;
291 ppc_md.pci_map_irq = bamboo_map_irq;
292}
293
294TODC_ALLOC();
295
296static void __init
297bamboo_early_serial_map(void)
298{
299 struct uart_port port;
300
301 /* Setup ioremapped serial port access */
302 memset(&port, 0, sizeof(port));
303 port.membase = ioremap64(PPC440EP_UART0_ADDR, 8);
304 port.irq = 0;
305 port.uartclk = clocks.uart0;
306 port.regshift = 0;
307 port.iotype = SERIAL_IO_MEM;
308 port.flags = ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST;
309 port.line = 0;
310
311 if (early_serial_setup(&port) != 0) {
312 printk("Early serial init of port 0 failed\n");
313 }
314
315#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
316 /* Configure debug serial access */
317 gen550_init(0, &port);
318#endif
319
320 port.membase = ioremap64(PPC440EP_UART1_ADDR, 8);
321 port.irq = 1;
322 port.uartclk = clocks.uart1;
323 port.line = 1;
324
325 if (early_serial_setup(&port) != 0) {
326 printk("Early serial init of port 1 failed\n");
327 }
328
329#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
330 /* Configure debug serial access */
331 gen550_init(1, &port);
332#endif
333
334 port.membase = ioremap64(PPC440EP_UART2_ADDR, 8);
335 port.irq = 3;
336 port.uartclk = clocks.uart2;
337 port.line = 2;
338
339 if (early_serial_setup(&port) != 0) {
340 printk("Early serial init of port 2 failed\n");
341 }
342
343#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
344 /* Configure debug serial access */
345 gen550_init(2, &port);
346#endif
347
348 port.membase = ioremap64(PPC440EP_UART3_ADDR, 8);
349 port.irq = 4;
350 port.uartclk = clocks.uart3;
351 port.line = 3;
352
353 if (early_serial_setup(&port) != 0) {
354 printk("Early serial init of port 3 failed\n");
355 }
356}
357
358static void __init
359bamboo_setup_arch(void)
360{
361
362 bamboo_set_emacdata();
363
364 ibm440gx_get_clocks(&clocks, 33333333, 6 * 1843200);
365 ocp_sys_info.opb_bus_freq = clocks.opb;
366
367 /* Setup TODC access */
368 TODC_INIT(TODC_TYPE_DS1743,
369 0,
370 0,
371 ioremap64(BAMBOO_RTC_ADDR, BAMBOO_RTC_SIZE),
372 8);
373
374 /* init to some ~sane value until calibrate_delay() runs */
375 loops_per_jiffy = 50000000/HZ;
376
377 /* Setup PCI host bridge */
378 bamboo_setup_hose();
379
380#ifdef CONFIG_BLK_DEV_INITRD
381 if (initrd_start)
382 ROOT_DEV = Root_RAM0;
383 else
384#endif
385#ifdef CONFIG_ROOT_NFS
386 ROOT_DEV = Root_NFS;
387#else
388 ROOT_DEV = Root_HDA1;
389#endif
390
391 bamboo_early_serial_map();
392
393 /* Identify the system */
394 printk("IBM Bamboo port (MontaVista Software, Inc. (source@mvista.com))\n");
395}
396
397void __init platform_init(unsigned long r3, unsigned long r4,
398 unsigned long r5, unsigned long r6, unsigned long r7)
399{
400 parse_bootinfo(find_bootinfo());
401
402 /*
403 * If we were passed in a board information, copy it into the
404 * residual data area.
405 */
406 if (r3)
407 __res = *(bd_t *)(r3 + KERNELBASE);
408
409
410 ibm44x_platform_init();
411
412 ppc_md.setup_arch = bamboo_setup_arch;
413 ppc_md.show_cpuinfo = bamboo_show_cpuinfo;
414 ppc_md.get_irq = NULL; /* Set in ppc4xx_pic_init() */
415
416 ppc_md.calibrate_decr = bamboo_calibrate_decr;
417 ppc_md.time_init = todc_time_init;
418 ppc_md.set_rtc_time = todc_set_rtc_time;
419 ppc_md.get_rtc_time = todc_get_rtc_time;
420
421 ppc_md.nvram_read_val = todc_direct_read_val;
422 ppc_md.nvram_write_val = todc_direct_write_val;
423#ifdef CONFIG_KGDB
424 ppc_md.early_serial_map = bamboo_early_serial_map;
425#endif
426}
427
diff --git a/arch/ppc/platforms/4xx/bamboo.h b/arch/ppc/platforms/4xx/bamboo.h
new file mode 100644
index 000000000000..63d714504148
--- /dev/null
+++ b/arch/ppc/platforms/4xx/bamboo.h
@@ -0,0 +1,136 @@
1/*
2 * arch/ppc/platforms/bamboo.h
3 *
4 * Bamboo board definitions
5 *
6 * Wade Farnsworth <wfarnsworth@mvista.com>
7 *
8 * Copyright 2004 MontaVista Software Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 */
15
16#ifdef __KERNEL__
17#ifndef __ASM_BAMBOO_H__
18#define __ASM_BAMBOO_H__
19
20#include <linux/config.h>
21#include <platforms/4xx/ibm440ep.h>
22
23/* F/W TLB mapping used in bootloader glue to reset EMAC */
24#define PPC44x_EMAC0_MR0 0x0EF600E00
25
26/* Location of MAC addresses in PIBS image */
27#define PIBS_FLASH_BASE 0xfff00000
28#define PIBS_MAC_BASE (PIBS_FLASH_BASE+0xc0400)
29#define PIBS_MAC_SIZE 0x200
30#define PIBS_MAC_OFFSET 0x100
31
32/* Default clock rate */
33#define BAMBOO_TMRCLK 25000000
34
35/* RTC/NVRAM location */
36#define BAMBOO_RTC_ADDR 0x080000000ULL
37#define BAMBOO_RTC_SIZE 0x2000
38
39/* FPGA Registers */
40#define BAMBOO_FPGA_ADDR 0x080002000ULL
41
42#define BAMBOO_FPGA_CONFIG2_REG_ADDR (BAMBOO_FPGA_ADDR + 0x1)
43#define BAMBOO_FULL_DUPLEX_EN(x) (x & 0x08)
44#define BAMBOO_FORCE_100Mbps(x) (x & 0x04)
45#define BAMBOO_AUTONEGOTIATE(x) (x & 0x02)
46
47#define BAMBOO_FPGA_SETTING_REG_ADDR (BAMBOO_FPGA_ADDR + 0x3)
48#define BAMBOO_BOOT_SMALL_FLASH(x) (!(x & 0x80))
49#define BAMBOO_LARGE_FLASH_EN(x) (!(x & 0x40))
50#define BAMBOO_BOOT_NAND_FLASH(x) (!(x & 0x20))
51
52#define BAMBOO_FPGA_SELECTION1_REG_ADDR (BAMBOO_FPGA_ADDR + 0x4)
53#define BAMBOO_SEL_MII(x) (x & 0x80)
54#define BAMBOO_SEL_RMII(x) (x & 0x40)
55#define BAMBOO_SEL_SMII(x) (x & 0x20)
56
57/* Flash */
58#define BAMBOO_SMALL_FLASH_LOW 0x087f00000ULL
59#define BAMBOO_SMALL_FLASH_HIGH 0x0fff00000ULL
60#define BAMBOO_SMALL_FLASH_SIZE 0x100000
61#define BAMBOO_LARGE_FLASH_LOW 0x087800000ULL
62#define BAMBOO_LARGE_FLASH_HIGH1 0x0ff800000ULL
63#define BAMBOO_LARGE_FLASH_HIGH2 0x0ffc00000ULL
64#define BAMBOO_LARGE_FLASH_SIZE 0x400000
65#define BAMBOO_SRAM_LOW 0x087f00000ULL
66#define BAMBOO_SRAM_HIGH1 0x0fff00000ULL
67#define BAMBOO_SRAM_HIGH2 0x0ff800000ULL
68#define BAMBOO_SRAM_SIZE 0x100000
69#define BAMBOO_NAND_FLASH_REG_ADDR 0x090000000ULL
70#define BAMBOO_NAND_FLASH_REG_SIZE 0x2000
71
72/*
73 * Serial port defines
74 */
75#define RS_TABLE_SIZE 4
76
77#define UART0_IO_BASE 0xEF600300
78#define UART1_IO_BASE 0xEF600400
79#define UART2_IO_BASE 0xEF600500
80#define UART3_IO_BASE 0xEF600600
81
82#define BASE_BAUD 33177600/3/16
83#define UART0_INT 0
84#define UART1_INT 1
85#define UART2_INT 3
86#define UART3_INT 4
87
88#define STD_UART_OP(num) \
89 { 0, BASE_BAUD, 0, UART##num##_INT, \
90 (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST), \
91 iomem_base: UART##num##_IO_BASE, \
92 io_type: SERIAL_IO_MEM},
93
94#define SERIAL_PORT_DFNS \
95 STD_UART_OP(0) \
96 STD_UART_OP(1) \
97 STD_UART_OP(2) \
98 STD_UART_OP(3)
99
100/* PCI support */
101#define BAMBOO_PCI_CFGA_PLB32 0xeec00000
102#define BAMBOO_PCI_CFGD_PLB32 0xeec00004
103
104#define BAMBOO_PCI_IO_BASE 0x00000000e8000000ULL
105#define BAMBOO_PCI_IO_SIZE 0x00010000
106#define BAMBOO_PCI_MEM_OFFSET 0x00000000
107#define BAMBOO_PCI_PHY_MEM_BASE 0x00000000a0000000ULL
108
109#define BAMBOO_PCI_LOWER_IO 0x00000000
110#define BAMBOO_PCI_UPPER_IO 0x0000ffff
111#define BAMBOO_PCI_LOWER_MEM 0xa0000000
112#define BAMBOO_PCI_UPPER_MEM 0xafffffff
113#define BAMBOO_PCI_MEM_BASE 0xa0000000
114
115#define BAMBOO_PCIL0_BASE 0x00000000ef400000ULL
116#define BAMBOO_PCIL0_SIZE 0x40
117
118#define BAMBOO_PCIL0_PMM0LA 0x000
119#define BAMBOO_PCIL0_PMM0MA 0x004
120#define BAMBOO_PCIL0_PMM0PCILA 0x008
121#define BAMBOO_PCIL0_PMM0PCIHA 0x00C
122#define BAMBOO_PCIL0_PMM1LA 0x010
123#define BAMBOO_PCIL0_PMM1MA 0x014
124#define BAMBOO_PCIL0_PMM1PCILA 0x018
125#define BAMBOO_PCIL0_PMM1PCIHA 0x01C
126#define BAMBOO_PCIL0_PMM2LA 0x020
127#define BAMBOO_PCIL0_PMM2MA 0x024
128#define BAMBOO_PCIL0_PMM2PCILA 0x028
129#define BAMBOO_PCIL0_PMM2PCIHA 0x02C
130#define BAMBOO_PCIL0_PTM1MS 0x030
131#define BAMBOO_PCIL0_PTM1LA 0x034
132#define BAMBOO_PCIL0_PTM2MS 0x038
133#define BAMBOO_PCIL0_PTM2LA 0x03C
134
135#endif /* __ASM_BAMBOO_H__ */
136#endif /* __KERNEL__ */
diff --git a/arch/ppc/platforms/4xx/ebony.c b/arch/ppc/platforms/4xx/ebony.c
index cd11734ef7c5..509e69a095f0 100644
--- a/arch/ppc/platforms/4xx/ebony.c
+++ b/arch/ppc/platforms/4xx/ebony.c
@@ -7,7 +7,7 @@
7 * Copyright 2002-2005 MontaVista Software Inc. 7 * Copyright 2002-2005 MontaVista Software Inc.
8 * 8 *
9 * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> 9 * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
10 * Copyright (c) 2003, 2004 Zultys Technologies 10 * Copyright (c) 2003-2005 Zultys Technologies
11 * 11 *
12 * This program is free software; you can redistribute it and/or modify it 12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the 13 * under the terms of the GNU General Public License as published by the
@@ -50,6 +50,7 @@
50#include <asm/bootinfo.h> 50#include <asm/bootinfo.h>
51#include <asm/ppc4xx_pic.h> 51#include <asm/ppc4xx_pic.h>
52#include <asm/ppcboot.h> 52#include <asm/ppcboot.h>
53#include <asm/tlbflush.h>
53 54
54#include <syslib/gen550.h> 55#include <syslib/gen550.h>
55#include <syslib/ibm440gp_common.h> 56#include <syslib/ibm440gp_common.h>
@@ -248,6 +249,9 @@ ebony_early_serial_map(void)
248#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB) 249#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
249 /* Configure debug serial access */ 250 /* Configure debug serial access */
250 gen550_init(0, &port); 251 gen550_init(0, &port);
252
253 /* Purge TLB entry added in head_44x.S for early serial access */
254 _tlbie(UART0_IO_BASE);
251#endif 255#endif
252 256
253 port.membase = ioremap64(PPC440GP_UART1_ADDR, 8); 257 port.membase = ioremap64(PPC440GP_UART1_ADDR, 8);
diff --git a/arch/ppc/platforms/4xx/ebony.h b/arch/ppc/platforms/4xx/ebony.h
index 47c391c9174d..d08faa46a0ae 100644
--- a/arch/ppc/platforms/4xx/ebony.h
+++ b/arch/ppc/platforms/4xx/ebony.h
@@ -56,9 +56,18 @@
56 * Serial port defines 56 * Serial port defines
57 */ 57 */
58 58
59/* OpenBIOS defined UART mappings, used before early_serial_setup */ 59#if defined(__BOOTER__)
60/* OpenBIOS defined UART mappings, used by bootloader shim */
60#define UART0_IO_BASE 0xE0000200 61#define UART0_IO_BASE 0xE0000200
61#define UART1_IO_BASE 0xE0000300 62#define UART1_IO_BASE 0xE0000300
63#else
64/* head_44x.S created UART mapping, used before early_serial_setup.
65 * We cannot use default OpenBIOS UART mappings because they
66 * don't work for configurations with more than 512M RAM. --ebs
67 */
68#define UART0_IO_BASE 0xF0000200
69#define UART1_IO_BASE 0xF0000300
70#endif
62 71
63/* external Epson SG-615P */ 72/* external Epson SG-615P */
64#define BASE_BAUD 691200 73#define BASE_BAUD 691200
@@ -66,7 +75,7 @@
66#define STD_UART_OP(num) \ 75#define STD_UART_OP(num) \
67 { 0, BASE_BAUD, 0, UART##num##_INT, \ 76 { 0, BASE_BAUD, 0, UART##num##_INT, \
68 (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST), \ 77 (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST), \
69 iomem_base: UART##num##_IO_BASE, \ 78 iomem_base: (void*)UART##num##_IO_BASE, \
70 io_type: SERIAL_IO_MEM}, 79 io_type: SERIAL_IO_MEM},
71 80
72#define SERIAL_PORT_DFNS \ 81#define SERIAL_PORT_DFNS \
diff --git a/arch/ppc/platforms/4xx/ibm440ep.c b/arch/ppc/platforms/4xx/ibm440ep.c
new file mode 100644
index 000000000000..284da01f1ffd
--- /dev/null
+++ b/arch/ppc/platforms/4xx/ibm440ep.c
@@ -0,0 +1,220 @@
1/*
2 * arch/ppc/platforms/4xx/ibm440ep.c
3 *
4 * PPC440EP I/O descriptions
5 *
6 * Wade Farnsworth <wfarnsworth@mvista.com>
7 * Copyright 2004 MontaVista Software Inc.
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 *
14 */
15#include <linux/init.h>
16#include <linux/module.h>
17#include <platforms/4xx/ibm440ep.h>
18#include <asm/ocp.h>
19#include <asm/ppc4xx_pic.h>
20
21static struct ocp_func_emac_data ibm440ep_emac0_def = {
22 .rgmii_idx = -1, /* No RGMII */
23 .rgmii_mux = -1, /* No RGMII */
24 .zmii_idx = 0, /* ZMII device index */
25 .zmii_mux = 0, /* ZMII input of this EMAC */
26 .mal_idx = 0, /* MAL device index */
27 .mal_rx_chan = 0, /* MAL rx channel number */
28 .mal_tx_chan = 0, /* MAL tx channel number */
29 .wol_irq = 61, /* WOL interrupt number */
30 .mdio_idx = -1, /* No shared MDIO */
31 .tah_idx = -1, /* No TAH */
32};
33
34static struct ocp_func_emac_data ibm440ep_emac1_def = {
35 .rgmii_idx = -1, /* No RGMII */
36 .rgmii_mux = -1, /* No RGMII */
37 .zmii_idx = 0, /* ZMII device index */
38 .zmii_mux = 1, /* ZMII input of this EMAC */
39 .mal_idx = 0, /* MAL device index */
40 .mal_rx_chan = 1, /* MAL rx channel number */
41 .mal_tx_chan = 2, /* MAL tx channel number */
42 .wol_irq = 63, /* WOL interrupt number */
43 .mdio_idx = -1, /* No shared MDIO */
44 .tah_idx = -1, /* No TAH */
45};
46OCP_SYSFS_EMAC_DATA()
47
48static struct ocp_func_mal_data ibm440ep_mal0_def = {
49 .num_tx_chans = 4, /* Number of TX channels */
50 .num_rx_chans = 2, /* Number of RX channels */
51 .txeob_irq = 10, /* TX End Of Buffer IRQ */
52 .rxeob_irq = 11, /* RX End Of Buffer IRQ */
53 .txde_irq = 33, /* TX Descriptor Error IRQ */
54 .rxde_irq = 34, /* RX Descriptor Error IRQ */
55 .serr_irq = 32, /* MAL System Error IRQ */
56};
57OCP_SYSFS_MAL_DATA()
58
59static struct ocp_func_iic_data ibm440ep_iic0_def = {
60 .fast_mode = 0, /* Use standad mode (100Khz) */
61};
62
63static struct ocp_func_iic_data ibm440ep_iic1_def = {
64 .fast_mode = 0, /* Use standad mode (100Khz) */
65};
66OCP_SYSFS_IIC_DATA()
67
68struct ocp_def core_ocp[] = {
69 { .vendor = OCP_VENDOR_IBM,
70 .function = OCP_FUNC_OPB,
71 .index = 0,
72 .paddr = 0x0EF600000ULL,
73 .irq = OCP_IRQ_NA,
74 .pm = OCP_CPM_NA,
75 },
76 { .vendor = OCP_VENDOR_IBM,
77 .function = OCP_FUNC_16550,
78 .index = 0,
79 .paddr = PPC440EP_UART0_ADDR,
80 .irq = UART0_INT,
81 .pm = IBM_CPM_UART0,
82 },
83 { .vendor = OCP_VENDOR_IBM,
84 .function = OCP_FUNC_16550,
85 .index = 1,
86 .paddr = PPC440EP_UART1_ADDR,
87 .irq = UART1_INT,
88 .pm = IBM_CPM_UART1,
89 },
90 { .vendor = OCP_VENDOR_IBM,
91 .function = OCP_FUNC_16550,
92 .index = 2,
93 .paddr = PPC440EP_UART2_ADDR,
94 .irq = UART2_INT,
95 .pm = IBM_CPM_UART2,
96 },
97 { .vendor = OCP_VENDOR_IBM,
98 .function = OCP_FUNC_16550,
99 .index = 3,
100 .paddr = PPC440EP_UART3_ADDR,
101 .irq = UART3_INT,
102 .pm = IBM_CPM_UART3,
103 },
104 { .vendor = OCP_VENDOR_IBM,
105 .function = OCP_FUNC_IIC,
106 .index = 0,
107 .paddr = 0x0EF600700ULL,
108 .irq = 2,
109 .pm = IBM_CPM_IIC0,
110 .additions = &ibm440ep_iic0_def,
111 .show = &ocp_show_iic_data
112 },
113 { .vendor = OCP_VENDOR_IBM,
114 .function = OCP_FUNC_IIC,
115 .index = 1,
116 .paddr = 0x0EF600800ULL,
117 .irq = 7,
118 .pm = IBM_CPM_IIC1,
119 .additions = &ibm440ep_iic1_def,
120 .show = &ocp_show_iic_data
121 },
122 { .vendor = OCP_VENDOR_IBM,
123 .function = OCP_FUNC_GPIO,
124 .index = 0,
125 .paddr = 0x0EF600B00ULL,
126 .irq = OCP_IRQ_NA,
127 .pm = IBM_CPM_GPIO0,
128 },
129 { .vendor = OCP_VENDOR_IBM,
130 .function = OCP_FUNC_GPIO,
131 .index = 1,
132 .paddr = 0x0EF600C00ULL,
133 .irq = OCP_IRQ_NA,
134 .pm = OCP_CPM_NA,
135 },
136 { .vendor = OCP_VENDOR_IBM,
137 .function = OCP_FUNC_MAL,
138 .paddr = OCP_PADDR_NA,
139 .irq = OCP_IRQ_NA,
140 .pm = OCP_CPM_NA,
141 .additions = &ibm440ep_mal0_def,
142 .show = &ocp_show_mal_data,
143 },
144 { .vendor = OCP_VENDOR_IBM,
145 .function = OCP_FUNC_EMAC,
146 .index = 0,
147 .paddr = 0x0EF600E00ULL,
148 .irq = 60,
149 .pm = OCP_CPM_NA,
150 .additions = &ibm440ep_emac0_def,
151 .show = &ocp_show_emac_data,
152 },
153 { .vendor = OCP_VENDOR_IBM,
154 .function = OCP_FUNC_EMAC,
155 .index = 1,
156 .paddr = 0x0EF600F00ULL,
157 .irq = 62,
158 .pm = OCP_CPM_NA,
159 .additions = &ibm440ep_emac1_def,
160 .show = &ocp_show_emac_data,
161 },
162 { .vendor = OCP_VENDOR_IBM,
163 .function = OCP_FUNC_ZMII,
164 .paddr = 0x0EF600D00ULL,
165 .irq = OCP_IRQ_NA,
166 .pm = OCP_CPM_NA,
167 },
168 { .vendor = OCP_VENDOR_INVALID
169 }
170};
171
172/* Polarity and triggering settings for internal interrupt sources */
173struct ppc4xx_uic_settings ppc4xx_core_uic_cfg[] __initdata = {
174 { .polarity = 0xffbffe03,
175 .triggering = 0xfffffe00,
176 .ext_irq_mask = 0x000001fc, /* IRQ0 - IRQ6 */
177 },
178 { .polarity = 0xffffc6ef,
179 .triggering = 0xffffc7ff,
180 .ext_irq_mask = 0x00003800, /* IRQ7 - IRQ9 */
181 },
182};
183
184static struct resource usb_gadget_resources[] = {
185 [0] = {
186 .start = 0x050000100ULL,
187 .end = 0x05000017FULL,
188 .flags = IORESOURCE_MEM,
189 },
190 [1] = {
191 .start = 55,
192 .end = 55,
193 .flags = IORESOURCE_IRQ,
194 },
195};
196
197static u64 dma_mask = 0xffffffffULL;
198
199static struct platform_device usb_gadget_device = {
200 .name = "musbhsfc",
201 .id = 0,
202 .num_resources = ARRAY_SIZE(usb_gadget_resources),
203 .resource = usb_gadget_resources,
204 .dev = {
205 .dma_mask = &dma_mask,
206 .coherent_dma_mask = 0xffffffffULL,
207 }
208};
209
210static struct platform_device *ibm440ep_devs[] __initdata = {
211 &usb_gadget_device,
212};
213
214static int __init
215ibm440ep_platform_add_devices(void)
216{
217 return platform_add_devices(ibm440ep_devs, ARRAY_SIZE(ibm440ep_devs));
218}
219arch_initcall(ibm440ep_platform_add_devices);
220
diff --git a/arch/ppc/platforms/4xx/ibm440ep.h b/arch/ppc/platforms/4xx/ibm440ep.h
new file mode 100644
index 000000000000..97c80b8e3e10
--- /dev/null
+++ b/arch/ppc/platforms/4xx/ibm440ep.h
@@ -0,0 +1,76 @@
1/*
2 * arch/ppc/platforms/4xx/ibm440ep.h
3 *
4 * PPC440EP definitions
5 *
6 * Wade Farnsworth <wfarnsworth@mvista.com>
7 *
8 * Copyright 2002 Roland Dreier
9 * Copyright 2004 MontaVista Software, Inc.
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 *
16 */
17
18#ifdef __KERNEL__
19#ifndef __PPC_PLATFORMS_IBM440EP_H
20#define __PPC_PLATFORMS_IBM440EP_H
21
22#include <linux/config.h>
23#include <asm/ibm44x.h>
24
25/* UART */
26#define PPC440EP_UART0_ADDR 0x0EF600300
27#define PPC440EP_UART1_ADDR 0x0EF600400
28#define PPC440EP_UART2_ADDR 0x0EF600500
29#define PPC440EP_UART3_ADDR 0x0EF600600
30#define UART0_INT 0
31#define UART1_INT 1
32#define UART2_INT 3
33#define UART3_INT 4
34
35/* Clock and Power Management */
36#define IBM_CPM_IIC0 0x80000000 /* IIC interface */
37#define IBM_CPM_IIC1 0x40000000 /* IIC interface */
38#define IBM_CPM_PCI 0x20000000 /* PCI bridge */
39#define IBM_CPM_USB1H 0x08000000 /* USB 1.1 Host */
40#define IBM_CPM_FPU 0x04000000 /* floating point unit */
41#define IBM_CPM_CPU 0x02000000 /* processor core */
42#define IBM_CPM_DMA 0x01000000 /* DMA controller */
43#define IBM_CPM_BGO 0x00800000 /* PLB to OPB bus arbiter */
44#define IBM_CPM_BGI 0x00400000 /* OPB to PLB bridge */
45#define IBM_CPM_EBC 0x00200000 /* External Bus Controller */
46#define IBM_CPM_EBM 0x00100000 /* Ext Bus Master Interface */
47#define IBM_CPM_DMC 0x00080000 /* SDRAM peripheral controller */
48#define IBM_CPM_PLB4 0x00040000 /* PLB4 bus arbiter */
49#define IBM_CPM_PLB4x3 0x00020000 /* PLB4 to PLB3 bridge controller */
50#define IBM_CPM_PLB3x4 0x00010000 /* PLB3 to PLB4 bridge controller */
51#define IBM_CPM_PLB3 0x00008000 /* PLB3 bus arbiter */
52#define IBM_CPM_PPM 0x00002000 /* PLB Performance Monitor */
53#define IBM_CPM_UIC1 0x00001000 /* Universal Interrupt Controller */
54#define IBM_CPM_GPIO0 0x00000800 /* General Purpose IO (??) */
55#define IBM_CPM_GPT 0x00000400 /* General Purpose Timers */
56#define IBM_CPM_UART0 0x00000200 /* serial port 0 */
57#define IBM_CPM_UART1 0x00000100 /* serial port 1 */
58#define IBM_CPM_UIC0 0x00000080 /* Universal Interrupt Controller */
59#define IBM_CPM_TMRCLK 0x00000040 /* CPU timers */
60#define IBM_CPM_EMAC0 0x00000020 /* ethernet port 0 */
61#define IBM_CPM_EMAC1 0x00000010 /* ethernet port 1 */
62#define IBM_CPM_UART2 0x00000008 /* serial port 2 */
63#define IBM_CPM_UART3 0x00000004 /* serial port 3 */
64#define IBM_CPM_USB2D 0x00000002 /* USB 2.0 Device */
65#define IBM_CPM_USB2H 0x00000001 /* USB 2.0 Host */
66
67#define DFLT_IBM4xx_PM ~(IBM_CPM_UIC0 | IBM_CPM_UIC1 | IBM_CPM_CPU \
68 | IBM_CPM_EBC | IBM_CPM_BGO | IBM_CPM_FPU \
69 | IBM_CPM_EBM | IBM_CPM_PLB4 | IBM_CPM_3x4 \
70 | IBM_CPM_PLB3 | IBM_CPM_PLB4x3 \
71 | IBM_CPM_EMAC0 | IBM_CPM_TMRCLK \
72 | IBM_CPM_DMA | IBM_CPM_PCI | IBM_CPM_EMAC1)
73
74
75#endif /* __PPC_PLATFORMS_IBM440EP_H */
76#endif /* __KERNEL__ */
diff --git a/arch/ppc/platforms/4xx/ocotea.c b/arch/ppc/platforms/4xx/ocotea.c
index 5f82a6bc7046..8fc34a344769 100644
--- a/arch/ppc/platforms/4xx/ocotea.c
+++ b/arch/ppc/platforms/4xx/ocotea.c
@@ -48,6 +48,7 @@
48#include <asm/bootinfo.h> 48#include <asm/bootinfo.h>
49#include <asm/ppc4xx_pic.h> 49#include <asm/ppc4xx_pic.h>
50#include <asm/ppcboot.h> 50#include <asm/ppcboot.h>
51#include <asm/tlbflush.h>
51 52
52#include <syslib/gen550.h> 53#include <syslib/gen550.h>
53#include <syslib/ibm440gx_common.h> 54#include <syslib/ibm440gx_common.h>
@@ -266,6 +267,9 @@ ocotea_early_serial_map(void)
266#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB) 267#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
267 /* Configure debug serial access */ 268 /* Configure debug serial access */
268 gen550_init(0, &port); 269 gen550_init(0, &port);
270
271 /* Purge TLB entry added in head_44x.S for early serial access */
272 _tlbie(UART0_IO_BASE);
269#endif 273#endif
270 274
271 port.membase = ioremap64(PPC440GX_UART1_ADDR, 8); 275 port.membase = ioremap64(PPC440GX_UART1_ADDR, 8);
diff --git a/arch/ppc/platforms/4xx/ocotea.h b/arch/ppc/platforms/4xx/ocotea.h
index 202dc8251190..33251153ac5f 100644
--- a/arch/ppc/platforms/4xx/ocotea.h
+++ b/arch/ppc/platforms/4xx/ocotea.h
@@ -55,15 +55,24 @@
55 */ 55 */
56#define RS_TABLE_SIZE 2 56#define RS_TABLE_SIZE 2
57 57
58/* OpenBIOS defined UART mappings, used before early_serial_setup */ 58#if defined(__BOOTER__)
59/* OpenBIOS defined UART mappings, used by bootloader shim */
59#define UART0_IO_BASE 0xE0000200 60#define UART0_IO_BASE 0xE0000200
60#define UART1_IO_BASE 0xE0000300 61#define UART1_IO_BASE 0xE0000300
62#else
63/* head_44x.S created UART mapping, used before early_serial_setup.
64 * We cannot use default OpenBIOS UART mappings because they
65 * don't work for configurations with more than 512M RAM. --ebs
66 */
67#define UART0_IO_BASE 0xF0000200
68#define UART1_IO_BASE 0xF0000300
69#endif
61 70
62#define BASE_BAUD 11059200/16 71#define BASE_BAUD 11059200/16
63#define STD_UART_OP(num) \ 72#define STD_UART_OP(num) \
64 { 0, BASE_BAUD, 0, UART##num##_INT, \ 73 { 0, BASE_BAUD, 0, UART##num##_INT, \
65 (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST), \ 74 (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST), \
66 iomem_base: UART##num##_IO_BASE, \ 75 iomem_base: (void*)UART##num##_IO_BASE, \
67 io_type: SERIAL_IO_MEM}, 76 io_type: SERIAL_IO_MEM},
68 77
69#define SERIAL_PORT_DFNS \ 78#define SERIAL_PORT_DFNS \
diff --git a/arch/ppc/syslib/Makefile b/arch/ppc/syslib/Makefile
index dec5bf4f6879..220a65ab0a51 100644
--- a/arch/ppc/syslib/Makefile
+++ b/arch/ppc/syslib/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_PPCBUG_NVRAM) += prep_nvram.o
11obj-$(CONFIG_PPC_OCP) += ocp.o 11obj-$(CONFIG_PPC_OCP) += ocp.o
12obj-$(CONFIG_IBM_OCP) += ibm_ocp.o 12obj-$(CONFIG_IBM_OCP) += ibm_ocp.o
13obj-$(CONFIG_44x) += ibm44x_common.o 13obj-$(CONFIG_44x) += ibm44x_common.o
14obj-$(CONFIG_440EP) += ibm440gx_common.o
14obj-$(CONFIG_440GP) += ibm440gp_common.o 15obj-$(CONFIG_440GP) += ibm440gp_common.o
15obj-$(CONFIG_440GX) += ibm440gx_common.o 16obj-$(CONFIG_440GX) += ibm440gx_common.o
16obj-$(CONFIG_440SP) += ibm440gx_common.o ibm440sp_common.o 17obj-$(CONFIG_440SP) += ibm440gx_common.o ibm440sp_common.o
@@ -44,6 +45,7 @@ obj-$(CONFIG_PPC_CHRP) += open_pic.o indirect_pci.o i8259.o
44obj-$(CONFIG_PPC_PREP) += open_pic.o indirect_pci.o i8259.o todc_time.o 45obj-$(CONFIG_PPC_PREP) += open_pic.o indirect_pci.o i8259.o todc_time.o
45obj-$(CONFIG_ADIR) += i8259.o indirect_pci.o pci_auto.o \ 46obj-$(CONFIG_ADIR) += i8259.o indirect_pci.o pci_auto.o \
46 todc_time.o 47 todc_time.o
48obj-$(CONFIG_BAMBOO) += indirect_pci.o pci_auto.o todc_time.o
47obj-$(CONFIG_CPCI690) += todc_time.o pci_auto.o 49obj-$(CONFIG_CPCI690) += todc_time.o pci_auto.o
48obj-$(CONFIG_EBONY) += indirect_pci.o pci_auto.o todc_time.o 50obj-$(CONFIG_EBONY) += indirect_pci.o pci_auto.o todc_time.o
49obj-$(CONFIG_EV64260) += todc_time.o pci_auto.o 51obj-$(CONFIG_EV64260) += todc_time.o pci_auto.o
diff --git a/arch/ppc/syslib/ibm440gx_common.c b/arch/ppc/syslib/ibm440gx_common.c
index 4ad85e0e0234..d4776af6a3ca 100644
--- a/arch/ppc/syslib/ibm440gx_common.c
+++ b/arch/ppc/syslib/ibm440gx_common.c
@@ -34,6 +34,10 @@ void __init ibm440gx_get_clocks(struct ibm44x_clocks* p, unsigned int sys_clk,
34 u32 plld = CPR_READ(DCRN_CPR_PLLD); 34 u32 plld = CPR_READ(DCRN_CPR_PLLD);
35 u32 uart0 = SDR_READ(DCRN_SDR_UART0); 35 u32 uart0 = SDR_READ(DCRN_SDR_UART0);
36 u32 uart1 = SDR_READ(DCRN_SDR_UART1); 36 u32 uart1 = SDR_READ(DCRN_SDR_UART1);
37#ifdef CONFIG_440EP
38 u32 uart2 = SDR_READ(DCRN_SDR_UART2);
39 u32 uart3 = SDR_READ(DCRN_SDR_UART3);
40#endif
37 41
38 /* Dividers */ 42 /* Dividers */
39 u32 fbdv = __fix_zero((plld >> 24) & 0x1f, 32); 43 u32 fbdv = __fix_zero((plld >> 24) & 0x1f, 32);
@@ -96,6 +100,17 @@ bypass:
96 p->uart1 = ser_clk; 100 p->uart1 = ser_clk;
97 else 101 else
98 p->uart1 = p->plb / __fix_zero(uart1 & 0xff, 256); 102 p->uart1 = p->plb / __fix_zero(uart1 & 0xff, 256);
103#ifdef CONFIG_440EP
104 if (uart2 & 0x00800000)
105 p->uart2 = ser_clk;
106 else
107 p->uart2 = p->plb / __fix_zero(uart2 & 0xff, 256);
108
109 if (uart3 & 0x00800000)
110 p->uart3 = ser_clk;
111 else
112 p->uart3 = p->plb / __fix_zero(uart3 & 0xff, 256);
113#endif
99} 114}
100 115
101/* Issue L2C diagnostic command */ 116/* Issue L2C diagnostic command */
diff --git a/arch/ppc/syslib/ibm44x_common.h b/arch/ppc/syslib/ibm44x_common.h
index b14eb603ce01..c16b6a5ac6ab 100644
--- a/arch/ppc/syslib/ibm44x_common.h
+++ b/arch/ppc/syslib/ibm44x_common.h
@@ -29,6 +29,10 @@ struct ibm44x_clocks {
29 unsigned int ebc; /* PerClk */ 29 unsigned int ebc; /* PerClk */
30 unsigned int uart0; 30 unsigned int uart0;
31 unsigned int uart1; 31 unsigned int uart1;
32#ifdef CONFIG_440EP
33 unsigned int uart2;
34 unsigned int uart3;
35#endif
32}; 36};
33 37
34/* common 44x platform init */ 38/* common 44x platform init */
diff --git a/arch/ppc64/kernel/head.S b/arch/ppc64/kernel/head.S
index 74fc3bc68604..784f56d4684c 100644
--- a/arch/ppc64/kernel/head.S
+++ b/arch/ppc64/kernel/head.S
@@ -2071,7 +2071,7 @@ _GLOBAL(hmt_start_secondary)
2071 blr 2071 blr
2072#endif 2072#endif
2073 2073
2074#if defined(CONFIG_SMP) && !defined(CONFIG_PPC_ISERIES) 2074#if defined(CONFIG_KEXEC) || (defined(CONFIG_SMP) && !defined(CONFIG_PPC_ISERIES))
2075_GLOBAL(smp_release_cpus) 2075_GLOBAL(smp_release_cpus)
2076 /* All secondary cpus are spinning on a common 2076 /* All secondary cpus are spinning on a common
2077 * spinloop, release them all now so they can start 2077 * spinloop, release them all now so they can start
diff --git a/arch/ppc64/kernel/machine_kexec.c b/arch/ppc64/kernel/machine_kexec.c
index fdb2fc649d72..4775f12a013c 100644
--- a/arch/ppc64/kernel/machine_kexec.c
+++ b/arch/ppc64/kernel/machine_kexec.c
@@ -185,7 +185,7 @@ void kexec_copy_flush(struct kimage *image)
185void kexec_smp_down(void *arg) 185void kexec_smp_down(void *arg)
186{ 186{
187 if (ppc_md.cpu_irq_down) 187 if (ppc_md.cpu_irq_down)
188 ppc_md.cpu_irq_down(); 188 ppc_md.cpu_irq_down(1);
189 189
190 local_irq_disable(); 190 local_irq_disable();
191 kexec_smp_wait(); 191 kexec_smp_wait();
@@ -232,7 +232,7 @@ static void kexec_prepare_cpus(void)
232 232
233 /* after we tell the others to go down */ 233 /* after we tell the others to go down */
234 if (ppc_md.cpu_irq_down) 234 if (ppc_md.cpu_irq_down)
235 ppc_md.cpu_irq_down(); 235 ppc_md.cpu_irq_down(0);
236 236
237 put_cpu(); 237 put_cpu();
238 238
@@ -243,15 +243,19 @@ static void kexec_prepare_cpus(void)
243 243
244static void kexec_prepare_cpus(void) 244static void kexec_prepare_cpus(void)
245{ 245{
246 extern void smp_release_cpus(void);
246 /* 247 /*
247 * move the secondarys to us so that we can copy 248 * move the secondarys to us so that we can copy
248 * the new kernel 0-0x100 safely 249 * the new kernel 0-0x100 safely
249 * 250 *
250 * do this if kexec in setup.c ? 251 * do this if kexec in setup.c ?
252 *
253 * We need to release the cpus if we are ever going from an
254 * UP to an SMP kernel.
251 */ 255 */
252 smp_relase_cpus(); 256 smp_release_cpus();
253 if (ppc_md.cpu_irq_down) 257 if (ppc_md.cpu_irq_down)
254 ppc_md.cpu_irq_down(); 258 ppc_md.cpu_irq_down(0);
255 local_irq_disable(); 259 local_irq_disable();
256} 260}
257 261
diff --git a/arch/ppc64/kernel/misc.S b/arch/ppc64/kernel/misc.S
index 59f4f9973818..a05b50b738e9 100644
--- a/arch/ppc64/kernel/misc.S
+++ b/arch/ppc64/kernel/misc.S
@@ -1129,6 +1129,9 @@ _GLOBAL(sys_call_table32)
1129 .llong .compat_sys_waitid 1129 .llong .compat_sys_waitid
1130 .llong .sys32_ioprio_set 1130 .llong .sys32_ioprio_set
1131 .llong .sys32_ioprio_get 1131 .llong .sys32_ioprio_get
1132 .llong .sys_inotify_init /* 275 */
1133 .llong .sys_inotify_add_watch
1134 .llong .sys_inotify_rm_watch
1132 1135
1133 .balign 8 1136 .balign 8
1134_GLOBAL(sys_call_table) 1137_GLOBAL(sys_call_table)
@@ -1407,3 +1410,6 @@ _GLOBAL(sys_call_table)
1407 .llong .sys_waitid 1410 .llong .sys_waitid
1408 .llong .sys_ioprio_set 1411 .llong .sys_ioprio_set
1409 .llong .sys_ioprio_get 1412 .llong .sys_ioprio_get
1413 .llong .sys_inotify_init /* 275 */
1414 .llong .sys_inotify_add_watch
1415 .llong .sys_inotify_rm_watch
diff --git a/arch/ppc64/kernel/mpic.c b/arch/ppc64/kernel/mpic.c
index e8fbab1df37f..cc262a05ddb4 100644
--- a/arch/ppc64/kernel/mpic.c
+++ b/arch/ppc64/kernel/mpic.c
@@ -794,10 +794,10 @@ void mpic_setup_this_cpu(void)
794 794
795/* 795/*
796 * XXX: someone who knows mpic should check this. 796 * XXX: someone who knows mpic should check this.
797 * do we need to eoi the ipi here (see xics comments)? 797 * do we need to eoi the ipi including for kexec cpu here (see xics comments)?
798 * or can we reset the mpic in the new kernel? 798 * or can we reset the mpic in the new kernel?
799 */ 799 */
800void mpic_teardown_this_cpu(void) 800void mpic_teardown_this_cpu(int secondary)
801{ 801{
802 struct mpic *mpic = mpic_primary; 802 struct mpic *mpic = mpic_primary;
803 unsigned long flags; 803 unsigned long flags;
diff --git a/arch/ppc64/kernel/mpic.h b/arch/ppc64/kernel/mpic.h
index 99fbbc9a084c..ca78a7f10528 100644
--- a/arch/ppc64/kernel/mpic.h
+++ b/arch/ppc64/kernel/mpic.h
@@ -256,7 +256,7 @@ extern unsigned int mpic_irq_get_priority(unsigned int irq);
256extern void mpic_setup_this_cpu(void); 256extern void mpic_setup_this_cpu(void);
257 257
258/* Clean up for kexec (or cpu offline or ...) */ 258/* Clean up for kexec (or cpu offline or ...) */
259extern void mpic_teardown_this_cpu(void); 259extern void mpic_teardown_this_cpu(int secondary);
260 260
261/* Request IPIs on primary mpic */ 261/* Request IPIs on primary mpic */
262extern void mpic_request_ipis(void); 262extern void mpic_request_ipis(void);
diff --git a/arch/ppc64/kernel/prom.c b/arch/ppc64/kernel/prom.c
index 47727a6f7346..5aca01ddd81f 100644
--- a/arch/ppc64/kernel/prom.c
+++ b/arch/ppc64/kernel/prom.c
@@ -916,6 +916,7 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
916 } 916 }
917 } 917 }
918 918
919#ifdef CONFIG_ALTIVEC
919 /* Check if we have a VMX and eventually update CPU features */ 920 /* Check if we have a VMX and eventually update CPU features */
920 prop = (u32 *)get_flat_dt_prop(node, "ibm,vmx", NULL); 921 prop = (u32 *)get_flat_dt_prop(node, "ibm,vmx", NULL);
921 if (prop && (*prop) > 0) { 922 if (prop && (*prop) > 0) {
@@ -929,6 +930,7 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
929 cur_cpu_spec->cpu_features |= CPU_FTR_ALTIVEC; 930 cur_cpu_spec->cpu_features |= CPU_FTR_ALTIVEC;
930 cur_cpu_spec->cpu_user_features |= PPC_FEATURE_HAS_ALTIVEC; 931 cur_cpu_spec->cpu_user_features |= PPC_FEATURE_HAS_ALTIVEC;
931 } 932 }
933#endif /* CONFIG_ALTIVEC */
932 934
933 /* 935 /*
934 * Check for an SMT capable CPU and set the CPU feature. We do 936 * Check for an SMT capable CPU and set the CPU feature. We do
diff --git a/arch/ppc64/kernel/xics.c b/arch/ppc64/kernel/xics.c
index 677c4450984a..d9dc6f28d050 100644
--- a/arch/ppc64/kernel/xics.c
+++ b/arch/ppc64/kernel/xics.c
@@ -647,29 +647,30 @@ static void xics_set_affinity(unsigned int virq, cpumask_t cpumask)
647 } 647 }
648} 648}
649 649
650void xics_teardown_cpu(void) 650void xics_teardown_cpu(int secondary)
651{ 651{
652 int cpu = smp_processor_id(); 652 int cpu = smp_processor_id();
653 int status;
654 653
655 ops->cppr_info(cpu, 0x00); 654 ops->cppr_info(cpu, 0x00);
656 iosync(); 655 iosync();
657 656
658 /* 657 /*
659 * we need to EOI the IPI if we got here from kexec down IPI 658 * Some machines need to have at least one cpu in the GIQ,
660 * 659 * so leave the master cpu in the group.
661 * xics doesn't care if we duplicate an EOI as long as we
662 * don't EOI and raise priority.
663 *
664 * probably need to check all the other interrupts too
665 * should we be flagging idle loop instead?
666 * or creating some task to be scheduled?
667 */ 660 */
668 ops->xirr_info_set(cpu, XICS_IPI); 661 if (secondary) {
669 662 /*
670 status = rtas_set_indicator(GLOBAL_INTERRUPT_QUEUE, 663 * we need to EOI the IPI if we got here from kexec down IPI
671 (1UL << interrupt_server_size) - 1 - default_distrib_server, 0); 664 *
672 WARN_ON(status != 0); 665 * probably need to check all the other interrupts too
666 * should we be flagging idle loop instead?
667 * or creating some task to be scheduled?
668 */
669 ops->xirr_info_set(cpu, XICS_IPI);
670 rtas_set_indicator(GLOBAL_INTERRUPT_QUEUE,
671 (1UL << interrupt_server_size) - 1 -
672 default_distrib_server, 0);
673 }
673} 674}
674 675
675#ifdef CONFIG_HOTPLUG_CPU 676#ifdef CONFIG_HOTPLUG_CPU
diff --git a/arch/ppc64/mm/numa.c b/arch/ppc64/mm/numa.c
index cafd91aef289..0b191f2de016 100644
--- a/arch/ppc64/mm/numa.c
+++ b/arch/ppc64/mm/numa.c
@@ -647,7 +647,12 @@ void __init do_init_bootmem(void)
647new_range: 647new_range:
648 mem_start = read_n_cells(addr_cells, &memcell_buf); 648 mem_start = read_n_cells(addr_cells, &memcell_buf);
649 mem_size = read_n_cells(size_cells, &memcell_buf); 649 mem_size = read_n_cells(size_cells, &memcell_buf);
650 numa_domain = numa_enabled ? of_node_numa_domain(memory) : 0; 650 if (numa_enabled) {
651 numa_domain = of_node_numa_domain(memory);
652 if (numa_domain >= MAX_NUMNODES)
653 numa_domain = 0;
654 } else
655 numa_domain = 0;
651 656
652 if (numa_domain != nid) 657 if (numa_domain != nid)
653 continue; 658 continue;
diff --git a/arch/ppc64/xmon/xmon.c b/arch/ppc64/xmon/xmon.c
index 7f6e13a4b71e..05539439e6bc 100644
--- a/arch/ppc64/xmon/xmon.c
+++ b/arch/ppc64/xmon/xmon.c
@@ -329,13 +329,16 @@ int xmon_core(struct pt_regs *regs, int fromipi)
329 printf("cpu 0x%x: Exception %lx %s in xmon, " 329 printf("cpu 0x%x: Exception %lx %s in xmon, "
330 "returning to main loop\n", 330 "returning to main loop\n",
331 cpu, regs->trap, getvecname(TRAP(regs))); 331 cpu, regs->trap, getvecname(TRAP(regs)));
332 release_output_lock();
332 longjmp(xmon_fault_jmp[cpu], 1); 333 longjmp(xmon_fault_jmp[cpu], 1);
333 } 334 }
334 335
335 if (setjmp(recurse_jmp) != 0) { 336 if (setjmp(recurse_jmp) != 0) {
336 if (!in_xmon || !xmon_gate) { 337 if (!in_xmon || !xmon_gate) {
338 get_output_lock();
337 printf("xmon: WARNING: bad recursive fault " 339 printf("xmon: WARNING: bad recursive fault "
338 "on cpu 0x%x\n", cpu); 340 "on cpu 0x%x\n", cpu);
341 release_output_lock();
339 goto waiting; 342 goto waiting;
340 } 343 }
341 secondary = !(xmon_taken && cpu == xmon_owner); 344 secondary = !(xmon_taken && cpu == xmon_owner);
diff --git a/arch/s390/kernel/compat_wrapper.S b/arch/s390/kernel/compat_wrapper.S
index 799a98eac92d..23fe94e58688 100644
--- a/arch/s390/kernel/compat_wrapper.S
+++ b/arch/s390/kernel/compat_wrapper.S
@@ -1449,3 +1449,29 @@ compat_sys_kexec_load_wrapper:
1449 llgtr %r4,%r4 # struct kexec_segment * 1449 llgtr %r4,%r4 # struct kexec_segment *
1450 llgfr %r5,%r5 # unsigned long 1450 llgfr %r5,%r5 # unsigned long
1451 jg compat_sys_kexec_load 1451 jg compat_sys_kexec_load
1452
1453 .globl sys_ioprio_set_wrapper
1454sys_ioprio_set_wrapper:
1455 lgfr %r2,%r2 # int
1456 lgfr %r3,%r3 # int
1457 lgfr %r4,%r4 # int
1458 jg sys_ioprio_set
1459
1460 .globl sys_ioprio_get_wrapper
1461sys_ioprio_get_wrapper:
1462 lgfr %r2,%r2 # int
1463 lgfr %r3,%r3 # int
1464 jg sys_ioprio_get
1465
1466 .globl sys_inotify_add_watch_wrapper
1467sys_inotify_add_watch_wrapper:
1468 lgfr %r2,%r2 # int
1469 llgtr %r3,%r3 # const char *
1470 llgfr %r4,%r4 # u32
1471 jg sys_inotify_add_watch
1472
1473 .globl sys_inotify_rm_watch_wrapper
1474sys_inotify_rm_watch_wrapper:
1475 lgfr %r2,%r2 # int
1476 llgfr %r3,%r3 # u32
1477 jg sys_inotify_rm_watch
diff --git a/arch/s390/kernel/machine_kexec.c b/arch/s390/kernel/machine_kexec.c
index 2721c3a32b84..5aa71b05b8ae 100644
--- a/arch/s390/kernel/machine_kexec.c
+++ b/arch/s390/kernel/machine_kexec.c
@@ -70,6 +70,8 @@ machine_kexec(struct kimage *image)
70 for (;;); 70 for (;;);
71} 71}
72 72
73extern void pfault_fini(void);
74
73static void 75static void
74kexec_halt_all_cpus(void *kernel_image) 76kexec_halt_all_cpus(void *kernel_image)
75{ 77{
@@ -78,6 +80,11 @@ kexec_halt_all_cpus(void *kernel_image)
78 struct kimage *image; 80 struct kimage *image;
79 relocate_kernel_t data_mover; 81 relocate_kernel_t data_mover;
80 82
83#ifdef CONFIG_PFAULT
84 if (MACHINE_IS_VM)
85 pfault_fini();
86#endif
87
81 if (atomic_compare_and_swap(-1, smp_processor_id(), &cpuid)) 88 if (atomic_compare_and_swap(-1, smp_processor_id(), &cpuid))
82 signal_processor(smp_processor_id(), sigp_stop); 89 signal_processor(smp_processor_id(), sigp_stop);
83 90
diff --git a/arch/s390/kernel/relocate_kernel.S b/arch/s390/kernel/relocate_kernel.S
index d5e4a62fbb79..2a25ec7147ff 100644
--- a/arch/s390/kernel/relocate_kernel.S
+++ b/arch/s390/kernel/relocate_kernel.S
@@ -4,6 +4,7 @@
4 * (C) Copyright IBM Corp. 2005 4 * (C) Copyright IBM Corp. 2005
5 * 5 *
6 * Author(s): Rolf Adelsberger <adelsberger@de.ibm.com> 6 * Author(s): Rolf Adelsberger <adelsberger@de.ibm.com>
7 * Heiko Carstens <heiko.carstens@de.ibm.com>
7 * 8 *
8 */ 9 */
9 10
@@ -25,8 +26,31 @@
25 relocate_kernel: 26 relocate_kernel:
26 basr %r13,0 #base address 27 basr %r13,0 #base address
27 .base: 28 .base:
28 spx zero64-.base(%r13) #absolute addressing mode
29 stnsm sys_msk-.base(%r13),0xf8 #disable DAT and IRQ (external) 29 stnsm sys_msk-.base(%r13),0xf8 #disable DAT and IRQ (external)
30 spx zero64-.base(%r13) #absolute addressing mode
31 stctl %c0,%c15,ctlregs-.base(%r13)
32 stm %r0,%r15,gprregs-.base(%r13)
33 la %r1,load_psw-.base(%r13)
34 mvc 0(8,%r0),0(%r1)
35 la %r0,.back-.base(%r13)
36 st %r0,4(%r0)
37 oi 4(%r0),0x80
38 mvc 0x68(8,%r0),0(%r1)
39 la %r0,.back_pgm-.base(%r13)
40 st %r0,0x6c(%r0)
41 oi 0x6c(%r0),0x80
42 lhi %r0,0
43 diag %r0,%r0,0x308
44 .back:
45 basr %r13,0
46 .back_base:
47 oi have_diag308-.back_base(%r13),0x01
48 lctl %c0,%c15,ctlregs-.back_base(%r13)
49 lm %r0,%r15,gprregs-.back_base(%r13)
50 j .start_reloc
51 .back_pgm:
52 lm %r0,%r15,gprregs-.base(%r13)
53 .start_reloc:
30 lhi %r10,-1 #preparing the mask 54 lhi %r10,-1 #preparing the mask
31 sll %r10,12 #shift it such that it becomes 0xf000 55 sll %r10,12 #shift it such that it becomes 0xf000
32 .top: 56 .top:
@@ -63,6 +87,10 @@
63 o %r3,4(%r4) #or load address into psw 87 o %r3,4(%r4) #or load address into psw
64 st %r3,4(%r4) 88 st %r3,4(%r4)
65 mvc 0(8,%r0),0(%r4) #copy psw to absolute address 0 89 mvc 0(8,%r0),0(%r4) #copy psw to absolute address 0
90 tm have_diag308-.base(%r13),0x01
91 jno .no_diag308
92 diag %r0,%r0,0x308
93 .no_diag308:
66 sr %r1,%r1 #clear %r1 94 sr %r1,%r1 #clear %r1
67 sr %r2,%r2 #clear %r2 95 sr %r2,%r2 #clear %r2
68 sigp %r1,%r2,0x12 #set cpuid to zero 96 sigp %r1,%r2,0x12 #set cpuid to zero
@@ -75,6 +103,17 @@
75 .long 0x00080000,0x80000000 103 .long 0x00080000,0x80000000
76 sys_msk: 104 sys_msk:
77 .quad 0 105 .quad 0
106 ctlregs:
107 .rept 16
108 .long 0
109 .endr
110 gprregs:
111 .rept 16
112 .long 0
113 .endr
114 have_diag308:
115 .byte 0
116 .align 8
78 relocate_kernel_end: 117 relocate_kernel_end:
79 .globl relocate_kernel_len 118 .globl relocate_kernel_len
80 relocate_kernel_len: 119 relocate_kernel_len:
diff --git a/arch/s390/kernel/relocate_kernel64.S b/arch/s390/kernel/relocate_kernel64.S
index 96290cc4eb3c..8cdb86e8911f 100644
--- a/arch/s390/kernel/relocate_kernel64.S
+++ b/arch/s390/kernel/relocate_kernel64.S
@@ -4,6 +4,7 @@
4 * (C) Copyright IBM Corp. 2005 4 * (C) Copyright IBM Corp. 2005
5 * 5 *
6 * Author(s): Rolf Adelsberger <adelsberger@de.ibm.com> 6 * Author(s): Rolf Adelsberger <adelsberger@de.ibm.com>
7 * Heiko Carstens <heiko.carstens@de.ibm.com>
7 * 8 *
8 */ 9 */
9 10
@@ -26,8 +27,34 @@
26 relocate_kernel: 27 relocate_kernel:
27 basr %r13,0 #base address 28 basr %r13,0 #base address
28 .base: 29 .base:
30 stnsm sys_msk-.base(%r13),0xf8 #disable DAT and IRQs
29 spx zero64-.base(%r13) #absolute addressing mode 31 spx zero64-.base(%r13) #absolute addressing mode
30 stnsm sys_msk-.base(%r13),0xf8 #disable DAT and IRQ (external) 32 stctg %c0,%c15,ctlregs-.base(%r13)
33 stmg %r0,%r15,gprregs-.base(%r13)
34 lghi %r0,3
35 sllg %r0,%r0,31
36 stg %r0,0x1d0(%r0)
37 la %r0,.back_pgm-.base(%r13)
38 stg %r0,0x1d8(%r0)
39 la %r1,load_psw-.base(%r13)
40 mvc 0(8,%r0),0(%r1)
41 la %r0,.back-.base(%r13)
42 st %r0,4(%r0)
43 oi 4(%r0),0x80
44 lghi %r0,0
45 diag %r0,%r0,0x308
46 .back:
47 lhi %r1,1 #mode 1 = esame
48 sigp %r1,%r0,0x12 #switch to esame mode
49 sam64 #switch to 64 bit addressing mode
50 basr %r13,0
51 .back_base:
52 oi have_diag308-.back_base(%r13),0x01
53 lctlg %c0,%c15,ctlregs-.back_base(%r13)
54 lmg %r0,%r15,gprregs-.back_base(%r13)
55 j .top
56 .back_pgm:
57 lmg %r0,%r15,gprregs-.base(%r13)
31 .top: 58 .top:
32 lghi %r7,4096 #load PAGE_SIZE in r7 59 lghi %r7,4096 #load PAGE_SIZE in r7
33 lghi %r9,4096 #load PAGE_SIZE in r9 60 lghi %r9,4096 #load PAGE_SIZE in r9
@@ -62,6 +89,10 @@
62 o %r3,4(%r4) #or load address into psw 89 o %r3,4(%r4) #or load address into psw
63 st %r3,4(%r4) 90 st %r3,4(%r4)
64 mvc 0(8,%r0),0(%r4) #copy psw to absolute address 0 91 mvc 0(8,%r0),0(%r4) #copy psw to absolute address 0
92 tm have_diag308-.base(%r13),0x01
93 jno .no_diag308
94 diag %r0,%r0,0x308
95 .no_diag308:
65 sam31 #31 bit mode 96 sam31 #31 bit mode
66 sr %r1,%r1 #erase register r1 97 sr %r1,%r1 #erase register r1
67 sr %r2,%r2 #erase register r2 98 sr %r2,%r2 #erase register r2
@@ -75,8 +106,18 @@
75 .long 0x00080000,0x80000000 106 .long 0x00080000,0x80000000
76 sys_msk: 107 sys_msk:
77 .quad 0 108 .quad 0
109 ctlregs:
110 .rept 16
111 .quad 0
112 .endr
113 gprregs:
114 .rept 16
115 .quad 0
116 .endr
117 have_diag308:
118 .byte 0
119 .align 8
78 relocate_kernel_end: 120 relocate_kernel_end:
79 .globl relocate_kernel_len 121 .globl relocate_kernel_len
80 relocate_kernel_len: 122 relocate_kernel_len:
81 .quad relocate_kernel_end - relocate_kernel 123 .quad relocate_kernel_end - relocate_kernel
82
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index da77f001af8d..85222fee4361 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -537,7 +537,8 @@ int __devinit start_secondary(void *cpuvoid)
537#endif 537#endif
538#ifdef CONFIG_PFAULT 538#ifdef CONFIG_PFAULT
539 /* Enable pfault pseudo page faults on this cpu. */ 539 /* Enable pfault pseudo page faults on this cpu. */
540 pfault_init(); 540 if (MACHINE_IS_VM)
541 pfault_init();
541#endif 542#endif
542 /* Mark this cpu as online */ 543 /* Mark this cpu as online */
543 cpu_set(smp_processor_id(), cpu_online_map); 544 cpu_set(smp_processor_id(), cpu_online_map);
@@ -690,7 +691,8 @@ __cpu_disable(void)
690 691
691#ifdef CONFIG_PFAULT 692#ifdef CONFIG_PFAULT
692 /* Disable pfault pseudo page faults on this cpu. */ 693 /* Disable pfault pseudo page faults on this cpu. */
693 pfault_fini(); 694 if (MACHINE_IS_VM)
695 pfault_fini();
694#endif 696#endif
695 697
696 /* disable all external interrupts */ 698 /* disable all external interrupts */
diff --git a/arch/s390/kernel/syscalls.S b/arch/s390/kernel/syscalls.S
index a8668afb5f87..426d7cafdab3 100644
--- a/arch/s390/kernel/syscalls.S
+++ b/arch/s390/kernel/syscalls.S
@@ -290,3 +290,8 @@ SYSCALL(sys_add_key,sys_add_key,compat_sys_add_key_wrapper)
290SYSCALL(sys_request_key,sys_request_key,compat_sys_request_key_wrapper) 290SYSCALL(sys_request_key,sys_request_key,compat_sys_request_key_wrapper)
291SYSCALL(sys_keyctl,sys_keyctl,compat_sys_keyctl) /* 280 */ 291SYSCALL(sys_keyctl,sys_keyctl,compat_sys_keyctl) /* 280 */
292SYSCALL(sys_waitid,sys_waitid,compat_sys_waitid_wrapper) 292SYSCALL(sys_waitid,sys_waitid,compat_sys_waitid_wrapper)
293SYSCALL(sys_ioprio_set,sys_ioprio_set,sys_ioprio_set_wrapper)
294SYSCALL(sys_ioprio_get,sys_ioprio_get,sys_ioprio_get_wrapper)
295SYSCALL(sys_inotify_init,sys_inotify_init,sys_inotify_init)
296SYSCALL(sys_inotify_add_watch,sys_inotify_add_watch,sys_inotify_add_watch_wrapper)
297SYSCALL(sys_inotify_rm_watch,sys_inotify_rm_watch,sys_inotify_rm_watch_wrapper)
diff --git a/arch/s390/kernel/traps.c b/arch/s390/kernel/traps.c
index bc7b7be7acbe..6b8703ec2ae6 100644
--- a/arch/s390/kernel/traps.c
+++ b/arch/s390/kernel/traps.c
@@ -29,6 +29,7 @@
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/kallsyms.h> 31#include <linux/kallsyms.h>
32#include <linux/reboot.h>
32 33
33#include <asm/system.h> 34#include <asm/system.h>
34#include <asm/uaccess.h> 35#include <asm/uaccess.h>
@@ -675,6 +676,19 @@ asmlinkage void kernel_stack_overflow(struct pt_regs * regs)
675 panic("Corrupt kernel stack, can't continue."); 676 panic("Corrupt kernel stack, can't continue.");
676} 677}
677 678
679#ifndef CONFIG_ARCH_S390X
680static int
681pagex_reboot_event(struct notifier_block *this, unsigned long event, void *ptr)
682{
683 if (MACHINE_IS_VM)
684 cpcmd("SET PAGEX OFF", NULL, 0, NULL);
685 return NOTIFY_DONE;
686}
687
688static struct notifier_block pagex_reboot_notifier = {
689 .notifier_call = &pagex_reboot_event,
690};
691#endif
678 692
679/* init is done in lowcore.S and head.S */ 693/* init is done in lowcore.S and head.S */
680 694
@@ -735,6 +749,7 @@ void __init trap_init(void)
735 &ext_int_pfault); 749 &ext_int_pfault);
736#endif 750#endif
737#ifndef CONFIG_ARCH_S390X 751#ifndef CONFIG_ARCH_S390X
752 register_reboot_notifier(&pagex_reboot_notifier);
738 cpcmd("SET PAGEX ON", NULL, 0, NULL); 753 cpcmd("SET PAGEX ON", NULL, 0, NULL);
739#endif 754#endif
740 } 755 }
diff --git a/arch/sh64/mm/fault.c b/arch/sh64/mm/fault.c
index a24932881dbb..f08d0eaf6497 100644
--- a/arch/sh64/mm/fault.c
+++ b/arch/sh64/mm/fault.c
@@ -223,13 +223,13 @@ good_area:
223 */ 223 */
224survive: 224survive:
225 switch (handle_mm_fault(mm, vma, address, writeaccess)) { 225 switch (handle_mm_fault(mm, vma, address, writeaccess)) {
226 case 1: 226 case VM_FAULT_MINOR:
227 tsk->min_flt++; 227 tsk->min_flt++;
228 break; 228 break;
229 case 2: 229 case VM_FAULT_MAJOR:
230 tsk->maj_flt++; 230 tsk->maj_flt++;
231 break; 231 break;
232 case 0: 232 case VM_FAULT_SIGBUS:
233 goto do_sigbus; 233 goto do_sigbus;
234 default: 234 default:
235 goto out_of_memory; 235 goto out_of_memory;
diff --git a/arch/x86_64/kernel/mpparse.c b/arch/x86_64/kernel/mpparse.c
index 08abf9f5b159..79c362d03e2e 100644
--- a/arch/x86_64/kernel/mpparse.c
+++ b/arch/x86_64/kernel/mpparse.c
@@ -970,8 +970,21 @@ int mp_register_gsi(u32 gsi, int edge_level, int active_high_low)
970 * due to unused I/O APIC pins. 970 * due to unused I/O APIC pins.
971 */ 971 */
972 int irq = gsi; 972 int irq = gsi;
973 gsi = pci_irq++; 973 if (gsi < MAX_GSI_NUM) {
974 gsi_to_irq[irq] = gsi; 974 if (gsi > 15)
975 gsi = pci_irq++;
976#ifdef CONFIG_ACPI_BUS
977 /*
978 * Don't assign IRQ used by ACPI SCI
979 */
980 if (gsi == acpi_fadt.sci_int)
981 gsi = pci_irq++;
982#endif
983 gsi_to_irq[irq] = gsi;
984 } else {
985 printk(KERN_ERR "GSI %u is too high\n", gsi);
986 return gsi;
987 }
975 } 988 }
976 989
977 io_apic_set_pci_routing(ioapic, ioapic_pin, gsi, 990 io_apic_set_pci_routing(ioapic, ioapic_pin, gsi,
diff --git a/arch/x86_64/lib/csum-copy.S b/arch/x86_64/lib/csum-copy.S
index 01808ec37836..72fd55ee896e 100644
--- a/arch/x86_64/lib/csum-copy.S
+++ b/arch/x86_64/lib/csum-copy.S
@@ -188,8 +188,8 @@ csum_partial_copy_generic:
188 source 188 source
189 movw (%rdi),%bx 189 movw (%rdi),%bx
190 adcl %ebx,%eax 190 adcl %ebx,%eax
191 dest
192 decl %ecx 191 decl %ecx
192 dest
193 movw %bx,(%rsi) 193 movw %bx,(%rsi)
194 leaq 2(%rdi),%rdi 194 leaq 2(%rdi),%rdi
195 leaq 2(%rsi),%rsi 195 leaq 2(%rsi),%rsi
diff --git a/arch/x86_64/mm/fault.c b/arch/x86_64/mm/fault.c
index 13792721037e..493819e543a5 100644
--- a/arch/x86_64/mm/fault.c
+++ b/arch/x86_64/mm/fault.c
@@ -439,13 +439,13 @@ good_area:
439 * the fault. 439 * the fault.
440 */ 440 */
441 switch (handle_mm_fault(mm, vma, address, write)) { 441 switch (handle_mm_fault(mm, vma, address, write)) {
442 case 1: 442 case VM_FAULT_MINOR:
443 tsk->min_flt++; 443 tsk->min_flt++;
444 break; 444 break;
445 case 2: 445 case VM_FAULT_MAJOR:
446 tsk->maj_flt++; 446 tsk->maj_flt++;
447 break; 447 break;
448 case 0: 448 case VM_FAULT_SIGBUS:
449 goto do_sigbus; 449 goto do_sigbus;
450 default: 450 default:
451 goto out_of_memory; 451 goto out_of_memory;
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 986410e7b483..ba13896cae40 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -133,9 +133,10 @@ config ACPI_HOTKEY
133 depends on ACPI_INTERPRETER 133 depends on ACPI_INTERPRETER
134 depends on EXPERIMENTAL 134 depends on EXPERIMENTAL
135 depends on !IA64_SGI_SN 135 depends on !IA64_SGI_SN
136 default m 136 default n
137 help 137 help
138 ACPI generic hotkey 138 Experimental consolidated hotkey driver.
139 If you are unsure, say N.
139 140
140config ACPI_FAN 141config ACPI_FAN
141 tristate "Fan" 142 tristate "Fan"
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 0f45d45f05a0..8162fd0c21a7 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -26,6 +26,9 @@
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/types.h>
30#include <linux/proc_fs.h>
31#include <linux/seq_file.h>
29#include <acpi/acpi_bus.h> 32#include <acpi/acpi_bus.h>
30#include <acpi/acpi_drivers.h> 33#include <acpi/acpi_drivers.h>
31 34
@@ -33,6 +36,9 @@
33#define ACPI_BUTTON_COMPONENT 0x00080000 36#define ACPI_BUTTON_COMPONENT 0x00080000
34#define ACPI_BUTTON_DRIVER_NAME "ACPI Button Driver" 37#define ACPI_BUTTON_DRIVER_NAME "ACPI Button Driver"
35#define ACPI_BUTTON_CLASS "button" 38#define ACPI_BUTTON_CLASS "button"
39#define ACPI_BUTTON_FILE_INFO "info"
40#define ACPI_BUTTON_FILE_STATE "state"
41#define ACPI_BUTTON_TYPE_UNKNOWN 0x00
36#define ACPI_BUTTON_NOTIFY_STATUS 0x80 42#define ACPI_BUTTON_NOTIFY_STATUS 0x80
37 43
38#define ACPI_BUTTON_SUBCLASS_POWER "power" 44#define ACPI_BUTTON_SUBCLASS_POWER "power"
@@ -64,6 +70,8 @@ MODULE_LICENSE("GPL");
64 70
65static int acpi_button_add (struct acpi_device *device); 71static int acpi_button_add (struct acpi_device *device);
66static int acpi_button_remove (struct acpi_device *device, int type); 72static int acpi_button_remove (struct acpi_device *device, int type);
73static int acpi_button_info_open_fs(struct inode *inode, struct file *file);
74static int acpi_button_state_open_fs(struct inode *inode, struct file *file);
67 75
68static struct acpi_driver acpi_button_driver = { 76static struct acpi_driver acpi_button_driver = {
69 .name = ACPI_BUTTON_DRIVER_NAME, 77 .name = ACPI_BUTTON_DRIVER_NAME,
@@ -82,6 +90,179 @@ struct acpi_button {
82 unsigned long pushed; 90 unsigned long pushed;
83}; 91};
84 92
93static struct file_operations acpi_button_info_fops = {
94 .open = acpi_button_info_open_fs,
95 .read = seq_read,
96 .llseek = seq_lseek,
97 .release = single_release,
98};
99
100static struct file_operations acpi_button_state_fops = {
101 .open = acpi_button_state_open_fs,
102 .read = seq_read,
103 .llseek = seq_lseek,
104 .release = single_release,
105};
106/* --------------------------------------------------------------------------
107 FS Interface (/proc)
108 -------------------------------------------------------------------------- */
109
110static struct proc_dir_entry *acpi_button_dir;
111
112static int acpi_button_info_seq_show(struct seq_file *seq, void *offset)
113{
114 struct acpi_button *button = (struct acpi_button *) seq->private;
115
116 ACPI_FUNCTION_TRACE("acpi_button_info_seq_show");
117
118 if (!button || !button->device)
119 return_VALUE(0);
120
121 seq_printf(seq, "type: %s\n",
122 acpi_device_name(button->device));
123
124 return_VALUE(0);
125}
126
127static int acpi_button_info_open_fs(struct inode *inode, struct file *file)
128{
129 return single_open(file, acpi_button_info_seq_show, PDE(inode)->data);
130}
131
132static int acpi_button_state_seq_show(struct seq_file *seq, void *offset)
133{
134 struct acpi_button *button = (struct acpi_button *) seq->private;
135 acpi_status status;
136 unsigned long state;
137
138 ACPI_FUNCTION_TRACE("acpi_button_state_seq_show");
139
140 if (!button || !button->device)
141 return_VALUE(0);
142
143 status = acpi_evaluate_integer(button->handle,"_LID",NULL,&state);
144 if (ACPI_FAILURE(status)) {
145 seq_printf(seq, "state: unsupported\n");
146 }
147 else{
148 seq_printf(seq, "state: %s\n", (state ? "open" : "closed"));
149 }
150
151 return_VALUE(0);
152}
153
154static int acpi_button_state_open_fs(struct inode *inode, struct file *file)
155{
156 return single_open(file, acpi_button_state_seq_show, PDE(inode)->data);
157}
158
159static struct proc_dir_entry *acpi_power_dir;
160static struct proc_dir_entry *acpi_sleep_dir;
161static struct proc_dir_entry *acpi_lid_dir;
162
163static int
164acpi_button_add_fs (
165 struct acpi_device *device)
166{
167 struct proc_dir_entry *entry = NULL;
168 struct acpi_button *button = NULL;
169
170 ACPI_FUNCTION_TRACE("acpi_button_add_fs");
171
172 if (!device || !acpi_driver_data(device))
173 return_VALUE(-EINVAL);
174
175 button = acpi_driver_data(device);
176
177 switch (button->type) {
178 case ACPI_BUTTON_TYPE_POWER:
179 case ACPI_BUTTON_TYPE_POWERF:
180 if (!acpi_power_dir)
181 acpi_power_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_POWER,
182 acpi_button_dir);
183 entry = acpi_power_dir;
184 break;
185 case ACPI_BUTTON_TYPE_SLEEP:
186 case ACPI_BUTTON_TYPE_SLEEPF:
187 if (!acpi_sleep_dir)
188 acpi_sleep_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_SLEEP,
189 acpi_button_dir);
190 entry = acpi_sleep_dir;
191 break;
192 case ACPI_BUTTON_TYPE_LID:
193 if (!acpi_lid_dir)
194 acpi_lid_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_LID,
195 acpi_button_dir);
196 entry = acpi_lid_dir;
197 break;
198 }
199
200 if (!entry)
201 return_VALUE(-ENODEV);
202 entry->owner = THIS_MODULE;
203
204 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), entry);
205 if (!acpi_device_dir(device))
206 return_VALUE(-ENODEV);
207 acpi_device_dir(device)->owner = THIS_MODULE;
208
209 /* 'info' [R] */
210 entry = create_proc_entry(ACPI_BUTTON_FILE_INFO,
211 S_IRUGO, acpi_device_dir(device));
212 if (!entry)
213 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
214 "Unable to create '%s' fs entry\n",
215 ACPI_BUTTON_FILE_INFO));
216 else {
217 entry->proc_fops = &acpi_button_info_fops;
218 entry->data = acpi_driver_data(device);
219 entry->owner = THIS_MODULE;
220 }
221
222 /* show lid state [R] */
223 if (button->type == ACPI_BUTTON_TYPE_LID) {
224 entry = create_proc_entry(ACPI_BUTTON_FILE_STATE,
225 S_IRUGO, acpi_device_dir(device));
226 if (!entry)
227 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
228 "Unable to create '%s' fs entry\n",
229 ACPI_BUTTON_FILE_INFO));
230 else {
231 entry->proc_fops = &acpi_button_state_fops;
232 entry->data = acpi_driver_data(device);
233 entry->owner = THIS_MODULE;
234 }
235 }
236
237 return_VALUE(0);
238}
239
240
241static int
242acpi_button_remove_fs (
243 struct acpi_device *device)
244{
245 struct acpi_button *button = NULL;
246
247 ACPI_FUNCTION_TRACE("acpi_button_remove_fs");
248
249 button = acpi_driver_data(device);
250 if (acpi_device_dir(device)) {
251 if (button->type == ACPI_BUTTON_TYPE_LID)
252 remove_proc_entry(ACPI_BUTTON_FILE_STATE,
253 acpi_device_dir(device));
254 remove_proc_entry(ACPI_BUTTON_FILE_INFO,
255 acpi_device_dir(device));
256
257 remove_proc_entry(acpi_device_bid(device),
258 acpi_device_dir(device)->parent);
259 acpi_device_dir(device) = NULL;
260 }
261
262 return_VALUE(0);
263}
264
265
85/* -------------------------------------------------------------------------- 266/* --------------------------------------------------------------------------
86 Driver Interface 267 Driver Interface
87 -------------------------------------------------------------------------- */ 268 -------------------------------------------------------------------------- */
@@ -121,7 +302,8 @@ acpi_button_notify_fixed (
121 302
122 ACPI_FUNCTION_TRACE("acpi_button_notify_fixed"); 303 ACPI_FUNCTION_TRACE("acpi_button_notify_fixed");
123 304
124 BUG_ON(!button); 305 if (!button)
306 return_ACPI_STATUS(AE_BAD_PARAMETER);
125 307
126 acpi_button_notify(button->handle, ACPI_BUTTON_NOTIFY_STATUS, button); 308 acpi_button_notify(button->handle, ACPI_BUTTON_NOTIFY_STATUS, button);
127 309
@@ -197,6 +379,10 @@ acpi_button_add (
197 goto end; 379 goto end;
198 } 380 }
199 381
382 result = acpi_button_add_fs(device);
383 if (result)
384 goto end;
385
200 switch (button->type) { 386 switch (button->type) {
201 case ACPI_BUTTON_TYPE_POWERF: 387 case ACPI_BUTTON_TYPE_POWERF:
202 status = acpi_install_fixed_event_handler ( 388 status = acpi_install_fixed_event_handler (
@@ -240,6 +426,7 @@ acpi_button_add (
240 426
241end: 427end:
242 if (result) { 428 if (result) {
429 acpi_button_remove_fs(device);
243 kfree(button); 430 kfree(button);
244 } 431 }
245 432
@@ -280,6 +467,8 @@ acpi_button_remove (struct acpi_device *device, int type)
280 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 467 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
281 "Error removing notify handler\n")); 468 "Error removing notify handler\n"));
282 469
470 acpi_button_remove_fs(device);
471
283 kfree(button); 472 kfree(button);
284 473
285 return_VALUE(0); 474 return_VALUE(0);
@@ -293,14 +482,20 @@ acpi_button_init (void)
293 482
294 ACPI_FUNCTION_TRACE("acpi_button_init"); 483 ACPI_FUNCTION_TRACE("acpi_button_init");
295 484
485 acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir);
486 if (!acpi_button_dir)
487 return_VALUE(-ENODEV);
488 acpi_button_dir->owner = THIS_MODULE;
296 result = acpi_bus_register_driver(&acpi_button_driver); 489 result = acpi_bus_register_driver(&acpi_button_driver);
297 if (result < 0) { 490 if (result < 0) {
491 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
298 return_VALUE(-ENODEV); 492 return_VALUE(-ENODEV);
299 } 493 }
300 494
301 return_VALUE(0); 495 return_VALUE(0);
302} 496}
303 497
498
304static void __exit 499static void __exit
305acpi_button_exit (void) 500acpi_button_exit (void)
306{ 501{
@@ -308,8 +503,17 @@ acpi_button_exit (void)
308 503
309 acpi_bus_unregister_driver(&acpi_button_driver); 504 acpi_bus_unregister_driver(&acpi_button_driver);
310 505
506 if (acpi_power_dir)
507 remove_proc_entry(ACPI_BUTTON_SUBCLASS_POWER, acpi_button_dir);
508 if (acpi_sleep_dir)
509 remove_proc_entry(ACPI_BUTTON_SUBCLASS_SLEEP, acpi_button_dir);
510 if (acpi_lid_dir)
511 remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir);
512 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
513
311 return_VOID; 514 return_VOID;
312} 515}
313 516
517
314module_init(acpi_button_init); 518module_init(acpi_button_init);
315module_exit(acpi_button_exit); 519module_exit(acpi_button_exit);
diff --git a/drivers/acpi/dispatcher/dswload.c b/drivers/acpi/dispatcher/dswload.c
index 1ac197ccfc80..d11620018421 100644
--- a/drivers/acpi/dispatcher/dswload.c
+++ b/drivers/acpi/dispatcher/dswload.c
@@ -491,12 +491,6 @@ acpi_ds_load2_begin_op (
491 if ((!(walk_state->op_info->flags & AML_NSOPCODE) && 491 if ((!(walk_state->op_info->flags & AML_NSOPCODE) &&
492 (walk_state->opcode != AML_INT_NAMEPATH_OP)) || 492 (walk_state->opcode != AML_INT_NAMEPATH_OP)) ||
493 (!(walk_state->op_info->flags & AML_NAMED))) { 493 (!(walk_state->op_info->flags & AML_NAMED))) {
494 if ((walk_state->op_info->class == AML_CLASS_EXECUTE) ||
495 (walk_state->op_info->class == AML_CLASS_CONTROL)) {
496 ACPI_REPORT_WARNING ((
497 "Encountered executable code at module level, [%s]\n",
498 acpi_ps_get_opcode_name (walk_state->opcode)));
499 }
500 return_ACPI_STATUS (AE_OK); 494 return_ACPI_STATUS (AE_OK);
501 } 495 }
502 496
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index fca4140a50a9..1ac5731d45e5 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -59,76 +59,186 @@ ACPI_MODULE_NAME ("acpi_ec")
59#define ACPI_EC_DELAY 50 /* Wait 50ms max. during EC ops */ 59#define ACPI_EC_DELAY 50 /* Wait 50ms max. during EC ops */
60#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ 60#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */
61 61
62#define ACPI_EC_UDELAY 100 /* Poll @ 100us increments */
63#define ACPI_EC_UDELAY_COUNT 1000 /* Wait 10ms max. during EC ops */
64
62#define ACPI_EC_COMMAND_READ 0x80 65#define ACPI_EC_COMMAND_READ 0x80
63#define ACPI_EC_COMMAND_WRITE 0x81 66#define ACPI_EC_COMMAND_WRITE 0x81
64#define ACPI_EC_BURST_ENABLE 0x82 67#define ACPI_EC_BURST_ENABLE 0x82
65#define ACPI_EC_BURST_DISABLE 0x83 68#define ACPI_EC_BURST_DISABLE 0x83
66#define ACPI_EC_COMMAND_QUERY 0x84 69#define ACPI_EC_COMMAND_QUERY 0x84
67 70
68static int acpi_ec_add (struct acpi_device *device); 71#define EC_POLLING 0xFF
72#define EC_BURST 0x00
73
74
69static int acpi_ec_remove (struct acpi_device *device, int type); 75static int acpi_ec_remove (struct acpi_device *device, int type);
70static int acpi_ec_start (struct acpi_device *device); 76static int acpi_ec_start (struct acpi_device *device);
71static int acpi_ec_stop (struct acpi_device *device, int type); 77static int acpi_ec_stop (struct acpi_device *device, int type);
78static int acpi_ec_burst_add ( struct acpi_device *device);
79static int acpi_ec_polling_add ( struct acpi_device *device);
72 80
73static struct acpi_driver acpi_ec_driver = { 81static struct acpi_driver acpi_ec_driver = {
74 .name = ACPI_EC_DRIVER_NAME, 82 .name = ACPI_EC_DRIVER_NAME,
75 .class = ACPI_EC_CLASS, 83 .class = ACPI_EC_CLASS,
76 .ids = ACPI_EC_HID, 84 .ids = ACPI_EC_HID,
77 .ops = { 85 .ops = {
78 .add = acpi_ec_add, 86 .add = acpi_ec_polling_add,
79 .remove = acpi_ec_remove, 87 .remove = acpi_ec_remove,
80 .start = acpi_ec_start, 88 .start = acpi_ec_start,
81 .stop = acpi_ec_stop, 89 .stop = acpi_ec_stop,
82 }, 90 },
83}; 91};
84 92union acpi_ec {
85struct acpi_ec { 93 struct {
86 acpi_handle handle; 94 u32 mode;
87 unsigned long uid; 95 acpi_handle handle;
88 unsigned long gpe_bit; 96 unsigned long uid;
89 struct acpi_generic_address status_addr; 97 unsigned long gpe_bit;
90 struct acpi_generic_address command_addr; 98 struct acpi_generic_address status_addr;
91 struct acpi_generic_address data_addr; 99 struct acpi_generic_address command_addr;
92 unsigned long global_lock; 100 struct acpi_generic_address data_addr;
93 unsigned int expect_event; 101 unsigned long global_lock;
94 atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort*/ 102 } common;
95 atomic_t pending_gpe; 103
96 struct semaphore sem; 104 struct {
97 wait_queue_head_t wait; 105 u32 mode;
106 acpi_handle handle;
107 unsigned long uid;
108 unsigned long gpe_bit;
109 struct acpi_generic_address status_addr;
110 struct acpi_generic_address command_addr;
111 struct acpi_generic_address data_addr;
112 unsigned long global_lock;
113 unsigned int expect_event;
114 atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort*/
115 atomic_t pending_gpe;
116 struct semaphore sem;
117 wait_queue_head_t wait;
118 }burst;
119
120 struct {
121 u32 mode;
122 acpi_handle handle;
123 unsigned long uid;
124 unsigned long gpe_bit;
125 struct acpi_generic_address status_addr;
126 struct acpi_generic_address command_addr;
127 struct acpi_generic_address data_addr;
128 unsigned long global_lock;
129 spinlock_t lock;
130 }polling;
98}; 131};
99 132
133static int acpi_ec_polling_wait ( union acpi_ec *ec, u8 event);
134static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event);
135static int acpi_ec_polling_read ( union acpi_ec *ec, u8 address, u32 *data);
136static int acpi_ec_burst_read( union acpi_ec *ec, u8 address, u32 *data);
137static int acpi_ec_polling_write ( union acpi_ec *ec, u8 address, u8 data);
138static int acpi_ec_burst_write ( union acpi_ec *ec, u8 address, u8 data);
139static int acpi_ec_polling_query ( union acpi_ec *ec, u32 *data);
140static int acpi_ec_burst_query ( union acpi_ec *ec, u32 *data);
141static void acpi_ec_gpe_polling_query ( void *ec_cxt);
142static void acpi_ec_gpe_burst_query ( void *ec_cxt);
143static u32 acpi_ec_gpe_polling_handler ( void *data);
144static u32 acpi_ec_gpe_burst_handler ( void *data);
145static acpi_status __init
146acpi_fake_ecdt_polling_callback (
147 acpi_handle handle,
148 u32 Level,
149 void *context,
150 void **retval);
151
152static acpi_status __init
153acpi_fake_ecdt_burst_callback (
154 acpi_handle handle,
155 u32 Level,
156 void *context,
157 void **retval);
158
159static int __init
160acpi_ec_polling_get_real_ecdt(void);
161static int __init
162acpi_ec_burst_get_real_ecdt(void);
100/* If we find an EC via the ECDT, we need to keep a ptr to its context */ 163/* If we find an EC via the ECDT, we need to keep a ptr to its context */
101static struct acpi_ec *ec_ecdt; 164static union acpi_ec *ec_ecdt;
102 165
103/* External interfaces use first EC only, so remember */ 166/* External interfaces use first EC only, so remember */
104static struct acpi_device *first_ec; 167static struct acpi_device *first_ec;
168static int acpi_ec_polling_mode = EC_POLLING;
105 169
106/* -------------------------------------------------------------------------- 170/* --------------------------------------------------------------------------
107 Transaction Management 171 Transaction Management
108 -------------------------------------------------------------------------- */ 172 -------------------------------------------------------------------------- */
109 173
110static inline u32 acpi_ec_read_status(struct acpi_ec *ec) 174static inline u32 acpi_ec_read_status(union acpi_ec *ec)
111{ 175{
112 u32 status = 0; 176 u32 status = 0;
113 177
114 acpi_hw_low_level_read(8, &status, &ec->status_addr); 178 acpi_hw_low_level_read(8, &status, &ec->common.status_addr);
115 return status; 179 return status;
116} 180}
117 181
118static int acpi_ec_wait(struct acpi_ec *ec, unsigned int event) 182static int
183acpi_ec_wait (
184 union acpi_ec *ec,
185 u8 event)
186{
187 if (acpi_ec_polling_mode)
188 return acpi_ec_polling_wait (ec, event);
189 else
190 return acpi_ec_burst_wait (ec, event);
191}
192
193static int
194acpi_ec_polling_wait (
195 union acpi_ec *ec,
196 u8 event)
197{
198 u32 acpi_ec_status = 0;
199 u32 i = ACPI_EC_UDELAY_COUNT;
200
201 if (!ec)
202 return -EINVAL;
203
204 /* Poll the EC status register waiting for the event to occur. */
205 switch (event) {
206 case ACPI_EC_EVENT_OBF:
207 do {
208 acpi_hw_low_level_read(8, &acpi_ec_status, &ec->common.status_addr);
209 if (acpi_ec_status & ACPI_EC_FLAG_OBF)
210 return 0;
211 udelay(ACPI_EC_UDELAY);
212 } while (--i>0);
213 break;
214 case ACPI_EC_EVENT_IBE:
215 do {
216 acpi_hw_low_level_read(8, &acpi_ec_status, &ec->common.status_addr);
217 if (!(acpi_ec_status & ACPI_EC_FLAG_IBF))
218 return 0;
219 udelay(ACPI_EC_UDELAY);
220 } while (--i>0);
221 break;
222 default:
223 return -EINVAL;
224 }
225
226 return -ETIME;
227}
228static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event)
119{ 229{
120 int result = 0; 230 int result = 0;
121 231
122 ACPI_FUNCTION_TRACE("acpi_ec_wait"); 232 ACPI_FUNCTION_TRACE("acpi_ec_wait");
123 233
124 ec->expect_event = event; 234 ec->burst.expect_event = event;
125 smp_mb(); 235 smp_mb();
126 236
127 result = wait_event_interruptible_timeout(ec->wait, 237 result = wait_event_interruptible_timeout(ec->burst.wait,
128 !ec->expect_event, 238 !ec->burst.expect_event,
129 msecs_to_jiffies(ACPI_EC_DELAY)); 239 msecs_to_jiffies(ACPI_EC_DELAY));
130 240
131 ec->expect_event = 0; 241 ec->burst.expect_event = 0;
132 smp_mb(); 242 smp_mb();
133 243
134 if (result < 0){ 244 if (result < 0){
@@ -160,7 +270,7 @@ static int acpi_ec_wait(struct acpi_ec *ec, unsigned int event)
160 270
161static int 271static int
162acpi_ec_enter_burst_mode ( 272acpi_ec_enter_burst_mode (
163 struct acpi_ec *ec) 273 union acpi_ec *ec)
164{ 274{
165 u32 tmp = 0; 275 u32 tmp = 0;
166 int status = 0; 276 int status = 0;
@@ -170,43 +280,43 @@ acpi_ec_enter_burst_mode (
170 status = acpi_ec_read_status(ec); 280 status = acpi_ec_read_status(ec);
171 if (status != -EINVAL && 281 if (status != -EINVAL &&
172 !(status & ACPI_EC_FLAG_BURST)){ 282 !(status & ACPI_EC_FLAG_BURST)){
173 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->command_addr); 283 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->common.command_addr);
174 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 284 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
175 if (status){ 285 if (status){
176 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 286 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
177 return_VALUE(-EINVAL); 287 return_VALUE(-EINVAL);
178 } 288 }
179 acpi_hw_low_level_read(8, &tmp, &ec->data_addr); 289 acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr);
180 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 290 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
181 if(tmp != 0x90 ) {/* Burst ACK byte*/ 291 if(tmp != 0x90 ) {/* Burst ACK byte*/
182 return_VALUE(-EINVAL); 292 return_VALUE(-EINVAL);
183 } 293 }
184 } 294 }
185 295
186 atomic_set(&ec->leaving_burst , 0); 296 atomic_set(&ec->burst.leaving_burst , 0);
187 return_VALUE(0); 297 return_VALUE(0);
188} 298}
189 299
190static int 300static int
191acpi_ec_leave_burst_mode ( 301acpi_ec_leave_burst_mode (
192 struct acpi_ec *ec) 302 union acpi_ec *ec)
193{ 303{
194 int status =0; 304 int status =0;
195 305
196 ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode"); 306 ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode");
197 307
198 atomic_set(&ec->leaving_burst , 1); 308 atomic_set(&ec->burst.leaving_burst , 1);
199 status = acpi_ec_read_status(ec); 309 status = acpi_ec_read_status(ec);
200 if (status != -EINVAL && 310 if (status != -EINVAL &&
201 (status & ACPI_EC_FLAG_BURST)){ 311 (status & ACPI_EC_FLAG_BURST)){
202 acpi_hw_low_level_write(8, ACPI_EC_BURST_DISABLE, &ec->command_addr); 312 acpi_hw_low_level_write(8, ACPI_EC_BURST_DISABLE, &ec->common.command_addr);
203 status = acpi_ec_wait(ec, ACPI_EC_FLAG_IBF); 313 status = acpi_ec_wait(ec, ACPI_EC_FLAG_IBF);
204 if (status){ 314 if (status){
205 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 315 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
206 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"------->wait fail\n")); 316 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"------->wait fail\n"));
207 return_VALUE(-EINVAL); 317 return_VALUE(-EINVAL);
208 } 318 }
209 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 319 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
210 status = acpi_ec_read_status(ec); 320 status = acpi_ec_read_status(ec);
211 } 321 }
212 322
@@ -215,7 +325,131 @@ acpi_ec_leave_burst_mode (
215 325
216static int 326static int
217acpi_ec_read ( 327acpi_ec_read (
218 struct acpi_ec *ec, 328 union acpi_ec *ec,
329 u8 address,
330 u32 *data)
331{
332 if (acpi_ec_polling_mode)
333 return acpi_ec_polling_read(ec, address, data);
334 else
335 return acpi_ec_burst_read(ec, address, data);
336}
337static int
338acpi_ec_write (
339 union acpi_ec *ec,
340 u8 address,
341 u8 data)
342{
343 if (acpi_ec_polling_mode)
344 return acpi_ec_polling_write(ec, address, data);
345 else
346 return acpi_ec_burst_write(ec, address, data);
347}
348static int
349acpi_ec_polling_read (
350 union acpi_ec *ec,
351 u8 address,
352 u32 *data)
353{
354 acpi_status status = AE_OK;
355 int result = 0;
356 unsigned long flags = 0;
357 u32 glk = 0;
358
359 ACPI_FUNCTION_TRACE("acpi_ec_read");
360
361 if (!ec || !data)
362 return_VALUE(-EINVAL);
363
364 *data = 0;
365
366 if (ec->common.global_lock) {
367 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
368 if (ACPI_FAILURE(status))
369 return_VALUE(-ENODEV);
370 }
371
372 spin_lock_irqsave(&ec->polling.lock, flags);
373
374 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, &ec->common.command_addr);
375 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
376 if (result)
377 goto end;
378
379 acpi_hw_low_level_write(8, address, &ec->common.data_addr);
380 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
381 if (result)
382 goto end;
383
384 acpi_hw_low_level_read(8, data, &ec->common.data_addr);
385
386 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n",
387 *data, address));
388
389end:
390 spin_unlock_irqrestore(&ec->polling.lock, flags);
391
392 if (ec->common.global_lock)
393 acpi_release_global_lock(glk);
394
395 return_VALUE(result);
396}
397
398
399static int
400acpi_ec_polling_write (
401 union acpi_ec *ec,
402 u8 address,
403 u8 data)
404{
405 int result = 0;
406 acpi_status status = AE_OK;
407 unsigned long flags = 0;
408 u32 glk = 0;
409
410 ACPI_FUNCTION_TRACE("acpi_ec_write");
411
412 if (!ec)
413 return_VALUE(-EINVAL);
414
415 if (ec->common.global_lock) {
416 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
417 if (ACPI_FAILURE(status))
418 return_VALUE(-ENODEV);
419 }
420
421 spin_lock_irqsave(&ec->polling.lock, flags);
422
423 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->common.command_addr);
424 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
425 if (result)
426 goto end;
427
428 acpi_hw_low_level_write(8, address, &ec->common.data_addr);
429 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
430 if (result)
431 goto end;
432
433 acpi_hw_low_level_write(8, data, &ec->common.data_addr);
434 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
435 if (result)
436 goto end;
437
438 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n",
439 data, address));
440
441end:
442 spin_unlock_irqrestore(&ec->polling.lock, flags);
443
444 if (ec->common.global_lock)
445 acpi_release_global_lock(glk);
446
447 return_VALUE(result);
448}
449
450static int
451acpi_ec_burst_read (
452 union acpi_ec *ec,
219 u8 address, 453 u8 address,
220 u32 *data) 454 u32 *data)
221{ 455{
@@ -230,51 +464,51 @@ acpi_ec_read (
230retry: 464retry:
231 *data = 0; 465 *data = 0;
232 466
233 if (ec->global_lock) { 467 if (ec->common.global_lock) {
234 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 468 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
235 if (ACPI_FAILURE(status)) 469 if (ACPI_FAILURE(status))
236 return_VALUE(-ENODEV); 470 return_VALUE(-ENODEV);
237 } 471 }
238 472
239 WARN_ON(in_interrupt()); 473 WARN_ON(in_interrupt());
240 down(&ec->sem); 474 down(&ec->burst.sem);
241 475
242 if(acpi_ec_enter_burst_mode(ec)) 476 if(acpi_ec_enter_burst_mode(ec))
243 goto end; 477 goto end;
244 478
245 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, &ec->command_addr); 479 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, &ec->common.command_addr);
246 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 480 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
247 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 481 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
248 if (status) { 482 if (status) {
249 goto end; 483 goto end;
250 } 484 }
251 485
252 acpi_hw_low_level_write(8, address, &ec->data_addr); 486 acpi_hw_low_level_write(8, address, &ec->common.data_addr);
253 status= acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 487 status= acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
254 if (status){ 488 if (status){
255 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 489 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
256 goto end; 490 goto end;
257 } 491 }
258 492
259 acpi_hw_low_level_read(8, data, &ec->data_addr); 493 acpi_hw_low_level_read(8, data, &ec->common.data_addr);
260 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 494 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
261 495
262 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n", 496 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n",
263 *data, address)); 497 *data, address));
264 498
265end: 499end:
266 acpi_ec_leave_burst_mode(ec); 500 acpi_ec_leave_burst_mode(ec);
267 up(&ec->sem); 501 up(&ec->burst.sem);
268 502
269 if (ec->global_lock) 503 if (ec->common.global_lock)
270 acpi_release_global_lock(glk); 504 acpi_release_global_lock(glk);
271 505
272 if(atomic_read(&ec->leaving_burst) == 2){ 506 if(atomic_read(&ec->burst.leaving_burst) == 2){
273 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n")); 507 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n"));
274 while(atomic_read(&ec->pending_gpe)){ 508 while(atomic_read(&ec->burst.pending_gpe)){
275 msleep(1); 509 msleep(1);
276 } 510 }
277 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 511 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
278 goto retry; 512 goto retry;
279 } 513 }
280 514
@@ -283,8 +517,8 @@ end:
283 517
284 518
285static int 519static int
286acpi_ec_write ( 520acpi_ec_burst_write (
287 struct acpi_ec *ec, 521 union acpi_ec *ec,
288 u8 address, 522 u8 address,
289 u8 data) 523 u8 data)
290{ 524{
@@ -297,14 +531,14 @@ acpi_ec_write (
297 if (!ec) 531 if (!ec)
298 return_VALUE(-EINVAL); 532 return_VALUE(-EINVAL);
299retry: 533retry:
300 if (ec->global_lock) { 534 if (ec->common.global_lock) {
301 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 535 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
302 if (ACPI_FAILURE(status)) 536 if (ACPI_FAILURE(status))
303 return_VALUE(-ENODEV); 537 return_VALUE(-ENODEV);
304 } 538 }
305 539
306 WARN_ON(in_interrupt()); 540 WARN_ON(in_interrupt());
307 down(&ec->sem); 541 down(&ec->burst.sem);
308 542
309 if(acpi_ec_enter_burst_mode(ec)) 543 if(acpi_ec_enter_burst_mode(ec))
310 goto end; 544 goto end;
@@ -312,33 +546,33 @@ retry:
312 status = acpi_ec_read_status(ec); 546 status = acpi_ec_read_status(ec);
313 if (status != -EINVAL && 547 if (status != -EINVAL &&
314 !(status & ACPI_EC_FLAG_BURST)){ 548 !(status & ACPI_EC_FLAG_BURST)){
315 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->command_addr); 549 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->common.command_addr);
316 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 550 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
317 if (status) 551 if (status)
318 goto end; 552 goto end;
319 acpi_hw_low_level_read(8, &tmp, &ec->data_addr); 553 acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr);
320 if(tmp != 0x90 ) /* Burst ACK byte*/ 554 if(tmp != 0x90 ) /* Burst ACK byte*/
321 goto end; 555 goto end;
322 } 556 }
323 /*Now we are in burst mode*/ 557 /*Now we are in burst mode*/
324 558
325 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->command_addr); 559 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->common.command_addr);
326 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 560 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
327 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 561 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
328 if (status){ 562 if (status){
329 goto end; 563 goto end;
330 } 564 }
331 565
332 acpi_hw_low_level_write(8, address, &ec->data_addr); 566 acpi_hw_low_level_write(8, address, &ec->common.data_addr);
333 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 567 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
334 if (status){ 568 if (status){
335 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 569 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
336 goto end; 570 goto end;
337 } 571 }
338 572
339 acpi_hw_low_level_write(8, data, &ec->data_addr); 573 acpi_hw_low_level_write(8, data, &ec->common.data_addr);
340 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 574 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
341 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 575 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
342 if (status) 576 if (status)
343 goto end; 577 goto end;
344 578
@@ -347,17 +581,17 @@ retry:
347 581
348end: 582end:
349 acpi_ec_leave_burst_mode(ec); 583 acpi_ec_leave_burst_mode(ec);
350 up(&ec->sem); 584 up(&ec->burst.sem);
351 585
352 if (ec->global_lock) 586 if (ec->common.global_lock)
353 acpi_release_global_lock(glk); 587 acpi_release_global_lock(glk);
354 588
355 if(atomic_read(&ec->leaving_burst) == 2){ 589 if(atomic_read(&ec->burst.leaving_burst) == 2){
356 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n")); 590 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n"));
357 while(atomic_read(&ec->pending_gpe)){ 591 while(atomic_read(&ec->burst.pending_gpe)){
358 msleep(1); 592 msleep(1);
359 } 593 }
360 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 594 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
361 goto retry; 595 goto retry;
362 } 596 }
363 597
@@ -370,7 +604,7 @@ end:
370int 604int
371ec_read(u8 addr, u8 *val) 605ec_read(u8 addr, u8 *val)
372{ 606{
373 struct acpi_ec *ec; 607 union acpi_ec *ec;
374 int err; 608 int err;
375 u32 temp_data; 609 u32 temp_data;
376 610
@@ -393,7 +627,7 @@ EXPORT_SYMBOL(ec_read);
393int 627int
394ec_write(u8 addr, u8 val) 628ec_write(u8 addr, u8 val)
395{ 629{
396 struct acpi_ec *ec; 630 union acpi_ec *ec;
397 int err; 631 int err;
398 632
399 if (!first_ec) 633 if (!first_ec)
@@ -407,10 +641,66 @@ ec_write(u8 addr, u8 val)
407} 641}
408EXPORT_SYMBOL(ec_write); 642EXPORT_SYMBOL(ec_write);
409 643
410
411static int 644static int
412acpi_ec_query ( 645acpi_ec_query (
413 struct acpi_ec *ec, 646 union acpi_ec *ec,
647 u32 *data)
648{
649 if (acpi_ec_polling_mode)
650 return acpi_ec_polling_query(ec, data);
651 else
652 return acpi_ec_burst_query(ec, data);
653}
654static int
655acpi_ec_polling_query (
656 union acpi_ec *ec,
657 u32 *data)
658{
659 int result = 0;
660 acpi_status status = AE_OK;
661 unsigned long flags = 0;
662 u32 glk = 0;
663
664 ACPI_FUNCTION_TRACE("acpi_ec_query");
665
666 if (!ec || !data)
667 return_VALUE(-EINVAL);
668
669 *data = 0;
670
671 if (ec->common.global_lock) {
672 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
673 if (ACPI_FAILURE(status))
674 return_VALUE(-ENODEV);
675 }
676
677 /*
678 * Query the EC to find out which _Qxx method we need to evaluate.
679 * Note that successful completion of the query causes the ACPI_EC_SCI
680 * bit to be cleared (and thus clearing the interrupt source).
681 */
682 spin_lock_irqsave(&ec->polling.lock, flags);
683
684 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, &ec->common.command_addr);
685 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
686 if (result)
687 goto end;
688
689 acpi_hw_low_level_read(8, data, &ec->common.data_addr);
690 if (!*data)
691 result = -ENODATA;
692
693end:
694 spin_unlock_irqrestore(&ec->polling.lock, flags);
695
696 if (ec->common.global_lock)
697 acpi_release_global_lock(glk);
698
699 return_VALUE(result);
700}
701static int
702acpi_ec_burst_query (
703 union acpi_ec *ec,
414 u32 *data) 704 u32 *data)
415{ 705{
416 int status = 0; 706 int status = 0;
@@ -422,13 +712,13 @@ acpi_ec_query (
422 return_VALUE(-EINVAL); 712 return_VALUE(-EINVAL);
423 *data = 0; 713 *data = 0;
424 714
425 if (ec->global_lock) { 715 if (ec->common.global_lock) {
426 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 716 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
427 if (ACPI_FAILURE(status)) 717 if (ACPI_FAILURE(status))
428 return_VALUE(-ENODEV); 718 return_VALUE(-ENODEV);
429 } 719 }
430 720
431 down(&ec->sem); 721 down(&ec->burst.sem);
432 if(acpi_ec_enter_burst_mode(ec)) 722 if(acpi_ec_enter_burst_mode(ec))
433 goto end; 723 goto end;
434 /* 724 /*
@@ -436,28 +726,28 @@ acpi_ec_query (
436 * Note that successful completion of the query causes the ACPI_EC_SCI 726 * Note that successful completion of the query causes the ACPI_EC_SCI
437 * bit to be cleared (and thus clearing the interrupt source). 727 * bit to be cleared (and thus clearing the interrupt source).
438 */ 728 */
439 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, &ec->command_addr); 729 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, &ec->common.command_addr);
440 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 730 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
441 if (status){ 731 if (status){
442 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 732 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
443 goto end; 733 goto end;
444 } 734 }
445 735
446 acpi_hw_low_level_read(8, data, &ec->data_addr); 736 acpi_hw_low_level_read(8, data, &ec->common.data_addr);
447 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 737 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
448 if (!*data) 738 if (!*data)
449 status = -ENODATA; 739 status = -ENODATA;
450 740
451end: 741end:
452 acpi_ec_leave_burst_mode(ec); 742 acpi_ec_leave_burst_mode(ec);
453 up(&ec->sem); 743 up(&ec->burst.sem);
454 744
455 if (ec->global_lock) 745 if (ec->common.global_lock)
456 acpi_release_global_lock(glk); 746 acpi_release_global_lock(glk);
457 747
458 if(atomic_read(&ec->leaving_burst) == 2){ 748 if(atomic_read(&ec->burst.leaving_burst) == 2){
459 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n")); 749 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n"));
460 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 750 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
461 status = -ENODATA; 751 status = -ENODATA;
462 } 752 }
463 return_VALUE(status); 753 return_VALUE(status);
@@ -468,7 +758,7 @@ end:
468 Event Management 758 Event Management
469 -------------------------------------------------------------------------- */ 759 -------------------------------------------------------------------------- */
470 760
471struct acpi_ec_query_data { 761union acpi_ec_query_data {
472 acpi_handle handle; 762 acpi_handle handle;
473 u8 data; 763 u8 data;
474}; 764};
@@ -477,7 +767,59 @@ static void
477acpi_ec_gpe_query ( 767acpi_ec_gpe_query (
478 void *ec_cxt) 768 void *ec_cxt)
479{ 769{
480 struct acpi_ec *ec = (struct acpi_ec *) ec_cxt; 770 if (acpi_ec_polling_mode)
771 acpi_ec_gpe_polling_query(ec_cxt);
772 else
773 acpi_ec_gpe_burst_query(ec_cxt);
774}
775
776static void
777acpi_ec_gpe_polling_query (
778 void *ec_cxt)
779{
780 union acpi_ec *ec = (union acpi_ec *) ec_cxt;
781 u32 value = 0;
782 unsigned long flags = 0;
783 static char object_name[5] = {'_','Q','0','0','\0'};
784 const char hex[] = {'0','1','2','3','4','5','6','7',
785 '8','9','A','B','C','D','E','F'};
786
787 ACPI_FUNCTION_TRACE("acpi_ec_gpe_query");
788
789 if (!ec_cxt)
790 goto end;
791
792 spin_lock_irqsave(&ec->polling.lock, flags);
793 acpi_hw_low_level_read(8, &value, &ec->common.command_addr);
794 spin_unlock_irqrestore(&ec->polling.lock, flags);
795
796 /* TBD: Implement asynch events!
797 * NOTE: All we care about are EC-SCI's. Other EC events are
798 * handled via polling (yuck!). This is because some systems
799 * treat EC-SCIs as level (versus EDGE!) triggered, preventing
800 * a purely interrupt-driven approach (grumble, grumble).
801 */
802 if (!(value & ACPI_EC_FLAG_SCI))
803 goto end;
804
805 if (acpi_ec_query(ec, &value))
806 goto end;
807
808 object_name[2] = hex[((value >> 4) & 0x0F)];
809 object_name[3] = hex[(value & 0x0F)];
810
811 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name));
812
813 acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL);
814
815end:
816 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
817}
818static void
819acpi_ec_gpe_burst_query (
820 void *ec_cxt)
821{
822 union acpi_ec *ec = (union acpi_ec *) ec_cxt;
481 u32 value; 823 u32 value;
482 int result = -ENODATA; 824 int result = -ENODATA;
483 static char object_name[5] = {'_','Q','0','0','\0'}; 825 static char object_name[5] = {'_','Q','0','0','\0'};
@@ -497,9 +839,9 @@ acpi_ec_gpe_query (
497 839
498 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name)); 840 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name));
499 841
500 acpi_evaluate_object(ec->handle, object_name, NULL, NULL); 842 acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL);
501end: 843end:
502 atomic_dec(&ec->pending_gpe); 844 atomic_dec(&ec->burst.pending_gpe);
503 return; 845 return;
504} 846}
505 847
@@ -507,48 +849,77 @@ static u32
507acpi_ec_gpe_handler ( 849acpi_ec_gpe_handler (
508 void *data) 850 void *data)
509{ 851{
852 if (acpi_ec_polling_mode)
853 return acpi_ec_gpe_polling_handler(data);
854 else
855 return acpi_ec_gpe_burst_handler(data);
856}
857static u32
858acpi_ec_gpe_polling_handler (
859 void *data)
860{
861 acpi_status status = AE_OK;
862 union acpi_ec *ec = (union acpi_ec *) data;
863
864 if (!ec)
865 return ACPI_INTERRUPT_NOT_HANDLED;
866
867 acpi_disable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR);
868
869 status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE,
870 acpi_ec_gpe_query, ec);
871
872 if (status == AE_OK)
873 return ACPI_INTERRUPT_HANDLED;
874 else
875 return ACPI_INTERRUPT_NOT_HANDLED;
876}
877static u32
878acpi_ec_gpe_burst_handler (
879 void *data)
880{
510 acpi_status status = AE_OK; 881 acpi_status status = AE_OK;
511 u32 value; 882 u32 value;
512 struct acpi_ec *ec = (struct acpi_ec *) data; 883 union acpi_ec *ec = (union acpi_ec *) data;
513 884
514 if (!ec) 885 if (!ec)
515 return ACPI_INTERRUPT_NOT_HANDLED; 886 return ACPI_INTERRUPT_NOT_HANDLED;
516 887
517 acpi_disable_gpe(NULL, ec->gpe_bit, ACPI_ISR); 888 acpi_disable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR);
518 889
519 value = acpi_ec_read_status(ec); 890 value = acpi_ec_read_status(ec);
520 891
521 if((value & ACPI_EC_FLAG_IBF) && 892 if((value & ACPI_EC_FLAG_IBF) &&
522 !(value & ACPI_EC_FLAG_BURST) && 893 !(value & ACPI_EC_FLAG_BURST) &&
523 (atomic_read(&ec->leaving_burst) == 0)) { 894 (atomic_read(&ec->burst.leaving_burst) == 0)) {
524 /* 895 /*
525 * the embedded controller disables 896 * the embedded controller disables
526 * burst mode for any reason other 897 * burst mode for any reason other
527 * than the burst disable command 898 * than the burst disable command
528 * to process critical event. 899 * to process critical event.
529 */ 900 */
530 atomic_set(&ec->leaving_burst , 2); /* block current pending transaction 901 atomic_set(&ec->burst.leaving_burst , 2); /* block current pending transaction
531 and retry */ 902 and retry */
532 wake_up(&ec->wait); 903 wake_up(&ec->burst.wait);
533 }else { 904 }else {
534 if ((ec->expect_event == ACPI_EC_EVENT_OBF && 905 if ((ec->burst.expect_event == ACPI_EC_EVENT_OBF &&
535 (value & ACPI_EC_FLAG_OBF)) || 906 (value & ACPI_EC_FLAG_OBF)) ||
536 (ec->expect_event == ACPI_EC_EVENT_IBE && 907 (ec->burst.expect_event == ACPI_EC_EVENT_IBE &&
537 !(value & ACPI_EC_FLAG_IBF))) { 908 !(value & ACPI_EC_FLAG_IBF))) {
538 ec->expect_event = 0; 909 ec->burst.expect_event = 0;
539 wake_up(&ec->wait); 910 wake_up(&ec->burst.wait);
540 return ACPI_INTERRUPT_HANDLED; 911 return ACPI_INTERRUPT_HANDLED;
541 } 912 }
542 } 913 }
543 914
544 if (value & ACPI_EC_FLAG_SCI){ 915 if (value & ACPI_EC_FLAG_SCI){
545 atomic_add(1, &ec->pending_gpe) ; 916 atomic_add(1, &ec->burst.pending_gpe) ;
546 status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE, 917 status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE,
547 acpi_ec_gpe_query, ec); 918 acpi_ec_gpe_query, ec);
548 return status == AE_OK ? 919 return status == AE_OK ?
549 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; 920 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
550 } 921 }
551 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_ISR); 922 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR);
552 return status == AE_OK ? 923 return status == AE_OK ?
553 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; 924 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
554} 925}
@@ -585,7 +956,7 @@ acpi_ec_space_handler (
585 void *region_context) 956 void *region_context)
586{ 957{
587 int result = 0; 958 int result = 0;
588 struct acpi_ec *ec = NULL; 959 union acpi_ec *ec = NULL;
589 u64 temp = *value; 960 u64 temp = *value;
590 acpi_integer f_v = 0; 961 acpi_integer f_v = 0;
591 int i = 0; 962 int i = 0;
@@ -600,7 +971,7 @@ acpi_ec_space_handler (
600 return_VALUE(AE_BAD_PARAMETER); 971 return_VALUE(AE_BAD_PARAMETER);
601 } 972 }
602 973
603 ec = (struct acpi_ec *) handler_context; 974 ec = (union acpi_ec *) handler_context;
604 975
605next_byte: 976next_byte:
606 switch (function) { 977 switch (function) {
@@ -661,7 +1032,7 @@ static struct proc_dir_entry *acpi_ec_dir;
661static int 1032static int
662acpi_ec_read_info (struct seq_file *seq, void *offset) 1033acpi_ec_read_info (struct seq_file *seq, void *offset)
663{ 1034{
664 struct acpi_ec *ec = (struct acpi_ec *) seq->private; 1035 union acpi_ec *ec = (union acpi_ec *) seq->private;
665 1036
666 ACPI_FUNCTION_TRACE("acpi_ec_read_info"); 1037 ACPI_FUNCTION_TRACE("acpi_ec_read_info");
667 1038
@@ -669,12 +1040,12 @@ acpi_ec_read_info (struct seq_file *seq, void *offset)
669 goto end; 1040 goto end;
670 1041
671 seq_printf(seq, "gpe bit: 0x%02x\n", 1042 seq_printf(seq, "gpe bit: 0x%02x\n",
672 (u32) ec->gpe_bit); 1043 (u32) ec->common.gpe_bit);
673 seq_printf(seq, "ports: 0x%02x, 0x%02x\n", 1044 seq_printf(seq, "ports: 0x%02x, 0x%02x\n",
674 (u32) ec->status_addr.address, (u32) ec->data_addr.address); 1045 (u32) ec->common.status_addr.address, (u32) ec->common.data_addr.address);
675 seq_printf(seq, "use global lock: %s\n", 1046 seq_printf(seq, "use global lock: %s\n",
676 ec->global_lock?"yes":"no"); 1047 ec->common.global_lock?"yes":"no");
677 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 1048 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
678 1049
679end: 1050end:
680 return_VALUE(0); 1051 return_VALUE(0);
@@ -697,7 +1068,7 @@ static int
697acpi_ec_add_fs ( 1068acpi_ec_add_fs (
698 struct acpi_device *device) 1069 struct acpi_device *device)
699{ 1070{
700 struct proc_dir_entry *entry; 1071 struct proc_dir_entry *entry = NULL;
701 1072
702 ACPI_FUNCTION_TRACE("acpi_ec_add_fs"); 1073 ACPI_FUNCTION_TRACE("acpi_ec_add_fs");
703 1074
@@ -744,13 +1115,14 @@ acpi_ec_remove_fs (
744 Driver Interface 1115 Driver Interface
745 -------------------------------------------------------------------------- */ 1116 -------------------------------------------------------------------------- */
746 1117
1118
747static int 1119static int
748acpi_ec_add ( 1120acpi_ec_polling_add (
749 struct acpi_device *device) 1121 struct acpi_device *device)
750{ 1122{
751 int result; 1123 int result = 0;
752 acpi_status status; 1124 acpi_status status = AE_OK;
753 struct acpi_ec *ec; 1125 union acpi_ec *ec = NULL;
754 unsigned long uid; 1126 unsigned long uid;
755 1127
756 ACPI_FUNCTION_TRACE("acpi_ec_add"); 1128 ACPI_FUNCTION_TRACE("acpi_ec_add");
@@ -758,39 +1130,107 @@ acpi_ec_add (
758 if (!device) 1130 if (!device)
759 return_VALUE(-EINVAL); 1131 return_VALUE(-EINVAL);
760 1132
761 ec = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL); 1133 ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
762 if (!ec) 1134 if (!ec)
763 return_VALUE(-ENOMEM); 1135 return_VALUE(-ENOMEM);
764 memset(ec, 0, sizeof(struct acpi_ec)); 1136 memset(ec, 0, sizeof(union acpi_ec));
765 1137
766 ec->handle = device->handle; 1138 ec->common.handle = device->handle;
767 ec->uid = -1; 1139 ec->common.uid = -1;
768 atomic_set(&ec->pending_gpe, 0); 1140 spin_lock_init(&ec->polling.lock);
769 atomic_set(&ec->leaving_burst , 1);
770 init_MUTEX(&ec->sem);
771 init_waitqueue_head(&ec->wait);
772 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); 1141 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
773 strcpy(acpi_device_class(device), ACPI_EC_CLASS); 1142 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
774 acpi_driver_data(device) = ec; 1143 acpi_driver_data(device) = ec;
775 1144
776 /* Use the global lock for all EC transactions? */ 1145 /* Use the global lock for all EC transactions? */
777 acpi_evaluate_integer(ec->handle, "_GLK", NULL, &ec->global_lock); 1146 acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, &ec->common.global_lock);
778 1147
779 /* If our UID matches the UID for the ECDT-enumerated EC, 1148 /* If our UID matches the UID for the ECDT-enumerated EC,
780 we now have the *real* EC info, so kill the makeshift one.*/ 1149 we now have the *real* EC info, so kill the makeshift one.*/
781 acpi_evaluate_integer(ec->handle, "_UID", NULL, &uid); 1150 acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid);
782 if (ec_ecdt && ec_ecdt->uid == uid) { 1151 if (ec_ecdt && ec_ecdt->common.uid == uid) {
783 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT, 1152 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
784 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); 1153 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler);
1154
1155 acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, &acpi_ec_gpe_handler);
1156
1157 kfree(ec_ecdt);
1158 }
1159
1160 /* Get GPE bit assignment (EC events). */
1161 /* TODO: Add support for _GPE returning a package */
1162 status = acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, &ec->common.gpe_bit);
1163 if (ACPI_FAILURE(status)) {
1164 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1165 "Error obtaining GPE bit assignment\n"));
1166 result = -ENODEV;
1167 goto end;
1168 }
785 1169
786 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe_bit, &acpi_ec_gpe_handler); 1170 result = acpi_ec_add_fs(device);
1171 if (result)
1172 goto end;
1173
1174 printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n",
1175 acpi_device_name(device), acpi_device_bid(device),
1176 (u32) ec->common.gpe_bit);
1177
1178 if (!first_ec)
1179 first_ec = device;
1180
1181end:
1182 if (result)
1183 kfree(ec);
1184
1185 return_VALUE(result);
1186}
1187static int
1188acpi_ec_burst_add (
1189 struct acpi_device *device)
1190{
1191 int result = 0;
1192 acpi_status status = AE_OK;
1193 union acpi_ec *ec = NULL;
1194 unsigned long uid;
1195
1196 ACPI_FUNCTION_TRACE("acpi_ec_add");
1197
1198 if (!device)
1199 return_VALUE(-EINVAL);
1200
1201 ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
1202 if (!ec)
1203 return_VALUE(-ENOMEM);
1204 memset(ec, 0, sizeof(union acpi_ec));
1205
1206 ec->common.handle = device->handle;
1207 ec->common.uid = -1;
1208 atomic_set(&ec->burst.pending_gpe, 0);
1209 atomic_set(&ec->burst.leaving_burst , 1);
1210 init_MUTEX(&ec->burst.sem);
1211 init_waitqueue_head(&ec->burst.wait);
1212 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
1213 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
1214 acpi_driver_data(device) = ec;
1215
1216 /* Use the global lock for all EC transactions? */
1217 acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, &ec->common.global_lock);
1218
1219 /* If our UID matches the UID for the ECDT-enumerated EC,
1220 we now have the *real* EC info, so kill the makeshift one.*/
1221 acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid);
1222 if (ec_ecdt && ec_ecdt->common.uid == uid) {
1223 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
1224 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler);
1225
1226 acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, &acpi_ec_gpe_handler);
787 1227
788 kfree(ec_ecdt); 1228 kfree(ec_ecdt);
789 } 1229 }
790 1230
791 /* Get GPE bit assignment (EC events). */ 1231 /* Get GPE bit assignment (EC events). */
792 /* TODO: Add support for _GPE returning a package */ 1232 /* TODO: Add support for _GPE returning a package */
793 status = acpi_evaluate_integer(ec->handle, "_GPE", NULL, &ec->gpe_bit); 1233 status = acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, &ec->common.gpe_bit);
794 if (ACPI_FAILURE(status)) { 1234 if (ACPI_FAILURE(status)) {
795 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1235 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
796 "Error obtaining GPE bit assignment\n")); 1236 "Error obtaining GPE bit assignment\n"));
@@ -804,7 +1244,7 @@ acpi_ec_add (
804 1244
805 printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n", 1245 printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n",
806 acpi_device_name(device), acpi_device_bid(device), 1246 acpi_device_name(device), acpi_device_bid(device),
807 (u32) ec->gpe_bit); 1247 (u32) ec->common.gpe_bit);
808 1248
809 if (!first_ec) 1249 if (!first_ec)
810 first_ec = device; 1250 first_ec = device;
@@ -822,7 +1262,7 @@ acpi_ec_remove (
822 struct acpi_device *device, 1262 struct acpi_device *device,
823 int type) 1263 int type)
824{ 1264{
825 struct acpi_ec *ec; 1265 union acpi_ec *ec = NULL;
826 1266
827 ACPI_FUNCTION_TRACE("acpi_ec_remove"); 1267 ACPI_FUNCTION_TRACE("acpi_ec_remove");
828 1268
@@ -844,7 +1284,7 @@ acpi_ec_io_ports (
844 struct acpi_resource *resource, 1284 struct acpi_resource *resource,
845 void *context) 1285 void *context)
846{ 1286{
847 struct acpi_ec *ec = (struct acpi_ec *) context; 1287 union acpi_ec *ec = (union acpi_ec *) context;
848 struct acpi_generic_address *addr; 1288 struct acpi_generic_address *addr;
849 1289
850 if (resource->id != ACPI_RSTYPE_IO) { 1290 if (resource->id != ACPI_RSTYPE_IO) {
@@ -856,10 +1296,10 @@ acpi_ec_io_ports (
856 * the second address region returned is the status/command 1296 * the second address region returned is the status/command
857 * port. 1297 * port.
858 */ 1298 */
859 if (ec->data_addr.register_bit_width == 0) { 1299 if (ec->common.data_addr.register_bit_width == 0) {
860 addr = &ec->data_addr; 1300 addr = &ec->common.data_addr;
861 } else if (ec->command_addr.register_bit_width == 0) { 1301 } else if (ec->common.command_addr.register_bit_width == 0) {
862 addr = &ec->command_addr; 1302 addr = &ec->common.command_addr;
863 } else { 1303 } else {
864 return AE_CTRL_TERMINATE; 1304 return AE_CTRL_TERMINATE;
865 } 1305 }
@@ -877,8 +1317,8 @@ static int
877acpi_ec_start ( 1317acpi_ec_start (
878 struct acpi_device *device) 1318 struct acpi_device *device)
879{ 1319{
880 acpi_status status; 1320 acpi_status status = AE_OK;
881 struct acpi_ec *ec; 1321 union acpi_ec *ec = NULL;
882 1322
883 ACPI_FUNCTION_TRACE("acpi_ec_start"); 1323 ACPI_FUNCTION_TRACE("acpi_ec_start");
884 1324
@@ -893,35 +1333,36 @@ acpi_ec_start (
893 /* 1333 /*
894 * Get I/O port addresses. Convert to GAS format. 1334 * Get I/O port addresses. Convert to GAS format.
895 */ 1335 */
896 status = acpi_walk_resources(ec->handle, METHOD_NAME__CRS, 1336 status = acpi_walk_resources(ec->common.handle, METHOD_NAME__CRS,
897 acpi_ec_io_ports, ec); 1337 acpi_ec_io_ports, ec);
898 if (ACPI_FAILURE(status) || ec->command_addr.register_bit_width == 0) { 1338 if (ACPI_FAILURE(status) || ec->common.command_addr.register_bit_width == 0) {
899 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error getting I/O port addresses")); 1339 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error getting I/O port addresses"));
900 return_VALUE(-ENODEV); 1340 return_VALUE(-ENODEV);
901 } 1341 }
902 1342
903 ec->status_addr = ec->command_addr; 1343 ec->common.status_addr = ec->common.command_addr;
904 1344
905 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02x, ports=0x%2x,0x%2x\n", 1345 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02x, ports=0x%2x,0x%2x\n",
906 (u32) ec->gpe_bit, (u32) ec->command_addr.address, 1346 (u32) ec->common.gpe_bit, (u32) ec->common.command_addr.address,
907 (u32) ec->data_addr.address)); 1347 (u32) ec->common.data_addr.address));
1348
908 1349
909 /* 1350 /*
910 * Install GPE handler 1351 * Install GPE handler
911 */ 1352 */
912 status = acpi_install_gpe_handler(NULL, ec->gpe_bit, 1353 status = acpi_install_gpe_handler(NULL, ec->common.gpe_bit,
913 ACPI_GPE_EDGE_TRIGGERED, &acpi_ec_gpe_handler, ec); 1354 ACPI_GPE_EDGE_TRIGGERED, &acpi_ec_gpe_handler, ec);
914 if (ACPI_FAILURE(status)) { 1355 if (ACPI_FAILURE(status)) {
915 return_VALUE(-ENODEV); 1356 return_VALUE(-ENODEV);
916 } 1357 }
917 acpi_set_gpe_type (NULL, ec->gpe_bit, ACPI_GPE_TYPE_RUNTIME); 1358 acpi_set_gpe_type (NULL, ec->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME);
918 acpi_enable_gpe (NULL, ec->gpe_bit, ACPI_NOT_ISR); 1359 acpi_enable_gpe (NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
919 1360
920 status = acpi_install_address_space_handler (ec->handle, 1361 status = acpi_install_address_space_handler (ec->common.handle,
921 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler, 1362 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler,
922 &acpi_ec_space_setup, ec); 1363 &acpi_ec_space_setup, ec);
923 if (ACPI_FAILURE(status)) { 1364 if (ACPI_FAILURE(status)) {
924 acpi_remove_gpe_handler(NULL, ec->gpe_bit, &acpi_ec_gpe_handler); 1365 acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, &acpi_ec_gpe_handler);
925 return_VALUE(-ENODEV); 1366 return_VALUE(-ENODEV);
926 } 1367 }
927 1368
@@ -934,8 +1375,8 @@ acpi_ec_stop (
934 struct acpi_device *device, 1375 struct acpi_device *device,
935 int type) 1376 int type)
936{ 1377{
937 acpi_status status; 1378 acpi_status status = AE_OK;
938 struct acpi_ec *ec; 1379 union acpi_ec *ec = NULL;
939 1380
940 ACPI_FUNCTION_TRACE("acpi_ec_stop"); 1381 ACPI_FUNCTION_TRACE("acpi_ec_stop");
941 1382
@@ -944,12 +1385,12 @@ acpi_ec_stop (
944 1385
945 ec = acpi_driver_data(device); 1386 ec = acpi_driver_data(device);
946 1387
947 status = acpi_remove_address_space_handler(ec->handle, 1388 status = acpi_remove_address_space_handler(ec->common.handle,
948 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); 1389 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler);
949 if (ACPI_FAILURE(status)) 1390 if (ACPI_FAILURE(status))
950 return_VALUE(-ENODEV); 1391 return_VALUE(-ENODEV);
951 1392
952 status = acpi_remove_gpe_handler(NULL, ec->gpe_bit, &acpi_ec_gpe_handler); 1393 status = acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, &acpi_ec_gpe_handler);
953 if (ACPI_FAILURE(status)) 1394 if (ACPI_FAILURE(status))
954 return_VALUE(-ENODEV); 1395 return_VALUE(-ENODEV);
955 1396
@@ -963,26 +1404,76 @@ acpi_fake_ecdt_callback (
963 void *context, 1404 void *context,
964 void **retval) 1405 void **retval)
965{ 1406{
1407
1408 if (acpi_ec_polling_mode)
1409 return acpi_fake_ecdt_polling_callback(handle,
1410 Level, context, retval);
1411 else
1412 return acpi_fake_ecdt_burst_callback(handle,
1413 Level, context, retval);
1414}
1415
1416static acpi_status __init
1417acpi_fake_ecdt_polling_callback (
1418 acpi_handle handle,
1419 u32 Level,
1420 void *context,
1421 void **retval)
1422{
966 acpi_status status; 1423 acpi_status status;
967 1424
968 status = acpi_walk_resources(handle, METHOD_NAME__CRS, 1425 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
969 acpi_ec_io_ports, ec_ecdt); 1426 acpi_ec_io_ports, ec_ecdt);
970 if (ACPI_FAILURE(status)) 1427 if (ACPI_FAILURE(status))
971 return status; 1428 return status;
972 ec_ecdt->status_addr = ec_ecdt->command_addr; 1429 ec_ecdt->common.status_addr = ec_ecdt->common.command_addr;
973 1430
974 ec_ecdt->uid = -1; 1431 ec_ecdt->common.uid = -1;
975 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->uid); 1432 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid);
976 1433
977 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->gpe_bit); 1434 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->common.gpe_bit);
978 if (ACPI_FAILURE(status)) 1435 if (ACPI_FAILURE(status))
979 return status; 1436 return status;
980 ec_ecdt->global_lock = TRUE; 1437 spin_lock_init(&ec_ecdt->polling.lock);
981 ec_ecdt->handle = handle; 1438 ec_ecdt->common.global_lock = TRUE;
1439 ec_ecdt->common.handle = handle;
982 1440
983 printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n", 1441 printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n",
984 (u32) ec_ecdt->gpe_bit, (u32) ec_ecdt->command_addr.address, 1442 (u32) ec_ecdt->common.gpe_bit, (u32) ec_ecdt->common.command_addr.address,
985 (u32) ec_ecdt->data_addr.address); 1443 (u32) ec_ecdt->common.data_addr.address);
1444
1445 return AE_CTRL_TERMINATE;
1446}
1447
1448static acpi_status __init
1449acpi_fake_ecdt_burst_callback (
1450 acpi_handle handle,
1451 u32 Level,
1452 void *context,
1453 void **retval)
1454{
1455 acpi_status status;
1456
1457 init_MUTEX(&ec_ecdt->burst.sem);
1458 init_waitqueue_head(&ec_ecdt->burst.wait);
1459 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
1460 acpi_ec_io_ports, ec_ecdt);
1461 if (ACPI_FAILURE(status))
1462 return status;
1463 ec_ecdt->common.status_addr = ec_ecdt->common.command_addr;
1464
1465 ec_ecdt->common.uid = -1;
1466 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid);
1467
1468 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->common.gpe_bit);
1469 if (ACPI_FAILURE(status))
1470 return status;
1471 ec_ecdt->common.global_lock = TRUE;
1472 ec_ecdt->common.handle = handle;
1473
1474 printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n",
1475 (u32) ec_ecdt->common.gpe_bit, (u32) ec_ecdt->common.command_addr.address,
1476 (u32) ec_ecdt->common.data_addr.address);
986 1477
987 return AE_CTRL_TERMINATE; 1478 return AE_CTRL_TERMINATE;
988} 1479}
@@ -1005,12 +1496,12 @@ acpi_ec_fake_ecdt(void)
1005 1496
1006 printk(KERN_INFO PREFIX "Try to make an fake ECDT\n"); 1497 printk(KERN_INFO PREFIX "Try to make an fake ECDT\n");
1007 1498
1008 ec_ecdt = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL); 1499 ec_ecdt = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
1009 if (!ec_ecdt) { 1500 if (!ec_ecdt) {
1010 ret = -ENOMEM; 1501 ret = -ENOMEM;
1011 goto error; 1502 goto error;
1012 } 1503 }
1013 memset(ec_ecdt, 0, sizeof(struct acpi_ec)); 1504 memset(ec_ecdt, 0, sizeof(union acpi_ec));
1014 1505
1015 status = acpi_get_devices (ACPI_EC_HID, 1506 status = acpi_get_devices (ACPI_EC_HID,
1016 acpi_fake_ecdt_callback, 1507 acpi_fake_ecdt_callback,
@@ -1031,6 +1522,60 @@ error:
1031static int __init 1522static int __init
1032acpi_ec_get_real_ecdt(void) 1523acpi_ec_get_real_ecdt(void)
1033{ 1524{
1525 if (acpi_ec_polling_mode)
1526 return acpi_ec_polling_get_real_ecdt();
1527 else
1528 return acpi_ec_burst_get_real_ecdt();
1529}
1530
1531static int __init
1532acpi_ec_polling_get_real_ecdt(void)
1533{
1534 acpi_status status;
1535 struct acpi_table_ecdt *ecdt_ptr;
1536
1537 status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING,
1538 (struct acpi_table_header **) &ecdt_ptr);
1539 if (ACPI_FAILURE(status))
1540 return -ENODEV;
1541
1542 printk(KERN_INFO PREFIX "Found ECDT\n");
1543
1544 /*
1545 * Generate a temporary ec context to use until the namespace is scanned
1546 */
1547 ec_ecdt = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
1548 if (!ec_ecdt)
1549 return -ENOMEM;
1550 memset(ec_ecdt, 0, sizeof(union acpi_ec));
1551
1552 ec_ecdt->common.command_addr = ecdt_ptr->ec_control;
1553 ec_ecdt->common.status_addr = ecdt_ptr->ec_control;
1554 ec_ecdt->common.data_addr = ecdt_ptr->ec_data;
1555 ec_ecdt->common.gpe_bit = ecdt_ptr->gpe_bit;
1556 spin_lock_init(&ec_ecdt->polling.lock);
1557 /* use the GL just to be safe */
1558 ec_ecdt->common.global_lock = TRUE;
1559 ec_ecdt->common.uid = ecdt_ptr->uid;
1560
1561 status = acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle);
1562 if (ACPI_FAILURE(status)) {
1563 goto error;
1564 }
1565
1566 return 0;
1567error:
1568 printk(KERN_ERR PREFIX "Could not use ECDT\n");
1569 kfree(ec_ecdt);
1570 ec_ecdt = NULL;
1571
1572 return -ENODEV;
1573}
1574
1575
1576static int __init
1577acpi_ec_burst_get_real_ecdt(void)
1578{
1034 acpi_status status; 1579 acpi_status status;
1035 struct acpi_table_ecdt *ecdt_ptr; 1580 struct acpi_table_ecdt *ecdt_ptr;
1036 1581
@@ -1044,22 +1589,22 @@ acpi_ec_get_real_ecdt(void)
1044 /* 1589 /*
1045 * Generate a temporary ec context to use until the namespace is scanned 1590 * Generate a temporary ec context to use until the namespace is scanned
1046 */ 1591 */
1047 ec_ecdt = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL); 1592 ec_ecdt = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
1048 if (!ec_ecdt) 1593 if (!ec_ecdt)
1049 return -ENOMEM; 1594 return -ENOMEM;
1050 memset(ec_ecdt, 0, sizeof(struct acpi_ec)); 1595 memset(ec_ecdt, 0, sizeof(union acpi_ec));
1051 1596
1052 init_MUTEX(&ec_ecdt->sem); 1597 init_MUTEX(&ec_ecdt->burst.sem);
1053 init_waitqueue_head(&ec_ecdt->wait); 1598 init_waitqueue_head(&ec_ecdt->burst.wait);
1054 ec_ecdt->command_addr = ecdt_ptr->ec_control; 1599 ec_ecdt->common.command_addr = ecdt_ptr->ec_control;
1055 ec_ecdt->status_addr = ecdt_ptr->ec_control; 1600 ec_ecdt->common.status_addr = ecdt_ptr->ec_control;
1056 ec_ecdt->data_addr = ecdt_ptr->ec_data; 1601 ec_ecdt->common.data_addr = ecdt_ptr->ec_data;
1057 ec_ecdt->gpe_bit = ecdt_ptr->gpe_bit; 1602 ec_ecdt->common.gpe_bit = ecdt_ptr->gpe_bit;
1058 /* use the GL just to be safe */ 1603 /* use the GL just to be safe */
1059 ec_ecdt->global_lock = TRUE; 1604 ec_ecdt->common.global_lock = TRUE;
1060 ec_ecdt->uid = ecdt_ptr->uid; 1605 ec_ecdt->common.uid = ecdt_ptr->uid;
1061 1606
1062 status = acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->handle); 1607 status = acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle);
1063 if (ACPI_FAILURE(status)) { 1608 if (ACPI_FAILURE(status)) {
1064 goto error; 1609 goto error;
1065 } 1610 }
@@ -1092,20 +1637,20 @@ acpi_ec_ecdt_probe (void)
1092 /* 1637 /*
1093 * Install GPE handler 1638 * Install GPE handler
1094 */ 1639 */
1095 status = acpi_install_gpe_handler(NULL, ec_ecdt->gpe_bit, 1640 status = acpi_install_gpe_handler(NULL, ec_ecdt->common.gpe_bit,
1096 ACPI_GPE_EDGE_TRIGGERED, &acpi_ec_gpe_handler, 1641 ACPI_GPE_EDGE_TRIGGERED, &acpi_ec_gpe_handler,
1097 ec_ecdt); 1642 ec_ecdt);
1098 if (ACPI_FAILURE(status)) { 1643 if (ACPI_FAILURE(status)) {
1099 goto error; 1644 goto error;
1100 } 1645 }
1101 acpi_set_gpe_type (NULL, ec_ecdt->gpe_bit, ACPI_GPE_TYPE_RUNTIME); 1646 acpi_set_gpe_type (NULL, ec_ecdt->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME);
1102 acpi_enable_gpe (NULL, ec_ecdt->gpe_bit, ACPI_NOT_ISR); 1647 acpi_enable_gpe (NULL, ec_ecdt->common.gpe_bit, ACPI_NOT_ISR);
1103 1648
1104 status = acpi_install_address_space_handler (ACPI_ROOT_OBJECT, 1649 status = acpi_install_address_space_handler (ACPI_ROOT_OBJECT,
1105 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler, 1650 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler,
1106 &acpi_ec_space_setup, ec_ecdt); 1651 &acpi_ec_space_setup, ec_ecdt);
1107 if (ACPI_FAILURE(status)) { 1652 if (ACPI_FAILURE(status)) {
1108 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe_bit, 1653 acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit,
1109 &acpi_ec_gpe_handler); 1654 &acpi_ec_gpe_handler);
1110 goto error; 1655 goto error;
1111 } 1656 }
@@ -1123,7 +1668,7 @@ error:
1123 1668
1124static int __init acpi_ec_init (void) 1669static int __init acpi_ec_init (void)
1125{ 1670{
1126 int result; 1671 int result = 0;
1127 1672
1128 ACPI_FUNCTION_TRACE("acpi_ec_init"); 1673 ACPI_FUNCTION_TRACE("acpi_ec_init");
1129 1674
@@ -1166,4 +1711,24 @@ static int __init acpi_fake_ecdt_setup(char *str)
1166 acpi_fake_ecdt_enabled = 1; 1711 acpi_fake_ecdt_enabled = 1;
1167 return 0; 1712 return 0;
1168} 1713}
1714
1169__setup("acpi_fake_ecdt", acpi_fake_ecdt_setup); 1715__setup("acpi_fake_ecdt", acpi_fake_ecdt_setup);
1716static int __init acpi_ec_set_polling_mode(char *str)
1717{
1718 int burst;
1719
1720 if (!get_option(&str, &burst))
1721 return 0;
1722
1723 if (burst) {
1724 acpi_ec_polling_mode = EC_BURST;
1725 acpi_ec_driver.ops.add = acpi_ec_burst_add;
1726 } else {
1727 acpi_ec_polling_mode = EC_POLLING;
1728 acpi_ec_driver.ops.add = acpi_ec_polling_add;
1729 }
1730 printk(KERN_INFO PREFIX "EC %s mode.\n",
1731 burst ? "burst": "polling");
1732 return 0;
1733}
1734__setup("ec_burst=", acpi_ec_set_polling_mode);
diff --git a/drivers/acpi/hotkey.c b/drivers/acpi/hotkey.c
index babdf762eadb..1f76a40badec 100644
--- a/drivers/acpi/hotkey.c
+++ b/drivers/acpi/hotkey.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * hotkey.c - ACPI Hotkey Driver ($Revision:$) 2 * hotkey.c - ACPI Hotkey Driver ($Revision: 0.2 $)
3 * 3 *
4 * Copyright (C) 2004 Luming Yu <luming.yu@intel.com> 4 * Copyright (C) 2004 Luming Yu <luming.yu@intel.com>
5 * 5 *
@@ -51,17 +51,18 @@
51#define ACPI_HOTKEY_POLLING 0x2 51#define ACPI_HOTKEY_POLLING 0x2
52#define ACPI_UNDEFINED_EVENT 0xf 52#define ACPI_UNDEFINED_EVENT 0xf
53 53
54#define MAX_CONFIG_RECORD_LEN 80 54#define RESULT_STR_LEN 80
55#define MAX_NAME_PATH_LEN 80
56#define MAX_CALL_PARM 80
57 55
58#define IS_EVENT(e) 0xff /* ((e) & 0x40000000) */ 56#define ACTION_METHOD 0
59#define IS_POLL(e) 0xff /* (~((e) & 0x40000000)) */ 57#define POLL_METHOD 1
60 58
59#define IS_EVENT(e) ((e) <= 10000 && (e) >0)
60#define IS_POLL(e) ((e) > 10000)
61#define IS_OTHERS(e) ((e)<=0 || (e)>=20000)
61#define _COMPONENT ACPI_HOTKEY_COMPONENT 62#define _COMPONENT ACPI_HOTKEY_COMPONENT
62ACPI_MODULE_NAME("acpi_hotkey") 63ACPI_MODULE_NAME("acpi_hotkey")
63 64
64 MODULE_AUTHOR("luming.yu@intel.com"); 65MODULE_AUTHOR("luming.yu@intel.com");
65MODULE_DESCRIPTION(ACPI_HOTK_NAME); 66MODULE_DESCRIPTION(ACPI_HOTK_NAME);
66MODULE_LICENSE("GPL"); 67MODULE_LICENSE("GPL");
67 68
@@ -114,7 +115,7 @@ struct acpi_event_hotkey {
114 char *action_method; /* action method */ 115 char *action_method; /* action method */
115}; 116};
116 117
117/* 118/*
118 * There are two ways to poll status 119 * There are two ways to poll status
119 * 1. directy call read_xxx method, without any arguments passed in 120 * 1. directy call read_xxx method, without any arguments passed in
120 * 2. call write_xxx method, with arguments passed in, you need 121 * 2. call write_xxx method, with arguments passed in, you need
@@ -131,7 +132,7 @@ struct acpi_polling_hotkey {
131 char *poll_method; /* poll method */ 132 char *poll_method; /* poll method */
132 acpi_handle action_handle; /* acpi handle attached action method */ 133 acpi_handle action_handle; /* acpi handle attached action method */
133 char *action_method; /* action method */ 134 char *action_method; /* action method */
134 void *poll_result; /* polling_result */ 135 union acpi_object *poll_result; /* polling_result */
135 struct proc_dir_entry *proc; 136 struct proc_dir_entry *proc;
136}; 137};
137 138
@@ -162,20 +163,25 @@ static struct acpi_driver hotkey_driver = {
162 }, 163 },
163}; 164};
164 165
166static void free_hotkey_device(union acpi_hotkey *key);
167static void free_hotkey_buffer(union acpi_hotkey *key);
168static void free_poll_hotkey_buffer(union acpi_hotkey *key);
165static int hotkey_open_config(struct inode *inode, struct file *file); 169static int hotkey_open_config(struct inode *inode, struct file *file);
170static int hotkey_poll_open_config(struct inode *inode, struct file *file);
166static ssize_t hotkey_write_config(struct file *file, 171static ssize_t hotkey_write_config(struct file *file,
167 const char __user * buffer, 172 const char __user * buffer,
168 size_t count, loff_t * data); 173 size_t count, loff_t * data);
169static ssize_t hotkey_write_poll_config(struct file *file,
170 const char __user * buffer,
171 size_t count, loff_t * data);
172static int hotkey_info_open_fs(struct inode *inode, struct file *file); 174static int hotkey_info_open_fs(struct inode *inode, struct file *file);
173static int hotkey_action_open_fs(struct inode *inode, struct file *file); 175static int hotkey_action_open_fs(struct inode *inode, struct file *file);
174static ssize_t hotkey_execute_aml_method(struct file *file, 176static ssize_t hotkey_execute_aml_method(struct file *file,
175 const char __user * buffer, 177 const char __user * buffer,
176 size_t count, loff_t * data); 178 size_t count, loff_t * data);
177static int hotkey_config_seq_show(struct seq_file *seq, void *offset); 179static int hotkey_config_seq_show(struct seq_file *seq, void *offset);
180static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset);
178static int hotkey_polling_open_fs(struct inode *inode, struct file *file); 181static int hotkey_polling_open_fs(struct inode *inode, struct file *file);
182static union acpi_hotkey *get_hotkey_by_event(struct
183 acpi_hotkey_list
184 *hotkey_list, int event);
179 185
180/* event based config */ 186/* event based config */
181static struct file_operations hotkey_config_fops = { 187static struct file_operations hotkey_config_fops = {
@@ -188,9 +194,9 @@ static struct file_operations hotkey_config_fops = {
188 194
189/* polling based config */ 195/* polling based config */
190static struct file_operations hotkey_poll_config_fops = { 196static struct file_operations hotkey_poll_config_fops = {
191 .open = hotkey_open_config, 197 .open = hotkey_poll_open_config,
192 .read = seq_read, 198 .read = seq_read,
193 .write = hotkey_write_poll_config, 199 .write = hotkey_write_config,
194 .llseek = seq_lseek, 200 .llseek = seq_lseek,
195 .release = single_release, 201 .release = single_release,
196}; 202};
@@ -227,7 +233,7 @@ static int hotkey_info_seq_show(struct seq_file *seq, void *offset)
227{ 233{
228 ACPI_FUNCTION_TRACE("hotkey_info_seq_show"); 234 ACPI_FUNCTION_TRACE("hotkey_info_seq_show");
229 235
230 seq_printf(seq, "Hotkey generic driver ver: %s", HOTKEY_ACPI_VERSION); 236 seq_printf(seq, "Hotkey generic driver ver: %s\n", HOTKEY_ACPI_VERSION);
231 237
232 return_VALUE(0); 238 return_VALUE(0);
233} 239}
@@ -239,27 +245,35 @@ static int hotkey_info_open_fs(struct inode *inode, struct file *file)
239 245
240static char *format_result(union acpi_object *object) 246static char *format_result(union acpi_object *object)
241{ 247{
242 char *buf = (char *)kmalloc(sizeof(union acpi_object), GFP_KERNEL); 248 char *buf = NULL;
243 249
244 memset(buf, 0, sizeof(union acpi_object)); 250 buf = (char *)kmalloc(RESULT_STR_LEN, GFP_KERNEL);
251 if (buf)
252 memset(buf, 0, RESULT_STR_LEN);
253 else
254 goto do_fail;
245 255
246 /* Now, just support integer type */ 256 /* Now, just support integer type */
247 if (object->type == ACPI_TYPE_INTEGER) 257 if (object->type == ACPI_TYPE_INTEGER)
248 sprintf(buf, "%d", (u32) object->integer.value); 258 sprintf(buf, "%d\n", (u32) object->integer.value);
249 259do_fail:
250 return buf; 260 return (buf);
251} 261}
252 262
253static int hotkey_polling_seq_show(struct seq_file *seq, void *offset) 263static int hotkey_polling_seq_show(struct seq_file *seq, void *offset)
254{ 264{
255 struct acpi_polling_hotkey *poll_hotkey = 265 struct acpi_polling_hotkey *poll_hotkey =
256 (struct acpi_polling_hotkey *)seq->private; 266 (struct acpi_polling_hotkey *)seq->private;
267 char *buf;
257 268
258 ACPI_FUNCTION_TRACE("hotkey_polling_seq_show"); 269 ACPI_FUNCTION_TRACE("hotkey_polling_seq_show");
259 270
260 if (poll_hotkey->poll_result) 271 if (poll_hotkey->poll_result){
261 seq_printf(seq, "%s", format_result(poll_hotkey->poll_result)); 272 buf = format_result(poll_hotkey->poll_result);
262 273 if(buf)
274 seq_printf(seq, "%s", buf);
275 kfree(buf);
276 }
263 return_VALUE(0); 277 return_VALUE(0);
264} 278}
265 279
@@ -276,19 +290,19 @@ static int hotkey_action_open_fs(struct inode *inode, struct file *file)
276/* Mapping external hotkey number to standardized hotkey event num */ 290/* Mapping external hotkey number to standardized hotkey event num */
277static int hotkey_get_internal_event(int event, struct acpi_hotkey_list *list) 291static int hotkey_get_internal_event(int event, struct acpi_hotkey_list *list)
278{ 292{
279 struct list_head *entries, *next; 293 struct list_head *entries;
280 int val = 0; 294 int val = -1;
281 295
282 ACPI_FUNCTION_TRACE("hotkey_get_internal_event"); 296 ACPI_FUNCTION_TRACE("hotkey_get_internal_event");
283 297
284 list_for_each_safe(entries, next, list->entries) { 298 list_for_each(entries, list->entries) {
285 union acpi_hotkey *key = 299 union acpi_hotkey *key =
286 container_of(entries, union acpi_hotkey, entries); 300 container_of(entries, union acpi_hotkey, entries);
287 if (key->link.hotkey_type == ACPI_HOTKEY_EVENT 301 if (key->link.hotkey_type == ACPI_HOTKEY_EVENT
288 && key->event_hotkey.external_hotkey_num == event) 302 && key->event_hotkey.external_hotkey_num == event){
289 val = key->link.hotkey_standard_num; 303 val = key->link.hotkey_standard_num;
290 else 304 break;
291 val = -1; 305 }
292 } 306 }
293 307
294 return_VALUE(val); 308 return_VALUE(val);
@@ -306,7 +320,7 @@ acpi_hotkey_notify_handler(acpi_handle handle, u32 event, void *data)
306 return_VOID; 320 return_VOID;
307 321
308 internal_event = hotkey_get_internal_event(event, &global_hotkey_list); 322 internal_event = hotkey_get_internal_event(event, &global_hotkey_list);
309 acpi_bus_generate_event(device, event, 0); 323 acpi_bus_generate_event(device, internal_event, 0);
310 324
311 return_VOID; 325 return_VOID;
312} 326}
@@ -329,13 +343,17 @@ static int auto_hotkey_remove(struct acpi_device *device, int type)
329static int create_polling_proc(union acpi_hotkey *device) 343static int create_polling_proc(union acpi_hotkey *device)
330{ 344{
331 struct proc_dir_entry *proc; 345 struct proc_dir_entry *proc;
346 char proc_name[80];
332 mode_t mode; 347 mode_t mode;
333 348
334 ACPI_FUNCTION_TRACE("create_polling_proc"); 349 ACPI_FUNCTION_TRACE("create_polling_proc");
335 mode = S_IFREG | S_IRUGO | S_IWUGO; 350 mode = S_IFREG | S_IRUGO | S_IWUGO;
336 351
337 proc = create_proc_entry(device->poll_hotkey.action_method, 352 sprintf(proc_name, "%d", device->link.hotkey_standard_num);
338 mode, hotkey_proc_dir); 353 /*
354 strcat(proc_name, device->poll_hotkey.poll_method);
355 */
356 proc = create_proc_entry(proc_name, mode, hotkey_proc_dir);
339 357
340 if (!proc) { 358 if (!proc) {
341 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 359 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
@@ -353,23 +371,6 @@ static int create_polling_proc(union acpi_hotkey *device)
353 return_VALUE(0); 371 return_VALUE(0);
354} 372}
355 373
356static int is_valid_acpi_path(const char *pathname)
357{
358 acpi_handle handle;
359 acpi_status status;
360 ACPI_FUNCTION_TRACE("is_valid_acpi_path");
361
362 status = acpi_get_handle(NULL, (char *)pathname, &handle);
363 return_VALUE(!ACPI_FAILURE(status));
364}
365
366static int is_valid_hotkey(union acpi_hotkey *device)
367{
368 ACPI_FUNCTION_TRACE("is_valid_hotkey");
369 /* Implement valid check */
370 return_VALUE(1);
371}
372
373static int hotkey_add(union acpi_hotkey *device) 374static int hotkey_add(union acpi_hotkey *device)
374{ 375{
375 int status = 0; 376 int status = 0;
@@ -378,15 +379,11 @@ static int hotkey_add(union acpi_hotkey *device)
378 ACPI_FUNCTION_TRACE("hotkey_add"); 379 ACPI_FUNCTION_TRACE("hotkey_add");
379 380
380 if (device->link.hotkey_type == ACPI_HOTKEY_EVENT) { 381 if (device->link.hotkey_type == ACPI_HOTKEY_EVENT) {
381 status = 382 acpi_bus_get_device(device->event_hotkey.bus_handle, &dev);
382 acpi_bus_get_device(device->event_hotkey.bus_handle, &dev);
383 if (status)
384 return_VALUE(status);
385
386 status = acpi_install_notify_handler(dev->handle, 383 status = acpi_install_notify_handler(dev->handle,
387 ACPI_SYSTEM_NOTIFY, 384 ACPI_DEVICE_NOTIFY,
388 acpi_hotkey_notify_handler, 385 acpi_hotkey_notify_handler,
389 device); 386 dev);
390 } else /* Add polling hotkey */ 387 } else /* Add polling hotkey */
391 create_polling_proc(device); 388 create_polling_proc(device);
392 389
@@ -409,84 +406,143 @@ static int hotkey_remove(union acpi_hotkey *device)
409 if (key->link.hotkey_standard_num == 406 if (key->link.hotkey_standard_num ==
410 device->link.hotkey_standard_num) { 407 device->link.hotkey_standard_num) {
411 list_del(&key->link.entries); 408 list_del(&key->link.entries);
412 remove_proc_entry(key->poll_hotkey.action_method, 409 free_hotkey_device(key);
413 hotkey_proc_dir);
414 global_hotkey_list.count--; 410 global_hotkey_list.count--;
415 break; 411 break;
416 } 412 }
417 } 413 }
414 kfree(device);
418 return_VALUE(0); 415 return_VALUE(0);
419} 416}
420 417
421static void hotkey_update(union acpi_hotkey *key) 418static int hotkey_update(union acpi_hotkey *key)
422{ 419{
423 struct list_head *entries, *next; 420 struct list_head *entries;
424 421
425 ACPI_FUNCTION_TRACE("hotkey_update"); 422 ACPI_FUNCTION_TRACE("hotkey_update");
426 423
427 list_for_each_safe(entries, next, global_hotkey_list.entries) { 424 list_for_each(entries, global_hotkey_list.entries) {
428 union acpi_hotkey *key = 425 union acpi_hotkey *tmp=
429 container_of(entries, union acpi_hotkey, entries); 426 container_of(entries, union acpi_hotkey, entries);
430 if (key->link.hotkey_standard_num == 427 if (tmp->link.hotkey_standard_num ==
431 key->link.hotkey_standard_num) { 428 key->link.hotkey_standard_num) {
432 key->event_hotkey.bus_handle = 429 if (key->link.hotkey_type == ACPI_HOTKEY_EVENT) {
433 key->event_hotkey.bus_handle; 430 free_hotkey_buffer(tmp);
434 key->event_hotkey.external_hotkey_num = 431 tmp->event_hotkey.bus_handle =
435 key->event_hotkey.external_hotkey_num; 432 key->event_hotkey.bus_handle;
436 key->event_hotkey.action_handle = 433 tmp->event_hotkey.external_hotkey_num =
437 key->event_hotkey.action_handle; 434 key->event_hotkey.external_hotkey_num;
438 key->event_hotkey.action_method = 435 tmp->event_hotkey.action_handle =
439 key->event_hotkey.action_method; 436 key->event_hotkey.action_handle;
437 tmp->event_hotkey.action_method =
438 key->event_hotkey.action_method;
439 kfree(key);
440 } else {
441 /*
442 char proc_name[80];
443
444 sprintf(proc_name, "%d", tmp->link.hotkey_standard_num);
445 strcat(proc_name, tmp->poll_hotkey.poll_method);
446 remove_proc_entry(proc_name,hotkey_proc_dir);
447 */
448 free_poll_hotkey_buffer(tmp);
449 tmp->poll_hotkey.poll_handle =
450 key->poll_hotkey.poll_handle;
451 tmp->poll_hotkey.poll_method =
452 key->poll_hotkey.poll_method;
453 tmp->poll_hotkey.action_handle =
454 key->poll_hotkey.action_handle;
455 tmp->poll_hotkey.action_method =
456 key->poll_hotkey.action_method;
457 tmp->poll_hotkey.poll_result =
458 key->poll_hotkey.poll_result;
459 /*
460 create_polling_proc(tmp);
461 */
462 kfree(key);
463 }
464 return_VALUE(0);
440 break; 465 break;
441 } 466 }
442 } 467 }
443 468
444 return_VOID; 469 return_VALUE(-ENODEV);
445} 470}
446 471
447static void free_hotkey_device(union acpi_hotkey *key) 472static void free_hotkey_device(union acpi_hotkey *key)
448{ 473{
449 struct acpi_device *dev; 474 struct acpi_device *dev;
450 int status;
451 475
452 ACPI_FUNCTION_TRACE("free_hotkey_device"); 476 ACPI_FUNCTION_TRACE("free_hotkey_device");
453 477
454 if (key->link.hotkey_type == ACPI_HOTKEY_EVENT) { 478 if (key->link.hotkey_type == ACPI_HOTKEY_EVENT) {
455 status = 479 acpi_bus_get_device(key->event_hotkey.bus_handle, &dev);
456 acpi_bus_get_device(key->event_hotkey.bus_handle, &dev);
457 if (dev->handle) 480 if (dev->handle)
458 acpi_remove_notify_handler(dev->handle, 481 acpi_remove_notify_handler(dev->handle,
459 ACPI_SYSTEM_NOTIFY, 482 ACPI_DEVICE_NOTIFY,
460 acpi_hotkey_notify_handler); 483 acpi_hotkey_notify_handler);
461 } else 484 free_hotkey_buffer(key);
462 remove_proc_entry(key->poll_hotkey.action_method, 485 } else {
463 hotkey_proc_dir); 486 char proc_name[80];
487
488 sprintf(proc_name, "%d", key->link.hotkey_standard_num);
489 /*
490 strcat(proc_name, key->poll_hotkey.poll_method);
491 */
492 remove_proc_entry(proc_name,hotkey_proc_dir);
493 free_poll_hotkey_buffer(key);
494 }
464 kfree(key); 495 kfree(key);
465 return_VOID; 496 return_VOID;
466} 497}
467 498
499static void
500free_hotkey_buffer(union acpi_hotkey *key)
501{
502 kfree(key->event_hotkey.action_method);
503}
504
505static void
506free_poll_hotkey_buffer(union acpi_hotkey *key)
507{
508 kfree(key->poll_hotkey.action_method);
509 kfree(key->poll_hotkey.poll_method);
510 kfree(key->poll_hotkey.poll_result);
511}
468static int 512static int
469init_hotkey_device(union acpi_hotkey *key, char *bus_str, char *action_str, 513init_hotkey_device(union acpi_hotkey *key, char *bus_str, char *action_str,
470 char *method, int std_num, int external_num) 514 char *method, int std_num, int external_num)
471{ 515{
516 acpi_handle tmp_handle;
517 acpi_status status = AE_OK;
518
472 ACPI_FUNCTION_TRACE("init_hotkey_device"); 519 ACPI_FUNCTION_TRACE("init_hotkey_device");
473 520
521 if(std_num < 0 || IS_POLL(std_num) || !key )
522 goto do_fail;
523
524 if(!bus_str || !action_str || !method)
525 goto do_fail;
526
474 key->link.hotkey_type = ACPI_HOTKEY_EVENT; 527 key->link.hotkey_type = ACPI_HOTKEY_EVENT;
475 key->link.hotkey_standard_num = std_num; 528 key->link.hotkey_standard_num = std_num;
476 key->event_hotkey.flag = 0; 529 key->event_hotkey.flag = 0;
477 if (is_valid_acpi_path(bus_str)) 530 key->event_hotkey.action_method = method;
478 acpi_get_handle((acpi_handle) 0,
479 bus_str, &(key->event_hotkey.bus_handle));
480 else
481 return_VALUE(-ENODEV);
482 key->event_hotkey.external_hotkey_num = external_num;
483 if (is_valid_acpi_path(action_str))
484 acpi_get_handle((acpi_handle) 0,
485 action_str, &(key->event_hotkey.action_handle));
486 key->event_hotkey.action_method = kmalloc(sizeof(method), GFP_KERNEL);
487 strcpy(key->event_hotkey.action_method, method);
488 531
489 return_VALUE(!is_valid_hotkey(key)); 532 status = acpi_get_handle(NULL,bus_str, &(key->event_hotkey.bus_handle));
533 if(ACPI_FAILURE(status))
534 goto do_fail;
535 key->event_hotkey.external_hotkey_num = external_num;
536 status = acpi_get_handle(NULL,action_str, &(key->event_hotkey.action_handle));
537 if(ACPI_FAILURE(status))
538 goto do_fail;
539 status = acpi_get_handle(key->event_hotkey.action_handle,
540 method, &tmp_handle);
541 if (ACPI_FAILURE(status))
542 goto do_fail;
543 return_VALUE(AE_OK);
544do_fail:
545 return_VALUE(-ENODEV);
490} 546}
491 547
492static int 548static int
@@ -495,34 +551,46 @@ init_poll_hotkey_device(union acpi_hotkey *key,
495 char *poll_method, 551 char *poll_method,
496 char *action_str, char *action_method, int std_num) 552 char *action_str, char *action_method, int std_num)
497{ 553{
554 acpi_status status = AE_OK;
555 acpi_handle tmp_handle;
556
498 ACPI_FUNCTION_TRACE("init_poll_hotkey_device"); 557 ACPI_FUNCTION_TRACE("init_poll_hotkey_device");
499 558
559 if(std_num < 0 || IS_EVENT(std_num) || !key)
560 goto do_fail;
561
562 if(!poll_str || !poll_method || !action_str || !action_method)
563 goto do_fail;
564
500 key->link.hotkey_type = ACPI_HOTKEY_POLLING; 565 key->link.hotkey_type = ACPI_HOTKEY_POLLING;
501 key->link.hotkey_standard_num = std_num; 566 key->link.hotkey_standard_num = std_num;
502 key->poll_hotkey.flag = 0; 567 key->poll_hotkey.flag = 0;
503 if (is_valid_acpi_path(poll_str))
504 acpi_get_handle((acpi_handle) 0,
505 poll_str, &(key->poll_hotkey.poll_handle));
506 else
507 return_VALUE(-ENODEV);
508 key->poll_hotkey.poll_method = poll_method; 568 key->poll_hotkey.poll_method = poll_method;
509 if (is_valid_acpi_path(action_str)) 569 key->poll_hotkey.action_method = action_method;
510 acpi_get_handle((acpi_handle) 0, 570
511 action_str, &(key->poll_hotkey.action_handle)); 571 status = acpi_get_handle(NULL,poll_str, &(key->poll_hotkey.poll_handle));
512 key->poll_hotkey.action_method = 572 if(ACPI_FAILURE(status))
513 kmalloc(sizeof(action_method), GFP_KERNEL); 573 goto do_fail;
514 strcpy(key->poll_hotkey.action_method, action_method); 574 status = acpi_get_handle(key->poll_hotkey.poll_handle,
575 poll_method, &tmp_handle);
576 if (ACPI_FAILURE(status))
577 goto do_fail;
578 status = acpi_get_handle(NULL,action_str, &(key->poll_hotkey.action_handle));
579 if (ACPI_FAILURE(status))
580 goto do_fail;
581 status = acpi_get_handle(key->poll_hotkey.action_handle,
582 action_method, &tmp_handle);
583 if (ACPI_FAILURE(status))
584 goto do_fail;
515 key->poll_hotkey.poll_result = 585 key->poll_hotkey.poll_result =
516 (union acpi_object *)kmalloc(sizeof(union acpi_object), GFP_KERNEL); 586 (union acpi_object *)kmalloc(sizeof(union acpi_object), GFP_KERNEL);
517 return_VALUE(is_valid_hotkey(key)); 587 if(!key->poll_hotkey.poll_result)
588 goto do_fail;
589 return_VALUE(AE_OK);
590do_fail:
591 return_VALUE(-ENODEV);
518} 592}
519 593
520static int check_hotkey_valid(union acpi_hotkey *key,
521 struct acpi_hotkey_list *list)
522{
523 ACPI_FUNCTION_TRACE("check_hotkey_valid");
524 return_VALUE(0);
525}
526 594
527static int hotkey_open_config(struct inode *inode, struct file *file) 595static int hotkey_open_config(struct inode *inode, struct file *file)
528{ 596{
@@ -531,10 +599,17 @@ static int hotkey_open_config(struct inode *inode, struct file *file)
531 (file, hotkey_config_seq_show, PDE(inode)->data)); 599 (file, hotkey_config_seq_show, PDE(inode)->data));
532} 600}
533 601
602static int hotkey_poll_open_config(struct inode *inode, struct file *file)
603{
604 ACPI_FUNCTION_TRACE("hotkey_poll_open_config");
605 return_VALUE(single_open
606 (file, hotkey_poll_config_seq_show, PDE(inode)->data));
607}
608
534static int hotkey_config_seq_show(struct seq_file *seq, void *offset) 609static int hotkey_config_seq_show(struct seq_file *seq, void *offset)
535{ 610{
536 struct acpi_hotkey_list *hotkey_list = &global_hotkey_list; 611 struct acpi_hotkey_list *hotkey_list = &global_hotkey_list;
537 struct list_head *entries, *next; 612 struct list_head *entries;
538 char bus_name[ACPI_PATHNAME_MAX] = { 0 }; 613 char bus_name[ACPI_PATHNAME_MAX] = { 0 };
539 char action_name[ACPI_PATHNAME_MAX] = { 0 }; 614 char action_name[ACPI_PATHNAME_MAX] = { 0 };
540 struct acpi_buffer bus = { ACPI_PATHNAME_MAX, bus_name }; 615 struct acpi_buffer bus = { ACPI_PATHNAME_MAX, bus_name };
@@ -542,10 +617,7 @@ static int hotkey_config_seq_show(struct seq_file *seq, void *offset)
542 617
543 ACPI_FUNCTION_TRACE(("hotkey_config_seq_show")); 618 ACPI_FUNCTION_TRACE(("hotkey_config_seq_show"));
544 619
545 if (!hotkey_list) 620 list_for_each(entries, hotkey_list->entries) {
546 goto end;
547
548 list_for_each_safe(entries, next, hotkey_list->entries) {
549 union acpi_hotkey *key = 621 union acpi_hotkey *key =
550 container_of(entries, union acpi_hotkey, entries); 622 container_of(entries, union acpi_hotkey, entries);
551 if (key->link.hotkey_type == ACPI_HOTKEY_EVENT) { 623 if (key->link.hotkey_type == ACPI_HOTKEY_EVENT) {
@@ -553,18 +625,37 @@ static int hotkey_config_seq_show(struct seq_file *seq, void *offset)
553 ACPI_NAME_TYPE_MAX, &bus); 625 ACPI_NAME_TYPE_MAX, &bus);
554 acpi_get_name(key->event_hotkey.action_handle, 626 acpi_get_name(key->event_hotkey.action_handle,
555 ACPI_NAME_TYPE_MAX, &act); 627 ACPI_NAME_TYPE_MAX, &act);
556 seq_printf(seq, "%s:%s:%s:%d:%d", bus_name, 628 seq_printf(seq, "%s:%s:%s:%d:%d\n", bus_name,
557 action_name, 629 action_name,
558 key->event_hotkey.action_method, 630 key->event_hotkey.action_method,
559 key->link.hotkey_standard_num, 631 key->link.hotkey_standard_num,
560 key->event_hotkey.external_hotkey_num); 632 key->event_hotkey.external_hotkey_num);
561 } /* ACPI_HOTKEY_POLLING */ 633 }
562 else { 634 }
635 seq_puts(seq, "\n");
636 return_VALUE(0);
637}
638
639static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset)
640{
641 struct acpi_hotkey_list *hotkey_list = &global_hotkey_list;
642 struct list_head *entries;
643 char bus_name[ACPI_PATHNAME_MAX] = { 0 };
644 char action_name[ACPI_PATHNAME_MAX] = { 0 };
645 struct acpi_buffer bus = { ACPI_PATHNAME_MAX, bus_name };
646 struct acpi_buffer act = { ACPI_PATHNAME_MAX, action_name };
647
648 ACPI_FUNCTION_TRACE(("hotkey_config_seq_show"));
649
650 list_for_each(entries, hotkey_list->entries) {
651 union acpi_hotkey *key =
652 container_of(entries, union acpi_hotkey, entries);
653 if (key->link.hotkey_type == ACPI_HOTKEY_POLLING) {
563 acpi_get_name(key->poll_hotkey.poll_handle, 654 acpi_get_name(key->poll_hotkey.poll_handle,
564 ACPI_NAME_TYPE_MAX, &bus); 655 ACPI_NAME_TYPE_MAX, &bus);
565 acpi_get_name(key->poll_hotkey.action_handle, 656 acpi_get_name(key->poll_hotkey.action_handle,
566 ACPI_NAME_TYPE_MAX, &act); 657 ACPI_NAME_TYPE_MAX, &act);
567 seq_printf(seq, "%s:%s:%s:%s:%d", bus_name, 658 seq_printf(seq, "%s:%s:%s:%s:%d\n", bus_name,
568 key->poll_hotkey.poll_method, 659 key->poll_hotkey.poll_method,
569 action_name, 660 action_name,
570 key->poll_hotkey.action_method, 661 key->poll_hotkey.action_method,
@@ -572,49 +663,83 @@ static int hotkey_config_seq_show(struct seq_file *seq, void *offset)
572 } 663 }
573 } 664 }
574 seq_puts(seq, "\n"); 665 seq_puts(seq, "\n");
575 end:
576 return_VALUE(0); 666 return_VALUE(0);
577} 667}
578 668
579static int 669static int
580get_parms(char *config_record, 670get_parms(char *config_record,
581 int *cmd, 671 int *cmd,
582 char *bus_handle, 672 char **bus_handle,
583 char *bus_method, 673 char **bus_method,
584 char *action_handle, 674 char **action_handle,
585 char *method, int *internal_event_num, int *external_event_num) 675 char **method, int *internal_event_num, int *external_event_num)
586{ 676{
587 char *tmp, *tmp1; 677 char *tmp, *tmp1, count;
588 ACPI_FUNCTION_TRACE(("get_parms")); 678 ACPI_FUNCTION_TRACE(("get_parms"));
589 679
590 sscanf(config_record, "%d", cmd); 680 sscanf(config_record, "%d", cmd);
591 681
682 if(*cmd == 1){
683 if(sscanf(config_record, "%d:%d", cmd, internal_event_num)!=2)
684 goto do_fail;
685 else
686 return (6);
687 }
592 tmp = strchr(config_record, ':'); 688 tmp = strchr(config_record, ':');
689 if (!tmp)
690 goto do_fail;
593 tmp++; 691 tmp++;
594 tmp1 = strchr(tmp, ':'); 692 tmp1 = strchr(tmp, ':');
595 strncpy(bus_handle, tmp, tmp1 - tmp); 693 if (!tmp1)
596 bus_handle[tmp1 - tmp] = 0; 694 goto do_fail;
695
696 count = tmp1 - tmp;
697 *bus_handle = (char *) kmalloc(count+1, GFP_KERNEL);
698 if(!*bus_handle)
699 goto do_fail;
700 strncpy(*bus_handle, tmp, count);
701 *(*bus_handle + count) = 0;
597 702
598 tmp = tmp1; 703 tmp = tmp1;
599 tmp++; 704 tmp++;
600 tmp1 = strchr(tmp, ':'); 705 tmp1 = strchr(tmp, ':');
601 strncpy(bus_method, tmp, tmp1 - tmp); 706 if (!tmp1)
602 bus_method[tmp1 - tmp] = 0; 707 goto do_fail;
708 count = tmp1 - tmp;
709 *bus_method = (char *) kmalloc(count+1, GFP_KERNEL);
710 if(!*bus_method)
711 goto do_fail;
712 strncpy(*bus_method, tmp, count);
713 *(*bus_method + count) = 0;
603 714
604 tmp = tmp1; 715 tmp = tmp1;
605 tmp++; 716 tmp++;
606 tmp1 = strchr(tmp, ':'); 717 tmp1 = strchr(tmp, ':');
607 strncpy(action_handle, tmp, tmp1 - tmp); 718 if (!tmp1)
608 action_handle[tmp1 - tmp] = 0; 719 goto do_fail;
720 count = tmp1 - tmp;
721 *action_handle = (char *) kmalloc(count+1, GFP_KERNEL);
722 strncpy(*action_handle, tmp, count);
723 *(*action_handle + count) = 0;
609 724
610 tmp = tmp1; 725 tmp = tmp1;
611 tmp++; 726 tmp++;
612 tmp1 = strchr(tmp, ':'); 727 tmp1 = strchr(tmp, ':');
613 strncpy(method, tmp, tmp1 - tmp); 728 if (!tmp1)
614 method[tmp1 - tmp] = 0; 729 goto do_fail;
730 count = tmp1 - tmp;
731 *method = (char *) kmalloc(count+1, GFP_KERNEL);
732 if(!*method)
733 goto do_fail;
734 strncpy(*method, tmp, count);
735 *(*method + count) = 0;
736
737 if(sscanf(tmp1 + 1, "%d:%d", internal_event_num, external_event_num)<=0)
738 goto do_fail;
615 739
616 sscanf(tmp1 + 1, "%d:%d", internal_event_num, external_event_num);
617 return_VALUE(6); 740 return_VALUE(6);
741do_fail:
742 return_VALUE(-1);
618} 743}
619 744
620/* count is length for one input record */ 745/* count is length for one input record */
@@ -622,135 +747,117 @@ static ssize_t hotkey_write_config(struct file *file,
622 const char __user * buffer, 747 const char __user * buffer,
623 size_t count, loff_t * data) 748 size_t count, loff_t * data)
624{ 749{
625 struct acpi_hotkey_list *hotkey_list = &global_hotkey_list; 750 char *config_record = NULL;
626 char config_record[MAX_CONFIG_RECORD_LEN]; 751 char *bus_handle = NULL;
627 char bus_handle[MAX_NAME_PATH_LEN]; 752 char *bus_method = NULL;
628 char bus_method[MAX_NAME_PATH_LEN]; 753 char *action_handle = NULL;
629 char action_handle[MAX_NAME_PATH_LEN]; 754 char *method = NULL;
630 char method[20];
631 int cmd, internal_event_num, external_event_num; 755 int cmd, internal_event_num, external_event_num;
632 int ret = 0; 756 int ret = 0;
633 union acpi_hotkey *key = NULL; 757 union acpi_hotkey *key = NULL;
634 758
635 ACPI_FUNCTION_TRACE(("hotkey_write_config")); 759 ACPI_FUNCTION_TRACE(("hotkey_write_config"));
636 760
637 if (!hotkey_list || count > MAX_CONFIG_RECORD_LEN) { 761 config_record = (char *) kmalloc(count+1, GFP_KERNEL);
638 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid arguments\n")); 762 if(!config_record)
639 return_VALUE(-EINVAL); 763 return_VALUE(-ENOMEM);
640 }
641 764
642 if (copy_from_user(config_record, buffer, count)) { 765 if (copy_from_user(config_record, buffer, count)) {
766 kfree(config_record);
643 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data \n")); 767 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data \n"));
644 return_VALUE(-EINVAL); 768 return_VALUE(-EINVAL);
645 } 769 }
646 config_record[count] = '\0'; 770 config_record[count] = 0;
647 771
648 ret = get_parms(config_record, 772 ret = get_parms(config_record,
649 &cmd, 773 &cmd,
650 bus_handle, 774 &bus_handle,
651 bus_method, 775 &bus_method,
652 action_handle, 776 &action_handle,
653 method, &internal_event_num, &external_event_num); 777 &method, &internal_event_num, &external_event_num);
778
779 kfree(config_record);
780 if(IS_OTHERS(internal_event_num))
781 goto do_fail;
654 if (ret != 6) { 782 if (ret != 6) {
783do_fail:
784 kfree(bus_handle);
785 kfree(bus_method);
786 kfree(action_handle);
787 kfree(method);
655 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 788 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
656 "Invalid data format ret=%d\n", ret)); 789 "Invalid data format ret=%d\n", ret));
657 return_VALUE(-EINVAL); 790 return_VALUE(-EINVAL);
658 } 791 }
659 792
660 key = kmalloc(sizeof(union acpi_hotkey), GFP_KERNEL); 793 key = kmalloc(sizeof(union acpi_hotkey), GFP_KERNEL);
661 ret = init_hotkey_device(key, bus_handle, action_handle, method, 794 if(!key)
795 goto do_fail;
796 memset(key, 0, sizeof(union acpi_hotkey));
797 if(cmd == 1) {
798 union acpi_hotkey *tmp = NULL;
799 tmp = get_hotkey_by_event(&global_hotkey_list,
800 internal_event_num);
801 if(!tmp)
802 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid key"));
803 else
804 memcpy(key, tmp, sizeof(union acpi_hotkey));
805 goto cont_cmd;
806 }
807 if (IS_EVENT(internal_event_num)) {
808 kfree(bus_method);
809 ret = init_hotkey_device(key, bus_handle, action_handle, method,
662 internal_event_num, external_event_num); 810 internal_event_num, external_event_num);
663 811 } else
664 if (ret || check_hotkey_valid(key, hotkey_list)) { 812 ret = init_poll_hotkey_device(key, bus_handle, bus_method,
813 action_handle, method,
814 internal_event_num);
815 if (ret) {
816 kfree(bus_handle);
817 kfree(action_handle);
818 if(IS_EVENT(internal_event_num))
819 free_hotkey_buffer(key);
820 else
821 free_poll_hotkey_buffer(key);
665 kfree(key); 822 kfree(key);
666 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid hotkey \n")); 823 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid hotkey \n"));
667 return_VALUE(-EINVAL); 824 return_VALUE(-EINVAL);
668 } 825 }
669 switch (cmd) {
670 case 0:
671 hotkey_add(key);
672 break;
673 case 1:
674 hotkey_remove(key);
675 free_hotkey_device(key);
676 break;
677 case 2:
678 hotkey_update(key);
679 break;
680 default:
681 break;
682 }
683 return_VALUE(count);
684}
685
686/* count is length for one input record */
687static ssize_t hotkey_write_poll_config(struct file *file,
688 const char __user * buffer,
689 size_t count, loff_t * data)
690{
691 struct seq_file *m = (struct seq_file *)file->private_data;
692 struct acpi_hotkey_list *hotkey_list =
693 (struct acpi_hotkey_list *)m->private;
694
695 char config_record[MAX_CONFIG_RECORD_LEN];
696 char polling_handle[MAX_NAME_PATH_LEN];
697 char action_handle[MAX_NAME_PATH_LEN];
698 char poll_method[20], action_method[20];
699 int ret, internal_event_num, cmd, external_event_num;
700 union acpi_hotkey *key = NULL;
701
702 ACPI_FUNCTION_TRACE("hotkey_write_poll_config");
703
704 if (!hotkey_list || count > MAX_CONFIG_RECORD_LEN) {
705 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid arguments\n"));
706 return_VALUE(-EINVAL);
707 }
708
709 if (copy_from_user(config_record, buffer, count)) {
710 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data \n"));
711 return_VALUE(-EINVAL);
712 }
713 config_record[count] = '\0';
714 826
715 ret = get_parms(config_record, 827cont_cmd:
716 &cmd, 828 kfree(bus_handle);
717 polling_handle, 829 kfree(action_handle);
718 poll_method,
719 action_handle,
720 action_method,
721 &internal_event_num, &external_event_num);
722
723 if (ret != 6) {
724 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data format\n"));
725 return_VALUE(-EINVAL);
726 }
727 830
728 key = kmalloc(sizeof(union acpi_hotkey), GFP_KERNEL);
729 ret = init_poll_hotkey_device(key, polling_handle, poll_method,
730 action_handle, action_method,
731 internal_event_num);
732 if (ret || check_hotkey_valid(key, hotkey_list)) {
733 kfree(key);
734 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid hotkey \n"));
735 return_VALUE(-EINVAL);
736 }
737 switch (cmd) { 831 switch (cmd) {
738 case 0: 832 case 0:
739 hotkey_add(key); 833 if(get_hotkey_by_event(&global_hotkey_list,key->link.hotkey_standard_num))
834 goto fail_out;
835 else
836 hotkey_add(key);
740 break; 837 break;
741 case 1: 838 case 1:
742 hotkey_remove(key); 839 hotkey_remove(key);
743 break; 840 break;
744 case 2: 841 case 2:
745 hotkey_update(key); 842 if(hotkey_update(key))
843 goto fail_out;
746 break; 844 break;
747 default: 845 default:
846 goto fail_out;
748 break; 847 break;
749 } 848 }
750 return_VALUE(count); 849 return_VALUE(count);
850fail_out:
851 if(IS_EVENT(internal_event_num))
852 free_hotkey_buffer(key);
853 else
854 free_poll_hotkey_buffer(key);
855 kfree(key);
856 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "invalid key\n"));
857 return_VALUE(-EINVAL);
751} 858}
752 859
753/* 860/*
754 * This function evaluates an ACPI method, given an int as parameter, the 861 * This function evaluates an ACPI method, given an int as parameter, the
755 * method is searched within the scope of the handle, can be NULL. The output 862 * method is searched within the scope of the handle, can be NULL. The output
756 * of the method is written is output, which can also be NULL 863 * of the method is written is output, which can also be NULL
@@ -775,7 +882,7 @@ static int write_acpi_int(acpi_handle handle, const char *method, int val,
775 return_VALUE(status == AE_OK); 882 return_VALUE(status == AE_OK);
776} 883}
777 884
778static int read_acpi_int(acpi_handle handle, const char *method, int *val) 885static int read_acpi_int(acpi_handle handle, const char *method, union acpi_object *val)
779{ 886{
780 struct acpi_buffer output; 887 struct acpi_buffer output;
781 union acpi_object out_obj; 888 union acpi_object out_obj;
@@ -786,62 +893,32 @@ static int read_acpi_int(acpi_handle handle, const char *method, int *val)
786 output.pointer = &out_obj; 893 output.pointer = &out_obj;
787 894
788 status = acpi_evaluate_object(handle, (char *)method, NULL, &output); 895 status = acpi_evaluate_object(handle, (char *)method, NULL, &output);
789 *val = out_obj.integer.value; 896 if(val){
897 val->integer.value = out_obj.integer.value;
898 val->type = out_obj.type;
899 } else
900 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "null val pointer"));
790 return_VALUE((status == AE_OK) 901 return_VALUE((status == AE_OK)
791 && (out_obj.type == ACPI_TYPE_INTEGER)); 902 && (out_obj.type == ACPI_TYPE_INTEGER));
792} 903}
793 904
794static acpi_handle 905static union acpi_hotkey *get_hotkey_by_event(struct
795get_handle_from_hotkeylist(struct acpi_hotkey_list *hotkey_list, int event_num) 906 acpi_hotkey_list
907 *hotkey_list, int event)
796{ 908{
797 struct list_head *entries, *next; 909 struct list_head *entries;
798
799 list_for_each_safe(entries, next, hotkey_list->entries) {
800 union acpi_hotkey *key =
801 container_of(entries, union acpi_hotkey, entries);
802 if (key->link.hotkey_type == ACPI_HOTKEY_EVENT
803 && key->link.hotkey_standard_num == event_num) {
804 return (key->event_hotkey.action_handle);
805 }
806 }
807 return (NULL);
808}
809
810static
811char *get_method_from_hotkeylist(struct acpi_hotkey_list *hotkey_list,
812 int event_num)
813{
814 struct list_head *entries, *next;
815
816 list_for_each_safe(entries, next, hotkey_list->entries) {
817 union acpi_hotkey *key =
818 container_of(entries, union acpi_hotkey, entries);
819
820 if (key->link.hotkey_type == ACPI_HOTKEY_EVENT &&
821 key->link.hotkey_standard_num == event_num)
822 return (key->event_hotkey.action_method);
823 }
824 return (NULL);
825}
826
827static struct acpi_polling_hotkey *get_hotkey_by_event(struct
828 acpi_hotkey_list
829 *hotkey_list, int event)
830{
831 struct list_head *entries, *next;
832 910
833 list_for_each_safe(entries, next, hotkey_list->entries) { 911 list_for_each(entries, hotkey_list->entries) {
834 union acpi_hotkey *key = 912 union acpi_hotkey *key =
835 container_of(entries, union acpi_hotkey, entries); 913 container_of(entries, union acpi_hotkey, entries);
836 if (key->link.hotkey_type == ACPI_HOTKEY_POLLING 914 if (key->link.hotkey_standard_num == event) {
837 && key->link.hotkey_standard_num == event) { 915 return(key);
838 return (&key->poll_hotkey);
839 } 916 }
840 } 917 }
841 return (NULL); 918 return(NULL);
842} 919}
843 920
844/* 921/*
845 * user call AML method interface: 922 * user call AML method interface:
846 * Call convention: 923 * Call convention:
847 * echo "event_num: arg type : value" 924 * echo "event_num: arg type : value"
@@ -854,48 +931,56 @@ static ssize_t hotkey_execute_aml_method(struct file *file,
854 size_t count, loff_t * data) 931 size_t count, loff_t * data)
855{ 932{
856 struct acpi_hotkey_list *hotkey_list = &global_hotkey_list; 933 struct acpi_hotkey_list *hotkey_list = &global_hotkey_list;
857 char arg[MAX_CALL_PARM]; 934 char *arg;
858 int event, type, value; 935 int event,method_type,type, value;
859 936 union acpi_hotkey *key;
860 char *method;
861 acpi_handle handle;
862 937
863 ACPI_FUNCTION_TRACE("hotkey_execte_aml_method"); 938 ACPI_FUNCTION_TRACE("hotkey_execte_aml_method");
864 939
865 if (!hotkey_list || count > MAX_CALL_PARM) { 940 arg = (char *) kmalloc(count+1, GFP_KERNEL);
866 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument 1")); 941 if(!arg)
867 return_VALUE(-EINVAL); 942 return_VALUE(-ENOMEM);
868 } 943 arg[count]=0;
869 944
870 if (copy_from_user(arg, buffer, count)) { 945 if (copy_from_user(arg, buffer, count)) {
946 kfree(arg);
871 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument 2")); 947 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument 2"));
872 return_VALUE(-EINVAL); 948 return_VALUE(-EINVAL);
873 } 949 }
874 950
875 arg[count] = '\0'; 951 if (sscanf(arg, "%d:%d:%d:%d", &event, &method_type, &type, &value) != 4) {
876 952 kfree(arg);
877 if (sscanf(arg, "%d:%d:%d", &event, &type, &value) != 3) {
878 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument 3")); 953 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument 3"));
879 return_VALUE(-EINVAL); 954 return_VALUE(-EINVAL);
880 } 955 }
881 956 kfree(arg);
882 if (type == ACPI_TYPE_INTEGER) { 957 if (type == ACPI_TYPE_INTEGER) {
883 handle = get_handle_from_hotkeylist(hotkey_list, event); 958 key = get_hotkey_by_event(hotkey_list, event);
884 method = (char *)get_method_from_hotkeylist(hotkey_list, event); 959 if(!key)
960 goto do_fail;
885 if (IS_EVENT(event)) 961 if (IS_EVENT(event))
886 write_acpi_int(handle, method, value, NULL); 962 write_acpi_int(key->event_hotkey.action_handle,
963 key->event_hotkey.action_method, value, NULL);
887 else if (IS_POLL(event)) { 964 else if (IS_POLL(event)) {
888 struct acpi_polling_hotkey *key; 965 if ( method_type == POLL_METHOD )
889 key = (struct acpi_polling_hotkey *) 966 read_acpi_int(key->poll_hotkey.poll_handle,
890 get_hotkey_by_event(hotkey_list, event); 967 key->poll_hotkey.poll_method,
891 read_acpi_int(handle, method, key->poll_result); 968 key->poll_hotkey.poll_result);
969 else if ( method_type == ACTION_METHOD )
970 write_acpi_int(key->poll_hotkey.action_handle,
971 key->poll_hotkey.action_method, value, NULL);
972 else
973 goto do_fail;
974
892 } 975 }
893 } else { 976 } else {
894 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Not supported")); 977 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Not supported"));
895 return_VALUE(-EINVAL); 978 return_VALUE(-EINVAL);
896 } 979 }
897
898 return_VALUE(count); 980 return_VALUE(count);
981do_fail:
982 return_VALUE(-EINVAL);
983
899} 984}
900 985
901static int __init hotkey_init(void) 986static int __init hotkey_init(void)
@@ -928,7 +1013,7 @@ static int __init hotkey_init(void)
928 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1013 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
929 "Hotkey: Unable to create %s entry\n", 1014 "Hotkey: Unable to create %s entry\n",
930 HOTKEY_EV_CONFIG)); 1015 HOTKEY_EV_CONFIG));
931 return (-ENODEV); 1016 goto do_fail1;
932 } else { 1017 } else {
933 hotkey_config->proc_fops = &hotkey_config_fops; 1018 hotkey_config->proc_fops = &hotkey_config_fops;
934 hotkey_config->data = &global_hotkey_list; 1019 hotkey_config->data = &global_hotkey_list;
@@ -943,7 +1028,8 @@ static int __init hotkey_init(void)
943 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1028 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
944 "Hotkey: Unable to create %s entry\n", 1029 "Hotkey: Unable to create %s entry\n",
945 HOTKEY_EV_CONFIG)); 1030 HOTKEY_EV_CONFIG));
946 return (-ENODEV); 1031
1032 goto do_fail2;
947 } else { 1033 } else {
948 hotkey_poll_config->proc_fops = &hotkey_poll_config_fops; 1034 hotkey_poll_config->proc_fops = &hotkey_poll_config_fops;
949 hotkey_poll_config->data = &global_hotkey_list; 1035 hotkey_poll_config->data = &global_hotkey_list;
@@ -957,7 +1043,7 @@ static int __init hotkey_init(void)
957 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1043 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
958 "Hotkey: Unable to create %s entry\n", 1044 "Hotkey: Unable to create %s entry\n",
959 HOTKEY_ACTION)); 1045 HOTKEY_ACTION));
960 return (-ENODEV); 1046 goto do_fail3;
961 } else { 1047 } else {
962 hotkey_action->proc_fops = &hotkey_action_fops; 1048 hotkey_action->proc_fops = &hotkey_action_fops;
963 hotkey_action->owner = THIS_MODULE; 1049 hotkey_action->owner = THIS_MODULE;
@@ -970,7 +1056,7 @@ static int __init hotkey_init(void)
970 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1056 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
971 "Hotkey: Unable to create %s entry\n", 1057 "Hotkey: Unable to create %s entry\n",
972 HOTKEY_INFO)); 1058 HOTKEY_INFO));
973 return (-ENODEV); 1059 goto do_fail4;
974 } else { 1060 } else {
975 hotkey_info->proc_fops = &hotkey_info_fops; 1061 hotkey_info->proc_fops = &hotkey_info_fops;
976 hotkey_info->owner = THIS_MODULE; 1062 hotkey_info->owner = THIS_MODULE;
@@ -979,23 +1065,33 @@ static int __init hotkey_init(void)
979 } 1065 }
980 1066
981 result = acpi_bus_register_driver(&hotkey_driver); 1067 result = acpi_bus_register_driver(&hotkey_driver);
982 if (result < 0) { 1068 if (result < 0)
983 remove_proc_entry(HOTKEY_PROC, acpi_root_dir); 1069 goto do_fail5;
984 return (-ENODEV);
985 }
986 global_hotkey_list.count = 0; 1070 global_hotkey_list.count = 0;
987 global_hotkey_list.entries = &hotkey_entries; 1071 global_hotkey_list.entries = &hotkey_entries;
988 1072
989 INIT_LIST_HEAD(&hotkey_entries); 1073 INIT_LIST_HEAD(&hotkey_entries);
990 1074
991 return (0); 1075 return (0);
1076
1077do_fail5:
1078 remove_proc_entry(HOTKEY_INFO, hotkey_proc_dir);
1079do_fail4:
1080 remove_proc_entry(HOTKEY_ACTION, hotkey_proc_dir);
1081do_fail3:
1082 remove_proc_entry(HOTKEY_PL_CONFIG, hotkey_proc_dir);
1083do_fail2:
1084 remove_proc_entry(HOTKEY_EV_CONFIG, hotkey_proc_dir);
1085do_fail1:
1086 remove_proc_entry(HOTKEY_PROC, acpi_root_dir);
1087 return (-ENODEV);
992} 1088}
993 1089
994static void __exit hotkey_exit(void) 1090static void __exit hotkey_exit(void)
995{ 1091{
996 struct list_head *entries, *next; 1092 struct list_head *entries, *next;
997 1093
998 ACPI_FUNCTION_TRACE("hotkey_remove"); 1094 ACPI_FUNCTION_TRACE("hotkey_exit");
999 1095
1000 list_for_each_safe(entries, next, global_hotkey_list.entries) { 1096 list_for_each_safe(entries, next, global_hotkey_list.entries) {
1001 union acpi_hotkey *key = 1097 union acpi_hotkey *key =
diff --git a/drivers/acpi/motherboard.c b/drivers/acpi/motherboard.c
index 61ea70742d49..2934475d67d6 100644
--- a/drivers/acpi/motherboard.c
+++ b/drivers/acpi/motherboard.c
@@ -43,7 +43,7 @@ ACPI_MODULE_NAME ("acpi_motherboard")
43 */ 43 */
44#define IS_RESERVED_ADDR(base, len) \ 44#define IS_RESERVED_ADDR(base, len) \
45 (((len) > 0) && ((base) > 0) && ((base) + (len) < IO_SPACE_LIMIT) \ 45 (((len) > 0) && ((base) > 0) && ((base) + (len) < IO_SPACE_LIMIT) \
46 && ((base) + (len) > PCIBIOS_MIN_IO)) 46 && ((base) + (len) > 0x1000))
47 47
48/* 48/*
49 * Clearing the flag (IORESOURCE_BUSY) allows drivers to use 49 * Clearing the flag (IORESOURCE_BUSY) allows drivers to use
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index bdd9f37f8101..7289da3c4db6 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -145,10 +145,14 @@ acpi_os_vprintf(const char *fmt, va_list args)
145#endif 145#endif
146} 146}
147 147
148extern int acpi_in_resume;
148void * 149void *
149acpi_os_allocate(acpi_size size) 150acpi_os_allocate(acpi_size size)
150{ 151{
151 return kmalloc(size, GFP_KERNEL); 152 if (acpi_in_resume)
153 return kmalloc(size, GFP_ATOMIC);
154 else
155 return kmalloc(size, GFP_KERNEL);
152} 156}
153 157
154void 158void
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index d1f42b972821..bb973d2109a1 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -269,7 +269,51 @@ acpi_pci_irq_del_prt (int segment, int bus)
269/* -------------------------------------------------------------------------- 269/* --------------------------------------------------------------------------
270 PCI Interrupt Routing Support 270 PCI Interrupt Routing Support
271 -------------------------------------------------------------------------- */ 271 -------------------------------------------------------------------------- */
272typedef int (*irq_lookup_func)(struct acpi_prt_entry *, int *, int *, char **);
272 273
274static int
275acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
276 int *edge_level,
277 int *active_high_low,
278 char **link)
279{
280 int irq;
281
282 ACPI_FUNCTION_TRACE("acpi_pci_allocate_irq");
283
284 if (entry->link.handle) {
285 irq = acpi_pci_link_allocate_irq(entry->link.handle,
286 entry->link.index, edge_level, active_high_low, link);
287 if (irq < 0) {
288 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid IRQ link routing entry\n"));
289 return_VALUE(-1);
290 }
291 } else {
292 irq = entry->link.index;
293 *edge_level = ACPI_LEVEL_SENSITIVE;
294 *active_high_low = ACPI_ACTIVE_LOW;
295 }
296
297 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", irq));
298 return_VALUE(irq);
299}
300
301static int
302acpi_pci_free_irq(struct acpi_prt_entry *entry,
303 int *edge_level,
304 int *active_high_low,
305 char **link)
306{
307 int irq;
308
309 ACPI_FUNCTION_TRACE("acpi_pci_free_irq");
310 if (entry->link.handle) {
311 irq = acpi_pci_link_free_irq(entry->link.handle);
312 } else {
313 irq = entry->link.index;
314 }
315 return_VALUE(irq);
316}
273/* 317/*
274 * acpi_pci_irq_lookup 318 * acpi_pci_irq_lookup
275 * success: return IRQ >= 0 319 * success: return IRQ >= 0
@@ -282,12 +326,13 @@ acpi_pci_irq_lookup (
282 int pin, 326 int pin,
283 int *edge_level, 327 int *edge_level,
284 int *active_high_low, 328 int *active_high_low,
285 char **link) 329 char **link,
330 irq_lookup_func func)
286{ 331{
287 struct acpi_prt_entry *entry = NULL; 332 struct acpi_prt_entry *entry = NULL;
288 int segment = pci_domain_nr(bus); 333 int segment = pci_domain_nr(bus);
289 int bus_nr = bus->number; 334 int bus_nr = bus->number;
290 int irq; 335 int ret;
291 336
292 ACPI_FUNCTION_TRACE("acpi_pci_irq_lookup"); 337 ACPI_FUNCTION_TRACE("acpi_pci_irq_lookup");
293 338
@@ -301,22 +346,8 @@ acpi_pci_irq_lookup (
301 return_VALUE(-1); 346 return_VALUE(-1);
302 } 347 }
303 348
304 if (entry->link.handle) { 349 ret = func(entry, edge_level, active_high_low, link);
305 irq = acpi_pci_link_get_irq(entry->link.handle, 350 return_VALUE(ret);
306 entry->link.index, edge_level, active_high_low, link);
307 if (irq < 0) {
308 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid IRQ link routing entry\n"));
309 return_VALUE(-1);
310 }
311 } else {
312 irq = entry->link.index;
313 *edge_level = ACPI_LEVEL_SENSITIVE;
314 *active_high_low = ACPI_ACTIVE_LOW;
315 }
316
317 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", irq));
318
319 return_VALUE(irq);
320} 351}
321 352
322/* 353/*
@@ -330,7 +361,8 @@ acpi_pci_irq_derive (
330 int pin, 361 int pin,
331 int *edge_level, 362 int *edge_level,
332 int *active_high_low, 363 int *active_high_low,
333 char **link) 364 char **link,
365 irq_lookup_func func)
334{ 366{
335 struct pci_dev *bridge = dev; 367 struct pci_dev *bridge = dev;
336 int irq = -1; 368 int irq = -1;
@@ -363,7 +395,7 @@ acpi_pci_irq_derive (
363 } 395 }
364 396
365 irq = acpi_pci_irq_lookup(bridge->bus, PCI_SLOT(bridge->devfn), 397 irq = acpi_pci_irq_lookup(bridge->bus, PCI_SLOT(bridge->devfn),
366 pin, edge_level, active_high_low, link); 398 pin, edge_level, active_high_low, link, func);
367 } 399 }
368 400
369 if (irq < 0) { 401 if (irq < 0) {
@@ -415,7 +447,7 @@ acpi_pci_irq_enable (
415 * values override any BIOS-assigned IRQs set during boot. 447 * values override any BIOS-assigned IRQs set during boot.
416 */ 448 */
417 irq = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin, 449 irq = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin,
418 &edge_level, &active_high_low, &link); 450 &edge_level, &active_high_low, &link, acpi_pci_allocate_irq);
419 451
420 /* 452 /*
421 * If no PRT entry was found, we'll try to derive an IRQ from the 453 * If no PRT entry was found, we'll try to derive an IRQ from the
@@ -423,7 +455,7 @@ acpi_pci_irq_enable (
423 */ 455 */
424 if (irq < 0) 456 if (irq < 0)
425 irq = acpi_pci_irq_derive(dev, pin, &edge_level, 457 irq = acpi_pci_irq_derive(dev, pin, &edge_level,
426 &active_high_low, &link); 458 &active_high_low, &link, acpi_pci_allocate_irq);
427 459
428 /* 460 /*
429 * No IRQ known to the ACPI subsystem - maybe the BIOS / 461 * No IRQ known to the ACPI subsystem - maybe the BIOS /
@@ -462,7 +494,9 @@ acpi_pci_irq_enable (
462EXPORT_SYMBOL(acpi_pci_irq_enable); 494EXPORT_SYMBOL(acpi_pci_irq_enable);
463 495
464 496
465#ifdef CONFIG_ACPI_DEALLOCATE_IRQ 497/* FIXME: implement x86/x86_64 version */
498void __attribute__((weak)) acpi_unregister_gsi(u32 i) {}
499
466void 500void
467acpi_pci_irq_disable ( 501acpi_pci_irq_disable (
468 struct pci_dev *dev) 502 struct pci_dev *dev)
@@ -489,14 +523,14 @@ acpi_pci_irq_disable (
489 * First we check the PCI IRQ routing table (PRT) for an IRQ. 523 * First we check the PCI IRQ routing table (PRT) for an IRQ.
490 */ 524 */
491 gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin, 525 gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin,
492 &edge_level, &active_high_low, NULL); 526 &edge_level, &active_high_low, NULL, acpi_pci_free_irq);
493 /* 527 /*
494 * If no PRT entry was found, we'll try to derive an IRQ from the 528 * If no PRT entry was found, we'll try to derive an IRQ from the
495 * device's parent bridge. 529 * device's parent bridge.
496 */ 530 */
497 if (gsi < 0) 531 if (gsi < 0)
498 gsi = acpi_pci_irq_derive(dev, pin, 532 gsi = acpi_pci_irq_derive(dev, pin,
499 &edge_level, &active_high_low, NULL); 533 &edge_level, &active_high_low, NULL, acpi_pci_free_irq);
500 if (gsi < 0) 534 if (gsi < 0)
501 return_VOID; 535 return_VOID;
502 536
@@ -512,4 +546,3 @@ acpi_pci_irq_disable (
512 546
513 return_VOID; 547 return_VOID;
514} 548}
515#endif /* CONFIG_ACPI_DEALLOCATE_IRQ */
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 6ad0e77df9b3..834c2ceff1aa 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -68,6 +68,10 @@ static struct acpi_driver acpi_pci_link_driver = {
68 }, 68 },
69}; 69};
70 70
71/*
72 * If a link is initialized, we never change its active and initialized
73 * later even the link is disable. Instead, we just repick the active irq
74 */
71struct acpi_pci_link_irq { 75struct acpi_pci_link_irq {
72 u8 active; /* Current IRQ */ 76 u8 active; /* Current IRQ */
73 u8 edge_level; /* All IRQs */ 77 u8 edge_level; /* All IRQs */
@@ -76,8 +80,7 @@ struct acpi_pci_link_irq {
76 u8 possible_count; 80 u8 possible_count;
77 u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE]; 81 u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE];
78 u8 initialized:1; 82 u8 initialized:1;
79 u8 suspend_resume:1; 83 u8 reserved:7;
80 u8 reserved:6;
81}; 84};
82 85
83struct acpi_pci_link { 86struct acpi_pci_link {
@@ -85,12 +88,14 @@ struct acpi_pci_link {
85 struct acpi_device *device; 88 struct acpi_device *device;
86 acpi_handle handle; 89 acpi_handle handle;
87 struct acpi_pci_link_irq irq; 90 struct acpi_pci_link_irq irq;
91 int refcnt;
88}; 92};
89 93
90static struct { 94static struct {
91 int count; 95 int count;
92 struct list_head entries; 96 struct list_head entries;
93} acpi_link; 97} acpi_link;
98DECLARE_MUTEX(acpi_link_lock);
94 99
95 100
96/* -------------------------------------------------------------------------- 101/* --------------------------------------------------------------------------
@@ -532,12 +537,12 @@ static int acpi_pci_link_allocate(
532 537
533 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate"); 538 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate");
534 539
535 if (link->irq.suspend_resume) { 540 if (link->irq.initialized) {
536 acpi_pci_link_set(link, link->irq.active); 541 if (link->refcnt == 0)
537 link->irq.suspend_resume = 0; 542 /* This means the link is disabled but initialized */
538 } 543 acpi_pci_link_set(link, link->irq.active);
539 if (link->irq.initialized)
540 return_VALUE(0); 544 return_VALUE(0);
545 }
541 546
542 /* 547 /*
543 * search for active IRQ in list of possible IRQs. 548 * search for active IRQ in list of possible IRQs.
@@ -596,13 +601,13 @@ static int acpi_pci_link_allocate(
596} 601}
597 602
598/* 603/*
599 * acpi_pci_link_get_irq 604 * acpi_pci_link_allocate_irq
600 * success: return IRQ >= 0 605 * success: return IRQ >= 0
601 * failure: return -1 606 * failure: return -1
602 */ 607 */
603 608
604int 609int
605acpi_pci_link_get_irq ( 610acpi_pci_link_allocate_irq (
606 acpi_handle handle, 611 acpi_handle handle,
607 int index, 612 int index,
608 int *edge_level, 613 int *edge_level,
@@ -613,7 +618,7 @@ acpi_pci_link_get_irq (
613 struct acpi_device *device = NULL; 618 struct acpi_device *device = NULL;
614 struct acpi_pci_link *link = NULL; 619 struct acpi_pci_link *link = NULL;
615 620
616 ACPI_FUNCTION_TRACE("acpi_pci_link_get_irq"); 621 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate_irq");
617 622
618 result = acpi_bus_get_device(handle, &device); 623 result = acpi_bus_get_device(handle, &device);
619 if (result) { 624 if (result) {
@@ -633,21 +638,81 @@ acpi_pci_link_get_irq (
633 return_VALUE(-1); 638 return_VALUE(-1);
634 } 639 }
635 640
636 if (acpi_pci_link_allocate(link)) 641 down(&acpi_link_lock);
642 if (acpi_pci_link_allocate(link)) {
643 up(&acpi_link_lock);
637 return_VALUE(-1); 644 return_VALUE(-1);
645 }
638 646
639 if (!link->irq.active) { 647 if (!link->irq.active) {
648 up(&acpi_link_lock);
640 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link active IRQ is 0!\n")); 649 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link active IRQ is 0!\n"));
641 return_VALUE(-1); 650 return_VALUE(-1);
642 } 651 }
652 link->refcnt ++;
653 up(&acpi_link_lock);
643 654
644 if (edge_level) *edge_level = link->irq.edge_level; 655 if (edge_level) *edge_level = link->irq.edge_level;
645 if (active_high_low) *active_high_low = link->irq.active_high_low; 656 if (active_high_low) *active_high_low = link->irq.active_high_low;
646 if (name) *name = acpi_device_bid(link->device); 657 if (name) *name = acpi_device_bid(link->device);
658 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
659 "Link %s is referenced\n", acpi_device_bid(link->device)));
647 return_VALUE(link->irq.active); 660 return_VALUE(link->irq.active);
648} 661}
649 662
663/*
664 * We don't change link's irq information here. After it is reenabled, we
665 * continue use the info
666 */
667int
668acpi_pci_link_free_irq(acpi_handle handle)
669{
670 struct acpi_device *device = NULL;
671 struct acpi_pci_link *link = NULL;
672 acpi_status result;
673
674 ACPI_FUNCTION_TRACE("acpi_pci_link_free_irq");
675
676 result = acpi_bus_get_device(handle, &device);
677 if (result) {
678 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link device\n"));
679 return_VALUE(-1);
680 }
681
682 link = (struct acpi_pci_link *) acpi_driver_data(device);
683 if (!link) {
684 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n"));
685 return_VALUE(-1);
686 }
687
688 down(&acpi_link_lock);
689 if (!link->irq.initialized) {
690 up(&acpi_link_lock);
691 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link isn't initialized\n"));
692 return_VALUE(-1);
693 }
650 694
695#ifdef FUTURE_USE
696 /*
697 * The Link reference count allows us to _DISable an unused link
698 * and suspend time, and set it again on resume.
699 * However, 2.6.12 still has irq_router.resume
700 * which blindly restores the link state.
701 * So we disable the reference count method
702 * to prevent duplicate acpi_pci_link_set()
703 * which would harm some systems
704 */
705 link->refcnt --;
706#endif
707 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
708 "Link %s is dereferenced\n", acpi_device_bid(link->device)));
709
710 if (link->refcnt == 0) {
711 acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL);
712 }
713 up(&acpi_link_lock);
714 return_VALUE(link->irq.active);
715}
651/* -------------------------------------------------------------------------- 716/* --------------------------------------------------------------------------
652 Driver Interface 717 Driver Interface
653 -------------------------------------------------------------------------- */ 718 -------------------------------------------------------------------------- */
@@ -677,6 +742,7 @@ acpi_pci_link_add (
677 strcpy(acpi_device_class(device), ACPI_PCI_LINK_CLASS); 742 strcpy(acpi_device_class(device), ACPI_PCI_LINK_CLASS);
678 acpi_driver_data(device) = link; 743 acpi_driver_data(device) = link;
679 744
745 down(&acpi_link_lock);
680 result = acpi_pci_link_get_possible(link); 746 result = acpi_pci_link_get_possible(link);
681 if (result) 747 if (result)
682 goto end; 748 goto end;
@@ -712,6 +778,7 @@ acpi_pci_link_add (
712end: 778end:
713 /* disable all links -- to be activated on use */ 779 /* disable all links -- to be activated on use */
714 acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL); 780 acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL);
781 up(&acpi_link_lock);
715 782
716 if (result) 783 if (result)
717 kfree(link); 784 kfree(link);
@@ -720,24 +787,42 @@ end:
720} 787}
721 788
722static int 789static int
723irqrouter_suspend( 790acpi_pci_link_resume(
724 struct sys_device *dev, 791 struct acpi_pci_link *link)
725 u32 state) 792{
793 ACPI_FUNCTION_TRACE("acpi_pci_link_resume");
794
795 if (link->refcnt && link->irq.active && link->irq.initialized)
796 return_VALUE(acpi_pci_link_set(link, link->irq.active));
797 else
798 return_VALUE(0);
799}
800
801/*
802 * FIXME: this is a workaround to avoid nasty warning. It will be removed
803 * after every device calls pci_disable_device in .resume.
804 */
805int acpi_in_resume;
806static int
807irqrouter_resume(
808 struct sys_device *dev)
726{ 809{
727 struct list_head *node = NULL; 810 struct list_head *node = NULL;
728 struct acpi_pci_link *link = NULL; 811 struct acpi_pci_link *link = NULL;
729 812
730 ACPI_FUNCTION_TRACE("irqrouter_suspend"); 813 ACPI_FUNCTION_TRACE("irqrouter_resume");
731 814
815 acpi_in_resume = 1;
732 list_for_each(node, &acpi_link.entries) { 816 list_for_each(node, &acpi_link.entries) {
733 link = list_entry(node, struct acpi_pci_link, node); 817 link = list_entry(node, struct acpi_pci_link, node);
734 if (!link) { 818 if (!link) {
735 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n")); 819 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
820 "Invalid link context\n"));
736 continue; 821 continue;
737 } 822 }
738 if (link->irq.active && link->irq.initialized) 823 acpi_pci_link_resume(link);
739 link->irq.suspend_resume = 1;
740 } 824 }
825 acpi_in_resume = 0;
741 return_VALUE(0); 826 return_VALUE(0);
742} 827}
743 828
@@ -756,8 +841,9 @@ acpi_pci_link_remove (
756 841
757 link = (struct acpi_pci_link *) acpi_driver_data(device); 842 link = (struct acpi_pci_link *) acpi_driver_data(device);
758 843
759 /* TBD: Acquire/release lock */ 844 down(&acpi_link_lock);
760 list_del(&link->node); 845 list_del(&link->node);
846 up(&acpi_link_lock);
761 847
762 kfree(link); 848 kfree(link);
763 849
@@ -849,9 +935,10 @@ int __init acpi_irq_balance_set(char *str)
849__setup("acpi_irq_balance", acpi_irq_balance_set); 935__setup("acpi_irq_balance", acpi_irq_balance_set);
850 936
851 937
938/* FIXME: we will remove this interface after all drivers call pci_disable_device */
852static struct sysdev_class irqrouter_sysdev_class = { 939static struct sysdev_class irqrouter_sysdev_class = {
853 set_kset_name("irqrouter"), 940 set_kset_name("irqrouter"),
854 .suspend = irqrouter_suspend, 941 .resume = irqrouter_resume,
855}; 942};
856 943
857 944
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 893b074e3d1a..2c04740c6543 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -81,30 +81,32 @@ module_param(bm_history, uint, 0644);
81 * 81 *
82 * To skip this limit, boot/load with a large max_cstate limit. 82 * To skip this limit, boot/load with a large max_cstate limit.
83 */ 83 */
84static int no_c2c3(struct dmi_system_id *id) 84static int set_max_cstate(struct dmi_system_id *id)
85{ 85{
86 if (max_cstate > ACPI_PROCESSOR_MAX_POWER) 86 if (max_cstate > ACPI_PROCESSOR_MAX_POWER)
87 return 0; 87 return 0;
88 88
89 printk(KERN_NOTICE PREFIX "%s detected - C2,C3 disabled." 89 printk(KERN_NOTICE PREFIX "%s detected - limiting to C%ld max_cstate."
90 " Override with \"processor.max_cstate=%d\"\n", id->ident, 90 " Override with \"processor.max_cstate=%d\"\n", id->ident,
91 ACPI_PROCESSOR_MAX_POWER + 1); 91 (long)id->driver_data, ACPI_PROCESSOR_MAX_POWER + 1);
92 92
93 max_cstate = 1; 93 max_cstate = (long)id->driver_data;
94 94
95 return 0; 95 return 0;
96} 96}
97 97
98 98
99
100
101static struct dmi_system_id __initdata processor_power_dmi_table[] = { 99static struct dmi_system_id __initdata processor_power_dmi_table[] = {
102 { no_c2c3, "IBM ThinkPad R40e", { 100 { set_max_cstate, "IBM ThinkPad R40e", {
103 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"), 101 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
104 DMI_MATCH(DMI_BIOS_VERSION,"1SET60WW") }}, 102 DMI_MATCH(DMI_BIOS_VERSION,"1SET60WW") }, (void*)1},
105 { no_c2c3, "Medion 41700", { 103 { set_max_cstate, "Medion 41700", {
104 DMI_MATCH(DMI_BIOS_VENDOR,"Phoenix Technologies LTD"),
105 DMI_MATCH(DMI_BIOS_VERSION,"R01-A1J") }, (void*)1},
106 { set_max_cstate, "Clevo 5600D", {
106 DMI_MATCH(DMI_BIOS_VENDOR,"Phoenix Technologies LTD"), 107 DMI_MATCH(DMI_BIOS_VENDOR,"Phoenix Technologies LTD"),
107 DMI_MATCH(DMI_BIOS_VERSION,"R01-A1J") }}, 108 DMI_MATCH(DMI_BIOS_VERSION,"SHE845M0.86C.0013.D.0302131307") },
109 (void*)2},
108 {}, 110 {},
109}; 111};
110 112
@@ -549,7 +551,8 @@ static int acpi_processor_get_power_info_default_c1 (struct acpi_processor *pr)
549 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_default_c1"); 551 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_default_c1");
550 552
551 for (i = 0; i < ACPI_PROCESSOR_MAX_POWER; i++) 553 for (i = 0; i < ACPI_PROCESSOR_MAX_POWER; i++)
552 memset(pr->power.states, 0, sizeof(struct acpi_processor_cx)); 554 memset(&(pr->power.states[i]), 0,
555 sizeof(struct acpi_processor_cx));
553 556
554 /* if info is obtained from pblk/fadt, type equals state */ 557 /* if info is obtained from pblk/fadt, type equals state */
555 pr->power.states[ACPI_STATE_C1].type = ACPI_STATE_C1; 558 pr->power.states[ACPI_STATE_C1].type = ACPI_STATE_C1;
@@ -580,7 +583,8 @@ static int acpi_processor_get_power_info_cst (struct acpi_processor *pr)
580 583
581 pr->power.count = 0; 584 pr->power.count = 0;
582 for (i = 0; i < ACPI_PROCESSOR_MAX_POWER; i++) 585 for (i = 0; i < ACPI_PROCESSOR_MAX_POWER; i++)
583 memset(pr->power.states, 0, sizeof(struct acpi_processor_cx)); 586 memset(&(pr->power.states[i]), 0,
587 sizeof(struct acpi_processor_cx));
584 588
585 status = acpi_evaluate_object(pr->handle, "_CST", NULL, &buffer); 589 status = acpi_evaluate_object(pr->handle, "_CST", NULL, &buffer);
586 if (ACPI_FAILURE(status)) { 590 if (ACPI_FAILURE(status)) {
@@ -763,7 +767,6 @@ static void acpi_processor_power_verify_c3(
763 } 767 }
764 768
765 if (pr->flags.bm_check) { 769 if (pr->flags.bm_check) {
766 printk("Disabling BM access before entering C3\n");
767 /* bus mastering control is necessary */ 770 /* bus mastering control is necessary */
768 if (!pr->flags.bm_control) { 771 if (!pr->flags.bm_control) {
769 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 772 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -771,7 +774,6 @@ static void acpi_processor_power_verify_c3(
771 return_VOID; 774 return_VOID;
772 } 775 }
773 } else { 776 } else {
774 printk("Invalidating cache before entering C3\n");
775 /* 777 /*
776 * WBINVD should be set in fadt, for C3 state to be 778 * WBINVD should be set in fadt, for C3 state to be
777 * supported on when bm_check is not required. 779 * supported on when bm_check is not required.
@@ -842,7 +844,7 @@ static int acpi_processor_get_power_info (
842 result = acpi_processor_get_power_info_cst(pr); 844 result = acpi_processor_get_power_info_cst(pr);
843 if ((result) || (acpi_processor_power_verify(pr) < 2)) { 845 if ((result) || (acpi_processor_power_verify(pr) < 2)) {
844 result = acpi_processor_get_power_info_fadt(pr); 846 result = acpi_processor_get_power_info_fadt(pr);
845 if (result) 847 if ((result) || (acpi_processor_power_verify(pr) < 2))
846 result = acpi_processor_get_power_info_default_c1(pr); 848 result = acpi_processor_get_power_info_default_c1(pr);
847 } 849 }
848 850
diff --git a/drivers/block/cfq-iosched.c b/drivers/block/cfq-iosched.c
index de5746e38af9..2435a7c99b2b 100644
--- a/drivers/block/cfq-iosched.c
+++ b/drivers/block/cfq-iosched.c
@@ -1281,6 +1281,7 @@ dispatch:
1281 */ 1281 */
1282 if (!cfq_crq_in_driver(crq) && 1282 if (!cfq_crq_in_driver(crq) &&
1283 !cfq_cfqq_idle_window(cfqq) && 1283 !cfq_cfqq_idle_window(cfqq) &&
1284 !blk_barrier_rq(rq) &&
1284 cfqd->rq_in_driver >= cfqd->cfq_max_depth) 1285 cfqd->rq_in_driver >= cfqd->cfq_max_depth)
1285 return NULL; 1286 return NULL;
1286 1287
diff --git a/drivers/char/watchdog/sa1100_wdt.c b/drivers/char/watchdog/sa1100_wdt.c
index 1b2132617dc3..fb88b4041dca 100644
--- a/drivers/char/watchdog/sa1100_wdt.c
+++ b/drivers/char/watchdog/sa1100_wdt.c
@@ -36,13 +36,10 @@
36#include <asm/uaccess.h> 36#include <asm/uaccess.h>
37 37
38#define OSCR_FREQ CLOCK_TICK_RATE 38#define OSCR_FREQ CLOCK_TICK_RATE
39#define SA1100_CLOSE_MAGIC (0x5afc4453)
40 39
41static unsigned long sa1100wdt_users; 40static unsigned long sa1100wdt_users;
42static int expect_close;
43static int pre_margin; 41static int pre_margin;
44static int boot_status; 42static int boot_status;
45static int nowayout = WATCHDOG_NOWAYOUT;
46 43
47/* 44/*
48 * Allow only one person to hold it open 45 * Allow only one person to hold it open
@@ -62,55 +59,33 @@ static int sa1100dog_open(struct inode *inode, struct file *file)
62} 59}
63 60
64/* 61/*
65 * Shut off the timer. 62 * The watchdog cannot be disabled.
66 * Lock it in if it's a module and we defined ...NOWAYOUT 63 *
67 * Oddly, the watchdog can only be enabled, but we can turn off 64 * Previous comments suggested that turning off the interrupt by
68 * the interrupt, which appears to prevent the watchdog timing out. 65 * clearing OIER[E3] would prevent the watchdog timing out but this
66 * does not appear to be true (at least on the PXA255).
69 */ 67 */
70static int sa1100dog_release(struct inode *inode, struct file *file) 68static int sa1100dog_release(struct inode *inode, struct file *file)
71{ 69{
72 OSMR3 = OSCR + pre_margin; 70 printk(KERN_CRIT "WATCHDOG: Device closed - timer will not stop\n");
73
74 if (expect_close == SA1100_CLOSE_MAGIC) {
75 OIER &= ~OIER_E3;
76 } else {
77 printk(KERN_CRIT "WATCHDOG: WDT device closed unexpectedly. WDT will not stop!\n");
78 }
79 71
80 clear_bit(1, &sa1100wdt_users); 72 clear_bit(1, &sa1100wdt_users);
81 expect_close = 0;
82 73
83 return 0; 74 return 0;
84} 75}
85 76
86static ssize_t sa1100dog_write(struct file *file, const char *data, size_t len, loff_t *ppos) 77static ssize_t sa1100dog_write(struct file *file, const char *data, size_t len, loff_t *ppos)
87{ 78{
88 if (len) { 79 if (len)
89 if (!nowayout) {
90 size_t i;
91
92 expect_close = 0;
93
94 for (i = 0; i != len; i++) {
95 char c;
96
97 if (get_user(c, data + i))
98 return -EFAULT;
99 if (c == 'V')
100 expect_close = SA1100_CLOSE_MAGIC;
101 }
102 }
103 /* Refresh OSMR3 timer. */ 80 /* Refresh OSMR3 timer. */
104 OSMR3 = OSCR + pre_margin; 81 OSMR3 = OSCR + pre_margin;
105 }
106 82
107 return len; 83 return len;
108} 84}
109 85
110static struct watchdog_info ident = { 86static struct watchdog_info ident = {
111 .options = WDIOF_CARDRESET | WDIOF_MAGICCLOSE | 87 .options = WDIOF_CARDRESET | WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
112 WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING, 88 .identity = "SA1100/PXA255 Watchdog",
113 .identity = "SA1100 Watchdog",
114}; 89};
115 90
116static int sa1100dog_ioctl(struct inode *inode, struct file *file, 91static int sa1100dog_ioctl(struct inode *inode, struct file *file,
@@ -172,7 +147,7 @@ static struct file_operations sa1100dog_fops =
172static struct miscdevice sa1100dog_miscdev = 147static struct miscdevice sa1100dog_miscdev =
173{ 148{
174 .minor = WATCHDOG_MINOR, 149 .minor = WATCHDOG_MINOR,
175 .name = "SA1100/PXA2xx watchdog", 150 .name = "watchdog",
176 .fops = &sa1100dog_fops, 151 .fops = &sa1100dog_fops,
177}; 152};
178 153
@@ -194,7 +169,6 @@ static int __init sa1100dog_init(void)
194 if (ret == 0) 169 if (ret == 0)
195 printk("SA1100/PXA2xx Watchdog Timer: timer margin %d sec\n", 170 printk("SA1100/PXA2xx Watchdog Timer: timer margin %d sec\n",
196 margin); 171 margin);
197
198 return ret; 172 return ret;
199} 173}
200 174
@@ -212,8 +186,5 @@ MODULE_DESCRIPTION("SA1100/PXA2xx Watchdog");
212module_param(margin, int, 0); 186module_param(margin, int, 0);
213MODULE_PARM_DESC(margin, "Watchdog margin in seconds (default 60s)"); 187MODULE_PARM_DESC(margin, "Watchdog margin in seconds (default 60s)");
214 188
215module_param(nowayout, int, 0);
216MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started");
217
218MODULE_LICENSE("GPL"); 189MODULE_LICENSE("GPL");
219MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); 190MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 04adde62a003..9ad3e9262e8a 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -382,100 +382,6 @@ static void __exit fsl_i2c_exit(void)
382module_init(fsl_i2c_init); 382module_init(fsl_i2c_init);
383module_exit(fsl_i2c_exit); 383module_exit(fsl_i2c_exit);
384 384
385static int fsl_i2c_probe(struct device *device)
386{
387 int result = 0;
388 struct mpc_i2c *i2c;
389 struct platform_device *pdev = to_platform_device(device);
390 struct fsl_i2c_platform_data *pdata;
391 struct resource *r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
392
393 pdata = (struct fsl_i2c_platform_data *) pdev->dev.platform_data;
394
395 if (!(i2c = kmalloc(sizeof(*i2c), GFP_KERNEL))) {
396 return -ENOMEM;
397 }
398 memset(i2c, 0, sizeof(*i2c));
399
400 i2c->irq = platform_get_irq(pdev, 0);
401 i2c->flags = pdata->device_flags;
402 init_waitqueue_head(&i2c->queue);
403
404 i2c->base = ioremap((phys_addr_t)r->start, MPC_I2C_REGION);
405
406 if (!i2c->base) {
407 printk(KERN_ERR "i2c-mpc - failed to map controller\n");
408 result = -ENOMEM;
409 goto fail_map;
410 }
411
412 if (i2c->irq != 0)
413 if ((result = request_irq(i2c->irq, mpc_i2c_isr,
414 SA_SHIRQ, "i2c-mpc", i2c)) < 0) {
415 printk(KERN_ERR
416 "i2c-mpc - failed to attach interrupt\n");
417 goto fail_irq;
418 }
419
420 mpc_i2c_setclock(i2c);
421 dev_set_drvdata(device, i2c);
422
423 i2c->adap = mpc_ops;
424 i2c_set_adapdata(&i2c->adap, i2c);
425 i2c->adap.dev.parent = &pdev->dev;
426 if ((result = i2c_add_adapter(&i2c->adap)) < 0) {
427 printk(KERN_ERR "i2c-mpc - failed to add adapter\n");
428 goto fail_add;
429 }
430
431 return result;
432
433 fail_add:
434 if (i2c->irq != 0)
435 free_irq(i2c->irq, NULL);
436 fail_irq:
437 iounmap(i2c->base);
438 fail_map:
439 kfree(i2c);
440 return result;
441};
442
443static int fsl_i2c_remove(struct device *device)
444{
445 struct mpc_i2c *i2c = dev_get_drvdata(device);
446
447 i2c_del_adapter(&i2c->adap);
448 dev_set_drvdata(device, NULL);
449
450 if (i2c->irq != 0)
451 free_irq(i2c->irq, i2c);
452
453 iounmap(i2c->base);
454 kfree(i2c);
455 return 0;
456};
457
458/* Structure for a device driver */
459static struct device_driver fsl_i2c_driver = {
460 .name = "fsl-i2c",
461 .bus = &platform_bus_type,
462 .probe = fsl_i2c_probe,
463 .remove = fsl_i2c_remove,
464};
465
466static int __init fsl_i2c_init(void)
467{
468 return driver_register(&fsl_i2c_driver);
469}
470
471static void __exit fsl_i2c_exit(void)
472{
473 driver_unregister(&fsl_i2c_driver);
474}
475
476module_init(fsl_i2c_init);
477module_exit(fsl_i2c_exit);
478
479MODULE_AUTHOR("Adrian Cox <adrian@humboldt.co.uk>"); 385MODULE_AUTHOR("Adrian Cox <adrian@humboldt.co.uk>");
480MODULE_DESCRIPTION 386MODULE_DESCRIPTION
481 ("I2C-Bus adapter for MPC107 bridge and MPC824x/85xx/52xx processors"); 387 ("I2C-Bus adapter for MPC107 bridge and MPC824x/85xx/52xx processors");
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 7df85af75371..94daf40ae323 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -960,6 +960,15 @@ static void save_match(ide_hwif_t *hwif, ide_hwif_t *new, ide_hwif_t **match)
960} 960}
961#endif /* MAX_HWIFS > 1 */ 961#endif /* MAX_HWIFS > 1 */
962 962
963static inline int hwif_to_node(ide_hwif_t *hwif)
964{
965 if (hwif->pci_dev)
966 return pcibus_to_node(hwif->pci_dev->bus);
967 else
968 /* Add ways to determine the node of other busses here */
969 return -1;
970}
971
963/* 972/*
964 * init request queue 973 * init request queue
965 */ 974 */
@@ -978,8 +987,7 @@ static int ide_init_queue(ide_drive_t *drive)
978 * do not. 987 * do not.
979 */ 988 */
980 989
981 q = blk_init_queue_node(do_ide_request, &ide_lock, 990 q = blk_init_queue_node(do_ide_request, &ide_lock, hwif_to_node(hwif));
982 pcibus_to_node(drive->hwif->pci_dev->bus));
983 if (!q) 991 if (!q)
984 return 1; 992 return 1;
985 993
@@ -1048,6 +1056,8 @@ static int init_irq (ide_hwif_t *hwif)
1048 1056
1049 BUG_ON(in_interrupt()); 1057 BUG_ON(in_interrupt());
1050 BUG_ON(irqs_disabled()); 1058 BUG_ON(irqs_disabled());
1059 BUG_ON(hwif == NULL);
1060
1051 down(&ide_cfg_sem); 1061 down(&ide_cfg_sem);
1052 hwif->hwgroup = NULL; 1062 hwif->hwgroup = NULL;
1053#if MAX_HWIFS > 1 1063#if MAX_HWIFS > 1
@@ -1097,7 +1107,7 @@ static int init_irq (ide_hwif_t *hwif)
1097 spin_unlock_irq(&ide_lock); 1107 spin_unlock_irq(&ide_lock);
1098 } else { 1108 } else {
1099 hwgroup = kmalloc_node(sizeof(ide_hwgroup_t), GFP_KERNEL, 1109 hwgroup = kmalloc_node(sizeof(ide_hwgroup_t), GFP_KERNEL,
1100 pcibus_to_node(hwif->drives[0].hwif->pci_dev->bus)); 1110 hwif_to_node(hwif->drives[0].hwif));
1101 if (!hwgroup) 1111 if (!hwgroup)
1102 goto out_up; 1112 goto out_up;
1103 1113
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c
index 03747439ac9c..f1d1ec4e9677 100644
--- a/drivers/ide/legacy/ide-cs.c
+++ b/drivers/ide/legacy/ide-cs.c
@@ -508,5 +508,5 @@ static void __exit exit_ide_cs(void)
508 BUG_ON(dev_list != NULL); 508 BUG_ON(dev_list != NULL);
509} 509}
510 510
511module_init(init_ide_cs); 511late_initcall(init_ide_cs);
512module_exit(exit_ide_cs); 512module_exit(exit_ide_cs);
diff --git a/drivers/infiniband/include/ib_cm.h b/drivers/infiniband/include/ib_cm.h
index e5d74a730a70..da650115e79a 100644
--- a/drivers/infiniband/include/ib_cm.h
+++ b/drivers/infiniband/include/ib_cm.h
@@ -169,7 +169,8 @@ enum ib_cm_rej_reason {
169 IB_CM_REJ_INVALID_ALT_TRAFFIC_CLASS = __constant_htons(21), 169 IB_CM_REJ_INVALID_ALT_TRAFFIC_CLASS = __constant_htons(21),
170 IB_CM_REJ_INVALID_ALT_HOP_LIMIT = __constant_htons(22), 170 IB_CM_REJ_INVALID_ALT_HOP_LIMIT = __constant_htons(22),
171 IB_CM_REJ_INVALID_ALT_PACKET_RATE = __constant_htons(23), 171 IB_CM_REJ_INVALID_ALT_PACKET_RATE = __constant_htons(23),
172 IB_CM_REJ_PORT_REDIRECT = __constant_htons(24), 172 IB_CM_REJ_PORT_CM_REDIRECT = __constant_htons(24),
173 IB_CM_REJ_PORT_REDIRECT = __constant_htons(25),
173 IB_CM_REJ_INVALID_MTU = __constant_htons(26), 174 IB_CM_REJ_INVALID_MTU = __constant_htons(26),
174 IB_CM_REJ_INSUFFICIENT_RESP_RESOURCES = __constant_htons(27), 175 IB_CM_REJ_INSUFFICIENT_RESP_RESOURCES = __constant_htons(27),
175 IB_CM_REJ_CONSUMER_DEFINED = __constant_htons(28), 176 IB_CM_REJ_CONSUMER_DEFINED = __constant_htons(28),
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 6f60abbaebd5..fa00816a3cf7 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -600,9 +600,10 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
600 600
601 ipoib_mcast_send(dev, (union ib_gid *) (phdr->hwaddr + 4), skb); 601 ipoib_mcast_send(dev, (union ib_gid *) (phdr->hwaddr + 4), skb);
602 } else { 602 } else {
603 /* unicast GID -- should be ARP reply */ 603 /* unicast GID -- should be ARP or RARP reply */
604 604
605 if (be16_to_cpup((u16 *) skb->data) != ETH_P_ARP) { 605 if ((be16_to_cpup((__be16 *) skb->data) != ETH_P_ARP) &&
606 (be16_to_cpup((__be16 *) skb->data) != ETH_P_RARP)) {
606 ipoib_warn(priv, "Unicast, no %s: type %04x, QPN %06x " 607 ipoib_warn(priv, "Unicast, no %s: type %04x, QPN %06x "
607 IPOIB_GID_FMT "\n", 608 IPOIB_GID_FMT "\n",
608 skb->dst ? "neigh" : "dst", 609 skb->dst ? "neigh" : "dst",
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 70bca955e0de..41df4cda66e2 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -818,8 +818,7 @@ int bitmap_unplug(struct bitmap *bitmap)
818 return 0; 818 return 0;
819} 819}
820 820
821static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, 821static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset);
822 unsigned long sectors, int in_sync);
823/* * bitmap_init_from_disk -- called at bitmap_create time to initialize 822/* * bitmap_init_from_disk -- called at bitmap_create time to initialize
824 * the in-memory bitmap from the on-disk bitmap -- also, sets up the 823 * the in-memory bitmap from the on-disk bitmap -- also, sets up the
825 * memory mapping of the bitmap file 824 * memory mapping of the bitmap file
@@ -828,7 +827,7 @@ static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset,
828 * previously kicked from the array, we mark all the bits as 827 * previously kicked from the array, we mark all the bits as
829 * 1's in order to cause a full resync. 828 * 1's in order to cause a full resync.
830 */ 829 */
831static int bitmap_init_from_disk(struct bitmap *bitmap, int in_sync) 830static int bitmap_init_from_disk(struct bitmap *bitmap)
832{ 831{
833 unsigned long i, chunks, index, oldindex, bit; 832 unsigned long i, chunks, index, oldindex, bit;
834 struct page *page = NULL, *oldpage = NULL; 833 struct page *page = NULL, *oldpage = NULL;
@@ -929,8 +928,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, int in_sync)
929 } 928 }
930 if (test_bit(bit, page_address(page))) { 929 if (test_bit(bit, page_address(page))) {
931 /* if the disk bit is set, set the memory bit */ 930 /* if the disk bit is set, set the memory bit */
932 bitmap_set_memory_bits(bitmap, 931 bitmap_set_memory_bits(bitmap, i << CHUNK_BLOCK_SHIFT(bitmap));
933 i << CHUNK_BLOCK_SHIFT(bitmap), 1, in_sync);
934 bit_cnt++; 932 bit_cnt++;
935 } 933 }
936 } 934 }
@@ -1426,35 +1424,53 @@ void bitmap_close_sync(struct bitmap *bitmap)
1426 } 1424 }
1427} 1425}
1428 1426
1429static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, 1427static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset)
1430 unsigned long sectors, int in_sync)
1431{ 1428{
1432 /* For each chunk covered by any of these sectors, set the 1429 /* For each chunk covered by any of these sectors, set the
1433 * counter to 1 and set resync_needed unless in_sync. They should all 1430 * counter to 1 and set resync_needed. They should all
1434 * be 0 at this point 1431 * be 0 at this point
1435 */ 1432 */
1436 while (sectors) { 1433
1437 int secs; 1434 int secs;
1438 bitmap_counter_t *bmc; 1435 bitmap_counter_t *bmc;
1439 spin_lock_irq(&bitmap->lock); 1436 spin_lock_irq(&bitmap->lock);
1440 bmc = bitmap_get_counter(bitmap, offset, &secs, 1); 1437 bmc = bitmap_get_counter(bitmap, offset, &secs, 1);
1441 if (!bmc) { 1438 if (!bmc) {
1442 spin_unlock_irq(&bitmap->lock);
1443 return;
1444 }
1445 if (! *bmc) {
1446 struct page *page;
1447 *bmc = 1 | (in_sync? 0 : NEEDED_MASK);
1448 bitmap_count_page(bitmap, offset, 1);
1449 page = filemap_get_page(bitmap, offset >> CHUNK_BLOCK_SHIFT(bitmap));
1450 set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN);
1451 }
1452 spin_unlock_irq(&bitmap->lock); 1439 spin_unlock_irq(&bitmap->lock);
1453 if (sectors > secs) 1440 return;
1454 sectors -= secs; 1441 }
1455 else 1442 if (! *bmc) {
1456 sectors = 0; 1443 struct page *page;
1444 *bmc = 1 | NEEDED_MASK;
1445 bitmap_count_page(bitmap, offset, 1);
1446 page = filemap_get_page(bitmap, offset >> CHUNK_BLOCK_SHIFT(bitmap));
1447 set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN);
1457 } 1448 }
1449 spin_unlock_irq(&bitmap->lock);
1450
1451}
1452
1453/*
1454 * flush out any pending updates
1455 */
1456void bitmap_flush(mddev_t *mddev)
1457{
1458 struct bitmap *bitmap = mddev->bitmap;
1459 int sleep;
1460
1461 if (!bitmap) /* there was no bitmap */
1462 return;
1463
1464 /* run the daemon_work three time to ensure everything is flushed
1465 * that can be
1466 */
1467 sleep = bitmap->daemon_sleep;
1468 bitmap->daemon_sleep = 0;
1469 bitmap_daemon_work(bitmap);
1470 bitmap_daemon_work(bitmap);
1471 bitmap_daemon_work(bitmap);
1472 bitmap->daemon_sleep = sleep;
1473 bitmap_update_sb(bitmap);
1458} 1474}
1459 1475
1460/* 1476/*
@@ -1565,7 +1581,8 @@ int bitmap_create(mddev_t *mddev)
1565 1581
1566 /* now that we have some pages available, initialize the in-memory 1582 /* now that we have some pages available, initialize the in-memory
1567 * bitmap from the on-disk bitmap */ 1583 * bitmap from the on-disk bitmap */
1568 err = bitmap_init_from_disk(bitmap, mddev->recovery_cp == MaxSector); 1584 err = bitmap_init_from_disk(bitmap);
1585
1569 if (err) 1586 if (err)
1570 return err; 1587 return err;
1571 1588
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index 12031c9d3f1e..b08df8b9b2ca 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -1230,7 +1230,7 @@ static int __init dm_mirror_init(void)
1230 if (r) 1230 if (r)
1231 return r; 1231 return r;
1232 1232
1233 _kmirrord_wq = create_workqueue("kmirrord"); 1233 _kmirrord_wq = create_singlethread_workqueue("kmirrord");
1234 if (!_kmirrord_wq) { 1234 if (!_kmirrord_wq) {
1235 DMERR("couldn't start kmirrord"); 1235 DMERR("couldn't start kmirrord");
1236 dm_dirty_log_exit(); 1236 dm_dirty_log_exit();
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 6580e0fa4a47..480f658db6f2 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1798,6 +1798,8 @@ static int do_md_stop(mddev_t * mddev, int ro)
1798 goto out; 1798 goto out;
1799 mddev->ro = 1; 1799 mddev->ro = 1;
1800 } else { 1800 } else {
1801 bitmap_flush(mddev);
1802 wait_event(mddev->sb_wait, atomic_read(&mddev->pending_writes)==0);
1801 if (mddev->ro) 1803 if (mddev->ro)
1802 set_disk_ro(disk, 0); 1804 set_disk_ro(disk, 0);
1803 blk_queue_make_request(mddev->queue, md_fail_request); 1805 blk_queue_make_request(mddev->queue, md_fail_request);
@@ -3484,7 +3486,6 @@ static void md_do_sync(mddev_t *mddev)
3484 goto skip; 3486 goto skip;
3485 } 3487 }
3486 ITERATE_MDDEV(mddev2,tmp) { 3488 ITERATE_MDDEV(mddev2,tmp) {
3487 printk(".");
3488 if (mddev2 == mddev) 3489 if (mddev2 == mddev)
3489 continue; 3490 continue;
3490 if (mddev2->curr_resync && 3491 if (mddev2->curr_resync &&
@@ -4007,3 +4008,4 @@ EXPORT_SYMBOL(md_wakeup_thread);
4007EXPORT_SYMBOL(md_print_devices); 4008EXPORT_SYMBOL(md_print_devices);
4008EXPORT_SYMBOL(md_check_recovery); 4009EXPORT_SYMBOL(md_check_recovery);
4009MODULE_LICENSE("GPL"); 4010MODULE_LICENSE("GPL");
4011MODULE_ALIAS("md");
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index d3a64a04a6d8..51d9645ed09c 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -893,7 +893,6 @@ static int end_sync_read(struct bio *bio, unsigned int bytes_done, int error)
893 if (!uptodate) { 893 if (!uptodate) {
894 md_error(r1_bio->mddev, 894 md_error(r1_bio->mddev,
895 conf->mirrors[r1_bio->read_disk].rdev); 895 conf->mirrors[r1_bio->read_disk].rdev);
896 set_bit(R1BIO_Degraded, &r1_bio->state);
897 } else 896 } else
898 set_bit(R1BIO_Uptodate, &r1_bio->state); 897 set_bit(R1BIO_Uptodate, &r1_bio->state);
899 rdev_dec_pending(conf->mirrors[r1_bio->read_disk].rdev, conf->mddev); 898 rdev_dec_pending(conf->mirrors[r1_bio->read_disk].rdev, conf->mddev);
@@ -918,10 +917,9 @@ static int end_sync_write(struct bio *bio, unsigned int bytes_done, int error)
918 mirror = i; 917 mirror = i;
919 break; 918 break;
920 } 919 }
921 if (!uptodate) { 920 if (!uptodate)
922 md_error(mddev, conf->mirrors[mirror].rdev); 921 md_error(mddev, conf->mirrors[mirror].rdev);
923 set_bit(R1BIO_Degraded, &r1_bio->state); 922
924 }
925 update_head_pos(mirror, r1_bio); 923 update_head_pos(mirror, r1_bio);
926 924
927 if (atomic_dec_and_test(&r1_bio->remaining)) { 925 if (atomic_dec_and_test(&r1_bio->remaining)) {
@@ -1109,6 +1107,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1109 int i; 1107 int i;
1110 int write_targets = 0; 1108 int write_targets = 0;
1111 int sync_blocks; 1109 int sync_blocks;
1110 int still_degraded = 0;
1112 1111
1113 if (!conf->r1buf_pool) 1112 if (!conf->r1buf_pool)
1114 { 1113 {
@@ -1137,7 +1136,10 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1137 return 0; 1136 return 0;
1138 } 1137 }
1139 1138
1140 if (!bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, mddev->degraded) && 1139 /* before building a request, check if we can skip these blocks..
1140 * This call the bitmap_start_sync doesn't actually record anything
1141 */
1142 if (!bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, 1) &&
1141 !conf->fullsync) { 1143 !conf->fullsync) {
1142 /* We can skip this block, and probably several more */ 1144 /* We can skip this block, and probably several more */
1143 *skipped = 1; 1145 *skipped = 1;
@@ -1203,24 +1205,23 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1203 if (i == disk) { 1205 if (i == disk) {
1204 bio->bi_rw = READ; 1206 bio->bi_rw = READ;
1205 bio->bi_end_io = end_sync_read; 1207 bio->bi_end_io = end_sync_read;
1206 } else if (conf->mirrors[i].rdev && 1208 } else if (conf->mirrors[i].rdev == NULL ||
1207 !conf->mirrors[i].rdev->faulty && 1209 conf->mirrors[i].rdev->faulty) {
1208 (!conf->mirrors[i].rdev->in_sync || 1210 still_degraded = 1;
1209 sector_nr + RESYNC_SECTORS > mddev->recovery_cp)) { 1211 continue;
1212 } else if (!conf->mirrors[i].rdev->in_sync ||
1213 sector_nr + RESYNC_SECTORS > mddev->recovery_cp) {
1210 bio->bi_rw = WRITE; 1214 bio->bi_rw = WRITE;
1211 bio->bi_end_io = end_sync_write; 1215 bio->bi_end_io = end_sync_write;
1212 write_targets ++; 1216 write_targets ++;
1213 } else 1217 } else
1218 /* no need to read or write here */
1214 continue; 1219 continue;
1215 bio->bi_sector = sector_nr + conf->mirrors[i].rdev->data_offset; 1220 bio->bi_sector = sector_nr + conf->mirrors[i].rdev->data_offset;
1216 bio->bi_bdev = conf->mirrors[i].rdev->bdev; 1221 bio->bi_bdev = conf->mirrors[i].rdev->bdev;
1217 bio->bi_private = r1_bio; 1222 bio->bi_private = r1_bio;
1218 } 1223 }
1219 1224
1220 if (write_targets + 1 < conf->raid_disks)
1221 /* array degraded, can't clear bitmap */
1222 set_bit(R1BIO_Degraded, &r1_bio->state);
1223
1224 if (write_targets == 0) { 1225 if (write_targets == 0) {
1225 /* There is nowhere to write, so all non-sync 1226 /* There is nowhere to write, so all non-sync
1226 * drives must be failed - so we are finished 1227 * drives must be failed - so we are finished
@@ -1243,7 +1244,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1243 break; 1244 break;
1244 if (sync_blocks == 0) { 1245 if (sync_blocks == 0) {
1245 if (!bitmap_start_sync(mddev->bitmap, sector_nr, 1246 if (!bitmap_start_sync(mddev->bitmap, sector_nr,
1246 &sync_blocks, mddev->degraded) && 1247 &sync_blocks, still_degraded) &&
1247 !conf->fullsync) 1248 !conf->fullsync)
1248 break; 1249 break;
1249 if (sync_blocks < (PAGE_SIZE>>9)) 1250 if (sync_blocks < (PAGE_SIZE>>9))
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 4698d5f79575..43f231a467d5 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -1653,6 +1653,7 @@ static int run (mddev_t *mddev)
1653 1653
1654 /* device size must be a multiple of chunk size */ 1654 /* device size must be a multiple of chunk size */
1655 mddev->size &= ~(mddev->chunk_size/1024 -1); 1655 mddev->size &= ~(mddev->chunk_size/1024 -1);
1656 mddev->resync_max_sectors = mddev->size << 1;
1656 1657
1657 if (!conf->chunk_size || conf->chunk_size % 4) { 1658 if (!conf->chunk_size || conf->chunk_size % 4) {
1658 printk(KERN_ERR "raid5: invalid chunk size %d for %s\n", 1659 printk(KERN_ERR "raid5: invalid chunk size %d for %s\n",
diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c
index f5ee16805111..495dee1d1e83 100644
--- a/drivers/md/raid6main.c
+++ b/drivers/md/raid6main.c
@@ -1813,6 +1813,7 @@ static int run (mddev_t *mddev)
1813 1813
1814 /* device size must be a multiple of chunk size */ 1814 /* device size must be a multiple of chunk size */
1815 mddev->size &= ~(mddev->chunk_size/1024 -1); 1815 mddev->size &= ~(mddev->chunk_size/1024 -1);
1816 mddev->resync_max_sectors = mddev->size << 1;
1816 1817
1817 if (conf->raid_disks < 4) { 1818 if (conf->raid_disks < 4) {
1818 printk(KERN_ERR "raid6: not enough configured devices for %s (%d, minimum 4)\n", 1819 printk(KERN_ERR "raid6: not enough configured devices for %s (%d, minimum 4)\n",
diff --git a/drivers/media/video/bttv-cards.c b/drivers/media/video/bttv-cards.c
index 6c52fd0bb7df..a97b9b958ed6 100644
--- a/drivers/media/video/bttv-cards.c
+++ b/drivers/media/video/bttv-cards.c
@@ -95,7 +95,7 @@ static int __devinit pvr_boot(struct bttv *btv);
95static unsigned int triton1=0; 95static unsigned int triton1=0;
96static unsigned int vsfx=0; 96static unsigned int vsfx=0;
97static unsigned int latency = UNSET; 97static unsigned int latency = UNSET;
98static unsigned int no_overlay=-1; 98int no_overlay=-1;
99 99
100static unsigned int card[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET }; 100static unsigned int card[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
101static unsigned int pll[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET }; 101static unsigned int pll[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
@@ -4296,9 +4296,11 @@ void __devinit bttv_check_chipset(void)
4296 printk(KERN_INFO "bttv: Host bridge needs VSFX enabled.\n"); 4296 printk(KERN_INFO "bttv: Host bridge needs VSFX enabled.\n");
4297 if (pcipci_fail) { 4297 if (pcipci_fail) {
4298 printk(KERN_WARNING "bttv: BT848 and your chipset may not work together.\n"); 4298 printk(KERN_WARNING "bttv: BT848 and your chipset may not work together.\n");
4299 if (UNSET == no_overlay) { 4299 if (!no_overlay) {
4300 printk(KERN_WARNING "bttv: going to disable overlay.\n"); 4300 printk(KERN_WARNING "bttv: overlay will be disabled.\n");
4301 no_overlay = 1; 4301 no_overlay = 1;
4302 } else {
4303 printk(KERN_WARNING "bttv: overlay forced. Use this option at your own risk.\n");
4302 } 4304 }
4303 } 4305 }
4304 if (UNSET != latency) 4306 if (UNSET != latency)
diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c
index 51a0f6d68e73..eee9322ce21b 100644
--- a/drivers/media/video/bttv-driver.c
+++ b/drivers/media/video/bttv-driver.c
@@ -1,5 +1,5 @@
1/* 1/*
2 $Id: bttv-driver.c,v 1.42 2005/07/05 17:37:35 nsh Exp $ 2 $Id: bttv-driver.c,v 1.52 2005/08/04 00:55:16 mchehab Exp $
3 3
4 bttv - Bt848 frame grabber driver 4 bttv - Bt848 frame grabber driver
5 5
@@ -80,6 +80,7 @@ static unsigned int irq_iswitch = 0;
80static unsigned int uv_ratio = 50; 80static unsigned int uv_ratio = 50;
81static unsigned int full_luma_range = 0; 81static unsigned int full_luma_range = 0;
82static unsigned int coring = 0; 82static unsigned int coring = 0;
83extern int no_overlay;
83 84
84/* API features (turn on/off stuff for testing) */ 85/* API features (turn on/off stuff for testing) */
85static unsigned int v4l2 = 1; 86static unsigned int v4l2 = 1;
@@ -2151,6 +2152,10 @@ static int bttv_s_fmt(struct bttv_fh *fh, struct bttv *btv,
2151 return 0; 2152 return 0;
2152 } 2153 }
2153 case V4L2_BUF_TYPE_VIDEO_OVERLAY: 2154 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
2155 if (no_overlay > 0) {
2156 printk ("V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n");
2157 return -EINVAL;
2158 }
2154 return setup_window(fh, btv, &f->fmt.win, 1); 2159 return setup_window(fh, btv, &f->fmt.win, 1);
2155 case V4L2_BUF_TYPE_VBI_CAPTURE: 2160 case V4L2_BUF_TYPE_VBI_CAPTURE:
2156 retval = bttv_switch_type(fh,f->type); 2161 retval = bttv_switch_type(fh,f->type);
@@ -2224,9 +2229,11 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2224 /* others */ 2229 /* others */
2225 cap->type = VID_TYPE_CAPTURE| 2230 cap->type = VID_TYPE_CAPTURE|
2226 VID_TYPE_TUNER| 2231 VID_TYPE_TUNER|
2227 VID_TYPE_OVERLAY|
2228 VID_TYPE_CLIPPING| 2232 VID_TYPE_CLIPPING|
2229 VID_TYPE_SCALES; 2233 VID_TYPE_SCALES;
2234 if (no_overlay <= 0)
2235 cap->type |= VID_TYPE_OVERLAY;
2236
2230 cap->maxwidth = bttv_tvnorms[btv->tvnorm].swidth; 2237 cap->maxwidth = bttv_tvnorms[btv->tvnorm].swidth;
2231 cap->maxheight = bttv_tvnorms[btv->tvnorm].sheight; 2238 cap->maxheight = bttv_tvnorms[btv->tvnorm].sheight;
2232 cap->minwidth = 48; 2239 cap->minwidth = 48;
@@ -2302,6 +2309,11 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2302 struct video_window *win = arg; 2309 struct video_window *win = arg;
2303 struct v4l2_window w2; 2310 struct v4l2_window w2;
2304 2311
2312 if (no_overlay > 0) {
2313 printk ("VIDIOCSWIN: no_overlay\n");
2314 return -EINVAL;
2315 }
2316
2305 w2.field = V4L2_FIELD_ANY; 2317 w2.field = V4L2_FIELD_ANY;
2306 w2.w.left = win->x; 2318 w2.w.left = win->x;
2307 w2.w.top = win->y; 2319 w2.w.top = win->y;
@@ -2577,10 +2589,12 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2577 cap->version = BTTV_VERSION_CODE; 2589 cap->version = BTTV_VERSION_CODE;
2578 cap->capabilities = 2590 cap->capabilities =
2579 V4L2_CAP_VIDEO_CAPTURE | 2591 V4L2_CAP_VIDEO_CAPTURE |
2580 V4L2_CAP_VIDEO_OVERLAY |
2581 V4L2_CAP_VBI_CAPTURE | 2592 V4L2_CAP_VBI_CAPTURE |
2582 V4L2_CAP_READWRITE | 2593 V4L2_CAP_READWRITE |
2583 V4L2_CAP_STREAMING; 2594 V4L2_CAP_STREAMING;
2595 if (no_overlay <= 0)
2596 cap->capabilities |= V4L2_CAP_VIDEO_OVERLAY;
2597
2584 if (bttv_tvcards[btv->c.type].tuner != UNSET && 2598 if (bttv_tvcards[btv->c.type].tuner != UNSET &&
2585 bttv_tvcards[btv->c.type].tuner != TUNER_ABSENT) 2599 bttv_tvcards[btv->c.type].tuner != TUNER_ABSENT)
2586 cap->capabilities |= V4L2_CAP_TUNER; 2600 cap->capabilities |= V4L2_CAP_TUNER;
@@ -3076,7 +3090,7 @@ static struct file_operations bttv_fops =
3076static struct video_device bttv_video_template = 3090static struct video_device bttv_video_template =
3077{ 3091{
3078 .name = "UNSET", 3092 .name = "UNSET",
3079 .type = VID_TYPE_CAPTURE|VID_TYPE_TUNER|VID_TYPE_OVERLAY| 3093 .type = VID_TYPE_CAPTURE|VID_TYPE_TUNER|
3080 VID_TYPE_CLIPPING|VID_TYPE_SCALES, 3094 VID_TYPE_CLIPPING|VID_TYPE_SCALES,
3081 .hardware = VID_HARDWARE_BT848, 3095 .hardware = VID_HARDWARE_BT848,
3082 .fops = &bttv_fops, 3096 .fops = &bttv_fops,
@@ -3756,6 +3770,12 @@ static void bttv_unregister_video(struct bttv *btv)
3756/* register video4linux devices */ 3770/* register video4linux devices */
3757static int __devinit bttv_register_video(struct bttv *btv) 3771static int __devinit bttv_register_video(struct bttv *btv)
3758{ 3772{
3773 if (no_overlay <= 0) {
3774 bttv_video_template.type |= VID_TYPE_OVERLAY;
3775 } else {
3776 printk("bttv: Overlay support disabled.\n");
3777 }
3778
3759 /* video */ 3779 /* video */
3760 btv->video_dev = vdev_init(btv, &bttv_video_template, "video"); 3780 btv->video_dev = vdev_init(btv, &bttv_video_template, "video");
3761 if (NULL == btv->video_dev) 3781 if (NULL == btv->video_dev)
@@ -3869,11 +3889,6 @@ static int __devinit bttv_probe(struct pci_dev *dev,
3869 pci_set_master(dev); 3889 pci_set_master(dev);
3870 pci_set_command(dev); 3890 pci_set_command(dev);
3871 pci_set_drvdata(dev,btv); 3891 pci_set_drvdata(dev,btv);
3872 if (!pci_dma_supported(dev,0xffffffff)) {
3873 printk("bttv%d: Oops: no 32bit PCI DMA ???\n", btv->c.nr);
3874 result = -EIO;
3875 goto fail1;
3876 }
3877 3892
3878 pci_read_config_byte(dev, PCI_CLASS_REVISION, &btv->revision); 3893 pci_read_config_byte(dev, PCI_CLASS_REVISION, &btv->revision);
3879 pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat); 3894 pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
diff --git a/drivers/media/video/bttv.h b/drivers/media/video/bttv.h
index 191eaf1714ba..f2af9e1454f0 100644
--- a/drivers/media/video/bttv.h
+++ b/drivers/media/video/bttv.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: bttv.h,v 1.18 2005/05/24 23:41:42 nsh Exp $ 2 * $Id: bttv.h,v 1.22 2005/07/28 18:41:21 mchehab Exp $
3 * 3 *
4 * bttv - Bt848 frame grabber driver 4 * bttv - Bt848 frame grabber driver
5 * 5 *
@@ -135,7 +135,9 @@
135#define BTTV_DVICO_DVBT_LITE 0x80 135#define BTTV_DVICO_DVBT_LITE 0x80
136#define BTTV_TIBET_CS16 0x83 136#define BTTV_TIBET_CS16 0x83
137#define BTTV_KODICOM_4400R 0x84 137#define BTTV_KODICOM_4400R 0x84
138#define BTTV_ADLINK_RTV24 0x85 138#define BTTV_ADLINK_RTV24 0x86
139#define BTTV_DVICO_FUSIONHDTV_5_LITE 0x87
140#define BTTV_ACORP_Y878F 0x88
139 141
140/* i2c address list */ 142/* i2c address list */
141#define I2C_TSA5522 0xc2 143#define I2C_TSA5522 0xc2
diff --git a/drivers/media/video/bttvp.h b/drivers/media/video/bttvp.h
index f3293e4a15ad..aab094bc243d 100644
--- a/drivers/media/video/bttvp.h
+++ b/drivers/media/video/bttvp.h
@@ -1,5 +1,5 @@
1/* 1/*
2 $Id: bttvp.h,v 1.19 2005/06/16 21:38:45 nsh Exp $ 2 $Id: bttvp.h,v 1.21 2005/07/15 21:44:14 mchehab Exp $
3 3
4 bttv - Bt848 frame grabber driver 4 bttv - Bt848 frame grabber driver
5 5
@@ -27,7 +27,7 @@
27#define _BTTVP_H_ 27#define _BTTVP_H_
28 28
29#include <linux/version.h> 29#include <linux/version.h>
30#define BTTV_VERSION_CODE KERNEL_VERSION(0,9,15) 30#define BTTV_VERSION_CODE KERNEL_VERSION(0,9,16)
31 31
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/wait.h> 33#include <linux/wait.h>
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
index 3d0c784b376f..ebf02a7f81e8 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: cx88-cards.c,v 1.86 2005/07/14 03:06:43 mchehab Exp $ 2 * $Id: cx88-cards.c,v 1.90 2005/07/28 02:47:42 mkrufky Exp $
3 * 3 *
4 * device driver for Conexant 2388x based TV cards 4 * device driver for Conexant 2388x based TV cards
5 * card-specific stuff. 5 * card-specific stuff.
@@ -90,6 +90,9 @@ struct cx88_board cx88_boards[] = {
90 .input = {{ 90 .input = {{
91 .type = CX88_VMUX_TELEVISION, 91 .type = CX88_VMUX_TELEVISION,
92 .vmux = 0, 92 .vmux = 0,
93 },{
94 .type = CX88_VMUX_SVIDEO,
95 .vmux = 2,
93 }}, 96 }},
94 }, 97 },
95 [CX88_BOARD_PIXELVIEW] = { 98 [CX88_BOARD_PIXELVIEW] = {
@@ -496,6 +499,9 @@ struct cx88_board cx88_boards[] = {
496 .input = {{ 499 .input = {{
497 .type = CX88_VMUX_DVB, 500 .type = CX88_VMUX_DVB,
498 .vmux = 0, 501 .vmux = 0,
502 },{
503 .type = CX88_VMUX_SVIDEO,
504 .vmux = 2,
499 }}, 505 }},
500 .dvb = 1, 506 .dvb = 1,
501 }, 507 },
@@ -753,6 +759,27 @@ struct cx88_board cx88_boards[] = {
753 }}, 759 }},
754 .dvb = 1, 760 .dvb = 1,
755 }, 761 },
762 [CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD] = {
763 .name = "DViCO FusionHDTV 5 Gold",
764 .tuner_type = TUNER_LG_TDVS_H062F,
765 .radio_type = UNSET,
766 .tuner_addr = ADDR_UNSET,
767 .radio_addr = ADDR_UNSET,
768 /* See DViCO FusionHDTV 3 Gold-Q for GPIO documentation. */
769 .input = {{
770 .type = CX88_VMUX_TELEVISION,
771 .vmux = 0,
772 .gpio0 = 0x0f0d,
773 },{
774 .type = CX88_VMUX_COMPOSITE1,
775 .vmux = 1,
776 .gpio0 = 0x0f00,
777 },{
778 .type = CX88_VMUX_SVIDEO,
779 .vmux = 2,
780 .gpio0 = 0x0f00,
781 }},
782 },
756}; 783};
757const unsigned int cx88_bcount = ARRAY_SIZE(cx88_boards); 784const unsigned int cx88_bcount = ARRAY_SIZE(cx88_boards);
758 785
@@ -880,6 +907,10 @@ struct cx88_subid cx88_subids[] = {
880 .subvendor = 0x153b, 907 .subvendor = 0x153b,
881 .subdevice = 0x1166, 908 .subdevice = 0x1166,
882 .card = CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1, 909 .card = CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1,
910 },{
911 .subvendor = 0x18ac,
912 .subdevice = 0xd500,
913 .card = CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD,
883 }, 914 },
884}; 915};
885const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids); 916const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids);
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index 5588a3aeecb4..5f58c103198a 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: cx88-video.c,v 1.80 2005/07/13 08:49:08 mchehab Exp $ 2 * $Id: cx88-video.c,v 1.82 2005/07/22 05:13:34 mkrufky Exp $
3 * 3 *
4 * device driver for Conexant 2388x based TV cards 4 * device driver for Conexant 2388x based TV cards
5 * video4linux video interface 5 * video4linux video interface
@@ -758,10 +758,10 @@ static int video_open(struct inode *inode, struct file *file)
758 struct cx88_core *core = dev->core; 758 struct cx88_core *core = dev->core;
759 int board = core->board; 759 int board = core->board;
760 dprintk(1,"video_open: setting radio device\n"); 760 dprintk(1,"video_open: setting radio device\n");
761 cx_write(MO_GP3_IO, cx88_boards[board].radio.gpio3);
761 cx_write(MO_GP0_IO, cx88_boards[board].radio.gpio0); 762 cx_write(MO_GP0_IO, cx88_boards[board].radio.gpio0);
762 cx_write(MO_GP1_IO, cx88_boards[board].radio.gpio1); 763 cx_write(MO_GP1_IO, cx88_boards[board].radio.gpio1);
763 cx_write(MO_GP2_IO, cx88_boards[board].radio.gpio2); 764 cx_write(MO_GP2_IO, cx88_boards[board].radio.gpio2);
764 cx_write(MO_GP3_IO, cx88_boards[board].radio.gpio3);
765 dev->core->tvaudio = WW_FM; 765 dev->core->tvaudio = WW_FM;
766 cx88_set_tvaudio(core); 766 cx88_set_tvaudio(core);
767 cx88_set_stereo(core,V4L2_TUNER_MODE_STEREO,1); 767 cx88_set_stereo(core,V4L2_TUNER_MODE_STEREO,1);
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index b008f7db6dfd..da65dc92787c 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: cx88.h,v 1.69 2005/07/13 17:25:25 mchehab Exp $ 2 * $Id: cx88.h,v 1.70 2005/07/24 17:44:09 mkrufky Exp $
3 * 3 *
4 * v4l2 device driver for cx2388x based TV cards 4 * v4l2 device driver for cx2388x based TV cards
5 * 5 *
@@ -171,6 +171,7 @@ extern struct sram_channel cx88_sram_channels[];
171#define CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T 28 171#define CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T 28
172#define CX88_BOARD_ADSTECH_DVB_T_PCI 29 172#define CX88_BOARD_ADSTECH_DVB_T_PCI 29
173#define CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1 30 173#define CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1 30
174#define CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD 31
174 175
175enum cx88_itype { 176enum cx88_itype {
176 CX88_VMUX_COMPOSITE1 = 1, 177 CX88_VMUX_COMPOSITE1 = 1,
diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c
index 6239254db27e..62f1b8ddb98b 100644
--- a/drivers/media/video/msp3400.c
+++ b/drivers/media/video/msp3400.c
@@ -741,11 +741,9 @@ static int msp34xx_sleep(struct msp3400c *msp, int timeout)
741 schedule_timeout(msecs_to_jiffies(timeout)); 741 schedule_timeout(msecs_to_jiffies(timeout));
742 } 742 }
743 } 743 }
744 if (current->flags & PF_FREEZE) {
745 refrigerator ();
746 }
747 744
748 remove_wait_queue(&msp->wq, &wait); 745 remove_wait_queue(&msp->wq, &wait);
746 try_to_freeze();
749 return msp->restart; 747 return msp->restart;
750} 748}
751 749
diff --git a/drivers/media/video/saa7134/saa7134-i2c.c b/drivers/media/video/saa7134/saa7134-i2c.c
index 93dd61978541..1203b93a572c 100644
--- a/drivers/media/video/saa7134/saa7134-i2c.c
+++ b/drivers/media/video/saa7134/saa7134-i2c.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: saa7134-i2c.c,v 1.19 2005/07/07 01:49:30 mkrufky Exp $ 2 * $Id: saa7134-i2c.c,v 1.22 2005/07/22 04:09:41 mkrufky Exp $
3 * 3 *
4 * device driver for philips saa7134 based TV cards 4 * device driver for philips saa7134 based TV cards
5 * i2c interface support 5 * i2c interface support
@@ -300,6 +300,8 @@ static int saa7134_i2c_xfer(struct i2c_adapter *i2c_adap,
300 status = i2c_get_status(dev); 300 status = i2c_get_status(dev);
301 if (i2c_is_error(status)) 301 if (i2c_is_error(status))
302 goto err; 302 goto err;
303 /* ensure that the bus is idle for at least one bit slot */
304 msleep(1);
303 305
304 d1printk("\n"); 306 d1printk("\n");
305 return num; 307 return num;
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index 6836c07794fc..2af0cb2a731b 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: saa7134.h,v 1.48 2005/07/01 08:22:24 nsh Exp $ 2 * $Id: saa7134.h,v 1.49 2005/07/13 17:25:25 mchehab Exp $
3 * 3 *
4 * v4l2 device driver for philips saa7134 based TV cards 4 * v4l2 device driver for philips saa7134 based TV cards
5 * 5 *
@@ -21,7 +21,7 @@
21 */ 21 */
22 22
23#include <linux/version.h> 23#include <linux/version.h>
24#define SAA7134_VERSION_CODE KERNEL_VERSION(0,2,13) 24#define SAA7134_VERSION_CODE KERNEL_VERSION(0,2,14)
25 25
26#include <linux/pci.h> 26#include <linux/pci.h>
27#include <linux/i2c.h> 27#include <linux/i2c.h>
diff --git a/drivers/media/video/tea5767.c b/drivers/media/video/tea5767.c
index 4d27ac1b7fb8..cebcc1fa68d1 100644
--- a/drivers/media/video/tea5767.c
+++ b/drivers/media/video/tea5767.c
@@ -2,7 +2,7 @@
2 * For Philips TEA5767 FM Chip used on some TV Cards like Prolink Pixelview 2 * For Philips TEA5767 FM Chip used on some TV Cards like Prolink Pixelview
3 * I2C address is allways 0xC0. 3 * I2C address is allways 0xC0.
4 * 4 *
5 * $Id: tea5767.c,v 1.21 2005/07/14 03:06:43 mchehab Exp $ 5 * $Id: tea5767.c,v 1.27 2005/07/31 12:10:56 mchehab Exp $
6 * 6 *
7 * Copyright (c) 2005 Mauro Carvalho Chehab (mchehab@brturbo.com.br) 7 * Copyright (c) 2005 Mauro Carvalho Chehab (mchehab@brturbo.com.br)
8 * This code is placed under the terms of the GNU General Public License 8 * This code is placed under the terms of the GNU General Public License
@@ -15,7 +15,6 @@
15#include <linux/videodev.h> 15#include <linux/videodev.h>
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <media/tuner.h> 17#include <media/tuner.h>
18#include <media/tuner.h>
19 18
20#define PREFIX "TEA5767 " 19#define PREFIX "TEA5767 "
21 20
@@ -293,16 +292,16 @@ static int tea5767_stereo(struct i2c_client *c)
293 292
294int tea5767_autodetection(struct i2c_client *c) 293int tea5767_autodetection(struct i2c_client *c)
295{ 294{
296 unsigned char buffer[5] = { 0xff, 0xff, 0xff, 0xff, 0xff }; 295 unsigned char buffer[7] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
297 int rc; 296 int rc;
298 struct tuner *t = i2c_get_clientdata(c); 297 struct tuner *t = i2c_get_clientdata(c);
299 298
300 if (5 != (rc = i2c_master_recv(c, buffer, 5))) { 299 if (7 != (rc = i2c_master_recv(c, buffer, 7))) {
301 tuner_warn("It is not a TEA5767. Received %i bytes.\n", rc); 300 tuner_warn("It is not a TEA5767. Received %i bytes.\n", rc);
302 return EINVAL; 301 return EINVAL;
303 } 302 }
304 303
305 /* If all bytes are the same then it's a TV tuner and not a tea5767 chip. */ 304 /* If all bytes are the same then it's a TV tuner and not a tea5767 */
306 if (buffer[0] == buffer[1] && buffer[0] == buffer[2] && 305 if (buffer[0] == buffer[1] && buffer[0] == buffer[2] &&
307 buffer[0] == buffer[3] && buffer[0] == buffer[4]) { 306 buffer[0] == buffer[3] && buffer[0] == buffer[4]) {
308 tuner_warn("All bytes are equal. It is not a TEA5767\n"); 307 tuner_warn("All bytes are equal. It is not a TEA5767\n");
@@ -318,6 +317,17 @@ int tea5767_autodetection(struct i2c_client *c)
318 tuner_warn("Chip ID is not zero. It is not a TEA5767\n"); 317 tuner_warn("Chip ID is not zero. It is not a TEA5767\n");
319 return EINVAL; 318 return EINVAL;
320 } 319 }
320 /* It seems that tea5767 returns 0xff after the 5th byte */
321 if ((buffer[5] != 0xff) || (buffer[6] != 0xff)) {
322 tuner_warn("Returned more than 5 bytes. It is not a TEA5767\n");
323 return EINVAL;
324 }
325
326 /* It seems that tea5767 returns 0xff after the 5th byte */
327 if ((buffer[5] != 0xff) || (buffer[6] != 0xff)) {
328 tuner_warn("Returned more than 5 bytes. It is not a TEA5767\n");
329 return EINVAL;
330 }
321 331
322 tuner_warn("TEA5767 detected.\n"); 332 tuner_warn("TEA5767 detected.\n");
323 return 0; 333 return 0;
@@ -327,10 +337,8 @@ int tea5767_tuner_init(struct i2c_client *c)
327{ 337{
328 struct tuner *t = i2c_get_clientdata(c); 338 struct tuner *t = i2c_get_clientdata(c);
329 339
330 if (tea5767_autodetection(c) == EINVAL) 340 tuner_info("type set to %d (%s)\n", t->type,
331 return EINVAL; 341 "Philips TEA5767HN FM Radio");
332
333 tuner_info("type set to %d (%s)\n", t->type, "Philips TEA5767HN FM Radio");
334 strlcpy(c->name, "tea5767", sizeof(c->name)); 342 strlcpy(c->name, "tea5767", sizeof(c->name));
335 343
336 t->tv_freq = set_tv_freq; 344 t->tv_freq = set_tv_freq;
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index b25a9c08ac02..f0a579827a24 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: tuner-core.c,v 1.58 2005/07/14 03:06:43 mchehab Exp $ 2 * $Id: tuner-core.c,v 1.63 2005/07/28 18:19:55 mchehab Exp $
3 * 3 *
4 * i2c tv tuner chip device driver 4 * i2c tv tuner chip device driver
5 * core core, i.e. kernel interfaces, registering and so on 5 * core core, i.e. kernel interfaces, registering and so on
@@ -23,6 +23,8 @@
23#include <media/tuner.h> 23#include <media/tuner.h>
24#include <media/audiochip.h> 24#include <media/audiochip.h>
25 25
26#include "msp3400.h"
27
26#define UNSET (-1U) 28#define UNSET (-1U)
27 29
28/* standard i2c insmod options */ 30/* standard i2c insmod options */
@@ -42,6 +44,9 @@ module_param(addr, int, 0444);
42static unsigned int no_autodetect = 0; 44static unsigned int no_autodetect = 0;
43module_param(no_autodetect, int, 0444); 45module_param(no_autodetect, int, 0444);
44 46
47static unsigned int show_i2c = 0;
48module_param(show_i2c, int, 0444);
49
45/* insmod options used at runtime => read/write */ 50/* insmod options used at runtime => read/write */
46unsigned int tuner_debug = 0; 51unsigned int tuner_debug = 0;
47module_param(tuner_debug, int, 0644); 52module_param(tuner_debug, int, 0644);
@@ -320,6 +325,17 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
320 325
321 tuner_info("chip found @ 0x%x (%s)\n", addr << 1, adap->name); 326 tuner_info("chip found @ 0x%x (%s)\n", addr << 1, adap->name);
322 327
328 if (show_i2c) {
329 unsigned char buffer[16];
330 int i,rc;
331
332 memset(buffer, 0, sizeof(buffer));
333 rc = i2c_master_recv(&t->i2c, buffer, sizeof(buffer));
334 printk("tuner-%04x I2C RECV = ",addr);
335 for (i=0;i<rc;i++)
336 printk("%02x ",buffer[i]);
337 printk("\n");
338 }
323 /* TEA5767 autodetection code - only for addr = 0xc0 */ 339 /* TEA5767 autodetection code - only for addr = 0xc0 */
324 if (!no_autodetect) { 340 if (!no_autodetect) {
325 if (addr == 0x60) { 341 if (addr == 0x60) {
@@ -451,6 +467,17 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
451 break; 467 break;
452 } 468 }
453 break; 469 break;
470 case VIDIOCSAUDIO:
471 if (check_mode(t, "VIDIOCSAUDIO") == EINVAL)
472 return 0;
473 if (check_v4l2(t) == EINVAL)
474 return 0;
475
476 /* Should be implemented, since bttv calls it */
477 tuner_dbg("VIDIOCSAUDIO not implemented.\n");
478
479 break;
480 case MSP_SET_MATRIX:
454 case TDA9887_SET_CONFIG: 481 case TDA9887_SET_CONFIG:
455 break; 482 break;
456 /* --- v4l ioctls --- */ 483 /* --- v4l ioctls --- */
diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c
index a3f8e83f5314..de0c93aeb75d 100644
--- a/drivers/media/video/tuner-simple.c
+++ b/drivers/media/video/tuner-simple.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: tuner-simple.c,v 1.39 2005/07/07 01:49:30 mkrufky Exp $ 2 * $Id: tuner-simple.c,v 1.43 2005/07/28 18:41:21 mchehab Exp $
3 * 3 *
4 * i2c tv tuner chip device driver 4 * i2c tv tuner chip device driver
5 * controls all those simple 4-control-bytes style tuners. 5 * controls all those simple 4-control-bytes style tuners.
@@ -245,6 +245,12 @@ static struct tunertype tuners[] = {
245 /* see tea5767.c for details */}, 245 /* see tea5767.c for details */},
246 { "Philips FMD1216ME MK3 Hybrid Tuner", Philips, PAL, 246 { "Philips FMD1216ME MK3 Hybrid Tuner", Philips, PAL,
247 16*160.00,16*442.00,0x51,0x52,0x54,0x86,623 }, 247 16*160.00,16*442.00,0x51,0x52,0x54,0x86,623 },
248
249 { "LG TDVS-H062F/TUA6034", LGINNOTEK, NTSC,
250 16*160.00,16*455.00,0x01,0x02,0x04,0x8e,732},
251
252 { "Ymec TVF66T5-B/DFF", Philips, PAL,
253 16*160.25,16*464.25,0x01,0x02,0x08,0x8e,623},
248}; 254};
249 255
250unsigned const int tuner_count = ARRAY_SIZE(tuners); 256unsigned const int tuner_count = ARRAY_SIZE(tuners);
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index 62b03ef091e0..127ec38ebd60 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -189,7 +189,7 @@ hauppauge_tuner[] =
189 { TUNER_ABSENT, "Philips FQ1236 MK3"}, 189 { TUNER_ABSENT, "Philips FQ1236 MK3"},
190 { TUNER_ABSENT, "Samsung TCPN 2121P30A"}, 190 { TUNER_ABSENT, "Samsung TCPN 2121P30A"},
191 { TUNER_ABSENT, "Samsung TCPE 4121P30A"}, 191 { TUNER_ABSENT, "Samsung TCPE 4121P30A"},
192 { TUNER_ABSENT, "TCL MFPE05 2"}, 192 { TUNER_PHILIPS_FM1216ME_MK3, "TCL MFPE05 2"},
193 /* 90-99 */ 193 /* 90-99 */
194 { TUNER_ABSENT, "LG TALN H202T"}, 194 { TUNER_ABSENT, "LG TALN H202T"},
195 { TUNER_PHILIPS_FQ1216AME_MK4, "Philips FQ1216AME MK4"}, 195 { TUNER_PHILIPS_FQ1216AME_MK4, "Philips FQ1216AME MK4"},
diff --git a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c
index 2c6dc24c3728..b780307093eb 100644
--- a/drivers/net/cs89x0.c
+++ b/drivers/net/cs89x0.c
@@ -417,6 +417,7 @@ cs89x0_probe1(struct net_device *dev, int ioaddr, int modular)
417 struct net_local *lp = netdev_priv(dev); 417 struct net_local *lp = netdev_priv(dev);
418 static unsigned version_printed; 418 static unsigned version_printed;
419 int i; 419 int i;
420 int tmp;
420 unsigned rev_type = 0; 421 unsigned rev_type = 0;
421 int eeprom_buff[CHKSUM_LEN]; 422 int eeprom_buff[CHKSUM_LEN];
422 int retval; 423 int retval;
@@ -492,14 +493,17 @@ cs89x0_probe1(struct net_device *dev, int ioaddr, int modular)
492 goto out2; 493 goto out2;
493 } 494 }
494 } 495 }
495printk("PP_addr=0x%x\n", inw(ioaddr + ADD_PORT)); 496 printk(KERN_DEBUG "PP_addr at %x: 0x%x\n",
497 ioaddr + ADD_PORT, inw(ioaddr + ADD_PORT));
496 498
497 ioaddr &= ~3; 499 ioaddr &= ~3;
498 outw(PP_ChipID, ioaddr + ADD_PORT); 500 outw(PP_ChipID, ioaddr + ADD_PORT);
499 501
500 if (inw(ioaddr + DATA_PORT) != CHIP_EISA_ID_SIG) { 502 tmp = inw(ioaddr + DATA_PORT);
501 printk(KERN_ERR "%s: incorrect signature 0x%x\n", 503 if (tmp != CHIP_EISA_ID_SIG) {
502 dev->name, inw(ioaddr + DATA_PORT)); 504 printk(KERN_DEBUG "%s: incorrect signature at %x: 0x%x!="
505 CHIP_EISA_ID_SIG_STR "\n",
506 dev->name, ioaddr + DATA_PORT, tmp);
503 retval = -ENODEV; 507 retval = -ENODEV;
504 goto out2; 508 goto out2;
505 } 509 }
diff --git a/drivers/net/cs89x0.h b/drivers/net/cs89x0.h
index bd3ad8e6cce9..decea264f121 100644
--- a/drivers/net/cs89x0.h
+++ b/drivers/net/cs89x0.h
@@ -93,6 +93,7 @@
93#endif 93#endif
94 94
95#define CHIP_EISA_ID_SIG 0x630E /* Product ID Code for Crystal Chip (CS8900 spec 4.3) */ 95#define CHIP_EISA_ID_SIG 0x630E /* Product ID Code for Crystal Chip (CS8900 spec 4.3) */
96#define CHIP_EISA_ID_SIG_STR "0x630E"
96 97
97#ifdef IBMEIPKT 98#ifdef IBMEIPKT
98#define EISA_ID_SIG 0x4D24 /* IBM */ 99#define EISA_ID_SIG 0x4D24 /* IBM */
diff --git a/drivers/net/hamradio/Kconfig b/drivers/net/hamradio/Kconfig
index 7cdebe1a0b61..0cd54306e636 100644
--- a/drivers/net/hamradio/Kconfig
+++ b/drivers/net/hamradio/Kconfig
@@ -17,7 +17,7 @@ config MKISS
17 17
18config 6PACK 18config 6PACK
19 tristate "Serial port 6PACK driver" 19 tristate "Serial port 6PACK driver"
20 depends on AX25 && BROKEN_ON_SMP 20 depends on AX25
21 ---help--- 21 ---help---
22 6pack is a transmission protocol for the data exchange between your 22 6pack is a transmission protocol for the data exchange between your
23 PC and your TNC (the Terminal Node Controller acts as a kind of 23 PC and your TNC (the Terminal Node Controller acts as a kind of
diff --git a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
index 82570ec44d8e..6ee4771addf1 100644
--- a/drivers/net/sk98lin/skge.c
+++ b/drivers/net/sk98lin/skge.c
@@ -5133,6 +5133,84 @@ static void __devexit skge_remove_one(struct pci_dev *pdev)
5133 kfree(pAC); 5133 kfree(pAC);
5134} 5134}
5135 5135
5136#ifdef CONFIG_PM
5137static int skge_suspend(struct pci_dev *pdev, pm_message_t state)
5138{
5139 struct net_device *dev = pci_get_drvdata(pdev);
5140 DEV_NET *pNet = netdev_priv(dev);
5141 SK_AC *pAC = pNet->pAC;
5142 struct net_device *otherdev = pAC->dev[1];
5143
5144 if (netif_running(dev)) {
5145 netif_carrier_off(dev);
5146 DoPrintInterfaceChange = SK_FALSE;
5147 SkDrvDeInitAdapter(pAC, 0); /* performs SkGeClose */
5148 netif_device_detach(dev);
5149 }
5150 if (otherdev != dev) {
5151 if (netif_running(otherdev)) {
5152 netif_carrier_off(otherdev);
5153 DoPrintInterfaceChange = SK_FALSE;
5154 SkDrvDeInitAdapter(pAC, 1); /* performs SkGeClose */
5155 netif_device_detach(otherdev);
5156 }
5157 }
5158
5159 pci_save_state(pdev);
5160 pci_enable_wake(pdev, pci_choose_state(pdev, state), 0);
5161 if (pAC->AllocFlag & SK_ALLOC_IRQ) {
5162 free_irq(dev->irq, dev);
5163 }
5164 pci_disable_device(pdev);
5165 pci_set_power_state(pdev, pci_choose_state(pdev, state));
5166
5167 return 0;
5168}
5169
5170static int skge_resume(struct pci_dev *pdev)
5171{
5172 struct net_device *dev = pci_get_drvdata(pdev);
5173 DEV_NET *pNet = netdev_priv(dev);
5174 SK_AC *pAC = pNet->pAC;
5175 struct net_device *otherdev = pAC->dev[1];
5176 int ret;
5177
5178 pci_set_power_state(pdev, PCI_D0);
5179 pci_restore_state(pdev);
5180 pci_enable_device(pdev);
5181 pci_set_master(pdev);
5182 if (pAC->GIni.GIMacsFound == 2)
5183 ret = request_irq(dev->irq, SkGeIsr, SA_SHIRQ, pAC->Name, dev);
5184 else
5185 ret = request_irq(dev->irq, SkGeIsrOnePort, SA_SHIRQ, pAC->Name, dev);
5186 if (ret) {
5187 printk(KERN_WARNING "sk98lin: unable to acquire IRQ %d\n", dev->irq);
5188 pAC->AllocFlag &= ~SK_ALLOC_IRQ;
5189 dev->irq = 0;
5190 pci_disable_device(pdev);
5191 return -EBUSY;
5192 }
5193
5194 netif_device_attach(dev);
5195 if (netif_running(dev)) {
5196 DoPrintInterfaceChange = SK_FALSE;
5197 SkDrvInitAdapter(pAC, 0); /* first device */
5198 }
5199 if (otherdev != dev) {
5200 netif_device_attach(otherdev);
5201 if (netif_running(otherdev)) {
5202 DoPrintInterfaceChange = SK_FALSE;
5203 SkDrvInitAdapter(pAC, 1); /* second device */
5204 }
5205 }
5206
5207 return 0;
5208}
5209#else
5210#define skge_suspend NULL
5211#define skge_resume NULL
5212#endif
5213
5136static struct pci_device_id skge_pci_tbl[] = { 5214static struct pci_device_id skge_pci_tbl[] = {
5137 { PCI_VENDOR_ID_3COM, 0x1700, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 5215 { PCI_VENDOR_ID_3COM, 0x1700, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
5138 { PCI_VENDOR_ID_3COM, 0x80eb, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 5216 { PCI_VENDOR_ID_3COM, 0x80eb, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
@@ -5158,6 +5236,8 @@ static struct pci_driver skge_driver = {
5158 .id_table = skge_pci_tbl, 5236 .id_table = skge_pci_tbl,
5159 .probe = skge_probe_one, 5237 .probe = skge_probe_one,
5160 .remove = __devexit_p(skge_remove_one), 5238 .remove = __devexit_p(skge_remove_one),
5239 .suspend = skge_suspend,
5240 .resume = skge_resume,
5161}; 5241};
5162 5242
5163static int __init skge_init(void) 5243static int __init skge_init(void)
diff --git a/drivers/net/sk98lin/skgeinit.c b/drivers/net/sk98lin/skgeinit.c
index df4483429a77..6cb49dd02251 100644
--- a/drivers/net/sk98lin/skgeinit.c
+++ b/drivers/net/sk98lin/skgeinit.c
@@ -2016,7 +2016,7 @@ SK_IOC IoC) /* IO context */
2016 * we set the PHY to coma mode and switch to D3 power state. 2016 * we set the PHY to coma mode and switch to D3 power state.
2017 */ 2017 */
2018 if (pAC->GIni.GIYukonLite && 2018 if (pAC->GIni.GIYukonLite &&
2019 pAC->GIni.GIChipRev == CHIP_REV_YU_LITE_A3) { 2019 pAC->GIni.GIChipRev >= CHIP_REV_YU_LITE_A3) {
2020 2020
2021 /* for all ports switch PHY to coma mode */ 2021 /* for all ports switch PHY to coma mode */
2022 for (i = 0; i < pAC->GIni.GIMacsFound; i++) { 2022 for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
diff --git a/drivers/net/sk98lin/skxmac2.c b/drivers/net/sk98lin/skxmac2.c
index 94a09deecb32..42d2d963150a 100644
--- a/drivers/net/sk98lin/skxmac2.c
+++ b/drivers/net/sk98lin/skxmac2.c
@@ -1065,7 +1065,7 @@ int Port) /* Port Index (MAC_1 + n) */
1065 1065
1066 /* WA code for COMA mode */ 1066 /* WA code for COMA mode */
1067 if (pAC->GIni.GIYukonLite && 1067 if (pAC->GIni.GIYukonLite &&
1068 pAC->GIni.GIChipRev == CHIP_REV_YU_LITE_A3) { 1068 pAC->GIni.GIChipRev >= CHIP_REV_YU_LITE_A3) {
1069 1069
1070 SK_IN32(IoC, B2_GP_IO, &DWord); 1070 SK_IN32(IoC, B2_GP_IO, &DWord);
1071 1071
@@ -1110,7 +1110,7 @@ int Port) /* Port Index (MAC_1 + n) */
1110 1110
1111 /* WA code for COMA mode */ 1111 /* WA code for COMA mode */
1112 if (pAC->GIni.GIYukonLite && 1112 if (pAC->GIni.GIYukonLite &&
1113 pAC->GIni.GIChipRev == CHIP_REV_YU_LITE_A3) { 1113 pAC->GIni.GIChipRev >= CHIP_REV_YU_LITE_A3) {
1114 1114
1115 SK_IN32(IoC, B2_GP_IO, &DWord); 1115 SK_IN32(IoC, B2_GP_IO, &DWord);
1116 1116
@@ -2126,7 +2126,7 @@ SK_U8 Mode) /* low power mode */
2126 int Ret = 0; 2126 int Ret = 0;
2127 2127
2128 if (pAC->GIni.GIYukonLite && 2128 if (pAC->GIni.GIYukonLite &&
2129 pAC->GIni.GIChipRev == CHIP_REV_YU_LITE_A3) { 2129 pAC->GIni.GIChipRev >= CHIP_REV_YU_LITE_A3) {
2130 2130
2131 /* save current power mode */ 2131 /* save current power mode */
2132 LastMode = pAC->GIni.GP[Port].PPhyPowerState; 2132 LastMode = pAC->GIni.GP[Port].PPhyPowerState;
@@ -2253,7 +2253,7 @@ int Port) /* Port Index (e.g. MAC_1) */
2253 int Ret = 0; 2253 int Ret = 0;
2254 2254
2255 if (pAC->GIni.GIYukonLite && 2255 if (pAC->GIni.GIYukonLite &&
2256 pAC->GIni.GIChipRev == CHIP_REV_YU_LITE_A3) { 2256 pAC->GIni.GIChipRev >= CHIP_REV_YU_LITE_A3) {
2257 2257
2258 /* save current power mode */ 2258 /* save current power mode */
2259 LastMode = pAC->GIni.GP[Port].PPhyPowerState; 2259 LastMode = pAC->GIni.GP[Port].PPhyPowerState;
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 5cacc7ad9e79..f15739481d62 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -42,7 +42,7 @@
42#include "skge.h" 42#include "skge.h"
43 43
44#define DRV_NAME "skge" 44#define DRV_NAME "skge"
45#define DRV_VERSION "0.7" 45#define DRV_VERSION "0.8"
46#define PFX DRV_NAME " " 46#define PFX DRV_NAME " "
47 47
48#define DEFAULT_TX_RING_SIZE 128 48#define DEFAULT_TX_RING_SIZE 128
@@ -55,7 +55,7 @@
55#define ETH_JUMBO_MTU 9000 55#define ETH_JUMBO_MTU 9000
56#define TX_WATCHDOG (5 * HZ) 56#define TX_WATCHDOG (5 * HZ)
57#define NAPI_WEIGHT 64 57#define NAPI_WEIGHT 64
58#define BLINK_HZ (HZ/4) 58#define BLINK_MS 250
59 59
60MODULE_DESCRIPTION("SysKonnect Gigabit Ethernet driver"); 60MODULE_DESCRIPTION("SysKonnect Gigabit Ethernet driver");
61MODULE_AUTHOR("Stephen Hemminger <shemminger@osdl.org>"); 61MODULE_AUTHOR("Stephen Hemminger <shemminger@osdl.org>");
@@ -75,7 +75,6 @@ static const struct pci_device_id skge_id_table[] = {
75 { PCI_DEVICE(PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C940B) }, 75 { PCI_DEVICE(PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C940B) },
76 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_GE) }, 76 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_GE) },
77 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_YU) }, 77 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_YU) },
78 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, /* SK-9Exx */
79 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, PCI_DEVICE_ID_DLINK_DGE510T), }, 78 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, PCI_DEVICE_ID_DLINK_DGE510T), },
80 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4320) }, 79 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4320) },
81 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x5005) }, /* Belkin */ 80 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x5005) }, /* Belkin */
@@ -249,7 +248,7 @@ static int skge_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
249 } else { 248 } else {
250 u32 setting; 249 u32 setting;
251 250
252 switch(ecmd->speed) { 251 switch (ecmd->speed) {
253 case SPEED_1000: 252 case SPEED_1000:
254 if (ecmd->duplex == DUPLEX_FULL) 253 if (ecmd->duplex == DUPLEX_FULL)
255 setting = SUPPORTED_1000baseT_Full; 254 setting = SUPPORTED_1000baseT_Full;
@@ -620,84 +619,98 @@ static int skge_set_coalesce(struct net_device *dev,
620 return 0; 619 return 0;
621} 620}
622 621
623static void skge_led_on(struct skge_hw *hw, int port) 622enum led_mode { LED_MODE_OFF, LED_MODE_ON, LED_MODE_TST };
623static void skge_led(struct skge_port *skge, enum led_mode mode)
624{ 624{
625 struct skge_hw *hw = skge->hw;
626 int port = skge->port;
627
628 spin_lock_bh(&hw->phy_lock);
625 if (hw->chip_id == CHIP_ID_GENESIS) { 629 if (hw->chip_id == CHIP_ID_GENESIS) {
626 skge_write8(hw, SK_REG(port, LNK_LED_REG), LINKLED_ON); 630 switch (mode) {
627 skge_write8(hw, B0_LED, LED_STAT_ON); 631 case LED_MODE_OFF:
632 xm_phy_write(hw, port, PHY_BCOM_P_EXT_CTRL, PHY_B_PEC_LED_OFF);
633 skge_write8(hw, SK_REG(port, LNK_LED_REG), LINKLED_OFF);
634 skge_write32(hw, SK_REG(port, RX_LED_VAL), 0);
635 skge_write8(hw, SK_REG(port, RX_LED_CTRL), LED_T_OFF);
636 break;
628 637
629 skge_write8(hw, SK_REG(port, RX_LED_TST), LED_T_ON); 638 case LED_MODE_ON:
630 skge_write32(hw, SK_REG(port, RX_LED_VAL), 100); 639 skge_write8(hw, SK_REG(port, LNK_LED_REG), LINKLED_ON);
631 skge_write8(hw, SK_REG(port, RX_LED_CTRL), LED_START); 640 skge_write8(hw, SK_REG(port, LNK_LED_REG), LINKLED_LINKSYNC_ON);
632 641
633 /* For Broadcom Phy only */ 642 skge_write8(hw, SK_REG(port, RX_LED_CTRL), LED_START);
634 xm_phy_write(hw, port, PHY_BCOM_P_EXT_CTRL, PHY_B_PEC_LED_ON); 643 skge_write8(hw, SK_REG(port, TX_LED_CTRL), LED_START);
635 } else {
636 gm_phy_write(hw, port, PHY_MARV_LED_CTRL, 0);
637 gm_phy_write(hw, port, PHY_MARV_LED_OVER,
638 PHY_M_LED_MO_DUP(MO_LED_ON) |
639 PHY_M_LED_MO_10(MO_LED_ON) |
640 PHY_M_LED_MO_100(MO_LED_ON) |
641 PHY_M_LED_MO_1000(MO_LED_ON) |
642 PHY_M_LED_MO_RX(MO_LED_ON));
643 }
644}
645 644
646static void skge_led_off(struct skge_hw *hw, int port) 645 break;
647{
648 if (hw->chip_id == CHIP_ID_GENESIS) {
649 skge_write8(hw, SK_REG(port, LNK_LED_REG), LINKLED_OFF);
650 skge_write8(hw, B0_LED, LED_STAT_OFF);
651 646
652 skge_write32(hw, SK_REG(port, RX_LED_VAL), 0); 647 case LED_MODE_TST:
653 skge_write8(hw, SK_REG(port, RX_LED_CTRL), LED_T_OFF); 648 skge_write8(hw, SK_REG(port, RX_LED_TST), LED_T_ON);
649 skge_write32(hw, SK_REG(port, RX_LED_VAL), 100);
650 skge_write8(hw, SK_REG(port, RX_LED_CTRL), LED_START);
654 651
655 /* Broadcom only */ 652 xm_phy_write(hw, port, PHY_BCOM_P_EXT_CTRL, PHY_B_PEC_LED_ON);
656 xm_phy_write(hw, port, PHY_BCOM_P_EXT_CTRL, PHY_B_PEC_LED_OFF); 653 break;
654 }
657 } else { 655 } else {
658 gm_phy_write(hw, port, PHY_MARV_LED_CTRL, 0); 656 switch (mode) {
659 gm_phy_write(hw, port, PHY_MARV_LED_OVER, 657 case LED_MODE_OFF:
660 PHY_M_LED_MO_DUP(MO_LED_OFF) | 658 gm_phy_write(hw, port, PHY_MARV_LED_CTRL, 0);
661 PHY_M_LED_MO_10(MO_LED_OFF) | 659 gm_phy_write(hw, port, PHY_MARV_LED_OVER,
662 PHY_M_LED_MO_100(MO_LED_OFF) | 660 PHY_M_LED_MO_DUP(MO_LED_OFF) |
663 PHY_M_LED_MO_1000(MO_LED_OFF) | 661 PHY_M_LED_MO_10(MO_LED_OFF) |
664 PHY_M_LED_MO_RX(MO_LED_OFF)); 662 PHY_M_LED_MO_100(MO_LED_OFF) |
663 PHY_M_LED_MO_1000(MO_LED_OFF) |
664 PHY_M_LED_MO_RX(MO_LED_OFF));
665 break;
666 case LED_MODE_ON:
667 gm_phy_write(hw, port, PHY_MARV_LED_CTRL,
668 PHY_M_LED_PULS_DUR(PULS_170MS) |
669 PHY_M_LED_BLINK_RT(BLINK_84MS) |
670 PHY_M_LEDC_TX_CTRL |
671 PHY_M_LEDC_DP_CTRL);
672
673 gm_phy_write(hw, port, PHY_MARV_LED_OVER,
674 PHY_M_LED_MO_RX(MO_LED_OFF) |
675 (skge->speed == SPEED_100 ?
676 PHY_M_LED_MO_100(MO_LED_ON) : 0));
677 break;
678 case LED_MODE_TST:
679 gm_phy_write(hw, port, PHY_MARV_LED_CTRL, 0);
680 gm_phy_write(hw, port, PHY_MARV_LED_OVER,
681 PHY_M_LED_MO_DUP(MO_LED_ON) |
682 PHY_M_LED_MO_10(MO_LED_ON) |
683 PHY_M_LED_MO_100(MO_LED_ON) |
684 PHY_M_LED_MO_1000(MO_LED_ON) |
685 PHY_M_LED_MO_RX(MO_LED_ON));
686 }
665 } 687 }
666} 688 spin_unlock_bh(&hw->phy_lock);
667
668static void skge_blink_timer(unsigned long data)
669{
670 struct skge_port *skge = (struct skge_port *) data;
671 struct skge_hw *hw = skge->hw;
672 unsigned long flags;
673
674 spin_lock_irqsave(&hw->phy_lock, flags);
675 if (skge->blink_on)
676 skge_led_on(hw, skge->port);
677 else
678 skge_led_off(hw, skge->port);
679 spin_unlock_irqrestore(&hw->phy_lock, flags);
680
681 skge->blink_on = !skge->blink_on;
682 mod_timer(&skge->led_blink, jiffies + BLINK_HZ);
683} 689}
684 690
685/* blink LED's for finding board */ 691/* blink LED's for finding board */
686static int skge_phys_id(struct net_device *dev, u32 data) 692static int skge_phys_id(struct net_device *dev, u32 data)
687{ 693{
688 struct skge_port *skge = netdev_priv(dev); 694 struct skge_port *skge = netdev_priv(dev);
695 unsigned long ms;
696 enum led_mode mode = LED_MODE_TST;
689 697
690 if (!data || data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ)) 698 if (!data || data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ))
691 data = (u32)(MAX_SCHEDULE_TIMEOUT / HZ); 699 ms = jiffies_to_msecs(MAX_SCHEDULE_TIMEOUT / HZ) * 1000;
700 else
701 ms = data * 1000;
692 702
693 /* start blinking */ 703 while (ms > 0) {
694 skge->blink_on = 1; 704 skge_led(skge, mode);
695 mod_timer(&skge->led_blink, jiffies+1); 705 mode ^= LED_MODE_TST;
696 706
697 msleep_interruptible(data * 1000); 707 if (msleep_interruptible(BLINK_MS))
698 del_timer_sync(&skge->led_blink); 708 break;
709 ms -= BLINK_MS;
710 }
699 711
700 skge_led_off(skge->hw, skge->port); 712 /* back to regular LED state */
713 skge_led(skge, netif_running(dev) ? LED_MODE_ON : LED_MODE_OFF);
701 714
702 return 0; 715 return 0;
703} 716}
@@ -1028,7 +1041,7 @@ static void bcom_check_link(struct skge_hw *hw, int port)
1028 } 1041 }
1029 1042
1030 /* Check Duplex mismatch */ 1043 /* Check Duplex mismatch */
1031 switch(aux & PHY_B_AS_AN_RES_MSK) { 1044 switch (aux & PHY_B_AS_AN_RES_MSK) {
1032 case PHY_B_RES_1000FD: 1045 case PHY_B_RES_1000FD:
1033 skge->duplex = DUPLEX_FULL; 1046 skge->duplex = DUPLEX_FULL;
1034 break; 1047 break;
@@ -1099,7 +1112,7 @@ static void bcom_phy_init(struct skge_port *skge, int jumbo)
1099 r |= XM_MMU_NO_PRE; 1112 r |= XM_MMU_NO_PRE;
1100 xm_write16(hw, port, XM_MMU_CMD,r); 1113 xm_write16(hw, port, XM_MMU_CMD,r);
1101 1114
1102 switch(id1) { 1115 switch (id1) {
1103 case PHY_BCOM_ID1_C0: 1116 case PHY_BCOM_ID1_C0:
1104 /* 1117 /*
1105 * Workaround BCOM Errata for the C0 type. 1118 * Workaround BCOM Errata for the C0 type.
@@ -1194,13 +1207,6 @@ static void genesis_mac_init(struct skge_hw *hw, int port)
1194 xm_write16(hw, port, XM_STAT_CMD, 1207 xm_write16(hw, port, XM_STAT_CMD,
1195 XM_SC_CLR_RXC | XM_SC_CLR_TXC); 1208 XM_SC_CLR_RXC | XM_SC_CLR_TXC);
1196 1209
1197 /* initialize Rx, Tx and Link LED */
1198 skge_write8(hw, SK_REG(port, LNK_LED_REG), LINKLED_ON);
1199 skge_write8(hw, SK_REG(port, LNK_LED_REG), LINKLED_LINKSYNC_ON);
1200
1201 skge_write8(hw, SK_REG(port, RX_LED_CTRL), LED_START);
1202 skge_write8(hw, SK_REG(port, TX_LED_CTRL), LED_START);
1203
1204 /* Unreset the XMAC. */ 1210 /* Unreset the XMAC. */
1205 skge_write16(hw, SK_REG(port, TX_MFF_CTRL1), MFF_CLR_MAC_RST); 1211 skge_write16(hw, SK_REG(port, TX_MFF_CTRL1), MFF_CLR_MAC_RST);
1206 1212
@@ -1209,7 +1215,6 @@ static void genesis_mac_init(struct skge_hw *hw, int port)
1209 * namely for the 1000baseTX cards that use the XMAC's 1215 * namely for the 1000baseTX cards that use the XMAC's
1210 * GMII mode. 1216 * GMII mode.
1211 */ 1217 */
1212 spin_lock_bh(&hw->phy_lock);
1213 /* Take external Phy out of reset */ 1218 /* Take external Phy out of reset */
1214 r = skge_read32(hw, B2_GP_IO); 1219 r = skge_read32(hw, B2_GP_IO);
1215 if (port == 0) 1220 if (port == 0)
@@ -1219,7 +1224,6 @@ static void genesis_mac_init(struct skge_hw *hw, int port)
1219 1224
1220 skge_write32(hw, B2_GP_IO, r); 1225 skge_write32(hw, B2_GP_IO, r);
1221 skge_read32(hw, B2_GP_IO); 1226 skge_read32(hw, B2_GP_IO);
1222 spin_unlock_bh(&hw->phy_lock);
1223 1227
1224 /* Enable GMII interfac */ 1228 /* Enable GMII interfac */
1225 xm_write16(hw, port, XM_HW_CFG, XM_HW_GMII_MD); 1229 xm_write16(hw, port, XM_HW_CFG, XM_HW_GMII_MD);
@@ -1569,7 +1573,6 @@ static void yukon_init(struct skge_hw *hw, int port)
1569{ 1573{
1570 struct skge_port *skge = netdev_priv(hw->dev[port]); 1574 struct skge_port *skge = netdev_priv(hw->dev[port]);
1571 u16 ctrl, ct1000, adv; 1575 u16 ctrl, ct1000, adv;
1572 u16 ledctrl, ledover;
1573 1576
1574 pr_debug("yukon_init\n"); 1577 pr_debug("yukon_init\n");
1575 if (skge->autoneg == AUTONEG_ENABLE) { 1578 if (skge->autoneg == AUTONEG_ENABLE) {
@@ -1641,32 +1644,11 @@ static void yukon_init(struct skge_hw *hw, int port)
1641 gm_phy_write(hw, port, PHY_MARV_AUNE_ADV, adv); 1644 gm_phy_write(hw, port, PHY_MARV_AUNE_ADV, adv);
1642 gm_phy_write(hw, port, PHY_MARV_CTRL, ctrl); 1645 gm_phy_write(hw, port, PHY_MARV_CTRL, ctrl);
1643 1646
1644 /* Setup Phy LED's */
1645 ledctrl = PHY_M_LED_PULS_DUR(PULS_170MS);
1646 ledover = 0;
1647
1648 ledctrl |= PHY_M_LED_BLINK_RT(BLINK_84MS) | PHY_M_LEDC_TX_CTRL;
1649
1650 /* turn off the Rx LED (LED_RX) */
1651 ledover |= PHY_M_LED_MO_RX(MO_LED_OFF);
1652
1653 /* disable blink mode (LED_DUPLEX) on collisions */
1654 ctrl |= PHY_M_LEDC_DP_CTRL;
1655 gm_phy_write(hw, port, PHY_MARV_LED_CTRL, ledctrl);
1656
1657 if (skge->autoneg == AUTONEG_DISABLE || skge->speed == SPEED_100) {
1658 /* turn on 100 Mbps LED (LED_LINK100) */
1659 ledover |= PHY_M_LED_MO_100(MO_LED_ON);
1660 }
1661
1662 if (ledover)
1663 gm_phy_write(hw, port, PHY_MARV_LED_OVER, ledover);
1664
1665 /* Enable phy interrupt on autonegotiation complete (or link up) */ 1647 /* Enable phy interrupt on autonegotiation complete (or link up) */
1666 if (skge->autoneg == AUTONEG_ENABLE) 1648 if (skge->autoneg == AUTONEG_ENABLE)
1667 gm_phy_write(hw, port, PHY_MARV_INT_MASK, PHY_M_IS_AN_COMPL); 1649 gm_phy_write(hw, port, PHY_MARV_INT_MASK, PHY_M_IS_AN_MSK);
1668 else 1650 else
1669 gm_phy_write(hw, port, PHY_MARV_INT_MASK, PHY_M_DEF_MSK); 1651 gm_phy_write(hw, port, PHY_MARV_INT_MASK, PHY_M_IS_DEF_MSK);
1670} 1652}
1671 1653
1672static void yukon_reset(struct skge_hw *hw, int port) 1654static void yukon_reset(struct skge_hw *hw, int port)
@@ -1691,7 +1673,7 @@ static void yukon_mac_init(struct skge_hw *hw, int port)
1691 1673
1692 /* WA code for COMA mode -- set PHY reset */ 1674 /* WA code for COMA mode -- set PHY reset */
1693 if (hw->chip_id == CHIP_ID_YUKON_LITE && 1675 if (hw->chip_id == CHIP_ID_YUKON_LITE &&
1694 hw->chip_rev == CHIP_REV_YU_LITE_A3) 1676 hw->chip_rev >= CHIP_REV_YU_LITE_A3)
1695 skge_write32(hw, B2_GP_IO, 1677 skge_write32(hw, B2_GP_IO,
1696 (skge_read32(hw, B2_GP_IO) | GP_DIR_9 | GP_IO_9)); 1678 (skge_read32(hw, B2_GP_IO) | GP_DIR_9 | GP_IO_9));
1697 1679
@@ -1701,7 +1683,7 @@ static void yukon_mac_init(struct skge_hw *hw, int port)
1701 1683
1702 /* WA code for COMA mode -- clear PHY reset */ 1684 /* WA code for COMA mode -- clear PHY reset */
1703 if (hw->chip_id == CHIP_ID_YUKON_LITE && 1685 if (hw->chip_id == CHIP_ID_YUKON_LITE &&
1704 hw->chip_rev == CHIP_REV_YU_LITE_A3) 1686 hw->chip_rev >= CHIP_REV_YU_LITE_A3)
1705 skge_write32(hw, B2_GP_IO, 1687 skge_write32(hw, B2_GP_IO,
1706 (skge_read32(hw, B2_GP_IO) | GP_DIR_9) 1688 (skge_read32(hw, B2_GP_IO) | GP_DIR_9)
1707 & ~GP_IO_9); 1689 & ~GP_IO_9);
@@ -1745,9 +1727,7 @@ static void yukon_mac_init(struct skge_hw *hw, int port)
1745 gma_write16(hw, port, GM_GP_CTRL, reg); 1727 gma_write16(hw, port, GM_GP_CTRL, reg);
1746 skge_read16(hw, GMAC_IRQ_SRC); 1728 skge_read16(hw, GMAC_IRQ_SRC);
1747 1729
1748 spin_lock_bh(&hw->phy_lock);
1749 yukon_init(hw, port); 1730 yukon_init(hw, port);
1750 spin_unlock_bh(&hw->phy_lock);
1751 1731
1752 /* MIB clear */ 1732 /* MIB clear */
1753 reg = gma_read16(hw, port, GM_PHY_ADDR); 1733 reg = gma_read16(hw, port, GM_PHY_ADDR);
@@ -1796,7 +1776,7 @@ static void yukon_mac_init(struct skge_hw *hw, int port)
1796 skge_write16(hw, SK_REG(port, RX_GMF_FL_MSK), RX_FF_FL_DEF_MSK); 1776 skge_write16(hw, SK_REG(port, RX_GMF_FL_MSK), RX_FF_FL_DEF_MSK);
1797 reg = GMF_OPER_ON | GMF_RX_F_FL_ON; 1777 reg = GMF_OPER_ON | GMF_RX_F_FL_ON;
1798 if (hw->chip_id == CHIP_ID_YUKON_LITE && 1778 if (hw->chip_id == CHIP_ID_YUKON_LITE &&
1799 hw->chip_rev == CHIP_REV_YU_LITE_A3) 1779 hw->chip_rev >= CHIP_REV_YU_LITE_A3)
1800 reg &= ~GMF_RX_F_FL_ON; 1780 reg &= ~GMF_RX_F_FL_ON;
1801 skge_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_CLR); 1781 skge_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_CLR);
1802 skge_write16(hw, SK_REG(port, RX_GMF_CTRL_T), reg); 1782 skge_write16(hw, SK_REG(port, RX_GMF_CTRL_T), reg);
@@ -1813,19 +1793,19 @@ static void yukon_stop(struct skge_port *skge)
1813 int port = skge->port; 1793 int port = skge->port;
1814 1794
1815 if (hw->chip_id == CHIP_ID_YUKON_LITE && 1795 if (hw->chip_id == CHIP_ID_YUKON_LITE &&
1816 hw->chip_rev == CHIP_REV_YU_LITE_A3) { 1796 hw->chip_rev >= CHIP_REV_YU_LITE_A3) {
1817 skge_write32(hw, B2_GP_IO, 1797 skge_write32(hw, B2_GP_IO,
1818 skge_read32(hw, B2_GP_IO) | GP_DIR_9 | GP_IO_9); 1798 skge_read32(hw, B2_GP_IO) | GP_DIR_9 | GP_IO_9);
1819 } 1799 }
1820 1800
1821 gma_write16(hw, port, GM_GP_CTRL, 1801 gma_write16(hw, port, GM_GP_CTRL,
1822 gma_read16(hw, port, GM_GP_CTRL) 1802 gma_read16(hw, port, GM_GP_CTRL)
1823 & ~(GM_GPCR_RX_ENA|GM_GPCR_RX_ENA)); 1803 & ~(GM_GPCR_TX_ENA|GM_GPCR_RX_ENA));
1824 gma_read16(hw, port, GM_GP_CTRL); 1804 gma_read16(hw, port, GM_GP_CTRL);
1825 1805
1826 /* set GPHY Control reset */ 1806 /* set GPHY Control reset */
1827 gma_write32(hw, port, GPHY_CTRL, GPC_RST_SET); 1807 skge_write32(hw, SK_REG(port, GPHY_CTRL), GPC_RST_SET);
1828 gma_write32(hw, port, GMAC_CTRL, GMC_RST_SET); 1808 skge_write32(hw, SK_REG(port, GMAC_CTRL), GMC_RST_SET);
1829} 1809}
1830 1810
1831static void yukon_get_stats(struct skge_port *skge, u64 *data) 1811static void yukon_get_stats(struct skge_port *skge, u64 *data)
@@ -1856,11 +1836,12 @@ static void yukon_mac_intr(struct skge_hw *hw, int port)
1856 1836
1857 if (status & GM_IS_RX_FF_OR) { 1837 if (status & GM_IS_RX_FF_OR) {
1858 ++skge->net_stats.rx_fifo_errors; 1838 ++skge->net_stats.rx_fifo_errors;
1859 gma_write8(hw, port, RX_GMF_CTRL_T, GMF_CLI_RX_FO); 1839 skge_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_CLI_RX_FO);
1860 } 1840 }
1841
1861 if (status & GM_IS_TX_FF_UR) { 1842 if (status & GM_IS_TX_FF_UR) {
1862 ++skge->net_stats.tx_fifo_errors; 1843 ++skge->net_stats.tx_fifo_errors;
1863 gma_write8(hw, port, TX_GMF_CTRL_T, GMF_CLI_TX_FU); 1844 skge_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_CLI_TX_FU);
1864 } 1845 }
1865 1846
1866} 1847}
@@ -1896,7 +1877,7 @@ static void yukon_link_up(struct skge_port *skge)
1896 reg |= GM_GPCR_RX_ENA | GM_GPCR_TX_ENA; 1877 reg |= GM_GPCR_RX_ENA | GM_GPCR_TX_ENA;
1897 gma_write16(hw, port, GM_GP_CTRL, reg); 1878 gma_write16(hw, port, GM_GP_CTRL, reg);
1898 1879
1899 gm_phy_write(hw, port, PHY_MARV_INT_MASK, PHY_M_DEF_MSK); 1880 gm_phy_write(hw, port, PHY_MARV_INT_MASK, PHY_M_IS_DEF_MSK);
1900 skge_link_up(skge); 1881 skge_link_up(skge);
1901} 1882}
1902 1883
@@ -1904,12 +1885,14 @@ static void yukon_link_down(struct skge_port *skge)
1904{ 1885{
1905 struct skge_hw *hw = skge->hw; 1886 struct skge_hw *hw = skge->hw;
1906 int port = skge->port; 1887 int port = skge->port;
1888 u16 ctrl;
1907 1889
1908 pr_debug("yukon_link_down\n"); 1890 pr_debug("yukon_link_down\n");
1909 gm_phy_write(hw, port, PHY_MARV_INT_MASK, 0); 1891 gm_phy_write(hw, port, PHY_MARV_INT_MASK, 0);
1910 gm_phy_write(hw, port, GM_GP_CTRL, 1892
1911 gm_phy_read(hw, port, GM_GP_CTRL) 1893 ctrl = gma_read16(hw, port, GM_GP_CTRL);
1912 & ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA)); 1894 ctrl &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA);
1895 gma_write16(hw, port, GM_GP_CTRL, ctrl);
1913 1896
1914 if (skge->flow_control == FLOW_MODE_REM_SEND) { 1897 if (skge->flow_control == FLOW_MODE_REM_SEND) {
1915 /* restore Asymmetric Pause bit */ 1898 /* restore Asymmetric Pause bit */
@@ -2097,10 +2080,12 @@ static int skge_up(struct net_device *dev)
2097 skge_write32(hw, B0_IMSK, hw->intr_mask); 2080 skge_write32(hw, B0_IMSK, hw->intr_mask);
2098 2081
2099 /* Initialze MAC */ 2082 /* Initialze MAC */
2083 spin_lock_bh(&hw->phy_lock);
2100 if (hw->chip_id == CHIP_ID_GENESIS) 2084 if (hw->chip_id == CHIP_ID_GENESIS)
2101 genesis_mac_init(hw, port); 2085 genesis_mac_init(hw, port);
2102 else 2086 else
2103 yukon_mac_init(hw, port); 2087 yukon_mac_init(hw, port);
2088 spin_unlock_bh(&hw->phy_lock);
2104 2089
2105 /* Configure RAMbuffers */ 2090 /* Configure RAMbuffers */
2106 chunk = hw->ram_size / ((hw->ports + 1)*2); 2091 chunk = hw->ram_size / ((hw->ports + 1)*2);
@@ -2116,6 +2101,7 @@ static int skge_up(struct net_device *dev)
2116 /* Start receiver BMU */ 2101 /* Start receiver BMU */
2117 wmb(); 2102 wmb();
2118 skge_write8(hw, Q_ADDR(rxqaddr[port], Q_CSR), CSR_START | CSR_IRQ_CL_F); 2103 skge_write8(hw, Q_ADDR(rxqaddr[port], Q_CSR), CSR_START | CSR_IRQ_CL_F);
2104 skge_led(skge, LED_MODE_ON);
2119 2105
2120 pr_debug("skge_up completed\n"); 2106 pr_debug("skge_up completed\n");
2121 return 0; 2107 return 0;
@@ -2140,8 +2126,6 @@ static int skge_down(struct net_device *dev)
2140 2126
2141 netif_stop_queue(dev); 2127 netif_stop_queue(dev);
2142 2128
2143 del_timer_sync(&skge->led_blink);
2144
2145 /* Stop transmitter */ 2129 /* Stop transmitter */
2146 skge_write8(hw, Q_ADDR(txqaddr[port], Q_CSR), CSR_STOP); 2130 skge_write8(hw, Q_ADDR(txqaddr[port], Q_CSR), CSR_STOP);
2147 skge_write32(hw, RB_ADDR(txqaddr[port], RB_CTRL), 2131 skge_write32(hw, RB_ADDR(txqaddr[port], RB_CTRL),
@@ -2175,15 +2159,12 @@ static int skge_down(struct net_device *dev)
2175 if (hw->chip_id == CHIP_ID_GENESIS) { 2159 if (hw->chip_id == CHIP_ID_GENESIS) {
2176 skge_write8(hw, SK_REG(port, TX_MFF_CTRL2), MFF_RST_SET); 2160 skge_write8(hw, SK_REG(port, TX_MFF_CTRL2), MFF_RST_SET);
2177 skge_write8(hw, SK_REG(port, RX_MFF_CTRL2), MFF_RST_SET); 2161 skge_write8(hw, SK_REG(port, RX_MFF_CTRL2), MFF_RST_SET);
2178 skge_write8(hw, SK_REG(port, TX_LED_CTRL), LED_STOP);
2179 skge_write8(hw, SK_REG(port, RX_LED_CTRL), LED_STOP);
2180 } else { 2162 } else {
2181 skge_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_SET); 2163 skge_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_SET);
2182 skge_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_RST_SET); 2164 skge_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_RST_SET);
2183 } 2165 }
2184 2166
2185 /* turn off led's */ 2167 skge_led(skge, LED_MODE_OFF);
2186 skge_write16(hw, B0_LED, LED_STAT_OFF);
2187 2168
2188 skge_tx_clean(skge); 2169 skge_tx_clean(skge);
2189 skge_rx_clean(skge); 2170 skge_rx_clean(skge);
@@ -2633,11 +2614,17 @@ static inline void skge_tx_intr(struct net_device *dev)
2633 spin_unlock(&skge->tx_lock); 2614 spin_unlock(&skge->tx_lock);
2634} 2615}
2635 2616
2617/* Parity errors seem to happen when Genesis is connected to a switch
2618 * with no other ports present. Heartbeat error??
2619 */
2636static void skge_mac_parity(struct skge_hw *hw, int port) 2620static void skge_mac_parity(struct skge_hw *hw, int port)
2637{ 2621{
2638 printk(KERN_ERR PFX "%s: mac data parity error\n", 2622 struct net_device *dev = hw->dev[port];
2639 hw->dev[port] ? hw->dev[port]->name 2623
2640 : (port == 0 ? "(port A)": "(port B")); 2624 if (dev) {
2625 struct skge_port *skge = netdev_priv(dev);
2626 ++skge->net_stats.tx_heartbeat_errors;
2627 }
2641 2628
2642 if (hw->chip_id == CHIP_ID_GENESIS) 2629 if (hw->chip_id == CHIP_ID_GENESIS)
2643 skge_write16(hw, SK_REG(port, TX_MFF_CTRL1), 2630 skge_write16(hw, SK_REG(port, TX_MFF_CTRL1),
@@ -3083,10 +3070,6 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port,
3083 3070
3084 spin_lock_init(&skge->tx_lock); 3071 spin_lock_init(&skge->tx_lock);
3085 3072
3086 init_timer(&skge->led_blink);
3087 skge->led_blink.function = skge_blink_timer;
3088 skge->led_blink.data = (unsigned long) skge;
3089
3090 if (hw->chip_id != CHIP_ID_GENESIS) { 3073 if (hw->chip_id != CHIP_ID_GENESIS) {
3091 dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG; 3074 dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG;
3092 skge->rx_csum = 1; 3075 skge->rx_csum = 1;
diff --git a/drivers/net/skge.h b/drivers/net/skge.h
index fced3d2bc072..b432f1bb8168 100644
--- a/drivers/net/skge.h
+++ b/drivers/net/skge.h
@@ -1449,10 +1449,12 @@ enum {
1449 PHY_M_IS_DTE_CHANGE = 1<<2, /* DTE Power Det. Status Changed */ 1449 PHY_M_IS_DTE_CHANGE = 1<<2, /* DTE Power Det. Status Changed */
1450 PHY_M_IS_POL_CHANGE = 1<<1, /* Polarity Changed */ 1450 PHY_M_IS_POL_CHANGE = 1<<1, /* Polarity Changed */
1451 PHY_M_IS_JABBER = 1<<0, /* Jabber */ 1451 PHY_M_IS_JABBER = 1<<0, /* Jabber */
1452};
1453 1452
1454#define PHY_M_DEF_MSK ( PHY_M_IS_AN_ERROR | PHY_M_IS_LSP_CHANGE | \ 1453 PHY_M_IS_DEF_MSK = PHY_M_IS_AN_ERROR | PHY_M_IS_LSP_CHANGE |
1455 PHY_M_IS_LST_CHANGE | PHY_M_IS_FIFO_ERROR) 1454 PHY_M_IS_LST_CHANGE | PHY_M_IS_FIFO_ERROR,
1455
1456 PHY_M_IS_AN_MSK = PHY_M_IS_AN_ERROR | PHY_M_IS_AN_COMPL,
1457};
1456 1458
1457/***** PHY_MARV_EXT_CTRL 16 bit r/w Ext. PHY Specific Ctrl *****/ 1459/***** PHY_MARV_EXT_CTRL 16 bit r/w Ext. PHY Specific Ctrl *****/
1458enum { 1460enum {
@@ -1509,7 +1511,7 @@ enum {
1509 PHY_M_LEDC_TX_C_MSB = 1<<0, /* Tx Control (MSB, 88E1111 only) */ 1511 PHY_M_LEDC_TX_C_MSB = 1<<0, /* Tx Control (MSB, 88E1111 only) */
1510}; 1512};
1511 1513
1512#define PHY_M_LED_PULS_DUR(x) ( ((x)<<12) & PHY_M_LEDC_PULS_MSK) 1514#define PHY_M_LED_PULS_DUR(x) (((x)<<12) & PHY_M_LEDC_PULS_MSK)
1513 1515
1514enum { 1516enum {
1515 PULS_NO_STR = 0,/* no pulse stretching */ 1517 PULS_NO_STR = 0,/* no pulse stretching */
@@ -1522,7 +1524,7 @@ enum {
1522 PULS_1300MS = 7,/* 1.3 s to 2.7 s */ 1524 PULS_1300MS = 7,/* 1.3 s to 2.7 s */
1523}; 1525};
1524 1526
1525#define PHY_M_LED_BLINK_RT(x) ( ((x)<<8) & PHY_M_LEDC_BL_R_MSK) 1527#define PHY_M_LED_BLINK_RT(x) (((x)<<8) & PHY_M_LEDC_BL_R_MSK)
1526 1528
1527enum { 1529enum {
1528 BLINK_42MS = 0,/* 42 ms */ 1530 BLINK_42MS = 0,/* 42 ms */
@@ -1602,9 +1604,9 @@ enum {
1602 PHY_M_FELP_LED0_MSK = 0xf, /* Bit 3.. 0: LED0 Mask (SPEED) */ 1604 PHY_M_FELP_LED0_MSK = 0xf, /* Bit 3.. 0: LED0 Mask (SPEED) */
1603}; 1605};
1604 1606
1605#define PHY_M_FELP_LED2_CTRL(x) ( ((x)<<8) & PHY_M_FELP_LED2_MSK) 1607#define PHY_M_FELP_LED2_CTRL(x) (((x)<<8) & PHY_M_FELP_LED2_MSK)
1606#define PHY_M_FELP_LED1_CTRL(x) ( ((x)<<4) & PHY_M_FELP_LED1_MSK) 1608#define PHY_M_FELP_LED1_CTRL(x) (((x)<<4) & PHY_M_FELP_LED1_MSK)
1607#define PHY_M_FELP_LED0_CTRL(x) ( ((x)<<0) & PHY_M_FELP_LED0_MSK) 1609#define PHY_M_FELP_LED0_CTRL(x) (((x)<<0) & PHY_M_FELP_LED0_MSK)
1608 1610
1609enum { 1611enum {
1610 LED_PAR_CTRL_COLX = 0x00, 1612 LED_PAR_CTRL_COLX = 0x00,
@@ -1640,7 +1642,7 @@ enum {
1640 PHY_M_MAC_MD_COPPER = 5,/* Copper only */ 1642 PHY_M_MAC_MD_COPPER = 5,/* Copper only */
1641 PHY_M_MAC_MD_1000BX = 7,/* 1000Base-X only */ 1643 PHY_M_MAC_MD_1000BX = 7,/* 1000Base-X only */
1642}; 1644};
1643#define PHY_M_MAC_MODE_SEL(x) ( ((x)<<7) & PHY_M_MAC_MD_MSK) 1645#define PHY_M_MAC_MODE_SEL(x) (((x)<<7) & PHY_M_MAC_MD_MSK)
1644 1646
1645/***** PHY_MARV_PHY_CTRL (page 3) 16 bit r/w LED Control Reg. *****/ 1647/***** PHY_MARV_PHY_CTRL (page 3) 16 bit r/w LED Control Reg. *****/
1646enum { 1648enum {
@@ -1650,10 +1652,10 @@ enum {
1650 PHY_M_LEDC_STA0_MSK = 0xf, /* Bit 3.. 0: STAT0 LED Ctrl. Mask */ 1652 PHY_M_LEDC_STA0_MSK = 0xf, /* Bit 3.. 0: STAT0 LED Ctrl. Mask */
1651}; 1653};
1652 1654
1653#define PHY_M_LEDC_LOS_CTRL(x) ( ((x)<<12) & PHY_M_LEDC_LOS_MSK) 1655#define PHY_M_LEDC_LOS_CTRL(x) (((x)<<12) & PHY_M_LEDC_LOS_MSK)
1654#define PHY_M_LEDC_INIT_CTRL(x) ( ((x)<<8) & PHY_M_LEDC_INIT_MSK) 1656#define PHY_M_LEDC_INIT_CTRL(x) (((x)<<8) & PHY_M_LEDC_INIT_MSK)
1655#define PHY_M_LEDC_STA1_CTRL(x) ( ((x)<<4) & PHY_M_LEDC_STA1_MSK) 1657#define PHY_M_LEDC_STA1_CTRL(x) (((x)<<4) & PHY_M_LEDC_STA1_MSK)
1656#define PHY_M_LEDC_STA0_CTRL(x) ( ((x)<<0) & PHY_M_LEDC_STA0_MSK) 1658#define PHY_M_LEDC_STA0_CTRL(x) (((x)<<0) & PHY_M_LEDC_STA0_MSK)
1657 1659
1658/* GMAC registers */ 1660/* GMAC registers */
1659/* Port Registers */ 1661/* Port Registers */
@@ -2505,8 +2507,6 @@ struct skge_port {
2505 dma_addr_t dma; 2507 dma_addr_t dma;
2506 unsigned long mem_size; 2508 unsigned long mem_size;
2507 unsigned int rx_buf_size; 2509 unsigned int rx_buf_size;
2508
2509 struct timer_list led_blink;
2510}; 2510};
2511 2511
2512 2512
@@ -2606,17 +2606,6 @@ static inline void gma_write16(const struct skge_hw *hw, int port, int r, u16 v)
2606 skge_write16(hw, SK_GMAC_REG(port,r), v); 2606 skge_write16(hw, SK_GMAC_REG(port,r), v);
2607} 2607}
2608 2608
2609static inline void gma_write32(const struct skge_hw *hw, int port, int r, u32 v)
2610{
2611 skge_write16(hw, SK_GMAC_REG(port, r), (u16) v);
2612 skge_write32(hw, SK_GMAC_REG(port, r+4), (u16)(v >> 16));
2613}
2614
2615static inline void gma_write8(const struct skge_hw *hw, int port, int r, u8 v)
2616{
2617 skge_write8(hw, SK_GMAC_REG(port,r), v);
2618}
2619
2620static inline void gma_set_addr(struct skge_hw *hw, int port, int reg, 2609static inline void gma_set_addr(struct skge_hw *hw, int port, int reg,
2621 const u8 *addr) 2610 const u8 *addr)
2622{ 2611{
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h
index 7089d86e857a..a9b06b8d8e3f 100644
--- a/drivers/net/smc91x.h
+++ b/drivers/net/smc91x.h
@@ -188,7 +188,7 @@ SMC_outw(u16 val, void __iomem *ioaddr, int reg)
188#define SMC_IRQ_TRIGGER_TYPE (( \ 188#define SMC_IRQ_TRIGGER_TYPE (( \
189 machine_is_omap_h2() \ 189 machine_is_omap_h2() \
190 || machine_is_omap_h3() \ 190 || machine_is_omap_h3() \
191 || (machine_is_omap_innovator() && !cpu_is_omap150()) \ 191 || (machine_is_omap_innovator() && !cpu_is_omap1510()) \
192 ) ? IRQT_FALLING : IRQT_RISING) 192 ) ? IRQT_FALLING : IRQT_RISING)
193 193
194 194
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index fedae89d8f7d..fb9a11243d2a 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -60,7 +60,9 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
60 continue; 60 continue;
61 61
62 /* Ok, try it out.. */ 62 /* Ok, try it out.. */
63 ret = allocate_resource(r, res, size, min, -1, align, 63 ret = allocate_resource(r, res, size,
64 r->start ? : min,
65 -1, align,
64 alignf, alignf_data); 66 alignf, alignf_data);
65 if (ret == 0) 67 if (ret == 0)
66 break; 68 break;
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index d63f22a5bf7e..43da2e92d50f 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -589,8 +589,8 @@ static void pcmcia_delayed_add_pseudo_device(void *data)
589static inline void pcmcia_add_pseudo_device(struct pcmcia_socket *s) 589static inline void pcmcia_add_pseudo_device(struct pcmcia_socket *s)
590{ 590{
591 if (!s->pcmcia_state.device_add_pending) { 591 if (!s->pcmcia_state.device_add_pending) {
592 schedule_work(&s->device_add);
593 s->pcmcia_state.device_add_pending = 1; 592 s->pcmcia_state.device_add_pending = 1;
593 schedule_work(&s->device_add);
594 } 594 }
595 return; 595 return;
596} 596}
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
index 744e469a9eda..91e7457d5b04 100644
--- a/drivers/pcmcia/yenta_socket.c
+++ b/drivers/pcmcia/yenta_socket.c
@@ -642,6 +642,7 @@ static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned typ
642 (yenta_search_res(socket, res, BRIDGE_IO_MIN))) { 642 (yenta_search_res(socket, res, BRIDGE_IO_MIN))) {
643 config_writel(socket, addr_start, res->start); 643 config_writel(socket, addr_start, res->start);
644 config_writel(socket, addr_end, res->end); 644 config_writel(socket, addr_end, res->end);
645 return;
645 } 646 }
646 } else { 647 } else {
647 if (type & IORESOURCE_PREFETCH) { 648 if (type & IORESOURCE_PREFETCH) {
@@ -650,6 +651,7 @@ static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned typ
650 (yenta_search_res(socket, res, BRIDGE_MEM_MIN))) { 651 (yenta_search_res(socket, res, BRIDGE_MEM_MIN))) {
651 config_writel(socket, addr_start, res->start); 652 config_writel(socket, addr_start, res->start);
652 config_writel(socket, addr_end, res->end); 653 config_writel(socket, addr_end, res->end);
654 return;
653 } 655 }
654 /* Approximating prefetchable by non-prefetchable */ 656 /* Approximating prefetchable by non-prefetchable */
655 res->flags = IORESOURCE_MEM; 657 res->flags = IORESOURCE_MEM;
@@ -659,6 +661,7 @@ static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned typ
659 (yenta_search_res(socket, res, BRIDGE_MEM_MIN))) { 661 (yenta_search_res(socket, res, BRIDGE_MEM_MIN))) {
660 config_writel(socket, addr_start, res->start); 662 config_writel(socket, addr_start, res->start);
661 config_writel(socket, addr_end, res->end); 663 config_writel(socket, addr_end, res->end);
664 return;
662 } 665 }
663 } 666 }
664 667
@@ -1107,8 +1110,6 @@ static int yenta_dev_suspend (struct pci_dev *dev, pm_message_t state)
1107 pci_read_config_dword(dev, 17*4, &socket->saved_state[1]); 1110 pci_read_config_dword(dev, 17*4, &socket->saved_state[1]);
1108 pci_disable_device(dev); 1111 pci_disable_device(dev);
1109 1112
1110 free_irq(dev->irq, socket);
1111
1112 /* 1113 /*
1113 * Some laptops (IBM T22) do not like us putting the Cardbus 1114 * Some laptops (IBM T22) do not like us putting the Cardbus
1114 * bridge into D3. At a guess, some other laptop will 1115 * bridge into D3. At a guess, some other laptop will
@@ -1134,13 +1135,6 @@ static int yenta_dev_resume (struct pci_dev *dev)
1134 pci_enable_device(dev); 1135 pci_enable_device(dev);
1135 pci_set_master(dev); 1136 pci_set_master(dev);
1136 1137
1137 if (socket->cb_irq)
1138 if (request_irq(socket->cb_irq, yenta_interrupt,
1139 SA_SHIRQ, "yenta", socket)) {
1140 printk(KERN_WARNING "Yenta: request_irq() failed on resume!\n");
1141 socket->cb_irq = 0;
1142 }
1143
1144 if (socket->type && socket->type->restore_state) 1138 if (socket->type && socket->type->restore_state)
1145 socket->type->restore_state(socket); 1139 socket->type->restore_state(socket);
1146 } 1140 }
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 96df148ed969..f1e8c4223ed1 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -424,7 +424,7 @@ config SCSI_IN2000
424source "drivers/scsi/megaraid/Kconfig.megaraid" 424source "drivers/scsi/megaraid/Kconfig.megaraid"
425 425
426config SCSI_SATA 426config SCSI_SATA
427 bool "Serial ATA (SATA) support" 427 tristate "Serial ATA (SATA) support"
428 depends on SCSI 428 depends on SCSI
429 help 429 help
430 This driver family supports Serial ATA host controllers 430 This driver family supports Serial ATA host controllers
diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
index 3a11a536c0da..4ab07861b457 100644
--- a/drivers/scsi/aacraid/aacraid.h
+++ b/drivers/scsi/aacraid/aacraid.h
@@ -15,11 +15,7 @@
15#define AAC_MAX_LUN (8) 15#define AAC_MAX_LUN (8)
16 16
17#define AAC_MAX_HOSTPHYSMEMPAGES (0xfffff) 17#define AAC_MAX_HOSTPHYSMEMPAGES (0xfffff)
18/* 18#define AAC_MAX_32BIT_SGBCOUNT ((unsigned short)512)
19 * max_sectors is an unsigned short, otherwise limit is 0x100000000 / 512
20 * Linux has starvation problems if we permit larger than 4MB I/O ...
21 */
22#define AAC_MAX_32BIT_SGBCOUNT ((unsigned short)8192)
23 19
24/* 20/*
25 * These macros convert from physical channels to virtual channels 21 * These macros convert from physical channels to virtual channels
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index c1a4f978fcba..562da90480a1 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -374,7 +374,8 @@ static int aac_slave_configure(struct scsi_device *sdev)
374 else 374 else
375 scsi_adjust_queue_depth(sdev, 0, 1); 375 scsi_adjust_queue_depth(sdev, 0, 1);
376 376
377 if (host->max_sectors < AAC_MAX_32BIT_SGBCOUNT) 377 if (!(((struct aac_dev *)host->hostdata)->adapter_info.options
378 & AAC_OPT_NEW_COMM))
378 blk_queue_max_segment_size(sdev->request_queue, 65536); 379 blk_queue_max_segment_size(sdev->request_queue, 65536);
379 380
380 return 0; 381 return 0;
diff --git a/drivers/scsi/aic7xxx/aicasm/aicasm.c b/drivers/scsi/aic7xxx/aicasm/aicasm.c
index c34639481904..f936b691232f 100644
--- a/drivers/scsi/aic7xxx/aicasm/aicasm.c
+++ b/drivers/scsi/aic7xxx/aicasm/aicasm.c
@@ -369,7 +369,7 @@ output_code()
369 369
370 fprintf(ofile, "%s\t0x%02x, 0x%02x, 0x%02x, 0x%02x", 370 fprintf(ofile, "%s\t0x%02x, 0x%02x, 0x%02x, 0x%02x",
371 cur_instr == STAILQ_FIRST(&seq_program) ? "" : ",\n", 371 cur_instr == STAILQ_FIRST(&seq_program) ? "" : ",\n",
372#if BYTE_ORDER == LITTLE_ENDIAN 372#ifdef __LITTLE_ENDIAN
373 cur_instr->format.bytes[0], 373 cur_instr->format.bytes[0],
374 cur_instr->format.bytes[1], 374 cur_instr->format.bytes[1],
375 cur_instr->format.bytes[2], 375 cur_instr->format.bytes[2],
@@ -613,7 +613,7 @@ output_listing(char *ifilename)
613 line++; 613 line++;
614 } 614 }
615 fprintf(listfile, "%03x %02x%02x%02x%02x", instrptr, 615 fprintf(listfile, "%03x %02x%02x%02x%02x", instrptr,
616#if BYTE_ORDER == LITTLE_ENDIAN 616#ifdef __LITTLE_ENDIAN
617 cur_instr->format.bytes[0], 617 cur_instr->format.bytes[0],
618 cur_instr->format.bytes[1], 618 cur_instr->format.bytes[1],
619 cur_instr->format.bytes[2], 619 cur_instr->format.bytes[2],
diff --git a/drivers/scsi/aic7xxx/aicasm/aicasm_insformat.h b/drivers/scsi/aic7xxx/aicasm/aicasm_insformat.h
index 3e80f07df49c..e64f802bbaaa 100644
--- a/drivers/scsi/aic7xxx/aicasm/aicasm_insformat.h
+++ b/drivers/scsi/aic7xxx/aicasm/aicasm_insformat.h
@@ -42,8 +42,10 @@
42 * $FreeBSD$ 42 * $FreeBSD$
43 */ 43 */
44 44
45#include <asm/byteorder.h>
46
45struct ins_format1 { 47struct ins_format1 {
46#if BYTE_ORDER == LITTLE_ENDIAN 48#ifdef __LITTLE_ENDIAN
47 uint32_t immediate : 8, 49 uint32_t immediate : 8,
48 source : 9, 50 source : 9,
49 destination : 9, 51 destination : 9,
@@ -61,7 +63,7 @@ struct ins_format1 {
61}; 63};
62 64
63struct ins_format2 { 65struct ins_format2 {
64#if BYTE_ORDER == LITTLE_ENDIAN 66#ifdef __LITTLE_ENDIAN
65 uint32_t shift_control : 8, 67 uint32_t shift_control : 8,
66 source : 9, 68 source : 9,
67 destination : 9, 69 destination : 9,
@@ -79,7 +81,7 @@ struct ins_format2 {
79}; 81};
80 82
81struct ins_format3 { 83struct ins_format3 {
82#if BYTE_ORDER == LITTLE_ENDIAN 84#ifdef __LITTLE_ENDIAN
83 uint32_t immediate : 8, 85 uint32_t immediate : 8,
84 source : 9, 86 source : 9,
85 address : 10, 87 address : 10,
diff --git a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c
index ed1d4d1ac4f7..1147b899f007 100644
--- a/drivers/video/fbsysfs.c
+++ b/drivers/video/fbsysfs.c
@@ -414,6 +414,13 @@ static ssize_t show_pan(struct class_device *class_device, char *buf)
414 fb_info->var.xoffset); 414 fb_info->var.xoffset);
415} 415}
416 416
417static ssize_t show_name(struct class_device *class_device, char *buf)
418{
419 struct fb_info *fb_info = (struct fb_info *)class_get_devdata(class_device);
420
421 return snprintf(buf, PAGE_SIZE, "%s\n", fb_info->fix.id);
422}
423
417static struct class_device_attribute class_device_attrs[] = { 424static struct class_device_attribute class_device_attrs[] = {
418 __ATTR(bits_per_pixel, S_IRUGO|S_IWUSR, show_bpp, store_bpp), 425 __ATTR(bits_per_pixel, S_IRUGO|S_IWUSR, show_bpp, store_bpp),
419 __ATTR(blank, S_IRUGO|S_IWUSR, show_blank, store_blank), 426 __ATTR(blank, S_IRUGO|S_IWUSR, show_blank, store_blank),
@@ -424,6 +431,7 @@ static struct class_device_attribute class_device_attrs[] = {
424 __ATTR(modes, S_IRUGO|S_IWUSR, show_modes, store_modes), 431 __ATTR(modes, S_IRUGO|S_IWUSR, show_modes, store_modes),
425 __ATTR(pan, S_IRUGO|S_IWUSR, show_pan, store_pan), 432 __ATTR(pan, S_IRUGO|S_IWUSR, show_pan, store_pan),
426 __ATTR(virtual_size, S_IRUGO|S_IWUSR, show_virtual, store_virtual), 433 __ATTR(virtual_size, S_IRUGO|S_IWUSR, show_virtual, store_virtual),
434 __ATTR(name, S_IRUGO, show_name, NULL),
427}; 435};
428 436
429int fb_init_class_device(struct fb_info *fb_info) 437int fb_init_class_device(struct fb_info *fb_info)
diff --git a/drivers/video/tridentfb.c b/drivers/video/tridentfb.c
index da8004e5d03d..698ca9232e73 100644
--- a/drivers/video/tridentfb.c
+++ b/drivers/video/tridentfb.c
@@ -454,13 +454,16 @@ static struct accel_switch accel_image = {
454static void tridentfb_fillrect(struct fb_info * info, const struct fb_fillrect *fr) 454static void tridentfb_fillrect(struct fb_info * info, const struct fb_fillrect *fr)
455{ 455{
456 int bpp = info->var.bits_per_pixel; 456 int bpp = info->var.bits_per_pixel;
457 int col; 457 int col = 0;
458 458
459 switch (bpp) { 459 switch (bpp) {
460 default: 460 default:
461 case 8: col = fr->color; 461 case 8: col |= fr->color;
462 col |= col << 8;
463 col |= col << 16;
462 break; 464 break;
463 case 16: col = ((u32 *)(info->pseudo_palette))[fr->color]; 465 case 16: col = ((u32 *)(info->pseudo_palette))[fr->color];
466
464 break; 467 break;
465 case 32: col = ((u32 *)(info->pseudo_palette))[fr->color]; 468 case 32: col = ((u32 *)(info->pseudo_palette))[fr->color];
466 break; 469 break;
@@ -882,8 +885,9 @@ static int tridentfb_set_par(struct fb_info *info)
882 885
883 write3X4(GraphEngReg, 0x80); //enable GE for text acceleration 886 write3X4(GraphEngReg, 0x80); //enable GE for text acceleration
884 887
885// if (info->var.accel_flags & FB_ACCELF_TEXT) 888#ifdef CONFIG_FB_TRIDENT_ACCEL
886//FIXME acc->init_accel(info->var.xres,bpp); 889 acc->init_accel(info->var.xres,bpp);
890#endif
887 891
888 switch (bpp) { 892 switch (bpp) {
889 case 8: tmp = 0x00; break; 893 case 8: tmp = 0x00; break;
@@ -900,7 +904,7 @@ static int tridentfb_set_par(struct fb_info *info)
900 write3X4(DRAMControl, tmp); //both IO,linear enable 904 write3X4(DRAMControl, tmp); //both IO,linear enable
901 905
902 write3X4(InterfaceSel, read3X4(InterfaceSel) | 0x40); 906 write3X4(InterfaceSel, read3X4(InterfaceSel) | 0x40);
903 write3X4(Performance,0x20); 907 write3X4(Performance,0x92);
904 write3X4(PCIReg,0x07); //MMIO & PCI read and write burst enable 908 write3X4(PCIReg,0x07); //MMIO & PCI read and write burst enable
905 909
906 /* convert from picoseconds to MHz */ 910 /* convert from picoseconds to MHz */
@@ -981,12 +985,14 @@ static int tridentfb_setcolreg(unsigned regno, unsigned red, unsigned green,
981 t_outb(green>>10,0x3C9); 985 t_outb(green>>10,0x3C9);
982 t_outb(blue>>10,0x3C9); 986 t_outb(blue>>10,0x3C9);
983 987
984 } else 988 } else if (bpp == 16) { /* RGB 565 */
985 if (bpp == 16) /* RGB 565 */ 989 u32 col;
986 ((u32*)info->pseudo_palette)[regno] = (red & 0xF800) | 990
987 ((green & 0xFC00) >> 5) | ((blue & 0xF800) >> 11); 991 col = (red & 0xF800) | ((green & 0xFC00) >> 5) |
988 else 992 ((blue & 0xF800) >> 11);
989 if (bpp == 32) /* ARGB 8888 */ 993 col |= col << 16;
994 ((u32 *)(info->pseudo_palette))[regno] = col;
995 } else if (bpp == 32) /* ARGB 8888 */
990 ((u32*)info->pseudo_palette)[regno] = 996 ((u32*)info->pseudo_palette)[regno] =
991 ((transp & 0xFF00) <<16) | 997 ((transp & 0xFF00) <<16) |
992 ((red & 0xFF00) << 8) | 998 ((red & 0xFF00) << 8) |
diff --git a/fs/hfs/bnode.c b/fs/hfs/bnode.c
index 6ad1211f84ed..a096c5a56664 100644
--- a/fs/hfs/bnode.c
+++ b/fs/hfs/bnode.c
@@ -480,6 +480,8 @@ void hfs_bnode_put(struct hfs_bnode *node)
480 return; 480 return;
481 } 481 }
482 for (i = 0; i < tree->pages_per_bnode; i++) { 482 for (i = 0; i < tree->pages_per_bnode; i++) {
483 if (!node->page[i])
484 continue;
483 mark_page_accessed(node->page[i]); 485 mark_page_accessed(node->page[i]);
484#if REF_PAGES 486#if REF_PAGES
485 put_page(node->page[i]); 487 put_page(node->page[i]);
diff --git a/fs/hfs/extent.c b/fs/hfs/extent.c
index cbc8510ad222..5ea6b3d45eaa 100644
--- a/fs/hfs/extent.c
+++ b/fs/hfs/extent.c
@@ -482,7 +482,8 @@ void hfs_file_truncate(struct inode *inode)
482 page_cache_release(page); 482 page_cache_release(page);
483 mark_inode_dirty(inode); 483 mark_inode_dirty(inode);
484 return; 484 return;
485 } 485 } else if (inode->i_size == HFS_I(inode)->phys_size)
486 return;
486 size = inode->i_size + HFS_SB(sb)->alloc_blksz - 1; 487 size = inode->i_size + HFS_SB(sb)->alloc_blksz - 1;
487 blk_cnt = size / HFS_SB(sb)->alloc_blksz; 488 blk_cnt = size / HFS_SB(sb)->alloc_blksz;
488 alloc_cnt = HFS_I(inode)->alloc_blocks; 489 alloc_cnt = HFS_I(inode)->alloc_blocks;
diff --git a/fs/hfsplus/bnode.c b/fs/hfsplus/bnode.c
index 267872e84d71..8868d3b766fd 100644
--- a/fs/hfsplus/bnode.c
+++ b/fs/hfsplus/bnode.c
@@ -643,6 +643,8 @@ void hfs_bnode_put(struct hfs_bnode *node)
643 return; 643 return;
644 } 644 }
645 for (i = 0; i < tree->pages_per_bnode; i++) { 645 for (i = 0; i < tree->pages_per_bnode; i++) {
646 if (!node->page[i])
647 continue;
646 mark_page_accessed(node->page[i]); 648 mark_page_accessed(node->page[i]);
647#if REF_PAGES 649#if REF_PAGES
648 put_page(node->page[i]); 650 put_page(node->page[i]);
diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c
index 376498cc64fd..e7235ca79a95 100644
--- a/fs/hfsplus/extents.c
+++ b/fs/hfsplus/extents.c
@@ -461,7 +461,9 @@ void hfsplus_file_truncate(struct inode *inode)
461 page_cache_release(page); 461 page_cache_release(page);
462 mark_inode_dirty(inode); 462 mark_inode_dirty(inode);
463 return; 463 return;
464 } 464 } else if (inode->i_size == HFSPLUS_I(inode).phys_size)
465 return;
466
465 blk_cnt = (inode->i_size + HFSPLUS_SB(sb).alloc_blksz - 1) >> HFSPLUS_SB(sb).alloc_blksz_shift; 467 blk_cnt = (inode->i_size + HFSPLUS_SB(sb).alloc_blksz - 1) >> HFSPLUS_SB(sb).alloc_blksz_shift;
466 alloc_cnt = HFSPLUS_I(inode).alloc_blocks; 468 alloc_cnt = HFSPLUS_I(inode).alloc_blocks;
467 if (blk_cnt == alloc_cnt) 469 if (blk_cnt == alloc_cnt)
diff --git a/fs/inotify.c b/fs/inotify.c
index a8a714e48140..27ebcac5e07f 100644
--- a/fs/inotify.c
+++ b/fs/inotify.c
@@ -90,6 +90,7 @@ struct inotify_device {
90 unsigned int queue_size; /* size of the queue (bytes) */ 90 unsigned int queue_size; /* size of the queue (bytes) */
91 unsigned int event_count; /* number of pending events */ 91 unsigned int event_count; /* number of pending events */
92 unsigned int max_events; /* maximum number of events */ 92 unsigned int max_events; /* maximum number of events */
93 u32 last_wd; /* the last wd allocated */
93}; 94};
94 95
95/* 96/*
@@ -352,7 +353,7 @@ static int inotify_dev_get_wd(struct inotify_device *dev,
352 do { 353 do {
353 if (unlikely(!idr_pre_get(&dev->idr, GFP_KERNEL))) 354 if (unlikely(!idr_pre_get(&dev->idr, GFP_KERNEL)))
354 return -ENOSPC; 355 return -ENOSPC;
355 ret = idr_get_new(&dev->idr, watch, &watch->wd); 356 ret = idr_get_new_above(&dev->idr, watch, dev->last_wd, &watch->wd);
356 } while (ret == -EAGAIN); 357 } while (ret == -EAGAIN);
357 358
358 return ret; 359 return ret;
@@ -401,6 +402,7 @@ static struct inotify_watch *create_watch(struct inotify_device *dev,
401 return ERR_PTR(ret); 402 return ERR_PTR(ret);
402 } 403 }
403 404
405 dev->last_wd = ret;
404 watch->mask = mask; 406 watch->mask = mask;
405 atomic_set(&watch->count, 0); 407 atomic_set(&watch->count, 0);
406 INIT_LIST_HEAD(&watch->d_list); 408 INIT_LIST_HEAD(&watch->d_list);
@@ -899,6 +901,7 @@ asmlinkage long sys_inotify_init(void)
899 dev->queue_size = 0; 901 dev->queue_size = 0;
900 dev->max_events = inotify_max_queued_events; 902 dev->max_events = inotify_max_queued_events;
901 dev->user = user; 903 dev->user = user;
904 dev->last_wd = 0;
902 atomic_set(&dev->count, 0); 905 atomic_set(&dev->count, 0);
903 906
904 get_inotify_dev(dev); 907 get_inotify_dev(dev);
diff --git a/fs/namei.c b/fs/namei.c
index 02a824cd3c5c..4a27eb798118 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2218,7 +2218,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
2218 error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry); 2218 error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry);
2219 if (!error) { 2219 if (!error) {
2220 const char *new_name = old_dentry->d_name.name; 2220 const char *new_name = old_dentry->d_name.name;
2221 fsnotify_move(old_dir, new_dir, old_name, new_name, is_dir); 2221 fsnotify_move(old_dir, new_dir, old_name, new_name, is_dir, new_dentry->d_inode);
2222 } 2222 }
2223 fsnotify_oldname_free(old_name); 2223 fsnotify_oldname_free(old_name);
2224 2224
diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h
index caeaa71a5663..579fe191b7e7 100644
--- a/include/acpi/acpi_drivers.h
+++ b/include/acpi/acpi_drivers.h
@@ -56,8 +56,9 @@
56/* ACPI PCI Interrupt Link (pci_link.c) */ 56/* ACPI PCI Interrupt Link (pci_link.c) */
57 57
58int acpi_irq_penalty_init (void); 58int acpi_irq_penalty_init (void);
59int acpi_pci_link_get_irq (acpi_handle handle, int index, int *edge_level, 59int acpi_pci_link_allocate_irq (acpi_handle handle, int index, int *edge_level,
60 int *active_high_low, char **name); 60 int *active_high_low, char **name);
61int acpi_pci_link_free_irq(acpi_handle handle);
61 62
62/* ACPI PCI Interrupt Routing (pci_irq.c) */ 63/* ACPI PCI Interrupt Routing (pci_irq.c) */
63 64
diff --git a/include/asm-i386/pci.h b/include/asm-i386/pci.h
index 78c85985aee3..2cbab30734d6 100644
--- a/include/asm-i386/pci.h
+++ b/include/asm-i386/pci.h
@@ -18,11 +18,9 @@ extern unsigned int pcibios_assign_all_busses(void);
18#define pcibios_scan_all_fns(a, b) 0 18#define pcibios_scan_all_fns(a, b) 0
19 19
20extern unsigned long pci_mem_start; 20extern unsigned long pci_mem_start;
21#define PCIBIOS_MIN_IO 0x1000 21#define PCIBIOS_MIN_IO 0x4000
22#define PCIBIOS_MIN_MEM (pci_mem_start) 22#define PCIBIOS_MIN_MEM (pci_mem_start)
23 23
24#define PCIBIOS_MIN_CARDBUS_IO 0x4000
25
26void pcibios_config_init(void); 24void pcibios_config_init(void);
27struct pci_bus * pcibios_scan_root(int bus); 25struct pci_bus * pcibios_scan_root(int bus);
28 26
diff --git a/include/asm-ppc/ibm44x.h b/include/asm-ppc/ibm44x.h
index 87f051138b9d..21e41c9b7267 100644
--- a/include/asm-ppc/ibm44x.h
+++ b/include/asm-ppc/ibm44x.h
@@ -35,8 +35,10 @@
35#define PPC44x_LOW_SLOT 63 35#define PPC44x_LOW_SLOT 63
36 36
37/* LS 32-bits of UART0 physical address location for early serial text debug */ 37/* LS 32-bits of UART0 physical address location for early serial text debug */
38#ifdef CONFIG_440SP 38#if defined(CONFIG_440SP)
39#define UART0_PHYS_IO_BASE 0xf0000200 39#define UART0_PHYS_IO_BASE 0xf0000200
40#elif defined(CONFIG_440EP)
41#define UART0_PHYS_IO_BASE 0xe0000000
40#else 42#else
41#define UART0_PHYS_IO_BASE 0x40000200 43#define UART0_PHYS_IO_BASE 0x40000200
42#endif 44#endif
@@ -49,11 +51,16 @@
49/* 51/*
50 * Standard 4GB "page" definitions 52 * Standard 4GB "page" definitions
51 */ 53 */
52#ifdef CONFIG_440SP 54#if defined(CONFIG_440SP)
53#define PPC44x_IO_PAGE 0x0000000100000000ULL 55#define PPC44x_IO_PAGE 0x0000000100000000ULL
54#define PPC44x_PCICFG_PAGE 0x0000000900000000ULL 56#define PPC44x_PCICFG_PAGE 0x0000000900000000ULL
55#define PPC44x_PCIIO_PAGE PPC44x_PCICFG_PAGE 57#define PPC44x_PCIIO_PAGE PPC44x_PCICFG_PAGE
56#define PPC44x_PCIMEM_PAGE 0x0000000a00000000ULL 58#define PPC44x_PCIMEM_PAGE 0x0000000a00000000ULL
59#elif defined(CONFIG_440EP)
60#define PPC44x_IO_PAGE 0x0000000000000000ULL
61#define PPC44x_PCICFG_PAGE 0x0000000000000000ULL
62#define PPC44x_PCIIO_PAGE PPC44x_PCICFG_PAGE
63#define PPC44x_PCIMEM_PAGE 0x0000000000000000ULL
57#else 64#else
58#define PPC44x_IO_PAGE 0x0000000100000000ULL 65#define PPC44x_IO_PAGE 0x0000000100000000ULL
59#define PPC44x_PCICFG_PAGE 0x0000000200000000ULL 66#define PPC44x_PCICFG_PAGE 0x0000000200000000ULL
@@ -64,7 +71,7 @@
64/* 71/*
65 * 36-bit trap ranges 72 * 36-bit trap ranges
66 */ 73 */
67#ifdef CONFIG_440SP 74#if defined(CONFIG_440SP)
68#define PPC44x_IO_LO 0xf0000000UL 75#define PPC44x_IO_LO 0xf0000000UL
69#define PPC44x_IO_HI 0xf0000fffUL 76#define PPC44x_IO_HI 0xf0000fffUL
70#define PPC44x_PCI0CFG_LO 0x0ec00000UL 77#define PPC44x_PCI0CFG_LO 0x0ec00000UL
@@ -75,6 +82,13 @@
75#define PPC44x_PCI2CFG_HI 0x2ec00007UL 82#define PPC44x_PCI2CFG_HI 0x2ec00007UL
76#define PPC44x_PCIMEM_LO 0x80000000UL 83#define PPC44x_PCIMEM_LO 0x80000000UL
77#define PPC44x_PCIMEM_HI 0xdfffffffUL 84#define PPC44x_PCIMEM_HI 0xdfffffffUL
85#elif defined(CONFIG_440EP)
86#define PPC44x_IO_LO 0xef500000UL
87#define PPC44x_IO_HI 0xefffffffUL
88#define PPC44x_PCI0CFG_LO 0xeec00000UL
89#define PPC44x_PCI0CFG_HI 0xeecfffffUL
90#define PPC44x_PCIMEM_LO 0xa0000000UL
91#define PPC44x_PCIMEM_HI 0xdfffffffUL
78#else 92#else
79#define PPC44x_IO_LO 0x40000000UL 93#define PPC44x_IO_LO 0x40000000UL
80#define PPC44x_IO_HI 0x40000fffUL 94#define PPC44x_IO_HI 0x40000fffUL
@@ -152,6 +166,12 @@
152#define DCRN_SDR_UART0 0x0120 166#define DCRN_SDR_UART0 0x0120
153#define DCRN_SDR_UART1 0x0121 167#define DCRN_SDR_UART1 0x0121
154 168
169#ifdef CONFIG_440EP
170#define DCRN_SDR_UART2 0x0122
171#define DCRN_SDR_UART3 0x0123
172#define DCRN_SDR_CUST0 0x4000
173#endif
174
155/* SDR read/write helper macros */ 175/* SDR read/write helper macros */
156#define SDR_READ(offset) ({\ 176#define SDR_READ(offset) ({\
157 mtdcr(DCRN_SDR_CONFIG_ADDR, offset); \ 177 mtdcr(DCRN_SDR_CONFIG_ADDR, offset); \
@@ -169,6 +189,14 @@
169#define DCRNCAP_DMA_SG 1 /* have DMA scatter/gather capability */ 189#define DCRNCAP_DMA_SG 1 /* have DMA scatter/gather capability */
170#define DCRN_MAL_BASE 0x180 190#define DCRN_MAL_BASE 0x180
171 191
192#ifdef CONFIG_440EP
193#define DCRN_DMA2P40_BASE 0x300
194#define DCRN_DMA2P41_BASE 0x308
195#define DCRN_DMA2P42_BASE 0x310
196#define DCRN_DMA2P43_BASE 0x318
197#define DCRN_DMA2P4SR_BASE 0x320
198#endif
199
172/* UIC */ 200/* UIC */
173#define DCRN_UIC0_BASE 0xc0 201#define DCRN_UIC0_BASE 0xc0
174#define DCRN_UIC1_BASE 0xd0 202#define DCRN_UIC1_BASE 0xd0
diff --git a/include/asm-ppc/ibm4xx.h b/include/asm-ppc/ibm4xx.h
index 35260afa33a9..e807be96e981 100644
--- a/include/asm-ppc/ibm4xx.h
+++ b/include/asm-ppc/ibm4xx.h
@@ -97,6 +97,10 @@ void ppc4xx_init(unsigned long r3, unsigned long r4, unsigned long r5,
97 97
98#elif CONFIG_44x 98#elif CONFIG_44x
99 99
100#if defined(CONFIG_BAMBOO)
101#include <platforms/4xx/bamboo.h>
102#endif
103
100#if defined(CONFIG_EBONY) 104#if defined(CONFIG_EBONY)
101#include <platforms/4xx/ebony.h> 105#include <platforms/4xx/ebony.h>
102#endif 106#endif
diff --git a/include/asm-ppc/ibm_ocp.h b/include/asm-ppc/ibm_ocp.h
index 8c61d93043af..3f7b5669e6d5 100644
--- a/include/asm-ppc/ibm_ocp.h
+++ b/include/asm-ppc/ibm_ocp.h
@@ -71,6 +71,8 @@ struct ocp_func_emac_data {
71 71
72/* Sysfs support */ 72/* Sysfs support */
73#define OCP_SYSFS_EMAC_DATA() \ 73#define OCP_SYSFS_EMAC_DATA() \
74OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, rgmii_idx) \
75OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, rgmii_mux) \
74OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, zmii_idx) \ 76OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, zmii_idx) \
75OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, zmii_mux) \ 77OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, zmii_mux) \
76OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, mal_idx) \ 78OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, mal_idx) \
@@ -78,9 +80,14 @@ OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, mal_rx_chan) \
78OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, mal_tx_chan) \ 80OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, mal_tx_chan) \
79OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, wol_irq) \ 81OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, wol_irq) \
80OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, mdio_idx) \ 82OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, mdio_idx) \
83OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, tah_idx) \
84OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, phy_mode) \
85OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "0x%08x\n", emac, phy_map) \
81 \ 86 \
82void ocp_show_emac_data(struct device *dev) \ 87void ocp_show_emac_data(struct device *dev) \
83{ \ 88{ \
89 device_create_file(dev, &dev_attr_emac_rgmii_idx); \
90 device_create_file(dev, &dev_attr_emac_rgmii_mux); \
84 device_create_file(dev, &dev_attr_emac_zmii_idx); \ 91 device_create_file(dev, &dev_attr_emac_zmii_idx); \
85 device_create_file(dev, &dev_attr_emac_zmii_mux); \ 92 device_create_file(dev, &dev_attr_emac_zmii_mux); \
86 device_create_file(dev, &dev_attr_emac_mal_idx); \ 93 device_create_file(dev, &dev_attr_emac_mal_idx); \
@@ -88,6 +95,9 @@ void ocp_show_emac_data(struct device *dev) \
88 device_create_file(dev, &dev_attr_emac_mal_tx_chan); \ 95 device_create_file(dev, &dev_attr_emac_mal_tx_chan); \
89 device_create_file(dev, &dev_attr_emac_wol_irq); \ 96 device_create_file(dev, &dev_attr_emac_wol_irq); \
90 device_create_file(dev, &dev_attr_emac_mdio_idx); \ 97 device_create_file(dev, &dev_attr_emac_mdio_idx); \
98 device_create_file(dev, &dev_attr_emac_tah_idx); \
99 device_create_file(dev, &dev_attr_emac_phy_mode); \
100 device_create_file(dev, &dev_attr_emac_phy_map); \
91} 101}
92 102
93#ifdef CONFIG_40x 103#ifdef CONFIG_40x
@@ -157,7 +167,7 @@ OCP_SYSFS_ADDTL(struct ocp_func_iic_data, "%d\n", iic, fast_mode) \
157 \ 167 \
158void ocp_show_iic_data(struct device *dev) \ 168void ocp_show_iic_data(struct device *dev) \
159{ \ 169{ \
160 device_create_file(dev, &dev_attr_iic_fast_mode); \ 170 device_create_file(dev, &dev_attr_iic_fast_mode); \
161} 171}
162#endif /* __IBM_OCP_H__ */ 172#endif /* __IBM_OCP_H__ */
163#endif /* __KERNEL__ */ 173#endif /* __KERNEL__ */
diff --git a/include/asm-ppc/ppc_asm.h b/include/asm-ppc/ppc_asm.h
index f76221def484..bb53e2def363 100644
--- a/include/asm-ppc/ppc_asm.h
+++ b/include/asm-ppc/ppc_asm.h
@@ -186,6 +186,12 @@ END_FTR_SECTION_IFCLR(CPU_FTR_601)
186#define PPC405_ERR77_SYNC 186#define PPC405_ERR77_SYNC
187#endif 187#endif
188 188
189#ifdef CONFIG_IBM440EP_ERR42
190#define PPC440EP_ERR42 isync
191#else
192#define PPC440EP_ERR42
193#endif
194
189/* The boring bits... */ 195/* The boring bits... */
190 196
191/* Condition Register Bit Fields */ 197/* Condition Register Bit Fields */
diff --git a/include/asm-ppc/unistd.h b/include/asm-ppc/unistd.h
index a7894e0fbbb1..3173ab3d2eb9 100644
--- a/include/asm-ppc/unistd.h
+++ b/include/asm-ppc/unistd.h
@@ -279,8 +279,11 @@
279#define __NR_waitid 272 279#define __NR_waitid 272
280#define __NR_ioprio_set 273 280#define __NR_ioprio_set 273
281#define __NR_ioprio_get 274 281#define __NR_ioprio_get 274
282#define __NR_inotify_init 275
283#define __NR_inotify_add_watch 276
284#define __NR_inotify_rm_watch 277
282 285
283#define __NR_syscalls 275 286#define __NR_syscalls 278
284 287
285#define __NR(n) #n 288#define __NR(n) #n
286 289
diff --git a/include/asm-ppc64/machdep.h b/include/asm-ppc64/machdep.h
index f0c1d2d92672..f0ef06375947 100644
--- a/include/asm-ppc64/machdep.h
+++ b/include/asm-ppc64/machdep.h
@@ -84,7 +84,7 @@ struct machdep_calls {
84 84
85 void (*init_IRQ)(void); 85 void (*init_IRQ)(void);
86 int (*get_irq)(struct pt_regs *); 86 int (*get_irq)(struct pt_regs *);
87 void (*cpu_irq_down)(void); 87 void (*cpu_irq_down)(int secondary);
88 88
89 /* PCI stuff */ 89 /* PCI stuff */
90 void (*pcibios_fixup)(void); 90 void (*pcibios_fixup)(void);
diff --git a/include/asm-ppc64/topology.h b/include/asm-ppc64/topology.h
index fcdcfd26a26b..1e9b19073230 100644
--- a/include/asm-ppc64/topology.h
+++ b/include/asm-ppc64/topology.h
@@ -33,6 +33,7 @@ static inline int node_to_first_cpu(int node)
33 return first_cpu(tmp); 33 return first_cpu(tmp);
34} 34}
35 35
36#define pcibus_to_node(node) (-1)
36#define pcibus_to_cpumask(bus) (cpu_online_map) 37#define pcibus_to_cpumask(bus) (cpu_online_map)
37 38
38#define nr_cpus_node(node) (nr_cpus_in_node[node]) 39#define nr_cpus_node(node) (nr_cpus_in_node[node])
@@ -59,8 +60,10 @@ static inline int node_to_first_cpu(int node)
59 .nr_balance_failed = 0, \ 60 .nr_balance_failed = 0, \
60} 61}
61 62
62#endif /* CONFIG_NUMA */ 63#else
63 64
64#include <asm-generic/topology.h> 65#include <asm-generic/topology.h>
65 66
67#endif /* CONFIG_NUMA */
68
66#endif /* _ASM_PPC64_TOPOLOGY_H */ 69#endif /* _ASM_PPC64_TOPOLOGY_H */
diff --git a/include/asm-ppc64/unistd.h b/include/asm-ppc64/unistd.h
index 4a94acf6bfed..977bc980c1af 100644
--- a/include/asm-ppc64/unistd.h
+++ b/include/asm-ppc64/unistd.h
@@ -285,8 +285,11 @@
285#define __NR_waitid 272 285#define __NR_waitid 272
286#define __NR_ioprio_set 273 286#define __NR_ioprio_set 273
287#define __NR_ioprio_get 274 287#define __NR_ioprio_get 274
288#define __NR_inotify_init 275
289#define __NR_inotify_add_watch 276
290#define __NR_inotify_rm_watch 277
288 291
289#define __NR_syscalls 275 292#define __NR_syscalls 278
290#ifdef __KERNEL__ 293#ifdef __KERNEL__
291#define NR_syscalls __NR_syscalls 294#define NR_syscalls __NR_syscalls
292#endif 295#endif
diff --git a/include/asm-ppc64/xics.h b/include/asm-ppc64/xics.h
index 0c45e14e26ca..1092af55d707 100644
--- a/include/asm-ppc64/xics.h
+++ b/include/asm-ppc64/xics.h
@@ -17,7 +17,7 @@
17void xics_init_IRQ(void); 17void xics_init_IRQ(void);
18int xics_get_irq(struct pt_regs *); 18int xics_get_irq(struct pt_regs *);
19void xics_setup_cpu(void); 19void xics_setup_cpu(void);
20void xics_teardown_cpu(void); 20void xics_teardown_cpu(int secondary);
21void xics_cause_IPI(int cpu); 21void xics_cause_IPI(int cpu);
22void xics_request_IPIs(void); 22void xics_request_IPIs(void);
23void xics_migrate_irqs_away(void); 23void xics_migrate_irqs_away(void);
diff --git a/include/asm-s390/unistd.h b/include/asm-s390/unistd.h
index 363db45f8d07..221e965da924 100644
--- a/include/asm-s390/unistd.h
+++ b/include/asm-s390/unistd.h
@@ -274,8 +274,13 @@
274#define __NR_request_key 279 274#define __NR_request_key 279
275#define __NR_keyctl 280 275#define __NR_keyctl 280
276#define __NR_waitid 281 276#define __NR_waitid 281
277#define __NR_ioprio_set 282
278#define __NR_ioprio_get 283
279#define __NR_inotify_init 284
280#define __NR_inotify_add_watch 285
281#define __NR_inotify_rm_watch 286
277 282
278#define NR_syscalls 282 283#define NR_syscalls 287
279 284
280/* 285/*
281 * There are some system calls that are not present on 64 bit, some 286 * There are some system calls that are not present on 64 bit, some
diff --git a/include/asm-x86_64/pci.h b/include/asm-x86_64/pci.h
index eeb3088a1c9e..9c4527eb55e2 100644
--- a/include/asm-x86_64/pci.h
+++ b/include/asm-x86_64/pci.h
@@ -22,11 +22,9 @@ extern unsigned int pcibios_assign_all_busses(void);
22extern int no_iommu, force_iommu; 22extern int no_iommu, force_iommu;
23 23
24extern unsigned long pci_mem_start; 24extern unsigned long pci_mem_start;
25#define PCIBIOS_MIN_IO 0x1000 25#define PCIBIOS_MIN_IO 0x4000
26#define PCIBIOS_MIN_MEM (pci_mem_start) 26#define PCIBIOS_MIN_MEM (pci_mem_start)
27 27
28#define PCIBIOS_MIN_CARDBUS_IO 0x4000
29
30void pcibios_config_init(void); 28void pcibios_config_init(void);
31struct pci_bus * pcibios_scan_root(int bus); 29struct pci_bus * pcibios_scan_root(int bus);
32extern int (*pci_config_read)(int seg, int bus, int dev, int fn, int reg, int len, u32 *value); 30extern int (*pci_config_read)(int seg, int bus, int dev, int fn, int reg, int len, u32 *value);
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index f85cbe919e13..b46a5205ee7b 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -453,9 +453,7 @@ int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
453 * If this matches the last registration, any IRQ resources for gsi 453 * If this matches the last registration, any IRQ resources for gsi
454 * are freed. 454 * are freed.
455 */ 455 */
456#ifdef CONFIG_ACPI_DEALLOCATE_IRQ
457void acpi_unregister_gsi (u32 gsi); 456void acpi_unregister_gsi (u32 gsi);
458#endif
459 457
460#ifdef CONFIG_ACPI_PCI 458#ifdef CONFIG_ACPI_PCI
461 459
@@ -480,9 +478,7 @@ struct pci_dev;
480int acpi_pci_irq_enable (struct pci_dev *dev); 478int acpi_pci_irq_enable (struct pci_dev *dev);
481void acpi_penalize_isa_irq(int irq, int active); 479void acpi_penalize_isa_irq(int irq, int active);
482 480
483#ifdef CONFIG_ACPI_DEALLOCATE_IRQ
484void acpi_pci_irq_disable (struct pci_dev *dev); 481void acpi_pci_irq_disable (struct pci_dev *dev);
485#endif
486 482
487struct acpi_pci_driver { 483struct acpi_pci_driver {
488 struct acpi_pci_driver *next; 484 struct acpi_pci_driver *next;
diff --git a/include/linux/dcookies.h b/include/linux/dcookies.h
index c28050136164..1d68428c925d 100644
--- a/include/linux/dcookies.h
+++ b/include/linux/dcookies.h
@@ -48,12 +48,12 @@ int get_dcookie(struct dentry * dentry, struct vfsmount * vfsmnt,
48 48
49#else 49#else
50 50
51struct dcookie_user * dcookie_register(void) 51static inline struct dcookie_user * dcookie_register(void)
52{ 52{
53 return NULL; 53 return NULL;
54} 54}
55 55
56void dcookie_unregister(struct dcookie_user * user) 56static inline void dcookie_unregister(struct dcookie_user * user)
57{ 57{
58 return; 58 return;
59} 59}
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index d07a92c94776..e96a4306ab3b 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -21,7 +21,7 @@
21 */ 21 */
22static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir, 22static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
23 const char *old_name, const char *new_name, 23 const char *old_name, const char *new_name,
24 int isdir) 24 int isdir, struct inode *target)
25{ 25{
26 u32 cookie = inotify_get_cookie(); 26 u32 cookie = inotify_get_cookie();
27 27
@@ -36,6 +36,11 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
36 isdir = IN_ISDIR; 36 isdir = IN_ISDIR;
37 inotify_inode_queue_event(old_dir, IN_MOVED_FROM|isdir,cookie,old_name); 37 inotify_inode_queue_event(old_dir, IN_MOVED_FROM|isdir,cookie,old_name);
38 inotify_inode_queue_event(new_dir, IN_MOVED_TO|isdir, cookie, new_name); 38 inotify_inode_queue_event(new_dir, IN_MOVED_TO|isdir, cookie, new_name);
39
40 if (target) {
41 inotify_inode_queue_event(target, IN_DELETE_SELF, 0, NULL);
42 inotify_inode_is_dead(target);
43 }
39} 44}
40 45
41/* 46/*
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 6eb7f48317f8..82d7024f0765 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -625,10 +625,16 @@ static inline int page_mapped(struct page *page)
625 * Used to decide whether a process gets delivered SIGBUS or 625 * Used to decide whether a process gets delivered SIGBUS or
626 * just gets major/minor fault counters bumped up. 626 * just gets major/minor fault counters bumped up.
627 */ 627 */
628#define VM_FAULT_OOM (-1) 628#define VM_FAULT_OOM 0x00
629#define VM_FAULT_SIGBUS 0 629#define VM_FAULT_SIGBUS 0x01
630#define VM_FAULT_MINOR 1 630#define VM_FAULT_MINOR 0x02
631#define VM_FAULT_MAJOR 2 631#define VM_FAULT_MAJOR 0x03
632
633/*
634 * Special case for get_user_pages.
635 * Must be in a distinct bit from the above VM_FAULT_ flags.
636 */
637#define VM_FAULT_WRITE 0x10
632 638
633#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK) 639#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK)
634 640
@@ -704,7 +710,13 @@ extern pte_t *FASTCALL(pte_alloc_kernel(struct mm_struct *mm, pmd_t *pmd, unsign
704extern pte_t *FASTCALL(pte_alloc_map(struct mm_struct *mm, pmd_t *pmd, unsigned long address)); 710extern pte_t *FASTCALL(pte_alloc_map(struct mm_struct *mm, pmd_t *pmd, unsigned long address));
705extern int install_page(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, struct page *page, pgprot_t prot); 711extern int install_page(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, struct page *page, pgprot_t prot);
706extern int install_file_pte(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, unsigned long pgoff, pgprot_t prot); 712extern int install_file_pte(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, unsigned long pgoff, pgprot_t prot);
707extern int handle_mm_fault(struct mm_struct *mm,struct vm_area_struct *vma, unsigned long address, int write_access); 713extern int __handle_mm_fault(struct mm_struct *mm,struct vm_area_struct *vma, unsigned long address, int write_access);
714
715static inline int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long address, int write_access)
716{
717 return __handle_mm_fault(mm, vma, address, write_access) & (~VM_FAULT_WRITE);
718}
719
708extern int make_pages_present(unsigned long addr, unsigned long end); 720extern int make_pages_present(unsigned long addr, unsigned long end);
709extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write); 721extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
710void install_arg_page(struct vm_area_struct *, struct page *, unsigned long); 722void install_arg_page(struct vm_area_struct *, struct page *, unsigned long);
diff --git a/include/linux/raid/bitmap.h b/include/linux/raid/bitmap.h
index 6213e976eade..4bf1659f8aa8 100644
--- a/include/linux/raid/bitmap.h
+++ b/include/linux/raid/bitmap.h
@@ -248,6 +248,7 @@ struct bitmap {
248 248
249/* these are used only by md/bitmap */ 249/* these are used only by md/bitmap */
250int bitmap_create(mddev_t *mddev); 250int bitmap_create(mddev_t *mddev);
251void bitmap_flush(mddev_t *mddev);
251void bitmap_destroy(mddev_t *mddev); 252void bitmap_destroy(mddev_t *mddev);
252int bitmap_active(struct bitmap *bitmap); 253int bitmap_active(struct bitmap *bitmap);
253 254
diff --git a/include/media/tuner.h b/include/media/tuner.h
index d8c0a5563289..eeaa15ddee85 100644
--- a/include/media/tuner.h
+++ b/include/media/tuner.h
@@ -1,5 +1,5 @@
1 1
2/* $Id: tuner.h,v 1.42 2005/07/06 09:42:19 mchehab Exp $ 2/* $Id: tuner.h,v 1.45 2005/07/28 18:41:21 mchehab Exp $
3 * 3 *
4 tuner.h - definition for different tuners 4 tuner.h - definition for different tuners
5 5
@@ -108,6 +108,8 @@
108 108
109#define TUNER_TEA5767 62 /* Only FM Radio Tuner */ 109#define TUNER_TEA5767 62 /* Only FM Radio Tuner */
110#define TUNER_PHILIPS_FMD1216ME_MK3 63 110#define TUNER_PHILIPS_FMD1216ME_MK3 63
111#define TUNER_LG_TDVS_H062F 64 /* DViCO FusionHDTV 5 */
112#define TUNER_YMEC_TVF66T5_B_DFF 65 /* Acorp Y878F */
111 113
112#define NOTUNER 0 114#define NOTUNER 0
113#define PAL 1 /* PAL_BG */ 115#define PAL 1 /* PAL_BG */
diff --git a/include/net/tcp.h b/include/net/tcp.h
index f4f9aba07ac2..5010f0c5a56e 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1236,7 +1236,7 @@ static inline void tcp_sync_left_out(struct tcp_sock *tp)
1236 tp->left_out = tp->sacked_out + tp->lost_out; 1236 tp->left_out = tp->sacked_out + tp->lost_out;
1237} 1237}
1238 1238
1239/* Set slow start threshould and cwnd not falling to slow start */ 1239/* Set slow start threshold and cwnd not falling to slow start */
1240static inline void __tcp_enter_cwr(struct tcp_sock *tp) 1240static inline void __tcp_enter_cwr(struct tcp_sock *tp)
1241{ 1241{
1242 tp->undo_marker = 0; 1242 tp->undo_marker = 0;
diff --git a/ipc/shm.c b/ipc/shm.c
index cce022435dbc..1d6cf08d950b 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -170,7 +170,7 @@ static struct vm_operations_struct shm_vm_ops = {
170 .open = shm_open, /* callback for a new vm-area open */ 170 .open = shm_open, /* callback for a new vm-area open */
171 .close = shm_close, /* callback for when the vm-area is released */ 171 .close = shm_close, /* callback for when the vm-area is released */
172 .nopage = shmem_nopage, 172 .nopage = shmem_nopage,
173#ifdef CONFIG_NUMA 173#if defined(CONFIG_NUMA) && defined(CONFIG_SHMEM)
174 .set_policy = shmem_set_policy, 174 .set_policy = shmem_set_policy,
175 .get_policy = shmem_get_policy, 175 .get_policy = shmem_get_policy,
176#endif 176#endif
diff --git a/kernel/module.c b/kernel/module.c
index 068e271ab3a5..c32995fbd8fd 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -250,13 +250,18 @@ static inline unsigned int block_size(int val)
250/* Created by linker magic */ 250/* Created by linker magic */
251extern char __per_cpu_start[], __per_cpu_end[]; 251extern char __per_cpu_start[], __per_cpu_end[];
252 252
253static void *percpu_modalloc(unsigned long size, unsigned long align) 253static void *percpu_modalloc(unsigned long size, unsigned long align,
254 const char *name)
254{ 255{
255 unsigned long extra; 256 unsigned long extra;
256 unsigned int i; 257 unsigned int i;
257 void *ptr; 258 void *ptr;
258 259
259 BUG_ON(align > SMP_CACHE_BYTES); 260 if (align > SMP_CACHE_BYTES) {
261 printk(KERN_WARNING "%s: per-cpu alignment %li > %i\n",
262 name, align, SMP_CACHE_BYTES);
263 align = SMP_CACHE_BYTES;
264 }
260 265
261 ptr = __per_cpu_start; 266 ptr = __per_cpu_start;
262 for (i = 0; i < pcpu_num_used; ptr += block_size(pcpu_size[i]), i++) { 267 for (i = 0; i < pcpu_num_used; ptr += block_size(pcpu_size[i]), i++) {
@@ -348,7 +353,8 @@ static int percpu_modinit(void)
348} 353}
349__initcall(percpu_modinit); 354__initcall(percpu_modinit);
350#else /* ... !CONFIG_SMP */ 355#else /* ... !CONFIG_SMP */
351static inline void *percpu_modalloc(unsigned long size, unsigned long align) 356static inline void *percpu_modalloc(unsigned long size, unsigned long align,
357 const char *name)
352{ 358{
353 return NULL; 359 return NULL;
354} 360}
@@ -1644,7 +1650,8 @@ static struct module *load_module(void __user *umod,
1644 if (pcpuindex) { 1650 if (pcpuindex) {
1645 /* We have a special allocation for this section. */ 1651 /* We have a special allocation for this section. */
1646 percpu = percpu_modalloc(sechdrs[pcpuindex].sh_size, 1652 percpu = percpu_modalloc(sechdrs[pcpuindex].sh_size,
1647 sechdrs[pcpuindex].sh_addralign); 1653 sechdrs[pcpuindex].sh_addralign,
1654 mod->name);
1648 if (!percpu) { 1655 if (!percpu) {
1649 err = -ENOMEM; 1656 err = -ENOMEM;
1650 goto free_mod; 1657 goto free_mod;
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 31007d6542cc..b4ab6af1dea8 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -86,7 +86,7 @@ restart:
86 /* Reset the pending bitmask before enabling irqs */ 86 /* Reset the pending bitmask before enabling irqs */
87 local_softirq_pending() = 0; 87 local_softirq_pending() = 0;
88 88
89 //local_irq_enable(); 89 local_irq_enable();
90 90
91 h = softirq_vec; 91 h = softirq_vec;
92 92
@@ -99,7 +99,7 @@ restart:
99 pending >>= 1; 99 pending >>= 1;
100 } while (pending); 100 } while (pending);
101 101
102 //local_irq_disable(); 102 local_irq_disable();
103 103
104 pending = local_softirq_pending(); 104 pending = local_softirq_pending();
105 if (pending && --max_restart) 105 if (pending && --max_restart)
diff --git a/kernel/sys.c b/kernel/sys.c
index 000e81ad2c1d..0bcaed6560ac 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -404,7 +404,6 @@ void kernel_halt(void)
404{ 404{
405 notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL); 405 notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL);
406 system_state = SYSTEM_HALT; 406 system_state = SYSTEM_HALT;
407 device_suspend(PMSG_SUSPEND);
408 device_shutdown(); 407 device_shutdown();
409 printk(KERN_EMERG "System halted.\n"); 408 printk(KERN_EMERG "System halted.\n");
410 machine_halt(); 409 machine_halt();
@@ -415,7 +414,6 @@ void kernel_power_off(void)
415{ 414{
416 notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL); 415 notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL);
417 system_state = SYSTEM_POWER_OFF; 416 system_state = SYSTEM_POWER_OFF;
418 device_suspend(PMSG_SUSPEND);
419 device_shutdown(); 417 device_shutdown();
420 printk(KERN_EMERG "Power down.\n"); 418 printk(KERN_EMERG "Power down.\n");
421 machine_power_off(); 419 machine_power_off();
diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c
index 42b40ae5eada..1ab2370e2efa 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -79,7 +79,6 @@ cond_syscall(sys_request_key);
79cond_syscall(sys_keyctl); 79cond_syscall(sys_keyctl);
80cond_syscall(compat_sys_keyctl); 80cond_syscall(compat_sys_keyctl);
81cond_syscall(compat_sys_socketcall); 81cond_syscall(compat_sys_socketcall);
82cond_syscall(sys_set_zone_reclaim);
83cond_syscall(sys_inotify_init); 82cond_syscall(sys_inotify_init);
84cond_syscall(sys_inotify_add_watch); 83cond_syscall(sys_inotify_add_watch);
85cond_syscall(sys_inotify_rm_watch); 84cond_syscall(sys_inotify_rm_watch);
diff --git a/mm/memory.c b/mm/memory.c
index 6fe77acbc1cd..e046b7e4b530 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -913,9 +913,13 @@ int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
913 pud = pud_offset(pgd, pg); 913 pud = pud_offset(pgd, pg);
914 BUG_ON(pud_none(*pud)); 914 BUG_ON(pud_none(*pud));
915 pmd = pmd_offset(pud, pg); 915 pmd = pmd_offset(pud, pg);
916 BUG_ON(pmd_none(*pmd)); 916 if (pmd_none(*pmd))
917 return i ? : -EFAULT;
917 pte = pte_offset_map(pmd, pg); 918 pte = pte_offset_map(pmd, pg);
918 BUG_ON(pte_none(*pte)); 919 if (pte_none(*pte)) {
920 pte_unmap(pte);
921 return i ? : -EFAULT;
922 }
919 if (pages) { 923 if (pages) {
920 pages[i] = pte_page(*pte); 924 pages[i] = pte_page(*pte);
921 get_page(pages[i]); 925 get_page(pages[i]);
@@ -940,11 +944,13 @@ int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
940 } 944 }
941 spin_lock(&mm->page_table_lock); 945 spin_lock(&mm->page_table_lock);
942 do { 946 do {
947 int write_access = write;
943 struct page *page; 948 struct page *page;
944 int lookup_write = write;
945 949
946 cond_resched_lock(&mm->page_table_lock); 950 cond_resched_lock(&mm->page_table_lock);
947 while (!(page = follow_page(mm, start, lookup_write))) { 951 while (!(page = follow_page(mm, start, write_access))) {
952 int ret;
953
948 /* 954 /*
949 * Shortcut for anonymous pages. We don't want 955 * Shortcut for anonymous pages. We don't want
950 * to force the creation of pages tables for 956 * to force the creation of pages tables for
@@ -952,13 +958,23 @@ int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
952 * nobody touched so far. This is important 958 * nobody touched so far. This is important
953 * for doing a core dump for these mappings. 959 * for doing a core dump for these mappings.
954 */ 960 */
955 if (!lookup_write && 961 if (!write && untouched_anonymous_page(mm,vma,start)) {
956 untouched_anonymous_page(mm,vma,start)) {
957 page = ZERO_PAGE(start); 962 page = ZERO_PAGE(start);
958 break; 963 break;
959 } 964 }
960 spin_unlock(&mm->page_table_lock); 965 spin_unlock(&mm->page_table_lock);
961 switch (handle_mm_fault(mm,vma,start,write)) { 966 ret = __handle_mm_fault(mm, vma, start, write_access);
967
968 /*
969 * The VM_FAULT_WRITE bit tells us that do_wp_page has
970 * broken COW when necessary, even if maybe_mkwrite
971 * decided not to set pte_write. We can thus safely do
972 * subsequent page lookups as if they were reads.
973 */
974 if (ret & VM_FAULT_WRITE)
975 write_access = 0;
976
977 switch (ret & ~VM_FAULT_WRITE) {
962 case VM_FAULT_MINOR: 978 case VM_FAULT_MINOR:
963 tsk->min_flt++; 979 tsk->min_flt++;
964 break; 980 break;
@@ -972,14 +988,6 @@ int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
972 default: 988 default:
973 BUG(); 989 BUG();
974 } 990 }
975 /*
976 * Now that we have performed a write fault
977 * and surely no longer have a shared page we
978 * shouldn't write, we shouldn't ignore an
979 * unwritable page in the page table if
980 * we are forcing write access.
981 */
982 lookup_write = write && !force;
983 spin_lock(&mm->page_table_lock); 991 spin_lock(&mm->page_table_lock);
984 } 992 }
985 if (pages) { 993 if (pages) {
@@ -1229,6 +1237,7 @@ static int do_wp_page(struct mm_struct *mm, struct vm_area_struct * vma,
1229 struct page *old_page, *new_page; 1237 struct page *old_page, *new_page;
1230 unsigned long pfn = pte_pfn(pte); 1238 unsigned long pfn = pte_pfn(pte);
1231 pte_t entry; 1239 pte_t entry;
1240 int ret;
1232 1241
1233 if (unlikely(!pfn_valid(pfn))) { 1242 if (unlikely(!pfn_valid(pfn))) {
1234 /* 1243 /*
@@ -1256,7 +1265,7 @@ static int do_wp_page(struct mm_struct *mm, struct vm_area_struct * vma,
1256 lazy_mmu_prot_update(entry); 1265 lazy_mmu_prot_update(entry);
1257 pte_unmap(page_table); 1266 pte_unmap(page_table);
1258 spin_unlock(&mm->page_table_lock); 1267 spin_unlock(&mm->page_table_lock);
1259 return VM_FAULT_MINOR; 1268 return VM_FAULT_MINOR|VM_FAULT_WRITE;
1260 } 1269 }
1261 } 1270 }
1262 pte_unmap(page_table); 1271 pte_unmap(page_table);
@@ -1283,6 +1292,7 @@ static int do_wp_page(struct mm_struct *mm, struct vm_area_struct * vma,
1283 /* 1292 /*
1284 * Re-check the pte - we dropped the lock 1293 * Re-check the pte - we dropped the lock
1285 */ 1294 */
1295 ret = VM_FAULT_MINOR;
1286 spin_lock(&mm->page_table_lock); 1296 spin_lock(&mm->page_table_lock);
1287 page_table = pte_offset_map(pmd, address); 1297 page_table = pte_offset_map(pmd, address);
1288 if (likely(pte_same(*page_table, pte))) { 1298 if (likely(pte_same(*page_table, pte))) {
@@ -1299,12 +1309,13 @@ static int do_wp_page(struct mm_struct *mm, struct vm_area_struct * vma,
1299 1309
1300 /* Free the old page.. */ 1310 /* Free the old page.. */
1301 new_page = old_page; 1311 new_page = old_page;
1312 ret |= VM_FAULT_WRITE;
1302 } 1313 }
1303 pte_unmap(page_table); 1314 pte_unmap(page_table);
1304 page_cache_release(new_page); 1315 page_cache_release(new_page);
1305 page_cache_release(old_page); 1316 page_cache_release(old_page);
1306 spin_unlock(&mm->page_table_lock); 1317 spin_unlock(&mm->page_table_lock);
1307 return VM_FAULT_MINOR; 1318 return ret;
1308 1319
1309no_new_page: 1320no_new_page:
1310 page_cache_release(old_page); 1321 page_cache_release(old_page);
@@ -1996,7 +2007,6 @@ static inline int handle_pte_fault(struct mm_struct *mm,
1996 if (write_access) { 2007 if (write_access) {
1997 if (!pte_write(entry)) 2008 if (!pte_write(entry))
1998 return do_wp_page(mm, vma, address, pte, pmd, entry); 2009 return do_wp_page(mm, vma, address, pte, pmd, entry);
1999
2000 entry = pte_mkdirty(entry); 2010 entry = pte_mkdirty(entry);
2001 } 2011 }
2002 entry = pte_mkyoung(entry); 2012 entry = pte_mkyoung(entry);
@@ -2011,7 +2021,7 @@ static inline int handle_pte_fault(struct mm_struct *mm,
2011/* 2021/*
2012 * By the time we get here, we already hold the mm semaphore 2022 * By the time we get here, we already hold the mm semaphore
2013 */ 2023 */
2014int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct * vma, 2024int __handle_mm_fault(struct mm_struct *mm, struct vm_area_struct * vma,
2015 unsigned long address, int write_access) 2025 unsigned long address, int write_access)
2016{ 2026{
2017 pgd_t *pgd; 2027 pgd_t *pgd;
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 1694845526be..b4eababc8198 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -443,7 +443,7 @@ asmlinkage long sys_set_mempolicy(int mode, unsigned long __user *nmask,
443 struct mempolicy *new; 443 struct mempolicy *new;
444 DECLARE_BITMAP(nodes, MAX_NUMNODES); 444 DECLARE_BITMAP(nodes, MAX_NUMNODES);
445 445
446 if (mode > MPOL_MAX) 446 if (mode < 0 || mode > MPOL_MAX)
447 return -EINVAL; 447 return -EINVAL;
448 err = get_nodes(nodes, nmask, maxnode, mode); 448 err = get_nodes(nodes, nmask, maxnode, mode);
449 if (err) 449 if (err)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 42bccfb8464d..8d088371196a 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1061,20 +1061,19 @@ unsigned int nr_free_pages_pgdat(pg_data_t *pgdat)
1061 1061
1062static unsigned int nr_free_zone_pages(int offset) 1062static unsigned int nr_free_zone_pages(int offset)
1063{ 1063{
1064 pg_data_t *pgdat; 1064 /* Just pick one node, since fallback list is circular */
1065 pg_data_t *pgdat = NODE_DATA(numa_node_id());
1065 unsigned int sum = 0; 1066 unsigned int sum = 0;
1066 1067
1067 for_each_pgdat(pgdat) { 1068 struct zonelist *zonelist = pgdat->node_zonelists + offset;
1068 struct zonelist *zonelist = pgdat->node_zonelists + offset; 1069 struct zone **zonep = zonelist->zones;
1069 struct zone **zonep = zonelist->zones; 1070 struct zone *zone;
1070 struct zone *zone;
1071 1071
1072 for (zone = *zonep++; zone; zone = *zonep++) { 1072 for (zone = *zonep++; zone; zone = *zonep++) {
1073 unsigned long size = zone->present_pages; 1073 unsigned long size = zone->present_pages;
1074 unsigned long high = zone->pages_high; 1074 unsigned long high = zone->pages_high;
1075 if (size > high) 1075 if (size > high)
1076 sum += size - high; 1076 sum += size - high;
1077 }
1078 } 1077 }
1079 1078
1080 return sum; 1079 return sum;
diff --git a/net/core/dst.c b/net/core/dst.c
index fc434ade5270..334790da9f16 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -45,6 +45,7 @@ static struct timer_list dst_gc_timer =
45static void dst_run_gc(unsigned long dummy) 45static void dst_run_gc(unsigned long dummy)
46{ 46{
47 int delayed = 0; 47 int delayed = 0;
48 int work_performed;
48 struct dst_entry * dst, **dstp; 49 struct dst_entry * dst, **dstp;
49 50
50 if (!spin_trylock(&dst_lock)) { 51 if (!spin_trylock(&dst_lock)) {
@@ -52,9 +53,9 @@ static void dst_run_gc(unsigned long dummy)
52 return; 53 return;
53 } 54 }
54 55
55
56 del_timer(&dst_gc_timer); 56 del_timer(&dst_gc_timer);
57 dstp = &dst_garbage_list; 57 dstp = &dst_garbage_list;
58 work_performed = 0;
58 while ((dst = *dstp) != NULL) { 59 while ((dst = *dstp) != NULL) {
59 if (atomic_read(&dst->__refcnt)) { 60 if (atomic_read(&dst->__refcnt)) {
60 dstp = &dst->next; 61 dstp = &dst->next;
@@ -62,6 +63,7 @@ static void dst_run_gc(unsigned long dummy)
62 continue; 63 continue;
63 } 64 }
64 *dstp = dst->next; 65 *dstp = dst->next;
66 work_performed = 1;
65 67
66 dst = dst_destroy(dst); 68 dst = dst_destroy(dst);
67 if (dst) { 69 if (dst) {
@@ -86,9 +88,14 @@ static void dst_run_gc(unsigned long dummy)
86 dst_gc_timer_inc = DST_GC_MAX; 88 dst_gc_timer_inc = DST_GC_MAX;
87 goto out; 89 goto out;
88 } 90 }
89 if ((dst_gc_timer_expires += dst_gc_timer_inc) > DST_GC_MAX) 91 if (!work_performed) {
90 dst_gc_timer_expires = DST_GC_MAX; 92 if ((dst_gc_timer_expires += dst_gc_timer_inc) > DST_GC_MAX)
91 dst_gc_timer_inc += DST_GC_INC; 93 dst_gc_timer_expires = DST_GC_MAX;
94 dst_gc_timer_inc += DST_GC_INC;
95 } else {
96 dst_gc_timer_inc = DST_GC_INC;
97 dst_gc_timer_expires = DST_GC_MIN;
98 }
92 dst_gc_timer.expires = jiffies + dst_gc_timer_expires; 99 dst_gc_timer.expires = jiffies + dst_gc_timer_expires;
93#if RT_CACHE_DEBUG >= 2 100#if RT_CACHE_DEBUG >= 2
94 printk("dst_total: %d/%d %ld\n", 101 printk("dst_total: %d/%d %ld\n",
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 884835522224..f0d5740d7e22 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -290,7 +290,6 @@ static struct ip_tunnel * ipgre_tunnel_locate(struct ip_tunnel_parm *parms, int
290 290
291 dev_hold(dev); 291 dev_hold(dev);
292 ipgre_tunnel_link(nt); 292 ipgre_tunnel_link(nt);
293 /* Do not decrement MOD_USE_COUNT here. */
294 return nt; 293 return nt;
295 294
296failed: 295failed:
@@ -1277,12 +1276,28 @@ err1:
1277 goto out; 1276 goto out;
1278} 1277}
1279 1278
1280static void ipgre_fini(void) 1279static void __exit ipgre_destroy_tunnels(void)
1280{
1281 int prio;
1282
1283 for (prio = 0; prio < 4; prio++) {
1284 int h;
1285 for (h = 0; h < HASH_SIZE; h++) {
1286 struct ip_tunnel *t;
1287 while ((t = tunnels[prio][h]) != NULL)
1288 unregister_netdevice(t->dev);
1289 }
1290 }
1291}
1292
1293static void __exit ipgre_fini(void)
1281{ 1294{
1282 if (inet_del_protocol(&ipgre_protocol, IPPROTO_GRE) < 0) 1295 if (inet_del_protocol(&ipgre_protocol, IPPROTO_GRE) < 0)
1283 printk(KERN_INFO "ipgre close: can't remove protocol\n"); 1296 printk(KERN_INFO "ipgre close: can't remove protocol\n");
1284 1297
1285 unregister_netdev(ipgre_fb_tunnel_dev); 1298 rtnl_lock();
1299 ipgre_destroy_tunnels();
1300 rtnl_unlock();
1286} 1301}
1287 1302
1288module_init(ipgre_init); 1303module_init(ipgre_init);
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index c3947cd566b7..c05c1df0bb04 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -255,7 +255,6 @@ static struct ip_tunnel * ipip_tunnel_locate(struct ip_tunnel_parm *parms, int c
255 255
256 dev_hold(dev); 256 dev_hold(dev);
257 ipip_tunnel_link(nt); 257 ipip_tunnel_link(nt);
258 /* Do not decrement MOD_USE_COUNT here. */
259 return nt; 258 return nt;
260 259
261failed: 260failed:
@@ -920,12 +919,29 @@ static int __init ipip_init(void)
920 goto out; 919 goto out;
921} 920}
922 921
922static void __exit ipip_destroy_tunnels(void)
923{
924 int prio;
925
926 for (prio = 1; prio < 4; prio++) {
927 int h;
928 for (h = 0; h < HASH_SIZE; h++) {
929 struct ip_tunnel *t;
930 while ((t = tunnels[prio][h]) != NULL)
931 unregister_netdevice(t->dev);
932 }
933 }
934}
935
923static void __exit ipip_fini(void) 936static void __exit ipip_fini(void)
924{ 937{
925 if (ipip_unregister() < 0) 938 if (ipip_unregister() < 0)
926 printk(KERN_INFO "ipip close: can't deregister tunnel\n"); 939 printk(KERN_INFO "ipip close: can't deregister tunnel\n");
927 940
928 unregister_netdev(ipip_fb_tunnel_dev); 941 rtnl_lock();
942 ipip_destroy_tunnels();
943 unregister_netdevice(ipip_fb_tunnel_dev);
944 rtnl_unlock();
929} 945}
930 946
931module_init(ipip_init); 947module_init(ipip_init);
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 7833d920bdba..dc806b578427 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -362,7 +362,7 @@ out:
362 362
363/* Fill oifs list. It is called under write locked mrt_lock. */ 363/* Fill oifs list. It is called under write locked mrt_lock. */
364 364
365static void ipmr_update_threshoulds(struct mfc_cache *cache, unsigned char *ttls) 365static void ipmr_update_thresholds(struct mfc_cache *cache, unsigned char *ttls)
366{ 366{
367 int vifi; 367 int vifi;
368 368
@@ -727,7 +727,7 @@ static int ipmr_mfc_add(struct mfcctl *mfc, int mrtsock)
727 if (c != NULL) { 727 if (c != NULL) {
728 write_lock_bh(&mrt_lock); 728 write_lock_bh(&mrt_lock);
729 c->mfc_parent = mfc->mfcc_parent; 729 c->mfc_parent = mfc->mfcc_parent;
730 ipmr_update_threshoulds(c, mfc->mfcc_ttls); 730 ipmr_update_thresholds(c, mfc->mfcc_ttls);
731 if (!mrtsock) 731 if (!mrtsock)
732 c->mfc_flags |= MFC_STATIC; 732 c->mfc_flags |= MFC_STATIC;
733 write_unlock_bh(&mrt_lock); 733 write_unlock_bh(&mrt_lock);
@@ -744,7 +744,7 @@ static int ipmr_mfc_add(struct mfcctl *mfc, int mrtsock)
744 c->mfc_origin=mfc->mfcc_origin.s_addr; 744 c->mfc_origin=mfc->mfcc_origin.s_addr;
745 c->mfc_mcastgrp=mfc->mfcc_mcastgrp.s_addr; 745 c->mfc_mcastgrp=mfc->mfcc_mcastgrp.s_addr;
746 c->mfc_parent=mfc->mfcc_parent; 746 c->mfc_parent=mfc->mfcc_parent;
747 ipmr_update_threshoulds(c, mfc->mfcc_ttls); 747 ipmr_update_thresholds(c, mfc->mfcc_ttls);
748 if (!mrtsock) 748 if (!mrtsock)
749 c->mfc_flags |= MFC_STATIC; 749 c->mfc_flags |= MFC_STATIC;
750 750
diff --git a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c
index 86f04e41dd8e..a7f0c821a9b2 100644
--- a/net/ipv4/netfilter/ip_conntrack_core.c
+++ b/net/ipv4/netfilter/ip_conntrack_core.c
@@ -513,6 +513,11 @@ init_conntrack(const struct ip_conntrack_tuple *tuple,
513#ifdef CONFIG_IP_NF_CONNTRACK_MARK 513#ifdef CONFIG_IP_NF_CONNTRACK_MARK
514 conntrack->mark = exp->master->mark; 514 conntrack->mark = exp->master->mark;
515#endif 515#endif
516#if defined(CONFIG_IP_NF_TARGET_MASQUERADE) || \
517 defined(CONFIG_IP_NF_TARGET_MASQUERADE_MODULE)
518 /* this is ugly, but there is no other place where to put it */
519 conntrack->nat.masq_index = exp->master->nat.masq_index;
520#endif
516 nf_conntrack_get(&conntrack->master->ct_general); 521 nf_conntrack_get(&conntrack->master->ct_general);
517 CONNTRACK_STAT_INC(expect_new); 522 CONNTRACK_STAT_INC(expect_new);
518 } else { 523 } else {
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index b788f55e139b..e553e5b80d6e 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -195,7 +195,6 @@ static struct ip_tunnel * ipip6_tunnel_locate(struct ip_tunnel_parm *parms, int
195 dev_hold(dev); 195 dev_hold(dev);
196 196
197 ipip6_tunnel_link(nt); 197 ipip6_tunnel_link(nt);
198 /* Do not decrement MOD_USE_COUNT here. */
199 return nt; 198 return nt;
200 199
201failed: 200failed:
@@ -794,10 +793,28 @@ static struct net_protocol sit_protocol = {
794 .err_handler = ipip6_err, 793 .err_handler = ipip6_err,
795}; 794};
796 795
796static void __exit sit_destroy_tunnels(void)
797{
798 int prio;
799
800 for (prio = 1; prio < 4; prio++) {
801 int h;
802 for (h = 0; h < HASH_SIZE; h++) {
803 struct ip_tunnel *t;
804 while ((t = tunnels[prio][h]) != NULL)
805 unregister_netdevice(t->dev);
806 }
807 }
808}
809
797void __exit sit_cleanup(void) 810void __exit sit_cleanup(void)
798{ 811{
799 inet_del_protocol(&sit_protocol, IPPROTO_IPV6); 812 inet_del_protocol(&sit_protocol, IPPROTO_IPV6);
800 unregister_netdev(ipip6_fb_tunnel_dev); 813
814 rtnl_lock();
815 sit_destroy_tunnels();
816 unregister_netdevice(ipip6_fb_tunnel_dev);
817 rtnl_unlock();
801} 818}
802 819
803int __init sit_init(void) 820int __init sit_init(void)
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index fea262860ea0..a6516a64b297 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -49,9 +49,6 @@ asmlinkage long sys_add_key(const char __user *_type,
49 goto error; 49 goto error;
50 type[31] = '\0'; 50 type[31] = '\0';
51 51
52 if (!type[0])
53 goto error;
54
55 ret = -EPERM; 52 ret = -EPERM;
56 if (type[0] == '.') 53 if (type[0] == '.')
57 goto error; 54 goto error;
@@ -144,6 +141,10 @@ asmlinkage long sys_request_key(const char __user *_type,
144 goto error; 141 goto error;
145 type[31] = '\0'; 142 type[31] = '\0';
146 143
144 ret = -EPERM;
145 if (type[0] == '.')
146 goto error;
147
147 /* pull the description into kernel space */ 148 /* pull the description into kernel space */
148 ret = -EFAULT; 149 ret = -EFAULT;
149 dlen = strnlen_user(_description, PAGE_SIZE - 1); 150 dlen = strnlen_user(_description, PAGE_SIZE - 1);
@@ -362,7 +363,7 @@ long keyctl_revoke_key(key_serial_t id)
362 363
363 key_put(key); 364 key_put(key);
364 error: 365 error:
365 return 0; 366 return ret;
366 367
367} /* end keyctl_revoke_key() */ 368} /* end keyctl_revoke_key() */
368 369
@@ -685,6 +686,8 @@ long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen)
685 goto can_read_key2; 686 goto can_read_key2;
686 687
687 ret = PTR_ERR(skey); 688 ret = PTR_ERR(skey);
689 if (ret == -EAGAIN)
690 ret = -EACCES;
688 goto error2; 691 goto error2;
689 } 692 }
690 693
diff --git a/security/keys/request_key.c b/security/keys/request_key.c
index dfcd983af1fd..90c1506d007c 100644
--- a/security/keys/request_key.c
+++ b/security/keys/request_key.c
@@ -405,7 +405,7 @@ struct key *request_key_and_link(struct key_type *type,
405 key_user_put(user); 405 key_user_put(user);
406 406
407 /* link the new key into the appropriate keyring */ 407 /* link the new key into the appropriate keyring */
408 if (!PTR_ERR(key)) 408 if (!IS_ERR(key))
409 request_key_link(key, dest_keyring); 409 request_key_link(key, dest_keyring);
410 } 410 }
411 411
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index 7c806bd9cc90..d7af3e474432 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -2376,6 +2376,9 @@ static int intel8x0_suspend(snd_card_t *card, pm_message_t state)
2376 snd_ac97_suspend(chip->ac97[i]); 2376 snd_ac97_suspend(chip->ac97[i]);
2377 if (chip->device_type == DEVICE_INTEL_ICH4) 2377 if (chip->device_type == DEVICE_INTEL_ICH4)
2378 chip->sdm_saved = igetbyte(chip, ICHREG(SDM)); 2378 chip->sdm_saved = igetbyte(chip, ICHREG(SDM));
2379
2380 if (chip->irq >= 0)
2381 free_irq(chip->irq, (void *)chip);
2379 pci_disable_device(chip->pci); 2382 pci_disable_device(chip->pci);
2380 return 0; 2383 return 0;
2381} 2384}
@@ -2387,7 +2390,9 @@ static int intel8x0_resume(snd_card_t *card)
2387 2390
2388 pci_enable_device(chip->pci); 2391 pci_enable_device(chip->pci);
2389 pci_set_master(chip->pci); 2392 pci_set_master(chip->pci);
2390 snd_intel8x0_chip_init(chip, 0); 2393 request_irq(chip->irq, snd_intel8x0_interrupt, SA_INTERRUPT|SA_SHIRQ, card->shortname, (void *)chip);
2394 synchronize_irq(chip->irq);
2395 snd_intel8x0_chip_init(chip, 1);
2391 2396
2392 /* re-initialize mixer stuff */ 2397 /* re-initialize mixer stuff */
2393 if (chip->device_type == DEVICE_INTEL_ICH4) { 2398 if (chip->device_type == DEVICE_INTEL_ICH4) {