aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/aoe/aoe.txt40
-rw-r--r--Documentation/aoe/status.sh4
-rw-r--r--Documentation/pci.txt1
-rw-r--r--Documentation/power/pci.txt35
-rw-r--r--arch/alpha/Kconfig4
-rw-r--r--arch/arm/Kconfig4
-rw-r--r--arch/arm/boot/compressed/head.S105
-rw-r--r--arch/arm/mach-imx/generic.c16
-rw-r--r--arch/arm/mach-integrator/core.c6
-rw-r--r--arch/arm/mach-integrator/leds.c2
-rw-r--r--arch/arm/mach-ixp4xx/common-pci.c10
-rw-r--r--arch/arm/mm/Kconfig1
-rw-r--r--arch/arm26/Kconfig4
-rw-r--r--arch/i386/Kconfig4
-rw-r--r--arch/m68knommu/Kconfig5
-rw-r--r--arch/mips/Kconfig4
-rw-r--r--arch/parisc/Kconfig4
-rw-r--r--arch/ppc/Kconfig4
-rw-r--r--arch/ppc64/Kconfig3
-rw-r--r--arch/ppc64/Makefile7
-rw-r--r--arch/sh/Kconfig4
-rw-r--r--arch/sparc/prom/memory.c28
-rw-r--r--arch/sparc/prom/sun4prom.c2
-rw-r--r--arch/sparc64/kernel/irq.c6
-rw-r--r--arch/x86_64/Kconfig5
-rw-r--r--drivers/block/Kconfig2
-rw-r--r--drivers/block/aoe/aoe.h2
-rw-r--r--drivers/block/aoe/aoeblk.c13
-rw-r--r--drivers/block/aoe/aoedev.c11
-rw-r--r--drivers/block/aoe/aoenet.c17
-rw-r--r--drivers/char/Kconfig4
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c32
-rw-r--r--drivers/char/ipmi/ipmi_si_sm.h2
-rw-r--r--drivers/char/mbcs.c4
-rw-r--r--drivers/char/mbcs.h4
-rw-r--r--drivers/char/sonypi.c6
-rw-r--r--drivers/mmc/Kconfig2
-rw-r--r--drivers/net/Kconfig10
-rw-r--r--drivers/net/appletalk/Kconfig2
-rw-r--r--drivers/net/hamradio/Kconfig4
-rw-r--r--drivers/net/irda/Kconfig10
-rw-r--r--drivers/net/ppp_deflate.c6
-rw-r--r--drivers/net/ppp_generic.c12
-rw-r--r--drivers/net/wan/Kconfig6
-rw-r--r--drivers/net/wan/cycx_x25.c8
-rw-r--r--drivers/net/wan/pc300_tty.c27
-rw-r--r--drivers/net/wan/sdla_chdlc.c13
-rw-r--r--drivers/net/wan/x25_asy.c20
-rw-r--r--drivers/parport/Kconfig2
-rw-r--r--drivers/parport/parport_pc.c34
-rw-r--r--drivers/pci/hotplug/ibmphp.h2
-rw-r--r--drivers/pci/hotplug/ibmphp_hpc.c6
-rw-r--r--drivers/pci/hotplug/ibmphp_pci.c7
-rw-r--r--drivers/pci/hotplug/pci_hotplug.h2
-rw-r--r--drivers/pci/hotplug/pciehp_core.c23
-rw-r--r--drivers/pci/hotplug/pcihp_skeleton.c2
-rw-r--r--drivers/pci/msi.c6
-rw-r--r--drivers/pci/pci-acpi.c2
-rw-r--r--drivers/pci/pci-driver.c11
-rw-r--r--drivers/pci/pci-sysfs.c82
-rw-r--r--drivers/pci/pci.c20
-rw-r--r--drivers/pci/probe.c1
-rw-r--r--drivers/pci/proc.c1
-rw-r--r--drivers/pci/quirks.c2
-rw-r--r--drivers/scsi/Kconfig12
-rw-r--r--drivers/usb/core/message.c4
-rw-r--r--drivers/usb/core/urb.c6
-rw-r--r--drivers/usb/gadget/ether.c2
-rw-r--r--drivers/usb/gadget/inode.c2
-rw-r--r--drivers/usb/gadget/lh7a40x_udc.c2
-rw-r--r--drivers/usb/gadget/serial.c2
-rw-r--r--drivers/usb/host/ehci-hcd.c65
-rw-r--r--drivers/usb/host/ehci-hub.c2
-rw-r--r--drivers/usb/host/ehci.h19
-rw-r--r--drivers/usb/host/hc_crisv10.c2
-rw-r--r--drivers/usb/host/sl811-hcd.c4
-rw-r--r--drivers/usb/image/mdc800.c2
-rw-r--r--drivers/usb/input/aiptek.c2
-rw-r--r--drivers/usb/input/mtouchusb.c2
-rw-r--r--drivers/usb/media/ov511.c2
-rw-r--r--drivers/usb/media/pwc/pwc-ctrl.c2
-rw-r--r--drivers/usb/media/pwc/pwc-if.c6
-rw-r--r--drivers/usb/media/pwc/pwc-ioctl.h2
-rw-r--r--drivers/usb/misc/legousbtower.c2
-rw-r--r--drivers/usb/net/usbnet.c3
-rw-r--r--drivers/usb/net/zd1201.c8
-rw-r--r--drivers/usb/serial/Kconfig9
-rw-r--r--drivers/usb/serial/Makefile1
-rw-r--r--drivers/usb/serial/airprime.c63
-rw-r--r--drivers/usb/serial/cypress_m8.c187
-rw-r--r--drivers/usb/serial/ftdi_sio.c46
-rw-r--r--drivers/usb/serial/ftdi_sio.h36
-rw-r--r--drivers/usb/serial/io_usbvend.h2
-rw-r--r--drivers/usb/serial/keyspan_usa90msg.h2
-rw-r--r--drivers/usb/storage/debug.c1
-rw-r--r--drivers/usb/storage/shuttle_usbat.c2
-rw-r--r--drivers/usb/storage/unusual_devs.h17
-rw-r--r--drivers/video/cyber2000fb.c8
-rw-r--r--drivers/video/i810/i810_main.c6
-rw-r--r--fs/jfs/inode.c35
-rw-r--r--fs/jfs/jfs_dmap.c12
-rw-r--r--fs/jfs/jfs_dtree.c6
-rw-r--r--fs/jfs/jfs_imap.c84
-rw-r--r--fs/jfs/jfs_incore.h1
-rw-r--r--fs/jfs/jfs_logmgr.c150
-rw-r--r--fs/jfs/jfs_logmgr.h9
-rw-r--r--fs/jfs/jfs_metapage.c908
-rw-r--r--fs/jfs/jfs_metapage.h80
-rw-r--r--fs/jfs/jfs_mount.c5
-rw-r--r--fs/jfs/jfs_txnmgr.c166
-rw-r--r--fs/jfs/jfs_umount.c16
-rw-r--r--fs/jfs/jfs_xtree.c63
-rw-r--r--fs/jfs/resize.c3
-rw-r--r--fs/jfs/super.c37
-rw-r--r--include/asm-alpha/signal.h11
-rw-r--r--include/asm-arm/arch-cl7500/vmalloc.h11
-rw-r--r--include/asm-arm/arch-clps711x/vmalloc.h11
-rw-r--r--include/asm-arm/arch-ebsa110/vmalloc.h11
-rw-r--r--include/asm-arm/arch-ebsa285/vmalloc.h11
-rw-r--r--include/asm-arm/arch-epxa10db/vmalloc.h11
-rw-r--r--include/asm-arm/arch-h720x/vmalloc.h11
-rw-r--r--include/asm-arm/arch-imx/vmalloc.h12
-rw-r--r--include/asm-arm/arch-integrator/platform.h108
-rw-r--r--include/asm-arm/arch-integrator/vmalloc.h11
-rw-r--r--include/asm-arm/arch-iop3xx/vmalloc.h3
-rw-r--r--include/asm-arm/arch-ixp2000/vmalloc.h3
-rw-r--r--include/asm-arm/arch-ixp4xx/vmalloc.h12
-rw-r--r--include/asm-arm/arch-l7200/vmalloc.h11
-rw-r--r--include/asm-arm/arch-lh7a40x/vmalloc.h11
-rw-r--r--include/asm-arm/arch-omap/vmalloc.h12
-rw-r--r--include/asm-arm/arch-pxa/vmalloc.h11
-rw-r--r--include/asm-arm/arch-rpc/vmalloc.h11
-rw-r--r--include/asm-arm/arch-s3c2410/vmalloc.h12
-rw-r--r--include/asm-arm/arch-sa1100/vmalloc.h11
-rw-r--r--include/asm-arm/arch-shark/vmalloc.h11
-rw-r--r--include/asm-arm/arch-versatile/vmalloc.h12
-rw-r--r--include/asm-arm/pgtable.h17
-rw-r--r--include/asm-arm/signal.h15
-rw-r--r--include/asm-arm26/signal.h11
-rw-r--r--include/asm-cris/signal.h11
-rw-r--r--include/asm-frv/signal.h11
-rw-r--r--include/asm-generic/signal.h21
-rw-r--r--include/asm-h8300/signal.h11
-rw-r--r--include/asm-i386/signal.h15
-rw-r--r--include/asm-ia64/signal.h11
-rw-r--r--include/asm-m32r/signal.h15
-rw-r--r--include/asm-m68k/signal.h15
-rw-r--r--include/asm-m68knommu/signal.h11
-rw-r--r--include/asm-mips/signal.h9
-rw-r--r--include/asm-ppc/signal.h15
-rw-r--r--include/asm-ppc64/signal.h20
-rw-r--r--include/asm-s390/signal.h11
-rw-r--r--include/asm-sh/signal.h11
-rw-r--r--include/asm-sh64/signal.h11
-rw-r--r--include/asm-sparc/floppy.h2
-rw-r--r--include/asm-sparc/signal.h11
-rw-r--r--include/asm-sparc64/parport.h6
-rw-r--r--include/asm-sparc64/signal.h16
-rw-r--r--include/asm-v850/signal.h12
-rw-r--r--include/asm-x86_64/signal.h14
-rw-r--r--include/linux/pci.h3
-rw-r--r--include/linux/rtnetlink.h8
-rw-r--r--include/linux/xfrm.h5
-rw-r--r--include/net/addrconf.h4
-rw-r--r--include/net/pkt_sched.h3
-rw-r--r--include/net/xfrm.h10
-rw-r--r--kernel/audit.c19
-rw-r--r--net/core/link_watch.c7
-rw-r--r--net/core/netfilter.c17
-rw-r--r--net/core/rtnetlink.c67
-rw-r--r--net/decnet/dn_dev.c25
-rw-r--r--net/decnet/netfilter/dn_rtmsg.c3
-rw-r--r--net/ipv4/devinet.c21
-rw-r--r--net/ipv4/ip_output.c1
-rw-r--r--net/ipv4/netfilter/ip_conntrack_proto_tcp.c1
-rw-r--r--net/ipv4/netfilter/ip_queue.c20
-rw-r--r--net/ipv4/netfilter/iptable_raw.c6
-rw-r--r--net/ipv4/tcp_diag.c3
-rw-r--r--net/ipv4/tcp_ipv4.c7
-rw-r--r--net/ipv4/xfrm4_policy.c42
-rw-r--r--net/ipv6/addrconf.c2
-rw-r--r--net/ipv6/netfilter/ip6_queue.c20
-rw-r--r--net/ipv6/raw.c7
-rw-r--r--net/ipv6/tcp_ipv6.c7
-rw-r--r--net/ipv6/xfrm6_policy.c43
-rw-r--r--net/irda/irda_device.c2
-rw-r--r--net/netlink/af_netlink.c3
-rw-r--r--net/sched/Kconfig2
-rw-r--r--net/sched/act_api.c4
-rw-r--r--net/sched/sch_api.c1
-rw-r--r--net/sched/sch_generic.c5
-rw-r--r--net/sched/sch_htb.c4
-rw-r--r--net/sched/sch_netem.c131
-rw-r--r--net/xfrm/xfrm_policy.c25
-rw-r--r--net/xfrm/xfrm_user.c87
195 files changed, 2233 insertions, 1848 deletions
diff --git a/Documentation/aoe/aoe.txt b/Documentation/aoe/aoe.txt
index 43e50108d0e2..3a4dbe4663c9 100644
--- a/Documentation/aoe/aoe.txt
+++ b/Documentation/aoe/aoe.txt
@@ -4,6 +4,16 @@ The EtherDrive (R) HOWTO for users of 2.6 kernels is found at ...
4 4
5 It has many tips and hints! 5 It has many tips and hints!
6 6
7The aoetools are userland programs that are designed to work with this
8driver. The aoetools are on sourceforge.
9
10 http://aoetools.sourceforge.net/
11
12The scripts in this Documentation/aoe directory are intended to
13document the use of the driver and are not necessary if you install
14the aoetools.
15
16
7CREATING DEVICE NODES 17CREATING DEVICE NODES
8 18
9 Users of udev should find the block device nodes created 19 Users of udev should find the block device nodes created
@@ -35,14 +45,15 @@ USING DEVICE NODES
35 45
36 "echo eth2 eth4 > /dev/etherd/interfaces" tells the aoe driver to 46 "echo eth2 eth4 > /dev/etherd/interfaces" tells the aoe driver to
37 limit ATA over Ethernet traffic to eth2 and eth4. AoE traffic from 47 limit ATA over Ethernet traffic to eth2 and eth4. AoE traffic from
38 untrusted networks should be ignored as a matter of security. 48 untrusted networks should be ignored as a matter of security. See
49 also the aoe_iflist driver option described below.
39 50
40 "echo > /dev/etherd/discover" tells the driver to find out what AoE 51 "echo > /dev/etherd/discover" tells the driver to find out what AoE
41 devices are available. 52 devices are available.
42 53
43 These character devices may disappear and be replaced by sysfs 54 These character devices may disappear and be replaced by sysfs
44 counterparts, so distribution maintainers are encouraged to create 55 counterparts. Using the commands in aoetools insulates users from
45 scripts that use these devices. 56 these implementation details.
46 57
47 The block devices are named like this: 58 The block devices are named like this:
48 59
@@ -66,7 +77,8 @@ USING SYSFS
66 through which we are communicating with the remote AoE device. 77 through which we are communicating with the remote AoE device.
67 78
68 There is a script in this directory that formats this information 79 There is a script in this directory that formats this information
69 in a convenient way. 80 in a convenient way. Users with aoetools can use the aoe-stat
81 command.
70 82
71 root@makki root# sh Documentation/aoe/status.sh 83 root@makki root# sh Documentation/aoe/status.sh
72 e10.0 eth3 up 84 e10.0 eth3 up
@@ -89,3 +101,23 @@ USING SYSFS
89 e4.7 eth1 up 101 e4.7 eth1 up
90 e4.8 eth1 up 102 e4.8 eth1 up
91 e4.9 eth1 up 103 e4.9 eth1 up
104
105 Use /sys/module/aoe/parameters/aoe_iflist (or better, the driver
106 option discussed below) instead of /dev/etherd/interfaces to limit
107 AoE traffic to the network interfaces in the given
108 whitespace-separated list. Unlike the old character device, the
109 sysfs entry can be read from as well as written to.
110
111 It's helpful to trigger discovery after setting the list of allowed
112 interfaces. The aoetools package provides an aoe-discover script
113 for this purpose. You can also directly use the
114 /dev/etherd/discover special file described above.
115
116DRIVER OPTIONS
117
118 There is a boot option for the built-in aoe driver and a
119 corresponding module parameter, aoe_iflist. Without this option,
120 all network interfaces may be used for ATA over Ethernet. Here is a
121 usage example for the module parameter.
122
123 modprobe aoe_iflist="eth1 eth3"
diff --git a/Documentation/aoe/status.sh b/Documentation/aoe/status.sh
index 6628116d4a9f..751f3be514b8 100644
--- a/Documentation/aoe/status.sh
+++ b/Documentation/aoe/status.sh
@@ -14,10 +14,6 @@ test ! -d "$sysd/block" && {
14 echo "$me Error: sysfs is not mounted" 1>&2 14 echo "$me Error: sysfs is not mounted" 1>&2
15 exit 1 15 exit 1
16} 16}
17test -z "`lsmod | grep '^aoe'`" && {
18 echo "$me Error: aoe module is not loaded" 1>&2
19 exit 1
20}
21 17
22for d in `ls -d $sysd/block/etherd* 2>/dev/null | grep -v p` end; do 18for d in `ls -d $sysd/block/etherd* 2>/dev/null | grep -v p` end; do
23 # maybe ls comes up empty, so we use "end" 19 # maybe ls comes up empty, so we use "end"
diff --git a/Documentation/pci.txt b/Documentation/pci.txt
index 67514bf87ccd..62b1dc5d97e2 100644
--- a/Documentation/pci.txt
+++ b/Documentation/pci.txt
@@ -279,6 +279,7 @@ pci_for_each_dev_reverse() Superseded by pci_find_device_reverse()
279pci_for_each_bus() Superseded by pci_find_next_bus() 279pci_for_each_bus() Superseded by pci_find_next_bus()
280pci_find_device() Superseded by pci_get_device() 280pci_find_device() Superseded by pci_get_device()
281pci_find_subsys() Superseded by pci_get_subsys() 281pci_find_subsys() Superseded by pci_get_subsys()
282pci_find_slot() Superseded by pci_get_slot()
282pcibios_find_class() Superseded by pci_get_class() 283pcibios_find_class() Superseded by pci_get_class()
283pci_find_class() Superseded by pci_get_class() 284pci_find_class() Superseded by pci_get_class()
284pci_(read|write)_*_nodev() Superseded by pci_bus_(read|write)_*() 285pci_(read|write)_*_nodev() Superseded by pci_bus_(read|write)_*()
diff --git a/Documentation/power/pci.txt b/Documentation/power/pci.txt
index c85428e7ad92..35b1a7dae342 100644
--- a/Documentation/power/pci.txt
+++ b/Documentation/power/pci.txt
@@ -165,40 +165,9 @@ Description:
165These functions are intended for use by individual drivers, and are defined in 165These functions are intended for use by individual drivers, and are defined in
166struct pci_driver: 166struct pci_driver:
167 167
168 int (*save_state) (struct pci_dev *dev, u32 state); 168 int (*suspend) (struct pci_dev *dev, pm_message_t state);
169 int (*suspend) (struct pci_dev *dev, u32 state);
170 int (*resume) (struct pci_dev *dev); 169 int (*resume) (struct pci_dev *dev);
171 int (*enable_wake) (struct pci_dev *dev, u32 state, int enable); 170 int (*enable_wake) (struct pci_dev *dev, pci_power_t state, int enable);
172
173
174save_state
175----------
176
177Usage:
178
179if (dev->driver && dev->driver->save_state)
180 dev->driver->save_state(dev,state);
181
182The driver should use this callback to save device state. It should take into
183account the current state of the device and the requested state in order to
184avoid any unnecessary operations.
185
186For example, a video card that supports all 4 states (D0-D3), all controller
187context is preserved when entering D1, but the screen is placed into a low power
188state (blanked).
189
190The driver can also interpret this function as a notification that it may be
191entering a sleep state in the near future. If it knows that the device cannot
192enter the requested state, either because of lack of support for it, or because
193the device is middle of some critical operation, then it should fail.
194
195This function should not be used to set any state in the device or the driver
196because the device may not actually enter the sleep state (e.g. another driver
197later causes causes a global state transition to fail).
198
199Note that in intermediate low power states, a device's I/O and memory spaces may
200be disabled and may not be available in subsequent transitions to lower power
201states.
202 171
203 172
204suspend 173suspend
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 0c79b9d95f74..f7c96635d3b4 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -280,6 +280,10 @@ config ISA
280 (MCA) or VESA. ISA is an older system, now being displaced by PCI; 280 (MCA) or VESA. ISA is an older system, now being displaced by PCI;
281 newer boards don't support it. If you have ISA, say Y, otherwise N. 281 newer boards don't support it. If you have ISA, say Y, otherwise N.
282 282
283config ISA_DMA_API
284 bool
285 default y
286
283config PCI 287config PCI
284 bool 288 bool
285 depends on !ALPHA_JENSEN 289 depends on !ALPHA_JENSEN
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 4055115ae0e2..8bfcb37460fa 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -266,6 +266,10 @@ config ISA_DMA
266 depends on FOOTBRIDGE_HOST || ARCH_SHARK 266 depends on FOOTBRIDGE_HOST || ARCH_SHARK
267 default y 267 default y
268 268
269config ISA_DMA_API
270 bool
271 default y
272
269config PCI 273config PCI
270 bool "PCI support" if ARCH_INTEGRATOR_AP 274 bool "PCI support" if ARCH_INTEGRATOR_AP
271 default y if ARCH_SHARK || FOOTBRIDGE_HOST || ARCH_IOP3XX || ARCH_IXP4XX || ARCH_IXP2000 275 default y if ARCH_SHARK || FOOTBRIDGE_HOST || ARCH_IOP3XX || ARCH_IXP4XX || ARCH_IXP2000
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index c0e7aff3dec2..7c7f475e213e 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -18,48 +18,30 @@
18 * Please select one of the following when turning on debugging. 18 * Please select one of the following when turning on debugging.
19 */ 19 */
20#ifdef DEBUG 20#ifdef DEBUG
21#if defined(CONFIG_DEBUG_DC21285_PORT) 21
22 .macro loadsp, rb 22#include <asm/arch/debug-macro.S>
23 mov \rb, #0x42000000 23
24 .endm 24#if defined(CONFIG_DEBUG_ICEDCC)
25 .macro writeb, rb
26 str \rb, [r3, #0x160]
27 .endm
28#elif defined(CONFIG_DEBUG_ICEDCC)
29 .macro loadsp, rb 25 .macro loadsp, rb
30 .endm 26 .endm
31 .macro writeb, rb 27 .macro writeb, ch, rb
32 mcr p14, 0, \rb, c0, c1, 0 28 mcr p14, 0, \ch, c0, c1, 0
33 .endm
34#elif defined(CONFIG_FOOTBRIDGE)
35 .macro loadsp, rb
36 mov \rb, #0x7c000000
37 .endm 29 .endm
38 .macro writeb, rb 30#else
39 strb \rb, [r3, #0x3f8] 31 .macro writeb, ch, rb
32 senduart \ch, \rb
40 .endm 33 .endm
41#elif defined(CONFIG_ARCH_RPC) 34
35#if defined(CONFIG_FOOTBRIDGE) || \
36 defined(CONFIG_ARCH_RPC) || \
37 defined(CONFIG_ARCH_INTEGRATOR) || \
38 defined(CONFIG_ARCH_PXA) || \
39 defined(CONFIG_ARCH_IXP4XX) || \
40 defined(CONFIG_ARCH_IXP2000) || \
41 defined(CONFIG_ARCH_LH7A40X) || \
42 defined(CONFIG_ARCH_OMAP)
42 .macro loadsp, rb 43 .macro loadsp, rb
43 mov \rb, #0x03000000 44 addruart \rb
44 orr \rb, \rb, #0x00010000
45 .endm
46 .macro writeb, rb
47 strb \rb, [r3, #0x3f8 << 2]
48 .endm
49#elif defined(CONFIG_ARCH_INTEGRATOR)
50 .macro loadsp, rb
51 mov \rb, #0x16000000
52 .endm
53 .macro writeb, rb
54 strb \rb, [r3, #0]
55 .endm
56#elif defined(CONFIG_ARCH_PXA) /* Xscale-type */
57 .macro loadsp, rb
58 mov \rb, #0x40000000
59 orr \rb, \rb, #0x00100000
60 .endm
61 .macro writeb, rb
62 strb \rb, [r3, #0]
63 .endm 45 .endm
64#elif defined(CONFIG_ARCH_SA1100) 46#elif defined(CONFIG_ARCH_SA1100)
65 .macro loadsp, rb 47 .macro loadsp, rb
@@ -70,65 +52,22 @@
70 add \rb, \rb, #0x00010000 @ Ser1 52 add \rb, \rb, #0x00010000 @ Ser1
71# endif 53# endif
72 .endm 54 .endm
73 .macro writeb, rb
74 str \rb, [r3, #0x14] @ UTDR
75 .endm
76#elif defined(CONFIG_ARCH_IXP4XX)
77 .macro loadsp, rb
78 mov \rb, #0xc8000000
79 .endm
80 .macro writeb, rb
81 str \rb, [r3, #0]
82#elif defined(CONFIG_ARCH_IXP2000)
83 .macro loadsp, rb
84 mov \rb, #0xc0000000
85 orr \rb, \rb, #0x00030000
86 .endm
87 .macro writeb, rb
88 str \rb, [r3, #0]
89 .endm
90#elif defined(CONFIG_ARCH_LH7A40X)
91 .macro loadsp, rb
92 ldr \rb, =0x80000700 @ UART2 UARTBASE
93 .endm
94 .macro writeb, rb
95 strb \rb, [r3, #0]
96 .endm
97#elif defined(CONFIG_ARCH_OMAP)
98 .macro loadsp, rb
99 mov \rb, #0xff000000 @ physical base address
100 add \rb, \rb, #0x00fb0000
101#if defined(CONFIG_OMAP_LL_DEBUG_UART2) || defined(CONFIG_OMAP_LL_DEBUG_UART3)
102 add \rb, \rb, #0x00000800
103#endif
104#ifdef CONFIG_OMAP_LL_DEBUG_UART3
105 add \rb, \rb, #0x00009000
106#endif
107 .endm
108 .macro writeb, rb
109 strb \rb, [r3]
110 .endm
111#elif defined(CONFIG_ARCH_IOP331) 55#elif defined(CONFIG_ARCH_IOP331)
112 .macro loadsp, rb 56 .macro loadsp, rb
113 mov \rb, #0xff000000 57 mov \rb, #0xff000000
114 orr \rb, \rb, #0x00ff0000 58 orr \rb, \rb, #0x00ff0000
115 orr \rb, \rb, #0x0000f700 @ location of the UART 59 orr \rb, \rb, #0x0000f700 @ location of the UART
116 .endm 60 .endm
117 .macro writeb, rb
118 str \rb, [r3, #0]
119 .endm
120#elif defined(CONFIG_ARCH_S3C2410) 61#elif defined(CONFIG_ARCH_S3C2410)
121 .macro loadsp, rb 62 .macro loadsp, rb
122 mov \rb, #0x50000000 63 mov \rb, #0x50000000
123 add \rb, \rb, #0x4000 * CONFIG_S3C2410_LOWLEVEL_UART_PORT 64 add \rb, \rb, #0x4000 * CONFIG_S3C2410_LOWLEVEL_UART_PORT
124 .endm 65 .endm
125 .macro writeb, rb
126 strb \rb, [r3, #0x20]
127 .endm
128#else 66#else
129#error no serial architecture defined 67#error no serial architecture defined
130#endif 68#endif
131#endif 69#endif
70#endif
132 71
133 .macro kputc,val 72 .macro kputc,val
134 mov r0, \val 73 mov r0, \val
@@ -734,7 +673,7 @@ puts: loadsp r3
7341: ldrb r2, [r0], #1 6731: ldrb r2, [r0], #1
735 teq r2, #0 674 teq r2, #0
736 moveq pc, lr 675 moveq pc, lr
7372: writeb r2 6762: writeb r2, r3
738 mov r1, #0x00020000 677 mov r1, #0x00020000
7393: subs r1, r1, #1 6783: subs r1, r1, #1
740 bne 3b 679 bne 3b
diff --git a/arch/arm/mach-imx/generic.c b/arch/arm/mach-imx/generic.c
index 54377d0f578c..41e5849ae8da 100644
--- a/arch/arm/mach-imx/generic.c
+++ b/arch/arm/mach-imx/generic.c
@@ -26,6 +26,7 @@
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/module.h> 28#include <linux/module.h>
29#include <asm/arch/imxfb.h>
29#include <asm/hardware.h> 30#include <asm/hardware.h>
30 31
31#include <asm/mach/map.h> 32#include <asm/mach/map.h>
@@ -228,6 +229,14 @@ static struct platform_device imx_uart2_device = {
228 .resource = imx_uart2_resources, 229 .resource = imx_uart2_resources,
229}; 230};
230 231
232static struct imxfb_mach_info imx_fb_info;
233
234void __init set_imx_fb_info(struct imxfb_mach_info *hard_imx_fb_info)
235{
236 memcpy(&imx_fb_info,hard_imx_fb_info,sizeof(struct imxfb_mach_info));
237}
238EXPORT_SYMBOL(set_imx_fb_info);
239
231static struct resource imxfb_resources[] = { 240static struct resource imxfb_resources[] = {
232 [0] = { 241 [0] = {
233 .start = 0x00205000, 242 .start = 0x00205000,
@@ -241,9 +250,16 @@ static struct resource imxfb_resources[] = {
241 }, 250 },
242}; 251};
243 252
253static u64 fb_dma_mask = ~(u64)0;
254
244static struct platform_device imxfb_device = { 255static struct platform_device imxfb_device = {
245 .name = "imx-fb", 256 .name = "imx-fb",
246 .id = 0, 257 .id = 0,
258 .dev = {
259 .platform_data = &imx_fb_info,
260 .dma_mask = &fb_dma_mask,
261 .coherent_dma_mask = 0xffffffff,
262 },
247 .num_resources = ARRAY_SIZE(imxfb_resources), 263 .num_resources = ARRAY_SIZE(imxfb_resources),
248 .resource = imxfb_resources, 264 .resource = imxfb_resources,
249}; 265};
diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c
index 86c50c3889b7..bd17b5154311 100644
--- a/arch/arm/mach-integrator/core.c
+++ b/arch/arm/mach-integrator/core.c
@@ -216,7 +216,9 @@ integrator_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
216 216
217 write_seqlock(&xtime_lock); 217 write_seqlock(&xtime_lock);
218 218
219 // ...clear the interrupt 219 /*
220 * clear the interrupt
221 */
220 timer1->TimerClear = 1; 222 timer1->TimerClear = 1;
221 223
222 timer_tick(regs); 224 timer_tick(regs);
@@ -264,7 +266,7 @@ void __init integrator_time_init(unsigned long reload, unsigned int ctrl)
264 timer1->TimerValue = timer_reload; 266 timer1->TimerValue = timer_reload;
265 timer1->TimerControl = timer_ctrl; 267 timer1->TimerControl = timer_ctrl;
266 268
267 /* 269 /*
268 * Make irqs happen for the system timer 270 * Make irqs happen for the system timer
269 */ 271 */
270 setup_irq(IRQ_TIMERINT1, &integrator_timer_irq); 272 setup_irq(IRQ_TIMERINT1, &integrator_timer_irq);
diff --git a/arch/arm/mach-integrator/leds.c b/arch/arm/mach-integrator/leds.c
index 9d182b77b312..d2c0ab21150c 100644
--- a/arch/arm/mach-integrator/leds.c
+++ b/arch/arm/mach-integrator/leds.c
@@ -37,7 +37,7 @@ static void integrator_leds_event(led_event_t ledevt)
37 unsigned long flags; 37 unsigned long flags;
38 const unsigned int dbg_base = IO_ADDRESS(INTEGRATOR_DBG_BASE); 38 const unsigned int dbg_base = IO_ADDRESS(INTEGRATOR_DBG_BASE);
39 unsigned int update_alpha_leds; 39 unsigned int update_alpha_leds;
40 40
41 // yup, change the LEDs 41 // yup, change the LEDs
42 local_irq_save(flags); 42 local_irq_save(flags);
43 update_alpha_leds = 0; 43 update_alpha_leds = 0;
diff --git a/arch/arm/mach-ixp4xx/common-pci.c b/arch/arm/mach-ixp4xx/common-pci.c
index 94bcdb933e41..aa92e3708838 100644
--- a/arch/arm/mach-ixp4xx/common-pci.c
+++ b/arch/arm/mach-ixp4xx/common-pci.c
@@ -502,15 +502,6 @@ pci_set_dma_mask(struct pci_dev *dev, u64 mask)
502} 502}
503 503
504int 504int
505pci_dac_set_dma_mask(struct pci_dev *dev, u64 mask)
506{
507 if (mask >= SZ_64M - 1 )
508 return 0;
509
510 return -EIO;
511}
512
513int
514pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask) 505pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
515{ 506{
516 if (mask >= SZ_64M - 1 ) 507 if (mask >= SZ_64M - 1 )
@@ -520,7 +511,6 @@ pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
520} 511}
521 512
522EXPORT_SYMBOL(pci_set_dma_mask); 513EXPORT_SYMBOL(pci_set_dma_mask);
523EXPORT_SYMBOL(pci_dac_set_dma_mask);
524EXPORT_SYMBOL(pci_set_consistent_dma_mask); 514EXPORT_SYMBOL(pci_set_consistent_dma_mask);
525EXPORT_SYMBOL(ixp4xx_pci_read); 515EXPORT_SYMBOL(ixp4xx_pci_read);
526EXPORT_SYMBOL(ixp4xx_pci_write); 516EXPORT_SYMBOL(ixp4xx_pci_write);
diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
index 007766a0644c..27892e34b060 100644
--- a/arch/arm/mm/Kconfig
+++ b/arch/arm/mm/Kconfig
@@ -413,6 +413,7 @@ config CPU_BPREDICT_DISABLE
413config HAS_TLS_REG 413config HAS_TLS_REG
414 bool 414 bool
415 depends on CPU_32v6 && !CPU_32v5 && !CPU_32v4 && !CPU_32v3 415 depends on CPU_32v6 && !CPU_32v5 && !CPU_32v4 && !CPU_32v3
416 default y
416 help 417 help
417 This selects support for the CP15 thread register. 418 This selects support for the CP15 thread register.
418 It is defined to be available on ARMv6 or later. However 419 It is defined to be available on ARMv6 or later. However
diff --git a/arch/arm26/Kconfig b/arch/arm26/Kconfig
index 3955de5af4c0..6caed90661fc 100644
--- a/arch/arm26/Kconfig
+++ b/arch/arm26/Kconfig
@@ -89,6 +89,10 @@ config PAGESIZE_16
89 machine with 4MB of memory. 89 machine with 4MB of memory.
90endmenu 90endmenu
91 91
92config ISA_DMA_API
93 bool
94 default y
95
92menu "General setup" 96menu "General setup"
93 97
94# Compressed boot loader in ROM. Yes, we really want to ask about 98# Compressed boot loader in ROM. Yes, we really want to ask about
diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
index 99b4f294a52d..fee589119606 100644
--- a/arch/i386/Kconfig
+++ b/arch/i386/Kconfig
@@ -1173,6 +1173,10 @@ source "drivers/pci/pcie/Kconfig"
1173 1173
1174source "drivers/pci/Kconfig" 1174source "drivers/pci/Kconfig"
1175 1175
1176config ISA_DMA_API
1177 bool
1178 default y
1179
1176config ISA 1180config ISA
1177 bool "ISA support" 1181 bool "ISA support"
1178 depends on !(X86_VOYAGER || X86_VISWS) 1182 depends on !(X86_VOYAGER || X86_VISWS)
diff --git a/arch/m68knommu/Kconfig b/arch/m68knommu/Kconfig
index fc4615b6d3a9..e729bd280623 100644
--- a/arch/m68knommu/Kconfig
+++ b/arch/m68knommu/Kconfig
@@ -534,6 +534,11 @@ endchoice
534 534
535endmenu 535endmenu
536 536
537config ISA_DMA_API
538 bool
539 depends on !M5272
540 default y
541
537menu "Bus options (PCI, PCMCIA, EISA, MCA, ISA)" 542menu "Bus options (PCI, PCMCIA, EISA, MCA, ISA)"
538 543
539config PCI 544config PCI
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 5e666aad8815..ab9944693f1f 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -1656,3 +1656,7 @@ config GENERIC_HARDIRQS
1656config GENERIC_IRQ_PROBE 1656config GENERIC_IRQ_PROBE
1657 bool 1657 bool
1658 default y 1658 default y
1659
1660config ISA_DMA_API
1661 bool
1662 default y
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index 5b5cd00d98ca..e7e7c56fc212 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -45,6 +45,10 @@ config GENERIC_IRQ_PROBE
45config PM 45config PM
46 bool 46 bool
47 47
48config ISA_DMA_API
49 bool
50 default y
51
48source "init/Kconfig" 52source "init/Kconfig"
49 53
50 54
diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig
index c3d941345e3d..ff04dcd30200 100644
--- a/arch/ppc/Kconfig
+++ b/arch/ppc/Kconfig
@@ -1079,6 +1079,10 @@ source kernel/power/Kconfig
1079 1079
1080endmenu 1080endmenu
1081 1081
1082config ISA_DMA_API
1083 bool
1084 default y
1085
1082menu "Bus options" 1086menu "Bus options"
1083 1087
1084config ISA 1088config ISA
diff --git a/arch/ppc64/Kconfig b/arch/ppc64/Kconfig
index ef1f05e437c4..f5508abf1188 100644
--- a/arch/ppc64/Kconfig
+++ b/arch/ppc64/Kconfig
@@ -293,6 +293,9 @@ config SECCOMP
293 293
294endmenu 294endmenu
295 295
296config ISA_DMA_API
297 bool
298 default y
296 299
297menu "General setup" 300menu "General setup"
298 301
diff --git a/arch/ppc64/Makefile b/arch/ppc64/Makefile
index d33e20bcc52f..691f3008e698 100644
--- a/arch/ppc64/Makefile
+++ b/arch/ppc64/Makefile
@@ -56,13 +56,20 @@ LDFLAGS_vmlinux := -Bstatic -e $(KERNELLOAD) -Ttext $(KERNELLOAD)
56CFLAGS += -msoft-float -pipe -mminimal-toc -mtraceback=none \ 56CFLAGS += -msoft-float -pipe -mminimal-toc -mtraceback=none \
57 -mcall-aixdesc 57 -mcall-aixdesc
58 58
59GCC_VERSION := $(call cc-version)
60GCC_BROKEN_VEC := $(shell if [ $(GCC_VERSION) -lt 0400 ] ; then echo "y"; fi ;)
61
59ifeq ($(CONFIG_POWER4_ONLY),y) 62ifeq ($(CONFIG_POWER4_ONLY),y)
60ifeq ($(CONFIG_ALTIVEC),y) 63ifeq ($(CONFIG_ALTIVEC),y)
64ifeq ($(GCC_BROKEN_VEC),y)
61 CFLAGS += $(call cc-option,-mcpu=970) 65 CFLAGS += $(call cc-option,-mcpu=970)
62else 66else
63 CFLAGS += $(call cc-option,-mcpu=power4) 67 CFLAGS += $(call cc-option,-mcpu=power4)
64endif 68endif
65else 69else
70 CFLAGS += $(call cc-option,-mcpu=power4)
71endif
72else
66 CFLAGS += $(call cc-option,-mtune=power4) 73 CFLAGS += $(call cc-option,-mtune=power4)
67endif 74endif
68 75
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 722ea1d63c94..3468d5127223 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -693,6 +693,10 @@ config RTC_9701JE
693 693
694endmenu 694endmenu
695 695
696config ISA_DMA_API
697 bool
698 depends on MPC1211
699 default y
696 700
697menu "Bus options (PCI, PCMCIA, EISA, MCA, ISA)" 701menu "Bus options (PCI, PCMCIA, EISA, MCA, ISA)"
698 702
diff --git a/arch/sparc/prom/memory.c b/arch/sparc/prom/memory.c
index 46aa51afec14..c20e5309f8aa 100644
--- a/arch/sparc/prom/memory.c
+++ b/arch/sparc/prom/memory.c
@@ -47,9 +47,9 @@ prom_sortmemlist(struct linux_mlist_v0 *thislist)
47 char *tmpaddr; 47 char *tmpaddr;
48 char *lowest; 48 char *lowest;
49 49
50 for(i=0; thislist[i].theres_more != 0; i++) { 50 for(i=0; thislist[i].theres_more; i++) {
51 lowest = thislist[i].start_adr; 51 lowest = thislist[i].start_adr;
52 for(mitr = i+1; thislist[mitr-1].theres_more != 0; mitr++) 52 for(mitr = i+1; thislist[mitr-1].theres_more; mitr++)
53 if(thislist[mitr].start_adr < lowest) { 53 if(thislist[mitr].start_adr < lowest) {
54 lowest = thislist[mitr].start_adr; 54 lowest = thislist[mitr].start_adr;
55 swapi = mitr; 55 swapi = mitr;
@@ -85,7 +85,7 @@ void __init prom_meminit(void)
85 prom_phys_total[iter].num_bytes = mptr->num_bytes; 85 prom_phys_total[iter].num_bytes = mptr->num_bytes;
86 prom_phys_total[iter].theres_more = &prom_phys_total[iter+1]; 86 prom_phys_total[iter].theres_more = &prom_phys_total[iter+1];
87 } 87 }
88 prom_phys_total[iter-1].theres_more = 0x0; 88 prom_phys_total[iter-1].theres_more = NULL;
89 /* Second, the total prom taken descriptors. */ 89 /* Second, the total prom taken descriptors. */
90 for(mptr = (*(romvec->pv_v0mem.v0_prommap)), iter=0; 90 for(mptr = (*(romvec->pv_v0mem.v0_prommap)), iter=0;
91 mptr; mptr=mptr->theres_more, iter++) { 91 mptr; mptr=mptr->theres_more, iter++) {
@@ -93,7 +93,7 @@ void __init prom_meminit(void)
93 prom_prom_taken[iter].num_bytes = mptr->num_bytes; 93 prom_prom_taken[iter].num_bytes = mptr->num_bytes;
94 prom_prom_taken[iter].theres_more = &prom_prom_taken[iter+1]; 94 prom_prom_taken[iter].theres_more = &prom_prom_taken[iter+1];
95 } 95 }
96 prom_prom_taken[iter-1].theres_more = 0x0; 96 prom_prom_taken[iter-1].theres_more = NULL;
97 /* Last, the available physical descriptors. */ 97 /* Last, the available physical descriptors. */
98 for(mptr = (*(romvec->pv_v0mem.v0_available)), iter=0; 98 for(mptr = (*(romvec->pv_v0mem.v0_available)), iter=0;
99 mptr; mptr=mptr->theres_more, iter++) { 99 mptr; mptr=mptr->theres_more, iter++) {
@@ -101,7 +101,7 @@ void __init prom_meminit(void)
101 prom_phys_avail[iter].num_bytes = mptr->num_bytes; 101 prom_phys_avail[iter].num_bytes = mptr->num_bytes;
102 prom_phys_avail[iter].theres_more = &prom_phys_avail[iter+1]; 102 prom_phys_avail[iter].theres_more = &prom_phys_avail[iter+1];
103 } 103 }
104 prom_phys_avail[iter-1].theres_more = 0x0; 104 prom_phys_avail[iter-1].theres_more = NULL;
105 /* Sort all the lists. */ 105 /* Sort all the lists. */
106 prom_sortmemlist(prom_phys_total); 106 prom_sortmemlist(prom_phys_total);
107 prom_sortmemlist(prom_prom_taken); 107 prom_sortmemlist(prom_prom_taken);
@@ -124,7 +124,7 @@ void __init prom_meminit(void)
124 prom_phys_avail[iter].theres_more = 124 prom_phys_avail[iter].theres_more =
125 &prom_phys_avail[iter+1]; 125 &prom_phys_avail[iter+1];
126 } 126 }
127 prom_phys_avail[iter-1].theres_more = 0x0; 127 prom_phys_avail[iter-1].theres_more = NULL;
128 128
129 num_regs = prom_getproperty(node, "reg", 129 num_regs = prom_getproperty(node, "reg",
130 (char *) prom_reg_memlist, 130 (char *) prom_reg_memlist,
@@ -138,7 +138,7 @@ void __init prom_meminit(void)
138 prom_phys_total[iter].theres_more = 138 prom_phys_total[iter].theres_more =
139 &prom_phys_total[iter+1]; 139 &prom_phys_total[iter+1];
140 } 140 }
141 prom_phys_total[iter-1].theres_more = 0x0; 141 prom_phys_total[iter-1].theres_more = NULL;
142 142
143 node = prom_getchild(prom_root_node); 143 node = prom_getchild(prom_root_node);
144 node = prom_searchsiblings(node, "virtual-memory"); 144 node = prom_searchsiblings(node, "virtual-memory");
@@ -158,7 +158,7 @@ void __init prom_meminit(void)
158 prom_prom_taken[iter].theres_more = 158 prom_prom_taken[iter].theres_more =
159 &prom_prom_taken[iter+1]; 159 &prom_prom_taken[iter+1];
160 } 160 }
161 prom_prom_taken[iter-1].theres_more = 0x0; 161 prom_prom_taken[iter-1].theres_more = NULL;
162 162
163 prom_sortmemlist(prom_prom_taken); 163 prom_sortmemlist(prom_prom_taken);
164 164
@@ -182,15 +182,15 @@ void __init prom_meminit(void)
182 case PROM_SUN4: 182 case PROM_SUN4:
183#ifdef CONFIG_SUN4 183#ifdef CONFIG_SUN4
184 /* how simple :) */ 184 /* how simple :) */
185 prom_phys_total[0].start_adr = 0x0; 185 prom_phys_total[0].start_adr = NULL;
186 prom_phys_total[0].num_bytes = *(sun4_romvec->memorysize); 186 prom_phys_total[0].num_bytes = *(sun4_romvec->memorysize);
187 prom_phys_total[0].theres_more = 0x0; 187 prom_phys_total[0].theres_more = NULL;
188 prom_prom_taken[0].start_adr = 0x0; 188 prom_prom_taken[0].start_adr = NULL;
189 prom_prom_taken[0].num_bytes = 0x0; 189 prom_prom_taken[0].num_bytes = 0x0;
190 prom_prom_taken[0].theres_more = 0x0; 190 prom_prom_taken[0].theres_more = NULL;
191 prom_phys_avail[0].start_adr = 0x0; 191 prom_phys_avail[0].start_adr = NULL;
192 prom_phys_avail[0].num_bytes = *(sun4_romvec->memoryavail); 192 prom_phys_avail[0].num_bytes = *(sun4_romvec->memoryavail);
193 prom_phys_avail[0].theres_more = 0x0; 193 prom_phys_avail[0].theres_more = NULL;
194#endif 194#endif
195 break; 195 break;
196 196
diff --git a/arch/sparc/prom/sun4prom.c b/arch/sparc/prom/sun4prom.c
index 69ca735f0d4e..00390a2652aa 100644
--- a/arch/sparc/prom/sun4prom.c
+++ b/arch/sparc/prom/sun4prom.c
@@ -151,7 +151,7 @@ struct linux_romvec * __init sun4_prom_init(void)
151 * have more time, we can teach the penguin to say "By your 151 * have more time, we can teach the penguin to say "By your
152 * command" or "Activating turbo boost, Michael". :-) 152 * command" or "Activating turbo boost, Michael". :-)
153 */ 153 */
154 sun4_romvec->setLEDs(0x0); 154 sun4_romvec->setLEDs(NULL);
155 155
156 printk("PROMLIB: Old Sun4 boot PROM monitor %s, romvec version %d\n", 156 printk("PROMLIB: Old Sun4 boot PROM monitor %s, romvec version %d\n",
157 sun4_romvec->monid, 157 sun4_romvec->monid,
diff --git a/arch/sparc64/kernel/irq.c b/arch/sparc64/kernel/irq.c
index a38cb5036df0..4dcb8af94090 100644
--- a/arch/sparc64/kernel/irq.c
+++ b/arch/sparc64/kernel/irq.c
@@ -756,7 +756,7 @@ void handler_irq(int irq, struct pt_regs *regs)
756 clear_softint(clr_mask); 756 clear_softint(clr_mask);
757 } 757 }
758#else 758#else
759 int should_forward = 1; 759 int should_forward = 0;
760 760
761 clear_softint(1 << irq); 761 clear_softint(1 << irq);
762#endif 762#endif
@@ -1007,10 +1007,10 @@ static int retarget_one_irq(struct irqaction *p, int goal_cpu)
1007 } 1007 }
1008 upa_writel(tid | IMAP_VALID, imap); 1008 upa_writel(tid | IMAP_VALID, imap);
1009 1009
1010 while (!cpu_online(goal_cpu)) { 1010 do {
1011 if (++goal_cpu >= NR_CPUS) 1011 if (++goal_cpu >= NR_CPUS)
1012 goal_cpu = 0; 1012 goal_cpu = 0;
1013 } 1013 } while (!cpu_online(goal_cpu));
1014 1014
1015 return goal_cpu; 1015 return goal_cpu;
1016} 1016}
diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig
index 80c38c5d71fe..44ee7f6acf7b 100644
--- a/arch/x86_64/Kconfig
+++ b/arch/x86_64/Kconfig
@@ -379,6 +379,11 @@ config GENERIC_IRQ_PROBE
379 bool 379 bool
380 default y 380 default y
381 381
382# we have no ISA slots, but we do have ISA-style DMA.
383config ISA_DMA_API
384 bool
385 default y
386
382menu "Power management options" 387menu "Power management options"
383 388
384source kernel/power/Kconfig 389source kernel/power/Kconfig
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index e43e02328968..b594768b0241 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -105,7 +105,7 @@ config ATARI_SLM
105 105
106config BLK_DEV_XD 106config BLK_DEV_XD
107 tristate "XT hard disk support" 107 tristate "XT hard disk support"
108 depends on ISA 108 depends on ISA && ISA_DMA_API
109 help 109 help
110 Very old 8 bit hard disk controllers used in the IBM XT computer 110 Very old 8 bit hard disk controllers used in the IBM XT computer
111 will be supported if you say Y here. 111 will be supported if you say Y here.
diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h
index aa8b547ffafa..721ba8086043 100644
--- a/drivers/block/aoe/aoe.h
+++ b/drivers/block/aoe/aoe.h
@@ -1,5 +1,5 @@
1/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ 1/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */
2#define VERSION "6" 2#define VERSION "10"
3#define AOE_MAJOR 152 3#define AOE_MAJOR 152
4#define DEVICE_NAME "aoe" 4#define DEVICE_NAME "aoe"
5 5
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
index 4780f7926d42..0e97fcb9f3a1 100644
--- a/drivers/block/aoe/aoeblk.c
+++ b/drivers/block/aoe/aoeblk.c
@@ -37,6 +37,13 @@ static ssize_t aoedisk_show_netif(struct gendisk * disk, char *page)
37 37
38 return snprintf(page, PAGE_SIZE, "%s\n", d->ifp->name); 38 return snprintf(page, PAGE_SIZE, "%s\n", d->ifp->name);
39} 39}
40/* firmware version */
41static ssize_t aoedisk_show_fwver(struct gendisk * disk, char *page)
42{
43 struct aoedev *d = disk->private_data;
44
45 return snprintf(page, PAGE_SIZE, "0x%04x\n", (unsigned int) d->fw_ver);
46}
40 47
41static struct disk_attribute disk_attr_state = { 48static struct disk_attribute disk_attr_state = {
42 .attr = {.name = "state", .mode = S_IRUGO }, 49 .attr = {.name = "state", .mode = S_IRUGO },
@@ -50,6 +57,10 @@ static struct disk_attribute disk_attr_netif = {
50 .attr = {.name = "netif", .mode = S_IRUGO }, 57 .attr = {.name = "netif", .mode = S_IRUGO },
51 .show = aoedisk_show_netif 58 .show = aoedisk_show_netif
52}; 59};
60static struct disk_attribute disk_attr_fwver = {
61 .attr = {.name = "firmware-version", .mode = S_IRUGO },
62 .show = aoedisk_show_fwver
63};
53 64
54static void 65static void
55aoedisk_add_sysfs(struct aoedev *d) 66aoedisk_add_sysfs(struct aoedev *d)
@@ -57,6 +68,7 @@ aoedisk_add_sysfs(struct aoedev *d)
57 sysfs_create_file(&d->gd->kobj, &disk_attr_state.attr); 68 sysfs_create_file(&d->gd->kobj, &disk_attr_state.attr);
58 sysfs_create_file(&d->gd->kobj, &disk_attr_mac.attr); 69 sysfs_create_file(&d->gd->kobj, &disk_attr_mac.attr);
59 sysfs_create_file(&d->gd->kobj, &disk_attr_netif.attr); 70 sysfs_create_file(&d->gd->kobj, &disk_attr_netif.attr);
71 sysfs_create_file(&d->gd->kobj, &disk_attr_fwver.attr);
60} 72}
61void 73void
62aoedisk_rm_sysfs(struct aoedev *d) 74aoedisk_rm_sysfs(struct aoedev *d)
@@ -64,6 +76,7 @@ aoedisk_rm_sysfs(struct aoedev *d)
64 sysfs_remove_link(&d->gd->kobj, "state"); 76 sysfs_remove_link(&d->gd->kobj, "state");
65 sysfs_remove_link(&d->gd->kobj, "mac"); 77 sysfs_remove_link(&d->gd->kobj, "mac");
66 sysfs_remove_link(&d->gd->kobj, "netif"); 78 sysfs_remove_link(&d->gd->kobj, "netif");
79 sysfs_remove_link(&d->gd->kobj, "firmware-version");
67} 80}
68 81
69static int 82static int
diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c
index ec16c64dd114..6e231c5a1199 100644
--- a/drivers/block/aoe/aoedev.c
+++ b/drivers/block/aoe/aoedev.c
@@ -109,25 +109,22 @@ aoedev_set(ulong sysminor, unsigned char *addr, struct net_device *ifp, ulong bu
109 spin_lock_irqsave(&devlist_lock, flags); 109 spin_lock_irqsave(&devlist_lock, flags);
110 110
111 for (d=devlist; d; d=d->next) 111 for (d=devlist; d; d=d->next)
112 if (d->sysminor == sysminor 112 if (d->sysminor == sysminor)
113 || memcmp(d->addr, addr, sizeof d->addr) == 0)
114 break; 113 break;
115 114
116 if (d == NULL && (d = aoedev_newdev(bufcnt)) == NULL) { 115 if (d == NULL && (d = aoedev_newdev(bufcnt)) == NULL) {
117 spin_unlock_irqrestore(&devlist_lock, flags); 116 spin_unlock_irqrestore(&devlist_lock, flags);
118 printk(KERN_INFO "aoe: aoedev_set: aoedev_newdev failure.\n"); 117 printk(KERN_INFO "aoe: aoedev_set: aoedev_newdev failure.\n");
119 return NULL; 118 return NULL;
120 } 119 } /* if newdev, (d->flags & DEVFL_UP) == 0 for below */
121 120
122 spin_unlock_irqrestore(&devlist_lock, flags); 121 spin_unlock_irqrestore(&devlist_lock, flags);
123 spin_lock_irqsave(&d->lock, flags); 122 spin_lock_irqsave(&d->lock, flags);
124 123
125 d->ifp = ifp; 124 d->ifp = ifp;
126 125 memcpy(d->addr, addr, sizeof d->addr);
127 if (d->sysminor != sysminor 126 if ((d->flags & DEVFL_UP) == 0) {
128 || (d->flags & DEVFL_UP) == 0) {
129 aoedev_downdev(d); /* flushes outstanding frames */ 127 aoedev_downdev(d); /* flushes outstanding frames */
130 memcpy(d->addr, addr, sizeof d->addr);
131 d->sysminor = sysminor; 128 d->sysminor = sysminor;
132 d->aoemajor = AOEMAJOR(sysminor); 129 d->aoemajor = AOEMAJOR(sysminor);
133 d->aoeminor = AOEMINOR(sysminor); 130 d->aoeminor = AOEMINOR(sysminor);
diff --git a/drivers/block/aoe/aoenet.c b/drivers/block/aoe/aoenet.c
index bc92aacb6dad..9e6f51c528b0 100644
--- a/drivers/block/aoe/aoenet.c
+++ b/drivers/block/aoe/aoenet.c
@@ -7,6 +7,7 @@
7#include <linux/hdreg.h> 7#include <linux/hdreg.h>
8#include <linux/blkdev.h> 8#include <linux/blkdev.h>
9#include <linux/netdevice.h> 9#include <linux/netdevice.h>
10#include <linux/moduleparam.h>
10#include "aoe.h" 11#include "aoe.h"
11 12
12#define NECODES 5 13#define NECODES 5
@@ -26,6 +27,19 @@ enum {
26}; 27};
27 28
28static char aoe_iflist[IFLISTSZ]; 29static char aoe_iflist[IFLISTSZ];
30module_param_string(aoe_iflist, aoe_iflist, IFLISTSZ, 0600);
31MODULE_PARM_DESC(aoe_iflist, "aoe_iflist=\"dev1 [dev2 ...]\"\n");
32
33#ifndef MODULE
34static int __init aoe_iflist_setup(char *str)
35{
36 strncpy(aoe_iflist, str, IFLISTSZ);
37 aoe_iflist[IFLISTSZ - 1] = '\0';
38 return 1;
39}
40
41__setup("aoe_iflist=", aoe_iflist_setup);
42#endif
29 43
30int 44int
31is_aoe_netif(struct net_device *ifp) 45is_aoe_netif(struct net_device *ifp)
@@ -36,7 +50,8 @@ is_aoe_netif(struct net_device *ifp)
36 if (aoe_iflist[0] == '\0') 50 if (aoe_iflist[0] == '\0')
37 return 1; 51 return 1;
38 52
39 for (p = aoe_iflist; *p; p = q + strspn(q, WHITESPACE)) { 53 p = aoe_iflist + strspn(aoe_iflist, WHITESPACE);
54 for (; *p; p = q + strspn(q, WHITESPACE)) {
40 q = p + strcspn(p, WHITESPACE); 55 q = p + strcspn(p, WHITESPACE);
41 if (q != p) 56 if (q != p)
42 len = q - p; 57 len = q - p;
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index a70e6b99fc9a..5ed6515ae01f 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -153,7 +153,7 @@ config DIGIEPCA
153 153
154config ESPSERIAL 154config ESPSERIAL
155 tristate "Hayes ESP serial port support" 155 tristate "Hayes ESP serial port support"
156 depends on SERIAL_NONSTANDARD && ISA && BROKEN_ON_SMP 156 depends on SERIAL_NONSTANDARD && ISA && BROKEN_ON_SMP && ISA_DMA_API
157 help 157 help
158 This is a driver which supports Hayes ESP serial ports. Both single 158 This is a driver which supports Hayes ESP serial ports. Both single
159 port cards and multiport cards are supported. Make sure to read 159 port cards and multiport cards are supported. Make sure to read
@@ -195,7 +195,7 @@ config ISI
195 195
196config SYNCLINK 196config SYNCLINK
197 tristate "Microgate SyncLink card support" 197 tristate "Microgate SyncLink card support"
198 depends on SERIAL_NONSTANDARD && PCI 198 depends on SERIAL_NONSTANDARD && PCI && ISA_DMA_API
199 help 199 help
200 Provides support for the SyncLink ISA and PCI multiprotocol serial 200 Provides support for the SyncLink ISA and PCI multiprotocol serial
201 adapters. These adapters support asynchronous and HDLC bit 201 adapters. These adapters support asynchronous and HDLC bit
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 5419440087fd..298574e16061 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -1617,15 +1617,15 @@ typedef struct dmi_header
1617 u16 handle; 1617 u16 handle;
1618} dmi_header_t; 1618} dmi_header_t;
1619 1619
1620static int decode_dmi(dmi_header_t *dm, int intf_num) 1620static int decode_dmi(dmi_header_t __iomem *dm, int intf_num)
1621{ 1621{
1622 u8 *data = (u8 *)dm; 1622 u8 __iomem *data = (u8 __iomem *)dm;
1623 unsigned long base_addr; 1623 unsigned long base_addr;
1624 u8 reg_spacing; 1624 u8 reg_spacing;
1625 u8 len = dm->length; 1625 u8 len = readb(&dm->length);
1626 dmi_ipmi_data_t *ipmi_data = dmi_data+intf_num; 1626 dmi_ipmi_data_t *ipmi_data = dmi_data+intf_num;
1627 1627
1628 ipmi_data->type = data[4]; 1628 ipmi_data->type = readb(&data[4]);
1629 1629
1630 memcpy(&base_addr, data+8, sizeof(unsigned long)); 1630 memcpy(&base_addr, data+8, sizeof(unsigned long));
1631 if (len >= 0x11) { 1631 if (len >= 0x11) {
@@ -1640,12 +1640,12 @@ static int decode_dmi(dmi_header_t *dm, int intf_num)
1640 } 1640 }
1641 /* If bit 4 of byte 0x10 is set, then the lsb for the address 1641 /* If bit 4 of byte 0x10 is set, then the lsb for the address
1642 is odd. */ 1642 is odd. */
1643 ipmi_data->base_addr = base_addr | ((data[0x10] & 0x10) >> 4); 1643 ipmi_data->base_addr = base_addr | ((readb(&data[0x10]) & 0x10) >> 4);
1644 1644
1645 ipmi_data->irq = data[0x11]; 1645 ipmi_data->irq = readb(&data[0x11]);
1646 1646
1647 /* The top two bits of byte 0x10 hold the register spacing. */ 1647 /* The top two bits of byte 0x10 hold the register spacing. */
1648 reg_spacing = (data[0x10] & 0xC0) >> 6; 1648 reg_spacing = (readb(&data[0x10]) & 0xC0) >> 6;
1649 switch(reg_spacing){ 1649 switch(reg_spacing){
1650 case 0x00: /* Byte boundaries */ 1650 case 0x00: /* Byte boundaries */
1651 ipmi_data->offset = 1; 1651 ipmi_data->offset = 1;
@@ -1673,7 +1673,7 @@ static int decode_dmi(dmi_header_t *dm, int intf_num)
1673 ipmi_data->offset = 1; 1673 ipmi_data->offset = 1;
1674 } 1674 }
1675 1675
1676 ipmi_data->slave_addr = data[6]; 1676 ipmi_data->slave_addr = readb(&data[6]);
1677 1677
1678 if (is_new_interface(-1, ipmi_data->addr_space,ipmi_data->base_addr)) { 1678 if (is_new_interface(-1, ipmi_data->addr_space,ipmi_data->base_addr)) {
1679 dmi_data_entries++; 1679 dmi_data_entries++;
@@ -1687,9 +1687,9 @@ static int decode_dmi(dmi_header_t *dm, int intf_num)
1687 1687
1688static int dmi_table(u32 base, int len, int num) 1688static int dmi_table(u32 base, int len, int num)
1689{ 1689{
1690 u8 *buf; 1690 u8 __iomem *buf;
1691 struct dmi_header *dm; 1691 struct dmi_header __iomem *dm;
1692 u8 *data; 1692 u8 __iomem *data;
1693 int i=1; 1693 int i=1;
1694 int status=-1; 1694 int status=-1;
1695 int intf_num = 0; 1695 int intf_num = 0;
@@ -1702,12 +1702,12 @@ static int dmi_table(u32 base, int len, int num)
1702 1702
1703 while(i<num && (data - buf) < len) 1703 while(i<num && (data - buf) < len)
1704 { 1704 {
1705 dm=(dmi_header_t *)data; 1705 dm=(dmi_header_t __iomem *)data;
1706 1706
1707 if((data-buf+dm->length) >= len) 1707 if((data-buf+readb(&dm->length)) >= len)
1708 break; 1708 break;
1709 1709
1710 if (dm->type == 38) { 1710 if (readb(&dm->type) == 38) {
1711 if (decode_dmi(dm, intf_num) == 0) { 1711 if (decode_dmi(dm, intf_num) == 0) {
1712 intf_num++; 1712 intf_num++;
1713 if (intf_num >= SI_MAX_DRIVERS) 1713 if (intf_num >= SI_MAX_DRIVERS)
@@ -1715,8 +1715,8 @@ static int dmi_table(u32 base, int len, int num)
1715 } 1715 }
1716 } 1716 }
1717 1717
1718 data+=dm->length; 1718 data+=readb(&dm->length);
1719 while((data-buf) < len && (*data || data[1])) 1719 while((data-buf) < len && (readb(data)||readb(data+1)))
1720 data++; 1720 data++;
1721 data+=2; 1721 data+=2;
1722 i++; 1722 i++;
diff --git a/drivers/char/ipmi/ipmi_si_sm.h b/drivers/char/ipmi/ipmi_si_sm.h
index a0212b004016..62791dd42985 100644
--- a/drivers/char/ipmi/ipmi_si_sm.h
+++ b/drivers/char/ipmi/ipmi_si_sm.h
@@ -51,7 +51,7 @@ struct si_sm_io
51 /* Generic info used by the actual handling routines, the 51 /* Generic info used by the actual handling routines, the
52 state machine shouldn't touch these. */ 52 state machine shouldn't touch these. */
53 void *info; 53 void *info;
54 void *addr; 54 void __iomem *addr;
55 int regspacing; 55 int regspacing;
56 int regsize; 56 int regsize;
57 int regshift; 57 int regshift;
diff --git a/drivers/char/mbcs.c b/drivers/char/mbcs.c
index ec7100556c50..ac9cfa9701ea 100644
--- a/drivers/char/mbcs.c
+++ b/drivers/char/mbcs.c
@@ -394,7 +394,7 @@ int mbcs_open(struct inode *ip, struct file *fp)
394 return -ENODEV; 394 return -ENODEV;
395} 395}
396 396
397ssize_t mbcs_sram_read(struct file * fp, char *buf, size_t len, loff_t * off) 397ssize_t mbcs_sram_read(struct file * fp, char __user *buf, size_t len, loff_t * off)
398{ 398{
399 struct cx_dev *cx_dev = fp->private_data; 399 struct cx_dev *cx_dev = fp->private_data;
400 struct mbcs_soft *soft = cx_dev->soft; 400 struct mbcs_soft *soft = cx_dev->soft;
@@ -419,7 +419,7 @@ ssize_t mbcs_sram_read(struct file * fp, char *buf, size_t len, loff_t * off)
419} 419}
420 420
421ssize_t 421ssize_t
422mbcs_sram_write(struct file * fp, const char *buf, size_t len, loff_t * off) 422mbcs_sram_write(struct file * fp, const char __user *buf, size_t len, loff_t * off)
423{ 423{
424 struct cx_dev *cx_dev = fp->private_data; 424 struct cx_dev *cx_dev = fp->private_data;
425 struct mbcs_soft *soft = cx_dev->soft; 425 struct mbcs_soft *soft = cx_dev->soft;
diff --git a/drivers/char/mbcs.h b/drivers/char/mbcs.h
index 844644d201c5..e7fd47e43257 100644
--- a/drivers/char/mbcs.h
+++ b/drivers/char/mbcs.h
@@ -543,9 +543,9 @@ struct mbcs_soft {
543}; 543};
544 544
545extern int mbcs_open(struct inode *ip, struct file *fp); 545extern int mbcs_open(struct inode *ip, struct file *fp);
546extern ssize_t mbcs_sram_read(struct file *fp, char *buf, size_t len, 546extern ssize_t mbcs_sram_read(struct file *fp, char __user *buf, size_t len,
547 loff_t * off); 547 loff_t * off);
548extern ssize_t mbcs_sram_write(struct file *fp, const char *buf, size_t len, 548extern ssize_t mbcs_sram_write(struct file *fp, const char __user *buf, size_t len,
549 loff_t * off); 549 loff_t * off);
550extern loff_t mbcs_sram_llseek(struct file *filp, loff_t off, int whence); 550extern loff_t mbcs_sram_llseek(struct file *filp, loff_t off, int whence);
551extern int mbcs_gscr_mmap(struct file *fp, struct vm_area_struct *vma); 551extern int mbcs_gscr_mmap(struct file *fp, struct vm_area_struct *vma);
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index c812191417c3..fd042060809a 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -1021,11 +1021,11 @@ static int sonypi_misc_ioctl(struct inode *ip, struct file *fp,
1021 ret = -EIO; 1021 ret = -EIO;
1022 break; 1022 break;
1023 } 1023 }
1024 if (copy_to_user((u8 *)arg, &val8, sizeof(val8))) 1024 if (copy_to_user(argp, &val8, sizeof(val8)))
1025 ret = -EFAULT; 1025 ret = -EFAULT;
1026 break; 1026 break;
1027 case SONYPI_IOCSFAN: 1027 case SONYPI_IOCSFAN:
1028 if (copy_from_user(&val8, (u8 *)arg, sizeof(val8))) { 1028 if (copy_from_user(&val8, argp, sizeof(val8))) {
1029 ret = -EFAULT; 1029 ret = -EFAULT;
1030 break; 1030 break;
1031 } 1031 }
@@ -1038,7 +1038,7 @@ static int sonypi_misc_ioctl(struct inode *ip, struct file *fp,
1038 ret = -EIO; 1038 ret = -EIO;
1039 break; 1039 break;
1040 } 1040 }
1041 if (copy_to_user((u8 *)arg, &val8, sizeof(val8))) 1041 if (copy_to_user(argp, &val8, sizeof(val8)))
1042 ret = -EFAULT; 1042 ret = -EFAULT;
1043 break; 1043 break;
1044 default: 1044 default:
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 72f2b466b816..2e70d74fbdee 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -51,7 +51,7 @@ config MMC_PXA
51 51
52config MMC_WBSD 52config MMC_WBSD
53 tristate "Winbond W83L51xD SD/MMC Card Interface support" 53 tristate "Winbond W83L51xD SD/MMC Card Interface support"
54 depends on MMC && ISA 54 depends on MMC && ISA && ISA_DMA_API
55 help 55 help
56 This selects the Winbond(R) W83L51xD Secure digital and 56 This selects the Winbond(R) W83L51xD Secure digital and
57 Multimedia card Interface. 57 Multimedia card Interface.
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 68242bda4b9c..3a0a55b62aaf 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -589,7 +589,7 @@ config EL2
589 589
590config ELPLUS 590config ELPLUS
591 tristate "3c505 \"EtherLink Plus\" support" 591 tristate "3c505 \"EtherLink Plus\" support"
592 depends on NET_VENDOR_3COM && ISA 592 depends on NET_VENDOR_3COM && ISA && ISA_DMA_API
593 ---help--- 593 ---help---
594 Information about this network (Ethernet) card can be found in 594 Information about this network (Ethernet) card can be found in
595 <file:Documentation/networking/3c505.txt>. If you have a card of 595 <file:Documentation/networking/3c505.txt>. If you have a card of
@@ -630,7 +630,7 @@ config EL3
630 630
631config 3C515 631config 3C515
632 tristate "3c515 ISA \"Fast EtherLink\"" 632 tristate "3c515 ISA \"Fast EtherLink\""
633 depends on NET_VENDOR_3COM && (ISA || EISA) 633 depends on NET_VENDOR_3COM && (ISA || EISA) && ISA_DMA_API
634 help 634 help
635 If you have a 3Com ISA EtherLink XL "Corkscrew" 3c515 Fast Ethernet 635 If you have a 3Com ISA EtherLink XL "Corkscrew" 3c515 Fast Ethernet
636 network card, say Y and read the Ethernet-HOWTO, available from 636 network card, say Y and read the Ethernet-HOWTO, available from
@@ -708,7 +708,7 @@ config TYPHOON
708 708
709config LANCE 709config LANCE
710 tristate "AMD LANCE and PCnet (AT1500 and NE2100) support" 710 tristate "AMD LANCE and PCnet (AT1500 and NE2100) support"
711 depends on NET_ETHERNET && ISA 711 depends on NET_ETHERNET && ISA && ISA_DMA_API
712 help 712 help
713 If you have a network (Ethernet) card of this type, say Y and read 713 If you have a network (Ethernet) card of this type, say Y and read
714 the Ethernet-HOWTO, available from 714 the Ethernet-HOWTO, available from
@@ -864,7 +864,7 @@ config NI52
864 864
865config NI65 865config NI65
866 tristate "NI6510 support" 866 tristate "NI6510 support"
867 depends on NET_VENDOR_RACAL && ISA 867 depends on NET_VENDOR_RACAL && ISA && ISA_DMA_API
868 help 868 help
869 If you have a network (Ethernet) card of this type, say Y and read 869 If you have a network (Ethernet) card of this type, say Y and read
870 the Ethernet-HOWTO, available from 870 the Ethernet-HOWTO, available from
@@ -1072,7 +1072,7 @@ config NE2000
1072 1072
1073config ZNET 1073config ZNET
1074 tristate "Zenith Z-Note support (EXPERIMENTAL)" 1074 tristate "Zenith Z-Note support (EXPERIMENTAL)"
1075 depends on NET_ISA && EXPERIMENTAL 1075 depends on NET_ISA && EXPERIMENTAL && ISA_DMA_API
1076 help 1076 help
1077 The Zenith Z-Note notebook computer has a built-in network 1077 The Zenith Z-Note notebook computer has a built-in network
1078 (Ethernet) card, and this is the Linux driver for it. Note that the 1078 (Ethernet) card, and this is the Linux driver for it. Note that the
diff --git a/drivers/net/appletalk/Kconfig b/drivers/net/appletalk/Kconfig
index 60b19679ca5c..69c488d933a2 100644
--- a/drivers/net/appletalk/Kconfig
+++ b/drivers/net/appletalk/Kconfig
@@ -13,7 +13,7 @@ config DEV_APPLETALK
13 13
14config LTPC 14config LTPC
15 tristate "Apple/Farallon LocalTalk PC support" 15 tristate "Apple/Farallon LocalTalk PC support"
16 depends on DEV_APPLETALK && (ISA || EISA) 16 depends on DEV_APPLETALK && (ISA || EISA) && ISA_DMA_API
17 help 17 help
18 This allows you to use the AppleTalk PC card to connect to LocalTalk 18 This allows you to use the AppleTalk PC card to connect to LocalTalk
19 networks. The card is also known as the Farallon PhoneNet PC card. 19 networks. The card is also known as the Farallon PhoneNet PC card.
diff --git a/drivers/net/hamradio/Kconfig b/drivers/net/hamradio/Kconfig
index 34068f81d45e..7cdebe1a0b61 100644
--- a/drivers/net/hamradio/Kconfig
+++ b/drivers/net/hamradio/Kconfig
@@ -45,7 +45,7 @@ config BPQETHER
45 45
46config DMASCC 46config DMASCC
47 tristate "High-speed (DMA) SCC driver for AX.25" 47 tristate "High-speed (DMA) SCC driver for AX.25"
48 depends on ISA && AX25 && BROKEN_ON_SMP 48 depends on ISA && AX25 && BROKEN_ON_SMP && ISA_DMA_API
49 ---help--- 49 ---help---
50 This is a driver for high-speed SCC boards, i.e. those supporting 50 This is a driver for high-speed SCC boards, i.e. those supporting
51 DMA on one port. You usually use those boards to connect your 51 DMA on one port. You usually use those boards to connect your
@@ -78,7 +78,7 @@ config DMASCC
78 78
79config SCC 79config SCC
80 tristate "Z8530 SCC driver" 80 tristate "Z8530 SCC driver"
81 depends on ISA && AX25 81 depends on ISA && AX25 && ISA_DMA_API
82 ---help--- 82 ---help---
83 These cards are used to connect your Linux box to an amateur radio 83 These cards are used to connect your Linux box to an amateur radio
84 in order to communicate with other computers. If you want to use 84 in order to communicate with other computers. If you want to use
diff --git a/drivers/net/irda/Kconfig b/drivers/net/irda/Kconfig
index 6bf76a444d48..1c553d7efdd9 100644
--- a/drivers/net/irda/Kconfig
+++ b/drivers/net/irda/Kconfig
@@ -310,7 +310,7 @@ config SIGMATEL_FIR
310 310
311config NSC_FIR 311config NSC_FIR
312 tristate "NSC PC87108/PC87338" 312 tristate "NSC PC87108/PC87338"
313 depends on IRDA 313 depends on IRDA && ISA_DMA_API
314 help 314 help
315 Say Y here if you want to build support for the NSC PC87108 and 315 Say Y here if you want to build support for the NSC PC87108 and
316 PC87338 IrDA chipsets. This driver supports SIR, 316 PC87338 IrDA chipsets. This driver supports SIR,
@@ -321,7 +321,7 @@ config NSC_FIR
321 321
322config WINBOND_FIR 322config WINBOND_FIR
323 tristate "Winbond W83977AF (IR)" 323 tristate "Winbond W83977AF (IR)"
324 depends on IRDA 324 depends on IRDA && ISA_DMA_API
325 help 325 help
326 Say Y here if you want to build IrDA support for the Winbond 326 Say Y here if you want to build IrDA support for the Winbond
327 W83977AF super-io chipset. This driver should be used for the IrDA 327 W83977AF super-io chipset. This driver should be used for the IrDA
@@ -347,7 +347,7 @@ config AU1000_FIR
347 347
348config SMC_IRCC_FIR 348config SMC_IRCC_FIR
349 tristate "SMSC IrCC (EXPERIMENTAL)" 349 tristate "SMSC IrCC (EXPERIMENTAL)"
350 depends on EXPERIMENTAL && IRDA 350 depends on EXPERIMENTAL && IRDA && ISA_DMA_API
351 help 351 help
352 Say Y here if you want to build support for the SMC Infrared 352 Say Y here if you want to build support for the SMC Infrared
353 Communications Controller. It is used in a wide variety of 353 Communications Controller. It is used in a wide variety of
@@ -357,7 +357,7 @@ config SMC_IRCC_FIR
357 357
358config ALI_FIR 358config ALI_FIR
359 tristate "ALi M5123 FIR (EXPERIMENTAL)" 359 tristate "ALi M5123 FIR (EXPERIMENTAL)"
360 depends on EXPERIMENTAL && IRDA 360 depends on EXPERIMENTAL && IRDA && ISA_DMA_API
361 help 361 help
362 Say Y here if you want to build support for the ALi M5123 FIR 362 Say Y here if you want to build support for the ALi M5123 FIR
363 Controller. The ALi M5123 FIR Controller is embedded in ALi M1543C, 363 Controller. The ALi M5123 FIR Controller is embedded in ALi M1543C,
@@ -385,7 +385,7 @@ config SA1100_FIR
385 385
386config VIA_FIR 386config VIA_FIR
387 tristate "VIA VT8231/VT1211 SIR/MIR/FIR" 387 tristate "VIA VT8231/VT1211 SIR/MIR/FIR"
388 depends on IRDA 388 depends on IRDA && ISA_DMA_API
389 help 389 help
390 Say Y here if you want to build support for the VIA VT8231 390 Say Y here if you want to build support for the VIA VT8231
391 and VIA VT1211 IrDA controllers, found on the motherboards using 391 and VIA VT1211 IrDA controllers, found on the motherboards using
diff --git a/drivers/net/ppp_deflate.c b/drivers/net/ppp_deflate.c
index 507d6328d4eb..3872088fdd10 100644
--- a/drivers/net/ppp_deflate.c
+++ b/drivers/net/ppp_deflate.c
@@ -87,8 +87,7 @@ static void z_comp_free(void *arg)
87 87
88 if (state) { 88 if (state) {
89 zlib_deflateEnd(&state->strm); 89 zlib_deflateEnd(&state->strm);
90 if (state->strm.workspace) 90 vfree(state->strm.workspace);
91 vfree(state->strm.workspace);
92 kfree(state); 91 kfree(state);
93 } 92 }
94} 93}
@@ -308,8 +307,7 @@ static void z_decomp_free(void *arg)
308 307
309 if (state) { 308 if (state) {
310 zlib_inflateEnd(&state->strm); 309 zlib_inflateEnd(&state->strm);
311 if (state->strm.workspace) 310 kfree(state->strm.workspace);
312 kfree(state->strm.workspace);
313 kfree(state); 311 kfree(state);
314 } 312 }
315} 313}
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index c456dc81b873..3b377f6cd4a0 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -2467,14 +2467,10 @@ static void ppp_destroy_interface(struct ppp *ppp)
2467 skb_queue_purge(&ppp->mrq); 2467 skb_queue_purge(&ppp->mrq);
2468#endif /* CONFIG_PPP_MULTILINK */ 2468#endif /* CONFIG_PPP_MULTILINK */
2469#ifdef CONFIG_PPP_FILTER 2469#ifdef CONFIG_PPP_FILTER
2470 if (ppp->pass_filter) { 2470 kfree(ppp->pass_filter);
2471 kfree(ppp->pass_filter); 2471 ppp->pass_filter = NULL;
2472 ppp->pass_filter = NULL; 2472 kfree(ppp->active_filter);
2473 } 2473 ppp->active_filter = NULL;
2474 if (ppp->active_filter) {
2475 kfree(ppp->active_filter);
2476 ppp->active_filter = NULL;
2477 }
2478#endif /* CONFIG_PPP_FILTER */ 2474#endif /* CONFIG_PPP_FILTER */
2479 2475
2480 kfree(ppp); 2476 kfree(ppp);
diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig
index 35791934a602..66b94668ddd8 100644
--- a/drivers/net/wan/Kconfig
+++ b/drivers/net/wan/Kconfig
@@ -26,7 +26,7 @@ config WAN
26# There is no way to detect a comtrol sv11 - force it modular for now. 26# There is no way to detect a comtrol sv11 - force it modular for now.
27config HOSTESS_SV11 27config HOSTESS_SV11
28 tristate "Comtrol Hostess SV-11 support" 28 tristate "Comtrol Hostess SV-11 support"
29 depends on WAN && ISA && m 29 depends on WAN && ISA && m && ISA_DMA_API
30 help 30 help
31 Driver for Comtrol Hostess SV-11 network card which 31 Driver for Comtrol Hostess SV-11 network card which
32 operates on low speed synchronous serial links at up to 32 operates on low speed synchronous serial links at up to
@@ -38,7 +38,7 @@ config HOSTESS_SV11
38# The COSA/SRP driver has not been tested as non-modular yet. 38# The COSA/SRP driver has not been tested as non-modular yet.
39config COSA 39config COSA
40 tristate "COSA/SRP sync serial boards support" 40 tristate "COSA/SRP sync serial boards support"
41 depends on WAN && ISA && m 41 depends on WAN && ISA && m && ISA_DMA_API
42 ---help--- 42 ---help---
43 Driver for COSA and SRP synchronous serial boards. 43 Driver for COSA and SRP synchronous serial boards.
44 44
@@ -127,7 +127,7 @@ config LANMEDIA
127# There is no way to detect a Sealevel board. Force it modular 127# There is no way to detect a Sealevel board. Force it modular
128config SEALEVEL_4021 128config SEALEVEL_4021
129 tristate "Sealevel Systems 4021 support" 129 tristate "Sealevel Systems 4021 support"
130 depends on WAN && ISA && m 130 depends on WAN && ISA && m && ISA_DMA_API
131 help 131 help
132 This is a driver for the Sealevel Systems ACB 56 serial I/O adapter. 132 This is a driver for the Sealevel Systems ACB 56 serial I/O adapter.
133 133
diff --git a/drivers/net/wan/cycx_x25.c b/drivers/net/wan/cycx_x25.c
index 5b48cd8568f5..02d57c0b4243 100644
--- a/drivers/net/wan/cycx_x25.c
+++ b/drivers/net/wan/cycx_x25.c
@@ -436,9 +436,7 @@ static int cycx_wan_new_if(struct wan_device *wandev, struct net_device *dev,
436 } 436 }
437 437
438 if (err) { 438 if (err) {
439 if (chan->local_addr) 439 kfree(chan->local_addr);
440 kfree(chan->local_addr);
441
442 kfree(chan); 440 kfree(chan);
443 return err; 441 return err;
444 } 442 }
@@ -458,9 +456,7 @@ static int cycx_wan_del_if(struct wan_device *wandev, struct net_device *dev)
458 struct cycx_x25_channel *chan = dev->priv; 456 struct cycx_x25_channel *chan = dev->priv;
459 457
460 if (chan->svc) { 458 if (chan->svc) {
461 if (chan->local_addr) 459 kfree(chan->local_addr);
462 kfree(chan->local_addr);
463
464 if (chan->state == WAN_CONNECTED) 460 if (chan->state == WAN_CONNECTED)
465 del_timer(&chan->timer); 461 del_timer(&chan->timer);
466 } 462 }
diff --git a/drivers/net/wan/pc300_tty.c b/drivers/net/wan/pc300_tty.c
index 29f84ad08730..8454bf6caaa7 100644
--- a/drivers/net/wan/pc300_tty.c
+++ b/drivers/net/wan/pc300_tty.c
@@ -400,10 +400,8 @@ static void cpc_tty_close(struct tty_struct *tty, struct file *flip)
400 cpc_tty->buf_rx.last = NULL; 400 cpc_tty->buf_rx.last = NULL;
401 } 401 }
402 402
403 if (cpc_tty->buf_tx) { 403 kfree(cpc_tty->buf_tx);
404 kfree(cpc_tty->buf_tx); 404 cpc_tty->buf_tx = NULL;
405 cpc_tty->buf_tx = NULL;
406 }
407 405
408 CPC_TTY_DBG("%s: TTY closed\n",cpc_tty->name); 406 CPC_TTY_DBG("%s: TTY closed\n",cpc_tty->name);
409 407
@@ -666,7 +664,7 @@ static void cpc_tty_rx_work(void * data)
666 unsigned long port; 664 unsigned long port;
667 int i, j; 665 int i, j;
668 st_cpc_tty_area *cpc_tty; 666 st_cpc_tty_area *cpc_tty;
669 volatile st_cpc_rx_buf * buf; 667 volatile st_cpc_rx_buf *buf;
670 char flags=0,flg_rx=1; 668 char flags=0,flg_rx=1;
671 struct tty_ldisc *ld; 669 struct tty_ldisc *ld;
672 670
@@ -680,9 +678,9 @@ static void cpc_tty_rx_work(void * data)
680 cpc_tty = &cpc_tty_area[port]; 678 cpc_tty = &cpc_tty_area[port];
681 679
682 if ((buf=cpc_tty->buf_rx.first) != 0) { 680 if ((buf=cpc_tty->buf_rx.first) != 0) {
683 if(cpc_tty->tty) { 681 if (cpc_tty->tty) {
684 ld = tty_ldisc_ref(cpc_tty->tty); 682 ld = tty_ldisc_ref(cpc_tty->tty);
685 if(ld) { 683 if (ld) {
686 if (ld->receive_buf) { 684 if (ld->receive_buf) {
687 CPC_TTY_DBG("%s: call line disc. receive_buf\n",cpc_tty->name); 685 CPC_TTY_DBG("%s: call line disc. receive_buf\n",cpc_tty->name);
688 ld->receive_buf(cpc_tty->tty, (char *)(buf->data), &flags, buf->size); 686 ld->receive_buf(cpc_tty->tty, (char *)(buf->data), &flags, buf->size);
@@ -691,7 +689,7 @@ static void cpc_tty_rx_work(void * data)
691 } 689 }
692 } 690 }
693 cpc_tty->buf_rx.first = cpc_tty->buf_rx.first->next; 691 cpc_tty->buf_rx.first = cpc_tty->buf_rx.first->next;
694 kfree((unsigned char *)buf); 692 kfree(buf);
695 buf = cpc_tty->buf_rx.first; 693 buf = cpc_tty->buf_rx.first;
696 flg_rx = 1; 694 flg_rx = 1;
697 } 695 }
@@ -733,7 +731,7 @@ static void cpc_tty_rx_disc_frame(pc300ch_t *pc300chan)
733 731
734void cpc_tty_receive(pc300dev_t *pc300dev) 732void cpc_tty_receive(pc300dev_t *pc300dev)
735{ 733{
736 st_cpc_tty_area *cpc_tty; 734 st_cpc_tty_area *cpc_tty;
737 pc300ch_t *pc300chan = (pc300ch_t *)pc300dev->chan; 735 pc300ch_t *pc300chan = (pc300ch_t *)pc300dev->chan;
738 pc300_t *card = (pc300_t *)pc300chan->card; 736 pc300_t *card = (pc300_t *)pc300chan->card;
739 int ch = pc300chan->channel; 737 int ch = pc300chan->channel;
@@ -742,7 +740,7 @@ void cpc_tty_receive(pc300dev_t *pc300dev)
742 int rx_len, rx_aux; 740 int rx_len, rx_aux;
743 volatile unsigned char status; 741 volatile unsigned char status;
744 unsigned short first_bd = pc300chan->rx_first_bd; 742 unsigned short first_bd = pc300chan->rx_first_bd;
745 st_cpc_rx_buf *new=NULL; 743 st_cpc_rx_buf *new = NULL;
746 unsigned char dsr_rx; 744 unsigned char dsr_rx;
747 745
748 if (pc300dev->cpc_tty == NULL) { 746 if (pc300dev->cpc_tty == NULL) {
@@ -762,7 +760,7 @@ void cpc_tty_receive(pc300dev_t *pc300dev)
762 if (status & DST_EOM) { 760 if (status & DST_EOM) {
763 break; 761 break;
764 } 762 }
765 ptdescr=(pcsca_bd_t __iomem *)(card->hw.rambase+cpc_readl(&ptdescr->next)); 763 ptdescr = (pcsca_bd_t __iomem *)(card->hw.rambase+cpc_readl(&ptdescr->next));
766 } 764 }
767 765
768 if (!rx_len) { 766 if (!rx_len) {
@@ -771,10 +769,7 @@ void cpc_tty_receive(pc300dev_t *pc300dev)
771 cpc_writel(card->hw.scabase + DRX_REG(EDAL, ch), 769 cpc_writel(card->hw.scabase + DRX_REG(EDAL, ch),
772 RX_BD_ADDR(ch, pc300chan->rx_last_bd)); 770 RX_BD_ADDR(ch, pc300chan->rx_last_bd));
773 } 771 }
774 if (new) { 772 kfree(new);
775 kfree(new);
776 new = NULL;
777 }
778 return; 773 return;
779 } 774 }
780 775
@@ -787,7 +782,7 @@ void cpc_tty_receive(pc300dev_t *pc300dev)
787 continue; 782 continue;
788 } 783 }
789 784
790 new = (st_cpc_rx_buf *) kmalloc(rx_len + sizeof(st_cpc_rx_buf), GFP_ATOMIC); 785 new = (st_cpc_rx_buf *)kmalloc(rx_len + sizeof(st_cpc_rx_buf), GFP_ATOMIC);
791 if (new == 0) { 786 if (new == 0) {
792 cpc_tty_rx_disc_frame(pc300chan); 787 cpc_tty_rx_disc_frame(pc300chan);
793 continue; 788 continue;
diff --git a/drivers/net/wan/sdla_chdlc.c b/drivers/net/wan/sdla_chdlc.c
index afbe0024e3e1..496d29237e92 100644
--- a/drivers/net/wan/sdla_chdlc.c
+++ b/drivers/net/wan/sdla_chdlc.c
@@ -3664,15 +3664,10 @@ static void wanpipe_tty_close(struct tty_struct *tty, struct file * filp)
3664 chdlc_disable_comm_shutdown(card); 3664 chdlc_disable_comm_shutdown(card);
3665 unlock_adapter_irq(&card->wandev.lock,&smp_flags); 3665 unlock_adapter_irq(&card->wandev.lock,&smp_flags);
3666 3666
3667 if (card->tty_buf){ 3667 kfree(card->tty_buf);
3668 kfree(card->tty_buf); 3668 card->tty_buf = NULL;
3669 card->tty_buf=NULL; 3669 kfree(card->tty_rx);
3670 } 3670 card->tty_rx = NULL;
3671
3672 if (card->tty_rx){
3673 kfree(card->tty_rx);
3674 card->tty_rx=NULL;
3675 }
3676 } 3671 }
3677 return; 3672 return;
3678} 3673}
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
index 8c5cfcb55826..1c540d825551 100644
--- a/drivers/net/wan/x25_asy.c
+++ b/drivers/net/wan/x25_asy.c
@@ -107,13 +107,9 @@ static struct x25_asy *x25_asy_alloc(void)
107static void x25_asy_free(struct x25_asy *sl) 107static void x25_asy_free(struct x25_asy *sl)
108{ 108{
109 /* Free all X.25 frame buffers. */ 109 /* Free all X.25 frame buffers. */
110 if (sl->rbuff) { 110 kfree(sl->rbuff);
111 kfree(sl->rbuff);
112 }
113 sl->rbuff = NULL; 111 sl->rbuff = NULL;
114 if (sl->xbuff) { 112 kfree(sl->xbuff);
115 kfree(sl->xbuff);
116 }
117 sl->xbuff = NULL; 113 sl->xbuff = NULL;
118 114
119 if (!test_and_clear_bit(SLF_INUSE, &sl->flags)) { 115 if (!test_and_clear_bit(SLF_INUSE, &sl->flags)) {
@@ -134,10 +130,8 @@ static int x25_asy_change_mtu(struct net_device *dev, int newmtu)
134 { 130 {
135 printk("%s: unable to grow X.25 buffers, MTU change cancelled.\n", 131 printk("%s: unable to grow X.25 buffers, MTU change cancelled.\n",
136 dev->name); 132 dev->name);
137 if (xbuff != NULL) 133 kfree(xbuff);
138 kfree(xbuff); 134 kfree(rbuff);
139 if (rbuff != NULL)
140 kfree(rbuff);
141 return -ENOMEM; 135 return -ENOMEM;
142 } 136 }
143 137
@@ -169,10 +163,8 @@ static int x25_asy_change_mtu(struct net_device *dev, int newmtu)
169 163
170 spin_unlock_bh(&sl->lock); 164 spin_unlock_bh(&sl->lock);
171 165
172 if (xbuff != NULL) 166 kfree(xbuff);
173 kfree(xbuff); 167 kfree(rbuff);
174 if (rbuff != NULL)
175 kfree(rbuff);
176 return 0; 168 return 0;
177} 169}
178 170
diff --git a/drivers/parport/Kconfig b/drivers/parport/Kconfig
index 731010e0e6f6..16a2e6ae37f4 100644
--- a/drivers/parport/Kconfig
+++ b/drivers/parport/Kconfig
@@ -34,7 +34,7 @@ config PARPORT
34 34
35config PARPORT_PC 35config PARPORT_PC
36 tristate "PC-style hardware" 36 tristate "PC-style hardware"
37 depends on PARPORT && (!SPARC64 || PCI) && (!SPARC32 || BROKEN) 37 depends on PARPORT && (!SPARC64 || PCI) && !SPARC32
38 ---help--- 38 ---help---
39 You should say Y here if you have a PC-style parallel port. All 39 You should say Y here if you have a PC-style parallel port. All
40 IBM PC compatible computers and some Alphas have PC-style 40 IBM PC compatible computers and some Alphas have PC-style
diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
index c5774e7855d0..e7f3bcb79000 100644
--- a/drivers/parport/parport_pc.c
+++ b/drivers/parport/parport_pc.c
@@ -67,6 +67,10 @@
67 67
68#define PARPORT_PC_MAX_PORTS PARPORT_MAX 68#define PARPORT_PC_MAX_PORTS PARPORT_MAX
69 69
70#ifdef CONFIG_ISA_DMA_API
71#define HAS_DMA
72#endif
73
70/* ECR modes */ 74/* ECR modes */
71#define ECR_SPP 00 75#define ECR_SPP 00
72#define ECR_PS2 01 76#define ECR_PS2 01
@@ -610,6 +614,7 @@ dump_parport_state ("leave fifo_write_block_pio", port);
610 return length - left; 614 return length - left;
611} 615}
612 616
617#ifdef HAS_DMA
613static size_t parport_pc_fifo_write_block_dma (struct parport *port, 618static size_t parport_pc_fifo_write_block_dma (struct parport *port,
614 const void *buf, size_t length) 619 const void *buf, size_t length)
615{ 620{
@@ -732,6 +737,17 @@ dump_parport_state ("enter fifo_write_block_dma", port);
732dump_parport_state ("leave fifo_write_block_dma", port); 737dump_parport_state ("leave fifo_write_block_dma", port);
733 return length - left; 738 return length - left;
734} 739}
740#endif
741
742static inline size_t parport_pc_fifo_write_block(struct parport *port,
743 const void *buf, size_t length)
744{
745#ifdef HAS_DMA
746 if (port->dma != PARPORT_DMA_NONE)
747 return parport_pc_fifo_write_block_dma (port, buf, length);
748#endif
749 return parport_pc_fifo_write_block_pio (port, buf, length);
750}
735 751
736/* Parallel Port FIFO mode (ECP chipsets) */ 752/* Parallel Port FIFO mode (ECP chipsets) */
737static size_t parport_pc_compat_write_block_pio (struct parport *port, 753static size_t parport_pc_compat_write_block_pio (struct parport *port,
@@ -758,10 +774,7 @@ static size_t parport_pc_compat_write_block_pio (struct parport *port,
758 port->physport->ieee1284.phase = IEEE1284_PH_FWD_DATA; 774 port->physport->ieee1284.phase = IEEE1284_PH_FWD_DATA;
759 775
760 /* Write the data to the FIFO. */ 776 /* Write the data to the FIFO. */
761 if (port->dma != PARPORT_DMA_NONE) 777 written = parport_pc_fifo_write_block(port, buf, length);
762 written = parport_pc_fifo_write_block_dma (port, buf, length);
763 else
764 written = parport_pc_fifo_write_block_pio (port, buf, length);
765 778
766 /* Finish up. */ 779 /* Finish up. */
767 /* For some hardware we don't want to touch the mode until 780 /* For some hardware we don't want to touch the mode until
@@ -856,10 +869,7 @@ static size_t parport_pc_ecp_write_block_pio (struct parport *port,
856 port->physport->ieee1284.phase = IEEE1284_PH_FWD_DATA; 869 port->physport->ieee1284.phase = IEEE1284_PH_FWD_DATA;
857 870
858 /* Write the data to the FIFO. */ 871 /* Write the data to the FIFO. */
859 if (port->dma != PARPORT_DMA_NONE) 872 written = parport_pc_fifo_write_block(port, buf, length);
860 written = parport_pc_fifo_write_block_dma (port, buf, length);
861 else
862 written = parport_pc_fifo_write_block_pio (port, buf, length);
863 873
864 /* Finish up. */ 874 /* Finish up. */
865 /* For some hardware we don't want to touch the mode until 875 /* For some hardware we don't want to touch the mode until
@@ -2285,6 +2295,7 @@ struct parport *parport_pc_probe_port (unsigned long int base,
2285 } 2295 }
2286 2296
2287#ifdef CONFIG_PARPORT_PC_FIFO 2297#ifdef CONFIG_PARPORT_PC_FIFO
2298#ifdef HAS_DMA
2288 if (p->dma != PARPORT_DMA_NONE) { 2299 if (p->dma != PARPORT_DMA_NONE) {
2289 if (request_dma (p->dma, p->name)) { 2300 if (request_dma (p->dma, p->name)) {
2290 printk (KERN_WARNING "%s: dma %d in use, " 2301 printk (KERN_WARNING "%s: dma %d in use, "
@@ -2306,7 +2317,8 @@ struct parport *parport_pc_probe_port (unsigned long int base,
2306 } 2317 }
2307 } 2318 }
2308 } 2319 }
2309#endif /* CONFIG_PARPORT_PC_FIFO */ 2320#endif
2321#endif
2310 } 2322 }
2311 2323
2312 /* Done probing. Now put the port into a sensible start-up state. */ 2324 /* Done probing. Now put the port into a sensible start-up state. */
@@ -2367,11 +2379,13 @@ void parport_pc_unregister_port (struct parport *p)
2367 if (p->modes & PARPORT_MODE_ECP) 2379 if (p->modes & PARPORT_MODE_ECP)
2368 release_region(p->base_hi, 3); 2380 release_region(p->base_hi, 3);
2369#ifdef CONFIG_PARPORT_PC_FIFO 2381#ifdef CONFIG_PARPORT_PC_FIFO
2382#ifdef HAS_DMA
2370 if (priv->dma_buf) 2383 if (priv->dma_buf)
2371 pci_free_consistent(priv->dev, PAGE_SIZE, 2384 pci_free_consistent(priv->dev, PAGE_SIZE,
2372 priv->dma_buf, 2385 priv->dma_buf,
2373 priv->dma_handle); 2386 priv->dma_handle);
2374#endif /* CONFIG_PARPORT_PC_FIFO */ 2387#endif
2388#endif
2375 kfree (p->private_data); 2389 kfree (p->private_data);
2376 parport_put_port(p); 2390 parport_put_port(p);
2377 kfree (ops); /* hope no-one cached it */ 2391 kfree (ops); /* hope no-one cached it */
diff --git a/drivers/pci/hotplug/ibmphp.h b/drivers/pci/hotplug/ibmphp.h
index 5bc039da647f..c22e0284d7b1 100644
--- a/drivers/pci/hotplug/ibmphp.h
+++ b/drivers/pci/hotplug/ibmphp.h
@@ -196,7 +196,7 @@ struct ebda_hpc_bus {
196 196
197 197
198/******************************************************************** 198/********************************************************************
199* THREE TYPE OF HOT PLUG CONTROLER * 199* THREE TYPE OF HOT PLUG CONTROLLER *
200********************************************************************/ 200********************************************************************/
201 201
202struct isa_ctlr_access { 202struct isa_ctlr_access {
diff --git a/drivers/pci/hotplug/ibmphp_hpc.c b/drivers/pci/hotplug/ibmphp_hpc.c
index 6894b548c8ca..1a3eb8d3d4cb 100644
--- a/drivers/pci/hotplug/ibmphp_hpc.c
+++ b/drivers/pci/hotplug/ibmphp_hpc.c
@@ -64,7 +64,7 @@ static int to_debug = FALSE;
64#define WPG_I2C_OR 0x2000 // I2C OR operation 64#define WPG_I2C_OR 0x2000 // I2C OR operation
65 65
66//---------------------------------------------------------------------------- 66//----------------------------------------------------------------------------
67// Command set for I2C Master Operation Setup Regisetr 67// Command set for I2C Master Operation Setup Register
68//---------------------------------------------------------------------------- 68//----------------------------------------------------------------------------
69#define WPG_READATADDR_MASK 0x00010000 // read,bytes,I2C shifted,index 69#define WPG_READATADDR_MASK 0x00010000 // read,bytes,I2C shifted,index
70#define WPG_WRITEATADDR_MASK 0x40010000 // write,bytes,I2C shifted,index 70#define WPG_WRITEATADDR_MASK 0x40010000 // write,bytes,I2C shifted,index
@@ -835,7 +835,7 @@ static void poll_hpc (void)
835 if (ibmphp_shutdown) 835 if (ibmphp_shutdown)
836 break; 836 break;
837 837
838 /* try to get the lock to do some kind of harware access */ 838 /* try to get the lock to do some kind of hardware access */
839 down (&semOperations); 839 down (&semOperations);
840 840
841 switch (poll_state) { 841 switch (poll_state) {
@@ -906,7 +906,7 @@ static void poll_hpc (void)
906 poll_state = POLL_LATCH_REGISTER; 906 poll_state = POLL_LATCH_REGISTER;
907 break; 907 break;
908 } 908 }
909 /* give up the harware semaphore */ 909 /* give up the hardware semaphore */
910 up (&semOperations); 910 up (&semOperations);
911 /* sleep for a short time just for good measure */ 911 /* sleep for a short time just for good measure */
912 msleep(100); 912 msleep(100);
diff --git a/drivers/pci/hotplug/ibmphp_pci.c b/drivers/pci/hotplug/ibmphp_pci.c
index 2335fac65fb4..8122fe734aa7 100644
--- a/drivers/pci/hotplug/ibmphp_pci.c
+++ b/drivers/pci/hotplug/ibmphp_pci.c
@@ -1308,10 +1308,10 @@ static int unconfigure_boot_device (u8 busno, u8 device, u8 function)
1308 /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */ 1308 /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */
1309 } else { 1309 } else {
1310 /* This is Memory */ 1310 /* This is Memory */
1311 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1312 if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) { 1311 if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) {
1313 /* pfmem */ 1312 /* pfmem */
1314 debug ("start address of pfmem is %x\n", start_address); 1313 debug ("start address of pfmem is %x\n", start_address);
1314 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1315 1315
1316 if (ibmphp_find_resource (bus, start_address, &pfmem, PFMEM) < 0) { 1316 if (ibmphp_find_resource (bus, start_address, &pfmem, PFMEM) < 0) {
1317 err ("cannot find corresponding PFMEM resource to remove\n"); 1317 err ("cannot find corresponding PFMEM resource to remove\n");
@@ -1325,6 +1325,8 @@ static int unconfigure_boot_device (u8 busno, u8 device, u8 function)
1325 } else { 1325 } else {
1326 /* regular memory */ 1326 /* regular memory */
1327 debug ("start address of mem is %x\n", start_address); 1327 debug ("start address of mem is %x\n", start_address);
1328 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1329
1328 if (ibmphp_find_resource (bus, start_address, &mem, MEM) < 0) { 1330 if (ibmphp_find_resource (bus, start_address, &mem, MEM) < 0) {
1329 err ("cannot find corresponding MEM resource to remove\n"); 1331 err ("cannot find corresponding MEM resource to remove\n");
1330 return -EIO; 1332 return -EIO;
@@ -1422,9 +1424,9 @@ static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function)
1422 /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */ 1424 /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */
1423 } else { 1425 } else {
1424 /* This is Memory */ 1426 /* This is Memory */
1425 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1426 if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) { 1427 if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) {
1427 /* pfmem */ 1428 /* pfmem */
1429 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1428 if (ibmphp_find_resource (bus, start_address, &pfmem, PFMEM) < 0) { 1430 if (ibmphp_find_resource (bus, start_address, &pfmem, PFMEM) < 0) {
1429 err ("cannot find corresponding PFMEM resource to remove\n"); 1431 err ("cannot find corresponding PFMEM resource to remove\n");
1430 return -EINVAL; 1432 return -EINVAL;
@@ -1436,6 +1438,7 @@ static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function)
1436 } 1438 }
1437 } else { 1439 } else {
1438 /* regular memory */ 1440 /* regular memory */
1441 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1439 if (ibmphp_find_resource (bus, start_address, &mem, MEM) < 0) { 1442 if (ibmphp_find_resource (bus, start_address, &mem, MEM) < 0) {
1440 err ("cannot find corresponding MEM resource to remove\n"); 1443 err ("cannot find corresponding MEM resource to remove\n");
1441 return -EINVAL; 1444 return -EINVAL;
diff --git a/drivers/pci/hotplug/pci_hotplug.h b/drivers/pci/hotplug/pci_hotplug.h
index 57ace325168d..88d44f7fef29 100644
--- a/drivers/pci/hotplug/pci_hotplug.h
+++ b/drivers/pci/hotplug/pci_hotplug.h
@@ -150,7 +150,7 @@ struct hotplug_slot_info {
150 * @name: the name of the slot being registered. This string must 150 * @name: the name of the slot being registered. This string must
151 * be unique amoung slots registered on this system. 151 * be unique amoung slots registered on this system.
152 * @ops: pointer to the &struct hotplug_slot_ops to be used for this slot 152 * @ops: pointer to the &struct hotplug_slot_ops to be used for this slot
153 * @info: pointer to the &struct hotplug_slot_info for the inital values for 153 * @info: pointer to the &struct hotplug_slot_info for the initial values for
154 * this slot. 154 * this slot.
155 * @release: called during pci_hp_deregister to free memory allocated in a 155 * @release: called during pci_hp_deregister to free memory allocated in a
156 * hotplug_slot structure. 156 * hotplug_slot structure.
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index 72baf749e65e..ed1fd8d6178d 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -90,6 +90,22 @@ static struct hotplug_slot_ops pciehp_hotplug_slot_ops = {
90 .get_cur_bus_speed = get_cur_bus_speed, 90 .get_cur_bus_speed = get_cur_bus_speed,
91}; 91};
92 92
93/**
94 * release_slot - free up the memory used by a slot
95 * @hotplug_slot: slot to free
96 */
97static void release_slot(struct hotplug_slot *hotplug_slot)
98{
99 struct slot *slot = hotplug_slot->private;
100
101 dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
102
103 kfree(slot->hotplug_slot->info);
104 kfree(slot->hotplug_slot->name);
105 kfree(slot->hotplug_slot);
106 kfree(slot);
107}
108
93static int init_slots(struct controller *ctrl) 109static int init_slots(struct controller *ctrl)
94{ 110{
95 struct slot *new_slot; 111 struct slot *new_slot;
@@ -139,7 +155,8 @@ static int init_slots(struct controller *ctrl)
139 155
140 /* register this slot with the hotplug pci core */ 156 /* register this slot with the hotplug pci core */
141 new_slot->hotplug_slot->private = new_slot; 157 new_slot->hotplug_slot->private = new_slot;
142 make_slot_name (new_slot->hotplug_slot->name, SLOT_NAME_SIZE, new_slot); 158 new_slot->hotplug_slot->release = &release_slot;
159 make_slot_name(new_slot->hotplug_slot->name, SLOT_NAME_SIZE, new_slot);
143 new_slot->hotplug_slot->ops = &pciehp_hotplug_slot_ops; 160 new_slot->hotplug_slot->ops = &pciehp_hotplug_slot_ops;
144 161
145 new_slot->hpc_ops->get_power_status(new_slot, &(new_slot->hotplug_slot->info->power_status)); 162 new_slot->hpc_ops->get_power_status(new_slot, &(new_slot->hotplug_slot->info->power_status));
@@ -188,10 +205,6 @@ static int cleanup_slots (struct controller * ctrl)
188 while (old_slot) { 205 while (old_slot) {
189 next_slot = old_slot->next; 206 next_slot = old_slot->next;
190 pci_hp_deregister (old_slot->hotplug_slot); 207 pci_hp_deregister (old_slot->hotplug_slot);
191 kfree(old_slot->hotplug_slot->info);
192 kfree(old_slot->hotplug_slot->name);
193 kfree(old_slot->hotplug_slot);
194 kfree(old_slot);
195 old_slot = next_slot; 208 old_slot = next_slot;
196 } 209 }
197 210
diff --git a/drivers/pci/hotplug/pcihp_skeleton.c b/drivers/pci/hotplug/pcihp_skeleton.c
index 6605d6bda529..3194d51c6ec9 100644
--- a/drivers/pci/hotplug/pcihp_skeleton.c
+++ b/drivers/pci/hotplug/pcihp_skeleton.c
@@ -297,7 +297,7 @@ static int __init init_slots(void)
297 hotplug_slot->ops = &skel_hotplug_slot_ops; 297 hotplug_slot->ops = &skel_hotplug_slot_ops;
298 298
299 /* 299 /*
300 * Initilize the slot info structure with some known 300 * Initialize the slot info structure with some known
301 * good values. 301 * good values.
302 */ 302 */
303 info->power_status = get_power_status(slot); 303 info->power_status = get_power_status(slot);
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 22ecd3b058be..30206ac43c44 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -522,7 +522,7 @@ void pci_scan_msi_device(struct pci_dev *dev)
522 * msi_capability_init - configure device's MSI capability structure 522 * msi_capability_init - configure device's MSI capability structure
523 * @dev: pointer to the pci_dev data structure of MSI device function 523 * @dev: pointer to the pci_dev data structure of MSI device function
524 * 524 *
525 * Setup the MSI capability structure of device funtion with a single 525 * Setup the MSI capability structure of device function with a single
526 * MSI vector, regardless of device function is capable of handling 526 * MSI vector, regardless of device function is capable of handling
527 * multiple messages. A return of zero indicates the successful setup 527 * multiple messages. A return of zero indicates the successful setup
528 * of an entry zero with the new MSI vector or non-zero for otherwise. 528 * of an entry zero with the new MSI vector or non-zero for otherwise.
@@ -599,7 +599,7 @@ static int msi_capability_init(struct pci_dev *dev)
599 * msix_capability_init - configure device's MSI-X capability 599 * msix_capability_init - configure device's MSI-X capability
600 * @dev: pointer to the pci_dev data structure of MSI-X device function 600 * @dev: pointer to the pci_dev data structure of MSI-X device function
601 * 601 *
602 * Setup the MSI-X capability structure of device funtion with a 602 * Setup the MSI-X capability structure of device function with a
603 * single MSI-X vector. A return of zero indicates the successful setup of 603 * single MSI-X vector. A return of zero indicates the successful setup of
604 * requested MSI-X entries with allocated vectors or non-zero for otherwise. 604 * requested MSI-X entries with allocated vectors or non-zero for otherwise.
605 **/ 605 **/
@@ -1074,7 +1074,7 @@ void pci_disable_msix(struct pci_dev* dev)
1074 * msi_remove_pci_irq_vectors - reclaim MSI(X) vectors to unused state 1074 * msi_remove_pci_irq_vectors - reclaim MSI(X) vectors to unused state
1075 * @dev: pointer to the pci_dev data structure of MSI(X) device function 1075 * @dev: pointer to the pci_dev data structure of MSI(X) device function
1076 * 1076 *
1077 * Being called during hotplug remove, from which the device funciton 1077 * Being called during hotplug remove, from which the device function
1078 * is hot-removed. All previous assigned MSI/MSI-X vectors, if 1078 * is hot-removed. All previous assigned MSI/MSI-X vectors, if
1079 * allocated for this device function, are reclaimed to unused state, 1079 * allocated for this device function, are reclaimed to unused state,
1080 * which may be used later on. 1080 * which may be used later on.
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 968eb32f292d..bc01d34e2634 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -19,7 +19,7 @@
19 19
20static u32 ctrlset_buf[3] = {0, 0, 0}; 20static u32 ctrlset_buf[3] = {0, 0, 0};
21static u32 global_ctrlsets = 0; 21static u32 global_ctrlsets = 0;
22u8 OSC_UUID[16] = {0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40, 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66}; 22static u8 OSC_UUID[16] = {0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40, 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66};
23 23
24static acpi_status 24static acpi_status
25acpi_query_osc ( 25acpi_query_osc (
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 37b7961efc44..fe98553c978f 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -318,6 +318,14 @@ static int pci_device_resume(struct device * dev)
318 return 0; 318 return 0;
319} 319}
320 320
321static void pci_device_shutdown(struct device *dev)
322{
323 struct pci_dev *pci_dev = to_pci_dev(dev);
324 struct pci_driver *drv = pci_dev->driver;
325
326 if (drv && drv->shutdown)
327 drv->shutdown(pci_dev);
328}
321 329
322#define kobj_to_pci_driver(obj) container_of(obj, struct device_driver, kobj) 330#define kobj_to_pci_driver(obj) container_of(obj, struct device_driver, kobj)
323#define attr_to_driver_attribute(obj) container_of(obj, struct driver_attribute, attr) 331#define attr_to_driver_attribute(obj) container_of(obj, struct driver_attribute, attr)
@@ -373,7 +381,7 @@ pci_populate_driver_dir(struct pci_driver *drv)
373 * 381 *
374 * Adds the driver structure to the list of registered drivers. 382 * Adds the driver structure to the list of registered drivers.
375 * Returns a negative value on error, otherwise 0. 383 * Returns a negative value on error, otherwise 0.
376 * If no error occured, the driver remains registered even if 384 * If no error occurred, the driver remains registered even if
377 * no device was claimed during registration. 385 * no device was claimed during registration.
378 */ 386 */
379int pci_register_driver(struct pci_driver *drv) 387int pci_register_driver(struct pci_driver *drv)
@@ -385,6 +393,7 @@ int pci_register_driver(struct pci_driver *drv)
385 drv->driver.bus = &pci_bus_type; 393 drv->driver.bus = &pci_bus_type;
386 drv->driver.probe = pci_device_probe; 394 drv->driver.probe = pci_device_probe;
387 drv->driver.remove = pci_device_remove; 395 drv->driver.remove = pci_device_remove;
396 drv->driver.shutdown = pci_device_shutdown,
388 drv->driver.owner = drv->owner; 397 drv->driver.owner = drv->owner;
389 drv->driver.kobj.ktype = &pci_driver_kobj_type; 398 drv->driver.kobj.ktype = &pci_driver_kobj_type;
390 pci_init_dynids(&drv->dynids); 399 pci_init_dynids(&drv->dynids);
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index d57ae71d32b1..8568b207f189 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -91,6 +91,7 @@ pci_read_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
91 struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj)); 91 struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj));
92 unsigned int size = 64; 92 unsigned int size = 64;
93 loff_t init_off = off; 93 loff_t init_off = off;
94 u8 *data = (u8*) buf;
94 95
95 /* Several chips lock up trying to read undefined config space */ 96 /* Several chips lock up trying to read undefined config space */
96 if (capable(CAP_SYS_ADMIN)) { 97 if (capable(CAP_SYS_ADMIN)) {
@@ -108,30 +109,47 @@ pci_read_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
108 size = count; 109 size = count;
109 } 110 }
110 111
111 while (off & 3) { 112 if ((off & 1) && size) {
112 unsigned char val; 113 u8 val;
113 pci_read_config_byte(dev, off, &val); 114 pci_read_config_byte(dev, off, &val);
114 buf[off - init_off] = val; 115 data[off - init_off] = val;
115 off++; 116 off++;
116 if (--size == 0) 117 size--;
117 break; 118 }
119
120 if ((off & 3) && size > 2) {
121 u16 val;
122 pci_read_config_word(dev, off, &val);
123 data[off - init_off] = val & 0xff;
124 data[off - init_off + 1] = (val >> 8) & 0xff;
125 off += 2;
126 size -= 2;
118 } 127 }
119 128
120 while (size > 3) { 129 while (size > 3) {
121 unsigned int val; 130 u32 val;
122 pci_read_config_dword(dev, off, &val); 131 pci_read_config_dword(dev, off, &val);
123 buf[off - init_off] = val & 0xff; 132 data[off - init_off] = val & 0xff;
124 buf[off - init_off + 1] = (val >> 8) & 0xff; 133 data[off - init_off + 1] = (val >> 8) & 0xff;
125 buf[off - init_off + 2] = (val >> 16) & 0xff; 134 data[off - init_off + 2] = (val >> 16) & 0xff;
126 buf[off - init_off + 3] = (val >> 24) & 0xff; 135 data[off - init_off + 3] = (val >> 24) & 0xff;
127 off += 4; 136 off += 4;
128 size -= 4; 137 size -= 4;
129 } 138 }
130 139
131 while (size > 0) { 140 if (size >= 2) {
132 unsigned char val; 141 u16 val;
142 pci_read_config_word(dev, off, &val);
143 data[off - init_off] = val & 0xff;
144 data[off - init_off + 1] = (val >> 8) & 0xff;
145 off += 2;
146 size -= 2;
147 }
148
149 if (size > 0) {
150 u8 val;
133 pci_read_config_byte(dev, off, &val); 151 pci_read_config_byte(dev, off, &val);
134 buf[off - init_off] = val; 152 data[off - init_off] = val;
135 off++; 153 off++;
136 --size; 154 --size;
137 } 155 }
@@ -145,6 +163,7 @@ pci_write_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
145 struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj)); 163 struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj));
146 unsigned int size = count; 164 unsigned int size = count;
147 loff_t init_off = off; 165 loff_t init_off = off;
166 u8 *data = (u8*) buf;
148 167
149 if (off > dev->cfg_size) 168 if (off > dev->cfg_size)
150 return 0; 169 return 0;
@@ -152,26 +171,41 @@ pci_write_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
152 size = dev->cfg_size - off; 171 size = dev->cfg_size - off;
153 count = size; 172 count = size;
154 } 173 }
155 174
156 while (off & 3) { 175 if ((off & 1) && size) {
157 pci_write_config_byte(dev, off, buf[off - init_off]); 176 pci_write_config_byte(dev, off, data[off - init_off]);
158 off++; 177 off++;
159 if (--size == 0) 178 size--;
160 break;
161 } 179 }
180
181 if ((off & 3) && size > 2) {
182 u16 val = data[off - init_off];
183 val |= (u16) data[off - init_off + 1] << 8;
184 pci_write_config_word(dev, off, val);
185 off += 2;
186 size -= 2;
187 }
162 188
163 while (size > 3) { 189 while (size > 3) {
164 unsigned int val = buf[off - init_off]; 190 u32 val = data[off - init_off];
165 val |= (unsigned int) buf[off - init_off + 1] << 8; 191 val |= (u32) data[off - init_off + 1] << 8;
166 val |= (unsigned int) buf[off - init_off + 2] << 16; 192 val |= (u32) data[off - init_off + 2] << 16;
167 val |= (unsigned int) buf[off - init_off + 3] << 24; 193 val |= (u32) data[off - init_off + 3] << 24;
168 pci_write_config_dword(dev, off, val); 194 pci_write_config_dword(dev, off, val);
169 off += 4; 195 off += 4;
170 size -= 4; 196 size -= 4;
171 } 197 }
198
199 if (size >= 2) {
200 u16 val = data[off - init_off];
201 val |= (u16) data[off - init_off + 1] << 8;
202 pci_write_config_word(dev, off, val);
203 off += 2;
204 size -= 2;
205 }
172 206
173 while (size > 0) { 207 if (size) {
174 pci_write_config_byte(dev, off, buf[off - init_off]); 208 pci_write_config_byte(dev, off, data[off - init_off]);
175 off++; 209 off++;
176 --size; 210 --size;
177 } 211 }
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index bfbff8335268..f04b9ffe4153 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -16,6 +16,7 @@
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/spinlock.h> 17#include <linux/spinlock.h>
18#include <asm/dma.h> /* isa_dma_bridge_buggy */ 18#include <asm/dma.h> /* isa_dma_bridge_buggy */
19#include "pci.h"
19 20
20 21
21/** 22/**
@@ -398,10 +399,10 @@ pci_enable_device(struct pci_dev *dev)
398{ 399{
399 int err; 400 int err;
400 401
401 dev->is_enabled = 1;
402 if ((err = pci_enable_device_bars(dev, (1 << PCI_NUM_RESOURCES) - 1))) 402 if ((err = pci_enable_device_bars(dev, (1 << PCI_NUM_RESOURCES) - 1)))
403 return err; 403 return err;
404 pci_fixup_device(pci_fixup_enable, dev); 404 pci_fixup_device(pci_fixup_enable, dev);
405 dev->is_enabled = 1;
405 return 0; 406 return 0;
406} 407}
407 408
@@ -427,16 +428,15 @@ pci_disable_device(struct pci_dev *dev)
427{ 428{
428 u16 pci_command; 429 u16 pci_command;
429 430
430 dev->is_enabled = 0;
431 dev->is_busmaster = 0;
432
433 pci_read_config_word(dev, PCI_COMMAND, &pci_command); 431 pci_read_config_word(dev, PCI_COMMAND, &pci_command);
434 if (pci_command & PCI_COMMAND_MASTER) { 432 if (pci_command & PCI_COMMAND_MASTER) {
435 pci_command &= ~PCI_COMMAND_MASTER; 433 pci_command &= ~PCI_COMMAND_MASTER;
436 pci_write_config_word(dev, PCI_COMMAND, pci_command); 434 pci_write_config_word(dev, PCI_COMMAND, pci_command);
437 } 435 }
436 dev->is_busmaster = 0;
438 437
439 pcibios_disable_device(dev); 438 pcibios_disable_device(dev);
439 dev->is_enabled = 0;
440} 440}
441 441
442/** 442/**
@@ -749,17 +749,6 @@ pci_set_dma_mask(struct pci_dev *dev, u64 mask)
749} 749}
750 750
751int 751int
752pci_dac_set_dma_mask(struct pci_dev *dev, u64 mask)
753{
754 if (!pci_dac_dma_supported(dev, mask))
755 return -EIO;
756
757 dev->dma_mask = mask;
758
759 return 0;
760}
761
762int
763pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask) 752pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
764{ 753{
765 if (!pci_dma_supported(dev, mask)) 754 if (!pci_dma_supported(dev, mask))
@@ -821,7 +810,6 @@ EXPORT_SYMBOL(pci_set_master);
821EXPORT_SYMBOL(pci_set_mwi); 810EXPORT_SYMBOL(pci_set_mwi);
822EXPORT_SYMBOL(pci_clear_mwi); 811EXPORT_SYMBOL(pci_clear_mwi);
823EXPORT_SYMBOL(pci_set_dma_mask); 812EXPORT_SYMBOL(pci_set_dma_mask);
824EXPORT_SYMBOL(pci_dac_set_dma_mask);
825EXPORT_SYMBOL(pci_set_consistent_dma_mask); 813EXPORT_SYMBOL(pci_set_consistent_dma_mask);
826EXPORT_SYMBOL(pci_assign_resource); 814EXPORT_SYMBOL(pci_assign_resource);
827EXPORT_SYMBOL(pci_find_parent_resource); 815EXPORT_SYMBOL(pci_find_parent_resource);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 6f0edadd132c..b7ae87823c69 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -9,6 +9,7 @@
9#include <linux/slab.h> 9#include <linux/slab.h>
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/cpumask.h> 11#include <linux/cpumask.h>
12#include "pci.h"
12 13
13#define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */ 14#define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */
14#define CARDBUS_RESERVE_BUSNR 3 15#define CARDBUS_RESERVE_BUSNR 3
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index 84cc4f620d8d..e68bbfb1e7c3 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -15,6 +15,7 @@
15 15
16#include <asm/uaccess.h> 16#include <asm/uaccess.h>
17#include <asm/byteorder.h> 17#include <asm/byteorder.h>
18#include "pci.h"
18 19
19static int proc_initialized; /* = 0 */ 20static int proc_initialized; /* = 0 */
20 21
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 15a398051682..026aa04669a2 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -18,6 +18,7 @@
18#include <linux/pci.h> 18#include <linux/pci.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include "pci.h"
21 22
22/* Deal with broken BIOS'es that neglect to enable passive release, 23/* Deal with broken BIOS'es that neglect to enable passive release,
23 which can cause problems in combination with the 82441FX/PPro MTRRs */ 24 which can cause problems in combination with the 82441FX/PPro MTRRs */
@@ -328,6 +329,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_12,
328DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0, quirk_ich4_lpc_acpi ); 329DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0, quirk_ich4_lpc_acpi );
329DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12, quirk_ich4_lpc_acpi ); 330DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12, quirk_ich4_lpc_acpi );
330DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0, quirk_ich4_lpc_acpi ); 331DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0, quirk_ich4_lpc_acpi );
332DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_1, quirk_ich4_lpc_acpi );
331 333
332/* 334/*
333 * VIA ACPI: One IO region pointed to by longword at 335 * VIA ACPI: One IO region pointed to by longword at
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 750b11cefd93..1811cb240315 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -260,7 +260,7 @@ config SCSI_3W_9XXX
260 260
261config SCSI_7000FASST 261config SCSI_7000FASST
262 tristate "7000FASST SCSI support" 262 tristate "7000FASST SCSI support"
263 depends on ISA && SCSI 263 depends on ISA && SCSI && ISA_DMA_API
264 help 264 help
265 This driver supports the Western Digital 7000 SCSI host adapter 265 This driver supports the Western Digital 7000 SCSI host adapter
266 family. Some information is in the source: 266 family. Some information is in the source:
@@ -295,7 +295,7 @@ config SCSI_AHA152X
295 295
296config SCSI_AHA1542 296config SCSI_AHA1542
297 tristate "Adaptec AHA1542 support" 297 tristate "Adaptec AHA1542 support"
298 depends on ISA && SCSI 298 depends on ISA && SCSI && ISA_DMA_API
299 ---help--- 299 ---help---
300 This is support for a SCSI host adapter. It is explained in section 300 This is support for a SCSI host adapter. It is explained in section
301 3.4 of the SCSI-HOWTO, available from 301 3.4 of the SCSI-HOWTO, available from
@@ -515,7 +515,7 @@ config SCSI_SATA_VITESSE
515 515
516config SCSI_BUSLOGIC 516config SCSI_BUSLOGIC
517 tristate "BusLogic SCSI support" 517 tristate "BusLogic SCSI support"
518 depends on (PCI || ISA || MCA) && SCSI && (BROKEN || !SPARC64) 518 depends on (PCI || ISA || MCA) && SCSI && ISA_DMA_API
519 ---help--- 519 ---help---
520 This is support for BusLogic MultiMaster and FlashPoint SCSI Host 520 This is support for BusLogic MultiMaster and FlashPoint SCSI Host
521 Adapters. Consult the SCSI-HOWTO, available from 521 Adapters. Consult the SCSI-HOWTO, available from
@@ -571,7 +571,7 @@ config SCSI_DTC3280
571 571
572config SCSI_EATA 572config SCSI_EATA
573 tristate "EATA ISA/EISA/PCI (DPT and generic EATA/DMA-compliant boards) support" 573 tristate "EATA ISA/EISA/PCI (DPT and generic EATA/DMA-compliant boards) support"
574 depends on (ISA || EISA || PCI) && SCSI && (BROKEN || !SPARC64) 574 depends on (ISA || EISA || PCI) && SCSI && ISA_DMA_API
575 ---help--- 575 ---help---
576 This driver supports all EATA/DMA-compliant SCSI host adapters. DPT 576 This driver supports all EATA/DMA-compliant SCSI host adapters. DPT
577 ISA and all EISA I/O addresses are probed looking for the "EATA" 577 ISA and all EISA I/O addresses are probed looking for the "EATA"
@@ -665,7 +665,7 @@ config SCSI_FD_MCS
665 665
666config SCSI_GDTH 666config SCSI_GDTH
667 tristate "Intel/ICP (former GDT SCSI Disk Array) RAID Controller support" 667 tristate "Intel/ICP (former GDT SCSI Disk Array) RAID Controller support"
668 depends on (ISA || EISA || PCI) && SCSI && (BROKEN || !SPARC64) 668 depends on (ISA || EISA || PCI) && SCSI && ISA_DMA_API
669 ---help--- 669 ---help---
670 Formerly called GDT SCSI Disk Array Controller Support. 670 Formerly called GDT SCSI Disk Array Controller Support.
671 671
@@ -1416,7 +1416,7 @@ config SCSI_T128
1416 1416
1417config SCSI_U14_34F 1417config SCSI_U14_34F
1418 tristate "UltraStor 14F/34F support" 1418 tristate "UltraStor 14F/34F support"
1419 depends on ISA && SCSI 1419 depends on ISA && SCSI && ISA_DMA_API
1420 ---help--- 1420 ---help---
1421 This is support for the UltraStor 14F and 34F SCSI-2 host adapters. 1421 This is support for the UltraStor 14F and 34F SCSI-2 host adapters.
1422 The source at <file:drivers/scsi/u14-34f.c> contains some 1422 The source at <file:drivers/scsi/u14-34f.c> contains some
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index e12c5be1e0a3..f50aaf25c98e 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -431,7 +431,7 @@ nomem:
431 * (2) error, where io->status is a negative errno value. The number 431 * (2) error, where io->status is a negative errno value. The number
432 * of io->bytes transferred before the error is usually less 432 * of io->bytes transferred before the error is usually less
433 * than requested, and can be nonzero. 433 * than requested, and can be nonzero.
434 * (3) cancelation, a type of error with status -ECONNRESET that 434 * (3) cancellation, a type of error with status -ECONNRESET that
435 * is initiated by usb_sg_cancel(). 435 * is initiated by usb_sg_cancel().
436 * 436 *
437 * When this function returns, all memory allocated through usb_sg_init() or 437 * When this function returns, all memory allocated through usb_sg_init() or
@@ -1282,7 +1282,7 @@ static void release_interface(struct device *dev)
1282 * bus rwsem; usb device driver probe() methods cannot use this routine. 1282 * bus rwsem; usb device driver probe() methods cannot use this routine.
1283 * 1283 *
1284 * Returns zero on success, or else the status code returned by the 1284 * Returns zero on success, or else the status code returned by the
1285 * underlying call that failed. On succesful completion, each interface 1285 * underlying call that failed. On successful completion, each interface
1286 * in the original device configuration has been destroyed, and each one 1286 * in the original device configuration has been destroyed, and each one
1287 * in the new configuration has been probed by all relevant usb device 1287 * in the new configuration has been probed by all relevant usb device
1288 * drivers currently known to the kernel. 1288 * drivers currently known to the kernel.
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 16972159a57a..0faf18d511de 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -121,7 +121,7 @@ struct urb * usb_get_urb(struct urb *urb)
121 * describing that request to the USB subsystem. Request completion will 121 * describing that request to the USB subsystem. Request completion will
122 * be indicated later, asynchronously, by calling the completion handler. 122 * be indicated later, asynchronously, by calling the completion handler.
123 * The three types of completion are success, error, and unlink 123 * The three types of completion are success, error, and unlink
124 * (a software-induced fault, also called "request cancelation"). 124 * (a software-induced fault, also called "request cancellation").
125 * 125 *
126 * URBs may be submitted in interrupt context. 126 * URBs may be submitted in interrupt context.
127 * 127 *
@@ -170,7 +170,7 @@ struct urb * usb_get_urb(struct urb *urb)
170 * As of Linux 2.6, all USB endpoint transfer queues support depths greater 170 * As of Linux 2.6, all USB endpoint transfer queues support depths greater
171 * than one. This was previously a HCD-specific behavior, except for ISO 171 * than one. This was previously a HCD-specific behavior, except for ISO
172 * transfers. Non-isochronous endpoint queues are inactive during cleanup 172 * transfers. Non-isochronous endpoint queues are inactive during cleanup
173 * after faults (transfer errors or cancelation). 173 * after faults (transfer errors or cancellation).
174 * 174 *
175 * Reserved Bandwidth Transfers: 175 * Reserved Bandwidth Transfers:
176 * 176 *
@@ -395,7 +395,7 @@ int usb_submit_urb(struct urb *urb, int mem_flags)
395 * 395 *
396 * This routine cancels an in-progress request. URBs complete only 396 * This routine cancels an in-progress request. URBs complete only
397 * once per submission, and may be canceled only once per submission. 397 * once per submission, and may be canceled only once per submission.
398 * Successful cancelation means the requests's completion handler will 398 * Successful cancellation means the requests's completion handler will
399 * be called with a status code indicating that the request has been 399 * be called with a status code indicating that the request has been
400 * canceled (rather than any other code) and will quickly be removed 400 * canceled (rather than any other code) and will quickly be removed
401 * from host controller data structures. 401 * from host controller data structures.
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 3993156c2e82..3f783cbdc7c3 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -569,7 +569,7 @@ static const struct usb_cdc_ether_desc ether_desc = {
569 569
570/* include the status endpoint if we can, even where it's optional. 570/* include the status endpoint if we can, even where it's optional.
571 * use wMaxPacketSize big enough to fit CDC_NOTIFY_SPEED_CHANGE in one 571 * use wMaxPacketSize big enough to fit CDC_NOTIFY_SPEED_CHANGE in one
572 * packet, to simplify cancelation; and a big transfer interval, to 572 * packet, to simplify cancellation; and a big transfer interval, to
573 * waste less bandwidth. 573 * waste less bandwidth.
574 * 574 *
575 * some drivers (like Linux 2.4 cdc-ether!) "need" it to exist even 575 * some drivers (like Linux 2.4 cdc-ether!) "need" it to exist even
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index 2cff67ccce45..1e5e6ddef787 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -275,7 +275,7 @@ static const char *CHIP;
275 * 275 *
276 * After opening, configure non-control endpoints. Then use normal 276 * After opening, configure non-control endpoints. Then use normal
277 * stream read() and write() requests; and maybe ioctl() to get more 277 * stream read() and write() requests; and maybe ioctl() to get more
278 * precise FIFO status when recovering from cancelation. 278 * precise FIFO status when recovering from cancellation.
279 */ 279 */
280 280
281static void epio_complete (struct usb_ep *ep, struct usb_request *req) 281static void epio_complete (struct usb_ep *ep, struct usb_request *req)
diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c
index 0def9f70e889..df75ab65a5ec 100644
--- a/drivers/usb/gadget/lh7a40x_udc.c
+++ b/drivers/usb/gadget/lh7a40x_udc.c
@@ -705,7 +705,7 @@ void nuke(struct lh7a40x_ep *ep, int status)
705 done(ep, req, status); 705 done(ep, req, status);
706 } 706 }
707 707
708 /* Disable IRQ if EP is enabled (has decriptor) */ 708 /* Disable IRQ if EP is enabled (has descriptor) */
709 if (ep->desc) 709 if (ep->desc)
710 pio_irq_disable(ep_index(ep)); 710 pio_irq_disable(ep_index(ep));
711} 711}
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index f1762ed6db63..4d591c764e38 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -240,7 +240,7 @@ struct gs_dev {
240 struct usb_ep *dev_notify_ep; /* address of notify endpoint */ 240 struct usb_ep *dev_notify_ep; /* address of notify endpoint */
241 struct usb_ep *dev_in_ep; /* address of in endpoint */ 241 struct usb_ep *dev_in_ep; /* address of in endpoint */
242 struct usb_ep *dev_out_ep; /* address of out endpoint */ 242 struct usb_ep *dev_out_ep; /* address of out endpoint */
243 struct usb_endpoint_descriptor /* desciptor of notify ep */ 243 struct usb_endpoint_descriptor /* descriptor of notify ep */
244 *dev_notify_ep_desc; 244 *dev_notify_ep_desc;
245 struct usb_endpoint_descriptor /* descriptor of in endpoint */ 245 struct usb_endpoint_descriptor /* descriptor of in endpoint */
246 *dev_in_ep_desc; 246 *dev_in_ep_desc;
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 84d2b93aca37..bc69bd7acebe 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -346,6 +346,22 @@ ehci_reboot (struct notifier_block *self, unsigned long code, void *null)
346 return 0; 346 return 0;
347} 347}
348 348
349static void ehci_port_power (struct ehci_hcd *ehci, int is_on)
350{
351 unsigned port;
352
353 if (!HCS_PPC (ehci->hcs_params))
354 return;
355
356 ehci_dbg (ehci, "...power%s ports...\n", is_on ? "up" : "down");
357 for (port = HCS_N_PORTS (ehci->hcs_params); port > 0; )
358 (void) ehci_hub_control(ehci_to_hcd(ehci),
359 is_on ? SetPortFeature : ClearPortFeature,
360 USB_PORT_FEAT_POWER,
361 port--, NULL, 0);
362 msleep(20);
363}
364
349 365
350/* called by khubd or root hub init threads */ 366/* called by khubd or root hub init threads */
351 367
@@ -362,8 +378,10 @@ static int ehci_hc_reset (struct usb_hcd *hcd)
362 dbg_hcs_params (ehci, "reset"); 378 dbg_hcs_params (ehci, "reset");
363 dbg_hcc_params (ehci, "reset"); 379 dbg_hcc_params (ehci, "reset");
364 380
381 /* cache this readonly data; minimize chip reads */
382 ehci->hcs_params = readl (&ehci->caps->hcs_params);
383
365#ifdef CONFIG_PCI 384#ifdef CONFIG_PCI
366 /* EHCI 0.96 and later may have "extended capabilities" */
367 if (hcd->self.controller->bus == &pci_bus_type) { 385 if (hcd->self.controller->bus == &pci_bus_type) {
368 struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 386 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
369 387
@@ -383,9 +401,30 @@ static int ehci_hc_reset (struct usb_hcd *hcd)
383 break; 401 break;
384 } 402 }
385 403
404 /* optional debug port, normally in the first BAR */
405 temp = pci_find_capability (pdev, 0x0a);
406 if (temp) {
407 pci_read_config_dword(pdev, temp, &temp);
408 temp >>= 16;
409 if ((temp & (3 << 13)) == (1 << 13)) {
410 temp &= 0x1fff;
411 ehci->debug = hcd->regs + temp;
412 temp = readl (&ehci->debug->control);
413 ehci_info (ehci, "debug port %d%s\n",
414 HCS_DEBUG_PORT(ehci->hcs_params),
415 (temp & DBGP_ENABLED)
416 ? " IN USE"
417 : "");
418 if (!(temp & DBGP_ENABLED))
419 ehci->debug = NULL;
420 }
421 }
422
386 temp = HCC_EXT_CAPS (readl (&ehci->caps->hcc_params)); 423 temp = HCC_EXT_CAPS (readl (&ehci->caps->hcc_params));
387 } else 424 } else
388 temp = 0; 425 temp = 0;
426
427 /* EHCI 0.96 and later may have "extended capabilities" */
389 while (temp && count--) { 428 while (temp && count--) {
390 u32 cap; 429 u32 cap;
391 430
@@ -414,8 +453,7 @@ static int ehci_hc_reset (struct usb_hcd *hcd)
414 ehci_reset (ehci); 453 ehci_reset (ehci);
415#endif 454#endif
416 455
417 /* cache this readonly data; minimize PCI reads */ 456 ehci_port_power (ehci, 0);
418 ehci->hcs_params = readl (&ehci->caps->hcs_params);
419 457
420 /* at least the Genesys GL880S needs fixup here */ 458 /* at least the Genesys GL880S needs fixup here */
421 temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params); 459 temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params);
@@ -657,16 +695,11 @@ done2:
657static void ehci_stop (struct usb_hcd *hcd) 695static void ehci_stop (struct usb_hcd *hcd)
658{ 696{
659 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 697 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
660 u8 rh_ports, port;
661 698
662 ehci_dbg (ehci, "stop\n"); 699 ehci_dbg (ehci, "stop\n");
663 700
664 /* Turn off port power on all root hub ports. */ 701 /* Turn off port power on all root hub ports. */
665 rh_ports = HCS_N_PORTS (ehci->hcs_params); 702 ehci_port_power (ehci, 0);
666 for (port = 1; port <= rh_ports; port++)
667 (void) ehci_hub_control(hcd,
668 ClearPortFeature, USB_PORT_FEAT_POWER,
669 port, NULL, 0);
670 703
671 /* no more interrupts ... */ 704 /* no more interrupts ... */
672 del_timer_sync (&ehci->watchdog); 705 del_timer_sync (&ehci->watchdog);
@@ -748,7 +781,6 @@ static int ehci_resume (struct usb_hcd *hcd)
748 unsigned port; 781 unsigned port;
749 struct usb_device *root = hcd->self.root_hub; 782 struct usb_device *root = hcd->self.root_hub;
750 int retval = -EINVAL; 783 int retval = -EINVAL;
751 int powerup = 0;
752 784
753 // maybe restore (PCI) FLADJ 785 // maybe restore (PCI) FLADJ
754 786
@@ -766,8 +798,6 @@ static int ehci_resume (struct usb_hcd *hcd)
766 up (&hcd->self.root_hub->serialize); 798 up (&hcd->self.root_hub->serialize);
767 break; 799 break;
768 } 800 }
769 if ((status & PORT_POWER) == 0)
770 powerup = 1;
771 if (!root->children [port]) 801 if (!root->children [port])
772 continue; 802 continue;
773 dbg_port (ehci, __FUNCTION__, port + 1, status); 803 dbg_port (ehci, __FUNCTION__, port + 1, status);
@@ -794,16 +824,9 @@ static int ehci_resume (struct usb_hcd *hcd)
794 retval = ehci_start (hcd); 824 retval = ehci_start (hcd);
795 825
796 /* here we "know" root ports should always stay powered; 826 /* here we "know" root ports should always stay powered;
797 * but some controllers may lost all power. 827 * but some controllers may lose all power.
798 */ 828 */
799 if (powerup) { 829 ehci_port_power (ehci, 1);
800 ehci_dbg (ehci, "...powerup ports...\n");
801 for (port = HCS_N_PORTS (ehci->hcs_params); port > 0; )
802 (void) ehci_hub_control(hcd,
803 SetPortFeature, USB_PORT_FEAT_POWER,
804 port--, NULL, 0);
805 msleep(20);
806 }
807 } 830 }
808 831
809 return retval; 832 return retval;
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 2373537fabed..02fefab3501e 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -281,6 +281,8 @@ ehci_hub_descriptor (
281 temp = 0x0008; /* per-port overcurrent reporting */ 281 temp = 0x0008; /* per-port overcurrent reporting */
282 if (HCS_PPC (ehci->hcs_params)) 282 if (HCS_PPC (ehci->hcs_params))
283 temp |= 0x0001; /* per-port power control */ 283 temp |= 0x0001; /* per-port power control */
284 else
285 temp |= 0x0002; /* no power switching */
284#if 0 286#if 0
285// re-enable when we support USB_PORT_FEAT_INDICATOR below. 287// re-enable when we support USB_PORT_FEAT_INDICATOR below.
286 if (HCS_INDICATOR (ehci->hcs_params)) 288 if (HCS_INDICATOR (ehci->hcs_params))
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index e763a8399a75..4df498231752 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -47,6 +47,12 @@ struct ehci_stats {
47#define EHCI_MAX_ROOT_PORTS 15 /* see HCS_N_PORTS */ 47#define EHCI_MAX_ROOT_PORTS 15 /* see HCS_N_PORTS */
48 48
49struct ehci_hcd { /* one per controller */ 49struct ehci_hcd { /* one per controller */
50 /* glue to PCI and HCD framework */
51 struct ehci_caps __iomem *caps;
52 struct ehci_regs __iomem *regs;
53 struct ehci_dbg_port __iomem *debug;
54
55 __u32 hcs_params; /* cached register copy */
50 spinlock_t lock; 56 spinlock_t lock;
51 57
52 /* async schedule support */ 58 /* async schedule support */
@@ -84,11 +90,6 @@ struct ehci_hcd { /* one per controller */
84 90
85 unsigned is_tdi_rh_tt:1; /* TDI roothub with TT */ 91 unsigned is_tdi_rh_tt:1; /* TDI roothub with TT */
86 92
87 /* glue to PCI and HCD framework */
88 struct ehci_caps __iomem *caps;
89 struct ehci_regs __iomem *regs;
90 __u32 hcs_params; /* cached register copy */
91
92 /* irq statistics */ 93 /* irq statistics */
93#ifdef EHCI_STATS 94#ifdef EHCI_STATS
94 struct ehci_stats stats; 95 struct ehci_stats stats;
@@ -165,7 +166,7 @@ struct ehci_caps {
165 /* these fields are specified as 8 and 16 bit registers, 166 /* these fields are specified as 8 and 16 bit registers,
166 * but some hosts can't perform 8 or 16 bit PCI accesses. 167 * but some hosts can't perform 8 or 16 bit PCI accesses.
167 */ 168 */
168 u32 hc_capbase; 169 u32 hc_capbase;
169#define HC_LENGTH(p) (((p)>>00)&0x00ff) /* bits 7:0 */ 170#define HC_LENGTH(p) (((p)>>00)&0x00ff) /* bits 7:0 */
170#define HC_VERSION(p) (((p)>>16)&0xffff) /* bits 31:16 */ 171#define HC_VERSION(p) (((p)>>16)&0xffff) /* bits 31:16 */
171 u32 hcs_params; /* HCSPARAMS - offset 0x4 */ 172 u32 hcs_params; /* HCSPARAMS - offset 0x4 */
@@ -273,7 +274,7 @@ struct ehci_dbg_port {
273#define DBGP_ENABLED (1<<28) 274#define DBGP_ENABLED (1<<28)
274#define DBGP_DONE (1<<16) 275#define DBGP_DONE (1<<16)
275#define DBGP_INUSE (1<<10) 276#define DBGP_INUSE (1<<10)
276#define DBGP_ERRCODE(x) (((x)>>7)&0x0f) 277#define DBGP_ERRCODE(x) (((x)>>7)&0x07)
277# define DBGP_ERR_BAD 1 278# define DBGP_ERR_BAD 1
278# define DBGP_ERR_SIGNAL 2 279# define DBGP_ERR_SIGNAL 2
279#define DBGP_ERROR (1<<6) 280#define DBGP_ERROR (1<<6)
@@ -282,11 +283,11 @@ struct ehci_dbg_port {
282#define DBGP_LEN(x) (((x)>>0)&0x0f) 283#define DBGP_LEN(x) (((x)>>0)&0x0f)
283 u32 pids; 284 u32 pids;
284#define DBGP_PID_GET(x) (((x)>>16)&0xff) 285#define DBGP_PID_GET(x) (((x)>>16)&0xff)
285#define DBGP_PID_SET(data,tok) (((data)<<8)|(tok)); 286#define DBGP_PID_SET(data,tok) (((data)<<8)|(tok))
286 u32 data03; 287 u32 data03;
287 u32 data47; 288 u32 data47;
288 u32 address; 289 u32 address;
289#define DBGP_EPADDR(dev,ep) (((dev)<<8)|(ep)); 290#define DBGP_EPADDR(dev,ep) (((dev)<<8)|(ep))
290} __attribute__ ((packed)); 291} __attribute__ ((packed));
291 292
292/*-------------------------------------------------------------------------*/ 293/*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/host/hc_crisv10.c b/drivers/usb/host/hc_crisv10.c
index 376f8a034f65..d9883d774d3a 100644
--- a/drivers/usb/host/hc_crisv10.c
+++ b/drivers/usb/host/hc_crisv10.c
@@ -4329,7 +4329,7 @@ static int __init etrax_usb_hc_init(void)
4329 bus->bus_name="ETRAX 100LX"; 4329 bus->bus_name="ETRAX 100LX";
4330 bus->hcpriv = hc; 4330 bus->hcpriv = hc;
4331 4331
4332 /* Initalize RH to the default address. 4332 /* Initialize RH to the default address.
4333 And make sure that we have no status change indication */ 4333 And make sure that we have no status change indication */
4334 hc->rh.numports = 2; /* The RH has two ports */ 4334 hc->rh.numports = 2; /* The RH has two ports */
4335 hc->rh.devnum = 1; 4335 hc->rh.devnum = 1;
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index d309e292198e..a374b7692073 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -134,7 +134,7 @@ static void port_power(struct sl811 *sl811, int is_on)
134 134
135/* This is a PIO-only HCD. Queueing appends URBs to the endpoint's queue, 135/* This is a PIO-only HCD. Queueing appends URBs to the endpoint's queue,
136 * and may start I/O. Endpoint queues are scanned during completion irq 136 * and may start I/O. Endpoint queues are scanned during completion irq
137 * handlers (one per packet: ACK, NAK, faults, etc) and urb cancelation. 137 * handlers (one per packet: ACK, NAK, faults, etc) and urb cancellation.
138 * 138 *
139 * Using an external DMA engine to copy a packet at a time could work, 139 * Using an external DMA engine to copy a packet at a time could work,
140 * though setup/teardown costs may be too big to make it worthwhile. 140 * though setup/teardown costs may be too big to make it worthwhile.
@@ -738,7 +738,7 @@ retry:
738 } 738 }
739#endif 739#endif
740 740
741 /* port status seems wierd until after reset, so 741 /* port status seems weird until after reset, so
742 * force the reset and make khubd clean up later. 742 * force the reset and make khubd clean up later.
743 */ 743 */
744 sl811->port1 |= (1 << USB_PORT_FEAT_C_CONNECTION) 744 sl811->port1 |= (1 << USB_PORT_FEAT_C_CONNECTION)
diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c
index 5791723e6083..a330a4b50e16 100644
--- a/drivers/usb/image/mdc800.c
+++ b/drivers/usb/image/mdc800.c
@@ -23,7 +23,7 @@
23 * 23 *
24 * 24 *
25 * The driver brings the USB functions of the MDC800 to Linux. 25 * The driver brings the USB functions of the MDC800 to Linux.
26 * To use the Camera you must support the USB Protocoll of the camera 26 * To use the Camera you must support the USB Protocol of the camera
27 * to the Kernel Node. 27 * to the Kernel Node.
28 * The Driver uses a misc device Node. Create it with : 28 * The Driver uses a misc device Node. Create it with :
29 * mknod /dev/mustek c 180 32 29 * mknod /dev/mustek c 180 32
diff --git a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c
index 2d76be62f4e0..94ce2a9ad50f 100644
--- a/drivers/usb/input/aiptek.c
+++ b/drivers/usb/input/aiptek.c
@@ -386,7 +386,7 @@ static int aiptek_convert_from_2s_complement(unsigned char c)
386 * convention above.) I therefore have taken over REL_MISC and ABS_MISC 386 * convention above.) I therefore have taken over REL_MISC and ABS_MISC
387 * (for relative and absolute reports, respectively) for communicating 387 * (for relative and absolute reports, respectively) for communicating
388 * Proximity. Why two events? I thought it interesting to know if the 388 * Proximity. Why two events? I thought it interesting to know if the
389 * Proximity event occured while the tablet was in absolute or relative 389 * Proximity event occurred while the tablet was in absolute or relative
390 * mode. 390 * mode.
391 * 391 *
392 * Other tablets use the notion of a certain minimum stylus pressure 392 * Other tablets use the notion of a certain minimum stylus pressure
diff --git a/drivers/usb/input/mtouchusb.c b/drivers/usb/input/mtouchusb.c
index 6b45a66d58c1..ab1a2a30ce7c 100644
--- a/drivers/usb/input/mtouchusb.c
+++ b/drivers/usb/input/mtouchusb.c
@@ -32,7 +32,7 @@
32 * Changed reset from standard USB dev reset to vendor reset 32 * Changed reset from standard USB dev reset to vendor reset
33 * Changed data sent to host from compensated to raw coordinates 33 * Changed data sent to host from compensated to raw coordinates
34 * Eliminated vendor/product module params 34 * Eliminated vendor/product module params
35 * Performed multiple successfull tests with an EXII-5010UC 35 * Performed multiple successful tests with an EXII-5010UC
36 * 36 *
37 * 1.5 02/27/2005 ddstreet@ieee.org 37 * 1.5 02/27/2005 ddstreet@ieee.org
38 * Added module parameter to select raw or hw-calibrated coordinate reporting 38 * Added module parameter to select raw or hw-calibrated coordinate reporting
diff --git a/drivers/usb/media/ov511.c b/drivers/usb/media/ov511.c
index d6051822416e..036c485d1d1e 100644
--- a/drivers/usb/media/ov511.c
+++ b/drivers/usb/media/ov511.c
@@ -5041,7 +5041,7 @@ ov6xx0_configure(struct usb_ov511 *ov)
5041 { OV511_I2C_BUS, 0x2a, 0x04 }, /* Disable framerate adjust */ 5041 { OV511_I2C_BUS, 0x2a, 0x04 }, /* Disable framerate adjust */
5042// { OV511_I2C_BUS, 0x2b, 0xac }, /* Framerate; Set 2a[7] first */ 5042// { OV511_I2C_BUS, 0x2b, 0xac }, /* Framerate; Set 2a[7] first */
5043 { OV511_I2C_BUS, 0x2d, 0x99 }, 5043 { OV511_I2C_BUS, 0x2d, 0x99 },
5044 { OV511_I2C_BUS, 0x33, 0xa0 }, /* Color Procesing Parameter */ 5044 { OV511_I2C_BUS, 0x33, 0xa0 }, /* Color Processing Parameter */
5045 { OV511_I2C_BUS, 0x34, 0xd2 }, /* Max A/D range */ 5045 { OV511_I2C_BUS, 0x34, 0xd2 }, /* Max A/D range */
5046 { OV511_I2C_BUS, 0x38, 0x8b }, 5046 { OV511_I2C_BUS, 0x38, 0x8b },
5047 { OV511_I2C_BUS, 0x39, 0x40 }, 5047 { OV511_I2C_BUS, 0x39, 0x40 },
diff --git a/drivers/usb/media/pwc/pwc-ctrl.c b/drivers/usb/media/pwc/pwc-ctrl.c
index 42352f531bc0..42ec468d52d6 100644
--- a/drivers/usb/media/pwc/pwc-ctrl.c
+++ b/drivers/usb/media/pwc/pwc-ctrl.c
@@ -1100,7 +1100,7 @@ static inline int pwc_mpt_set_angle(struct pwc_device *pdev, int pan, int tilt)
1100 unsigned char buf[4]; 1100 unsigned char buf[4];
1101 1101
1102 /* set new relative angle; angles are expressed in degrees * 100, 1102 /* set new relative angle; angles are expressed in degrees * 100,
1103 but cam as .5 degree resolution, hence devide by 200. Also 1103 but cam as .5 degree resolution, hence divide by 200. Also
1104 the angle must be multiplied by 64 before it's send to 1104 the angle must be multiplied by 64 before it's send to
1105 the cam (??) 1105 the cam (??)
1106 */ 1106 */
diff --git a/drivers/usb/media/pwc/pwc-if.c b/drivers/usb/media/pwc/pwc-if.c
index c53e2263b7fb..cca47f480a8b 100644
--- a/drivers/usb/media/pwc/pwc-if.c
+++ b/drivers/usb/media/pwc/pwc-if.c
@@ -272,7 +272,7 @@ static int pwc_allocate_buffers(struct pwc_device *pdev)
272 return -ENXIO; 272 return -ENXIO;
273 } 273 }
274#endif 274#endif
275 /* Allocate Isochronuous pipe buffers */ 275 /* Allocate Isochronous pipe buffers */
276 for (i = 0; i < MAX_ISO_BUFS; i++) { 276 for (i = 0; i < MAX_ISO_BUFS; i++) {
277 if (pdev->sbuf[i].data == NULL) { 277 if (pdev->sbuf[i].data == NULL) {
278 kbuf = kmalloc(ISO_BUFFER_SIZE, GFP_KERNEL); 278 kbuf = kmalloc(ISO_BUFFER_SIZE, GFP_KERNEL);
@@ -850,7 +850,7 @@ static int pwc_isoc_init(struct pwc_device *pdev)
850 850
851 if (pdev->vmax_packet_size < 0 || pdev->vmax_packet_size > ISO_MAX_FRAME_SIZE) { 851 if (pdev->vmax_packet_size < 0 || pdev->vmax_packet_size > ISO_MAX_FRAME_SIZE) {
852 Err("Failed to find packet size for video endpoint in current alternate setting.\n"); 852 Err("Failed to find packet size for video endpoint in current alternate setting.\n");
853 return -ENFILE; /* Odd error, that should be noticable */ 853 return -ENFILE; /* Odd error, that should be noticeable */
854 } 854 }
855 855
856 /* Set alternate interface */ 856 /* Set alternate interface */
@@ -2128,7 +2128,7 @@ static int __init usb_pwc_init(void)
2128 if (leds[1] >= 0) 2128 if (leds[1] >= 0)
2129 led_off = leds[1]; 2129 led_off = leds[1];
2130 2130
2131 /* Big device node whoopla. Basicly, it allows you to assign a 2131 /* Big device node whoopla. Basically, it allows you to assign a
2132 device node (/dev/videoX) to a camera, based on its type 2132 device node (/dev/videoX) to a camera, based on its type
2133 & serial number. The format is [type[.serialnumber]:]node. 2133 & serial number. The format is [type[.serialnumber]:]node.
2134 2134
diff --git a/drivers/usb/media/pwc/pwc-ioctl.h b/drivers/usb/media/pwc/pwc-ioctl.h
index 65805eaa9a1c..5f9cb08bc02e 100644
--- a/drivers/usb/media/pwc/pwc-ioctl.h
+++ b/drivers/usb/media/pwc/pwc-ioctl.h
@@ -75,7 +75,7 @@
75#define PWC_FPS_SNAPSHOT 0x00400000 75#define PWC_FPS_SNAPSHOT 0x00400000
76 76
77 77
78/* structure for transfering x & y coordinates */ 78/* structure for transferring x & y coordinates */
79struct pwc_coord 79struct pwc_coord
80{ 80{
81 int x, y; /* guess what */ 81 int x, y; /* guess what */
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c
index dd4580cb57e0..7d06105763d4 100644
--- a/drivers/usb/misc/legousbtower.c
+++ b/drivers/usb/misc/legousbtower.c
@@ -859,7 +859,7 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device
859 info ("udev is NULL."); 859 info ("udev is NULL.");
860 } 860 }
861 861
862 /* allocate memory for our device state and intialize it */ 862 /* allocate memory for our device state and initialize it */
863 863
864 dev = kmalloc (sizeof(struct lego_usb_tower), GFP_KERNEL); 864 dev = kmalloc (sizeof(struct lego_usb_tower), GFP_KERNEL);
865 865
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
index a45ea7c97356..f6bc6b3b333c 100644
--- a/drivers/usb/net/usbnet.c
+++ b/drivers/usb/net/usbnet.c
@@ -4071,6 +4071,9 @@ static const struct usb_device_id products [] = {
4071 USB_DEVICE (0x8086, 0x07d3), // "blob" bootloader 4071 USB_DEVICE (0x8086, 0x07d3), // "blob" bootloader
4072 .driver_info = (unsigned long) &blob_info, 4072 .driver_info = (unsigned long) &blob_info,
4073}, { 4073}, {
4074 USB_DEVICE (0x22b8, 0x600c), // USBNET Motorola E680
4075 .driver_info = (unsigned long) &linuxdev_info,
4076}, {
4074 // Linux Ethernet/RNDIS gadget on pxa210/25x/26x 4077 // Linux Ethernet/RNDIS gadget on pxa210/25x/26x
4075 // e.g. Gumstix, current OpenZaurus, ... 4078 // e.g. Gumstix, current OpenZaurus, ...
4076 USB_DEVICE_VER (0x0525, 0xa4a2, 0x0203, 0x0203), 4079 USB_DEVICE_VER (0x0525, 0xa4a2, 0x0203, 0x0203),
diff --git a/drivers/usb/net/zd1201.c b/drivers/usb/net/zd1201.c
index f98cb2af024e..341ae5f732dd 100644
--- a/drivers/usb/net/zd1201.c
+++ b/drivers/usb/net/zd1201.c
@@ -183,7 +183,7 @@ static void zd1201_usbtx(struct urb *urb, struct pt_regs *regs)
183 return; 183 return;
184} 184}
185 185
186/* Incomming data */ 186/* Incoming data */
187static void zd1201_usbrx(struct urb *urb, struct pt_regs *regs) 187static void zd1201_usbrx(struct urb *urb, struct pt_regs *regs)
188{ 188{
189 struct zd1201 *zd = urb->context; 189 struct zd1201 *zd = urb->context;
@@ -772,7 +772,7 @@ static int zd1201_net_stop(struct net_device *dev)
772/* 772/*
773 RFC 1042 encapsulates Ethernet frames in 802.11 frames 773 RFC 1042 encapsulates Ethernet frames in 802.11 frames
774 by prefixing them with 0xaa, 0xaa, 0x03) followed by a SNAP OID of 0 774 by prefixing them with 0xaa, 0xaa, 0x03) followed by a SNAP OID of 0
775 (0x00, 0x00, 0x00). Zd requires an additionnal padding, copy 775 (0x00, 0x00, 0x00). Zd requires an additional padding, copy
776 of ethernet addresses, length of the standard RFC 1042 packet 776 of ethernet addresses, length of the standard RFC 1042 packet
777 and a command byte (which is nul for tx). 777 and a command byte (which is nul for tx).
778 778
@@ -1098,7 +1098,7 @@ static int zd1201_get_range(struct net_device *dev,
1098 1098
1099/* Little bit of magic here: we only get the quality if we poll 1099/* Little bit of magic here: we only get the quality if we poll
1100 * for it, and we never get an actual request to trigger such 1100 * for it, and we never get an actual request to trigger such
1101 * a poll. Therefore we 'asume' that the user will soon ask for 1101 * a poll. Therefore we 'assume' that the user will soon ask for
1102 * the stats after asking the bssid. 1102 * the stats after asking the bssid.
1103 */ 1103 */
1104static int zd1201_get_wap(struct net_device *dev, 1104static int zd1201_get_wap(struct net_device *dev,
@@ -1108,7 +1108,7 @@ static int zd1201_get_wap(struct net_device *dev,
1108 unsigned char buffer[6]; 1108 unsigned char buffer[6];
1109 1109
1110 if (!zd1201_getconfig(zd, ZD1201_RID_COMMSQUALITY, buffer, 6)) { 1110 if (!zd1201_getconfig(zd, ZD1201_RID_COMMSQUALITY, buffer, 6)) {
1111 /* Unfortunatly the quality and noise reported is useless. 1111 /* Unfortunately the quality and noise reported is useless.
1112 they seem to be accumulators that increase until you 1112 they seem to be accumulators that increase until you
1113 read them, unless we poll on a fixed interval we can't 1113 read them, unless we poll on a fixed interval we can't
1114 use them 1114 use them
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index 0c4aa00bb39d..bc798edf0358 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -53,6 +53,15 @@ config USB_SERIAL_GENERIC
53 support" be compiled as a module for this driver to be used 53 support" be compiled as a module for this driver to be used
54 properly. 54 properly.
55 55
56config USB_SERIAL_AIRPRIME
57 tristate "USB AirPrime CDMA Wireless Driver"
58 depends on USB_SERIAL
59 help
60 Say Y here if you want to use a AirPrime CDMA Wireless PC card.
61
62 To compile this driver as a module, choose M here: the
63 module will be called airprime.
64
56config USB_SERIAL_BELKIN 65config USB_SERIAL_BELKIN
57 tristate "USB Belkin and Peracom Single Port Serial Driver" 66 tristate "USB Belkin and Peracom Single Port Serial Driver"
58 depends on USB_SERIAL 67 depends on USB_SERIAL
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index b0aac47d1959..d56ff6d86cce 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -11,6 +11,7 @@ usbserial-obj-$(CONFIG_USB_EZUSB) += ezusb.o
11 11
12usbserial-objs := usb-serial.o generic.o bus.o $(usbserial-obj-y) 12usbserial-objs := usb-serial.o generic.o bus.o $(usbserial-obj-y)
13 13
14obj-$(CONFIG_USB_SERIAL_AIRPRIME) += airprime.o
14obj-$(CONFIG_USB_SERIAL_BELKIN) += belkin_sa.o 15obj-$(CONFIG_USB_SERIAL_BELKIN) += belkin_sa.o
15obj-$(CONFIG_USB_SERIAL_CP2101) += cp2101.o 16obj-$(CONFIG_USB_SERIAL_CP2101) += cp2101.o
16obj-$(CONFIG_USB_SERIAL_CYBERJACK) += cyberjack.o 17obj-$(CONFIG_USB_SERIAL_CYBERJACK) += cyberjack.o
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c
new file mode 100644
index 000000000000..a4ce0008d69b
--- /dev/null
+++ b/drivers/usb/serial/airprime.c
@@ -0,0 +1,63 @@
1/*
2 * AirPrime CDMA Wireless Serial USB driver
3 *
4 * Copyright (C) 2005 Greg Kroah-Hartman <gregkh@suse.de>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 */
10
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/tty.h>
14#include <linux/module.h>
15#include <linux/usb.h>
16#include "usb-serial.h"
17
18static struct usb_device_id id_table [] = {
19 { USB_DEVICE(0xf3d, 0x0112) },
20 { },
21};
22MODULE_DEVICE_TABLE(usb, id_table);
23
24static struct usb_driver airprime_driver = {
25 .owner = THIS_MODULE,
26 .name = "airprime",
27 .probe = usb_serial_probe,
28 .disconnect = usb_serial_disconnect,
29 .id_table = id_table,
30};
31
32static struct usb_serial_device_type airprime_device = {
33 .owner = THIS_MODULE,
34 .name = "airprime",
35 .id_table = id_table,
36 .num_interrupt_in = NUM_DONT_CARE,
37 .num_bulk_in = NUM_DONT_CARE,
38 .num_bulk_out = NUM_DONT_CARE,
39 .num_ports = 1,
40};
41
42static int __init airprime_init(void)
43{
44 int retval;
45
46 retval = usb_serial_register(&airprime_device);
47 if (retval)
48 return retval;
49 retval = usb_register(&airprime_driver);
50 if (retval)
51 usb_serial_deregister(&airprime_device);
52 return retval;
53}
54
55static void __exit airprime_exit(void)
56{
57 usb_deregister(&airprime_driver);
58 usb_serial_deregister(&airprime_device);
59}
60
61module_init(airprime_init);
62module_exit(airprime_exit);
63MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index d165f42d560d..f34a9bb6a219 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -16,6 +16,14 @@
16 * See http://geocities.com/i0xox0i for information on this driver and the 16 * See http://geocities.com/i0xox0i for information on this driver and the
17 * earthmate usb device. 17 * earthmate usb device.
18 * 18 *
19 * Lonnie Mendez <dignome@gmail.com>
20 * 4-29-2005
21 * Fixed problem where setting or retreiving the serial config would fail with
22 * EPIPE. Removed CRTS toggling so the driver behaves more like other usbserial
23 * adapters. Issued new interval of 1ms instead of the default 10ms. As a
24 * result, transfer speed has been substantially increased. From avg. 850bps to
25 * avg. 3300bps. initial termios has also been modified. Cleaned up code and
26 * formatting issues so it is more readable. Replaced the C++ style comments.
19 * 27 *
20 * Lonnie Mendez <dignome@gmail.com> 28 * Lonnie Mendez <dignome@gmail.com>
21 * 12-15-2004 29 * 12-15-2004
@@ -32,12 +40,6 @@
32 * 10-2003 40 * 10-2003
33 * Driver first released. 41 * Driver first released.
34 * 42 *
35 *
36 * Long Term TODO:
37 * Improve transfer speeds - both read/write are somewhat slow
38 * at this point.
39 * Improve debugging. Show modem line status with debug output and
40 * implement filtering for certain data as a module parameter.
41 */ 43 */
42 44
43/* Thanks to Neil Whelchel for writing the first cypress m8 implementation for linux. */ 45/* Thanks to Neil Whelchel for writing the first cypress m8 implementation for linux. */
@@ -72,11 +74,12 @@
72 static int debug; 74 static int debug;
73#endif 75#endif
74static int stats; 76static int stats;
77static int interval;
75 78
76/* 79/*
77 * Version Information 80 * Version Information
78 */ 81 */
79#define DRIVER_VERSION "v1.08" 82#define DRIVER_VERSION "v1.09"
80#define DRIVER_AUTHOR "Lonnie Mendez <dignome@gmail.com>, Neil Whelchel <koyama@firstlight.net>" 83#define DRIVER_AUTHOR "Lonnie Mendez <dignome@gmail.com>, Neil Whelchel <koyama@firstlight.net>"
81#define DRIVER_DESC "Cypress USB to Serial Driver" 84#define DRIVER_DESC "Cypress USB to Serial Driver"
82 85
@@ -130,7 +133,6 @@ struct cypress_private {
130 char prev_status, diff_status; /* used for TIOCMIWAIT */ 133 char prev_status, diff_status; /* used for TIOCMIWAIT */
131 /* we pass a pointer to this as the arguement sent to cypress_set_termios old_termios */ 134 /* we pass a pointer to this as the arguement sent to cypress_set_termios old_termios */
132 struct termios tmp_termios; /* stores the old termios settings */ 135 struct termios tmp_termios; /* stores the old termios settings */
133 char calledfromopen; /* used when issuing lines on open - fixes rts drop bug */
134}; 136};
135 137
136/* write buffer structure */ 138/* write buffer structure */
@@ -168,10 +170,8 @@ static void cypress_buf_free(struct cypress_buf *cb);
168static void cypress_buf_clear(struct cypress_buf *cb); 170static void cypress_buf_clear(struct cypress_buf *cb);
169static unsigned int cypress_buf_data_avail(struct cypress_buf *cb); 171static unsigned int cypress_buf_data_avail(struct cypress_buf *cb);
170static unsigned int cypress_buf_space_avail(struct cypress_buf *cb); 172static unsigned int cypress_buf_space_avail(struct cypress_buf *cb);
171static unsigned int cypress_buf_put(struct cypress_buf *cb, const char *buf, 173static unsigned int cypress_buf_put(struct cypress_buf *cb, const char *buf, unsigned int count);
172 unsigned int count); 174static unsigned int cypress_buf_get(struct cypress_buf *cb, char *buf, unsigned int count);
173static unsigned int cypress_buf_get(struct cypress_buf *cb, char *buf,
174 unsigned int count);
175 175
176 176
177static struct usb_serial_device_type cypress_earthmate_device = { 177static struct usb_serial_device_type cypress_earthmate_device = {
@@ -234,14 +234,13 @@ static struct usb_serial_device_type cypress_hidcom_device = {
234 *****************************************************************************/ 234 *****************************************************************************/
235 235
236 236
237/* This function can either set or retreive the current serial line settings */ 237/* This function can either set or retrieve the current serial line settings */
238static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_mask, int data_bits, int stop_bits, 238static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_mask, int data_bits, int stop_bits,
239 int parity_enable, int parity_type, int reset, int cypress_request_type) 239 int parity_enable, int parity_type, int reset, int cypress_request_type)
240{ 240{
241 int i, n_baud_rate = 0, retval = 0; 241 int new_baudrate = 0, retval = 0, tries = 0;
242 struct cypress_private *priv; 242 struct cypress_private *priv;
243 __u8 feature_buffer[5]; 243 __u8 feature_buffer[8];
244 __u8 config;
245 unsigned long flags; 244 unsigned long flags;
246 245
247 dbg("%s", __FUNCTION__); 246 dbg("%s", __FUNCTION__);
@@ -256,7 +255,8 @@ static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_m
256 * of 57600bps (I have no idea whether DeLorme chose to use the general purpose 255 * of 57600bps (I have no idea whether DeLorme chose to use the general purpose
257 * firmware or not), if you need to modify this speed setting for your own 256 * firmware or not), if you need to modify this speed setting for your own
258 * project please add your own chiptype and modify the code likewise. The 257 * project please add your own chiptype and modify the code likewise. The
259 * Cypress HID->COM device will work successfully up to 115200bps. 258 * Cypress HID->COM device will work successfully up to 115200bps (but the
259 * actual throughput is around 3kBps).
260 */ 260 */
261 if (baud_mask != priv->cbr_mask) { 261 if (baud_mask != priv->cbr_mask) {
262 dbg("%s - baud rate is changing", __FUNCTION__); 262 dbg("%s - baud rate is changing", __FUNCTION__);
@@ -265,109 +265,114 @@ static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_m
265 * but are not used with NMEA and SiRF protocols */ 265 * but are not used with NMEA and SiRF protocols */
266 266
267 if ( (baud_mask == B300) || (baud_mask == B600) ) { 267 if ( (baud_mask == B300) || (baud_mask == B600) ) {
268 err("%s - failed setting baud rate, unsupported speed (default to 4800)", 268 err("%s - failed setting baud rate, unsupported speed",
269 __FUNCTION__); 269 __FUNCTION__);
270 n_baud_rate = 4800; 270 new_baudrate = priv->baud_rate;
271 } else if ( (n_baud_rate = mask_to_rate(baud_mask)) == -1) { 271 } else if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) {
272 err("%s - failed setting baud rate, unsupported speed (default to 4800)", 272 err("%s - failed setting baud rate, unsupported speed",
273 __FUNCTION__); 273 __FUNCTION__);
274 n_baud_rate = 4800; 274 new_baudrate = priv->baud_rate;
275 } 275 }
276 } else if (priv->chiptype == CT_CYPHIDCOM) { 276 } else if (priv->chiptype == CT_CYPHIDCOM) {
277 if ( (n_baud_rate = mask_to_rate(baud_mask)) == -1) { 277 if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) {
278 err("%s - failed setting baud rate, unsupported speed (default to 4800)", 278 err("%s - failed setting baud rate, unsupported speed",
279 __FUNCTION__); 279 __FUNCTION__);
280 n_baud_rate = 4800; 280 new_baudrate = priv->baud_rate;
281 } 281 }
282 } else if (priv->chiptype == CT_GENERIC) { 282 } else if (priv->chiptype == CT_GENERIC) {
283 if ( (n_baud_rate = mask_to_rate(baud_mask)) == -1) { 283 if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) {
284 err("%s - failed setting baud rate, unsupported speed (default to 4800)", 284 err("%s - failed setting baud rate, unsupported speed",
285 __FUNCTION__); 285 __FUNCTION__);
286 n_baud_rate = 4800; 286 new_baudrate = priv->baud_rate;
287 } 287 }
288 } else { 288 } else {
289 info("%s - please define your chiptype, using 4800bps default", __FUNCTION__); 289 info("%s - please define your chiptype", __FUNCTION__);
290 n_baud_rate = 4800; 290 new_baudrate = priv->baud_rate;
291 } 291 }
292 } else { /* baud rate not changing, keep the old */ 292 } else { /* baud rate not changing, keep the old */
293 n_baud_rate = priv->baud_rate; 293 new_baudrate = priv->baud_rate;
294 } 294 }
295 dbg("%s - baud rate is being sent as %d", __FUNCTION__, n_baud_rate); 295 dbg("%s - baud rate is being sent as %d", __FUNCTION__, new_baudrate);
296
297 296
298 /* 297 memset(feature_buffer, 0, 8);
299 * This algorithm accredited to Jiang Jay Zhang... thanks for all the help! 298 /* fill the feature_buffer with new configuration */
300 */ 299 *((u_int32_t *)feature_buffer) = new_baudrate;
301 for (i = 0; i < 4; ++i) {
302 feature_buffer[i] = ( n_baud_rate >> (i*8) & 0xFF );
303 }
304 300
305 config = 0; // reset config byte 301 feature_buffer[4] |= data_bits; /* assign data bits in 2 bit space ( max 3 ) */
306 config |= data_bits; // assign data bits in 2 bit space ( max 3 )
307 /* 1 bit gap */ 302 /* 1 bit gap */
308 config |= (stop_bits << 3); // assign stop bits in 1 bit space 303 feature_buffer[4] |= (stop_bits << 3); /* assign stop bits in 1 bit space */
309 config |= (parity_enable << 4); // assign parity flag in 1 bit space 304 feature_buffer[4] |= (parity_enable << 4); /* assign parity flag in 1 bit space */
310 config |= (parity_type << 5); // assign parity type in 1 bit space 305 feature_buffer[4] |= (parity_type << 5); /* assign parity type in 1 bit space */
311 /* 1 bit gap */ 306 /* 1 bit gap */
312 config |= (reset << 7); // assign reset at end of byte, 1 bit space 307 feature_buffer[4] |= (reset << 7); /* assign reset at end of byte, 1 bit space */
313
314 feature_buffer[4] = config;
315 308
316 dbg("%s - device is being sent this feature report:", __FUNCTION__); 309 dbg("%s - device is being sent this feature report:", __FUNCTION__);
317 dbg("%s - %02X - %02X - %02X - %02X - %02X", __FUNCTION__, feature_buffer[0], feature_buffer[1], 310 dbg("%s - %02X - %02X - %02X - %02X - %02X", __FUNCTION__, feature_buffer[0], feature_buffer[1],
318 feature_buffer[2], feature_buffer[3], feature_buffer[4]); 311 feature_buffer[2], feature_buffer[3], feature_buffer[4]);
319 312
313 do {
320 retval = usb_control_msg (port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0), 314 retval = usb_control_msg (port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0),
321 HID_REQ_SET_REPORT, USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS, 315 HID_REQ_SET_REPORT, USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
322 0x0300, 0, feature_buffer, 5, 500); 316 0x0300, 0, feature_buffer, 8, 500);
317
318 if (tries++ >= 3)
319 break;
323 320
324 if (retval != 5) 321 if (retval == EPIPE)
322 usb_clear_halt(port->serial->dev, 0x00);
323 } while (retval != 8 && retval != ENODEV);
324
325 if (retval != 8)
325 err("%s - failed sending serial line settings - %d", __FUNCTION__, retval); 326 err("%s - failed sending serial line settings - %d", __FUNCTION__, retval);
326 else { 327 else {
327 spin_lock_irqsave(&priv->lock, flags); 328 spin_lock_irqsave(&priv->lock, flags);
328 priv->baud_rate = n_baud_rate; 329 priv->baud_rate = new_baudrate;
329 priv->cbr_mask = baud_mask; 330 priv->cbr_mask = baud_mask;
330 priv->current_config = config; 331 priv->current_config = feature_buffer[4];
331 ++priv->cmd_count;
332 spin_unlock_irqrestore(&priv->lock, flags); 332 spin_unlock_irqrestore(&priv->lock, flags);
333 } 333 }
334 break; 334 break;
335 case CYPRESS_GET_CONFIG: 335 case CYPRESS_GET_CONFIG:
336 dbg("%s - retreiving serial line settings", __FUNCTION__); 336 dbg("%s - retreiving serial line settings", __FUNCTION__);
337 /* reset values in feature buffer */ 337 /* set initial values in feature buffer */
338 memset(feature_buffer, 0, 5); 338 memset(feature_buffer, 0, 8);
339 339
340 do {
340 retval = usb_control_msg (port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0), 341 retval = usb_control_msg (port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0),
341 HID_REQ_GET_REPORT, USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS, 342 HID_REQ_GET_REPORT, USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
342 0x0300, 0, feature_buffer, 5, 500); 343 0x0300, 0, feature_buffer, 8, 500);
344
345 if (tries++ >= 3)
346 break;
347
348 if (retval == EPIPE)
349 usb_clear_halt(port->serial->dev, 0x00);
350 } while (retval != 5 && retval != ENODEV);
351
343 if (retval != 5) { 352 if (retval != 5) {
344 err("%s - failed to retreive serial line settings - %d", __FUNCTION__, retval); 353 err("%s - failed to retreive serial line settings - %d", __FUNCTION__, retval);
345 return retval; 354 return retval;
346 } else { 355 } else {
347 spin_lock_irqsave(&priv->lock, flags); 356 spin_lock_irqsave(&priv->lock, flags);
357
348 /* store the config in one byte, and later use bit masks to check values */ 358 /* store the config in one byte, and later use bit masks to check values */
349 priv->current_config = feature_buffer[4]; 359 priv->current_config = feature_buffer[4];
350 /* reverse the process above to get the baud_mask value */ 360 priv->baud_rate = *((u_int32_t *)feature_buffer);
351 n_baud_rate = 0; // reset bits
352 for (i = 0; i < 4; ++i) {
353 n_baud_rate |= ( feature_buffer[i] << (i*8) );
354 }
355 361
356 priv->baud_rate = n_baud_rate; 362 if ( (priv->cbr_mask = rate_to_mask(priv->baud_rate)) == 0x40)
357 if ( (priv->cbr_mask = rate_to_mask(n_baud_rate)) == 0x40)
358 dbg("%s - failed setting the baud mask (not defined)", __FUNCTION__); 363 dbg("%s - failed setting the baud mask (not defined)", __FUNCTION__);
359 ++priv->cmd_count;
360 spin_unlock_irqrestore(&priv->lock, flags); 364 spin_unlock_irqrestore(&priv->lock, flags);
361 } 365 }
362 break;
363 default:
364 err("%s - unsupported serial control command issued", __FUNCTION__);
365 } 366 }
367 spin_lock_irqsave(&priv->lock, flags);
368 ++priv->cmd_count;
369 spin_unlock_irqrestore(&priv->lock, flags);
370
366 return retval; 371 return retval;
367} /* cypress_serial_control */ 372} /* cypress_serial_control */
368 373
369 374
370/* given a baud mask, it will return speed on success */ 375/* given a baud mask, it will return integer baud on success */
371static int mask_to_rate (unsigned mask) 376static int mask_to_rate (unsigned mask)
372{ 377{
373 int rate; 378 int rate;
@@ -438,11 +443,12 @@ static int generic_startup (struct usb_serial *serial)
438 443
439 usb_reset_configuration (serial->dev); 444 usb_reset_configuration (serial->dev);
440 445
446 interval = 1;
441 priv->cmd_ctrl = 0; 447 priv->cmd_ctrl = 0;
442 priv->line_control = 0; 448 priv->line_control = 0;
443 priv->termios_initialized = 0; 449 priv->termios_initialized = 0;
444 priv->calledfromopen = 0;
445 priv->rx_flags = 0; 450 priv->rx_flags = 0;
451 priv->cbr_mask = B300;
446 usb_set_serial_port_data(serial->port[0], priv); 452 usb_set_serial_port_data(serial->port[0], priv);
447 453
448 return (0); 454 return (0);
@@ -513,7 +519,6 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp)
513 dbg("%s - port %d", __FUNCTION__, port->number); 519 dbg("%s - port %d", __FUNCTION__, port->number);
514 520
515 /* clear halts before open */ 521 /* clear halts before open */
516 usb_clear_halt(serial->dev, 0x00);
517 usb_clear_halt(serial->dev, 0x81); 522 usb_clear_halt(serial->dev, 0x81);
518 usb_clear_halt(serial->dev, 0x02); 523 usb_clear_halt(serial->dev, 0x02);
519 524
@@ -531,7 +536,6 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp)
531 /* raise both lines and set termios */ 536 /* raise both lines and set termios */
532 spin_lock_irqsave(&priv->lock, flags); 537 spin_lock_irqsave(&priv->lock, flags);
533 priv->line_control = CONTROL_DTR | CONTROL_RTS; 538 priv->line_control = CONTROL_DTR | CONTROL_RTS;
534 priv->calledfromopen = 1;
535 priv->cmd_ctrl = 1; 539 priv->cmd_ctrl = 1;
536 spin_unlock_irqrestore(&priv->lock, flags); 540 spin_unlock_irqrestore(&priv->lock, flags);
537 result = cypress_write(port, NULL, 0); 541 result = cypress_write(port, NULL, 0);
@@ -553,7 +557,7 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp)
553 usb_fill_int_urb(port->interrupt_in_urb, serial->dev, 557 usb_fill_int_urb(port->interrupt_in_urb, serial->dev,
554 usb_rcvintpipe(serial->dev, port->interrupt_in_endpointAddress), 558 usb_rcvintpipe(serial->dev, port->interrupt_in_endpointAddress),
555 port->interrupt_in_urb->transfer_buffer, port->interrupt_in_urb->transfer_buffer_length, 559 port->interrupt_in_urb->transfer_buffer, port->interrupt_in_urb->transfer_buffer_length,
556 cypress_read_int_callback, port, port->interrupt_in_urb->interval); 560 cypress_read_int_callback, port, interval);
557 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 561 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
558 562
559 if (result){ 563 if (result){
@@ -680,12 +684,12 @@ static void cypress_send(struct usb_serial_port *port)
680 spin_lock_irqsave(&priv->lock, flags); 684 spin_lock_irqsave(&priv->lock, flags);
681 switch (port->interrupt_out_size) { 685 switch (port->interrupt_out_size) {
682 case 32: 686 case 32:
683 // this is for the CY7C64013... 687 /* this is for the CY7C64013... */
684 offset = 2; 688 offset = 2;
685 port->interrupt_out_buffer[0] = priv->line_control; 689 port->interrupt_out_buffer[0] = priv->line_control;
686 break; 690 break;
687 case 8: 691 case 8:
688 // this is for the CY7C63743... 692 /* this is for the CY7C63743... */
689 offset = 1; 693 offset = 1;
690 port->interrupt_out_buffer[0] = priv->line_control; 694 port->interrupt_out_buffer[0] = priv->line_control;
691 break; 695 break;
@@ -738,6 +742,7 @@ send:
738 742
739 port->interrupt_out_urb->transfer_buffer_length = actual_size; 743 port->interrupt_out_urb->transfer_buffer_length = actual_size;
740 port->interrupt_out_urb->dev = port->serial->dev; 744 port->interrupt_out_urb->dev = port->serial->dev;
745 port->interrupt_out_urb->interval = interval;
741 result = usb_submit_urb (port->interrupt_out_urb, GFP_ATOMIC); 746 result = usb_submit_urb (port->interrupt_out_urb, GFP_ATOMIC);
742 if (result) { 747 if (result) {
743 dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, 748 dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__,
@@ -910,7 +915,7 @@ static void cypress_set_termios (struct usb_serial_port *port, struct termios *o
910 unsigned cflag, iflag, baud_mask; 915 unsigned cflag, iflag, baud_mask;
911 unsigned long flags; 916 unsigned long flags;
912 __u8 oldlines; 917 __u8 oldlines;
913 int linechange; 918 int linechange = 0;
914 919
915 dbg("%s - port %d", __FUNCTION__, port->number); 920 dbg("%s - port %d", __FUNCTION__, port->number);
916 921
@@ -996,15 +1001,7 @@ static void cypress_set_termios (struct usb_serial_port *port, struct termios *o
996 case B115200: dbg("%s - setting baud 115200bps", __FUNCTION__); break; 1001 case B115200: dbg("%s - setting baud 115200bps", __FUNCTION__); break;
997 default: dbg("%s - unknown masked baud rate", __FUNCTION__); 1002 default: dbg("%s - unknown masked baud rate", __FUNCTION__);
998 } 1003 }
999 priv->line_control |= CONTROL_DTR; 1004 priv->line_control = (CONTROL_DTR | CONTROL_RTS);
1000
1001 /* toggle CRTSCTS? - don't do this if being called from cypress_open */
1002 if (!priv->calledfromopen) {
1003 if (cflag & CRTSCTS)
1004 priv->line_control |= CONTROL_RTS;
1005 else
1006 priv->line_control &= ~CONTROL_RTS;
1007 }
1008 } 1005 }
1009 spin_unlock_irqrestore(&priv->lock, flags); 1006 spin_unlock_irqrestore(&priv->lock, flags);
1010 1007
@@ -1014,8 +1011,6 @@ static void cypress_set_termios (struct usb_serial_port *port, struct termios *o
1014 cypress_serial_control(port, baud_mask, data_bits, stop_bits, parity_enable, 1011 cypress_serial_control(port, baud_mask, data_bits, stop_bits, parity_enable,
1015 parity_type, 0, CYPRESS_SET_CONFIG); 1012 parity_type, 0, CYPRESS_SET_CONFIG);
1016 1013
1017 msleep(50); /* give some time between change and read (50ms) */
1018
1019 /* we perform a CYPRESS_GET_CONFIG so that the current settings are filled into the private structure 1014 /* we perform a CYPRESS_GET_CONFIG so that the current settings are filled into the private structure
1020 * this should confirm that all is working if it returns what we just set */ 1015 * this should confirm that all is working if it returns what we just set */
1021 cypress_serial_control(port, 0, 0, 0, 0, 0, 0, CYPRESS_GET_CONFIG); 1016 cypress_serial_control(port, 0, 0, 0, 0, 0, 0, CYPRESS_GET_CONFIG);
@@ -1031,7 +1026,6 @@ static void cypress_set_termios (struct usb_serial_port *port, struct termios *o
1031 dbg("Using custom termios settings for a baud rate of 4800bps."); 1026 dbg("Using custom termios settings for a baud rate of 4800bps.");
1032 /* define custom termios settings for NMEA protocol */ 1027 /* define custom termios settings for NMEA protocol */
1033 1028
1034
1035 tty->termios->c_iflag /* input modes - */ 1029 tty->termios->c_iflag /* input modes - */
1036 &= ~(IGNBRK /* disable ignore break */ 1030 &= ~(IGNBRK /* disable ignore break */
1037 | BRKINT /* disable break causes interrupt */ 1031 | BRKINT /* disable break causes interrupt */
@@ -1052,23 +1046,16 @@ static void cypress_set_termios (struct usb_serial_port *port, struct termios *o
1052 | ISIG /* disable interrupt, quit, and suspend special characters */ 1046 | ISIG /* disable interrupt, quit, and suspend special characters */
1053 | IEXTEN); /* disable non-POSIX special characters */ 1047 | IEXTEN); /* disable non-POSIX special characters */
1054 1048
1055 } else if (priv->chiptype == CT_CYPHIDCOM) { 1049 } /* CT_CYPHIDCOM: Application should handle this for device */
1056
1057 // Software app handling it for device...
1058 1050
1059 }
1060 linechange = (priv->line_control != oldlines); 1051 linechange = (priv->line_control != oldlines);
1061 spin_unlock_irqrestore(&priv->lock, flags); 1052 spin_unlock_irqrestore(&priv->lock, flags);
1062 1053
1063 /* if necessary, set lines */ 1054 /* if necessary, set lines */
1064 if (!priv->calledfromopen && linechange) { 1055 if (linechange) {
1065 priv->cmd_ctrl = 1; 1056 priv->cmd_ctrl = 1;
1066 cypress_write(port, NULL, 0); 1057 cypress_write(port, NULL, 0);
1067 } 1058 }
1068
1069 if (priv->calledfromopen)
1070 priv->calledfromopen = 0;
1071
1072} /* cypress_set_termios */ 1059} /* cypress_set_termios */
1073 1060
1074 1061
@@ -1164,7 +1151,7 @@ static void cypress_read_int_callback(struct urb *urb, struct pt_regs *regs)
1164 spin_lock_irqsave(&priv->lock, flags); 1151 spin_lock_irqsave(&priv->lock, flags);
1165 switch(urb->actual_length) { 1152 switch(urb->actual_length) {
1166 case 32: 1153 case 32:
1167 // This is for the CY7C64013... 1154 /* This is for the CY7C64013... */
1168 priv->current_status = data[0] & 0xF8; 1155 priv->current_status = data[0] & 0xF8;
1169 bytes = data[1]+2; 1156 bytes = data[1]+2;
1170 i=2; 1157 i=2;
@@ -1172,7 +1159,7 @@ static void cypress_read_int_callback(struct urb *urb, struct pt_regs *regs)
1172 havedata = 1; 1159 havedata = 1;
1173 break; 1160 break;
1174 case 8: 1161 case 8:
1175 // This is for the CY7C63743... 1162 /* This is for the CY7C63743... */
1176 priv->current_status = data[0] & 0xF8; 1163 priv->current_status = data[0] & 0xF8;
1177 bytes = (data[0] & 0x07)+1; 1164 bytes = (data[0] & 0x07)+1;
1178 i=1; 1165 i=1;
@@ -1245,7 +1232,7 @@ continue_read:
1245 port->interrupt_in_urb->transfer_buffer, 1232 port->interrupt_in_urb->transfer_buffer,
1246 port->interrupt_in_urb->transfer_buffer_length, 1233 port->interrupt_in_urb->transfer_buffer_length,
1247 cypress_read_int_callback, port, 1234 cypress_read_int_callback, port,
1248 port->interrupt_in_urb->interval); 1235 interval);
1249 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 1236 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
1250 if (result) 1237 if (result)
1251 dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); 1238 dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result);
@@ -1274,6 +1261,8 @@ static void cypress_write_int_callback(struct urb *urb, struct pt_regs *regs)
1274 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status); 1261 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
1275 priv->write_urb_in_use = 0; 1262 priv->write_urb_in_use = 0;
1276 return; 1263 return;
1264 case -EPIPE: /* no break needed */
1265 usb_clear_halt(port->serial->dev, 0x02);
1277 default: 1266 default:
1278 /* error in the urb, so we have to resubmit it */ 1267 /* error in the urb, so we have to resubmit it */
1279 dbg("%s - Overflow in write", __FUNCTION__); 1268 dbg("%s - Overflow in write", __FUNCTION__);
@@ -1535,3 +1524,5 @@ module_param(debug, bool, S_IRUGO | S_IWUSR);
1535MODULE_PARM_DESC(debug, "Debug enabled or not"); 1524MODULE_PARM_DESC(debug, "Debug enabled or not");
1536module_param(stats, bool, S_IRUGO | S_IWUSR); 1525module_param(stats, bool, S_IRUGO | S_IWUSR);
1537MODULE_PARM_DESC(stats, "Enable statistics or not"); 1526MODULE_PARM_DESC(stats, "Enable statistics or not");
1527module_param(interval, int, S_IRUGO | S_IWUSR);
1528MODULE_PARM_DESC(interval, "Overrides interrupt interval");
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 4c788c767a97..52394f08a947 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -76,7 +76,7 @@
76 * Defererence pointers after any paranoid checks, not before. 76 * Defererence pointers after any paranoid checks, not before.
77 * 77 *
78 * (21/Jun/2003) Erik Nygren 78 * (21/Jun/2003) Erik Nygren
79 * Added support for Home Electronics Tira-1 IR tranceiver using FT232BM chip. 79 * Added support for Home Electronics Tira-1 IR transceiver using FT232BM chip.
80 * See <http://www.home-electro.com/tira1.htm>. Only operates properly 80 * See <http://www.home-electro.com/tira1.htm>. Only operates properly
81 * at 100000 and RTS-CTS, so set custom divisor mode on startup. 81 * at 100000 and RTS-CTS, so set custom divisor mode on startup.
82 * Also force the Tira-1 and USB-UIRT to only use their custom baud rates. 82 * Also force the Tira-1 and USB-UIRT to only use their custom baud rates.
@@ -91,7 +91,7 @@
91 * Minor whitespace and comment changes. 91 * Minor whitespace and comment changes.
92 * 92 *
93 * (12/Jun/2003) David Norwood 93 * (12/Jun/2003) David Norwood
94 * Added support for USB-UIRT IR tranceiver using 8U232AM chip. 94 * Added support for USB-UIRT IR transceiver using 8U232AM chip.
95 * See <http://home.earthlink.net/~jrhees/USBUIRT/index.htm>. Only 95 * See <http://home.earthlink.net/~jrhees/USBUIRT/index.htm>. Only
96 * operates properly at 312500, so set custom divisor mode on startup. 96 * operates properly at 312500, so set custom divisor mode on startup.
97 * 97 *
@@ -272,6 +272,7 @@ static int debug;
272 272
273static struct usb_device_id id_table_sio [] = { 273static struct usb_device_id id_table_sio [] = {
274 { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) }, 274 { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) },
275 { USB_DEVICE(MOBILITY_VID, MOBILITY_USB_SERIAL_PID) },
275 { } /* Terminating entry */ 276 { } /* Terminating entry */
276}; 277};
277 278
@@ -296,7 +297,6 @@ static struct usb_device_id id_table_8U232AM [] = {
296 { USB_DEVICE_VER(FTDI_VID, FTDI_IRTRANS_PID, 0, 0x3ff) }, 297 { USB_DEVICE_VER(FTDI_VID, FTDI_IRTRANS_PID, 0, 0x3ff) },
297 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_PID, 0, 0x3ff) }, 298 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_PID, 0, 0x3ff) },
298 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_ALT_PID, 0, 0x3ff) }, 299 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_ALT_PID, 0, 0x3ff) },
299 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_ALT_ALT_PID, 0, 0x3ff) },
300 { USB_DEVICE_VER(FTDI_VID, FTDI_RELAIS_PID, 0, 0x3ff) }, 300 { USB_DEVICE_VER(FTDI_VID, FTDI_RELAIS_PID, 0, 0x3ff) },
301 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) }, 301 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) },
302 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) }, 302 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) },
@@ -369,11 +369,14 @@ static struct usb_device_id id_table_8U232AM [] = {
369 { USB_DEVICE_VER(INTREPID_VID, INTREPID_NEOVI_PID, 0, 0x3ff) }, 369 { USB_DEVICE_VER(INTREPID_VID, INTREPID_NEOVI_PID, 0, 0x3ff) },
370 { USB_DEVICE_VER(FALCOM_VID, FALCOM_TWIST_PID, 0, 0x3ff) }, 370 { USB_DEVICE_VER(FALCOM_VID, FALCOM_TWIST_PID, 0, 0x3ff) },
371 { USB_DEVICE_VER(FTDI_VID, FTDI_SUUNTO_SPORTS_PID, 0, 0x3ff) }, 371 { USB_DEVICE_VER(FTDI_VID, FTDI_SUUNTO_SPORTS_PID, 0, 0x3ff) },
372 { USB_DEVICE_VER(FTDI_RM_VID, FTDI_RMCANVIEW_PID, 0, 0x3ff) }, 372 { USB_DEVICE_VER(FTDI_VID, FTDI_RM_CANVIEW_PID, 0, 0x3ff) },
373 { USB_DEVICE_VER(BANDB_VID, BANDB_USOTL4_PID, 0, 0x3ff) }, 373 { USB_DEVICE_VER(BANDB_VID, BANDB_USOTL4_PID, 0, 0x3ff) },
374 { USB_DEVICE_VER(BANDB_VID, BANDB_USTL4_PID, 0, 0x3ff) }, 374 { USB_DEVICE_VER(BANDB_VID, BANDB_USTL4_PID, 0, 0x3ff) },
375 { USB_DEVICE_VER(BANDB_VID, BANDB_USO9ML2_PID, 0, 0x3ff) }, 375 { USB_DEVICE_VER(BANDB_VID, BANDB_USO9ML2_PID, 0, 0x3ff) },
376 { USB_DEVICE_VER(FTDI_VID, EVER_ECO_PRO_CDS, 0, 0x3ff) }, 376 { USB_DEVICE_VER(FTDI_VID, EVER_ECO_PRO_CDS, 0, 0x3ff) },
377 { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_0_PID, 0, 0x3ff) },
378 { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_1_PID, 0, 0x3ff) },
379 { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_2_PID, 0, 0x3ff) },
377 { } /* Terminating entry */ 380 { } /* Terminating entry */
378}; 381};
379 382
@@ -382,7 +385,6 @@ static struct usb_device_id id_table_FT232BM [] = {
382 { USB_DEVICE_VER(FTDI_VID, FTDI_IRTRANS_PID, 0x400, 0xffff) }, 385 { USB_DEVICE_VER(FTDI_VID, FTDI_IRTRANS_PID, 0x400, 0xffff) },
383 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_PID, 0x400, 0xffff) }, 386 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_PID, 0x400, 0xffff) },
384 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_ALT_PID, 0x400, 0xffff) }, 387 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_ALT_PID, 0x400, 0xffff) },
385 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_ALT_ALT_PID, 0x400, 0xffff) },
386 { USB_DEVICE_VER(FTDI_VID, FTDI_RELAIS_PID, 0x400, 0xffff) }, 388 { USB_DEVICE_VER(FTDI_VID, FTDI_RELAIS_PID, 0x400, 0xffff) },
387 { USB_DEVICE_VER(FTDI_NF_RIC_VID, FTDI_NF_RIC_PID, 0x400, 0xffff) }, 389 { USB_DEVICE_VER(FTDI_NF_RIC_VID, FTDI_NF_RIC_PID, 0x400, 0xffff) },
388 { USB_DEVICE_VER(FTDI_VID, FTDI_XF_632_PID, 0x400, 0xffff) }, 390 { USB_DEVICE_VER(FTDI_VID, FTDI_XF_632_PID, 0x400, 0xffff) },
@@ -485,11 +487,15 @@ static struct usb_device_id id_table_FT232BM [] = {
485 { USB_DEVICE_VER(INTREPID_VID, INTREPID_NEOVI_PID, 0x400, 0xffff) }, 487 { USB_DEVICE_VER(INTREPID_VID, INTREPID_NEOVI_PID, 0x400, 0xffff) },
486 { USB_DEVICE_VER(FALCOM_VID, FALCOM_TWIST_PID, 0x400, 0xffff) }, 488 { USB_DEVICE_VER(FALCOM_VID, FALCOM_TWIST_PID, 0x400, 0xffff) },
487 { USB_DEVICE_VER(FTDI_VID, FTDI_SUUNTO_SPORTS_PID, 0x400, 0xffff) }, 489 { USB_DEVICE_VER(FTDI_VID, FTDI_SUUNTO_SPORTS_PID, 0x400, 0xffff) },
488 { USB_DEVICE_VER(FTDI_RM_VID, FTDI_RMCANVIEW_PID, 0x400, 0xffff) }, 490 { USB_DEVICE_VER(FTDI_VID, FTDI_RM_CANVIEW_PID, 0x400, 0xffff) },
489 { USB_DEVICE_VER(BANDB_VID, BANDB_USOTL4_PID, 0x400, 0xffff) }, 491 { USB_DEVICE_VER(BANDB_VID, BANDB_USOTL4_PID, 0x400, 0xffff) },
490 { USB_DEVICE_VER(BANDB_VID, BANDB_USTL4_PID, 0x400, 0xffff) }, 492 { USB_DEVICE_VER(BANDB_VID, BANDB_USTL4_PID, 0x400, 0xffff) },
491 { USB_DEVICE_VER(BANDB_VID, BANDB_USO9ML2_PID, 0x400, 0xffff) }, 493 { USB_DEVICE_VER(BANDB_VID, BANDB_USO9ML2_PID, 0x400, 0xffff) },
492 { USB_DEVICE_VER(FTDI_VID, EVER_ECO_PRO_CDS, 0x400, 0xffff) }, 494 { USB_DEVICE_VER(FTDI_VID, EVER_ECO_PRO_CDS, 0x400, 0xffff) },
495 { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_0_PID, 0x400, 0xffff) },
496 { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_1_PID, 0x400, 0xffff) },
497 { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_2_PID, 0x400, 0xffff) },
498 { USB_DEVICE_VER(FTDI_VID, FTDI_ACTIVE_ROBOTS_PID, 0x400, 0xffff) },
493 { } /* Terminating entry */ 499 { } /* Terminating entry */
494}; 500};
495 501
@@ -517,7 +523,6 @@ static struct usb_device_id id_table_combined [] = {
517 { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) }, 523 { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) },
518 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) }, 524 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) },
519 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) }, 525 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) },
520 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_ALT_PID) },
521 { USB_DEVICE(FTDI_VID, FTDI_8U2232C_PID) }, 526 { USB_DEVICE(FTDI_VID, FTDI_8U2232C_PID) },
522 { USB_DEVICE(FTDI_VID, FTDI_RELAIS_PID) }, 527 { USB_DEVICE(FTDI_VID, FTDI_RELAIS_PID) },
523 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) }, 528 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) },
@@ -596,6 +601,22 @@ static struct usb_device_id id_table_combined [] = {
596 { USB_DEVICE(FTDI_VID, PROTEGO_R2X0) }, 601 { USB_DEVICE(FTDI_VID, PROTEGO_R2X0) },
597 { USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_3) }, 602 { USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_3) },
598 { USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_4) }, 603 { USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_4) },
604 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E808_PID, 0x400, 0xffff) },
605 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E809_PID, 0x400, 0xffff) },
606 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80A_PID, 0x400, 0xffff) },
607 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80B_PID, 0x400, 0xffff) },
608 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80C_PID, 0x400, 0xffff) },
609 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80D_PID, 0x400, 0xffff) },
610 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80E_PID, 0x400, 0xffff) },
611 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80F_PID, 0x400, 0xffff) },
612 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E888_PID, 0x400, 0xffff) },
613 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E889_PID, 0x400, 0xffff) },
614 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88A_PID, 0x400, 0xffff) },
615 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88B_PID, 0x400, 0xffff) },
616 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88C_PID, 0x400, 0xffff) },
617 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88D_PID, 0x400, 0xffff) },
618 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88E_PID, 0x400, 0xffff) },
619 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88F_PID, 0x400, 0xffff) },
599 { USB_DEVICE(FTDI_VID, FTDI_ELV_UO100_PID) }, 620 { USB_DEVICE(FTDI_VID, FTDI_ELV_UO100_PID) },
600 { USB_DEVICE_VER(FTDI_VID, LINX_SDMUSBQSS_PID, 0x400, 0xffff) }, 621 { USB_DEVICE_VER(FTDI_VID, LINX_SDMUSBQSS_PID, 0x400, 0xffff) },
601 { USB_DEVICE_VER(FTDI_VID, LINX_MASTERDEVEL2_PID, 0x400, 0xffff) }, 622 { USB_DEVICE_VER(FTDI_VID, LINX_MASTERDEVEL2_PID, 0x400, 0xffff) },
@@ -609,11 +630,16 @@ static struct usb_device_id id_table_combined [] = {
609 { USB_DEVICE(INTREPID_VID, INTREPID_NEOVI_PID) }, 630 { USB_DEVICE(INTREPID_VID, INTREPID_NEOVI_PID) },
610 { USB_DEVICE(FALCOM_VID, FALCOM_TWIST_PID) }, 631 { USB_DEVICE(FALCOM_VID, FALCOM_TWIST_PID) },
611 { USB_DEVICE(FTDI_VID, FTDI_SUUNTO_SPORTS_PID) }, 632 { USB_DEVICE(FTDI_VID, FTDI_SUUNTO_SPORTS_PID) },
612 { USB_DEVICE(FTDI_RM_VID, FTDI_RMCANVIEW_PID) }, 633 { USB_DEVICE(FTDI_VID, FTDI_RM_CANVIEW_PID) },
613 { USB_DEVICE(BANDB_VID, BANDB_USOTL4_PID) }, 634 { USB_DEVICE(BANDB_VID, BANDB_USOTL4_PID) },
614 { USB_DEVICE(BANDB_VID, BANDB_USTL4_PID) }, 635 { USB_DEVICE(BANDB_VID, BANDB_USTL4_PID) },
615 { USB_DEVICE(BANDB_VID, BANDB_USO9ML2_PID) }, 636 { USB_DEVICE(BANDB_VID, BANDB_USO9ML2_PID) },
616 { USB_DEVICE(FTDI_VID, EVER_ECO_PRO_CDS) }, 637 { USB_DEVICE(FTDI_VID, EVER_ECO_PRO_CDS) },
638 { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_0_PID) },
639 { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_1_PID) },
640 { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_2_PID) },
641 { USB_DEVICE(MOBILITY_VID, MOBILITY_USB_SERIAL_PID) },
642 { USB_DEVICE_VER(FTDI_VID, FTDI_ACTIVE_ROBOTS_PID, 0x400, 0xffff) },
617 { } /* Terminating entry */ 643 { } /* Terminating entry */
618}; 644};
619 645
@@ -1457,10 +1483,10 @@ static int ftdi_FT2232C_startup (struct usb_serial *serial)
1457 inter = serial->interface->altsetting->desc.bInterfaceNumber; 1483 inter = serial->interface->altsetting->desc.bInterfaceNumber;
1458 1484
1459 if (inter) { 1485 if (inter) {
1460 priv->interface = INTERFACE_B; 1486 priv->interface = PIT_SIOB;
1461 } 1487 }
1462 else { 1488 else {
1463 priv->interface = INTERFACE_A; 1489 priv->interface = PIT_SIOA;
1464 } 1490 }
1465 priv->baud_base = 48000000 / 2; /* Would be / 16, but FT2232C supports multiple of 0.125 divisor fractions! */ 1491 priv->baud_base = 48000000 / 2; /* Would be / 16, but FT2232C supports multiple of 0.125 divisor fractions! */
1466 1492
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index be5d60bf90b9..a52bb13a9ce4 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -26,7 +26,6 @@
26#define FTDI_SIO_PID 0x8372 /* Product Id SIO application of 8U100AX */ 26#define FTDI_SIO_PID 0x8372 /* Product Id SIO application of 8U100AX */
27#define FTDI_8U232AM_PID 0x6001 /* Similar device to SIO above */ 27#define FTDI_8U232AM_PID 0x6001 /* Similar device to SIO above */
28#define FTDI_8U232AM_ALT_PID 0x6006 /* FTDI's alternate PID for above */ 28#define FTDI_8U232AM_ALT_PID 0x6006 /* FTDI's alternate PID for above */
29#define FTDI_8U232AM_ALT_ALT_PID 0xf3c0 /* FTDI's second alternate PID for above */
30#define FTDI_8U2232C_PID 0x6010 /* Dual channel device */ 29#define FTDI_8U2232C_PID 0x6010 /* Dual channel device */
31#define FTDI_RELAIS_PID 0xFA10 /* Relais device from Rudolf Gugler */ 30#define FTDI_RELAIS_PID 0xFA10 /* Relais device from Rudolf Gugler */
32#define FTDI_NF_RIC_VID 0x0DCD /* Vendor Id */ 31#define FTDI_NF_RIC_VID 0x0DCD /* Vendor Id */
@@ -137,7 +136,7 @@
137/* 136/*
138 * Home Electronics (www.home-electro.com) USB gadgets 137 * Home Electronics (www.home-electro.com) USB gadgets
139 */ 138 */
140#define FTDI_HE_TIRA1_PID 0xFA78 /* Tira-1 IR tranceiver */ 139#define FTDI_HE_TIRA1_PID 0xFA78 /* Tira-1 IR transceiver */
141 140
142/* USB-UIRT - An infrared receiver and transmitter using the 8U232AM chip */ 141/* USB-UIRT - An infrared receiver and transmitter using the 8U232AM chip */
143/* http://home.earthlink.net/~jrhees/USBUIRT/index.htm */ 142/* http://home.earthlink.net/~jrhees/USBUIRT/index.htm */
@@ -157,7 +156,8 @@
157 */ 156 */
158#define OCT_VID 0x0B39 /* OCT vendor ID */ 157#define OCT_VID 0x0B39 /* OCT vendor ID */
159/* Note: OCT US101 is also rebadged as Dick Smith Electronics (NZ) XH6381 */ 158/* Note: OCT US101 is also rebadged as Dick Smith Electronics (NZ) XH6381 */
160/* Also rebadged as SIIG Inc. model US2308 */ 159/* Also rebadged as Dick Smith Electronics (Aus) XH6451 */
160/* Also rebadged as SIIG Inc. model US2308 hardware version 1 */
161#define OCT_US101_PID 0x0421 /* OCT US101 USB to RS-232 */ 161#define OCT_US101_PID 0x0421 /* OCT US101 USB to RS-232 */
162 162
163/* an infrared receiver for user access control with IR tags */ 163/* an infrared receiver for user access control with IR tags */
@@ -236,10 +236,10 @@
236 236
237/* 237/*
238 * RM Michaelides CANview USB (http://www.rmcan.com) 238 * RM Michaelides CANview USB (http://www.rmcan.com)
239 * CAN filedbus interface adapter, addad by port GmbH www.port.de) 239 * CAN fieldbus interface adapter, added by port GmbH www.port.de)
240 * Ian Abbott changed the macro names for consistency.
240 */ 241 */
241#define FTDI_RM_VID 0x0403 /* Vendor Id */ 242#define FTDI_RM_CANVIEW_PID 0xfd60 /* Product Id */
242#define FTDI_RMCANVIEW_PID 0xfd60 /* Product Id */
243 243
244/* 244/*
245 * EVER Eco Pro UPS (http://www.ever.com.pl/) 245 * EVER Eco Pro UPS (http://www.ever.com.pl/)
@@ -247,6 +247,26 @@
247 247
248#define EVER_ECO_PRO_CDS 0xe520 /* RS-232 converter */ 248#define EVER_ECO_PRO_CDS 0xe520 /* RS-232 converter */
249 249
250/*
251 * 4N-GALAXY.DE PIDs for CAN-USB, USB-RS232, USB-RS422, USB-RS485,
252 * USB-TTY activ, USB-TTY passiv. Some PIDs are used by several devices
253 * and I'm not entirely sure which are used by which.
254 */
255#define FTDI_4N_GALAXY_DE_0_PID 0x8372
256#define FTDI_4N_GALAXY_DE_1_PID 0xF3C0
257#define FTDI_4N_GALAXY_DE_2_PID 0xF3C1
258
259/*
260 * Mobility Electronics products.
261 */
262#define MOBILITY_VID 0x1342
263#define MOBILITY_USB_SERIAL_PID 0x0202 /* EasiDock USB 200 serial */
264
265/*
266 * Active Robots product ids.
267 */
268#define FTDI_ACTIVE_ROBOTS_PID 0xE548 /* USB comms board */
269
250/* Commands */ 270/* Commands */
251#define FTDI_SIO_RESET 0 /* Reset the port */ 271#define FTDI_SIO_RESET 0 /* Reset the port */
252#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */ 272#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */
@@ -259,10 +279,6 @@
259#define FTDI_SIO_SET_LATENCY_TIMER 9 /* Set the latency timer */ 279#define FTDI_SIO_SET_LATENCY_TIMER 9 /* Set the latency timer */
260#define FTDI_SIO_GET_LATENCY_TIMER 10 /* Get the latency timer */ 280#define FTDI_SIO_GET_LATENCY_TIMER 10 /* Get the latency timer */
261 281
262/* Port interface code for FT2232C */
263#define INTERFACE_A 1
264#define INTERFACE_B 2
265
266 282
267/* 283/*
268 * BmRequestType: 1100 0000b 284 * BmRequestType: 1100 0000b
diff --git a/drivers/usb/serial/io_usbvend.h b/drivers/usb/serial/io_usbvend.h
index 8c1fa5e722b1..f1804fd5a3dd 100644
--- a/drivers/usb/serial/io_usbvend.h
+++ b/drivers/usb/serial/io_usbvend.h
@@ -289,7 +289,7 @@
289// 289//
290 290
291// 291//
292// Edgeport Compatiblity Descriptor 292// Edgeport Compatibility Descriptor
293// 293//
294// This descriptor is only returned by Edgeport-compatible devices 294// This descriptor is only returned by Edgeport-compatible devices
295// supporting the EPiC spec. True ION devices do not return this 295// supporting the EPiC spec. True ION devices do not return this
diff --git a/drivers/usb/serial/keyspan_usa90msg.h b/drivers/usb/serial/keyspan_usa90msg.h
index dd935b62c1a8..86708ecd8735 100644
--- a/drivers/usb/serial/keyspan_usa90msg.h
+++ b/drivers/usb/serial/keyspan_usa90msg.h
@@ -19,7 +19,7 @@
19 19
20 This file is available under a BSD-style copyright 20 This file is available under a BSD-style copyright
21 21
22 2. The name of InnoSys Incorprated may not be used to endorse or promote 22 2. The name of InnoSys Incorporated may not be used to endorse or promote
23 products derived from this software without specific prior written 23 products derived from this software without specific prior written
24 permission. 24 permission.
25 25
diff --git a/drivers/usb/storage/debug.c b/drivers/usb/storage/debug.c
index d76483706bc9..5a9321705a74 100644
--- a/drivers/usb/storage/debug.c
+++ b/drivers/usb/storage/debug.c
@@ -47,6 +47,7 @@
47#include <linux/cdrom.h> 47#include <linux/cdrom.h>
48#include <scsi/scsi.h> 48#include <scsi/scsi.h>
49#include <scsi/scsi_cmnd.h> 49#include <scsi/scsi_cmnd.h>
50#include <scsi/scsi_dbg.h>
50 51
51#include "debug.h" 52#include "debug.h"
52#include "scsi.h" 53#include "scsi.h"
diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c
index 7eff03d9b041..f3b60288696c 100644
--- a/drivers/usb/storage/shuttle_usbat.c
+++ b/drivers/usb/storage/shuttle_usbat.c
@@ -786,7 +786,7 @@ static int usbat_flash_check_media(struct us_data *us,
786 if (rc != USB_STOR_XFER_GOOD) 786 if (rc != USB_STOR_XFER_GOOD)
787 return USB_STOR_TRANSPORT_ERROR; 787 return USB_STOR_TRANSPORT_ERROR;
788 788
789 // Check for media existance 789 // Check for media existence
790 rc = usbat_flash_check_media_present(uio); 790 rc = usbat_flash_check_media_present(uio);
791 if (rc == USBAT_FLASH_MEDIA_NONE) { 791 if (rc == USBAT_FLASH_MEDIA_NONE) {
792 info->sense_key = 0x02; 792 info->sense_key = 0x02;
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index bbda63c24c4d..d2891f475793 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -1,5 +1,5 @@
1/* Driver for USB Mass Storage compliant devices 1/* Driver for USB Mass Storage compliant devices
2 * Ununsual Devices File 2 * Unusual Devices File
3 * 3 *
4 * $Id: unusual_devs.h,v 1.32 2002/02/25 02:41:24 mdharm Exp $ 4 * $Id: unusual_devs.h,v 1.32 2002/02/25 02:41:24 mdharm Exp $
5 * 5 *
@@ -48,6 +48,14 @@
48 * USB development list <linux-usb-devel@lists.sourceforge.net>. 48 * USB development list <linux-usb-devel@lists.sourceforge.net>.
49 */ 49 */
50 50
51/* patch submitted by Vivian Bregier <Vivian.Bregier@imag.fr>
52 */
53UNUSUAL_DEV( 0x03eb, 0x2002, 0x0100, 0x0100,
54 "ATMEL",
55 "SND1 Storage",
56 US_SC_DEVICE, US_PR_DEVICE, NULL,
57 US_FL_IGNORE_RESIDUE),
58
51UNUSUAL_DEV( 0x03ee, 0x6901, 0x0000, 0x0100, 59UNUSUAL_DEV( 0x03ee, 0x6901, 0x0000, 0x0100,
52 "Mitsumi", 60 "Mitsumi",
53 "USB FDD", 61 "USB FDD",
@@ -994,6 +1002,13 @@ UNUSUAL_DEV( 0x1019, 0x0c55, 0x0000, 0x9999,
994 US_SC_DEVICE, US_PR_DEVICE, usb_stor_ucr61s2b_init, 1002 US_SC_DEVICE, US_PR_DEVICE, usb_stor_ucr61s2b_init,
995 0 ), 1003 0 ),
996 1004
1005/* Reported by Vilius Bilinkevicius <vilisas AT xxx DOT lt) */
1006UNUSUAL_DEV( 0x132b, 0x000b, 0x0001, 0x0001,
1007 "Minolta",
1008 "Dimage Z10",
1009 US_SC_DEVICE, US_PR_DEVICE, NULL,
1010 0 ),
1011
997/* Reported by Kotrla Vitezslav <kotrla@ceb.cz> */ 1012/* Reported by Kotrla Vitezslav <kotrla@ceb.cz> */
998UNUSUAL_DEV( 0x1370, 0x6828, 0x0110, 0x0110, 1013UNUSUAL_DEV( 0x1370, 0x6828, 0x0110, 0x0110,
999 "SWISSBIT", 1014 "SWISSBIT",
diff --git a/drivers/video/cyber2000fb.c b/drivers/video/cyber2000fb.c
index 8b1b7c687a99..3894b2a501d6 100644
--- a/drivers/video/cyber2000fb.c
+++ b/drivers/video/cyber2000fb.c
@@ -90,6 +90,8 @@ struct cfb_info {
90 */ 90 */
91 u_char ramdac_ctrl; 91 u_char ramdac_ctrl;
92 u_char ramdac_powerdown; 92 u_char ramdac_powerdown;
93
94 u32 pseudo_palette[16];
93}; 95};
94 96
95static char *default_font = "Acorn8x8"; 97static char *default_font = "Acorn8x8";
@@ -1223,9 +1225,7 @@ cyberpro_alloc_fb_info(unsigned int id, char *name)
1223{ 1225{
1224 struct cfb_info *cfb; 1226 struct cfb_info *cfb;
1225 1227
1226 cfb = kmalloc(sizeof(struct cfb_info) + 1228 cfb = kmalloc(sizeof(struct cfb_info), GFP_KERNEL);
1227 sizeof(u32) * 16, GFP_KERNEL);
1228
1229 if (!cfb) 1229 if (!cfb)
1230 return NULL; 1230 return NULL;
1231 1231
@@ -1281,7 +1281,7 @@ cyberpro_alloc_fb_info(unsigned int id, char *name)
1281 1281
1282 cfb->fb.fbops = &cyber2000fb_ops; 1282 cfb->fb.fbops = &cyber2000fb_ops;
1283 cfb->fb.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN; 1283 cfb->fb.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
1284 cfb->fb.pseudo_palette = (void *)(cfb + 1); 1284 cfb->fb.pseudo_palette = cfb->pseudo_palette;
1285 1285
1286 fb_alloc_cmap(&cfb->fb.cmap, NR_PALETTE, 0); 1286 fb_alloc_cmap(&cfb->fb.cmap, NR_PALETTE, 0);
1287 1287
diff --git a/drivers/video/i810/i810_main.c b/drivers/video/i810/i810_main.c
index e04d3e8b2549..a9a618f2aa6a 100644
--- a/drivers/video/i810/i810_main.c
+++ b/drivers/video/i810/i810_main.c
@@ -1000,8 +1000,10 @@ static int i810_check_params(struct fb_var_screeninfo *var,
1000 1000
1001 if (fb_validate_mode(var, info)) { 1001 if (fb_validate_mode(var, info)) {
1002 if (fb_get_mode(FB_MAXTIMINGS, 0, var, info)) { 1002 if (fb_get_mode(FB_MAXTIMINGS, 0, var, info)) {
1003 int default_sync = (hsync1-HFMIN)|(hsync2-HFMAX) 1003 int default_sync = (info->monspecs.hfmin-HFMIN)
1004 |(vsync1-VFMIN)|(vsync2-VFMAX); 1004 |(info->monspecs.hfmax-HFMAX)
1005 |(info->monspecs.vfmin-VFMIN)
1006 |(info->monspecs.vfmax-VFMAX);
1005 printk("i810fb: invalid video mode%s\n", 1007 printk("i810fb: invalid video mode%s\n",
1006 default_sync ? "" : 1008 default_sync ? "" :
1007 ". Specifying vsyncN/hsyncN parameters may help"); 1009 ". Specifying vsyncN/hsyncN parameters may help");
diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
index 7bc906677b0d..24a689179af2 100644
--- a/fs/jfs/inode.c
+++ b/fs/jfs/inode.c
@@ -175,31 +175,22 @@ jfs_get_blocks(struct inode *ip, sector_t lblock, unsigned long max_blocks,
175{ 175{
176 s64 lblock64 = lblock; 176 s64 lblock64 = lblock;
177 int rc = 0; 177 int rc = 0;
178 int take_locks;
179 xad_t xad; 178 xad_t xad;
180 s64 xaddr; 179 s64 xaddr;
181 int xflag; 180 int xflag;
182 s32 xlen; 181 s32 xlen = max_blocks;
183
184 /*
185 * If this is a special inode (imap, dmap)
186 * the lock should already be taken
187 */
188 take_locks = (JFS_IP(ip)->fileset != AGGREGATE_I);
189 182
190 /* 183 /*
191 * Take appropriate lock on inode 184 * Take appropriate lock on inode
192 */ 185 */
193 if (take_locks) { 186 if (create)
194 if (create) 187 IWRITE_LOCK(ip);
195 IWRITE_LOCK(ip); 188 else
196 else 189 IREAD_LOCK(ip);
197 IREAD_LOCK(ip);
198 }
199 190
200 if (((lblock64 << ip->i_sb->s_blocksize_bits) < ip->i_size) && 191 if (((lblock64 << ip->i_sb->s_blocksize_bits) < ip->i_size) &&
201 (xtLookup(ip, lblock64, max_blocks, &xflag, &xaddr, &xlen, 0) 192 (!xtLookup(ip, lblock64, max_blocks, &xflag, &xaddr, &xlen, 0)) &&
202 == 0) && xlen) { 193 xaddr) {
203 if (xflag & XAD_NOTRECORDED) { 194 if (xflag & XAD_NOTRECORDED) {
204 if (!create) 195 if (!create)
205 /* 196 /*
@@ -238,7 +229,7 @@ jfs_get_blocks(struct inode *ip, sector_t lblock, unsigned long max_blocks,
238#ifdef _JFS_4K 229#ifdef _JFS_4K
239 if ((rc = extHint(ip, lblock64 << ip->i_sb->s_blocksize_bits, &xad))) 230 if ((rc = extHint(ip, lblock64 << ip->i_sb->s_blocksize_bits, &xad)))
240 goto unlock; 231 goto unlock;
241 rc = extAlloc(ip, max_blocks, lblock64, &xad, FALSE); 232 rc = extAlloc(ip, xlen, lblock64, &xad, FALSE);
242 if (rc) 233 if (rc)
243 goto unlock; 234 goto unlock;
244 235
@@ -258,12 +249,10 @@ jfs_get_blocks(struct inode *ip, sector_t lblock, unsigned long max_blocks,
258 /* 249 /*
259 * Release lock on inode 250 * Release lock on inode
260 */ 251 */
261 if (take_locks) { 252 if (create)
262 if (create) 253 IWRITE_UNLOCK(ip);
263 IWRITE_UNLOCK(ip); 254 else
264 else 255 IREAD_UNLOCK(ip);
265 IREAD_UNLOCK(ip);
266 }
267 return rc; 256 return rc;
268} 257}
269 258
diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
index d86e467c6e42..69007fd546ef 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -471,6 +471,7 @@ dbUpdatePMap(struct inode *ipbmap,
471 struct metapage *mp; 471 struct metapage *mp;
472 struct jfs_log *log; 472 struct jfs_log *log;
473 int lsn, difft, diffp; 473 int lsn, difft, diffp;
474 unsigned long flags;
474 475
475 /* the blocks better be within the mapsize. */ 476 /* the blocks better be within the mapsize. */
476 if (blkno + nblocks > bmp->db_mapsize) { 477 if (blkno + nblocks > bmp->db_mapsize) {
@@ -504,6 +505,7 @@ dbUpdatePMap(struct inode *ipbmap,
504 0); 505 0);
505 if (mp == NULL) 506 if (mp == NULL)
506 return -EIO; 507 return -EIO;
508 metapage_wait_for_io(mp);
507 } 509 }
508 dp = (struct dmap *) mp->data; 510 dp = (struct dmap *) mp->data;
509 511
@@ -578,34 +580,32 @@ dbUpdatePMap(struct inode *ipbmap,
578 if (mp->lsn != 0) { 580 if (mp->lsn != 0) {
579 /* inherit older/smaller lsn */ 581 /* inherit older/smaller lsn */
580 logdiff(diffp, mp->lsn, log); 582 logdiff(diffp, mp->lsn, log);
583 LOGSYNC_LOCK(log, flags);
581 if (difft < diffp) { 584 if (difft < diffp) {
582 mp->lsn = lsn; 585 mp->lsn = lsn;
583 586
584 /* move bp after tblock in logsync list */ 587 /* move bp after tblock in logsync list */
585 LOGSYNC_LOCK(log);
586 list_move(&mp->synclist, &tblk->synclist); 588 list_move(&mp->synclist, &tblk->synclist);
587 LOGSYNC_UNLOCK(log);
588 } 589 }
589 590
590 /* inherit younger/larger clsn */ 591 /* inherit younger/larger clsn */
591 LOGSYNC_LOCK(log);
592 logdiff(difft, tblk->clsn, log); 592 logdiff(difft, tblk->clsn, log);
593 logdiff(diffp, mp->clsn, log); 593 logdiff(diffp, mp->clsn, log);
594 if (difft > diffp) 594 if (difft > diffp)
595 mp->clsn = tblk->clsn; 595 mp->clsn = tblk->clsn;
596 LOGSYNC_UNLOCK(log); 596 LOGSYNC_UNLOCK(log, flags);
597 } else { 597 } else {
598 mp->log = log; 598 mp->log = log;
599 mp->lsn = lsn; 599 mp->lsn = lsn;
600 600
601 /* insert bp after tblock in logsync list */ 601 /* insert bp after tblock in logsync list */
602 LOGSYNC_LOCK(log); 602 LOGSYNC_LOCK(log, flags);
603 603
604 log->count++; 604 log->count++;
605 list_add(&mp->synclist, &tblk->synclist); 605 list_add(&mp->synclist, &tblk->synclist);
606 606
607 mp->clsn = tblk->clsn; 607 mp->clsn = tblk->clsn;
608 LOGSYNC_UNLOCK(log); 608 LOGSYNC_UNLOCK(log, flags);
609 } 609 }
610 } 610 }
611 611
diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c
index e357890adfb2..ac41f72d6d50 100644
--- a/fs/jfs/jfs_dtree.c
+++ b/fs/jfs/jfs_dtree.c
@@ -212,7 +212,7 @@ static struct metapage *read_index_page(struct inode *inode, s64 blkno)
212 s32 xlen; 212 s32 xlen;
213 213
214 rc = xtLookup(inode, blkno, 1, &xflag, &xaddr, &xlen, 1); 214 rc = xtLookup(inode, blkno, 1, &xflag, &xaddr, &xlen, 1);
215 if (rc || (xlen == 0)) 215 if (rc || (xaddr == 0))
216 return NULL; 216 return NULL;
217 217
218 return read_metapage(inode, xaddr, PSIZE, 1); 218 return read_metapage(inode, xaddr, PSIZE, 1);
@@ -231,7 +231,7 @@ static struct metapage *get_index_page(struct inode *inode, s64 blkno)
231 s32 xlen; 231 s32 xlen;
232 232
233 rc = xtLookup(inode, blkno, 1, &xflag, &xaddr, &xlen, 1); 233 rc = xtLookup(inode, blkno, 1, &xflag, &xaddr, &xlen, 1);
234 if (rc || (xlen == 0)) 234 if (rc || (xaddr == 0))
235 return NULL; 235 return NULL;
236 236
237 return get_metapage(inode, xaddr, PSIZE, 1); 237 return get_metapage(inode, xaddr, PSIZE, 1);
@@ -3181,7 +3181,7 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
3181 d = (struct ldtentry *) & p->slot[stbl[i]]; 3181 d = (struct ldtentry *) & p->slot[stbl[i]];
3182 3182
3183 if (((long) jfs_dirent + d->namlen + 1) > 3183 if (((long) jfs_dirent + d->namlen + 1) >
3184 (dirent_buf + PSIZE)) { 3184 (dirent_buf + PAGE_SIZE)) {
3185 /* DBCS codepages could overrun dirent_buf */ 3185 /* DBCS codepages could overrun dirent_buf */
3186 index = i; 3186 index = i;
3187 overflow = 1; 3187 overflow = 1;
diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
index 783831301625..7acff2ce3c80 100644
--- a/fs/jfs/jfs_imap.c
+++ b/fs/jfs/jfs_imap.c
@@ -502,7 +502,7 @@ struct inode *diReadSpecial(struct super_block *sb, ino_t inum, int secondary)
502 502
503 } 503 }
504 504
505 ip->i_mapping->a_ops = &jfs_aops; 505 ip->i_mapping->a_ops = &jfs_metapage_aops;
506 mapping_set_gfp_mask(ip->i_mapping, GFP_NOFS); 506 mapping_set_gfp_mask(ip->i_mapping, GFP_NOFS);
507 507
508 /* Allocations to metadata inodes should not affect quotas */ 508 /* Allocations to metadata inodes should not affect quotas */
@@ -2573,9 +2573,18 @@ diNewIAG(struct inomap * imap, int *iagnop, int agno, struct metapage ** mpp)
2573 goto out; 2573 goto out;
2574 } 2574 }
2575 2575
2576 /* assign a buffer for the page */ 2576 /*
2577 mp = get_metapage(ipimap, xaddr, PSIZE, 1); 2577 * start transaction of update of the inode map
2578 if (!mp) { 2578 * addressing structure pointing to the new iag page;
2579 */
2580 tid = txBegin(sb, COMMIT_FORCE);
2581 down(&JFS_IP(ipimap)->commit_sem);
2582
2583 /* update the inode map addressing structure to point to it */
2584 if ((rc =
2585 xtInsert(tid, ipimap, 0, blkno, xlen, &xaddr, 0))) {
2586 txEnd(tid);
2587 up(&JFS_IP(ipimap)->commit_sem);
2579 /* Free the blocks allocated for the iag since it was 2588 /* Free the blocks allocated for the iag since it was
2580 * not successfully added to the inode map 2589 * not successfully added to the inode map
2581 */ 2590 */
@@ -2584,6 +2593,29 @@ diNewIAG(struct inomap * imap, int *iagnop, int agno, struct metapage ** mpp)
2584 /* release the inode map lock */ 2593 /* release the inode map lock */
2585 IWRITE_UNLOCK(ipimap); 2594 IWRITE_UNLOCK(ipimap);
2586 2595
2596 goto out;
2597 }
2598
2599 /* update the inode map's inode to reflect the extension */
2600 ipimap->i_size += PSIZE;
2601 inode_add_bytes(ipimap, PSIZE);
2602
2603 /* assign a buffer for the page */
2604 mp = get_metapage(ipimap, blkno, PSIZE, 0);
2605 if (!mp) {
2606 /*
2607 * This is very unlikely since we just created the
2608 * extent, but let's try to handle it correctly
2609 */
2610 xtTruncate(tid, ipimap, ipimap->i_size - PSIZE,
2611 COMMIT_PWMAP);
2612
2613 txAbort(tid, 0);
2614 txEnd(tid);
2615
2616 /* release the inode map lock */
2617 IWRITE_UNLOCK(ipimap);
2618
2587 rc = -EIO; 2619 rc = -EIO;
2588 goto out; 2620 goto out;
2589 } 2621 }
@@ -2605,41 +2637,11 @@ diNewIAG(struct inomap * imap, int *iagnop, int agno, struct metapage ** mpp)
2605 iagp->inosmap[i] = cpu_to_le32(ONES); 2637 iagp->inosmap[i] = cpu_to_le32(ONES);
2606 2638
2607 /* 2639 /*
2608 * Invalidate the page after writing and syncing it. 2640 * Write and sync the metapage
2609 * After it's initialized, we access it in a different
2610 * address space
2611 */ 2641 */
2612 set_bit(META_discard, &mp->flag);
2613 flush_metapage(mp); 2642 flush_metapage(mp);
2614 2643
2615 /* 2644 /*
2616 * start tyransaction of update of the inode map
2617 * addressing structure pointing to the new iag page;
2618 */
2619 tid = txBegin(sb, COMMIT_FORCE);
2620 down(&JFS_IP(ipimap)->commit_sem);
2621
2622 /* update the inode map addressing structure to point to it */
2623 if ((rc =
2624 xtInsert(tid, ipimap, 0, blkno, xlen, &xaddr, 0))) {
2625 txEnd(tid);
2626 up(&JFS_IP(ipimap)->commit_sem);
2627 /* Free the blocks allocated for the iag since it was
2628 * not successfully added to the inode map
2629 */
2630 dbFree(ipimap, xaddr, (s64) xlen);
2631
2632 /* release the inode map lock */
2633 IWRITE_UNLOCK(ipimap);
2634
2635 goto out;
2636 }
2637
2638 /* update the inode map's inode to reflect the extension */
2639 ipimap->i_size += PSIZE;
2640 inode_add_bytes(ipimap, PSIZE);
2641
2642 /*
2643 * txCommit(COMMIT_FORCE) will synchronously write address 2645 * txCommit(COMMIT_FORCE) will synchronously write address
2644 * index pages and inode after commit in careful update order 2646 * index pages and inode after commit in careful update order
2645 * of address index pages (right to left, bottom up); 2647 * of address index pages (right to left, bottom up);
@@ -2789,6 +2791,7 @@ diUpdatePMap(struct inode *ipimap,
2789 u32 mask; 2791 u32 mask;
2790 struct jfs_log *log; 2792 struct jfs_log *log;
2791 int lsn, difft, diffp; 2793 int lsn, difft, diffp;
2794 unsigned long flags;
2792 2795
2793 imap = JFS_IP(ipimap)->i_imap; 2796 imap = JFS_IP(ipimap)->i_imap;
2794 /* get the iag number containing the inode */ 2797 /* get the iag number containing the inode */
@@ -2805,6 +2808,7 @@ diUpdatePMap(struct inode *ipimap,
2805 IREAD_UNLOCK(ipimap); 2808 IREAD_UNLOCK(ipimap);
2806 if (rc) 2809 if (rc)
2807 return (rc); 2810 return (rc);
2811 metapage_wait_for_io(mp);
2808 iagp = (struct iag *) mp->data; 2812 iagp = (struct iag *) mp->data;
2809 /* get the inode number and extent number of the inode within 2813 /* get the inode number and extent number of the inode within
2810 * the iag and the inode number within the extent. 2814 * the iag and the inode number within the extent.
@@ -2868,30 +2872,28 @@ diUpdatePMap(struct inode *ipimap,
2868 /* inherit older/smaller lsn */ 2872 /* inherit older/smaller lsn */
2869 logdiff(difft, lsn, log); 2873 logdiff(difft, lsn, log);
2870 logdiff(diffp, mp->lsn, log); 2874 logdiff(diffp, mp->lsn, log);
2875 LOGSYNC_LOCK(log, flags);
2871 if (difft < diffp) { 2876 if (difft < diffp) {
2872 mp->lsn = lsn; 2877 mp->lsn = lsn;
2873 /* move mp after tblock in logsync list */ 2878 /* move mp after tblock in logsync list */
2874 LOGSYNC_LOCK(log);
2875 list_move(&mp->synclist, &tblk->synclist); 2879 list_move(&mp->synclist, &tblk->synclist);
2876 LOGSYNC_UNLOCK(log);
2877 } 2880 }
2878 /* inherit younger/larger clsn */ 2881 /* inherit younger/larger clsn */
2879 LOGSYNC_LOCK(log);
2880 assert(mp->clsn); 2882 assert(mp->clsn);
2881 logdiff(difft, tblk->clsn, log); 2883 logdiff(difft, tblk->clsn, log);
2882 logdiff(diffp, mp->clsn, log); 2884 logdiff(diffp, mp->clsn, log);
2883 if (difft > diffp) 2885 if (difft > diffp)
2884 mp->clsn = tblk->clsn; 2886 mp->clsn = tblk->clsn;
2885 LOGSYNC_UNLOCK(log); 2887 LOGSYNC_UNLOCK(log, flags);
2886 } else { 2888 } else {
2887 mp->log = log; 2889 mp->log = log;
2888 mp->lsn = lsn; 2890 mp->lsn = lsn;
2889 /* insert mp after tblock in logsync list */ 2891 /* insert mp after tblock in logsync list */
2890 LOGSYNC_LOCK(log); 2892 LOGSYNC_LOCK(log, flags);
2891 log->count++; 2893 log->count++;
2892 list_add(&mp->synclist, &tblk->synclist); 2894 list_add(&mp->synclist, &tblk->synclist);
2893 mp->clsn = tblk->clsn; 2895 mp->clsn = tblk->clsn;
2894 LOGSYNC_UNLOCK(log); 2896 LOGSYNC_UNLOCK(log, flags);
2895 } 2897 }
2896 write_metapage(mp); 2898 write_metapage(mp);
2897 return (0); 2899 return (0);
diff --git a/fs/jfs/jfs_incore.h b/fs/jfs/jfs_incore.h
index ebd77c1bed66..c0fd7b3eadc6 100644
--- a/fs/jfs/jfs_incore.h
+++ b/fs/jfs/jfs_incore.h
@@ -165,6 +165,7 @@ struct jfs_sb_info {
165 /* Formerly in ipbmap */ 165 /* Formerly in ipbmap */
166 struct bmap *bmap; /* incore bmap descriptor */ 166 struct bmap *bmap; /* incore bmap descriptor */
167 struct nls_table *nls_tab; /* current codepage */ 167 struct nls_table *nls_tab; /* current codepage */
168 struct inode *direct_inode; /* metadata inode */
168 uint state; /* mount/recovery state */ 169 uint state; /* mount/recovery state */
169 unsigned long flag; /* mount time flags */ 170 unsigned long flag; /* mount time flags */
170 uint p_state; /* state prior to going no integrity */ 171 uint p_state; /* state prior to going no integrity */
diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c
index b6a6869ebb4f..dfa1200daa61 100644
--- a/fs/jfs/jfs_logmgr.c
+++ b/fs/jfs/jfs_logmgr.c
@@ -234,6 +234,7 @@ int lmLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
234 int lsn; 234 int lsn;
235 int diffp, difft; 235 int diffp, difft;
236 struct metapage *mp = NULL; 236 struct metapage *mp = NULL;
237 unsigned long flags;
237 238
238 jfs_info("lmLog: log:0x%p tblk:0x%p, lrd:0x%p tlck:0x%p", 239 jfs_info("lmLog: log:0x%p tblk:0x%p, lrd:0x%p tlck:0x%p",
239 log, tblk, lrd, tlck); 240 log, tblk, lrd, tlck);
@@ -254,7 +255,7 @@ int lmLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
254 */ 255 */
255 lsn = log->lsn; 256 lsn = log->lsn;
256 257
257 LOGSYNC_LOCK(log); 258 LOGSYNC_LOCK(log, flags);
258 259
259 /* 260 /*
260 * initialize page lsn if first log write of the page 261 * initialize page lsn if first log write of the page
@@ -310,7 +311,7 @@ int lmLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
310 } 311 }
311 } 312 }
312 313
313 LOGSYNC_UNLOCK(log); 314 LOGSYNC_UNLOCK(log, flags);
314 315
315 /* 316 /*
316 * write the log record 317 * write the log record
@@ -334,7 +335,6 @@ int lmLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
334 return lsn; 335 return lsn;
335} 336}
336 337
337
338/* 338/*
339 * NAME: lmWriteRecord() 339 * NAME: lmWriteRecord()
340 * 340 *
@@ -927,9 +927,8 @@ static void lmPostGC(struct lbuf * bp)
927 * calculate new value of i_nextsync which determines when 927 * calculate new value of i_nextsync which determines when
928 * this code is called again. 928 * this code is called again.
929 * 929 *
930 * this is called only from lmLog(). 930 * PARAMETERS: log - log structure
931 * 931 * nosyncwait - 1 if called asynchronously
932 * PARAMETER: ip - pointer to logs inode.
933 * 932 *
934 * RETURN: 0 933 * RETURN: 0
935 * 934 *
@@ -945,6 +944,15 @@ static int lmLogSync(struct jfs_log * log, int nosyncwait)
945 struct lrd lrd; 944 struct lrd lrd;
946 int lsn; 945 int lsn;
947 struct logsyncblk *lp; 946 struct logsyncblk *lp;
947 struct jfs_sb_info *sbi;
948 unsigned long flags;
949
950 /* push dirty metapages out to disk */
951 list_for_each_entry(sbi, &log->sb_list, log_list) {
952 filemap_flush(sbi->ipbmap->i_mapping);
953 filemap_flush(sbi->ipimap->i_mapping);
954 filemap_flush(sbi->direct_inode->i_mapping);
955 }
948 956
949 /* 957 /*
950 * forward syncpt 958 * forward syncpt
@@ -954,10 +962,7 @@ static int lmLogSync(struct jfs_log * log, int nosyncwait)
954 */ 962 */
955 963
956 if (log->sync == log->syncpt) { 964 if (log->sync == log->syncpt) {
957 LOGSYNC_LOCK(log); 965 LOGSYNC_LOCK(log, flags);
958 /* ToDo: push dirty metapages out to disk */
959// bmLogSync(log);
960
961 if (list_empty(&log->synclist)) 966 if (list_empty(&log->synclist))
962 log->sync = log->lsn; 967 log->sync = log->lsn;
963 else { 968 else {
@@ -965,7 +970,7 @@ static int lmLogSync(struct jfs_log * log, int nosyncwait)
965 struct logsyncblk, synclist); 970 struct logsyncblk, synclist);
966 log->sync = lp->lsn; 971 log->sync = lp->lsn;
967 } 972 }
968 LOGSYNC_UNLOCK(log); 973 LOGSYNC_UNLOCK(log, flags);
969 974
970 } 975 }
971 976
@@ -974,27 +979,6 @@ static int lmLogSync(struct jfs_log * log, int nosyncwait)
974 * reset syncpt = sync 979 * reset syncpt = sync
975 */ 980 */
976 if (log->sync != log->syncpt) { 981 if (log->sync != log->syncpt) {
977 struct jfs_sb_info *sbi;
978
979 /*
980 * We need to make sure all of the "written" metapages
981 * actually make it to disk
982 */
983 list_for_each_entry(sbi, &log->sb_list, log_list) {
984 if (sbi->flag & JFS_NOINTEGRITY)
985 continue;
986 filemap_fdatawrite(sbi->ipbmap->i_mapping);
987 filemap_fdatawrite(sbi->ipimap->i_mapping);
988 filemap_fdatawrite(sbi->sb->s_bdev->bd_inode->i_mapping);
989 }
990 list_for_each_entry(sbi, &log->sb_list, log_list) {
991 if (sbi->flag & JFS_NOINTEGRITY)
992 continue;
993 filemap_fdatawait(sbi->ipbmap->i_mapping);
994 filemap_fdatawait(sbi->ipimap->i_mapping);
995 filemap_fdatawait(sbi->sb->s_bdev->bd_inode->i_mapping);
996 }
997
998 lrd.logtid = 0; 982 lrd.logtid = 0;
999 lrd.backchain = 0; 983 lrd.backchain = 0;
1000 lrd.type = cpu_to_le16(LOG_SYNCPT); 984 lrd.type = cpu_to_le16(LOG_SYNCPT);
@@ -1066,6 +1050,18 @@ static int lmLogSync(struct jfs_log * log, int nosyncwait)
1066 return lsn; 1050 return lsn;
1067} 1051}
1068 1052
1053/*
1054 * NAME: jfs_syncpt
1055 *
1056 * FUNCTION: write log SYNCPT record for specified log
1057 *
1058 * PARAMETERS: log - log structure
1059 */
1060void jfs_syncpt(struct jfs_log *log)
1061{ LOG_LOCK(log);
1062 lmLogSync(log, 1);
1063 LOG_UNLOCK(log);
1064}
1069 1065
1070/* 1066/*
1071 * NAME: lmLogOpen() 1067 * NAME: lmLogOpen()
@@ -1547,6 +1543,7 @@ void jfs_flush_journal(struct jfs_log *log, int wait)
1547{ 1543{
1548 int i; 1544 int i;
1549 struct tblock *target = NULL; 1545 struct tblock *target = NULL;
1546 struct jfs_sb_info *sbi;
1550 1547
1551 /* jfs_write_inode may call us during read-only mount */ 1548 /* jfs_write_inode may call us during read-only mount */
1552 if (!log) 1549 if (!log)
@@ -1608,12 +1605,18 @@ void jfs_flush_journal(struct jfs_log *log, int wait)
1608 if (wait < 2) 1605 if (wait < 2)
1609 return; 1606 return;
1610 1607
1608 list_for_each_entry(sbi, &log->sb_list, log_list) {
1609 filemap_fdatawrite(sbi->ipbmap->i_mapping);
1610 filemap_fdatawrite(sbi->ipimap->i_mapping);
1611 filemap_fdatawrite(sbi->direct_inode->i_mapping);
1612 }
1613
1611 /* 1614 /*
1612 * If there was recent activity, we may need to wait 1615 * If there was recent activity, we may need to wait
1613 * for the lazycommit thread to catch up 1616 * for the lazycommit thread to catch up
1614 */ 1617 */
1615 if ((!list_empty(&log->cqueue)) || !list_empty(&log->synclist)) { 1618 if ((!list_empty(&log->cqueue)) || !list_empty(&log->synclist)) {
1616 for (i = 0; i < 800; i++) { /* Too much? */ 1619 for (i = 0; i < 200; i++) { /* Too much? */
1617 msleep(250); 1620 msleep(250);
1618 if (list_empty(&log->cqueue) && 1621 if (list_empty(&log->cqueue) &&
1619 list_empty(&log->synclist)) 1622 list_empty(&log->synclist))
@@ -1621,7 +1624,24 @@ void jfs_flush_journal(struct jfs_log *log, int wait)
1621 } 1624 }
1622 } 1625 }
1623 assert(list_empty(&log->cqueue)); 1626 assert(list_empty(&log->cqueue));
1624 assert(list_empty(&log->synclist)); 1627 if (!list_empty(&log->synclist)) {
1628 struct logsyncblk *lp;
1629
1630 list_for_each_entry(lp, &log->synclist, synclist) {
1631 if (lp->xflag & COMMIT_PAGE) {
1632 struct metapage *mp = (struct metapage *)lp;
1633 dump_mem("orphan metapage", lp,
1634 sizeof(struct metapage));
1635 dump_mem("page", mp->page, sizeof(struct page));
1636 }
1637 else
1638 dump_mem("orphan tblock", lp,
1639 sizeof(struct tblock));
1640 }
1641// current->state = TASK_INTERRUPTIBLE;
1642// schedule();
1643 }
1644 //assert(list_empty(&log->synclist));
1625 clear_bit(log_FLUSH, &log->flag); 1645 clear_bit(log_FLUSH, &log->flag);
1626} 1646}
1627 1647
@@ -1669,6 +1689,7 @@ int lmLogShutdown(struct jfs_log * log)
1669 lp->h.eor = lp->t.eor = cpu_to_le16(bp->l_eor); 1689 lp->h.eor = lp->t.eor = cpu_to_le16(bp->l_eor);
1670 lbmWrite(log, log->bp, lbmWRITE | lbmRELEASE | lbmSYNC, 0); 1690 lbmWrite(log, log->bp, lbmWRITE | lbmRELEASE | lbmSYNC, 0);
1671 lbmIOWait(log->bp, lbmFREE); 1691 lbmIOWait(log->bp, lbmFREE);
1692 log->bp = NULL;
1672 1693
1673 /* 1694 /*
1674 * synchronous update log superblock 1695 * synchronous update log superblock
@@ -1819,20 +1840,34 @@ static int lbmLogInit(struct jfs_log * log)
1819 1840
1820 log->lbuf_free = NULL; 1841 log->lbuf_free = NULL;
1821 1842
1822 for (i = 0; i < LOGPAGES; i++) { 1843 for (i = 0; i < LOGPAGES;) {
1823 lbuf = kmalloc(sizeof(struct lbuf), GFP_KERNEL); 1844 char *buffer;
1824 if (lbuf == 0) 1845 uint offset;
1825 goto error; 1846 struct page *page;
1826 lbuf->l_ldata = (char *) get_zeroed_page(GFP_KERNEL); 1847
1827 if (lbuf->l_ldata == 0) { 1848 buffer = (char *) get_zeroed_page(GFP_KERNEL);
1828 kfree(lbuf); 1849 if (buffer == NULL)
1829 goto error; 1850 goto error;
1851 page = virt_to_page(buffer);
1852 for (offset = 0; offset < PAGE_SIZE; offset += LOGPSIZE) {
1853 lbuf = kmalloc(sizeof(struct lbuf), GFP_KERNEL);
1854 if (lbuf == NULL) {
1855 if (offset == 0)
1856 free_page((unsigned long) buffer);
1857 goto error;
1858 }
1859 if (offset) /* we already have one reference */
1860 get_page(page);
1861 lbuf->l_offset = offset;
1862 lbuf->l_ldata = buffer + offset;
1863 lbuf->l_page = page;
1864 lbuf->l_log = log;
1865 init_waitqueue_head(&lbuf->l_ioevent);
1866
1867 lbuf->l_freelist = log->lbuf_free;
1868 log->lbuf_free = lbuf;
1869 i++;
1830 } 1870 }
1831 lbuf->l_log = log;
1832 init_waitqueue_head(&lbuf->l_ioevent);
1833
1834 lbuf->l_freelist = log->lbuf_free;
1835 log->lbuf_free = lbuf;
1836 } 1871 }
1837 1872
1838 return (0); 1873 return (0);
@@ -1857,12 +1892,10 @@ static void lbmLogShutdown(struct jfs_log * log)
1857 lbuf = log->lbuf_free; 1892 lbuf = log->lbuf_free;
1858 while (lbuf) { 1893 while (lbuf) {
1859 struct lbuf *next = lbuf->l_freelist; 1894 struct lbuf *next = lbuf->l_freelist;
1860 free_page((unsigned long) lbuf->l_ldata); 1895 __free_page(lbuf->l_page);
1861 kfree(lbuf); 1896 kfree(lbuf);
1862 lbuf = next; 1897 lbuf = next;
1863 } 1898 }
1864
1865 log->bp = NULL;
1866} 1899}
1867 1900
1868 1901
@@ -1974,9 +2007,9 @@ static int lbmRead(struct jfs_log * log, int pn, struct lbuf ** bpp)
1974 2007
1975 bio->bi_sector = bp->l_blkno << (log->l2bsize - 9); 2008 bio->bi_sector = bp->l_blkno << (log->l2bsize - 9);
1976 bio->bi_bdev = log->bdev; 2009 bio->bi_bdev = log->bdev;
1977 bio->bi_io_vec[0].bv_page = virt_to_page(bp->l_ldata); 2010 bio->bi_io_vec[0].bv_page = bp->l_page;
1978 bio->bi_io_vec[0].bv_len = LOGPSIZE; 2011 bio->bi_io_vec[0].bv_len = LOGPSIZE;
1979 bio->bi_io_vec[0].bv_offset = 0; 2012 bio->bi_io_vec[0].bv_offset = bp->l_offset;
1980 2013
1981 bio->bi_vcnt = 1; 2014 bio->bi_vcnt = 1;
1982 bio->bi_idx = 0; 2015 bio->bi_idx = 0;
@@ -2115,9 +2148,9 @@ static void lbmStartIO(struct lbuf * bp)
2115 bio = bio_alloc(GFP_NOFS, 1); 2148 bio = bio_alloc(GFP_NOFS, 1);
2116 bio->bi_sector = bp->l_blkno << (log->l2bsize - 9); 2149 bio->bi_sector = bp->l_blkno << (log->l2bsize - 9);
2117 bio->bi_bdev = log->bdev; 2150 bio->bi_bdev = log->bdev;
2118 bio->bi_io_vec[0].bv_page = virt_to_page(bp->l_ldata); 2151 bio->bi_io_vec[0].bv_page = bp->l_page;
2119 bio->bi_io_vec[0].bv_len = LOGPSIZE; 2152 bio->bi_io_vec[0].bv_len = LOGPSIZE;
2120 bio->bi_io_vec[0].bv_offset = 0; 2153 bio->bi_io_vec[0].bv_offset = bp->l_offset;
2121 2154
2122 bio->bi_vcnt = 1; 2155 bio->bi_vcnt = 1;
2123 bio->bi_idx = 0; 2156 bio->bi_idx = 0;
@@ -2127,16 +2160,13 @@ static void lbmStartIO(struct lbuf * bp)
2127 bio->bi_private = bp; 2160 bio->bi_private = bp;
2128 2161
2129 /* check if journaling to disk has been disabled */ 2162 /* check if journaling to disk has been disabled */
2130 if (!log->no_integrity) { 2163 if (log->no_integrity) {
2164 bio->bi_size = 0;
2165 lbmIODone(bio, 0, 0);
2166 } else {
2131 submit_bio(WRITE_SYNC, bio); 2167 submit_bio(WRITE_SYNC, bio);
2132 INCREMENT(lmStat.submitted); 2168 INCREMENT(lmStat.submitted);
2133 } 2169 }
2134 else {
2135 bio->bi_size = 0;
2136 lbmIODone(bio, 0, 0); /* 2nd argument appears to not be used => 0
2137 * 3rd argument appears to not be used => 0
2138 */
2139 }
2140} 2170}
2141 2171
2142 2172
diff --git a/fs/jfs/jfs_logmgr.h b/fs/jfs/jfs_logmgr.h
index 141ad74010c9..51291fbc420c 100644
--- a/fs/jfs/jfs_logmgr.h
+++ b/fs/jfs/jfs_logmgr.h
@@ -463,9 +463,10 @@ struct lbuf {
463 463
464 s64 l_blkno; /* 8: log page block number */ 464 s64 l_blkno; /* 8: log page block number */
465 caddr_t l_ldata; /* 4: data page */ 465 caddr_t l_ldata; /* 4: data page */
466 struct page *l_page; /* The page itself */
467 uint l_offset; /* Offset of l_ldata within the page */
466 468
467 wait_queue_head_t l_ioevent; /* 4: i/o done event */ 469 wait_queue_head_t l_ioevent; /* 4: i/o done event */
468 struct page *l_page; /* The page itself */
469}; 470};
470 471
471/* Reuse l_freelist for redrive list */ 472/* Reuse l_freelist for redrive list */
@@ -489,8 +490,9 @@ struct logsyncblk {
489 */ 490 */
490 491
491#define LOGSYNC_LOCK_INIT(log) spin_lock_init(&(log)->synclock) 492#define LOGSYNC_LOCK_INIT(log) spin_lock_init(&(log)->synclock)
492#define LOGSYNC_LOCK(log) spin_lock(&(log)->synclock) 493#define LOGSYNC_LOCK(log, flags) spin_lock_irqsave(&(log)->synclock, flags)
493#define LOGSYNC_UNLOCK(log) spin_unlock(&(log)->synclock) 494#define LOGSYNC_UNLOCK(log, flags) \
495 spin_unlock_irqrestore(&(log)->synclock, flags)
494 496
495/* compute the difference in bytes of lsn from sync point */ 497/* compute the difference in bytes of lsn from sync point */
496#define logdiff(diff, lsn, log)\ 498#define logdiff(diff, lsn, log)\
@@ -506,5 +508,6 @@ extern int lmLogShutdown(struct jfs_log * log);
506extern int lmLogInit(struct jfs_log * log); 508extern int lmLogInit(struct jfs_log * log);
507extern int lmLogFormat(struct jfs_log *log, s64 logAddress, int logSize); 509extern int lmLogFormat(struct jfs_log *log, s64 logAddress, int logSize);
508extern void jfs_flush_journal(struct jfs_log * log, int wait); 510extern void jfs_flush_journal(struct jfs_log * log, int wait);
511extern void jfs_syncpt(struct jfs_log *log);
509 512
510#endif /* _H_JFS_LOGMGR */ 513#endif /* _H_JFS_LOGMGR */
diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index 4c0a3ac75c08..41bf078dce05 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/jfs/jfs_metapage.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) International Business Machines Corp., 2000-2003 2 * Copyright (C) International Business Machines Corp., 2000-2005
3 * Portions Copyright (C) Christoph Hellwig, 2001-2002 3 * Portions Copyright (C) Christoph Hellwig, 2001-2002
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
@@ -18,10 +18,11 @@
18 */ 18 */
19 19
20#include <linux/fs.h> 20#include <linux/fs.h>
21#include <linux/mm.h>
22#include <linux/bio.h>
21#include <linux/init.h> 23#include <linux/init.h>
22#include <linux/buffer_head.h> 24#include <linux/buffer_head.h>
23#include <linux/mempool.h> 25#include <linux/mempool.h>
24#include <linux/delay.h>
25#include "jfs_incore.h" 26#include "jfs_incore.h"
26#include "jfs_superblock.h" 27#include "jfs_superblock.h"
27#include "jfs_filsys.h" 28#include "jfs_filsys.h"
@@ -29,8 +30,6 @@
29#include "jfs_txnmgr.h" 30#include "jfs_txnmgr.h"
30#include "jfs_debug.h" 31#include "jfs_debug.h"
31 32
32static DEFINE_SPINLOCK(meta_lock);
33
34#ifdef CONFIG_JFS_STATISTICS 33#ifdef CONFIG_JFS_STATISTICS
35static struct { 34static struct {
36 uint pagealloc; /* # of page allocations */ 35 uint pagealloc; /* # of page allocations */
@@ -39,22 +38,8 @@ static struct {
39} mpStat; 38} mpStat;
40#endif 39#endif
41 40
42 41#define metapage_locked(mp) test_bit(META_locked, &(mp)->flag)
43#define HASH_BITS 10 /* This makes hash_table 1 4K page */ 42#define trylock_metapage(mp) test_and_set_bit(META_locked, &(mp)->flag)
44#define HASH_SIZE (1 << HASH_BITS)
45static struct metapage **hash_table = NULL;
46static unsigned long hash_order;
47
48
49static inline int metapage_locked(struct metapage *mp)
50{
51 return test_bit(META_locked, &mp->flag);
52}
53
54static inline int trylock_metapage(struct metapage *mp)
55{
56 return test_and_set_bit(META_locked, &mp->flag);
57}
58 43
59static inline void unlock_metapage(struct metapage *mp) 44static inline void unlock_metapage(struct metapage *mp)
60{ 45{
@@ -62,26 +47,26 @@ static inline void unlock_metapage(struct metapage *mp)
62 wake_up(&mp->wait); 47 wake_up(&mp->wait);
63} 48}
64 49
65static void __lock_metapage(struct metapage *mp) 50static inline void __lock_metapage(struct metapage *mp)
66{ 51{
67 DECLARE_WAITQUEUE(wait, current); 52 DECLARE_WAITQUEUE(wait, current);
68
69 INCREMENT(mpStat.lockwait); 53 INCREMENT(mpStat.lockwait);
70
71 add_wait_queue_exclusive(&mp->wait, &wait); 54 add_wait_queue_exclusive(&mp->wait, &wait);
72 do { 55 do {
73 set_current_state(TASK_UNINTERRUPTIBLE); 56 set_current_state(TASK_UNINTERRUPTIBLE);
74 if (metapage_locked(mp)) { 57 if (metapage_locked(mp)) {
75 spin_unlock(&meta_lock); 58 unlock_page(mp->page);
76 schedule(); 59 schedule();
77 spin_lock(&meta_lock); 60 lock_page(mp->page);
78 } 61 }
79 } while (trylock_metapage(mp)); 62 } while (trylock_metapage(mp));
80 __set_current_state(TASK_RUNNING); 63 __set_current_state(TASK_RUNNING);
81 remove_wait_queue(&mp->wait, &wait); 64 remove_wait_queue(&mp->wait, &wait);
82} 65}
83 66
84/* needs meta_lock */ 67/*
68 * Must have mp->page locked
69 */
85static inline void lock_metapage(struct metapage *mp) 70static inline void lock_metapage(struct metapage *mp)
86{ 71{
87 if (trylock_metapage(mp)) 72 if (trylock_metapage(mp))
@@ -92,6 +77,110 @@ static inline void lock_metapage(struct metapage *mp)
92static kmem_cache_t *metapage_cache; 77static kmem_cache_t *metapage_cache;
93static mempool_t *metapage_mempool; 78static mempool_t *metapage_mempool;
94 79
80#define MPS_PER_PAGE (PAGE_CACHE_SIZE >> L2PSIZE)
81
82#if MPS_PER_PAGE > 1
83
84struct meta_anchor {
85 int mp_count;
86 atomic_t io_count;
87 struct metapage *mp[MPS_PER_PAGE];
88};
89#define mp_anchor(page) ((struct meta_anchor *)page->private)
90
91static inline struct metapage *page_to_mp(struct page *page, uint offset)
92{
93 if (!PagePrivate(page))
94 return NULL;
95 return mp_anchor(page)->mp[offset >> L2PSIZE];
96}
97
98static inline int insert_metapage(struct page *page, struct metapage *mp)
99{
100 struct meta_anchor *a;
101 int index;
102 int l2mp_blocks; /* log2 blocks per metapage */
103
104 if (PagePrivate(page))
105 a = mp_anchor(page);
106 else {
107 a = kmalloc(sizeof(struct meta_anchor), GFP_NOFS);
108 if (!a)
109 return -ENOMEM;
110 memset(a, 0, sizeof(struct meta_anchor));
111 page->private = (unsigned long)a;
112 SetPagePrivate(page);
113 kmap(page);
114 }
115
116 if (mp) {
117 l2mp_blocks = L2PSIZE - page->mapping->host->i_blkbits;
118 index = (mp->index >> l2mp_blocks) & (MPS_PER_PAGE - 1);
119 a->mp_count++;
120 a->mp[index] = mp;
121 }
122
123 return 0;
124}
125
126static inline void remove_metapage(struct page *page, struct metapage *mp)
127{
128 struct meta_anchor *a = mp_anchor(page);
129 int l2mp_blocks = L2PSIZE - page->mapping->host->i_blkbits;
130 int index;
131
132 index = (mp->index >> l2mp_blocks) & (MPS_PER_PAGE - 1);
133
134 BUG_ON(a->mp[index] != mp);
135
136 a->mp[index] = NULL;
137 if (--a->mp_count == 0) {
138 kfree(a);
139 page->private = 0;
140 ClearPagePrivate(page);
141 kunmap(page);
142 }
143}
144
145static inline void inc_io(struct page *page)
146{
147 atomic_inc(&mp_anchor(page)->io_count);
148}
149
150static inline void dec_io(struct page *page, void (*handler) (struct page *))
151{
152 if (atomic_dec_and_test(&mp_anchor(page)->io_count))
153 handler(page);
154}
155
156#else
157static inline struct metapage *page_to_mp(struct page *page, uint offset)
158{
159 return PagePrivate(page) ? (struct metapage *)page->private : NULL;
160}
161
162static inline int insert_metapage(struct page *page, struct metapage *mp)
163{
164 if (mp) {
165 page->private = (unsigned long)mp;
166 SetPagePrivate(page);
167 kmap(page);
168 }
169 return 0;
170}
171
172static inline void remove_metapage(struct page *page, struct metapage *mp)
173{
174 page->private = 0;
175 ClearPagePrivate(page);
176 kunmap(page);
177}
178
179#define inc_io(page) do {} while(0)
180#define dec_io(page, handler) handler(page)
181
182#endif
183
95static void init_once(void *foo, kmem_cache_t *cachep, unsigned long flags) 184static void init_once(void *foo, kmem_cache_t *cachep, unsigned long flags)
96{ 185{
97 struct metapage *mp = (struct metapage *)foo; 186 struct metapage *mp = (struct metapage *)foo;
@@ -139,16 +228,6 @@ int __init metapage_init(void)
139 kmem_cache_destroy(metapage_cache); 228 kmem_cache_destroy(metapage_cache);
140 return -ENOMEM; 229 return -ENOMEM;
141 } 230 }
142 /*
143 * Now the hash list
144 */
145 for (hash_order = 0;
146 ((PAGE_SIZE << hash_order) / sizeof(void *)) < HASH_SIZE;
147 hash_order++);
148 hash_table =
149 (struct metapage **) __get_free_pages(GFP_KERNEL, hash_order);
150 assert(hash_table);
151 memset(hash_table, 0, PAGE_SIZE << hash_order);
152 231
153 return 0; 232 return 0;
154} 233}
@@ -159,73 +238,388 @@ void metapage_exit(void)
159 kmem_cache_destroy(metapage_cache); 238 kmem_cache_destroy(metapage_cache);
160} 239}
161 240
241static inline void drop_metapage(struct page *page, struct metapage *mp)
242{
243 if (mp->count || mp->nohomeok || test_bit(META_dirty, &mp->flag) ||
244 test_bit(META_io, &mp->flag))
245 return;
246 remove_metapage(page, mp);
247 INCREMENT(mpStat.pagefree);
248 free_metapage(mp);
249}
250
162/* 251/*
163 * Basically same hash as in pagemap.h, but using our hash table 252 * Metapage address space operations
164 */ 253 */
165static struct metapage **meta_hash(struct address_space *mapping, 254
166 unsigned long index) 255static sector_t metapage_get_blocks(struct inode *inode, sector_t lblock,
256 unsigned int *len)
167{ 257{
168#define i (((unsigned long)mapping)/ \ 258 int rc = 0;
169 (sizeof(struct inode) & ~(sizeof(struct inode) -1 ))) 259 int xflag;
170#define s(x) ((x) + ((x) >> HASH_BITS)) 260 s64 xaddr;
171 return hash_table + (s(i + index) & (HASH_SIZE - 1)); 261 sector_t file_blocks = (inode->i_size + inode->i_blksize - 1) >>
172#undef i 262 inode->i_blkbits;
173#undef s 263
264 if (lblock >= file_blocks)
265 return 0;
266 if (lblock + *len > file_blocks)
267 *len = file_blocks - lblock;
268
269 if (inode->i_ino) {
270 rc = xtLookup(inode, (s64)lblock, *len, &xflag, &xaddr, len, 0);
271 if ((rc == 0) && *len)
272 lblock = (sector_t)xaddr;
273 else
274 lblock = 0;
275 } /* else no mapping */
276
277 return lblock;
174} 278}
175 279
176static struct metapage *search_hash(struct metapage ** hash_ptr, 280static void last_read_complete(struct page *page)
177 struct address_space *mapping,
178 unsigned long index)
179{ 281{
180 struct metapage *ptr; 282 if (!PageError(page))
283 SetPageUptodate(page);
284 unlock_page(page);
285}
286
287static int metapage_read_end_io(struct bio *bio, unsigned int bytes_done,
288 int err)
289{
290 struct page *page = bio->bi_private;
291
292 if (bio->bi_size)
293 return 1;
181 294
182 for (ptr = *hash_ptr; ptr; ptr = ptr->hash_next) { 295 if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) {
183 if ((ptr->mapping == mapping) && (ptr->index == index)) 296 printk(KERN_ERR "metapage_read_end_io: I/O error\n");
184 return ptr; 297 SetPageError(page);
185 } 298 }
186 299
187 return NULL; 300 dec_io(page, last_read_complete);
301 bio_put(bio);
302
303 return 0;
188} 304}
189 305
190static void add_to_hash(struct metapage * mp, struct metapage ** hash_ptr) 306static void remove_from_logsync(struct metapage *mp)
191{ 307{
192 if (*hash_ptr) 308 struct jfs_log *log = mp->log;
193 (*hash_ptr)->hash_prev = mp; 309 unsigned long flags;
310/*
311 * This can race. Recheck that log hasn't been set to null, and after
312 * acquiring logsync lock, recheck lsn
313 */
314 if (!log)
315 return;
316
317 LOGSYNC_LOCK(log, flags);
318 if (mp->lsn) {
319 mp->log = NULL;
320 mp->lsn = 0;
321 mp->clsn = 0;
322 log->count--;
323 list_del(&mp->synclist);
324 }
325 LOGSYNC_UNLOCK(log, flags);
326}
194 327
195 mp->hash_prev = NULL; 328static void last_write_complete(struct page *page)
196 mp->hash_next = *hash_ptr; 329{
197 *hash_ptr = mp; 330 struct metapage *mp;
331 unsigned int offset;
332
333 for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) {
334 mp = page_to_mp(page, offset);
335 if (mp && test_bit(META_io, &mp->flag)) {
336 if (mp->lsn)
337 remove_from_logsync(mp);
338 clear_bit(META_io, &mp->flag);
339 }
340 /*
341 * I'd like to call drop_metapage here, but I don't think it's
342 * safe unless I have the page locked
343 */
344 }
345 end_page_writeback(page);
198} 346}
199 347
200static void remove_from_hash(struct metapage * mp, struct metapage ** hash_ptr) 348static int metapage_write_end_io(struct bio *bio, unsigned int bytes_done,
349 int err)
201{ 350{
202 if (mp->hash_prev) 351 struct page *page = bio->bi_private;
203 mp->hash_prev->hash_next = mp->hash_next; 352
204 else { 353 BUG_ON(!PagePrivate(page));
205 assert(*hash_ptr == mp); 354
206 *hash_ptr = mp->hash_next; 355 if (bio->bi_size)
356 return 1;
357
358 if (! test_bit(BIO_UPTODATE, &bio->bi_flags)) {
359 printk(KERN_ERR "metapage_write_end_io: I/O error\n");
360 SetPageError(page);
361 }
362 dec_io(page, last_write_complete);
363 bio_put(bio);
364 return 0;
365}
366
367static int metapage_writepage(struct page *page, struct writeback_control *wbc)
368{
369 struct bio *bio = NULL;
370 unsigned int block_offset; /* block offset of mp within page */
371 struct inode *inode = page->mapping->host;
372 unsigned int blocks_per_mp = JFS_SBI(inode->i_sb)->nbperpage;
373 unsigned int len;
374 unsigned int xlen;
375 struct metapage *mp;
376 int redirty = 0;
377 sector_t lblock;
378 sector_t pblock;
379 sector_t next_block = 0;
380 sector_t page_start;
381 unsigned long bio_bytes = 0;
382 unsigned long bio_offset = 0;
383 unsigned int offset;
384
385 page_start = (sector_t)page->index <<
386 (PAGE_CACHE_SHIFT - inode->i_blkbits);
387 BUG_ON(!PageLocked(page));
388 BUG_ON(PageWriteback(page));
389
390 for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) {
391 mp = page_to_mp(page, offset);
392
393 if (!mp || !test_bit(META_dirty, &mp->flag))
394 continue;
395
396 if (mp->nohomeok && !test_bit(META_forcewrite, &mp->flag)) {
397 redirty = 1;
398 continue;
399 }
400
401 clear_bit(META_dirty, &mp->flag);
402 block_offset = offset >> inode->i_blkbits;
403 lblock = page_start + block_offset;
404 if (bio) {
405 if (xlen && lblock == next_block) {
406 /* Contiguous, in memory & on disk */
407 len = min(xlen, blocks_per_mp);
408 xlen -= len;
409 bio_bytes += len << inode->i_blkbits;
410 set_bit(META_io, &mp->flag);
411 continue;
412 }
413 /* Not contiguous */
414 if (bio_add_page(bio, page, bio_bytes, bio_offset) <
415 bio_bytes)
416 goto add_failed;
417 /*
418 * Increment counter before submitting i/o to keep
419 * count from hitting zero before we're through
420 */
421 inc_io(page);
422 if (!bio->bi_size)
423 goto dump_bio;
424 submit_bio(WRITE, bio);
425 bio = NULL;
426 } else {
427 set_page_writeback(page);
428 inc_io(page);
429 }
430 xlen = (PAGE_CACHE_SIZE - offset) >> inode->i_blkbits;
431 pblock = metapage_get_blocks(inode, lblock, &xlen);
432 if (!pblock) {
433 /* Need better error handling */
434 printk(KERN_ERR "JFS: metapage_get_blocks failed\n");
435 dec_io(page, last_write_complete);
436 continue;
437 }
438 set_bit(META_io, &mp->flag);
439 len = min(xlen, (uint) JFS_SBI(inode->i_sb)->nbperpage);
440
441 bio = bio_alloc(GFP_NOFS, 1);
442 bio->bi_bdev = inode->i_sb->s_bdev;
443 bio->bi_sector = pblock << (inode->i_blkbits - 9);
444 bio->bi_end_io = metapage_write_end_io;
445 bio->bi_private = page;
446
447 /* Don't call bio_add_page yet, we may add to this vec */
448 bio_offset = offset;
449 bio_bytes = len << inode->i_blkbits;
450
451 xlen -= len;
452 next_block = lblock + len;
453 }
454 if (bio) {
455 if (bio_add_page(bio, page, bio_bytes, bio_offset) < bio_bytes)
456 goto add_failed;
457 if (!bio->bi_size)
458 goto dump_bio;
459
460 submit_bio(WRITE, bio);
461 }
462 if (redirty)
463 redirty_page_for_writepage(wbc, page);
464
465 unlock_page(page);
466
467 return 0;
468add_failed:
469 /* We should never reach here, since we're only adding one vec */
470 printk(KERN_ERR "JFS: bio_add_page failed unexpectedly\n");
471 goto skip;
472dump_bio:
473 dump_mem("bio", bio, sizeof(*bio));
474skip:
475 bio_put(bio);
476 unlock_page(page);
477 dec_io(page, last_write_complete);
478
479 return -EIO;
480}
481
482static int metapage_readpage(struct file *fp, struct page *page)
483{
484 struct inode *inode = page->mapping->host;
485 struct bio *bio = NULL;
486 unsigned int block_offset;
487 unsigned int blocks_per_page = PAGE_CACHE_SIZE >> inode->i_blkbits;
488 sector_t page_start; /* address of page in fs blocks */
489 sector_t pblock;
490 unsigned int xlen;
491 unsigned int len;
492 unsigned int offset;
493
494 BUG_ON(!PageLocked(page));
495 page_start = (sector_t)page->index <<
496 (PAGE_CACHE_SHIFT - inode->i_blkbits);
497
498 block_offset = 0;
499 while (block_offset < blocks_per_page) {
500 xlen = blocks_per_page - block_offset;
501 pblock = metapage_get_blocks(inode, page_start + block_offset,
502 &xlen);
503 if (pblock) {
504 if (!PagePrivate(page))
505 insert_metapage(page, NULL);
506 inc_io(page);
507 if (bio)
508 submit_bio(READ, bio);
509
510 bio = bio_alloc(GFP_NOFS, 1);
511 bio->bi_bdev = inode->i_sb->s_bdev;
512 bio->bi_sector = pblock << (inode->i_blkbits - 9);
513 bio->bi_end_io = metapage_read_end_io;
514 bio->bi_private = page;
515 len = xlen << inode->i_blkbits;
516 offset = block_offset << inode->i_blkbits;
517 if (bio_add_page(bio, page, len, offset) < len)
518 goto add_failed;
519 block_offset += xlen;
520 } else
521 block_offset++;
207 } 522 }
523 if (bio)
524 submit_bio(READ, bio);
525 else
526 unlock_page(page);
527
528 return 0;
208 529
209 if (mp->hash_next) 530add_failed:
210 mp->hash_next->hash_prev = mp->hash_prev; 531 printk(KERN_ERR "JFS: bio_add_page failed unexpectedly\n");
532 bio_put(bio);
533 dec_io(page, last_read_complete);
534 return -EIO;
211} 535}
212 536
537static int metapage_releasepage(struct page *page, int gfp_mask)
538{
539 struct metapage *mp;
540 int busy = 0;
541 unsigned int offset;
542
543 for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) {
544 mp = page_to_mp(page, offset);
545
546 if (!mp)
547 continue;
548
549 jfs_info("metapage_releasepage: mp = 0x%p", mp);
550 if (mp->count || mp->nohomeok) {
551 jfs_info("count = %ld, nohomeok = %d", mp->count,
552 mp->nohomeok);
553 busy = 1;
554 continue;
555 }
556 wait_on_page_writeback(page);
557 //WARN_ON(test_bit(META_dirty, &mp->flag));
558 if (test_bit(META_dirty, &mp->flag)) {
559 dump_mem("dirty mp in metapage_releasepage", mp,
560 sizeof(struct metapage));
561 dump_mem("page", page, sizeof(struct page));
562 dump_stack();
563 }
564 WARN_ON(mp->lsn);
565 if (mp->lsn)
566 remove_from_logsync(mp);
567 remove_metapage(page, mp);
568 INCREMENT(mpStat.pagefree);
569 free_metapage(mp);
570 }
571 if (busy)
572 return -1;
573
574 return 0;
575}
576
577static int metapage_invalidatepage(struct page *page, unsigned long offset)
578{
579 BUG_ON(offset);
580
581 if (PageWriteback(page))
582 return 0;
583
584 return metapage_releasepage(page, 0);
585}
586
587struct address_space_operations jfs_metapage_aops = {
588 .readpage = metapage_readpage,
589 .writepage = metapage_writepage,
590 .sync_page = block_sync_page,
591 .releasepage = metapage_releasepage,
592 .invalidatepage = metapage_invalidatepage,
593 .set_page_dirty = __set_page_dirty_nobuffers,
594};
595
213struct metapage *__get_metapage(struct inode *inode, unsigned long lblock, 596struct metapage *__get_metapage(struct inode *inode, unsigned long lblock,
214 unsigned int size, int absolute, 597 unsigned int size, int absolute,
215 unsigned long new) 598 unsigned long new)
216{ 599{
217 struct metapage **hash_ptr;
218 int l2BlocksPerPage; 600 int l2BlocksPerPage;
219 int l2bsize; 601 int l2bsize;
220 struct address_space *mapping; 602 struct address_space *mapping;
221 struct metapage *mp; 603 struct metapage *mp = NULL;
604 struct page *page;
222 unsigned long page_index; 605 unsigned long page_index;
223 unsigned long page_offset; 606 unsigned long page_offset;
224 607
225 jfs_info("__get_metapage: inode = 0x%p, lblock = 0x%lx", inode, lblock); 608 jfs_info("__get_metapage: ino = %ld, lblock = 0x%lx, abs=%d",
226 609 inode->i_ino, lblock, absolute);
610
611 l2bsize = inode->i_blkbits;
612 l2BlocksPerPage = PAGE_CACHE_SHIFT - l2bsize;
613 page_index = lblock >> l2BlocksPerPage;
614 page_offset = (lblock - (page_index << l2BlocksPerPage)) << l2bsize;
615 if ((page_offset + size) > PAGE_CACHE_SIZE) {
616 jfs_err("MetaData crosses page boundary!!");
617 jfs_err("lblock = %lx, size = %d", lblock, size);
618 dump_stack();
619 return NULL;
620 }
227 if (absolute) 621 if (absolute)
228 mapping = inode->i_sb->s_bdev->bd_inode->i_mapping; 622 mapping = JFS_SBI(inode->i_sb)->direct_inode->i_mapping;
229 else { 623 else {
230 /* 624 /*
231 * If an nfs client tries to read an inode that is larger 625 * If an nfs client tries to read an inode that is larger
@@ -237,312 +631,212 @@ struct metapage *__get_metapage(struct inode *inode, unsigned long lblock,
237 mapping = inode->i_mapping; 631 mapping = inode->i_mapping;
238 } 632 }
239 633
240 hash_ptr = meta_hash(mapping, lblock); 634 if (new && (PSIZE == PAGE_CACHE_SIZE)) {
241again: 635 page = grab_cache_page(mapping, page_index);
242 spin_lock(&meta_lock); 636 if (!page) {
243 mp = search_hash(hash_ptr, mapping, lblock); 637 jfs_err("grab_cache_page failed!");
638 return NULL;
639 }
640 SetPageUptodate(page);
641 } else {
642 page = read_cache_page(mapping, page_index,
643 (filler_t *)mapping->a_ops->readpage, NULL);
644 if (IS_ERR(page)) {
645 jfs_err("read_cache_page failed!");
646 return NULL;
647 }
648 lock_page(page);
649 }
650
651 mp = page_to_mp(page, page_offset);
244 if (mp) { 652 if (mp) {
245 page_found: 653 if (mp->logical_size != size) {
246 if (test_bit(META_stale, &mp->flag)) { 654 jfs_error(inode->i_sb,
247 spin_unlock(&meta_lock); 655 "__get_metapage: mp->logical_size != size");
248 msleep(1); 656 jfs_err("logical_size = %d, size = %d",
249 goto again; 657 mp->logical_size, size);
658 dump_stack();
659 goto unlock;
250 } 660 }
251 mp->count++; 661 mp->count++;
252 lock_metapage(mp); 662 lock_metapage(mp);
253 spin_unlock(&meta_lock);
254 if (test_bit(META_discard, &mp->flag)) { 663 if (test_bit(META_discard, &mp->flag)) {
255 if (!new) { 664 if (!new) {
256 jfs_error(inode->i_sb, 665 jfs_error(inode->i_sb,
257 "__get_metapage: using a " 666 "__get_metapage: using a "
258 "discarded metapage"); 667 "discarded metapage");
259 release_metapage(mp); 668 discard_metapage(mp);
260 return NULL; 669 goto unlock;
261 } 670 }
262 clear_bit(META_discard, &mp->flag); 671 clear_bit(META_discard, &mp->flag);
263 } 672 }
264 jfs_info("__get_metapage: found 0x%p, in hash", mp);
265 if (mp->logical_size != size) {
266 jfs_error(inode->i_sb,
267 "__get_metapage: mp->logical_size != size");
268 release_metapage(mp);
269 return NULL;
270 }
271 } else { 673 } else {
272 l2bsize = inode->i_blkbits; 674 INCREMENT(mpStat.pagealloc);
273 l2BlocksPerPage = PAGE_CACHE_SHIFT - l2bsize; 675 mp = alloc_metapage(GFP_NOFS);
274 page_index = lblock >> l2BlocksPerPage; 676 mp->page = page;
275 page_offset = (lblock - (page_index << l2BlocksPerPage)) <<
276 l2bsize;
277 if ((page_offset + size) > PAGE_CACHE_SIZE) {
278 spin_unlock(&meta_lock);
279 jfs_err("MetaData crosses page boundary!!");
280 return NULL;
281 }
282
283 /*
284 * Locks held on aggregate inode pages are usually
285 * not held long, and they are taken in critical code
286 * paths (committing dirty inodes, txCommit thread)
287 *
288 * Attempt to get metapage without blocking, tapping into
289 * reserves if necessary.
290 */
291 mp = NULL;
292 if (JFS_IP(inode)->fileset == AGGREGATE_I) {
293 mp = alloc_metapage(GFP_ATOMIC);
294 if (!mp) {
295 /*
296 * mempool is supposed to protect us from
297 * failing here. We will try a blocking
298 * call, but a deadlock is possible here
299 */
300 printk(KERN_WARNING
301 "__get_metapage: atomic call to mempool_alloc failed.\n");
302 printk(KERN_WARNING
303 "Will attempt blocking call\n");
304 }
305 }
306 if (!mp) {
307 struct metapage *mp2;
308
309 spin_unlock(&meta_lock);
310 mp = alloc_metapage(GFP_NOFS);
311 spin_lock(&meta_lock);
312
313 /* we dropped the meta_lock, we need to search the
314 * hash again.
315 */
316 mp2 = search_hash(hash_ptr, mapping, lblock);
317 if (mp2) {
318 free_metapage(mp);
319 mp = mp2;
320 goto page_found;
321 }
322 }
323 mp->flag = 0; 677 mp->flag = 0;
324 lock_metapage(mp);
325 if (absolute)
326 set_bit(META_absolute, &mp->flag);
327 mp->xflag = COMMIT_PAGE; 678 mp->xflag = COMMIT_PAGE;
328 mp->count = 1; 679 mp->count = 1;
329 atomic_set(&mp->nohomeok,0); 680 mp->nohomeok = 0;
330 mp->mapping = mapping;
331 mp->index = lblock;
332 mp->page = NULL;
333 mp->logical_size = size; 681 mp->logical_size = size;
334 add_to_hash(mp, hash_ptr); 682 mp->data = page_address(page) + page_offset;
335 spin_unlock(&meta_lock); 683 mp->index = lblock;
336 684 if (unlikely(insert_metapage(page, mp))) {
337 if (new) { 685 free_metapage(mp);
338 jfs_info("__get_metapage: Calling grab_cache_page"); 686 goto unlock;
339 mp->page = grab_cache_page(mapping, page_index);
340 if (!mp->page) {
341 jfs_err("grab_cache_page failed!");
342 goto freeit;
343 } else {
344 INCREMENT(mpStat.pagealloc);
345 unlock_page(mp->page);
346 }
347 } else {
348 jfs_info("__get_metapage: Calling read_cache_page");
349 mp->page = read_cache_page(mapping, lblock,
350 (filler_t *)mapping->a_ops->readpage, NULL);
351 if (IS_ERR(mp->page)) {
352 jfs_err("read_cache_page failed!");
353 goto freeit;
354 } else
355 INCREMENT(mpStat.pagealloc);
356 } 687 }
357 mp->data = kmap(mp->page) + page_offset; 688 lock_metapage(mp);
358 } 689 }
359 690
360 if (new) 691 if (new) {
692 jfs_info("zeroing mp = 0x%p", mp);
361 memset(mp->data, 0, PSIZE); 693 memset(mp->data, 0, PSIZE);
694 }
362 695
363 jfs_info("__get_metapage: returning = 0x%p", mp); 696 unlock_page(page);
697 jfs_info("__get_metapage: returning = 0x%p data = 0x%p", mp, mp->data);
364 return mp; 698 return mp;
365 699
366freeit: 700unlock:
367 spin_lock(&meta_lock); 701 unlock_page(page);
368 remove_from_hash(mp, hash_ptr);
369 free_metapage(mp);
370 spin_unlock(&meta_lock);
371 return NULL; 702 return NULL;
372} 703}
373 704
374void hold_metapage(struct metapage * mp, int force) 705void grab_metapage(struct metapage * mp)
375{ 706{
376 spin_lock(&meta_lock); 707 jfs_info("grab_metapage: mp = 0x%p", mp);
377 708 page_cache_get(mp->page);
709 lock_page(mp->page);
378 mp->count++; 710 mp->count++;
379 711 lock_metapage(mp);
380 if (force) { 712 unlock_page(mp->page);
381 ASSERT (!(test_bit(META_forced, &mp->flag)));
382 if (trylock_metapage(mp))
383 set_bit(META_forced, &mp->flag);
384 } else
385 lock_metapage(mp);
386
387 spin_unlock(&meta_lock);
388} 713}
389 714
390static void __write_metapage(struct metapage * mp) 715void force_metapage(struct metapage *mp)
391{ 716{
392 int l2bsize = mp->mapping->host->i_blkbits; 717 struct page *page = mp->page;
393 int l2BlocksPerPage = PAGE_CACHE_SHIFT - l2bsize; 718 jfs_info("force_metapage: mp = 0x%p", mp);
394 unsigned long page_index; 719 set_bit(META_forcewrite, &mp->flag);
395 unsigned long page_offset; 720 clear_bit(META_sync, &mp->flag);
396 int rc; 721 page_cache_get(page);
397 722 lock_page(page);
398 jfs_info("__write_metapage: mp = 0x%p", mp); 723 set_page_dirty(page);
399 724 write_one_page(page, 1);
400 page_index = mp->page->index; 725 clear_bit(META_forcewrite, &mp->flag);
401 page_offset = 726 page_cache_release(page);
402 (mp->index - (page_index << l2BlocksPerPage)) << l2bsize; 727}
403 728
729extern void hold_metapage(struct metapage *mp)
730{
404 lock_page(mp->page); 731 lock_page(mp->page);
405 rc = mp->mapping->a_ops->prepare_write(NULL, mp->page, page_offset, 732}
406 page_offset + 733
407 mp->logical_size); 734extern void put_metapage(struct metapage *mp)
408 if (rc) { 735{
409 jfs_err("prepare_write return %d!", rc); 736 if (mp->count || mp->nohomeok) {
410 ClearPageUptodate(mp->page); 737 /* Someone else will release this */
411 unlock_page(mp->page); 738 unlock_page(mp->page);
412 clear_bit(META_dirty, &mp->flag);
413 return; 739 return;
414 } 740 }
415 rc = mp->mapping->a_ops->commit_write(NULL, mp->page, page_offset, 741 page_cache_get(mp->page);
416 page_offset + 742 mp->count++;
417 mp->logical_size); 743 lock_metapage(mp);
418 if (rc) {
419 jfs_err("commit_write returned %d", rc);
420 }
421
422 unlock_page(mp->page); 744 unlock_page(mp->page);
423 clear_bit(META_dirty, &mp->flag); 745 release_metapage(mp);
424
425 jfs_info("__write_metapage done");
426}
427
428static inline void sync_metapage(struct metapage *mp)
429{
430 struct page *page = mp->page;
431
432 page_cache_get(page);
433 lock_page(page);
434
435 /* we're done with this page - no need to check for errors */
436 if (page_has_buffers(page))
437 write_one_page(page, 1);
438 else
439 unlock_page(page);
440 page_cache_release(page);
441} 746}
442 747
443void release_metapage(struct metapage * mp) 748void release_metapage(struct metapage * mp)
444{ 749{
445 struct jfs_log *log; 750 struct page *page = mp->page;
446
447 jfs_info("release_metapage: mp = 0x%p, flag = 0x%lx", mp, mp->flag); 751 jfs_info("release_metapage: mp = 0x%p, flag = 0x%lx", mp, mp->flag);
448 752
449 spin_lock(&meta_lock); 753 BUG_ON(!page);
450 if (test_bit(META_forced, &mp->flag)) { 754
451 clear_bit(META_forced, &mp->flag); 755 lock_page(page);
452 mp->count--; 756 unlock_metapage(mp);
453 spin_unlock(&meta_lock);
454 return;
455 }
456 757
457 assert(mp->count); 758 assert(mp->count);
458 if (--mp->count || atomic_read(&mp->nohomeok)) { 759 if (--mp->count || mp->nohomeok) {
459 unlock_metapage(mp); 760 unlock_page(page);
460 spin_unlock(&meta_lock); 761 page_cache_release(page);
461 return; 762 return;
462 } 763 }
463 764
464 if (mp->page) { 765 if (test_bit(META_dirty, &mp->flag)) {
465 set_bit(META_stale, &mp->flag); 766 set_page_dirty(page);
466 spin_unlock(&meta_lock);
467 kunmap(mp->page);
468 mp->data = NULL;
469 if (test_bit(META_dirty, &mp->flag))
470 __write_metapage(mp);
471 if (test_bit(META_sync, &mp->flag)) { 767 if (test_bit(META_sync, &mp->flag)) {
472 sync_metapage(mp);
473 clear_bit(META_sync, &mp->flag); 768 clear_bit(META_sync, &mp->flag);
769 write_one_page(page, 1);
770 lock_page(page); /* write_one_page unlocks the page */
474 } 771 }
772 } else if (mp->lsn) /* discard_metapage doesn't remove it */
773 remove_from_logsync(mp);
475 774
476 if (test_bit(META_discard, &mp->flag)) { 775#if MPS_PER_PAGE == 1
477 lock_page(mp->page); 776 /*
478 block_invalidatepage(mp->page, 0); 777 * If we know this is the only thing in the page, we can throw
479 unlock_page(mp->page); 778 * the page out of the page cache. If pages are larger, we
480 } 779 * don't want to do this.
481 780 */
482 page_cache_release(mp->page);
483 mp->page = NULL;
484 INCREMENT(mpStat.pagefree);
485 spin_lock(&meta_lock);
486 }
487 781
488 if (mp->lsn) { 782 /* Retest mp->count since we may have released page lock */
489 /* 783 if (test_bit(META_discard, &mp->flag) && !mp->count) {
490 * Remove metapage from logsynclist. 784 clear_page_dirty(page);
491 */ 785 ClearPageUptodate(page);
492 log = mp->log; 786#ifdef _NOT_YET
493 LOGSYNC_LOCK(log); 787 if (page->mapping) {
494 mp->log = NULL; 788 /* Remove from page cache and page cache reference */
495 mp->lsn = 0; 789 remove_from_page_cache(page);
496 mp->clsn = 0; 790 page_cache_release(page);
497 log->count--; 791 metapage_releasepage(page, 0);
498 list_del(&mp->synclist); 792 }
499 LOGSYNC_UNLOCK(log); 793#endif
500 } 794 }
501 remove_from_hash(mp, meta_hash(mp->mapping, mp->index)); 795#else
502 spin_unlock(&meta_lock); 796 /* Try to keep metapages from using up too much memory */
503 797 drop_metapage(page, mp);
504 free_metapage(mp); 798#endif
799 unlock_page(page);
800 page_cache_release(page);
505} 801}
506 802
507void __invalidate_metapages(struct inode *ip, s64 addr, int len) 803void __invalidate_metapages(struct inode *ip, s64 addr, int len)
508{ 804{
509 struct metapage **hash_ptr; 805 sector_t lblock;
510 unsigned long lblock;
511 int l2BlocksPerPage = PAGE_CACHE_SHIFT - ip->i_blkbits; 806 int l2BlocksPerPage = PAGE_CACHE_SHIFT - ip->i_blkbits;
807 int BlocksPerPage = 1 << l2BlocksPerPage;
512 /* All callers are interested in block device's mapping */ 808 /* All callers are interested in block device's mapping */
513 struct address_space *mapping = ip->i_sb->s_bdev->bd_inode->i_mapping; 809 struct address_space *mapping =
810 JFS_SBI(ip->i_sb)->direct_inode->i_mapping;
514 struct metapage *mp; 811 struct metapage *mp;
515 struct page *page; 812 struct page *page;
813 unsigned int offset;
516 814
517 /* 815 /*
518 * First, mark metapages to discard. They will eventually be 816 * Mark metapages to discard. They will eventually be
519 * released, but should not be written. 817 * released, but should not be written.
520 */ 818 */
521 for (lblock = addr; lblock < addr + len; 819 for (lblock = addr & ~(BlocksPerPage - 1); lblock < addr + len;
522 lblock += 1 << l2BlocksPerPage) { 820 lblock += BlocksPerPage) {
523 hash_ptr = meta_hash(mapping, lblock); 821 page = find_lock_page(mapping, lblock >> l2BlocksPerPage);
524again: 822 if (!page)
525 spin_lock(&meta_lock); 823 continue;
526 mp = search_hash(hash_ptr, mapping, lblock); 824 for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) {
527 if (mp) { 825 mp = page_to_mp(page, offset);
528 if (test_bit(META_stale, &mp->flag)) { 826 if (!mp)
529 spin_unlock(&meta_lock); 827 continue;
530 msleep(1); 828 if (mp->index < addr)
531 goto again; 829 continue;
532 } 830 if (mp->index >= addr + len)
831 break;
533 832
534 clear_bit(META_dirty, &mp->flag); 833 clear_bit(META_dirty, &mp->flag);
535 set_bit(META_discard, &mp->flag); 834 set_bit(META_discard, &mp->flag);
536 spin_unlock(&meta_lock); 835 if (mp->lsn)
537 } else { 836 remove_from_logsync(mp);
538 spin_unlock(&meta_lock);
539 page = find_lock_page(mapping, lblock>>l2BlocksPerPage);
540 if (page) {
541 block_invalidatepage(page, 0);
542 unlock_page(page);
543 page_cache_release(page);
544 }
545 } 837 }
838 unlock_page(page);
839 page_cache_release(page);
546 } 840 }
547} 841}
548 842
diff --git a/fs/jfs/jfs_metapage.h b/fs/jfs/jfs_metapage.h
index 0e58aba58c37..991e9fb84c75 100644
--- a/fs/jfs/jfs_metapage.h
+++ b/fs/jfs/jfs_metapage.h
@@ -33,38 +33,27 @@ struct metapage {
33 unsigned long flag; /* See Below */ 33 unsigned long flag; /* See Below */
34 unsigned long count; /* Reference count */ 34 unsigned long count; /* Reference count */
35 void *data; /* Data pointer */ 35 void *data; /* Data pointer */
36 36 sector_t index; /* block address of page */
37 /* list management stuff */
38 struct metapage *hash_prev;
39 struct metapage *hash_next; /* Also used for free list */
40
41 /*
42 * mapping & index become redundant, but we need these here to
43 * add the metapage to the hash before we have the real page
44 */
45 struct address_space *mapping;
46 unsigned long index;
47 wait_queue_head_t wait; 37 wait_queue_head_t wait;
48 38
49 /* implementation */ 39 /* implementation */
50 struct page *page; 40 struct page *page;
51 unsigned long logical_size; 41 unsigned int logical_size;
52 42
53 /* Journal management */ 43 /* Journal management */
54 int clsn; 44 int clsn;
55 atomic_t nohomeok; 45 int nohomeok;
56 struct jfs_log *log; 46 struct jfs_log *log;
57}; 47};
58 48
59/* metapage flag */ 49/* metapage flag */
60#define META_locked 0 50#define META_locked 0
61#define META_absolute 1 51#define META_free 1
62#define META_free 2 52#define META_dirty 2
63#define META_dirty 3 53#define META_sync 3
64#define META_sync 4 54#define META_discard 4
65#define META_discard 5 55#define META_forcewrite 5
66#define META_forced 6 56#define META_io 6
67#define META_stale 7
68 57
69#define mark_metapage_dirty(mp) set_bit(META_dirty, &(mp)->flag) 58#define mark_metapage_dirty(mp) set_bit(META_dirty, &(mp)->flag)
70 59
@@ -80,7 +69,16 @@ extern struct metapage *__get_metapage(struct inode *inode,
80 __get_metapage(inode, lblock, size, absolute, TRUE) 69 __get_metapage(inode, lblock, size, absolute, TRUE)
81 70
82extern void release_metapage(struct metapage *); 71extern void release_metapage(struct metapage *);
83extern void hold_metapage(struct metapage *, int); 72extern void grab_metapage(struct metapage *);
73extern void force_metapage(struct metapage *);
74
75/*
76 * hold_metapage and put_metapage are used in conjuction. The page lock
77 * is not dropped between the two, so no other threads can get or release
78 * the metapage
79 */
80extern void hold_metapage(struct metapage *);
81extern void put_metapage(struct metapage *);
84 82
85static inline void write_metapage(struct metapage *mp) 83static inline void write_metapage(struct metapage *mp)
86{ 84{
@@ -101,6 +99,46 @@ static inline void discard_metapage(struct metapage *mp)
101 release_metapage(mp); 99 release_metapage(mp);
102} 100}
103 101
102static inline void metapage_nohomeok(struct metapage *mp)
103{
104 struct page *page = mp->page;
105 lock_page(page);
106 if (!mp->nohomeok++) {
107 mark_metapage_dirty(mp);
108 page_cache_get(page);
109 wait_on_page_writeback(page);
110 }
111 unlock_page(page);
112}
113
114/*
115 * This serializes access to mp->lsn when metapages are added to logsynclist
116 * without setting nohomeok. i.e. updating imap & dmap
117 */
118static inline void metapage_wait_for_io(struct metapage *mp)
119{
120 if (test_bit(META_io, &mp->flag))
121 wait_on_page_writeback(mp->page);
122}
123
124/*
125 * This is called when already holding the metapage
126 */
127static inline void _metapage_homeok(struct metapage *mp)
128{
129 if (!--mp->nohomeok)
130 page_cache_release(mp->page);
131}
132
133static inline void metapage_homeok(struct metapage *mp)
134{
135 hold_metapage(mp);
136 _metapage_homeok(mp);
137 put_metapage(mp);
138}
139
140extern struct address_space_operations jfs_metapage_aops;
141
104/* 142/*
105 * This routines invalidate all pages for an extent. 143 * This routines invalidate all pages for an extent.
106 */ 144 */
diff --git a/fs/jfs/jfs_mount.c b/fs/jfs/jfs_mount.c
index c535ffd638e8..032d111bc330 100644
--- a/fs/jfs/jfs_mount.c
+++ b/fs/jfs/jfs_mount.c
@@ -285,11 +285,6 @@ int jfs_mount_rw(struct super_block *sb, int remount)
285 */ 285 */
286 logMOUNT(sb); 286 logMOUNT(sb);
287 287
288 /*
289 * Set page cache allocation policy
290 */
291 mapping_set_gfp_mask(sb->s_bdev->bd_inode->i_mapping, GFP_NOFS);
292
293 return rc; 288 return rc;
294} 289}
295 290
diff --git a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c
index f40301d93f74..e93d01aa12c4 100644
--- a/fs/jfs/jfs_txnmgr.c
+++ b/fs/jfs/jfs_txnmgr.c
@@ -227,6 +227,7 @@ static lid_t txLockAlloc(void)
227 227
228static void txLockFree(lid_t lid) 228static void txLockFree(lid_t lid)
229{ 229{
230 TxLock[lid].tid = 0;
230 TxLock[lid].next = TxAnchor.freelock; 231 TxLock[lid].next = TxAnchor.freelock;
231 TxAnchor.freelock = lid; 232 TxAnchor.freelock = lid;
232 TxAnchor.tlocksInUse--; 233 TxAnchor.tlocksInUse--;
@@ -566,9 +567,6 @@ void txEnd(tid_t tid)
566 * synchronize with logsync barrier 567 * synchronize with logsync barrier
567 */ 568 */
568 if (test_bit(log_SYNCBARRIER, &log->flag)) { 569 if (test_bit(log_SYNCBARRIER, &log->flag)) {
569 /* forward log syncpt */
570 /* lmSync(log); */
571
572 jfs_info("log barrier off: 0x%x", log->lsn); 570 jfs_info("log barrier off: 0x%x", log->lsn);
573 571
574 /* enable new transactions start */ 572 /* enable new transactions start */
@@ -576,15 +574,22 @@ void txEnd(tid_t tid)
576 574
577 /* wakeup all waitors for logsync barrier */ 575 /* wakeup all waitors for logsync barrier */
578 TXN_WAKEUP(&log->syncwait); 576 TXN_WAKEUP(&log->syncwait);
577
578 TXN_UNLOCK();
579
580 /* forward log syncpt */
581 jfs_syncpt(log);
582
583 goto wakeup;
579 } 584 }
580 } 585 }
581 586
587 TXN_UNLOCK();
588wakeup:
582 /* 589 /*
583 * wakeup all waitors for a free tblock 590 * wakeup all waitors for a free tblock
584 */ 591 */
585 TXN_WAKEUP(&TxAnchor.freewait); 592 TXN_WAKEUP(&TxAnchor.freewait);
586
587 TXN_UNLOCK();
588} 593}
589 594
590 595
@@ -633,8 +638,10 @@ struct tlock *txLock(tid_t tid, struct inode *ip, struct metapage * mp,
633 638
634 /* is page locked by the requester transaction ? */ 639 /* is page locked by the requester transaction ? */
635 tlck = lid_to_tlock(lid); 640 tlck = lid_to_tlock(lid);
636 if ((xtid = tlck->tid) == tid) 641 if ((xtid = tlck->tid) == tid) {
642 TXN_UNLOCK();
637 goto grantLock; 643 goto grantLock;
644 }
638 645
639 /* 646 /*
640 * is page locked by anonymous transaction/lock ? 647 * is page locked by anonymous transaction/lock ?
@@ -649,6 +656,7 @@ struct tlock *txLock(tid_t tid, struct inode *ip, struct metapage * mp,
649 */ 656 */
650 if (xtid == 0) { 657 if (xtid == 0) {
651 tlck->tid = tid; 658 tlck->tid = tid;
659 TXN_UNLOCK();
652 tblk = tid_to_tblock(tid); 660 tblk = tid_to_tblock(tid);
653 /* 661 /*
654 * The order of the tlocks in the transaction is important 662 * The order of the tlocks in the transaction is important
@@ -706,17 +714,18 @@ struct tlock *txLock(tid_t tid, struct inode *ip, struct metapage * mp,
706 */ 714 */
707 tlck->tid = tid; 715 tlck->tid = tid;
708 716
717 TXN_UNLOCK();
718
709 /* mark tlock for meta-data page */ 719 /* mark tlock for meta-data page */
710 if (mp->xflag & COMMIT_PAGE) { 720 if (mp->xflag & COMMIT_PAGE) {
711 721
712 tlck->flag = tlckPAGELOCK; 722 tlck->flag = tlckPAGELOCK;
713 723
714 /* mark the page dirty and nohomeok */ 724 /* mark the page dirty and nohomeok */
715 mark_metapage_dirty(mp); 725 metapage_nohomeok(mp);
716 atomic_inc(&mp->nohomeok);
717 726
718 jfs_info("locking mp = 0x%p, nohomeok = %d tid = %d tlck = 0x%p", 727 jfs_info("locking mp = 0x%p, nohomeok = %d tid = %d tlck = 0x%p",
719 mp, atomic_read(&mp->nohomeok), tid, tlck); 728 mp, mp->nohomeok, tid, tlck);
720 729
721 /* if anonymous transaction, and buffer is on the group 730 /* if anonymous transaction, and buffer is on the group
722 * commit synclist, mark inode to show this. This will 731 * commit synclist, mark inode to show this. This will
@@ -762,8 +771,10 @@ struct tlock *txLock(tid_t tid, struct inode *ip, struct metapage * mp,
762 if (tlck->next == 0) { 771 if (tlck->next == 0) {
763 /* This inode's first anonymous transaction */ 772 /* This inode's first anonymous transaction */
764 jfs_ip->atltail = lid; 773 jfs_ip->atltail = lid;
774 TXN_LOCK();
765 list_add_tail(&jfs_ip->anon_inode_list, 775 list_add_tail(&jfs_ip->anon_inode_list,
766 &TxAnchor.anon_list); 776 &TxAnchor.anon_list);
777 TXN_UNLOCK();
767 } 778 }
768 } 779 }
769 780
@@ -821,8 +832,6 @@ struct tlock *txLock(tid_t tid, struct inode *ip, struct metapage * mp,
821 grantLock: 832 grantLock:
822 tlck->type |= type; 833 tlck->type |= type;
823 834
824 TXN_UNLOCK();
825
826 return tlck; 835 return tlck;
827 836
828 /* 837 /*
@@ -841,11 +850,19 @@ struct tlock *txLock(tid_t tid, struct inode *ip, struct metapage * mp,
841 BUG(); 850 BUG();
842 } 851 }
843 INCREMENT(stattx.waitlock); /* statistics */ 852 INCREMENT(stattx.waitlock); /* statistics */
853 TXN_UNLOCK();
844 release_metapage(mp); 854 release_metapage(mp);
855 TXN_LOCK();
856 xtid = tlck->tid; /* reaquire after dropping TXN_LOCK */
845 857
846 jfs_info("txLock: in waitLock, tid = %d, xtid = %d, lid = %d", 858 jfs_info("txLock: in waitLock, tid = %d, xtid = %d, lid = %d",
847 tid, xtid, lid); 859 tid, xtid, lid);
848 TXN_SLEEP_DROP_LOCK(&tid_to_tblock(xtid)->waitor); 860
861 /* Recheck everything since dropping TXN_LOCK */
862 if (xtid && (tlck->mp == mp) && (mp->lid == lid))
863 TXN_SLEEP_DROP_LOCK(&tid_to_tblock(xtid)->waitor);
864 else
865 TXN_UNLOCK();
849 jfs_info("txLock: awakened tid = %d, lid = %d", tid, lid); 866 jfs_info("txLock: awakened tid = %d, lid = %d", tid, lid);
850 867
851 return NULL; 868 return NULL;
@@ -906,6 +923,7 @@ static void txUnlock(struct tblock * tblk)
906 struct metapage *mp; 923 struct metapage *mp;
907 struct jfs_log *log; 924 struct jfs_log *log;
908 int difft, diffp; 925 int difft, diffp;
926 unsigned long flags;
909 927
910 jfs_info("txUnlock: tblk = 0x%p", tblk); 928 jfs_info("txUnlock: tblk = 0x%p", tblk);
911 log = JFS_SBI(tblk->sb)->log; 929 log = JFS_SBI(tblk->sb)->log;
@@ -925,19 +943,14 @@ static void txUnlock(struct tblock * tblk)
925 assert(mp->xflag & COMMIT_PAGE); 943 assert(mp->xflag & COMMIT_PAGE);
926 944
927 /* hold buffer 945 /* hold buffer
928 *
929 * It's possible that someone else has the metapage.
930 * The only things were changing are nohomeok, which
931 * is handled atomically, and clsn which is protected
932 * by the LOGSYNC_LOCK.
933 */ 946 */
934 hold_metapage(mp, 1); 947 hold_metapage(mp);
935 948
936 assert(atomic_read(&mp->nohomeok) > 0); 949 assert(mp->nohomeok > 0);
937 atomic_dec(&mp->nohomeok); 950 _metapage_homeok(mp);
938 951
939 /* inherit younger/larger clsn */ 952 /* inherit younger/larger clsn */
940 LOGSYNC_LOCK(log); 953 LOGSYNC_LOCK(log, flags);
941 if (mp->clsn) { 954 if (mp->clsn) {
942 logdiff(difft, tblk->clsn, log); 955 logdiff(difft, tblk->clsn, log);
943 logdiff(diffp, mp->clsn, log); 956 logdiff(diffp, mp->clsn, log);
@@ -945,16 +958,11 @@ static void txUnlock(struct tblock * tblk)
945 mp->clsn = tblk->clsn; 958 mp->clsn = tblk->clsn;
946 } else 959 } else
947 mp->clsn = tblk->clsn; 960 mp->clsn = tblk->clsn;
948 LOGSYNC_UNLOCK(log); 961 LOGSYNC_UNLOCK(log, flags);
949 962
950 assert(!(tlck->flag & tlckFREEPAGE)); 963 assert(!(tlck->flag & tlckFREEPAGE));
951 964
952 if (tlck->flag & tlckWRITEPAGE) { 965 put_metapage(mp);
953 write_metapage(mp);
954 } else {
955 /* release page which has been forced */
956 release_metapage(mp);
957 }
958 } 966 }
959 967
960 /* insert tlock, and linelock(s) of the tlock if any, 968 /* insert tlock, and linelock(s) of the tlock if any,
@@ -981,10 +989,10 @@ static void txUnlock(struct tblock * tblk)
981 * has been inserted in logsync list at txUpdateMap()) 989 * has been inserted in logsync list at txUpdateMap())
982 */ 990 */
983 if (tblk->lsn) { 991 if (tblk->lsn) {
984 LOGSYNC_LOCK(log); 992 LOGSYNC_LOCK(log, flags);
985 log->count--; 993 log->count--;
986 list_del(&tblk->synclist); 994 list_del(&tblk->synclist);
987 LOGSYNC_UNLOCK(log); 995 LOGSYNC_UNLOCK(log, flags);
988 } 996 }
989} 997}
990 998
@@ -1573,8 +1581,8 @@ static int dataLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
1573 * the last entry, so don't bother logging this 1581 * the last entry, so don't bother logging this
1574 */ 1582 */
1575 mp->lid = 0; 1583 mp->lid = 0;
1576 hold_metapage(mp, 0); 1584 grab_metapage(mp);
1577 atomic_dec(&mp->nohomeok); 1585 metapage_homeok(mp);
1578 discard_metapage(mp); 1586 discard_metapage(mp);
1579 tlck->mp = NULL; 1587 tlck->mp = NULL;
1580 return 0; 1588 return 0;
@@ -1712,7 +1720,7 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
1712 struct maplock *maplock; 1720 struct maplock *maplock;
1713 struct xdlistlock *xadlock; 1721 struct xdlistlock *xadlock;
1714 struct pxd_lock *pxdlock; 1722 struct pxd_lock *pxdlock;
1715 pxd_t *pxd; 1723 pxd_t *page_pxd;
1716 int next, lwm, hwm; 1724 int next, lwm, hwm;
1717 1725
1718 ip = tlck->ip; 1726 ip = tlck->ip;
@@ -1722,7 +1730,7 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
1722 lrd->log.redopage.type = cpu_to_le16(LOG_XTREE); 1730 lrd->log.redopage.type = cpu_to_le16(LOG_XTREE);
1723 lrd->log.redopage.l2linesize = cpu_to_le16(L2XTSLOTSIZE); 1731 lrd->log.redopage.l2linesize = cpu_to_le16(L2XTSLOTSIZE);
1724 1732
1725 pxd = &lrd->log.redopage.pxd; 1733 page_pxd = &lrd->log.redopage.pxd;
1726 1734
1727 if (tlck->type & tlckBTROOT) { 1735 if (tlck->type & tlckBTROOT) {
1728 lrd->log.redopage.type |= cpu_to_le16(LOG_BTROOT); 1736 lrd->log.redopage.type |= cpu_to_le16(LOG_BTROOT);
@@ -1752,9 +1760,9 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
1752 * applying the after-image to the meta-data page. 1760 * applying the after-image to the meta-data page.
1753 */ 1761 */
1754 lrd->type = cpu_to_le16(LOG_REDOPAGE); 1762 lrd->type = cpu_to_le16(LOG_REDOPAGE);
1755// *pxd = mp->cm_pxd; 1763// *page_pxd = mp->cm_pxd;
1756 PXDaddress(pxd, mp->index); 1764 PXDaddress(page_pxd, mp->index);
1757 PXDlength(pxd, 1765 PXDlength(page_pxd,
1758 mp->logical_size >> tblk->sb->s_blocksize_bits); 1766 mp->logical_size >> tblk->sb->s_blocksize_bits);
1759 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, tlck)); 1767 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, tlck));
1760 1768
@@ -1776,25 +1784,31 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
1776 tlck->flag |= tlckUPDATEMAP; 1784 tlck->flag |= tlckUPDATEMAP;
1777 xadlock->flag = mlckALLOCXADLIST; 1785 xadlock->flag = mlckALLOCXADLIST;
1778 xadlock->count = next - lwm; 1786 xadlock->count = next - lwm;
1779 if ((xadlock->count <= 2) && (tblk->xflag & COMMIT_LAZY)) { 1787 if ((xadlock->count <= 4) && (tblk->xflag & COMMIT_LAZY)) {
1780 int i; 1788 int i;
1789 pxd_t *pxd;
1781 /* 1790 /*
1782 * Lazy commit may allow xtree to be modified before 1791 * Lazy commit may allow xtree to be modified before
1783 * txUpdateMap runs. Copy xad into linelock to 1792 * txUpdateMap runs. Copy xad into linelock to
1784 * preserve correct data. 1793 * preserve correct data.
1794 *
1795 * We can fit twice as may pxd's as xads in the lock
1785 */ 1796 */
1786 xadlock->xdlist = &xtlck->pxdlock; 1797 xadlock->flag = mlckALLOCPXDLIST;
1787 memcpy(xadlock->xdlist, &p->xad[lwm], 1798 pxd = xadlock->xdlist = &xtlck->pxdlock;
1788 sizeof(xad_t) * xadlock->count); 1799 for (i = 0; i < xadlock->count; i++) {
1789 1800 PXDaddress(pxd, addressXAD(&p->xad[lwm + i]));
1790 for (i = 0; i < xadlock->count; i++) 1801 PXDlength(pxd, lengthXAD(&p->xad[lwm + i]));
1791 p->xad[lwm + i].flag &= 1802 p->xad[lwm + i].flag &=
1792 ~(XAD_NEW | XAD_EXTENDED); 1803 ~(XAD_NEW | XAD_EXTENDED);
1804 pxd++;
1805 }
1793 } else { 1806 } else {
1794 /* 1807 /*
1795 * xdlist will point to into inode's xtree, ensure 1808 * xdlist will point to into inode's xtree, ensure
1796 * that transaction is not committed lazily. 1809 * that transaction is not committed lazily.
1797 */ 1810 */
1811 xadlock->flag = mlckALLOCXADLIST;
1798 xadlock->xdlist = &p->xad[lwm]; 1812 xadlock->xdlist = &p->xad[lwm];
1799 tblk->xflag &= ~COMMIT_LAZY; 1813 tblk->xflag &= ~COMMIT_LAZY;
1800 } 1814 }
@@ -1836,8 +1850,8 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
1836 if (tblk->xflag & COMMIT_TRUNCATE) { 1850 if (tblk->xflag & COMMIT_TRUNCATE) {
1837 /* write NOREDOPAGE for the page */ 1851 /* write NOREDOPAGE for the page */
1838 lrd->type = cpu_to_le16(LOG_NOREDOPAGE); 1852 lrd->type = cpu_to_le16(LOG_NOREDOPAGE);
1839 PXDaddress(pxd, mp->index); 1853 PXDaddress(page_pxd, mp->index);
1840 PXDlength(pxd, 1854 PXDlength(page_pxd,
1841 mp->logical_size >> tblk->sb-> 1855 mp->logical_size >> tblk->sb->
1842 s_blocksize_bits); 1856 s_blocksize_bits);
1843 lrd->backchain = 1857 lrd->backchain =
@@ -1872,22 +1886,32 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
1872 * deleted page itself; 1886 * deleted page itself;
1873 */ 1887 */
1874 tlck->flag |= tlckUPDATEMAP; 1888 tlck->flag |= tlckUPDATEMAP;
1875 xadlock->flag = mlckFREEXADLIST;
1876 xadlock->count = hwm - XTENTRYSTART + 1; 1889 xadlock->count = hwm - XTENTRYSTART + 1;
1877 if ((xadlock->count <= 2) && (tblk->xflag & COMMIT_LAZY)) { 1890 if ((xadlock->count <= 4) && (tblk->xflag & COMMIT_LAZY)) {
1891 int i;
1892 pxd_t *pxd;
1878 /* 1893 /*
1879 * Lazy commit may allow xtree to be modified before 1894 * Lazy commit may allow xtree to be modified before
1880 * txUpdateMap runs. Copy xad into linelock to 1895 * txUpdateMap runs. Copy xad into linelock to
1881 * preserve correct data. 1896 * preserve correct data.
1897 *
1898 * We can fit twice as may pxd's as xads in the lock
1882 */ 1899 */
1883 xadlock->xdlist = &xtlck->pxdlock; 1900 xadlock->flag = mlckFREEPXDLIST;
1884 memcpy(xadlock->xdlist, &p->xad[XTENTRYSTART], 1901 pxd = xadlock->xdlist = &xtlck->pxdlock;
1885 sizeof(xad_t) * xadlock->count); 1902 for (i = 0; i < xadlock->count; i++) {
1903 PXDaddress(pxd,
1904 addressXAD(&p->xad[XTENTRYSTART + i]));
1905 PXDlength(pxd,
1906 lengthXAD(&p->xad[XTENTRYSTART + i]));
1907 pxd++;
1908 }
1886 } else { 1909 } else {
1887 /* 1910 /*
1888 * xdlist will point to into inode's xtree, ensure 1911 * xdlist will point to into inode's xtree, ensure
1889 * that transaction is not committed lazily. 1912 * that transaction is not committed lazily.
1890 */ 1913 */
1914 xadlock->flag = mlckFREEXADLIST;
1891 xadlock->xdlist = &p->xad[XTENTRYSTART]; 1915 xadlock->xdlist = &p->xad[XTENTRYSTART];
1892 tblk->xflag &= ~COMMIT_LAZY; 1916 tblk->xflag &= ~COMMIT_LAZY;
1893 } 1917 }
@@ -1918,7 +1942,7 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
1918 * header ? 1942 * header ?
1919 */ 1943 */
1920 if (tlck->type & tlckTRUNCATE) { 1944 if (tlck->type & tlckTRUNCATE) {
1921 pxd_t tpxd; /* truncated extent of xad */ 1945 pxd_t pxd; /* truncated extent of xad */
1922 int twm; 1946 int twm;
1923 1947
1924 /* 1948 /*
@@ -1947,8 +1971,9 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
1947 * applying the after-image to the meta-data page. 1971 * applying the after-image to the meta-data page.
1948 */ 1972 */
1949 lrd->type = cpu_to_le16(LOG_REDOPAGE); 1973 lrd->type = cpu_to_le16(LOG_REDOPAGE);
1950 PXDaddress(pxd, mp->index); 1974 PXDaddress(page_pxd, mp->index);
1951 PXDlength(pxd, mp->logical_size >> tblk->sb->s_blocksize_bits); 1975 PXDlength(page_pxd,
1976 mp->logical_size >> tblk->sb->s_blocksize_bits);
1952 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, tlck)); 1977 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, tlck));
1953 1978
1954 /* 1979 /*
@@ -1966,7 +1991,7 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
1966 lrd->log.updatemap.type = cpu_to_le16(LOG_FREEPXD); 1991 lrd->log.updatemap.type = cpu_to_le16(LOG_FREEPXD);
1967 lrd->log.updatemap.nxd = cpu_to_le16(1); 1992 lrd->log.updatemap.nxd = cpu_to_le16(1);
1968 lrd->log.updatemap.pxd = pxdlock->pxd; 1993 lrd->log.updatemap.pxd = pxdlock->pxd;
1969 tpxd = pxdlock->pxd; /* save to format maplock */ 1994 pxd = pxdlock->pxd; /* save to format maplock */
1970 lrd->backchain = 1995 lrd->backchain =
1971 cpu_to_le32(lmLog(log, tblk, lrd, NULL)); 1996 cpu_to_le32(lmLog(log, tblk, lrd, NULL));
1972 } 1997 }
@@ -2035,7 +2060,7 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
2035 pxdlock = (struct pxd_lock *) xadlock; 2060 pxdlock = (struct pxd_lock *) xadlock;
2036 pxdlock->flag = mlckFREEPXD; 2061 pxdlock->flag = mlckFREEPXD;
2037 pxdlock->count = 1; 2062 pxdlock->count = 1;
2038 pxdlock->pxd = tpxd; 2063 pxdlock->pxd = pxd;
2039 2064
2040 jfs_info("xtLog: truncate ip:0x%p mp:0x%p count:%d " 2065 jfs_info("xtLog: truncate ip:0x%p mp:0x%p count:%d "
2041 "hwm:%d", ip, mp, pxdlock->count, hwm); 2066 "hwm:%d", ip, mp, pxdlock->count, hwm);
@@ -2253,7 +2278,8 @@ void txForce(struct tblock * tblk)
2253 tlck->flag &= ~tlckWRITEPAGE; 2278 tlck->flag &= ~tlckWRITEPAGE;
2254 2279
2255 /* do not release page to freelist */ 2280 /* do not release page to freelist */
2256 2281 force_metapage(mp);
2282#if 0
2257 /* 2283 /*
2258 * The "right" thing to do here is to 2284 * The "right" thing to do here is to
2259 * synchronously write the metadata. 2285 * synchronously write the metadata.
@@ -2265,9 +2291,10 @@ void txForce(struct tblock * tblk)
2265 * we can get by with synchronously writing 2291 * we can get by with synchronously writing
2266 * the pages when they are released. 2292 * the pages when they are released.
2267 */ 2293 */
2268 assert(atomic_read(&mp->nohomeok)); 2294 assert(mp->nohomeok);
2269 set_bit(META_dirty, &mp->flag); 2295 set_bit(META_dirty, &mp->flag);
2270 set_bit(META_sync, &mp->flag); 2296 set_bit(META_sync, &mp->flag);
2297#endif
2271 } 2298 }
2272 } 2299 }
2273 } 2300 }
@@ -2327,7 +2354,7 @@ static void txUpdateMap(struct tblock * tblk)
2327 */ 2354 */
2328 mp = tlck->mp; 2355 mp = tlck->mp;
2329 ASSERT(mp->xflag & COMMIT_PAGE); 2356 ASSERT(mp->xflag & COMMIT_PAGE);
2330 hold_metapage(mp, 0); 2357 grab_metapage(mp);
2331 } 2358 }
2332 2359
2333 /* 2360 /*
@@ -2377,8 +2404,8 @@ static void txUpdateMap(struct tblock * tblk)
2377 ASSERT(mp->lid == lid); 2404 ASSERT(mp->lid == lid);
2378 tlck->mp->lid = 0; 2405 tlck->mp->lid = 0;
2379 } 2406 }
2380 assert(atomic_read(&mp->nohomeok) == 1); 2407 assert(mp->nohomeok == 1);
2381 atomic_dec(&mp->nohomeok); 2408 metapage_homeok(mp);
2382 discard_metapage(mp); 2409 discard_metapage(mp);
2383 tlck->mp = NULL; 2410 tlck->mp = NULL;
2384 } 2411 }
@@ -2844,24 +2871,9 @@ static void LogSyncRelease(struct metapage * mp)
2844{ 2871{
2845 struct jfs_log *log = mp->log; 2872 struct jfs_log *log = mp->log;
2846 2873
2847 assert(atomic_read(&mp->nohomeok)); 2874 assert(mp->nohomeok);
2848 assert(log); 2875 assert(log);
2849 atomic_dec(&mp->nohomeok); 2876 metapage_homeok(mp);
2850
2851 if (atomic_read(&mp->nohomeok))
2852 return;
2853
2854 hold_metapage(mp, 0);
2855
2856 LOGSYNC_LOCK(log);
2857 mp->log = NULL;
2858 mp->lsn = 0;
2859 mp->clsn = 0;
2860 log->count--;
2861 list_del_init(&mp->synclist);
2862 LOGSYNC_UNLOCK(log);
2863
2864 release_metapage(mp);
2865} 2877}
2866 2878
2867/* 2879/*
diff --git a/fs/jfs/jfs_umount.c b/fs/jfs/jfs_umount.c
index f31a9e3f3fec..5cf91785b541 100644
--- a/fs/jfs/jfs_umount.c
+++ b/fs/jfs/jfs_umount.c
@@ -49,7 +49,6 @@
49 */ 49 */
50int jfs_umount(struct super_block *sb) 50int jfs_umount(struct super_block *sb)
51{ 51{
52 struct address_space *bdev_mapping = sb->s_bdev->bd_inode->i_mapping;
53 struct jfs_sb_info *sbi = JFS_SBI(sb); 52 struct jfs_sb_info *sbi = JFS_SBI(sb);
54 struct inode *ipbmap = sbi->ipbmap; 53 struct inode *ipbmap = sbi->ipbmap;
55 struct inode *ipimap = sbi->ipimap; 54 struct inode *ipimap = sbi->ipimap;
@@ -109,8 +108,8 @@ int jfs_umount(struct super_block *sb)
109 * Make sure all metadata makes it to disk before we mark 108 * Make sure all metadata makes it to disk before we mark
110 * the superblock as clean 109 * the superblock as clean
111 */ 110 */
112 filemap_fdatawrite(bdev_mapping); 111 filemap_fdatawrite(sbi->direct_inode->i_mapping);
113 filemap_fdatawait(bdev_mapping); 112 filemap_fdatawait(sbi->direct_inode->i_mapping);
114 113
115 /* 114 /*
116 * ensure all file system file pages are propagated to their 115 * ensure all file system file pages are propagated to their
@@ -123,9 +122,6 @@ int jfs_umount(struct super_block *sb)
123 if (log) { /* log = NULL if read-only mount */ 122 if (log) { /* log = NULL if read-only mount */
124 updateSuper(sb, FM_CLEAN); 123 updateSuper(sb, FM_CLEAN);
125 124
126 /* Restore default gfp_mask for bdev */
127 mapping_set_gfp_mask(bdev_mapping, GFP_USER);
128
129 /* 125 /*
130 * close log: 126 * close log:
131 * 127 *
@@ -140,7 +136,6 @@ int jfs_umount(struct super_block *sb)
140 136
141int jfs_umount_rw(struct super_block *sb) 137int jfs_umount_rw(struct super_block *sb)
142{ 138{
143 struct address_space *bdev_mapping = sb->s_bdev->bd_inode->i_mapping;
144 struct jfs_sb_info *sbi = JFS_SBI(sb); 139 struct jfs_sb_info *sbi = JFS_SBI(sb);
145 struct jfs_log *log = sbi->log; 140 struct jfs_log *log = sbi->log;
146 141
@@ -166,13 +161,10 @@ int jfs_umount_rw(struct super_block *sb)
166 * mark the superblock clean before everything is flushed to 161 * mark the superblock clean before everything is flushed to
167 * disk. 162 * disk.
168 */ 163 */
169 filemap_fdatawrite(bdev_mapping); 164 filemap_fdatawrite(sbi->direct_inode->i_mapping);
170 filemap_fdatawait(bdev_mapping); 165 filemap_fdatawait(sbi->direct_inode->i_mapping);
171 166
172 updateSuper(sb, FM_CLEAN); 167 updateSuper(sb, FM_CLEAN);
173 168
174 /* Restore default gfp_mask for bdev */
175 mapping_set_gfp_mask(bdev_mapping, GFP_USER);
176
177 return lmLogClose(sb); 169 return lmLogClose(sb);
178} 170}
diff --git a/fs/jfs/jfs_xtree.c b/fs/jfs/jfs_xtree.c
index 11c58c54b818..31b34db4519e 100644
--- a/fs/jfs/jfs_xtree.c
+++ b/fs/jfs/jfs_xtree.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) International Business Machines Corp., 2000-2004 2 * Copyright (C) International Business Machines Corp., 2000-2005
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by 5 * it under the terms of the GNU General Public License as published by
@@ -111,8 +111,8 @@ static struct {
111/* 111/*
112 * forward references 112 * forward references
113 */ 113 */
114static int xtSearch(struct inode *ip, 114static int xtSearch(struct inode *ip, s64 xoff, s64 *next, int *cmpp,
115 s64 xoff, int *cmpp, struct btstack * btstack, int flag); 115 struct btstack * btstack, int flag);
116 116
117static int xtSplitUp(tid_t tid, 117static int xtSplitUp(tid_t tid,
118 struct inode *ip, 118 struct inode *ip,
@@ -159,11 +159,12 @@ int xtLookup(struct inode *ip, s64 lstart,
159 xtpage_t *p; 159 xtpage_t *p;
160 int index; 160 int index;
161 xad_t *xad; 161 xad_t *xad;
162 s64 size, xoff, xend; 162 s64 next, size, xoff, xend;
163 int xlen; 163 int xlen;
164 s64 xaddr; 164 s64 xaddr;
165 165
166 *plen = 0; 166 *paddr = 0;
167 *plen = llen;
167 168
168 if (!no_check) { 169 if (!no_check) {
169 /* is lookup offset beyond eof ? */ 170 /* is lookup offset beyond eof ? */
@@ -180,7 +181,7 @@ int xtLookup(struct inode *ip, s64 lstart,
180 * search for the xad entry covering the logical extent 181 * search for the xad entry covering the logical extent
181 */ 182 */
182//search: 183//search:
183 if ((rc = xtSearch(ip, lstart, &cmp, &btstack, 0))) { 184 if ((rc = xtSearch(ip, lstart, &next, &cmp, &btstack, 0))) {
184 jfs_err("xtLookup: xtSearch returned %d", rc); 185 jfs_err("xtLookup: xtSearch returned %d", rc);
185 return rc; 186 return rc;
186 } 187 }
@@ -198,8 +199,11 @@ int xtLookup(struct inode *ip, s64 lstart,
198 * lstart is a page start address, 199 * lstart is a page start address,
199 * i.e., lstart cannot start in a hole; 200 * i.e., lstart cannot start in a hole;
200 */ 201 */
201 if (cmp) 202 if (cmp) {
203 if (next)
204 *plen = min(next - lstart, llen);
202 goto out; 205 goto out;
206 }
203 207
204 /* 208 /*
205 * lxd covered by xad 209 * lxd covered by xad
@@ -284,7 +288,7 @@ int xtLookupList(struct inode *ip, struct lxdlist * lxdlist,
284 if (lstart >= size) 288 if (lstart >= size)
285 return 0; 289 return 0;
286 290
287 if ((rc = xtSearch(ip, lstart, &cmp, &btstack, 0))) 291 if ((rc = xtSearch(ip, lstart, NULL, &cmp, &btstack, 0)))
288 return rc; 292 return rc;
289 293
290 /* 294 /*
@@ -488,6 +492,7 @@ int xtLookupList(struct inode *ip, struct lxdlist * lxdlist,
488 * parameters: 492 * parameters:
489 * ip - file object; 493 * ip - file object;
490 * xoff - extent offset; 494 * xoff - extent offset;
495 * nextp - address of next extent (if any) for search miss
491 * cmpp - comparison result: 496 * cmpp - comparison result:
492 * btstack - traverse stack; 497 * btstack - traverse stack;
493 * flag - search process flag (XT_INSERT); 498 * flag - search process flag (XT_INSERT);
@@ -497,7 +502,7 @@ int xtLookupList(struct inode *ip, struct lxdlist * lxdlist,
497 * *cmpp is set to result of comparison with the entry returned. 502 * *cmpp is set to result of comparison with the entry returned.
498 * the page containing the entry is pinned at exit. 503 * the page containing the entry is pinned at exit.
499 */ 504 */
500static int xtSearch(struct inode *ip, s64 xoff, /* offset of extent */ 505static int xtSearch(struct inode *ip, s64 xoff, s64 *nextp,
501 int *cmpp, struct btstack * btstack, int flag) 506 int *cmpp, struct btstack * btstack, int flag)
502{ 507{
503 struct jfs_inode_info *jfs_ip = JFS_IP(ip); 508 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
@@ -511,6 +516,7 @@ static int xtSearch(struct inode *ip, s64 xoff, /* offset of extent */
511 struct btframe *btsp; 516 struct btframe *btsp;
512 int nsplit = 0; /* number of pages to split */ 517 int nsplit = 0; /* number of pages to split */
513 s64 t64; 518 s64 t64;
519 s64 next = 0;
514 520
515 INCREMENT(xtStat.search); 521 INCREMENT(xtStat.search);
516 522
@@ -579,6 +585,7 @@ static int xtSearch(struct inode *ip, s64 xoff, /* offset of extent */
579 * previous and this entry 585 * previous and this entry
580 */ 586 */
581 *cmpp = 1; 587 *cmpp = 1;
588 next = t64;
582 goto out; 589 goto out;
583 } 590 }
584 591
@@ -623,6 +630,9 @@ static int xtSearch(struct inode *ip, s64 xoff, /* offset of extent */
623 /* update sequential access heuristics */ 630 /* update sequential access heuristics */
624 jfs_ip->btindex = index; 631 jfs_ip->btindex = index;
625 632
633 if (nextp)
634 *nextp = next;
635
626 INCREMENT(xtStat.fastSearch); 636 INCREMENT(xtStat.fastSearch);
627 return 0; 637 return 0;
628 } 638 }
@@ -675,10 +685,11 @@ static int xtSearch(struct inode *ip, s64 xoff, /* offset of extent */
675 685
676 return 0; 686 return 0;
677 } 687 }
678
679 /* search hit - internal page: 688 /* search hit - internal page:
680 * descend/search its child page 689 * descend/search its child page
681 */ 690 */
691 if (index < le16_to_cpu(p->header.nextindex)-1)
692 next = offsetXAD(&p->xad[index + 1]);
682 goto next; 693 goto next;
683 } 694 }
684 695
@@ -694,6 +705,8 @@ static int xtSearch(struct inode *ip, s64 xoff, /* offset of extent */
694 * base is the smallest index with key (Kj) greater than 705 * base is the smallest index with key (Kj) greater than
695 * search key (K) and may be zero or maxentry index. 706 * search key (K) and may be zero or maxentry index.
696 */ 707 */
708 if (base < le16_to_cpu(p->header.nextindex))
709 next = offsetXAD(&p->xad[base]);
697 /* 710 /*
698 * search miss - leaf page: 711 * search miss - leaf page:
699 * 712 *
@@ -727,6 +740,9 @@ static int xtSearch(struct inode *ip, s64 xoff, /* offset of extent */
727 jfs_ip->btorder = BT_RANDOM; 740 jfs_ip->btorder = BT_RANDOM;
728 jfs_ip->btindex = base; 741 jfs_ip->btindex = base;
729 742
743 if (nextp)
744 *nextp = next;
745
730 return 0; 746 return 0;
731 } 747 }
732 748
@@ -793,6 +809,7 @@ int xtInsert(tid_t tid, /* transaction id */
793 struct xtsplit split; /* split information */ 809 struct xtsplit split; /* split information */
794 xad_t *xad; 810 xad_t *xad;
795 int cmp; 811 int cmp;
812 s64 next;
796 struct tlock *tlck; 813 struct tlock *tlck;
797 struct xtlock *xtlck; 814 struct xtlock *xtlck;
798 815
@@ -806,7 +823,7 @@ int xtInsert(tid_t tid, /* transaction id */
806 * n.b. xtSearch() may return index of maxentry of 823 * n.b. xtSearch() may return index of maxentry of
807 * the full page. 824 * the full page.
808 */ 825 */
809 if ((rc = xtSearch(ip, xoff, &cmp, &btstack, XT_INSERT))) 826 if ((rc = xtSearch(ip, xoff, &next, &cmp, &btstack, XT_INSERT)))
810 return rc; 827 return rc;
811 828
812 /* retrieve search result */ 829 /* retrieve search result */
@@ -814,7 +831,7 @@ int xtInsert(tid_t tid, /* transaction id */
814 831
815 /* This test must follow XT_GETSEARCH since mp must be valid if 832 /* This test must follow XT_GETSEARCH since mp must be valid if
816 * we branch to out: */ 833 * we branch to out: */
817 if (cmp == 0) { 834 if ((cmp == 0) || (next && (xlen > next - xoff))) {
818 rc = -EEXIST; 835 rc = -EEXIST;
819 goto out; 836 goto out;
820 } 837 }
@@ -1626,7 +1643,7 @@ int xtExtend(tid_t tid, /* transaction id */
1626 jfs_info("xtExtend: nxoff:0x%lx nxlen:0x%x", (ulong) xoff, xlen); 1643 jfs_info("xtExtend: nxoff:0x%lx nxlen:0x%x", (ulong) xoff, xlen);
1627 1644
1628 /* there must exist extent to be extended */ 1645 /* there must exist extent to be extended */
1629 if ((rc = xtSearch(ip, xoff - 1, &cmp, &btstack, XT_INSERT))) 1646 if ((rc = xtSearch(ip, xoff - 1, NULL, &cmp, &btstack, XT_INSERT)))
1630 return rc; 1647 return rc;
1631 1648
1632 /* retrieve search result */ 1649 /* retrieve search result */
@@ -1794,7 +1811,7 @@ printf("xtTailgate: nxoff:0x%lx nxlen:0x%x nxaddr:0x%lx\n",
1794*/ 1811*/
1795 1812
1796 /* there must exist extent to be tailgated */ 1813 /* there must exist extent to be tailgated */
1797 if ((rc = xtSearch(ip, xoff, &cmp, &btstack, XT_INSERT))) 1814 if ((rc = xtSearch(ip, xoff, NULL, &cmp, &btstack, XT_INSERT)))
1798 return rc; 1815 return rc;
1799 1816
1800 /* retrieve search result */ 1817 /* retrieve search result */
@@ -1977,7 +1994,7 @@ int xtUpdate(tid_t tid, struct inode *ip, xad_t * nxad)
1977 nxlen = lengthXAD(nxad); 1994 nxlen = lengthXAD(nxad);
1978 nxaddr = addressXAD(nxad); 1995 nxaddr = addressXAD(nxad);
1979 1996
1980 if ((rc = xtSearch(ip, nxoff, &cmp, &btstack, XT_INSERT))) 1997 if ((rc = xtSearch(ip, nxoff, NULL, &cmp, &btstack, XT_INSERT)))
1981 return rc; 1998 return rc;
1982 1999
1983 /* retrieve search result */ 2000 /* retrieve search result */
@@ -2291,7 +2308,7 @@ int xtUpdate(tid_t tid, struct inode *ip, xad_t * nxad)
2291 if (nextindex == le16_to_cpu(p->header.maxentry)) { 2308 if (nextindex == le16_to_cpu(p->header.maxentry)) {
2292 XT_PUTPAGE(mp); 2309 XT_PUTPAGE(mp);
2293 2310
2294 if ((rc = xtSearch(ip, nxoff, &cmp, &btstack, XT_INSERT))) 2311 if ((rc = xtSearch(ip, nxoff, NULL, &cmp, &btstack, XT_INSERT)))
2295 return rc; 2312 return rc;
2296 2313
2297 /* retrieve search result */ 2314 /* retrieve search result */
@@ -2438,6 +2455,7 @@ int xtAppend(tid_t tid, /* transaction id */
2438 int nsplit, nblocks, xlen; 2455 int nsplit, nblocks, xlen;
2439 struct pxdlist pxdlist; 2456 struct pxdlist pxdlist;
2440 pxd_t *pxd; 2457 pxd_t *pxd;
2458 s64 next;
2441 2459
2442 xaddr = *xaddrp; 2460 xaddr = *xaddrp;
2443 xlen = *xlenp; 2461 xlen = *xlenp;
@@ -2452,7 +2470,7 @@ int xtAppend(tid_t tid, /* transaction id */
2452 * n.b. xtSearch() may return index of maxentry of 2470 * n.b. xtSearch() may return index of maxentry of
2453 * the full page. 2471 * the full page.
2454 */ 2472 */
2455 if ((rc = xtSearch(ip, xoff, &cmp, &btstack, XT_INSERT))) 2473 if ((rc = xtSearch(ip, xoff, &next, &cmp, &btstack, XT_INSERT)))
2456 return rc; 2474 return rc;
2457 2475
2458 /* retrieve search result */ 2476 /* retrieve search result */
@@ -2462,6 +2480,9 @@ int xtAppend(tid_t tid, /* transaction id */
2462 rc = -EEXIST; 2480 rc = -EEXIST;
2463 goto out; 2481 goto out;
2464 } 2482 }
2483
2484 if (next)
2485 xlen = min(xlen, (int)(next - xoff));
2465//insert: 2486//insert:
2466 /* 2487 /*
2467 * insert entry for new extent 2488 * insert entry for new extent
@@ -2600,7 +2621,7 @@ int xtDelete(tid_t tid, struct inode *ip, s64 xoff, s32 xlen, int flag)
2600 /* 2621 /*
2601 * find the matching entry; xtSearch() pins the page 2622 * find the matching entry; xtSearch() pins the page
2602 */ 2623 */
2603 if ((rc = xtSearch(ip, xoff, &cmp, &btstack, 0))) 2624 if ((rc = xtSearch(ip, xoff, NULL, &cmp, &btstack, 0)))
2604 return rc; 2625 return rc;
2605 2626
2606 XT_GETSEARCH(ip, btstack.top, bn, mp, p, index); 2627 XT_GETSEARCH(ip, btstack.top, bn, mp, p, index);
@@ -2852,7 +2873,7 @@ xtRelocate(tid_t tid, struct inode * ip, xad_t * oxad, /* old XAD */
2852 */ 2873 */
2853 if (xtype == DATAEXT) { 2874 if (xtype == DATAEXT) {
2854 /* search in leaf entry */ 2875 /* search in leaf entry */
2855 rc = xtSearch(ip, xoff, &cmp, &btstack, 0); 2876 rc = xtSearch(ip, xoff, NULL, &cmp, &btstack, 0);
2856 if (rc) 2877 if (rc)
2857 return rc; 2878 return rc;
2858 2879
@@ -2958,7 +2979,7 @@ xtRelocate(tid_t tid, struct inode * ip, xad_t * oxad, /* old XAD */
2958 } 2979 }
2959 2980
2960 /* get back parent page */ 2981 /* get back parent page */
2961 if ((rc = xtSearch(ip, xoff, &cmp, &btstack, 0))) 2982 if ((rc = xtSearch(ip, xoff, NULL, &cmp, &btstack, 0)))
2962 return rc; 2983 return rc;
2963 2984
2964 XT_GETSEARCH(ip, btstack.top, bn, pmp, pp, index); 2985 XT_GETSEARCH(ip, btstack.top, bn, pmp, pp, index);
@@ -3991,7 +4012,7 @@ s64 xtTruncate_pmap(tid_t tid, struct inode *ip, s64 committed_size)
3991 4012
3992 if (committed_size) { 4013 if (committed_size) {
3993 xoff = (committed_size >> JFS_SBI(ip->i_sb)->l2bsize) - 1; 4014 xoff = (committed_size >> JFS_SBI(ip->i_sb)->l2bsize) - 1;
3994 rc = xtSearch(ip, xoff, &cmp, &btstack, 0); 4015 rc = xtSearch(ip, xoff, NULL, &cmp, &btstack, 0);
3995 if (rc) 4016 if (rc)
3996 return rc; 4017 return rc;
3997 4018
diff --git a/fs/jfs/resize.c b/fs/jfs/resize.c
index 2eb6869b6e72..c6dc254d3253 100644
--- a/fs/jfs/resize.c
+++ b/fs/jfs/resize.c
@@ -209,6 +209,9 @@ int jfs_extendfs(struct super_block *sb, s64 newLVSize, int newLogSize)
209 */ 209 */
210 txQuiesce(sb); 210 txQuiesce(sb);
211 211
212 /* Reset size of direct inode */
213 sbi->direct_inode->i_size = sb->s_bdev->bd_inode->i_size;
214
212 if (sbi->mntflag & JFS_INLINELOG) { 215 if (sbi->mntflag & JFS_INLINELOG) {
213 /* 216 /*
214 * deactivate old inline log 217 * deactivate old inline log
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index 5856866e24fc..5e774ed7fb64 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -210,6 +210,10 @@ static void jfs_put_super(struct super_block *sb)
210 unload_nls(sbi->nls_tab); 210 unload_nls(sbi->nls_tab);
211 sbi->nls_tab = NULL; 211 sbi->nls_tab = NULL;
212 212
213 truncate_inode_pages(sbi->direct_inode->i_mapping, 0);
214 iput(sbi->direct_inode);
215 sbi->direct_inode = NULL;
216
213 kfree(sbi); 217 kfree(sbi);
214} 218}
215 219
@@ -358,6 +362,12 @@ static int jfs_remount(struct super_block *sb, int *flags, char *data)
358 } 362 }
359 363
360 if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) { 364 if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) {
365 /*
366 * Invalidate any previously read metadata. fsck may have
367 * changed the on-disk data since we mounted r/o
368 */
369 truncate_inode_pages(JFS_SBI(sb)->direct_inode->i_mapping, 0);
370
361 JFS_SBI(sb)->flag = flag; 371 JFS_SBI(sb)->flag = flag;
362 return jfs_mount_rw(sb, 1); 372 return jfs_mount_rw(sb, 1);
363 } 373 }
@@ -428,12 +438,26 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)
428 sb->s_op = &jfs_super_operations; 438 sb->s_op = &jfs_super_operations;
429 sb->s_export_op = &jfs_export_operations; 439 sb->s_export_op = &jfs_export_operations;
430 440
441 /*
442 * Initialize direct-mapping inode/address-space
443 */
444 inode = new_inode(sb);
445 if (inode == NULL)
446 goto out_kfree;
447 inode->i_ino = 0;
448 inode->i_nlink = 1;
449 inode->i_size = sb->s_bdev->bd_inode->i_size;
450 inode->i_mapping->a_ops = &jfs_metapage_aops;
451 mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS);
452
453 sbi->direct_inode = inode;
454
431 rc = jfs_mount(sb); 455 rc = jfs_mount(sb);
432 if (rc) { 456 if (rc) {
433 if (!silent) { 457 if (!silent) {
434 jfs_err("jfs_mount failed w/return code = %d", rc); 458 jfs_err("jfs_mount failed w/return code = %d", rc);
435 } 459 }
436 goto out_kfree; 460 goto out_mount_failed;
437 } 461 }
438 if (sb->s_flags & MS_RDONLY) 462 if (sb->s_flags & MS_RDONLY)
439 sbi->log = NULL; 463 sbi->log = NULL;
@@ -482,6 +506,13 @@ out_no_rw:
482 if (rc) { 506 if (rc) {
483 jfs_err("jfs_umount failed with return code %d", rc); 507 jfs_err("jfs_umount failed with return code %d", rc);
484 } 508 }
509out_mount_failed:
510 filemap_fdatawrite(sbi->direct_inode->i_mapping);
511 filemap_fdatawait(sbi->direct_inode->i_mapping);
512 truncate_inode_pages(sbi->direct_inode->i_mapping, 0);
513 make_bad_inode(sbi->direct_inode);
514 iput(sbi->direct_inode);
515 sbi->direct_inode = NULL;
485out_kfree: 516out_kfree:
486 if (sbi->nls_tab) 517 if (sbi->nls_tab)
487 unload_nls(sbi->nls_tab); 518 unload_nls(sbi->nls_tab);
@@ -527,8 +558,10 @@ static int jfs_sync_fs(struct super_block *sb, int wait)
527 struct jfs_log *log = JFS_SBI(sb)->log; 558 struct jfs_log *log = JFS_SBI(sb)->log;
528 559
529 /* log == NULL indicates read-only mount */ 560 /* log == NULL indicates read-only mount */
530 if (log) 561 if (log) {
531 jfs_flush_journal(log, wait); 562 jfs_flush_journal(log, wait);
563 jfs_syncpt(log);
564 }
532 565
533 return 0; 566 return 0;
534} 567}
diff --git a/include/asm-alpha/signal.h b/include/asm-alpha/signal.h
index 4e0842b415aa..1a2c52a056fb 100644
--- a/include/asm-alpha/signal.h
+++ b/include/asm-alpha/signal.h
@@ -113,16 +113,7 @@ typedef unsigned long sigset_t;
113#define SIG_UNBLOCK 2 /* for unblocking signals */ 113#define SIG_UNBLOCK 2 /* for unblocking signals */
114#define SIG_SETMASK 3 /* for setting the signal mask */ 114#define SIG_SETMASK 3 /* for setting the signal mask */
115 115
116/* Type of a signal handler. */ 116#include <asm-generic/signal.h>
117typedef void __signalfn_t(int);
118typedef __signalfn_t __user *__sighandler_t;
119
120typedef void __restorefn_t(void);
121typedef __restorefn_t __user *__sigrestore_t;
122
123#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
124#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
125#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
126 117
127#ifdef __KERNEL__ 118#ifdef __KERNEL__
128struct osf_sigaction { 119struct osf_sigaction {
diff --git a/include/asm-arm/arch-cl7500/vmalloc.h b/include/asm-arm/arch-cl7500/vmalloc.h
index 91883def4889..ba8d7a84456a 100644
--- a/include/asm-arm/arch-cl7500/vmalloc.h
+++ b/include/asm-arm/arch-cl7500/vmalloc.h
@@ -1,15 +1,4 @@
1/* 1/*
2 * linux/include/asm-arm/arch-cl7500/vmalloc.h 2 * linux/include/asm-arm/arch-cl7500/vmalloc.h
3 */ 3 */
4
5/*
6 * Just any arbitrary offset to the start of the vmalloc VM area: the
7 * current 8MB value just means that there will be a 8MB "hole" after the
8 * physical memory until the kernel virtual memory starts. That means that
9 * any out-of-bounds memory accesses will hopefully be caught.
10 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
11 * area for the same reason. ;)
12 */
13#define VMALLOC_OFFSET (8*1024*1024)
14#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
15#define VMALLOC_END (PAGE_OFFSET + 0x1c000000) 4#define VMALLOC_END (PAGE_OFFSET + 0x1c000000)
diff --git a/include/asm-arm/arch-clps711x/vmalloc.h b/include/asm-arm/arch-clps711x/vmalloc.h
index 42571ed5e493..a5dfe96abc96 100644
--- a/include/asm-arm/arch-clps711x/vmalloc.h
+++ b/include/asm-arm/arch-clps711x/vmalloc.h
@@ -17,15 +17,4 @@
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21/*
22 * Just any arbitrary offset to the start of the vmalloc VM area: the
23 * current 8MB value just means that there will be a 8MB "hole" after the
24 * physical memory until the kernel virtual memory starts. That means that
25 * any out-of-bounds memory accesses will hopefully be caught.
26 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
27 * area for the same reason. ;)
28 */
29#define VMALLOC_OFFSET (8*1024*1024)
30#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
31#define VMALLOC_END (PAGE_OFFSET + 0x10000000) 20#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
diff --git a/include/asm-arm/arch-ebsa110/vmalloc.h b/include/asm-arm/arch-ebsa110/vmalloc.h
index 759659be109f..26674ba4683c 100644
--- a/include/asm-arm/arch-ebsa110/vmalloc.h
+++ b/include/asm-arm/arch-ebsa110/vmalloc.h
@@ -7,15 +7,4 @@
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10
11/*
12 * Just any arbitrary offset to the start of the vmalloc VM area: the
13 * current 8MB value just means that there will be a 8MB "hole" after the
14 * physical memory until the kernel virtual memory starts. That means that
15 * any out-of-bounds memory accesses will hopefully be caught.
16 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
17 * area for the same reason. ;)
18 */
19#define VMALLOC_OFFSET (8*1024*1024)
20#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
21#define VMALLOC_END (PAGE_OFFSET + 0x1f000000) 10#define VMALLOC_END (PAGE_OFFSET + 0x1f000000)
diff --git a/include/asm-arm/arch-ebsa285/vmalloc.h b/include/asm-arm/arch-ebsa285/vmalloc.h
index def705a3c209..d1ca955ce434 100644
--- a/include/asm-arm/arch-ebsa285/vmalloc.h
+++ b/include/asm-arm/arch-ebsa285/vmalloc.h
@@ -8,17 +8,6 @@
8 8
9#include <linux/config.h> 9#include <linux/config.h>
10 10
11/*
12 * Just any arbitrary offset to the start of the vmalloc VM area: the
13 * current 8MB value just means that there will be a 8MB "hole" after the
14 * physical memory until the kernel virtual memory starts. That means that
15 * any out-of-bounds memory accesses will hopefully be caught.
16 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
17 * area for the same reason. ;)
18 */
19#define VMALLOC_OFFSET (8*1024*1024)
20#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
21
22#ifdef CONFIG_ARCH_FOOTBRIDGE 11#ifdef CONFIG_ARCH_FOOTBRIDGE
23#define VMALLOC_END (PAGE_OFFSET + 0x30000000) 12#define VMALLOC_END (PAGE_OFFSET + 0x30000000)
24#else 13#else
diff --git a/include/asm-arm/arch-epxa10db/vmalloc.h b/include/asm-arm/arch-epxa10db/vmalloc.h
index d31ef8584760..546fb7d2b6ad 100644
--- a/include/asm-arm/arch-epxa10db/vmalloc.h
+++ b/include/asm-arm/arch-epxa10db/vmalloc.h
@@ -17,15 +17,4 @@
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21/*
22 * Just any arbitrary offset to the start of the vmalloc VM area: the
23 * current 8MB value just means that there will be a 8MB "hole" after the
24 * physical memory until the kernel virtual memory starts. That means that
25 * any out-of-bounds memory accesses will hopefully be caught.
26 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
27 * area for the same reason. ;)
28 */
29#define VMALLOC_OFFSET (8*1024*1024)
30#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
31#define VMALLOC_END (PAGE_OFFSET + 0x10000000) 20#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
diff --git a/include/asm-arm/arch-h720x/vmalloc.h b/include/asm-arm/arch-h720x/vmalloc.h
index 4af523a5e189..b4693cb821ef 100644
--- a/include/asm-arm/arch-h720x/vmalloc.h
+++ b/include/asm-arm/arch-h720x/vmalloc.h
@@ -5,17 +5,6 @@
5#ifndef __ARCH_ARM_VMALLOC_H 5#ifndef __ARCH_ARM_VMALLOC_H
6#define __ARCH_ARM_VMALLOC_H 6#define __ARCH_ARM_VMALLOC_H
7 7
8/*
9 * Just any arbitrary offset to the start of the vmalloc VM area: the
10 * current 8MB value just means that there will be a 8MB "hole" after the
11 * physical memory until the kernel virtual memory starts. That means that
12 * any out-of-bounds memory accesses will hopefully be caught.
13 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
14 * area for the same reason. ;)
15 */
16#define VMALLOC_OFFSET (8*1024*1024)
17#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
18#define VMALLOC_VMADDR(x) ((unsigned long)(x))
19#define VMALLOC_END (PAGE_OFFSET + 0x10000000) 8#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
20 9
21#endif 10#endif
diff --git a/include/asm-arm/arch-imx/vmalloc.h b/include/asm-arm/arch-imx/vmalloc.h
index 252038f48163..cb6169127068 100644
--- a/include/asm-arm/arch-imx/vmalloc.h
+++ b/include/asm-arm/arch-imx/vmalloc.h
@@ -17,16 +17,4 @@
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21/*
22 * Just any arbitrary offset to the start of the vmalloc VM area: the
23 * current 8MB value just means that there will be a 8MB "hole" after the
24 * physical memory until the kernel virtual memory starts. That means that
25 * any out-of-bounds memory accesses will hopefully be caught.
26 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
27 * area for the same reason. ;)
28 */
29#define VMALLOC_OFFSET (8*1024*1024)
30#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
31#define VMALLOC_VMADDR(x) ((unsigned long)(x))
32#define VMALLOC_END (PAGE_OFFSET + 0x10000000) 20#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
diff --git a/include/asm-arm/arch-integrator/platform.h b/include/asm-arm/arch-integrator/platform.h
index 6b67e41669f4..bd364f5a99bc 100644
--- a/include/asm-arm/arch-integrator/platform.h
+++ b/include/asm-arm/arch-integrator/platform.h
@@ -20,14 +20,14 @@
20 * * Copyright © ARM Limited 1998. All rights reserved. 20 * * Copyright © ARM Limited 1998. All rights reserved.
21 * ***********************************************************************/ 21 * ***********************************************************************/
22/* ************************************************************************ 22/* ************************************************************************
23 * 23 *
24 * Integrator address map 24 * Integrator address map
25 * 25 *
26 * NOTE: This is a multi-hosted header file for use with uHAL and 26 * NOTE: This is a multi-hosted header file for use with uHAL and
27 * supported debuggers. 27 * supported debuggers.
28 * 28 *
29 * $Id: platform.s,v 1.32 2000/02/18 10:51:39 asims Exp $ 29 * $Id: platform.s,v 1.32 2000/02/18 10:51:39 asims Exp $
30 * 30 *
31 * ***********************************************************************/ 31 * ***********************************************************************/
32 32
33#ifndef __address_h 33#ifndef __address_h
@@ -40,22 +40,22 @@
40 * Memory definitions 40 * Memory definitions
41 * ------------------------------------------------------------------------ 41 * ------------------------------------------------------------------------
42 * Integrator memory map 42 * Integrator memory map
43 * 43 *
44 */ 44 */
45#define INTEGRATOR_BOOT_ROM_LO 0x00000000 45#define INTEGRATOR_BOOT_ROM_LO 0x00000000
46#define INTEGRATOR_BOOT_ROM_HI 0x20000000 46#define INTEGRATOR_BOOT_ROM_HI 0x20000000
47#define INTEGRATOR_BOOT_ROM_BASE INTEGRATOR_BOOT_ROM_HI /* Normal position */ 47#define INTEGRATOR_BOOT_ROM_BASE INTEGRATOR_BOOT_ROM_HI /* Normal position */
48#define INTEGRATOR_BOOT_ROM_SIZE SZ_512K 48#define INTEGRATOR_BOOT_ROM_SIZE SZ_512K
49 49
50/* 50/*
51 * New Core Modules have different amounts of SSRAM, the amount of SSRAM 51 * New Core Modules have different amounts of SSRAM, the amount of SSRAM
52 * fitted can be found in HDR_STAT. 52 * fitted can be found in HDR_STAT.
53 * 53 *
54 * The symbol INTEGRATOR_SSRAM_SIZE is kept, however this now refers to 54 * The symbol INTEGRATOR_SSRAM_SIZE is kept, however this now refers to
55 * the minimum amount of SSRAM fitted on any core module. 55 * the minimum amount of SSRAM fitted on any core module.
56 * 56 *
57 * New Core Modules also alias the SSRAM. 57 * New Core Modules also alias the SSRAM.
58 * 58 *
59 */ 59 */
60#define INTEGRATOR_SSRAM_BASE 0x00000000 60#define INTEGRATOR_SSRAM_BASE 0x00000000
61#define INTEGRATOR_SSRAM_ALIAS_BASE 0x10800000 61#define INTEGRATOR_SSRAM_ALIAS_BASE 0x10800000
@@ -67,9 +67,9 @@
67#define INTEGRATOR_MBRD_SSRAM_BASE 0x28000000 67#define INTEGRATOR_MBRD_SSRAM_BASE 0x28000000
68#define INTEGRATOR_MBRD_SSRAM_SIZE SZ_512K 68#define INTEGRATOR_MBRD_SSRAM_SIZE SZ_512K
69 69
70/* 70/*
71 * SDRAM is a SIMM therefore the size is not known. 71 * SDRAM is a SIMM therefore the size is not known.
72 * 72 *
73 */ 73 */
74#define INTEGRATOR_SDRAM_BASE 0x00040000 74#define INTEGRATOR_SDRAM_BASE 0x00040000
75 75
@@ -79,9 +79,9 @@
79#define INTEGRATOR_HDR2_SDRAM_BASE 0xA0000000 79#define INTEGRATOR_HDR2_SDRAM_BASE 0xA0000000
80#define INTEGRATOR_HDR3_SDRAM_BASE 0xB0000000 80#define INTEGRATOR_HDR3_SDRAM_BASE 0xB0000000
81 81
82/* 82/*
83 * Logic expansion modules 83 * Logic expansion modules
84 * 84 *
85 */ 85 */
86#define INTEGRATOR_LOGIC_MODULES_BASE 0xC0000000 86#define INTEGRATOR_LOGIC_MODULES_BASE 0xC0000000
87#define INTEGRATOR_LOGIC_MODULE0_BASE 0xC0000000 87#define INTEGRATOR_LOGIC_MODULE0_BASE 0xC0000000
@@ -92,7 +92,7 @@
92/* ------------------------------------------------------------------------ 92/* ------------------------------------------------------------------------
93 * Integrator header card registers 93 * Integrator header card registers
94 * ------------------------------------------------------------------------ 94 * ------------------------------------------------------------------------
95 * 95 *
96 */ 96 */
97#define INTEGRATOR_HDR_ID_OFFSET 0x00 97#define INTEGRATOR_HDR_ID_OFFSET 0x00
98#define INTEGRATOR_HDR_PROC_OFFSET 0x04 98#define INTEGRATOR_HDR_PROC_OFFSET 0x04
@@ -185,12 +185,12 @@
185/* ------------------------------------------------------------------------ 185/* ------------------------------------------------------------------------
186 * Integrator system registers 186 * Integrator system registers
187 * ------------------------------------------------------------------------ 187 * ------------------------------------------------------------------------
188 * 188 *
189 */ 189 */
190 190
191/* 191/*
192 * System Controller 192 * System Controller
193 * 193 *
194 */ 194 */
195#define INTEGRATOR_SC_ID_OFFSET 0x00 195#define INTEGRATOR_SC_ID_OFFSET 0x00
196#define INTEGRATOR_SC_OSC_OFFSET 0x04 196#define INTEGRATOR_SC_OSC_OFFSET 0x04
@@ -230,11 +230,11 @@
230#define INTEGRATOR_SC_CTRL_URTS1 (1 << 6) 230#define INTEGRATOR_SC_CTRL_URTS1 (1 << 6)
231#define INTEGRATOR_SC_CTRL_UDTR1 (1 << 7) 231#define INTEGRATOR_SC_CTRL_UDTR1 (1 << 7)
232 232
233/* 233/*
234 * External Bus Interface 234 * External Bus Interface
235 * 235 *
236 */ 236 */
237#define INTEGRATOR_EBI_BASE 0x12000000 237#define INTEGRATOR_EBI_BASE 0x12000000
238 238
239#define INTEGRATOR_EBI_CSR0_OFFSET 0x00 239#define INTEGRATOR_EBI_CSR0_OFFSET 0x00
240#define INTEGRATOR_EBI_CSR1_OFFSET 0x04 240#define INTEGRATOR_EBI_CSR1_OFFSET 0x04
@@ -279,9 +279,9 @@
279#define INTEGRATOR_KBD_BASE 0x18000000 /* Keyboard */ 279#define INTEGRATOR_KBD_BASE 0x18000000 /* Keyboard */
280#define INTEGRATOR_MOUSE_BASE 0x19000000 /* Mouse */ 280#define INTEGRATOR_MOUSE_BASE 0x19000000 /* Mouse */
281 281
282/* 282/*
283 * LED's & Switches 283 * LED's & Switches
284 * 284 *
285 */ 285 */
286#define INTEGRATOR_DBG_ALPHA_OFFSET 0x00 286#define INTEGRATOR_DBG_ALPHA_OFFSET 0x00
287#define INTEGRATOR_DBG_LEDS_OFFSET 0x04 287#define INTEGRATOR_DBG_LEDS_OFFSET 0x04
@@ -300,7 +300,7 @@
300 * ------------------------------------------------------------------------ 300 * ------------------------------------------------------------------------
301 */ 301 */
302/* PS2 Keyboard interface */ 302/* PS2 Keyboard interface */
303#define KMI0_BASE INTEGRATOR_KBD_BASE 303#define KMI0_BASE INTEGRATOR_KBD_BASE
304 304
305/* PS2 Mouse interface */ 305/* PS2 Mouse interface */
306#define KMI1_BASE INTEGRATOR_MOUSE_BASE 306#define KMI1_BASE INTEGRATOR_MOUSE_BASE
@@ -313,7 +313,7 @@
313 * This represents a fairly liberal usage of address space. Even though 313 * This represents a fairly liberal usage of address space. Even though
314 * the V3 only has two windows (therefore we need to map stuff on the fly), 314 * the V3 only has two windows (therefore we need to map stuff on the fly),
315 * we maintain the same addresses, even if they're not mapped. 315 * we maintain the same addresses, even if they're not mapped.
316 * 316 *
317 */ 317 */
318#define PHYS_PCI_MEM_BASE 0x40000000 /* 512M to xxx */ 318#define PHYS_PCI_MEM_BASE 0x40000000 /* 512M to xxx */
319/* unused 256M from A0000000-AFFFFFFF might be used for I2O ??? 319/* unused 256M from A0000000-AFFFFFFF might be used for I2O ???
@@ -326,7 +326,7 @@
326 */ 326 */
327#define PHYS_PCI_V3_BASE 0x62000000 327#define PHYS_PCI_V3_BASE 0x62000000
328 328
329#define PCI_DRAMSIZE INTEGRATOR_SSRAM_SIZE 329#define PCI_DRAMSIZE INTEGRATOR_SSRAM_SIZE
330 330
331/* 'export' these to UHAL */ 331/* 'export' these to UHAL */
332#define UHAL_PCI_IO PCI_IO_BASE 332#define UHAL_PCI_IO PCI_IO_BASE
@@ -334,7 +334,7 @@
334#define UHAL_PCI_ALLOC_IO_BASE 0x00004000 334#define UHAL_PCI_ALLOC_IO_BASE 0x00004000
335#define UHAL_PCI_ALLOC_MEM_BASE PCI_MEM_BASE 335#define UHAL_PCI_ALLOC_MEM_BASE PCI_MEM_BASE
336#define UHAL_PCI_MAX_SLOT 20 336#define UHAL_PCI_MAX_SLOT 20
337 337
338/* ======================================================================== 338/* ========================================================================
339 * Start of uHAL definitions 339 * Start of uHAL definitions
340 * ======================================================================== 340 * ========================================================================
@@ -343,17 +343,17 @@
343/* ------------------------------------------------------------------------ 343/* ------------------------------------------------------------------------
344 * Integrator Interrupt Controllers 344 * Integrator Interrupt Controllers
345 * ------------------------------------------------------------------------ 345 * ------------------------------------------------------------------------
346 * 346 *
347 * Offsets from interrupt controller base 347 * Offsets from interrupt controller base
348 * 348 *
349 * System Controller interrupt controller base is 349 * System Controller interrupt controller base is
350 * 350 *
351 * INTEGRATOR_IC_BASE + (header_number << 6) 351 * INTEGRATOR_IC_BASE + (header_number << 6)
352 * 352 *
353 * Core Module interrupt controller base is 353 * Core Module interrupt controller base is
354 * 354 *
355 * INTEGRATOR_HDR_IC 355 * INTEGRATOR_HDR_IC
356 * 356 *
357 */ 357 */
358#define IRQ_STATUS 0 358#define IRQ_STATUS 0
359#define IRQ_RAW_STATUS 0x04 359#define IRQ_RAW_STATUS 0x04
@@ -374,22 +374,22 @@
374/* ------------------------------------------------------------------------ 374/* ------------------------------------------------------------------------
375 * Interrupts 375 * Interrupts
376 * ------------------------------------------------------------------------ 376 * ------------------------------------------------------------------------
377 * 377 *
378 * 378 *
379 * Each Core Module has two interrupts controllers, one on the core module 379 * Each Core Module has two interrupts controllers, one on the core module
380 * itself and one in the system controller on the motherboard. The 380 * itself and one in the system controller on the motherboard. The
381 * READ_INT macro in target.s reads both interrupt controllers and returns 381 * READ_INT macro in target.s reads both interrupt controllers and returns
382 * a 32 bit bitmask, bits 0 to 23 are interrupts from the system controller 382 * a 32 bit bitmask, bits 0 to 23 are interrupts from the system controller
383 * and bits 24 to 31 are from the core module. 383 * and bits 24 to 31 are from the core module.
384 * 384 *
385 * The following definitions relate to the bitmask returned by READ_INT. 385 * The following definitions relate to the bitmask returned by READ_INT.
386 * 386 *
387 */ 387 */
388 388
389/* ------------------------------------------------------------------------ 389/* ------------------------------------------------------------------------
390 * LED's - The header LED is not accessible via the uHAL API 390 * LED's - The header LED is not accessible via the uHAL API
391 * ------------------------------------------------------------------------ 391 * ------------------------------------------------------------------------
392 * 392 *
393 */ 393 */
394#define GREEN_LED 0x01 394#define GREEN_LED 0x01
395#define YELLOW_LED 0x02 395#define YELLOW_LED 0x02
@@ -399,44 +399,44 @@
399 399
400#define LED_BANK INTEGRATOR_DBG_LEDS 400#define LED_BANK INTEGRATOR_DBG_LEDS
401 401
402/* 402/*
403 * Memory definitions - run uHAL out of SSRAM. 403 * Memory definitions - run uHAL out of SSRAM.
404 * 404 *
405 */ 405 */
406#define uHAL_MEMORY_SIZE INTEGRATOR_SSRAM_SIZE 406#define uHAL_MEMORY_SIZE INTEGRATOR_SSRAM_SIZE
407 407
408/* 408/*
409 * Application Flash 409 * Application Flash
410 * 410 *
411 */ 411 */
412#define FLASH_BASE INTEGRATOR_FLASH_BASE 412#define FLASH_BASE INTEGRATOR_FLASH_BASE
413#define FLASH_SIZE INTEGRATOR_FLASH_SIZE 413#define FLASH_SIZE INTEGRATOR_FLASH_SIZE
414#define FLASH_END (FLASH_BASE + FLASH_SIZE - 1) 414#define FLASH_END (FLASH_BASE + FLASH_SIZE - 1)
415#define FLASH_BLOCK_SIZE SZ_128K 415#define FLASH_BLOCK_SIZE SZ_128K
416 416
417/* 417/*
418 * Boot Flash 418 * Boot Flash
419 * 419 *
420 */ 420 */
421#define EPROM_BASE INTEGRATOR_BOOT_ROM_HI 421#define EPROM_BASE INTEGRATOR_BOOT_ROM_HI
422#define EPROM_SIZE INTEGRATOR_BOOT_ROM_SIZE 422#define EPROM_SIZE INTEGRATOR_BOOT_ROM_SIZE
423#define EPROM_END (EPROM_BASE + EPROM_SIZE - 1) 423#define EPROM_END (EPROM_BASE + EPROM_SIZE - 1)
424 424
425/* 425/*
426 * Clean base - dummy 426 * Clean base - dummy
427 * 427 *
428 */ 428 */
429#define CLEAN_BASE EPROM_BASE 429#define CLEAN_BASE EPROM_BASE
430 430
431/* 431/*
432 * Timer definitions 432 * Timer definitions
433 * 433 *
434 * Only use timer 1 & 2 434 * Only use timer 1 & 2
435 * (both run at 24MHz and will need the clock divider set to 16). 435 * (both run at 24MHz and will need the clock divider set to 16).
436 * 436 *
437 * Timer 0 runs at bus frequency and therefore could vary and currently 437 * Timer 0 runs at bus frequency and therefore could vary and currently
438 * uHAL can't handle that. 438 * uHAL can't handle that.
439 * 439 *
440 */ 440 */
441 441
442#define INTEGRATOR_TIMER0_BASE INTEGRATOR_CT_BASE 442#define INTEGRATOR_TIMER0_BASE INTEGRATOR_CT_BASE
@@ -447,9 +447,9 @@
447#define MAX_PERIOD 699050 447#define MAX_PERIOD 699050
448#define TICKS_PER_uSEC 24 448#define TICKS_PER_uSEC 24
449 449
450/* 450/*
451 * These are useconds NOT ticks. 451 * These are useconds NOT ticks.
452 * 452 *
453 */ 453 */
454#define mSEC_1 1000 454#define mSEC_1 1000
455#define mSEC_5 (mSEC_1 * 5) 455#define mSEC_5 (mSEC_1 * 5)
diff --git a/include/asm-arm/arch-integrator/vmalloc.h b/include/asm-arm/arch-integrator/vmalloc.h
index 50e9aee79486..170cccece523 100644
--- a/include/asm-arm/arch-integrator/vmalloc.h
+++ b/include/asm-arm/arch-integrator/vmalloc.h
@@ -17,15 +17,4 @@
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21/*
22 * Just any arbitrary offset to the start of the vmalloc VM area: the
23 * current 8MB value just means that there will be a 8MB "hole" after the
24 * physical memory until the kernel virtual memory starts. That means that
25 * any out-of-bounds memory accesses will hopefully be caught.
26 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
27 * area for the same reason. ;)
28 */
29#define VMALLOC_OFFSET (8*1024*1024)
30#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
31#define VMALLOC_END (PAGE_OFFSET + 0x10000000) 20#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
diff --git a/include/asm-arm/arch-iop3xx/vmalloc.h b/include/asm-arm/arch-iop3xx/vmalloc.h
index dc1d2a957164..0f2f6847f93c 100644
--- a/include/asm-arm/arch-iop3xx/vmalloc.h
+++ b/include/asm-arm/arch-iop3xx/vmalloc.h
@@ -10,9 +10,6 @@
10 * The vmalloc() routines leaves a hole of 4kB between each vmalloced 10 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
11 * area for the same reason. ;) 11 * area for the same reason. ;)
12 */ 12 */
13#define VMALLOC_OFFSET (8*1024*1024)
14#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
15#define VMALLOC_VMADDR(x) ((unsigned long)(x))
16//#define VMALLOC_END (0xe8000000) 13//#define VMALLOC_END (0xe8000000)
17/* increase usable physical RAM to ~992M per RMK */ 14/* increase usable physical RAM to ~992M per RMK */
18#define VMALLOC_END (0xfe000000) 15#define VMALLOC_END (0xfe000000)
diff --git a/include/asm-arm/arch-ixp2000/vmalloc.h b/include/asm-arm/arch-ixp2000/vmalloc.h
index 2e4bcbcf31f0..473dff4ec561 100644
--- a/include/asm-arm/arch-ixp2000/vmalloc.h
+++ b/include/asm-arm/arch-ixp2000/vmalloc.h
@@ -17,7 +17,4 @@
17 * The vmalloc() routines leaves a hole of 4kB between each vmalloced 17 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
18 * area for the same reason. ;) 18 * area for the same reason. ;)
19 */ 19 */
20#define VMALLOC_OFFSET (8*1024*1024)
21#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
22#define VMALLOC_VMADDR(x) ((unsigned long)(x))
23#define VMALLOC_END 0xfaffefff 20#define VMALLOC_END 0xfaffefff
diff --git a/include/asm-arm/arch-ixp4xx/vmalloc.h b/include/asm-arm/arch-ixp4xx/vmalloc.h
index da46e560ad6f..050d46e6b126 100644
--- a/include/asm-arm/arch-ixp4xx/vmalloc.h
+++ b/include/asm-arm/arch-ixp4xx/vmalloc.h
@@ -1,17 +1,5 @@
1/* 1/*
2 * linux/include/asm-arm/arch-ixp4xx/vmalloc.h 2 * linux/include/asm-arm/arch-ixp4xx/vmalloc.h
3 */ 3 */
4
5/*
6 * Just any arbitrary offset to the start of the vmalloc VM area: the
7 * current 8MB value just means that there will be a 8MB "hole" after the
8 * physical memory until the kernel virtual memory starts. That means that
9 * any out-of-bounds memory accesses will hopefully be caught.
10 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
11 * area for the same reason. ;)
12 */
13#define VMALLOC_OFFSET (8*1024*1024)
14#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
15#define VMALLOC_VMADDR(x) ((unsigned long)(x))
16#define VMALLOC_END (0xFF000000) 4#define VMALLOC_END (0xFF000000)
17 5
diff --git a/include/asm-arm/arch-l7200/vmalloc.h b/include/asm-arm/arch-l7200/vmalloc.h
index edeaebe1f14a..816231eedaac 100644
--- a/include/asm-arm/arch-l7200/vmalloc.h
+++ b/include/asm-arm/arch-l7200/vmalloc.h
@@ -1,15 +1,4 @@
1/* 1/*
2 * linux/include/asm-arm/arch-l7200/vmalloc.h 2 * linux/include/asm-arm/arch-l7200/vmalloc.h
3 */ 3 */
4
5/*
6 * Just any arbitrary offset to the start of the vmalloc VM area: the
7 * current 8MB value just means that there will be a 8MB "hole" after the
8 * physical memory until the kernel virtual memory starts. That means that
9 * any out-of-bounds memory accesses will hopefully be caught.
10 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
11 * area for the same reason. ;)
12 */
13#define VMALLOC_OFFSET (8*1024*1024)
14#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
15#define VMALLOC_END (PAGE_OFFSET + 0x10000000) 4#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
diff --git a/include/asm-arm/arch-lh7a40x/vmalloc.h b/include/asm-arm/arch-lh7a40x/vmalloc.h
index 5ac607925bea..8163e45109b9 100644
--- a/include/asm-arm/arch-lh7a40x/vmalloc.h
+++ b/include/asm-arm/arch-lh7a40x/vmalloc.h
@@ -7,15 +7,4 @@
7 * version 2 as published by the Free Software Foundation. 7 * version 2 as published by the Free Software Foundation.
8 * 8 *
9 */ 9 */
10
11/*
12 * Just any arbitrary offset to the start of the vmalloc VM area: the
13 * current 8MB value just means that there will be a 8MB "hole" after
14 * the physical memory until the kernel virtual memory starts. That
15 * means that any out-of-bounds memory accesses will hopefully be
16 * caught. The vmalloc() routines leaves a hole of 4kB (one page)
17 * between each vmalloced area for the same reason. ;)
18 */
19#define VMALLOC_OFFSET (8*1024*1024)
20#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
21#define VMALLOC_END (0xe8000000) 10#define VMALLOC_END (0xe8000000)
diff --git a/include/asm-arm/arch-omap/vmalloc.h b/include/asm-arm/arch-omap/vmalloc.h
index c6a83581a2fc..5b8bd8dae8be 100644
--- a/include/asm-arm/arch-omap/vmalloc.h
+++ b/include/asm-arm/arch-omap/vmalloc.h
@@ -17,17 +17,5 @@
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21/*
22 * Just any arbitrary offset to the start of the vmalloc VM area: the
23 * current 8MB value just means that there will be a 8MB "hole" after the
24 * physical memory until the kernel virtual memory starts. That means that
25 * any out-of-bounds memory accesses will hopefully be caught.
26 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
27 * area for the same reason. ;)
28 */
29#define VMALLOC_OFFSET (8*1024*1024)
30#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
31#define VMALLOC_VMADDR(x) ((unsigned long)(x))
32#define VMALLOC_END (PAGE_OFFSET + 0x10000000) 20#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
33 21
diff --git a/include/asm-arm/arch-pxa/vmalloc.h b/include/asm-arm/arch-pxa/vmalloc.h
index 3381af6ddb0d..5bb450c7aa2c 100644
--- a/include/asm-arm/arch-pxa/vmalloc.h
+++ b/include/asm-arm/arch-pxa/vmalloc.h
@@ -8,15 +8,4 @@
8 * it under the terms of the GNU General Public License version 2 as 8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
10 */ 10 */
11
12/*
13 * Just any arbitrary offset to the start of the vmalloc VM area: the
14 * current 8MB value just means that there will be a 8MB "hole" after the
15 * physical memory until the kernel virtual memory starts. That means that
16 * any out-of-bounds memory accesses will hopefully be caught.
17 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
18 * area for the same reason. ;)
19 */
20#define VMALLOC_OFFSET (8*1024*1024)
21#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
22#define VMALLOC_END (0xe8000000) 11#define VMALLOC_END (0xe8000000)
diff --git a/include/asm-arm/arch-rpc/vmalloc.h b/include/asm-arm/arch-rpc/vmalloc.h
index a13c27f37d71..077046bb2f36 100644
--- a/include/asm-arm/arch-rpc/vmalloc.h
+++ b/include/asm-arm/arch-rpc/vmalloc.h
@@ -7,15 +7,4 @@
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10
11/*
12 * Just any arbitrary offset to the start of the vmalloc VM area: the
13 * current 8MB value just means that there will be a 8MB "hole" after the
14 * physical memory until the kernel virtual memory starts. That means that
15 * any out-of-bounds memory accesses will hopefully be caught.
16 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
17 * area for the same reason. ;)
18 */
19#define VMALLOC_OFFSET (8*1024*1024)
20#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
21#define VMALLOC_END (PAGE_OFFSET + 0x1c000000) 10#define VMALLOC_END (PAGE_OFFSET + 0x1c000000)
diff --git a/include/asm-arm/arch-s3c2410/vmalloc.h b/include/asm-arm/arch-s3c2410/vmalloc.h
index 5fe72ad70904..33963cd5461b 100644
--- a/include/asm-arm/arch-s3c2410/vmalloc.h
+++ b/include/asm-arm/arch-s3c2410/vmalloc.h
@@ -19,18 +19,6 @@
19#ifndef __ASM_ARCH_VMALLOC_H 19#ifndef __ASM_ARCH_VMALLOC_H
20#define __ASM_ARCH_VMALLOC_H 20#define __ASM_ARCH_VMALLOC_H
21 21
22/*
23 * Just any arbitrary offset to the start of the vmalloc VM area: the
24 * current 8MB value just means that there will be a 8MB "hole" after the
25 * physical memory until the kernel virtual memory starts. That means that
26 * any out-of-bounds memory accesses will hopefully be caught.
27 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
28 * area for the same reason. ;)
29 */
30
31#define VMALLOC_OFFSET (8*1024*1024)
32#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
33#define VMALLOC_VMADDR(x) ((unsigned long)(x))
34#define VMALLOC_END (0xE0000000) 22#define VMALLOC_END (0xE0000000)
35 23
36#endif /* __ASM_ARCH_VMALLOC_H */ 24#endif /* __ASM_ARCH_VMALLOC_H */
diff --git a/include/asm-arm/arch-sa1100/vmalloc.h b/include/asm-arm/arch-sa1100/vmalloc.h
index 135bc9493c06..2fb1c6f3aa1b 100644
--- a/include/asm-arm/arch-sa1100/vmalloc.h
+++ b/include/asm-arm/arch-sa1100/vmalloc.h
@@ -1,15 +1,4 @@
1/* 1/*
2 * linux/include/asm-arm/arch-sa1100/vmalloc.h 2 * linux/include/asm-arm/arch-sa1100/vmalloc.h
3 */ 3 */
4
5/*
6 * Just any arbitrary offset to the start of the vmalloc VM area: the
7 * current 8MB value just means that there will be a 8MB "hole" after the
8 * physical memory until the kernel virtual memory starts. That means that
9 * any out-of-bounds memory accesses will hopefully be caught.
10 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
11 * area for the same reason. ;)
12 */
13#define VMALLOC_OFFSET (8*1024*1024)
14#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
15#define VMALLOC_END (0xe8000000) 4#define VMALLOC_END (0xe8000000)
diff --git a/include/asm-arm/arch-shark/vmalloc.h b/include/asm-arm/arch-shark/vmalloc.h
index 1cc20098f690..10db5d188231 100644
--- a/include/asm-arm/arch-shark/vmalloc.h
+++ b/include/asm-arm/arch-shark/vmalloc.h
@@ -1,15 +1,4 @@
1/* 1/*
2 * linux/include/asm-arm/arch-rpc/vmalloc.h 2 * linux/include/asm-arm/arch-rpc/vmalloc.h
3 */ 3 */
4
5/*
6 * Just any arbitrary offset to the start of the vmalloc VM area: the
7 * current 8MB value just means that there will be a 8MB "hole" after the
8 * physical memory until the kernel virtual memory starts. That means that
9 * any out-of-bounds memory accesses will hopefully be caught.
10 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
11 * area for the same reason. ;)
12 */
13#define VMALLOC_OFFSET (8*1024*1024)
14#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
15#define VMALLOC_END (PAGE_OFFSET + 0x10000000) 4#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
diff --git a/include/asm-arm/arch-versatile/vmalloc.h b/include/asm-arm/arch-versatile/vmalloc.h
index adfb34829bfc..ac780df62156 100644
--- a/include/asm-arm/arch-versatile/vmalloc.h
+++ b/include/asm-arm/arch-versatile/vmalloc.h
@@ -18,16 +18,4 @@
18 * along with this program; if not, write to the Free Software 18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 20 */
21
22/*
23 * Just any arbitrary offset to the start of the vmalloc VM area: the
24 * current 8MB value just means that there will be a 8MB "hole" after the
25 * physical memory until the kernel virtual memory starts. That means that
26 * any out-of-bounds memory accesses will hopefully be caught.
27 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
28 * area for the same reason. ;)
29 */
30#define VMALLOC_OFFSET (8*1024*1024)
31#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
32#define VMALLOC_VMADDR(x) ((unsigned long)(x))
33#define VMALLOC_END (PAGE_OFFSET + 0x18000000) 21#define VMALLOC_END (PAGE_OFFSET + 0x18000000)
diff --git a/include/asm-arm/pgtable.h b/include/asm-arm/pgtable.h
index 2df4eacf4fa9..a9892eb42a23 100644
--- a/include/asm-arm/pgtable.h
+++ b/include/asm-arm/pgtable.h
@@ -17,6 +17,23 @@
17#include <asm/arch/vmalloc.h> 17#include <asm/arch/vmalloc.h>
18 18
19/* 19/*
20 * Just any arbitrary offset to the start of the vmalloc VM area: the
21 * current 8MB value just means that there will be a 8MB "hole" after the
22 * physical memory until the kernel virtual memory starts. That means that
23 * any out-of-bounds memory accesses will hopefully be caught.
24 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
25 * area for the same reason. ;)
26 *
27 * Note that platforms may override VMALLOC_START, but they must provide
28 * VMALLOC_END. VMALLOC_END defines the (exclusive) limit of this space,
29 * which may not overlap IO space.
30 */
31#ifndef VMALLOC_START
32#define VMALLOC_OFFSET (8*1024*1024)
33#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
34#endif
35
36/*
20 * Hardware-wise, we have a two level page table structure, where the first 37 * Hardware-wise, we have a two level page table structure, where the first
21 * level has 4096 entries, and the second level has 256 entries. Each entry 38 * level has 4096 entries, and the second level has 256 entries. Each entry
22 * is one 32-bit word. Most of the bits in the second level entry are used 39 * is one 32-bit word. Most of the bits in the second level entry are used
diff --git a/include/asm-arm/signal.h b/include/asm-arm/signal.h
index b860dc3c5dc7..46e69ae395af 100644
--- a/include/asm-arm/signal.h
+++ b/include/asm-arm/signal.h
@@ -117,20 +117,7 @@ typedef unsigned long sigset_t;
117#define SA_IRQNOMASK 0x08000000 117#define SA_IRQNOMASK 0x08000000
118#endif 118#endif
119 119
120#define SIG_BLOCK 0 /* for blocking signals */ 120#include <asm-generic/signal.h>
121#define SIG_UNBLOCK 1 /* for unblocking signals */
122#define SIG_SETMASK 2 /* for setting the signal mask */
123
124/* Type of a signal handler. */
125typedef void __signalfn_t(int);
126typedef __signalfn_t __user *__sighandler_t;
127
128typedef void __restorefn_t(void);
129typedef __restorefn_t __user *__sigrestore_t;
130
131#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
132#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
133#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
134 121
135#ifdef __KERNEL__ 122#ifdef __KERNEL__
136struct old_sigaction { 123struct old_sigaction {
diff --git a/include/asm-arm26/signal.h b/include/asm-arm26/signal.h
index a1aacefa6562..dedb29280303 100644
--- a/include/asm-arm26/signal.h
+++ b/include/asm-arm26/signal.h
@@ -117,16 +117,7 @@ typedef unsigned long sigset_t;
117#define SA_IRQNOMASK 0x08000000 117#define SA_IRQNOMASK 0x08000000
118#endif 118#endif
119 119
120#define SIG_BLOCK 0 /* for blocking signals */ 120#include <asm-generic/signal.h>
121#define SIG_UNBLOCK 1 /* for unblocking signals */
122#define SIG_SETMASK 2 /* for setting the signal mask */
123
124/* Type of a signal handler. */
125typedef void (*__sighandler_t)(int);
126
127#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
128#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
129#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
130 121
131#ifdef __KERNEL__ 122#ifdef __KERNEL__
132struct old_sigaction { 123struct old_sigaction {
diff --git a/include/asm-cris/signal.h b/include/asm-cris/signal.h
index 2330769ba55d..dfe039593a78 100644
--- a/include/asm-cris/signal.h
+++ b/include/asm-cris/signal.h
@@ -108,16 +108,7 @@ typedef unsigned long sigset_t;
108#define MINSIGSTKSZ 2048 108#define MINSIGSTKSZ 2048
109#define SIGSTKSZ 8192 109#define SIGSTKSZ 8192
110 110
111#define SIG_BLOCK 0 /* for blocking signals */ 111#include <asm-generic/signal.h>
112#define SIG_UNBLOCK 1 /* for unblocking signals */
113#define SIG_SETMASK 2 /* for setting the signal mask */
114
115/* Type of a signal handler. */
116typedef void (*__sighandler_t)(int);
117
118#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
119#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
120#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
121 112
122#ifdef __KERNEL__ 113#ifdef __KERNEL__
123struct old_sigaction { 114struct old_sigaction {
diff --git a/include/asm-frv/signal.h b/include/asm-frv/signal.h
index c930bb176875..d407bde57eca 100644
--- a/include/asm-frv/signal.h
+++ b/include/asm-frv/signal.h
@@ -107,16 +107,7 @@ typedef unsigned long sigset_t;
107#define MINSIGSTKSZ 2048 107#define MINSIGSTKSZ 2048
108#define SIGSTKSZ 8192 108#define SIGSTKSZ 8192
109 109
110#define SIG_BLOCK 0 /* for blocking signals */ 110#include <asm-generic/signal.h>
111#define SIG_UNBLOCK 1 /* for unblocking signals */
112#define SIG_SETMASK 2 /* for setting the signal mask */
113
114/* Type of a signal handler. */
115typedef void (*__sighandler_t)(int);
116
117#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
118#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
119#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
120 111
121#ifdef __KERNEL__ 112#ifdef __KERNEL__
122struct old_sigaction { 113struct old_sigaction {
diff --git a/include/asm-generic/signal.h b/include/asm-generic/signal.h
new file mode 100644
index 000000000000..9418d6e9b8cd
--- /dev/null
+++ b/include/asm-generic/signal.h
@@ -0,0 +1,21 @@
1#ifndef SIG_BLOCK
2#define SIG_BLOCK 0 /* for blocking signals */
3#endif
4#ifndef SIG_UNBLOCK
5#define SIG_UNBLOCK 1 /* for unblocking signals */
6#endif
7#ifndef SIG_SETMASK
8#define SIG_SETMASK 2 /* for setting the signal mask */
9#endif
10
11#ifndef __ASSEMBLY__
12typedef void __signalfn_t(int);
13typedef __signalfn_t __user *__sighandler_t;
14
15typedef void __restorefn_t(void);
16typedef __restorefn_t __user *__sigrestore_t;
17
18#define SIG_DFL ((__force __sighandler_t)0) /* default signal handling */
19#define SIG_IGN ((__force __sighandler_t)1) /* ignore signal */
20#define SIG_ERR ((__force __sighandler_t)-1) /* error return from signal */
21#endif
diff --git a/include/asm-h8300/signal.h b/include/asm-h8300/signal.h
index ac3e01bd6396..8eccdc176163 100644
--- a/include/asm-h8300/signal.h
+++ b/include/asm-h8300/signal.h
@@ -107,16 +107,7 @@ typedef unsigned long sigset_t;
107#define MINSIGSTKSZ 2048 107#define MINSIGSTKSZ 2048
108#define SIGSTKSZ 8192 108#define SIGSTKSZ 8192
109 109
110#define SIG_BLOCK 0 /* for blocking signals */ 110#include <asm-generic/signal.h>
111#define SIG_UNBLOCK 1 /* for unblocking signals */
112#define SIG_SETMASK 2 /* for setting the signal mask */
113
114/* Type of a signal handler. */
115typedef void (*__sighandler_t)(int);
116
117#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
118#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
119#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
120 111
121#ifdef __KERNEL__ 112#ifdef __KERNEL__
122struct old_sigaction { 113struct old_sigaction {
diff --git a/include/asm-i386/signal.h b/include/asm-i386/signal.h
index 0f082bd1c455..cbb47d34aa31 100644
--- a/include/asm-i386/signal.h
+++ b/include/asm-i386/signal.h
@@ -110,20 +110,7 @@ typedef unsigned long sigset_t;
110#define MINSIGSTKSZ 2048 110#define MINSIGSTKSZ 2048
111#define SIGSTKSZ 8192 111#define SIGSTKSZ 8192
112 112
113#define SIG_BLOCK 0 /* for blocking signals */ 113#include <asm-generic/signal.h>
114#define SIG_UNBLOCK 1 /* for unblocking signals */
115#define SIG_SETMASK 2 /* for setting the signal mask */
116
117/* Type of a signal handler. */
118typedef void __signalfn_t(int);
119typedef __signalfn_t __user *__sighandler_t;
120
121typedef void __restorefn_t(void);
122typedef __restorefn_t __user *__sigrestore_t;
123
124#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
125#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
126#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
127 114
128#ifdef __KERNEL__ 115#ifdef __KERNEL__
129struct old_sigaction { 116struct old_sigaction {
diff --git a/include/asm-ia64/signal.h b/include/asm-ia64/signal.h
index 85a577ae9146..608168d713d3 100644
--- a/include/asm-ia64/signal.h
+++ b/include/asm-ia64/signal.h
@@ -118,13 +118,7 @@
118 118
119#endif /* __KERNEL__ */ 119#endif /* __KERNEL__ */
120 120
121#define SIG_BLOCK 0 /* for blocking signals */ 121#include <asm-generic/signal.h>
122#define SIG_UNBLOCK 1 /* for unblocking signals */
123#define SIG_SETMASK 2 /* for setting the signal mask */
124
125#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
126#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
127#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
128 122
129# ifndef __ASSEMBLY__ 123# ifndef __ASSEMBLY__
130 124
@@ -133,9 +127,6 @@
133/* Avoid too many header ordering problems. */ 127/* Avoid too many header ordering problems. */
134struct siginfo; 128struct siginfo;
135 129
136/* Type of a signal handler. */
137typedef void __user (*__sighandler_t)(int);
138
139typedef struct sigaltstack { 130typedef struct sigaltstack {
140 void __user *ss_sp; 131 void __user *ss_sp;
141 int ss_flags; 132 int ss_flags;
diff --git a/include/asm-m32r/signal.h b/include/asm-m32r/signal.h
index 6e55fd421883..95f69b191953 100644
--- a/include/asm-m32r/signal.h
+++ b/include/asm-m32r/signal.h
@@ -114,20 +114,7 @@ typedef unsigned long sigset_t;
114#define MINSIGSTKSZ 2048 114#define MINSIGSTKSZ 2048
115#define SIGSTKSZ 8192 115#define SIGSTKSZ 8192
116 116
117#define SIG_BLOCK 0 /* for blocking signals */ 117#include <asm-generic/signal.h>
118#define SIG_UNBLOCK 1 /* for unblocking signals */
119#define SIG_SETMASK 2 /* for setting the signal mask */
120
121/* Type of a signal handler. */
122typedef void __signalfn_t(int);
123typedef __signalfn_t __user *__sighandler_t;
124
125typedef void __restorefn_t(void);
126typedef __restorefn_t __user *__sigrestore_t;
127
128#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
129#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
130#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
131 118
132#ifdef __KERNEL__ 119#ifdef __KERNEL__
133struct old_sigaction { 120struct old_sigaction {
diff --git a/include/asm-m68k/signal.h b/include/asm-m68k/signal.h
index 1d016e9f19bf..a0cdf9082372 100644
--- a/include/asm-m68k/signal.h
+++ b/include/asm-m68k/signal.h
@@ -105,29 +105,20 @@ typedef unsigned long sigset_t;
105#define MINSIGSTKSZ 2048 105#define MINSIGSTKSZ 2048
106#define SIGSTKSZ 8192 106#define SIGSTKSZ 8192
107 107
108#define SIG_BLOCK 0 /* for blocking signals */ 108#include <asm-generic/signal.h>
109#define SIG_UNBLOCK 1 /* for unblocking signals */
110#define SIG_SETMASK 2 /* for setting the signal mask */
111
112/* Type of a signal handler. */
113typedef void (*__sighandler_t)(int);
114
115#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
116#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
117#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
118 109
119#ifdef __KERNEL__ 110#ifdef __KERNEL__
120struct old_sigaction { 111struct old_sigaction {
121 __sighandler_t sa_handler; 112 __sighandler_t sa_handler;
122 old_sigset_t sa_mask; 113 old_sigset_t sa_mask;
123 unsigned long sa_flags; 114 unsigned long sa_flags;
124 void (*sa_restorer)(void); 115 __sigrestore_t sa_restorer;
125}; 116};
126 117
127struct sigaction { 118struct sigaction {
128 __sighandler_t sa_handler; 119 __sighandler_t sa_handler;
129 unsigned long sa_flags; 120 unsigned long sa_flags;
130 void (*sa_restorer)(void); 121 __sigrestore_t sa_restorer;
131 sigset_t sa_mask; /* mask last for extensibility */ 122 sigset_t sa_mask; /* mask last for extensibility */
132}; 123};
133 124
diff --git a/include/asm-m68knommu/signal.h b/include/asm-m68knommu/signal.h
index 37c9c8a024ba..1d13187f6062 100644
--- a/include/asm-m68knommu/signal.h
+++ b/include/asm-m68knommu/signal.h
@@ -105,16 +105,7 @@ typedef unsigned long sigset_t;
105#define MINSIGSTKSZ 2048 105#define MINSIGSTKSZ 2048
106#define SIGSTKSZ 8192 106#define SIGSTKSZ 8192
107 107
108#define SIG_BLOCK 0 /* for blocking signals */ 108#include <asm-generic/signal.h>
109#define SIG_UNBLOCK 1 /* for unblocking signals */
110#define SIG_SETMASK 2 /* for setting the signal mask */
111
112/* Type of a signal handler. */
113typedef void (*__sighandler_t)(int);
114
115#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
116#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
117#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
118 109
119#ifdef __KERNEL__ 110#ifdef __KERNEL__
120struct old_sigaction { 111struct old_sigaction {
diff --git a/include/asm-mips/signal.h b/include/asm-mips/signal.h
index d81356731eb6..f2c470f1d369 100644
--- a/include/asm-mips/signal.h
+++ b/include/asm-mips/signal.h
@@ -103,14 +103,7 @@ typedef unsigned long old_sigset_t; /* at least 32 bits */
103#define SIG_SETMASK 3 /* for setting the signal mask */ 103#define SIG_SETMASK 3 /* for setting the signal mask */
104#define SIG_SETMASK32 256 /* Goodie from SGI for BSD compatibility: 104#define SIG_SETMASK32 256 /* Goodie from SGI for BSD compatibility:
105 set only the low 32 bit of the sigset. */ 105 set only the low 32 bit of the sigset. */
106 106#include <asm-generic/signal.h>
107/* Type of a signal handler. */
108typedef void (*__sighandler_t)(int);
109
110/* Fake signal functions */
111#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
112#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
113#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
114 107
115struct sigaction { 108struct sigaction {
116 unsigned int sa_flags; 109 unsigned int sa_flags;
diff --git a/include/asm-ppc/signal.h b/include/asm-ppc/signal.h
index d890dabd5a69..caf6ede3710f 100644
--- a/include/asm-ppc/signal.h
+++ b/include/asm-ppc/signal.h
@@ -100,20 +100,7 @@ typedef struct {
100#define MINSIGSTKSZ 2048 100#define MINSIGSTKSZ 2048
101#define SIGSTKSZ 8192 101#define SIGSTKSZ 8192
102 102
103#define SIG_BLOCK 0 /* for blocking signals */ 103#include <asm-generic/signal.h>
104#define SIG_UNBLOCK 1 /* for unblocking signals */
105#define SIG_SETMASK 2 /* for setting the signal mask */
106
107/* Type of a signal handler. */
108typedef void __signalfn_t(int);
109typedef __signalfn_t __user *__sighandler_t;
110
111typedef void __restorefn_t(void);
112typedef __restorefn_t __user *__sigrestore_t;
113
114#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
115#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
116#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
117 104
118struct old_sigaction { 105struct old_sigaction {
119 __sighandler_t sa_handler; 106 __sighandler_t sa_handler;
diff --git a/include/asm-ppc64/signal.h b/include/asm-ppc64/signal.h
index a2d7bbb4befd..432df7dd355d 100644
--- a/include/asm-ppc64/signal.h
+++ b/include/asm-ppc64/signal.h
@@ -97,33 +97,19 @@ typedef struct {
97#define MINSIGSTKSZ 2048 97#define MINSIGSTKSZ 2048
98#define SIGSTKSZ 8192 98#define SIGSTKSZ 8192
99 99
100#define SIG_BLOCK 0 /* for blocking signals */ 100#include <asm-generic/signal.h>
101#define SIG_UNBLOCK 1 /* for unblocking signals */
102#define SIG_SETMASK 2 /* for setting the signal mask */
103
104/* Type of a signal handler. */
105typedef void __sigfunction(int);
106typedef __sigfunction __user * __sighandler_t;
107
108/* Type of the restorer function */
109typedef void __sigrestorer(void);
110typedef __sigrestorer __user * __sigrestorer_t;
111
112#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
113#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
114#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
115 101
116struct old_sigaction { 102struct old_sigaction {
117 __sighandler_t sa_handler; 103 __sighandler_t sa_handler;
118 old_sigset_t sa_mask; 104 old_sigset_t sa_mask;
119 unsigned long sa_flags; 105 unsigned long sa_flags;
120 __sigrestorer_t sa_restorer; 106 __sigrestore_t sa_restorer;
121}; 107};
122 108
123struct sigaction { 109struct sigaction {
124 __sighandler_t sa_handler; 110 __sighandler_t sa_handler;
125 unsigned long sa_flags; 111 unsigned long sa_flags;
126 __sigrestorer_t sa_restorer; 112 __sigrestore_t sa_restorer;
127 sigset_t sa_mask; /* mask last for extensibility */ 113 sigset_t sa_mask; /* mask last for extensibility */
128}; 114};
129 115
diff --git a/include/asm-s390/signal.h b/include/asm-s390/signal.h
index bfed83a818cc..3d6e11c6c1fd 100644
--- a/include/asm-s390/signal.h
+++ b/include/asm-s390/signal.h
@@ -117,16 +117,7 @@ typedef unsigned long sigset_t;
117#define MINSIGSTKSZ 2048 117#define MINSIGSTKSZ 2048
118#define SIGSTKSZ 8192 118#define SIGSTKSZ 8192
119 119
120#define SIG_BLOCK 0 /* for blocking signals */ 120#include <asm-generic/signal.h>
121#define SIG_UNBLOCK 1 /* for unblocking signals */
122#define SIG_SETMASK 2 /* for setting the signal mask */
123
124/* Type of a signal handler. */
125typedef void (*__sighandler_t)(int);
126
127#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
128#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
129#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
130 121
131#ifdef __KERNEL__ 122#ifdef __KERNEL__
132struct old_sigaction { 123struct old_sigaction {
diff --git a/include/asm-sh/signal.h b/include/asm-sh/signal.h
index 29f1ac1bf4df..d6e8eb0e65c7 100644
--- a/include/asm-sh/signal.h
+++ b/include/asm-sh/signal.h
@@ -108,16 +108,7 @@ typedef unsigned long sigset_t;
108#define MINSIGSTKSZ 2048 108#define MINSIGSTKSZ 2048
109#define SIGSTKSZ 8192 109#define SIGSTKSZ 8192
110 110
111#define SIG_BLOCK 0 /* for blocking signals */ 111#include <asm-generic/signal.h>
112#define SIG_UNBLOCK 1 /* for unblocking signals */
113#define SIG_SETMASK 2 /* for setting the signal mask */
114
115/* Type of a signal handler. */
116typedef void (*__sighandler_t)(int);
117
118#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
119#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
120#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
121 112
122#ifdef __KERNEL__ 113#ifdef __KERNEL__
123struct old_sigaction { 114struct old_sigaction {
diff --git a/include/asm-sh64/signal.h b/include/asm-sh64/signal.h
index 864c94ecc98c..2400dc688a65 100644
--- a/include/asm-sh64/signal.h
+++ b/include/asm-sh64/signal.h
@@ -107,16 +107,7 @@ typedef struct {
107#define MINSIGSTKSZ 2048 107#define MINSIGSTKSZ 2048
108#define SIGSTKSZ THREAD_SIZE 108#define SIGSTKSZ THREAD_SIZE
109 109
110#define SIG_BLOCK 0 /* for blocking signals */ 110#include <asm-generic/signal.h>
111#define SIG_UNBLOCK 1 /* for unblocking signals */
112#define SIG_SETMASK 2 /* for setting the signal mask */
113
114/* Type of a signal handler. */
115typedef void (*__sighandler_t)(int);
116
117#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
118#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
119#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
120 111
121#ifdef __KERNEL__ 112#ifdef __KERNEL__
122struct old_sigaction { 113struct old_sigaction {
diff --git a/include/asm-sparc/floppy.h b/include/asm-sparc/floppy.h
index 780ee7ff9dc3..caf926116506 100644
--- a/include/asm-sparc/floppy.h
+++ b/include/asm-sparc/floppy.h
@@ -227,7 +227,7 @@ static __inline__ void sun_fd_disable_dma(void)
227 doing_pdma = 0; 227 doing_pdma = 0;
228 if (pdma_base) { 228 if (pdma_base) {
229 mmu_unlockarea(pdma_base, pdma_areasize); 229 mmu_unlockarea(pdma_base, pdma_areasize);
230 pdma_base = 0; 230 pdma_base = NULL;
231 } 231 }
232} 232}
233 233
diff --git a/include/asm-sparc/signal.h b/include/asm-sparc/signal.h
index f792e10e704f..aa9960ad0ca9 100644
--- a/include/asm-sparc/signal.h
+++ b/include/asm-sparc/signal.h
@@ -174,16 +174,7 @@ struct sigstack {
174#define SA_STATIC_ALLOC 0x80 174#define SA_STATIC_ALLOC 0x80
175#endif 175#endif
176 176
177/* Type of a signal handler. */ 177#include <asm-generic/signal.h>
178#ifdef __KERNEL__
179typedef void (*__sighandler_t)(int, int, struct sigcontext *, char *);
180#else
181typedef void (*__sighandler_t)(int);
182#endif
183
184#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
185#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
186#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
187 178
188#ifdef __KERNEL__ 179#ifdef __KERNEL__
189struct __new_sigaction { 180struct __new_sigaction {
diff --git a/include/asm-sparc64/parport.h b/include/asm-sparc64/parport.h
index ab88349ddadc..b7e635544cec 100644
--- a/include/asm-sparc64/parport.h
+++ b/include/asm-sparc64/parport.h
@@ -13,6 +13,12 @@
13 13
14#define PARPORT_PC_MAX_PORTS PARPORT_MAX 14#define PARPORT_PC_MAX_PORTS PARPORT_MAX
15 15
16/*
17 * While sparc64 doesn't have an ISA DMA API, we provide something that looks
18 * close enough to make parport_pc happy
19 */
20#define HAS_DMA
21
16static struct sparc_ebus_info { 22static struct sparc_ebus_info {
17 struct ebus_dma_info info; 23 struct ebus_dma_info info;
18 unsigned int addr; 24 unsigned int addr;
diff --git a/include/asm-sparc64/signal.h b/include/asm-sparc64/signal.h
index 466d021d7038..becdf1bc5924 100644
--- a/include/asm-sparc64/signal.h
+++ b/include/asm-sparc64/signal.h
@@ -177,21 +177,7 @@ struct sigstack {
177#define SA_STATIC_ALLOC 0x80 177#define SA_STATIC_ALLOC 0x80
178#endif 178#endif
179 179
180/* Type of a signal handler. */ 180#include <asm-generic/signal.h>
181#ifdef __KERNEL__
182typedef void __signalfn_t(int);
183typedef __signalfn_t __user *__sighandler_t;
184
185typedef void __restorefn_t(void);
186typedef __restorefn_t __user *__sigrestore_t;
187#else
188typedef void (*__sighandler_t)(int);
189typedef void (*__sigrestore_t)(void);
190#endif
191
192#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
193#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
194#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
195 181
196struct __new_sigaction { 182struct __new_sigaction {
197 __sighandler_t sa_handler; 183 __sighandler_t sa_handler;
diff --git a/include/asm-v850/signal.h b/include/asm-v850/signal.h
index ec3566c875d9..cb52caa69925 100644
--- a/include/asm-v850/signal.h
+++ b/include/asm-v850/signal.h
@@ -110,17 +110,7 @@ typedef unsigned long sigset_t;
110#define MINSIGSTKSZ 2048 110#define MINSIGSTKSZ 2048
111#define SIGSTKSZ 8192 111#define SIGSTKSZ 8192
112 112
113#define SIG_BLOCK 0 /* for blocking signals */ 113#include <asm-generic/signal.h>
114#define SIG_UNBLOCK 1 /* for unblocking signals */
115#define SIG_SETMASK 2 /* for setting the signal mask */
116
117/* Type of a signal handler. */
118typedef void (*__sighandler_t)(int);
119
120#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
121#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
122#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
123
124 114
125#ifdef __KERNEL__ 115#ifdef __KERNEL__
126 116
diff --git a/include/asm-x86_64/signal.h b/include/asm-x86_64/signal.h
index 4987ad8082ba..fe9b96d94815 100644
--- a/include/asm-x86_64/signal.h
+++ b/include/asm-x86_64/signal.h
@@ -116,21 +116,9 @@ typedef unsigned long sigset_t;
116#define MINSIGSTKSZ 2048 116#define MINSIGSTKSZ 2048
117#define SIGSTKSZ 8192 117#define SIGSTKSZ 8192
118 118
119#define SIG_BLOCK 0 /* for blocking signals */ 119#include <asm-generic/signal.h>
120#define SIG_UNBLOCK 1 /* for unblocking signals */
121#define SIG_SETMASK 2 /* for setting the signal mask */
122 120
123#ifndef __ASSEMBLY__ 121#ifndef __ASSEMBLY__
124/* Type of a signal handler. */
125typedef void __signalfn_t(int);
126typedef __signalfn_t __user *__sighandler_t;
127
128typedef void __restorefn_t(void);
129typedef __restorefn_t __user *__sigrestore_t;
130
131#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
132#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
133#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
134 122
135struct sigaction { 123struct sigaction {
136 __sighandler_t sa_handler; 124 __sighandler_t sa_handler;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 3c89148ae28a..b5238bd18830 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -671,6 +671,7 @@ struct pci_driver {
671 int (*suspend) (struct pci_dev *dev, pm_message_t state); /* Device suspended */ 671 int (*suspend) (struct pci_dev *dev, pm_message_t state); /* Device suspended */
672 int (*resume) (struct pci_dev *dev); /* Device woken up */ 672 int (*resume) (struct pci_dev *dev); /* Device woken up */
673 int (*enable_wake) (struct pci_dev *dev, pci_power_t state, int enable); /* Enable wake event */ 673 int (*enable_wake) (struct pci_dev *dev, pci_power_t state, int enable); /* Enable wake event */
674 void (*shutdown) (struct pci_dev *dev);
674 675
675 struct device_driver driver; 676 struct device_driver driver;
676 struct pci_dynids dynids; 677 struct pci_dynids dynids;
@@ -810,7 +811,6 @@ void pci_set_master(struct pci_dev *dev);
810int pci_set_mwi(struct pci_dev *dev); 811int pci_set_mwi(struct pci_dev *dev);
811void pci_clear_mwi(struct pci_dev *dev); 812void pci_clear_mwi(struct pci_dev *dev);
812int pci_set_dma_mask(struct pci_dev *dev, u64 mask); 813int pci_set_dma_mask(struct pci_dev *dev, u64 mask);
813int pci_dac_set_dma_mask(struct pci_dev *dev, u64 mask);
814int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask); 814int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask);
815int pci_assign_resource(struct pci_dev *dev, int i); 815int pci_assign_resource(struct pci_dev *dev, int i);
816 816
@@ -941,7 +941,6 @@ static inline void pci_set_master(struct pci_dev *dev) { }
941static inline int pci_enable_device(struct pci_dev *dev) { return -EIO; } 941static inline int pci_enable_device(struct pci_dev *dev) { return -EIO; }
942static inline void pci_disable_device(struct pci_dev *dev) { } 942static inline void pci_disable_device(struct pci_dev *dev) { }
943static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask) { return -EIO; } 943static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask) { return -EIO; }
944static inline int pci_dac_set_dma_mask(struct pci_dev *dev, u64 mask) { return -EIO; }
945static inline int pci_assign_resource(struct pci_dev *dev, int i) { return -EBUSY;} 944static inline int pci_assign_resource(struct pci_dev *dev, int i) { return -EBUSY;}
946static inline int pci_register_driver(struct pci_driver *drv) { return 0;} 945static inline int pci_register_driver(struct pci_driver *drv) { return 0;}
947static inline void pci_unregister_driver(struct pci_driver *drv) { } 946static inline void pci_unregister_driver(struct pci_driver *drv) { }
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index 32e52769a00b..91ac97c20777 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -89,10 +89,14 @@ enum {
89 RTM_GETANYCAST = 62, 89 RTM_GETANYCAST = 62,
90#define RTM_GETANYCAST RTM_GETANYCAST 90#define RTM_GETANYCAST RTM_GETANYCAST
91 91
92 RTM_MAX, 92 __RTM_MAX,
93#define RTM_MAX RTM_MAX 93#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1)
94}; 94};
95 95
96#define RTM_NR_MSGTYPES (RTM_MAX + 1 - RTM_BASE)
97#define RTM_NR_FAMILIES (RTM_NR_MSGTYPES >> 2)
98#define RTM_FAM(cmd) (((cmd) - RTM_BASE) >> 2)
99
96/* 100/*
97 Generic structure for encapsulation of optional route information. 101 Generic structure for encapsulation of optional route information.
98 It is reminiscent of sockaddr, but with sa_family replaced 102 It is reminiscent of sockaddr, but with sa_family replaced
diff --git a/include/linux/xfrm.h b/include/linux/xfrm.h
index f0df02ae68a4..fd2ef742a9fd 100644
--- a/include/linux/xfrm.h
+++ b/include/linux/xfrm.h
@@ -140,8 +140,11 @@ enum {
140 XFRM_MSG_FLUSHPOLICY, 140 XFRM_MSG_FLUSHPOLICY,
141#define XFRM_MSG_FLUSHPOLICY XFRM_MSG_FLUSHPOLICY 141#define XFRM_MSG_FLUSHPOLICY XFRM_MSG_FLUSHPOLICY
142 142
143 XFRM_MSG_MAX 143 __XFRM_MSG_MAX
144}; 144};
145#define XFRM_MSG_MAX (__XFRM_MSG_MAX - 1)
146
147#define XFRM_NR_MSGTYPES (XFRM_MSG_MAX + 1 - XFRM_MSG_BASE)
145 148
146struct xfrm_user_tmpl { 149struct xfrm_user_tmpl {
147 struct xfrm_id id; 150 struct xfrm_id id;
diff --git a/include/net/addrconf.h b/include/net/addrconf.h
index 7af9a13cb9be..a0ed93672176 100644
--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -17,6 +17,8 @@
17 17
18#define IPV6_MAX_ADDRESSES 16 18#define IPV6_MAX_ADDRESSES 16
19 19
20#include <linux/in6.h>
21
20struct prefix_info { 22struct prefix_info {
21 __u8 type; 23 __u8 type;
22 __u8 length; 24 __u8 length;
@@ -43,9 +45,9 @@ struct prefix_info {
43 45
44#ifdef __KERNEL__ 46#ifdef __KERNEL__
45 47
46#include <linux/in6.h>
47#include <linux/netdevice.h> 48#include <linux/netdevice.h>
48#include <net/if_inet6.h> 49#include <net/if_inet6.h>
50#include <net/ipv6.h>
49 51
50#define IN6_ADDR_HSIZE 16 52#define IN6_ADDR_HSIZE 16
51 53
diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h
index 7352e455053c..fcb05a387dbe 100644
--- a/include/net/pkt_sched.h
+++ b/include/net/pkt_sched.h
@@ -157,7 +157,8 @@ psched_tod_diff(int delta_sec, int bound)
157 case 1: \ 157 case 1: \
158 __delta += 1000000; \ 158 __delta += 1000000; \
159 case 0: \ 159 case 0: \
160 __delta = abs(__delta); \ 160 if (__delta > bound || __delta < 0) \
161 __delta = bound; \
161 } \ 162 } \
162 __delta; \ 163 __delta; \
163}) 164})
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 73e9a8ca3d3b..e142a256d5dc 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -1,6 +1,7 @@
1#ifndef _NET_XFRM_H 1#ifndef _NET_XFRM_H
2#define _NET_XFRM_H 2#define _NET_XFRM_H
3 3
4#include <linux/compiler.h>
4#include <linux/xfrm.h> 5#include <linux/xfrm.h>
5#include <linux/spinlock.h> 6#include <linux/spinlock.h>
6#include <linux/list.h> 7#include <linux/list.h>
@@ -516,6 +517,15 @@ struct xfrm_dst
516 u32 child_mtu_cached; 517 u32 child_mtu_cached;
517}; 518};
518 519
520static inline void xfrm_dst_destroy(struct xfrm_dst *xdst)
521{
522 dst_release(xdst->route);
523 if (likely(xdst->u.dst.xfrm))
524 xfrm_state_put(xdst->u.dst.xfrm);
525}
526
527extern void xfrm_dst_ifdown(struct dst_entry *dst, struct net_device *dev);
528
519/* Decapsulation state, used by the input to store data during 529/* Decapsulation state, used by the input to store data during
520 * decapsulation procedure, to be used later (during the policy 530 * decapsulation procedure, to be used later (during the policy
521 * check 531 * check
diff --git a/kernel/audit.c b/kernel/audit.c
index 0f84dd7af2c8..ac26d4d960d3 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -427,7 +427,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
427/* Get message from skb (based on rtnetlink_rcv_skb). Each message is 427/* Get message from skb (based on rtnetlink_rcv_skb). Each message is
428 * processed by audit_receive_msg. Malformed skbs with wrong length are 428 * processed by audit_receive_msg. Malformed skbs with wrong length are
429 * discarded silently. */ 429 * discarded silently. */
430static int audit_receive_skb(struct sk_buff *skb) 430static void audit_receive_skb(struct sk_buff *skb)
431{ 431{
432 int err; 432 int err;
433 struct nlmsghdr *nlh; 433 struct nlmsghdr *nlh;
@@ -436,7 +436,7 @@ static int audit_receive_skb(struct sk_buff *skb)
436 while (skb->len >= NLMSG_SPACE(0)) { 436 while (skb->len >= NLMSG_SPACE(0)) {
437 nlh = (struct nlmsghdr *)skb->data; 437 nlh = (struct nlmsghdr *)skb->data;
438 if (nlh->nlmsg_len < sizeof(*nlh) || skb->len < nlh->nlmsg_len) 438 if (nlh->nlmsg_len < sizeof(*nlh) || skb->len < nlh->nlmsg_len)
439 return 0; 439 return;
440 rlen = NLMSG_ALIGN(nlh->nlmsg_len); 440 rlen = NLMSG_ALIGN(nlh->nlmsg_len);
441 if (rlen > skb->len) 441 if (rlen > skb->len)
442 rlen = skb->len; 442 rlen = skb->len;
@@ -446,23 +446,20 @@ static int audit_receive_skb(struct sk_buff *skb)
446 netlink_ack(skb, nlh, 0); 446 netlink_ack(skb, nlh, 0);
447 skb_pull(skb, rlen); 447 skb_pull(skb, rlen);
448 } 448 }
449 return 0;
450} 449}
451 450
452/* Receive messages from netlink socket. */ 451/* Receive messages from netlink socket. */
453static void audit_receive(struct sock *sk, int length) 452static void audit_receive(struct sock *sk, int length)
454{ 453{
455 struct sk_buff *skb; 454 struct sk_buff *skb;
455 unsigned int qlen;
456 456
457 if (down_trylock(&audit_netlink_sem)) 457 down(&audit_netlink_sem);
458 return;
459 458
460 /* FIXME: this must not cause starvation */ 459 for (qlen = skb_queue_len(&sk->sk_receive_queue); qlen; qlen--) {
461 while ((skb = skb_dequeue(&sk->sk_receive_queue))) { 460 skb = skb_dequeue(&sk->sk_receive_queue);
462 if (audit_receive_skb(skb) && skb->len) 461 audit_receive_skb(skb);
463 skb_queue_head(&sk->sk_receive_queue, skb); 462 kfree_skb(skb);
464 else
465 kfree_skb(skb);
466 } 463 }
467 up(&audit_netlink_sem); 464 up(&audit_netlink_sem);
468} 465}
diff --git a/net/core/link_watch.c b/net/core/link_watch.c
index 4859b7446c6f..d43d1201275c 100644
--- a/net/core/link_watch.c
+++ b/net/core/link_watch.c
@@ -16,6 +16,7 @@
16#include <linux/netdevice.h> 16#include <linux/netdevice.h>
17#include <linux/if.h> 17#include <linux/if.h>
18#include <net/sock.h> 18#include <net/sock.h>
19#include <net/pkt_sched.h>
19#include <linux/rtnetlink.h> 20#include <linux/rtnetlink.h>
20#include <linux/jiffies.h> 21#include <linux/jiffies.h>
21#include <linux/spinlock.h> 22#include <linux/spinlock.h>
@@ -74,6 +75,12 @@ void linkwatch_run_queue(void)
74 clear_bit(__LINK_STATE_LINKWATCH_PENDING, &dev->state); 75 clear_bit(__LINK_STATE_LINKWATCH_PENDING, &dev->state);
75 76
76 if (dev->flags & IFF_UP) { 77 if (dev->flags & IFF_UP) {
78 if (netif_carrier_ok(dev)) {
79 WARN_ON(dev->qdisc_sleeping == &noop_qdisc);
80 dev_activate(dev);
81 } else
82 dev_deactivate(dev);
83
77 netdev_state_change(dev); 84 netdev_state_change(dev);
78 } 85 }
79 86
diff --git a/net/core/netfilter.c b/net/core/netfilter.c
index e51cfa46950c..22a8f127c4aa 100644
--- a/net/core/netfilter.c
+++ b/net/core/netfilter.c
@@ -217,21 +217,10 @@ void nf_debug_ip_local_deliver(struct sk_buff *skb)
217 * NF_IP_RAW_INPUT and NF_IP_PRE_ROUTING. */ 217 * NF_IP_RAW_INPUT and NF_IP_PRE_ROUTING. */
218 if (!skb->dev) { 218 if (!skb->dev) {
219 printk("ip_local_deliver: skb->dev is NULL.\n"); 219 printk("ip_local_deliver: skb->dev is NULL.\n");
220 } 220 } else {
221 else if (strcmp(skb->dev->name, "lo") == 0) {
222 if (skb->nf_debug != ((1 << NF_IP_LOCAL_OUT)
223 | (1 << NF_IP_POST_ROUTING)
224 | (1 << NF_IP_PRE_ROUTING)
225 | (1 << NF_IP_LOCAL_IN))) {
226 printk("ip_local_deliver: bad loopback skb: ");
227 debug_print_hooks_ip(skb->nf_debug);
228 nf_dump_skb(PF_INET, skb);
229 }
230 }
231 else {
232 if (skb->nf_debug != ((1<<NF_IP_PRE_ROUTING) 221 if (skb->nf_debug != ((1<<NF_IP_PRE_ROUTING)
233 | (1<<NF_IP_LOCAL_IN))) { 222 | (1<<NF_IP_LOCAL_IN))) {
234 printk("ip_local_deliver: bad non-lo skb: "); 223 printk("ip_local_deliver: bad skb: ");
235 debug_print_hooks_ip(skb->nf_debug); 224 debug_print_hooks_ip(skb->nf_debug);
236 nf_dump_skb(PF_INET, skb); 225 nf_dump_skb(PF_INET, skb);
237 } 226 }
@@ -247,8 +236,6 @@ void nf_debug_ip_loopback_xmit(struct sk_buff *newskb)
247 debug_print_hooks_ip(newskb->nf_debug); 236 debug_print_hooks_ip(newskb->nf_debug);
248 nf_dump_skb(PF_INET, newskb); 237 nf_dump_skb(PF_INET, newskb);
249 } 238 }
250 /* Clear to avoid confusing input check */
251 newskb->nf_debug = 0;
252} 239}
253 240
254void nf_debug_ip_finish_output2(struct sk_buff *skb) 241void nf_debug_ip_finish_output2(struct sk_buff *skb)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index d8c198e42f90..00caf4b318b2 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -86,30 +86,33 @@ struct sock *rtnl;
86 86
87struct rtnetlink_link * rtnetlink_links[NPROTO]; 87struct rtnetlink_link * rtnetlink_links[NPROTO];
88 88
89static const int rtm_min[(RTM_MAX+1-RTM_BASE)/4] = 89static const int rtm_min[RTM_NR_FAMILIES] =
90{ 90{
91 NLMSG_LENGTH(sizeof(struct ifinfomsg)), 91 [RTM_FAM(RTM_NEWLINK)] = NLMSG_LENGTH(sizeof(struct ifinfomsg)),
92 NLMSG_LENGTH(sizeof(struct ifaddrmsg)), 92 [RTM_FAM(RTM_NEWADDR)] = NLMSG_LENGTH(sizeof(struct ifaddrmsg)),
93 NLMSG_LENGTH(sizeof(struct rtmsg)), 93 [RTM_FAM(RTM_NEWROUTE)] = NLMSG_LENGTH(sizeof(struct rtmsg)),
94 NLMSG_LENGTH(sizeof(struct ndmsg)), 94 [RTM_FAM(RTM_NEWNEIGH)] = NLMSG_LENGTH(sizeof(struct ndmsg)),
95 NLMSG_LENGTH(sizeof(struct rtmsg)), 95 [RTM_FAM(RTM_NEWRULE)] = NLMSG_LENGTH(sizeof(struct rtmsg)),
96 NLMSG_LENGTH(sizeof(struct tcmsg)), 96 [RTM_FAM(RTM_NEWQDISC)] = NLMSG_LENGTH(sizeof(struct tcmsg)),
97 NLMSG_LENGTH(sizeof(struct tcmsg)), 97 [RTM_FAM(RTM_NEWTCLASS)] = NLMSG_LENGTH(sizeof(struct tcmsg)),
98 NLMSG_LENGTH(sizeof(struct tcmsg)), 98 [RTM_FAM(RTM_NEWTFILTER)] = NLMSG_LENGTH(sizeof(struct tcmsg)),
99 NLMSG_LENGTH(sizeof(struct tcamsg)) 99 [RTM_FAM(RTM_NEWACTION)] = NLMSG_LENGTH(sizeof(struct tcamsg)),
100 [RTM_FAM(RTM_NEWPREFIX)] = NLMSG_LENGTH(sizeof(struct rtgenmsg)),
101 [RTM_FAM(RTM_GETMULTICAST)] = NLMSG_LENGTH(sizeof(struct rtgenmsg)),
102 [RTM_FAM(RTM_GETANYCAST)] = NLMSG_LENGTH(sizeof(struct rtgenmsg)),
100}; 103};
101 104
102static const int rta_max[(RTM_MAX+1-RTM_BASE)/4] = 105static const int rta_max[RTM_NR_FAMILIES] =
103{ 106{
104 IFLA_MAX, 107 [RTM_FAM(RTM_NEWLINK)] = IFLA_MAX,
105 IFA_MAX, 108 [RTM_FAM(RTM_NEWADDR)] = IFA_MAX,
106 RTA_MAX, 109 [RTM_FAM(RTM_NEWROUTE)] = RTA_MAX,
107 NDA_MAX, 110 [RTM_FAM(RTM_NEWNEIGH)] = NDA_MAX,
108 RTA_MAX, 111 [RTM_FAM(RTM_NEWRULE)] = RTA_MAX,
109 TCA_MAX, 112 [RTM_FAM(RTM_NEWQDISC)] = TCA_MAX,
110 TCA_MAX, 113 [RTM_FAM(RTM_NEWTCLASS)] = TCA_MAX,
111 TCA_MAX, 114 [RTM_FAM(RTM_NEWTFILTER)] = TCA_MAX,
112 TCAA_MAX 115 [RTM_FAM(RTM_NEWACTION)] = TCAA_MAX,
113}; 116};
114 117
115void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const void *data) 118void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const void *data)
@@ -606,27 +609,33 @@ static inline int rtnetlink_rcv_skb(struct sk_buff *skb)
606 609
607/* 610/*
608 * rtnetlink input queue processing routine: 611 * rtnetlink input queue processing routine:
609 * - try to acquire shared lock. If it is failed, defer processing. 612 * - process as much as there was in the queue upon entry.
610 * - feed skbs to rtnetlink_rcv_skb, until it refuse a message, 613 * - feed skbs to rtnetlink_rcv_skb, until it refuse a message,
611 * that will occur, when a dump started and/or acquisition of 614 * that will occur, when a dump started.
612 * exclusive lock failed.
613 */ 615 */
614 616
615static void rtnetlink_rcv(struct sock *sk, int len) 617static void rtnetlink_rcv(struct sock *sk, int len)
616{ 618{
619 unsigned int qlen = skb_queue_len(&sk->sk_receive_queue);
620
617 do { 621 do {
618 struct sk_buff *skb; 622 struct sk_buff *skb;
619 623
620 if (rtnl_shlock_nowait()) 624 rtnl_lock();
621 return; 625
626 if (qlen > skb_queue_len(&sk->sk_receive_queue))
627 qlen = skb_queue_len(&sk->sk_receive_queue);
622 628
623 while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { 629 for (; qlen; qlen--) {
630 skb = skb_dequeue(&sk->sk_receive_queue);
624 if (rtnetlink_rcv_skb(skb)) { 631 if (rtnetlink_rcv_skb(skb)) {
625 if (skb->len) 632 if (skb->len)
626 skb_queue_head(&sk->sk_receive_queue, 633 skb_queue_head(&sk->sk_receive_queue,
627 skb); 634 skb);
628 else 635 else {
629 kfree_skb(skb); 636 kfree_skb(skb);
637 qlen--;
638 }
630 break; 639 break;
631 } 640 }
632 kfree_skb(skb); 641 kfree_skb(skb);
@@ -635,10 +644,10 @@ static void rtnetlink_rcv(struct sock *sk, int len)
635 up(&rtnl_sem); 644 up(&rtnl_sem);
636 645
637 netdev_run_todo(); 646 netdev_run_todo();
638 } while (rtnl && rtnl->sk_receive_queue.qlen); 647 } while (qlen);
639} 648}
640 649
641static struct rtnetlink_link link_rtnetlink_table[RTM_MAX-RTM_BASE+1] = 650static struct rtnetlink_link link_rtnetlink_table[RTM_NR_MSGTYPES] =
642{ 651{
643 [RTM_GETLINK - RTM_BASE] = { .dumpit = rtnetlink_dump_ifinfo }, 652 [RTM_GETLINK - RTM_BASE] = { .dumpit = rtnetlink_dump_ifinfo },
644 [RTM_SETLINK - RTM_BASE] = { .doit = do_setlink }, 653 [RTM_SETLINK - RTM_BASE] = { .doit = do_setlink },
diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c
index c2a0346f423b..e6e23eb14428 100644
--- a/net/decnet/dn_dev.c
+++ b/net/decnet/dn_dev.c
@@ -1411,21 +1411,22 @@ static struct file_operations dn_dev_seq_fops = {
1411 1411
1412#endif /* CONFIG_PROC_FS */ 1412#endif /* CONFIG_PROC_FS */
1413 1413
1414static struct rtnetlink_link dnet_rtnetlink_table[RTM_MAX-RTM_BASE+1] = 1414static struct rtnetlink_link dnet_rtnetlink_table[RTM_NR_MSGTYPES] =
1415{ 1415{
1416 [4] = { .doit = dn_dev_rtm_newaddr, }, 1416 [RTM_NEWADDR - RTM_BASE] = { .doit = dn_dev_rtm_newaddr, },
1417 [5] = { .doit = dn_dev_rtm_deladdr, }, 1417 [RTM_DELADDR - RTM_BASE] = { .doit = dn_dev_rtm_deladdr, },
1418 [6] = { .dumpit = dn_dev_dump_ifaddr, }, 1418 [RTM_GETADDR - RTM_BASE] = { .dumpit = dn_dev_dump_ifaddr, },
1419
1420#ifdef CONFIG_DECNET_ROUTER 1419#ifdef CONFIG_DECNET_ROUTER
1421 [8] = { .doit = dn_fib_rtm_newroute, }, 1420 [RTM_NEWROUTE - RTM_BASE] = { .doit = dn_fib_rtm_newroute, },
1422 [9] = { .doit = dn_fib_rtm_delroute, }, 1421 [RTM_DELROUTE - RTM_BASE] = { .doit = dn_fib_rtm_delroute, },
1423 [10] = { .doit = dn_cache_getroute, .dumpit = dn_fib_dump, }, 1422 [RTM_GETROUTE - RTM_BASE] = { .doit = dn_cache_getroute,
1424 [16] = { .doit = dn_fib_rtm_newrule, }, 1423 .dumpit = dn_fib_dump, },
1425 [17] = { .doit = dn_fib_rtm_delrule, }, 1424 [RTM_NEWRULE - RTM_BASE] = { .doit = dn_fib_rtm_newrule, },
1426 [18] = { .dumpit = dn_fib_dump_rules, }, 1425 [RTM_DELRULE - RTM_BASE] = { .doit = dn_fib_rtm_delrule, },
1426 [RTM_GETRULE - RTM_BASE] = { .dumpit = dn_fib_dump_rules, },
1427#else 1427#else
1428 [10] = { .doit = dn_cache_getroute, .dumpit = dn_cache_dump, }, 1428 [RTM_GETROUTE - RTM_BASE] = { .doit = dn_cache_getroute,
1429 .dumpit = dn_cache_dump,
1429#endif 1430#endif
1430 1431
1431}; 1432};
diff --git a/net/decnet/netfilter/dn_rtmsg.c b/net/decnet/netfilter/dn_rtmsg.c
index f86a6259fd12..284a9998e53d 100644
--- a/net/decnet/netfilter/dn_rtmsg.c
+++ b/net/decnet/netfilter/dn_rtmsg.c
@@ -119,8 +119,9 @@ static inline void dnrmg_receive_user_skb(struct sk_buff *skb)
119static void dnrmg_receive_user_sk(struct sock *sk, int len) 119static void dnrmg_receive_user_sk(struct sock *sk, int len)
120{ 120{
121 struct sk_buff *skb; 121 struct sk_buff *skb;
122 unsigned int qlen = skb_queue_len(&sk->sk_receive_queue);
122 123
123 while((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { 124 for (; qlen && (skb = skb_dequeue(&sk->sk_receive_queue)); qlen--) {
124 dnrmg_receive_user_skb(skb); 125 dnrmg_receive_user_skb(skb);
125 kfree_skb(skb); 126 kfree_skb(skb);
126 } 127 }
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index eea7ef010776..abbc6d5c183e 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1107,17 +1107,18 @@ static void rtmsg_ifa(int event, struct in_ifaddr* ifa)
1107 } 1107 }
1108} 1108}
1109 1109
1110static struct rtnetlink_link inet_rtnetlink_table[RTM_MAX - RTM_BASE + 1] = { 1110static struct rtnetlink_link inet_rtnetlink_table[RTM_NR_MSGTYPES] = {
1111 [4] = { .doit = inet_rtm_newaddr, }, 1111 [RTM_NEWADDR - RTM_BASE] = { .doit = inet_rtm_newaddr, },
1112 [5] = { .doit = inet_rtm_deladdr, }, 1112 [RTM_DELADDR - RTM_BASE] = { .doit = inet_rtm_deladdr, },
1113 [6] = { .dumpit = inet_dump_ifaddr, }, 1113 [RTM_GETADDR - RTM_BASE] = { .dumpit = inet_dump_ifaddr, },
1114 [8] = { .doit = inet_rtm_newroute, }, 1114 [RTM_NEWROUTE - RTM_BASE] = { .doit = inet_rtm_newroute, },
1115 [9] = { .doit = inet_rtm_delroute, }, 1115 [RTM_DELROUTE - RTM_BASE] = { .doit = inet_rtm_delroute, },
1116 [10] = { .doit = inet_rtm_getroute, .dumpit = inet_dump_fib, }, 1116 [RTM_GETROUTE - RTM_BASE] = { .doit = inet_rtm_getroute,
1117 .dumpit = inet_dump_fib, },
1117#ifdef CONFIG_IP_MULTIPLE_TABLES 1118#ifdef CONFIG_IP_MULTIPLE_TABLES
1118 [16] = { .doit = inet_rtm_newrule, }, 1119 [RTM_NEWRULE - RTM_BASE] = { .doit = inet_rtm_newrule, },
1119 [17] = { .doit = inet_rtm_delrule, }, 1120 [RTM_DELRULE - RTM_BASE] = { .doit = inet_rtm_delrule, },
1120 [18] = { .dumpit = inet_dump_rules, }, 1121 [RTM_GETRULE - RTM_BASE] = { .dumpit = inet_dump_rules, },
1121#endif 1122#endif
1122}; 1123};
1123 1124
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 38f69532a029..24fe3e00b42b 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -111,6 +111,7 @@ static int ip_dev_loopback_xmit(struct sk_buff *newskb)
111#ifdef CONFIG_NETFILTER_DEBUG 111#ifdef CONFIG_NETFILTER_DEBUG
112 nf_debug_ip_loopback_xmit(newskb); 112 nf_debug_ip_loopback_xmit(newskb);
113#endif 113#endif
114 nf_reset(newskb);
114 netif_rx(newskb); 115 netif_rx(newskb);
115 return 0; 116 return 0;
116} 117}
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_tcp.c b/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
index 2b87c1974be6..721ddbf522b4 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
@@ -819,6 +819,7 @@ static int tcp_error(struct sk_buff *skb,
819 */ 819 */
820 /* FIXME: Source route IP option packets --RR */ 820 /* FIXME: Source route IP option packets --RR */
821 if (hooknum == NF_IP_PRE_ROUTING 821 if (hooknum == NF_IP_PRE_ROUTING
822 && skb->ip_summed != CHECKSUM_UNNECESSARY
822 && csum_tcpudp_magic(iph->saddr, iph->daddr, tcplen, IPPROTO_TCP, 823 && csum_tcpudp_magic(iph->saddr, iph->daddr, tcplen, IPPROTO_TCP,
823 skb->ip_summed == CHECKSUM_HW ? skb->csum 824 skb->ip_summed == CHECKSUM_HW ? skb->csum
824 : skb_checksum(skb, iph->ihl*4, tcplen, 0))) { 825 : skb_checksum(skb, iph->ihl*4, tcplen, 0))) {
diff --git a/net/ipv4/netfilter/ip_queue.c b/net/ipv4/netfilter/ip_queue.c
index 9e40dffc204f..e5746b674413 100644
--- a/net/ipv4/netfilter/ip_queue.c
+++ b/net/ipv4/netfilter/ip_queue.c
@@ -546,20 +546,18 @@ ipq_rcv_skb(struct sk_buff *skb)
546static void 546static void
547ipq_rcv_sk(struct sock *sk, int len) 547ipq_rcv_sk(struct sock *sk, int len)
548{ 548{
549 do { 549 struct sk_buff *skb;
550 struct sk_buff *skb; 550 unsigned int qlen;
551 551
552 if (down_trylock(&ipqnl_sem)) 552 down(&ipqnl_sem);
553 return;
554 553
555 while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { 554 for (qlen = skb_queue_len(&sk->sk_receive_queue); qlen; qlen--) {
556 ipq_rcv_skb(skb); 555 skb = skb_dequeue(&sk->sk_receive_queue);
557 kfree_skb(skb); 556 ipq_rcv_skb(skb);
558 } 557 kfree_skb(skb);
558 }
559 559
560 up(&ipqnl_sem); 560 up(&ipqnl_sem);
561
562 } while (ipqnl && ipqnl->sk_receive_queue.qlen);
563} 561}
564 562
565static int 563static int
diff --git a/net/ipv4/netfilter/iptable_raw.c b/net/ipv4/netfilter/iptable_raw.c
index 01b4a3c814d3..47449ba83eb9 100644
--- a/net/ipv4/netfilter/iptable_raw.c
+++ b/net/ipv4/netfilter/iptable_raw.c
@@ -103,13 +103,15 @@ static struct nf_hook_ops ipt_ops[] = {
103 .hook = ipt_hook, 103 .hook = ipt_hook,
104 .pf = PF_INET, 104 .pf = PF_INET,
105 .hooknum = NF_IP_PRE_ROUTING, 105 .hooknum = NF_IP_PRE_ROUTING,
106 .priority = NF_IP_PRI_RAW 106 .priority = NF_IP_PRI_RAW,
107 .owner = THIS_MODULE,
107 }, 108 },
108 { 109 {
109 .hook = ipt_hook, 110 .hook = ipt_hook,
110 .pf = PF_INET, 111 .pf = PF_INET,
111 .hooknum = NF_IP_LOCAL_OUT, 112 .hooknum = NF_IP_LOCAL_OUT,
112 .priority = NF_IP_PRI_RAW 113 .priority = NF_IP_PRI_RAW,
114 .owner = THIS_MODULE,
113 }, 115 },
114}; 116};
115 117
diff --git a/net/ipv4/tcp_diag.c b/net/ipv4/tcp_diag.c
index 313c1408da33..8faa8948f75c 100644
--- a/net/ipv4/tcp_diag.c
+++ b/net/ipv4/tcp_diag.c
@@ -777,8 +777,9 @@ static inline void tcpdiag_rcv_skb(struct sk_buff *skb)
777static void tcpdiag_rcv(struct sock *sk, int len) 777static void tcpdiag_rcv(struct sock *sk, int len)
778{ 778{
779 struct sk_buff *skb; 779 struct sk_buff *skb;
780 unsigned int qlen = skb_queue_len(&sk->sk_receive_queue);
780 781
781 while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { 782 while (qlen-- && (skb = skb_dequeue(&sk->sk_receive_queue))) {
782 tcpdiag_rcv_skb(skb); 783 tcpdiag_rcv_skb(skb);
783 kfree_skb(skb); 784 kfree_skb(skb);
784 } 785 }
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 3ac6659869c4..dad98e4a5043 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -222,10 +222,13 @@ static int tcp_v4_get_port(struct sock *sk, unsigned short snum)
222 int rover; 222 int rover;
223 223
224 spin_lock(&tcp_portalloc_lock); 224 spin_lock(&tcp_portalloc_lock);
225 rover = tcp_port_rover; 225 if (tcp_port_rover < low)
226 rover = low;
227 else
228 rover = tcp_port_rover;
226 do { 229 do {
227 rover++; 230 rover++;
228 if (rover < low || rover > high) 231 if (rover > high)
229 rover = low; 232 rover = low;
230 head = &tcp_bhash[tcp_bhashfn(rover)]; 233 head = &tcp_bhash[tcp_bhashfn(rover)];
231 spin_lock(&head->lock); 234 spin_lock(&head->lock);
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
index 7fe2afd2e669..b2b60f3e9cdd 100644
--- a/net/ipv4/xfrm4_policy.c
+++ b/net/ipv4/xfrm4_policy.c
@@ -8,7 +8,10 @@
8 * 8 *
9 */ 9 */
10 10
11#include <asm/bug.h>
12#include <linux/compiler.h>
11#include <linux/config.h> 13#include <linux/config.h>
14#include <linux/inetdevice.h>
12#include <net/xfrm.h> 15#include <net/xfrm.h>
13#include <net/ip.h> 16#include <net/ip.h>
14 17
@@ -152,6 +155,8 @@ __xfrm4_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
152 x->u.rt.rt_dst = rt0->rt_dst; 155 x->u.rt.rt_dst = rt0->rt_dst;
153 x->u.rt.rt_gateway = rt->rt_gateway; 156 x->u.rt.rt_gateway = rt->rt_gateway;
154 x->u.rt.rt_spec_dst = rt0->rt_spec_dst; 157 x->u.rt.rt_spec_dst = rt0->rt_spec_dst;
158 x->u.rt.idev = rt0->idev;
159 in_dev_hold(rt0->idev);
155 header_len -= x->u.dst.xfrm->props.header_len; 160 header_len -= x->u.dst.xfrm->props.header_len;
156 trailer_len -= x->u.dst.xfrm->props.trailer_len; 161 trailer_len -= x->u.dst.xfrm->props.trailer_len;
157 } 162 }
@@ -243,11 +248,48 @@ static void xfrm4_update_pmtu(struct dst_entry *dst, u32 mtu)
243 path->ops->update_pmtu(path, mtu); 248 path->ops->update_pmtu(path, mtu);
244} 249}
245 250
251static void xfrm4_dst_destroy(struct dst_entry *dst)
252{
253 struct xfrm_dst *xdst = (struct xfrm_dst *)dst;
254
255 if (likely(xdst->u.rt.idev))
256 in_dev_put(xdst->u.rt.idev);
257 xfrm_dst_destroy(xdst);
258}
259
260static void xfrm4_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
261 int unregister)
262{
263 struct xfrm_dst *xdst;
264
265 if (!unregister)
266 return;
267
268 xdst = (struct xfrm_dst *)dst;
269 if (xdst->u.rt.idev->dev == dev) {
270 struct in_device *loopback_idev = in_dev_get(&loopback_dev);
271 BUG_ON(!loopback_idev);
272
273 do {
274 in_dev_put(xdst->u.rt.idev);
275 xdst->u.rt.idev = loopback_idev;
276 in_dev_hold(loopback_idev);
277 xdst = (struct xfrm_dst *)xdst->u.dst.child;
278 } while (xdst->u.dst.xfrm);
279
280 __in_dev_put(loopback_idev);
281 }
282
283 xfrm_dst_ifdown(dst, dev);
284}
285
246static struct dst_ops xfrm4_dst_ops = { 286static struct dst_ops xfrm4_dst_ops = {
247 .family = AF_INET, 287 .family = AF_INET,
248 .protocol = __constant_htons(ETH_P_IP), 288 .protocol = __constant_htons(ETH_P_IP),
249 .gc = xfrm4_garbage_collect, 289 .gc = xfrm4_garbage_collect,
250 .update_pmtu = xfrm4_update_pmtu, 290 .update_pmtu = xfrm4_update_pmtu,
291 .destroy = xfrm4_dst_destroy,
292 .ifdown = xfrm4_dst_ifdown,
251 .gc_thresh = 1024, 293 .gc_thresh = 1024,
252 .entry_size = sizeof(struct xfrm_dst), 294 .entry_size = sizeof(struct xfrm_dst),
253}; 295};
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 7196ac2f2d16..7744a2592693 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -3076,7 +3076,7 @@ static void inet6_prefix_notify(int event, struct inet6_dev *idev,
3076 netlink_broadcast(rtnl, skb, 0, RTMGRP_IPV6_PREFIX, GFP_ATOMIC); 3076 netlink_broadcast(rtnl, skb, 0, RTMGRP_IPV6_PREFIX, GFP_ATOMIC);
3077} 3077}
3078 3078
3079static struct rtnetlink_link inet6_rtnetlink_table[RTM_MAX - RTM_BASE + 1] = { 3079static struct rtnetlink_link inet6_rtnetlink_table[RTM_NR_MSGTYPES] = {
3080 [RTM_GETLINK - RTM_BASE] = { .dumpit = inet6_dump_ifinfo, }, 3080 [RTM_GETLINK - RTM_BASE] = { .dumpit = inet6_dump_ifinfo, },
3081 [RTM_NEWADDR - RTM_BASE] = { .doit = inet6_rtm_newaddr, }, 3081 [RTM_NEWADDR - RTM_BASE] = { .doit = inet6_rtm_newaddr, },
3082 [RTM_DELADDR - RTM_BASE] = { .doit = inet6_rtm_deladdr, }, 3082 [RTM_DELADDR - RTM_BASE] = { .doit = inet6_rtm_deladdr, },
diff --git a/net/ipv6/netfilter/ip6_queue.c b/net/ipv6/netfilter/ip6_queue.c
index c54830b89593..750943e2d34e 100644
--- a/net/ipv6/netfilter/ip6_queue.c
+++ b/net/ipv6/netfilter/ip6_queue.c
@@ -549,20 +549,18 @@ ipq_rcv_skb(struct sk_buff *skb)
549static void 549static void
550ipq_rcv_sk(struct sock *sk, int len) 550ipq_rcv_sk(struct sock *sk, int len)
551{ 551{
552 do { 552 struct sk_buff *skb;
553 struct sk_buff *skb; 553 unsigned int qlen;
554 554
555 if (down_trylock(&ipqnl_sem)) 555 down(&ipqnl_sem);
556 return;
557 556
558 while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { 557 for (qlen = skb_queue_len(&sk->sk_receive_queue); qlen; qlen--) {
559 ipq_rcv_skb(skb); 558 skb = skb_dequeue(&sk->sk_receive_queue);
560 kfree_skb(skb); 559 ipq_rcv_skb(skb);
561 } 560 kfree_skb(skb);
561 }
562 562
563 up(&ipqnl_sem); 563 up(&ipqnl_sem);
564
565 } while (ipqnl && ipqnl->sk_receive_queue.qlen);
566} 564}
567 565
568static int 566static int
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 1352c1d9bf4d..617645bc5ed6 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -455,11 +455,11 @@ csum_copy_err:
455static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl, 455static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl,
456 struct raw6_sock *rp) 456 struct raw6_sock *rp)
457{ 457{
458 struct inet_sock *inet = inet_sk(sk);
459 struct sk_buff *skb; 458 struct sk_buff *skb;
460 int err = 0; 459 int err = 0;
461 int offset; 460 int offset;
462 int len; 461 int len;
462 int total_len;
463 u32 tmp_csum; 463 u32 tmp_csum;
464 u16 csum; 464 u16 csum;
465 465
@@ -470,7 +470,8 @@ static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl,
470 goto out; 470 goto out;
471 471
472 offset = rp->offset; 472 offset = rp->offset;
473 if (offset >= inet->cork.length - 1) { 473 total_len = inet_sk(sk)->cork.length - (skb->nh.raw - skb->data);
474 if (offset >= total_len - 1) {
474 err = -EINVAL; 475 err = -EINVAL;
475 ip6_flush_pending_frames(sk); 476 ip6_flush_pending_frames(sk);
476 goto out; 477 goto out;
@@ -514,7 +515,7 @@ static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl,
514 515
515 tmp_csum = csum_ipv6_magic(&fl->fl6_src, 516 tmp_csum = csum_ipv6_magic(&fl->fl6_src,
516 &fl->fl6_dst, 517 &fl->fl6_dst,
517 inet->cork.length, fl->proto, tmp_csum); 518 total_len, fl->proto, tmp_csum);
518 519
519 if (tmp_csum == 0) 520 if (tmp_csum == 0)
520 tmp_csum = -1; 521 tmp_csum = -1;
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 4760c85e19db..0f69e800a0ad 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -139,9 +139,12 @@ static int tcp_v6_get_port(struct sock *sk, unsigned short snum)
139 int rover; 139 int rover;
140 140
141 spin_lock(&tcp_portalloc_lock); 141 spin_lock(&tcp_portalloc_lock);
142 rover = tcp_port_rover; 142 if (tcp_port_rover < low)
143 rover = low;
144 else
145 rover = tcp_port_rover;
143 do { rover++; 146 do { rover++;
144 if ((rover < low) || (rover > high)) 147 if (rover > high)
145 rover = low; 148 rover = low;
146 head = &tcp_bhash[tcp_bhashfn(rover)]; 149 head = &tcp_bhash[tcp_bhashfn(rover)];
147 spin_lock(&head->lock); 150 spin_lock(&head->lock);
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
index 8a4f37de4d2d..4429b1a1fe5f 100644
--- a/net/ipv6/xfrm6_policy.c
+++ b/net/ipv6/xfrm6_policy.c
@@ -11,7 +11,11 @@
11 * 11 *
12 */ 12 */
13 13
14#include <asm/bug.h>
15#include <linux/compiler.h>
14#include <linux/config.h> 16#include <linux/config.h>
17#include <linux/netdevice.h>
18#include <net/addrconf.h>
15#include <net/xfrm.h> 19#include <net/xfrm.h>
16#include <net/ip.h> 20#include <net/ip.h>
17#include <net/ipv6.h> 21#include <net/ipv6.h>
@@ -166,6 +170,8 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
166 memcpy(&x->u.rt6.rt6i_gateway, &rt0->rt6i_gateway, sizeof(x->u.rt6.rt6i_gateway)); 170 memcpy(&x->u.rt6.rt6i_gateway, &rt0->rt6i_gateway, sizeof(x->u.rt6.rt6i_gateway));
167 x->u.rt6.rt6i_dst = rt0->rt6i_dst; 171 x->u.rt6.rt6i_dst = rt0->rt6i_dst;
168 x->u.rt6.rt6i_src = rt0->rt6i_src; 172 x->u.rt6.rt6i_src = rt0->rt6i_src;
173 x->u.rt6.rt6i_idev = rt0->rt6i_idev;
174 in6_dev_hold(rt0->rt6i_idev);
169 header_len -= x->u.dst.xfrm->props.header_len; 175 header_len -= x->u.dst.xfrm->props.header_len;
170 trailer_len -= x->u.dst.xfrm->props.trailer_len; 176 trailer_len -= x->u.dst.xfrm->props.trailer_len;
171 } 177 }
@@ -251,11 +257,48 @@ static void xfrm6_update_pmtu(struct dst_entry *dst, u32 mtu)
251 path->ops->update_pmtu(path, mtu); 257 path->ops->update_pmtu(path, mtu);
252} 258}
253 259
260static void xfrm6_dst_destroy(struct dst_entry *dst)
261{
262 struct xfrm_dst *xdst = (struct xfrm_dst *)dst;
263
264 if (likely(xdst->u.rt6.rt6i_idev))
265 in6_dev_put(xdst->u.rt6.rt6i_idev);
266 xfrm_dst_destroy(xdst);
267}
268
269static void xfrm6_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
270 int unregister)
271{
272 struct xfrm_dst *xdst;
273
274 if (!unregister)
275 return;
276
277 xdst = (struct xfrm_dst *)dst;
278 if (xdst->u.rt6.rt6i_idev->dev == dev) {
279 struct inet6_dev *loopback_idev = in6_dev_get(&loopback_dev);
280 BUG_ON(!loopback_idev);
281
282 do {
283 in6_dev_put(xdst->u.rt6.rt6i_idev);
284 xdst->u.rt6.rt6i_idev = loopback_idev;
285 in6_dev_hold(loopback_idev);
286 xdst = (struct xfrm_dst *)xdst->u.dst.child;
287 } while (xdst->u.dst.xfrm);
288
289 __in6_dev_put(loopback_idev);
290 }
291
292 xfrm_dst_ifdown(dst, dev);
293}
294
254static struct dst_ops xfrm6_dst_ops = { 295static struct dst_ops xfrm6_dst_ops = {
255 .family = AF_INET6, 296 .family = AF_INET6,
256 .protocol = __constant_htons(ETH_P_IPV6), 297 .protocol = __constant_htons(ETH_P_IPV6),
257 .gc = xfrm6_garbage_collect, 298 .gc = xfrm6_garbage_collect,
258 .update_pmtu = xfrm6_update_pmtu, 299 .update_pmtu = xfrm6_update_pmtu,
300 .destroy = xfrm6_dst_destroy,
301 .ifdown = xfrm6_dst_ifdown,
259 .gc_thresh = 1024, 302 .gc_thresh = 1024,
260 .entry_size = sizeof(struct xfrm_dst), 303 .entry_size = sizeof(struct xfrm_dst),
261}; 304};
diff --git a/net/irda/irda_device.c b/net/irda/irda_device.c
index d6ccd3239dcf..70543d89438b 100644
--- a/net/irda/irda_device.c
+++ b/net/irda/irda_device.c
@@ -470,6 +470,7 @@ void irda_device_unregister_dongle(struct dongle_reg *dongle)
470} 470}
471EXPORT_SYMBOL(irda_device_unregister_dongle); 471EXPORT_SYMBOL(irda_device_unregister_dongle);
472 472
473#ifdef CONFIG_ISA_DMA_API
473/* 474/*
474 * Function setup_dma (idev, buffer, count, mode) 475 * Function setup_dma (idev, buffer, count, mode)
475 * 476 *
@@ -492,3 +493,4 @@ void irda_setup_dma(int channel, dma_addr_t buffer, int count, int mode)
492 release_dma_lock(flags); 493 release_dma_lock(flags);
493} 494}
494EXPORT_SYMBOL(irda_setup_dma); 495EXPORT_SYMBOL(irda_setup_dma);
496#endif
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 29a5fd231eac..4ee392066148 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -373,7 +373,6 @@ static int netlink_release(struct socket *sock)
373 nlk->cb->done(nlk->cb); 373 nlk->cb->done(nlk->cb);
374 netlink_destroy_callback(nlk->cb); 374 netlink_destroy_callback(nlk->cb);
375 nlk->cb = NULL; 375 nlk->cb = NULL;
376 __sock_put(sk);
377 } 376 }
378 spin_unlock(&nlk->cb_lock); 377 spin_unlock(&nlk->cb_lock);
379 378
@@ -1099,7 +1098,6 @@ static int netlink_dump(struct sock *sk)
1099 spin_unlock(&nlk->cb_lock); 1098 spin_unlock(&nlk->cb_lock);
1100 1099
1101 netlink_destroy_callback(cb); 1100 netlink_destroy_callback(cb);
1102 __sock_put(sk);
1103 return 0; 1101 return 0;
1104} 1102}
1105 1103
@@ -1138,7 +1136,6 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
1138 return -EBUSY; 1136 return -EBUSY;
1139 } 1137 }
1140 nlk->cb = cb; 1138 nlk->cb = cb;
1141 sock_hold(sk);
1142 spin_unlock(&nlk->cb_lock); 1139 spin_unlock(&nlk->cb_lock);
1143 1140
1144 netlink_dump(sk); 1141 netlink_dump(sk);
diff --git a/net/sched/Kconfig b/net/sched/Kconfig
index 9c118baed9dc..b0941186f867 100644
--- a/net/sched/Kconfig
+++ b/net/sched/Kconfig
@@ -185,7 +185,7 @@ config NET_SCH_GRED
185 depends on NET_SCHED 185 depends on NET_SCHED
186 help 186 help
187 Say Y here if you want to use the Generic Random Early Detection 187 Say Y here if you want to use the Generic Random Early Detection
188 (RED) packet scheduling algorithm for some of your network devices 188 (GRED) packet scheduling algorithm for some of your network devices
189 (see the top of <file:net/sched/sch_red.c> for details and 189 (see the top of <file:net/sched/sch_red.c> for details and
190 references about the algorithm). 190 references about the algorithm).
191 191
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 5e6cc371b39e..cafcb084098d 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -171,10 +171,10 @@ repeat:
171 skb->tc_verd = SET_TC_OK2MUNGE(skb->tc_verd); 171 skb->tc_verd = SET_TC_OK2MUNGE(skb->tc_verd);
172 skb->tc_verd = CLR_TC_MUNGED(skb->tc_verd); 172 skb->tc_verd = CLR_TC_MUNGED(skb->tc_verd);
173 } 173 }
174 if (ret != TC_ACT_PIPE)
175 goto exec_done;
176 if (ret == TC_ACT_REPEAT) 174 if (ret == TC_ACT_REPEAT)
177 goto repeat; /* we need a ttl - JHS */ 175 goto repeat; /* we need a ttl - JHS */
176 if (ret != TC_ACT_PIPE)
177 goto exec_done;
178 } 178 }
179 act = a->next; 179 act = a->next;
180 } 180 }
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 4323a74eea30..07977f8f2679 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -1289,6 +1289,7 @@ static int __init pktsched_init(void)
1289 1289
1290subsys_initcall(pktsched_init); 1290subsys_initcall(pktsched_init);
1291 1291
1292EXPORT_SYMBOL(qdisc_lookup);
1292EXPORT_SYMBOL(qdisc_get_rtab); 1293EXPORT_SYMBOL(qdisc_get_rtab);
1293EXPORT_SYMBOL(qdisc_put_rtab); 1294EXPORT_SYMBOL(qdisc_put_rtab);
1294EXPORT_SYMBOL(register_qdisc); 1295EXPORT_SYMBOL(register_qdisc);
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 8c01e023f02e..87e48a4e1051 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -179,6 +179,7 @@ requeue:
179 netif_schedule(dev); 179 netif_schedule(dev);
180 return 1; 180 return 1;
181 } 181 }
182 BUG_ON((int) q->q.qlen < 0);
182 return q->q.qlen; 183 return q->q.qlen;
183} 184}
184 185
@@ -539,6 +540,10 @@ void dev_activate(struct net_device *dev)
539 write_unlock_bh(&qdisc_tree_lock); 540 write_unlock_bh(&qdisc_tree_lock);
540 } 541 }
541 542
543 if (!netif_carrier_ok(dev))
544 /* Delay activation until next carrier-on event */
545 return;
546
542 spin_lock_bh(&dev->queue_lock); 547 spin_lock_bh(&dev->queue_lock);
543 rcu_assign_pointer(dev->qdisc, dev->qdisc_sleeping); 548 rcu_assign_pointer(dev->qdisc, dev->qdisc_sleeping);
544 if (dev->qdisc != &noqueue_qdisc) { 549 if (dev->qdisc != &noqueue_qdisc) {
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index a85935e7d53d..558cc087e602 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -717,6 +717,10 @@ static int htb_enqueue(struct sk_buff *skb, struct Qdisc *sch)
717 if (q->direct_queue.qlen < q->direct_qlen) { 717 if (q->direct_queue.qlen < q->direct_qlen) {
718 __skb_queue_tail(&q->direct_queue, skb); 718 __skb_queue_tail(&q->direct_queue, skb);
719 q->direct_pkts++; 719 q->direct_pkts++;
720 } else {
721 kfree_skb(skb);
722 sch->qstats.drops++;
723 return NET_XMIT_DROP;
720 } 724 }
721#ifdef CONFIG_NET_CLS_ACT 725#ifdef CONFIG_NET_CLS_ACT
722 } else if (!cl) { 726 } else if (!cl) {
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index 31c29deb139d..e0c9fbe73b15 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -138,38 +138,77 @@ static long tabledist(unsigned long mu, long sigma,
138} 138}
139 139
140/* Put skb in the private delayed queue. */ 140/* Put skb in the private delayed queue. */
141static int delay_skb(struct Qdisc *sch, struct sk_buff *skb) 141static int netem_delay(struct Qdisc *sch, struct sk_buff *skb)
142{ 142{
143 struct netem_sched_data *q = qdisc_priv(sch); 143 struct netem_sched_data *q = qdisc_priv(sch);
144 struct netem_skb_cb *cb = (struct netem_skb_cb *)skb->cb;
145 psched_tdiff_t td; 144 psched_tdiff_t td;
146 psched_time_t now; 145 psched_time_t now;
147 146
148 PSCHED_GET_TIME(now); 147 PSCHED_GET_TIME(now);
149 td = tabledist(q->latency, q->jitter, &q->delay_cor, q->delay_dist); 148 td = tabledist(q->latency, q->jitter, &q->delay_cor, q->delay_dist);
150 PSCHED_TADD2(now, td, cb->time_to_send);
151 149
152 /* Always queue at tail to keep packets in order */ 150 /* Always queue at tail to keep packets in order */
153 if (likely(q->delayed.qlen < q->limit)) { 151 if (likely(q->delayed.qlen < q->limit)) {
152 struct netem_skb_cb *cb = (struct netem_skb_cb *)skb->cb;
153
154 PSCHED_TADD2(now, td, cb->time_to_send);
155
156 pr_debug("netem_delay: skb=%p now=%llu tosend=%llu\n", skb,
157 now, cb->time_to_send);
158
154 __skb_queue_tail(&q->delayed, skb); 159 __skb_queue_tail(&q->delayed, skb);
155 if (!timer_pending(&q->timer)) {
156 q->timer.expires = jiffies + PSCHED_US2JIFFIE(td);
157 add_timer(&q->timer);
158 }
159 return NET_XMIT_SUCCESS; 160 return NET_XMIT_SUCCESS;
160 } 161 }
161 162
163 pr_debug("netem_delay: queue over limit %d\n", q->limit);
164 sch->qstats.overlimits++;
162 kfree_skb(skb); 165 kfree_skb(skb);
163 return NET_XMIT_DROP; 166 return NET_XMIT_DROP;
164} 167}
165 168
169/*
170 * Move a packet that is ready to send from the delay holding
171 * list to the underlying qdisc.
172 */
173static int netem_run(struct Qdisc *sch)
174{
175 struct netem_sched_data *q = qdisc_priv(sch);
176 struct sk_buff *skb;
177 psched_time_t now;
178
179 PSCHED_GET_TIME(now);
180
181 skb = skb_peek(&q->delayed);
182 if (skb) {
183 const struct netem_skb_cb *cb
184 = (const struct netem_skb_cb *)skb->cb;
185 long delay
186 = PSCHED_US2JIFFIE(PSCHED_TDIFF(cb->time_to_send, now));
187 pr_debug("netem_run: skb=%p delay=%ld\n", skb, delay);
188
189 /* if more time remaining? */
190 if (delay > 0) {
191 mod_timer(&q->timer, jiffies + delay);
192 return 1;
193 }
194
195 __skb_unlink(skb, &q->delayed);
196
197 if (q->qdisc->enqueue(skb, q->qdisc)) {
198 sch->q.qlen--;
199 sch->qstats.drops++;
200 }
201 }
202
203 return 0;
204}
205
166static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch) 206static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
167{ 207{
168 struct netem_sched_data *q = qdisc_priv(sch); 208 struct netem_sched_data *q = qdisc_priv(sch);
169 struct sk_buff *skb2;
170 int ret; 209 int ret;
171 210
172 pr_debug("netem_enqueue skb=%p @%lu\n", skb, jiffies); 211 pr_debug("netem_enqueue skb=%p\n", skb);
173 212
174 /* Random packet drop 0 => none, ~0 => all */ 213 /* Random packet drop 0 => none, ~0 => all */
175 if (q->loss && q->loss >= get_crandom(&q->loss_cor)) { 214 if (q->loss && q->loss >= get_crandom(&q->loss_cor)) {
@@ -180,11 +219,21 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
180 } 219 }
181 220
182 /* Random duplication */ 221 /* Random duplication */
183 if (q->duplicate && q->duplicate >= get_crandom(&q->dup_cor) 222 if (q->duplicate && q->duplicate >= get_crandom(&q->dup_cor)) {
184 && (skb2 = skb_clone(skb, GFP_ATOMIC)) != NULL) { 223 struct sk_buff *skb2;
185 pr_debug("netem_enqueue: dup %p\n", skb2); 224
225 skb2 = skb_clone(skb, GFP_ATOMIC);
226 if (skb2 && netem_delay(sch, skb2) == NET_XMIT_SUCCESS) {
227 struct Qdisc *qp;
228
229 /* Since one packet can generate two packets in the
230 * queue, the parent's qlen accounting gets confused,
231 * so fix it.
232 */
233 qp = qdisc_lookup(sch->dev, TC_H_MAJ(sch->parent));
234 if (qp)
235 qp->q.qlen++;
186 236
187 if (delay_skb(sch, skb2)) {
188 sch->q.qlen++; 237 sch->q.qlen++;
189 sch->bstats.bytes += skb2->len; 238 sch->bstats.bytes += skb2->len;
190 sch->bstats.packets++; 239 sch->bstats.packets++;
@@ -202,7 +251,8 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
202 ret = q->qdisc->enqueue(skb, q->qdisc); 251 ret = q->qdisc->enqueue(skb, q->qdisc);
203 } else { 252 } else {
204 q->counter = 0; 253 q->counter = 0;
205 ret = delay_skb(sch, skb); 254 ret = netem_delay(sch, skb);
255 netem_run(sch);
206 } 256 }
207 257
208 if (likely(ret == NET_XMIT_SUCCESS)) { 258 if (likely(ret == NET_XMIT_SUCCESS)) {
@@ -212,6 +262,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
212 } else 262 } else
213 sch->qstats.drops++; 263 sch->qstats.drops++;
214 264
265 pr_debug("netem: enqueue ret %d\n", ret);
215 return ret; 266 return ret;
216} 267}
217 268
@@ -241,56 +292,35 @@ static unsigned int netem_drop(struct Qdisc* sch)
241 return len; 292 return len;
242} 293}
243 294
244/* Dequeue packet.
245 * Move all packets that are ready to send from the delay holding
246 * list to the underlying qdisc, then just call dequeue
247 */
248static struct sk_buff *netem_dequeue(struct Qdisc *sch) 295static struct sk_buff *netem_dequeue(struct Qdisc *sch)
249{ 296{
250 struct netem_sched_data *q = qdisc_priv(sch); 297 struct netem_sched_data *q = qdisc_priv(sch);
251 struct sk_buff *skb; 298 struct sk_buff *skb;
299 int pending;
300
301 pending = netem_run(sch);
252 302
253 skb = q->qdisc->dequeue(q->qdisc); 303 skb = q->qdisc->dequeue(q->qdisc);
254 if (skb) 304 if (skb) {
305 pr_debug("netem_dequeue: return skb=%p\n", skb);
255 sch->q.qlen--; 306 sch->q.qlen--;
307 sch->flags &= ~TCQ_F_THROTTLED;
308 }
309 else if (pending) {
310 pr_debug("netem_dequeue: throttling\n");
311 sch->flags |= TCQ_F_THROTTLED;
312 }
313
256 return skb; 314 return skb;
257} 315}
258 316
259static void netem_watchdog(unsigned long arg) 317static void netem_watchdog(unsigned long arg)
260{ 318{
261 struct Qdisc *sch = (struct Qdisc *)arg; 319 struct Qdisc *sch = (struct Qdisc *)arg;
262 struct netem_sched_data *q = qdisc_priv(sch);
263 struct net_device *dev = sch->dev;
264 struct sk_buff *skb;
265 psched_time_t now;
266
267 pr_debug("netem_watchdog: fired @%lu\n", jiffies);
268
269 spin_lock_bh(&dev->queue_lock);
270 PSCHED_GET_TIME(now);
271
272 while ((skb = skb_peek(&q->delayed)) != NULL) {
273 const struct netem_skb_cb *cb
274 = (const struct netem_skb_cb *)skb->cb;
275 long delay
276 = PSCHED_US2JIFFIE(PSCHED_TDIFF(cb->time_to_send, now));
277 pr_debug("netem_watchdog: skb %p@%lu %ld\n",
278 skb, jiffies, delay);
279 320
280 /* if more time remaining? */ 321 pr_debug("netem_watchdog qlen=%d\n", sch->q.qlen);
281 if (delay > 0) { 322 sch->flags &= ~TCQ_F_THROTTLED;
282 mod_timer(&q->timer, jiffies + delay); 323 netif_schedule(sch->dev);
283 break;
284 }
285 __skb_unlink(skb, &q->delayed);
286
287 if (q->qdisc->enqueue(skb, q->qdisc)) {
288 sch->q.qlen--;
289 sch->qstats.drops++;
290 }
291 }
292 qdisc_run(dev);
293 spin_unlock_bh(&dev->queue_lock);
294} 324}
295 325
296static void netem_reset(struct Qdisc *sch) 326static void netem_reset(struct Qdisc *sch)
@@ -301,6 +331,7 @@ static void netem_reset(struct Qdisc *sch)
301 skb_queue_purge(&q->delayed); 331 skb_queue_purge(&q->delayed);
302 332
303 sch->q.qlen = 0; 333 sch->q.qlen = 0;
334 sch->flags &= ~TCQ_F_THROTTLED;
304 del_timer_sync(&q->timer); 335 del_timer_sync(&q->timer);
305} 336}
306 337
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 80828078733d..55ed979db144 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1028,30 +1028,15 @@ static int stale_bundle(struct dst_entry *dst)
1028 return !xfrm_bundle_ok((struct xfrm_dst *)dst, NULL, AF_UNSPEC); 1028 return !xfrm_bundle_ok((struct xfrm_dst *)dst, NULL, AF_UNSPEC);
1029} 1029}
1030 1030
1031static void xfrm_dst_destroy(struct dst_entry *dst) 1031void xfrm_dst_ifdown(struct dst_entry *dst, struct net_device *dev)
1032{ 1032{
1033 struct xfrm_dst *xdst = (struct xfrm_dst *)dst;
1034
1035 dst_release(xdst->route);
1036
1037 if (!dst->xfrm)
1038 return;
1039 xfrm_state_put(dst->xfrm);
1040 dst->xfrm = NULL;
1041}
1042
1043static void xfrm_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
1044 int unregister)
1045{
1046 if (!unregister)
1047 return;
1048
1049 while ((dst = dst->child) && dst->xfrm && dst->dev == dev) { 1033 while ((dst = dst->child) && dst->xfrm && dst->dev == dev) {
1050 dst->dev = &loopback_dev; 1034 dst->dev = &loopback_dev;
1051 dev_hold(&loopback_dev); 1035 dev_hold(&loopback_dev);
1052 dev_put(dev); 1036 dev_put(dev);
1053 } 1037 }
1054} 1038}
1039EXPORT_SYMBOL(xfrm_dst_ifdown);
1055 1040
1056static void xfrm_link_failure(struct sk_buff *skb) 1041static void xfrm_link_failure(struct sk_buff *skb)
1057{ 1042{
@@ -1262,10 +1247,6 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
1262 dst_ops->kmem_cachep = xfrm_dst_cache; 1247 dst_ops->kmem_cachep = xfrm_dst_cache;
1263 if (likely(dst_ops->check == NULL)) 1248 if (likely(dst_ops->check == NULL))
1264 dst_ops->check = xfrm_dst_check; 1249 dst_ops->check = xfrm_dst_check;
1265 if (likely(dst_ops->destroy == NULL))
1266 dst_ops->destroy = xfrm_dst_destroy;
1267 if (likely(dst_ops->ifdown == NULL))
1268 dst_ops->ifdown = xfrm_dst_ifdown;
1269 if (likely(dst_ops->negative_advice == NULL)) 1250 if (likely(dst_ops->negative_advice == NULL))
1270 dst_ops->negative_advice = xfrm_negative_advice; 1251 dst_ops->negative_advice = xfrm_negative_advice;
1271 if (likely(dst_ops->link_failure == NULL)) 1252 if (likely(dst_ops->link_failure == NULL))
@@ -1297,8 +1278,6 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
1297 xfrm_policy_afinfo[afinfo->family] = NULL; 1278 xfrm_policy_afinfo[afinfo->family] = NULL;
1298 dst_ops->kmem_cachep = NULL; 1279 dst_ops->kmem_cachep = NULL;
1299 dst_ops->check = NULL; 1280 dst_ops->check = NULL;
1300 dst_ops->destroy = NULL;
1301 dst_ops->ifdown = NULL;
1302 dst_ops->negative_advice = NULL; 1281 dst_ops->negative_advice = NULL;
1303 dst_ops->link_failure = NULL; 1282 dst_ops->link_failure = NULL;
1304 dst_ops->get_mss = NULL; 1283 dst_ops->get_mss = NULL;
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 63661b0fd736..5ddda2c98af9 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -855,47 +855,44 @@ static int xfrm_flush_policy(struct sk_buff *skb, struct nlmsghdr *nlh, void **x
855 return 0; 855 return 0;
856} 856}
857 857
858static const int xfrm_msg_min[(XFRM_MSG_MAX + 1 - XFRM_MSG_BASE)] = { 858#define XMSGSIZE(type) NLMSG_LENGTH(sizeof(struct type))
859 NLMSG_LENGTH(sizeof(struct xfrm_usersa_info)), /* NEW SA */ 859
860 NLMSG_LENGTH(sizeof(struct xfrm_usersa_id)), /* DEL SA */ 860static const int xfrm_msg_min[XFRM_NR_MSGTYPES] = {
861 NLMSG_LENGTH(sizeof(struct xfrm_usersa_id)), /* GET SA */ 861 [XFRM_MSG_NEWSA - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_info),
862 NLMSG_LENGTH(sizeof(struct xfrm_userpolicy_info)),/* NEW POLICY */ 862 [XFRM_MSG_DELSA - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_id),
863 NLMSG_LENGTH(sizeof(struct xfrm_userpolicy_id)), /* DEL POLICY */ 863 [XFRM_MSG_GETSA - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_id),
864 NLMSG_LENGTH(sizeof(struct xfrm_userpolicy_id)), /* GET POLICY */ 864 [XFRM_MSG_NEWPOLICY - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_info),
865 NLMSG_LENGTH(sizeof(struct xfrm_userspi_info)), /* ALLOC SPI */ 865 [XFRM_MSG_DELPOLICY - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_id),
866 NLMSG_LENGTH(sizeof(struct xfrm_user_acquire)), /* ACQUIRE */ 866 [XFRM_MSG_GETPOLICY - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_id),
867 NLMSG_LENGTH(sizeof(struct xfrm_user_expire)), /* EXPIRE */ 867 [XFRM_MSG_ALLOCSPI - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userspi_info),
868 NLMSG_LENGTH(sizeof(struct xfrm_userpolicy_info)),/* UPD POLICY */ 868 [XFRM_MSG_ACQUIRE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_user_acquire),
869 NLMSG_LENGTH(sizeof(struct xfrm_usersa_info)), /* UPD SA */ 869 [XFRM_MSG_EXPIRE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_user_expire),
870 NLMSG_LENGTH(sizeof(struct xfrm_user_polexpire)), /* POLEXPIRE */ 870 [XFRM_MSG_UPDPOLICY - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_info),
871 NLMSG_LENGTH(sizeof(struct xfrm_usersa_flush)), /* FLUSH SA */ 871 [XFRM_MSG_UPDSA - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_info),
872 NLMSG_LENGTH(0), /* FLUSH POLICY */ 872 [XFRM_MSG_POLEXPIRE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_user_polexpire),
873 [XFRM_MSG_FLUSHSA - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_flush),
874 [XFRM_MSG_FLUSHPOLICY - XFRM_MSG_BASE] = NLMSG_LENGTH(0),
873}; 875};
874 876
877#undef XMSGSIZE
878
875static struct xfrm_link { 879static struct xfrm_link {
876 int (*doit)(struct sk_buff *, struct nlmsghdr *, void **); 880 int (*doit)(struct sk_buff *, struct nlmsghdr *, void **);
877 int (*dump)(struct sk_buff *, struct netlink_callback *); 881 int (*dump)(struct sk_buff *, struct netlink_callback *);
878} xfrm_dispatch[] = { 882} xfrm_dispatch[XFRM_NR_MSGTYPES] = {
879 { .doit = xfrm_add_sa, }, 883 [XFRM_MSG_NEWSA - XFRM_MSG_BASE] = { .doit = xfrm_add_sa },
880 { .doit = xfrm_del_sa, }, 884 [XFRM_MSG_DELSA - XFRM_MSG_BASE] = { .doit = xfrm_del_sa },
881 { 885 [XFRM_MSG_GETSA - XFRM_MSG_BASE] = { .doit = xfrm_get_sa,
882 .doit = xfrm_get_sa, 886 .dump = xfrm_dump_sa },
883 .dump = xfrm_dump_sa, 887 [XFRM_MSG_NEWPOLICY - XFRM_MSG_BASE] = { .doit = xfrm_add_policy },
884 }, 888 [XFRM_MSG_DELPOLICY - XFRM_MSG_BASE] = { .doit = xfrm_get_policy },
885 { .doit = xfrm_add_policy }, 889 [XFRM_MSG_GETPOLICY - XFRM_MSG_BASE] = { .doit = xfrm_get_policy,
886 { .doit = xfrm_get_policy }, 890 .dump = xfrm_dump_policy },
887 { 891 [XFRM_MSG_ALLOCSPI - XFRM_MSG_BASE] = { .doit = xfrm_alloc_userspi },
888 .doit = xfrm_get_policy, 892 [XFRM_MSG_UPDPOLICY - XFRM_MSG_BASE] = { .doit = xfrm_add_policy },
889 .dump = xfrm_dump_policy, 893 [XFRM_MSG_UPDSA - XFRM_MSG_BASE] = { .doit = xfrm_add_sa },
890 }, 894 [XFRM_MSG_FLUSHSA - XFRM_MSG_BASE] = { .doit = xfrm_flush_sa },
891 { .doit = xfrm_alloc_userspi }, 895 [XFRM_MSG_FLUSHPOLICY - XFRM_MSG_BASE] = { .doit = xfrm_flush_policy },
892 {},
893 {},
894 { .doit = xfrm_add_policy },
895 { .doit = xfrm_add_sa, },
896 {},
897 { .doit = xfrm_flush_sa },
898 { .doit = xfrm_flush_policy },
899}; 896};
900 897
901static int xfrm_done(struct netlink_callback *cb) 898static int xfrm_done(struct netlink_callback *cb)
@@ -931,7 +928,9 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, int *err
931 return -1; 928 return -1;
932 } 929 }
933 930
934 if ((type == 2 || type == 5) && (nlh->nlmsg_flags & NLM_F_DUMP)) { 931 if ((type == (XFRM_MSG_GETSA - XFRM_MSG_BASE) ||
932 type == (XFRM_MSG_GETPOLICY - XFRM_MSG_BASE)) &&
933 (nlh->nlmsg_flags & NLM_F_DUMP)) {
935 u32 rlen; 934 u32 rlen;
936 935
937 if (link->dump == NULL) 936 if (link->dump == NULL)
@@ -1009,18 +1008,26 @@ static int xfrm_user_rcv_skb(struct sk_buff *skb)
1009 1008
1010static void xfrm_netlink_rcv(struct sock *sk, int len) 1009static void xfrm_netlink_rcv(struct sock *sk, int len)
1011{ 1010{
1011 unsigned int qlen = skb_queue_len(&sk->sk_receive_queue);
1012
1012 do { 1013 do {
1013 struct sk_buff *skb; 1014 struct sk_buff *skb;
1014 1015
1015 down(&xfrm_cfg_sem); 1016 down(&xfrm_cfg_sem);
1016 1017
1017 while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { 1018 if (qlen > skb_queue_len(&sk->sk_receive_queue))
1019 qlen = skb_queue_len(&sk->sk_receive_queue);
1020
1021 for (; qlen; qlen--) {
1022 skb = skb_dequeue(&sk->sk_receive_queue);
1018 if (xfrm_user_rcv_skb(skb)) { 1023 if (xfrm_user_rcv_skb(skb)) {
1019 if (skb->len) 1024 if (skb->len)
1020 skb_queue_head(&sk->sk_receive_queue, 1025 skb_queue_head(&sk->sk_receive_queue,
1021 skb); 1026 skb);
1022 else 1027 else {
1023 kfree_skb(skb); 1028 kfree_skb(skb);
1029 qlen--;
1030 }
1024 break; 1031 break;
1025 } 1032 }
1026 kfree_skb(skb); 1033 kfree_skb(skb);
@@ -1028,7 +1035,7 @@ static void xfrm_netlink_rcv(struct sock *sk, int len)
1028 1035
1029 up(&xfrm_cfg_sem); 1036 up(&xfrm_cfg_sem);
1030 1037
1031 } while (xfrm_nl && xfrm_nl->sk_receive_queue.qlen); 1038 } while (qlen);
1032} 1039}
1033 1040
1034static int build_expire(struct sk_buff *skb, struct xfrm_state *x, int hard) 1041static int build_expire(struct sk_buff *skb, struct xfrm_state *x, int hard)