aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/cpu-freq/core.txt2
-rw-r--r--Documentation/feature-removal-schedule.txt33
-rw-r--r--Documentation/filesystems/ocfs2.txt3
-rw-r--r--Documentation/i2c/busses/i2c-amd81112
-rw-r--r--Documentation/i2c/busses/i2c-i8015
-rw-r--r--Documentation/i2c/busses/i2c-nforce26
-rw-r--r--Documentation/kbuild/kconfig-language.txt8
-rw-r--r--MAINTAINERS8
-rw-r--r--Makefile4
-rw-r--r--arch/arm/mach-pnx4008/Makefile2
-rw-r--r--arch/arm/mach-pnx4008/i2c.c167
-rw-r--r--arch/arm/mach-pxa/Kconfig16
-rw-r--r--arch/arm/mach-realview/core.c13
-rw-r--r--arch/arm/mach-realview/core.h1
-rw-r--r--arch/arm/mach-realview/realview_eb.c1
-rw-r--r--arch/arm/mach-versatile/core.c14
-rw-r--r--arch/arm/plat-omap/Kconfig2
-rw-r--r--arch/i386/kernel/cpu/cpufreq/Kconfig6
-rw-r--r--arch/i386/kernel/cpu/cpufreq/Makefile2
-rw-r--r--arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c813
-rw-r--r--arch/i386/kernel/cpu/cpufreq/gx-suspmod.c4
-rw-r--r--arch/i386/kernel/cpu/cpufreq/longhaul.c8
-rw-r--r--arch/i386/kernel/cpu/cpufreq/p4-clockmod.c38
-rw-r--r--arch/i386/kernel/cpu/cpufreq/sc520_freq.c7
-rw-r--r--arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c15
-rw-r--r--arch/i386/kernel/cpu/cpufreq/speedstep-lib.c32
-rw-r--r--arch/i386/kernel/cpu/cpufreq/speedstep-lib.h1
-rw-r--r--arch/i386/kernel/cpu/cpufreq/speedstep-smi.c3
-rw-r--r--arch/powerpc/platforms/4xx/Kconfig2
-rw-r--r--arch/powerpc/platforms/embedded6xx/Kconfig2
-rw-r--r--arch/ppc/Kconfig4
-rw-r--r--arch/ppc/platforms/4xx/Kconfig2
-rw-r--r--arch/um/drivers/net_kern.c3
-rw-r--r--arch/v850/Kconfig28
-rw-r--r--arch/x86_64/kernel/cpufreq/Kconfig6
-rw-r--r--arch/x86_64/kernel/cpufreq/Makefile2
-rw-r--r--drivers/acorn/char/i2c.c2
-rw-r--r--drivers/char/Kconfig2
-rw-r--r--drivers/char/agp/Kconfig4
-rw-r--r--drivers/char/agp/generic.c25
-rw-r--r--drivers/char/watchdog/at91rm9200_wdt.c6
-rw-r--r--drivers/char/watchdog/mpcore_wdt.c2
-rw-r--r--drivers/char/watchdog/omap_wdt.c2
-rw-r--r--drivers/char/watchdog/pcwd_usb.c5
-rw-r--r--drivers/char/watchdog/rm9k_wdt.c44
-rw-r--r--drivers/cpufreq/cpufreq.c153
-rw-r--r--drivers/cpufreq/cpufreq_conservative.c33
-rw-r--r--drivers/cpufreq/cpufreq_ondemand.c33
-rw-r--r--drivers/cpufreq/cpufreq_performance.c9
-rw-r--r--drivers/cpufreq/cpufreq_powersave.c9
-rw-r--r--drivers/cpufreq/cpufreq_stats.c11
-rw-r--r--drivers/cpufreq/cpufreq_userspace.c11
-rw-r--r--drivers/cpufreq/freq_table.c28
-rw-r--r--drivers/i2c/algos/Kconfig11
-rw-r--r--drivers/i2c/algos/Makefile1
-rw-r--r--drivers/i2c/algos/i2c-algo-bit.c8
-rw-r--r--drivers/i2c/algos/i2c-algo-ite.c806
-rw-r--r--drivers/i2c/algos/i2c-algo-ite.h117
-rw-r--r--drivers/i2c/algos/i2c-algo-pca.c7
-rw-r--r--drivers/i2c/algos/i2c-algo-pcf.c8
-rw-r--r--drivers/i2c/algos/i2c-algo-sgi.c8
-rw-r--r--drivers/i2c/busses/Kconfig49
-rw-r--r--drivers/i2c/busses/Makefile4
-rw-r--r--drivers/i2c/busses/i2c-at91.c325
-rw-r--r--drivers/i2c/busses/i2c-elektor.c2
-rw-r--r--drivers/i2c/busses/i2c-hydra.c2
-rw-r--r--drivers/i2c/busses/i2c-i801.c16
-rw-r--r--drivers/i2c/busses/i2c-i810.c6
-rw-r--r--drivers/i2c/busses/i2c-ibm_iic.c9
-rw-r--r--drivers/i2c/busses/i2c-ite.c278
-rw-r--r--drivers/i2c/busses/i2c-ixp2000.c2
-rw-r--r--drivers/i2c/busses/i2c-ixp4xx.c2
-rw-r--r--drivers/i2c/busses/i2c-nforce2.c89
-rw-r--r--drivers/i2c/busses/i2c-omap.c4
-rw-r--r--drivers/i2c/busses/i2c-parport-light.c2
-rw-r--r--drivers/i2c/busses/i2c-parport.c2
-rw-r--r--drivers/i2c/busses/i2c-pca-isa.c2
-rw-r--r--drivers/i2c/busses/i2c-pnx.c708
-rw-r--r--drivers/i2c/busses/i2c-prosavage.c2
-rw-r--r--drivers/i2c/busses/i2c-savage4.c2
-rw-r--r--drivers/i2c/busses/i2c-versatile.c153
-rw-r--r--drivers/i2c/busses/i2c-via.c2
-rw-r--r--drivers/i2c/busses/i2c-voodoo3.c6
-rw-r--r--drivers/i2c/busses/scx200_i2c.c2
-rw-r--r--drivers/i2c/chips/ds1337.c8
-rw-r--r--drivers/i2c/i2c-core.c67
-rw-r--r--drivers/i2c/i2c-dev.c44
-rw-r--r--drivers/ide/Kconfig2
-rw-r--r--drivers/ieee1394/pcilynx.c2
-rw-r--r--drivers/infiniband/core/Makefile6
-rw-r--r--drivers/infiniband/core/cm.c4
-rw-r--r--drivers/infiniband/core/cma.c416
-rw-r--r--drivers/infiniband/core/fmr_pool.c12
-rw-r--r--drivers/infiniband/core/mad.c90
-rw-r--r--drivers/infiniband/core/mad_priv.h6
-rw-r--r--drivers/infiniband/core/ucma.c874
-rw-r--r--drivers/infiniband/core/uverbs_marshall.c5
-rw-r--r--drivers/infiniband/core/uverbs_mem.c12
-rw-r--r--drivers/infiniband/hw/amso1100/c2_qp.c13
-rw-r--r--drivers/infiniband/hw/ipath/Makefile1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_dma.c189
-rw-r--r--drivers/infiniband/hw/ipath/ipath_driver.c4
-rw-r--r--drivers/infiniband/hw/ipath/ipath_file_ops.c5
-rw-r--r--drivers/infiniband/hw/ipath/ipath_iba6110.c3
-rw-r--r--drivers/infiniband/hw/ipath/ipath_iba6120.c8
-rw-r--r--drivers/infiniband/hw/ipath/ipath_init_chip.c3
-rw-r--r--drivers/infiniband/hw/ipath/ipath_intr.c3
-rw-r--r--drivers/infiniband/hw/ipath/ipath_keys.c8
-rw-r--r--drivers/infiniband/hw/ipath/ipath_mr.c7
-rw-r--r--drivers/infiniband/hw/ipath/ipath_sysfs.c3
-rw-r--r--drivers/infiniband/hw/ipath/ipath_verbs.c1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_verbs.h2
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib.h4
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_ib.c75
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c3
-rw-r--r--drivers/infiniband/ulp/iser/iscsi_iser.h2
-rw-r--r--drivers/infiniband/ulp/iser/iser_initiator.c4
-rw-r--r--drivers/infiniband/ulp/iser/iser_memory.c125
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c81
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.h2
-rw-r--r--drivers/input/touchscreen/Kconfig2
-rw-r--r--drivers/leds/Kconfig22
-rw-r--r--drivers/media/dvb/pluto2/pluto2.c8
-rw-r--r--drivers/media/video/bt8xx/bttv-i2c.c6
-rw-r--r--drivers/media/video/cx88/cx88-core.c2
-rw-r--r--drivers/media/video/cx88/cx88-vp3054-i2c.c2
-rw-r--r--drivers/media/video/ov7670.c2
-rw-r--r--drivers/media/video/vino.c2
-rw-r--r--drivers/media/video/zoran_card.c2
-rw-r--r--drivers/net/e100.c3
-rw-r--r--drivers/serial/Kconfig4
-rw-r--r--drivers/serial/icom.c2
-rw-r--r--drivers/video/aty/radeon_i2c.c8
-rw-r--r--drivers/video/i810/i810-i2c.c6
-rw-r--r--drivers/video/intelfb/intelfb_i2c.c4
-rw-r--r--drivers/video/matrox/i2c-matroxfb.c2
-rw-r--r--drivers/video/nvidia/nv_i2c.c6
-rw-r--r--drivers/video/riva/rivafb-i2c.c6
-rw-r--r--drivers/video/savage/savagefb-i2c.c2
-rw-r--r--fs/Kconfig14
-rw-r--r--fs/binfmt_elf_fdpic.c3
-rw-r--r--fs/ocfs2/cluster/nodemanager.c192
-rw-r--r--fs/ocfs2/cluster/nodemanager.h17
-rw-r--r--fs/ocfs2/cluster/tcp.c152
-rw-r--r--fs/ocfs2/cluster/tcp.h8
-rw-r--r--fs/ocfs2/cluster/tcp_internal.h15
-rw-r--r--fs/ocfs2/dlmglue.c79
-rw-r--r--fs/ocfs2/heartbeat.c9
-rw-r--r--fs/ocfs2/inode.c3
-rw-r--r--fs/ocfs2/journal.c46
-rw-r--r--fs/ocfs2/journal.h5
-rw-r--r--fs/ocfs2/mmap.c6
-rw-r--r--fs/ocfs2/namei.c8
-rw-r--r--fs/ocfs2/ocfs2.h5
-rw-r--r--fs/ocfs2/ocfs2_fs.h14
-rw-r--r--fs/ocfs2/super.c90
-rw-r--r--fs/ocfs2/vote.c3
-rw-r--r--include/asm-arm/arch-pnx4008/i2c.h67
-rw-r--r--include/asm-i386/msr.h5
-rw-r--r--include/asm-x86_64/msr.h4
-rw-r--r--include/linux/compiler.h2
-rw-r--r--include/linux/configfs.h25
-rw-r--r--include/linux/cpufreq.h3
-rw-r--r--include/linux/i2c-algo-bit.h5
-rw-r--r--include/linux/i2c-algo-ite.h72
-rw-r--r--include/linux/i2c-algo-pca.h1
-rw-r--r--include/linux/i2c-algo-pcf.h3
-rw-r--r--include/linux/i2c-algo-sgi.h1
-rw-r--r--include/linux/i2c-id.h17
-rw-r--r--include/linux/i2c-pnx.h43
-rw-r--r--include/linux/i2c.h75
-rw-r--r--include/linux/sysctl.h2
-rw-r--r--include/rdma/ib_marshall.h5
-rw-r--r--include/rdma/ib_verbs.h253
-rw-r--r--include/rdma/rdma_cm.h62
-rw-r--r--include/rdma/rdma_cm_ib.h3
-rw-r--r--include/rdma/rdma_user_cm.h206
-rw-r--r--init/Kconfig2
-rw-r--r--lib/Kconfig.debug2
-rw-r--r--net/ipv4/ip_fragment.c2
-rw-r--r--sound/Kconfig8
-rw-r--r--sound/Makefile3
-rw-r--r--sound/ac97_bus.c (renamed from sound/pci/ac97/ac97_bus.c)0
-rw-r--r--sound/aoa/fabrics/Kconfig2
-rw-r--r--sound/drivers/Kconfig6
-rw-r--r--sound/pci/ac97/Makefile2
186 files changed, 5392 insertions, 2622 deletions
diff --git a/Documentation/cpu-freq/core.txt b/Documentation/cpu-freq/core.txt
index 29b3f9ffc66c..ce0666e51036 100644
--- a/Documentation/cpu-freq/core.txt
+++ b/Documentation/cpu-freq/core.txt
@@ -24,7 +24,7 @@ Contents:
241. General Information 241. General Information
25======================= 25=======================
26 26
27The CPUFreq core code is located in linux/kernel/cpufreq.c. This 27The CPUFreq core code is located in drivers/cpufreq/cpufreq.c. This
28cpufreq code offers a standardized interface for the CPUFreq 28cpufreq code offers a standardized interface for the CPUFreq
29architecture drivers (those pieces of code that do actual 29architecture drivers (those pieces of code that do actual
30frequency transitions), as well as to "notifiers". These are device 30frequency transitions), as well as to "notifiers". These are device
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 46f2a559b27c..64ce44da5936 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -216,17 +216,6 @@ Who: Thomas Gleixner <tglx@linutronix.de>
216 216
217--------------------------- 217---------------------------
218 218
219What: i2c-ite and i2c-algo-ite drivers
220When: September 2006
221Why: These drivers never compiled since they were added to the kernel
222 tree 5 years ago. This feature removal can be reevaluated if
223 someone shows interest in the drivers, fixes them and takes over
224 maintenance.
225 http://marc.theaimsgroup.com/?l=linux-mips&m=115040510817448
226Who: Jean Delvare <khali@linux-fr.org>
227
228---------------------------
229
230What: Bridge netfilter deferred IPv4/IPv6 output hook calling 219What: Bridge netfilter deferred IPv4/IPv6 output hook calling
231When: January 2007 220When: January 2007
232Why: The deferred output hooks are a layering violation causing unusual 221Why: The deferred output hooks are a layering violation causing unusual
@@ -270,3 +259,25 @@ Why: The new layer 3 independant connection tracking replaces the old
270Who: Patrick McHardy <kaber@trash.net> 259Who: Patrick McHardy <kaber@trash.net>
271 260
272--------------------------- 261---------------------------
262
263What: ACPI hooks (X86_SPEEDSTEP_CENTRINO_ACPI) in speedstep-centrino driver
264When: December 2006
265Why: Speedstep-centrino driver with ACPI hooks and acpi-cpufreq driver are
266 functionally very much similar. They talk to ACPI in same way. Only
267 difference between them is the way they do frequency transitions.
268 One uses MSRs and the other one uses IO ports. Functionaliy of
269 speedstep_centrino with ACPI hooks is now merged into acpi-cpufreq.
270 That means one common driver will support all Intel Enhanced Speedstep
271 capable CPUs. That means less confusion over name of
272 speedstep-centrino driver (with that driver supposed to be used on
273 non-centrino platforms). That means less duplication of code and
274 less maintenance effort and no possibility of these two drivers
275 going out of sync.
276 Current users of speedstep_centrino with ACPI hooks are requested to
277 switch over to acpi-cpufreq driver. speedstep-centrino will continue
278 to work using older non-ACPI static table based scheme even after this
279 date.
280
281Who: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
282
283---------------------------
diff --git a/Documentation/filesystems/ocfs2.txt b/Documentation/filesystems/ocfs2.txt
index af6defd10cb6..8ccf0c1b58ed 100644
--- a/Documentation/filesystems/ocfs2.txt
+++ b/Documentation/filesystems/ocfs2.txt
@@ -54,3 +54,6 @@ errors=panic Panic and halt the machine if an error occurs.
54intr (*) Allow signals to interrupt cluster operations. 54intr (*) Allow signals to interrupt cluster operations.
55nointr Do not allow signals to interrupt cluster 55nointr Do not allow signals to interrupt cluster
56 operations. 56 operations.
57atime_quantum=60(*) OCFS2 will not update atime unless this number
58 of seconds has passed since the last update.
59 Set to zero to always update atime.
diff --git a/Documentation/i2c/busses/i2c-amd8111 b/Documentation/i2c/busses/i2c-amd8111
index db294ee7455a..460dd6635fd2 100644
--- a/Documentation/i2c/busses/i2c-amd8111
+++ b/Documentation/i2c/busses/i2c-amd8111
@@ -5,7 +5,7 @@ Supported adapters:
5 5
6Datasheets: 6Datasheets:
7 AMD datasheet not yet available, but almost everything can be found 7 AMD datasheet not yet available, but almost everything can be found
8 in publically available ACPI 2.0 specification, which the adapter 8 in the publicly available ACPI 2.0 specification, which the adapter
9 follows. 9 follows.
10 10
11Author: Vojtech Pavlik <vojtech@suse.cz> 11Author: Vojtech Pavlik <vojtech@suse.cz>
diff --git a/Documentation/i2c/busses/i2c-i801 b/Documentation/i2c/busses/i2c-i801
index e46c23458242..3db69a086c41 100644
--- a/Documentation/i2c/busses/i2c-i801
+++ b/Documentation/i2c/busses/i2c-i801
@@ -9,7 +9,10 @@ Supported adapters:
9 * Intel 82801EB/ER (ICH5) (HW PEC supported, 32 byte buffer not supported) 9 * Intel 82801EB/ER (ICH5) (HW PEC supported, 32 byte buffer not supported)
10 * Intel 6300ESB 10 * Intel 6300ESB
11 * Intel 82801FB/FR/FW/FRW (ICH6) 11 * Intel 82801FB/FR/FW/FRW (ICH6)
12 * Intel ICH7 12 * Intel 82801G (ICH7)
13 * Intel 631xESB/632xESB (ESB2)
14 * Intel 82801H (ICH8)
15 * Intel ICH9
13 Datasheets: Publicly available at the Intel website 16 Datasheets: Publicly available at the Intel website
14 17
15Authors: 18Authors:
diff --git a/Documentation/i2c/busses/i2c-nforce2 b/Documentation/i2c/busses/i2c-nforce2
index cd49c428a3ab..7f61fbc03f7f 100644
--- a/Documentation/i2c/busses/i2c-nforce2
+++ b/Documentation/i2c/busses/i2c-nforce2
@@ -10,11 +10,11 @@ Supported adapters:
10 * nForce4 MCP51 10de:0264 10 * nForce4 MCP51 10de:0264
11 * nForce4 MCP55 10de:0368 11 * nForce4 MCP55 10de:0368
12 12
13Datasheet: not publically available, but seems to be similar to the 13Datasheet: not publicly available, but seems to be similar to the
14 AMD-8111 SMBus 2.0 adapter. 14 AMD-8111 SMBus 2.0 adapter.
15 15
16Authors: 16Authors:
17 Hans-Frieder Vogt <hfvogt@arcor.de>, 17 Hans-Frieder Vogt <hfvogt@gmx.net>,
18 Thomas Leibold <thomas@plx.com>, 18 Thomas Leibold <thomas@plx.com>,
19 Patrick Dreker <patrick@dreker.de> 19 Patrick Dreker <patrick@dreker.de>
20 20
@@ -38,7 +38,7 @@ Notes
38----- 38-----
39 39
40The SMBus adapter in the nForce2 chipset seems to be very similar to the 40The SMBus adapter in the nForce2 chipset seems to be very similar to the
41SMBus 2.0 adapter in the AMD-8111 southbridge. However, I could only get 41SMBus 2.0 adapter in the AMD-8111 south bridge. However, I could only get
42the driver to work with direct I/O access, which is different to the EC 42the driver to work with direct I/O access, which is different to the EC
43interface of the AMD-8111. Tested on Asus A7N8X. The ACPI DSDT table of the 43interface of the AMD-8111. Tested on Asus A7N8X. The ACPI DSDT table of the
44Asus A7N8X lists two SMBuses, both of which are supported by this driver. 44Asus A7N8X lists two SMBuses, both of which are supported by this driver.
diff --git a/Documentation/kbuild/kconfig-language.txt b/Documentation/kbuild/kconfig-language.txt
index 125093c3ef76..536d5bfbdb8d 100644
--- a/Documentation/kbuild/kconfig-language.txt
+++ b/Documentation/kbuild/kconfig-language.txt
@@ -29,7 +29,7 @@ them. A single configuration option is defined like this:
29 29
30config MODVERSIONS 30config MODVERSIONS
31 bool "Set version information on all module symbols" 31 bool "Set version information on all module symbols"
32 depends MODULES 32 depends on MODULES
33 help 33 help
34 Usually, modules have to be recompiled whenever you switch to a new 34 Usually, modules have to be recompiled whenever you switch to a new
35 kernel. ... 35 kernel. ...
@@ -163,7 +163,7 @@ The position of a menu entry in the tree is determined in two ways. First
163it can be specified explicitly: 163it can be specified explicitly:
164 164
165menu "Network device support" 165menu "Network device support"
166 depends NET 166 depends on NET
167 167
168config NETDEVICES 168config NETDEVICES
169 ... 169 ...
@@ -188,10 +188,10 @@ config MODULES
188 188
189config MODVERSIONS 189config MODVERSIONS
190 bool "Set version information on all module symbols" 190 bool "Set version information on all module symbols"
191 depends MODULES 191 depends on MODULES
192 192
193comment "module support disabled" 193comment "module support disabled"
194 depends !MODULES 194 depends on !MODULES
195 195
196MODVERSIONS directly depends on MODULES, this means it's only visible if 196MODVERSIONS directly depends on MODULES, this means it's only visible if
197MODULES is different from 'n'. The comment on the other hand is always 197MODULES is different from 'n'. The comment on the other hand is always
diff --git a/MAINTAINERS b/MAINTAINERS
index b2024938adcf..8a0bfeca55c9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -740,7 +740,7 @@ P: Dave Jones
740M: davej@codemonkey.org.uk 740M: davej@codemonkey.org.uk
741L: cpufreq@lists.linux.org.uk 741L: cpufreq@lists.linux.org.uk
742W: http://www.codemonkey.org.uk/projects/cpufreq/ 742W: http://www.codemonkey.org.uk/projects/cpufreq/
743T: git kernel.org/pub/scm/linux/kernel/davej/cpufreq.git 743T: git kernel.org/pub/scm/linux/kernel/git/davej/cpufreq.git
744S: Maintained 744S: Maintained
745 745
746CPUID/MSR DRIVER 746CPUID/MSR DRIVER
@@ -1504,8 +1504,10 @@ T: git kernel.org:/pub/scm/linux/kernel/git/dtor/input.git
1504S: Maintained 1504S: Maintained
1505 1505
1506INOTIFY 1506INOTIFY
1507P: John McCutchan and Robert Love 1507P: John McCutchan
1508M: ttb@tentacle.dhs.org and rml@novell.com 1508M: ttb@tentacle.dhs.org
1509P: Robert Love
1510M: rml@novell.com
1509L: linux-kernel@vger.kernel.org 1511L: linux-kernel@vger.kernel.org
1510S: Maintained 1512S: Maintained
1511 1513
diff --git a/Makefile b/Makefile
index 73e825b39a08..4eabaa8afbff 100644
--- a/Makefile
+++ b/Makefile
@@ -1100,9 +1100,9 @@ boards := $(notdir $(boards))
1100 1100
1101help: 1101help:
1102 @echo 'Cleaning targets:' 1102 @echo 'Cleaning targets:'
1103 @echo ' clean - remove most generated files but keep the config and' 1103 @echo ' clean - Remove most generated files but keep the config and'
1104 @echo ' enough build support to build external modules' 1104 @echo ' enough build support to build external modules'
1105 @echo ' mrproper - remove all generated files + config + various backup files' 1105 @echo ' mrproper - Remove all generated files + config + various backup files'
1106 @echo ' distclean - mrproper + remove editor backup and patch files' 1106 @echo ' distclean - mrproper + remove editor backup and patch files'
1107 @echo '' 1107 @echo ''
1108 @echo 'Configuration targets:' 1108 @echo 'Configuration targets:'
diff --git a/arch/arm/mach-pnx4008/Makefile b/arch/arm/mach-pnx4008/Makefile
index b457ca0a431a..777564c90a12 100644
--- a/arch/arm/mach-pnx4008/Makefile
+++ b/arch/arm/mach-pnx4008/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the linux kernel. 2# Makefile for the linux kernel.
3# 3#
4 4
5obj-y := core.o irq.o time.o clock.o gpio.o serial.o dma.o 5obj-y := core.o irq.o time.o clock.o gpio.o serial.o dma.o i2c.o
6obj-m := 6obj-m :=
7obj-n := 7obj-n :=
8obj- := 8obj- :=
diff --git a/arch/arm/mach-pnx4008/i2c.c b/arch/arm/mach-pnx4008/i2c.c
new file mode 100644
index 000000000000..6f308827c4fe
--- /dev/null
+++ b/arch/arm/mach-pnx4008/i2c.c
@@ -0,0 +1,167 @@
1/*
2 * I2C initialization for PNX4008.
3 *
4 * Author: Vitaly Wool <vitalywool@gmail.com>
5 *
6 * 2005-2006 (c) MontaVista Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 */
11
12#include <linux/clk.h>
13#include <linux/i2c.h>
14#include <linux/i2c-pnx.h>
15#include <linux/platform_device.h>
16#include <linux/err.h>
17#include <asm/arch/platform.h>
18#include <asm/arch/i2c.h>
19
20static int set_clock_run(struct platform_device *pdev)
21{
22 struct clk *clk;
23 char name[10];
24 int retval = 0;
25
26 snprintf(name, 10, "i2c%d_ck", pdev->id);
27 clk = clk_get(&pdev->dev, name);
28 if (!IS_ERR(clk)) {
29 clk_set_rate(clk, 1);
30 clk_put(clk);
31 } else
32 retval = -ENOENT;
33
34 return retval;
35}
36
37static int set_clock_stop(struct platform_device *pdev)
38{
39 struct clk *clk;
40 char name[10];
41 int retval = 0;
42
43 snprintf(name, 10, "i2c%d_ck", pdev->id);
44 clk = clk_get(&pdev->dev, name);
45 if (!IS_ERR(clk)) {
46 clk_set_rate(clk, 0);
47 clk_put(clk);
48 } else
49 retval = -ENOENT;
50
51 return retval;
52}
53
54static int i2c_pnx_suspend(struct platform_device *pdev, pm_message_t state)
55{
56 int retval = 0;
57#ifdef CONFIG_PM
58 retval = set_clock_run(pdev);
59#endif
60 return retval;
61}
62
63static int i2c_pnx_resume(struct platform_device *pdev)
64{
65 int retval = 0;
66#ifdef CONFIG_PM
67 retval = set_clock_run(pdev);
68#endif
69 return retval;
70}
71
72static u32 calculate_input_freq(struct platform_device *pdev)
73{
74 return HCLK_MHZ;
75}
76
77
78static struct i2c_pnx_algo_data pnx_algo_data0 = {
79 .base = PNX4008_I2C1_BASE,
80 .irq = I2C_1_INT,
81};
82
83static struct i2c_pnx_algo_data pnx_algo_data1 = {
84 .base = PNX4008_I2C2_BASE,
85 .irq = I2C_2_INT,
86};
87
88static struct i2c_pnx_algo_data pnx_algo_data2 = {
89 .base = (PNX4008_USB_CONFIG_BASE + 0x300),
90 .irq = USB_I2C_INT,
91};
92
93static struct i2c_adapter pnx_adapter0 = {
94 .name = I2C_CHIP_NAME "0",
95 .algo_data = &pnx_algo_data0,
96};
97static struct i2c_adapter pnx_adapter1 = {
98 .name = I2C_CHIP_NAME "1",
99 .algo_data = &pnx_algo_data1,
100};
101
102static struct i2c_adapter pnx_adapter2 = {
103 .name = "USB-I2C",
104 .algo_data = &pnx_algo_data2,
105};
106
107static struct i2c_pnx_data i2c0_data = {
108 .suspend = i2c_pnx_suspend,
109 .resume = i2c_pnx_resume,
110 .calculate_input_freq = calculate_input_freq,
111 .set_clock_run = set_clock_run,
112 .set_clock_stop = set_clock_stop,
113 .adapter = &pnx_adapter0,
114};
115
116static struct i2c_pnx_data i2c1_data = {
117 .suspend = i2c_pnx_suspend,
118 .resume = i2c_pnx_resume,
119 .calculate_input_freq = calculate_input_freq,
120 .set_clock_run = set_clock_run,
121 .set_clock_stop = set_clock_stop,
122 .adapter = &pnx_adapter1,
123};
124
125static struct i2c_pnx_data i2c2_data = {
126 .suspend = i2c_pnx_suspend,
127 .resume = i2c_pnx_resume,
128 .calculate_input_freq = calculate_input_freq,
129 .set_clock_run = set_clock_run,
130 .set_clock_stop = set_clock_stop,
131 .adapter = &pnx_adapter2,
132};
133
134static struct platform_device i2c0_device = {
135 .name = "pnx-i2c",
136 .id = 0,
137 .dev = {
138 .platform_data = &i2c0_data,
139 },
140};
141
142static struct platform_device i2c1_device = {
143 .name = "pnx-i2c",
144 .id = 1,
145 .dev = {
146 .platform_data = &i2c1_data,
147 },
148};
149
150static struct platform_device i2c2_device = {
151 .name = "pnx-i2c",
152 .id = 2,
153 .dev = {
154 .platform_data = &i2c2_data,
155 },
156};
157
158static struct platform_device *devices[] __initdata = {
159 &i2c0_device,
160 &i2c1_device,
161 &i2c2_device,
162};
163
164void __init pnx4008_register_i2c_devices(void)
165{
166 platform_add_devices(devices, ARRAY_SIZE(devices));
167}
diff --git a/arch/arm/mach-pxa/Kconfig b/arch/arm/mach-pxa/Kconfig
index 9e3d0bdcba07..5c0a10041cd1 100644
--- a/arch/arm/mach-pxa/Kconfig
+++ b/arch/arm/mach-pxa/Kconfig
@@ -75,28 +75,28 @@ endmenu
75 75
76config MACH_POODLE 76config MACH_POODLE
77 bool "Enable Sharp SL-5600 (Poodle) Support" 77 bool "Enable Sharp SL-5600 (Poodle) Support"
78 depends PXA_SHARPSL_25x 78 depends on PXA_SHARPSL_25x
79 select SHARP_LOCOMO 79 select SHARP_LOCOMO
80 select PXA_SSP 80 select PXA_SSP
81 81
82config MACH_CORGI 82config MACH_CORGI
83 bool "Enable Sharp SL-C700 (Corgi) Support" 83 bool "Enable Sharp SL-C700 (Corgi) Support"
84 depends PXA_SHARPSL_25x 84 depends on PXA_SHARPSL_25x
85 select PXA_SHARP_C7xx 85 select PXA_SHARP_C7xx
86 86
87config MACH_SHEPHERD 87config MACH_SHEPHERD
88 bool "Enable Sharp SL-C750 (Shepherd) Support" 88 bool "Enable Sharp SL-C750 (Shepherd) Support"
89 depends PXA_SHARPSL_25x 89 depends on PXA_SHARPSL_25x
90 select PXA_SHARP_C7xx 90 select PXA_SHARP_C7xx
91 91
92config MACH_HUSKY 92config MACH_HUSKY
93 bool "Enable Sharp SL-C760 (Husky) Support" 93 bool "Enable Sharp SL-C760 (Husky) Support"
94 depends PXA_SHARPSL_25x 94 depends on PXA_SHARPSL_25x
95 select PXA_SHARP_C7xx 95 select PXA_SHARP_C7xx
96 96
97config MACH_AKITA 97config MACH_AKITA
98 bool "Enable Sharp SL-1000 (Akita) Support" 98 bool "Enable Sharp SL-1000 (Akita) Support"
99 depends PXA_SHARPSL_27x 99 depends on PXA_SHARPSL_27x
100 select PXA_SHARP_Cxx00 100 select PXA_SHARP_Cxx00
101 select MACH_SPITZ 101 select MACH_SPITZ
102 select I2C 102 select I2C
@@ -104,17 +104,17 @@ config MACH_AKITA
104 104
105config MACH_SPITZ 105config MACH_SPITZ
106 bool "Enable Sharp Zaurus SL-3000 (Spitz) Support" 106 bool "Enable Sharp Zaurus SL-3000 (Spitz) Support"
107 depends PXA_SHARPSL_27x 107 depends on PXA_SHARPSL_27x
108 select PXA_SHARP_Cxx00 108 select PXA_SHARP_Cxx00
109 109
110config MACH_BORZOI 110config MACH_BORZOI
111 bool "Enable Sharp Zaurus SL-3100 (Borzoi) Support" 111 bool "Enable Sharp Zaurus SL-3100 (Borzoi) Support"
112 depends PXA_SHARPSL_27x 112 depends on PXA_SHARPSL_27x
113 select PXA_SHARP_Cxx00 113 select PXA_SHARP_Cxx00
114 114
115config MACH_TOSA 115config MACH_TOSA
116 bool "Enable Sharp SL-6000x (Tosa) Support" 116 bool "Enable Sharp SL-6000x (Tosa) Support"
117 depends PXA_SHARPSL_25x 117 depends on PXA_SHARPSL_25x
118 118
119config PXA25x 119config PXA25x
120 bool 120 bool
diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c
index 68c67053f479..84d3fe76e94e 100644
--- a/arch/arm/mach-realview/core.c
+++ b/arch/arm/mach-realview/core.c
@@ -141,6 +141,19 @@ struct platform_device realview_smc91x_device = {
141 .resource = realview_smc91x_resources, 141 .resource = realview_smc91x_resources,
142}; 142};
143 143
144static struct resource realview_i2c_resource = {
145 .start = REALVIEW_I2C_BASE,
146 .end = REALVIEW_I2C_BASE + SZ_4K - 1,
147 .flags = IORESOURCE_MEM,
148};
149
150struct platform_device realview_i2c_device = {
151 .name = "versatile-i2c",
152 .id = -1,
153 .num_resources = 1,
154 .resource = &realview_i2c_resource,
155};
156
144#define REALVIEW_SYSMCI (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_MCI_OFFSET) 157#define REALVIEW_SYSMCI (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_MCI_OFFSET)
145 158
146static unsigned int realview_mmc_status(struct device *dev) 159static unsigned int realview_mmc_status(struct device *dev)
diff --git a/arch/arm/mach-realview/core.h b/arch/arm/mach-realview/core.h
index 93e86d9f439c..2b53420f9c1b 100644
--- a/arch/arm/mach-realview/core.h
+++ b/arch/arm/mach-realview/core.h
@@ -108,6 +108,7 @@ static struct amba_device name##_device = { \
108 108
109extern struct platform_device realview_flash_device; 109extern struct platform_device realview_flash_device;
110extern struct platform_device realview_smc91x_device; 110extern struct platform_device realview_smc91x_device;
111extern struct platform_device realview_i2c_device;
111extern struct mmc_platform_data realview_mmc0_plat_data; 112extern struct mmc_platform_data realview_mmc0_plat_data;
112extern struct mmc_platform_data realview_mmc1_plat_data; 113extern struct mmc_platform_data realview_mmc1_plat_data;
113extern struct clk realview_clcd_clk; 114extern struct clk realview_clcd_clk;
diff --git a/arch/arm/mach-realview/realview_eb.c b/arch/arm/mach-realview/realview_eb.c
index 84a959530fb6..9741b4d3c9cf 100644
--- a/arch/arm/mach-realview/realview_eb.c
+++ b/arch/arm/mach-realview/realview_eb.c
@@ -155,6 +155,7 @@ static void __init realview_eb_init(void)
155 155
156 platform_device_register(&realview_flash_device); 156 platform_device_register(&realview_flash_device);
157 platform_device_register(&realview_smc91x_device); 157 platform_device_register(&realview_smc91x_device);
158 platform_device_register(&realview_i2c_device);
158 159
159 for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { 160 for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
160 struct amba_device *d = amba_devs[i]; 161 struct amba_device *d = amba_devs[i];
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
index 57196947559f..bf71507c76fd 100644
--- a/arch/arm/mach-versatile/core.c
+++ b/arch/arm/mach-versatile/core.c
@@ -325,6 +325,19 @@ static struct platform_device smc91x_device = {
325 .resource = smc91x_resources, 325 .resource = smc91x_resources,
326}; 326};
327 327
328static struct resource versatile_i2c_resource = {
329 .start = VERSATILE_I2C_BASE,
330 .end = VERSATILE_I2C_BASE + SZ_4K - 1,
331 .flags = IORESOURCE_MEM,
332};
333
334static struct platform_device versatile_i2c_device = {
335 .name = "versatile-i2c",
336 .id = -1,
337 .num_resources = 1,
338 .resource = &versatile_i2c_resource,
339};
340
328#define VERSATILE_SYSMCI (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_MCI_OFFSET) 341#define VERSATILE_SYSMCI (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_MCI_OFFSET)
329 342
330unsigned int mmc_status(struct device *dev) 343unsigned int mmc_status(struct device *dev)
@@ -775,6 +788,7 @@ void __init versatile_init(void)
775 clk_register(&versatile_clcd_clk); 788 clk_register(&versatile_clcd_clk);
776 789
777 platform_device_register(&versatile_flash_device); 790 platform_device_register(&versatile_flash_device);
791 platform_device_register(&versatile_i2c_device);
778 platform_device_register(&smc91x_device); 792 platform_device_register(&smc91x_device);
779 793
780 for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { 794 for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index ec752e16d618..f2dc363de66b 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -113,7 +113,7 @@ endchoice
113 113
114config OMAP_SERIAL_WAKE 114config OMAP_SERIAL_WAKE
115 bool "Enable wake-up events for serial ports" 115 bool "Enable wake-up events for serial ports"
116 depends OMAP_MUX 116 depends on OMAP_MUX
117 default y 117 default y
118 help 118 help
119 Select this option if you want to have your system wake up 119 Select this option if you want to have your system wake up
diff --git a/arch/i386/kernel/cpu/cpufreq/Kconfig b/arch/i386/kernel/cpu/cpufreq/Kconfig
index ccc1edff5c97..5299c5bf4454 100644
--- a/arch/i386/kernel/cpu/cpufreq/Kconfig
+++ b/arch/i386/kernel/cpu/cpufreq/Kconfig
@@ -17,6 +17,7 @@ config X86_ACPI_CPUFREQ
17 help 17 help
18 This driver adds a CPUFreq driver which utilizes the ACPI 18 This driver adds a CPUFreq driver which utilizes the ACPI
19 Processor Performance States. 19 Processor Performance States.
20 This driver also supports Intel Enhanced Speedstep.
20 21
21 For details, take a look at <file:Documentation/cpu-freq/>. 22 For details, take a look at <file:Documentation/cpu-freq/>.
22 23
@@ -121,11 +122,14 @@ config X86_SPEEDSTEP_CENTRINO
121 If in doubt, say N. 122 If in doubt, say N.
122 123
123config X86_SPEEDSTEP_CENTRINO_ACPI 124config X86_SPEEDSTEP_CENTRINO_ACPI
124 bool "Use ACPI tables to decode valid frequency/voltage pairs" 125 bool "Use ACPI tables to decode valid frequency/voltage (deprecated)"
125 depends on X86_SPEEDSTEP_CENTRINO && ACPI_PROCESSOR 126 depends on X86_SPEEDSTEP_CENTRINO && ACPI_PROCESSOR
126 depends on !(X86_SPEEDSTEP_CENTRINO = y && ACPI_PROCESSOR = m) 127 depends on !(X86_SPEEDSTEP_CENTRINO = y && ACPI_PROCESSOR = m)
127 default y 128 default y
128 help 129 help
130 This is deprecated and this functionality is now merged into
131 acpi_cpufreq (X86_ACPI_CPUFREQ). Use that driver instead of
132 speedstep_centrino.
129 Use primarily the information provided in the BIOS ACPI tables 133 Use primarily the information provided in the BIOS ACPI tables
130 to determine valid CPU frequency and voltage pairings. It is 134 to determine valid CPU frequency and voltage pairings. It is
131 required for the driver to work on non-Banias CPUs. 135 required for the driver to work on non-Banias CPUs.
diff --git a/arch/i386/kernel/cpu/cpufreq/Makefile b/arch/i386/kernel/cpu/cpufreq/Makefile
index 2e894f1c8910..8de3abe322a9 100644
--- a/arch/i386/kernel/cpu/cpufreq/Makefile
+++ b/arch/i386/kernel/cpu/cpufreq/Makefile
@@ -7,9 +7,9 @@ obj-$(CONFIG_SC520_CPUFREQ) += sc520_freq.o
7obj-$(CONFIG_X86_LONGRUN) += longrun.o 7obj-$(CONFIG_X86_LONGRUN) += longrun.o
8obj-$(CONFIG_X86_GX_SUSPMOD) += gx-suspmod.o 8obj-$(CONFIG_X86_GX_SUSPMOD) += gx-suspmod.o
9obj-$(CONFIG_X86_SPEEDSTEP_ICH) += speedstep-ich.o 9obj-$(CONFIG_X86_SPEEDSTEP_ICH) += speedstep-ich.o
10obj-$(CONFIG_X86_SPEEDSTEP_CENTRINO) += speedstep-centrino.o
11obj-$(CONFIG_X86_SPEEDSTEP_LIB) += speedstep-lib.o 10obj-$(CONFIG_X86_SPEEDSTEP_LIB) += speedstep-lib.o
12obj-$(CONFIG_X86_SPEEDSTEP_SMI) += speedstep-smi.o 11obj-$(CONFIG_X86_SPEEDSTEP_SMI) += speedstep-smi.o
13obj-$(CONFIG_X86_ACPI_CPUFREQ) += acpi-cpufreq.o 12obj-$(CONFIG_X86_ACPI_CPUFREQ) += acpi-cpufreq.o
13obj-$(CONFIG_X86_SPEEDSTEP_CENTRINO) += speedstep-centrino.o
14obj-$(CONFIG_X86_P4_CLOCKMOD) += p4-clockmod.o 14obj-$(CONFIG_X86_P4_CLOCKMOD) += p4-clockmod.o
15obj-$(CONFIG_X86_CPUFREQ_NFORCE2) += cpufreq-nforce2.o 15obj-$(CONFIG_X86_CPUFREQ_NFORCE2) += cpufreq-nforce2.o
diff --git a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
index 57c880bf0bd6..18f4715c655d 100644
--- a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
+++ b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -1,9 +1,10 @@
1/* 1/*
2 * acpi-cpufreq.c - ACPI Processor P-States Driver ($Revision: 1.3 $) 2 * acpi-cpufreq.c - ACPI Processor P-States Driver ($Revision: 1.4 $)
3 * 3 *
4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> 4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> 5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6 * Copyright (C) 2002 - 2004 Dominik Brodowski <linux@brodo.de> 6 * Copyright (C) 2002 - 2004 Dominik Brodowski <linux@brodo.de>
7 * Copyright (C) 2006 Denis Sadykov <denis.m.sadykov@intel.com>
7 * 8 *
8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 9 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9 * 10 *
@@ -27,202 +28,387 @@
27#include <linux/kernel.h> 28#include <linux/kernel.h>
28#include <linux/module.h> 29#include <linux/module.h>
29#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/smp.h>
32#include <linux/sched.h>
30#include <linux/cpufreq.h> 33#include <linux/cpufreq.h>
31#include <linux/proc_fs.h>
32#include <linux/seq_file.h>
33#include <linux/compiler.h> 34#include <linux/compiler.h>
34#include <linux/sched.h> /* current */
35#include <linux/dmi.h> 35#include <linux/dmi.h>
36#include <asm/io.h>
37#include <asm/delay.h>
38#include <asm/uaccess.h>
39 36
40#include <linux/acpi.h> 37#include <linux/acpi.h>
41#include <acpi/processor.h> 38#include <acpi/processor.h>
42 39
40#include <asm/io.h>
41#include <asm/msr.h>
42#include <asm/processor.h>
43#include <asm/cpufeature.h>
44#include <asm/delay.h>
45#include <asm/uaccess.h>
46
43#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "acpi-cpufreq", msg) 47#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "acpi-cpufreq", msg)
44 48
45MODULE_AUTHOR("Paul Diefenbaugh, Dominik Brodowski"); 49MODULE_AUTHOR("Paul Diefenbaugh, Dominik Brodowski");
46MODULE_DESCRIPTION("ACPI Processor P-States Driver"); 50MODULE_DESCRIPTION("ACPI Processor P-States Driver");
47MODULE_LICENSE("GPL"); 51MODULE_LICENSE("GPL");
48 52
53enum {
54 UNDEFINED_CAPABLE = 0,
55 SYSTEM_INTEL_MSR_CAPABLE,
56 SYSTEM_IO_CAPABLE,
57};
58
59#define INTEL_MSR_RANGE (0xffff)
60#define CPUID_6_ECX_APERFMPERF_CAPABILITY (0x1)
49 61
50struct cpufreq_acpi_io { 62struct acpi_cpufreq_data {
51 struct acpi_processor_performance *acpi_data; 63 struct acpi_processor_performance *acpi_data;
52 struct cpufreq_frequency_table *freq_table; 64 struct cpufreq_frequency_table *freq_table;
53 unsigned int resume; 65 unsigned int max_freq;
66 unsigned int resume;
67 unsigned int cpu_feature;
54}; 68};
55 69
56static struct cpufreq_acpi_io *acpi_io_data[NR_CPUS]; 70static struct acpi_cpufreq_data *drv_data[NR_CPUS];
57static struct acpi_processor_performance *acpi_perf_data[NR_CPUS]; 71static struct acpi_processor_performance *acpi_perf_data[NR_CPUS];
58 72
59static struct cpufreq_driver acpi_cpufreq_driver; 73static struct cpufreq_driver acpi_cpufreq_driver;
60 74
61static unsigned int acpi_pstate_strict; 75static unsigned int acpi_pstate_strict;
62 76
63static int 77static int check_est_cpu(unsigned int cpuid)
64acpi_processor_write_port( 78{
65 u16 port, 79 struct cpuinfo_x86 *cpu = &cpu_data[cpuid];
66 u8 bit_width, 80
67 u32 value) 81 if (cpu->x86_vendor != X86_VENDOR_INTEL ||
82 !cpu_has(cpu, X86_FEATURE_EST))
83 return 0;
84
85 return 1;
86}
87
88static unsigned extract_io(u32 value, struct acpi_cpufreq_data *data)
89{
90 struct acpi_processor_performance *perf;
91 int i;
92
93 perf = data->acpi_data;
94
95 for (i=0; i<perf->state_count; i++) {
96 if (value == perf->states[i].status)
97 return data->freq_table[i].frequency;
98 }
99 return 0;
100}
101
102static unsigned extract_msr(u32 msr, struct acpi_cpufreq_data *data)
68{ 103{
69 if (bit_width <= 8) { 104 int i;
105 struct acpi_processor_performance *perf;
106
107 msr &= INTEL_MSR_RANGE;
108 perf = data->acpi_data;
109
110 for (i=0; data->freq_table[i].frequency != CPUFREQ_TABLE_END; i++) {
111 if (msr == perf->states[data->freq_table[i].index].status)
112 return data->freq_table[i].frequency;
113 }
114 return data->freq_table[0].frequency;
115}
116
117static unsigned extract_freq(u32 val, struct acpi_cpufreq_data *data)
118{
119 switch (data->cpu_feature) {
120 case SYSTEM_INTEL_MSR_CAPABLE:
121 return extract_msr(val, data);
122 case SYSTEM_IO_CAPABLE:
123 return extract_io(val, data);
124 default:
125 return 0;
126 }
127}
128
129static void wrport(u16 port, u8 bit_width, u32 value)
130{
131 if (bit_width <= 8)
70 outb(value, port); 132 outb(value, port);
71 } else if (bit_width <= 16) { 133 else if (bit_width <= 16)
72 outw(value, port); 134 outw(value, port);
73 } else if (bit_width <= 32) { 135 else if (bit_width <= 32)
74 outl(value, port); 136 outl(value, port);
75 } else {
76 return -ENODEV;
77 }
78 return 0;
79} 137}
80 138
81static int 139static void rdport(u16 port, u8 bit_width, u32 * ret)
82acpi_processor_read_port(
83 u16 port,
84 u8 bit_width,
85 u32 *ret)
86{ 140{
87 *ret = 0; 141 *ret = 0;
88 if (bit_width <= 8) { 142 if (bit_width <= 8)
89 *ret = inb(port); 143 *ret = inb(port);
90 } else if (bit_width <= 16) { 144 else if (bit_width <= 16)
91 *ret = inw(port); 145 *ret = inw(port);
92 } else if (bit_width <= 32) { 146 else if (bit_width <= 32)
93 *ret = inl(port); 147 *ret = inl(port);
94 } else { 148}
95 return -ENODEV; 149
150struct msr_addr {
151 u32 reg;
152};
153
154struct io_addr {
155 u16 port;
156 u8 bit_width;
157};
158
159typedef union {
160 struct msr_addr msr;
161 struct io_addr io;
162} drv_addr_union;
163
164struct drv_cmd {
165 unsigned int type;
166 cpumask_t mask;
167 drv_addr_union addr;
168 u32 val;
169};
170
171static void do_drv_read(struct drv_cmd *cmd)
172{
173 u32 h;
174
175 switch (cmd->type) {
176 case SYSTEM_INTEL_MSR_CAPABLE:
177 rdmsr(cmd->addr.msr.reg, cmd->val, h);
178 break;
179 case SYSTEM_IO_CAPABLE:
180 rdport(cmd->addr.io.port, cmd->addr.io.bit_width, &cmd->val);
181 break;
182 default:
183 break;
96 } 184 }
97 return 0;
98} 185}
99 186
100static int 187static void do_drv_write(struct drv_cmd *cmd)
101acpi_processor_set_performance (
102 struct cpufreq_acpi_io *data,
103 unsigned int cpu,
104 int state)
105{ 188{
106 u16 port = 0; 189 u32 h = 0;
107 u8 bit_width = 0; 190
108 int i = 0; 191 switch (cmd->type) {
109 int ret = 0; 192 case SYSTEM_INTEL_MSR_CAPABLE:
110 u32 value = 0; 193 wrmsr(cmd->addr.msr.reg, cmd->val, h);
111 int retval; 194 break;
112 struct acpi_processor_performance *perf; 195 case SYSTEM_IO_CAPABLE:
113 196 wrport(cmd->addr.io.port, cmd->addr.io.bit_width, cmd->val);
114 dprintk("acpi_processor_set_performance\n"); 197 break;
115 198 default:
116 retval = 0; 199 break;
117 perf = data->acpi_data;
118 if (state == perf->state) {
119 if (unlikely(data->resume)) {
120 dprintk("Called after resume, resetting to P%d\n", state);
121 data->resume = 0;
122 } else {
123 dprintk("Already at target state (P%d)\n", state);
124 return (retval);
125 }
126 } 200 }
201}
127 202
128 dprintk("Transitioning from P%d to P%d\n", perf->state, state); 203static void drv_read(struct drv_cmd *cmd)
204{
205 cpumask_t saved_mask = current->cpus_allowed;
206 cmd->val = 0;
129 207
130 /* 208 set_cpus_allowed(current, cmd->mask);
131 * First we write the target state's 'control' value to the 209 do_drv_read(cmd);
132 * control_register. 210 set_cpus_allowed(current, saved_mask);
133 */ 211}
212
213static void drv_write(struct drv_cmd *cmd)
214{
215 cpumask_t saved_mask = current->cpus_allowed;
216 unsigned int i;
217
218 for_each_cpu_mask(i, cmd->mask) {
219 set_cpus_allowed(current, cpumask_of_cpu(i));
220 do_drv_write(cmd);
221 }
222
223 set_cpus_allowed(current, saved_mask);
224 return;
225}
226
227static u32 get_cur_val(cpumask_t mask)
228{
229 struct acpi_processor_performance *perf;
230 struct drv_cmd cmd;
231
232 if (unlikely(cpus_empty(mask)))
233 return 0;
234
235 switch (drv_data[first_cpu(mask)]->cpu_feature) {
236 case SYSTEM_INTEL_MSR_CAPABLE:
237 cmd.type = SYSTEM_INTEL_MSR_CAPABLE;
238 cmd.addr.msr.reg = MSR_IA32_PERF_STATUS;
239 break;
240 case SYSTEM_IO_CAPABLE:
241 cmd.type = SYSTEM_IO_CAPABLE;
242 perf = drv_data[first_cpu(mask)]->acpi_data;
243 cmd.addr.io.port = perf->control_register.address;
244 cmd.addr.io.bit_width = perf->control_register.bit_width;
245 break;
246 default:
247 return 0;
248 }
249
250 cmd.mask = mask;
134 251
135 port = perf->control_register.address; 252 drv_read(&cmd);
136 bit_width = perf->control_register.bit_width;
137 value = (u32) perf->states[state].control;
138 253
139 dprintk("Writing 0x%08x to port 0x%04x\n", value, port); 254 dprintk("get_cur_val = %u\n", cmd.val);
140 255
141 ret = acpi_processor_write_port(port, bit_width, value); 256 return cmd.val;
142 if (ret) { 257}
143 dprintk("Invalid port width 0x%04x\n", bit_width); 258
144 return (ret); 259/*
260 * Return the measured active (C0) frequency on this CPU since last call
261 * to this function.
262 * Input: cpu number
263 * Return: Average CPU frequency in terms of max frequency (zero on error)
264 *
265 * We use IA32_MPERF and IA32_APERF MSRs to get the measured performance
266 * over a period of time, while CPU is in C0 state.
267 * IA32_MPERF counts at the rate of max advertised frequency
268 * IA32_APERF counts at the rate of actual CPU frequency
269 * Only IA32_APERF/IA32_MPERF ratio is architecturally defined and
270 * no meaning should be associated with absolute values of these MSRs.
271 */
272static unsigned int get_measured_perf(unsigned int cpu)
273{
274 union {
275 struct {
276 u32 lo;
277 u32 hi;
278 } split;
279 u64 whole;
280 } aperf_cur, mperf_cur;
281
282 cpumask_t saved_mask;
283 unsigned int perf_percent;
284 unsigned int retval;
285
286 saved_mask = current->cpus_allowed;
287 set_cpus_allowed(current, cpumask_of_cpu(cpu));
288 if (get_cpu() != cpu) {
289 /* We were not able to run on requested processor */
290 put_cpu();
291 return 0;
145 } 292 }
146 293
294 rdmsr(MSR_IA32_APERF, aperf_cur.split.lo, aperf_cur.split.hi);
295 rdmsr(MSR_IA32_MPERF, mperf_cur.split.lo, mperf_cur.split.hi);
296
297 wrmsr(MSR_IA32_APERF, 0,0);
298 wrmsr(MSR_IA32_MPERF, 0,0);
299
300#ifdef __i386__
147 /* 301 /*
148 * Assume the write went through when acpi_pstate_strict is not used. 302 * We dont want to do 64 bit divide with 32 bit kernel
149 * As read status_register is an expensive operation and there 303 * Get an approximate value. Return failure in case we cannot get
150 * are no specific error cases where an IO port write will fail. 304 * an approximate value.
151 */ 305 */
152 if (acpi_pstate_strict) { 306 if (unlikely(aperf_cur.split.hi || mperf_cur.split.hi)) {
153 /* Then we read the 'status_register' and compare the value 307 int shift_count;
154 * with the target state's 'status' to make sure the 308 u32 h;
155 * transition was successful. 309
156 * Note that we'll poll for up to 1ms (100 cycles of 10us) 310 h = max_t(u32, aperf_cur.split.hi, mperf_cur.split.hi);
157 * before giving up. 311 shift_count = fls(h);
158 */ 312
159 313 aperf_cur.whole >>= shift_count;
160 port = perf->status_register.address; 314 mperf_cur.whole >>= shift_count;
161 bit_width = perf->status_register.bit_width; 315 }
162 316
163 dprintk("Looking for 0x%08x from port 0x%04x\n", 317 if (((unsigned long)(-1) / 100) < aperf_cur.split.lo) {
164 (u32) perf->states[state].status, port); 318 int shift_count = 7;
165 319 aperf_cur.split.lo >>= shift_count;
166 for (i = 0; i < 100; i++) { 320 mperf_cur.split.lo >>= shift_count;
167 ret = acpi_processor_read_port(port, bit_width, &value); 321 }
168 if (ret) { 322
169 dprintk("Invalid port width 0x%04x\n", bit_width); 323 if (aperf_cur.split.lo && mperf_cur.split.lo)
170 return (ret); 324 perf_percent = (aperf_cur.split.lo * 100) / mperf_cur.split.lo;
171 } 325 else
172 if (value == (u32) perf->states[state].status) 326 perf_percent = 0;
173 break; 327
174 udelay(10); 328#else
175 } 329 if (unlikely(((unsigned long)(-1) / 100) < aperf_cur.whole)) {
176 } else { 330 int shift_count = 7;
177 value = (u32) perf->states[state].status; 331 aperf_cur.whole >>= shift_count;
332 mperf_cur.whole >>= shift_count;
178 } 333 }
179 334
180 if (unlikely(value != (u32) perf->states[state].status)) { 335 if (aperf_cur.whole && mperf_cur.whole)
181 printk(KERN_WARNING "acpi-cpufreq: Transition failed\n"); 336 perf_percent = (aperf_cur.whole * 100) / mperf_cur.whole;
182 retval = -ENODEV; 337 else
183 return (retval); 338 perf_percent = 0;
339
340#endif
341
342 retval = drv_data[cpu]->max_freq * perf_percent / 100;
343
344 put_cpu();
345 set_cpus_allowed(current, saved_mask);
346
347 dprintk("cpu %d: performance percent %d\n", cpu, perf_percent);
348 return retval;
349}
350
351static unsigned int get_cur_freq_on_cpu(unsigned int cpu)
352{
353 struct acpi_cpufreq_data *data = drv_data[cpu];
354 unsigned int freq;
355
356 dprintk("get_cur_freq_on_cpu (%d)\n", cpu);
357
358 if (unlikely(data == NULL ||
359 data->acpi_data == NULL || data->freq_table == NULL)) {
360 return 0;
184 } 361 }
185 362
186 dprintk("Transition successful after %d microseconds\n", i * 10); 363 freq = extract_freq(get_cur_val(cpumask_of_cpu(cpu)), data);
364 dprintk("cur freq = %u\n", freq);
187 365
188 perf->state = state; 366 return freq;
189 return (retval);
190} 367}
191 368
369static unsigned int check_freqs(cpumask_t mask, unsigned int freq,
370 struct acpi_cpufreq_data *data)
371{
372 unsigned int cur_freq;
373 unsigned int i;
374
375 for (i=0; i<100; i++) {
376 cur_freq = extract_freq(get_cur_val(mask), data);
377 if (cur_freq == freq)
378 return 1;
379 udelay(10);
380 }
381 return 0;
382}
192 383
193static int 384static int acpi_cpufreq_target(struct cpufreq_policy *policy,
194acpi_cpufreq_target ( 385 unsigned int target_freq, unsigned int relation)
195 struct cpufreq_policy *policy,
196 unsigned int target_freq,
197 unsigned int relation)
198{ 386{
199 struct cpufreq_acpi_io *data = acpi_io_data[policy->cpu]; 387 struct acpi_cpufreq_data *data = drv_data[policy->cpu];
200 struct acpi_processor_performance *perf; 388 struct acpi_processor_performance *perf;
201 struct cpufreq_freqs freqs; 389 struct cpufreq_freqs freqs;
202 cpumask_t online_policy_cpus; 390 cpumask_t online_policy_cpus;
203 cpumask_t saved_mask; 391 struct drv_cmd cmd;
204 cpumask_t set_mask; 392 unsigned int msr;
205 cpumask_t covered_cpus;
206 unsigned int cur_state = 0;
207 unsigned int next_state = 0; 393 unsigned int next_state = 0;
208 unsigned int result = 0; 394 unsigned int next_perf_state = 0;
209 unsigned int j; 395 unsigned int i;
210 unsigned int tmp; 396 int result = 0;
211 397
212 dprintk("acpi_cpufreq_setpolicy\n"); 398 dprintk("acpi_cpufreq_target %d (%d)\n", target_freq, policy->cpu);
213 399
214 result = cpufreq_frequency_table_target(policy, 400 if (unlikely(data == NULL ||
215 data->freq_table, 401 data->acpi_data == NULL || data->freq_table == NULL)) {
216 target_freq, 402 return -ENODEV;
217 relation, 403 }
218 &next_state);
219 if (unlikely(result))
220 return (result);
221 404
222 perf = data->acpi_data; 405 perf = data->acpi_data;
223 cur_state = perf->state; 406 result = cpufreq_frequency_table_target(policy,
224 freqs.old = data->freq_table[cur_state].frequency; 407 data->freq_table,
225 freqs.new = data->freq_table[next_state].frequency; 408 target_freq,
409 relation, &next_state);
410 if (unlikely(result))
411 return -ENODEV;
226 412
227#ifdef CONFIG_HOTPLUG_CPU 413#ifdef CONFIG_HOTPLUG_CPU
228 /* cpufreq holds the hotplug lock, so we are safe from here on */ 414 /* cpufreq holds the hotplug lock, so we are safe from here on */
@@ -231,106 +417,84 @@ acpi_cpufreq_target (
231 online_policy_cpus = policy->cpus; 417 online_policy_cpus = policy->cpus;
232#endif 418#endif
233 419
234 for_each_cpu_mask(j, online_policy_cpus) { 420 next_perf_state = data->freq_table[next_state].index;
235 freqs.cpu = j; 421 if (perf->state == next_perf_state) {
236 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 422 if (unlikely(data->resume)) {
423 dprintk("Called after resume, resetting to P%d\n",
424 next_perf_state);
425 data->resume = 0;
426 } else {
427 dprintk("Already at target state (P%d)\n",
428 next_perf_state);
429 return 0;
430 }
237 } 431 }
238 432
239 /* 433 switch (data->cpu_feature) {
240 * We need to call driver->target() on all or any CPU in 434 case SYSTEM_INTEL_MSR_CAPABLE:
241 * policy->cpus, depending on policy->shared_type. 435 cmd.type = SYSTEM_INTEL_MSR_CAPABLE;
242 */ 436 cmd.addr.msr.reg = MSR_IA32_PERF_CTL;
243 saved_mask = current->cpus_allowed; 437 msr =
244 cpus_clear(covered_cpus); 438 (u32) perf->states[next_perf_state].
245 for_each_cpu_mask(j, online_policy_cpus) { 439 control & INTEL_MSR_RANGE;
246 /* 440 cmd.val = (cmd.val & ~INTEL_MSR_RANGE) | msr;
247 * Support for SMP systems. 441 break;
248 * Make sure we are running on CPU that wants to change freq 442 case SYSTEM_IO_CAPABLE:
249 */ 443 cmd.type = SYSTEM_IO_CAPABLE;
250 cpus_clear(set_mask); 444 cmd.addr.io.port = perf->control_register.address;
251 if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) 445 cmd.addr.io.bit_width = perf->control_register.bit_width;
252 cpus_or(set_mask, set_mask, online_policy_cpus); 446 cmd.val = (u32) perf->states[next_perf_state].control;
253 else 447 break;
254 cpu_set(j, set_mask); 448 default:
255 449 return -ENODEV;
256 set_cpus_allowed(current, set_mask); 450 }
257 if (unlikely(!cpu_isset(smp_processor_id(), set_mask))) {
258 dprintk("couldn't limit to CPUs in this domain\n");
259 result = -EAGAIN;
260 break;
261 }
262 451
263 result = acpi_processor_set_performance (data, j, next_state); 452 cpus_clear(cmd.mask);
264 if (result) {
265 result = -EAGAIN;
266 break;
267 }
268 453
269 if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) 454 if (policy->shared_type != CPUFREQ_SHARED_TYPE_ANY)
270 break; 455 cmd.mask = online_policy_cpus;
271 456 else
272 cpu_set(j, covered_cpus); 457 cpu_set(policy->cpu, cmd.mask);
273 }
274 458
275 for_each_cpu_mask(j, online_policy_cpus) { 459 freqs.old = data->freq_table[perf->state].frequency;
276 freqs.cpu = j; 460 freqs.new = data->freq_table[next_perf_state].frequency;
277 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 461 for_each_cpu_mask(i, cmd.mask) {
462 freqs.cpu = i;
463 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
278 } 464 }
279 465
280 if (unlikely(result)) { 466 drv_write(&cmd);
281 /*
282 * We have failed halfway through the frequency change.
283 * We have sent callbacks to online_policy_cpus and
284 * acpi_processor_set_performance() has been called on
285 * coverd_cpus. Best effort undo..
286 */
287
288 if (!cpus_empty(covered_cpus)) {
289 for_each_cpu_mask(j, covered_cpus) {
290 policy->cpu = j;
291 acpi_processor_set_performance (data,
292 j,
293 cur_state);
294 }
295 }
296 467
297 tmp = freqs.new; 468 if (acpi_pstate_strict) {
298 freqs.new = freqs.old; 469 if (!check_freqs(cmd.mask, freqs.new, data)) {
299 freqs.old = tmp; 470 dprintk("acpi_cpufreq_target failed (%d)\n",
300 for_each_cpu_mask(j, online_policy_cpus) { 471 policy->cpu);
301 freqs.cpu = j; 472 return -EAGAIN;
302 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
303 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
304 } 473 }
305 } 474 }
306 475
307 set_cpus_allowed(current, saved_mask); 476 for_each_cpu_mask(i, cmd.mask) {
308 return (result); 477 freqs.cpu = i;
309} 478 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
479 }
480 perf->state = next_perf_state;
310 481
482 return result;
483}
311 484
312static int 485static int acpi_cpufreq_verify(struct cpufreq_policy *policy)
313acpi_cpufreq_verify (
314 struct cpufreq_policy *policy)
315{ 486{
316 unsigned int result = 0; 487 struct acpi_cpufreq_data *data = drv_data[policy->cpu];
317 struct cpufreq_acpi_io *data = acpi_io_data[policy->cpu];
318 488
319 dprintk("acpi_cpufreq_verify\n"); 489 dprintk("acpi_cpufreq_verify\n");
320 490
321 result = cpufreq_frequency_table_verify(policy, 491 return cpufreq_frequency_table_verify(policy, data->freq_table);
322 data->freq_table);
323
324 return (result);
325} 492}
326 493
327
328static unsigned long 494static unsigned long
329acpi_cpufreq_guess_freq ( 495acpi_cpufreq_guess_freq(struct acpi_cpufreq_data *data, unsigned int cpu)
330 struct cpufreq_acpi_io *data,
331 unsigned int cpu)
332{ 496{
333 struct acpi_processor_performance *perf = data->acpi_data; 497 struct acpi_processor_performance *perf = data->acpi_data;
334 498
335 if (cpu_khz) { 499 if (cpu_khz) {
336 /* search the closest match to cpu_khz */ 500 /* search the closest match to cpu_khz */
@@ -338,16 +502,16 @@ acpi_cpufreq_guess_freq (
338 unsigned long freq; 502 unsigned long freq;
339 unsigned long freqn = perf->states[0].core_frequency * 1000; 503 unsigned long freqn = perf->states[0].core_frequency * 1000;
340 504
341 for (i = 0; i < (perf->state_count - 1); i++) { 505 for (i=0; i<(perf->state_count-1); i++) {
342 freq = freqn; 506 freq = freqn;
343 freqn = perf->states[i+1].core_frequency * 1000; 507 freqn = perf->states[i+1].core_frequency * 1000;
344 if ((2 * cpu_khz) > (freqn + freq)) { 508 if ((2 * cpu_khz) > (freqn + freq)) {
345 perf->state = i; 509 perf->state = i;
346 return (freq); 510 return freq;
347 } 511 }
348 } 512 }
349 perf->state = perf->state_count - 1; 513 perf->state = perf->state_count-1;
350 return (freqn); 514 return freqn;
351 } else { 515 } else {
352 /* assume CPU is at P0... */ 516 /* assume CPU is at P0... */
353 perf->state = 0; 517 perf->state = 0;
@@ -355,7 +519,6 @@ acpi_cpufreq_guess_freq (
355 } 519 }
356} 520}
357 521
358
359/* 522/*
360 * acpi_cpufreq_early_init - initialize ACPI P-States library 523 * acpi_cpufreq_early_init - initialize ACPI P-States library
361 * 524 *
@@ -364,30 +527,34 @@ acpi_cpufreq_guess_freq (
364 * do _PDC and _PSD and find out the processor dependency for the 527 * do _PDC and _PSD and find out the processor dependency for the
365 * actual init that will happen later... 528 * actual init that will happen later...
366 */ 529 */
367static int acpi_cpufreq_early_init_acpi(void) 530static int acpi_cpufreq_early_init(void)
368{ 531{
369 struct acpi_processor_performance *data; 532 struct acpi_processor_performance *data;
370 unsigned int i, j; 533 cpumask_t covered;
534 unsigned int i, j;
371 535
372 dprintk("acpi_cpufreq_early_init\n"); 536 dprintk("acpi_cpufreq_early_init\n");
373 537
374 for_each_possible_cpu(i) { 538 for_each_possible_cpu(i) {
375 data = kzalloc(sizeof(struct acpi_processor_performance), 539 data = kzalloc(sizeof(struct acpi_processor_performance),
376 GFP_KERNEL); 540 GFP_KERNEL);
377 if (!data) { 541 if (!data) {
378 for_each_possible_cpu(j) { 542 for_each_cpu_mask(j, covered) {
379 kfree(acpi_perf_data[j]); 543 kfree(acpi_perf_data[j]);
380 acpi_perf_data[j] = NULL; 544 acpi_perf_data[j] = NULL;
381 } 545 }
382 return (-ENOMEM); 546 return -ENOMEM;
383 } 547 }
384 acpi_perf_data[i] = data; 548 acpi_perf_data[i] = data;
549 cpu_set(i, covered);
385 } 550 }
386 551
387 /* Do initialization in ACPI core */ 552 /* Do initialization in ACPI core */
388 return acpi_processor_preregister_performance(acpi_perf_data); 553 acpi_processor_preregister_performance(acpi_perf_data);
554 return 0;
389} 555}
390 556
557#ifdef CONFIG_SMP
391/* 558/*
392 * Some BIOSes do SW_ANY coordination internally, either set it up in hw 559 * Some BIOSes do SW_ANY coordination internally, either set it up in hw
393 * or do it in BIOS firmware and won't inform about it to OS. If not 560 * or do it in BIOS firmware and won't inform about it to OS. If not
@@ -414,39 +581,42 @@ static struct dmi_system_id sw_any_bug_dmi_table[] = {
414 }, 581 },
415 { } 582 { }
416}; 583};
584#endif
417 585
418static int 586static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
419acpi_cpufreq_cpu_init (
420 struct cpufreq_policy *policy)
421{ 587{
422 unsigned int i; 588 unsigned int i;
423 unsigned int cpu = policy->cpu; 589 unsigned int valid_states = 0;
424 struct cpufreq_acpi_io *data; 590 unsigned int cpu = policy->cpu;
425 unsigned int result = 0; 591 struct acpi_cpufreq_data *data;
592 unsigned int result = 0;
426 struct cpuinfo_x86 *c = &cpu_data[policy->cpu]; 593 struct cpuinfo_x86 *c = &cpu_data[policy->cpu];
427 struct acpi_processor_performance *perf; 594 struct acpi_processor_performance *perf;
428 595
429 dprintk("acpi_cpufreq_cpu_init\n"); 596 dprintk("acpi_cpufreq_cpu_init\n");
430 597
431 if (!acpi_perf_data[cpu]) 598 if (!acpi_perf_data[cpu])
432 return (-ENODEV); 599 return -ENODEV;
433 600
434 data = kzalloc(sizeof(struct cpufreq_acpi_io), GFP_KERNEL); 601 data = kzalloc(sizeof(struct acpi_cpufreq_data), GFP_KERNEL);
435 if (!data) 602 if (!data)
436 return (-ENOMEM); 603 return -ENOMEM;
437 604
438 data->acpi_data = acpi_perf_data[cpu]; 605 data->acpi_data = acpi_perf_data[cpu];
439 acpi_io_data[cpu] = data; 606 drv_data[cpu] = data;
440 607
441 result = acpi_processor_register_performance(data->acpi_data, cpu); 608 if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
609 acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
442 610
611 result = acpi_processor_register_performance(data->acpi_data, cpu);
443 if (result) 612 if (result)
444 goto err_free; 613 goto err_free;
445 614
446 perf = data->acpi_data; 615 perf = data->acpi_data;
447 policy->shared_type = perf->shared_type; 616 policy->shared_type = perf->shared_type;
617
448 /* 618 /*
449 * Will let policy->cpus know about dependency only when software 619 * Will let policy->cpus know about dependency only when software
450 * coordination is required. 620 * coordination is required.
451 */ 621 */
452 if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL || 622 if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL ||
@@ -462,10 +632,6 @@ acpi_cpufreq_cpu_init (
462 } 632 }
463#endif 633#endif
464 634
465 if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
466 acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
467 }
468
469 /* capability check */ 635 /* capability check */
470 if (perf->state_count <= 1) { 636 if (perf->state_count <= 1) {
471 dprintk("No P-States\n"); 637 dprintk("No P-States\n");
@@ -473,17 +639,33 @@ acpi_cpufreq_cpu_init (
473 goto err_unreg; 639 goto err_unreg;
474 } 640 }
475 641
476 if ((perf->control_register.space_id != ACPI_ADR_SPACE_SYSTEM_IO) || 642 if (perf->control_register.space_id != perf->status_register.space_id) {
477 (perf->status_register.space_id != ACPI_ADR_SPACE_SYSTEM_IO)) { 643 result = -ENODEV;
478 dprintk("Unsupported address space [%d, %d]\n", 644 goto err_unreg;
479 (u32) (perf->control_register.space_id), 645 }
480 (u32) (perf->status_register.space_id)); 646
647 switch (perf->control_register.space_id) {
648 case ACPI_ADR_SPACE_SYSTEM_IO:
649 dprintk("SYSTEM IO addr space\n");
650 data->cpu_feature = SYSTEM_IO_CAPABLE;
651 break;
652 case ACPI_ADR_SPACE_FIXED_HARDWARE:
653 dprintk("HARDWARE addr space\n");
654 if (!check_est_cpu(cpu)) {
655 result = -ENODEV;
656 goto err_unreg;
657 }
658 data->cpu_feature = SYSTEM_INTEL_MSR_CAPABLE;
659 break;
660 default:
661 dprintk("Unknown addr space %d\n",
662 (u32) (perf->control_register.space_id));
481 result = -ENODEV; 663 result = -ENODEV;
482 goto err_unreg; 664 goto err_unreg;
483 } 665 }
484 666
485 /* alloc freq_table */ 667 data->freq_table = kmalloc(sizeof(struct cpufreq_frequency_table) *
486 data->freq_table = kmalloc(sizeof(struct cpufreq_frequency_table) * (perf->state_count + 1), GFP_KERNEL); 668 (perf->state_count+1), GFP_KERNEL);
487 if (!data->freq_table) { 669 if (!data->freq_table) {
488 result = -ENOMEM; 670 result = -ENOMEM;
489 goto err_unreg; 671 goto err_unreg;
@@ -492,129 +674,140 @@ acpi_cpufreq_cpu_init (
492 /* detect transition latency */ 674 /* detect transition latency */
493 policy->cpuinfo.transition_latency = 0; 675 policy->cpuinfo.transition_latency = 0;
494 for (i=0; i<perf->state_count; i++) { 676 for (i=0; i<perf->state_count; i++) {
495 if ((perf->states[i].transition_latency * 1000) > policy->cpuinfo.transition_latency) 677 if ((perf->states[i].transition_latency * 1000) >
496 policy->cpuinfo.transition_latency = perf->states[i].transition_latency * 1000; 678 policy->cpuinfo.transition_latency)
679 policy->cpuinfo.transition_latency =
680 perf->states[i].transition_latency * 1000;
497 } 681 }
498 policy->governor = CPUFREQ_DEFAULT_GOVERNOR; 682 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
499 683
500 /* The current speed is unknown and not detectable by ACPI... */ 684 data->max_freq = perf->states[0].core_frequency * 1000;
501 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
502
503 /* table init */ 685 /* table init */
504 for (i=0; i<=perf->state_count; i++) 686 for (i=0; i<perf->state_count; i++) {
505 { 687 if (i>0 && perf->states[i].core_frequency ==
506 data->freq_table[i].index = i; 688 perf->states[i-1].core_frequency)
507 if (i<perf->state_count) 689 continue;
508 data->freq_table[i].frequency = perf->states[i].core_frequency * 1000; 690
509 else 691 data->freq_table[valid_states].index = i;
510 data->freq_table[i].frequency = CPUFREQ_TABLE_END; 692 data->freq_table[valid_states].frequency =
693 perf->states[i].core_frequency * 1000;
694 valid_states++;
511 } 695 }
696 data->freq_table[valid_states].frequency = CPUFREQ_TABLE_END;
512 697
513 result = cpufreq_frequency_table_cpuinfo(policy, data->freq_table); 698 result = cpufreq_frequency_table_cpuinfo(policy, data->freq_table);
514 if (result) { 699 if (result)
515 goto err_freqfree; 700 goto err_freqfree;
701
702 switch (data->cpu_feature) {
703 case ACPI_ADR_SPACE_SYSTEM_IO:
704 /* Current speed is unknown and not detectable by IO port */
705 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
706 break;
707 case ACPI_ADR_SPACE_FIXED_HARDWARE:
708 acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
709 get_cur_freq_on_cpu(cpu);
710 break;
711 default:
712 break;
516 } 713 }
517 714
518 /* notify BIOS that we exist */ 715 /* notify BIOS that we exist */
519 acpi_processor_notify_smm(THIS_MODULE); 716 acpi_processor_notify_smm(THIS_MODULE);
520 717
521 printk(KERN_INFO "acpi-cpufreq: CPU%u - ACPI performance management activated.\n", 718 /* Check for APERF/MPERF support in hardware */
522 cpu); 719 if (c->x86_vendor == X86_VENDOR_INTEL && c->cpuid_level >= 6) {
720 unsigned int ecx;
721 ecx = cpuid_ecx(6);
722 if (ecx & CPUID_6_ECX_APERFMPERF_CAPABILITY)
723 acpi_cpufreq_driver.getavg = get_measured_perf;
724 }
725
726 dprintk("CPU%u - ACPI performance management activated.\n", cpu);
523 for (i = 0; i < perf->state_count; i++) 727 for (i = 0; i < perf->state_count; i++)
524 dprintk(" %cP%d: %d MHz, %d mW, %d uS\n", 728 dprintk(" %cP%d: %d MHz, %d mW, %d uS\n",
525 (i == perf->state?'*':' '), i, 729 (i == perf->state ? '*' : ' '), i,
526 (u32) perf->states[i].core_frequency, 730 (u32) perf->states[i].core_frequency,
527 (u32) perf->states[i].power, 731 (u32) perf->states[i].power,
528 (u32) perf->states[i].transition_latency); 732 (u32) perf->states[i].transition_latency);
529 733
530 cpufreq_frequency_table_get_attr(data->freq_table, policy->cpu); 734 cpufreq_frequency_table_get_attr(data->freq_table, policy->cpu);
531 735
532 /* 736 /*
533 * the first call to ->target() should result in us actually 737 * the first call to ->target() should result in us actually
534 * writing something to the appropriate registers. 738 * writing something to the appropriate registers.
535 */ 739 */
536 data->resume = 1; 740 data->resume = 1;
537
538 return (result);
539 741
540 err_freqfree: 742 return result;
743
744err_freqfree:
541 kfree(data->freq_table); 745 kfree(data->freq_table);
542 err_unreg: 746err_unreg:
543 acpi_processor_unregister_performance(perf, cpu); 747 acpi_processor_unregister_performance(perf, cpu);
544 err_free: 748err_free:
545 kfree(data); 749 kfree(data);
546 acpi_io_data[cpu] = NULL; 750 drv_data[cpu] = NULL;
547 751
548 return (result); 752 return result;
549} 753}
550 754
551 755static int acpi_cpufreq_cpu_exit(struct cpufreq_policy *policy)
552static int
553acpi_cpufreq_cpu_exit (
554 struct cpufreq_policy *policy)
555{ 756{
556 struct cpufreq_acpi_io *data = acpi_io_data[policy->cpu]; 757 struct acpi_cpufreq_data *data = drv_data[policy->cpu];
557
558 758
559 dprintk("acpi_cpufreq_cpu_exit\n"); 759 dprintk("acpi_cpufreq_cpu_exit\n");
560 760
561 if (data) { 761 if (data) {
562 cpufreq_frequency_table_put_attr(policy->cpu); 762 cpufreq_frequency_table_put_attr(policy->cpu);
563 acpi_io_data[policy->cpu] = NULL; 763 drv_data[policy->cpu] = NULL;
564 acpi_processor_unregister_performance(data->acpi_data, policy->cpu); 764 acpi_processor_unregister_performance(data->acpi_data,
765 policy->cpu);
565 kfree(data); 766 kfree(data);
566 } 767 }
567 768
568 return (0); 769 return 0;
569} 770}
570 771
571static int 772static int acpi_cpufreq_resume(struct cpufreq_policy *policy)
572acpi_cpufreq_resume (
573 struct cpufreq_policy *policy)
574{ 773{
575 struct cpufreq_acpi_io *data = acpi_io_data[policy->cpu]; 774 struct acpi_cpufreq_data *data = drv_data[policy->cpu];
576
577 775
578 dprintk("acpi_cpufreq_resume\n"); 776 dprintk("acpi_cpufreq_resume\n");
579 777
580 data->resume = 1; 778 data->resume = 1;
581 779
582 return (0); 780 return 0;
583} 781}
584 782
585 783static struct freq_attr *acpi_cpufreq_attr[] = {
586static struct freq_attr* acpi_cpufreq_attr[] = {
587 &cpufreq_freq_attr_scaling_available_freqs, 784 &cpufreq_freq_attr_scaling_available_freqs,
588 NULL, 785 NULL,
589}; 786};
590 787
591static struct cpufreq_driver acpi_cpufreq_driver = { 788static struct cpufreq_driver acpi_cpufreq_driver = {
592 .verify = acpi_cpufreq_verify, 789 .verify = acpi_cpufreq_verify,
593 .target = acpi_cpufreq_target, 790 .target = acpi_cpufreq_target,
594 .init = acpi_cpufreq_cpu_init, 791 .init = acpi_cpufreq_cpu_init,
595 .exit = acpi_cpufreq_cpu_exit, 792 .exit = acpi_cpufreq_cpu_exit,
596 .resume = acpi_cpufreq_resume, 793 .resume = acpi_cpufreq_resume,
597 .name = "acpi-cpufreq", 794 .name = "acpi-cpufreq",
598 .owner = THIS_MODULE, 795 .owner = THIS_MODULE,
599 .attr = acpi_cpufreq_attr, 796 .attr = acpi_cpufreq_attr,
600}; 797};
601 798
602 799static int __init acpi_cpufreq_init(void)
603static int __init
604acpi_cpufreq_init (void)
605{ 800{
606 dprintk("acpi_cpufreq_init\n"); 801 dprintk("acpi_cpufreq_init\n");
607 802
608 acpi_cpufreq_early_init_acpi(); 803 acpi_cpufreq_early_init();
609 804
610 return cpufreq_register_driver(&acpi_cpufreq_driver); 805 return cpufreq_register_driver(&acpi_cpufreq_driver);
611} 806}
612 807
613 808static void __exit acpi_cpufreq_exit(void)
614static void __exit
615acpi_cpufreq_exit (void)
616{ 809{
617 unsigned int i; 810 unsigned int i;
618 dprintk("acpi_cpufreq_exit\n"); 811 dprintk("acpi_cpufreq_exit\n");
619 812
620 cpufreq_unregister_driver(&acpi_cpufreq_driver); 813 cpufreq_unregister_driver(&acpi_cpufreq_driver);
@@ -627,7 +820,9 @@ acpi_cpufreq_exit (void)
627} 820}
628 821
629module_param(acpi_pstate_strict, uint, 0644); 822module_param(acpi_pstate_strict, uint, 0644);
630MODULE_PARM_DESC(acpi_pstate_strict, "value 0 or non-zero. non-zero -> strict ACPI checks are performed during frequency changes."); 823MODULE_PARM_DESC(acpi_pstate_strict,
824 "value 0 or non-zero. non-zero -> strict ACPI checks are "
825 "performed during frequency changes.");
631 826
632late_initcall(acpi_cpufreq_init); 827late_initcall(acpi_cpufreq_init);
633module_exit(acpi_cpufreq_exit); 828module_exit(acpi_cpufreq_exit);
diff --git a/arch/i386/kernel/cpu/cpufreq/gx-suspmod.c b/arch/i386/kernel/cpu/cpufreq/gx-suspmod.c
index 92afa3bc84f1..6667e9cceb9f 100644
--- a/arch/i386/kernel/cpu/cpufreq/gx-suspmod.c
+++ b/arch/i386/kernel/cpu/cpufreq/gx-suspmod.c
@@ -447,7 +447,6 @@ static int __init cpufreq_gx_init(void)
447 int ret; 447 int ret;
448 struct gxfreq_params *params; 448 struct gxfreq_params *params;
449 struct pci_dev *gx_pci; 449 struct pci_dev *gx_pci;
450 u32 class_rev;
451 450
452 /* Test if we have the right hardware */ 451 /* Test if we have the right hardware */
453 if ((gx_pci = gx_detect_chipset()) == NULL) 452 if ((gx_pci = gx_detect_chipset()) == NULL)
@@ -472,8 +471,7 @@ static int __init cpufreq_gx_init(void)
472 pci_read_config_byte(params->cs55x0, PCI_PMER2, &(params->pci_pmer2)); 471 pci_read_config_byte(params->cs55x0, PCI_PMER2, &(params->pci_pmer2));
473 pci_read_config_byte(params->cs55x0, PCI_MODON, &(params->on_duration)); 472 pci_read_config_byte(params->cs55x0, PCI_MODON, &(params->on_duration));
474 pci_read_config_byte(params->cs55x0, PCI_MODOFF, &(params->off_duration)); 473 pci_read_config_byte(params->cs55x0, PCI_MODOFF, &(params->off_duration));
475 pci_read_config_dword(params->cs55x0, PCI_CLASS_REVISION, &class_rev); 474 pci_read_config_byte(params->cs55x0, PCI_REVISION_ID, &params->pci_rev);
476 params->pci_rev = class_rev && 0xff;
477 475
478 if ((ret = cpufreq_register_driver(&gx_suspmod_driver))) { 476 if ((ret = cpufreq_register_driver(&gx_suspmod_driver))) {
479 kfree(params); 477 kfree(params);
diff --git a/arch/i386/kernel/cpu/cpufreq/longhaul.c b/arch/i386/kernel/cpu/cpufreq/longhaul.c
index 7233abe5d695..c548daad3476 100644
--- a/arch/i386/kernel/cpu/cpufreq/longhaul.c
+++ b/arch/i386/kernel/cpu/cpufreq/longhaul.c
@@ -410,7 +410,7 @@ static int __init longhaul_get_ranges(void)
410 maxmult=longhaul_get_cpu_mult(); 410 maxmult=longhaul_get_cpu_mult();
411 411
412 /* Starting with the 1.2GHz parts, theres a 200MHz bus. */ 412 /* Starting with the 1.2GHz parts, theres a 200MHz bus. */
413 if ((cpu_khz/1000) > 1200) 413 if ((cpu_khz/maxmult) > 13400)
414 fsb = 200; 414 fsb = 200;
415 else 415 else
416 fsb = eblcr_fsb_table_v2[longhaul.bits.MaxMHzFSB]; 416 fsb = eblcr_fsb_table_v2[longhaul.bits.MaxMHzFSB];
@@ -583,6 +583,10 @@ static int enable_arbiter_disable(void)
583 if (dev == NULL) { 583 if (dev == NULL) {
584 reg = 0x76; 584 reg = 0x76;
585 dev = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_862X_0, NULL); 585 dev = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_862X_0, NULL);
586 /* Find CN400 V-Link host bridge */
587 if (dev == NULL)
588 dev = pci_find_device(PCI_VENDOR_ID_VIA, 0x7259, NULL);
589
586 } 590 }
587 if (dev != NULL) { 591 if (dev != NULL) {
588 /* Enable access to port 0x22 */ 592 /* Enable access to port 0x22 */
@@ -734,7 +738,7 @@ print_support_type:
734 return 0; 738 return 0;
735 739
736err_acpi: 740err_acpi:
737 printk(KERN_ERR PFX "No ACPI support. No VT8601 or VT8623 northbridge. Aborting.\n"); 741 printk(KERN_ERR PFX "No ACPI support. Unsupported northbridge. Aborting.\n");
738 return -ENODEV; 742 return -ENODEV;
739} 743}
740 744
diff --git a/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c b/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c
index 304d2eaa4a1b..bec50170b75a 100644
--- a/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c
+++ b/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c
@@ -163,29 +163,27 @@ static int cpufreq_p4_verify(struct cpufreq_policy *policy)
163 163
164static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c) 164static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
165{ 165{
166 if ((c->x86 == 0x06) && (c->x86_model == 0x09)) { 166 if (c->x86 == 0x06) {
167 /* Pentium M (Banias) */ 167 if (cpu_has(c, X86_FEATURE_EST))
168 printk(KERN_WARNING PFX "Warning: Pentium M detected. " 168 printk(KERN_WARNING PFX "Warning: EST-capable CPU detected. "
169 "The speedstep_centrino module offers voltage scaling" 169 "The acpi-cpufreq module offers voltage scaling"
170 " in addition of frequency scaling. You should use " 170 " in addition of frequency scaling. You should use "
171 "that instead of p4-clockmod, if possible.\n"); 171 "that instead of p4-clockmod, if possible.\n");
172 return speedstep_get_processor_frequency(SPEEDSTEP_PROCESSOR_PM); 172 switch (c->x86_model) {
173 } 173 case 0x0E: /* Core */
174 174 case 0x0F: /* Core Duo */
175 if ((c->x86 == 0x06) && (c->x86_model == 0x0D)) { 175 p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
176 /* Pentium M (Dothan) */ 176 return speedstep_get_processor_frequency(SPEEDSTEP_PROCESSOR_PCORE);
177 printk(KERN_WARNING PFX "Warning: Pentium M detected. " 177 case 0x0D: /* Pentium M (Dothan) */
178 "The speedstep_centrino module offers voltage scaling" 178 p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
179 " in addition of frequency scaling. You should use " 179 /* fall through */
180 "that instead of p4-clockmod, if possible.\n"); 180 case 0x09: /* Pentium M (Banias) */
181 /* on P-4s, the TSC runs with constant frequency independent whether 181 return speedstep_get_processor_frequency(SPEEDSTEP_PROCESSOR_PM);
182 * throttling is active or not. */ 182 }
183 p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
184 return speedstep_get_processor_frequency(SPEEDSTEP_PROCESSOR_PM);
185 } 183 }
186 184
187 if (c->x86 != 0xF) { 185 if (c->x86 != 0xF) {
188 printk(KERN_WARNING PFX "Unknown p4-clockmod-capable CPU. Please send an e-mail to <linux@brodo.de>\n"); 186 printk(KERN_WARNING PFX "Unknown p4-clockmod-capable CPU. Please send an e-mail to <cpufreq@lists.linux.org.uk>\n");
189 return 0; 187 return 0;
190 } 188 }
191 189
diff --git a/arch/i386/kernel/cpu/cpufreq/sc520_freq.c b/arch/i386/kernel/cpu/cpufreq/sc520_freq.c
index ef457d50f4ac..b8fb4b521c62 100644
--- a/arch/i386/kernel/cpu/cpufreq/sc520_freq.c
+++ b/arch/i386/kernel/cpu/cpufreq/sc520_freq.c
@@ -153,6 +153,7 @@ static struct cpufreq_driver sc520_freq_driver = {
153static int __init sc520_freq_init(void) 153static int __init sc520_freq_init(void)
154{ 154{
155 struct cpuinfo_x86 *c = cpu_data; 155 struct cpuinfo_x86 *c = cpu_data;
156 int err;
156 157
157 /* Test if we have the right hardware */ 158 /* Test if we have the right hardware */
158 if(c->x86_vendor != X86_VENDOR_AMD || 159 if(c->x86_vendor != X86_VENDOR_AMD ||
@@ -166,7 +167,11 @@ static int __init sc520_freq_init(void)
166 return -ENOMEM; 167 return -ENOMEM;
167 } 168 }
168 169
169 return cpufreq_register_driver(&sc520_freq_driver); 170 err = cpufreq_register_driver(&sc520_freq_driver);
171 if (err)
172 iounmap(cpuctl);
173
174 return err;
170} 175}
171 176
172 177
diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
index e8993baf3d14..5113e9231634 100644
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
+++ b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
@@ -36,6 +36,7 @@
36 36
37#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "speedstep-centrino", msg) 37#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "speedstep-centrino", msg)
38 38
39#define INTEL_MSR_RANGE (0xffff)
39 40
40struct cpu_id 41struct cpu_id
41{ 42{
@@ -379,6 +380,7 @@ static int centrino_cpu_early_init_acpi(void)
379} 380}
380 381
381 382
383#ifdef CONFIG_SMP
382/* 384/*
383 * Some BIOSes do SW_ANY coordination internally, either set it up in hw 385 * Some BIOSes do SW_ANY coordination internally, either set it up in hw
384 * or do it in BIOS firmware and won't inform about it to OS. If not 386 * or do it in BIOS firmware and won't inform about it to OS. If not
@@ -392,7 +394,6 @@ static int sw_any_bug_found(struct dmi_system_id *d)
392 return 0; 394 return 0;
393} 395}
394 396
395
396static struct dmi_system_id sw_any_bug_dmi_table[] = { 397static struct dmi_system_id sw_any_bug_dmi_table[] = {
397 { 398 {
398 .callback = sw_any_bug_found, 399 .callback = sw_any_bug_found,
@@ -405,7 +406,7 @@ static struct dmi_system_id sw_any_bug_dmi_table[] = {
405 }, 406 },
406 { } 407 { }
407}; 408};
408 409#endif
409 410
410/* 411/*
411 * centrino_cpu_init_acpi - register with ACPI P-States library 412 * centrino_cpu_init_acpi - register with ACPI P-States library
@@ -463,8 +464,9 @@ static int centrino_cpu_init_acpi(struct cpufreq_policy *policy)
463 } 464 }
464 465
465 for (i=0; i<p->state_count; i++) { 466 for (i=0; i<p->state_count; i++) {
466 if (p->states[i].control != p->states[i].status) { 467 if ((p->states[i].control & INTEL_MSR_RANGE) !=
467 dprintk("Different control (%llu) and status values (%llu)\n", 468 (p->states[i].status & INTEL_MSR_RANGE)) {
469 dprintk("Different MSR bits in control (%llu) and status (%llu)\n",
468 p->states[i].control, p->states[i].status); 470 p->states[i].control, p->states[i].status);
469 result = -EINVAL; 471 result = -EINVAL;
470 goto err_unreg; 472 goto err_unreg;
@@ -500,7 +502,7 @@ static int centrino_cpu_init_acpi(struct cpufreq_policy *policy)
500 } 502 }
501 503
502 for (i=0; i<p->state_count; i++) { 504 for (i=0; i<p->state_count; i++) {
503 centrino_model[cpu]->op_points[i].index = p->states[i].control; 505 centrino_model[cpu]->op_points[i].index = p->states[i].control & INTEL_MSR_RANGE;
504 centrino_model[cpu]->op_points[i].frequency = p->states[i].core_frequency * 1000; 506 centrino_model[cpu]->op_points[i].frequency = p->states[i].core_frequency * 1000;
505 dprintk("adding state %i with frequency %u and control value %04x\n", 507 dprintk("adding state %i with frequency %u and control value %04x\n",
506 i, centrino_model[cpu]->op_points[i].frequency, centrino_model[cpu]->op_points[i].index); 508 i, centrino_model[cpu]->op_points[i].frequency, centrino_model[cpu]->op_points[i].index);
@@ -531,6 +533,9 @@ static int centrino_cpu_init_acpi(struct cpufreq_policy *policy)
531 533
532 /* notify BIOS that we exist */ 534 /* notify BIOS that we exist */
533 acpi_processor_notify_smm(THIS_MODULE); 535 acpi_processor_notify_smm(THIS_MODULE);
536 printk("speedstep-centrino with X86_SPEEDSTEP_CENTRINO_ACPI"
537 "config is deprecated.\n "
538 "Use X86_ACPI_CPUFREQ (acpi-cpufreq instead.\n" );
534 539
535 return 0; 540 return 0;
536 541
diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c b/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c
index 4f46cac155c4..d59277c00911 100644
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c
+++ b/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c
@@ -123,6 +123,36 @@ static unsigned int pentiumM_get_frequency(void)
123 return (msr_tmp * 100 * 1000); 123 return (msr_tmp * 100 * 1000);
124} 124}
125 125
126static unsigned int pentium_core_get_frequency(void)
127{
128 u32 fsb = 0;
129 u32 msr_lo, msr_tmp;
130
131 rdmsr(MSR_FSB_FREQ, msr_lo, msr_tmp);
132 /* see table B-2 of 25366920.pdf */
133 switch (msr_lo & 0x07) {
134 case 5:
135 fsb = 100000;
136 break;
137 case 1:
138 fsb = 133333;
139 break;
140 case 3:
141 fsb = 166667;
142 break;
143 default:
144 printk(KERN_ERR "PCORE - MSR_FSB_FREQ undefined value");
145 }
146
147 rdmsr(MSR_IA32_EBL_CR_POWERON, msr_lo, msr_tmp);
148 dprintk("PCORE - MSR_IA32_EBL_CR_POWERON: 0x%x 0x%x\n", msr_lo, msr_tmp);
149
150 msr_tmp = (msr_lo >> 22) & 0x1f;
151 dprintk("bits 22-26 are 0x%x, speed is %u\n", msr_tmp, (msr_tmp * fsb));
152
153 return (msr_tmp * fsb);
154}
155
126 156
127static unsigned int pentium4_get_frequency(void) 157static unsigned int pentium4_get_frequency(void)
128{ 158{
@@ -174,6 +204,8 @@ static unsigned int pentium4_get_frequency(void)
174unsigned int speedstep_get_processor_frequency(unsigned int processor) 204unsigned int speedstep_get_processor_frequency(unsigned int processor)
175{ 205{
176 switch (processor) { 206 switch (processor) {
207 case SPEEDSTEP_PROCESSOR_PCORE:
208 return pentium_core_get_frequency();
177 case SPEEDSTEP_PROCESSOR_PM: 209 case SPEEDSTEP_PROCESSOR_PM:
178 return pentiumM_get_frequency(); 210 return pentiumM_get_frequency();
179 case SPEEDSTEP_PROCESSOR_P4D: 211 case SPEEDSTEP_PROCESSOR_P4D:
diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-lib.h b/arch/i386/kernel/cpu/cpufreq/speedstep-lib.h
index b735429c50b4..b11bcc608cac 100644
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-lib.h
+++ b/arch/i386/kernel/cpu/cpufreq/speedstep-lib.h
@@ -22,6 +22,7 @@
22 * the speedstep_get_processor_frequency() call. */ 22 * the speedstep_get_processor_frequency() call. */
23#define SPEEDSTEP_PROCESSOR_PM 0xFFFFFF03 /* Pentium M */ 23#define SPEEDSTEP_PROCESSOR_PM 0xFFFFFF03 /* Pentium M */
24#define SPEEDSTEP_PROCESSOR_P4D 0xFFFFFF04 /* desktop P4 */ 24#define SPEEDSTEP_PROCESSOR_P4D 0xFFFFFF04 /* desktop P4 */
25#define SPEEDSTEP_PROCESSOR_PCORE 0xFFFFFF05 /* Core */
25 26
26/* speedstep states -- only two of them */ 27/* speedstep states -- only two of them */
27 28
diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c b/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c
index c28333d53646..ff0d89806114 100644
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c
+++ b/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c
@@ -360,9 +360,6 @@ static int __init speedstep_init(void)
360 case SPEEDSTEP_PROCESSOR_PIII_C: 360 case SPEEDSTEP_PROCESSOR_PIII_C:
361 case SPEEDSTEP_PROCESSOR_PIII_C_EARLY: 361 case SPEEDSTEP_PROCESSOR_PIII_C_EARLY:
362 break; 362 break;
363 case SPEEDSTEP_PROCESSOR_P4M:
364 printk(KERN_INFO "speedstep-smi: you're trying to use this cpufreq driver on a Pentium 4-based CPU. Most likely it will not work.\n");
365 break;
366 default: 363 default:
367 speedstep_processor = 0; 364 speedstep_processor = 0;
368 } 365 }
diff --git a/arch/powerpc/platforms/4xx/Kconfig b/arch/powerpc/platforms/4xx/Kconfig
index ed39d6a3d22a..2f2a13ed7667 100644
--- a/arch/powerpc/platforms/4xx/Kconfig
+++ b/arch/powerpc/platforms/4xx/Kconfig
@@ -179,7 +179,7 @@ config BIOS_FIXUP
179# OAK doesn't exist but wanted to keep this around for any future 403GCX boards 179# OAK doesn't exist but wanted to keep this around for any future 403GCX boards
180config 403GCX 180config 403GCX
181 bool 181 bool
182 depends OAK 182 depends on OAK
183 default y 183 default y
184 184
185config 405EP 185config 405EP
diff --git a/arch/powerpc/platforms/embedded6xx/Kconfig b/arch/powerpc/platforms/embedded6xx/Kconfig
index ddbe398fbd48..b3c2ce4cb7a8 100644
--- a/arch/powerpc/platforms/embedded6xx/Kconfig
+++ b/arch/powerpc/platforms/embedded6xx/Kconfig
@@ -35,7 +35,7 @@ config HDPU
35 Select HDPU if configuring a Sky Computers Compute Blade. 35 Select HDPU if configuring a Sky Computers Compute Blade.
36 36
37config HDPU_FEATURES 37config HDPU_FEATURES
38 depends HDPU 38 depends on HDPU
39 tristate "HDPU-Features" 39 tristate "HDPU-Features"
40 help 40 help
41 Select to enable HDPU enhanced features. 41 Select to enable HDPU enhanced features.
diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig
index 692b5ba53209..8eb82efe05a1 100644
--- a/arch/ppc/Kconfig
+++ b/arch/ppc/Kconfig
@@ -624,7 +624,7 @@ config HDPU
624 Select HDPU if configuring a Sky Computers Compute Blade. 624 Select HDPU if configuring a Sky Computers Compute Blade.
625 625
626config HDPU_FEATURES 626config HDPU_FEATURES
627 depends HDPU 627 depends on HDPU
628 tristate "HDPU-Features" 628 tristate "HDPU-Features"
629 help 629 help
630 Select to enable HDPU enhanced features. 630 Select to enable HDPU enhanced features.
@@ -735,7 +735,7 @@ config LITE5200
735 735
736config LITE5200B 736config LITE5200B
737 bool "Freescale LITE5200B" 737 bool "Freescale LITE5200B"
738 depends LITE5200 738 depends on LITE5200
739 help 739 help
740 Support for the LITE5200B dev board for the MPC5200 from Freescale. 740 Support for the LITE5200B dev board for the MPC5200 from Freescale.
741 This is the new board with 2 PCI slots. 741 This is the new board with 2 PCI slots.
diff --git a/arch/ppc/platforms/4xx/Kconfig b/arch/ppc/platforms/4xx/Kconfig
index 293bd489e7d9..6980de420e92 100644
--- a/arch/ppc/platforms/4xx/Kconfig
+++ b/arch/ppc/platforms/4xx/Kconfig
@@ -189,7 +189,7 @@ config BIOS_FIXUP
189# OAK doesn't exist but wanted to keep this around for any future 403GCX boards 189# OAK doesn't exist but wanted to keep this around for any future 403GCX boards
190config 403GCX 190config 403GCX
191 bool 191 bool
192 depends OAK 192 depends on OAK
193 default y 193 default y
194 194
195config 405EP 195config 405EP
diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c
index 286bc0b3207f..b2e9762e13c5 100644
--- a/arch/um/drivers/net_kern.c
+++ b/arch/um/drivers/net_kern.c
@@ -334,13 +334,12 @@ static int eth_configure(int n, void *init, char *mac,
334 size = transport->private_size + sizeof(struct uml_net_private) + 334 size = transport->private_size + sizeof(struct uml_net_private) +
335 sizeof(((struct uml_net_private *) 0)->user); 335 sizeof(((struct uml_net_private *) 0)->user);
336 336
337 device = kmalloc(sizeof(*device), GFP_KERNEL); 337 device = kzalloc(sizeof(*device), GFP_KERNEL);
338 if (device == NULL) { 338 if (device == NULL) {
339 printk(KERN_ERR "eth_configure failed to allocate uml_net\n"); 339 printk(KERN_ERR "eth_configure failed to allocate uml_net\n");
340 return(1); 340 return(1);
341 } 341 }
342 342
343 memset(device, 0, sizeof(*device));
344 INIT_LIST_HEAD(&device->list); 343 INIT_LIST_HEAD(&device->list);
345 device->index = n; 344 device->index = n;
346 345
diff --git a/arch/v850/Kconfig b/arch/v850/Kconfig
index bcf825875d17..f0d4d72e560f 100644
--- a/arch/v850/Kconfig
+++ b/arch/v850/Kconfig
@@ -105,17 +105,17 @@ menu "Processor type and features"
105 # currently support 105 # currently support
106 config V850E_MA1 106 config V850E_MA1
107 bool 107 bool
108 depends RTE_CB_MA1 108 depends on RTE_CB_MA1
109 default y 109 default y
110 # Similarly for the RTE-V850E/NB85E-CB - V850E/TEG 110 # Similarly for the RTE-V850E/NB85E-CB - V850E/TEG
111 config V850E_TEG 111 config V850E_TEG
112 bool 112 bool
113 depends RTE_CB_NB85E 113 depends on RTE_CB_NB85E
114 default y 114 default y
115 # ... and the RTE-V850E/ME2-CB - V850E/ME2 115 # ... and the RTE-V850E/ME2-CB - V850E/ME2
116 config V850E_ME2 116 config V850E_ME2
117 bool 117 bool
118 depends RTE_CB_ME2 118 depends on RTE_CB_ME2
119 default y 119 default y
120 120
121 121
@@ -123,7 +123,7 @@ menu "Processor type and features"
123 123
124 config V850E2_SIM85E2 124 config V850E2_SIM85E2
125 bool 125 bool
126 depends V850E2_SIM85E2C || V850E2_SIM85E2S 126 depends on V850E2_SIM85E2C || V850E2_SIM85E2S
127 default y 127 default y
128 128
129 129
@@ -132,7 +132,7 @@ menu "Processor type and features"
132 # V850E2 processors 132 # V850E2 processors
133 config V850E2 133 config V850E2
134 bool 134 bool
135 depends V850E2_SIM85E2 || V850E2_FPGA85E2C || V850E2_ANNA 135 depends on V850E2_SIM85E2 || V850E2_FPGA85E2C || V850E2_ANNA
136 default y 136 default y
137 137
138 138
@@ -141,7 +141,7 @@ menu "Processor type and features"
141 # Boards in the RTE-x-CB series 141 # Boards in the RTE-x-CB series
142 config RTE_CB 142 config RTE_CB
143 bool 143 bool
144 depends RTE_CB_MA1 || RTE_CB_NB85E || RTE_CB_ME2 144 depends on RTE_CB_MA1 || RTE_CB_NB85E || RTE_CB_ME2
145 default y 145 default y
146 146
147 config RTE_CB_MULTI 147 config RTE_CB_MULTI
@@ -149,28 +149,28 @@ menu "Processor type and features"
149 # RTE_CB_NB85E can either have multi ROM support or not, but 149 # RTE_CB_NB85E can either have multi ROM support or not, but
150 # other platforms (currently only RTE_CB_MA1) require it. 150 # other platforms (currently only RTE_CB_MA1) require it.
151 prompt "Multi monitor ROM support" if RTE_CB_NB85E 151 prompt "Multi monitor ROM support" if RTE_CB_NB85E
152 depends RTE_CB_MA1 || RTE_CB_NB85E 152 depends on RTE_CB_MA1 || RTE_CB_NB85E
153 default y 153 default y
154 154
155 config RTE_CB_MULTI_DBTRAP 155 config RTE_CB_MULTI_DBTRAP
156 bool "Pass illegal insn trap / dbtrap to kernel" 156 bool "Pass illegal insn trap / dbtrap to kernel"
157 depends RTE_CB_MULTI 157 depends on RTE_CB_MULTI
158 default n 158 default n
159 159
160 config RTE_CB_MA1_KSRAM 160 config RTE_CB_MA1_KSRAM
161 bool "Kernel in SRAM (limits size of kernel)" 161 bool "Kernel in SRAM (limits size of kernel)"
162 depends RTE_CB_MA1 && RTE_CB_MULTI 162 depends on RTE_CB_MA1 && RTE_CB_MULTI
163 default n 163 default n
164 164
165 config RTE_MB_A_PCI 165 config RTE_MB_A_PCI
166 bool "Mother-A PCI support" 166 bool "Mother-A PCI support"
167 depends RTE_CB 167 depends on RTE_CB
168 default y 168 default y
169 169
170 # The GBUS is used to talk to the RTE-MOTHER-A board 170 # The GBUS is used to talk to the RTE-MOTHER-A board
171 config RTE_GBUS_INT 171 config RTE_GBUS_INT
172 bool 172 bool
173 depends RTE_MB_A_PCI 173 depends on RTE_MB_A_PCI
174 default y 174 default y
175 175
176 # The only PCI bus we support is on the RTE-MOTHER-A board 176 # The only PCI bus we support is on the RTE-MOTHER-A board
@@ -209,7 +209,7 @@ menu "Processor type and features"
209 209
210 config ROM_KERNEL 210 config ROM_KERNEL
211 bool "Kernel in ROM" 211 bool "Kernel in ROM"
212 depends V850E2_ANNA || V850E_AS85EP1 || RTE_CB_ME2 212 depends on V850E2_ANNA || V850E_AS85EP1 || RTE_CB_ME2
213 213
214 # Some platforms pre-zero memory, in which case the kernel doesn't need to 214 # Some platforms pre-zero memory, in which case the kernel doesn't need to
215 config ZERO_BSS 215 config ZERO_BSS
@@ -225,10 +225,10 @@ menu "Processor type and features"
225 225
226 config V850E_HIGHRES_TIMER 226 config V850E_HIGHRES_TIMER
227 bool "High resolution timer support" 227 bool "High resolution timer support"
228 depends V850E_TIMER_D 228 depends on V850E_TIMER_D
229 config TIME_BOOTUP 229 config TIME_BOOTUP
230 bool "Time bootup" 230 bool "Time bootup"
231 depends V850E_HIGHRES_TIMER 231 depends on V850E_HIGHRES_TIMER
232 232
233 config RESET_GUARD 233 config RESET_GUARD
234 bool "Reset Guard" 234 bool "Reset Guard"
diff --git a/arch/x86_64/kernel/cpufreq/Kconfig b/arch/x86_64/kernel/cpufreq/Kconfig
index 81f1562e5393..3abcfa3e1ed7 100644
--- a/arch/x86_64/kernel/cpufreq/Kconfig
+++ b/arch/x86_64/kernel/cpufreq/Kconfig
@@ -27,10 +27,13 @@ config X86_POWERNOW_K8_ACPI
27 default y 27 default y
28 28
29config X86_SPEEDSTEP_CENTRINO 29config X86_SPEEDSTEP_CENTRINO
30 tristate "Intel Enhanced SpeedStep" 30 tristate "Intel Enhanced SpeedStep (deprecated)"
31 select CPU_FREQ_TABLE 31 select CPU_FREQ_TABLE
32 depends on ACPI_PROCESSOR 32 depends on ACPI_PROCESSOR
33 help 33 help
34 This is deprecated and this functionality is now merged into
35 acpi_cpufreq (X86_ACPI_CPUFREQ). Use that driver instead of
36 speedstep_centrino.
34 This adds the CPUFreq driver for Enhanced SpeedStep enabled 37 This adds the CPUFreq driver for Enhanced SpeedStep enabled
35 mobile CPUs. This means Intel Pentium M (Centrino) CPUs 38 mobile CPUs. This means Intel Pentium M (Centrino) CPUs
36 or 64bit enabled Intel Xeons. 39 or 64bit enabled Intel Xeons.
@@ -50,6 +53,7 @@ config X86_ACPI_CPUFREQ
50 help 53 help
51 This driver adds a CPUFreq driver which utilizes the ACPI 54 This driver adds a CPUFreq driver which utilizes the ACPI
52 Processor Performance States. 55 Processor Performance States.
56 This driver also supports Intel Enhanced Speedstep.
53 57
54 For details, take a look at <file:Documentation/cpu-freq/>. 58 For details, take a look at <file:Documentation/cpu-freq/>.
55 59
diff --git a/arch/x86_64/kernel/cpufreq/Makefile b/arch/x86_64/kernel/cpufreq/Makefile
index d8b593879224..753ce1dd418e 100644
--- a/arch/x86_64/kernel/cpufreq/Makefile
+++ b/arch/x86_64/kernel/cpufreq/Makefile
@@ -5,8 +5,8 @@
5SRCDIR := ../../../i386/kernel/cpu/cpufreq 5SRCDIR := ../../../i386/kernel/cpu/cpufreq
6 6
7obj-$(CONFIG_X86_POWERNOW_K8) += powernow-k8.o 7obj-$(CONFIG_X86_POWERNOW_K8) += powernow-k8.o
8obj-$(CONFIG_X86_SPEEDSTEP_CENTRINO) += speedstep-centrino.o
9obj-$(CONFIG_X86_ACPI_CPUFREQ) += acpi-cpufreq.o 8obj-$(CONFIG_X86_ACPI_CPUFREQ) += acpi-cpufreq.o
9obj-$(CONFIG_X86_SPEEDSTEP_CENTRINO) += speedstep-centrino.o
10obj-$(CONFIG_X86_P4_CLOCKMOD) += p4-clockmod.o 10obj-$(CONFIG_X86_P4_CLOCKMOD) += p4-clockmod.o
11obj-$(CONFIG_X86_SPEEDSTEP_LIB) += speedstep-lib.o 11obj-$(CONFIG_X86_SPEEDSTEP_LIB) += speedstep-lib.o
12 12
diff --git a/drivers/acorn/char/i2c.c b/drivers/acorn/char/i2c.c
index bdb9c8b78ed8..9e584a7af434 100644
--- a/drivers/acorn/char/i2c.c
+++ b/drivers/acorn/char/i2c.c
@@ -360,7 +360,7 @@ static int __init i2c_ioc_init(void)
360 if (ret >= 0){ 360 if (ret >= 0){
361 ret = misc_register(&rtc_dev); 361 ret = misc_register(&rtc_dev);
362 if(ret < 0) 362 if(ret < 0)
363 i2c_bit_del_bus(&ioc_ops); 363 i2c_del_adapter(&ioc_ops);
364 } 364 }
365 365
366 return ret; 366 return ret;
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index b10f4d8fdc7f..0a3aee29e067 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -867,7 +867,7 @@ config SONYPI
867 867
868config TANBAC_TB0219 868config TANBAC_TB0219
869 tristate "TANBAC TB0219 base board support" 869 tristate "TANBAC TB0219 base board support"
870 depends TANBAC_TB022X 870 depends on TANBAC_TB022X
871 select GPIO_VR41XX 871 select GPIO_VR41XX
872 872
873source "drivers/char/agp/Kconfig" 873source "drivers/char/agp/Kconfig"
diff --git a/drivers/char/agp/Kconfig b/drivers/char/agp/Kconfig
index c603bf291580..a9f9c48c2424 100644
--- a/drivers/char/agp/Kconfig
+++ b/drivers/char/agp/Kconfig
@@ -86,7 +86,7 @@ config AGP_NVIDIA
86 86
87config AGP_SIS 87config AGP_SIS
88 tristate "SiS chipset support" 88 tristate "SiS chipset support"
89 depends on AGP 89 depends on AGP && X86
90 help 90 help
91 This option gives you AGP support for the GLX component of 91 This option gives you AGP support for the GLX component of
92 X on Silicon Integrated Systems [SiS] chipsets. 92 X on Silicon Integrated Systems [SiS] chipsets.
@@ -103,7 +103,7 @@ config AGP_SWORKS
103 103
104config AGP_VIA 104config AGP_VIA
105 tristate "VIA chipset support" 105 tristate "VIA chipset support"
106 depends on AGP 106 depends on AGP && X86
107 help 107 help
108 This option gives you AGP support for the GLX component of 108 This option gives you AGP support for the GLX component of
109 X on VIA MVP3/Apollo Pro chipsets. 109 X on VIA MVP3/Apollo Pro chipsets.
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index 5ff457b41efb..883a36a27833 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -419,6 +419,31 @@ static void agp_v2_parse_one(u32 *requested_mode, u32 *bridge_agpstat, u32 *vga_
419 *requested_mode &= ~AGP2_RESERVED_MASK; 419 *requested_mode &= ~AGP2_RESERVED_MASK;
420 } 420 }
421 421
422 /*
423 * Some dumb bridges are programmed to disobey the AGP2 spec.
424 * This is likely a BIOS misprogramming rather than poweron default, or
425 * it would be a lot more common.
426 * https://bugs.freedesktop.org/show_bug.cgi?id=8816
427 * AGPv2 spec 6.1.9 states:
428 * The RATE field indicates the data transfer rates supported by this
429 * device. A.G.P. devices must report all that apply.
430 * Fix them up as best we can.
431 */
432 switch (*bridge_agpstat & 7) {
433 case 4:
434 *bridge_agpstat |= (AGPSTAT2_2X | AGPSTAT2_1X);
435 printk(KERN_INFO PFX "BIOS bug. AGP bridge claims to only support x4 rate"
436 "Fixing up support for x2 & x1\n");
437 break;
438 case 2:
439 *bridge_agpstat |= AGPSTAT2_1X;
440 printk(KERN_INFO PFX "BIOS bug. AGP bridge claims to only support x2 rate"
441 "Fixing up support for x1\n");
442 break;
443 default:
444 break;
445 }
446
422 /* Check the speed bits make sense. Only one should be set. */ 447 /* Check the speed bits make sense. Only one should be set. */
423 tmp = *requested_mode & 7; 448 tmp = *requested_mode & 7;
424 switch (tmp) { 449 switch (tmp) {
diff --git a/drivers/char/watchdog/at91rm9200_wdt.c b/drivers/char/watchdog/at91rm9200_wdt.c
index cb86967e2c5f..38bd37372599 100644
--- a/drivers/char/watchdog/at91rm9200_wdt.c
+++ b/drivers/char/watchdog/at91rm9200_wdt.c
@@ -203,9 +203,9 @@ static int __init at91wdt_probe(struct platform_device *pdev)
203{ 203{
204 int res; 204 int res;
205 205
206 if (at91wdt_miscdev.dev) 206 if (at91wdt_miscdev.parent)
207 return -EBUSY; 207 return -EBUSY;
208 at91wdt_miscdev.dev = &pdev->dev; 208 at91wdt_miscdev.parent = &pdev->dev;
209 209
210 res = misc_register(&at91wdt_miscdev); 210 res = misc_register(&at91wdt_miscdev);
211 if (res) 211 if (res)
@@ -221,7 +221,7 @@ static int __exit at91wdt_remove(struct platform_device *pdev)
221 221
222 res = misc_deregister(&at91wdt_miscdev); 222 res = misc_deregister(&at91wdt_miscdev);
223 if (!res) 223 if (!res)
224 at91wdt_miscdev.dev = NULL; 224 at91wdt_miscdev.parent = NULL;
225 225
226 return res; 226 return res;
227} 227}
diff --git a/drivers/char/watchdog/mpcore_wdt.c b/drivers/char/watchdog/mpcore_wdt.c
index 3404a9c67f08..e88947f8fe53 100644
--- a/drivers/char/watchdog/mpcore_wdt.c
+++ b/drivers/char/watchdog/mpcore_wdt.c
@@ -347,7 +347,7 @@ static int __devinit mpcore_wdt_probe(struct platform_device *dev)
347 goto err_free; 347 goto err_free;
348 } 348 }
349 349
350 mpcore_wdt_miscdev.dev = &dev->dev; 350 mpcore_wdt_miscdev.parent = &dev->dev;
351 ret = misc_register(&mpcore_wdt_miscdev); 351 ret = misc_register(&mpcore_wdt_miscdev);
352 if (ret) { 352 if (ret) {
353 dev_printk(KERN_ERR, _dev, "cannot register miscdev on minor=%d (err=%d)\n", 353 dev_printk(KERN_ERR, _dev, "cannot register miscdev on minor=%d (err=%d)\n",
diff --git a/drivers/char/watchdog/omap_wdt.c b/drivers/char/watchdog/omap_wdt.c
index 5dbd7dc2936f..6c6f97332dbb 100644
--- a/drivers/char/watchdog/omap_wdt.c
+++ b/drivers/char/watchdog/omap_wdt.c
@@ -290,7 +290,7 @@ static int __init omap_wdt_probe(struct platform_device *pdev)
290 omap_wdt_disable(); 290 omap_wdt_disable();
291 omap_wdt_adjust_timeout(timer_margin); 291 omap_wdt_adjust_timeout(timer_margin);
292 292
293 omap_wdt_miscdev.dev = &pdev->dev; 293 omap_wdt_miscdev.parent = &pdev->dev;
294 ret = misc_register(&omap_wdt_miscdev); 294 ret = misc_register(&omap_wdt_miscdev);
295 if (ret) 295 if (ret)
296 goto fail; 296 goto fail;
diff --git a/drivers/char/watchdog/pcwd_usb.c b/drivers/char/watchdog/pcwd_usb.c
index 61138726b501..2da5ac99687c 100644
--- a/drivers/char/watchdog/pcwd_usb.c
+++ b/drivers/char/watchdog/pcwd_usb.c
@@ -42,6 +42,7 @@
42#include <asm/uaccess.h> 42#include <asm/uaccess.h>
43#include <linux/usb.h> 43#include <linux/usb.h>
44#include <linux/mutex.h> 44#include <linux/mutex.h>
45#include <linux/hid.h> /* For HID_REQ_SET_REPORT & HID_DT_REPORT */
45 46
46 47
47#ifdef CONFIG_USB_DEBUG 48#ifdef CONFIG_USB_DEBUG
@@ -109,10 +110,6 @@ MODULE_DEVICE_TABLE (usb, usb_pcwd_table);
109#define CMD_ENABLE_WATCHDOG 0x30 /* Enable / Disable Watchdog */ 110#define CMD_ENABLE_WATCHDOG 0x30 /* Enable / Disable Watchdog */
110#define CMD_DISABLE_WATCHDOG CMD_ENABLE_WATCHDOG 111#define CMD_DISABLE_WATCHDOG CMD_ENABLE_WATCHDOG
111 112
112/* Some defines that I like to be somewhere else like include/linux/usb_hid.h */
113#define HID_REQ_SET_REPORT 0x09
114#define HID_DT_REPORT (USB_TYPE_CLASS | 0x02)
115
116/* We can only use 1 card due to the /dev/watchdog restriction */ 113/* We can only use 1 card due to the /dev/watchdog restriction */
117static int cards_found; 114static int cards_found;
118 115
diff --git a/drivers/char/watchdog/rm9k_wdt.c b/drivers/char/watchdog/rm9k_wdt.c
index ec3909371c21..7576a13e86bc 100644
--- a/drivers/char/watchdog/rm9k_wdt.c
+++ b/drivers/char/watchdog/rm9k_wdt.c
@@ -47,7 +47,7 @@
47 47
48 48
49/* Function prototypes */ 49/* Function prototypes */
50static irqreturn_t wdt_gpi_irqhdl(int, void *, struct pt_regs *); 50static irqreturn_t wdt_gpi_irqhdl(int, void *);
51static void wdt_gpi_start(void); 51static void wdt_gpi_start(void);
52static void wdt_gpi_stop(void); 52static void wdt_gpi_stop(void);
53static void wdt_gpi_set_timeout(unsigned int); 53static void wdt_gpi_set_timeout(unsigned int);
@@ -94,8 +94,28 @@ module_param(nowayout, bool, 0444);
94MODULE_PARM_DESC(nowayout, "Watchdog cannot be disabled once started"); 94MODULE_PARM_DESC(nowayout, "Watchdog cannot be disabled once started");
95 95
96 96
97/* Kernel interfaces */
98static struct file_operations fops = {
99 .owner = THIS_MODULE,
100 .open = wdt_gpi_open,
101 .release = wdt_gpi_release,
102 .write = wdt_gpi_write,
103 .unlocked_ioctl = wdt_gpi_ioctl,
104};
105
106static struct miscdevice miscdev = {
107 .minor = WATCHDOG_MINOR,
108 .name = wdt_gpi_name,
109 .fops = &fops,
110};
111
112static struct notifier_block wdt_gpi_shutdown = {
113 .notifier_call = wdt_gpi_notify,
114};
115
116
97/* Interrupt handler */ 117/* Interrupt handler */
98static irqreturn_t wdt_gpi_irqhdl(int irq, void *ctxt, struct pt_regs *regs) 118static irqreturn_t wdt_gpi_irqhdl(int irq, void *ctxt)
99{ 119{
100 if (!unlikely(__raw_readl(wd_regs + 0x0008) & 0x1)) 120 if (!unlikely(__raw_readl(wd_regs + 0x0008) & 0x1))
101 return IRQ_NONE; 121 return IRQ_NONE;
@@ -312,26 +332,6 @@ wdt_gpi_notify(struct notifier_block *this, unsigned long code, void *unused)
312} 332}
313 333
314 334
315/* Kernel interfaces */
316static struct file_operations fops = {
317 .owner = THIS_MODULE,
318 .open = wdt_gpi_open,
319 .release = wdt_gpi_release,
320 .write = wdt_gpi_write,
321 .unlocked_ioctl = wdt_gpi_ioctl,
322};
323
324static struct miscdevice miscdev = {
325 .minor = WATCHDOG_MINOR,
326 .name = wdt_gpi_name,
327 .fops = &fops,
328};
329
330static struct notifier_block wdt_gpi_shutdown = {
331 .notifier_call = wdt_gpi_notify,
332};
333
334
335/* Init & exit procedures */ 335/* Init & exit procedures */
336static const struct resource * 336static const struct resource *
337wdt_gpi_get_resource(struct platform_device *pdv, const char *name, 337wdt_gpi_get_resource(struct platform_device *pdv, const char *name,
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 47ab42db122a..9fb2edf36611 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -29,7 +29,8 @@
29#include <linux/completion.h> 29#include <linux/completion.h>
30#include <linux/mutex.h> 30#include <linux/mutex.h>
31 31
32#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_CORE, "cpufreq-core", msg) 32#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_CORE, \
33 "cpufreq-core", msg)
33 34
34/** 35/**
35 * The "cpufreq driver" - the arch- or hardware-dependent low 36 * The "cpufreq driver" - the arch- or hardware-dependent low
@@ -151,7 +152,8 @@ static void cpufreq_debug_disable_ratelimit(void)
151 spin_unlock_irqrestore(&disable_ratelimit_lock, flags); 152 spin_unlock_irqrestore(&disable_ratelimit_lock, flags);
152} 153}
153 154
154void cpufreq_debug_printk(unsigned int type, const char *prefix, const char *fmt, ...) 155void cpufreq_debug_printk(unsigned int type, const char *prefix,
156 const char *fmt, ...)
155{ 157{
156 char s[256]; 158 char s[256];
157 va_list args; 159 va_list args;
@@ -161,7 +163,8 @@ void cpufreq_debug_printk(unsigned int type, const char *prefix, const char *fmt
161 WARN_ON(!prefix); 163 WARN_ON(!prefix);
162 if (type & debug) { 164 if (type & debug) {
163 spin_lock_irqsave(&disable_ratelimit_lock, flags); 165 spin_lock_irqsave(&disable_ratelimit_lock, flags);
164 if (!disable_ratelimit && debug_ratelimit && !printk_ratelimit()) { 166 if (!disable_ratelimit && debug_ratelimit
167 && !printk_ratelimit()) {
165 spin_unlock_irqrestore(&disable_ratelimit_lock, flags); 168 spin_unlock_irqrestore(&disable_ratelimit_lock, flags);
166 return; 169 return;
167 } 170 }
@@ -182,10 +185,12 @@ EXPORT_SYMBOL(cpufreq_debug_printk);
182 185
183 186
184module_param(debug, uint, 0644); 187module_param(debug, uint, 0644);
185MODULE_PARM_DESC(debug, "CPUfreq debugging: add 1 to debug core, 2 to debug drivers, and 4 to debug governors."); 188MODULE_PARM_DESC(debug, "CPUfreq debugging: add 1 to debug core,"
189 " 2 to debug drivers, and 4 to debug governors.");
186 190
187module_param(debug_ratelimit, uint, 0644); 191module_param(debug_ratelimit, uint, 0644);
188MODULE_PARM_DESC(debug_ratelimit, "CPUfreq debugging: set to 0 to disable ratelimiting."); 192MODULE_PARM_DESC(debug_ratelimit, "CPUfreq debugging:"
193 " set to 0 to disable ratelimiting.");
189 194
190#else /* !CONFIG_CPU_FREQ_DEBUG */ 195#else /* !CONFIG_CPU_FREQ_DEBUG */
191 196
@@ -219,17 +224,23 @@ static void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci)
219 if (!l_p_j_ref_freq) { 224 if (!l_p_j_ref_freq) {
220 l_p_j_ref = loops_per_jiffy; 225 l_p_j_ref = loops_per_jiffy;
221 l_p_j_ref_freq = ci->old; 226 l_p_j_ref_freq = ci->old;
222 dprintk("saving %lu as reference value for loops_per_jiffy; freq is %u kHz\n", l_p_j_ref, l_p_j_ref_freq); 227 dprintk("saving %lu as reference value for loops_per_jiffy;"
228 "freq is %u kHz\n", l_p_j_ref, l_p_j_ref_freq);
223 } 229 }
224 if ((val == CPUFREQ_PRECHANGE && ci->old < ci->new) || 230 if ((val == CPUFREQ_PRECHANGE && ci->old < ci->new) ||
225 (val == CPUFREQ_POSTCHANGE && ci->old > ci->new) || 231 (val == CPUFREQ_POSTCHANGE && ci->old > ci->new) ||
226 (val == CPUFREQ_RESUMECHANGE || val == CPUFREQ_SUSPENDCHANGE)) { 232 (val == CPUFREQ_RESUMECHANGE || val == CPUFREQ_SUSPENDCHANGE)) {
227 loops_per_jiffy = cpufreq_scale(l_p_j_ref, l_p_j_ref_freq, ci->new); 233 loops_per_jiffy = cpufreq_scale(l_p_j_ref, l_p_j_ref_freq,
228 dprintk("scaling loops_per_jiffy to %lu for frequency %u kHz\n", loops_per_jiffy, ci->new); 234 ci->new);
235 dprintk("scaling loops_per_jiffy to %lu"
236 "for frequency %u kHz\n", loops_per_jiffy, ci->new);
229 } 237 }
230} 238}
231#else 239#else
232static inline void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci) { return; } 240static inline void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci)
241{
242 return;
243}
233#endif 244#endif
234 245
235 246
@@ -316,7 +327,8 @@ static int cpufreq_parse_governor (char *str_governor, unsigned int *policy,
316 if (!strnicmp(str_governor, "performance", CPUFREQ_NAME_LEN)) { 327 if (!strnicmp(str_governor, "performance", CPUFREQ_NAME_LEN)) {
317 *policy = CPUFREQ_POLICY_PERFORMANCE; 328 *policy = CPUFREQ_POLICY_PERFORMANCE;
318 err = 0; 329 err = 0;
319 } else if (!strnicmp(str_governor, "powersave", CPUFREQ_NAME_LEN)) { 330 } else if (!strnicmp(str_governor, "powersave",
331 CPUFREQ_NAME_LEN)) {
320 *policy = CPUFREQ_POLICY_POWERSAVE; 332 *policy = CPUFREQ_POLICY_POWERSAVE;
321 err = 0; 333 err = 0;
322 } 334 }
@@ -328,7 +340,8 @@ static int cpufreq_parse_governor (char *str_governor, unsigned int *policy,
328 t = __find_governor(str_governor); 340 t = __find_governor(str_governor);
329 341
330 if (t == NULL) { 342 if (t == NULL) {
331 char *name = kasprintf(GFP_KERNEL, "cpufreq_%s", str_governor); 343 char *name = kasprintf(GFP_KERNEL, "cpufreq_%s",
344 str_governor);
332 345
333 if (name) { 346 if (name) {
334 int ret; 347 int ret;
@@ -361,7 +374,8 @@ extern struct sysdev_class cpu_sysdev_class;
361 374
362 375
363/** 376/**
364 * cpufreq_per_cpu_attr_read() / show_##file_name() - print out cpufreq information 377 * cpufreq_per_cpu_attr_read() / show_##file_name() -
378 * print out cpufreq information
365 * 379 *
366 * Write out information from cpufreq_driver->policy[cpu]; object must be 380 * Write out information from cpufreq_driver->policy[cpu]; object must be
367 * "unsigned int". 381 * "unsigned int".
@@ -380,7 +394,8 @@ show_one(scaling_min_freq, min);
380show_one(scaling_max_freq, max); 394show_one(scaling_max_freq, max);
381show_one(scaling_cur_freq, cur); 395show_one(scaling_cur_freq, cur);
382 396
383static int __cpufreq_set_policy(struct cpufreq_policy *data, struct cpufreq_policy *policy); 397static int __cpufreq_set_policy(struct cpufreq_policy *data,
398 struct cpufreq_policy *policy);
384 399
385/** 400/**
386 * cpufreq_per_cpu_attr_write() / store_##file_name() - sysfs write access 401 * cpufreq_per_cpu_attr_write() / store_##file_name() - sysfs write access
@@ -416,7 +431,8 @@ store_one(scaling_max_freq,max);
416/** 431/**
417 * show_cpuinfo_cur_freq - current CPU frequency as detected by hardware 432 * show_cpuinfo_cur_freq - current CPU frequency as detected by hardware
418 */ 433 */
419static ssize_t show_cpuinfo_cur_freq (struct cpufreq_policy * policy, char *buf) 434static ssize_t show_cpuinfo_cur_freq (struct cpufreq_policy * policy,
435 char *buf)
420{ 436{
421 unsigned int cur_freq = cpufreq_get(policy->cpu); 437 unsigned int cur_freq = cpufreq_get(policy->cpu);
422 if (!cur_freq) 438 if (!cur_freq)
@@ -428,7 +444,8 @@ static ssize_t show_cpuinfo_cur_freq (struct cpufreq_policy * policy, char *buf)
428/** 444/**
429 * show_scaling_governor - show the current policy for the specified CPU 445 * show_scaling_governor - show the current policy for the specified CPU
430 */ 446 */
431static ssize_t show_scaling_governor (struct cpufreq_policy * policy, char *buf) 447static ssize_t show_scaling_governor (struct cpufreq_policy * policy,
448 char *buf)
432{ 449{
433 if(policy->policy == CPUFREQ_POLICY_POWERSAVE) 450 if(policy->policy == CPUFREQ_POLICY_POWERSAVE)
434 return sprintf(buf, "powersave\n"); 451 return sprintf(buf, "powersave\n");
@@ -458,7 +475,8 @@ static ssize_t store_scaling_governor (struct cpufreq_policy * policy,
458 if (ret != 1) 475 if (ret != 1)
459 return -EINVAL; 476 return -EINVAL;
460 477
461 if (cpufreq_parse_governor(str_governor, &new_policy.policy, &new_policy.governor)) 478 if (cpufreq_parse_governor(str_governor, &new_policy.policy,
479 &new_policy.governor))
462 return -EINVAL; 480 return -EINVAL;
463 481
464 lock_cpu_hotplug(); 482 lock_cpu_hotplug();
@@ -474,7 +492,10 @@ static ssize_t store_scaling_governor (struct cpufreq_policy * policy,
474 492
475 unlock_cpu_hotplug(); 493 unlock_cpu_hotplug();
476 494
477 return ret ? ret : count; 495 if (ret)
496 return ret;
497 else
498 return count;
478} 499}
479 500
480/** 501/**
@@ -488,7 +509,7 @@ static ssize_t show_scaling_driver (struct cpufreq_policy * policy, char *buf)
488/** 509/**
489 * show_scaling_available_governors - show the available CPUfreq governors 510 * show_scaling_available_governors - show the available CPUfreq governors
490 */ 511 */
491static ssize_t show_scaling_available_governors (struct cpufreq_policy * policy, 512static ssize_t show_scaling_available_governors (struct cpufreq_policy *policy,
492 char *buf) 513 char *buf)
493{ 514{
494 ssize_t i = 0; 515 ssize_t i = 0;
@@ -574,7 +595,11 @@ static ssize_t show(struct kobject * kobj, struct attribute * attr ,char * buf)
574 policy = cpufreq_cpu_get(policy->cpu); 595 policy = cpufreq_cpu_get(policy->cpu);
575 if (!policy) 596 if (!policy)
576 return -EINVAL; 597 return -EINVAL;
577 ret = fattr->show ? fattr->show(policy,buf) : -EIO; 598 if (fattr->show)
599 ret = fattr->show(policy, buf);
600 else
601 ret = -EIO;
602
578 cpufreq_cpu_put(policy); 603 cpufreq_cpu_put(policy);
579 return ret; 604 return ret;
580} 605}
@@ -588,7 +613,11 @@ static ssize_t store(struct kobject * kobj, struct attribute * attr,
588 policy = cpufreq_cpu_get(policy->cpu); 613 policy = cpufreq_cpu_get(policy->cpu);
589 if (!policy) 614 if (!policy)
590 return -EINVAL; 615 return -EINVAL;
591 ret = fattr->store ? fattr->store(policy,buf,count) : -EIO; 616 if (fattr->store)
617 ret = fattr->store(policy, buf, count);
618 else
619 ret = -EIO;
620
592 cpufreq_cpu_put(policy); 621 cpufreq_cpu_put(policy);
593 return ret; 622 return ret;
594} 623}
@@ -913,7 +942,8 @@ static void handle_update(struct work_struct *work)
913 * We adjust to current frequency first, and need to clean up later. So either call 942 * We adjust to current frequency first, and need to clean up later. So either call
914 * to cpufreq_update_policy() or schedule handle_update()). 943 * to cpufreq_update_policy() or schedule handle_update()).
915 */ 944 */
916static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq, unsigned int new_freq) 945static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq,
946 unsigned int new_freq)
917{ 947{
918 struct cpufreq_freqs freqs; 948 struct cpufreq_freqs freqs;
919 949
@@ -938,16 +968,16 @@ static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq, unsigne
938unsigned int cpufreq_quick_get(unsigned int cpu) 968unsigned int cpufreq_quick_get(unsigned int cpu)
939{ 969{
940 struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); 970 struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);
941 unsigned int ret = 0; 971 unsigned int ret_freq = 0;
942 972
943 if (policy) { 973 if (policy) {
944 mutex_lock(&policy->lock); 974 mutex_lock(&policy->lock);
945 ret = policy->cur; 975 ret_freq = policy->cur;
946 mutex_unlock(&policy->lock); 976 mutex_unlock(&policy->lock);
947 cpufreq_cpu_put(policy); 977 cpufreq_cpu_put(policy);
948 } 978 }
949 979
950 return (ret); 980 return (ret_freq);
951} 981}
952EXPORT_SYMBOL(cpufreq_quick_get); 982EXPORT_SYMBOL(cpufreq_quick_get);
953 983
@@ -961,7 +991,7 @@ EXPORT_SYMBOL(cpufreq_quick_get);
961unsigned int cpufreq_get(unsigned int cpu) 991unsigned int cpufreq_get(unsigned int cpu)
962{ 992{
963 struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); 993 struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);
964 unsigned int ret = 0; 994 unsigned int ret_freq = 0;
965 995
966 if (!policy) 996 if (!policy)
967 return 0; 997 return 0;
@@ -971,12 +1001,14 @@ unsigned int cpufreq_get(unsigned int cpu)
971 1001
972 mutex_lock(&policy->lock); 1002 mutex_lock(&policy->lock);
973 1003
974 ret = cpufreq_driver->get(cpu); 1004 ret_freq = cpufreq_driver->get(cpu);
975 1005
976 if (ret && policy->cur && !(cpufreq_driver->flags & CPUFREQ_CONST_LOOPS)) { 1006 if (ret_freq && policy->cur &&
977 /* verify no discrepancy between actual and saved value exists */ 1007 !(cpufreq_driver->flags & CPUFREQ_CONST_LOOPS)) {
978 if (unlikely(ret != policy->cur)) { 1008 /* verify no discrepancy between actual and
979 cpufreq_out_of_sync(cpu, policy->cur, ret); 1009 saved value exists */
1010 if (unlikely(ret_freq != policy->cur)) {
1011 cpufreq_out_of_sync(cpu, policy->cur, ret_freq);
980 schedule_work(&policy->update); 1012 schedule_work(&policy->update);
981 } 1013 }
982 } 1014 }
@@ -986,7 +1018,7 @@ unsigned int cpufreq_get(unsigned int cpu)
986out: 1018out:
987 cpufreq_cpu_put(policy); 1019 cpufreq_cpu_put(policy);
988 1020
989 return (ret); 1021 return (ret_freq);
990} 1022}
991EXPORT_SYMBOL(cpufreq_get); 1023EXPORT_SYMBOL(cpufreq_get);
992 1024
@@ -998,7 +1030,7 @@ EXPORT_SYMBOL(cpufreq_get);
998static int cpufreq_suspend(struct sys_device * sysdev, pm_message_t pmsg) 1030static int cpufreq_suspend(struct sys_device * sysdev, pm_message_t pmsg)
999{ 1031{
1000 int cpu = sysdev->id; 1032 int cpu = sysdev->id;
1001 unsigned int ret = 0; 1033 int ret = 0;
1002 unsigned int cur_freq = 0; 1034 unsigned int cur_freq = 0;
1003 struct cpufreq_policy *cpu_policy; 1035 struct cpufreq_policy *cpu_policy;
1004 1036
@@ -1080,7 +1112,7 @@ out:
1080static int cpufreq_resume(struct sys_device * sysdev) 1112static int cpufreq_resume(struct sys_device * sysdev)
1081{ 1113{
1082 int cpu = sysdev->id; 1114 int cpu = sysdev->id;
1083 unsigned int ret = 0; 1115 int ret = 0;
1084 struct cpufreq_policy *cpu_policy; 1116 struct cpufreq_policy *cpu_policy;
1085 1117
1086 dprintk("resuming cpu %u\n", cpu); 1118 dprintk("resuming cpu %u\n", cpu);
@@ -1276,22 +1308,45 @@ int cpufreq_driver_target(struct cpufreq_policy *policy,
1276} 1308}
1277EXPORT_SYMBOL_GPL(cpufreq_driver_target); 1309EXPORT_SYMBOL_GPL(cpufreq_driver_target);
1278 1310
1311int cpufreq_driver_getavg(struct cpufreq_policy *policy)
1312{
1313 int ret = 0;
1314
1315 policy = cpufreq_cpu_get(policy->cpu);
1316 if (!policy)
1317 return -EINVAL;
1318
1319 mutex_lock(&policy->lock);
1320
1321 if (cpu_online(policy->cpu) && cpufreq_driver->getavg)
1322 ret = cpufreq_driver->getavg(policy->cpu);
1323
1324 mutex_unlock(&policy->lock);
1325
1326 cpufreq_cpu_put(policy);
1327 return ret;
1328}
1329EXPORT_SYMBOL_GPL(cpufreq_driver_getavg);
1330
1279/* 1331/*
1280 * Locking: Must be called with the lock_cpu_hotplug() lock held 1332 * Locking: Must be called with the lock_cpu_hotplug() lock held
1281 * when "event" is CPUFREQ_GOV_LIMITS 1333 * when "event" is CPUFREQ_GOV_LIMITS
1282 */ 1334 */
1283 1335
1284static int __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event) 1336static int __cpufreq_governor(struct cpufreq_policy *policy,
1337 unsigned int event)
1285{ 1338{
1286 int ret; 1339 int ret;
1287 1340
1288 if (!try_module_get(policy->governor->owner)) 1341 if (!try_module_get(policy->governor->owner))
1289 return -EINVAL; 1342 return -EINVAL;
1290 1343
1291 dprintk("__cpufreq_governor for CPU %u, event %u\n", policy->cpu, event); 1344 dprintk("__cpufreq_governor for CPU %u, event %u\n",
1345 policy->cpu, event);
1292 ret = policy->governor->governor(policy, event); 1346 ret = policy->governor->governor(policy, event);
1293 1347
1294 /* we keep one module reference alive for each CPU governed by this CPU */ 1348 /* we keep one module reference alive for
1349 each CPU governed by this CPU */
1295 if ((event != CPUFREQ_GOV_START) || ret) 1350 if ((event != CPUFREQ_GOV_START) || ret)
1296 module_put(policy->governor->owner); 1351 module_put(policy->governor->owner);
1297 if ((event == CPUFREQ_GOV_STOP) && !ret) 1352 if ((event == CPUFREQ_GOV_STOP) && !ret)
@@ -1367,9 +1422,12 @@ EXPORT_SYMBOL(cpufreq_get_policy);
1367 1422
1368 1423
1369/* 1424/*
1425 * data : current policy.
1426 * policy : policy to be set.
1370 * Locking: Must be called with the lock_cpu_hotplug() lock held 1427 * Locking: Must be called with the lock_cpu_hotplug() lock held
1371 */ 1428 */
1372static int __cpufreq_set_policy(struct cpufreq_policy *data, struct cpufreq_policy *policy) 1429static int __cpufreq_set_policy(struct cpufreq_policy *data,
1430 struct cpufreq_policy *policy)
1373{ 1431{
1374 int ret = 0; 1432 int ret = 0;
1375 1433
@@ -1377,7 +1435,8 @@ static int __cpufreq_set_policy(struct cpufreq_policy *data, struct cpufreq_poli
1377 dprintk("setting new policy for CPU %u: %u - %u kHz\n", policy->cpu, 1435 dprintk("setting new policy for CPU %u: %u - %u kHz\n", policy->cpu,
1378 policy->min, policy->max); 1436 policy->min, policy->max);
1379 1437
1380 memcpy(&policy->cpuinfo, &data->cpuinfo, sizeof(struct cpufreq_cpuinfo)); 1438 memcpy(&policy->cpuinfo, &data->cpuinfo,
1439 sizeof(struct cpufreq_cpuinfo));
1381 1440
1382 if (policy->min > data->min && policy->min > policy->max) { 1441 if (policy->min > data->min && policy->min > policy->max) {
1383 ret = -EINVAL; 1442 ret = -EINVAL;
@@ -1410,7 +1469,8 @@ static int __cpufreq_set_policy(struct cpufreq_policy *data, struct cpufreq_poli
1410 data->min = policy->min; 1469 data->min = policy->min;
1411 data->max = policy->max; 1470 data->max = policy->max;
1412 1471
1413 dprintk("new min and max freqs are %u - %u kHz\n", data->min, data->max); 1472 dprintk("new min and max freqs are %u - %u kHz\n",
1473 data->min, data->max);
1414 1474
1415 if (cpufreq_driver->setpolicy) { 1475 if (cpufreq_driver->setpolicy) {
1416 data->policy = policy->policy; 1476 data->policy = policy->policy;
@@ -1431,10 +1491,12 @@ static int __cpufreq_set_policy(struct cpufreq_policy *data, struct cpufreq_poli
1431 data->governor = policy->governor; 1491 data->governor = policy->governor;
1432 if (__cpufreq_governor(data, CPUFREQ_GOV_START)) { 1492 if (__cpufreq_governor(data, CPUFREQ_GOV_START)) {
1433 /* new governor failed, so re-start old one */ 1493 /* new governor failed, so re-start old one */
1434 dprintk("starting governor %s failed\n", data->governor->name); 1494 dprintk("starting governor %s failed\n",
1495 data->governor->name);
1435 if (old_gov) { 1496 if (old_gov) {
1436 data->governor = old_gov; 1497 data->governor = old_gov;
1437 __cpufreq_governor(data, CPUFREQ_GOV_START); 1498 __cpufreq_governor(data,
1499 CPUFREQ_GOV_START);
1438 } 1500 }
1439 ret = -EINVAL; 1501 ret = -EINVAL;
1440 goto error_out; 1502 goto error_out;
@@ -1524,7 +1586,8 @@ int cpufreq_update_policy(unsigned int cpu)
1524 data->cur = policy.cur; 1586 data->cur = policy.cur;
1525 } else { 1587 } else {
1526 if (data->cur != policy.cur) 1588 if (data->cur != policy.cur)
1527 cpufreq_out_of_sync(cpu, data->cur, policy.cur); 1589 cpufreq_out_of_sync(cpu, data->cur,
1590 policy.cur);
1528 } 1591 }
1529 } 1592 }
1530 1593
@@ -1626,8 +1689,10 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
1626 1689
1627 /* if all ->init() calls failed, unregister */ 1690 /* if all ->init() calls failed, unregister */
1628 if (ret) { 1691 if (ret) {
1629 dprintk("no CPU initialized for driver %s\n", driver_data->name); 1692 dprintk("no CPU initialized for driver %s\n",
1630 sysdev_driver_unregister(&cpu_sysdev_class, &cpufreq_sysdev_driver); 1693 driver_data->name);
1694 sysdev_driver_unregister(&cpu_sysdev_class,
1695 &cpufreq_sysdev_driver);
1631 1696
1632 spin_lock_irqsave(&cpufreq_driver_lock, flags); 1697 spin_lock_irqsave(&cpufreq_driver_lock, flags);
1633 cpufreq_driver = NULL; 1698 cpufreq_driver = NULL;
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c
index 5ef5ede5b884..eef0270c6f3d 100644
--- a/drivers/cpufreq/cpufreq_conservative.c
+++ b/drivers/cpufreq/cpufreq_conservative.c
@@ -44,15 +44,17 @@
44 * latency of the processor. The governor will work on any processor with 44 * latency of the processor. The governor will work on any processor with
45 * transition latency <= 10mS, using appropriate sampling 45 * transition latency <= 10mS, using appropriate sampling
46 * rate. 46 * rate.
47 * For CPUs with transition latency > 10mS (mostly drivers with CPUFREQ_ETERNAL) 47 * For CPUs with transition latency > 10mS (mostly drivers
48 * this governor will not work. 48 * with CPUFREQ_ETERNAL), this governor will not work.
49 * All times here are in uS. 49 * All times here are in uS.
50 */ 50 */
51static unsigned int def_sampling_rate; 51static unsigned int def_sampling_rate;
52#define MIN_SAMPLING_RATE_RATIO (2) 52#define MIN_SAMPLING_RATE_RATIO (2)
53/* for correct statistics, we need at least 10 ticks between each measure */ 53/* for correct statistics, we need at least 10 ticks between each measure */
54#define MIN_STAT_SAMPLING_RATE (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10)) 54#define MIN_STAT_SAMPLING_RATE \
55#define MIN_SAMPLING_RATE (def_sampling_rate / MIN_SAMPLING_RATE_RATIO) 55 (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10))
56#define MIN_SAMPLING_RATE \
57 (def_sampling_rate / MIN_SAMPLING_RATE_RATIO)
56#define MAX_SAMPLING_RATE (500 * def_sampling_rate) 58#define MAX_SAMPLING_RATE (500 * def_sampling_rate)
57#define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000) 59#define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000)
58#define DEF_SAMPLING_DOWN_FACTOR (1) 60#define DEF_SAMPLING_DOWN_FACTOR (1)
@@ -103,11 +105,16 @@ static struct dbs_tuners dbs_tuners_ins = {
103 105
104static inline unsigned int get_cpu_idle_time(unsigned int cpu) 106static inline unsigned int get_cpu_idle_time(unsigned int cpu)
105{ 107{
106 return kstat_cpu(cpu).cpustat.idle + 108 unsigned int add_nice = 0, ret;
109
110 if (dbs_tuners_ins.ignore_nice)
111 add_nice = kstat_cpu(cpu).cpustat.nice;
112
113 ret = kstat_cpu(cpu).cpustat.idle +
107 kstat_cpu(cpu).cpustat.iowait + 114 kstat_cpu(cpu).cpustat.iowait +
108 ( dbs_tuners_ins.ignore_nice ? 115 add_nice;
109 kstat_cpu(cpu).cpustat.nice : 116
110 0); 117 return ret;
111} 118}
112 119
113/************************** sysfs interface ************************/ 120/************************** sysfs interface ************************/
@@ -452,6 +459,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
452 unsigned int cpu = policy->cpu; 459 unsigned int cpu = policy->cpu;
453 struct cpu_dbs_info_s *this_dbs_info; 460 struct cpu_dbs_info_s *this_dbs_info;
454 unsigned int j; 461 unsigned int j;
462 int rc;
455 463
456 this_dbs_info = &per_cpu(cpu_dbs_info, cpu); 464 this_dbs_info = &per_cpu(cpu_dbs_info, cpu);
457 465
@@ -468,6 +476,13 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
468 break; 476 break;
469 477
470 mutex_lock(&dbs_mutex); 478 mutex_lock(&dbs_mutex);
479
480 rc = sysfs_create_group(&policy->kobj, &dbs_attr_group);
481 if (rc) {
482 mutex_unlock(&dbs_mutex);
483 return rc;
484 }
485
471 for_each_cpu_mask(j, policy->cpus) { 486 for_each_cpu_mask(j, policy->cpus) {
472 struct cpu_dbs_info_s *j_dbs_info; 487 struct cpu_dbs_info_s *j_dbs_info;
473 j_dbs_info = &per_cpu(cpu_dbs_info, j); 488 j_dbs_info = &per_cpu(cpu_dbs_info, j);
@@ -480,7 +495,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
480 this_dbs_info->enable = 1; 495 this_dbs_info->enable = 1;
481 this_dbs_info->down_skip = 0; 496 this_dbs_info->down_skip = 0;
482 this_dbs_info->requested_freq = policy->cur; 497 this_dbs_info->requested_freq = policy->cur;
483 sysfs_create_group(&policy->kobj, &dbs_attr_group); 498
484 dbs_enable++; 499 dbs_enable++;
485 /* 500 /*
486 * Start the timerschedule work, when this governor 501 * Start the timerschedule work, when this governor
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index e1cc5113c2ae..f697449327c6 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -41,8 +41,10 @@
41static unsigned int def_sampling_rate; 41static unsigned int def_sampling_rate;
42#define MIN_SAMPLING_RATE_RATIO (2) 42#define MIN_SAMPLING_RATE_RATIO (2)
43/* for correct statistics, we need at least 10 ticks between each measure */ 43/* for correct statistics, we need at least 10 ticks between each measure */
44#define MIN_STAT_SAMPLING_RATE (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10)) 44#define MIN_STAT_SAMPLING_RATE \
45#define MIN_SAMPLING_RATE (def_sampling_rate / MIN_SAMPLING_RATE_RATIO) 45 (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10))
46#define MIN_SAMPLING_RATE \
47 (def_sampling_rate / MIN_SAMPLING_RATE_RATIO)
46#define MAX_SAMPLING_RATE (500 * def_sampling_rate) 48#define MAX_SAMPLING_RATE (500 * def_sampling_rate)
47#define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000) 49#define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000)
48#define TRANSITION_LATENCY_LIMIT (10 * 1000) 50#define TRANSITION_LATENCY_LIMIT (10 * 1000)
@@ -206,7 +208,8 @@ static ssize_t store_sampling_rate(struct cpufreq_policy *unused,
206 ret = sscanf(buf, "%u", &input); 208 ret = sscanf(buf, "%u", &input);
207 209
208 mutex_lock(&dbs_mutex); 210 mutex_lock(&dbs_mutex);
209 if (ret != 1 || input > MAX_SAMPLING_RATE || input < MIN_SAMPLING_RATE) { 211 if (ret != 1 || input > MAX_SAMPLING_RATE
212 || input < MIN_SAMPLING_RATE) {
210 mutex_unlock(&dbs_mutex); 213 mutex_unlock(&dbs_mutex);
211 return -EINVAL; 214 return -EINVAL;
212 } 215 }
@@ -397,8 +400,15 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
397 * policy. To be safe, we focus 10 points under the threshold. 400 * policy. To be safe, we focus 10 points under the threshold.
398 */ 401 */
399 if (load < (dbs_tuners_ins.up_threshold - 10)) { 402 if (load < (dbs_tuners_ins.up_threshold - 10)) {
400 unsigned int freq_next = (policy->cur * load) / 403 unsigned int freq_next, freq_cur;
404
405 freq_cur = cpufreq_driver_getavg(policy);
406 if (!freq_cur)
407 freq_cur = policy->cur;
408
409 freq_next = (freq_cur * load) /
401 (dbs_tuners_ins.up_threshold - 10); 410 (dbs_tuners_ins.up_threshold - 10);
411
402 if (!dbs_tuners_ins.powersave_bias) { 412 if (!dbs_tuners_ins.powersave_bias) {
403 __cpufreq_driver_target(policy, freq_next, 413 __cpufreq_driver_target(policy, freq_next,
404 CPUFREQ_RELATION_L); 414 CPUFREQ_RELATION_L);
@@ -472,6 +482,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
472 unsigned int cpu = policy->cpu; 482 unsigned int cpu = policy->cpu;
473 struct cpu_dbs_info_s *this_dbs_info; 483 struct cpu_dbs_info_s *this_dbs_info;
474 unsigned int j; 484 unsigned int j;
485 int rc;
475 486
476 this_dbs_info = &per_cpu(cpu_dbs_info, cpu); 487 this_dbs_info = &per_cpu(cpu_dbs_info, cpu);
477 488
@@ -494,12 +505,23 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
494 if (dbs_enable == 1) { 505 if (dbs_enable == 1) {
495 kondemand_wq = create_workqueue("kondemand"); 506 kondemand_wq = create_workqueue("kondemand");
496 if (!kondemand_wq) { 507 if (!kondemand_wq) {
497 printk(KERN_ERR "Creation of kondemand failed\n"); 508 printk(KERN_ERR
509 "Creation of kondemand failed\n");
498 dbs_enable--; 510 dbs_enable--;
499 mutex_unlock(&dbs_mutex); 511 mutex_unlock(&dbs_mutex);
500 return -ENOSPC; 512 return -ENOSPC;
501 } 513 }
502 } 514 }
515
516 rc = sysfs_create_group(&policy->kobj, &dbs_attr_group);
517 if (rc) {
518 if (dbs_enable == 1)
519 destroy_workqueue(kondemand_wq);
520 dbs_enable--;
521 mutex_unlock(&dbs_mutex);
522 return rc;
523 }
524
503 for_each_cpu_mask(j, policy->cpus) { 525 for_each_cpu_mask(j, policy->cpus) {
504 struct cpu_dbs_info_s *j_dbs_info; 526 struct cpu_dbs_info_s *j_dbs_info;
505 j_dbs_info = &per_cpu(cpu_dbs_info, j); 527 j_dbs_info = &per_cpu(cpu_dbs_info, j);
@@ -509,7 +531,6 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
509 j_dbs_info->prev_cpu_wall = get_jiffies_64(); 531 j_dbs_info->prev_cpu_wall = get_jiffies_64();
510 } 532 }
511 this_dbs_info->enable = 1; 533 this_dbs_info->enable = 1;
512 sysfs_create_group(&policy->kobj, &dbs_attr_group);
513 /* 534 /*
514 * Start the timerschedule work, when this governor 535 * Start the timerschedule work, when this governor
515 * is used for first time 536 * is used for first time
diff --git a/drivers/cpufreq/cpufreq_performance.c b/drivers/cpufreq/cpufreq_performance.c
index de91e3371ef8..e8e1451ef1c1 100644
--- a/drivers/cpufreq/cpufreq_performance.c
+++ b/drivers/cpufreq/cpufreq_performance.c
@@ -15,7 +15,8 @@
15#include <linux/cpufreq.h> 15#include <linux/cpufreq.h>
16#include <linux/init.h> 16#include <linux/init.h>
17 17
18#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_GOVERNOR, "performance", msg) 18#define dprintk(msg...) \
19 cpufreq_debug_printk(CPUFREQ_DEBUG_GOVERNOR, "performance", msg)
19 20
20 21
21static int cpufreq_governor_performance(struct cpufreq_policy *policy, 22static int cpufreq_governor_performance(struct cpufreq_policy *policy,
@@ -24,8 +25,10 @@ static int cpufreq_governor_performance(struct cpufreq_policy *policy,
24 switch (event) { 25 switch (event) {
25 case CPUFREQ_GOV_START: 26 case CPUFREQ_GOV_START:
26 case CPUFREQ_GOV_LIMITS: 27 case CPUFREQ_GOV_LIMITS:
27 dprintk("setting to %u kHz because of event %u\n", policy->max, event); 28 dprintk("setting to %u kHz because of event %u\n",
28 __cpufreq_driver_target(policy, policy->max, CPUFREQ_RELATION_H); 29 policy->max, event);
30 __cpufreq_driver_target(policy, policy->max,
31 CPUFREQ_RELATION_H);
29 break; 32 break;
30 default: 33 default:
31 break; 34 break;
diff --git a/drivers/cpufreq/cpufreq_powersave.c b/drivers/cpufreq/cpufreq_powersave.c
index 0a2596044e65..13fe06b94b0a 100644
--- a/drivers/cpufreq/cpufreq_powersave.c
+++ b/drivers/cpufreq/cpufreq_powersave.c
@@ -15,7 +15,8 @@
15#include <linux/cpufreq.h> 15#include <linux/cpufreq.h>
16#include <linux/init.h> 16#include <linux/init.h>
17 17
18#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_GOVERNOR, "powersave", msg) 18#define dprintk(msg...) \
19 cpufreq_debug_printk(CPUFREQ_DEBUG_GOVERNOR, "powersave", msg)
19 20
20static int cpufreq_governor_powersave(struct cpufreq_policy *policy, 21static int cpufreq_governor_powersave(struct cpufreq_policy *policy,
21 unsigned int event) 22 unsigned int event)
@@ -23,8 +24,10 @@ static int cpufreq_governor_powersave(struct cpufreq_policy *policy,
23 switch (event) { 24 switch (event) {
24 case CPUFREQ_GOV_START: 25 case CPUFREQ_GOV_START:
25 case CPUFREQ_GOV_LIMITS: 26 case CPUFREQ_GOV_LIMITS:
26 dprintk("setting to %u kHz because of event %u\n", policy->min, event); 27 dprintk("setting to %u kHz because of event %u\n",
27 __cpufreq_driver_target(policy, policy->min, CPUFREQ_RELATION_L); 28 policy->min, event);
29 __cpufreq_driver_target(policy, policy->min,
30 CPUFREQ_RELATION_L);
28 break; 31 break;
29 default: 32 default:
30 break; 33 break;
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index c2ecc599dc5f..6742b1adf2c8 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -351,8 +351,8 @@ __init cpufreq_stats_init(void)
351 351
352 register_hotcpu_notifier(&cpufreq_stat_cpu_notifier); 352 register_hotcpu_notifier(&cpufreq_stat_cpu_notifier);
353 for_each_online_cpu(cpu) { 353 for_each_online_cpu(cpu) {
354 cpufreq_stat_cpu_callback(&cpufreq_stat_cpu_notifier, CPU_ONLINE, 354 cpufreq_stat_cpu_callback(&cpufreq_stat_cpu_notifier,
355 (void *)(long)cpu); 355 CPU_ONLINE, (void *)(long)cpu);
356 } 356 }
357 return 0; 357 return 0;
358} 358}
@@ -368,14 +368,15 @@ __exit cpufreq_stats_exit(void)
368 unregister_hotcpu_notifier(&cpufreq_stat_cpu_notifier); 368 unregister_hotcpu_notifier(&cpufreq_stat_cpu_notifier);
369 lock_cpu_hotplug(); 369 lock_cpu_hotplug();
370 for_each_online_cpu(cpu) { 370 for_each_online_cpu(cpu) {
371 cpufreq_stat_cpu_callback(&cpufreq_stat_cpu_notifier, CPU_DEAD, 371 cpufreq_stat_cpu_callback(&cpufreq_stat_cpu_notifier,
372 (void *)(long)cpu); 372 CPU_DEAD, (void *)(long)cpu);
373 } 373 }
374 unlock_cpu_hotplug(); 374 unlock_cpu_hotplug();
375} 375}
376 376
377MODULE_AUTHOR ("Zou Nan hai <nanhai.zou@intel.com>"); 377MODULE_AUTHOR ("Zou Nan hai <nanhai.zou@intel.com>");
378MODULE_DESCRIPTION ("'cpufreq_stats' - A driver to export cpufreq stats through sysfs filesystem"); 378MODULE_DESCRIPTION ("'cpufreq_stats' - A driver to export cpufreq stats"
379 "through sysfs filesystem");
379MODULE_LICENSE ("GPL"); 380MODULE_LICENSE ("GPL");
380 381
381module_init(cpufreq_stats_init); 382module_init(cpufreq_stats_init);
diff --git a/drivers/cpufreq/cpufreq_userspace.c b/drivers/cpufreq/cpufreq_userspace.c
index a06c204589cd..2a4eb0bfaf30 100644
--- a/drivers/cpufreq/cpufreq_userspace.c
+++ b/drivers/cpufreq/cpufreq_userspace.c
@@ -131,19 +131,26 @@ static int cpufreq_governor_userspace(struct cpufreq_policy *policy,
131 unsigned int event) 131 unsigned int event)
132{ 132{
133 unsigned int cpu = policy->cpu; 133 unsigned int cpu = policy->cpu;
134 int rc = 0;
135
134 switch (event) { 136 switch (event) {
135 case CPUFREQ_GOV_START: 137 case CPUFREQ_GOV_START:
136 if (!cpu_online(cpu)) 138 if (!cpu_online(cpu))
137 return -EINVAL; 139 return -EINVAL;
138 BUG_ON(!policy->cur); 140 BUG_ON(!policy->cur);
139 mutex_lock(&userspace_mutex); 141 mutex_lock(&userspace_mutex);
142 rc = sysfs_create_file (&policy->kobj,
143 &freq_attr_scaling_setspeed.attr);
144 if (rc)
145 goto start_out;
146
140 cpu_is_managed[cpu] = 1; 147 cpu_is_managed[cpu] = 1;
141 cpu_min_freq[cpu] = policy->min; 148 cpu_min_freq[cpu] = policy->min;
142 cpu_max_freq[cpu] = policy->max; 149 cpu_max_freq[cpu] = policy->max;
143 cpu_cur_freq[cpu] = policy->cur; 150 cpu_cur_freq[cpu] = policy->cur;
144 cpu_set_freq[cpu] = policy->cur; 151 cpu_set_freq[cpu] = policy->cur;
145 sysfs_create_file (&policy->kobj, &freq_attr_scaling_setspeed.attr);
146 dprintk("managing cpu %u started (%u - %u kHz, currently %u kHz)\n", cpu, cpu_min_freq[cpu], cpu_max_freq[cpu], cpu_cur_freq[cpu]); 152 dprintk("managing cpu %u started (%u - %u kHz, currently %u kHz)\n", cpu, cpu_min_freq[cpu], cpu_max_freq[cpu], cpu_cur_freq[cpu]);
153start_out:
147 mutex_unlock(&userspace_mutex); 154 mutex_unlock(&userspace_mutex);
148 break; 155 break;
149 case CPUFREQ_GOV_STOP: 156 case CPUFREQ_GOV_STOP:
@@ -180,7 +187,7 @@ static int cpufreq_governor_userspace(struct cpufreq_policy *policy,
180 mutex_unlock(&userspace_mutex); 187 mutex_unlock(&userspace_mutex);
181 break; 188 break;
182 } 189 }
183 return 0; 190 return rc;
184} 191}
185 192
186 193
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
index 551f4ccf87fd..e7490925fdcf 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -9,7 +9,8 @@
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/cpufreq.h> 10#include <linux/cpufreq.h>
11 11
12#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_CORE, "freq-table", msg) 12#define dprintk(msg...) \
13 cpufreq_debug_printk(CPUFREQ_DEBUG_CORE, "freq-table", msg)
13 14
14/********************************************************************* 15/*********************************************************************
15 * FREQUENCY TABLE HELPERS * 16 * FREQUENCY TABLE HELPERS *
@@ -29,7 +30,8 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
29 30
30 continue; 31 continue;
31 } 32 }
32 dprintk("table entry %u: %u kHz, %u index\n", i, freq, table[i].index); 33 dprintk("table entry %u: %u kHz, %u index\n",
34 i, freq, table[i].index);
33 if (freq < min_freq) 35 if (freq < min_freq)
34 min_freq = freq; 36 min_freq = freq;
35 if (freq > max_freq) 37 if (freq > max_freq)
@@ -54,13 +56,14 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,
54 unsigned int i; 56 unsigned int i;
55 unsigned int count = 0; 57 unsigned int count = 0;
56 58
57 dprintk("request for verification of policy (%u - %u kHz) for cpu %u\n", policy->min, policy->max, policy->cpu); 59 dprintk("request for verification of policy (%u - %u kHz) for cpu %u\n",
60 policy->min, policy->max, policy->cpu);
58 61
59 if (!cpu_online(policy->cpu)) 62 if (!cpu_online(policy->cpu))
60 return -EINVAL; 63 return -EINVAL;
61 64
62 cpufreq_verify_within_limits(policy, 65 cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
63 policy->cpuinfo.min_freq, policy->cpuinfo.max_freq); 66 policy->cpuinfo.max_freq);
64 67
65 for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { 68 for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {
66 unsigned int freq = table[i].frequency; 69 unsigned int freq = table[i].frequency;
@@ -75,10 +78,11 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,
75 if (!count) 78 if (!count)
76 policy->max = next_larger; 79 policy->max = next_larger;
77 80
78 cpufreq_verify_within_limits(policy, 81 cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
79 policy->cpuinfo.min_freq, policy->cpuinfo.max_freq); 82 policy->cpuinfo.max_freq);
80 83
81 dprintk("verification lead to (%u - %u kHz) for cpu %u\n", policy->min, policy->max, policy->cpu); 84 dprintk("verification lead to (%u - %u kHz) for cpu %u\n",
85 policy->min, policy->max, policy->cpu);
82 86
83 return 0; 87 return 0;
84} 88}
@@ -101,7 +105,8 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
101 }; 105 };
102 unsigned int i; 106 unsigned int i;
103 107
104 dprintk("request for target %u kHz (relation: %u) for cpu %u\n", target_freq, relation, policy->cpu); 108 dprintk("request for target %u kHz (relation: %u) for cpu %u\n",
109 target_freq, relation, policy->cpu);
105 110
106 switch (relation) { 111 switch (relation) {
107 case CPUFREQ_RELATION_H: 112 case CPUFREQ_RELATION_H:
@@ -192,7 +197,10 @@ static ssize_t show_available_freqs (struct cpufreq_policy *policy, char *buf)
192} 197}
193 198
194struct freq_attr cpufreq_freq_attr_scaling_available_freqs = { 199struct freq_attr cpufreq_freq_attr_scaling_available_freqs = {
195 .attr = { .name = "scaling_available_frequencies", .mode = 0444, .owner=THIS_MODULE }, 200 .attr = { .name = "scaling_available_frequencies",
201 .mode = 0444,
202 .owner=THIS_MODULE
203 },
196 .show = show_available_freqs, 204 .show = show_available_freqs,
197}; 205};
198EXPORT_SYMBOL_GPL(cpufreq_freq_attr_scaling_available_freqs); 206EXPORT_SYMBOL_GPL(cpufreq_freq_attr_scaling_available_freqs);
diff --git a/drivers/i2c/algos/Kconfig b/drivers/i2c/algos/Kconfig
index c034820615bb..af0203409dd1 100644
--- a/drivers/i2c/algos/Kconfig
+++ b/drivers/i2c/algos/Kconfig
@@ -38,17 +38,6 @@ config I2C_ALGOPCA
38 This support is also available as a module. If so, the module 38 This support is also available as a module. If so, the module
39 will be called i2c-algo-pca. 39 will be called i2c-algo-pca.
40 40
41config I2C_ALGOITE
42 tristate "ITE I2C Algorithm"
43 depends on MIPS_ITE8172 && I2C
44 help
45 This supports the use of the ITE8172 I2C interface found on some MIPS
46 systems. Say Y if you have one of these. You should also say Y for
47 the ITE I2C peripheral driver support below.
48
49 This support is also available as a module. If so, the module
50 will be called i2c-algo-ite.
51
52config I2C_ALGO8XX 41config I2C_ALGO8XX
53 tristate "MPC8xx CPM I2C interface" 42 tristate "MPC8xx CPM I2C interface"
54 depends on 8xx && I2C 43 depends on 8xx && I2C
diff --git a/drivers/i2c/algos/Makefile b/drivers/i2c/algos/Makefile
index 208be04a3dbd..cac1051bd4f1 100644
--- a/drivers/i2c/algos/Makefile
+++ b/drivers/i2c/algos/Makefile
@@ -5,7 +5,6 @@
5obj-$(CONFIG_I2C_ALGOBIT) += i2c-algo-bit.o 5obj-$(CONFIG_I2C_ALGOBIT) += i2c-algo-bit.o
6obj-$(CONFIG_I2C_ALGOPCF) += i2c-algo-pcf.o 6obj-$(CONFIG_I2C_ALGOPCF) += i2c-algo-pcf.o
7obj-$(CONFIG_I2C_ALGOPCA) += i2c-algo-pca.o 7obj-$(CONFIG_I2C_ALGOPCA) += i2c-algo-pca.o
8obj-$(CONFIG_I2C_ALGOITE) += i2c-algo-ite.o
9obj-$(CONFIG_I2C_ALGO_SGI) += i2c-algo-sgi.o 8obj-$(CONFIG_I2C_ALGO_SGI) += i2c-algo-sgi.o
10 9
11ifeq ($(CONFIG_I2C_DEBUG_ALGO),y) 10ifeq ($(CONFIG_I2C_DEBUG_ALGO),y)
diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c
index 21c36bfb5e6b..95aa5395a5be 100644
--- a/drivers/i2c/algos/i2c-algo-bit.c
+++ b/drivers/i2c/algos/i2c-algo-bit.c
@@ -540,15 +540,7 @@ int i2c_bit_add_bus(struct i2c_adapter *adap)
540 540
541 return i2c_add_adapter(adap); 541 return i2c_add_adapter(adap);
542} 542}
543
544
545int i2c_bit_del_bus(struct i2c_adapter *adap)
546{
547 return i2c_del_adapter(adap);
548}
549
550EXPORT_SYMBOL(i2c_bit_add_bus); 543EXPORT_SYMBOL(i2c_bit_add_bus);
551EXPORT_SYMBOL(i2c_bit_del_bus);
552 544
553MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); 545MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>");
554MODULE_DESCRIPTION("I2C-Bus bit-banging algorithm"); 546MODULE_DESCRIPTION("I2C-Bus bit-banging algorithm");
diff --git a/drivers/i2c/algos/i2c-algo-ite.c b/drivers/i2c/algos/i2c-algo-ite.c
deleted file mode 100644
index 70d8eefb5efc..000000000000
--- a/drivers/i2c/algos/i2c-algo-ite.c
+++ /dev/null
@@ -1,806 +0,0 @@
1/*
2 -------------------------------------------------------------------------
3 i2c-algo-ite.c i2c driver algorithms for ITE adapters
4
5 Hai-Pao Fan, MontaVista Software, Inc.
6 hpfan@mvista.com or source@mvista.com
7
8 Copyright 2000 MontaVista Software Inc.
9
10 ---------------------------------------------------------------------------
11 This file was highly leveraged from i2c-algo-pcf.c, which was created
12 by Simon G. Vogl and Hans Berglund:
13
14
15 Copyright (C) 1995-1997 Simon G. Vogl
16 1998-2000 Hans Berglund
17
18 This program is free software; you can redistribute it and/or modify
19 it under the terms of the GNU General Public License as published by
20 the Free Software Foundation; either version 2 of the License, or
21 (at your option) any later version.
22
23 This program is distributed in the hope that it will be useful,
24 but WITHOUT ANY WARRANTY; without even the implied warranty of
25 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 GNU General Public License for more details.
27
28 You should have received a copy of the GNU General Public License
29 along with this program; if not, write to the Free Software
30 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
31/* ------------------------------------------------------------------------- */
32
33/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and
34 Frodo Looijaard <frodol@dds.nl> ,and also from Martin Bailey
35 <mbailey@littlefeet-inc.com> */
36
37#include <linux/kernel.h>
38#include <linux/module.h>
39#include <linux/delay.h>
40#include <linux/slab.h>
41#include <linux/init.h>
42#include <asm/uaccess.h>
43#include <linux/ioport.h>
44#include <linux/errno.h>
45#include <linux/sched.h>
46
47#include <linux/i2c.h>
48#include <linux/i2c-algo-ite.h>
49#include "i2c-algo-ite.h"
50
51#define PM_DSR IT8172_PCI_IO_BASE + IT_PM_DSR
52#define PM_IBSR IT8172_PCI_IO_BASE + IT_PM_DSR + 0x04
53#define GPIO_CCR IT8172_PCI_IO_BASE + IT_GPCCR
54
55#define DEB2(x) if (i2c_debug>=2) x
56#define DEB3(x) if (i2c_debug>=3) x /* print several statistical values*/
57#define DEF_TIMEOUT 16
58
59
60/* module parameters:
61 */
62static int i2c_debug;
63static int iic_test; /* see if the line-setting functions work */
64
65/* --- setting states on the bus with the right timing: --------------- */
66
67#define get_clock(adap) adap->getclock(adap->data)
68#define iic_outw(adap, reg, val) adap->setiic(adap->data, reg, val)
69#define iic_inw(adap, reg) adap->getiic(adap->data, reg)
70
71
72/* --- other auxiliary functions -------------------------------------- */
73
74static void iic_start(struct i2c_algo_iic_data *adap)
75{
76 iic_outw(adap,ITE_I2CHCR,ITE_CMD);
77}
78
79static void iic_stop(struct i2c_algo_iic_data *adap)
80{
81 iic_outw(adap,ITE_I2CHCR,0);
82 iic_outw(adap,ITE_I2CHSR,ITE_I2CHSR_TDI);
83}
84
85static void iic_reset(struct i2c_algo_iic_data *adap)
86{
87 iic_outw(adap, PM_IBSR, iic_inw(adap, PM_IBSR) | 0x80);
88}
89
90
91static int wait_for_bb(struct i2c_algo_iic_data *adap)
92{
93 int timeout = DEF_TIMEOUT;
94 short status;
95
96 status = iic_inw(adap, ITE_I2CHSR);
97#ifndef STUB_I2C
98 while (timeout-- && (status & ITE_I2CHSR_HB)) {
99 udelay(1000); /* How much is this? */
100 status = iic_inw(adap, ITE_I2CHSR);
101 }
102#endif
103 if (timeout<=0) {
104 printk(KERN_ERR "Timeout, host is busy\n");
105 iic_reset(adap);
106 }
107 return(timeout<=0);
108}
109
110/* After we issue a transaction on the IIC bus, this function
111 * is called. It puts this process to sleep until we get an interrupt from
112 * from the controller telling us that the transaction we requested in complete.
113 */
114static int wait_for_pin(struct i2c_algo_iic_data *adap, short *status) {
115
116 int timeout = DEF_TIMEOUT;
117
118 timeout = wait_for_bb(adap);
119 if (timeout) {
120 DEB2(printk("Timeout waiting for host not busy\n");)
121 return -EIO;
122 }
123 timeout = DEF_TIMEOUT;
124
125 *status = iic_inw(adap, ITE_I2CHSR);
126#ifndef STUB_I2C
127 while (timeout-- && !(*status & ITE_I2CHSR_TDI)) {
128 adap->waitforpin();
129 *status = iic_inw(adap, ITE_I2CHSR);
130 }
131#endif
132 if (timeout <= 0)
133 return(-1);
134 else
135 return(0);
136}
137
138static int wait_for_fe(struct i2c_algo_iic_data *adap, short *status)
139{
140 int timeout = DEF_TIMEOUT;
141
142 *status = iic_inw(adap, ITE_I2CFSR);
143#ifndef STUB_I2C
144 while (timeout-- && (*status & ITE_I2CFSR_FE)) {
145 udelay(1000);
146 iic_inw(adap, ITE_I2CFSR);
147 }
148#endif
149 if (timeout <= 0)
150 return(-1);
151 else
152 return(0);
153}
154
155static int iic_init (struct i2c_algo_iic_data *adap)
156{
157 short i;
158
159 /* Clear bit 7 to set I2C to normal operation mode */
160 i=iic_inw(adap, PM_DSR)& 0xff7f;
161 iic_outw(adap, PM_DSR, i);
162
163 /* set IT_GPCCR port C bit 2&3 as function 2 */
164 i = iic_inw(adap, GPIO_CCR) & 0xfc0f;
165 iic_outw(adap,GPIO_CCR,i);
166
167 /* Clear slave address/sub-address */
168 iic_outw(adap,ITE_I2CSAR, 0);
169 iic_outw(adap,ITE_I2CSSAR, 0);
170
171 /* Set clock counter register */
172 iic_outw(adap,ITE_I2CCKCNT, get_clock(adap));
173
174 /* Set START/reSTART/STOP time registers */
175 iic_outw(adap,ITE_I2CSHDR, 0x0a);
176 iic_outw(adap,ITE_I2CRSUR, 0x0a);
177 iic_outw(adap,ITE_I2CPSUR, 0x0a);
178
179 /* Enable interrupts on completing the current transaction */
180 iic_outw(adap,ITE_I2CHCR, ITE_I2CHCR_IE | ITE_I2CHCR_HCE);
181
182 /* Clear transfer count */
183 iic_outw(adap,ITE_I2CFBCR, 0x0);
184
185 DEB2(printk("iic_init: Initialized IIC on ITE 0x%x\n",
186 iic_inw(adap, ITE_I2CHSR)));
187 return 0;
188}
189
190
191/*
192 * Sanity check for the adapter hardware - check the reaction of
193 * the bus lines only if it seems to be idle.
194 */
195static int test_bus(struct i2c_algo_iic_data *adap, char *name) {
196#if 0
197 int scl,sda;
198 sda=getsda(adap);
199 if (adap->getscl==NULL) {
200 printk("test_bus: Warning: Adapter can't read from clock line - skipping test.\n");
201 return 0;
202 }
203 scl=getscl(adap);
204 printk("test_bus: Adapter: %s scl: %d sda: %d -- testing...\n",
205 name,getscl(adap),getsda(adap));
206 if (!scl || !sda ) {
207 printk("test_bus: %s seems to be busy.\n",adap->name);
208 goto bailout;
209 }
210 sdalo(adap);
211 printk("test_bus:1 scl: %d sda: %d\n", getscl(adap),
212 getsda(adap));
213 if ( 0 != getsda(adap) ) {
214 printk("test_bus: %s SDA stuck high!\n",name);
215 sdahi(adap);
216 goto bailout;
217 }
218 if ( 0 == getscl(adap) ) {
219 printk("test_bus: %s SCL unexpected low while pulling SDA low!\n",
220 name);
221 goto bailout;
222 }
223 sdahi(adap);
224 printk("test_bus:2 scl: %d sda: %d\n", getscl(adap),
225 getsda(adap));
226 if ( 0 == getsda(adap) ) {
227 printk("test_bus: %s SDA stuck low!\n",name);
228 sdahi(adap);
229 goto bailout;
230 }
231 if ( 0 == getscl(adap) ) {
232 printk("test_bus: %s SCL unexpected low while SDA high!\n",
233 adap->name);
234 goto bailout;
235 }
236 scllo(adap);
237 printk("test_bus:3 scl: %d sda: %d\n", getscl(adap),
238 getsda(adap));
239 if ( 0 != getscl(adap) ) {
240
241 sclhi(adap);
242 goto bailout;
243 }
244 if ( 0 == getsda(adap) ) {
245 printk("test_bus: %s SDA unexpected low while pulling SCL low!\n",
246 name);
247 goto bailout;
248 }
249 sclhi(adap);
250 printk("test_bus:4 scl: %d sda: %d\n", getscl(adap),
251 getsda(adap));
252 if ( 0 == getscl(adap) ) {
253 printk("test_bus: %s SCL stuck low!\n",name);
254 sclhi(adap);
255 goto bailout;
256 }
257 if ( 0 == getsda(adap) ) {
258 printk("test_bus: %s SDA unexpected low while SCL high!\n",
259 name);
260 goto bailout;
261 }
262 printk("test_bus: %s passed test.\n",name);
263 return 0;
264bailout:
265 sdahi(adap);
266 sclhi(adap);
267 return -ENODEV;
268#endif
269 return (0);
270}
271
272/* ----- Utility functions
273 */
274
275
276/* Verify the device we want to talk to on the IIC bus really exists. */
277static inline int try_address(struct i2c_algo_iic_data *adap,
278 unsigned int addr, int retries)
279{
280 int i, ret = -1;
281 short status;
282
283 for (i=0;i<retries;i++) {
284 iic_outw(adap, ITE_I2CSAR, addr);
285 iic_start(adap);
286 if (wait_for_pin(adap, &status) == 0) {
287 if ((status & ITE_I2CHSR_DNE) == 0) {
288 iic_stop(adap);
289 iic_outw(adap, ITE_I2CFCR, ITE_I2CFCR_FLUSH);
290 ret=1;
291 break; /* success! */
292 }
293 }
294 iic_stop(adap);
295 udelay(adap->udelay);
296 }
297 DEB2(if (i) printk("try_address: needed %d retries for 0x%x\n",i,
298 addr));
299 return ret;
300}
301
302
303static int iic_sendbytes(struct i2c_adapter *i2c_adap,const char *buf,
304 int count)
305{
306 struct i2c_algo_iic_data *adap = i2c_adap->algo_data;
307 int wrcount=0, timeout;
308 short status;
309 int loops, remainder, i, j;
310 union {
311 char byte[2];
312 unsigned short word;
313 } tmp;
314
315 iic_outw(adap, ITE_I2CSSAR, (unsigned short)buf[wrcount++]);
316 count--;
317 if (count == 0)
318 return -EIO;
319
320 loops = count / 32; /* 32-byte FIFO */
321 remainder = count % 32;
322
323 if(loops) {
324 for(i=0; i<loops; i++) {
325
326 iic_outw(adap, ITE_I2CFBCR, 32);
327 for(j=0; j<32/2; j++) {
328 tmp.byte[1] = buf[wrcount++];
329 tmp.byte[0] = buf[wrcount++];
330 iic_outw(adap, ITE_I2CFDR, tmp.word);
331 }
332
333 /* status FIFO overrun */
334 iic_inw(adap, ITE_I2CFSR);
335 iic_inw(adap, ITE_I2CFBCR);
336
337 iic_outw(adap, ITE_I2CHCR, ITE_WRITE); /* Issue WRITE command */
338
339 /* Wait for transmission to complete */
340 timeout = wait_for_pin(adap, &status);
341 if(timeout) {
342 iic_stop(adap);
343 printk("iic_sendbytes: %s write timeout.\n", i2c_adap->name);
344 return -EREMOTEIO; /* got a better one ?? */
345 }
346 if (status & ITE_I2CHSR_DB) {
347 iic_stop(adap);
348 printk("iic_sendbytes: %s write error - no ack.\n", i2c_adap->name);
349 return -EREMOTEIO; /* got a better one ?? */
350 }
351 }
352 }
353 if(remainder) {
354 iic_outw(adap, ITE_I2CFBCR, remainder);
355 for(i=0; i<remainder/2; i++) {
356 tmp.byte[1] = buf[wrcount++];
357 tmp.byte[0] = buf[wrcount++];
358 iic_outw(adap, ITE_I2CFDR, tmp.word);
359 }
360
361 /* status FIFO overrun */
362 iic_inw(adap, ITE_I2CFSR);
363 iic_inw(adap, ITE_I2CFBCR);
364
365 iic_outw(adap, ITE_I2CHCR, ITE_WRITE); /* Issue WRITE command */
366
367 timeout = wait_for_pin(adap, &status);
368 if(timeout) {
369 iic_stop(adap);
370 printk("iic_sendbytes: %s write timeout.\n", i2c_adap->name);
371 return -EREMOTEIO; /* got a better one ?? */
372 }
373#ifndef STUB_I2C
374 if (status & ITE_I2CHSR_DB) {
375 iic_stop(adap);
376 printk("iic_sendbytes: %s write error - no ack.\n", i2c_adap->name);
377 return -EREMOTEIO; /* got a better one ?? */
378 }
379#endif
380 }
381 iic_stop(adap);
382 return wrcount;
383}
384
385
386static int iic_readbytes(struct i2c_adapter *i2c_adap, char *buf, int count,
387 int sread)
388{
389 int rdcount=0, i, timeout;
390 short status;
391 struct i2c_algo_iic_data *adap = i2c_adap->algo_data;
392 int loops, remainder, j;
393 union {
394 char byte[2];
395 unsigned short word;
396 } tmp;
397
398 loops = count / 32; /* 32-byte FIFO */
399 remainder = count % 32;
400
401 if(loops) {
402 for(i=0; i<loops; i++) {
403 iic_outw(adap, ITE_I2CFBCR, 32);
404 if (sread)
405 iic_outw(adap, ITE_I2CHCR, ITE_SREAD);
406 else
407 iic_outw(adap, ITE_I2CHCR, ITE_READ); /* Issue READ command */
408
409 timeout = wait_for_pin(adap, &status);
410 if(timeout) {
411 iic_stop(adap);
412 printk("iic_readbytes: %s read timeout.\n", i2c_adap->name);
413 return (-1);
414 }
415#ifndef STUB_I2C
416 if (status & ITE_I2CHSR_DB) {
417 iic_stop(adap);
418 printk("iic_readbytes: %s read error - no ack.\n", i2c_adap->name);
419 return (-1);
420 }
421#endif
422
423 timeout = wait_for_fe(adap, &status);
424 if(timeout) {
425 iic_stop(adap);
426 printk("iic_readbytes: %s FIFO is empty\n", i2c_adap->name);
427 return (-1);
428 }
429
430 for(j=0; j<32/2; j++) {
431 tmp.word = iic_inw(adap, ITE_I2CFDR);
432 buf[rdcount++] = tmp.byte[1];
433 buf[rdcount++] = tmp.byte[0];
434 }
435
436 /* status FIFO underrun */
437 iic_inw(adap, ITE_I2CFSR);
438
439 }
440 }
441
442
443 if(remainder) {
444 remainder=(remainder+1)/2 * 2;
445 iic_outw(adap, ITE_I2CFBCR, remainder);
446 if (sread)
447 iic_outw(adap, ITE_I2CHCR, ITE_SREAD);
448 else
449 iic_outw(adap, ITE_I2CHCR, ITE_READ); /* Issue READ command */
450
451 timeout = wait_for_pin(adap, &status);
452 if(timeout) {
453 iic_stop(adap);
454 printk("iic_readbytes: %s read timeout.\n", i2c_adap->name);
455 return (-1);
456 }
457#ifndef STUB_I2C
458 if (status & ITE_I2CHSR_DB) {
459 iic_stop(adap);
460 printk("iic_readbytes: %s read error - no ack.\n", i2c_adap->name);
461 return (-1);
462 }
463#endif
464 timeout = wait_for_fe(adap, &status);
465 if(timeout) {
466 iic_stop(adap);
467 printk("iic_readbytes: %s FIFO is empty\n", i2c_adap->name);
468 return (-1);
469 }
470
471 for(i=0; i<(remainder+1)/2; i++) {
472 tmp.word = iic_inw(adap, ITE_I2CFDR);
473 buf[rdcount++] = tmp.byte[1];
474 buf[rdcount++] = tmp.byte[0];
475 }
476
477 /* status FIFO underrun */
478 iic_inw(adap, ITE_I2CFSR);
479
480 }
481
482 iic_stop(adap);
483 return rdcount;
484}
485
486
487/* This function implements combined transactions. Combined
488 * transactions consist of combinations of reading and writing blocks of data.
489 * Each transfer (i.e. a read or a write) is separated by a repeated start
490 * condition.
491 */
492#if 0
493static int iic_combined_transaction(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num)
494{
495 int i;
496 struct i2c_msg *pmsg;
497 int ret;
498
499 DEB2(printk("Beginning combined transaction\n"));
500
501 for(i=0; i<(num-1); i++) {
502 pmsg = &msgs[i];
503 if(pmsg->flags & I2C_M_RD) {
504 DEB2(printk(" This one is a read\n"));
505 ret = iic_readbytes(i2c_adap, pmsg->buf, pmsg->len, IIC_COMBINED_XFER);
506 }
507 else if(!(pmsg->flags & I2C_M_RD)) {
508 DEB2(printk("This one is a write\n"));
509 ret = iic_sendbytes(i2c_adap, pmsg->buf, pmsg->len, IIC_COMBINED_XFER);
510 }
511 }
512 /* Last read or write segment needs to be terminated with a stop */
513 pmsg = &msgs[i];
514
515 if(pmsg->flags & I2C_M_RD) {
516 DEB2(printk("Doing the last read\n"));
517 ret = iic_readbytes(i2c_adap, pmsg->buf, pmsg->len, IIC_SINGLE_XFER);
518 }
519 else if(!(pmsg->flags & I2C_M_RD)) {
520 DEB2(printk("Doing the last write\n"));
521 ret = iic_sendbytes(i2c_adap, pmsg->buf, pmsg->len, IIC_SINGLE_XFER);
522 }
523
524 return ret;
525}
526#endif
527
528
529/* Whenever we initiate a transaction, the first byte clocked
530 * onto the bus after the start condition is the address (7 bit) of the
531 * device we want to talk to. This function manipulates the address specified
532 * so that it makes sense to the hardware when written to the IIC peripheral.
533 *
534 * Note: 10 bit addresses are not supported in this driver, although they are
535 * supported by the hardware. This functionality needs to be implemented.
536 */
537static inline int iic_doAddress(struct i2c_algo_iic_data *adap,
538 struct i2c_msg *msg, int retries)
539{
540 unsigned short flags = msg->flags;
541 unsigned int addr;
542 int ret;
543
544/* Ten bit addresses not supported right now */
545 if ( (flags & I2C_M_TEN) ) {
546#if 0
547 addr = 0xf0 | (( msg->addr >> 7) & 0x03);
548 DEB2(printk("addr0: %d\n",addr));
549 ret = try_address(adap, addr, retries);
550 if (ret!=1) {
551 printk("iic_doAddress: died at extended address code.\n");
552 return -EREMOTEIO;
553 }
554 iic_outw(adap,msg->addr & 0x7f);
555 if (ret != 1) {
556 printk("iic_doAddress: died at 2nd address code.\n");
557 return -EREMOTEIO;
558 }
559 if ( flags & I2C_M_RD ) {
560 i2c_repstart(adap);
561 addr |= 0x01;
562 ret = try_address(adap, addr, retries);
563 if (ret!=1) {
564 printk("iic_doAddress: died at extended address code.\n");
565 return -EREMOTEIO;
566 }
567 }
568#endif
569 } else {
570
571 addr = ( msg->addr << 1 );
572
573#if 0
574 if (flags & I2C_M_RD )
575 addr |= 1;
576 if (flags & I2C_M_REV_DIR_ADDR )
577 addr ^= 1;
578#endif
579
580 if (iic_inw(adap, ITE_I2CSAR) != addr) {
581 iic_outw(adap, ITE_I2CSAR, addr);
582 ret = try_address(adap, addr, retries);
583 if (ret!=1) {
584 printk("iic_doAddress: died at address code.\n");
585 return -EREMOTEIO;
586 }
587 }
588
589 }
590
591 return 0;
592}
593
594
595/* Description: Prepares the controller for a transaction (clearing status
596 * registers, data buffers, etc), and then calls either iic_readbytes or
597 * iic_sendbytes to do the actual transaction.
598 *
599 * still to be done: Before we issue a transaction, we should
600 * verify that the bus is not busy or in some unknown state.
601 */
602static int iic_xfer(struct i2c_adapter *i2c_adap,
603 struct i2c_msg *msgs,
604 int num)
605{
606 struct i2c_algo_iic_data *adap = i2c_adap->algo_data;
607 struct i2c_msg *pmsg;
608 int i = 0;
609 int ret, timeout;
610
611 pmsg = &msgs[i];
612
613 if(!pmsg->len) {
614 DEB2(printk("iic_xfer: read/write length is 0\n");)
615 return -EIO;
616 }
617 if(!(pmsg->flags & I2C_M_RD) && (!(pmsg->len)%2) ) {
618 DEB2(printk("iic_xfer: write buffer length is not odd\n");)
619 return -EIO;
620 }
621
622 /* Wait for any pending transfers to complete */
623 timeout = wait_for_bb(adap);
624 if (timeout) {
625 DEB2(printk("iic_xfer: Timeout waiting for host not busy\n");)
626 return -EIO;
627 }
628
629 /* Flush FIFO */
630 iic_outw(adap, ITE_I2CFCR, ITE_I2CFCR_FLUSH);
631
632 /* Load address */
633 ret = iic_doAddress(adap, pmsg, i2c_adap->retries);
634 if (ret)
635 return -EIO;
636
637#if 0
638 /* Combined transaction (read and write) */
639 if(num > 1) {
640 DEB2(printk("iic_xfer: Call combined transaction\n"));
641 ret = iic_combined_transaction(i2c_adap, msgs, num);
642 }
643#endif
644
645 DEB3(printk("iic_xfer: Msg %d, addr=0x%x, flags=0x%x, len=%d\n",
646 i, msgs[i].addr, msgs[i].flags, msgs[i].len);)
647
648 if(pmsg->flags & I2C_M_RD) /* Read */
649 ret = iic_readbytes(i2c_adap, pmsg->buf, pmsg->len, 0);
650 else { /* Write */
651 udelay(1000);
652 ret = iic_sendbytes(i2c_adap, pmsg->buf, pmsg->len);
653 }
654
655 if (ret != pmsg->len)
656 DEB3(printk("iic_xfer: error or fail on read/write %d bytes.\n",ret));
657 else
658 DEB3(printk("iic_xfer: read/write %d bytes.\n",ret));
659
660 return ret;
661}
662
663
664/* Implements device specific ioctls. Higher level ioctls can
665 * be found in i2c-core.c and are typical of any i2c controller (specifying
666 * slave address, timeouts, etc). These ioctls take advantage of any hardware
667 * features built into the controller for which this algorithm-adapter set
668 * was written. These ioctls allow you to take control of the data and clock
669 * lines and set the either high or low,
670 * similar to a GPIO pin.
671 */
672static int algo_control(struct i2c_adapter *adapter,
673 unsigned int cmd, unsigned long arg)
674{
675
676 struct i2c_algo_iic_data *adap = adapter->algo_data;
677 struct i2c_iic_msg s_msg;
678 char *buf;
679 int ret;
680
681 if (cmd == I2C_SREAD) {
682 if(copy_from_user(&s_msg, (struct i2c_iic_msg *)arg,
683 sizeof(struct i2c_iic_msg)))
684 return -EFAULT;
685 buf = kmalloc(s_msg.len, GFP_KERNEL);
686 if (buf== NULL)
687 return -ENOMEM;
688
689 /* Flush FIFO */
690 iic_outw(adap, ITE_I2CFCR, ITE_I2CFCR_FLUSH);
691
692 /* Load address */
693 iic_outw(adap, ITE_I2CSAR,s_msg.addr<<1);
694 iic_outw(adap, ITE_I2CSSAR,s_msg.waddr & 0xff);
695
696 ret = iic_readbytes(adapter, buf, s_msg.len, 1);
697 if (ret>=0) {
698 if(copy_to_user( s_msg.buf, buf, s_msg.len) )
699 ret = -EFAULT;
700 }
701 kfree(buf);
702 }
703 return 0;
704}
705
706
707static u32 iic_func(struct i2c_adapter *adap)
708{
709 return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR |
710 I2C_FUNC_PROTOCOL_MANGLING;
711}
712
713/* -----exported algorithm data: ------------------------------------- */
714
715static struct i2c_algorithm iic_algo = {
716 .master_xfer = iic_xfer,
717 .algo_control = algo_control, /* ioctl */
718 .functionality = iic_func,
719};
720
721
722/*
723 * registering functions to load algorithms at runtime
724 */
725int i2c_iic_add_bus(struct i2c_adapter *adap)
726{
727 struct i2c_algo_iic_data *iic_adap = adap->algo_data;
728
729 if (iic_test) {
730 int ret = test_bus(iic_adap, adap->name);
731 if (ret<0)
732 return -ENODEV;
733 }
734
735 DEB2(printk("i2c-algo-ite: hw routines for %s registered.\n",
736 adap->name));
737
738 /* register new adapter to i2c module... */
739 adap->algo = &iic_algo;
740
741 adap->timeout = 100; /* default values, should */
742 adap->retries = 3; /* be replaced by defines */
743 adap->flags = 0;
744
745 iic_init(iic_adap);
746 return i2c_add_adapter(adap);
747}
748
749
750int i2c_iic_del_bus(struct i2c_adapter *adap)
751{
752 int res;
753 if ((res = i2c_del_adapter(adap)) < 0)
754 return res;
755 DEB2(printk("i2c-algo-ite: adapter unregistered: %s\n",adap->name));
756
757 return 0;
758}
759
760
761int __init i2c_algo_iic_init (void)
762{
763 printk(KERN_INFO "ITE iic (i2c) algorithm module\n");
764 return 0;
765}
766
767
768void i2c_algo_iic_exit(void)
769{
770 return;
771}
772
773
774EXPORT_SYMBOL(i2c_iic_add_bus);
775EXPORT_SYMBOL(i2c_iic_del_bus);
776
777/* The MODULE_* macros resolve to nothing if MODULES is not defined
778 * when this file is compiled.
779 */
780MODULE_AUTHOR("MontaVista Software <www.mvista.com>");
781MODULE_DESCRIPTION("ITE iic algorithm");
782MODULE_LICENSE("GPL");
783
784module_param(iic_test, bool, 0);
785module_param(i2c_debug, int, S_IRUGO | S_IWUSR);
786
787MODULE_PARM_DESC(iic_test, "Test if the I2C bus is available");
788MODULE_PARM_DESC(i2c_debug,
789 "debug level - 0 off; 1 normal; 2,3 more verbose; 9 iic-protocol");
790
791
792/* This function resolves to init_module (the function invoked when a module
793 * is loaded via insmod) when this file is compiled with MODULES defined.
794 * Otherwise (i.e. if you want this driver statically linked to the kernel),
795 * a pointer to this function is stored in a table and called
796 * during the initialization of the kernel (in do_basic_setup in /init/main.c)
797 *
798 * All this functionality is complements of the macros defined in linux/init.h
799 */
800module_init(i2c_algo_iic_init);
801
802
803/* If MODULES is defined when this file is compiled, then this function will
804 * resolved to cleanup_module.
805 */
806module_exit(i2c_algo_iic_exit);
diff --git a/drivers/i2c/algos/i2c-algo-ite.h b/drivers/i2c/algos/i2c-algo-ite.h
deleted file mode 100644
index a8ca3c9b546a..000000000000
--- a/drivers/i2c/algos/i2c-algo-ite.h
+++ /dev/null
@@ -1,117 +0,0 @@
1/*
2 --------------------------------------------------------------------
3 i2c-ite.h: Global defines for the I2C controller on board the
4 ITE MIPS processor.
5 --------------------------------------------------------------------
6 Hai-Pao Fan, MontaVista Software, Inc.
7 hpfan@mvista.com or source@mvista.com
8
9 Copyright 2001 MontaVista Software Inc.
10
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 *
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
19 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
22 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * You should have received a copy of the GNU General Public License along
28 * with this program; if not, write to the Free Software Foundation, Inc.,
29 * 675 Mass Ave, Cambridge, MA 02139, USA.
30
31 */
32
33#ifndef I2C_ITE_H
34#define I2C_ITE_H 1
35
36#include <asm/it8172/it8172.h>
37
38/* I2C Registers */
39#define ITE_I2CHCR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x30
40#define ITE_I2CHSR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x34
41#define ITE_I2CSAR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x38
42#define ITE_I2CSSAR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x3c
43#define ITE_I2CCKCNT IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x48
44#define ITE_I2CSHDR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x4c
45#define ITE_I2CRSUR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x50
46#define ITE_I2CPSUR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x54
47
48#define ITE_I2CFDR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x70
49#define ITE_I2CFBCR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x74
50#define ITE_I2CFCR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x78
51#define ITE_I2CFSR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x7c
52
53
54/* Host Control Register ITE_I2CHCR */
55#define ITE_I2CHCR_HCE 0x01 /* Enable I2C Host Controller */
56#define ITE_I2CHCR_IE 0x02 /* Enable the interrupt after completing
57 the current transaction */
58#define ITE_I2CHCR_CP_W 0x00 /* bit2-4 000 - Write */
59#define ITE_I2CHCR_CP_R 0x08 /* 010 - Current address read */
60#define ITE_I2CHCR_CP_S 0x10 /* 100 - Sequential read */
61#define ITE_I2CHCR_ST 0x20 /* Initiates the I2C host controller to execute
62 the command and send the data programmed in
63 all required registers to I2C bus */
64#define ITE_CMD ITE_I2CHCR_HCE | ITE_I2CHCR_IE | ITE_I2CHCR_ST
65#define ITE_WRITE ITE_CMD | ITE_I2CHCR_CP_W
66#define ITE_READ ITE_CMD | ITE_I2CHCR_CP_R
67#define ITE_SREAD ITE_CMD | ITE_I2CHCR_CP_S
68
69/* Host Status Register ITE_I2CHSR */
70#define ITE_I2CHSR_DB 0x01 /* Device is busy, receives NACK response except
71 in the first and last bytes */
72#define ITE_I2CHSR_DNE 0x02 /* Target address on I2C bus does not exist */
73#define ITE_I2CHSR_TDI 0x04 /* R/W Transaction on I2C bus was completed */
74#define ITE_I2CHSR_HB 0x08 /* Host controller is processing transactions */
75#define ITE_I2CHSR_FER 0x10 /* Error occurs in the FIFO */
76
77/* Slave Address Register ITE_I2CSAR */
78#define ITE_I2CSAR_SA_MASK 0xfe /* Target I2C device address */
79#define ITE_I2CSAR_ASO 0x0100 /* Output 1/0 to I2CAS port when the
80 next slave address is addressed */
81
82/* Slave Sub-address Register ITE_I2CSSAR */
83#define ITE_I2CSSAR_SUBA_MASK 0xff /* Target I2C device sub-address */
84
85/* Clock Counter Register ITE_I2CCKCNT */
86#define ITE_I2CCKCNT_STOP 0x00 /* stop I2C clock */
87#define ITE_I2CCKCNT_HPCC_MASK 0x7f /* SCL high period counter */
88#define ITE_I2CCKCNT_LPCC_MASK 0x7f00 /* SCL low period counter */
89
90/* START Hold Time Register ITE_I2CSHDR */
91/* value is counted based on 16 MHz internal clock */
92#define ITE_I2CSHDR_FM 0x0a /* START condition at fast mode */
93#define ITE_I2CSHDR_SM 0x47 /* START contition at standard mode */
94
95/* (Repeated) START Setup Time Register ITE_I2CRSUR */
96/* value is counted based on 16 MHz internal clock */
97#define ITE_I2CRSUR_FM 0x0a /* repeated START condition at fast mode */
98#define ITE_I2CRSUR_SM 0x50 /* repeated START condition at standard mode */
99
100/* STOP setup Time Register ITE_I2CPSUR */
101
102/* FIFO Data Register ITE_I2CFDR */
103#define ITE_I2CFDR_MASK 0xff
104
105/* FIFO Byte Count Register ITE_I2CFBCR */
106#define ITE_I2CFBCR_MASK 0x3f
107
108/* FIFO Control Register ITE_I2CFCR */
109#define ITE_I2CFCR_FLUSH 0x01 /* Flush FIFO and reset the FIFO point
110 and I2CFSR */
111/* FIFO Status Register ITE_I2CFSR */
112#define ITE_I2CFSR_FO 0x01 /* FIFO is overrun when write */
113#define ITE_I2CFSR_FU 0x02 /* FIFO is underrun when read */
114#define ITE_I2CFSR_FF 0x04 /* FIFO is full when write */
115#define ITE_I2CFSR_FE 0x08 /* FIFO is empty when read */
116
117#endif /* I2C_ITE_H */
diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c
index 9081c9fbcd29..36fdf971f080 100644
--- a/drivers/i2c/algos/i2c-algo-pca.c
+++ b/drivers/i2c/algos/i2c-algo-pca.c
@@ -381,14 +381,7 @@ int i2c_pca_add_bus(struct i2c_adapter *adap)
381 381
382 return rval; 382 return rval;
383} 383}
384
385int i2c_pca_del_bus(struct i2c_adapter *adap)
386{
387 return i2c_del_adapter(adap);
388}
389
390EXPORT_SYMBOL(i2c_pca_add_bus); 384EXPORT_SYMBOL(i2c_pca_add_bus);
391EXPORT_SYMBOL(i2c_pca_del_bus);
392 385
393MODULE_AUTHOR("Ian Campbell <icampbell@arcom.com>"); 386MODULE_AUTHOR("Ian Campbell <icampbell@arcom.com>");
394MODULE_DESCRIPTION("I2C-Bus PCA9564 algorithm"); 387MODULE_DESCRIPTION("I2C-Bus PCA9564 algorithm");
diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index 3b2003398966..ecb2c2d7d540 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -486,15 +486,7 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap)
486 486
487 return rval; 487 return rval;
488} 488}
489
490
491int i2c_pcf_del_bus(struct i2c_adapter *adap)
492{
493 return i2c_del_adapter(adap);
494}
495
496EXPORT_SYMBOL(i2c_pcf_add_bus); 489EXPORT_SYMBOL(i2c_pcf_add_bus);
497EXPORT_SYMBOL(i2c_pcf_del_bus);
498 490
499MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>"); 491MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>");
500MODULE_DESCRIPTION("I2C-Bus PCF8584 algorithm"); 492MODULE_DESCRIPTION("I2C-Bus PCF8584 algorithm");
diff --git a/drivers/i2c/algos/i2c-algo-sgi.c b/drivers/i2c/algos/i2c-algo-sgi.c
index 490d99997fd0..ac2d5053078a 100644
--- a/drivers/i2c/algos/i2c-algo-sgi.c
+++ b/drivers/i2c/algos/i2c-algo-sgi.c
@@ -171,15 +171,7 @@ int i2c_sgi_add_bus(struct i2c_adapter *adap)
171 171
172 return i2c_add_adapter(adap); 172 return i2c_add_adapter(adap);
173} 173}
174
175
176int i2c_sgi_del_bus(struct i2c_adapter *adap)
177{
178 return i2c_del_adapter(adap);
179}
180
181EXPORT_SYMBOL(i2c_sgi_add_bus); 174EXPORT_SYMBOL(i2c_sgi_add_bus);
182EXPORT_SYMBOL(i2c_sgi_del_bus);
183 175
184MODULE_AUTHOR("Ladislav Michl <ladis@linux-mips.org>"); 176MODULE_AUTHOR("Ladislav Michl <ladis@linux-mips.org>");
185MODULE_DESCRIPTION("I2C-Bus SGI algorithm"); 177MODULE_DESCRIPTION("I2C-Bus SGI algorithm");
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 90f91d039ee2..e1989f3a2684 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -74,6 +74,13 @@ config I2C_AMD8111
74 This driver can also be built as a module. If so, the module 74 This driver can also be built as a module. If so, the module
75 will be called i2c-amd8111. 75 will be called i2c-amd8111.
76 76
77config I2C_AT91
78 tristate "Atmel AT91 I2C Two-Wire interface (TWI)"
79 depends on I2C && ARCH_AT91 && EXPERIMENTAL
80 help
81 This supports the use of the I2C interface on Atmel AT91
82 processors.
83
77config I2C_AU1550 84config I2C_AU1550
78 tristate "Au1550/Au1200 SMBus interface" 85 tristate "Au1550/Au1200 SMBus interface"
79 depends on I2C && (SOC_AU1550 || SOC_AU1200) 86 depends on I2C && (SOC_AU1550 || SOC_AU1200)
@@ -209,18 +216,6 @@ config I2C_ISA
209 tristate 216 tristate
210 depends on I2C 217 depends on I2C
211 218
212config I2C_ITE
213 tristate "ITE I2C Adapter"
214 depends on I2C && MIPS_ITE8172
215 select I2C_ALGOITE
216 help
217 This supports the ITE8172 I2C peripheral found on some MIPS
218 systems. Say Y if you have one of these. You should also say Y for
219 the ITE I2C driver algorithm support above.
220
221 This support is also available as a module. If so, the module
222 will be called i2c-ite.
223
224config I2C_IXP4XX 219config I2C_IXP4XX
225 tristate "IXP4xx GPIO-Based I2C Interface" 220 tristate "IXP4xx GPIO-Based I2C Interface"
226 depends on I2C && ARCH_IXP4XX 221 depends on I2C && ARCH_IXP4XX
@@ -481,6 +476,17 @@ config I2C_STUB
481 476
482 If you don't know what to do here, definitely say N. 477 If you don't know what to do here, definitely say N.
483 478
479config I2C_VERSATILE
480 tristate "ARM Versatile/Realview I2C bus support"
481 depends on I2C && (ARCH_VERSATILE || ARCH_REALVIEW)
482 select I2C_ALGOBIT
483 help
484 Say yes if you want to support the I2C serial bus on ARMs Versatile
485 range of platforms.
486
487 This driver can also be built as a module. If so, the module
488 will be called i2c-versatile.
489
484config I2C_VIA 490config I2C_VIA
485 tristate "VIA 82C586B" 491 tristate "VIA 82C586B"
486 depends on I2C && PCI && EXPERIMENTAL 492 depends on I2C && PCI && EXPERIMENTAL
@@ -548,4 +554,23 @@ config I2C_MV64XXX
548 This driver can also be built as a module. If so, the module 554 This driver can also be built as a module. If so, the module
549 will be called i2c-mv64xxx. 555 will be called i2c-mv64xxx.
550 556
557config I2C_PNX
558 tristate "I2C bus support for Philips PNX targets"
559 depends on ARCH_PNX4008 && I2C
560 help
561 This driver supports the Philips IP3204 I2C IP block master and/or
562 slave controller
563
564 This driver can also be built as a module. If so, the module
565 will be called i2c-pnx.
566
567config I2C_PNX_EARLY
568 bool "Early initialization for I2C on PNXxxxx"
569 depends on I2C_PNX=y
570 help
571 Under certain circumstances one may need to make sure I2C on PNXxxxx
572 is initialized earlier than some other driver that depends on it
573 (for instance, that might be USB in case of PNX4008). With this
574 option turned on you can guarantee that.
575
551endmenu 576endmenu
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 493c87289b62..37196c1d0794 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_I2C_ALI15X3) += i2c-ali15x3.o
8obj-$(CONFIG_I2C_AMD756) += i2c-amd756.o 8obj-$(CONFIG_I2C_AMD756) += i2c-amd756.o
9obj-$(CONFIG_I2C_AMD756_S4882) += i2c-amd756-s4882.o 9obj-$(CONFIG_I2C_AMD756_S4882) += i2c-amd756-s4882.o
10obj-$(CONFIG_I2C_AMD8111) += i2c-amd8111.o 10obj-$(CONFIG_I2C_AMD8111) += i2c-amd8111.o
11obj-$(CONFIG_I2C_AT91) += i2c-at91.o
11obj-$(CONFIG_I2C_AU1550) += i2c-au1550.o 12obj-$(CONFIG_I2C_AU1550) += i2c-au1550.o
12obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o 13obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o
13obj-$(CONFIG_I2C_HYDRA) += i2c-hydra.o 14obj-$(CONFIG_I2C_HYDRA) += i2c-hydra.o
@@ -16,7 +17,6 @@ obj-$(CONFIG_I2C_I810) += i2c-i810.o
16obj-$(CONFIG_I2C_IBM_IIC) += i2c-ibm_iic.o 17obj-$(CONFIG_I2C_IBM_IIC) += i2c-ibm_iic.o
17obj-$(CONFIG_I2C_IOP3XX) += i2c-iop3xx.o 18obj-$(CONFIG_I2C_IOP3XX) += i2c-iop3xx.o
18obj-$(CONFIG_I2C_ISA) += i2c-isa.o 19obj-$(CONFIG_I2C_ISA) += i2c-isa.o
19obj-$(CONFIG_I2C_ITE) += i2c-ite.o
20obj-$(CONFIG_I2C_IXP2000) += i2c-ixp2000.o 20obj-$(CONFIG_I2C_IXP2000) += i2c-ixp2000.o
21obj-$(CONFIG_I2C_IXP4XX) += i2c-ixp4xx.o 21obj-$(CONFIG_I2C_IXP4XX) += i2c-ixp4xx.o
22obj-$(CONFIG_I2C_POWERMAC) += i2c-powermac.o 22obj-$(CONFIG_I2C_POWERMAC) += i2c-powermac.o
@@ -29,6 +29,7 @@ obj-$(CONFIG_I2C_PARPORT) += i2c-parport.o
29obj-$(CONFIG_I2C_PARPORT_LIGHT) += i2c-parport-light.o 29obj-$(CONFIG_I2C_PARPORT_LIGHT) += i2c-parport-light.o
30obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o 30obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o
31obj-$(CONFIG_I2C_PIIX4) += i2c-piix4.o 31obj-$(CONFIG_I2C_PIIX4) += i2c-piix4.o
32obj-$(CONFIG_I2C_PNX) += i2c-pnx.o
32obj-$(CONFIG_I2C_PROSAVAGE) += i2c-prosavage.o 33obj-$(CONFIG_I2C_PROSAVAGE) += i2c-prosavage.o
33obj-$(CONFIG_I2C_PXA) += i2c-pxa.o 34obj-$(CONFIG_I2C_PXA) += i2c-pxa.o
34obj-$(CONFIG_I2C_RPXLITE) += i2c-rpx.o 35obj-$(CONFIG_I2C_RPXLITE) += i2c-rpx.o
@@ -39,6 +40,7 @@ obj-$(CONFIG_I2C_SIS5595) += i2c-sis5595.o
39obj-$(CONFIG_I2C_SIS630) += i2c-sis630.o 40obj-$(CONFIG_I2C_SIS630) += i2c-sis630.o
40obj-$(CONFIG_I2C_SIS96X) += i2c-sis96x.o 41obj-$(CONFIG_I2C_SIS96X) += i2c-sis96x.o
41obj-$(CONFIG_I2C_STUB) += i2c-stub.o 42obj-$(CONFIG_I2C_STUB) += i2c-stub.o
43obj-$(CONFIG_I2C_VERSATILE) += i2c-versatile.o
42obj-$(CONFIG_I2C_VIA) += i2c-via.o 44obj-$(CONFIG_I2C_VIA) += i2c-via.o
43obj-$(CONFIG_I2C_VIAPRO) += i2c-viapro.o 45obj-$(CONFIG_I2C_VIAPRO) += i2c-viapro.o
44obj-$(CONFIG_I2C_VOODOO3) += i2c-voodoo3.o 46obj-$(CONFIG_I2C_VOODOO3) += i2c-voodoo3.o
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
new file mode 100644
index 000000000000..67f91bdda089
--- /dev/null
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -0,0 +1,325 @@
1/*
2 i2c Support for Atmel's AT91 Two-Wire Interface (TWI)
3
4 Copyright (C) 2004 Rick Bronson
5 Converted to 2.6 by Andrew Victor <andrew@sanpeople.com>
6
7 Borrowed heavily from original work by:
8 Copyright (C) 2000 Philip Edelbrock <phil@stimpy.netroedge.com>
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14*/
15
16#include <linux/module.h>
17#include <linux/version.h>
18#include <linux/kernel.h>
19#include <linux/slab.h>
20#include <linux/pci.h>
21#include <linux/types.h>
22#include <linux/delay.h>
23#include <linux/i2c.h>
24#include <linux/init.h>
25#include <linux/clk.h>
26#include <linux/platform_device.h>
27
28#include <asm/io.h>
29
30#include <asm/arch/at91_twi.h>
31#include <asm/arch/board.h>
32#include <asm/arch/cpu.h>
33
34#define TWI_CLOCK 100000 /* Hz. max 400 Kbits/sec */
35
36
37static struct clk *twi_clk;
38static void __iomem *twi_base;
39
40#define at91_twi_read(reg) __raw_readl(twi_base + (reg))
41#define at91_twi_write(reg, val) __raw_writel((val), twi_base + (reg))
42
43
44/*
45 * Initialize the TWI hardware registers.
46 */
47static void __devinit at91_twi_hwinit(void)
48{
49 unsigned long cdiv, ckdiv;
50
51 at91_twi_write(AT91_TWI_IDR, 0xffffffff); /* Disable all interrupts */
52 at91_twi_write(AT91_TWI_CR, AT91_TWI_SWRST); /* Reset peripheral */
53 at91_twi_write(AT91_TWI_CR, AT91_TWI_MSEN); /* Set Master mode */
54
55 /* Calcuate clock dividers */
56 cdiv = (clk_get_rate(twi_clk) / (2 * TWI_CLOCK)) - 3;
57 cdiv = cdiv + 1; /* round up */
58 ckdiv = 0;
59 while (cdiv > 255) {
60 ckdiv++;
61 cdiv = cdiv >> 1;
62 }
63
64 if (cpu_is_at91rm9200()) { /* AT91RM9200 Errata #22 */
65 if (ckdiv > 5) {
66 printk(KERN_ERR "AT91 I2C: Invalid TWI_CLOCK value!\n");
67 ckdiv = 5;
68 }
69 }
70
71 at91_twi_write(AT91_TWI_CWGR, (ckdiv << 16) | (cdiv << 8) | cdiv);
72}
73
74/*
75 * Poll the i2c status register until the specified bit is set.
76 * Returns 0 if timed out (100 msec).
77 */
78static short at91_poll_status(unsigned long bit)
79{
80 int loop_cntr = 10000;
81
82 do {
83 udelay(10);
84 } while (!(at91_twi_read(AT91_TWI_SR) & bit) && (--loop_cntr > 0));
85
86 return (loop_cntr > 0);
87}
88
89static int xfer_read(struct i2c_adapter *adap, unsigned char *buf, int length)
90{
91 /* Send Start */
92 at91_twi_write(AT91_TWI_CR, AT91_TWI_START);
93
94 /* Read data */
95 while (length--) {
96 if (!length) /* need to send Stop before reading last byte */
97 at91_twi_write(AT91_TWI_CR, AT91_TWI_STOP);
98 if (!at91_poll_status(AT91_TWI_RXRDY)) {
99 dev_dbg(&adap->dev, "RXRDY timeout\n");
100 return -ETIMEDOUT;
101 }
102 *buf++ = (at91_twi_read(AT91_TWI_RHR) & 0xff);
103 }
104
105 return 0;
106}
107
108static int xfer_write(struct i2c_adapter *adap, unsigned char *buf, int length)
109{
110 /* Load first byte into transmitter */
111 at91_twi_write(AT91_TWI_THR, *buf++);
112
113 /* Send Start */
114 at91_twi_write(AT91_TWI_CR, AT91_TWI_START);
115
116 do {
117 if (!at91_poll_status(AT91_TWI_TXRDY)) {
118 dev_dbg(&adap->dev, "TXRDY timeout\n");
119 return -ETIMEDOUT;
120 }
121
122 length--; /* byte was transmitted */
123
124 if (length > 0) /* more data to send? */
125 at91_twi_write(AT91_TWI_THR, *buf++);
126 } while (length);
127
128 /* Send Stop */
129 at91_twi_write(AT91_TWI_CR, AT91_TWI_STOP);
130
131 return 0;
132}
133
134/*
135 * Generic i2c master transfer entrypoint.
136 *
137 * Note: We do not use Atmel's feature of storing the "internal device address".
138 * Instead the "internal device address" has to be written using a seperate
139 * i2c message.
140 * http://lists.arm.linux.org.uk/pipermail/linux-arm-kernel/2004-September/024411.html
141 */
142static int at91_xfer(struct i2c_adapter *adap, struct i2c_msg *pmsg, int num)
143{
144 int i, ret;
145
146 dev_dbg(&adap->dev, "at91_xfer: processing %d messages:\n", num);
147
148 for (i = 0; i < num; i++) {
149 dev_dbg(&adap->dev, " #%d: %sing %d byte%s %s 0x%02x\n", i,
150 pmsg->flags & I2C_M_RD ? "read" : "writ",
151 pmsg->len, pmsg->len > 1 ? "s" : "",
152 pmsg->flags & I2C_M_RD ? "from" : "to", pmsg->addr);
153
154 at91_twi_write(AT91_TWI_MMR, (pmsg->addr << 16)
155 | ((pmsg->flags & I2C_M_RD) ? AT91_TWI_MREAD : 0));
156
157 if (pmsg->len && pmsg->buf) { /* sanity check */
158 if (pmsg->flags & I2C_M_RD)
159 ret = xfer_read(adap, pmsg->buf, pmsg->len);
160 else
161 ret = xfer_write(adap, pmsg->buf, pmsg->len);
162
163 if (ret)
164 return ret;
165
166 /* Wait until transfer is finished */
167 if (!at91_poll_status(AT91_TWI_TXCOMP)) {
168 dev_dbg(&adap->dev, "TXCOMP timeout\n");
169 return -ETIMEDOUT;
170 }
171 }
172 dev_dbg(&adap->dev, "transfer complete\n");
173 pmsg++; /* next message */
174 }
175 return i;
176}
177
178/*
179 * Return list of supported functionality.
180 */
181static u32 at91_func(struct i2c_adapter *adapter)
182{
183 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
184}
185
186static struct i2c_algorithm at91_algorithm = {
187 .master_xfer = at91_xfer,
188 .functionality = at91_func,
189};
190
191/*
192 * Main initialization routine.
193 */
194static int __devinit at91_i2c_probe(struct platform_device *pdev)
195{
196 struct i2c_adapter *adapter;
197 struct resource *res;
198 int rc;
199
200 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
201 if (!res)
202 return -ENXIO;
203
204 if (!request_mem_region(res->start, res->end - res->start + 1, "at91_i2c"))
205 return -EBUSY;
206
207 twi_base = ioremap(res->start, res->end - res->start + 1);
208 if (!twi_base) {
209 rc = -ENOMEM;
210 goto fail0;
211 }
212
213 twi_clk = clk_get(NULL, "twi_clk");
214 if (IS_ERR(twi_clk)) {
215 dev_err(&pdev->dev, "no clock defined\n");
216 rc = -ENODEV;
217 goto fail1;
218 }
219
220 adapter = kzalloc(sizeof(struct i2c_adapter), GFP_KERNEL);
221 if (adapter == NULL) {
222 dev_err(&pdev->dev, "can't allocate inteface!\n");
223 rc = -ENOMEM;
224 goto fail2;
225 }
226 sprintf(adapter->name, "AT91");
227 adapter->algo = &at91_algorithm;
228 adapter->class = I2C_CLASS_HWMON;
229 adapter->dev.parent = &pdev->dev;
230
231 platform_set_drvdata(pdev, adapter);
232
233 clk_enable(twi_clk); /* enable peripheral clock */
234 at91_twi_hwinit(); /* initialize TWI controller */
235
236 rc = i2c_add_adapter(adapter);
237 if (rc) {
238 dev_err(&pdev->dev, "Adapter %s registration failed\n",
239 adapter->name);
240 goto fail3;
241 }
242
243 dev_info(&pdev->dev, "AT91 i2c bus driver.\n");
244 return 0;
245
246fail3:
247 platform_set_drvdata(pdev, NULL);
248 kfree(adapter);
249 clk_disable(twi_clk);
250fail2:
251 clk_put(twi_clk);
252fail1:
253 iounmap(twi_base);
254fail0:
255 release_mem_region(res->start, res->end - res->start + 1);
256
257 return rc;
258}
259
260static int __devexit at91_i2c_remove(struct platform_device *pdev)
261{
262 struct i2c_adapter *adapter = platform_get_drvdata(pdev);
263 struct resource *res;
264 int rc;
265
266 rc = i2c_del_adapter(adapter);
267 platform_set_drvdata(pdev, NULL);
268
269 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
270 iounmap(twi_base);
271 release_mem_region(res->start, res->end - res->start + 1);
272
273 clk_disable(twi_clk); /* disable peripheral clock */
274 clk_put(twi_clk);
275
276 return rc;
277}
278
279#ifdef CONFIG_PM
280
281/* NOTE: could save a few mA by keeping clock off outside of at91_xfer... */
282
283static int at91_i2c_suspend(struct platform_device *pdev, pm_message_t mesg)
284{
285 clk_disable(twi_clk);
286 return 0;
287}
288
289static int at91_i2c_resume(struct platform_device *pdev)
290{
291 return clk_enable(twi_clk);
292}
293
294#else
295#define at91_i2c_suspend NULL
296#define at91_i2c_resume NULL
297#endif
298
299static struct platform_driver at91_i2c_driver = {
300 .probe = at91_i2c_probe,
301 .remove = __devexit_p(at91_i2c_remove),
302 .suspend = at91_i2c_suspend,
303 .resume = at91_i2c_resume,
304 .driver = {
305 .name = "at91_i2c",
306 .owner = THIS_MODULE,
307 },
308};
309
310static int __init at91_i2c_init(void)
311{
312 return platform_driver_register(&at91_i2c_driver);
313}
314
315static void __exit at91_i2c_exit(void)
316{
317 platform_driver_unregister(&at91_i2c_driver);
318}
319
320module_init(at91_i2c_init);
321module_exit(at91_i2c_exit);
322
323MODULE_AUTHOR("Rick Bronson");
324MODULE_DESCRIPTION("I2C (TWI) driver for Atmel AT91");
325MODULE_LICENSE("GPL");
diff --git a/drivers/i2c/busses/i2c-elektor.c b/drivers/i2c/busses/i2c-elektor.c
index a591fe685f06..834967464814 100644
--- a/drivers/i2c/busses/i2c-elektor.c
+++ b/drivers/i2c/busses/i2c-elektor.c
@@ -293,7 +293,7 @@ static int __init i2c_pcfisa_init(void)
293 293
294static void i2c_pcfisa_exit(void) 294static void i2c_pcfisa_exit(void)
295{ 295{
296 i2c_pcf_del_bus(&pcf_isa_ops); 296 i2c_del_adapter(&pcf_isa_ops);
297 297
298 if (irq > 0) { 298 if (irq > 0) {
299 disable_irq(irq); 299 disable_irq(irq);
diff --git a/drivers/i2c/busses/i2c-hydra.c b/drivers/i2c/busses/i2c-hydra.c
index 457d48a0ab9d..9832f773651d 100644
--- a/drivers/i2c/busses/i2c-hydra.c
+++ b/drivers/i2c/busses/i2c-hydra.c
@@ -146,7 +146,7 @@ static int __devinit hydra_probe(struct pci_dev *dev,
146static void __devexit hydra_remove(struct pci_dev *dev) 146static void __devexit hydra_remove(struct pci_dev *dev)
147{ 147{
148 pdregw(hydra_bit_data.data, 0); /* clear SCLK_OE and SDAT_OE */ 148 pdregw(hydra_bit_data.data, 0); /* clear SCLK_OE and SDAT_OE */
149 i2c_bit_del_bus(&hydra_adap); 149 i2c_del_adapter(&hydra_adap);
150 iounmap(hydra_bit_data.data); 150 iounmap(hydra_bit_data.data);
151 release_mem_region(pci_resource_start(dev, 0)+ 151 release_mem_region(pci_resource_start(dev, 0)+
152 offsetof(struct Hydra, CachePD), 4); 152 offsetof(struct Hydra, CachePD), 4);
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index c7be2fdbd86b..ae625b854470 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -470,12 +470,20 @@ static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id
470 int err; 470 int err;
471 471
472 I801_dev = dev; 472 I801_dev = dev;
473 if ((dev->device == PCI_DEVICE_ID_INTEL_82801DB_3) || 473 switch (dev->device) {
474 (dev->device == PCI_DEVICE_ID_INTEL_82801EB_3) || 474 case PCI_DEVICE_ID_INTEL_82801DB_3:
475 (dev->device == PCI_DEVICE_ID_INTEL_ESB_4)) 475 case PCI_DEVICE_ID_INTEL_82801EB_3:
476 case PCI_DEVICE_ID_INTEL_ESB_4:
477 case PCI_DEVICE_ID_INTEL_ICH6_16:
478 case PCI_DEVICE_ID_INTEL_ICH7_17:
479 case PCI_DEVICE_ID_INTEL_ESB2_17:
480 case PCI_DEVICE_ID_INTEL_ICH8_5:
481 case PCI_DEVICE_ID_INTEL_ICH9_6:
476 isich4 = 1; 482 isich4 = 1;
477 else 483 break;
484 default:
478 isich4 = 0; 485 isich4 = 0;
486 }
479 487
480 err = pci_enable_device(dev); 488 err = pci_enable_device(dev);
481 if (err) { 489 if (err) {
diff --git a/drivers/i2c/busses/i2c-i810.c b/drivers/i2c/busses/i2c-i810.c
index b66fb6bb1870..10c98bc88aa6 100644
--- a/drivers/i2c/busses/i2c-i810.c
+++ b/drivers/i2c/busses/i2c-i810.c
@@ -219,14 +219,14 @@ static int __devinit i810_probe(struct pci_dev *dev, const struct pci_device_id
219 return retval; 219 return retval;
220 retval = i2c_bit_add_bus(&i810_ddc_adapter); 220 retval = i2c_bit_add_bus(&i810_ddc_adapter);
221 if (retval) 221 if (retval)
222 i2c_bit_del_bus(&i810_i2c_adapter); 222 i2c_del_adapter(&i810_i2c_adapter);
223 return retval; 223 return retval;
224} 224}
225 225
226static void __devexit i810_remove(struct pci_dev *dev) 226static void __devexit i810_remove(struct pci_dev *dev)
227{ 227{
228 i2c_bit_del_bus(&i810_ddc_adapter); 228 i2c_del_adapter(&i810_ddc_adapter);
229 i2c_bit_del_bus(&i810_i2c_adapter); 229 i2c_del_adapter(&i810_i2c_adapter);
230 iounmap(ioaddr); 230 iounmap(ioaddr);
231} 231}
232 232
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
index 781a99c1647a..1898e9987021 100644
--- a/drivers/i2c/busses/i2c-ibm_iic.c
+++ b/drivers/i2c/busses/i2c-ibm_iic.c
@@ -680,6 +680,12 @@ static int __devinit iic_probe(struct ocp_device *ocp){
680 dev->idx = ocp->def->index; 680 dev->idx = ocp->def->index;
681 ocp_set_drvdata(ocp, dev); 681 ocp_set_drvdata(ocp, dev);
682 682
683 if (!request_mem_region(ocp->def->paddr, sizeof(struct iic_regs),
684 "ibm_iic")) {
685 ret = -EBUSY;
686 goto fail1;
687 }
688
683 if (!(dev->vaddr = ioremap(ocp->def->paddr, sizeof(struct iic_regs)))){ 689 if (!(dev->vaddr = ioremap(ocp->def->paddr, sizeof(struct iic_regs)))){
684 printk(KERN_CRIT "ibm-iic%d: failed to ioremap device registers\n", 690 printk(KERN_CRIT "ibm-iic%d: failed to ioremap device registers\n",
685 dev->idx); 691 dev->idx);
@@ -750,6 +756,8 @@ fail:
750 756
751 iounmap(dev->vaddr); 757 iounmap(dev->vaddr);
752fail2: 758fail2:
759 release_mem_region(ocp->def->paddr, sizeof(struct iic_regs));
760fail1:
753 ocp_set_drvdata(ocp, NULL); 761 ocp_set_drvdata(ocp, NULL);
754 kfree(dev); 762 kfree(dev);
755 return ret; 763 return ret;
@@ -777,6 +785,7 @@ static void __devexit iic_remove(struct ocp_device *ocp)
777 free_irq(dev->irq, dev); 785 free_irq(dev->irq, dev);
778 } 786 }
779 iounmap(dev->vaddr); 787 iounmap(dev->vaddr);
788 release_mem_region(ocp->def->paddr, sizeof(struct iic_regs));
780 kfree(dev); 789 kfree(dev);
781 } 790 }
782} 791}
diff --git a/drivers/i2c/busses/i2c-ite.c b/drivers/i2c/busses/i2c-ite.c
deleted file mode 100644
index f7d71869b3b9..000000000000
--- a/drivers/i2c/busses/i2c-ite.c
+++ /dev/null
@@ -1,278 +0,0 @@
1/*
2 -------------------------------------------------------------------------
3 i2c-adap-ite.c i2c-hw access for the IIC peripheral on the ITE MIPS system
4 -------------------------------------------------------------------------
5 Hai-Pao Fan, MontaVista Software, Inc.
6 hpfan@mvista.com or source@mvista.com
7
8 Copyright 2001 MontaVista Software Inc.
9
10 ----------------------------------------------------------------------------
11 This file was highly leveraged from i2c-elektor.c, which was created
12 by Simon G. Vogl and Hans Berglund:
13
14
15 Copyright (C) 1995-97 Simon G. Vogl
16 1998-99 Hans Berglund
17
18 This program is free software; you can redistribute it and/or modify
19 it under the terms of the GNU General Public License as published by
20 the Free Software Foundation; either version 2 of the License, or
21 (at your option) any later version.
22
23 This program is distributed in the hope that it will be useful,
24 but WITHOUT ANY WARRANTY; without even the implied warranty of
25 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 GNU General Public License for more details.
27
28 You should have received a copy of the GNU General Public License
29 along with this program; if not, write to the Free Software
30 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
31/* ------------------------------------------------------------------------- */
32
33/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
34 Frodo Looijaard <frodol@dds.nl> */
35
36#include <linux/kernel.h>
37#include <linux/ioport.h>
38#include <linux/module.h>
39#include <linux/delay.h>
40#include <linux/slab.h>
41#include <linux/init.h>
42#include <linux/wait.h>
43#include <asm/irq.h>
44#include <asm/io.h>
45
46#include <linux/i2c.h>
47#include <linux/i2c-algo-ite.h>
48#include <linux/i2c-adap-ite.h>
49#include "../i2c-ite.h"
50
51#define DEFAULT_BASE 0x14014030
52#define ITE_IIC_IO_SIZE 0x40
53#define DEFAULT_IRQ 0
54#define DEFAULT_CLOCK 0x1b0e /* default 16MHz/(27+14) = 400KHz */
55#define DEFAULT_OWN 0x55
56
57static int base;
58static int irq;
59static int clock;
60static int own;
61
62static struct iic_ite gpi;
63static wait_queue_head_t iic_wait;
64static int iic_pending;
65static spinlock_t lock;
66
67/* ----- local functions ---------------------------------------------- */
68
69static void iic_ite_setiic(void *data, int ctl, short val)
70{
71 unsigned long j = jiffies + 10;
72
73 pr_debug(" Write 0x%02x to 0x%x\n",(unsigned short)val, ctl&0xff);
74#ifdef DEBUG
75 while (time_before(jiffies, j))
76 schedule();
77#endif
78 outw(val,ctl);
79}
80
81static short iic_ite_getiic(void *data, int ctl)
82{
83 short val;
84
85 val = inw(ctl);
86 pr_debug("Read 0x%02x from 0x%x\n",(unsigned short)val, ctl&0xff);
87 return (val);
88}
89
90/* Return our slave address. This is the address
91 * put on the I2C bus when another master on the bus wants to address us
92 * as a slave
93 */
94static int iic_ite_getown(void *data)
95{
96 return (gpi.iic_own);
97}
98
99
100static int iic_ite_getclock(void *data)
101{
102 return (gpi.iic_clock);
103}
104
105
106/* Put this process to sleep. We will wake up when the
107 * IIC controller interrupts.
108 */
109static void iic_ite_waitforpin(void) {
110 DEFINE_WAIT(wait);
111 int timeout = 2;
112 unsigned long flags;
113
114 /* If interrupts are enabled (which they are), then put the process to
115 * sleep. This process will be awakened by two events -- either the
116 * the IIC peripheral interrupts or the timeout expires.
117 * If interrupts are not enabled then delay for a reasonable amount
118 * of time and return.
119 */
120 if (gpi.iic_irq > 0) {
121 spin_lock_irqsave(&lock, flags);
122 if (iic_pending == 0) {
123 spin_unlock_irqrestore(&lock, flags);
124 prepare_to_wait(&iic_wait, &wait, TASK_INTERRUPTIBLE);
125 if (schedule_timeout(timeout*HZ)) {
126 spin_lock_irqsave(&lock, flags);
127 if (iic_pending == 1) {
128 iic_pending = 0;
129 }
130 spin_unlock_irqrestore(&lock, flags);
131 }
132 finish_wait(&iic_wait, &wait);
133 } else {
134 iic_pending = 0;
135 spin_unlock_irqrestore(&lock, flags);
136 }
137 } else {
138 udelay(100);
139 }
140}
141
142
143static irqreturn_t iic_ite_handler(int this_irq, void *dev_id)
144{
145 spin_lock(&lock);
146 iic_pending = 1;
147 spin_unlock(&lock);
148
149 wake_up_interruptible(&iic_wait);
150
151 return IRQ_HANDLED;
152}
153
154
155/* Lock the region of memory where I/O registers exist. Request our
156 * interrupt line and register its associated handler.
157 */
158static int iic_hw_resrc_init(void)
159{
160 if (!request_region(gpi.iic_base, ITE_IIC_IO_SIZE, "i2c"))
161 return -ENODEV;
162
163 if (gpi.iic_irq <= 0)
164 return 0;
165
166 if (request_irq(gpi.iic_irq, iic_ite_handler, 0, "ITE IIC", 0) < 0)
167 gpi.iic_irq = 0;
168 else
169 enable_irq(gpi.iic_irq);
170
171 return 0;
172}
173
174
175static void iic_ite_release(void)
176{
177 if (gpi.iic_irq > 0) {
178 disable_irq(gpi.iic_irq);
179 free_irq(gpi.iic_irq, 0);
180 }
181 release_region(gpi.iic_base , 2);
182}
183
184/* ------------------------------------------------------------------------
185 * Encapsulate the above functions in the correct operations structure.
186 * This is only done when more than one hardware adapter is supported.
187 */
188static struct i2c_algo_iic_data iic_ite_data = {
189 NULL,
190 iic_ite_setiic,
191 iic_ite_getiic,
192 iic_ite_getown,
193 iic_ite_getclock,
194 iic_ite_waitforpin,
195 80, 80, 100, /* waits, timeout */
196};
197
198static struct i2c_adapter iic_ite_ops = {
199 .owner = THIS_MODULE,
200 .id = I2C_HW_I_IIC,
201 .algo_data = &iic_ite_data,
202 .name = "ITE IIC adapter",
203};
204
205/* Called when the module is loaded. This function starts the
206 * cascade of calls up through the hierarchy of i2c modules (i.e. up to the
207 * algorithm layer and into to the core layer)
208 */
209static int __init iic_ite_init(void)
210{
211
212 struct iic_ite *piic = &gpi;
213
214 printk(KERN_INFO "Initialize ITE IIC adapter module\n");
215 if (base == 0)
216 piic->iic_base = DEFAULT_BASE;
217 else
218 piic->iic_base = base;
219
220 if (irq == 0)
221 piic->iic_irq = DEFAULT_IRQ;
222 else
223 piic->iic_irq = irq;
224
225 if (clock == 0)
226 piic->iic_clock = DEFAULT_CLOCK;
227 else
228 piic->iic_clock = clock;
229
230 if (own == 0)
231 piic->iic_own = DEFAULT_OWN;
232 else
233 piic->iic_own = own;
234
235 iic_ite_data.data = (void *)piic;
236 init_waitqueue_head(&iic_wait);
237 spin_lock_init(&lock);
238 if (iic_hw_resrc_init() == 0) {
239 if (i2c_iic_add_bus(&iic_ite_ops) < 0)
240 return -ENODEV;
241 } else {
242 return -ENODEV;
243 }
244 printk(KERN_INFO " found device at %#x irq %d.\n",
245 piic->iic_base, piic->iic_irq);
246 return 0;
247}
248
249
250static void iic_ite_exit(void)
251{
252 i2c_iic_del_bus(&iic_ite_ops);
253 iic_ite_release();
254}
255
256/* If modules is NOT defined when this file is compiled, then the MODULE_*
257 * macros will resolve to nothing
258 */
259MODULE_AUTHOR("MontaVista Software <www.mvista.com>");
260MODULE_DESCRIPTION("I2C-Bus adapter routines for ITE IIC bus adapter");
261MODULE_LICENSE("GPL");
262
263module_param(base, int, 0);
264module_param(irq, int, 0);
265module_param(clock, int, 0);
266module_param(own, int, 0);
267
268
269/* Called when module is loaded or when kernel is initialized.
270 * If MODULES is defined when this file is compiled, then this function will
271 * resolve to init_module (the function called when insmod is invoked for a
272 * module). Otherwise, this function is called early in the boot, when the
273 * kernel is intialized. Check out /include/init.h to see how this works.
274 */
275module_init(iic_ite_init);
276
277/* Resolves to module_cleanup when MODULES is defined. */
278module_exit(iic_ite_exit);
diff --git a/drivers/i2c/busses/i2c-ixp2000.c b/drivers/i2c/busses/i2c-ixp2000.c
index dd3f4cd3aa68..efa3ecc5522a 100644
--- a/drivers/i2c/busses/i2c-ixp2000.c
+++ b/drivers/i2c/busses/i2c-ixp2000.c
@@ -90,7 +90,7 @@ static int ixp2000_i2c_remove(struct platform_device *plat_dev)
90 90
91 platform_set_drvdata(plat_dev, NULL); 91 platform_set_drvdata(plat_dev, NULL);
92 92
93 i2c_bit_del_bus(&drv_data->adapter); 93 i2c_del_adapter(&drv_data->adapter);
94 94
95 kfree(drv_data); 95 kfree(drv_data);
96 96
diff --git a/drivers/i2c/busses/i2c-ixp4xx.c b/drivers/i2c/busses/i2c-ixp4xx.c
index 68fe863f9d54..08e89b83984a 100644
--- a/drivers/i2c/busses/i2c-ixp4xx.c
+++ b/drivers/i2c/busses/i2c-ixp4xx.c
@@ -91,7 +91,7 @@ static int ixp4xx_i2c_remove(struct platform_device *plat_dev)
91 91
92 platform_set_drvdata(plat_dev, NULL); 92 platform_set_drvdata(plat_dev, NULL);
93 93
94 i2c_bit_del_bus(&drv_data->adapter); 94 i2c_del_adapter(&drv_data->adapter);
95 95
96 kfree(drv_data); 96 kfree(drv_data);
97 97
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
index e0292e414ab2..ad37c10e7fec 100644
--- a/drivers/i2c/busses/i2c-nforce2.c
+++ b/drivers/i2c/busses/i2c-nforce2.c
@@ -35,7 +35,7 @@
35 nForce4 MCP55 0368 35 nForce4 MCP55 0368
36 36
37 This driver supports the 2 SMBuses that are included in the MCP of the 37 This driver supports the 2 SMBuses that are included in the MCP of the
38 nForce2/3/4 chipsets. 38 nForce2/3/4/5xx chipsets.
39*/ 39*/
40 40
41/* Note: we assume there can only be one nForce2, with two SMBus interfaces */ 41/* Note: we assume there can only be one nForce2, with two SMBus interfaces */
@@ -52,8 +52,8 @@
52#include <asm/io.h> 52#include <asm/io.h>
53 53
54MODULE_LICENSE("GPL"); 54MODULE_LICENSE("GPL");
55MODULE_AUTHOR ("Hans-Frieder Vogt <hfvogt@arcor.de>"); 55MODULE_AUTHOR ("Hans-Frieder Vogt <hfvogt@gmx.net>");
56MODULE_DESCRIPTION("nForce2 SMBus driver"); 56MODULE_DESCRIPTION("nForce2/3/4/5xx SMBus driver");
57 57
58 58
59struct nforce2_smbus { 59struct nforce2_smbus {
@@ -80,9 +80,6 @@ struct nforce2_smbus {
80#define NVIDIA_SMB_ADDR (smbus->base + 0x02) /* address */ 80#define NVIDIA_SMB_ADDR (smbus->base + 0x02) /* address */
81#define NVIDIA_SMB_CMD (smbus->base + 0x03) /* command */ 81#define NVIDIA_SMB_CMD (smbus->base + 0x03) /* command */
82#define NVIDIA_SMB_DATA (smbus->base + 0x04) /* 32 data registers */ 82#define NVIDIA_SMB_DATA (smbus->base + 0x04) /* 32 data registers */
83#define NVIDIA_SMB_BCNT (smbus->base + 0x24) /* number of data bytes */
84#define NVIDIA_SMB_ALRM_A (smbus->base + 0x25) /* alarm address */
85#define NVIDIA_SMB_ALRM_D (smbus->base + 0x26) /* 2 bytes alarm data */
86 83
87#define NVIDIA_SMB_STS_DONE 0x80 84#define NVIDIA_SMB_STS_DONE 0x80
88#define NVIDIA_SMB_STS_ALRM 0x40 85#define NVIDIA_SMB_STS_ALRM 0x40
@@ -95,40 +92,17 @@ struct nforce2_smbus {
95#define NVIDIA_SMB_PRTCL_BYTE 0x04 92#define NVIDIA_SMB_PRTCL_BYTE 0x04
96#define NVIDIA_SMB_PRTCL_BYTE_DATA 0x06 93#define NVIDIA_SMB_PRTCL_BYTE_DATA 0x06
97#define NVIDIA_SMB_PRTCL_WORD_DATA 0x08 94#define NVIDIA_SMB_PRTCL_WORD_DATA 0x08
98#define NVIDIA_SMB_PRTCL_BLOCK_DATA 0x0a
99#define NVIDIA_SMB_PRTCL_PROC_CALL 0x0c
100#define NVIDIA_SMB_PRTCL_BLOCK_PROC_CALL 0x0d
101#define NVIDIA_SMB_PRTCL_I2C_BLOCK_DATA 0x4a
102#define NVIDIA_SMB_PRTCL_PEC 0x80 95#define NVIDIA_SMB_PRTCL_PEC 0x80
103 96
104static struct pci_driver nforce2_driver; 97static struct pci_driver nforce2_driver;
105 98
106static s32 nforce2_access(struct i2c_adapter *adap, u16 addr, 99/* Return -1 on error */
107 unsigned short flags, char read_write,
108 u8 command, int size, union i2c_smbus_data *data);
109static u32 nforce2_func(struct i2c_adapter *adapter);
110
111
112static const struct i2c_algorithm smbus_algorithm = {
113 .smbus_xfer = nforce2_access,
114 .functionality = nforce2_func,
115};
116
117static struct i2c_adapter nforce2_adapter = {
118 .owner = THIS_MODULE,
119 .class = I2C_CLASS_HWMON,
120 .algo = &smbus_algorithm,
121};
122
123/* Return -1 on error. See smbus.h for more information */
124static s32 nforce2_access(struct i2c_adapter * adap, u16 addr, 100static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
125 unsigned short flags, char read_write, 101 unsigned short flags, char read_write,
126 u8 command, int size, union i2c_smbus_data * data) 102 u8 command, int size, union i2c_smbus_data * data)
127{ 103{
128 struct nforce2_smbus *smbus = adap->algo_data; 104 struct nforce2_smbus *smbus = adap->algo_data;
129 unsigned char protocol, pec, temp; 105 unsigned char protocol, pec, temp;
130 unsigned char len = 0; /* to keep the compiler quiet */
131 int i;
132 106
133 protocol = (read_write == I2C_SMBUS_READ) ? NVIDIA_SMB_PRTCL_READ : 107 protocol = (read_write == I2C_SMBUS_READ) ? NVIDIA_SMB_PRTCL_READ :
134 NVIDIA_SMB_PRTCL_WRITE; 108 NVIDIA_SMB_PRTCL_WRITE;
@@ -163,35 +137,6 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
163 protocol |= NVIDIA_SMB_PRTCL_WORD_DATA | pec; 137 protocol |= NVIDIA_SMB_PRTCL_WORD_DATA | pec;
164 break; 138 break;
165 139
166 case I2C_SMBUS_BLOCK_DATA:
167 outb_p(command, NVIDIA_SMB_CMD);
168 if (read_write == I2C_SMBUS_WRITE) {
169 len = min_t(u8, data->block[0], 32);
170 outb_p(len, NVIDIA_SMB_BCNT);
171 for (i = 0; i < len; i++)
172 outb_p(data->block[i + 1], NVIDIA_SMB_DATA+i);
173 }
174 protocol |= NVIDIA_SMB_PRTCL_BLOCK_DATA | pec;
175 break;
176
177 case I2C_SMBUS_I2C_BLOCK_DATA:
178 len = min_t(u8, data->block[0], 32);
179 outb_p(command, NVIDIA_SMB_CMD);
180 outb_p(len, NVIDIA_SMB_BCNT);
181 if (read_write == I2C_SMBUS_WRITE)
182 for (i = 0; i < len; i++)
183 outb_p(data->block[i + 1], NVIDIA_SMB_DATA+i);
184 protocol |= NVIDIA_SMB_PRTCL_I2C_BLOCK_DATA;
185 break;
186
187 case I2C_SMBUS_PROC_CALL:
188 dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
189 return -1;
190
191 case I2C_SMBUS_BLOCK_PROC_CALL:
192 dev_err(&adap->dev, "I2C_SMBUS_BLOCK_PROC_CALL not supported!\n");
193 return -1;
194
195 default: 140 default:
196 dev_err(&adap->dev, "Unsupported transaction %d\n", size); 141 dev_err(&adap->dev, "Unsupported transaction %d\n", size);
197 return -1; 142 return -1;
@@ -227,19 +172,8 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
227 break; 172 break;
228 173
229 case I2C_SMBUS_WORD_DATA: 174 case I2C_SMBUS_WORD_DATA:
230 /* case I2C_SMBUS_PROC_CALL: not supported */
231 data->word = inb_p(NVIDIA_SMB_DATA) | (inb_p(NVIDIA_SMB_DATA+1) << 8); 175 data->word = inb_p(NVIDIA_SMB_DATA) | (inb_p(NVIDIA_SMB_DATA+1) << 8);
232 break; 176 break;
233
234 case I2C_SMBUS_BLOCK_DATA:
235 /* case I2C_SMBUS_BLOCK_PROC_CALL: not supported */
236 len = inb_p(NVIDIA_SMB_BCNT);
237 len = min_t(u8, len, 32);
238 case I2C_SMBUS_I2C_BLOCK_DATA:
239 for (i = 0; i < len; i++)
240 data->block[i+1] = inb_p(NVIDIA_SMB_DATA + i);
241 data->block[0] = len;
242 break;
243 } 177 }
244 178
245 return 0; 179 return 0;
@@ -250,10 +184,14 @@ static u32 nforce2_func(struct i2c_adapter *adapter)
250{ 184{
251 /* other functionality might be possible, but is not tested */ 185 /* other functionality might be possible, but is not tested */
252 return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | 186 return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
253 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA /* | 187 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA;
254 I2C_FUNC_SMBUS_BLOCK_DATA */;
255} 188}
256 189
190static struct i2c_algorithm smbus_algorithm = {
191 .smbus_xfer = nforce2_access,
192 .functionality = nforce2_func,
193};
194
257 195
258static struct pci_device_id nforce2_ids[] = { 196static struct pci_device_id nforce2_ids[] = {
259 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS) }, 197 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS) },
@@ -267,7 +205,6 @@ static struct pci_device_id nforce2_ids[] = {
267 { 0 } 205 { 0 }
268}; 206};
269 207
270
271MODULE_DEVICE_TABLE (pci, nforce2_ids); 208MODULE_DEVICE_TABLE (pci, nforce2_ids);
272 209
273 210
@@ -291,7 +228,7 @@ static int __devinit nforce2_probe_smb (struct pci_dev *dev, int bar,
291 } 228 }
292 229
293 smbus->base = iobase & PCI_BASE_ADDRESS_IO_MASK; 230 smbus->base = iobase & PCI_BASE_ADDRESS_IO_MASK;
294 smbus->size = 8; 231 smbus->size = 64;
295 } 232 }
296 smbus->dev = dev; 233 smbus->dev = dev;
297 234
@@ -300,7 +237,9 @@ static int __devinit nforce2_probe_smb (struct pci_dev *dev, int bar,
300 smbus->base, smbus->base+smbus->size-1, name); 237 smbus->base, smbus->base+smbus->size-1, name);
301 return -1; 238 return -1;
302 } 239 }
303 smbus->adapter = nforce2_adapter; 240 smbus->adapter.owner = THIS_MODULE;
241 smbus->adapter.class = I2C_CLASS_HWMON;
242 smbus->adapter.algo = &smbus_algorithm;
304 smbus->adapter.algo_data = smbus; 243 smbus->adapter.algo_data = smbus;
305 smbus->adapter.dev.parent = &dev->dev; 244 smbus->adapter.dev.parent = &dev->dev;
306 snprintf(smbus->adapter.name, I2C_NAME_SIZE, 245 snprintf(smbus->adapter.name, I2C_NAME_SIZE,
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index dec04da0455c..bcd8367cede1 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -231,8 +231,8 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
231 * 13 2 1 231 * 13 2 1
232 * 19.2 2 1 232 * 19.2 2 1
233 */ 233 */
234 if (fclk_rate > 16000000) 234 if (fclk_rate > 12000000)
235 psc = (fclk_rate + 8000000) / 12000000; 235 psc = fclk_rate / 12000000;
236 } 236 }
237 237
238 /* Setup clock prescaler to obtain approx 12MHz I2C module clock: */ 238 /* Setup clock prescaler to obtain approx 12MHz I2C module clock: */
diff --git a/drivers/i2c/busses/i2c-parport-light.c b/drivers/i2c/busses/i2c-parport-light.c
index 5eb2bd294fd9..4bc42810b9aa 100644
--- a/drivers/i2c/busses/i2c-parport-light.c
+++ b/drivers/i2c/busses/i2c-parport-light.c
@@ -163,7 +163,7 @@ static void __exit i2c_parport_exit(void)
163 if (adapter_parm[type].init.val) 163 if (adapter_parm[type].init.val)
164 line_set(0, &adapter_parm[type].init); 164 line_set(0, &adapter_parm[type].init);
165 165
166 i2c_bit_del_bus(&parport_adapter); 166 i2c_del_adapter(&parport_adapter);
167 release_region(base, 3); 167 release_region(base, 3);
168} 168}
169 169
diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c
index 48a829431c7b..66696a40c7b5 100644
--- a/drivers/i2c/busses/i2c-parport.c
+++ b/drivers/i2c/busses/i2c-parport.c
@@ -218,7 +218,7 @@ static void i2c_parport_detach (struct parport *port)
218 if (adapter_parm[type].init.val) 218 if (adapter_parm[type].init.val)
219 line_set(port, 0, &adapter_parm[type].init); 219 line_set(port, 0, &adapter_parm[type].init);
220 220
221 i2c_bit_del_bus(&adapter->adapter); 221 i2c_del_adapter(&adapter->adapter);
222 parport_unregister_device(adapter->pdev); 222 parport_unregister_device(adapter->pdev);
223 if (prev) 223 if (prev)
224 prev->next = adapter->next; 224 prev->next = adapter->next;
diff --git a/drivers/i2c/busses/i2c-pca-isa.c b/drivers/i2c/busses/i2c-pca-isa.c
index 407840b6a260..cc6536a19eca 100644
--- a/drivers/i2c/busses/i2c-pca-isa.c
+++ b/drivers/i2c/busses/i2c-pca-isa.c
@@ -156,7 +156,7 @@ static int __init pca_isa_init(void)
156 156
157static void pca_isa_exit(void) 157static void pca_isa_exit(void)
158{ 158{
159 i2c_pca_del_bus(&pca_isa_ops); 159 i2c_del_adapter(&pca_isa_ops);
160 160
161 if (irq > 0) { 161 if (irq > 0) {
162 disable_irq(irq); 162 disable_irq(irq);
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c
new file mode 100644
index 000000000000..de0bca77e926
--- /dev/null
+++ b/drivers/i2c/busses/i2c-pnx.c
@@ -0,0 +1,708 @@
1/*
2 * Provides I2C support for Philips PNX010x/PNX4008 boards.
3 *
4 * Authors: Dennis Kovalev <dkovalev@ru.mvista.com>
5 * Vitaly Wool <vwool@ru.mvista.com>
6 *
7 * 2004-2006 (c) MontaVista Software, Inc. This file is licensed under
8 * the terms of the GNU General Public License version 2. This program
9 * is licensed "as is" without any warranty of any kind, whether express
10 * or implied.
11 */
12
13#include <linux/module.h>
14#include <linux/interrupt.h>
15#include <linux/ioport.h>
16#include <linux/delay.h>
17#include <linux/i2c.h>
18#include <linux/timer.h>
19#include <linux/completion.h>
20#include <linux/platform_device.h>
21#include <linux/i2c-pnx.h>
22#include <asm/hardware.h>
23#include <asm/irq.h>
24#include <asm/uaccess.h>
25
26#define I2C_PNX_TIMEOUT 10 /* msec */
27#define I2C_PNX_SPEED_KHZ 100
28#define I2C_PNX_REGION_SIZE 0x100
29#define PNX_DEFAULT_FREQ 13 /* MHz */
30
31static inline int wait_timeout(long timeout, struct i2c_pnx_algo_data *data)
32{
33 while (timeout > 0 &&
34 (ioread32(I2C_REG_STS(data)) & mstatus_active)) {
35 mdelay(1);
36 timeout--;
37 }
38 return (timeout <= 0);
39}
40
41static inline int wait_reset(long timeout, struct i2c_pnx_algo_data *data)
42{
43 while (timeout > 0 &&
44 (ioread32(I2C_REG_CTL(data)) & mcntrl_reset)) {
45 mdelay(1);
46 timeout--;
47 }
48 return (timeout <= 0);
49}
50
51static inline void i2c_pnx_arm_timer(struct i2c_adapter *adap)
52{
53 struct i2c_pnx_algo_data *data = adap->algo_data;
54 struct timer_list *timer = &data->mif.timer;
55 int expires = I2C_PNX_TIMEOUT / (1000 / HZ);
56
57 del_timer_sync(timer);
58
59 dev_dbg(&adap->dev, "Timer armed at %lu plus %u jiffies.\n",
60 jiffies, expires);
61
62 timer->expires = jiffies + expires;
63 timer->data = (unsigned long)adap;
64
65 add_timer(timer);
66}
67
68/**
69 * i2c_pnx_start - start a device
70 * @slave_addr: slave address
71 * @adap: pointer to adapter structure
72 *
73 * Generate a START signal in the desired mode.
74 */
75static int i2c_pnx_start(unsigned char slave_addr, struct i2c_adapter *adap)
76{
77 struct i2c_pnx_algo_data *alg_data = adap->algo_data;
78
79 dev_dbg(&adap->dev, "%s(): addr 0x%x mode %d\n", __FUNCTION__,
80 slave_addr, alg_data->mif.mode);
81
82 /* Check for 7 bit slave addresses only */
83 if (slave_addr & ~0x7f) {
84 dev_err(&adap->dev, "%s: Invalid slave address %x. "
85 "Only 7-bit addresses are supported\n",
86 adap->name, slave_addr);
87 return -EINVAL;
88 }
89
90 /* First, make sure bus is idle */
91 if (wait_timeout(I2C_PNX_TIMEOUT, alg_data)) {
92 /* Somebody else is monopolizing the bus */
93 dev_err(&adap->dev, "%s: Bus busy. Slave addr = %02x, "
94 "cntrl = %x, stat = %x\n",
95 adap->name, slave_addr,
96 ioread32(I2C_REG_CTL(alg_data)),
97 ioread32(I2C_REG_STS(alg_data)));
98 return -EBUSY;
99 } else if (ioread32(I2C_REG_STS(alg_data)) & mstatus_afi) {
100 /* Sorry, we lost the bus */
101 dev_err(&adap->dev, "%s: Arbitration failure. "
102 "Slave addr = %02x\n", adap->name, slave_addr);
103 return -EIO;
104 }
105
106 /*
107 * OK, I2C is enabled and we have the bus.
108 * Clear the current TDI and AFI status flags.
109 */
110 iowrite32(ioread32(I2C_REG_STS(alg_data)) | mstatus_tdi | mstatus_afi,
111 I2C_REG_STS(alg_data));
112
113 dev_dbg(&adap->dev, "%s(): sending %#x\n", __FUNCTION__,
114 (slave_addr << 1) | start_bit | alg_data->mif.mode);
115
116 /* Write the slave address, START bit and R/W bit */
117 iowrite32((slave_addr << 1) | start_bit | alg_data->mif.mode,
118 I2C_REG_TX(alg_data));
119
120 dev_dbg(&adap->dev, "%s(): exit\n", __FUNCTION__);
121
122 return 0;
123}
124
125/**
126 * i2c_pnx_stop - stop a device
127 * @adap: pointer to I2C adapter structure
128 *
129 * Generate a STOP signal to terminate the master transaction.
130 */
131static void i2c_pnx_stop(struct i2c_adapter *adap)
132{
133 struct i2c_pnx_algo_data *alg_data = adap->algo_data;
134 /* Only 1 msec max timeout due to interrupt context */
135 long timeout = 1000;
136
137 dev_dbg(&adap->dev, "%s(): entering: stat = %04x.\n",
138 __FUNCTION__, ioread32(I2C_REG_STS(alg_data)));
139
140 /* Write a STOP bit to TX FIFO */
141 iowrite32(0xff | stop_bit, I2C_REG_TX(alg_data));
142
143 /* Wait until the STOP is seen. */
144 while (timeout > 0 &&
145 (ioread32(I2C_REG_STS(alg_data)) & mstatus_active)) {
146 /* may be called from interrupt context */
147 udelay(1);
148 timeout--;
149 }
150
151 dev_dbg(&adap->dev, "%s(): exiting: stat = %04x.\n",
152 __FUNCTION__, ioread32(I2C_REG_STS(alg_data)));
153}
154
155/**
156 * i2c_pnx_master_xmit - transmit data to slave
157 * @adap: pointer to I2C adapter structure
158 *
159 * Sends one byte of data to the slave
160 */
161static int i2c_pnx_master_xmit(struct i2c_adapter *adap)
162{
163 struct i2c_pnx_algo_data *alg_data = adap->algo_data;
164 u32 val;
165
166 dev_dbg(&adap->dev, "%s(): entering: stat = %04x.\n",
167 __FUNCTION__, ioread32(I2C_REG_STS(alg_data)));
168
169 if (alg_data->mif.len > 0) {
170 /* We still have something to talk about... */
171 val = *alg_data->mif.buf++;
172
173 if (alg_data->mif.len == 1) {
174 val |= stop_bit;
175 if (!alg_data->last)
176 val |= start_bit;
177 }
178
179 alg_data->mif.len--;
180 iowrite32(val, I2C_REG_TX(alg_data));
181
182 dev_dbg(&adap->dev, "%s(): xmit %#x [%d]\n", __FUNCTION__,
183 val, alg_data->mif.len + 1);
184
185 if (alg_data->mif.len == 0) {
186 if (alg_data->last) {
187 /* Wait until the STOP is seen. */
188 if (wait_timeout(I2C_PNX_TIMEOUT, alg_data))
189 dev_err(&adap->dev, "The bus is still "
190 "active after timeout\n");
191 }
192 /* Disable master interrupts */
193 iowrite32(ioread32(I2C_REG_CTL(alg_data)) &
194 ~(mcntrl_afie | mcntrl_naie | mcntrl_drmie),
195 I2C_REG_CTL(alg_data));
196
197 del_timer_sync(&alg_data->mif.timer);
198
199 dev_dbg(&adap->dev, "%s(): Waking up xfer routine.\n",
200 __FUNCTION__);
201
202 complete(&alg_data->mif.complete);
203 }
204 } else if (alg_data->mif.len == 0) {
205 /* zero-sized transfer */
206 i2c_pnx_stop(adap);
207
208 /* Disable master interrupts. */
209 iowrite32(ioread32(I2C_REG_CTL(alg_data)) &
210 ~(mcntrl_afie | mcntrl_naie | mcntrl_drmie),
211 I2C_REG_CTL(alg_data));
212
213 /* Stop timer. */
214 del_timer_sync(&alg_data->mif.timer);
215 dev_dbg(&adap->dev, "%s(): Waking up xfer routine after "
216 "zero-xfer.\n", __FUNCTION__);
217
218 complete(&alg_data->mif.complete);
219 }
220
221 dev_dbg(&adap->dev, "%s(): exiting: stat = %04x.\n",
222 __FUNCTION__, ioread32(I2C_REG_STS(alg_data)));
223
224 return 0;
225}
226
227/**
228 * i2c_pnx_master_rcv - receive data from slave
229 * @adap: pointer to I2C adapter structure
230 *
231 * Reads one byte data from the slave
232 */
233static int i2c_pnx_master_rcv(struct i2c_adapter *adap)
234{
235 struct i2c_pnx_algo_data *alg_data = adap->algo_data;
236 unsigned int val = 0;
237 u32 ctl = 0;
238
239 dev_dbg(&adap->dev, "%s(): entering: stat = %04x.\n",
240 __FUNCTION__, ioread32(I2C_REG_STS(alg_data)));
241
242 /* Check, whether there is already data,
243 * or we didn't 'ask' for it yet.
244 */
245 if (ioread32(I2C_REG_STS(alg_data)) & mstatus_rfe) {
246 dev_dbg(&adap->dev, "%s(): Write dummy data to fill "
247 "Rx-fifo...\n", __FUNCTION__);
248
249 if (alg_data->mif.len == 1) {
250 /* Last byte, do not acknowledge next rcv. */
251 val |= stop_bit;
252 if (!alg_data->last)
253 val |= start_bit;
254
255 /*
256 * Enable interrupt RFDAIE (data in Rx fifo),
257 * and disable DRMIE (need data for Tx)
258 */
259 ctl = ioread32(I2C_REG_CTL(alg_data));
260 ctl |= mcntrl_rffie | mcntrl_daie;
261 ctl &= ~mcntrl_drmie;
262 iowrite32(ctl, I2C_REG_CTL(alg_data));
263 }
264
265 /*
266 * Now we'll 'ask' for data:
267 * For each byte we want to receive, we must
268 * write a (dummy) byte to the Tx-FIFO.
269 */
270 iowrite32(val, I2C_REG_TX(alg_data));
271
272 return 0;
273 }
274
275 /* Handle data. */
276 if (alg_data->mif.len > 0) {
277 val = ioread32(I2C_REG_RX(alg_data));
278 *alg_data->mif.buf++ = (u8) (val & 0xff);
279 dev_dbg(&adap->dev, "%s(): rcv 0x%x [%d]\n", __FUNCTION__, val,
280 alg_data->mif.len);
281
282 alg_data->mif.len--;
283 if (alg_data->mif.len == 0) {
284 if (alg_data->last)
285 /* Wait until the STOP is seen. */
286 if (wait_timeout(I2C_PNX_TIMEOUT, alg_data))
287 dev_err(&adap->dev, "The bus is still "
288 "active after timeout\n");
289
290 /* Disable master interrupts */
291 ctl = ioread32(I2C_REG_CTL(alg_data));
292 ctl &= ~(mcntrl_afie | mcntrl_naie | mcntrl_rffie |
293 mcntrl_drmie | mcntrl_daie);
294 iowrite32(ctl, I2C_REG_CTL(alg_data));
295
296 /* Kill timer. */
297 del_timer_sync(&alg_data->mif.timer);
298 complete(&alg_data->mif.complete);
299 }
300 }
301
302 dev_dbg(&adap->dev, "%s(): exiting: stat = %04x.\n",
303 __FUNCTION__, ioread32(I2C_REG_STS(alg_data)));
304
305 return 0;
306}
307
308static irqreturn_t
309i2c_pnx_interrupt(int irq, void *dev_id, struct pt_regs *regs)
310{
311 u32 stat, ctl;
312 struct i2c_adapter *adap = dev_id;
313 struct i2c_pnx_algo_data *alg_data = adap->algo_data;
314
315 dev_dbg(&adap->dev, "%s(): mstat = %x mctrl = %x, mode = %d\n",
316 __FUNCTION__,
317 ioread32(I2C_REG_STS(alg_data)),
318 ioread32(I2C_REG_CTL(alg_data)),
319 alg_data->mif.mode);
320 stat = ioread32(I2C_REG_STS(alg_data));
321
322 /* let's see what kind of event this is */
323 if (stat & mstatus_afi) {
324 /* We lost arbitration in the midst of a transfer */
325 alg_data->mif.ret = -EIO;
326
327 /* Disable master interrupts. */
328 ctl = ioread32(I2C_REG_CTL(alg_data));
329 ctl &= ~(mcntrl_afie | mcntrl_naie | mcntrl_rffie |
330 mcntrl_drmie);
331 iowrite32(ctl, I2C_REG_CTL(alg_data));
332
333 /* Stop timer, to prevent timeout. */
334 del_timer_sync(&alg_data->mif.timer);
335 complete(&alg_data->mif.complete);
336 } else if (stat & mstatus_nai) {
337 /* Slave did not acknowledge, generate a STOP */
338 dev_dbg(&adap->dev, "%s(): "
339 "Slave did not acknowledge, generating a STOP.\n",
340 __FUNCTION__);
341 i2c_pnx_stop(adap);
342
343 /* Disable master interrupts. */
344 ctl = ioread32(I2C_REG_CTL(alg_data));
345 ctl &= ~(mcntrl_afie | mcntrl_naie | mcntrl_rffie |
346 mcntrl_drmie);
347 iowrite32(ctl, I2C_REG_CTL(alg_data));
348
349 /* Our return value. */
350 alg_data->mif.ret = -EIO;
351
352 /* Stop timer, to prevent timeout. */
353 del_timer_sync(&alg_data->mif.timer);
354 complete(&alg_data->mif.complete);
355 } else {
356 /*
357 * Two options:
358 * - Master Tx needs data.
359 * - There is data in the Rx-fifo
360 * The latter is only the case if we have requested for data,
361 * via a dummy write. (See 'i2c_pnx_master_rcv'.)
362 * We therefore check, as a sanity check, whether that interrupt
363 * has been enabled.
364 */
365 if ((stat & mstatus_drmi) || !(stat & mstatus_rfe)) {
366 if (alg_data->mif.mode == I2C_SMBUS_WRITE) {
367 i2c_pnx_master_xmit(adap);
368 } else if (alg_data->mif.mode == I2C_SMBUS_READ) {
369 i2c_pnx_master_rcv(adap);
370 }
371 }
372 }
373
374 /* Clear TDI and AFI bits */
375 stat = ioread32(I2C_REG_STS(alg_data));
376 iowrite32(stat | mstatus_tdi | mstatus_afi, I2C_REG_STS(alg_data));
377
378 dev_dbg(&adap->dev, "%s(): exiting, stat = %x ctrl = %x.\n",
379 __FUNCTION__, ioread32(I2C_REG_STS(alg_data)),
380 ioread32(I2C_REG_CTL(alg_data)));
381
382 return IRQ_HANDLED;
383}
384
385static void i2c_pnx_timeout(unsigned long data)
386{
387 struct i2c_adapter *adap = (struct i2c_adapter *)data;
388 struct i2c_pnx_algo_data *alg_data = adap->algo_data;
389 u32 ctl;
390
391 dev_err(&adap->dev, "Master timed out. stat = %04x, cntrl = %04x. "
392 "Resetting master...\n",
393 ioread32(I2C_REG_STS(alg_data)),
394 ioread32(I2C_REG_CTL(alg_data)));
395
396 /* Reset master and disable interrupts */
397 ctl = ioread32(I2C_REG_CTL(alg_data));
398 ctl &= ~(mcntrl_afie | mcntrl_naie | mcntrl_rffie | mcntrl_drmie);
399 iowrite32(ctl, I2C_REG_CTL(alg_data));
400
401 ctl |= mcntrl_reset;
402 iowrite32(ctl, I2C_REG_CTL(alg_data));
403 wait_reset(I2C_PNX_TIMEOUT, alg_data);
404 alg_data->mif.ret = -EIO;
405 complete(&alg_data->mif.complete);
406}
407
408static inline void bus_reset_if_active(struct i2c_adapter *adap)
409{
410 struct i2c_pnx_algo_data *alg_data = adap->algo_data;
411 u32 stat;
412
413 if ((stat = ioread32(I2C_REG_STS(alg_data))) & mstatus_active) {
414 dev_err(&adap->dev,
415 "%s: Bus is still active after xfer. Reset it...\n",
416 adap->name);
417 iowrite32(ioread32(I2C_REG_CTL(alg_data)) | mcntrl_reset,
418 I2C_REG_CTL(alg_data));
419 wait_reset(I2C_PNX_TIMEOUT, alg_data);
420 } else if (!(stat & mstatus_rfe) || !(stat & mstatus_tfe)) {
421 /* If there is data in the fifo's after transfer,
422 * flush fifo's by reset.
423 */
424 iowrite32(ioread32(I2C_REG_CTL(alg_data)) | mcntrl_reset,
425 I2C_REG_CTL(alg_data));
426 wait_reset(I2C_PNX_TIMEOUT, alg_data);
427 } else if (stat & mstatus_nai) {
428 iowrite32(ioread32(I2C_REG_CTL(alg_data)) | mcntrl_reset,
429 I2C_REG_CTL(alg_data));
430 wait_reset(I2C_PNX_TIMEOUT, alg_data);
431 }
432}
433
434/**
435 * i2c_pnx_xfer - generic transfer entry point
436 * @adap: pointer to I2C adapter structure
437 * @msgs: array of messages
438 * @num: number of messages
439 *
440 * Initiates the transfer
441 */
442static int
443i2c_pnx_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
444{
445 struct i2c_msg *pmsg;
446 int rc = 0, completed = 0, i;
447 struct i2c_pnx_algo_data *alg_data = adap->algo_data;
448 u32 stat = ioread32(I2C_REG_STS(alg_data));
449
450 dev_dbg(&adap->dev, "%s(): entering: %d messages, stat = %04x.\n",
451 __FUNCTION__, num, ioread32(I2C_REG_STS(alg_data)));
452
453 bus_reset_if_active(adap);
454
455 /* Process transactions in a loop. */
456 for (i = 0; rc >= 0 && i < num; i++) {
457 u8 addr;
458
459 pmsg = &msgs[i];
460 addr = pmsg->addr;
461
462 if (pmsg->flags & I2C_M_TEN) {
463 dev_err(&adap->dev,
464 "%s: 10 bits addr not supported!\n",
465 adap->name);
466 rc = -EINVAL;
467 break;
468 }
469
470 alg_data->mif.buf = pmsg->buf;
471 alg_data->mif.len = pmsg->len;
472 alg_data->mif.mode = (pmsg->flags & I2C_M_RD) ?
473 I2C_SMBUS_READ : I2C_SMBUS_WRITE;
474 alg_data->mif.ret = 0;
475 alg_data->last = (i == num - 1);
476
477 dev_dbg(&adap->dev, "%s(): mode %d, %d bytes\n", __FUNCTION__,
478 alg_data->mif.mode,
479 alg_data->mif.len);
480
481 i2c_pnx_arm_timer(adap);
482
483 /* initialize the completion var */
484 init_completion(&alg_data->mif.complete);
485
486 /* Enable master interrupt */
487 iowrite32(ioread32(I2C_REG_CTL(alg_data)) | mcntrl_afie |
488 mcntrl_naie | mcntrl_drmie,
489 I2C_REG_CTL(alg_data));
490
491 /* Put start-code and slave-address on the bus. */
492 rc = i2c_pnx_start(addr, adap);
493 if (rc < 0)
494 break;
495
496 /* Wait for completion */
497 wait_for_completion(&alg_data->mif.complete);
498
499 if (!(rc = alg_data->mif.ret))
500 completed++;
501 dev_dbg(&adap->dev, "%s(): Complete, return code = %d.\n",
502 __FUNCTION__, rc);
503
504 /* Clear TDI and AFI bits in case they are set. */
505 if ((stat = ioread32(I2C_REG_STS(alg_data))) & mstatus_tdi) {
506 dev_dbg(&adap->dev,
507 "%s: TDI still set... clearing now.\n",
508 adap->name);
509 iowrite32(stat, I2C_REG_STS(alg_data));
510 }
511 if ((stat = ioread32(I2C_REG_STS(alg_data))) & mstatus_afi) {
512 dev_dbg(&adap->dev,
513 "%s: AFI still set... clearing now.\n",
514 adap->name);
515 iowrite32(stat, I2C_REG_STS(alg_data));
516 }
517 }
518
519 bus_reset_if_active(adap);
520
521 /* Cleanup to be sure... */
522 alg_data->mif.buf = NULL;
523 alg_data->mif.len = 0;
524
525 dev_dbg(&adap->dev, "%s(): exiting, stat = %x\n",
526 __FUNCTION__, ioread32(I2C_REG_STS(alg_data)));
527
528 if (completed != num)
529 return ((rc < 0) ? rc : -EREMOTEIO);
530
531 return num;
532}
533
534static u32 i2c_pnx_func(struct i2c_adapter *adapter)
535{
536 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
537}
538
539static struct i2c_algorithm pnx_algorithm = {
540 .master_xfer = i2c_pnx_xfer,
541 .functionality = i2c_pnx_func,
542};
543
544static int i2c_pnx_controller_suspend(struct platform_device *pdev,
545 pm_message_t state)
546{
547 struct i2c_pnx_data *i2c_pnx = platform_get_drvdata(pdev);
548 return i2c_pnx->suspend(pdev, state);
549}
550
551static int i2c_pnx_controller_resume(struct platform_device *pdev)
552{
553 struct i2c_pnx_data *i2c_pnx = platform_get_drvdata(pdev);
554 return i2c_pnx->resume(pdev);
555}
556
557static int __devinit i2c_pnx_probe(struct platform_device *pdev)
558{
559 unsigned long tmp;
560 int ret = 0;
561 struct i2c_pnx_algo_data *alg_data;
562 int freq_mhz;
563 struct i2c_pnx_data *i2c_pnx = pdev->dev.platform_data;
564
565 if (!i2c_pnx || !i2c_pnx->adapter) {
566 dev_err(&pdev->dev, "%s: no platform data supplied\n",
567 __FUNCTION__);
568 ret = -EINVAL;
569 goto out;
570 }
571
572 platform_set_drvdata(pdev, i2c_pnx);
573
574 if (i2c_pnx->calculate_input_freq)
575 freq_mhz = i2c_pnx->calculate_input_freq(pdev);
576 else {
577 freq_mhz = PNX_DEFAULT_FREQ;
578 dev_info(&pdev->dev, "Setting bus frequency to default value: "
579 "%d MHz", freq_mhz);
580 }
581
582 i2c_pnx->adapter->algo = &pnx_algorithm;
583
584 alg_data = i2c_pnx->adapter->algo_data;
585 init_timer(&alg_data->mif.timer);
586 alg_data->mif.timer.function = i2c_pnx_timeout;
587 alg_data->mif.timer.data = (unsigned long)i2c_pnx->adapter;
588
589 /* Register I/O resource */
590 if (!request_region(alg_data->base, I2C_PNX_REGION_SIZE, pdev->name)) {
591 dev_err(&pdev->dev,
592 "I/O region 0x%08x for I2C already in use.\n",
593 alg_data->base);
594 ret = -ENODEV;
595 goto out_drvdata;
596 }
597
598 if (!(alg_data->ioaddr =
599 (u32)ioremap(alg_data->base, I2C_PNX_REGION_SIZE))) {
600 dev_err(&pdev->dev, "Couldn't ioremap I2C I/O region\n");
601 ret = -ENOMEM;
602 goto out_release;
603 }
604
605 i2c_pnx->set_clock_run(pdev);
606
607 /*
608 * Clock Divisor High This value is the number of system clocks
609 * the serial clock (SCL) will be high.
610 * For example, if the system clock period is 50 ns and the maximum
611 * desired serial period is 10000 ns (100 kHz), then CLKHI would be
612 * set to 0.5*(f_sys/f_i2c)-2=0.5*(20e6/100e3)-2=98. The actual value
613 * programmed into CLKHI will vary from this slightly due to
614 * variations in the output pad's rise and fall times as well as
615 * the deglitching filter length.
616 */
617
618 tmp = ((freq_mhz * 1000) / I2C_PNX_SPEED_KHZ) / 2 - 2;
619 iowrite32(tmp, I2C_REG_CKH(alg_data));
620 iowrite32(tmp, I2C_REG_CKL(alg_data));
621
622 iowrite32(mcntrl_reset, I2C_REG_CTL(alg_data));
623 if (wait_reset(I2C_PNX_TIMEOUT, alg_data)) {
624 ret = -ENODEV;
625 goto out_unmap;
626 }
627 init_completion(&alg_data->mif.complete);
628
629 ret = request_irq(alg_data->irq, i2c_pnx_interrupt,
630 0, pdev->name, i2c_pnx->adapter);
631 if (ret)
632 goto out_clock;
633
634 /* Register this adapter with the I2C subsystem */
635 i2c_pnx->adapter->dev.parent = &pdev->dev;
636 ret = i2c_add_adapter(i2c_pnx->adapter);
637 if (ret < 0) {
638 dev_err(&pdev->dev, "I2C: Failed to add bus\n");
639 goto out_irq;
640 }
641
642 dev_dbg(&pdev->dev, "%s: Master at %#8x, irq %d.\n",
643 i2c_pnx->adapter->name, alg_data->base, alg_data->irq);
644
645 return 0;
646
647out_irq:
648 free_irq(alg_data->irq, alg_data);
649out_clock:
650 i2c_pnx->set_clock_stop(pdev);
651out_unmap:
652 iounmap((void *)alg_data->ioaddr);
653out_release:
654 release_region(alg_data->base, I2C_PNX_REGION_SIZE);
655out_drvdata:
656 platform_set_drvdata(pdev, NULL);
657out:
658 return ret;
659}
660
661static int __devexit i2c_pnx_remove(struct platform_device *pdev)
662{
663 struct i2c_pnx_data *i2c_pnx = platform_get_drvdata(pdev);
664 struct i2c_adapter *adap = i2c_pnx->adapter;
665 struct i2c_pnx_algo_data *alg_data = adap->algo_data;
666
667 free_irq(alg_data->irq, alg_data);
668 i2c_del_adapter(adap);
669 i2c_pnx->set_clock_stop(pdev);
670 iounmap((void *)alg_data->ioaddr);
671 release_region(alg_data->base, I2C_PNX_REGION_SIZE);
672 platform_set_drvdata(pdev, NULL);
673
674 return 0;
675}
676
677static struct platform_driver i2c_pnx_driver = {
678 .driver = {
679 .name = "pnx-i2c",
680 .owner = THIS_MODULE,
681 },
682 .probe = i2c_pnx_probe,
683 .remove = __devexit_p(i2c_pnx_remove),
684 .suspend = i2c_pnx_controller_suspend,
685 .resume = i2c_pnx_controller_resume,
686};
687
688static int __init i2c_adap_pnx_init(void)
689{
690 return platform_driver_register(&i2c_pnx_driver);
691}
692
693static void __exit i2c_adap_pnx_exit(void)
694{
695 platform_driver_unregister(&i2c_pnx_driver);
696}
697
698MODULE_AUTHOR("Vitaly Wool, Dennis Kovalev <source@mvista.com>");
699MODULE_DESCRIPTION("I2C driver for Philips IP3204-based I2C busses");
700MODULE_LICENSE("GPL");
701
702#ifdef CONFIG_I2C_PNX_EARLY
703/* We need to make sure I2C is initialized before USB */
704subsys_initcall(i2c_adap_pnx_init);
705#else
706mudule_init(i2c_adap_pnx_init);
707#endif
708module_exit(i2c_adap_pnx_exit);
diff --git a/drivers/i2c/busses/i2c-prosavage.c b/drivers/i2c/busses/i2c-prosavage.c
index 7745e21874a8..07c1f1e27df1 100644
--- a/drivers/i2c/busses/i2c-prosavage.c
+++ b/drivers/i2c/busses/i2c-prosavage.c
@@ -212,7 +212,7 @@ static void prosavage_remove(struct pci_dev *dev)
212 if (chip->i2c_bus[i].adap_ok == 0) 212 if (chip->i2c_bus[i].adap_ok == 0)
213 continue; 213 continue;
214 214
215 ret = i2c_bit_del_bus(&chip->i2c_bus[i].adap); 215 ret = i2c_del_adapter(&chip->i2c_bus[i].adap);
216 if (ret) { 216 if (ret) {
217 dev_err(&dev->dev, "%s not removed\n", 217 dev_err(&dev->dev, "%s not removed\n",
218 chip->i2c_bus[i].adap.name); 218 chip->i2c_bus[i].adap.name);
diff --git a/drivers/i2c/busses/i2c-savage4.c b/drivers/i2c/busses/i2c-savage4.c
index 209f47ea1750..844b4ff90893 100644
--- a/drivers/i2c/busses/i2c-savage4.c
+++ b/drivers/i2c/busses/i2c-savage4.c
@@ -173,7 +173,7 @@ static int __devinit savage4_probe(struct pci_dev *dev, const struct pci_device_
173 173
174static void __devexit savage4_remove(struct pci_dev *dev) 174static void __devexit savage4_remove(struct pci_dev *dev)
175{ 175{
176 i2c_bit_del_bus(&savage4_i2c_adapter); 176 i2c_del_adapter(&savage4_i2c_adapter);
177 iounmap(ioaddr); 177 iounmap(ioaddr);
178} 178}
179 179
diff --git a/drivers/i2c/busses/i2c-versatile.c b/drivers/i2c/busses/i2c-versatile.c
new file mode 100644
index 000000000000..081d9578ce10
--- /dev/null
+++ b/drivers/i2c/busses/i2c-versatile.c
@@ -0,0 +1,153 @@
1/*
2 * i2c-versatile.c
3 *
4 * Copyright (C) 2006 ARM Ltd.
5 * written by Russell King, Deep Blue Solutions Ltd.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#include <linux/kernel.h>
12#include <linux/module.h>
13#include <linux/i2c.h>
14#include <linux/i2c-algo-bit.h>
15#include <linux/init.h>
16#include <linux/platform_device.h>
17
18#include <asm/io.h>
19
20#define I2C_CONTROL 0x00
21#define I2C_CONTROLS 0x00
22#define I2C_CONTROLC 0x04
23#define SCL (1 << 0)
24#define SDA (1 << 1)
25
26struct i2c_versatile {
27 struct i2c_adapter adap;
28 struct i2c_algo_bit_data algo;
29 void __iomem *base;
30};
31
32static void i2c_versatile_setsda(void *data, int state)
33{
34 struct i2c_versatile *i2c = data;
35
36 writel(SDA, i2c->base + (state ? I2C_CONTROLS : I2C_CONTROLC));
37}
38
39static void i2c_versatile_setscl(void *data, int state)
40{
41 struct i2c_versatile *i2c = data;
42
43 writel(SCL, i2c->base + (state ? I2C_CONTROLS : I2C_CONTROLC));
44}
45
46static int i2c_versatile_getsda(void *data)
47{
48 struct i2c_versatile *i2c = data;
49 return !!(readl(i2c->base + I2C_CONTROL) & SDA);
50}
51
52static int i2c_versatile_getscl(void *data)
53{
54 struct i2c_versatile *i2c = data;
55 return !!(readl(i2c->base + I2C_CONTROL) & SCL);
56}
57
58static struct i2c_algo_bit_data i2c_versatile_algo = {
59 .setsda = i2c_versatile_setsda,
60 .setscl = i2c_versatile_setscl,
61 .getsda = i2c_versatile_getsda,
62 .getscl = i2c_versatile_getscl,
63 .udelay = 30,
64 .timeout = HZ,
65};
66
67static int i2c_versatile_probe(struct platform_device *dev)
68{
69 struct i2c_versatile *i2c;
70 struct resource *r;
71 int ret;
72
73 r = platform_get_resource(dev, IORESOURCE_MEM, 0);
74 if (!r) {
75 ret = -EINVAL;
76 goto err_out;
77 }
78
79 if (!request_mem_region(r->start, r->end - r->start + 1, "versatile-i2c")) {
80 ret = -EBUSY;
81 goto err_out;
82 }
83
84 i2c = kzalloc(sizeof(struct i2c_versatile), GFP_KERNEL);
85 if (!i2c) {
86 ret = -ENOMEM;
87 goto err_release;
88 }
89
90 i2c->base = ioremap(r->start, r->end - r->start + 1);
91 if (!i2c->base) {
92 ret = -ENOMEM;
93 goto err_free;
94 }
95
96 writel(SCL | SDA, i2c->base + I2C_CONTROLS);
97
98 i2c->adap.owner = THIS_MODULE;
99 strlcpy(i2c->adap.name, "Versatile I2C adapter", sizeof(i2c->adap.name));
100 i2c->adap.algo_data = &i2c->algo;
101 i2c->adap.dev.parent = &dev->dev;
102 i2c->algo = i2c_versatile_algo;
103 i2c->algo.data = i2c;
104
105 ret = i2c_bit_add_bus(&i2c->adap);
106 if (ret >= 0) {
107 platform_set_drvdata(dev, i2c);
108 return 0;
109 }
110
111 iounmap(i2c->base);
112 err_free:
113 kfree(i2c);
114 err_release:
115 release_mem_region(r->start, r->end - r->start + 1);
116 err_out:
117 return ret;
118}
119
120static int i2c_versatile_remove(struct platform_device *dev)
121{
122 struct i2c_versatile *i2c = platform_get_drvdata(dev);
123
124 platform_set_drvdata(dev, NULL);
125
126 i2c_del_adapter(&i2c->adap);
127 return 0;
128}
129
130static struct platform_driver i2c_versatile_driver = {
131 .probe = i2c_versatile_probe,
132 .remove = i2c_versatile_remove,
133 .driver = {
134 .name = "versatile-i2c",
135 .owner = THIS_MODULE,
136 },
137};
138
139static int __init i2c_versatile_init(void)
140{
141 return platform_driver_register(&i2c_versatile_driver);
142}
143
144static void __exit i2c_versatile_exit(void)
145{
146 platform_driver_unregister(&i2c_versatile_driver);
147}
148
149module_init(i2c_versatile_init);
150module_exit(i2c_versatile_exit);
151
152MODULE_DESCRIPTION("ARM Versatile I2C bus driver");
153MODULE_LICENSE("GPL");
diff --git a/drivers/i2c/busses/i2c-via.c b/drivers/i2c/busses/i2c-via.c
index 910e200ad500..15d7e00e47e6 100644
--- a/drivers/i2c/busses/i2c-via.c
+++ b/drivers/i2c/busses/i2c-via.c
@@ -151,7 +151,7 @@ static int __devinit vt586b_probe(struct pci_dev *dev, const struct pci_device_i
151 151
152static void __devexit vt586b_remove(struct pci_dev *dev) 152static void __devexit vt586b_remove(struct pci_dev *dev)
153{ 153{
154 i2c_bit_del_bus(&vt586b_adapter); 154 i2c_del_adapter(&vt586b_adapter);
155 release_region(I2C_DIR, IOSPACE); 155 release_region(I2C_DIR, IOSPACE);
156 pm_io_base = 0; 156 pm_io_base = 0;
157} 157}
diff --git a/drivers/i2c/busses/i2c-voodoo3.c b/drivers/i2c/busses/i2c-voodoo3.c
index 6c8d25183382..b0377b81744b 100644
--- a/drivers/i2c/busses/i2c-voodoo3.c
+++ b/drivers/i2c/busses/i2c-voodoo3.c
@@ -211,14 +211,14 @@ static int __devinit voodoo3_probe(struct pci_dev *dev, const struct pci_device_
211 return retval; 211 return retval;
212 retval = i2c_bit_add_bus(&voodoo3_ddc_adapter); 212 retval = i2c_bit_add_bus(&voodoo3_ddc_adapter);
213 if (retval) 213 if (retval)
214 i2c_bit_del_bus(&voodoo3_i2c_adapter); 214 i2c_del_adapter(&voodoo3_i2c_adapter);
215 return retval; 215 return retval;
216} 216}
217 217
218static void __devexit voodoo3_remove(struct pci_dev *dev) 218static void __devexit voodoo3_remove(struct pci_dev *dev)
219{ 219{
220 i2c_bit_del_bus(&voodoo3_i2c_adapter); 220 i2c_del_adapter(&voodoo3_i2c_adapter);
221 i2c_bit_del_bus(&voodoo3_ddc_adapter); 221 i2c_del_adapter(&voodoo3_ddc_adapter);
222 iounmap(ioaddr); 222 iounmap(ioaddr);
223} 223}
224 224
diff --git a/drivers/i2c/busses/scx200_i2c.c b/drivers/i2c/busses/scx200_i2c.c
index 8ddbae4fafe6..6cd96e43aa72 100644
--- a/drivers/i2c/busses/scx200_i2c.c
+++ b/drivers/i2c/busses/scx200_i2c.c
@@ -116,7 +116,7 @@ static int scx200_i2c_init(void)
116 116
117static void scx200_i2c_cleanup(void) 117static void scx200_i2c_cleanup(void)
118{ 118{
119 i2c_bit_del_bus(&scx200_i2c_ops); 119 i2c_del_adapter(&scx200_i2c_ops);
120} 120}
121 121
122module_init(scx200_i2c_init); 122module_init(scx200_i2c_init);
diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c
index 93d483b8b770..ec17d6b684a2 100644
--- a/drivers/i2c/chips/ds1337.c
+++ b/drivers/i2c/chips/ds1337.c
@@ -347,13 +347,19 @@ static void ds1337_init_client(struct i2c_client *client)
347 347
348 if ((status & 0x80) || (control & 0x80)) { 348 if ((status & 0x80) || (control & 0x80)) {
349 /* RTC not running */ 349 /* RTC not running */
350 u8 buf[16]; 350 u8 buf[1+16]; /* First byte is interpreted as address */
351 struct i2c_msg msg[1]; 351 struct i2c_msg msg[1];
352 352
353 dev_dbg(&client->dev, "%s: RTC not running!\n", __FUNCTION__); 353 dev_dbg(&client->dev, "%s: RTC not running!\n", __FUNCTION__);
354 354
355 /* Initialize all, including STATUS and CONTROL to zero */ 355 /* Initialize all, including STATUS and CONTROL to zero */
356 memset(buf, 0, sizeof(buf)); 356 memset(buf, 0, sizeof(buf));
357
358 /* Write valid values in the date/time registers */
359 buf[1+DS1337_REG_DAY] = 1;
360 buf[1+DS1337_REG_DATE] = 1;
361 buf[1+DS1337_REG_MONTH] = 1;
362
357 msg[0].addr = client->addr; 363 msg[0].addr = client->addr;
358 msg[0].flags = 0; 364 msg[0].flags = 0;
359 msg[0].len = sizeof(buf); 365 msg[0].len = sizeof(buf);
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 7ca81f42d14b..3e31f1d265c9 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -127,20 +127,17 @@ static ssize_t show_client_name(struct device *dev, struct device_attribute *att
127 return sprintf(buf, "%s\n", client->name); 127 return sprintf(buf, "%s\n", client->name);
128} 128}
129 129
130/* 130/*
131 * We can't use the DEVICE_ATTR() macro here as we want the same filename for a 131 * We can't use the DEVICE_ATTR() macro here, as we used the same name for
132 * different type of a device. So beware if the DEVICE_ATTR() macro ever 132 * an i2c adapter attribute (above).
133 * changes, this definition will also have to change.
134 */ 133 */
135static struct device_attribute dev_attr_client_name = { 134static struct device_attribute dev_attr_client_name =
136 .attr = {.name = "name", .mode = S_IRUGO, .owner = THIS_MODULE }, 135 __ATTR(name, S_IRUGO, &show_client_name, NULL);
137 .show = &show_client_name,
138};
139 136
140 137
141/* --------------------------------------------------- 138/* ---------------------------------------------------
142 * registering functions 139 * registering functions
143 * --------------------------------------------------- 140 * ---------------------------------------------------
144 */ 141 */
145 142
146/* ----- 143/* -----
@@ -314,7 +311,7 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
314 res = driver_register(&driver->driver); 311 res = driver_register(&driver->driver);
315 if (res) 312 if (res)
316 return res; 313 return res;
317 314
318 mutex_lock(&core_lists); 315 mutex_lock(&core_lists);
319 316
320 list_add_tail(&driver->list,&drivers); 317 list_add_tail(&driver->list,&drivers);
@@ -338,13 +335,13 @@ int i2c_del_driver(struct i2c_driver *driver)
338 struct list_head *item1, *item2, *_n; 335 struct list_head *item1, *item2, *_n;
339 struct i2c_client *client; 336 struct i2c_client *client;
340 struct i2c_adapter *adap; 337 struct i2c_adapter *adap;
341 338
342 int res = 0; 339 int res = 0;
343 340
344 mutex_lock(&core_lists); 341 mutex_lock(&core_lists);
345 342
346 /* Have a look at each adapter, if clients of this driver are still 343 /* Have a look at each adapter, if clients of this driver are still
347 * attached. If so, detach them to be able to kill the driver 344 * attached. If so, detach them to be able to kill the driver
348 * afterwards. 345 * afterwards.
349 */ 346 */
350 list_for_each(item1,&adapters) { 347 list_for_each(item1,&adapters) {
@@ -419,14 +416,14 @@ int i2c_attach_client(struct i2c_client *client)
419 goto out_unlock; 416 goto out_unlock;
420 } 417 }
421 list_add_tail(&client->list,&adapter->clients); 418 list_add_tail(&client->list,&adapter->clients);
422 419
423 client->usage_count = 0; 420 client->usage_count = 0;
424 421
425 client->dev.parent = &client->adapter->dev; 422 client->dev.parent = &client->adapter->dev;
426 client->dev.driver = &client->driver->driver; 423 client->dev.driver = &client->driver->driver;
427 client->dev.bus = &i2c_bus_type; 424 client->dev.bus = &i2c_bus_type;
428 client->dev.release = &i2c_client_release; 425 client->dev.release = &i2c_client_release;
429 426
430 snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id), 427 snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id),
431 "%d-%04x", i2c_adapter_id(adapter), client->addr); 428 "%d-%04x", i2c_adapter_id(adapter), client->addr);
432 dev_dbg(&adapter->dev, "client [%s] registered with bus id %s\n", 429 dev_dbg(&adapter->dev, "client [%s] registered with bus id %s\n",
@@ -467,7 +464,7 @@ int i2c_detach_client(struct i2c_client *client)
467{ 464{
468 struct i2c_adapter *adapter = client->adapter; 465 struct i2c_adapter *adapter = client->adapter;
469 int res = 0; 466 int res = 0;
470 467
471 if (client->usage_count > 0) { 468 if (client->usage_count > 0) {
472 dev_warn(&client->dev, "Client [%s] still busy, " 469 dev_warn(&client->dev, "Client [%s] still busy, "
473 "can't detach\n", client->name); 470 "can't detach\n", client->name);
@@ -535,10 +532,10 @@ int i2c_release_client(struct i2c_client *client)
535 __FUNCTION__); 532 __FUNCTION__);
536 return -EPERM; 533 return -EPERM;
537 } 534 }
538 535
539 client->usage_count--; 536 client->usage_count--;
540 i2c_dec_use_client(client); 537 i2c_dec_use_client(client);
541 538
542 return 0; 539 return 0;
543} 540}
544 541
@@ -603,7 +600,7 @@ int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg *msgs, int num)
603 } 600 }
604#endif 601#endif
605 602
606 mutex_lock(&adap->bus_lock); 603 mutex_lock_nested(&adap->bus_lock, adap->level);
607 ret = adap->algo->master_xfer(adap,msgs,num); 604 ret = adap->algo->master_xfer(adap,msgs,num);
608 mutex_unlock(&adap->bus_lock); 605 mutex_unlock(&adap->bus_lock);
609 606
@@ -624,7 +621,7 @@ int i2c_master_send(struct i2c_client *client,const char *buf ,int count)
624 msg.flags = client->flags & I2C_M_TEN; 621 msg.flags = client->flags & I2C_M_TEN;
625 msg.len = count; 622 msg.len = count;
626 msg.buf = (char *)buf; 623 msg.buf = (char *)buf;
627 624
628 ret = i2c_transfer(adap, &msg, 1); 625 ret = i2c_transfer(adap, &msg, 1);
629 626
630 /* If everything went ok (i.e. 1 msg transmitted), return #bytes 627 /* If everything went ok (i.e. 1 msg transmitted), return #bytes
@@ -757,7 +754,7 @@ int i2c_probe(struct i2c_adapter *adapter,
757 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) { 754 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) {
758 if (address_data->probe[0] == I2C_CLIENT_END 755 if (address_data->probe[0] == I2C_CLIENT_END
759 && address_data->normal_i2c[0] == I2C_CLIENT_END) 756 && address_data->normal_i2c[0] == I2C_CLIENT_END)
760 return 0; 757 return 0;
761 758
762 dev_warn(&adapter->dev, "SMBus Quick command not supported, " 759 dev_warn(&adapter->dev, "SMBus Quick command not supported, "
763 "can't probe for chips\n"); 760 "can't probe for chips\n");
@@ -817,7 +814,7 @@ int i2c_probe(struct i2c_adapter *adapter,
817struct i2c_adapter* i2c_get_adapter(int id) 814struct i2c_adapter* i2c_get_adapter(int id)
818{ 815{
819 struct i2c_adapter *adapter; 816 struct i2c_adapter *adapter;
820 817
821 mutex_lock(&core_lists); 818 mutex_lock(&core_lists);
822 adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id); 819 adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id);
823 if (adapter && !try_module_get(adapter->owner)) 820 if (adapter && !try_module_get(adapter->owner))
@@ -834,14 +831,14 @@ void i2c_put_adapter(struct i2c_adapter *adap)
834 831
835/* The SMBus parts */ 832/* The SMBus parts */
836 833
837#define POLY (0x1070U << 3) 834#define POLY (0x1070U << 3)
838static u8 835static u8
839crc8(u16 data) 836crc8(u16 data)
840{ 837{
841 int i; 838 int i;
842 839
843 for(i = 0; i < 8; i++) { 840 for(i = 0; i < 8; i++) {
844 if (data & 0x8000) 841 if (data & 0x8000)
845 data = data ^ POLY; 842 data = data ^ POLY;
846 data = data << 1; 843 data = data << 1;
847 } 844 }
@@ -891,13 +888,13 @@ static int i2c_smbus_check_pec(u8 cpec, struct i2c_msg *msg)
891 rpec, cpec); 888 rpec, cpec);
892 return -1; 889 return -1;
893 } 890 }
894 return 0; 891 return 0;
895} 892}
896 893
897s32 i2c_smbus_write_quick(struct i2c_client *client, u8 value) 894s32 i2c_smbus_write_quick(struct i2c_client *client, u8 value)
898{ 895{
899 return i2c_smbus_xfer(client->adapter,client->addr,client->flags, 896 return i2c_smbus_xfer(client->adapter,client->addr,client->flags,
900 value,0,I2C_SMBUS_QUICK,NULL); 897 value,0,I2C_SMBUS_QUICK,NULL);
901} 898}
902 899
903s32 i2c_smbus_read_byte(struct i2c_client *client) 900s32 i2c_smbus_read_byte(struct i2c_client *client)
@@ -996,11 +993,11 @@ s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client, u8 command,
996 I2C_SMBUS_I2C_BLOCK_DATA, &data); 993 I2C_SMBUS_I2C_BLOCK_DATA, &data);
997} 994}
998 995
999/* Simulate a SMBus command using the i2c protocol 996/* Simulate a SMBus command using the i2c protocol
1000 No checking of parameters is done! */ 997 No checking of parameters is done! */
1001static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, 998static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
1002 unsigned short flags, 999 unsigned short flags,
1003 char read_write, u8 command, int size, 1000 char read_write, u8 command, int size,
1004 union i2c_smbus_data * data) 1001 union i2c_smbus_data * data)
1005{ 1002{
1006 /* So we need to generate a series of msgs. In the case of writing, we 1003 /* So we need to generate a series of msgs. In the case of writing, we
@@ -1010,7 +1007,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
1010 unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX+3]; 1007 unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX+3];
1011 unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2]; 1008 unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2];
1012 int num = read_write == I2C_SMBUS_READ?2:1; 1009 int num = read_write == I2C_SMBUS_READ?2:1;
1013 struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 }, 1010 struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 },
1014 { addr, flags | I2C_M_RD, 0, msgbuf1 } 1011 { addr, flags | I2C_M_RD, 0, msgbuf1 }
1015 }; 1012 };
1016 int i; 1013 int i;
@@ -1103,14 +1100,14 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
1103 if (i) { 1100 if (i) {
1104 /* Compute PEC if first message is a write */ 1101 /* Compute PEC if first message is a write */
1105 if (!(msg[0].flags & I2C_M_RD)) { 1102 if (!(msg[0].flags & I2C_M_RD)) {
1106 if (num == 1) /* Write only */ 1103 if (num == 1) /* Write only */
1107 i2c_smbus_add_pec(&msg[0]); 1104 i2c_smbus_add_pec(&msg[0]);
1108 else /* Write followed by read */ 1105 else /* Write followed by read */
1109 partial_pec = i2c_smbus_msg_pec(0, &msg[0]); 1106 partial_pec = i2c_smbus_msg_pec(0, &msg[0]);
1110 } 1107 }
1111 /* Ask for PEC if last message is a read */ 1108 /* Ask for PEC if last message is a read */
1112 if (msg[num-1].flags & I2C_M_RD) 1109 if (msg[num-1].flags & I2C_M_RD)
1113 msg[num-1].len++; 1110 msg[num-1].len++;
1114 } 1111 }
1115 1112
1116 if (i2c_transfer(adapter, msg, num) < 0) 1113 if (i2c_transfer(adapter, msg, num) < 0)
@@ -1130,7 +1127,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
1130 case I2C_SMBUS_BYTE_DATA: 1127 case I2C_SMBUS_BYTE_DATA:
1131 data->byte = msgbuf1[0]; 1128 data->byte = msgbuf1[0];
1132 break; 1129 break;
1133 case I2C_SMBUS_WORD_DATA: 1130 case I2C_SMBUS_WORD_DATA:
1134 case I2C_SMBUS_PROC_CALL: 1131 case I2C_SMBUS_PROC_CALL:
1135 data->word = msgbuf1[0] | (msgbuf1[1] << 8); 1132 data->word = msgbuf1[0] | (msgbuf1[1] << 8);
1136 break; 1133 break;
@@ -1146,7 +1143,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
1146 1143
1147 1144
1148s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags, 1145s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags,
1149 char read_write, u8 command, int size, 1146 char read_write, u8 command, int size,
1150 union i2c_smbus_data * data) 1147 union i2c_smbus_data * data)
1151{ 1148{
1152 s32 res; 1149 s32 res;
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 2e22a2ffa606..ac5bd2a7ca99 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -1,5 +1,5 @@
1/* 1/*
2 i2c-dev.c - i2c-bus driver, char device interface 2 i2c-dev.c - i2c-bus driver, char device interface
3 3
4 Copyright (C) 1995-97 Simon G. Vogl 4 Copyright (C) 1995-97 Simon G. Vogl
5 Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl> 5 Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl>
@@ -90,6 +90,7 @@ static void return_i2c_dev(struct i2c_dev *i2c_dev)
90 spin_lock(&i2c_dev_list_lock); 90 spin_lock(&i2c_dev_list_lock);
91 list_del(&i2c_dev->list); 91 list_del(&i2c_dev->list);
92 spin_unlock(&i2c_dev_list_lock); 92 spin_unlock(&i2c_dev_list_lock);
93 kfree(i2c_dev);
93} 94}
94 95
95static ssize_t show_adapter_name(struct device *dev, 96static ssize_t show_adapter_name(struct device *dev,
@@ -172,7 +173,7 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file,
172 switch ( cmd ) { 173 switch ( cmd ) {
173 case I2C_SLAVE: 174 case I2C_SLAVE:
174 case I2C_SLAVE_FORCE: 175 case I2C_SLAVE_FORCE:
175 if ((arg > 0x3ff) || 176 if ((arg > 0x3ff) ||
176 (((client->flags & I2C_M_TEN) == 0) && arg > 0x7f)) 177 (((client->flags & I2C_M_TEN) == 0) && arg > 0x7f))
177 return -EINVAL; 178 return -EINVAL;
178 if ((cmd == I2C_SLAVE) && i2c_check_addr(client->adapter,arg)) 179 if ((cmd == I2C_SLAVE) && i2c_check_addr(client->adapter,arg))
@@ -193,12 +194,11 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file,
193 return 0; 194 return 0;
194 case I2C_FUNCS: 195 case I2C_FUNCS:
195 funcs = i2c_get_functionality(client->adapter); 196 funcs = i2c_get_functionality(client->adapter);
196 return (copy_to_user((unsigned long __user *)arg, &funcs, 197 return put_user(funcs, (unsigned long __user *)arg);
197 sizeof(unsigned long)))?-EFAULT:0;
198 198
199 case I2C_RDWR: 199 case I2C_RDWR:
200 if (copy_from_user(&rdwr_arg, 200 if (copy_from_user(&rdwr_arg,
201 (struct i2c_rdwr_ioctl_data __user *)arg, 201 (struct i2c_rdwr_ioctl_data __user *)arg,
202 sizeof(rdwr_arg))) 202 sizeof(rdwr_arg)))
203 return -EFAULT; 203 return -EFAULT;
204 204
@@ -206,9 +206,9 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file,
206 * be sent at once */ 206 * be sent at once */
207 if (rdwr_arg.nmsgs > I2C_RDRW_IOCTL_MAX_MSGS) 207 if (rdwr_arg.nmsgs > I2C_RDRW_IOCTL_MAX_MSGS)
208 return -EINVAL; 208 return -EINVAL;
209 209
210 rdwr_pa = (struct i2c_msg *) 210 rdwr_pa = (struct i2c_msg *)
211 kmalloc(rdwr_arg.nmsgs * sizeof(struct i2c_msg), 211 kmalloc(rdwr_arg.nmsgs * sizeof(struct i2c_msg),
212 GFP_KERNEL); 212 GFP_KERNEL);
213 213
214 if (rdwr_pa == NULL) return -ENOMEM; 214 if (rdwr_pa == NULL) return -ENOMEM;
@@ -278,9 +278,9 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file,
278 (struct i2c_smbus_ioctl_data __user *) arg, 278 (struct i2c_smbus_ioctl_data __user *) arg,
279 sizeof(struct i2c_smbus_ioctl_data))) 279 sizeof(struct i2c_smbus_ioctl_data)))
280 return -EFAULT; 280 return -EFAULT;
281 if ((data_arg.size != I2C_SMBUS_BYTE) && 281 if ((data_arg.size != I2C_SMBUS_BYTE) &&
282 (data_arg.size != I2C_SMBUS_QUICK) && 282 (data_arg.size != I2C_SMBUS_QUICK) &&
283 (data_arg.size != I2C_SMBUS_BYTE_DATA) && 283 (data_arg.size != I2C_SMBUS_BYTE_DATA) &&
284 (data_arg.size != I2C_SMBUS_WORD_DATA) && 284 (data_arg.size != I2C_SMBUS_WORD_DATA) &&
285 (data_arg.size != I2C_SMBUS_PROC_CALL) && 285 (data_arg.size != I2C_SMBUS_PROC_CALL) &&
286 (data_arg.size != I2C_SMBUS_BLOCK_DATA) && 286 (data_arg.size != I2C_SMBUS_BLOCK_DATA) &&
@@ -291,11 +291,11 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file,
291 data_arg.size); 291 data_arg.size);
292 return -EINVAL; 292 return -EINVAL;
293 } 293 }
294 /* Note that I2C_SMBUS_READ and I2C_SMBUS_WRITE are 0 and 1, 294 /* Note that I2C_SMBUS_READ and I2C_SMBUS_WRITE are 0 and 1,
295 so the check is valid if size==I2C_SMBUS_QUICK too. */ 295 so the check is valid if size==I2C_SMBUS_QUICK too. */
296 if ((data_arg.read_write != I2C_SMBUS_READ) && 296 if ((data_arg.read_write != I2C_SMBUS_READ) &&
297 (data_arg.read_write != I2C_SMBUS_WRITE)) { 297 (data_arg.read_write != I2C_SMBUS_WRITE)) {
298 dev_dbg(&client->adapter->dev, 298 dev_dbg(&client->adapter->dev,
299 "read_write out of range (%x) in ioctl I2C_SMBUS.\n", 299 "read_write out of range (%x) in ioctl I2C_SMBUS.\n",
300 data_arg.read_write); 300 data_arg.read_write);
301 return -EINVAL; 301 return -EINVAL;
@@ -304,7 +304,7 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file,
304 /* Note that command values are always valid! */ 304 /* Note that command values are always valid! */
305 305
306 if ((data_arg.size == I2C_SMBUS_QUICK) || 306 if ((data_arg.size == I2C_SMBUS_QUICK) ||
307 ((data_arg.size == I2C_SMBUS_BYTE) && 307 ((data_arg.size == I2C_SMBUS_BYTE) &&
308 (data_arg.read_write == I2C_SMBUS_WRITE))) 308 (data_arg.read_write == I2C_SMBUS_WRITE)))
309 /* These are special: we do not use data */ 309 /* These are special: we do not use data */
310 return i2c_smbus_xfer(client->adapter, client->addr, 310 return i2c_smbus_xfer(client->adapter, client->addr,
@@ -322,14 +322,14 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file,
322 if ((data_arg.size == I2C_SMBUS_BYTE_DATA) || 322 if ((data_arg.size == I2C_SMBUS_BYTE_DATA) ||
323 (data_arg.size == I2C_SMBUS_BYTE)) 323 (data_arg.size == I2C_SMBUS_BYTE))
324 datasize = sizeof(data_arg.data->byte); 324 datasize = sizeof(data_arg.data->byte);
325 else if ((data_arg.size == I2C_SMBUS_WORD_DATA) || 325 else if ((data_arg.size == I2C_SMBUS_WORD_DATA) ||
326 (data_arg.size == I2C_SMBUS_PROC_CALL)) 326 (data_arg.size == I2C_SMBUS_PROC_CALL))
327 datasize = sizeof(data_arg.data->word); 327 datasize = sizeof(data_arg.data->word);
328 else /* size == smbus block, i2c block, or block proc. call */ 328 else /* size == smbus block, i2c block, or block proc. call */
329 datasize = sizeof(data_arg.data->block); 329 datasize = sizeof(data_arg.data->block);
330 330
331 if ((data_arg.size == I2C_SMBUS_PROC_CALL) || 331 if ((data_arg.size == I2C_SMBUS_PROC_CALL) ||
332 (data_arg.size == I2C_SMBUS_BLOCK_PROC_CALL) || 332 (data_arg.size == I2C_SMBUS_BLOCK_PROC_CALL) ||
333 (data_arg.read_write == I2C_SMBUS_WRITE)) { 333 (data_arg.read_write == I2C_SMBUS_WRITE)) {
334 if (copy_from_user(&temp, data_arg.data, datasize)) 334 if (copy_from_user(&temp, data_arg.data, datasize))
335 return -EFAULT; 335 return -EFAULT;
@@ -337,8 +337,8 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file,
337 res = i2c_smbus_xfer(client->adapter,client->addr,client->flags, 337 res = i2c_smbus_xfer(client->adapter,client->addr,client->flags,
338 data_arg.read_write, 338 data_arg.read_write,
339 data_arg.command,data_arg.size,&temp); 339 data_arg.command,data_arg.size,&temp);
340 if (! res && ((data_arg.size == I2C_SMBUS_PROC_CALL) || 340 if (! res && ((data_arg.size == I2C_SMBUS_PROC_CALL) ||
341 (data_arg.size == I2C_SMBUS_BLOCK_PROC_CALL) || 341 (data_arg.size == I2C_SMBUS_BLOCK_PROC_CALL) ||
342 (data_arg.read_write == I2C_SMBUS_READ))) { 342 (data_arg.read_write == I2C_SMBUS_READ))) {
343 if (copy_to_user(data_arg.data, &temp, datasize)) 343 if (copy_to_user(data_arg.data, &temp, datasize))
344 return -EFAULT; 344 return -EFAULT;
@@ -417,8 +417,8 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap)
417 i2c_dev->dev = device_create(i2c_dev_class, &adap->dev, 417 i2c_dev->dev = device_create(i2c_dev_class, &adap->dev,
418 MKDEV(I2C_MAJOR, adap->nr), 418 MKDEV(I2C_MAJOR, adap->nr),
419 "i2c-%d", adap->nr); 419 "i2c-%d", adap->nr);
420 if (!i2c_dev->dev) { 420 if (IS_ERR(i2c_dev->dev)) {
421 res = -ENODEV; 421 res = PTR_ERR(i2c_dev->dev);
422 goto error; 422 goto error;
423 } 423 }
424 res = device_create_file(i2c_dev->dev, &dev_attr_name); 424 res = device_create_file(i2c_dev->dev, &dev_attr_name);
@@ -432,7 +432,6 @@ error_destroy:
432 device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); 432 device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr));
433error: 433error:
434 return_i2c_dev(i2c_dev); 434 return_i2c_dev(i2c_dev);
435 kfree(i2c_dev);
436 return res; 435 return res;
437} 436}
438 437
@@ -447,7 +446,6 @@ static int i2cdev_detach_adapter(struct i2c_adapter *adap)
447 device_remove_file(i2c_dev->dev, &dev_attr_name); 446 device_remove_file(i2c_dev->dev, &dev_attr_name);
448 return_i2c_dev(i2c_dev); 447 return_i2c_dev(i2c_dev);
449 device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); 448 device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr));
450 kfree(i2c_dev);
451 449
452 pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name); 450 pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name);
453 return 0; 451 return 0;
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index e23bc0d62159..3f828052f8d2 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -796,7 +796,7 @@ endchoice
796config BLK_DEV_IDE_AU1XXX_SEQTS_PER_RQ 796config BLK_DEV_IDE_AU1XXX_SEQTS_PER_RQ
797 int "Maximum transfer size (KB) per request (up to 128)" 797 int "Maximum transfer size (KB) per request (up to 128)"
798 default "128" 798 default "128"
799 depends BLK_DEV_IDE_AU1XXX 799 depends on BLK_DEV_IDE_AU1XXX
800 800
801config IDE_ARM 801config IDE_ARM
802 def_bool ARM && (ARCH_A5K || ARCH_CLPS7500 || ARCH_RPC || ARCH_SHARK) 802 def_bool ARM && (ARCH_A5K || ARCH_CLPS7500 || ARCH_RPC || ARCH_SHARK)
diff --git a/drivers/ieee1394/pcilynx.c b/drivers/ieee1394/pcilynx.c
index 13a617917bf2..fbb7f14ec509 100644
--- a/drivers/ieee1394/pcilynx.c
+++ b/drivers/ieee1394/pcilynx.c
@@ -1485,7 +1485,7 @@ static int __devinit add_card(struct pci_dev *dev,
1485 1485
1486 } 1486 }
1487 1487
1488 i2c_bit_del_bus(i2c_ad); 1488 i2c_del_adapter(i2c_ad);
1489 kfree(i2c_ad); 1489 kfree(i2c_ad);
1490 } 1490 }
1491 } 1491 }
diff --git a/drivers/infiniband/core/Makefile b/drivers/infiniband/core/Makefile
index 163d991eb8c9..50fb1cd447b7 100644
--- a/drivers/infiniband/core/Makefile
+++ b/drivers/infiniband/core/Makefile
@@ -1,9 +1,11 @@
1infiniband-$(CONFIG_INFINIBAND_ADDR_TRANS) := ib_addr.o rdma_cm.o 1infiniband-$(CONFIG_INFINIBAND_ADDR_TRANS) := ib_addr.o rdma_cm.o
2user_access-$(CONFIG_INFINIBAND_ADDR_TRANS) := rdma_ucm.o
2 3
3obj-$(CONFIG_INFINIBAND) += ib_core.o ib_mad.o ib_sa.o \ 4obj-$(CONFIG_INFINIBAND) += ib_core.o ib_mad.o ib_sa.o \
4 ib_cm.o iw_cm.o $(infiniband-y) 5 ib_cm.o iw_cm.o $(infiniband-y)
5obj-$(CONFIG_INFINIBAND_USER_MAD) += ib_umad.o 6obj-$(CONFIG_INFINIBAND_USER_MAD) += ib_umad.o
6obj-$(CONFIG_INFINIBAND_USER_ACCESS) += ib_uverbs.o ib_ucm.o 7obj-$(CONFIG_INFINIBAND_USER_ACCESS) += ib_uverbs.o ib_ucm.o \
8 $(user_access-y)
7 9
8ib_core-y := packer.o ud_header.o verbs.o sysfs.o \ 10ib_core-y := packer.o ud_header.o verbs.o sysfs.o \
9 device.o fmr_pool.o cache.o 11 device.o fmr_pool.o cache.o
@@ -18,6 +20,8 @@ iw_cm-y := iwcm.o
18 20
19rdma_cm-y := cma.o 21rdma_cm-y := cma.o
20 22
23rdma_ucm-y := ucma.o
24
21ib_addr-y := addr.o 25ib_addr-y := addr.o
22 26
23ib_umad-y := user_mad.o 27ib_umad-y := user_mad.o
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index 79c937bf6962..d446998b12a4 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -3289,6 +3289,10 @@ static int cm_init_qp_rts_attr(struct cm_id_private *cm_id_priv,
3289 3289
3290 spin_lock_irqsave(&cm_id_priv->lock, flags); 3290 spin_lock_irqsave(&cm_id_priv->lock, flags);
3291 switch (cm_id_priv->id.state) { 3291 switch (cm_id_priv->id.state) {
3292 /* Allow transition to RTS before sending REP */
3293 case IB_CM_REQ_RCVD:
3294 case IB_CM_MRA_REQ_SENT:
3295
3292 case IB_CM_REP_RCVD: 3296 case IB_CM_REP_RCVD:
3293 case IB_CM_MRA_REP_SENT: 3297 case IB_CM_MRA_REP_SENT:
3294 case IB_CM_REP_SENT: 3298 case IB_CM_REP_SENT:
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 985a6b564d8f..533193d4e5df 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -70,6 +70,7 @@ static DEFINE_MUTEX(lock);
70static struct workqueue_struct *cma_wq; 70static struct workqueue_struct *cma_wq;
71static DEFINE_IDR(sdp_ps); 71static DEFINE_IDR(sdp_ps);
72static DEFINE_IDR(tcp_ps); 72static DEFINE_IDR(tcp_ps);
73static DEFINE_IDR(udp_ps);
73 74
74struct cma_device { 75struct cma_device {
75 struct list_head list; 76 struct list_head list;
@@ -133,7 +134,6 @@ struct rdma_id_private {
133 134
134 u32 seq_num; 135 u32 seq_num;
135 u32 qp_num; 136 u32 qp_num;
136 enum ib_qp_type qp_type;
137 u8 srq; 137 u8 srq;
138}; 138};
139 139
@@ -392,7 +392,6 @@ int rdma_create_qp(struct rdma_cm_id *id, struct ib_pd *pd,
392 392
393 id->qp = qp; 393 id->qp = qp;
394 id_priv->qp_num = qp->qp_num; 394 id_priv->qp_num = qp->qp_num;
395 id_priv->qp_type = qp->qp_type;
396 id_priv->srq = (qp->srq != NULL); 395 id_priv->srq = (qp->srq != NULL);
397 return 0; 396 return 0;
398err: 397err:
@@ -510,9 +509,17 @@ static inline int cma_any_addr(struct sockaddr *addr)
510 return cma_zero_addr(addr) || cma_loopback_addr(addr); 509 return cma_zero_addr(addr) || cma_loopback_addr(addr);
511} 510}
512 511
512static inline __be16 cma_port(struct sockaddr *addr)
513{
514 if (addr->sa_family == AF_INET)
515 return ((struct sockaddr_in *) addr)->sin_port;
516 else
517 return ((struct sockaddr_in6 *) addr)->sin6_port;
518}
519
513static inline int cma_any_port(struct sockaddr *addr) 520static inline int cma_any_port(struct sockaddr *addr)
514{ 521{
515 return !((struct sockaddr_in *) addr)->sin_port; 522 return !cma_port(addr);
516} 523}
517 524
518static int cma_get_net_info(void *hdr, enum rdma_port_space ps, 525static int cma_get_net_info(void *hdr, enum rdma_port_space ps,
@@ -594,20 +601,6 @@ static inline int cma_user_data_offset(enum rdma_port_space ps)
594 } 601 }
595} 602}
596 603
597static int cma_notify_user(struct rdma_id_private *id_priv,
598 enum rdma_cm_event_type type, int status,
599 void *data, u8 data_len)
600{
601 struct rdma_cm_event event;
602
603 event.event = type;
604 event.status = status;
605 event.private_data = data;
606 event.private_data_len = data_len;
607
608 return id_priv->id.event_handler(&id_priv->id, &event);
609}
610
611static void cma_cancel_route(struct rdma_id_private *id_priv) 604static void cma_cancel_route(struct rdma_id_private *id_priv)
612{ 605{
613 switch (rdma_node_get_transport(id_priv->id.device->node_type)) { 606 switch (rdma_node_get_transport(id_priv->id.device->node_type)) {
@@ -776,63 +769,61 @@ static int cma_verify_rep(struct rdma_id_private *id_priv, void *data)
776 return 0; 769 return 0;
777} 770}
778 771
779static int cma_rtu_recv(struct rdma_id_private *id_priv) 772static void cma_set_rep_event_data(struct rdma_cm_event *event,
773 struct ib_cm_rep_event_param *rep_data,
774 void *private_data)
780{ 775{
781 int ret; 776 event->param.conn.private_data = private_data;
782 777 event->param.conn.private_data_len = IB_CM_REP_PRIVATE_DATA_SIZE;
783 ret = cma_modify_qp_rts(&id_priv->id); 778 event->param.conn.responder_resources = rep_data->responder_resources;
784 if (ret) 779 event->param.conn.initiator_depth = rep_data->initiator_depth;
785 goto reject; 780 event->param.conn.flow_control = rep_data->flow_control;
786 781 event->param.conn.rnr_retry_count = rep_data->rnr_retry_count;
787 return 0; 782 event->param.conn.srq = rep_data->srq;
788reject: 783 event->param.conn.qp_num = rep_data->remote_qpn;
789 cma_modify_qp_err(&id_priv->id);
790 ib_send_cm_rej(id_priv->cm_id.ib, IB_CM_REJ_CONSUMER_DEFINED,
791 NULL, 0, NULL, 0);
792 return ret;
793} 784}
794 785
795static int cma_ib_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event) 786static int cma_ib_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
796{ 787{
797 struct rdma_id_private *id_priv = cm_id->context; 788 struct rdma_id_private *id_priv = cm_id->context;
798 enum rdma_cm_event_type event; 789 struct rdma_cm_event event;
799 u8 private_data_len = 0; 790 int ret = 0;
800 int ret = 0, status = 0;
801 791
802 atomic_inc(&id_priv->dev_remove); 792 atomic_inc(&id_priv->dev_remove);
803 if (!cma_comp(id_priv, CMA_CONNECT)) 793 if (!cma_comp(id_priv, CMA_CONNECT))
804 goto out; 794 goto out;
805 795
796 memset(&event, 0, sizeof event);
806 switch (ib_event->event) { 797 switch (ib_event->event) {
807 case IB_CM_REQ_ERROR: 798 case IB_CM_REQ_ERROR:
808 case IB_CM_REP_ERROR: 799 case IB_CM_REP_ERROR:
809 event = RDMA_CM_EVENT_UNREACHABLE; 800 event.event = RDMA_CM_EVENT_UNREACHABLE;
810 status = -ETIMEDOUT; 801 event.status = -ETIMEDOUT;
811 break; 802 break;
812 case IB_CM_REP_RECEIVED: 803 case IB_CM_REP_RECEIVED:
813 status = cma_verify_rep(id_priv, ib_event->private_data); 804 event.status = cma_verify_rep(id_priv, ib_event->private_data);
814 if (status) 805 if (event.status)
815 event = RDMA_CM_EVENT_CONNECT_ERROR; 806 event.event = RDMA_CM_EVENT_CONNECT_ERROR;
816 else if (id_priv->id.qp && id_priv->id.ps != RDMA_PS_SDP) { 807 else if (id_priv->id.qp && id_priv->id.ps != RDMA_PS_SDP) {
817 status = cma_rep_recv(id_priv); 808 event.status = cma_rep_recv(id_priv);
818 event = status ? RDMA_CM_EVENT_CONNECT_ERROR : 809 event.event = event.status ? RDMA_CM_EVENT_CONNECT_ERROR :
819 RDMA_CM_EVENT_ESTABLISHED; 810 RDMA_CM_EVENT_ESTABLISHED;
820 } else 811 } else
821 event = RDMA_CM_EVENT_CONNECT_RESPONSE; 812 event.event = RDMA_CM_EVENT_CONNECT_RESPONSE;
822 private_data_len = IB_CM_REP_PRIVATE_DATA_SIZE; 813 cma_set_rep_event_data(&event, &ib_event->param.rep_rcvd,
814 ib_event->private_data);
823 break; 815 break;
824 case IB_CM_RTU_RECEIVED: 816 case IB_CM_RTU_RECEIVED:
825 status = cma_rtu_recv(id_priv); 817 case IB_CM_USER_ESTABLISHED:
826 event = status ? RDMA_CM_EVENT_CONNECT_ERROR : 818 event.event = RDMA_CM_EVENT_ESTABLISHED;
827 RDMA_CM_EVENT_ESTABLISHED;
828 break; 819 break;
829 case IB_CM_DREQ_ERROR: 820 case IB_CM_DREQ_ERROR:
830 status = -ETIMEDOUT; /* fall through */ 821 event.status = -ETIMEDOUT; /* fall through */
831 case IB_CM_DREQ_RECEIVED: 822 case IB_CM_DREQ_RECEIVED:
832 case IB_CM_DREP_RECEIVED: 823 case IB_CM_DREP_RECEIVED:
833 if (!cma_comp_exch(id_priv, CMA_CONNECT, CMA_DISCONNECT)) 824 if (!cma_comp_exch(id_priv, CMA_CONNECT, CMA_DISCONNECT))
834 goto out; 825 goto out;
835 event = RDMA_CM_EVENT_DISCONNECTED; 826 event.event = RDMA_CM_EVENT_DISCONNECTED;
836 break; 827 break;
837 case IB_CM_TIMEWAIT_EXIT: 828 case IB_CM_TIMEWAIT_EXIT:
838 case IB_CM_MRA_RECEIVED: 829 case IB_CM_MRA_RECEIVED:
@@ -840,9 +831,10 @@ static int cma_ib_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
840 goto out; 831 goto out;
841 case IB_CM_REJ_RECEIVED: 832 case IB_CM_REJ_RECEIVED:
842 cma_modify_qp_err(&id_priv->id); 833 cma_modify_qp_err(&id_priv->id);
843 status = ib_event->param.rej_rcvd.reason; 834 event.status = ib_event->param.rej_rcvd.reason;
844 event = RDMA_CM_EVENT_REJECTED; 835 event.event = RDMA_CM_EVENT_REJECTED;
845 private_data_len = IB_CM_REJ_PRIVATE_DATA_SIZE; 836 event.param.conn.private_data = ib_event->private_data;
837 event.param.conn.private_data_len = IB_CM_REJ_PRIVATE_DATA_SIZE;
846 break; 838 break;
847 default: 839 default:
848 printk(KERN_ERR "RDMA CMA: unexpected IB CM event: %d", 840 printk(KERN_ERR "RDMA CMA: unexpected IB CM event: %d",
@@ -850,8 +842,7 @@ static int cma_ib_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
850 goto out; 842 goto out;
851 } 843 }
852 844
853 ret = cma_notify_user(id_priv, event, status, ib_event->private_data, 845 ret = id_priv->id.event_handler(&id_priv->id, &event);
854 private_data_len);
855 if (ret) { 846 if (ret) {
856 /* Destroy the CM ID by returning a non-zero value. */ 847 /* Destroy the CM ID by returning a non-zero value. */
857 id_priv->cm_id.ib = NULL; 848 id_priv->cm_id.ib = NULL;
@@ -865,8 +856,8 @@ out:
865 return ret; 856 return ret;
866} 857}
867 858
868static struct rdma_id_private *cma_new_id(struct rdma_cm_id *listen_id, 859static struct rdma_id_private *cma_new_conn_id(struct rdma_cm_id *listen_id,
869 struct ib_cm_event *ib_event) 860 struct ib_cm_event *ib_event)
870{ 861{
871 struct rdma_id_private *id_priv; 862 struct rdma_id_private *id_priv;
872 struct rdma_cm_id *id; 863 struct rdma_cm_id *id;
@@ -913,9 +904,61 @@ err:
913 return NULL; 904 return NULL;
914} 905}
915 906
907static struct rdma_id_private *cma_new_udp_id(struct rdma_cm_id *listen_id,
908 struct ib_cm_event *ib_event)
909{
910 struct rdma_id_private *id_priv;
911 struct rdma_cm_id *id;
912 union cma_ip_addr *src, *dst;
913 __u16 port;
914 u8 ip_ver;
915 int ret;
916
917 id = rdma_create_id(listen_id->event_handler, listen_id->context,
918 listen_id->ps);
919 if (IS_ERR(id))
920 return NULL;
921
922
923 if (cma_get_net_info(ib_event->private_data, listen_id->ps,
924 &ip_ver, &port, &src, &dst))
925 goto err;
926
927 cma_save_net_info(&id->route.addr, &listen_id->route.addr,
928 ip_ver, port, src, dst);
929
930 ret = rdma_translate_ip(&id->route.addr.src_addr,
931 &id->route.addr.dev_addr);
932 if (ret)
933 goto err;
934
935 id_priv = container_of(id, struct rdma_id_private, id);
936 id_priv->state = CMA_CONNECT;
937 return id_priv;
938err:
939 rdma_destroy_id(id);
940 return NULL;
941}
942
943static void cma_set_req_event_data(struct rdma_cm_event *event,
944 struct ib_cm_req_event_param *req_data,
945 void *private_data, int offset)
946{
947 event->param.conn.private_data = private_data + offset;
948 event->param.conn.private_data_len = IB_CM_REQ_PRIVATE_DATA_SIZE - offset;
949 event->param.conn.responder_resources = req_data->responder_resources;
950 event->param.conn.initiator_depth = req_data->initiator_depth;
951 event->param.conn.flow_control = req_data->flow_control;
952 event->param.conn.retry_count = req_data->retry_count;
953 event->param.conn.rnr_retry_count = req_data->rnr_retry_count;
954 event->param.conn.srq = req_data->srq;
955 event->param.conn.qp_num = req_data->remote_qpn;
956}
957
916static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event) 958static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
917{ 959{
918 struct rdma_id_private *listen_id, *conn_id; 960 struct rdma_id_private *listen_id, *conn_id;
961 struct rdma_cm_event event;
919 int offset, ret; 962 int offset, ret;
920 963
921 listen_id = cm_id->context; 964 listen_id = cm_id->context;
@@ -925,7 +968,19 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
925 goto out; 968 goto out;
926 } 969 }
927 970
928 conn_id = cma_new_id(&listen_id->id, ib_event); 971 memset(&event, 0, sizeof event);
972 offset = cma_user_data_offset(listen_id->id.ps);
973 event.event = RDMA_CM_EVENT_CONNECT_REQUEST;
974 if (listen_id->id.ps == RDMA_PS_UDP) {
975 conn_id = cma_new_udp_id(&listen_id->id, ib_event);
976 event.param.ud.private_data = ib_event->private_data + offset;
977 event.param.ud.private_data_len =
978 IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE - offset;
979 } else {
980 conn_id = cma_new_conn_id(&listen_id->id, ib_event);
981 cma_set_req_event_data(&event, &ib_event->param.req_rcvd,
982 ib_event->private_data, offset);
983 }
929 if (!conn_id) { 984 if (!conn_id) {
930 ret = -ENOMEM; 985 ret = -ENOMEM;
931 goto out; 986 goto out;
@@ -942,10 +997,7 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
942 cm_id->context = conn_id; 997 cm_id->context = conn_id;
943 cm_id->cm_handler = cma_ib_handler; 998 cm_id->cm_handler = cma_ib_handler;
944 999
945 offset = cma_user_data_offset(listen_id->id.ps); 1000 ret = conn_id->id.event_handler(&conn_id->id, &event);
946 ret = cma_notify_user(conn_id, RDMA_CM_EVENT_CONNECT_REQUEST, 0,
947 ib_event->private_data + offset,
948 IB_CM_REQ_PRIVATE_DATA_SIZE - offset);
949 if (!ret) 1001 if (!ret)
950 goto out; 1002 goto out;
951 1003
@@ -964,8 +1016,7 @@ out:
964 1016
965static __be64 cma_get_service_id(enum rdma_port_space ps, struct sockaddr *addr) 1017static __be64 cma_get_service_id(enum rdma_port_space ps, struct sockaddr *addr)
966{ 1018{
967 return cpu_to_be64(((u64)ps << 16) + 1019 return cpu_to_be64(((u64)ps << 16) + be16_to_cpu(cma_port(addr)));
968 be16_to_cpu(((struct sockaddr_in *) addr)->sin_port));
969} 1020}
970 1021
971static void cma_set_compare_data(enum rdma_port_space ps, struct sockaddr *addr, 1022static void cma_set_compare_data(enum rdma_port_space ps, struct sockaddr *addr,
@@ -1021,15 +1072,16 @@ static void cma_set_compare_data(enum rdma_port_space ps, struct sockaddr *addr,
1021static int cma_iw_handler(struct iw_cm_id *iw_id, struct iw_cm_event *iw_event) 1072static int cma_iw_handler(struct iw_cm_id *iw_id, struct iw_cm_event *iw_event)
1022{ 1073{
1023 struct rdma_id_private *id_priv = iw_id->context; 1074 struct rdma_id_private *id_priv = iw_id->context;
1024 enum rdma_cm_event_type event = 0; 1075 struct rdma_cm_event event;
1025 struct sockaddr_in *sin; 1076 struct sockaddr_in *sin;
1026 int ret = 0; 1077 int ret = 0;
1027 1078
1079 memset(&event, 0, sizeof event);
1028 atomic_inc(&id_priv->dev_remove); 1080 atomic_inc(&id_priv->dev_remove);
1029 1081
1030 switch (iw_event->event) { 1082 switch (iw_event->event) {
1031 case IW_CM_EVENT_CLOSE: 1083 case IW_CM_EVENT_CLOSE:
1032 event = RDMA_CM_EVENT_DISCONNECTED; 1084 event.event = RDMA_CM_EVENT_DISCONNECTED;
1033 break; 1085 break;
1034 case IW_CM_EVENT_CONNECT_REPLY: 1086 case IW_CM_EVENT_CONNECT_REPLY:
1035 sin = (struct sockaddr_in *) &id_priv->id.route.addr.src_addr; 1087 sin = (struct sockaddr_in *) &id_priv->id.route.addr.src_addr;
@@ -1037,20 +1089,21 @@ static int cma_iw_handler(struct iw_cm_id *iw_id, struct iw_cm_event *iw_event)
1037 sin = (struct sockaddr_in *) &id_priv->id.route.addr.dst_addr; 1089 sin = (struct sockaddr_in *) &id_priv->id.route.addr.dst_addr;
1038 *sin = iw_event->remote_addr; 1090 *sin = iw_event->remote_addr;
1039 if (iw_event->status) 1091 if (iw_event->status)
1040 event = RDMA_CM_EVENT_REJECTED; 1092 event.event = RDMA_CM_EVENT_REJECTED;
1041 else 1093 else
1042 event = RDMA_CM_EVENT_ESTABLISHED; 1094 event.event = RDMA_CM_EVENT_ESTABLISHED;
1043 break; 1095 break;
1044 case IW_CM_EVENT_ESTABLISHED: 1096 case IW_CM_EVENT_ESTABLISHED:
1045 event = RDMA_CM_EVENT_ESTABLISHED; 1097 event.event = RDMA_CM_EVENT_ESTABLISHED;
1046 break; 1098 break;
1047 default: 1099 default:
1048 BUG_ON(1); 1100 BUG_ON(1);
1049 } 1101 }
1050 1102
1051 ret = cma_notify_user(id_priv, event, iw_event->status, 1103 event.status = iw_event->status;
1052 iw_event->private_data, 1104 event.param.conn.private_data = iw_event->private_data;
1053 iw_event->private_data_len); 1105 event.param.conn.private_data_len = iw_event->private_data_len;
1106 ret = id_priv->id.event_handler(&id_priv->id, &event);
1054 if (ret) { 1107 if (ret) {
1055 /* Destroy the CM ID by returning a non-zero value. */ 1108 /* Destroy the CM ID by returning a non-zero value. */
1056 id_priv->cm_id.iw = NULL; 1109 id_priv->cm_id.iw = NULL;
@@ -1071,6 +1124,7 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id,
1071 struct rdma_id_private *listen_id, *conn_id; 1124 struct rdma_id_private *listen_id, *conn_id;
1072 struct sockaddr_in *sin; 1125 struct sockaddr_in *sin;
1073 struct net_device *dev = NULL; 1126 struct net_device *dev = NULL;
1127 struct rdma_cm_event event;
1074 int ret; 1128 int ret;
1075 1129
1076 listen_id = cm_id->context; 1130 listen_id = cm_id->context;
@@ -1124,9 +1178,11 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id,
1124 sin = (struct sockaddr_in *) &new_cm_id->route.addr.dst_addr; 1178 sin = (struct sockaddr_in *) &new_cm_id->route.addr.dst_addr;
1125 *sin = iw_event->remote_addr; 1179 *sin = iw_event->remote_addr;
1126 1180
1127 ret = cma_notify_user(conn_id, RDMA_CM_EVENT_CONNECT_REQUEST, 0, 1181 memset(&event, 0, sizeof event);
1128 iw_event->private_data, 1182 event.event = RDMA_CM_EVENT_CONNECT_REQUEST;
1129 iw_event->private_data_len); 1183 event.param.conn.private_data = iw_event->private_data;
1184 event.param.conn.private_data_len = iw_event->private_data_len;
1185 ret = conn_id->id.event_handler(&conn_id->id, &event);
1130 if (ret) { 1186 if (ret) {
1131 /* User wants to destroy the CM ID */ 1187 /* User wants to destroy the CM ID */
1132 conn_id->cm_id.iw = NULL; 1188 conn_id->cm_id.iw = NULL;
@@ -1515,8 +1571,9 @@ static void addr_handler(int status, struct sockaddr *src_addr,
1515 struct rdma_dev_addr *dev_addr, void *context) 1571 struct rdma_dev_addr *dev_addr, void *context)
1516{ 1572{
1517 struct rdma_id_private *id_priv = context; 1573 struct rdma_id_private *id_priv = context;
1518 enum rdma_cm_event_type event; 1574 struct rdma_cm_event event;
1519 1575
1576 memset(&event, 0, sizeof event);
1520 atomic_inc(&id_priv->dev_remove); 1577 atomic_inc(&id_priv->dev_remove);
1521 1578
1522 /* 1579 /*
@@ -1536,14 +1593,15 @@ static void addr_handler(int status, struct sockaddr *src_addr,
1536 if (status) { 1593 if (status) {
1537 if (!cma_comp_exch(id_priv, CMA_ADDR_RESOLVED, CMA_ADDR_BOUND)) 1594 if (!cma_comp_exch(id_priv, CMA_ADDR_RESOLVED, CMA_ADDR_BOUND))
1538 goto out; 1595 goto out;
1539 event = RDMA_CM_EVENT_ADDR_ERROR; 1596 event.event = RDMA_CM_EVENT_ADDR_ERROR;
1597 event.status = status;
1540 } else { 1598 } else {
1541 memcpy(&id_priv->id.route.addr.src_addr, src_addr, 1599 memcpy(&id_priv->id.route.addr.src_addr, src_addr,
1542 ip_addr_size(src_addr)); 1600 ip_addr_size(src_addr));
1543 event = RDMA_CM_EVENT_ADDR_RESOLVED; 1601 event.event = RDMA_CM_EVENT_ADDR_RESOLVED;
1544 } 1602 }
1545 1603
1546 if (cma_notify_user(id_priv, event, status, NULL, 0)) { 1604 if (id_priv->id.event_handler(&id_priv->id, &event)) {
1547 cma_exch(id_priv, CMA_DESTROYING); 1605 cma_exch(id_priv, CMA_DESTROYING);
1548 cma_release_remove(id_priv); 1606 cma_release_remove(id_priv);
1549 cma_deref_id(id_priv); 1607 cma_deref_id(id_priv);
@@ -1733,6 +1791,9 @@ static int cma_get_port(struct rdma_id_private *id_priv)
1733 case RDMA_PS_TCP: 1791 case RDMA_PS_TCP:
1734 ps = &tcp_ps; 1792 ps = &tcp_ps;
1735 break; 1793 break;
1794 case RDMA_PS_UDP:
1795 ps = &udp_ps;
1796 break;
1736 default: 1797 default:
1737 return -EPROTONOSUPPORT; 1798 return -EPROTONOSUPPORT;
1738 } 1799 }
@@ -1821,6 +1882,110 @@ static int cma_format_hdr(void *hdr, enum rdma_port_space ps,
1821 return 0; 1882 return 0;
1822} 1883}
1823 1884
1885static int cma_sidr_rep_handler(struct ib_cm_id *cm_id,
1886 struct ib_cm_event *ib_event)
1887{
1888 struct rdma_id_private *id_priv = cm_id->context;
1889 struct rdma_cm_event event;
1890 struct ib_cm_sidr_rep_event_param *rep = &ib_event->param.sidr_rep_rcvd;
1891 int ret = 0;
1892
1893 memset(&event, 0, sizeof event);
1894 atomic_inc(&id_priv->dev_remove);
1895 if (!cma_comp(id_priv, CMA_CONNECT))
1896 goto out;
1897
1898 switch (ib_event->event) {
1899 case IB_CM_SIDR_REQ_ERROR:
1900 event.event = RDMA_CM_EVENT_UNREACHABLE;
1901 event.status = -ETIMEDOUT;
1902 break;
1903 case IB_CM_SIDR_REP_RECEIVED:
1904 event.param.ud.private_data = ib_event->private_data;
1905 event.param.ud.private_data_len = IB_CM_SIDR_REP_PRIVATE_DATA_SIZE;
1906 if (rep->status != IB_SIDR_SUCCESS) {
1907 event.event = RDMA_CM_EVENT_UNREACHABLE;
1908 event.status = ib_event->param.sidr_rep_rcvd.status;
1909 break;
1910 }
1911 if (rep->qkey != RDMA_UD_QKEY) {
1912 event.event = RDMA_CM_EVENT_UNREACHABLE;
1913 event.status = -EINVAL;
1914 break;
1915 }
1916 ib_init_ah_from_path(id_priv->id.device, id_priv->id.port_num,
1917 id_priv->id.route.path_rec,
1918 &event.param.ud.ah_attr);
1919 event.param.ud.qp_num = rep->qpn;
1920 event.param.ud.qkey = rep->qkey;
1921 event.event = RDMA_CM_EVENT_ESTABLISHED;
1922 event.status = 0;
1923 break;
1924 default:
1925 printk(KERN_ERR "RDMA CMA: unexpected IB CM event: %d",
1926 ib_event->event);
1927 goto out;
1928 }
1929
1930 ret = id_priv->id.event_handler(&id_priv->id, &event);
1931 if (ret) {
1932 /* Destroy the CM ID by returning a non-zero value. */
1933 id_priv->cm_id.ib = NULL;
1934 cma_exch(id_priv, CMA_DESTROYING);
1935 cma_release_remove(id_priv);
1936 rdma_destroy_id(&id_priv->id);
1937 return ret;
1938 }
1939out:
1940 cma_release_remove(id_priv);
1941 return ret;
1942}
1943
1944static int cma_resolve_ib_udp(struct rdma_id_private *id_priv,
1945 struct rdma_conn_param *conn_param)
1946{
1947 struct ib_cm_sidr_req_param req;
1948 struct rdma_route *route;
1949 int ret;
1950
1951 req.private_data_len = sizeof(struct cma_hdr) +
1952 conn_param->private_data_len;
1953 req.private_data = kzalloc(req.private_data_len, GFP_ATOMIC);
1954 if (!req.private_data)
1955 return -ENOMEM;
1956
1957 if (conn_param->private_data && conn_param->private_data_len)
1958 memcpy((void *) req.private_data + sizeof(struct cma_hdr),
1959 conn_param->private_data, conn_param->private_data_len);
1960
1961 route = &id_priv->id.route;
1962 ret = cma_format_hdr((void *) req.private_data, id_priv->id.ps, route);
1963 if (ret)
1964 goto out;
1965
1966 id_priv->cm_id.ib = ib_create_cm_id(id_priv->id.device,
1967 cma_sidr_rep_handler, id_priv);
1968 if (IS_ERR(id_priv->cm_id.ib)) {
1969 ret = PTR_ERR(id_priv->cm_id.ib);
1970 goto out;
1971 }
1972
1973 req.path = route->path_rec;
1974 req.service_id = cma_get_service_id(id_priv->id.ps,
1975 &route->addr.dst_addr);
1976 req.timeout_ms = 1 << (CMA_CM_RESPONSE_TIMEOUT - 8);
1977 req.max_cm_retries = CMA_MAX_CM_RETRIES;
1978
1979 ret = ib_send_cm_sidr_req(id_priv->cm_id.ib, &req);
1980 if (ret) {
1981 ib_destroy_cm_id(id_priv->cm_id.ib);
1982 id_priv->cm_id.ib = NULL;
1983 }
1984out:
1985 kfree(req.private_data);
1986 return ret;
1987}
1988
1824static int cma_connect_ib(struct rdma_id_private *id_priv, 1989static int cma_connect_ib(struct rdma_id_private *id_priv,
1825 struct rdma_conn_param *conn_param) 1990 struct rdma_conn_param *conn_param)
1826{ 1991{
@@ -1860,7 +2025,7 @@ static int cma_connect_ib(struct rdma_id_private *id_priv,
1860 req.service_id = cma_get_service_id(id_priv->id.ps, 2025 req.service_id = cma_get_service_id(id_priv->id.ps,
1861 &route->addr.dst_addr); 2026 &route->addr.dst_addr);
1862 req.qp_num = id_priv->qp_num; 2027 req.qp_num = id_priv->qp_num;
1863 req.qp_type = id_priv->qp_type; 2028 req.qp_type = IB_QPT_RC;
1864 req.starting_psn = id_priv->seq_num; 2029 req.starting_psn = id_priv->seq_num;
1865 req.responder_resources = conn_param->responder_resources; 2030 req.responder_resources = conn_param->responder_resources;
1866 req.initiator_depth = conn_param->initiator_depth; 2031 req.initiator_depth = conn_param->initiator_depth;
@@ -1937,13 +2102,15 @@ int rdma_connect(struct rdma_cm_id *id, struct rdma_conn_param *conn_param)
1937 2102
1938 if (!id->qp) { 2103 if (!id->qp) {
1939 id_priv->qp_num = conn_param->qp_num; 2104 id_priv->qp_num = conn_param->qp_num;
1940 id_priv->qp_type = conn_param->qp_type;
1941 id_priv->srq = conn_param->srq; 2105 id_priv->srq = conn_param->srq;
1942 } 2106 }
1943 2107
1944 switch (rdma_node_get_transport(id->device->node_type)) { 2108 switch (rdma_node_get_transport(id->device->node_type)) {
1945 case RDMA_TRANSPORT_IB: 2109 case RDMA_TRANSPORT_IB:
1946 ret = cma_connect_ib(id_priv, conn_param); 2110 if (id->ps == RDMA_PS_UDP)
2111 ret = cma_resolve_ib_udp(id_priv, conn_param);
2112 else
2113 ret = cma_connect_ib(id_priv, conn_param);
1947 break; 2114 break;
1948 case RDMA_TRANSPORT_IWARP: 2115 case RDMA_TRANSPORT_IWARP:
1949 ret = cma_connect_iw(id_priv, conn_param); 2116 ret = cma_connect_iw(id_priv, conn_param);
@@ -1966,11 +2133,25 @@ static int cma_accept_ib(struct rdma_id_private *id_priv,
1966 struct rdma_conn_param *conn_param) 2133 struct rdma_conn_param *conn_param)
1967{ 2134{
1968 struct ib_cm_rep_param rep; 2135 struct ib_cm_rep_param rep;
1969 int ret; 2136 struct ib_qp_attr qp_attr;
2137 int qp_attr_mask, ret;
1970 2138
1971 ret = cma_modify_qp_rtr(&id_priv->id); 2139 if (id_priv->id.qp) {
1972 if (ret) 2140 ret = cma_modify_qp_rtr(&id_priv->id);
1973 return ret; 2141 if (ret)
2142 goto out;
2143
2144 qp_attr.qp_state = IB_QPS_RTS;
2145 ret = ib_cm_init_qp_attr(id_priv->cm_id.ib, &qp_attr,
2146 &qp_attr_mask);
2147 if (ret)
2148 goto out;
2149
2150 qp_attr.max_rd_atomic = conn_param->initiator_depth;
2151 ret = ib_modify_qp(id_priv->id.qp, &qp_attr, qp_attr_mask);
2152 if (ret)
2153 goto out;
2154 }
1974 2155
1975 memset(&rep, 0, sizeof rep); 2156 memset(&rep, 0, sizeof rep);
1976 rep.qp_num = id_priv->qp_num; 2157 rep.qp_num = id_priv->qp_num;
@@ -1985,7 +2166,9 @@ static int cma_accept_ib(struct rdma_id_private *id_priv,
1985 rep.rnr_retry_count = conn_param->rnr_retry_count; 2166 rep.rnr_retry_count = conn_param->rnr_retry_count;
1986 rep.srq = id_priv->srq ? 1 : 0; 2167 rep.srq = id_priv->srq ? 1 : 0;
1987 2168
1988 return ib_send_cm_rep(id_priv->cm_id.ib, &rep); 2169 ret = ib_send_cm_rep(id_priv->cm_id.ib, &rep);
2170out:
2171 return ret;
1989} 2172}
1990 2173
1991static int cma_accept_iw(struct rdma_id_private *id_priv, 2174static int cma_accept_iw(struct rdma_id_private *id_priv,
@@ -2010,6 +2193,24 @@ static int cma_accept_iw(struct rdma_id_private *id_priv,
2010 return iw_cm_accept(id_priv->cm_id.iw, &iw_param); 2193 return iw_cm_accept(id_priv->cm_id.iw, &iw_param);
2011} 2194}
2012 2195
2196static int cma_send_sidr_rep(struct rdma_id_private *id_priv,
2197 enum ib_cm_sidr_status status,
2198 const void *private_data, int private_data_len)
2199{
2200 struct ib_cm_sidr_rep_param rep;
2201
2202 memset(&rep, 0, sizeof rep);
2203 rep.status = status;
2204 if (status == IB_SIDR_SUCCESS) {
2205 rep.qp_num = id_priv->qp_num;
2206 rep.qkey = RDMA_UD_QKEY;
2207 }
2208 rep.private_data = private_data;
2209 rep.private_data_len = private_data_len;
2210
2211 return ib_send_cm_sidr_rep(id_priv->cm_id.ib, &rep);
2212}
2213
2013int rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param) 2214int rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param)
2014{ 2215{
2015 struct rdma_id_private *id_priv; 2216 struct rdma_id_private *id_priv;
@@ -2021,13 +2222,16 @@ int rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param)
2021 2222
2022 if (!id->qp && conn_param) { 2223 if (!id->qp && conn_param) {
2023 id_priv->qp_num = conn_param->qp_num; 2224 id_priv->qp_num = conn_param->qp_num;
2024 id_priv->qp_type = conn_param->qp_type;
2025 id_priv->srq = conn_param->srq; 2225 id_priv->srq = conn_param->srq;
2026 } 2226 }
2027 2227
2028 switch (rdma_node_get_transport(id->device->node_type)) { 2228 switch (rdma_node_get_transport(id->device->node_type)) {
2029 case RDMA_TRANSPORT_IB: 2229 case RDMA_TRANSPORT_IB:
2030 if (conn_param) 2230 if (id->ps == RDMA_PS_UDP)
2231 ret = cma_send_sidr_rep(id_priv, IB_SIDR_SUCCESS,
2232 conn_param->private_data,
2233 conn_param->private_data_len);
2234 else if (conn_param)
2031 ret = cma_accept_ib(id_priv, conn_param); 2235 ret = cma_accept_ib(id_priv, conn_param);
2032 else 2236 else
2033 ret = cma_rep_recv(id_priv); 2237 ret = cma_rep_recv(id_priv);
@@ -2051,6 +2255,27 @@ reject:
2051} 2255}
2052EXPORT_SYMBOL(rdma_accept); 2256EXPORT_SYMBOL(rdma_accept);
2053 2257
2258int rdma_notify(struct rdma_cm_id *id, enum ib_event_type event)
2259{
2260 struct rdma_id_private *id_priv;
2261 int ret;
2262
2263 id_priv = container_of(id, struct rdma_id_private, id);
2264 if (!cma_comp(id_priv, CMA_CONNECT))
2265 return -EINVAL;
2266
2267 switch (id->device->node_type) {
2268 case RDMA_NODE_IB_CA:
2269 ret = ib_cm_notify(id_priv->cm_id.ib, event);
2270 break;
2271 default:
2272 ret = 0;
2273 break;
2274 }
2275 return ret;
2276}
2277EXPORT_SYMBOL(rdma_notify);
2278
2054int rdma_reject(struct rdma_cm_id *id, const void *private_data, 2279int rdma_reject(struct rdma_cm_id *id, const void *private_data,
2055 u8 private_data_len) 2280 u8 private_data_len)
2056{ 2281{
@@ -2063,9 +2288,13 @@ int rdma_reject(struct rdma_cm_id *id, const void *private_data,
2063 2288
2064 switch (rdma_node_get_transport(id->device->node_type)) { 2289 switch (rdma_node_get_transport(id->device->node_type)) {
2065 case RDMA_TRANSPORT_IB: 2290 case RDMA_TRANSPORT_IB:
2066 ret = ib_send_cm_rej(id_priv->cm_id.ib, 2291 if (id->ps == RDMA_PS_UDP)
2067 IB_CM_REJ_CONSUMER_DEFINED, NULL, 0, 2292 ret = cma_send_sidr_rep(id_priv, IB_SIDR_REJECT,
2068 private_data, private_data_len); 2293 private_data, private_data_len);
2294 else
2295 ret = ib_send_cm_rej(id_priv->cm_id.ib,
2296 IB_CM_REJ_CONSUMER_DEFINED, NULL,
2297 0, private_data, private_data_len);
2069 break; 2298 break;
2070 case RDMA_TRANSPORT_IWARP: 2299 case RDMA_TRANSPORT_IWARP:
2071 ret = iw_cm_reject(id_priv->cm_id.iw, 2300 ret = iw_cm_reject(id_priv->cm_id.iw,
@@ -2136,6 +2365,7 @@ static void cma_add_one(struct ib_device *device)
2136 2365
2137static int cma_remove_id_dev(struct rdma_id_private *id_priv) 2366static int cma_remove_id_dev(struct rdma_id_private *id_priv)
2138{ 2367{
2368 struct rdma_cm_event event;
2139 enum cma_state state; 2369 enum cma_state state;
2140 2370
2141 /* Record that we want to remove the device */ 2371 /* Record that we want to remove the device */
@@ -2150,8 +2380,9 @@ static int cma_remove_id_dev(struct rdma_id_private *id_priv)
2150 if (!cma_comp(id_priv, CMA_DEVICE_REMOVAL)) 2380 if (!cma_comp(id_priv, CMA_DEVICE_REMOVAL))
2151 return 0; 2381 return 0;
2152 2382
2153 return cma_notify_user(id_priv, RDMA_CM_EVENT_DEVICE_REMOVAL, 2383 memset(&event, 0, sizeof event);
2154 0, NULL, 0); 2384 event.event = RDMA_CM_EVENT_DEVICE_REMOVAL;
2385 return id_priv->id.event_handler(&id_priv->id, &event);
2155} 2386}
2156 2387
2157static void cma_process_remove(struct cma_device *cma_dev) 2388static void cma_process_remove(struct cma_device *cma_dev)
@@ -2233,6 +2464,7 @@ static void cma_cleanup(void)
2233 destroy_workqueue(cma_wq); 2464 destroy_workqueue(cma_wq);
2234 idr_destroy(&sdp_ps); 2465 idr_destroy(&sdp_ps);
2235 idr_destroy(&tcp_ps); 2466 idr_destroy(&tcp_ps);
2467 idr_destroy(&udp_ps);
2236} 2468}
2237 2469
2238module_init(cma_init); 2470module_init(cma_init);
diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
index 86a3b2d401db..8926a2bd4a87 100644
--- a/drivers/infiniband/core/fmr_pool.c
+++ b/drivers/infiniband/core/fmr_pool.c
@@ -394,20 +394,12 @@ EXPORT_SYMBOL(ib_destroy_fmr_pool);
394 */ 394 */
395int ib_flush_fmr_pool(struct ib_fmr_pool *pool) 395int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
396{ 396{
397 int serial; 397 int serial = atomic_inc_return(&pool->req_ser);
398
399 atomic_inc(&pool->req_ser);
400 /*
401 * It's OK if someone else bumps req_ser again here -- we'll
402 * just wait a little longer.
403 */
404 serial = atomic_read(&pool->req_ser);
405 398
406 wake_up_process(pool->thread); 399 wake_up_process(pool->thread);
407 400
408 if (wait_event_interruptible(pool->force_wait, 401 if (wait_event_interruptible(pool->force_wait,
409 atomic_read(&pool->flush_ser) - 402 atomic_read(&pool->flush_ser) - serial >= 0))
410 atomic_read(&pool->req_ser) >= 0))
411 return -EINTR; 403 return -EINTR;
412 404
413 return 0; 405 return 0;
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index 15f38d94b3a8..5ed141ebd1c8 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -998,17 +998,17 @@ int ib_send_mad(struct ib_mad_send_wr_private *mad_send_wr)
998 998
999 mad_agent = mad_send_wr->send_buf.mad_agent; 999 mad_agent = mad_send_wr->send_buf.mad_agent;
1000 sge = mad_send_wr->sg_list; 1000 sge = mad_send_wr->sg_list;
1001 sge[0].addr = dma_map_single(mad_agent->device->dma_device, 1001 sge[0].addr = ib_dma_map_single(mad_agent->device,
1002 mad_send_wr->send_buf.mad, 1002 mad_send_wr->send_buf.mad,
1003 sge[0].length, 1003 sge[0].length,
1004 DMA_TO_DEVICE); 1004 DMA_TO_DEVICE);
1005 pci_unmap_addr_set(mad_send_wr, header_mapping, sge[0].addr); 1005 mad_send_wr->header_mapping = sge[0].addr;
1006 1006
1007 sge[1].addr = dma_map_single(mad_agent->device->dma_device, 1007 sge[1].addr = ib_dma_map_single(mad_agent->device,
1008 ib_get_payload(mad_send_wr), 1008 ib_get_payload(mad_send_wr),
1009 sge[1].length, 1009 sge[1].length,
1010 DMA_TO_DEVICE); 1010 DMA_TO_DEVICE);
1011 pci_unmap_addr_set(mad_send_wr, payload_mapping, sge[1].addr); 1011 mad_send_wr->payload_mapping = sge[1].addr;
1012 1012
1013 spin_lock_irqsave(&qp_info->send_queue.lock, flags); 1013 spin_lock_irqsave(&qp_info->send_queue.lock, flags);
1014 if (qp_info->send_queue.count < qp_info->send_queue.max_active) { 1014 if (qp_info->send_queue.count < qp_info->send_queue.max_active) {
@@ -1026,12 +1026,12 @@ int ib_send_mad(struct ib_mad_send_wr_private *mad_send_wr)
1026 } 1026 }
1027 spin_unlock_irqrestore(&qp_info->send_queue.lock, flags); 1027 spin_unlock_irqrestore(&qp_info->send_queue.lock, flags);
1028 if (ret) { 1028 if (ret) {
1029 dma_unmap_single(mad_agent->device->dma_device, 1029 ib_dma_unmap_single(mad_agent->device,
1030 pci_unmap_addr(mad_send_wr, header_mapping), 1030 mad_send_wr->header_mapping,
1031 sge[0].length, DMA_TO_DEVICE); 1031 sge[0].length, DMA_TO_DEVICE);
1032 dma_unmap_single(mad_agent->device->dma_device, 1032 ib_dma_unmap_single(mad_agent->device,
1033 pci_unmap_addr(mad_send_wr, payload_mapping), 1033 mad_send_wr->payload_mapping,
1034 sge[1].length, DMA_TO_DEVICE); 1034 sge[1].length, DMA_TO_DEVICE);
1035 } 1035 }
1036 return ret; 1036 return ret;
1037} 1037}
@@ -1850,11 +1850,11 @@ static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv,
1850 mad_priv_hdr = container_of(mad_list, struct ib_mad_private_header, 1850 mad_priv_hdr = container_of(mad_list, struct ib_mad_private_header,
1851 mad_list); 1851 mad_list);
1852 recv = container_of(mad_priv_hdr, struct ib_mad_private, header); 1852 recv = container_of(mad_priv_hdr, struct ib_mad_private, header);
1853 dma_unmap_single(port_priv->device->dma_device, 1853 ib_dma_unmap_single(port_priv->device,
1854 pci_unmap_addr(&recv->header, mapping), 1854 recv->header.mapping,
1855 sizeof(struct ib_mad_private) - 1855 sizeof(struct ib_mad_private) -
1856 sizeof(struct ib_mad_private_header), 1856 sizeof(struct ib_mad_private_header),
1857 DMA_FROM_DEVICE); 1857 DMA_FROM_DEVICE);
1858 1858
1859 /* Setup MAD receive work completion from "normal" work completion */ 1859 /* Setup MAD receive work completion from "normal" work completion */
1860 recv->header.wc = *wc; 1860 recv->header.wc = *wc;
@@ -2080,12 +2080,12 @@ static void ib_mad_send_done_handler(struct ib_mad_port_private *port_priv,
2080 qp_info = send_queue->qp_info; 2080 qp_info = send_queue->qp_info;
2081 2081
2082retry: 2082retry:
2083 dma_unmap_single(mad_send_wr->send_buf.mad_agent->device->dma_device, 2083 ib_dma_unmap_single(mad_send_wr->send_buf.mad_agent->device,
2084 pci_unmap_addr(mad_send_wr, header_mapping), 2084 mad_send_wr->header_mapping,
2085 mad_send_wr->sg_list[0].length, DMA_TO_DEVICE); 2085 mad_send_wr->sg_list[0].length, DMA_TO_DEVICE);
2086 dma_unmap_single(mad_send_wr->send_buf.mad_agent->device->dma_device, 2086 ib_dma_unmap_single(mad_send_wr->send_buf.mad_agent->device,
2087 pci_unmap_addr(mad_send_wr, payload_mapping), 2087 mad_send_wr->payload_mapping,
2088 mad_send_wr->sg_list[1].length, DMA_TO_DEVICE); 2088 mad_send_wr->sg_list[1].length, DMA_TO_DEVICE);
2089 queued_send_wr = NULL; 2089 queued_send_wr = NULL;
2090 spin_lock_irqsave(&send_queue->lock, flags); 2090 spin_lock_irqsave(&send_queue->lock, flags);
2091 list_del(&mad_list->list); 2091 list_del(&mad_list->list);
@@ -2528,13 +2528,12 @@ static int ib_mad_post_receive_mads(struct ib_mad_qp_info *qp_info,
2528 break; 2528 break;
2529 } 2529 }
2530 } 2530 }
2531 sg_list.addr = dma_map_single(qp_info->port_priv-> 2531 sg_list.addr = ib_dma_map_single(qp_info->port_priv->device,
2532 device->dma_device, 2532 &mad_priv->grh,
2533 &mad_priv->grh, 2533 sizeof *mad_priv -
2534 sizeof *mad_priv - 2534 sizeof mad_priv->header,
2535 sizeof mad_priv->header, 2535 DMA_FROM_DEVICE);
2536 DMA_FROM_DEVICE); 2536 mad_priv->header.mapping = sg_list.addr;
2537 pci_unmap_addr_set(&mad_priv->header, mapping, sg_list.addr);
2538 recv_wr.wr_id = (unsigned long)&mad_priv->header.mad_list; 2537 recv_wr.wr_id = (unsigned long)&mad_priv->header.mad_list;
2539 mad_priv->header.mad_list.mad_queue = recv_queue; 2538 mad_priv->header.mad_list.mad_queue = recv_queue;
2540 2539
@@ -2549,12 +2548,11 @@ static int ib_mad_post_receive_mads(struct ib_mad_qp_info *qp_info,
2549 list_del(&mad_priv->header.mad_list.list); 2548 list_del(&mad_priv->header.mad_list.list);
2550 recv_queue->count--; 2549 recv_queue->count--;
2551 spin_unlock_irqrestore(&recv_queue->lock, flags); 2550 spin_unlock_irqrestore(&recv_queue->lock, flags);
2552 dma_unmap_single(qp_info->port_priv->device->dma_device, 2551 ib_dma_unmap_single(qp_info->port_priv->device,
2553 pci_unmap_addr(&mad_priv->header, 2552 mad_priv->header.mapping,
2554 mapping), 2553 sizeof *mad_priv -
2555 sizeof *mad_priv - 2554 sizeof mad_priv->header,
2556 sizeof mad_priv->header, 2555 DMA_FROM_DEVICE);
2557 DMA_FROM_DEVICE);
2558 kmem_cache_free(ib_mad_cache, mad_priv); 2556 kmem_cache_free(ib_mad_cache, mad_priv);
2559 printk(KERN_ERR PFX "ib_post_recv failed: %d\n", ret); 2557 printk(KERN_ERR PFX "ib_post_recv failed: %d\n", ret);
2560 break; 2558 break;
@@ -2586,11 +2584,11 @@ static void cleanup_recv_queue(struct ib_mad_qp_info *qp_info)
2586 /* Remove from posted receive MAD list */ 2584 /* Remove from posted receive MAD list */
2587 list_del(&mad_list->list); 2585 list_del(&mad_list->list);
2588 2586
2589 dma_unmap_single(qp_info->port_priv->device->dma_device, 2587 ib_dma_unmap_single(qp_info->port_priv->device,
2590 pci_unmap_addr(&recv->header, mapping), 2588 recv->header.mapping,
2591 sizeof(struct ib_mad_private) - 2589 sizeof(struct ib_mad_private) -
2592 sizeof(struct ib_mad_private_header), 2590 sizeof(struct ib_mad_private_header),
2593 DMA_FROM_DEVICE); 2591 DMA_FROM_DEVICE);
2594 kmem_cache_free(ib_mad_cache, recv); 2592 kmem_cache_free(ib_mad_cache, recv);
2595 } 2593 }
2596 2594
diff --git a/drivers/infiniband/core/mad_priv.h b/drivers/infiniband/core/mad_priv.h
index d5548e73e068..de89717f49fe 100644
--- a/drivers/infiniband/core/mad_priv.h
+++ b/drivers/infiniband/core/mad_priv.h
@@ -73,7 +73,7 @@ struct ib_mad_private_header {
73 struct ib_mad_list_head mad_list; 73 struct ib_mad_list_head mad_list;
74 struct ib_mad_recv_wc recv_wc; 74 struct ib_mad_recv_wc recv_wc;
75 struct ib_wc wc; 75 struct ib_wc wc;
76 DECLARE_PCI_UNMAP_ADDR(mapping) 76 u64 mapping;
77} __attribute__ ((packed)); 77} __attribute__ ((packed));
78 78
79struct ib_mad_private { 79struct ib_mad_private {
@@ -126,8 +126,8 @@ struct ib_mad_send_wr_private {
126 struct list_head agent_list; 126 struct list_head agent_list;
127 struct ib_mad_agent_private *mad_agent_priv; 127 struct ib_mad_agent_private *mad_agent_priv;
128 struct ib_mad_send_buf send_buf; 128 struct ib_mad_send_buf send_buf;
129 DECLARE_PCI_UNMAP_ADDR(header_mapping) 129 u64 header_mapping;
130 DECLARE_PCI_UNMAP_ADDR(payload_mapping) 130 u64 payload_mapping;
131 struct ib_send_wr send_wr; 131 struct ib_send_wr send_wr;
132 struct ib_sge sg_list[IB_MAD_SEND_REQ_MAX_SG]; 132 struct ib_sge sg_list[IB_MAD_SEND_REQ_MAX_SG];
133 __be64 tid; 133 __be64 tid;
diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
new file mode 100644
index 000000000000..81a5cdc5733a
--- /dev/null
+++ b/drivers/infiniband/core/ucma.c
@@ -0,0 +1,874 @@
1/*
2 * Copyright (c) 2005-2006 Intel Corporation. All rights reserved.
3 *
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
9 *
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
12 * conditions are met:
13 *
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer.
17 *
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE.
31 */
32
33#include <linux/completion.h>
34#include <linux/mutex.h>
35#include <linux/poll.h>
36#include <linux/idr.h>
37#include <linux/in.h>
38#include <linux/in6.h>
39#include <linux/miscdevice.h>
40
41#include <rdma/rdma_user_cm.h>
42#include <rdma/ib_marshall.h>
43#include <rdma/rdma_cm.h>
44
45MODULE_AUTHOR("Sean Hefty");
46MODULE_DESCRIPTION("RDMA Userspace Connection Manager Access");
47MODULE_LICENSE("Dual BSD/GPL");
48
49enum {
50 UCMA_MAX_BACKLOG = 128
51};
52
53struct ucma_file {
54 struct mutex mut;
55 struct file *filp;
56 struct list_head ctx_list;
57 struct list_head event_list;
58 wait_queue_head_t poll_wait;
59};
60
61struct ucma_context {
62 int id;
63 struct completion comp;
64 atomic_t ref;
65 int events_reported;
66 int backlog;
67
68 struct ucma_file *file;
69 struct rdma_cm_id *cm_id;
70 u64 uid;
71
72 struct list_head list;
73};
74
75struct ucma_event {
76 struct ucma_context *ctx;
77 struct list_head list;
78 struct rdma_cm_id *cm_id;
79 struct rdma_ucm_event_resp resp;
80};
81
82static DEFINE_MUTEX(mut);
83static DEFINE_IDR(ctx_idr);
84
85static inline struct ucma_context *_ucma_find_context(int id,
86 struct ucma_file *file)
87{
88 struct ucma_context *ctx;
89
90 ctx = idr_find(&ctx_idr, id);
91 if (!ctx)
92 ctx = ERR_PTR(-ENOENT);
93 else if (ctx->file != file)
94 ctx = ERR_PTR(-EINVAL);
95 return ctx;
96}
97
98static struct ucma_context *ucma_get_ctx(struct ucma_file *file, int id)
99{
100 struct ucma_context *ctx;
101
102 mutex_lock(&mut);
103 ctx = _ucma_find_context(id, file);
104 if (!IS_ERR(ctx))
105 atomic_inc(&ctx->ref);
106 mutex_unlock(&mut);
107 return ctx;
108}
109
110static void ucma_put_ctx(struct ucma_context *ctx)
111{
112 if (atomic_dec_and_test(&ctx->ref))
113 complete(&ctx->comp);
114}
115
116static struct ucma_context *ucma_alloc_ctx(struct ucma_file *file)
117{
118 struct ucma_context *ctx;
119 int ret;
120
121 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
122 if (!ctx)
123 return NULL;
124
125 atomic_set(&ctx->ref, 1);
126 init_completion(&ctx->comp);
127 ctx->file = file;
128
129 do {
130 ret = idr_pre_get(&ctx_idr, GFP_KERNEL);
131 if (!ret)
132 goto error;
133
134 mutex_lock(&mut);
135 ret = idr_get_new(&ctx_idr, ctx, &ctx->id);
136 mutex_unlock(&mut);
137 } while (ret == -EAGAIN);
138
139 if (ret)
140 goto error;
141
142 list_add_tail(&ctx->list, &file->ctx_list);
143 return ctx;
144
145error:
146 kfree(ctx);
147 return NULL;
148}
149
150static void ucma_copy_conn_event(struct rdma_ucm_conn_param *dst,
151 struct rdma_conn_param *src)
152{
153 if (src->private_data_len)
154 memcpy(dst->private_data, src->private_data,
155 src->private_data_len);
156 dst->private_data_len = src->private_data_len;
157 dst->responder_resources =src->responder_resources;
158 dst->initiator_depth = src->initiator_depth;
159 dst->flow_control = src->flow_control;
160 dst->retry_count = src->retry_count;
161 dst->rnr_retry_count = src->rnr_retry_count;
162 dst->srq = src->srq;
163 dst->qp_num = src->qp_num;
164}
165
166static void ucma_copy_ud_event(struct rdma_ucm_ud_param *dst,
167 struct rdma_ud_param *src)
168{
169 if (src->private_data_len)
170 memcpy(dst->private_data, src->private_data,
171 src->private_data_len);
172 dst->private_data_len = src->private_data_len;
173 ib_copy_ah_attr_to_user(&dst->ah_attr, &src->ah_attr);
174 dst->qp_num = src->qp_num;
175 dst->qkey = src->qkey;
176}
177
178static void ucma_set_event_context(struct ucma_context *ctx,
179 struct rdma_cm_event *event,
180 struct ucma_event *uevent)
181{
182 uevent->ctx = ctx;
183 uevent->resp.uid = ctx->uid;
184 uevent->resp.id = ctx->id;
185}
186
187static int ucma_event_handler(struct rdma_cm_id *cm_id,
188 struct rdma_cm_event *event)
189{
190 struct ucma_event *uevent;
191 struct ucma_context *ctx = cm_id->context;
192 int ret = 0;
193
194 uevent = kzalloc(sizeof(*uevent), GFP_KERNEL);
195 if (!uevent)
196 return event->event == RDMA_CM_EVENT_CONNECT_REQUEST;
197
198 uevent->cm_id = cm_id;
199 ucma_set_event_context(ctx, event, uevent);
200 uevent->resp.event = event->event;
201 uevent->resp.status = event->status;
202 if (cm_id->ps == RDMA_PS_UDP)
203 ucma_copy_ud_event(&uevent->resp.param.ud, &event->param.ud);
204 else
205 ucma_copy_conn_event(&uevent->resp.param.conn,
206 &event->param.conn);
207
208 mutex_lock(&ctx->file->mut);
209 if (event->event == RDMA_CM_EVENT_CONNECT_REQUEST) {
210 if (!ctx->backlog) {
211 ret = -EDQUOT;
212 goto out;
213 }
214 ctx->backlog--;
215 }
216 list_add_tail(&uevent->list, &ctx->file->event_list);
217 wake_up_interruptible(&ctx->file->poll_wait);
218out:
219 mutex_unlock(&ctx->file->mut);
220 return ret;
221}
222
223static ssize_t ucma_get_event(struct ucma_file *file, const char __user *inbuf,
224 int in_len, int out_len)
225{
226 struct ucma_context *ctx;
227 struct rdma_ucm_get_event cmd;
228 struct ucma_event *uevent;
229 int ret = 0;
230 DEFINE_WAIT(wait);
231
232 if (out_len < sizeof uevent->resp)
233 return -ENOSPC;
234
235 if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
236 return -EFAULT;
237
238 mutex_lock(&file->mut);
239 while (list_empty(&file->event_list)) {
240 if (file->filp->f_flags & O_NONBLOCK) {
241 ret = -EAGAIN;
242 break;
243 }
244
245 if (signal_pending(current)) {
246 ret = -ERESTARTSYS;
247 break;
248 }
249
250 prepare_to_wait(&file->poll_wait, &wait, TASK_INTERRUPTIBLE);
251 mutex_unlock(&file->mut);
252 schedule();
253 mutex_lock(&file->mut);
254 finish_wait(&file->poll_wait, &wait);
255 }
256
257 if (ret)
258 goto done;
259
260 uevent = list_entry(file->event_list.next, struct ucma_event, list);
261
262 if (uevent->resp.event == RDMA_CM_EVENT_CONNECT_REQUEST) {
263 ctx = ucma_alloc_ctx(file);
264 if (!ctx) {
265 ret = -ENOMEM;
266 goto done;
267 }
268 uevent->ctx->backlog++;
269 ctx->cm_id = uevent->cm_id;
270 ctx->cm_id->context = ctx;
271 uevent->resp.id = ctx->id;
272 }
273
274 if (copy_to_user((void __user *)(unsigned long)cmd.response,
275 &uevent->resp, sizeof uevent->resp)) {
276 ret = -EFAULT;
277 goto done;
278 }
279
280 list_del(&uevent->list);
281 uevent->ctx->events_reported++;
282 kfree(uevent);
283done:
284 mutex_unlock(&file->mut);
285 return ret;
286}
287
288static ssize_t ucma_create_id(struct ucma_file *file,
289 const char __user *inbuf,
290 int in_len, int out_len)
291{
292 struct rdma_ucm_create_id cmd;
293 struct rdma_ucm_create_id_resp resp;
294 struct ucma_context *ctx;
295 int ret;
296
297 if (out_len < sizeof(resp))
298 return -ENOSPC;
299
300 if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
301 return -EFAULT;
302
303 mutex_lock(&file->mut);
304 ctx = ucma_alloc_ctx(file);
305 mutex_unlock(&file->mut);
306 if (!ctx)
307 return -ENOMEM;
308
309 ctx->uid = cmd.uid;
310 ctx->cm_id = rdma_create_id(ucma_event_handler, ctx, cmd.ps);
311 if (IS_ERR(ctx->cm_id)) {
312 ret = PTR_ERR(ctx->cm_id);
313 goto err1;
314 }
315
316 resp.id = ctx->id;
317 if (copy_to_user((void __user *)(unsigned long)cmd.response,
318 &resp, sizeof(resp))) {
319 ret = -EFAULT;
320 goto err2;
321 }
322 return 0;
323
324err2:
325 rdma_destroy_id(ctx->cm_id);
326err1:
327 mutex_lock(&mut);
328 idr_remove(&ctx_idr, ctx->id);
329 mutex_unlock(&mut);
330 kfree(ctx);
331 return ret;
332}
333
334static void ucma_cleanup_events(struct ucma_context *ctx)
335{
336 struct ucma_event *uevent, *tmp;
337
338 list_for_each_entry_safe(uevent, tmp, &ctx->file->event_list, list) {
339 if (uevent->ctx != ctx)
340 continue;
341
342 list_del(&uevent->list);
343
344 /* clear incoming connections. */
345 if (uevent->resp.event == RDMA_CM_EVENT_CONNECT_REQUEST)
346 rdma_destroy_id(uevent->cm_id);
347
348 kfree(uevent);
349 }
350}
351
352static int ucma_free_ctx(struct ucma_context *ctx)
353{
354 int events_reported;
355
356 /* No new events will be generated after destroying the id. */
357 rdma_destroy_id(ctx->cm_id);
358
359 /* Cleanup events not yet reported to the user. */
360 mutex_lock(&ctx->file->mut);
361 ucma_cleanup_events(ctx);
362 list_del(&ctx->list);
363 mutex_unlock(&ctx->file->mut);
364
365 events_reported = ctx->events_reported;
366 kfree(ctx);
367 return events_reported;
368}
369
370static ssize_t ucma_destroy_id(struct ucma_file *file, const char __user *inbuf,
371 int in_len, int out_len)
372{
373 struct rdma_ucm_destroy_id cmd;
374 struct rdma_ucm_destroy_id_resp resp;
375 struct ucma_context *ctx;
376 int ret = 0;
377
378 if (out_len < sizeof(resp))
379 return -ENOSPC;
380
381 if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
382 return -EFAULT;
383
384 mutex_lock(&mut);
385 ctx = _ucma_find_context(cmd.id, file);
386 if (!IS_ERR(ctx))
387 idr_remove(&ctx_idr, ctx->id);
388 mutex_unlock(&mut);
389
390 if (IS_ERR(ctx))
391 return PTR_ERR(ctx);
392
393 ucma_put_ctx(ctx);
394 wait_for_completion(&ctx->comp);
395 resp.events_reported = ucma_free_ctx(ctx);
396
397 if (copy_to_user((void __user *)(unsigned long)cmd.response,
398 &resp, sizeof(resp)))
399 ret = -EFAULT;
400
401 return ret;
402}
403
404static ssize_t ucma_bind_addr(struct ucma_file *file, const char __user *inbuf,
405 int in_len, int out_len)
406{
407 struct rdma_ucm_bind_addr cmd;
408 struct ucma_context *ctx;
409 int ret;
410
411 if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
412 return -EFAULT;
413
414 ctx = ucma_get_ctx(file, cmd.id);
415 if (IS_ERR(ctx))
416 return PTR_ERR(ctx);
417
418 ret = rdma_bind_addr(ctx->cm_id, (struct sockaddr *) &cmd.addr);
419 ucma_put_ctx(ctx);
420 return ret;
421}
422
423static ssize_t ucma_resolve_addr(struct ucma_file *file,
424 const char __user *inbuf,
425 int in_len, int out_len)
426{
427 struct rdma_ucm_resolve_addr cmd;
428 struct ucma_context *ctx;
429 int ret;
430
431 if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
432 return -EFAULT;
433
434 ctx = ucma_get_ctx(file, cmd.id);
435 if (IS_ERR(ctx))
436 return PTR_ERR(ctx);
437
438 ret = rdma_resolve_addr(ctx->cm_id, (struct sockaddr *) &cmd.src_addr,
439 (struct sockaddr *) &cmd.dst_addr,
440 cmd.timeout_ms);
441 ucma_put_ctx(ctx);
442 return ret;
443}
444
445static ssize_t ucma_resolve_route(struct ucma_file *file,
446 const char __user *inbuf,
447 int in_len, int out_len)
448{
449 struct rdma_ucm_resolve_route cmd;
450 struct ucma_context *ctx;
451 int ret;
452
453 if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
454 return -EFAULT;
455
456 ctx = ucma_get_ctx(file, cmd.id);
457 if (IS_ERR(ctx))
458 return PTR_ERR(ctx);
459
460 ret = rdma_resolve_route(ctx->cm_id, cmd.timeout_ms);
461 ucma_put_ctx(ctx);
462 return ret;
463}
464
465static void ucma_copy_ib_route(struct rdma_ucm_query_route_resp *resp,
466 struct rdma_route *route)
467{
468 struct rdma_dev_addr *dev_addr;
469
470 resp->num_paths = route->num_paths;
471 switch (route->num_paths) {
472 case 0:
473 dev_addr = &route->addr.dev_addr;
474 ib_addr_get_dgid(dev_addr,
475 (union ib_gid *) &resp->ib_route[0].dgid);
476 ib_addr_get_sgid(dev_addr,
477 (union ib_gid *) &resp->ib_route[0].sgid);
478 resp->ib_route[0].pkey = cpu_to_be16(ib_addr_get_pkey(dev_addr));
479 break;
480 case 2:
481 ib_copy_path_rec_to_user(&resp->ib_route[1],
482 &route->path_rec[1]);
483 /* fall through */
484 case 1:
485 ib_copy_path_rec_to_user(&resp->ib_route[0],
486 &route->path_rec[0]);
487 break;
488 default:
489 break;
490 }
491}
492
493static ssize_t ucma_query_route(struct ucma_file *file,
494 const char __user *inbuf,
495 int in_len, int out_len)
496{
497 struct rdma_ucm_query_route cmd;
498 struct rdma_ucm_query_route_resp resp;
499 struct ucma_context *ctx;
500 struct sockaddr *addr;
501 int ret = 0;
502
503 if (out_len < sizeof(resp))
504 return -ENOSPC;
505
506 if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
507 return -EFAULT;
508
509 ctx = ucma_get_ctx(file, cmd.id);
510 if (IS_ERR(ctx))
511 return PTR_ERR(ctx);
512
513 memset(&resp, 0, sizeof resp);
514 addr = &ctx->cm_id->route.addr.src_addr;
515 memcpy(&resp.src_addr, addr, addr->sa_family == AF_INET ?
516 sizeof(struct sockaddr_in) :
517 sizeof(struct sockaddr_in6));
518 addr = &ctx->cm_id->route.addr.dst_addr;
519 memcpy(&resp.dst_addr, addr, addr->sa_family == AF_INET ?
520 sizeof(struct sockaddr_in) :
521 sizeof(struct sockaddr_in6));
522 if (!ctx->cm_id->device)
523 goto out;
524
525 resp.node_guid = ctx->cm_id->device->node_guid;
526 resp.port_num = ctx->cm_id->port_num;
527 switch (rdma_node_get_transport(ctx->cm_id->device->node_type)) {
528 case RDMA_TRANSPORT_IB:
529 ucma_copy_ib_route(&resp, &ctx->cm_id->route);
530 break;
531 default:
532 break;
533 }
534
535out:
536 if (copy_to_user((void __user *)(unsigned long)cmd.response,
537 &resp, sizeof(resp)))
538 ret = -EFAULT;
539
540 ucma_put_ctx(ctx);
541 return ret;
542}
543
544static void ucma_copy_conn_param(struct rdma_conn_param *dst,
545 struct rdma_ucm_conn_param *src)
546{
547 dst->private_data = src->private_data;
548 dst->private_data_len = src->private_data_len;
549 dst->responder_resources =src->responder_resources;
550 dst->initiator_depth = src->initiator_depth;
551 dst->flow_control = src->flow_control;
552 dst->retry_count = src->retry_count;
553 dst->rnr_retry_count = src->rnr_retry_count;
554 dst->srq = src->srq;
555 dst->qp_num = src->qp_num;
556}
557
558static ssize_t ucma_connect(struct ucma_file *file, const char __user *inbuf,
559 int in_len, int out_len)
560{
561 struct rdma_ucm_connect cmd;
562 struct rdma_conn_param conn_param;
563 struct ucma_context *ctx;
564 int ret;
565
566 if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
567 return -EFAULT;
568
569 if (!cmd.conn_param.valid)
570 return -EINVAL;
571
572 ctx = ucma_get_ctx(file, cmd.id);
573 if (IS_ERR(ctx))
574 return PTR_ERR(ctx);
575
576 ucma_copy_conn_param(&conn_param, &cmd.conn_param);
577 ret = rdma_connect(ctx->cm_id, &conn_param);
578 ucma_put_ctx(ctx);
579 return ret;
580}
581
582static ssize_t ucma_listen(struct ucma_file *file, const char __user *inbuf,
583 int in_len, int out_len)
584{
585 struct rdma_ucm_listen cmd;
586 struct ucma_context *ctx;
587 int ret;
588
589 if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
590 return -EFAULT;
591
592 ctx = ucma_get_ctx(file, cmd.id);
593 if (IS_ERR(ctx))
594 return PTR_ERR(ctx);
595
596 ctx->backlog = cmd.backlog > 0 && cmd.backlog < UCMA_MAX_BACKLOG ?
597 cmd.backlog : UCMA_MAX_BACKLOG;
598 ret = rdma_listen(ctx->cm_id, ctx->backlog);
599 ucma_put_ctx(ctx);
600 return ret;
601}
602
603static ssize_t ucma_accept(struct ucma_file *file, const char __user *inbuf,
604 int in_len, int out_len)
605{
606 struct rdma_ucm_accept cmd;
607 struct rdma_conn_param conn_param;
608 struct ucma_context *ctx;
609 int ret;
610
611 if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
612 return -EFAULT;
613
614 ctx = ucma_get_ctx(file, cmd.id);
615 if (IS_ERR(ctx))
616 return PTR_ERR(ctx);
617
618 if (cmd.conn_param.valid) {
619 ctx->uid = cmd.uid;
620 ucma_copy_conn_param(&conn_param, &cmd.conn_param);
621 ret = rdma_accept(ctx->cm_id, &conn_param);
622 } else
623 ret = rdma_accept(ctx->cm_id, NULL);
624
625 ucma_put_ctx(ctx);
626 return ret;
627}
628
629static ssize_t ucma_reject(struct ucma_file *file, const char __user *inbuf,
630 int in_len, int out_len)
631{
632 struct rdma_ucm_reject cmd;
633 struct ucma_context *ctx;
634 int ret;
635
636 if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
637 return -EFAULT;
638
639 ctx = ucma_get_ctx(file, cmd.id);
640 if (IS_ERR(ctx))
641 return PTR_ERR(ctx);
642
643 ret = rdma_reject(ctx->cm_id, cmd.private_data, cmd.private_data_len);
644 ucma_put_ctx(ctx);
645 return ret;
646}
647
648static ssize_t ucma_disconnect(struct ucma_file *file, const char __user *inbuf,
649 int in_len, int out_len)
650{
651 struct rdma_ucm_disconnect cmd;
652 struct ucma_context *ctx;
653 int ret;
654
655 if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
656 return -EFAULT;
657
658 ctx = ucma_get_ctx(file, cmd.id);
659 if (IS_ERR(ctx))
660 return PTR_ERR(ctx);
661
662 ret = rdma_disconnect(ctx->cm_id);
663 ucma_put_ctx(ctx);
664 return ret;
665}
666
667static ssize_t ucma_init_qp_attr(struct ucma_file *file,
668 const char __user *inbuf,
669 int in_len, int out_len)
670{
671 struct rdma_ucm_init_qp_attr cmd;
672 struct ib_uverbs_qp_attr resp;
673 struct ucma_context *ctx;
674 struct ib_qp_attr qp_attr;
675 int ret;
676
677 if (out_len < sizeof(resp))
678 return -ENOSPC;
679
680 if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
681 return -EFAULT;
682
683 ctx = ucma_get_ctx(file, cmd.id);
684 if (IS_ERR(ctx))
685 return PTR_ERR(ctx);
686
687 resp.qp_attr_mask = 0;
688 memset(&qp_attr, 0, sizeof qp_attr);
689 qp_attr.qp_state = cmd.qp_state;
690 ret = rdma_init_qp_attr(ctx->cm_id, &qp_attr, &resp.qp_attr_mask);
691 if (ret)
692 goto out;
693
694 ib_copy_qp_attr_to_user(&resp, &qp_attr);
695 if (copy_to_user((void __user *)(unsigned long)cmd.response,
696 &resp, sizeof(resp)))
697 ret = -EFAULT;
698
699out:
700 ucma_put_ctx(ctx);
701 return ret;
702}
703
704static ssize_t ucma_notify(struct ucma_file *file, const char __user *inbuf,
705 int in_len, int out_len)
706{
707 struct rdma_ucm_notify cmd;
708 struct ucma_context *ctx;
709 int ret;
710
711 if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
712 return -EFAULT;
713
714 ctx = ucma_get_ctx(file, cmd.id);
715 if (IS_ERR(ctx))
716 return PTR_ERR(ctx);
717
718 ret = rdma_notify(ctx->cm_id, (enum ib_event_type) cmd.event);
719 ucma_put_ctx(ctx);
720 return ret;
721}
722
723static ssize_t (*ucma_cmd_table[])(struct ucma_file *file,
724 const char __user *inbuf,
725 int in_len, int out_len) = {
726 [RDMA_USER_CM_CMD_CREATE_ID] = ucma_create_id,
727 [RDMA_USER_CM_CMD_DESTROY_ID] = ucma_destroy_id,
728 [RDMA_USER_CM_CMD_BIND_ADDR] = ucma_bind_addr,
729 [RDMA_USER_CM_CMD_RESOLVE_ADDR] = ucma_resolve_addr,
730 [RDMA_USER_CM_CMD_RESOLVE_ROUTE]= ucma_resolve_route,
731 [RDMA_USER_CM_CMD_QUERY_ROUTE] = ucma_query_route,
732 [RDMA_USER_CM_CMD_CONNECT] = ucma_connect,
733 [RDMA_USER_CM_CMD_LISTEN] = ucma_listen,
734 [RDMA_USER_CM_CMD_ACCEPT] = ucma_accept,
735 [RDMA_USER_CM_CMD_REJECT] = ucma_reject,
736 [RDMA_USER_CM_CMD_DISCONNECT] = ucma_disconnect,
737 [RDMA_USER_CM_CMD_INIT_QP_ATTR] = ucma_init_qp_attr,
738 [RDMA_USER_CM_CMD_GET_EVENT] = ucma_get_event,
739 [RDMA_USER_CM_CMD_GET_OPTION] = NULL,
740 [RDMA_USER_CM_CMD_SET_OPTION] = NULL,
741 [RDMA_USER_CM_CMD_NOTIFY] = ucma_notify,
742};
743
744static ssize_t ucma_write(struct file *filp, const char __user *buf,
745 size_t len, loff_t *pos)
746{
747 struct ucma_file *file = filp->private_data;
748 struct rdma_ucm_cmd_hdr hdr;
749 ssize_t ret;
750
751 if (len < sizeof(hdr))
752 return -EINVAL;
753
754 if (copy_from_user(&hdr, buf, sizeof(hdr)))
755 return -EFAULT;
756
757 if (hdr.cmd < 0 || hdr.cmd >= ARRAY_SIZE(ucma_cmd_table))
758 return -EINVAL;
759
760 if (hdr.in + sizeof(hdr) > len)
761 return -EINVAL;
762
763 if (!ucma_cmd_table[hdr.cmd])
764 return -ENOSYS;
765
766 ret = ucma_cmd_table[hdr.cmd](file, buf + sizeof(hdr), hdr.in, hdr.out);
767 if (!ret)
768 ret = len;
769
770 return ret;
771}
772
773static unsigned int ucma_poll(struct file *filp, struct poll_table_struct *wait)
774{
775 struct ucma_file *file = filp->private_data;
776 unsigned int mask = 0;
777
778 poll_wait(filp, &file->poll_wait, wait);
779
780 if (!list_empty(&file->event_list))
781 mask = POLLIN | POLLRDNORM;
782
783 return mask;
784}
785
786static int ucma_open(struct inode *inode, struct file *filp)
787{
788 struct ucma_file *file;
789
790 file = kmalloc(sizeof *file, GFP_KERNEL);
791 if (!file)
792 return -ENOMEM;
793
794 INIT_LIST_HEAD(&file->event_list);
795 INIT_LIST_HEAD(&file->ctx_list);
796 init_waitqueue_head(&file->poll_wait);
797 mutex_init(&file->mut);
798
799 filp->private_data = file;
800 file->filp = filp;
801 return 0;
802}
803
804static int ucma_close(struct inode *inode, struct file *filp)
805{
806 struct ucma_file *file = filp->private_data;
807 struct ucma_context *ctx, *tmp;
808
809 mutex_lock(&file->mut);
810 list_for_each_entry_safe(ctx, tmp, &file->ctx_list, list) {
811 mutex_unlock(&file->mut);
812
813 mutex_lock(&mut);
814 idr_remove(&ctx_idr, ctx->id);
815 mutex_unlock(&mut);
816
817 ucma_free_ctx(ctx);
818 mutex_lock(&file->mut);
819 }
820 mutex_unlock(&file->mut);
821 kfree(file);
822 return 0;
823}
824
825static struct file_operations ucma_fops = {
826 .owner = THIS_MODULE,
827 .open = ucma_open,
828 .release = ucma_close,
829 .write = ucma_write,
830 .poll = ucma_poll,
831};
832
833static struct miscdevice ucma_misc = {
834 .minor = MISC_DYNAMIC_MINOR,
835 .name = "rdma_cm",
836 .fops = &ucma_fops,
837};
838
839static ssize_t show_abi_version(struct device *dev,
840 struct device_attribute *attr,
841 char *buf)
842{
843 return sprintf(buf, "%d\n", RDMA_USER_CM_ABI_VERSION);
844}
845static DEVICE_ATTR(abi_version, S_IRUGO, show_abi_version, NULL);
846
847static int __init ucma_init(void)
848{
849 int ret;
850
851 ret = misc_register(&ucma_misc);
852 if (ret)
853 return ret;
854
855 ret = device_create_file(ucma_misc.this_device, &dev_attr_abi_version);
856 if (ret) {
857 printk(KERN_ERR "rdma_ucm: couldn't create abi_version attr\n");
858 goto err;
859 }
860 return 0;
861err:
862 misc_deregister(&ucma_misc);
863 return ret;
864}
865
866static void __exit ucma_cleanup(void)
867{
868 device_remove_file(ucma_misc.this_device, &dev_attr_abi_version);
869 misc_deregister(&ucma_misc);
870 idr_destroy(&ctx_idr);
871}
872
873module_init(ucma_init);
874module_exit(ucma_cleanup);
diff --git a/drivers/infiniband/core/uverbs_marshall.c b/drivers/infiniband/core/uverbs_marshall.c
index ce46b13ae02b..5440da0e59b4 100644
--- a/drivers/infiniband/core/uverbs_marshall.c
+++ b/drivers/infiniband/core/uverbs_marshall.c
@@ -32,8 +32,8 @@
32 32
33#include <rdma/ib_marshall.h> 33#include <rdma/ib_marshall.h>
34 34
35static void ib_copy_ah_attr_to_user(struct ib_uverbs_ah_attr *dst, 35void ib_copy_ah_attr_to_user(struct ib_uverbs_ah_attr *dst,
36 struct ib_ah_attr *src) 36 struct ib_ah_attr *src)
37{ 37{
38 memcpy(dst->grh.dgid, src->grh.dgid.raw, sizeof src->grh.dgid); 38 memcpy(dst->grh.dgid, src->grh.dgid.raw, sizeof src->grh.dgid);
39 dst->grh.flow_label = src->grh.flow_label; 39 dst->grh.flow_label = src->grh.flow_label;
@@ -47,6 +47,7 @@ static void ib_copy_ah_attr_to_user(struct ib_uverbs_ah_attr *dst,
47 dst->is_global = src->ah_flags & IB_AH_GRH ? 1 : 0; 47 dst->is_global = src->ah_flags & IB_AH_GRH ? 1 : 0;
48 dst->port_num = src->port_num; 48 dst->port_num = src->port_num;
49} 49}
50EXPORT_SYMBOL(ib_copy_ah_attr_to_user);
50 51
51void ib_copy_qp_attr_to_user(struct ib_uverbs_qp_attr *dst, 52void ib_copy_qp_attr_to_user(struct ib_uverbs_qp_attr *dst,
52 struct ib_qp_attr *src) 53 struct ib_qp_attr *src)
diff --git a/drivers/infiniband/core/uverbs_mem.c b/drivers/infiniband/core/uverbs_mem.c
index db12cc0841df..c95fe952abd5 100644
--- a/drivers/infiniband/core/uverbs_mem.c
+++ b/drivers/infiniband/core/uverbs_mem.c
@@ -52,8 +52,8 @@ static void __ib_umem_release(struct ib_device *dev, struct ib_umem *umem, int d
52 int i; 52 int i;
53 53
54 list_for_each_entry_safe(chunk, tmp, &umem->chunk_list, list) { 54 list_for_each_entry_safe(chunk, tmp, &umem->chunk_list, list) {
55 dma_unmap_sg(dev->dma_device, chunk->page_list, 55 ib_dma_unmap_sg(dev, chunk->page_list,
56 chunk->nents, DMA_BIDIRECTIONAL); 56 chunk->nents, DMA_BIDIRECTIONAL);
57 for (i = 0; i < chunk->nents; ++i) { 57 for (i = 0; i < chunk->nents; ++i) {
58 if (umem->writable && dirty) 58 if (umem->writable && dirty)
59 set_page_dirty_lock(chunk->page_list[i].page); 59 set_page_dirty_lock(chunk->page_list[i].page);
@@ -136,10 +136,10 @@ int ib_umem_get(struct ib_device *dev, struct ib_umem *mem,
136 chunk->page_list[i].length = PAGE_SIZE; 136 chunk->page_list[i].length = PAGE_SIZE;
137 } 137 }
138 138
139 chunk->nmap = dma_map_sg(dev->dma_device, 139 chunk->nmap = ib_dma_map_sg(dev,
140 &chunk->page_list[0], 140 &chunk->page_list[0],
141 chunk->nents, 141 chunk->nents,
142 DMA_BIDIRECTIONAL); 142 DMA_BIDIRECTIONAL);
143 if (chunk->nmap <= 0) { 143 if (chunk->nmap <= 0) {
144 for (i = 0; i < chunk->nents; ++i) 144 for (i = 0; i < chunk->nents; ++i)
145 put_page(chunk->page_list[i].page); 145 put_page(chunk->page_list[i].page);
diff --git a/drivers/infiniband/hw/amso1100/c2_qp.c b/drivers/infiniband/hw/amso1100/c2_qp.c
index 179d005ed4a5..420c1380f5c3 100644
--- a/drivers/infiniband/hw/amso1100/c2_qp.c
+++ b/drivers/infiniband/hw/amso1100/c2_qp.c
@@ -161,8 +161,10 @@ int c2_qp_modify(struct c2_dev *c2dev, struct c2_qp *qp,
161 161
162 if (attr_mask & IB_QP_STATE) { 162 if (attr_mask & IB_QP_STATE) {
163 /* Ensure the state is valid */ 163 /* Ensure the state is valid */
164 if (attr->qp_state < 0 || attr->qp_state > IB_QPS_ERR) 164 if (attr->qp_state < 0 || attr->qp_state > IB_QPS_ERR) {
165 return -EINVAL; 165 err = -EINVAL;
166 goto bail0;
167 }
166 168
167 wr.next_qp_state = cpu_to_be32(to_c2_state(attr->qp_state)); 169 wr.next_qp_state = cpu_to_be32(to_c2_state(attr->qp_state));
168 170
@@ -184,9 +186,10 @@ int c2_qp_modify(struct c2_dev *c2dev, struct c2_qp *qp,
184 if (attr->cur_qp_state != IB_QPS_RTR && 186 if (attr->cur_qp_state != IB_QPS_RTR &&
185 attr->cur_qp_state != IB_QPS_RTS && 187 attr->cur_qp_state != IB_QPS_RTS &&
186 attr->cur_qp_state != IB_QPS_SQD && 188 attr->cur_qp_state != IB_QPS_SQD &&
187 attr->cur_qp_state != IB_QPS_SQE) 189 attr->cur_qp_state != IB_QPS_SQE) {
188 return -EINVAL; 190 err = -EINVAL;
189 else 191 goto bail0;
192 } else
190 wr.next_qp_state = 193 wr.next_qp_state =
191 cpu_to_be32(to_c2_state(attr->cur_qp_state)); 194 cpu_to_be32(to_c2_state(attr->cur_qp_state));
192 195
diff --git a/drivers/infiniband/hw/ipath/Makefile b/drivers/infiniband/hw/ipath/Makefile
index 7dc10551cf18..ec2e603ea241 100644
--- a/drivers/infiniband/hw/ipath/Makefile
+++ b/drivers/infiniband/hw/ipath/Makefile
@@ -6,6 +6,7 @@ obj-$(CONFIG_INFINIBAND_IPATH) += ib_ipath.o
6ib_ipath-y := \ 6ib_ipath-y := \
7 ipath_cq.o \ 7 ipath_cq.o \
8 ipath_diag.o \ 8 ipath_diag.o \
9 ipath_dma.o \
9 ipath_driver.o \ 10 ipath_driver.o \
10 ipath_eeprom.o \ 11 ipath_eeprom.o \
11 ipath_file_ops.o \ 12 ipath_file_ops.o \
diff --git a/drivers/infiniband/hw/ipath/ipath_dma.c b/drivers/infiniband/hw/ipath/ipath_dma.c
new file mode 100644
index 000000000000..6e0f2b8918ce
--- /dev/null
+++ b/drivers/infiniband/hw/ipath/ipath_dma.c
@@ -0,0 +1,189 @@
1/*
2 * Copyright (c) 2006 QLogic, Corporation. All rights reserved.
3 *
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
9 *
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
12 * conditions are met:
13 *
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer.
17 *
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE.
31 */
32
33#include <rdma/ib_verbs.h>
34
35#include "ipath_verbs.h"
36
37#define BAD_DMA_ADDRESS ((u64) 0)
38
39/*
40 * The following functions implement driver specific replacements
41 * for the ib_dma_*() functions.
42 *
43 * These functions return kernel virtual addresses instead of
44 * device bus addresses since the driver uses the CPU to copy
45 * data instead of using hardware DMA.
46 */
47
48static int ipath_mapping_error(struct ib_device *dev, u64 dma_addr)
49{
50 return dma_addr == BAD_DMA_ADDRESS;
51}
52
53static u64 ipath_dma_map_single(struct ib_device *dev,
54 void *cpu_addr, size_t size,
55 enum dma_data_direction direction)
56{
57 BUG_ON(!valid_dma_direction(direction));
58 return (u64) cpu_addr;
59}
60
61static void ipath_dma_unmap_single(struct ib_device *dev,
62 u64 addr, size_t size,
63 enum dma_data_direction direction)
64{
65 BUG_ON(!valid_dma_direction(direction));
66}
67
68static u64 ipath_dma_map_page(struct ib_device *dev,
69 struct page *page,
70 unsigned long offset,
71 size_t size,
72 enum dma_data_direction direction)
73{
74 u64 addr;
75
76 BUG_ON(!valid_dma_direction(direction));
77
78 if (offset + size > PAGE_SIZE) {
79 addr = BAD_DMA_ADDRESS;
80 goto done;
81 }
82
83 addr = (u64) page_address(page);
84 if (addr)
85 addr += offset;
86 /* TODO: handle highmem pages */
87
88done:
89 return addr;
90}
91
92static void ipath_dma_unmap_page(struct ib_device *dev,
93 u64 addr, size_t size,
94 enum dma_data_direction direction)
95{
96 BUG_ON(!valid_dma_direction(direction));
97}
98
99int ipath_map_sg(struct ib_device *dev, struct scatterlist *sg, int nents,
100 enum dma_data_direction direction)
101{
102 u64 addr;
103 int i;
104 int ret = nents;
105
106 BUG_ON(!valid_dma_direction(direction));
107
108 for (i = 0; i < nents; i++) {
109 addr = (u64) page_address(sg[i].page);
110 /* TODO: handle highmem pages */
111 if (!addr) {
112 ret = 0;
113 break;
114 }
115 }
116 return ret;
117}
118
119static void ipath_unmap_sg(struct ib_device *dev,
120 struct scatterlist *sg, int nents,
121 enum dma_data_direction direction)
122{
123 BUG_ON(!valid_dma_direction(direction));
124}
125
126static u64 ipath_sg_dma_address(struct ib_device *dev, struct scatterlist *sg)
127{
128 u64 addr = (u64) page_address(sg->page);
129
130 if (addr)
131 addr += sg->offset;
132 return addr;
133}
134
135static unsigned int ipath_sg_dma_len(struct ib_device *dev,
136 struct scatterlist *sg)
137{
138 return sg->length;
139}
140
141static void ipath_sync_single_for_cpu(struct ib_device *dev,
142 u64 addr,
143 size_t size,
144 enum dma_data_direction dir)
145{
146}
147
148static void ipath_sync_single_for_device(struct ib_device *dev,
149 u64 addr,
150 size_t size,
151 enum dma_data_direction dir)
152{
153}
154
155static void *ipath_dma_alloc_coherent(struct ib_device *dev, size_t size,
156 u64 *dma_handle, gfp_t flag)
157{
158 struct page *p;
159 void *addr = NULL;
160
161 p = alloc_pages(flag, get_order(size));
162 if (p)
163 addr = page_address(p);
164 if (dma_handle)
165 *dma_handle = (u64) addr;
166 return addr;
167}
168
169static void ipath_dma_free_coherent(struct ib_device *dev, size_t size,
170 void *cpu_addr, dma_addr_t dma_handle)
171{
172 free_pages((unsigned long) cpu_addr, get_order(size));
173}
174
175struct ib_dma_mapping_ops ipath_dma_mapping_ops = {
176 ipath_mapping_error,
177 ipath_dma_map_single,
178 ipath_dma_unmap_single,
179 ipath_dma_map_page,
180 ipath_dma_unmap_page,
181 ipath_map_sg,
182 ipath_unmap_sg,
183 ipath_sg_dma_address,
184 ipath_sg_dma_len,
185 ipath_sync_single_for_cpu,
186 ipath_sync_single_for_device,
187 ipath_dma_alloc_coherent,
188 ipath_dma_free_coherent
189};
diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c b/drivers/infiniband/hw/ipath/ipath_driver.c
index 1aeddb48e355..ae7f21a0cdc0 100644
--- a/drivers/infiniband/hw/ipath/ipath_driver.c
+++ b/drivers/infiniband/hw/ipath/ipath_driver.c
@@ -1825,8 +1825,6 @@ void ipath_write_kreg_port(const struct ipath_devdata *dd, ipath_kreg regno,
1825 */ 1825 */
1826void ipath_shutdown_device(struct ipath_devdata *dd) 1826void ipath_shutdown_device(struct ipath_devdata *dd)
1827{ 1827{
1828 u64 val;
1829
1830 ipath_dbg("Shutting down the device\n"); 1828 ipath_dbg("Shutting down the device\n");
1831 1829
1832 dd->ipath_flags |= IPATH_LINKUNK; 1830 dd->ipath_flags |= IPATH_LINKUNK;
@@ -1849,7 +1847,7 @@ void ipath_shutdown_device(struct ipath_devdata *dd)
1849 */ 1847 */
1850 ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl, 0ULL); 1848 ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl, 0ULL);
1851 /* flush it */ 1849 /* flush it */
1852 val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch); 1850 ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch);
1853 /* 1851 /*
1854 * enough for anything that's going to trickle out to have actually 1852 * enough for anything that's going to trickle out to have actually
1855 * done so. 1853 * done so.
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c
index 340f27e3ebff..b932bcb67a5e 100644
--- a/drivers/infiniband/hw/ipath/ipath_file_ops.c
+++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c
@@ -699,7 +699,6 @@ static int ipath_manage_rcvq(struct ipath_portdata *pd, unsigned subport,
699 int start_stop) 699 int start_stop)
700{ 700{
701 struct ipath_devdata *dd = pd->port_dd; 701 struct ipath_devdata *dd = pd->port_dd;
702 u64 tval;
703 702
704 ipath_cdbg(PROC, "%sabling rcv for unit %u port %u:%u\n", 703 ipath_cdbg(PROC, "%sabling rcv for unit %u port %u:%u\n",
705 start_stop ? "en" : "dis", dd->ipath_unit, 704 start_stop ? "en" : "dis", dd->ipath_unit,
@@ -729,7 +728,7 @@ static int ipath_manage_rcvq(struct ipath_portdata *pd, unsigned subport,
729 ipath_write_kreg(dd, dd->ipath_kregs->kr_rcvctrl, 728 ipath_write_kreg(dd, dd->ipath_kregs->kr_rcvctrl,
730 dd->ipath_rcvctrl); 729 dd->ipath_rcvctrl);
731 /* now be sure chip saw it before we return */ 730 /* now be sure chip saw it before we return */
732 tval = ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch); 731 ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch);
733 if (start_stop) { 732 if (start_stop) {
734 /* 733 /*
735 * And try to be sure that tail reg update has happened too. 734 * And try to be sure that tail reg update has happened too.
@@ -738,7 +737,7 @@ static int ipath_manage_rcvq(struct ipath_portdata *pd, unsigned subport,
738 * in memory copy, since we could overwrite an update by the 737 * in memory copy, since we could overwrite an update by the
739 * chip if we did. 738 * chip if we did.
740 */ 739 */
741 tval = ipath_read_ureg32(dd, ur_rcvhdrtail, pd->port_port); 740 ipath_read_ureg32(dd, ur_rcvhdrtail, pd->port_port);
742 } 741 }
743 /* always; new head should be equal to new tail; see above */ 742 /* always; new head should be equal to new tail; see above */
744bail: 743bail:
diff --git a/drivers/infiniband/hw/ipath/ipath_iba6110.c b/drivers/infiniband/hw/ipath/ipath_iba6110.c
index e57c7a351cb5..7468477ba837 100644
--- a/drivers/infiniband/hw/ipath/ipath_iba6110.c
+++ b/drivers/infiniband/hw/ipath/ipath_iba6110.c
@@ -1447,7 +1447,7 @@ static void ipath_ht_tidtemplate(struct ipath_devdata *dd)
1447static int ipath_ht_early_init(struct ipath_devdata *dd) 1447static int ipath_ht_early_init(struct ipath_devdata *dd)
1448{ 1448{
1449 u32 __iomem *piobuf; 1449 u32 __iomem *piobuf;
1450 u32 pioincr, val32, egrsize; 1450 u32 pioincr, val32;
1451 int i; 1451 int i;
1452 1452
1453 /* 1453 /*
@@ -1467,7 +1467,6 @@ static int ipath_ht_early_init(struct ipath_devdata *dd)
1467 * errors interrupts if we ever see one). 1467 * errors interrupts if we ever see one).
1468 */ 1468 */
1469 dd->ipath_rcvegrbufsize = dd->ipath_piosize2k; 1469 dd->ipath_rcvegrbufsize = dd->ipath_piosize2k;
1470 egrsize = dd->ipath_rcvegrbufsize;
1471 1470
1472 /* 1471 /*
1473 * the min() check here is currently a nop, but it may not 1472 * the min() check here is currently a nop, but it may not
diff --git a/drivers/infiniband/hw/ipath/ipath_iba6120.c b/drivers/infiniband/hw/ipath/ipath_iba6120.c
index 6af89683f710..ae8bf9950c6d 100644
--- a/drivers/infiniband/hw/ipath/ipath_iba6120.c
+++ b/drivers/infiniband/hw/ipath/ipath_iba6120.c
@@ -602,7 +602,7 @@ static void ipath_pe_init_hwerrors(struct ipath_devdata *dd)
602 */ 602 */
603static int ipath_pe_bringup_serdes(struct ipath_devdata *dd) 603static int ipath_pe_bringup_serdes(struct ipath_devdata *dd)
604{ 604{
605 u64 val, tmp, config1, prev_val; 605 u64 val, config1, prev_val;
606 int ret = 0; 606 int ret = 0;
607 607
608 ipath_dbg("Trying to bringup serdes\n"); 608 ipath_dbg("Trying to bringup serdes\n");
@@ -633,7 +633,7 @@ static int ipath_pe_bringup_serdes(struct ipath_devdata *dd)
633 | INFINIPATH_SERDC0_L1PWR_DN; 633 | INFINIPATH_SERDC0_L1PWR_DN;
634 ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0, val); 634 ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0, val);
635 /* be sure chip saw it */ 635 /* be sure chip saw it */
636 tmp = ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch); 636 ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch);
637 udelay(5); /* need pll reset set at least for a bit */ 637 udelay(5); /* need pll reset set at least for a bit */
638 /* 638 /*
639 * after PLL is reset, set the per-lane Resets and TxIdle and 639 * after PLL is reset, set the per-lane Resets and TxIdle and
@@ -647,7 +647,7 @@ static int ipath_pe_bringup_serdes(struct ipath_devdata *dd)
647 "and txidle (%llx)\n", (unsigned long long) val); 647 "and txidle (%llx)\n", (unsigned long long) val);
648 ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0, val); 648 ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0, val);
649 /* be sure chip saw it */ 649 /* be sure chip saw it */
650 tmp = ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch); 650 ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch);
651 /* need PLL reset clear for at least 11 usec before lane 651 /* need PLL reset clear for at least 11 usec before lane
652 * resets cleared; give it a few more to be sure */ 652 * resets cleared; give it a few more to be sure */
653 udelay(15); 653 udelay(15);
@@ -851,12 +851,12 @@ static int ipath_setup_pe_config(struct ipath_devdata *dd,
851 int pos, ret; 851 int pos, ret;
852 852
853 dd->ipath_msi_lo = 0; /* used as a flag during reset processing */ 853 dd->ipath_msi_lo = 0; /* used as a flag during reset processing */
854 dd->ipath_irq = pdev->irq;
855 ret = pci_enable_msi(dd->pcidev); 854 ret = pci_enable_msi(dd->pcidev);
856 if (ret) 855 if (ret)
857 ipath_dev_err(dd, "pci_enable_msi failed: %d, " 856 ipath_dev_err(dd, "pci_enable_msi failed: %d, "
858 "interrupts may not work\n", ret); 857 "interrupts may not work\n", ret);
859 /* continue even if it fails, we may still be OK... */ 858 /* continue even if it fails, we may still be OK... */
859 dd->ipath_irq = pdev->irq;
860 860
861 if ((pos = pci_find_capability(dd->pcidev, PCI_CAP_ID_MSI))) { 861 if ((pos = pci_find_capability(dd->pcidev, PCI_CAP_ID_MSI))) {
862 u16 control; 862 u16 control;
diff --git a/drivers/infiniband/hw/ipath/ipath_init_chip.c b/drivers/infiniband/hw/ipath/ipath_init_chip.c
index d819cca524cd..d4f6b5239ef8 100644
--- a/drivers/infiniband/hw/ipath/ipath_init_chip.c
+++ b/drivers/infiniband/hw/ipath/ipath_init_chip.c
@@ -347,10 +347,9 @@ done:
347static int init_chip_reset(struct ipath_devdata *dd, 347static int init_chip_reset(struct ipath_devdata *dd,
348 struct ipath_portdata **pdp) 348 struct ipath_portdata **pdp)
349{ 349{
350 struct ipath_portdata *pd;
351 u32 rtmp; 350 u32 rtmp;
352 351
353 *pdp = pd = dd->ipath_pd[0]; 352 *pdp = dd->ipath_pd[0];
354 /* ensure chip does no sends or receives while we re-initialize */ 353 /* ensure chip does no sends or receives while we re-initialize */
355 dd->ipath_control = dd->ipath_sendctrl = dd->ipath_rcvctrl = 0U; 354 dd->ipath_control = dd->ipath_sendctrl = dd->ipath_rcvctrl = 0U;
356 ipath_write_kreg(dd, dd->ipath_kregs->kr_rcvctrl, 0); 355 ipath_write_kreg(dd, dd->ipath_kregs->kr_rcvctrl, 0);
diff --git a/drivers/infiniband/hw/ipath/ipath_intr.c b/drivers/infiniband/hw/ipath/ipath_intr.c
index 5652a550d442..72b9e279d19d 100644
--- a/drivers/infiniband/hw/ipath/ipath_intr.c
+++ b/drivers/infiniband/hw/ipath/ipath_intr.c
@@ -598,10 +598,9 @@ static int handle_errors(struct ipath_devdata *dd, ipath_err_t errs)
598 * on close 598 * on close
599 */ 599 */
600 if (errs & INFINIPATH_E_RRCVHDRFULL) { 600 if (errs & INFINIPATH_E_RRCVHDRFULL) {
601 int any;
602 u32 hd, tl; 601 u32 hd, tl;
603 ipath_stats.sps_hdrqfull++; 602 ipath_stats.sps_hdrqfull++;
604 for (any = i = 0; i < dd->ipath_cfgports; i++) { 603 for (i = 0; i < dd->ipath_cfgports; i++) {
605 struct ipath_portdata *pd = dd->ipath_pd[i]; 604 struct ipath_portdata *pd = dd->ipath_pd[i];
606 if (i == 0) { 605 if (i == 0) {
607 hd = dd->ipath_port0head; 606 hd = dd->ipath_port0head;
diff --git a/drivers/infiniband/hw/ipath/ipath_keys.c b/drivers/infiniband/hw/ipath/ipath_keys.c
index 9a6cbd05adcd..851763d7d2db 100644
--- a/drivers/infiniband/hw/ipath/ipath_keys.c
+++ b/drivers/infiniband/hw/ipath/ipath_keys.c
@@ -134,7 +134,7 @@ int ipath_lkey_ok(struct ipath_qp *qp, struct ipath_sge *isge,
134 */ 134 */
135 if (sge->lkey == 0) { 135 if (sge->lkey == 0) {
136 isge->mr = NULL; 136 isge->mr = NULL;
137 isge->vaddr = bus_to_virt(sge->addr); 137 isge->vaddr = (void *) sge->addr;
138 isge->length = sge->length; 138 isge->length = sge->length;
139 isge->sge_length = sge->length; 139 isge->sge_length = sge->length;
140 ret = 1; 140 ret = 1;
@@ -202,12 +202,12 @@ int ipath_rkey_ok(struct ipath_qp *qp, struct ipath_sge_state *ss,
202 int ret; 202 int ret;
203 203
204 /* 204 /*
205 * We use RKEY == zero for physical addresses 205 * We use RKEY == zero for kernel virtual addresses
206 * (see ipath_get_dma_mr). 206 * (see ipath_get_dma_mr and ipath_dma.c).
207 */ 207 */
208 if (rkey == 0) { 208 if (rkey == 0) {
209 sge->mr = NULL; 209 sge->mr = NULL;
210 sge->vaddr = phys_to_virt(vaddr); 210 sge->vaddr = (void *) vaddr;
211 sge->length = len; 211 sge->length = len;
212 sge->sge_length = len; 212 sge->sge_length = len;
213 ss->sg_list = NULL; 213 ss->sg_list = NULL;
diff --git a/drivers/infiniband/hw/ipath/ipath_mr.c b/drivers/infiniband/hw/ipath/ipath_mr.c
index a0673c1eef71..8cc8598d6c69 100644
--- a/drivers/infiniband/hw/ipath/ipath_mr.c
+++ b/drivers/infiniband/hw/ipath/ipath_mr.c
@@ -54,6 +54,8 @@ static inline struct ipath_fmr *to_ifmr(struct ib_fmr *ibfmr)
54 * @acc: access flags 54 * @acc: access flags
55 * 55 *
56 * Returns the memory region on success, otherwise returns an errno. 56 * Returns the memory region on success, otherwise returns an errno.
57 * Note that all DMA addresses should be created via the
58 * struct ib_dma_mapping_ops functions (see ipath_dma.c).
57 */ 59 */
58struct ib_mr *ipath_get_dma_mr(struct ib_pd *pd, int acc) 60struct ib_mr *ipath_get_dma_mr(struct ib_pd *pd, int acc)
59{ 61{
@@ -149,8 +151,7 @@ struct ib_mr *ipath_reg_phys_mr(struct ib_pd *pd,
149 m = 0; 151 m = 0;
150 n = 0; 152 n = 0;
151 for (i = 0; i < num_phys_buf; i++) { 153 for (i = 0; i < num_phys_buf; i++) {
152 mr->mr.map[m]->segs[n].vaddr = 154 mr->mr.map[m]->segs[n].vaddr = (void *) buffer_list[i].addr;
153 phys_to_virt(buffer_list[i].addr);
154 mr->mr.map[m]->segs[n].length = buffer_list[i].size; 155 mr->mr.map[m]->segs[n].length = buffer_list[i].size;
155 mr->mr.length += buffer_list[i].size; 156 mr->mr.length += buffer_list[i].size;
156 n++; 157 n++;
@@ -347,7 +348,7 @@ int ipath_map_phys_fmr(struct ib_fmr *ibfmr, u64 * page_list,
347 n = 0; 348 n = 0;
348 ps = 1 << fmr->page_shift; 349 ps = 1 << fmr->page_shift;
349 for (i = 0; i < list_len; i++) { 350 for (i = 0; i < list_len; i++) {
350 fmr->mr.map[m]->segs[n].vaddr = phys_to_virt(page_list[i]); 351 fmr->mr.map[m]->segs[n].vaddr = (void *) page_list[i];
351 fmr->mr.map[m]->segs[n].length = ps; 352 fmr->mr.map[m]->segs[n].length = ps;
352 if (++n == IPATH_SEGSZ) { 353 if (++n == IPATH_SEGSZ) {
353 m++; 354 m++;
diff --git a/drivers/infiniband/hw/ipath/ipath_sysfs.c b/drivers/infiniband/hw/ipath/ipath_sysfs.c
index 182de34f9f47..ffa6318ad0cc 100644
--- a/drivers/infiniband/hw/ipath/ipath_sysfs.c
+++ b/drivers/infiniband/hw/ipath/ipath_sysfs.c
@@ -215,7 +215,6 @@ static ssize_t store_mlid(struct device *dev,
215 size_t count) 215 size_t count)
216{ 216{
217 struct ipath_devdata *dd = dev_get_drvdata(dev); 217 struct ipath_devdata *dd = dev_get_drvdata(dev);
218 int unit;
219 u16 mlid; 218 u16 mlid;
220 int ret; 219 int ret;
221 220
@@ -223,8 +222,6 @@ static ssize_t store_mlid(struct device *dev,
223 if (ret < 0 || mlid < IPATH_MULTICAST_LID_BASE) 222 if (ret < 0 || mlid < IPATH_MULTICAST_LID_BASE)
224 goto invalid; 223 goto invalid;
225 224
226 unit = dd->ipath_unit;
227
228 dd->ipath_mlid = mlid; 225 dd->ipath_mlid = mlid;
229 226
230 goto bail; 227 goto bail;
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.c b/drivers/infiniband/hw/ipath/ipath_verbs.c
index acdee33ee1f8..2aaacdb7e52a 100644
--- a/drivers/infiniband/hw/ipath/ipath_verbs.c
+++ b/drivers/infiniband/hw/ipath/ipath_verbs.c
@@ -1599,6 +1599,7 @@ int ipath_register_ib_device(struct ipath_devdata *dd)
1599 dev->detach_mcast = ipath_multicast_detach; 1599 dev->detach_mcast = ipath_multicast_detach;
1600 dev->process_mad = ipath_process_mad; 1600 dev->process_mad = ipath_process_mad;
1601 dev->mmap = ipath_mmap; 1601 dev->mmap = ipath_mmap;
1602 dev->dma_ops = &ipath_dma_mapping_ops;
1602 1603
1603 snprintf(dev->node_desc, sizeof(dev->node_desc), 1604 snprintf(dev->node_desc, sizeof(dev->node_desc),
1604 IPATH_IDSTR " %s", init_utsname()->nodename); 1605 IPATH_IDSTR " %s", init_utsname()->nodename);
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.h b/drivers/infiniband/hw/ipath/ipath_verbs.h
index 8039f6e5f0c8..c0c8d5b24a7d 100644
--- a/drivers/infiniband/hw/ipath/ipath_verbs.h
+++ b/drivers/infiniband/hw/ipath/ipath_verbs.h
@@ -812,4 +812,6 @@ extern unsigned int ib_ipath_max_srq_wrs;
812 812
813extern const u32 ib_ipath_rnr_table[]; 813extern const u32 ib_ipath_rnr_table[];
814 814
815extern struct ib_dma_mapping_ops ipath_dma_mapping_ops;
816
815#endif /* IPATH_VERBS_H */ 817#endif /* IPATH_VERBS_H */
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index 99547996aba2..07deee8f81ce 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -105,12 +105,12 @@ struct ipoib_mcast;
105 105
106struct ipoib_rx_buf { 106struct ipoib_rx_buf {
107 struct sk_buff *skb; 107 struct sk_buff *skb;
108 dma_addr_t mapping; 108 u64 mapping;
109}; 109};
110 110
111struct ipoib_tx_buf { 111struct ipoib_tx_buf {
112 struct sk_buff *skb; 112 struct sk_buff *skb;
113 DECLARE_PCI_UNMAP_ADDR(mapping) 113 u64 mapping;
114}; 114};
115 115
116/* 116/*
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
index f10fba5d3265..59d9594ed6d9 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -109,9 +109,8 @@ static int ipoib_ib_post_receive(struct net_device *dev, int id)
109 ret = ib_post_recv(priv->qp, &param, &bad_wr); 109 ret = ib_post_recv(priv->qp, &param, &bad_wr);
110 if (unlikely(ret)) { 110 if (unlikely(ret)) {
111 ipoib_warn(priv, "receive failed for buf %d (%d)\n", id, ret); 111 ipoib_warn(priv, "receive failed for buf %d (%d)\n", id, ret);
112 dma_unmap_single(priv->ca->dma_device, 112 ib_dma_unmap_single(priv->ca, priv->rx_ring[id].mapping,
113 priv->rx_ring[id].mapping, 113 IPOIB_BUF_SIZE, DMA_FROM_DEVICE);
114 IPOIB_BUF_SIZE, DMA_FROM_DEVICE);
115 dev_kfree_skb_any(priv->rx_ring[id].skb); 114 dev_kfree_skb_any(priv->rx_ring[id].skb);
116 priv->rx_ring[id].skb = NULL; 115 priv->rx_ring[id].skb = NULL;
117 } 116 }
@@ -123,7 +122,7 @@ static int ipoib_alloc_rx_skb(struct net_device *dev, int id)
123{ 122{
124 struct ipoib_dev_priv *priv = netdev_priv(dev); 123 struct ipoib_dev_priv *priv = netdev_priv(dev);
125 struct sk_buff *skb; 124 struct sk_buff *skb;
126 dma_addr_t addr; 125 u64 addr;
127 126
128 skb = dev_alloc_skb(IPOIB_BUF_SIZE + 4); 127 skb = dev_alloc_skb(IPOIB_BUF_SIZE + 4);
129 if (!skb) 128 if (!skb)
@@ -136,10 +135,9 @@ static int ipoib_alloc_rx_skb(struct net_device *dev, int id)
136 */ 135 */
137 skb_reserve(skb, 4); 136 skb_reserve(skb, 4);
138 137
139 addr = dma_map_single(priv->ca->dma_device, 138 addr = ib_dma_map_single(priv->ca, skb->data, IPOIB_BUF_SIZE,
140 skb->data, IPOIB_BUF_SIZE, 139 DMA_FROM_DEVICE);
141 DMA_FROM_DEVICE); 140 if (unlikely(ib_dma_mapping_error(priv->ca, addr))) {
142 if (unlikely(dma_mapping_error(addr))) {
143 dev_kfree_skb_any(skb); 141 dev_kfree_skb_any(skb);
144 return -EIO; 142 return -EIO;
145 } 143 }
@@ -174,7 +172,7 @@ static void ipoib_ib_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
174 struct ipoib_dev_priv *priv = netdev_priv(dev); 172 struct ipoib_dev_priv *priv = netdev_priv(dev);
175 unsigned int wr_id = wc->wr_id & ~IPOIB_OP_RECV; 173 unsigned int wr_id = wc->wr_id & ~IPOIB_OP_RECV;
176 struct sk_buff *skb; 174 struct sk_buff *skb;
177 dma_addr_t addr; 175 u64 addr;
178 176
179 ipoib_dbg_data(priv, "recv completion: id %d, op %d, status: %d\n", 177 ipoib_dbg_data(priv, "recv completion: id %d, op %d, status: %d\n",
180 wr_id, wc->opcode, wc->status); 178 wr_id, wc->opcode, wc->status);
@@ -193,8 +191,8 @@ static void ipoib_ib_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
193 ipoib_warn(priv, "failed recv event " 191 ipoib_warn(priv, "failed recv event "
194 "(status=%d, wrid=%d vend_err %x)\n", 192 "(status=%d, wrid=%d vend_err %x)\n",
195 wc->status, wr_id, wc->vendor_err); 193 wc->status, wr_id, wc->vendor_err);
196 dma_unmap_single(priv->ca->dma_device, addr, 194 ib_dma_unmap_single(priv->ca, addr,
197 IPOIB_BUF_SIZE, DMA_FROM_DEVICE); 195 IPOIB_BUF_SIZE, DMA_FROM_DEVICE);
198 dev_kfree_skb_any(skb); 196 dev_kfree_skb_any(skb);
199 priv->rx_ring[wr_id].skb = NULL; 197 priv->rx_ring[wr_id].skb = NULL;
200 return; 198 return;
@@ -212,8 +210,7 @@ static void ipoib_ib_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
212 ipoib_dbg_data(priv, "received %d bytes, SLID 0x%04x\n", 210 ipoib_dbg_data(priv, "received %d bytes, SLID 0x%04x\n",
213 wc->byte_len, wc->slid); 211 wc->byte_len, wc->slid);
214 212
215 dma_unmap_single(priv->ca->dma_device, addr, 213 ib_dma_unmap_single(priv->ca, addr, IPOIB_BUF_SIZE, DMA_FROM_DEVICE);
216 IPOIB_BUF_SIZE, DMA_FROM_DEVICE);
217 214
218 skb_put(skb, wc->byte_len); 215 skb_put(skb, wc->byte_len);
219 skb_pull(skb, IB_GRH_BYTES); 216 skb_pull(skb, IB_GRH_BYTES);
@@ -261,10 +258,8 @@ static void ipoib_ib_handle_tx_wc(struct net_device *dev, struct ib_wc *wc)
261 258
262 tx_req = &priv->tx_ring[wr_id]; 259 tx_req = &priv->tx_ring[wr_id];
263 260
264 dma_unmap_single(priv->ca->dma_device, 261 ib_dma_unmap_single(priv->ca, tx_req->mapping,
265 pci_unmap_addr(tx_req, mapping), 262 tx_req->skb->len, DMA_TO_DEVICE);
266 tx_req->skb->len,
267 DMA_TO_DEVICE);
268 263
269 ++priv->stats.tx_packets; 264 ++priv->stats.tx_packets;
270 priv->stats.tx_bytes += tx_req->skb->len; 265 priv->stats.tx_bytes += tx_req->skb->len;
@@ -311,7 +306,7 @@ void ipoib_ib_completion(struct ib_cq *cq, void *dev_ptr)
311static inline int post_send(struct ipoib_dev_priv *priv, 306static inline int post_send(struct ipoib_dev_priv *priv,
312 unsigned int wr_id, 307 unsigned int wr_id,
313 struct ib_ah *address, u32 qpn, 308 struct ib_ah *address, u32 qpn,
314 dma_addr_t addr, int len) 309 u64 addr, int len)
315{ 310{
316 struct ib_send_wr *bad_wr; 311 struct ib_send_wr *bad_wr;
317 312
@@ -330,7 +325,7 @@ void ipoib_send(struct net_device *dev, struct sk_buff *skb,
330{ 325{
331 struct ipoib_dev_priv *priv = netdev_priv(dev); 326 struct ipoib_dev_priv *priv = netdev_priv(dev);
332 struct ipoib_tx_buf *tx_req; 327 struct ipoib_tx_buf *tx_req;
333 dma_addr_t addr; 328 u64 addr;
334 329
335 if (unlikely(skb->len > dev->mtu + INFINIBAND_ALEN)) { 330 if (unlikely(skb->len > dev->mtu + INFINIBAND_ALEN)) {
336 ipoib_warn(priv, "packet len %d (> %d) too long to send, dropping\n", 331 ipoib_warn(priv, "packet len %d (> %d) too long to send, dropping\n",
@@ -353,21 +348,20 @@ void ipoib_send(struct net_device *dev, struct sk_buff *skb,
353 */ 348 */
354 tx_req = &priv->tx_ring[priv->tx_head & (ipoib_sendq_size - 1)]; 349 tx_req = &priv->tx_ring[priv->tx_head & (ipoib_sendq_size - 1)];
355 tx_req->skb = skb; 350 tx_req->skb = skb;
356 addr = dma_map_single(priv->ca->dma_device, skb->data, skb->len, 351 addr = ib_dma_map_single(priv->ca, skb->data, skb->len,
357 DMA_TO_DEVICE); 352 DMA_TO_DEVICE);
358 if (unlikely(dma_mapping_error(addr))) { 353 if (unlikely(ib_dma_mapping_error(priv->ca, addr))) {
359 ++priv->stats.tx_errors; 354 ++priv->stats.tx_errors;
360 dev_kfree_skb_any(skb); 355 dev_kfree_skb_any(skb);
361 return; 356 return;
362 } 357 }
363 pci_unmap_addr_set(tx_req, mapping, addr); 358 tx_req->mapping = addr;
364 359
365 if (unlikely(post_send(priv, priv->tx_head & (ipoib_sendq_size - 1), 360 if (unlikely(post_send(priv, priv->tx_head & (ipoib_sendq_size - 1),
366 address->ah, qpn, addr, skb->len))) { 361 address->ah, qpn, addr, skb->len))) {
367 ipoib_warn(priv, "post_send failed\n"); 362 ipoib_warn(priv, "post_send failed\n");
368 ++priv->stats.tx_errors; 363 ++priv->stats.tx_errors;
369 dma_unmap_single(priv->ca->dma_device, addr, skb->len, 364 ib_dma_unmap_single(priv->ca, addr, skb->len, DMA_TO_DEVICE);
370 DMA_TO_DEVICE);
371 dev_kfree_skb_any(skb); 365 dev_kfree_skb_any(skb);
372 } else { 366 } else {
373 dev->trans_start = jiffies; 367 dev->trans_start = jiffies;
@@ -538,24 +532,27 @@ int ipoib_ib_dev_stop(struct net_device *dev)
538 while ((int) priv->tx_tail - (int) priv->tx_head < 0) { 532 while ((int) priv->tx_tail - (int) priv->tx_head < 0) {
539 tx_req = &priv->tx_ring[priv->tx_tail & 533 tx_req = &priv->tx_ring[priv->tx_tail &
540 (ipoib_sendq_size - 1)]; 534 (ipoib_sendq_size - 1)];
541 dma_unmap_single(priv->ca->dma_device, 535 ib_dma_unmap_single(priv->ca,
542 pci_unmap_addr(tx_req, mapping), 536 tx_req->mapping,
543 tx_req->skb->len, 537 tx_req->skb->len,
544 DMA_TO_DEVICE); 538 DMA_TO_DEVICE);
545 dev_kfree_skb_any(tx_req->skb); 539 dev_kfree_skb_any(tx_req->skb);
546 ++priv->tx_tail; 540 ++priv->tx_tail;
547 } 541 }
548 542
549 for (i = 0; i < ipoib_recvq_size; ++i) 543 for (i = 0; i < ipoib_recvq_size; ++i) {
550 if (priv->rx_ring[i].skb) { 544 struct ipoib_rx_buf *rx_req;
551 dma_unmap_single(priv->ca->dma_device, 545
552 pci_unmap_addr(&priv->rx_ring[i], 546 rx_req = &priv->rx_ring[i];
553 mapping), 547 if (!rx_req->skb)
554 IPOIB_BUF_SIZE, 548 continue;
555 DMA_FROM_DEVICE); 549 ib_dma_unmap_single(priv->ca,
556 dev_kfree_skb_any(priv->rx_ring[i].skb); 550 rx_req->mapping,
557 priv->rx_ring[i].skb = NULL; 551 IPOIB_BUF_SIZE,
558 } 552 DMA_FROM_DEVICE);
553 dev_kfree_skb_any(rx_req->skb);
554 rx_req->skb = NULL;
555 }
559 556
560 goto timeout; 557 goto timeout;
561 } 558 }
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index c09280243726..705eb1d0e554 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -497,8 +497,6 @@ static void neigh_add_path(struct sk_buff *skb, struct net_device *dev)
497 return; 497 return;
498 } 498 }
499 499
500 skb_queue_head_init(&neigh->queue);
501
502 /* 500 /*
503 * We can only be called from ipoib_start_xmit, so we're 501 * We can only be called from ipoib_start_xmit, so we're
504 * inside tx_lock -- no need to save/restore flags. 502 * inside tx_lock -- no need to save/restore flags.
@@ -806,6 +804,7 @@ struct ipoib_neigh *ipoib_neigh_alloc(struct neighbour *neighbour)
806 804
807 neigh->neighbour = neighbour; 805 neigh->neighbour = neighbour;
808 *to_ipoib_neigh(neighbour) = neigh; 806 *to_ipoib_neigh(neighbour) = neigh;
807 skb_queue_head_init(&neigh->queue);
809 808
810 return neigh; 809 return neigh;
811} 810}
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.h b/drivers/infiniband/ulp/iser/iscsi_iser.h
index 234e5b061a75..cae8c96a55f8 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.h
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.h
@@ -182,7 +182,7 @@ struct iser_regd_buf {
182 struct iser_mem_reg reg; /* memory registration info */ 182 struct iser_mem_reg reg; /* memory registration info */
183 void *virt_addr; 183 void *virt_addr;
184 struct iser_device *device; /* device->device for dma_unmap */ 184 struct iser_device *device; /* device->device for dma_unmap */
185 dma_addr_t dma_addr; /* if non zero, addr for dma_unmap */ 185 u64 dma_addr; /* if non zero, addr for dma_unmap */
186 enum dma_data_direction direction; /* direction for dma_unmap */ 186 enum dma_data_direction direction; /* direction for dma_unmap */
187 unsigned int data_size; 187 unsigned int data_size;
188 atomic_t ref_count; /* refcount, freed when dec to 0 */ 188 atomic_t ref_count; /* refcount, freed when dec to 0 */
diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c b/drivers/infiniband/ulp/iser/iser_initiator.c
index 9b3d79c796c8..e73c87b9be43 100644
--- a/drivers/infiniband/ulp/iser/iser_initiator.c
+++ b/drivers/infiniband/ulp/iser/iser_initiator.c
@@ -487,10 +487,8 @@ int iser_send_control(struct iscsi_conn *conn,
487 struct iscsi_iser_conn *iser_conn = conn->dd_data; 487 struct iscsi_iser_conn *iser_conn = conn->dd_data;
488 struct iser_desc *mdesc = mtask->dd_data; 488 struct iser_desc *mdesc = mtask->dd_data;
489 struct iser_dto *send_dto = NULL; 489 struct iser_dto *send_dto = NULL;
490 unsigned int itt;
491 unsigned long data_seg_len; 490 unsigned long data_seg_len;
492 int err = 0; 491 int err = 0;
493 unsigned char opcode;
494 struct iser_regd_buf *regd_buf; 492 struct iser_regd_buf *regd_buf;
495 struct iser_device *device; 493 struct iser_device *device;
496 494
@@ -512,8 +510,6 @@ int iser_send_control(struct iscsi_conn *conn,
512 510
513 iser_reg_single(device, send_dto->regd[0], DMA_TO_DEVICE); 511 iser_reg_single(device, send_dto->regd[0], DMA_TO_DEVICE);
514 512
515 itt = ntohl(mtask->hdr->itt);
516 opcode = mtask->hdr->opcode & ISCSI_OPCODE_MASK;
517 data_seg_len = ntoh24(mtask->hdr->dlength); 513 data_seg_len = ntoh24(mtask->hdr->dlength);
518 514
519 if (data_seg_len > 0) { 515 if (data_seg_len > 0) {
diff --git a/drivers/infiniband/ulp/iser/iser_memory.c b/drivers/infiniband/ulp/iser/iser_memory.c
index 3aedd59b8a84..fc9f1fd0ae54 100644
--- a/drivers/infiniband/ulp/iser/iser_memory.c
+++ b/drivers/infiniband/ulp/iser/iser_memory.c
@@ -52,7 +52,7 @@
52 */ 52 */
53int iser_regd_buff_release(struct iser_regd_buf *regd_buf) 53int iser_regd_buff_release(struct iser_regd_buf *regd_buf)
54{ 54{
55 struct device *dma_device; 55 struct ib_device *dev;
56 56
57 if ((atomic_read(&regd_buf->ref_count) == 0) || 57 if ((atomic_read(&regd_buf->ref_count) == 0) ||
58 atomic_dec_and_test(&regd_buf->ref_count)) { 58 atomic_dec_and_test(&regd_buf->ref_count)) {
@@ -61,8 +61,8 @@ int iser_regd_buff_release(struct iser_regd_buf *regd_buf)
61 iser_unreg_mem(&regd_buf->reg); 61 iser_unreg_mem(&regd_buf->reg);
62 62
63 if (regd_buf->dma_addr) { 63 if (regd_buf->dma_addr) {
64 dma_device = regd_buf->device->ib_device->dma_device; 64 dev = regd_buf->device->ib_device;
65 dma_unmap_single(dma_device, 65 ib_dma_unmap_single(dev,
66 regd_buf->dma_addr, 66 regd_buf->dma_addr,
67 regd_buf->data_size, 67 regd_buf->data_size,
68 regd_buf->direction); 68 regd_buf->direction);
@@ -84,12 +84,12 @@ void iser_reg_single(struct iser_device *device,
84 struct iser_regd_buf *regd_buf, 84 struct iser_regd_buf *regd_buf,
85 enum dma_data_direction direction) 85 enum dma_data_direction direction)
86{ 86{
87 dma_addr_t dma_addr; 87 u64 dma_addr;
88 88
89 dma_addr = dma_map_single(device->ib_device->dma_device, 89 dma_addr = ib_dma_map_single(device->ib_device,
90 regd_buf->virt_addr, 90 regd_buf->virt_addr,
91 regd_buf->data_size, direction); 91 regd_buf->data_size, direction);
92 BUG_ON(dma_mapping_error(dma_addr)); 92 BUG_ON(ib_dma_mapping_error(device->ib_device, dma_addr));
93 93
94 regd_buf->reg.lkey = device->mr->lkey; 94 regd_buf->reg.lkey = device->mr->lkey;
95 regd_buf->reg.len = regd_buf->data_size; 95 regd_buf->reg.len = regd_buf->data_size;
@@ -107,7 +107,7 @@ int iser_start_rdma_unaligned_sg(struct iscsi_iser_cmd_task *iser_ctask,
107 enum iser_data_dir cmd_dir) 107 enum iser_data_dir cmd_dir)
108{ 108{
109 int dma_nents; 109 int dma_nents;
110 struct device *dma_device; 110 struct ib_device *dev;
111 char *mem = NULL; 111 char *mem = NULL;
112 struct iser_data_buf *data = &iser_ctask->data[cmd_dir]; 112 struct iser_data_buf *data = &iser_ctask->data[cmd_dir];
113 unsigned long cmd_data_len = data->data_len; 113 unsigned long cmd_data_len = data->data_len;
@@ -147,17 +147,12 @@ int iser_start_rdma_unaligned_sg(struct iscsi_iser_cmd_task *iser_ctask,
147 147
148 iser_ctask->data_copy[cmd_dir].copy_buf = mem; 148 iser_ctask->data_copy[cmd_dir].copy_buf = mem;
149 149
150 dma_device = iser_ctask->iser_conn->ib_conn->device->ib_device->dma_device; 150 dev = iser_ctask->iser_conn->ib_conn->device->ib_device;
151 151 dma_nents = ib_dma_map_sg(dev,
152 if (cmd_dir == ISER_DIR_OUT) 152 &iser_ctask->data_copy[cmd_dir].sg_single,
153 dma_nents = dma_map_sg(dma_device, 153 1,
154 &iser_ctask->data_copy[cmd_dir].sg_single, 154 (cmd_dir == ISER_DIR_OUT) ?
155 1, DMA_TO_DEVICE); 155 DMA_TO_DEVICE : DMA_FROM_DEVICE);
156 else
157 dma_nents = dma_map_sg(dma_device,
158 &iser_ctask->data_copy[cmd_dir].sg_single,
159 1, DMA_FROM_DEVICE);
160
161 BUG_ON(dma_nents == 0); 156 BUG_ON(dma_nents == 0);
162 157
163 iser_ctask->data_copy[cmd_dir].dma_nents = dma_nents; 158 iser_ctask->data_copy[cmd_dir].dma_nents = dma_nents;
@@ -170,19 +165,16 @@ int iser_start_rdma_unaligned_sg(struct iscsi_iser_cmd_task *iser_ctask,
170void iser_finalize_rdma_unaligned_sg(struct iscsi_iser_cmd_task *iser_ctask, 165void iser_finalize_rdma_unaligned_sg(struct iscsi_iser_cmd_task *iser_ctask,
171 enum iser_data_dir cmd_dir) 166 enum iser_data_dir cmd_dir)
172{ 167{
173 struct device *dma_device; 168 struct ib_device *dev;
174 struct iser_data_buf *mem_copy; 169 struct iser_data_buf *mem_copy;
175 unsigned long cmd_data_len; 170 unsigned long cmd_data_len;
176 171
177 dma_device = iser_ctask->iser_conn->ib_conn->device->ib_device->dma_device; 172 dev = iser_ctask->iser_conn->ib_conn->device->ib_device;
178 mem_copy = &iser_ctask->data_copy[cmd_dir]; 173 mem_copy = &iser_ctask->data_copy[cmd_dir];
179 174
180 if (cmd_dir == ISER_DIR_OUT) 175 ib_dma_unmap_sg(dev, &mem_copy->sg_single, 1,
181 dma_unmap_sg(dma_device, &mem_copy->sg_single, 1, 176 (cmd_dir == ISER_DIR_OUT) ?
182 DMA_TO_DEVICE); 177 DMA_TO_DEVICE : DMA_FROM_DEVICE);
183 else
184 dma_unmap_sg(dma_device, &mem_copy->sg_single, 1,
185 DMA_FROM_DEVICE);
186 178
187 if (cmd_dir == ISER_DIR_IN) { 179 if (cmd_dir == ISER_DIR_IN) {
188 char *mem; 180 char *mem;
@@ -231,11 +223,12 @@ void iser_finalize_rdma_unaligned_sg(struct iscsi_iser_cmd_task *iser_ctask,
231 * consecutive elements. Also, it handles one entry SG. 223 * consecutive elements. Also, it handles one entry SG.
232 */ 224 */
233static int iser_sg_to_page_vec(struct iser_data_buf *data, 225static int iser_sg_to_page_vec(struct iser_data_buf *data,
234 struct iser_page_vec *page_vec) 226 struct iser_page_vec *page_vec,
227 struct ib_device *ibdev)
235{ 228{
236 struct scatterlist *sg = (struct scatterlist *)data->buf; 229 struct scatterlist *sg = (struct scatterlist *)data->buf;
237 dma_addr_t first_addr, last_addr, page; 230 u64 first_addr, last_addr, page;
238 int start_aligned, end_aligned; 231 int end_aligned;
239 unsigned int cur_page = 0; 232 unsigned int cur_page = 0;
240 unsigned long total_sz = 0; 233 unsigned long total_sz = 0;
241 int i; 234 int i;
@@ -244,19 +237,21 @@ static int iser_sg_to_page_vec(struct iser_data_buf *data,
244 page_vec->offset = (u64) sg[0].offset & ~MASK_4K; 237 page_vec->offset = (u64) sg[0].offset & ~MASK_4K;
245 238
246 for (i = 0; i < data->dma_nents; i++) { 239 for (i = 0; i < data->dma_nents; i++) {
247 total_sz += sg_dma_len(&sg[i]); 240 unsigned int dma_len = ib_sg_dma_len(ibdev, &sg[i]);
241
242 total_sz += dma_len;
248 243
249 first_addr = sg_dma_address(&sg[i]); 244 first_addr = ib_sg_dma_address(ibdev, &sg[i]);
250 last_addr = first_addr + sg_dma_len(&sg[i]); 245 last_addr = first_addr + dma_len;
251 246
252 start_aligned = !(first_addr & ~MASK_4K);
253 end_aligned = !(last_addr & ~MASK_4K); 247 end_aligned = !(last_addr & ~MASK_4K);
254 248
255 /* continue to collect page fragments till aligned or SG ends */ 249 /* continue to collect page fragments till aligned or SG ends */
256 while (!end_aligned && (i + 1 < data->dma_nents)) { 250 while (!end_aligned && (i + 1 < data->dma_nents)) {
257 i++; 251 i++;
258 total_sz += sg_dma_len(&sg[i]); 252 dma_len = ib_sg_dma_len(ibdev, &sg[i]);
259 last_addr = sg_dma_address(&sg[i]) + sg_dma_len(&sg[i]); 253 total_sz += dma_len;
254 last_addr = ib_sg_dma_address(ibdev, &sg[i]) + dma_len;
260 end_aligned = !(last_addr & ~MASK_4K); 255 end_aligned = !(last_addr & ~MASK_4K);
261 } 256 }
262 257
@@ -288,10 +283,11 @@ static int iser_sg_to_page_vec(struct iser_data_buf *data,
288 * the number of entries which are aligned correctly. Supports the case where 283 * the number of entries which are aligned correctly. Supports the case where
289 * consecutive SG elements are actually fragments of the same physcial page. 284 * consecutive SG elements are actually fragments of the same physcial page.
290 */ 285 */
291static unsigned int iser_data_buf_aligned_len(struct iser_data_buf *data) 286static unsigned int iser_data_buf_aligned_len(struct iser_data_buf *data,
287 struct ib_device *ibdev)
292{ 288{
293 struct scatterlist *sg; 289 struct scatterlist *sg;
294 dma_addr_t end_addr, next_addr; 290 u64 end_addr, next_addr;
295 int i, cnt; 291 int i, cnt;
296 unsigned int ret_len = 0; 292 unsigned int ret_len = 0;
297 293
@@ -303,12 +299,12 @@ static unsigned int iser_data_buf_aligned_len(struct iser_data_buf *data)
303 (unsigned long)page_to_phys(sg[i].page), 299 (unsigned long)page_to_phys(sg[i].page),
304 (unsigned long)sg[i].offset, 300 (unsigned long)sg[i].offset,
305 (unsigned long)sg[i].length); */ 301 (unsigned long)sg[i].length); */
306 end_addr = sg_dma_address(&sg[i]) + 302 end_addr = ib_sg_dma_address(ibdev, &sg[i]) +
307 sg_dma_len(&sg[i]); 303 ib_sg_dma_len(ibdev, &sg[i]);
308 /* iser_dbg("Checking sg iobuf end address " 304 /* iser_dbg("Checking sg iobuf end address "
309 "0x%08lX\n", end_addr); */ 305 "0x%08lX\n", end_addr); */
310 if (i + 1 < data->dma_nents) { 306 if (i + 1 < data->dma_nents) {
311 next_addr = sg_dma_address(&sg[i+1]); 307 next_addr = ib_sg_dma_address(ibdev, &sg[i+1]);
312 /* are i, i+1 fragments of the same page? */ 308 /* are i, i+1 fragments of the same page? */
313 if (end_addr == next_addr) 309 if (end_addr == next_addr)
314 continue; 310 continue;
@@ -325,7 +321,8 @@ static unsigned int iser_data_buf_aligned_len(struct iser_data_buf *data)
325 return ret_len; 321 return ret_len;
326} 322}
327 323
328static void iser_data_buf_dump(struct iser_data_buf *data) 324static void iser_data_buf_dump(struct iser_data_buf *data,
325 struct ib_device *ibdev)
329{ 326{
330 struct scatterlist *sg = (struct scatterlist *)data->buf; 327 struct scatterlist *sg = (struct scatterlist *)data->buf;
331 int i; 328 int i;
@@ -333,9 +330,9 @@ static void iser_data_buf_dump(struct iser_data_buf *data)
333 for (i = 0; i < data->dma_nents; i++) 330 for (i = 0; i < data->dma_nents; i++)
334 iser_err("sg[%d] dma_addr:0x%lX page:0x%p " 331 iser_err("sg[%d] dma_addr:0x%lX page:0x%p "
335 "off:0x%x sz:0x%x dma_len:0x%x\n", 332 "off:0x%x sz:0x%x dma_len:0x%x\n",
336 i, (unsigned long)sg_dma_address(&sg[i]), 333 i, (unsigned long)ib_sg_dma_address(ibdev, &sg[i]),
337 sg[i].page, sg[i].offset, 334 sg[i].page, sg[i].offset,
338 sg[i].length,sg_dma_len(&sg[i])); 335 sg[i].length, ib_sg_dma_len(ibdev, &sg[i]));
339} 336}
340 337
341static void iser_dump_page_vec(struct iser_page_vec *page_vec) 338static void iser_dump_page_vec(struct iser_page_vec *page_vec)
@@ -349,7 +346,8 @@ static void iser_dump_page_vec(struct iser_page_vec *page_vec)
349} 346}
350 347
351static void iser_page_vec_build(struct iser_data_buf *data, 348static void iser_page_vec_build(struct iser_data_buf *data,
352 struct iser_page_vec *page_vec) 349 struct iser_page_vec *page_vec,
350 struct ib_device *ibdev)
353{ 351{
354 int page_vec_len = 0; 352 int page_vec_len = 0;
355 353
@@ -357,14 +355,14 @@ static void iser_page_vec_build(struct iser_data_buf *data,
357 page_vec->offset = 0; 355 page_vec->offset = 0;
358 356
359 iser_dbg("Translating sg sz: %d\n", data->dma_nents); 357 iser_dbg("Translating sg sz: %d\n", data->dma_nents);
360 page_vec_len = iser_sg_to_page_vec(data,page_vec); 358 page_vec_len = iser_sg_to_page_vec(data, page_vec, ibdev);
361 iser_dbg("sg len %d page_vec_len %d\n", data->dma_nents,page_vec_len); 359 iser_dbg("sg len %d page_vec_len %d\n", data->dma_nents,page_vec_len);
362 360
363 page_vec->length = page_vec_len; 361 page_vec->length = page_vec_len;
364 362
365 if (page_vec_len * SIZE_4K < page_vec->data_size) { 363 if (page_vec_len * SIZE_4K < page_vec->data_size) {
366 iser_err("page_vec too short to hold this SG\n"); 364 iser_err("page_vec too short to hold this SG\n");
367 iser_data_buf_dump(data); 365 iser_data_buf_dump(data, ibdev);
368 iser_dump_page_vec(page_vec); 366 iser_dump_page_vec(page_vec);
369 BUG(); 367 BUG();
370 } 368 }
@@ -375,13 +373,12 @@ int iser_dma_map_task_data(struct iscsi_iser_cmd_task *iser_ctask,
375 enum iser_data_dir iser_dir, 373 enum iser_data_dir iser_dir,
376 enum dma_data_direction dma_dir) 374 enum dma_data_direction dma_dir)
377{ 375{
378 struct device *dma_device; 376 struct ib_device *dev;
379 377
380 iser_ctask->dir[iser_dir] = 1; 378 iser_ctask->dir[iser_dir] = 1;
381 dma_device = 379 dev = iser_ctask->iser_conn->ib_conn->device->ib_device;
382 iser_ctask->iser_conn->ib_conn->device->ib_device->dma_device;
383 380
384 data->dma_nents = dma_map_sg(dma_device, data->buf, data->size, dma_dir); 381 data->dma_nents = ib_dma_map_sg(dev, data->buf, data->size, dma_dir);
385 if (data->dma_nents == 0) { 382 if (data->dma_nents == 0) {
386 iser_err("dma_map_sg failed!!!\n"); 383 iser_err("dma_map_sg failed!!!\n");
387 return -EINVAL; 384 return -EINVAL;
@@ -391,20 +388,19 @@ int iser_dma_map_task_data(struct iscsi_iser_cmd_task *iser_ctask,
391 388
392void iser_dma_unmap_task_data(struct iscsi_iser_cmd_task *iser_ctask) 389void iser_dma_unmap_task_data(struct iscsi_iser_cmd_task *iser_ctask)
393{ 390{
394 struct device *dma_device; 391 struct ib_device *dev;
395 struct iser_data_buf *data; 392 struct iser_data_buf *data;
396 393
397 dma_device = 394 dev = iser_ctask->iser_conn->ib_conn->device->ib_device;
398 iser_ctask->iser_conn->ib_conn->device->ib_device->dma_device;
399 395
400 if (iser_ctask->dir[ISER_DIR_IN]) { 396 if (iser_ctask->dir[ISER_DIR_IN]) {
401 data = &iser_ctask->data[ISER_DIR_IN]; 397 data = &iser_ctask->data[ISER_DIR_IN];
402 dma_unmap_sg(dma_device, data->buf, data->size, DMA_FROM_DEVICE); 398 ib_dma_unmap_sg(dev, data->buf, data->size, DMA_FROM_DEVICE);
403 } 399 }
404 400
405 if (iser_ctask->dir[ISER_DIR_OUT]) { 401 if (iser_ctask->dir[ISER_DIR_OUT]) {
406 data = &iser_ctask->data[ISER_DIR_OUT]; 402 data = &iser_ctask->data[ISER_DIR_OUT];
407 dma_unmap_sg(dma_device, data->buf, data->size, DMA_TO_DEVICE); 403 ib_dma_unmap_sg(dev, data->buf, data->size, DMA_TO_DEVICE);
408 } 404 }
409} 405}
410 406
@@ -419,6 +415,7 @@ int iser_reg_rdma_mem(struct iscsi_iser_cmd_task *iser_ctask,
419{ 415{
420 struct iser_conn *ib_conn = iser_ctask->iser_conn->ib_conn; 416 struct iser_conn *ib_conn = iser_ctask->iser_conn->ib_conn;
421 struct iser_device *device = ib_conn->device; 417 struct iser_device *device = ib_conn->device;
418 struct ib_device *ibdev = device->ib_device;
422 struct iser_data_buf *mem = &iser_ctask->data[cmd_dir]; 419 struct iser_data_buf *mem = &iser_ctask->data[cmd_dir];
423 struct iser_regd_buf *regd_buf; 420 struct iser_regd_buf *regd_buf;
424 int aligned_len; 421 int aligned_len;
@@ -428,11 +425,11 @@ int iser_reg_rdma_mem(struct iscsi_iser_cmd_task *iser_ctask,
428 425
429 regd_buf = &iser_ctask->rdma_regd[cmd_dir]; 426 regd_buf = &iser_ctask->rdma_regd[cmd_dir];
430 427
431 aligned_len = iser_data_buf_aligned_len(mem); 428 aligned_len = iser_data_buf_aligned_len(mem, ibdev);
432 if (aligned_len != mem->dma_nents) { 429 if (aligned_len != mem->dma_nents) {
433 iser_err("rdma alignment violation %d/%d aligned\n", 430 iser_err("rdma alignment violation %d/%d aligned\n",
434 aligned_len, mem->size); 431 aligned_len, mem->size);
435 iser_data_buf_dump(mem); 432 iser_data_buf_dump(mem, ibdev);
436 433
437 /* unmap the command data before accessing it */ 434 /* unmap the command data before accessing it */
438 iser_dma_unmap_task_data(iser_ctask); 435 iser_dma_unmap_task_data(iser_ctask);
@@ -450,8 +447,8 @@ int iser_reg_rdma_mem(struct iscsi_iser_cmd_task *iser_ctask,
450 447
451 regd_buf->reg.lkey = device->mr->lkey; 448 regd_buf->reg.lkey = device->mr->lkey;
452 regd_buf->reg.rkey = device->mr->rkey; 449 regd_buf->reg.rkey = device->mr->rkey;
453 regd_buf->reg.len = sg_dma_len(&sg[0]); 450 regd_buf->reg.len = ib_sg_dma_len(ibdev, &sg[0]);
454 regd_buf->reg.va = sg_dma_address(&sg[0]); 451 regd_buf->reg.va = ib_sg_dma_address(ibdev, &sg[0]);
455 regd_buf->reg.is_fmr = 0; 452 regd_buf->reg.is_fmr = 0;
456 453
457 iser_dbg("PHYSICAL Mem.register: lkey: 0x%08X rkey: 0x%08X " 454 iser_dbg("PHYSICAL Mem.register: lkey: 0x%08X rkey: 0x%08X "
@@ -461,10 +458,10 @@ int iser_reg_rdma_mem(struct iscsi_iser_cmd_task *iser_ctask,
461 (unsigned long)regd_buf->reg.va, 458 (unsigned long)regd_buf->reg.va,
462 (unsigned long)regd_buf->reg.len); 459 (unsigned long)regd_buf->reg.len);
463 } else { /* use FMR for multiple dma entries */ 460 } else { /* use FMR for multiple dma entries */
464 iser_page_vec_build(mem, ib_conn->page_vec); 461 iser_page_vec_build(mem, ib_conn->page_vec, ibdev);
465 err = iser_reg_page_vec(ib_conn, ib_conn->page_vec, &regd_buf->reg); 462 err = iser_reg_page_vec(ib_conn, ib_conn->page_vec, &regd_buf->reg);
466 if (err) { 463 if (err) {
467 iser_data_buf_dump(mem); 464 iser_data_buf_dump(mem, ibdev);
468 iser_err("mem->dma_nents = %d (dlength = 0x%x)\n", mem->dma_nents, 465 iser_err("mem->dma_nents = %d (dlength = 0x%x)\n", mem->dma_nents,
469 ntoh24(iser_ctask->desc.iscsi_header.dlength)); 466 ntoh24(iser_ctask->desc.iscsi_header.dlength));
470 iser_err("page_vec: data_size = 0x%x, length = %d, offset = 0x%x\n", 467 iser_err("page_vec: data_size = 0x%x, length = %d, offset = 0x%x\n",
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index a6289595557b..e9b6a6f07dd7 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -122,9 +122,8 @@ static struct srp_iu *srp_alloc_iu(struct srp_host *host, size_t size,
122 if (!iu->buf) 122 if (!iu->buf)
123 goto out_free_iu; 123 goto out_free_iu;
124 124
125 iu->dma = dma_map_single(host->dev->dev->dma_device, 125 iu->dma = ib_dma_map_single(host->dev->dev, iu->buf, size, direction);
126 iu->buf, size, direction); 126 if (ib_dma_mapping_error(host->dev->dev, iu->dma))
127 if (dma_mapping_error(iu->dma))
128 goto out_free_buf; 127 goto out_free_buf;
129 128
130 iu->size = size; 129 iu->size = size;
@@ -145,8 +144,7 @@ static void srp_free_iu(struct srp_host *host, struct srp_iu *iu)
145 if (!iu) 144 if (!iu)
146 return; 145 return;
147 146
148 dma_unmap_single(host->dev->dev->dma_device, 147 ib_dma_unmap_single(host->dev->dev, iu->dma, iu->size, iu->direction);
149 iu->dma, iu->size, iu->direction);
150 kfree(iu->buf); 148 kfree(iu->buf);
151 kfree(iu); 149 kfree(iu);
152} 150}
@@ -482,8 +480,8 @@ static void srp_unmap_data(struct scsi_cmnd *scmnd,
482 scat = &req->fake_sg; 480 scat = &req->fake_sg;
483 } 481 }
484 482
485 dma_unmap_sg(target->srp_host->dev->dev->dma_device, scat, nents, 483 ib_dma_unmap_sg(target->srp_host->dev->dev, scat, nents,
486 scmnd->sc_data_direction); 484 scmnd->sc_data_direction);
487} 485}
488 486
489static void srp_remove_req(struct srp_target_port *target, struct srp_request *req) 487static void srp_remove_req(struct srp_target_port *target, struct srp_request *req)
@@ -595,23 +593,26 @@ static int srp_map_fmr(struct srp_target_port *target, struct scatterlist *scat,
595 int i, j; 593 int i, j;
596 int ret; 594 int ret;
597 struct srp_device *dev = target->srp_host->dev; 595 struct srp_device *dev = target->srp_host->dev;
596 struct ib_device *ibdev = dev->dev;
598 597
599 if (!dev->fmr_pool) 598 if (!dev->fmr_pool)
600 return -ENODEV; 599 return -ENODEV;
601 600
602 if ((sg_dma_address(&scat[0]) & ~dev->fmr_page_mask) && 601 if ((ib_sg_dma_address(ibdev, &scat[0]) & ~dev->fmr_page_mask) &&
603 mellanox_workarounds && !memcmp(&target->ioc_guid, mellanox_oui, 3)) 602 mellanox_workarounds && !memcmp(&target->ioc_guid, mellanox_oui, 3))
604 return -EINVAL; 603 return -EINVAL;
605 604
606 len = page_cnt = 0; 605 len = page_cnt = 0;
607 for (i = 0; i < sg_cnt; ++i) { 606 for (i = 0; i < sg_cnt; ++i) {
608 if (sg_dma_address(&scat[i]) & ~dev->fmr_page_mask) { 607 unsigned int dma_len = ib_sg_dma_len(ibdev, &scat[i]);
608
609 if (ib_sg_dma_address(ibdev, &scat[i]) & ~dev->fmr_page_mask) {
609 if (i > 0) 610 if (i > 0)
610 return -EINVAL; 611 return -EINVAL;
611 else 612 else
612 ++page_cnt; 613 ++page_cnt;
613 } 614 }
614 if ((sg_dma_address(&scat[i]) + sg_dma_len(&scat[i])) & 615 if ((ib_sg_dma_address(ibdev, &scat[i]) + dma_len) &
615 ~dev->fmr_page_mask) { 616 ~dev->fmr_page_mask) {
616 if (i < sg_cnt - 1) 617 if (i < sg_cnt - 1)
617 return -EINVAL; 618 return -EINVAL;
@@ -619,7 +620,7 @@ static int srp_map_fmr(struct srp_target_port *target, struct scatterlist *scat,
619 ++page_cnt; 620 ++page_cnt;
620 } 621 }
621 622
622 len += sg_dma_len(&scat[i]); 623 len += dma_len;
623 } 624 }
624 625
625 page_cnt += len >> dev->fmr_page_shift; 626 page_cnt += len >> dev->fmr_page_shift;
@@ -631,10 +632,14 @@ static int srp_map_fmr(struct srp_target_port *target, struct scatterlist *scat,
631 return -ENOMEM; 632 return -ENOMEM;
632 633
633 page_cnt = 0; 634 page_cnt = 0;
634 for (i = 0; i < sg_cnt; ++i) 635 for (i = 0; i < sg_cnt; ++i) {
635 for (j = 0; j < sg_dma_len(&scat[i]); j += dev->fmr_page_size) 636 unsigned int dma_len = ib_sg_dma_len(ibdev, &scat[i]);
637
638 for (j = 0; j < dma_len; j += dev->fmr_page_size)
636 dma_pages[page_cnt++] = 639 dma_pages[page_cnt++] =
637 (sg_dma_address(&scat[i]) & dev->fmr_page_mask) + j; 640 (ib_sg_dma_address(ibdev, &scat[i]) &
641 dev->fmr_page_mask) + j;
642 }
638 643
639 req->fmr = ib_fmr_pool_map_phys(dev->fmr_pool, 644 req->fmr = ib_fmr_pool_map_phys(dev->fmr_pool,
640 dma_pages, page_cnt, io_addr); 645 dma_pages, page_cnt, io_addr);
@@ -644,7 +649,8 @@ static int srp_map_fmr(struct srp_target_port *target, struct scatterlist *scat,
644 goto out; 649 goto out;
645 } 650 }
646 651
647 buf->va = cpu_to_be64(sg_dma_address(&scat[0]) & ~dev->fmr_page_mask); 652 buf->va = cpu_to_be64(ib_sg_dma_address(ibdev, &scat[0]) &
653 ~dev->fmr_page_mask);
648 buf->key = cpu_to_be32(req->fmr->fmr->rkey); 654 buf->key = cpu_to_be32(req->fmr->fmr->rkey);
649 buf->len = cpu_to_be32(len); 655 buf->len = cpu_to_be32(len);
650 656
@@ -663,6 +669,8 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_target_port *target,
663 struct srp_cmd *cmd = req->cmd->buf; 669 struct srp_cmd *cmd = req->cmd->buf;
664 int len, nents, count; 670 int len, nents, count;
665 u8 fmt = SRP_DATA_DESC_DIRECT; 671 u8 fmt = SRP_DATA_DESC_DIRECT;
672 struct srp_device *dev;
673 struct ib_device *ibdev;
666 674
667 if (!scmnd->request_buffer || scmnd->sc_data_direction == DMA_NONE) 675 if (!scmnd->request_buffer || scmnd->sc_data_direction == DMA_NONE)
668 return sizeof (struct srp_cmd); 676 return sizeof (struct srp_cmd);
@@ -687,8 +695,10 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_target_port *target,
687 sg_init_one(scat, scmnd->request_buffer, scmnd->request_bufflen); 695 sg_init_one(scat, scmnd->request_buffer, scmnd->request_bufflen);
688 } 696 }
689 697
690 count = dma_map_sg(target->srp_host->dev->dev->dma_device, 698 dev = target->srp_host->dev;
691 scat, nents, scmnd->sc_data_direction); 699 ibdev = dev->dev;
700
701 count = ib_dma_map_sg(ibdev, scat, nents, scmnd->sc_data_direction);
692 702
693 fmt = SRP_DATA_DESC_DIRECT; 703 fmt = SRP_DATA_DESC_DIRECT;
694 len = sizeof (struct srp_cmd) + sizeof (struct srp_direct_buf); 704 len = sizeof (struct srp_cmd) + sizeof (struct srp_direct_buf);
@@ -702,9 +712,9 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_target_port *target,
702 */ 712 */
703 struct srp_direct_buf *buf = (void *) cmd->add_data; 713 struct srp_direct_buf *buf = (void *) cmd->add_data;
704 714
705 buf->va = cpu_to_be64(sg_dma_address(scat)); 715 buf->va = cpu_to_be64(ib_sg_dma_address(ibdev, scat));
706 buf->key = cpu_to_be32(target->srp_host->dev->mr->rkey); 716 buf->key = cpu_to_be32(dev->mr->rkey);
707 buf->len = cpu_to_be32(sg_dma_len(scat)); 717 buf->len = cpu_to_be32(ib_sg_dma_len(ibdev, scat));
708 } else if (srp_map_fmr(target, scat, count, req, 718 } else if (srp_map_fmr(target, scat, count, req,
709 (void *) cmd->add_data)) { 719 (void *) cmd->add_data)) {
710 /* 720 /*
@@ -722,13 +732,14 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_target_port *target,
722 count * sizeof (struct srp_direct_buf); 732 count * sizeof (struct srp_direct_buf);
723 733
724 for (i = 0; i < count; ++i) { 734 for (i = 0; i < count; ++i) {
735 unsigned int dma_len = ib_sg_dma_len(ibdev, &scat[i]);
736
725 buf->desc_list[i].va = 737 buf->desc_list[i].va =
726 cpu_to_be64(sg_dma_address(&scat[i])); 738 cpu_to_be64(ib_sg_dma_address(ibdev, &scat[i]));
727 buf->desc_list[i].key = 739 buf->desc_list[i].key =
728 cpu_to_be32(target->srp_host->dev->mr->rkey); 740 cpu_to_be32(dev->mr->rkey);
729 buf->desc_list[i].len = 741 buf->desc_list[i].len = cpu_to_be32(dma_len);
730 cpu_to_be32(sg_dma_len(&scat[i])); 742 datalen += dma_len;
731 datalen += sg_dma_len(&scat[i]);
732 } 743 }
733 744
734 if (scmnd->sc_data_direction == DMA_TO_DEVICE) 745 if (scmnd->sc_data_direction == DMA_TO_DEVICE)
@@ -808,13 +819,15 @@ static void srp_process_rsp(struct srp_target_port *target, struct srp_rsp *rsp)
808 819
809static void srp_handle_recv(struct srp_target_port *target, struct ib_wc *wc) 820static void srp_handle_recv(struct srp_target_port *target, struct ib_wc *wc)
810{ 821{
822 struct ib_device *dev;
811 struct srp_iu *iu; 823 struct srp_iu *iu;
812 u8 opcode; 824 u8 opcode;
813 825
814 iu = target->rx_ring[wc->wr_id & ~SRP_OP_RECV]; 826 iu = target->rx_ring[wc->wr_id & ~SRP_OP_RECV];
815 827
816 dma_sync_single_for_cpu(target->srp_host->dev->dev->dma_device, iu->dma, 828 dev = target->srp_host->dev->dev;
817 target->max_ti_iu_len, DMA_FROM_DEVICE); 829 ib_dma_sync_single_for_cpu(dev, iu->dma, target->max_ti_iu_len,
830 DMA_FROM_DEVICE);
818 831
819 opcode = *(u8 *) iu->buf; 832 opcode = *(u8 *) iu->buf;
820 833
@@ -850,8 +863,8 @@ static void srp_handle_recv(struct srp_target_port *target, struct ib_wc *wc)
850 break; 863 break;
851 } 864 }
852 865
853 dma_sync_single_for_device(target->srp_host->dev->dev->dma_device, iu->dma, 866 ib_dma_sync_single_for_device(dev, iu->dma, target->max_ti_iu_len,
854 target->max_ti_iu_len, DMA_FROM_DEVICE); 867 DMA_FROM_DEVICE);
855} 868}
856 869
857static void srp_completion(struct ib_cq *cq, void *target_ptr) 870static void srp_completion(struct ib_cq *cq, void *target_ptr)
@@ -969,6 +982,7 @@ static int srp_queuecommand(struct scsi_cmnd *scmnd,
969 struct srp_request *req; 982 struct srp_request *req;
970 struct srp_iu *iu; 983 struct srp_iu *iu;
971 struct srp_cmd *cmd; 984 struct srp_cmd *cmd;
985 struct ib_device *dev;
972 int len; 986 int len;
973 987
974 if (target->state == SRP_TARGET_CONNECTING) 988 if (target->state == SRP_TARGET_CONNECTING)
@@ -985,8 +999,9 @@ static int srp_queuecommand(struct scsi_cmnd *scmnd,
985 if (!iu) 999 if (!iu)
986 goto err; 1000 goto err;
987 1001
988 dma_sync_single_for_cpu(target->srp_host->dev->dev->dma_device, iu->dma, 1002 dev = target->srp_host->dev->dev;
989 srp_max_iu_len, DMA_TO_DEVICE); 1003 ib_dma_sync_single_for_cpu(dev, iu->dma, srp_max_iu_len,
1004 DMA_TO_DEVICE);
990 1005
991 req = list_entry(target->free_reqs.next, struct srp_request, list); 1006 req = list_entry(target->free_reqs.next, struct srp_request, list);
992 1007
@@ -1018,8 +1033,8 @@ static int srp_queuecommand(struct scsi_cmnd *scmnd,
1018 goto err_unmap; 1033 goto err_unmap;
1019 } 1034 }
1020 1035
1021 dma_sync_single_for_device(target->srp_host->dev->dev->dma_device, iu->dma, 1036 ib_dma_sync_single_for_device(dev, iu->dma, srp_max_iu_len,
1022 srp_max_iu_len, DMA_TO_DEVICE); 1037 DMA_TO_DEVICE);
1023 1038
1024 if (__srp_post_send(target, iu, len)) { 1039 if (__srp_post_send(target, iu, len)) {
1025 printk(KERN_ERR PFX "Send failed\n"); 1040 printk(KERN_ERR PFX "Send failed\n");
diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h
index d4e35ef51374..868a540ef7cd 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.h
+++ b/drivers/infiniband/ulp/srp/ib_srp.h
@@ -161,7 +161,7 @@ struct srp_target_port {
161}; 161};
162 162
163struct srp_iu { 163struct srp_iu {
164 dma_addr_t dma; 164 u64 dma;
165 void *buf; 165 void *buf;
166 size_t size; 166 size_t size;
167 enum dma_data_direction direction; 167 enum dma_data_direction direction;
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 3d5f19658032..6b46c9bf1d20 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -146,7 +146,7 @@ config TOUCHSCREEN_TOUCHWIN
146 146
147config TOUCHSCREEN_UCB1400 147config TOUCHSCREEN_UCB1400
148 tristate "Philips UCB1400 touchscreen" 148 tristate "Philips UCB1400 touchscreen"
149 depends on SND_AC97_BUS 149 select AC97_BUS
150 help 150 help
151 This enables support for the Philips UCB1400 touchscreen interface. 151 This enables support for the Philips UCB1400 touchscreen interface.
152 The UCB1400 is an AC97 audio codec. The touchscreen interface 152 The UCB1400 is an AC97 audio codec. The touchscreen interface
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 176142c61492..7399ba791116 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -12,7 +12,7 @@ config NEW_LEDS
12 12
13config LEDS_CLASS 13config LEDS_CLASS
14 tristate "LED Class Support" 14 tristate "LED Class Support"
15 depends NEW_LEDS 15 depends on NEW_LEDS
16 help 16 help
17 This option enables the led sysfs class in /sys/class/leds. You'll 17 This option enables the led sysfs class in /sys/class/leds. You'll
18 need this to do anything useful with LEDs. If unsure, say N. 18 need this to do anything useful with LEDs. If unsure, say N.
@@ -21,28 +21,28 @@ comment "LED drivers"
21 21
22config LEDS_CORGI 22config LEDS_CORGI
23 tristate "LED Support for the Sharp SL-C7x0 series" 23 tristate "LED Support for the Sharp SL-C7x0 series"
24 depends LEDS_CLASS && PXA_SHARP_C7xx 24 depends on LEDS_CLASS && PXA_SHARP_C7xx
25 help 25 help
26 This option enables support for the LEDs on Sharp Zaurus 26 This option enables support for the LEDs on Sharp Zaurus
27 SL-C7x0 series (C700, C750, C760, C860). 27 SL-C7x0 series (C700, C750, C760, C860).
28 28
29config LEDS_LOCOMO 29config LEDS_LOCOMO
30 tristate "LED Support for Locomo device" 30 tristate "LED Support for Locomo device"
31 depends LEDS_CLASS && SHARP_LOCOMO 31 depends on LEDS_CLASS && SHARP_LOCOMO
32 help 32 help
33 This option enables support for the LEDs on Sharp Locomo. 33 This option enables support for the LEDs on Sharp Locomo.
34 Zaurus models SL-5500 and SL-5600. 34 Zaurus models SL-5500 and SL-5600.
35 35
36config LEDS_SPITZ 36config LEDS_SPITZ
37 tristate "LED Support for the Sharp SL-Cxx00 series" 37 tristate "LED Support for the Sharp SL-Cxx00 series"
38 depends LEDS_CLASS && PXA_SHARP_Cxx00 38 depends on LEDS_CLASS && PXA_SHARP_Cxx00
39 help 39 help
40 This option enables support for the LEDs on Sharp Zaurus 40 This option enables support for the LEDs on Sharp Zaurus
41 SL-Cxx00 series (C1000, C3000, C3100). 41 SL-Cxx00 series (C1000, C3000, C3100).
42 42
43config LEDS_IXP4XX 43config LEDS_IXP4XX
44 tristate "LED Support for GPIO connected LEDs on IXP4XX processors" 44 tristate "LED Support for GPIO connected LEDs on IXP4XX processors"
45 depends LEDS_CLASS && ARCH_IXP4XX 45 depends on LEDS_CLASS && ARCH_IXP4XX
46 help 46 help
47 This option enables support for the LEDs connected to GPIO 47 This option enables support for the LEDs connected to GPIO
48 outputs of the Intel IXP4XX processors. To be useful the 48 outputs of the Intel IXP4XX processors. To be useful the
@@ -51,7 +51,7 @@ config LEDS_IXP4XX
51 51
52config LEDS_TOSA 52config LEDS_TOSA
53 tristate "LED Support for the Sharp SL-6000 series" 53 tristate "LED Support for the Sharp SL-6000 series"
54 depends LEDS_CLASS && PXA_SHARPSL 54 depends on LEDS_CLASS && PXA_SHARPSL
55 help 55 help
56 This option enables support for the LEDs on Sharp Zaurus 56 This option enables support for the LEDs on Sharp Zaurus
57 SL-6000 series. 57 SL-6000 series.
@@ -65,7 +65,7 @@ config LEDS_S3C24XX
65 65
66config LEDS_AMS_DELTA 66config LEDS_AMS_DELTA
67 tristate "LED Support for the Amstrad Delta (E3)" 67 tristate "LED Support for the Amstrad Delta (E3)"
68 depends LEDS_CLASS && MACH_AMS_DELTA 68 depends on LEDS_CLASS && MACH_AMS_DELTA
69 help 69 help
70 This option enables support for the LEDs on Amstrad Delta (E3). 70 This option enables support for the LEDs on Amstrad Delta (E3).
71 71
@@ -86,7 +86,7 @@ comment "LED Triggers"
86 86
87config LEDS_TRIGGERS 87config LEDS_TRIGGERS
88 bool "LED Trigger support" 88 bool "LED Trigger support"
89 depends NEW_LEDS 89 depends on NEW_LEDS
90 help 90 help
91 This option enables trigger support for the leds class. 91 This option enables trigger support for the leds class.
92 These triggers allow kernel events to drive the LEDs and can 92 These triggers allow kernel events to drive the LEDs and can
@@ -94,21 +94,21 @@ config LEDS_TRIGGERS
94 94
95config LEDS_TRIGGER_TIMER 95config LEDS_TRIGGER_TIMER
96 tristate "LED Timer Trigger" 96 tristate "LED Timer Trigger"
97 depends LEDS_TRIGGERS 97 depends on LEDS_TRIGGERS
98 help 98 help
99 This allows LEDs to be controlled by a programmable timer 99 This allows LEDs to be controlled by a programmable timer
100 via sysfs. If unsure, say Y. 100 via sysfs. If unsure, say Y.
101 101
102config LEDS_TRIGGER_IDE_DISK 102config LEDS_TRIGGER_IDE_DISK
103 bool "LED IDE Disk Trigger" 103 bool "LED IDE Disk Trigger"
104 depends LEDS_TRIGGERS && BLK_DEV_IDEDISK 104 depends on LEDS_TRIGGERS && BLK_DEV_IDEDISK
105 help 105 help
106 This allows LEDs to be controlled by IDE disk activity. 106 This allows LEDs to be controlled by IDE disk activity.
107 If unsure, say Y. 107 If unsure, say Y.
108 108
109config LEDS_TRIGGER_HEARTBEAT 109config LEDS_TRIGGER_HEARTBEAT
110 tristate "LED Heartbeat Trigger" 110 tristate "LED Heartbeat Trigger"
111 depends LEDS_TRIGGERS 111 depends on LEDS_TRIGGERS
112 help 112 help
113 This allows LEDs to be controlled by a CPU load average. 113 This allows LEDs to be controlled by a CPU load average.
114 The flash frequency is a hyperbolic function of the 1-minute 114 The flash frequency is a hyperbolic function of the 1-minute
diff --git a/drivers/media/dvb/pluto2/pluto2.c b/drivers/media/dvb/pluto2/pluto2.c
index 8e4ce101eb22..ffda71dfdd65 100644
--- a/drivers/media/dvb/pluto2/pluto2.c
+++ b/drivers/media/dvb/pluto2/pluto2.c
@@ -650,7 +650,7 @@ static int __devinit pluto2_probe(struct pci_dev *pdev,
650 /* dvb */ 650 /* dvb */
651 ret = dvb_register_adapter(&pluto->dvb_adapter, DRIVER_NAME, THIS_MODULE, &pdev->dev); 651 ret = dvb_register_adapter(&pluto->dvb_adapter, DRIVER_NAME, THIS_MODULE, &pdev->dev);
652 if (ret < 0) 652 if (ret < 0)
653 goto err_i2c_bit_del_bus; 653 goto err_i2c_del_adapter;
654 654
655 dvb_adapter = &pluto->dvb_adapter; 655 dvb_adapter = &pluto->dvb_adapter;
656 656
@@ -712,8 +712,8 @@ err_dvb_dmx_release:
712 dvb_dmx_release(dvbdemux); 712 dvb_dmx_release(dvbdemux);
713err_dvb_unregister_adapter: 713err_dvb_unregister_adapter:
714 dvb_unregister_adapter(dvb_adapter); 714 dvb_unregister_adapter(dvb_adapter);
715err_i2c_bit_del_bus: 715err_i2c_del_adapter:
716 i2c_bit_del_bus(&pluto->i2c_adap); 716 i2c_del_adapter(&pluto->i2c_adap);
717err_pluto_hw_exit: 717err_pluto_hw_exit:
718 pluto_hw_exit(pluto); 718 pluto_hw_exit(pluto);
719err_free_irq: 719err_free_irq:
@@ -748,7 +748,7 @@ static void __devexit pluto2_remove(struct pci_dev *pdev)
748 dvb_dmxdev_release(&pluto->dmxdev); 748 dvb_dmxdev_release(&pluto->dmxdev);
749 dvb_dmx_release(dvbdemux); 749 dvb_dmx_release(dvbdemux);
750 dvb_unregister_adapter(dvb_adapter); 750 dvb_unregister_adapter(dvb_adapter);
751 i2c_bit_del_bus(&pluto->i2c_adap); 751 i2c_del_adapter(&pluto->i2c_adap);
752 pluto_hw_exit(pluto); 752 pluto_hw_exit(pluto);
753 free_irq(pdev->irq, pluto); 753 free_irq(pdev->irq, pluto);
754 pci_iounmap(pdev, pluto->io_mem); 754 pci_iounmap(pdev, pluto->io_mem);
diff --git a/drivers/media/video/bt8xx/bttv-i2c.c b/drivers/media/video/bt8xx/bttv-i2c.c
index 70de6c96e201..62b873076e09 100644
--- a/drivers/media/video/bt8xx/bttv-i2c.c
+++ b/drivers/media/video/bt8xx/bttv-i2c.c
@@ -479,11 +479,7 @@ int __devexit fini_bttv_i2c(struct bttv *btv)
479 if (0 != btv->i2c_rc) 479 if (0 != btv->i2c_rc)
480 return 0; 480 return 0;
481 481
482 if (btv->use_i2c_hw) { 482 return i2c_del_adapter(&btv->c.i2c_adap);
483 return i2c_del_adapter(&btv->c.i2c_adap);
484 } else {
485 return i2c_bit_del_bus(&btv->c.i2c_adap);
486 }
487} 483}
488 484
489/* 485/*
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index 4b655f2ef278..453af5e943ff 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -1153,7 +1153,7 @@ void cx88_core_put(struct cx88_core *core, struct pci_dev *pci)
1153 mutex_lock(&devlist); 1153 mutex_lock(&devlist);
1154 cx88_ir_fini(core); 1154 cx88_ir_fini(core);
1155 if (0 == core->i2c_rc) 1155 if (0 == core->i2c_rc)
1156 i2c_bit_del_bus(&core->i2c_adap); 1156 i2c_del_adapter(&core->i2c_adap);
1157 list_del(&core->devlist); 1157 list_del(&core->devlist);
1158 iounmap(core->lmmio); 1158 iounmap(core->lmmio);
1159 cx88_devcount--; 1159 cx88_devcount--;
diff --git a/drivers/media/video/cx88/cx88-vp3054-i2c.c b/drivers/media/video/cx88/cx88-vp3054-i2c.c
index 2b4f1970c7df..6068c9bf82cd 100644
--- a/drivers/media/video/cx88/cx88-vp3054-i2c.c
+++ b/drivers/media/video/cx88/cx88-vp3054-i2c.c
@@ -168,7 +168,7 @@ void vp3054_i2c_remove(struct cx8802_dev *dev)
168 dev->core->board != CX88_BOARD_DNTV_LIVE_DVB_T_PRO) 168 dev->core->board != CX88_BOARD_DNTV_LIVE_DVB_T_PRO)
169 return; 169 return;
170 170
171 i2c_bit_del_bus(&vp3054_i2c->adap); 171 i2c_del_adapter(&vp3054_i2c->adap);
172 kfree(vp3054_i2c); 172 kfree(vp3054_i2c);
173} 173}
174 174
diff --git a/drivers/media/video/ov7670.c b/drivers/media/video/ov7670.c
index 89dd18c3c5cc..5ed0adc4ca26 100644
--- a/drivers/media/video/ov7670.c
+++ b/drivers/media/video/ov7670.c
@@ -18,7 +18,7 @@
18#include <linux/i2c.h> 18#include <linux/i2c.h>
19 19
20 20
21MODULE_AUTHOR("Jonathan Corbet <corbet@lwn.net."); 21MODULE_AUTHOR("Jonathan Corbet <corbet@lwn.net>");
22MODULE_DESCRIPTION("A low-level driver for OmniVision ov7670 sensors"); 22MODULE_DESCRIPTION("A low-level driver for OmniVision ov7670 sensors");
23MODULE_LICENSE("GPL"); 23MODULE_LICENSE("GPL");
24 24
diff --git a/drivers/media/video/vino.c b/drivers/media/video/vino.c
index 6b6dff4d236a..a373c142e742 100644
--- a/drivers/media/video/vino.c
+++ b/drivers/media/video/vino.c
@@ -782,7 +782,7 @@ static int vino_i2c_add_bus(void)
782 782
783static int vino_i2c_del_bus(void) 783static int vino_i2c_del_bus(void)
784{ 784{
785 return i2c_sgi_del_bus(&vino_i2c_adapter); 785 return i2c_del_adapter(&vino_i2c_adapter);
786} 786}
787 787
788static int i2c_camera_command(unsigned int cmd, void *arg) 788static int i2c_camera_command(unsigned int cmd, void *arg)
diff --git a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c
index 653822ce391c..4d1eb2fba34a 100644
--- a/drivers/media/video/zoran_card.c
+++ b/drivers/media/video/zoran_card.c
@@ -849,7 +849,7 @@ zoran_register_i2c (struct zoran *zr)
849static void 849static void
850zoran_unregister_i2c (struct zoran *zr) 850zoran_unregister_i2c (struct zoran *zr)
851{ 851{
852 i2c_bit_del_bus((&zr->i2c_adapter)); 852 i2c_del_adapter(&zr->i2c_adapter);
853} 853}
854 854
855/* Check a zoran_params struct for correctness, insert default params */ 855/* Check a zoran_params struct for correctness, insert default params */
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 03bf164f9e8d..c2ae2a24629b 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -1930,9 +1930,8 @@ static int e100_rx_alloc_list(struct nic *nic)
1930 nic->rx_to_use = nic->rx_to_clean = NULL; 1930 nic->rx_to_use = nic->rx_to_clean = NULL;
1931 nic->ru_running = RU_UNINITIALIZED; 1931 nic->ru_running = RU_UNINITIALIZED;
1932 1932
1933 if(!(nic->rxs = kmalloc(sizeof(struct rx) * count, GFP_ATOMIC))) 1933 if(!(nic->rxs = kcalloc(count, sizeof(struct rx), GFP_ATOMIC)))
1934 return -ENOMEM; 1934 return -ENOMEM;
1935 memset(nic->rxs, 0, sizeof(struct rx) * count);
1936 1935
1937 for(rx = nic->rxs, i = 0; i < count; rx++, i++) { 1936 for(rx = nic->rxs, i = 0; i < count; rx++, i++) {
1938 rx->next = (i + 1 < count) ? rx + 1 : nic->rxs; 1937 rx->next = (i + 1 < count) ? rx + 1 : nic->rxs;
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 0b36dd5cdac2..2978c09860ee 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -663,7 +663,7 @@ config V850E_UART
663 663
664config V850E_UARTB 664config V850E_UARTB
665 bool 665 bool
666 depends V850E_UART && V850E_ME2 666 depends on V850E_UART && V850E_ME2
667 default y 667 default y
668 668
669config V850E_UART_CONSOLE 669config V850E_UART_CONSOLE
@@ -909,7 +909,7 @@ config SERIAL_M32R_PLDSIO
909 909
910config SERIAL_TXX9 910config SERIAL_TXX9
911 bool "TMPTX39XX/49XX SIO support" 911 bool "TMPTX39XX/49XX SIO support"
912 depends HAS_TXX9_SERIAL 912 depends on HAS_TXX9_SERIAL
913 select SERIAL_CORE 913 select SERIAL_CORE
914 default y 914 default y
915 915
diff --git a/drivers/serial/icom.c b/drivers/serial/icom.c
index 7d623003e65e..71e6a24d8c28 100644
--- a/drivers/serial/icom.c
+++ b/drivers/serial/icom.c
@@ -1510,7 +1510,7 @@ static int __devinit icom_probe(struct pci_dev *dev,
1510 } 1510 }
1511 1511
1512 if ( (retval = pci_request_regions(dev, "icom"))) { 1512 if ( (retval = pci_request_regions(dev, "icom"))) {
1513 dev_err(&dev->dev, "pci_request_region FAILED\n"); 1513 dev_err(&dev->dev, "pci_request_regions FAILED\n");
1514 pci_disable_device(dev); 1514 pci_disable_device(dev);
1515 return retval; 1515 return retval;
1516 } 1516 }
diff --git a/drivers/video/aty/radeon_i2c.c b/drivers/video/aty/radeon_i2c.c
index 869725a13c21..e7c5b219ad1b 100644
--- a/drivers/video/aty/radeon_i2c.c
+++ b/drivers/video/aty/radeon_i2c.c
@@ -120,19 +120,19 @@ void radeon_create_i2c_busses(struct radeonfb_info *rinfo)
120void radeon_delete_i2c_busses(struct radeonfb_info *rinfo) 120void radeon_delete_i2c_busses(struct radeonfb_info *rinfo)
121{ 121{
122 if (rinfo->i2c[0].rinfo) 122 if (rinfo->i2c[0].rinfo)
123 i2c_bit_del_bus(&rinfo->i2c[0].adapter); 123 i2c_del_adapter(&rinfo->i2c[0].adapter);
124 rinfo->i2c[0].rinfo = NULL; 124 rinfo->i2c[0].rinfo = NULL;
125 125
126 if (rinfo->i2c[1].rinfo) 126 if (rinfo->i2c[1].rinfo)
127 i2c_bit_del_bus(&rinfo->i2c[1].adapter); 127 i2c_del_adapter(&rinfo->i2c[1].adapter);
128 rinfo->i2c[1].rinfo = NULL; 128 rinfo->i2c[1].rinfo = NULL;
129 129
130 if (rinfo->i2c[2].rinfo) 130 if (rinfo->i2c[2].rinfo)
131 i2c_bit_del_bus(&rinfo->i2c[2].adapter); 131 i2c_del_adapter(&rinfo->i2c[2].adapter);
132 rinfo->i2c[2].rinfo = NULL; 132 rinfo->i2c[2].rinfo = NULL;
133 133
134 if (rinfo->i2c[3].rinfo) 134 if (rinfo->i2c[3].rinfo)
135 i2c_bit_del_bus(&rinfo->i2c[3].adapter); 135 i2c_del_adapter(&rinfo->i2c[3].adapter);
136 rinfo->i2c[3].rinfo = NULL; 136 rinfo->i2c[3].rinfo = NULL;
137} 137}
138 138
diff --git a/drivers/video/i810/i810-i2c.c b/drivers/video/i810/i810-i2c.c
index b952e4504abe..961f4d404467 100644
--- a/drivers/video/i810/i810-i2c.c
+++ b/drivers/video/i810/i810-i2c.c
@@ -137,15 +137,15 @@ void i810_create_i2c_busses(struct i810fb_par *par)
137void i810_delete_i2c_busses(struct i810fb_par *par) 137void i810_delete_i2c_busses(struct i810fb_par *par)
138{ 138{
139 if (par->chan[0].par) 139 if (par->chan[0].par)
140 i2c_bit_del_bus(&par->chan[0].adapter); 140 i2c_del_adapter(&par->chan[0].adapter);
141 par->chan[0].par = NULL; 141 par->chan[0].par = NULL;
142 142
143 if (par->chan[1].par) 143 if (par->chan[1].par)
144 i2c_bit_del_bus(&par->chan[1].adapter); 144 i2c_del_adapter(&par->chan[1].adapter);
145 par->chan[1].par = NULL; 145 par->chan[1].par = NULL;
146 146
147 if (par->chan[2].par) 147 if (par->chan[2].par)
148 i2c_bit_del_bus(&par->chan[2].adapter); 148 i2c_del_adapter(&par->chan[2].adapter);
149 par->chan[2].par = NULL; 149 par->chan[2].par = NULL;
150} 150}
151 151
diff --git a/drivers/video/intelfb/intelfb_i2c.c b/drivers/video/intelfb/intelfb_i2c.c
index 5686e2164e39..33bc41f50540 100644
--- a/drivers/video/intelfb/intelfb_i2c.c
+++ b/drivers/video/intelfb/intelfb_i2c.c
@@ -188,11 +188,11 @@ void intelfb_delete_i2c_busses(struct intelfb_info *dinfo)
188 188
189 for (i = 0; i < MAX_OUTPUTS; i++) { 189 for (i = 0; i < MAX_OUTPUTS; i++) {
190 if (dinfo->output[i].i2c_bus.dinfo) { 190 if (dinfo->output[i].i2c_bus.dinfo) {
191 i2c_bit_del_bus(&dinfo->output[i].i2c_bus.adapter); 191 i2c_del_adapter(&dinfo->output[i].i2c_bus.adapter);
192 dinfo->output[i].i2c_bus.dinfo = NULL; 192 dinfo->output[i].i2c_bus.dinfo = NULL;
193 } 193 }
194 if (dinfo->output[i].ddc_bus.dinfo) { 194 if (dinfo->output[i].ddc_bus.dinfo) {
195 i2c_bit_del_bus(&dinfo->output[i].ddc_bus.adapter); 195 i2c_del_adapter(&dinfo->output[i].ddc_bus.adapter);
196 dinfo->output[i].ddc_bus.dinfo = NULL; 196 dinfo->output[i].ddc_bus.dinfo = NULL;
197 } 197 }
198 } 198 }
diff --git a/drivers/video/matrox/i2c-matroxfb.c b/drivers/video/matrox/i2c-matroxfb.c
index 795c1a99a680..797b42305b0f 100644
--- a/drivers/video/matrox/i2c-matroxfb.c
+++ b/drivers/video/matrox/i2c-matroxfb.c
@@ -124,7 +124,7 @@ static int i2c_bus_reg(struct i2c_bit_adapter* b, struct matrox_fb_info* minfo,
124 124
125static void i2c_bit_bus_del(struct i2c_bit_adapter* b) { 125static void i2c_bit_bus_del(struct i2c_bit_adapter* b) {
126 if (b->initialized) { 126 if (b->initialized) {
127 i2c_bit_del_bus(&b->adapter); 127 i2c_del_adapter(&b->adapter);
128 b->initialized = 0; 128 b->initialized = 0;
129 } 129 }
130} 130}
diff --git a/drivers/video/nvidia/nv_i2c.c b/drivers/video/nvidia/nv_i2c.c
index 442e85328341..8454adf2d178 100644
--- a/drivers/video/nvidia/nv_i2c.c
+++ b/drivers/video/nvidia/nv_i2c.c
@@ -147,15 +147,15 @@ void nvidia_create_i2c_busses(struct nvidia_par *par)
147void nvidia_delete_i2c_busses(struct nvidia_par *par) 147void nvidia_delete_i2c_busses(struct nvidia_par *par)
148{ 148{
149 if (par->chan[0].par) 149 if (par->chan[0].par)
150 i2c_bit_del_bus(&par->chan[0].adapter); 150 i2c_del_adapter(&par->chan[0].adapter);
151 par->chan[0].par = NULL; 151 par->chan[0].par = NULL;
152 152
153 if (par->chan[1].par) 153 if (par->chan[1].par)
154 i2c_bit_del_bus(&par->chan[1].adapter); 154 i2c_del_adapter(&par->chan[1].adapter);
155 par->chan[1].par = NULL; 155 par->chan[1].par = NULL;
156 156
157 if (par->chan[2].par) 157 if (par->chan[2].par)
158 i2c_bit_del_bus(&par->chan[2].adapter); 158 i2c_del_adapter(&par->chan[2].adapter);
159 par->chan[2].par = NULL; 159 par->chan[2].par = NULL;
160 160
161} 161}
diff --git a/drivers/video/riva/rivafb-i2c.c b/drivers/video/riva/rivafb-i2c.c
index c15b259af644..01b85e3b0ae1 100644
--- a/drivers/video/riva/rivafb-i2c.c
+++ b/drivers/video/riva/rivafb-i2c.c
@@ -144,15 +144,15 @@ void riva_create_i2c_busses(struct riva_par *par)
144void riva_delete_i2c_busses(struct riva_par *par) 144void riva_delete_i2c_busses(struct riva_par *par)
145{ 145{
146 if (par->chan[0].par) 146 if (par->chan[0].par)
147 i2c_bit_del_bus(&par->chan[0].adapter); 147 i2c_del_adapter(&par->chan[0].adapter);
148 par->chan[0].par = NULL; 148 par->chan[0].par = NULL;
149 149
150 if (par->chan[1].par) 150 if (par->chan[1].par)
151 i2c_bit_del_bus(&par->chan[1].adapter); 151 i2c_del_adapter(&par->chan[1].adapter);
152 par->chan[1].par = NULL; 152 par->chan[1].par = NULL;
153 153
154 if (par->chan[2].par) 154 if (par->chan[2].par)
155 i2c_bit_del_bus(&par->chan[2].adapter); 155 i2c_del_adapter(&par->chan[2].adapter);
156 par->chan[2].par = NULL; 156 par->chan[2].par = NULL;
157} 157}
158 158
diff --git a/drivers/video/savage/savagefb-i2c.c b/drivers/video/savage/savagefb-i2c.c
index cef5bf591cdf..1411f3b6a009 100644
--- a/drivers/video/savage/savagefb-i2c.c
+++ b/drivers/video/savage/savagefb-i2c.c
@@ -208,7 +208,7 @@ void savagefb_delete_i2c_busses(struct fb_info *info)
208 struct savagefb_par *par = info->par; 208 struct savagefb_par *par = info->par;
209 209
210 if (par->chan.par) 210 if (par->chan.par)
211 i2c_bit_del_bus(&par->chan.adapter); 211 i2c_del_adapter(&par->chan.adapter);
212 212
213 par->chan.par = NULL; 213 par->chan.par = NULL;
214} 214}
diff --git a/fs/Kconfig b/fs/Kconfig
index b3b5aa0edff9..276ff3baaafe 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -12,9 +12,7 @@ config EXT2_FS
12 Ext2 is a standard Linux file system for hard disks. 12 Ext2 is a standard Linux file system for hard disks.
13 13
14 To compile this file system support as a module, choose M here: the 14 To compile this file system support as a module, choose M here: the
15 module will be called ext2. Be aware however that the file system 15 module will be called ext2.
16 of your root partition (the one containing the directory /) cannot
17 be compiled as a module, and so this could be dangerous.
18 16
19 If unsure, say Y. 17 If unsure, say Y.
20 18
@@ -98,9 +96,7 @@ config EXT3_FS
98 (available at <http://sourceforge.net/projects/e2fsprogs/>). 96 (available at <http://sourceforge.net/projects/e2fsprogs/>).
99 97
100 To compile this file system support as a module, choose M here: the 98 To compile this file system support as a module, choose M here: the
101 module will be called ext3. Be aware however that the file system 99 module will be called ext3.
102 of your root partition (the one containing the directory /) cannot
103 be compiled as a module, and so this may be dangerous.
104 100
105config EXT3_FS_XATTR 101config EXT3_FS_XATTR
106 bool "Ext3 extended attributes" 102 bool "Ext3 extended attributes"
@@ -163,9 +159,7 @@ config EXT4DEV_FS
163 features will be added to ext4dev gradually. 159 features will be added to ext4dev gradually.
164 160
165 To compile this file system support as a module, choose M here. The 161 To compile this file system support as a module, choose M here. The
166 module will be called ext4dev. Be aware, however, that the filesystem 162 module will be called ext4dev.
167 of your root partition (the one containing the directory /) cannot
168 be compiled as a module, and so this could be dangerous.
169 163
170 If unsure, say N. 164 If unsure, say N.
171 165
@@ -1008,7 +1002,7 @@ config TMPFS_POSIX_ACL
1008 1002
1009config HUGETLBFS 1003config HUGETLBFS
1010 bool "HugeTLB file system support" 1004 bool "HugeTLB file system support"
1011 depends X86 || IA64 || PPC64 || SPARC64 || SUPERH || BROKEN 1005 depends on X86 || IA64 || PPC64 || SPARC64 || SUPERH || BROKEN
1012 help 1006 help
1013 hugetlbfs is a filesystem backing for HugeTLB pages, based on 1007 hugetlbfs is a filesystem backing for HugeTLB pages, based on
1014 ramfs. For architectures that support it, say Y here and read 1008 ramfs. For architectures that support it, say Y here and read
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index 76f06f6bc2f6..6e6d4568d548 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -706,12 +706,11 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params,
706 return -ELIBBAD; 706 return -ELIBBAD;
707 707
708 size = sizeof(*loadmap) + nloads * sizeof(*seg); 708 size = sizeof(*loadmap) + nloads * sizeof(*seg);
709 loadmap = kmalloc(size, GFP_KERNEL); 709 loadmap = kzalloc(size, GFP_KERNEL);
710 if (!loadmap) 710 if (!loadmap)
711 return -ENOMEM; 711 return -ENOMEM;
712 712
713 params->loadmap = loadmap; 713 params->loadmap = loadmap;
714 memset(loadmap, 0, size);
715 714
716 loadmap->version = ELF32_FDPIC_LOADMAP_VERSION; 715 loadmap->version = ELF32_FDPIC_LOADMAP_VERSION;
717 loadmap->nsegs = nloads; 716 loadmap->nsegs = nloads;
diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c
index d11753c50bc1..357f1d551771 100644
--- a/fs/ocfs2/cluster/nodemanager.c
+++ b/fs/ocfs2/cluster/nodemanager.c
@@ -35,7 +35,7 @@
35/* for now we operate under the assertion that there can be only one 35/* for now we operate under the assertion that there can be only one
36 * cluster active at a time. Changing this will require trickling 36 * cluster active at a time. Changing this will require trickling
37 * cluster references throughout where nodes are looked up */ 37 * cluster references throughout where nodes are looked up */
38static struct o2nm_cluster *o2nm_single_cluster = NULL; 38struct o2nm_cluster *o2nm_single_cluster = NULL;
39 39
40#define OCFS2_MAX_HB_CTL_PATH 256 40#define OCFS2_MAX_HB_CTL_PATH 256
41static char ocfs2_hb_ctl_path[OCFS2_MAX_HB_CTL_PATH] = "/sbin/ocfs2_hb_ctl"; 41static char ocfs2_hb_ctl_path[OCFS2_MAX_HB_CTL_PATH] = "/sbin/ocfs2_hb_ctl";
@@ -97,17 +97,6 @@ const char *o2nm_get_hb_ctl_path(void)
97} 97}
98EXPORT_SYMBOL_GPL(o2nm_get_hb_ctl_path); 98EXPORT_SYMBOL_GPL(o2nm_get_hb_ctl_path);
99 99
100struct o2nm_cluster {
101 struct config_group cl_group;
102 unsigned cl_has_local:1;
103 u8 cl_local_node;
104 rwlock_t cl_nodes_lock;
105 struct o2nm_node *cl_nodes[O2NM_MAX_NODES];
106 struct rb_root cl_node_ip_tree;
107 /* this bitmap is part of a hack for disk bitmap.. will go eventually. - zab */
108 unsigned long cl_nodes_bitmap[BITS_TO_LONGS(O2NM_MAX_NODES)];
109};
110
111struct o2nm_node *o2nm_get_node_by_num(u8 node_num) 100struct o2nm_node *o2nm_get_node_by_num(u8 node_num)
112{ 101{
113 struct o2nm_node *node = NULL; 102 struct o2nm_node *node = NULL;
@@ -543,6 +532,179 @@ static struct o2nm_node_group *to_o2nm_node_group(struct config_group *group)
543} 532}
544#endif 533#endif
545 534
535struct o2nm_cluster_attribute {
536 struct configfs_attribute attr;
537 ssize_t (*show)(struct o2nm_cluster *, char *);
538 ssize_t (*store)(struct o2nm_cluster *, const char *, size_t);
539};
540
541static ssize_t o2nm_cluster_attr_write(const char *page, ssize_t count,
542 unsigned int *val)
543{
544 unsigned long tmp;
545 char *p = (char *)page;
546
547 tmp = simple_strtoul(p, &p, 0);
548 if (!p || (*p && (*p != '\n')))
549 return -EINVAL;
550
551 if (tmp == 0)
552 return -EINVAL;
553 if (tmp >= (u32)-1)
554 return -ERANGE;
555
556 *val = tmp;
557
558 return count;
559}
560
561static ssize_t o2nm_cluster_attr_idle_timeout_ms_read(
562 struct o2nm_cluster *cluster, char *page)
563{
564 return sprintf(page, "%u\n", cluster->cl_idle_timeout_ms);
565}
566
567static ssize_t o2nm_cluster_attr_idle_timeout_ms_write(
568 struct o2nm_cluster *cluster, const char *page, size_t count)
569{
570 ssize_t ret;
571 unsigned int val;
572
573 ret = o2nm_cluster_attr_write(page, count, &val);
574
575 if (ret > 0) {
576 if (cluster->cl_idle_timeout_ms != val
577 && o2net_num_connected_peers()) {
578 mlog(ML_NOTICE,
579 "o2net: cannot change idle timeout after "
580 "the first peer has agreed to it."
581 " %d connected peers\n",
582 o2net_num_connected_peers());
583 ret = -EINVAL;
584 } else if (val <= cluster->cl_keepalive_delay_ms) {
585 mlog(ML_NOTICE, "o2net: idle timeout must be larger "
586 "than keepalive delay\n");
587 ret = -EINVAL;
588 } else {
589 cluster->cl_idle_timeout_ms = val;
590 }
591 }
592
593 return ret;
594}
595
596static ssize_t o2nm_cluster_attr_keepalive_delay_ms_read(
597 struct o2nm_cluster *cluster, char *page)
598{
599 return sprintf(page, "%u\n", cluster->cl_keepalive_delay_ms);
600}
601
602static ssize_t o2nm_cluster_attr_keepalive_delay_ms_write(
603 struct o2nm_cluster *cluster, const char *page, size_t count)
604{
605 ssize_t ret;
606 unsigned int val;
607
608 ret = o2nm_cluster_attr_write(page, count, &val);
609
610 if (ret > 0) {
611 if (cluster->cl_keepalive_delay_ms != val
612 && o2net_num_connected_peers()) {
613 mlog(ML_NOTICE,
614 "o2net: cannot change keepalive delay after"
615 " the first peer has agreed to it."
616 " %d connected peers\n",
617 o2net_num_connected_peers());
618 ret = -EINVAL;
619 } else if (val >= cluster->cl_idle_timeout_ms) {
620 mlog(ML_NOTICE, "o2net: keepalive delay must be "
621 "smaller than idle timeout\n");
622 ret = -EINVAL;
623 } else {
624 cluster->cl_keepalive_delay_ms = val;
625 }
626 }
627
628 return ret;
629}
630
631static ssize_t o2nm_cluster_attr_reconnect_delay_ms_read(
632 struct o2nm_cluster *cluster, char *page)
633{
634 return sprintf(page, "%u\n", cluster->cl_reconnect_delay_ms);
635}
636
637static ssize_t o2nm_cluster_attr_reconnect_delay_ms_write(
638 struct o2nm_cluster *cluster, const char *page, size_t count)
639{
640 return o2nm_cluster_attr_write(page, count,
641 &cluster->cl_reconnect_delay_ms);
642}
643static struct o2nm_cluster_attribute o2nm_cluster_attr_idle_timeout_ms = {
644 .attr = { .ca_owner = THIS_MODULE,
645 .ca_name = "idle_timeout_ms",
646 .ca_mode = S_IRUGO | S_IWUSR },
647 .show = o2nm_cluster_attr_idle_timeout_ms_read,
648 .store = o2nm_cluster_attr_idle_timeout_ms_write,
649};
650
651static struct o2nm_cluster_attribute o2nm_cluster_attr_keepalive_delay_ms = {
652 .attr = { .ca_owner = THIS_MODULE,
653 .ca_name = "keepalive_delay_ms",
654 .ca_mode = S_IRUGO | S_IWUSR },
655 .show = o2nm_cluster_attr_keepalive_delay_ms_read,
656 .store = o2nm_cluster_attr_keepalive_delay_ms_write,
657};
658
659static struct o2nm_cluster_attribute o2nm_cluster_attr_reconnect_delay_ms = {
660 .attr = { .ca_owner = THIS_MODULE,
661 .ca_name = "reconnect_delay_ms",
662 .ca_mode = S_IRUGO | S_IWUSR },
663 .show = o2nm_cluster_attr_reconnect_delay_ms_read,
664 .store = o2nm_cluster_attr_reconnect_delay_ms_write,
665};
666
667static struct configfs_attribute *o2nm_cluster_attrs[] = {
668 &o2nm_cluster_attr_idle_timeout_ms.attr,
669 &o2nm_cluster_attr_keepalive_delay_ms.attr,
670 &o2nm_cluster_attr_reconnect_delay_ms.attr,
671 NULL,
672};
673static ssize_t o2nm_cluster_show(struct config_item *item,
674 struct configfs_attribute *attr,
675 char *page)
676{
677 struct o2nm_cluster *cluster = to_o2nm_cluster(item);
678 struct o2nm_cluster_attribute *o2nm_cluster_attr =
679 container_of(attr, struct o2nm_cluster_attribute, attr);
680 ssize_t ret = 0;
681
682 if (o2nm_cluster_attr->show)
683 ret = o2nm_cluster_attr->show(cluster, page);
684 return ret;
685}
686
687static ssize_t o2nm_cluster_store(struct config_item *item,
688 struct configfs_attribute *attr,
689 const char *page, size_t count)
690{
691 struct o2nm_cluster *cluster = to_o2nm_cluster(item);
692 struct o2nm_cluster_attribute *o2nm_cluster_attr =
693 container_of(attr, struct o2nm_cluster_attribute, attr);
694 ssize_t ret;
695
696 if (o2nm_cluster_attr->store == NULL) {
697 ret = -EINVAL;
698 goto out;
699 }
700
701 ret = o2nm_cluster_attr->store(cluster, page, count);
702 if (ret < count)
703 goto out;
704out:
705 return ret;
706}
707
546static struct config_item *o2nm_node_group_make_item(struct config_group *group, 708static struct config_item *o2nm_node_group_make_item(struct config_group *group,
547 const char *name) 709 const char *name)
548{ 710{
@@ -624,10 +786,13 @@ static void o2nm_cluster_release(struct config_item *item)
624 786
625static struct configfs_item_operations o2nm_cluster_item_ops = { 787static struct configfs_item_operations o2nm_cluster_item_ops = {
626 .release = o2nm_cluster_release, 788 .release = o2nm_cluster_release,
789 .show_attribute = o2nm_cluster_show,
790 .store_attribute = o2nm_cluster_store,
627}; 791};
628 792
629static struct config_item_type o2nm_cluster_type = { 793static struct config_item_type o2nm_cluster_type = {
630 .ct_item_ops = &o2nm_cluster_item_ops, 794 .ct_item_ops = &o2nm_cluster_item_ops,
795 .ct_attrs = o2nm_cluster_attrs,
631 .ct_owner = THIS_MODULE, 796 .ct_owner = THIS_MODULE,
632}; 797};
633 798
@@ -678,6 +843,9 @@ static struct config_group *o2nm_cluster_group_make_group(struct config_group *g
678 cluster->cl_group.default_groups[2] = NULL; 843 cluster->cl_group.default_groups[2] = NULL;
679 rwlock_init(&cluster->cl_nodes_lock); 844 rwlock_init(&cluster->cl_nodes_lock);
680 cluster->cl_node_ip_tree = RB_ROOT; 845 cluster->cl_node_ip_tree = RB_ROOT;
846 cluster->cl_reconnect_delay_ms = O2NET_RECONNECT_DELAY_MS_DEFAULT;
847 cluster->cl_idle_timeout_ms = O2NET_IDLE_TIMEOUT_MS_DEFAULT;
848 cluster->cl_keepalive_delay_ms = O2NET_KEEPALIVE_DELAY_MS_DEFAULT;
681 849
682 ret = &cluster->cl_group; 850 ret = &cluster->cl_group;
683 o2nm_single_cluster = cluster; 851 o2nm_single_cluster = cluster;
diff --git a/fs/ocfs2/cluster/nodemanager.h b/fs/ocfs2/cluster/nodemanager.h
index fce8033c310f..8fb23cacc2f5 100644
--- a/fs/ocfs2/cluster/nodemanager.h
+++ b/fs/ocfs2/cluster/nodemanager.h
@@ -53,6 +53,23 @@ struct o2nm_node {
53 unsigned long nd_set_attributes; 53 unsigned long nd_set_attributes;
54}; 54};
55 55
56struct o2nm_cluster {
57 struct config_group cl_group;
58 unsigned cl_has_local:1;
59 u8 cl_local_node;
60 rwlock_t cl_nodes_lock;
61 struct o2nm_node *cl_nodes[O2NM_MAX_NODES];
62 struct rb_root cl_node_ip_tree;
63 unsigned int cl_idle_timeout_ms;
64 unsigned int cl_keepalive_delay_ms;
65 unsigned int cl_reconnect_delay_ms;
66
67 /* this bitmap is part of a hack for disk bitmap.. will go eventually. - zab */
68 unsigned long cl_nodes_bitmap[BITS_TO_LONGS(O2NM_MAX_NODES)];
69};
70
71extern struct o2nm_cluster *o2nm_single_cluster;
72
56u8 o2nm_this_node(void); 73u8 o2nm_this_node(void);
57 74
58int o2nm_configured_node_map(unsigned long *map, unsigned bytes); 75int o2nm_configured_node_map(unsigned long *map, unsigned bytes);
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c
index 9b3209dc0b16..457753df1ae7 100644
--- a/fs/ocfs2/cluster/tcp.c
+++ b/fs/ocfs2/cluster/tcp.c
@@ -147,6 +147,28 @@ static void o2net_listen_data_ready(struct sock *sk, int bytes);
147static void o2net_sc_send_keep_req(struct work_struct *work); 147static void o2net_sc_send_keep_req(struct work_struct *work);
148static void o2net_idle_timer(unsigned long data); 148static void o2net_idle_timer(unsigned long data);
149static void o2net_sc_postpone_idle(struct o2net_sock_container *sc); 149static void o2net_sc_postpone_idle(struct o2net_sock_container *sc);
150static void o2net_sc_reset_idle_timer(struct o2net_sock_container *sc);
151
152/*
153 * FIXME: These should use to_o2nm_cluster_from_node(), but we end up
154 * losing our parent link to the cluster during shutdown. This can be
155 * solved by adding a pre-removal callback to configfs, or passing
156 * around the cluster with the node. -jeffm
157 */
158static inline int o2net_reconnect_delay(struct o2nm_node *node)
159{
160 return o2nm_single_cluster->cl_reconnect_delay_ms;
161}
162
163static inline int o2net_keepalive_delay(struct o2nm_node *node)
164{
165 return o2nm_single_cluster->cl_keepalive_delay_ms;
166}
167
168static inline int o2net_idle_timeout(struct o2nm_node *node)
169{
170 return o2nm_single_cluster->cl_idle_timeout_ms;
171}
150 172
151static inline int o2net_sys_err_to_errno(enum o2net_system_error err) 173static inline int o2net_sys_err_to_errno(enum o2net_system_error err)
152{ 174{
@@ -271,6 +293,8 @@ static void sc_kref_release(struct kref *kref)
271{ 293{
272 struct o2net_sock_container *sc = container_of(kref, 294 struct o2net_sock_container *sc = container_of(kref,
273 struct o2net_sock_container, sc_kref); 295 struct o2net_sock_container, sc_kref);
296 BUG_ON(timer_pending(&sc->sc_idle_timeout));
297
274 sclog(sc, "releasing\n"); 298 sclog(sc, "releasing\n");
275 299
276 if (sc->sc_sock) { 300 if (sc->sc_sock) {
@@ -356,6 +380,13 @@ static void o2net_sc_cancel_delayed_work(struct o2net_sock_container *sc,
356 sc_put(sc); 380 sc_put(sc);
357} 381}
358 382
383static atomic_t o2net_connected_peers = ATOMIC_INIT(0);
384
385int o2net_num_connected_peers(void)
386{
387 return atomic_read(&o2net_connected_peers);
388}
389
359static void o2net_set_nn_state(struct o2net_node *nn, 390static void o2net_set_nn_state(struct o2net_node *nn,
360 struct o2net_sock_container *sc, 391 struct o2net_sock_container *sc,
361 unsigned valid, int err) 392 unsigned valid, int err)
@@ -366,6 +397,11 @@ static void o2net_set_nn_state(struct o2net_node *nn,
366 397
367 assert_spin_locked(&nn->nn_lock); 398 assert_spin_locked(&nn->nn_lock);
368 399
400 if (old_sc && !sc)
401 atomic_dec(&o2net_connected_peers);
402 else if (!old_sc && sc)
403 atomic_inc(&o2net_connected_peers);
404
369 /* the node num comparison and single connect/accept path should stop 405 /* the node num comparison and single connect/accept path should stop
370 * an non-null sc from being overwritten with another */ 406 * an non-null sc from being overwritten with another */
371 BUG_ON(sc && nn->nn_sc && nn->nn_sc != sc); 407 BUG_ON(sc && nn->nn_sc && nn->nn_sc != sc);
@@ -424,9 +460,9 @@ static void o2net_set_nn_state(struct o2net_node *nn,
424 /* delay if we're withing a RECONNECT_DELAY of the 460 /* delay if we're withing a RECONNECT_DELAY of the
425 * last attempt */ 461 * last attempt */
426 delay = (nn->nn_last_connect_attempt + 462 delay = (nn->nn_last_connect_attempt +
427 msecs_to_jiffies(O2NET_RECONNECT_DELAY_MS)) 463 msecs_to_jiffies(o2net_reconnect_delay(sc->sc_node)))
428 - jiffies; 464 - jiffies;
429 if (delay > msecs_to_jiffies(O2NET_RECONNECT_DELAY_MS)) 465 if (delay > msecs_to_jiffies(o2net_reconnect_delay(sc->sc_node)))
430 delay = 0; 466 delay = 0;
431 mlog(ML_CONN, "queueing conn attempt in %lu jiffies\n", delay); 467 mlog(ML_CONN, "queueing conn attempt in %lu jiffies\n", delay);
432 queue_delayed_work(o2net_wq, &nn->nn_connect_work, delay); 468 queue_delayed_work(o2net_wq, &nn->nn_connect_work, delay);
@@ -1099,13 +1135,51 @@ static int o2net_check_handshake(struct o2net_sock_container *sc)
1099 return -1; 1135 return -1;
1100 } 1136 }
1101 1137
1138 /*
1139 * Ensure timeouts are consistent with other nodes, otherwise
1140 * we can end up with one node thinking that the other must be down,
1141 * but isn't. This can ultimately cause corruption.
1142 */
1143 if (be32_to_cpu(hand->o2net_idle_timeout_ms) !=
1144 o2net_idle_timeout(sc->sc_node)) {
1145 mlog(ML_NOTICE, SC_NODEF_FMT " uses a network idle timeout of "
1146 "%u ms, but we use %u ms locally. disconnecting\n",
1147 SC_NODEF_ARGS(sc),
1148 be32_to_cpu(hand->o2net_idle_timeout_ms),
1149 o2net_idle_timeout(sc->sc_node));
1150 o2net_ensure_shutdown(nn, sc, -ENOTCONN);
1151 return -1;
1152 }
1153
1154 if (be32_to_cpu(hand->o2net_keepalive_delay_ms) !=
1155 o2net_keepalive_delay(sc->sc_node)) {
1156 mlog(ML_NOTICE, SC_NODEF_FMT " uses a keepalive delay of "
1157 "%u ms, but we use %u ms locally. disconnecting\n",
1158 SC_NODEF_ARGS(sc),
1159 be32_to_cpu(hand->o2net_keepalive_delay_ms),
1160 o2net_keepalive_delay(sc->sc_node));
1161 o2net_ensure_shutdown(nn, sc, -ENOTCONN);
1162 return -1;
1163 }
1164
1165 if (be32_to_cpu(hand->o2hb_heartbeat_timeout_ms) !=
1166 O2HB_MAX_WRITE_TIMEOUT_MS) {
1167 mlog(ML_NOTICE, SC_NODEF_FMT " uses a heartbeat timeout of "
1168 "%u ms, but we use %u ms locally. disconnecting\n",
1169 SC_NODEF_ARGS(sc),
1170 be32_to_cpu(hand->o2hb_heartbeat_timeout_ms),
1171 O2HB_MAX_WRITE_TIMEOUT_MS);
1172 o2net_ensure_shutdown(nn, sc, -ENOTCONN);
1173 return -1;
1174 }
1175
1102 sc->sc_handshake_ok = 1; 1176 sc->sc_handshake_ok = 1;
1103 1177
1104 spin_lock(&nn->nn_lock); 1178 spin_lock(&nn->nn_lock);
1105 /* set valid and queue the idle timers only if it hasn't been 1179 /* set valid and queue the idle timers only if it hasn't been
1106 * shut down already */ 1180 * shut down already */
1107 if (nn->nn_sc == sc) { 1181 if (nn->nn_sc == sc) {
1108 o2net_sc_postpone_idle(sc); 1182 o2net_sc_reset_idle_timer(sc);
1109 o2net_set_nn_state(nn, sc, 1, 0); 1183 o2net_set_nn_state(nn, sc, 1, 0);
1110 } 1184 }
1111 spin_unlock(&nn->nn_lock); 1185 spin_unlock(&nn->nn_lock);
@@ -1131,6 +1205,23 @@ static int o2net_advance_rx(struct o2net_sock_container *sc)
1131 sclog(sc, "receiving\n"); 1205 sclog(sc, "receiving\n");
1132 do_gettimeofday(&sc->sc_tv_advance_start); 1206 do_gettimeofday(&sc->sc_tv_advance_start);
1133 1207
1208 if (unlikely(sc->sc_handshake_ok == 0)) {
1209 if(sc->sc_page_off < sizeof(struct o2net_handshake)) {
1210 data = page_address(sc->sc_page) + sc->sc_page_off;
1211 datalen = sizeof(struct o2net_handshake) - sc->sc_page_off;
1212 ret = o2net_recv_tcp_msg(sc->sc_sock, data, datalen);
1213 if (ret > 0)
1214 sc->sc_page_off += ret;
1215 }
1216
1217 if (sc->sc_page_off == sizeof(struct o2net_handshake)) {
1218 o2net_check_handshake(sc);
1219 if (unlikely(sc->sc_handshake_ok == 0))
1220 ret = -EPROTO;
1221 }
1222 goto out;
1223 }
1224
1134 /* do we need more header? */ 1225 /* do we need more header? */
1135 if (sc->sc_page_off < sizeof(struct o2net_msg)) { 1226 if (sc->sc_page_off < sizeof(struct o2net_msg)) {
1136 data = page_address(sc->sc_page) + sc->sc_page_off; 1227 data = page_address(sc->sc_page) + sc->sc_page_off;
@@ -1138,15 +1229,6 @@ static int o2net_advance_rx(struct o2net_sock_container *sc)
1138 ret = o2net_recv_tcp_msg(sc->sc_sock, data, datalen); 1229 ret = o2net_recv_tcp_msg(sc->sc_sock, data, datalen);
1139 if (ret > 0) { 1230 if (ret > 0) {
1140 sc->sc_page_off += ret; 1231 sc->sc_page_off += ret;
1141
1142 /* this working relies on the handshake being
1143 * smaller than the normal message header */
1144 if (sc->sc_page_off >= sizeof(struct o2net_handshake)&&
1145 !sc->sc_handshake_ok && o2net_check_handshake(sc)) {
1146 ret = -EPROTO;
1147 goto out;
1148 }
1149
1150 /* only swab incoming here.. we can 1232 /* only swab incoming here.. we can
1151 * only get here once as we cross from 1233 * only get here once as we cross from
1152 * being under to over */ 1234 * being under to over */
@@ -1248,6 +1330,18 @@ static int o2net_set_nodelay(struct socket *sock)
1248 return ret; 1330 return ret;
1249} 1331}
1250 1332
1333static void o2net_initialize_handshake(void)
1334{
1335 o2net_hand->o2hb_heartbeat_timeout_ms = cpu_to_be32(
1336 O2HB_MAX_WRITE_TIMEOUT_MS);
1337 o2net_hand->o2net_idle_timeout_ms = cpu_to_be32(
1338 o2net_idle_timeout(NULL));
1339 o2net_hand->o2net_keepalive_delay_ms = cpu_to_be32(
1340 o2net_keepalive_delay(NULL));
1341 o2net_hand->o2net_reconnect_delay_ms = cpu_to_be32(
1342 o2net_reconnect_delay(NULL));
1343}
1344
1251/* ------------------------------------------------------------ */ 1345/* ------------------------------------------------------------ */
1252 1346
1253/* called when a connect completes and after a sock is accepted. the 1347/* called when a connect completes and after a sock is accepted. the
@@ -1262,6 +1356,7 @@ static void o2net_sc_connect_completed(struct work_struct *work)
1262 (unsigned long long)O2NET_PROTOCOL_VERSION, 1356 (unsigned long long)O2NET_PROTOCOL_VERSION,
1263 (unsigned long long)be64_to_cpu(o2net_hand->connector_id)); 1357 (unsigned long long)be64_to_cpu(o2net_hand->connector_id));
1264 1358
1359 o2net_initialize_handshake();
1265 o2net_sendpage(sc, o2net_hand, sizeof(*o2net_hand)); 1360 o2net_sendpage(sc, o2net_hand, sizeof(*o2net_hand));
1266 sc_put(sc); 1361 sc_put(sc);
1267} 1362}
@@ -1287,8 +1382,10 @@ static void o2net_idle_timer(unsigned long data)
1287 1382
1288 do_gettimeofday(&now); 1383 do_gettimeofday(&now);
1289 1384
1290 printk(KERN_INFO "o2net: connection to " SC_NODEF_FMT " has been idle for 10 " 1385 printk(KERN_INFO "o2net: connection to " SC_NODEF_FMT " has been idle for %u.%u "
1291 "seconds, shutting it down.\n", SC_NODEF_ARGS(sc)); 1386 "seconds, shutting it down.\n", SC_NODEF_ARGS(sc),
1387 o2net_idle_timeout(sc->sc_node) / 1000,
1388 o2net_idle_timeout(sc->sc_node) % 1000);
1292 mlog(ML_NOTICE, "here are some times that might help debug the " 1389 mlog(ML_NOTICE, "here are some times that might help debug the "
1293 "situation: (tmr %ld.%ld now %ld.%ld dr %ld.%ld adv " 1390 "situation: (tmr %ld.%ld now %ld.%ld dr %ld.%ld adv "
1294 "%ld.%ld:%ld.%ld func (%08x:%u) %ld.%ld:%ld.%ld)\n", 1391 "%ld.%ld:%ld.%ld func (%08x:%u) %ld.%ld:%ld.%ld)\n",
@@ -1306,14 +1403,21 @@ static void o2net_idle_timer(unsigned long data)
1306 o2net_sc_queue_work(sc, &sc->sc_shutdown_work); 1403 o2net_sc_queue_work(sc, &sc->sc_shutdown_work);
1307} 1404}
1308 1405
1309static void o2net_sc_postpone_idle(struct o2net_sock_container *sc) 1406static void o2net_sc_reset_idle_timer(struct o2net_sock_container *sc)
1310{ 1407{
1311 o2net_sc_cancel_delayed_work(sc, &sc->sc_keepalive_work); 1408 o2net_sc_cancel_delayed_work(sc, &sc->sc_keepalive_work);
1312 o2net_sc_queue_delayed_work(sc, &sc->sc_keepalive_work, 1409 o2net_sc_queue_delayed_work(sc, &sc->sc_keepalive_work,
1313 O2NET_KEEPALIVE_DELAY_SECS * HZ); 1410 msecs_to_jiffies(o2net_keepalive_delay(sc->sc_node)));
1314 do_gettimeofday(&sc->sc_tv_timer); 1411 do_gettimeofday(&sc->sc_tv_timer);
1315 mod_timer(&sc->sc_idle_timeout, 1412 mod_timer(&sc->sc_idle_timeout,
1316 jiffies + (O2NET_IDLE_TIMEOUT_SECS * HZ)); 1413 jiffies + msecs_to_jiffies(o2net_idle_timeout(sc->sc_node)));
1414}
1415
1416static void o2net_sc_postpone_idle(struct o2net_sock_container *sc)
1417{
1418 /* Only push out an existing timer */
1419 if (timer_pending(&sc->sc_idle_timeout))
1420 o2net_sc_reset_idle_timer(sc);
1317} 1421}
1318 1422
1319/* this work func is kicked whenever a path sets the nn state which doesn't 1423/* this work func is kicked whenever a path sets the nn state which doesn't
@@ -1435,9 +1539,12 @@ static void o2net_connect_expired(struct work_struct *work)
1435 1539
1436 spin_lock(&nn->nn_lock); 1540 spin_lock(&nn->nn_lock);
1437 if (!nn->nn_sc_valid) { 1541 if (!nn->nn_sc_valid) {
1542 struct o2nm_node *node = nn->nn_sc->sc_node;
1438 mlog(ML_ERROR, "no connection established with node %u after " 1543 mlog(ML_ERROR, "no connection established with node %u after "
1439 "%u seconds, giving up and returning errors.\n", 1544 "%u.%u seconds, giving up and returning errors.\n",
1440 o2net_num_from_nn(nn), O2NET_IDLE_TIMEOUT_SECS); 1545 o2net_num_from_nn(nn),
1546 o2net_idle_timeout(node) / 1000,
1547 o2net_idle_timeout(node) % 1000);
1441 1548
1442 o2net_set_nn_state(nn, NULL, 0, -ENOTCONN); 1549 o2net_set_nn_state(nn, NULL, 0, -ENOTCONN);
1443 } 1550 }
@@ -1478,6 +1585,8 @@ static void o2net_hb_node_down_cb(struct o2nm_node *node, int node_num,
1478 1585
1479 if (node_num != o2nm_this_node()) 1586 if (node_num != o2nm_this_node())
1480 o2net_disconnect_node(node); 1587 o2net_disconnect_node(node);
1588
1589 BUG_ON(atomic_read(&o2net_connected_peers) < 0);
1481} 1590}
1482 1591
1483static void o2net_hb_node_up_cb(struct o2nm_node *node, int node_num, 1592static void o2net_hb_node_up_cb(struct o2nm_node *node, int node_num,
@@ -1489,14 +1598,14 @@ static void o2net_hb_node_up_cb(struct o2nm_node *node, int node_num,
1489 1598
1490 /* ensure an immediate connect attempt */ 1599 /* ensure an immediate connect attempt */
1491 nn->nn_last_connect_attempt = jiffies - 1600 nn->nn_last_connect_attempt = jiffies -
1492 (msecs_to_jiffies(O2NET_RECONNECT_DELAY_MS) + 1); 1601 (msecs_to_jiffies(o2net_reconnect_delay(node)) + 1);
1493 1602
1494 if (node_num != o2nm_this_node()) { 1603 if (node_num != o2nm_this_node()) {
1495 /* heartbeat doesn't work unless a local node number is 1604 /* heartbeat doesn't work unless a local node number is
1496 * configured and doing so brings up the o2net_wq, so we can 1605 * configured and doing so brings up the o2net_wq, so we can
1497 * use it.. */ 1606 * use it.. */
1498 queue_delayed_work(o2net_wq, &nn->nn_connect_expired, 1607 queue_delayed_work(o2net_wq, &nn->nn_connect_expired,
1499 O2NET_IDLE_TIMEOUT_SECS * HZ); 1608 msecs_to_jiffies(o2net_idle_timeout(node)));
1500 1609
1501 /* believe it or not, accept and node hearbeating testing 1610 /* believe it or not, accept and node hearbeating testing
1502 * can succeed for this node before we got here.. so 1611 * can succeed for this node before we got here.. so
@@ -1641,6 +1750,7 @@ static int o2net_accept_one(struct socket *sock)
1641 o2net_register_callbacks(sc->sc_sock->sk, sc); 1750 o2net_register_callbacks(sc->sc_sock->sk, sc);
1642 o2net_sc_queue_work(sc, &sc->sc_rx_work); 1751 o2net_sc_queue_work(sc, &sc->sc_rx_work);
1643 1752
1753 o2net_initialize_handshake();
1644 o2net_sendpage(sc, o2net_hand, sizeof(*o2net_hand)); 1754 o2net_sendpage(sc, o2net_hand, sizeof(*o2net_hand));
1645 1755
1646out: 1756out:
diff --git a/fs/ocfs2/cluster/tcp.h b/fs/ocfs2/cluster/tcp.h
index 616ff2b8434a..21a4e43df836 100644
--- a/fs/ocfs2/cluster/tcp.h
+++ b/fs/ocfs2/cluster/tcp.h
@@ -54,6 +54,13 @@ typedef int (o2net_msg_handler_func)(struct o2net_msg *msg, u32 len, void *data)
54 54
55#define O2NET_MAX_PAYLOAD_BYTES (4096 - sizeof(struct o2net_msg)) 55#define O2NET_MAX_PAYLOAD_BYTES (4096 - sizeof(struct o2net_msg))
56 56
57/* same as hb delay, we're waiting for another node to recognize our hb */
58#define O2NET_RECONNECT_DELAY_MS_DEFAULT 2000
59
60#define O2NET_KEEPALIVE_DELAY_MS_DEFAULT 5000
61#define O2NET_IDLE_TIMEOUT_MS_DEFAULT 10000
62
63
57/* TODO: figure this out.... */ 64/* TODO: figure this out.... */
58static inline int o2net_link_down(int err, struct socket *sock) 65static inline int o2net_link_down(int err, struct socket *sock)
59{ 66{
@@ -101,6 +108,7 @@ void o2net_unregister_hb_callbacks(void);
101int o2net_start_listening(struct o2nm_node *node); 108int o2net_start_listening(struct o2nm_node *node);
102void o2net_stop_listening(struct o2nm_node *node); 109void o2net_stop_listening(struct o2nm_node *node);
103void o2net_disconnect_node(struct o2nm_node *node); 110void o2net_disconnect_node(struct o2nm_node *node);
111int o2net_num_connected_peers(void);
104 112
105int o2net_init(void); 113int o2net_init(void);
106void o2net_exit(void); 114void o2net_exit(void);
diff --git a/fs/ocfs2/cluster/tcp_internal.h b/fs/ocfs2/cluster/tcp_internal.h
index daebbd3a2c8c..b700dc9624d1 100644
--- a/fs/ocfs2/cluster/tcp_internal.h
+++ b/fs/ocfs2/cluster/tcp_internal.h
@@ -27,23 +27,20 @@
27#define O2NET_MSG_KEEP_REQ_MAGIC ((u16)0xfa57) 27#define O2NET_MSG_KEEP_REQ_MAGIC ((u16)0xfa57)
28#define O2NET_MSG_KEEP_RESP_MAGIC ((u16)0xfa58) 28#define O2NET_MSG_KEEP_RESP_MAGIC ((u16)0xfa58)
29 29
30/* same as hb delay, we're waiting for another node to recognize our hb */
31#define O2NET_RECONNECT_DELAY_MS O2HB_REGION_TIMEOUT_MS
32
33/* we're delaying our quorum decision so that heartbeat will have timed 30/* we're delaying our quorum decision so that heartbeat will have timed
34 * out truly dead nodes by the time we come around to making decisions 31 * out truly dead nodes by the time we come around to making decisions
35 * on their number */ 32 * on their number */
36#define O2NET_QUORUM_DELAY_MS ((o2hb_dead_threshold + 2) * O2HB_REGION_TIMEOUT_MS) 33#define O2NET_QUORUM_DELAY_MS ((o2hb_dead_threshold + 2) * O2HB_REGION_TIMEOUT_MS)
37 34
38#define O2NET_KEEPALIVE_DELAY_SECS 5
39#define O2NET_IDLE_TIMEOUT_SECS 10
40
41/* 35/*
42 * This version number represents quite a lot, unfortunately. It not 36 * This version number represents quite a lot, unfortunately. It not
43 * only represents the raw network message protocol on the wire but also 37 * only represents the raw network message protocol on the wire but also
44 * locking semantics of the file system using the protocol. It should 38 * locking semantics of the file system using the protocol. It should
45 * be somewhere else, I'm sure, but right now it isn't. 39 * be somewhere else, I'm sure, but right now it isn't.
46 * 40 *
41 * New in version 5:
42 * - Network timeout checking protocol
43 *
47 * New in version 4: 44 * New in version 4:
48 * - Remove i_generation from lock names for better stat performance. 45 * - Remove i_generation from lock names for better stat performance.
49 * 46 *
@@ -54,10 +51,14 @@
54 * - full 64 bit i_size in the metadata lock lvbs 51 * - full 64 bit i_size in the metadata lock lvbs
55 * - introduction of "rw" lock and pushing meta/data locking down 52 * - introduction of "rw" lock and pushing meta/data locking down
56 */ 53 */
57#define O2NET_PROTOCOL_VERSION 4ULL 54#define O2NET_PROTOCOL_VERSION 5ULL
58struct o2net_handshake { 55struct o2net_handshake {
59 __be64 protocol_version; 56 __be64 protocol_version;
60 __be64 connector_id; 57 __be64 connector_id;
58 __be32 o2hb_heartbeat_timeout_ms;
59 __be32 o2net_idle_timeout_ms;
60 __be32 o2net_keepalive_delay_ms;
61 __be32 o2net_reconnect_delay_ms;
61}; 62};
62 63
63struct o2net_node { 64struct o2net_node {
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 69fba16efbd1..e6220137bf69 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -770,7 +770,7 @@ static int ocfs2_lock_create(struct ocfs2_super *osb,
770 int dlm_flags) 770 int dlm_flags)
771{ 771{
772 int ret = 0; 772 int ret = 0;
773 enum dlm_status status; 773 enum dlm_status status = DLM_NORMAL;
774 unsigned long flags; 774 unsigned long flags;
775 775
776 mlog_entry_void(); 776 mlog_entry_void();
@@ -1138,6 +1138,7 @@ int ocfs2_rw_lock(struct inode *inode, int write)
1138{ 1138{
1139 int status, level; 1139 int status, level;
1140 struct ocfs2_lock_res *lockres; 1140 struct ocfs2_lock_res *lockres;
1141 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1141 1142
1142 BUG_ON(!inode); 1143 BUG_ON(!inode);
1143 1144
@@ -1147,6 +1148,9 @@ int ocfs2_rw_lock(struct inode *inode, int write)
1147 (unsigned long long)OCFS2_I(inode)->ip_blkno, 1148 (unsigned long long)OCFS2_I(inode)->ip_blkno,
1148 write ? "EXMODE" : "PRMODE"); 1149 write ? "EXMODE" : "PRMODE");
1149 1150
1151 if (ocfs2_mount_local(osb))
1152 return 0;
1153
1150 lockres = &OCFS2_I(inode)->ip_rw_lockres; 1154 lockres = &OCFS2_I(inode)->ip_rw_lockres;
1151 1155
1152 level = write ? LKM_EXMODE : LKM_PRMODE; 1156 level = write ? LKM_EXMODE : LKM_PRMODE;
@@ -1164,6 +1168,7 @@ void ocfs2_rw_unlock(struct inode *inode, int write)
1164{ 1168{
1165 int level = write ? LKM_EXMODE : LKM_PRMODE; 1169 int level = write ? LKM_EXMODE : LKM_PRMODE;
1166 struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_rw_lockres; 1170 struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_rw_lockres;
1171 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1167 1172
1168 mlog_entry_void(); 1173 mlog_entry_void();
1169 1174
@@ -1171,7 +1176,8 @@ void ocfs2_rw_unlock(struct inode *inode, int write)
1171 (unsigned long long)OCFS2_I(inode)->ip_blkno, 1176 (unsigned long long)OCFS2_I(inode)->ip_blkno,
1172 write ? "EXMODE" : "PRMODE"); 1177 write ? "EXMODE" : "PRMODE");
1173 1178
1174 ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level); 1179 if (!ocfs2_mount_local(osb))
1180 ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level);
1175 1181
1176 mlog_exit_void(); 1182 mlog_exit_void();
1177} 1183}
@@ -1182,6 +1188,7 @@ int ocfs2_data_lock_full(struct inode *inode,
1182{ 1188{
1183 int status = 0, level; 1189 int status = 0, level;
1184 struct ocfs2_lock_res *lockres; 1190 struct ocfs2_lock_res *lockres;
1191 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1185 1192
1186 BUG_ON(!inode); 1193 BUG_ON(!inode);
1187 1194
@@ -1201,6 +1208,9 @@ int ocfs2_data_lock_full(struct inode *inode,
1201 goto out; 1208 goto out;
1202 } 1209 }
1203 1210
1211 if (ocfs2_mount_local(osb))
1212 goto out;
1213
1204 lockres = &OCFS2_I(inode)->ip_data_lockres; 1214 lockres = &OCFS2_I(inode)->ip_data_lockres;
1205 1215
1206 level = write ? LKM_EXMODE : LKM_PRMODE; 1216 level = write ? LKM_EXMODE : LKM_PRMODE;
@@ -1269,6 +1279,7 @@ void ocfs2_data_unlock(struct inode *inode,
1269{ 1279{
1270 int level = write ? LKM_EXMODE : LKM_PRMODE; 1280 int level = write ? LKM_EXMODE : LKM_PRMODE;
1271 struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_data_lockres; 1281 struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_data_lockres;
1282 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1272 1283
1273 mlog_entry_void(); 1284 mlog_entry_void();
1274 1285
@@ -1276,7 +1287,8 @@ void ocfs2_data_unlock(struct inode *inode,
1276 (unsigned long long)OCFS2_I(inode)->ip_blkno, 1287 (unsigned long long)OCFS2_I(inode)->ip_blkno,
1277 write ? "EXMODE" : "PRMODE"); 1288 write ? "EXMODE" : "PRMODE");
1278 1289
1279 if (!ocfs2_is_hard_readonly(OCFS2_SB(inode->i_sb))) 1290 if (!ocfs2_is_hard_readonly(OCFS2_SB(inode->i_sb)) &&
1291 !ocfs2_mount_local(osb))
1280 ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level); 1292 ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level);
1281 1293
1282 mlog_exit_void(); 1294 mlog_exit_void();
@@ -1467,8 +1479,9 @@ static int ocfs2_meta_lock_update(struct inode *inode,
1467{ 1479{
1468 int status = 0; 1480 int status = 0;
1469 struct ocfs2_inode_info *oi = OCFS2_I(inode); 1481 struct ocfs2_inode_info *oi = OCFS2_I(inode);
1470 struct ocfs2_lock_res *lockres; 1482 struct ocfs2_lock_res *lockres = NULL;
1471 struct ocfs2_dinode *fe; 1483 struct ocfs2_dinode *fe;
1484 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1472 1485
1473 mlog_entry_void(); 1486 mlog_entry_void();
1474 1487
@@ -1483,10 +1496,12 @@ static int ocfs2_meta_lock_update(struct inode *inode,
1483 } 1496 }
1484 spin_unlock(&oi->ip_lock); 1497 spin_unlock(&oi->ip_lock);
1485 1498
1486 lockres = &oi->ip_meta_lockres; 1499 if (!ocfs2_mount_local(osb)) {
1500 lockres = &oi->ip_meta_lockres;
1487 1501
1488 if (!ocfs2_should_refresh_lock_res(lockres)) 1502 if (!ocfs2_should_refresh_lock_res(lockres))
1489 goto bail; 1503 goto bail;
1504 }
1490 1505
1491 /* This will discard any caching information we might have had 1506 /* This will discard any caching information we might have had
1492 * for the inode metadata. */ 1507 * for the inode metadata. */
@@ -1496,7 +1511,7 @@ static int ocfs2_meta_lock_update(struct inode *inode,
1496 * map (directories, bitmap files, etc) */ 1511 * map (directories, bitmap files, etc) */
1497 ocfs2_extent_map_trunc(inode, 0); 1512 ocfs2_extent_map_trunc(inode, 0);
1498 1513
1499 if (ocfs2_meta_lvb_is_trustable(inode, lockres)) { 1514 if (lockres && ocfs2_meta_lvb_is_trustable(inode, lockres)) {
1500 mlog(0, "Trusting LVB on inode %llu\n", 1515 mlog(0, "Trusting LVB on inode %llu\n",
1501 (unsigned long long)oi->ip_blkno); 1516 (unsigned long long)oi->ip_blkno);
1502 ocfs2_refresh_inode_from_lvb(inode); 1517 ocfs2_refresh_inode_from_lvb(inode);
@@ -1543,7 +1558,8 @@ static int ocfs2_meta_lock_update(struct inode *inode,
1543 1558
1544 status = 0; 1559 status = 0;
1545bail_refresh: 1560bail_refresh:
1546 ocfs2_complete_lock_res_refresh(lockres, status); 1561 if (lockres)
1562 ocfs2_complete_lock_res_refresh(lockres, status);
1547bail: 1563bail:
1548 mlog_exit(status); 1564 mlog_exit(status);
1549 return status; 1565 return status;
@@ -1585,7 +1601,7 @@ int ocfs2_meta_lock_full(struct inode *inode,
1585 int arg_flags) 1601 int arg_flags)
1586{ 1602{
1587 int status, level, dlm_flags, acquired; 1603 int status, level, dlm_flags, acquired;
1588 struct ocfs2_lock_res *lockres; 1604 struct ocfs2_lock_res *lockres = NULL;
1589 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 1605 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1590 struct buffer_head *local_bh = NULL; 1606 struct buffer_head *local_bh = NULL;
1591 1607
@@ -1607,6 +1623,9 @@ int ocfs2_meta_lock_full(struct inode *inode,
1607 goto bail; 1623 goto bail;
1608 } 1624 }
1609 1625
1626 if (ocfs2_mount_local(osb))
1627 goto local;
1628
1610 if (!(arg_flags & OCFS2_META_LOCK_RECOVERY)) 1629 if (!(arg_flags & OCFS2_META_LOCK_RECOVERY))
1611 wait_event(osb->recovery_event, 1630 wait_event(osb->recovery_event,
1612 ocfs2_node_map_is_empty(osb, &osb->recovery_map)); 1631 ocfs2_node_map_is_empty(osb, &osb->recovery_map));
@@ -1636,6 +1655,7 @@ int ocfs2_meta_lock_full(struct inode *inode,
1636 wait_event(osb->recovery_event, 1655 wait_event(osb->recovery_event,
1637 ocfs2_node_map_is_empty(osb, &osb->recovery_map)); 1656 ocfs2_node_map_is_empty(osb, &osb->recovery_map));
1638 1657
1658local:
1639 /* 1659 /*
1640 * We only see this flag if we're being called from 1660 * We only see this flag if we're being called from
1641 * ocfs2_read_locked_inode(). It means we're locking an inode 1661 * ocfs2_read_locked_inode(). It means we're locking an inode
@@ -1644,7 +1664,8 @@ int ocfs2_meta_lock_full(struct inode *inode,
1644 */ 1664 */
1645 if (inode->i_state & I_NEW) { 1665 if (inode->i_state & I_NEW) {
1646 status = 0; 1666 status = 0;
1647 ocfs2_complete_lock_res_refresh(lockres, 0); 1667 if (lockres)
1668 ocfs2_complete_lock_res_refresh(lockres, 0);
1648 goto bail; 1669 goto bail;
1649 } 1670 }
1650 1671
@@ -1767,6 +1788,7 @@ void ocfs2_meta_unlock(struct inode *inode,
1767{ 1788{
1768 int level = ex ? LKM_EXMODE : LKM_PRMODE; 1789 int level = ex ? LKM_EXMODE : LKM_PRMODE;
1769 struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_meta_lockres; 1790 struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_meta_lockres;
1791 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1770 1792
1771 mlog_entry_void(); 1793 mlog_entry_void();
1772 1794
@@ -1774,7 +1796,8 @@ void ocfs2_meta_unlock(struct inode *inode,
1774 (unsigned long long)OCFS2_I(inode)->ip_blkno, 1796 (unsigned long long)OCFS2_I(inode)->ip_blkno,
1775 ex ? "EXMODE" : "PRMODE"); 1797 ex ? "EXMODE" : "PRMODE");
1776 1798
1777 if (!ocfs2_is_hard_readonly(OCFS2_SB(inode->i_sb))) 1799 if (!ocfs2_is_hard_readonly(OCFS2_SB(inode->i_sb)) &&
1800 !ocfs2_mount_local(osb))
1778 ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level); 1801 ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level);
1779 1802
1780 mlog_exit_void(); 1803 mlog_exit_void();
@@ -1783,7 +1806,7 @@ void ocfs2_meta_unlock(struct inode *inode,
1783int ocfs2_super_lock(struct ocfs2_super *osb, 1806int ocfs2_super_lock(struct ocfs2_super *osb,
1784 int ex) 1807 int ex)
1785{ 1808{
1786 int status; 1809 int status = 0;
1787 int level = ex ? LKM_EXMODE : LKM_PRMODE; 1810 int level = ex ? LKM_EXMODE : LKM_PRMODE;
1788 struct ocfs2_lock_res *lockres = &osb->osb_super_lockres; 1811 struct ocfs2_lock_res *lockres = &osb->osb_super_lockres;
1789 struct buffer_head *bh; 1812 struct buffer_head *bh;
@@ -1794,6 +1817,9 @@ int ocfs2_super_lock(struct ocfs2_super *osb,
1794 if (ocfs2_is_hard_readonly(osb)) 1817 if (ocfs2_is_hard_readonly(osb))
1795 return -EROFS; 1818 return -EROFS;
1796 1819
1820 if (ocfs2_mount_local(osb))
1821 goto bail;
1822
1797 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0); 1823 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0);
1798 if (status < 0) { 1824 if (status < 0) {
1799 mlog_errno(status); 1825 mlog_errno(status);
@@ -1832,7 +1858,8 @@ void ocfs2_super_unlock(struct ocfs2_super *osb,
1832 int level = ex ? LKM_EXMODE : LKM_PRMODE; 1858 int level = ex ? LKM_EXMODE : LKM_PRMODE;
1833 struct ocfs2_lock_res *lockres = &osb->osb_super_lockres; 1859 struct ocfs2_lock_res *lockres = &osb->osb_super_lockres;
1834 1860
1835 ocfs2_cluster_unlock(osb, lockres, level); 1861 if (!ocfs2_mount_local(osb))
1862 ocfs2_cluster_unlock(osb, lockres, level);
1836} 1863}
1837 1864
1838int ocfs2_rename_lock(struct ocfs2_super *osb) 1865int ocfs2_rename_lock(struct ocfs2_super *osb)
@@ -1843,6 +1870,9 @@ int ocfs2_rename_lock(struct ocfs2_super *osb)
1843 if (ocfs2_is_hard_readonly(osb)) 1870 if (ocfs2_is_hard_readonly(osb))
1844 return -EROFS; 1871 return -EROFS;
1845 1872
1873 if (ocfs2_mount_local(osb))
1874 return 0;
1875
1846 status = ocfs2_cluster_lock(osb, lockres, LKM_EXMODE, 0, 0); 1876 status = ocfs2_cluster_lock(osb, lockres, LKM_EXMODE, 0, 0);
1847 if (status < 0) 1877 if (status < 0)
1848 mlog_errno(status); 1878 mlog_errno(status);
@@ -1854,7 +1884,8 @@ void ocfs2_rename_unlock(struct ocfs2_super *osb)
1854{ 1884{
1855 struct ocfs2_lock_res *lockres = &osb->osb_rename_lockres; 1885 struct ocfs2_lock_res *lockres = &osb->osb_rename_lockres;
1856 1886
1857 ocfs2_cluster_unlock(osb, lockres, LKM_EXMODE); 1887 if (!ocfs2_mount_local(osb))
1888 ocfs2_cluster_unlock(osb, lockres, LKM_EXMODE);
1858} 1889}
1859 1890
1860int ocfs2_dentry_lock(struct dentry *dentry, int ex) 1891int ocfs2_dentry_lock(struct dentry *dentry, int ex)
@@ -1869,6 +1900,9 @@ int ocfs2_dentry_lock(struct dentry *dentry, int ex)
1869 if (ocfs2_is_hard_readonly(osb)) 1900 if (ocfs2_is_hard_readonly(osb))
1870 return -EROFS; 1901 return -EROFS;
1871 1902
1903 if (ocfs2_mount_local(osb))
1904 return 0;
1905
1872 ret = ocfs2_cluster_lock(osb, &dl->dl_lockres, level, 0, 0); 1906 ret = ocfs2_cluster_lock(osb, &dl->dl_lockres, level, 0, 0);
1873 if (ret < 0) 1907 if (ret < 0)
1874 mlog_errno(ret); 1908 mlog_errno(ret);
@@ -1882,7 +1916,8 @@ void ocfs2_dentry_unlock(struct dentry *dentry, int ex)
1882 struct ocfs2_dentry_lock *dl = dentry->d_fsdata; 1916 struct ocfs2_dentry_lock *dl = dentry->d_fsdata;
1883 struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); 1917 struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb);
1884 1918
1885 ocfs2_cluster_unlock(osb, &dl->dl_lockres, level); 1919 if (!ocfs2_mount_local(osb))
1920 ocfs2_cluster_unlock(osb, &dl->dl_lockres, level);
1886} 1921}
1887 1922
1888/* Reference counting of the dlm debug structure. We want this because 1923/* Reference counting of the dlm debug structure. We want this because
@@ -2145,12 +2180,15 @@ static void ocfs2_dlm_shutdown_debug(struct ocfs2_super *osb)
2145 2180
2146int ocfs2_dlm_init(struct ocfs2_super *osb) 2181int ocfs2_dlm_init(struct ocfs2_super *osb)
2147{ 2182{
2148 int status; 2183 int status = 0;
2149 u32 dlm_key; 2184 u32 dlm_key;
2150 struct dlm_ctxt *dlm; 2185 struct dlm_ctxt *dlm = NULL;
2151 2186
2152 mlog_entry_void(); 2187 mlog_entry_void();
2153 2188
2189 if (ocfs2_mount_local(osb))
2190 goto local;
2191
2154 status = ocfs2_dlm_init_debug(osb); 2192 status = ocfs2_dlm_init_debug(osb);
2155 if (status < 0) { 2193 if (status < 0) {
2156 mlog_errno(status); 2194 mlog_errno(status);
@@ -2178,11 +2216,12 @@ int ocfs2_dlm_init(struct ocfs2_super *osb)
2178 goto bail; 2216 goto bail;
2179 } 2217 }
2180 2218
2219 dlm_register_eviction_cb(dlm, &osb->osb_eviction_cb);
2220
2221local:
2181 ocfs2_super_lock_res_init(&osb->osb_super_lockres, osb); 2222 ocfs2_super_lock_res_init(&osb->osb_super_lockres, osb);
2182 ocfs2_rename_lock_res_init(&osb->osb_rename_lockres, osb); 2223 ocfs2_rename_lock_res_init(&osb->osb_rename_lockres, osb);
2183 2224
2184 dlm_register_eviction_cb(dlm, &osb->osb_eviction_cb);
2185
2186 osb->dlm = dlm; 2225 osb->dlm = dlm;
2187 2226
2188 status = 0; 2227 status = 0;
diff --git a/fs/ocfs2/heartbeat.c b/fs/ocfs2/heartbeat.c
index cbfd45a97a63..8fc52d6d0ce7 100644
--- a/fs/ocfs2/heartbeat.c
+++ b/fs/ocfs2/heartbeat.c
@@ -154,6 +154,9 @@ int ocfs2_register_hb_callbacks(struct ocfs2_super *osb)
154{ 154{
155 int status; 155 int status;
156 156
157 if (ocfs2_mount_local(osb))
158 return 0;
159
157 status = o2hb_register_callback(&osb->osb_hb_down); 160 status = o2hb_register_callback(&osb->osb_hb_down);
158 if (status < 0) { 161 if (status < 0) {
159 mlog_errno(status); 162 mlog_errno(status);
@@ -172,6 +175,9 @@ void ocfs2_clear_hb_callbacks(struct ocfs2_super *osb)
172{ 175{
173 int status; 176 int status;
174 177
178 if (ocfs2_mount_local(osb))
179 return;
180
175 status = o2hb_unregister_callback(&osb->osb_hb_down); 181 status = o2hb_unregister_callback(&osb->osb_hb_down);
176 if (status < 0) 182 if (status < 0)
177 mlog_errno(status); 183 mlog_errno(status);
@@ -186,6 +192,9 @@ void ocfs2_stop_heartbeat(struct ocfs2_super *osb)
186 int ret; 192 int ret;
187 char *argv[5], *envp[3]; 193 char *argv[5], *envp[3];
188 194
195 if (ocfs2_mount_local(osb))
196 return;
197
189 if (!osb->uuid_str) { 198 if (!osb->uuid_str) {
190 /* This can happen if we don't get far enough in mount... */ 199 /* This can happen if we don't get far enough in mount... */
191 mlog(0, "No UUID with which to stop heartbeat!\n\n"); 200 mlog(0, "No UUID with which to stop heartbeat!\n\n");
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index 42e361f3054f..e4d91493d7d7 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -423,7 +423,8 @@ static int ocfs2_read_locked_inode(struct inode *inode,
423 * cluster lock before trusting anything anyway. 423 * cluster lock before trusting anything anyway.
424 */ 424 */
425 can_lock = !(args->fi_flags & OCFS2_FI_FLAG_SYSFILE) 425 can_lock = !(args->fi_flags & OCFS2_FI_FLAG_SYSFILE)
426 && !(args->fi_flags & OCFS2_FI_FLAG_NOLOCK); 426 && !(args->fi_flags & OCFS2_FI_FLAG_NOLOCK)
427 && !ocfs2_mount_local(osb);
427 428
428 /* 429 /*
429 * To maintain backwards compatibility with older versions of 430 * To maintain backwards compatibility with older versions of
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index 1d7f4ab1e5ed..825cb0ae1b4c 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -144,8 +144,10 @@ handle_t *ocfs2_start_trans(struct ocfs2_super *osb, int max_buffs)
144 ocfs2_abort(osb->sb, "Detected aborted journal"); 144 ocfs2_abort(osb->sb, "Detected aborted journal");
145 handle = ERR_PTR(-EROFS); 145 handle = ERR_PTR(-EROFS);
146 } 146 }
147 } else 147 } else {
148 atomic_inc(&(osb->journal->j_num_trans)); 148 if (!ocfs2_mount_local(osb))
149 atomic_inc(&(osb->journal->j_num_trans));
150 }
149 151
150 return handle; 152 return handle;
151} 153}
@@ -507,9 +509,23 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)
507 509
508 BUG_ON(atomic_read(&(osb->journal->j_num_trans)) != 0); 510 BUG_ON(atomic_read(&(osb->journal->j_num_trans)) != 0);
509 511
510 status = ocfs2_journal_toggle_dirty(osb, 0); 512 if (ocfs2_mount_local(osb)) {
511 if (status < 0) 513 journal_lock_updates(journal->j_journal);
512 mlog_errno(status); 514 status = journal_flush(journal->j_journal);
515 journal_unlock_updates(journal->j_journal);
516 if (status < 0)
517 mlog_errno(status);
518 }
519
520 if (status == 0) {
521 /*
522 * Do not toggle if flush was unsuccessful otherwise
523 * will leave dirty metadata in a "clean" journal
524 */
525 status = ocfs2_journal_toggle_dirty(osb, 0);
526 if (status < 0)
527 mlog_errno(status);
528 }
513 529
514 /* Shutdown the kernel journal system */ 530 /* Shutdown the kernel journal system */
515 journal_destroy(journal->j_journal); 531 journal_destroy(journal->j_journal);
@@ -549,7 +565,7 @@ static void ocfs2_clear_journal_error(struct super_block *sb,
549 } 565 }
550} 566}
551 567
552int ocfs2_journal_load(struct ocfs2_journal *journal) 568int ocfs2_journal_load(struct ocfs2_journal *journal, int local)
553{ 569{
554 int status = 0; 570 int status = 0;
555 struct ocfs2_super *osb; 571 struct ocfs2_super *osb;
@@ -576,14 +592,18 @@ int ocfs2_journal_load(struct ocfs2_journal *journal)
576 } 592 }
577 593
578 /* Launch the commit thread */ 594 /* Launch the commit thread */
579 osb->commit_task = kthread_run(ocfs2_commit_thread, osb, "ocfs2cmt"); 595 if (!local) {
580 if (IS_ERR(osb->commit_task)) { 596 osb->commit_task = kthread_run(ocfs2_commit_thread, osb,
581 status = PTR_ERR(osb->commit_task); 597 "ocfs2cmt");
598 if (IS_ERR(osb->commit_task)) {
599 status = PTR_ERR(osb->commit_task);
600 osb->commit_task = NULL;
601 mlog(ML_ERROR, "unable to launch ocfs2commit thread, "
602 "error=%d", status);
603 goto done;
604 }
605 } else
582 osb->commit_task = NULL; 606 osb->commit_task = NULL;
583 mlog(ML_ERROR, "unable to launch ocfs2commit thread, error=%d",
584 status);
585 goto done;
586 }
587 607
588done: 608done:
589 mlog_exit(status); 609 mlog_exit(status);
diff --git a/fs/ocfs2/journal.h b/fs/ocfs2/journal.h
index 899112ad8136..e1216364d191 100644
--- a/fs/ocfs2/journal.h
+++ b/fs/ocfs2/journal.h
@@ -157,7 +157,7 @@ int ocfs2_journal_init(struct ocfs2_journal *journal,
157void ocfs2_journal_shutdown(struct ocfs2_super *osb); 157void ocfs2_journal_shutdown(struct ocfs2_super *osb);
158int ocfs2_journal_wipe(struct ocfs2_journal *journal, 158int ocfs2_journal_wipe(struct ocfs2_journal *journal,
159 int full); 159 int full);
160int ocfs2_journal_load(struct ocfs2_journal *journal); 160int ocfs2_journal_load(struct ocfs2_journal *journal, int local);
161int ocfs2_check_journals_nolocks(struct ocfs2_super *osb); 161int ocfs2_check_journals_nolocks(struct ocfs2_super *osb);
162void ocfs2_recovery_thread(struct ocfs2_super *osb, 162void ocfs2_recovery_thread(struct ocfs2_super *osb,
163 int node_num); 163 int node_num);
@@ -174,6 +174,9 @@ static inline void ocfs2_checkpoint_inode(struct inode *inode)
174{ 174{
175 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 175 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
176 176
177 if (ocfs2_mount_local(osb))
178 return;
179
177 if (!ocfs2_inode_fully_checkpointed(inode)) { 180 if (!ocfs2_inode_fully_checkpointed(inode)) {
178 /* WARNING: This only kicks off a single 181 /* WARNING: This only kicks off a single
179 * checkpoint. If someone races you and adds more 182 * checkpoint. If someone races you and adds more
diff --git a/fs/ocfs2/mmap.c b/fs/ocfs2/mmap.c
index 69f85ae392dc..51b020447683 100644
--- a/fs/ocfs2/mmap.c
+++ b/fs/ocfs2/mmap.c
@@ -83,10 +83,12 @@ static struct vm_operations_struct ocfs2_file_vm_ops = {
83int ocfs2_mmap(struct file *file, struct vm_area_struct *vma) 83int ocfs2_mmap(struct file *file, struct vm_area_struct *vma)
84{ 84{
85 int ret = 0, lock_level = 0; 85 int ret = 0, lock_level = 0;
86 struct ocfs2_super *osb = OCFS2_SB(file->f_dentry->d_inode->i_sb);
86 87
87 /* We don't want to support shared writable mappings yet. */ 88 /* We don't want to support shared writable mappings yet. */
88 if (((vma->vm_flags & VM_SHARED) || (vma->vm_flags & VM_MAYSHARE)) 89 if (!ocfs2_mount_local(osb) &&
89 && ((vma->vm_flags & VM_WRITE) || (vma->vm_flags & VM_MAYWRITE))) { 90 ((vma->vm_flags & VM_SHARED) || (vma->vm_flags & VM_MAYSHARE)) &&
91 ((vma->vm_flags & VM_WRITE) || (vma->vm_flags & VM_MAYWRITE))) {
90 mlog(0, "disallow shared writable mmaps %lx\n", vma->vm_flags); 92 mlog(0, "disallow shared writable mmaps %lx\n", vma->vm_flags);
91 /* This is -EINVAL because generic_file_readonly_mmap 93 /* This is -EINVAL because generic_file_readonly_mmap
92 * returns it in a similar situation. */ 94 * returns it in a similar situation. */
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 21db45ddf144..9637039c2633 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -587,9 +587,11 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb,
587 } 587 }
588 588
589 ocfs2_inode_set_new(osb, inode); 589 ocfs2_inode_set_new(osb, inode);
590 status = ocfs2_create_new_inode_locks(inode); 590 if (!ocfs2_mount_local(osb)) {
591 if (status < 0) 591 status = ocfs2_create_new_inode_locks(inode);
592 mlog_errno(status); 592 if (status < 0)
593 mlog_errno(status);
594 }
593 595
594 status = 0; /* error in ocfs2_create_new_inode_locks is not 596 status = 0; /* error in ocfs2_create_new_inode_locks is not
595 * critical */ 597 * critical */
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
index b767fd7da6eb..db8e77cd35d3 100644
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -349,6 +349,11 @@ static inline int ocfs2_is_soft_readonly(struct ocfs2_super *osb)
349 return ret; 349 return ret;
350} 350}
351 351
352static inline int ocfs2_mount_local(struct ocfs2_super *osb)
353{
354 return (osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT);
355}
356
352#define OCFS2_IS_VALID_DINODE(ptr) \ 357#define OCFS2_IS_VALID_DINODE(ptr) \
353 (!strcmp((ptr)->i_signature, OCFS2_INODE_SIGNATURE)) 358 (!strcmp((ptr)->i_signature, OCFS2_INODE_SIGNATURE))
354 359
diff --git a/fs/ocfs2/ocfs2_fs.h b/fs/ocfs2/ocfs2_fs.h
index 3330a5dc6be2..b5c68567077e 100644
--- a/fs/ocfs2/ocfs2_fs.h
+++ b/fs/ocfs2/ocfs2_fs.h
@@ -86,7 +86,7 @@
86 OCFS2_SB(sb)->s_feature_incompat &= ~(mask) 86 OCFS2_SB(sb)->s_feature_incompat &= ~(mask)
87 87
88#define OCFS2_FEATURE_COMPAT_SUPP 0 88#define OCFS2_FEATURE_COMPAT_SUPP 0
89#define OCFS2_FEATURE_INCOMPAT_SUPP 0 89#define OCFS2_FEATURE_INCOMPAT_SUPP OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT
90#define OCFS2_FEATURE_RO_COMPAT_SUPP 0 90#define OCFS2_FEATURE_RO_COMPAT_SUPP 0
91 91
92/* 92/*
@@ -96,6 +96,18 @@
96 */ 96 */
97#define OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV 0x0002 97#define OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV 0x0002
98 98
99/*
100 * tunefs sets this incompat flag before starting the resize and clears it
101 * at the end. This flag protects users from inadvertently mounting the fs
102 * after an aborted run without fsck-ing.
103 */
104#define OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG 0x0004
105
106/* Used to denote a non-clustered volume */
107#define OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT 0x0008
108
109/* Support for sparse allocation in b-trees */
110#define OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC 0x0010
99 111
100/* 112/*
101 * Flags on ocfs2_dinode.i_flags 113 * Flags on ocfs2_dinode.i_flags
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 4bf39540e652..a6d2f8cc165b 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -508,6 +508,27 @@ bail:
508 return status; 508 return status;
509} 509}
510 510
511static int ocfs2_verify_heartbeat(struct ocfs2_super *osb)
512{
513 if (ocfs2_mount_local(osb)) {
514 if (osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) {
515 mlog(ML_ERROR, "Cannot heartbeat on a locally "
516 "mounted device.\n");
517 return -EINVAL;
518 }
519 }
520
521 if (!(osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL)) {
522 if (!ocfs2_mount_local(osb) && !ocfs2_is_hard_readonly(osb)) {
523 mlog(ML_ERROR, "Heartbeat has to be started to mount "
524 "a read-write clustered device.\n");
525 return -EINVAL;
526 }
527 }
528
529 return 0;
530}
531
511static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) 532static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
512{ 533{
513 struct dentry *root; 534 struct dentry *root;
@@ -516,16 +537,24 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
516 struct inode *inode = NULL; 537 struct inode *inode = NULL;
517 struct ocfs2_super *osb = NULL; 538 struct ocfs2_super *osb = NULL;
518 struct buffer_head *bh = NULL; 539 struct buffer_head *bh = NULL;
540 char nodestr[8];
519 541
520 mlog_entry("%p, %p, %i", sb, data, silent); 542 mlog_entry("%p, %p, %i", sb, data, silent);
521 543
522 /* for now we only have one cluster/node, make sure we see it 544 if (!ocfs2_parse_options(sb, data, &parsed_opt, 0)) {
523 * in the heartbeat universe */
524 if (!o2hb_check_local_node_heartbeating()) {
525 status = -EINVAL; 545 status = -EINVAL;
526 goto read_super_error; 546 goto read_super_error;
527 } 547 }
528 548
549 /* for now we only have one cluster/node, make sure we see it
550 * in the heartbeat universe */
551 if (parsed_opt & OCFS2_MOUNT_HB_LOCAL) {
552 if (!o2hb_check_local_node_heartbeating()) {
553 status = -EINVAL;
554 goto read_super_error;
555 }
556 }
557
529 /* probe for superblock */ 558 /* probe for superblock */
530 status = ocfs2_sb_probe(sb, &bh, &sector_size); 559 status = ocfs2_sb_probe(sb, &bh, &sector_size);
531 if (status < 0) { 560 if (status < 0) {
@@ -541,11 +570,6 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
541 } 570 }
542 brelse(bh); 571 brelse(bh);
543 bh = NULL; 572 bh = NULL;
544
545 if (!ocfs2_parse_options(sb, data, &parsed_opt, 0)) {
546 status = -EINVAL;
547 goto read_super_error;
548 }
549 osb->s_mount_opt = parsed_opt; 573 osb->s_mount_opt = parsed_opt;
550 574
551 sb->s_magic = OCFS2_SUPER_MAGIC; 575 sb->s_magic = OCFS2_SUPER_MAGIC;
@@ -588,21 +612,16 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
588 } 612 }
589 613
590 if (!ocfs2_is_hard_readonly(osb)) { 614 if (!ocfs2_is_hard_readonly(osb)) {
591 /* If this isn't a hard readonly mount, then we need
592 * to make sure that heartbeat is in a valid state,
593 * and that we mark ourselves soft readonly is -oro
594 * was specified. */
595 if (!(osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL)) {
596 mlog(ML_ERROR, "No heartbeat for device (%s)\n",
597 sb->s_id);
598 status = -EINVAL;
599 goto read_super_error;
600 }
601
602 if (sb->s_flags & MS_RDONLY) 615 if (sb->s_flags & MS_RDONLY)
603 ocfs2_set_ro_flag(osb, 0); 616 ocfs2_set_ro_flag(osb, 0);
604 } 617 }
605 618
619 status = ocfs2_verify_heartbeat(osb);
620 if (status < 0) {
621 mlog_errno(status);
622 goto read_super_error;
623 }
624
606 osb->osb_debug_root = debugfs_create_dir(osb->uuid_str, 625 osb->osb_debug_root = debugfs_create_dir(osb->uuid_str,
607 ocfs2_debugfs_root); 626 ocfs2_debugfs_root);
608 if (!osb->osb_debug_root) { 627 if (!osb->osb_debug_root) {
@@ -635,9 +654,14 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
635 654
636 ocfs2_complete_mount_recovery(osb); 655 ocfs2_complete_mount_recovery(osb);
637 656
638 printk(KERN_INFO "ocfs2: Mounting device (%s) on (node %d, slot %d) " 657 if (ocfs2_mount_local(osb))
658 snprintf(nodestr, sizeof(nodestr), "local");
659 else
660 snprintf(nodestr, sizeof(nodestr), "%d", osb->node_num);
661
662 printk(KERN_INFO "ocfs2: Mounting device (%s) on (node %s, slot %d) "
639 "with %s data mode.\n", 663 "with %s data mode.\n",
640 osb->dev_str, osb->node_num, osb->slot_num, 664 osb->dev_str, nodestr, osb->slot_num,
641 osb->s_mount_opt & OCFS2_MOUNT_DATA_WRITEBACK ? "writeback" : 665 osb->s_mount_opt & OCFS2_MOUNT_DATA_WRITEBACK ? "writeback" :
642 "ordered"); 666 "ordered");
643 667
@@ -999,7 +1023,11 @@ static int ocfs2_fill_local_node_info(struct ocfs2_super *osb)
999 1023
1000 /* XXX hold a ref on the node while mounte? easy enough, if 1024 /* XXX hold a ref on the node while mounte? easy enough, if
1001 * desirable. */ 1025 * desirable. */
1002 osb->node_num = o2nm_this_node(); 1026 if (ocfs2_mount_local(osb))
1027 osb->node_num = 0;
1028 else
1029 osb->node_num = o2nm_this_node();
1030
1003 if (osb->node_num == O2NM_MAX_NODES) { 1031 if (osb->node_num == O2NM_MAX_NODES) {
1004 mlog(ML_ERROR, "could not find this host's node number\n"); 1032 mlog(ML_ERROR, "could not find this host's node number\n");
1005 status = -ENOENT; 1033 status = -ENOENT;
@@ -1084,6 +1112,9 @@ static int ocfs2_mount_volume(struct super_block *sb)
1084 goto leave; 1112 goto leave;
1085 } 1113 }
1086 1114
1115 if (ocfs2_mount_local(osb))
1116 goto leave;
1117
1087 /* This should be sent *after* we recovered our journal as it 1118 /* This should be sent *after* we recovered our journal as it
1088 * will cause other nodes to unmark us as needing 1119 * will cause other nodes to unmark us as needing
1089 * recovery. However, we need to send it *before* dropping the 1120 * recovery. However, we need to send it *before* dropping the
@@ -1114,6 +1145,7 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err)
1114{ 1145{
1115 int tmp; 1146 int tmp;
1116 struct ocfs2_super *osb = NULL; 1147 struct ocfs2_super *osb = NULL;
1148 char nodestr[8];
1117 1149
1118 mlog_entry("(0x%p)\n", sb); 1150 mlog_entry("(0x%p)\n", sb);
1119 1151
@@ -1177,8 +1209,13 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err)
1177 1209
1178 atomic_set(&osb->vol_state, VOLUME_DISMOUNTED); 1210 atomic_set(&osb->vol_state, VOLUME_DISMOUNTED);
1179 1211
1180 printk(KERN_INFO "ocfs2: Unmounting device (%s) on (node %d)\n", 1212 if (ocfs2_mount_local(osb))
1181 osb->dev_str, osb->node_num); 1213 snprintf(nodestr, sizeof(nodestr), "local");
1214 else
1215 snprintf(nodestr, sizeof(nodestr), "%d", osb->node_num);
1216
1217 printk(KERN_INFO "ocfs2: Unmounting device (%s) on (node %s)\n",
1218 osb->dev_str, nodestr);
1182 1219
1183 ocfs2_delete_osb(osb); 1220 ocfs2_delete_osb(osb);
1184 kfree(osb); 1221 kfree(osb);
@@ -1536,6 +1573,7 @@ static int ocfs2_check_volume(struct ocfs2_super *osb)
1536{ 1573{
1537 int status = 0; 1574 int status = 0;
1538 int dirty; 1575 int dirty;
1576 int local;
1539 struct ocfs2_dinode *local_alloc = NULL; /* only used if we 1577 struct ocfs2_dinode *local_alloc = NULL; /* only used if we
1540 * recover 1578 * recover
1541 * ourselves. */ 1579 * ourselves. */
@@ -1563,8 +1601,10 @@ static int ocfs2_check_volume(struct ocfs2_super *osb)
1563 "recovering volume.\n"); 1601 "recovering volume.\n");
1564 } 1602 }
1565 1603
1604 local = ocfs2_mount_local(osb);
1605
1566 /* will play back anything left in the journal. */ 1606 /* will play back anything left in the journal. */
1567 ocfs2_journal_load(osb->journal); 1607 ocfs2_journal_load(osb->journal, local);
1568 1608
1569 if (dirty) { 1609 if (dirty) {
1570 /* recover my local alloc if we didn't unmount cleanly. */ 1610 /* recover my local alloc if we didn't unmount cleanly. */
diff --git a/fs/ocfs2/vote.c b/fs/ocfs2/vote.c
index 5b4dca79990b..0315a8b61ed6 100644
--- a/fs/ocfs2/vote.c
+++ b/fs/ocfs2/vote.c
@@ -1000,6 +1000,9 @@ int ocfs2_register_net_handlers(struct ocfs2_super *osb)
1000{ 1000{
1001 int status = 0; 1001 int status = 0;
1002 1002
1003 if (ocfs2_mount_local(osb))
1004 return 0;
1005
1003 status = o2net_register_handler(OCFS2_MESSAGE_TYPE_RESPONSE, 1006 status = o2net_register_handler(OCFS2_MESSAGE_TYPE_RESPONSE,
1004 osb->net_key, 1007 osb->net_key,
1005 sizeof(struct ocfs2_response_msg), 1008 sizeof(struct ocfs2_response_msg),
diff --git a/include/asm-arm/arch-pnx4008/i2c.h b/include/asm-arm/arch-pnx4008/i2c.h
new file mode 100644
index 000000000000..92e8d65006f7
--- /dev/null
+++ b/include/asm-arm/arch-pnx4008/i2c.h
@@ -0,0 +1,67 @@
1/*
2 * PNX4008-specific tweaks for I2C IP3204 block
3 *
4 * Author: Vitaly Wool <vwool@ru.mvista.com>
5 *
6 * 2005 (c) MontaVista Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 */
11
12#ifndef __ASM_ARCH_I2C_H__
13#define __ASM_ARCH_I2C_H__
14
15#include <linux/pm.h>
16#include <linux/platform_device.h>
17
18enum {
19 mstatus_tdi = 0x00000001,
20 mstatus_afi = 0x00000002,
21 mstatus_nai = 0x00000004,
22 mstatus_drmi = 0x00000008,
23 mstatus_active = 0x00000020,
24 mstatus_scl = 0x00000040,
25 mstatus_sda = 0x00000080,
26 mstatus_rff = 0x00000100,
27 mstatus_rfe = 0x00000200,
28 mstatus_tff = 0x00000400,
29 mstatus_tfe = 0x00000800,
30};
31
32enum {
33 mcntrl_tdie = 0x00000001,
34 mcntrl_afie = 0x00000002,
35 mcntrl_naie = 0x00000004,
36 mcntrl_drmie = 0x00000008,
37 mcntrl_daie = 0x00000020,
38 mcntrl_rffie = 0x00000040,
39 mcntrl_tffie = 0x00000080,
40 mcntrl_reset = 0x00000100,
41 mcntrl_cdbmode = 0x00000400,
42};
43
44enum {
45 rw_bit = 1 << 0,
46 start_bit = 1 << 8,
47 stop_bit = 1 << 9,
48};
49
50#define I2C_REG_RX(a) ((a)->ioaddr) /* Rx FIFO reg (RO) */
51#define I2C_REG_TX(a) ((a)->ioaddr) /* Tx FIFO reg (WO) */
52#define I2C_REG_STS(a) ((a)->ioaddr + 0x04) /* Status reg (RO) */
53#define I2C_REG_CTL(a) ((a)->ioaddr + 0x08) /* Ctl reg */
54#define I2C_REG_CKL(a) ((a)->ioaddr + 0x0c) /* Clock divider low */
55#define I2C_REG_CKH(a) ((a)->ioaddr + 0x10) /* Clock divider high */
56#define I2C_REG_ADR(a) ((a)->ioaddr + 0x14) /* I2C address */
57#define I2C_REG_RFL(a) ((a)->ioaddr + 0x18) /* Rx FIFO level (RO) */
58#define I2C_REG_TFL(a) ((a)->ioaddr + 0x1c) /* Tx FIFO level (RO) */
59#define I2C_REG_RXB(a) ((a)->ioaddr + 0x20) /* Num of bytes Rx-ed (RO) */
60#define I2C_REG_TXB(a) ((a)->ioaddr + 0x24) /* Num of bytes Tx-ed (RO) */
61#define I2C_REG_TXS(a) ((a)->ioaddr + 0x28) /* Tx slave FIFO (RO) */
62#define I2C_REG_STFL(a) ((a)->ioaddr + 0x2c) /* Tx slave FIFO level (RO) */
63
64#define HCLK_MHZ 13
65#define I2C_CHIP_NAME "PNX4008-I2C"
66
67#endif /* __ASM_ARCH_I2C_H___ */
diff --git a/include/asm-i386/msr.h b/include/asm-i386/msr.h
index 5679d4993072..609a3899475c 100644
--- a/include/asm-i386/msr.h
+++ b/include/asm-i386/msr.h
@@ -100,6 +100,8 @@ static inline void wrmsrl (unsigned long msr, unsigned long long val)
100 100
101#define MSR_P6_PERFCTR0 0xc1 101#define MSR_P6_PERFCTR0 0xc1
102#define MSR_P6_PERFCTR1 0xc2 102#define MSR_P6_PERFCTR1 0xc2
103#define MSR_FSB_FREQ 0xcd
104
103 105
104#define MSR_IA32_BBL_CR_CTL 0x119 106#define MSR_IA32_BBL_CR_CTL 0x119
105 107
@@ -130,6 +132,9 @@ static inline void wrmsrl (unsigned long msr, unsigned long long val)
130#define MSR_IA32_PERF_STATUS 0x198 132#define MSR_IA32_PERF_STATUS 0x198
131#define MSR_IA32_PERF_CTL 0x199 133#define MSR_IA32_PERF_CTL 0x199
132 134
135#define MSR_IA32_MPERF 0xE7
136#define MSR_IA32_APERF 0xE8
137
133#define MSR_IA32_THERM_CONTROL 0x19a 138#define MSR_IA32_THERM_CONTROL 0x19a
134#define MSR_IA32_THERM_INTERRUPT 0x19b 139#define MSR_IA32_THERM_INTERRUPT 0x19b
135#define MSR_IA32_THERM_STATUS 0x19c 140#define MSR_IA32_THERM_STATUS 0x19c
diff --git a/include/asm-x86_64/msr.h b/include/asm-x86_64/msr.h
index 952783d35c7b..3227bc93d69b 100644
--- a/include/asm-x86_64/msr.h
+++ b/include/asm-x86_64/msr.h
@@ -189,6 +189,7 @@ static inline unsigned int cpuid_edx(unsigned int op)
189 189
190#define MSR_IA32_PERFCTR0 0xc1 190#define MSR_IA32_PERFCTR0 0xc1
191#define MSR_IA32_PERFCTR1 0xc2 191#define MSR_IA32_PERFCTR1 0xc2
192#define MSR_FSB_FREQ 0xcd
192 193
193#define MSR_MTRRcap 0x0fe 194#define MSR_MTRRcap 0x0fe
194#define MSR_IA32_BBL_CR_CTL 0x119 195#define MSR_IA32_BBL_CR_CTL 0x119
@@ -311,6 +312,9 @@ static inline unsigned int cpuid_edx(unsigned int op)
311#define MSR_IA32_PERF_STATUS 0x198 312#define MSR_IA32_PERF_STATUS 0x198
312#define MSR_IA32_PERF_CTL 0x199 313#define MSR_IA32_PERF_CTL 0x199
313 314
315#define MSR_IA32_MPERF 0xE7
316#define MSR_IA32_APERF 0xE8
317
314#define MSR_IA32_THERM_CONTROL 0x19a 318#define MSR_IA32_THERM_CONTROL 0x19a
315#define MSR_IA32_THERM_INTERRUPT 0x19b 319#define MSR_IA32_THERM_INTERRUPT 0x19b
316#define MSR_IA32_THERM_STATUS 0x19c 320#define MSR_IA32_THERM_STATUS 0x19c
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 538423d4a865..aca66984aafd 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -40,7 +40,7 @@ extern void __chk_io_ptr(void __iomem *);
40#error no compiler-gcc.h file for this gcc version 40#error no compiler-gcc.h file for this gcc version
41#elif __GNUC__ == 4 41#elif __GNUC__ == 4
42# include <linux/compiler-gcc4.h> 42# include <linux/compiler-gcc4.h>
43#elif __GNUC__ == 3 43#elif __GNUC__ == 3 && __GNUC_MINOR__ >= 2
44# include <linux/compiler-gcc3.h> 44# include <linux/compiler-gcc3.h>
45#else 45#else
46# error Sorry, your compiler is too old/not recognized. 46# error Sorry, your compiler is too old/not recognized.
diff --git a/include/linux/configfs.h b/include/linux/configfs.h
index a7f015027535..fef6f3d0a4a7 100644
--- a/include/linux/configfs.h
+++ b/include/linux/configfs.h
@@ -160,31 +160,6 @@ struct configfs_group_operations {
160 void (*drop_item)(struct config_group *group, struct config_item *item); 160 void (*drop_item)(struct config_group *group, struct config_item *item);
161}; 161};
162 162
163
164
165/**
166 * Use these macros to make defining attributes easier. See include/linux/device.h
167 * for examples..
168 */
169
170#if 0
171#define __ATTR(_name,_mode,_show,_store) { \
172 .attr = {.ca_name = __stringify(_name), .ca_mode = _mode, .ca_owner = THIS_MODULE }, \
173 .show = _show, \
174 .store = _store, \
175}
176
177#define __ATTR_RO(_name) { \
178 .attr = { .ca_name = __stringify(_name), .ca_mode = 0444, .ca_owner = THIS_MODULE }, \
179 .show = _name##_show, \
180}
181
182#define __ATTR_NULL { .attr = { .name = NULL } }
183
184#define attr_name(_attr) (_attr).attr.name
185#endif
186
187
188struct configfs_subsystem { 163struct configfs_subsystem {
189 struct config_group su_group; 164 struct config_group su_group;
190 struct semaphore su_sem; 165 struct semaphore su_sem;
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 4ea39fee99c7..7f008f6bfdc3 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -172,6 +172,8 @@ extern int __cpufreq_driver_target(struct cpufreq_policy *policy,
172 unsigned int relation); 172 unsigned int relation);
173 173
174 174
175extern int cpufreq_driver_getavg(struct cpufreq_policy *policy);
176
175int cpufreq_register_governor(struct cpufreq_governor *governor); 177int cpufreq_register_governor(struct cpufreq_governor *governor);
176void cpufreq_unregister_governor(struct cpufreq_governor *governor); 178void cpufreq_unregister_governor(struct cpufreq_governor *governor);
177 179
@@ -204,6 +206,7 @@ struct cpufreq_driver {
204 unsigned int (*get) (unsigned int cpu); 206 unsigned int (*get) (unsigned int cpu);
205 207
206 /* optional */ 208 /* optional */
209 unsigned int (*getavg) (unsigned int cpu);
207 int (*exit) (struct cpufreq_policy *policy); 210 int (*exit) (struct cpufreq_policy *policy);
208 int (*suspend) (struct cpufreq_policy *policy, pm_message_t pmsg); 211 int (*suspend) (struct cpufreq_policy *policy, pm_message_t pmsg);
209 int (*resume) (struct cpufreq_policy *policy); 212 int (*resume) (struct cpufreq_policy *policy);
diff --git a/include/linux/i2c-algo-bit.h b/include/linux/i2c-algo-bit.h
index c8f8df25c7e0..937da70cb4c4 100644
--- a/include/linux/i2c-algo-bit.h
+++ b/include/linux/i2c-algo-bit.h
@@ -26,9 +26,9 @@
26 26
27/* --- Defines for bit-adapters --------------------------------------- */ 27/* --- Defines for bit-adapters --------------------------------------- */
28/* 28/*
29 * This struct contains the hw-dependent functions of bit-style adapters to 29 * This struct contains the hw-dependent functions of bit-style adapters to
30 * manipulate the line states, and to init any hw-specific features. This is 30 * manipulate the line states, and to init any hw-specific features. This is
31 * only used if you have more than one hw-type of adapter running. 31 * only used if you have more than one hw-type of adapter running.
32 */ 32 */
33struct i2c_algo_bit_data { 33struct i2c_algo_bit_data {
34 void *data; /* private data for lowlevel routines */ 34 void *data; /* private data for lowlevel routines */
@@ -44,6 +44,5 @@ struct i2c_algo_bit_data {
44}; 44};
45 45
46int i2c_bit_add_bus(struct i2c_adapter *); 46int i2c_bit_add_bus(struct i2c_adapter *);
47int i2c_bit_del_bus(struct i2c_adapter *);
48 47
49#endif /* _LINUX_I2C_ALGO_BIT_H */ 48#endif /* _LINUX_I2C_ALGO_BIT_H */
diff --git a/include/linux/i2c-algo-ite.h b/include/linux/i2c-algo-ite.h
deleted file mode 100644
index 0073fe96c76e..000000000000
--- a/include/linux/i2c-algo-ite.h
+++ /dev/null
@@ -1,72 +0,0 @@
1/* ------------------------------------------------------------------------- */
2/* i2c-algo-ite.h i2c driver algorithms for ITE IIC adapters */
3/* ------------------------------------------------------------------------- */
4/* Copyright (C) 1995-97 Simon G. Vogl
5 1998-99 Hans Berglund
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20/* ------------------------------------------------------------------------- */
21
22/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
23 Frodo Looijaard <frodol@dds.nl> */
24
25/* Modifications by MontaVista Software, 2001
26 Changes made to support the ITE IIC peripheral */
27
28
29#ifndef I2C_ALGO_ITE_H
30#define I2C_ALGO_ITE_H 1
31
32#include <linux/types.h>
33
34/* Example of a sequential read request:
35 struct i2c_iic_msg s_msg;
36
37 s_msg.addr=device_address;
38 s_msg.len=length;
39 s_msg.buf=buffer;
40 s_msg.waddr=word_address;
41 ioctl(file,I2C_SREAD, &s_msg);
42 */
43#define I2C_SREAD 0x780 /* SREAD ioctl command */
44
45struct i2c_iic_msg {
46 __u16 addr; /* device address */
47 __u16 waddr; /* word address */
48 short len; /* msg length */
49 char *buf; /* pointer to msg data */
50};
51
52#ifdef __KERNEL__
53struct i2c_adapter;
54
55struct i2c_algo_iic_data {
56 void *data; /* private data for lolevel routines */
57 void (*setiic) (void *data, int ctl, int val);
58 int (*getiic) (void *data, int ctl);
59 int (*getown) (void *data);
60 int (*getclock) (void *data);
61 void (*waitforpin) (void);
62
63 /* local settings */
64 int udelay;
65 int mdelay;
66 int timeout;
67};
68
69int i2c_iic_add_bus(struct i2c_adapter *);
70int i2c_iic_del_bus(struct i2c_adapter *);
71#endif /* __KERNEL__ */
72#endif /* I2C_ALGO_ITE_H */
diff --git a/include/linux/i2c-algo-pca.h b/include/linux/i2c-algo-pca.h
index 226693e0d88b..fce47c051bb1 100644
--- a/include/linux/i2c-algo-pca.h
+++ b/include/linux/i2c-algo-pca.h
@@ -10,6 +10,5 @@ struct i2c_algo_pca_data {
10}; 10};
11 11
12int i2c_pca_add_bus(struct i2c_adapter *); 12int i2c_pca_add_bus(struct i2c_adapter *);
13int i2c_pca_del_bus(struct i2c_adapter *);
14 13
15#endif /* _LINUX_I2C_ALGO_PCA_H */ 14#endif /* _LINUX_I2C_ALGO_PCA_H */
diff --git a/include/linux/i2c-algo-pcf.h b/include/linux/i2c-algo-pcf.h
index 9908f3fc4839..994eb86f882c 100644
--- a/include/linux/i2c-algo-pcf.h
+++ b/include/linux/i2c-algo-pcf.h
@@ -31,7 +31,7 @@ struct i2c_algo_pcf_data {
31 int (*getpcf) (void *data, int ctl); 31 int (*getpcf) (void *data, int ctl);
32 int (*getown) (void *data); 32 int (*getown) (void *data);
33 int (*getclock) (void *data); 33 int (*getclock) (void *data);
34 void (*waitforpin) (void); 34 void (*waitforpin) (void);
35 35
36 /* local settings */ 36 /* local settings */
37 int udelay; 37 int udelay;
@@ -39,6 +39,5 @@ struct i2c_algo_pcf_data {
39}; 39};
40 40
41int i2c_pcf_add_bus(struct i2c_adapter *); 41int i2c_pcf_add_bus(struct i2c_adapter *);
42int i2c_pcf_del_bus(struct i2c_adapter *);
43 42
44#endif /* _LINUX_I2C_ALGO_PCF_H */ 43#endif /* _LINUX_I2C_ALGO_PCF_H */
diff --git a/include/linux/i2c-algo-sgi.h b/include/linux/i2c-algo-sgi.h
index 4a0113d64064..3b7715024e69 100644
--- a/include/linux/i2c-algo-sgi.h
+++ b/include/linux/i2c-algo-sgi.h
@@ -22,6 +22,5 @@ struct i2c_algo_sgi_data {
22}; 22};
23 23
24int i2c_sgi_add_bus(struct i2c_adapter *); 24int i2c_sgi_add_bus(struct i2c_adapter *);
25int i2c_sgi_del_bus(struct i2c_adapter *);
26 25
27#endif /* I2C_ALGO_SGI_H */ 26#endif /* I2C_ALGO_SGI_H */
diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h
index 0f4cf34b6fa2..7ae3c3326643 100644
--- a/include/linux/i2c-id.h
+++ b/include/linux/i2c-id.h
@@ -1,7 +1,7 @@
1/* ------------------------------------------------------------------------- */ 1/* ------------------------------------------------------------------------- */
2/* */ 2/* */
3/* i2c-id.h - identifier values for i2c drivers and adapters */ 3/* i2c-id.h - identifier values for i2c drivers and adapters */
4/* */ 4/* */
5/* ------------------------------------------------------------------------- */ 5/* ------------------------------------------------------------------------- */
6/* Copyright (C) 1995-1999 Simon G. Vogl 6/* Copyright (C) 1995-1999 Simon G. Vogl
7 7
@@ -40,10 +40,10 @@
40#define I2C_DRIVERID_SAA7120 11 /* video encoder */ 40#define I2C_DRIVERID_SAA7120 11 /* video encoder */
41#define I2C_DRIVERID_SAA7121 12 /* video encoder */ 41#define I2C_DRIVERID_SAA7121 12 /* video encoder */
42#define I2C_DRIVERID_SAA7185B 13 /* video encoder */ 42#define I2C_DRIVERID_SAA7185B 13 /* video encoder */
43#define I2C_DRIVERID_CH7003 14 /* digital pc to tv encoder */ 43#define I2C_DRIVERID_CH7003 14 /* digital pc to tv encoder */
44#define I2C_DRIVERID_PCF8574A 15 /* i2c expander - 8 bit in/out */ 44#define I2C_DRIVERID_PCF8574A 15 /* i2c expander - 8 bit in/out */
45#define I2C_DRIVERID_PCF8582C 16 /* eeprom */ 45#define I2C_DRIVERID_PCF8582C 16 /* eeprom */
46#define I2C_DRIVERID_AT24Cxx 17 /* eeprom 1/2/4/8/16 K */ 46#define I2C_DRIVERID_AT24Cxx 17 /* eeprom 1/2/4/8/16 K */
47#define I2C_DRIVERID_TEA6300 18 /* audio mixer */ 47#define I2C_DRIVERID_TEA6300 18 /* audio mixer */
48#define I2C_DRIVERID_BT829 19 /* pc to tv encoder */ 48#define I2C_DRIVERID_BT829 19 /* pc to tv encoder */
49#define I2C_DRIVERID_TDA9850 20 /* audio mixer */ 49#define I2C_DRIVERID_TDA9850 20 /* audio mixer */
@@ -82,9 +82,8 @@
82#define I2C_DRIVERID_STM41T00 52 /* real time clock */ 82#define I2C_DRIVERID_STM41T00 52 /* real time clock */
83#define I2C_DRIVERID_UDA1342 53 /* UDA1342 audio codec */ 83#define I2C_DRIVERID_UDA1342 53 /* UDA1342 audio codec */
84#define I2C_DRIVERID_ADV7170 54 /* video encoder */ 84#define I2C_DRIVERID_ADV7170 54 /* video encoder */
85#define I2C_DRIVERID_RADEON 55 /* I2C bus on Radeon boards */
86#define I2C_DRIVERID_MAX1617 56 /* temp sensor */ 85#define I2C_DRIVERID_MAX1617 56 /* temp sensor */
87#define I2C_DRIVERID_SAA7191 57 /* video encoder */ 86#define I2C_DRIVERID_SAA7191 57 /* video decoder */
88#define I2C_DRIVERID_INDYCAM 58 /* SGI IndyCam */ 87#define I2C_DRIVERID_INDYCAM 58 /* SGI IndyCam */
89#define I2C_DRIVERID_BT832 59 /* CMOS camera video processor */ 88#define I2C_DRIVERID_BT832 59 /* CMOS camera video processor */
90#define I2C_DRIVERID_TDA9887 60 /* TDA988x IF-PLL demodulator */ 89#define I2C_DRIVERID_TDA9887 60 /* TDA988x IF-PLL demodulator */
@@ -132,7 +131,6 @@
132#define I2C_DRIVERID_ADM1021 1008 131#define I2C_DRIVERID_ADM1021 1008
133#define I2C_DRIVERID_ADM9240 1009 132#define I2C_DRIVERID_ADM9240 1009
134#define I2C_DRIVERID_LTC1710 1010 133#define I2C_DRIVERID_LTC1710 1010
135#define I2C_DRIVERID_ICSPLL 1012
136#define I2C_DRIVERID_BT869 1013 134#define I2C_DRIVERID_BT869 1013
137#define I2C_DRIVERID_MAXILIFE 1014 135#define I2C_DRIVERID_MAXILIFE 1014
138#define I2C_DRIVERID_MATORB 1015 136#define I2C_DRIVERID_MATORB 1015
@@ -165,7 +163,7 @@
165 * ---- Adapter types ---------------------------------------------------- 163 * ---- Adapter types ----------------------------------------------------
166 */ 164 */
167 165
168/* --- Bit algorithm adapters */ 166/* --- Bit algorithm adapters */
169#define I2C_HW_B_LP 0x010000 /* Parallel port Philips style */ 167#define I2C_HW_B_LP 0x010000 /* Parallel port Philips style */
170#define I2C_HW_B_SER 0x010002 /* Serial line interface */ 168#define I2C_HW_B_SER 0x010002 /* Serial line interface */
171#define I2C_HW_B_BT848 0x010005 /* BT848 video boards */ 169#define I2C_HW_B_BT848 0x010005 /* BT848 video boards */
@@ -213,9 +211,6 @@
213/* --- MPC8xx PowerPC adapters */ 211/* --- MPC8xx PowerPC adapters */
214#define I2C_HW_MPC8XX_EPON 0x110000 /* Eponymous MPC8xx I2C adapter */ 212#define I2C_HW_MPC8XX_EPON 0x110000 /* Eponymous MPC8xx I2C adapter */
215 213
216/* --- ITE based algorithms */
217#define I2C_HW_I_IIC 0x080000 /* controller on the ITE */
218
219/* --- PowerPC on-chip adapters */ 214/* --- PowerPC on-chip adapters */
220#define I2C_HW_OCP 0x120000 /* IBM on-chip I2C adapter */ 215#define I2C_HW_OCP 0x120000 /* IBM on-chip I2C adapter */
221 216
diff --git a/include/linux/i2c-pnx.h b/include/linux/i2c-pnx.h
new file mode 100644
index 000000000000..e6e9c814da61
--- /dev/null
+++ b/include/linux/i2c-pnx.h
@@ -0,0 +1,43 @@
1/*
2 * Header file for I2C support on PNX010x/4008.
3 *
4 * Author: Dennis Kovalev <dkovalev@ru.mvista.com>
5 *
6 * 2004-2006 (c) MontaVista Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 */
11
12#ifndef __I2C_PNX_H__
13#define __I2C_PNX_H__
14
15#include <asm/arch/i2c.h>
16
17struct i2c_pnx_mif {
18 int ret; /* Return value */
19 int mode; /* Interface mode */
20 struct completion complete; /* I/O completion */
21 struct timer_list timer; /* Timeout */
22 char * buf; /* Data buffer */
23 int len; /* Length of data buffer */
24};
25
26struct i2c_pnx_algo_data {
27 u32 base;
28 u32 ioaddr;
29 int irq;
30 struct i2c_pnx_mif mif;
31 int last;
32};
33
34struct i2c_pnx_data {
35 int (*suspend) (struct platform_device *pdev, pm_message_t state);
36 int (*resume) (struct platform_device *pdev);
37 u32 (*calculate_input_freq) (struct platform_device *pdev);
38 int (*set_clock_run) (struct platform_device *pdev);
39 int (*set_clock_stop) (struct platform_device *pdev);
40 struct i2c_adapter *adapter;
41};
42
43#endif /* __I2C_PNX_H__ */
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 9b5d04768c2c..71e50d3e492f 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -1,7 +1,7 @@
1/* ------------------------------------------------------------------------- */ 1/* ------------------------------------------------------------------------- */
2/* */ 2/* */
3/* i2c.h - definitions for the i2c-bus interface */ 3/* i2c.h - definitions for the i2c-bus interface */
4/* */ 4/* */
5/* ------------------------------------------------------------------------- */ 5/* ------------------------------------------------------------------------- */
6/* Copyright (C) 1995-2000 Simon G. Vogl 6/* Copyright (C) 1995-2000 Simon G. Vogl
7 7
@@ -27,7 +27,7 @@
27#define _LINUX_I2C_H 27#define _LINUX_I2C_H
28 28
29#include <linux/types.h> 29#include <linux/types.h>
30#ifdef __KERNEL__ 30#ifdef __KERNEL__
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/i2c-id.h> 32#include <linux/i2c-id.h>
33#include <linux/mod_devicetable.h> 33#include <linux/mod_devicetable.h>
@@ -53,8 +53,8 @@ union i2c_smbus_data;
53 53
54/* 54/*
55 * The master routines are the ones normally used to transmit data to devices 55 * The master routines are the ones normally used to transmit data to devices
56 * on a bus (or read from them). Apart from two basic transfer functions to 56 * on a bus (or read from them). Apart from two basic transfer functions to
57 * transmit one message at a time, a more complex version can be used to 57 * transmit one message at a time, a more complex version can be used to
58 * transmit an arbitrary number of messages without interruption. 58 * transmit an arbitrary number of messages without interruption.
59 */ 59 */
60extern int i2c_master_send(struct i2c_client *,const char* ,int); 60extern int i2c_master_send(struct i2c_client *,const char* ,int);
@@ -67,10 +67,10 @@ extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
67 67
68/* This is the very generalized SMBus access routine. You probably do not 68/* This is the very generalized SMBus access routine. You probably do not
69 want to use this, though; one of the functions below may be much easier, 69 want to use this, though; one of the functions below may be much easier,
70 and probably just as fast. 70 and probably just as fast.
71 Note that we use i2c_adapter here, because you do not need a specific 71 Note that we use i2c_adapter here, because you do not need a specific
72 smbus adapter to call this function. */ 72 smbus adapter to call this function. */
73extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u16 addr, 73extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u16 addr,
74 unsigned short flags, 74 unsigned short flags,
75 char read_write, u8 command, int size, 75 char read_write, u8 command, int size,
76 union i2c_smbus_data * data); 76 union i2c_smbus_data * data);
@@ -112,14 +112,14 @@ struct i2c_driver {
112 112
113 /* Notifies the driver that a new bus has appeared. This routine 113 /* Notifies the driver that a new bus has appeared. This routine
114 * can be used by the driver to test if the bus meets its conditions 114 * can be used by the driver to test if the bus meets its conditions
115 * & seek for the presence of the chip(s) it supports. If found, it 115 * & seek for the presence of the chip(s) it supports. If found, it
116 * registers the client(s) that are on the bus to the i2c admin. via 116 * registers the client(s) that are on the bus to the i2c admin. via
117 * i2c_attach_client. 117 * i2c_attach_client.
118 */ 118 */
119 int (*attach_adapter)(struct i2c_adapter *); 119 int (*attach_adapter)(struct i2c_adapter *);
120 int (*detach_adapter)(struct i2c_adapter *); 120 int (*detach_adapter)(struct i2c_adapter *);
121 121
122 /* tells the driver that a client is about to be deleted & gives it 122 /* tells the driver that a client is about to be deleted & gives it
123 * the chance to remove its private data. Also, if the client struct 123 * the chance to remove its private data. Also, if the client struct
124 * has been dynamically allocated by the driver in the function above, 124 * has been dynamically allocated by the driver in the function above,
125 * it must be freed here. 125 * it must be freed here.
@@ -139,13 +139,13 @@ struct i2c_driver {
139#define I2C_NAME_SIZE 50 139#define I2C_NAME_SIZE 50
140 140
141/* 141/*
142 * i2c_client identifies a single device (i.e. chip) that is connected to an 142 * i2c_client identifies a single device (i.e. chip) that is connected to an
143 * i2c bus. The behaviour is defined by the routines of the driver. This 143 * i2c bus. The behaviour is defined by the routines of the driver. This
144 * function is mainly used for lookup & other admin. functions. 144 * function is mainly used for lookup & other admin. functions.
145 */ 145 */
146struct i2c_client { 146struct i2c_client {
147 unsigned int flags; /* div., see below */ 147 unsigned int flags; /* div., see below */
148 unsigned short addr; /* chip address - NOTE: 7bit */ 148 unsigned short addr; /* chip address - NOTE: 7bit */
149 /* addresses are stored in the */ 149 /* addresses are stored in the */
150 /* _LOWER_ 7 bits */ 150 /* _LOWER_ 7 bits */
151 struct i2c_adapter *adapter; /* the adapter we sit on */ 151 struct i2c_adapter *adapter; /* the adapter we sit on */
@@ -182,14 +182,14 @@ static inline void i2c_set_clientdata (struct i2c_client *dev, void *data)
182 */ 182 */
183struct i2c_algorithm { 183struct i2c_algorithm {
184 /* If an adapter algorithm can't do I2C-level access, set master_xfer 184 /* If an adapter algorithm can't do I2C-level access, set master_xfer
185 to NULL. If an adapter algorithm can do SMBus access, set 185 to NULL. If an adapter algorithm can do SMBus access, set
186 smbus_xfer. If set to NULL, the SMBus protocol is simulated 186 smbus_xfer. If set to NULL, the SMBus protocol is simulated
187 using common I2C messages */ 187 using common I2C messages */
188 /* master_xfer should return the number of messages successfully 188 /* master_xfer should return the number of messages successfully
189 processed, or a negative value on error */ 189 processed, or a negative value on error */
190 int (*master_xfer)(struct i2c_adapter *adap,struct i2c_msg *msgs, 190 int (*master_xfer)(struct i2c_adapter *adap,struct i2c_msg *msgs,
191 int num); 191 int num);
192 int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr, 192 int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr,
193 unsigned short flags, char read_write, 193 unsigned short flags, char read_write,
194 u8 command, int size, union i2c_smbus_data * data); 194 u8 command, int size, union i2c_smbus_data * data);
195 195
@@ -216,6 +216,7 @@ struct i2c_adapter {
216 int (*client_unregister)(struct i2c_client *); 216 int (*client_unregister)(struct i2c_client *);
217 217
218 /* data fields that are valid for all devices */ 218 /* data fields that are valid for all devices */
219 u8 level; /* nesting level for lockdep */
219 struct mutex bus_lock; 220 struct mutex bus_lock;
220 struct mutex clist_lock; 221 struct mutex clist_lock;
221 222
@@ -316,7 +317,7 @@ extern int i2c_check_addr (struct i2c_adapter *adapter, int addr);
316 * It will only call found_proc if some client is connected at the 317 * It will only call found_proc if some client is connected at the
317 * specific address (unless a 'force' matched); 318 * specific address (unless a 'force' matched);
318 */ 319 */
319extern int i2c_probe(struct i2c_adapter *adapter, 320extern int i2c_probe(struct i2c_adapter *adapter,
320 struct i2c_client_address_data *address_data, 321 struct i2c_client_address_data *address_data,
321 int (*found_proc) (struct i2c_adapter *, int, int)); 322 int (*found_proc) (struct i2c_adapter *, int, int));
322 323
@@ -352,15 +353,15 @@ static inline int i2c_adapter_id(struct i2c_adapter *adap)
352 */ 353 */
353struct i2c_msg { 354struct i2c_msg {
354 __u16 addr; /* slave address */ 355 __u16 addr; /* slave address */
355 __u16 flags; 356 __u16 flags;
356#define I2C_M_TEN 0x10 /* we have a ten bit chip address */ 357#define I2C_M_TEN 0x10 /* we have a ten bit chip address */
357#define I2C_M_RD 0x01 358#define I2C_M_RD 0x01
358#define I2C_M_NOSTART 0x4000 359#define I2C_M_NOSTART 0x4000
359#define I2C_M_REV_DIR_ADDR 0x2000 360#define I2C_M_REV_DIR_ADDR 0x2000
360#define I2C_M_IGNORE_NAK 0x1000 361#define I2C_M_IGNORE_NAK 0x1000
361#define I2C_M_NO_RD_ACK 0x0800 362#define I2C_M_NO_RD_ACK 0x0800
362 __u16 len; /* msg length */ 363 __u16 len; /* msg length */
363 __u8 *buf; /* pointer to msg data */ 364 __u8 *buf; /* pointer to msg data */
364}; 365};
365 366
366/* To determine what functionality is present */ 367/* To determine what functionality is present */
@@ -370,16 +371,16 @@ struct i2c_msg {
370#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */ 371#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */
371#define I2C_FUNC_SMBUS_HWPEC_CALC 0x00000008 /* SMBus 2.0 */ 372#define I2C_FUNC_SMBUS_HWPEC_CALC 0x00000008 /* SMBus 2.0 */
372#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */ 373#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */
373#define I2C_FUNC_SMBUS_QUICK 0x00010000 374#define I2C_FUNC_SMBUS_QUICK 0x00010000
374#define I2C_FUNC_SMBUS_READ_BYTE 0x00020000 375#define I2C_FUNC_SMBUS_READ_BYTE 0x00020000
375#define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000 376#define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000
376#define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000 377#define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000
377#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000 378#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000
378#define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000 379#define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000
379#define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000 380#define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000
380#define I2C_FUNC_SMBUS_PROC_CALL 0x00800000 381#define I2C_FUNC_SMBUS_PROC_CALL 0x00800000
381#define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000 382#define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000
382#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 383#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000
383#define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */ 384#define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */
384#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */ 385#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */
385#define I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 0x10000000 /* I2C-like block xfer */ 386#define I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 0x10000000 /* I2C-like block xfer */
@@ -406,10 +407,10 @@ struct i2c_msg {
406 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \ 407 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \
407 I2C_FUNC_SMBUS_I2C_BLOCK) 408 I2C_FUNC_SMBUS_I2C_BLOCK)
408 409
409/* 410/*
410 * Data for SMBus Messages 411 * Data for SMBus Messages
411 */ 412 */
412#define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */ 413#define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */
413union i2c_smbus_data { 414union i2c_smbus_data {
414 __u8 byte; 415 __u8 byte;
415 __u16 word; 416 __u16 word;
@@ -421,11 +422,11 @@ union i2c_smbus_data {
421#define I2C_SMBUS_READ 1 422#define I2C_SMBUS_READ 1
422#define I2C_SMBUS_WRITE 0 423#define I2C_SMBUS_WRITE 0
423 424
424/* SMBus transaction types (size parameter in the above functions) 425/* SMBus transaction types (size parameter in the above functions)
425 Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */ 426 Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */
426#define I2C_SMBUS_QUICK 0 427#define I2C_SMBUS_QUICK 0
427#define I2C_SMBUS_BYTE 1 428#define I2C_SMBUS_BYTE 1
428#define I2C_SMBUS_BYTE_DATA 2 429#define I2C_SMBUS_BYTE_DATA 2
429#define I2C_SMBUS_WORD_DATA 3 430#define I2C_SMBUS_WORD_DATA 3
430#define I2C_SMBUS_PROC_CALL 4 431#define I2C_SMBUS_PROC_CALL 4
431#define I2C_SMBUS_BLOCK_DATA 5 432#define I2C_SMBUS_BLOCK_DATA 5
@@ -434,15 +435,15 @@ union i2c_smbus_data {
434 435
435 436
436/* ----- commands for the ioctl like i2c_command call: 437/* ----- commands for the ioctl like i2c_command call:
437 * note that additional calls are defined in the algorithm and hw 438 * note that additional calls are defined in the algorithm and hw
438 * dependent layers - these can be listed here, or see the 439 * dependent layers - these can be listed here, or see the
439 * corresponding header files. 440 * corresponding header files.
440 */ 441 */
441 /* -> bit-adapter specific ioctls */ 442 /* -> bit-adapter specific ioctls */
442#define I2C_RETRIES 0x0701 /* number of times a device address */ 443#define I2C_RETRIES 0x0701 /* number of times a device address */
443 /* should be polled when not */ 444 /* should be polled when not */
444 /* acknowledging */ 445 /* acknowledging */
445#define I2C_TIMEOUT 0x0702 /* set timeout - call with int */ 446#define I2C_TIMEOUT 0x0702 /* set timeout - call with int */
446 447
447 448
448/* this is for i2c-dev.c */ 449/* this is for i2c-dev.c */
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 6d8846e7be6d..81480e613467 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -11,7 +11,7 @@
11 ** the sysctl() binary interface. Do *NOT* change the 11 ** the sysctl() binary interface. Do *NOT* change the
12 ** numbering of any existing values here, and do not change 12 ** numbering of any existing values here, and do not change
13 ** any numbers within any one set of values. If you have to 13 ** any numbers within any one set of values. If you have to
14 ** have to redefine an existing interface, use a new number for it. 14 ** redefine an existing interface, use a new number for it.
15 ** The kernel will then return -ENOTDIR to any application using 15 ** The kernel will then return -ENOTDIR to any application using
16 ** the old binary interface. 16 ** the old binary interface.
17 ** 17 **
diff --git a/include/rdma/ib_marshall.h b/include/rdma/ib_marshall.h
index 66bf4d7d0dfb..db037205c9e8 100644
--- a/include/rdma/ib_marshall.h
+++ b/include/rdma/ib_marshall.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005 Intel Corporation. All rights reserved. 2 * Copyright (c) 2005-2006 Intel Corporation. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
@@ -41,6 +41,9 @@
41void ib_copy_qp_attr_to_user(struct ib_uverbs_qp_attr *dst, 41void ib_copy_qp_attr_to_user(struct ib_uverbs_qp_attr *dst,
42 struct ib_qp_attr *src); 42 struct ib_qp_attr *src);
43 43
44void ib_copy_ah_attr_to_user(struct ib_uverbs_ah_attr *dst,
45 struct ib_ah_attr *src);
46
44void ib_copy_path_rec_to_user(struct ib_user_path_rec *dst, 47void ib_copy_path_rec_to_user(struct ib_user_path_rec *dst,
45 struct ib_sa_path_rec *src); 48 struct ib_sa_path_rec *src);
46 49
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 8eacc3510993..fd2353fa7e12 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -43,6 +43,8 @@
43 43
44#include <linux/types.h> 44#include <linux/types.h>
45#include <linux/device.h> 45#include <linux/device.h>
46#include <linux/mm.h>
47#include <linux/dma-mapping.h>
46 48
47#include <asm/atomic.h> 49#include <asm/atomic.h>
48#include <asm/scatterlist.h> 50#include <asm/scatterlist.h>
@@ -848,6 +850,49 @@ struct ib_cache {
848 u8 *lmc_cache; 850 u8 *lmc_cache;
849}; 851};
850 852
853struct ib_dma_mapping_ops {
854 int (*mapping_error)(struct ib_device *dev,
855 u64 dma_addr);
856 u64 (*map_single)(struct ib_device *dev,
857 void *ptr, size_t size,
858 enum dma_data_direction direction);
859 void (*unmap_single)(struct ib_device *dev,
860 u64 addr, size_t size,
861 enum dma_data_direction direction);
862 u64 (*map_page)(struct ib_device *dev,
863 struct page *page, unsigned long offset,
864 size_t size,
865 enum dma_data_direction direction);
866 void (*unmap_page)(struct ib_device *dev,
867 u64 addr, size_t size,
868 enum dma_data_direction direction);
869 int (*map_sg)(struct ib_device *dev,
870 struct scatterlist *sg, int nents,
871 enum dma_data_direction direction);
872 void (*unmap_sg)(struct ib_device *dev,
873 struct scatterlist *sg, int nents,
874 enum dma_data_direction direction);
875 u64 (*dma_address)(struct ib_device *dev,
876 struct scatterlist *sg);
877 unsigned int (*dma_len)(struct ib_device *dev,
878 struct scatterlist *sg);
879 void (*sync_single_for_cpu)(struct ib_device *dev,
880 u64 dma_handle,
881 size_t size,
882 enum dma_data_direction dir);
883 void (*sync_single_for_device)(struct ib_device *dev,
884 u64 dma_handle,
885 size_t size,
886 enum dma_data_direction dir);
887 void *(*alloc_coherent)(struct ib_device *dev,
888 size_t size,
889 u64 *dma_handle,
890 gfp_t flag);
891 void (*free_coherent)(struct ib_device *dev,
892 size_t size, void *cpu_addr,
893 u64 dma_handle);
894};
895
851struct iw_cm_verbs; 896struct iw_cm_verbs;
852 897
853struct ib_device { 898struct ib_device {
@@ -992,6 +1037,8 @@ struct ib_device {
992 struct ib_mad *in_mad, 1037 struct ib_mad *in_mad,
993 struct ib_mad *out_mad); 1038 struct ib_mad *out_mad);
994 1039
1040 struct ib_dma_mapping_ops *dma_ops;
1041
995 struct module *owner; 1042 struct module *owner;
996 struct class_device class_dev; 1043 struct class_device class_dev;
997 struct kobject ports_parent; 1044 struct kobject ports_parent;
@@ -1395,10 +1442,216 @@ static inline int ib_req_ncomp_notif(struct ib_cq *cq, int wc_cnt)
1395 * usable for DMA. 1442 * usable for DMA.
1396 * @pd: The protection domain associated with the memory region. 1443 * @pd: The protection domain associated with the memory region.
1397 * @mr_access_flags: Specifies the memory access rights. 1444 * @mr_access_flags: Specifies the memory access rights.
1445 *
1446 * Note that the ib_dma_*() functions defined below must be used
1447 * to create/destroy addresses used with the Lkey or Rkey returned
1448 * by ib_get_dma_mr().
1398 */ 1449 */
1399struct ib_mr *ib_get_dma_mr(struct ib_pd *pd, int mr_access_flags); 1450struct ib_mr *ib_get_dma_mr(struct ib_pd *pd, int mr_access_flags);
1400 1451
1401/** 1452/**
1453 * ib_dma_mapping_error - check a DMA addr for error
1454 * @dev: The device for which the dma_addr was created
1455 * @dma_addr: The DMA address to check
1456 */
1457static inline int ib_dma_mapping_error(struct ib_device *dev, u64 dma_addr)
1458{
1459 return dev->dma_ops ?
1460 dev->dma_ops->mapping_error(dev, dma_addr) :
1461 dma_mapping_error(dma_addr);
1462}
1463
1464/**
1465 * ib_dma_map_single - Map a kernel virtual address to DMA address
1466 * @dev: The device for which the dma_addr is to be created
1467 * @cpu_addr: The kernel virtual address
1468 * @size: The size of the region in bytes
1469 * @direction: The direction of the DMA
1470 */
1471static inline u64 ib_dma_map_single(struct ib_device *dev,
1472 void *cpu_addr, size_t size,
1473 enum dma_data_direction direction)
1474{
1475 return dev->dma_ops ?
1476 dev->dma_ops->map_single(dev, cpu_addr, size, direction) :
1477 dma_map_single(dev->dma_device, cpu_addr, size, direction);
1478}
1479
1480/**
1481 * ib_dma_unmap_single - Destroy a mapping created by ib_dma_map_single()
1482 * @dev: The device for which the DMA address was created
1483 * @addr: The DMA address
1484 * @size: The size of the region in bytes
1485 * @direction: The direction of the DMA
1486 */
1487static inline void ib_dma_unmap_single(struct ib_device *dev,
1488 u64 addr, size_t size,
1489 enum dma_data_direction direction)
1490{
1491 dev->dma_ops ?
1492 dev->dma_ops->unmap_single(dev, addr, size, direction) :
1493 dma_unmap_single(dev->dma_device, addr, size, direction);
1494}
1495
1496/**
1497 * ib_dma_map_page - Map a physical page to DMA address
1498 * @dev: The device for which the dma_addr is to be created
1499 * @page: The page to be mapped
1500 * @offset: The offset within the page
1501 * @size: The size of the region in bytes
1502 * @direction: The direction of the DMA
1503 */
1504static inline u64 ib_dma_map_page(struct ib_device *dev,
1505 struct page *page,
1506 unsigned long offset,
1507 size_t size,
1508 enum dma_data_direction direction)
1509{
1510 return dev->dma_ops ?
1511 dev->dma_ops->map_page(dev, page, offset, size, direction) :
1512 dma_map_page(dev->dma_device, page, offset, size, direction);
1513}
1514
1515/**
1516 * ib_dma_unmap_page - Destroy a mapping created by ib_dma_map_page()
1517 * @dev: The device for which the DMA address was created
1518 * @addr: The DMA address
1519 * @size: The size of the region in bytes
1520 * @direction: The direction of the DMA
1521 */
1522static inline void ib_dma_unmap_page(struct ib_device *dev,
1523 u64 addr, size_t size,
1524 enum dma_data_direction direction)
1525{
1526 dev->dma_ops ?
1527 dev->dma_ops->unmap_page(dev, addr, size, direction) :
1528 dma_unmap_page(dev->dma_device, addr, size, direction);
1529}
1530
1531/**
1532 * ib_dma_map_sg - Map a scatter/gather list to DMA addresses
1533 * @dev: The device for which the DMA addresses are to be created
1534 * @sg: The array of scatter/gather entries
1535 * @nents: The number of scatter/gather entries
1536 * @direction: The direction of the DMA
1537 */
1538static inline int ib_dma_map_sg(struct ib_device *dev,
1539 struct scatterlist *sg, int nents,
1540 enum dma_data_direction direction)
1541{
1542 return dev->dma_ops ?
1543 dev->dma_ops->map_sg(dev, sg, nents, direction) :
1544 dma_map_sg(dev->dma_device, sg, nents, direction);
1545}
1546
1547/**
1548 * ib_dma_unmap_sg - Unmap a scatter/gather list of DMA addresses
1549 * @dev: The device for which the DMA addresses were created
1550 * @sg: The array of scatter/gather entries
1551 * @nents: The number of scatter/gather entries
1552 * @direction: The direction of the DMA
1553 */
1554static inline void ib_dma_unmap_sg(struct ib_device *dev,
1555 struct scatterlist *sg, int nents,
1556 enum dma_data_direction direction)
1557{
1558 dev->dma_ops ?
1559 dev->dma_ops->unmap_sg(dev, sg, nents, direction) :
1560 dma_unmap_sg(dev->dma_device, sg, nents, direction);
1561}
1562
1563/**
1564 * ib_sg_dma_address - Return the DMA address from a scatter/gather entry
1565 * @dev: The device for which the DMA addresses were created
1566 * @sg: The scatter/gather entry
1567 */
1568static inline u64 ib_sg_dma_address(struct ib_device *dev,
1569 struct scatterlist *sg)
1570{
1571 return dev->dma_ops ?
1572 dev->dma_ops->dma_address(dev, sg) : sg_dma_address(sg);
1573}
1574
1575/**
1576 * ib_sg_dma_len - Return the DMA length from a scatter/gather entry
1577 * @dev: The device for which the DMA addresses were created
1578 * @sg: The scatter/gather entry
1579 */
1580static inline unsigned int ib_sg_dma_len(struct ib_device *dev,
1581 struct scatterlist *sg)
1582{
1583 return dev->dma_ops ?
1584 dev->dma_ops->dma_len(dev, sg) : sg_dma_len(sg);
1585}
1586
1587/**
1588 * ib_dma_sync_single_for_cpu - Prepare DMA region to be accessed by CPU
1589 * @dev: The device for which the DMA address was created
1590 * @addr: The DMA address
1591 * @size: The size of the region in bytes
1592 * @dir: The direction of the DMA
1593 */
1594static inline void ib_dma_sync_single_for_cpu(struct ib_device *dev,
1595 u64 addr,
1596 size_t size,
1597 enum dma_data_direction dir)
1598{
1599 dev->dma_ops ?
1600 dev->dma_ops->sync_single_for_cpu(dev, addr, size, dir) :
1601 dma_sync_single_for_cpu(dev->dma_device, addr, size, dir);
1602}
1603
1604/**
1605 * ib_dma_sync_single_for_device - Prepare DMA region to be accessed by device
1606 * @dev: The device for which the DMA address was created
1607 * @addr: The DMA address
1608 * @size: The size of the region in bytes
1609 * @dir: The direction of the DMA
1610 */
1611static inline void ib_dma_sync_single_for_device(struct ib_device *dev,
1612 u64 addr,
1613 size_t size,
1614 enum dma_data_direction dir)
1615{
1616 dev->dma_ops ?
1617 dev->dma_ops->sync_single_for_device(dev, addr, size, dir) :
1618 dma_sync_single_for_device(dev->dma_device, addr, size, dir);
1619}
1620
1621/**
1622 * ib_dma_alloc_coherent - Allocate memory and map it for DMA
1623 * @dev: The device for which the DMA address is requested
1624 * @size: The size of the region to allocate in bytes
1625 * @dma_handle: A pointer for returning the DMA address of the region
1626 * @flag: memory allocator flags
1627 */
1628static inline void *ib_dma_alloc_coherent(struct ib_device *dev,
1629 size_t size,
1630 u64 *dma_handle,
1631 gfp_t flag)
1632{
1633 return dev->dma_ops ?
1634 dev->dma_ops->alloc_coherent(dev, size, dma_handle, flag) :
1635 dma_alloc_coherent(dev->dma_device, size, dma_handle, flag);
1636}
1637
1638/**
1639 * ib_dma_free_coherent - Free memory allocated by ib_dma_alloc_coherent()
1640 * @dev: The device for which the DMA addresses were allocated
1641 * @size: The size of the region
1642 * @cpu_addr: the address returned by ib_dma_alloc_coherent()
1643 * @dma_handle: the DMA address returned by ib_dma_alloc_coherent()
1644 */
1645static inline void ib_dma_free_coherent(struct ib_device *dev,
1646 size_t size, void *cpu_addr,
1647 u64 dma_handle)
1648{
1649 dev->dma_ops ?
1650 dev->dma_ops->free_coherent(dev, size, cpu_addr, dma_handle) :
1651 dma_free_coherent(dev->dma_device, size, cpu_addr, dma_handle);
1652}
1653
1654/**
1402 * ib_reg_phys_mr - Prepares a virtually addressed memory region for use 1655 * ib_reg_phys_mr - Prepares a virtually addressed memory region for use
1403 * by an HCA. 1656 * by an HCA.
1404 * @pd: The protection domain associated assigned to the registered region. 1657 * @pd: The protection domain associated assigned to the registered region.
diff --git a/include/rdma/rdma_cm.h b/include/rdma/rdma_cm.h
index deb5a0a4cee5..36cd8a8526a0 100644
--- a/include/rdma/rdma_cm.h
+++ b/include/rdma/rdma_cm.h
@@ -77,11 +77,34 @@ struct rdma_route {
77 int num_paths; 77 int num_paths;
78}; 78};
79 79
80struct rdma_conn_param {
81 const void *private_data;
82 u8 private_data_len;
83 u8 responder_resources;
84 u8 initiator_depth;
85 u8 flow_control;
86 u8 retry_count; /* ignored when accepting */
87 u8 rnr_retry_count;
88 /* Fields below ignored if a QP is created on the rdma_cm_id. */
89 u8 srq;
90 u32 qp_num;
91};
92
93struct rdma_ud_param {
94 const void *private_data;
95 u8 private_data_len;
96 struct ib_ah_attr ah_attr;
97 u32 qp_num;
98 u32 qkey;
99};
100
80struct rdma_cm_event { 101struct rdma_cm_event {
81 enum rdma_cm_event_type event; 102 enum rdma_cm_event_type event;
82 int status; 103 int status;
83 void *private_data; 104 union {
84 u8 private_data_len; 105 struct rdma_conn_param conn;
106 struct rdma_ud_param ud;
107 } param;
85}; 108};
86 109
87struct rdma_cm_id; 110struct rdma_cm_id;
@@ -204,25 +227,17 @@ void rdma_destroy_qp(struct rdma_cm_id *id);
204int rdma_init_qp_attr(struct rdma_cm_id *id, struct ib_qp_attr *qp_attr, 227int rdma_init_qp_attr(struct rdma_cm_id *id, struct ib_qp_attr *qp_attr,
205 int *qp_attr_mask); 228 int *qp_attr_mask);
206 229
207struct rdma_conn_param {
208 const void *private_data;
209 u8 private_data_len;
210 u8 responder_resources;
211 u8 initiator_depth;
212 u8 flow_control;
213 u8 retry_count; /* ignored when accepting */
214 u8 rnr_retry_count;
215 /* Fields below ignored if a QP is created on the rdma_cm_id. */
216 u8 srq;
217 u32 qp_num;
218 enum ib_qp_type qp_type;
219};
220
221/** 230/**
222 * rdma_connect - Initiate an active connection request. 231 * rdma_connect - Initiate an active connection request.
232 * @id: Connection identifier to connect.
233 * @conn_param: Connection information used for connected QPs.
223 * 234 *
224 * Users must have resolved a route for the rdma_cm_id to connect with 235 * Users must have resolved a route for the rdma_cm_id to connect with
225 * by having called rdma_resolve_route before calling this routine. 236 * by having called rdma_resolve_route before calling this routine.
237 *
238 * This call will either connect to a remote QP or obtain remote QP
239 * information for unconnected rdma_cm_id's. The actual operation is
240 * based on the rdma_cm_id's port space.
226 */ 241 */
227int rdma_connect(struct rdma_cm_id *id, struct rdma_conn_param *conn_param); 242int rdma_connect(struct rdma_cm_id *id, struct rdma_conn_param *conn_param);
228 243
@@ -253,6 +268,21 @@ int rdma_listen(struct rdma_cm_id *id, int backlog);
253int rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param); 268int rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param);
254 269
255/** 270/**
271 * rdma_notify - Notifies the RDMA CM of an asynchronous event that has
272 * occurred on the connection.
273 * @id: Connection identifier to transition to established.
274 * @event: Asynchronous event.
275 *
276 * This routine should be invoked by users to notify the CM of relevant
277 * communication events. Events that should be reported to the CM and
278 * when to report them are:
279 *
280 * IB_EVENT_COMM_EST - Used when a message is received on a connected
281 * QP before an RTU has been received.
282 */
283int rdma_notify(struct rdma_cm_id *id, enum ib_event_type event);
284
285/**
256 * rdma_reject - Called to reject a connection request or response. 286 * rdma_reject - Called to reject a connection request or response.
257 */ 287 */
258int rdma_reject(struct rdma_cm_id *id, const void *private_data, 288int rdma_reject(struct rdma_cm_id *id, const void *private_data,
diff --git a/include/rdma/rdma_cm_ib.h b/include/rdma/rdma_cm_ib.h
index e8c3af1804d4..9b176df1d667 100644
--- a/include/rdma/rdma_cm_ib.h
+++ b/include/rdma/rdma_cm_ib.h
@@ -44,4 +44,7 @@
44int rdma_set_ib_paths(struct rdma_cm_id *id, 44int rdma_set_ib_paths(struct rdma_cm_id *id,
45 struct ib_sa_path_rec *path_rec, int num_paths); 45 struct ib_sa_path_rec *path_rec, int num_paths);
46 46
47/* Global qkey for UD QPs and multicast groups. */
48#define RDMA_UD_QKEY 0x01234567
49
47#endif /* RDMA_CM_IB_H */ 50#endif /* RDMA_CM_IB_H */
diff --git a/include/rdma/rdma_user_cm.h b/include/rdma/rdma_user_cm.h
new file mode 100644
index 000000000000..9572ab8eeac1
--- /dev/null
+++ b/include/rdma/rdma_user_cm.h
@@ -0,0 +1,206 @@
1/*
2 * Copyright (c) 2005-2006 Intel Corporation. All rights reserved.
3 *
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
9 *
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
12 * conditions are met:
13 *
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer.
17 *
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE.
31 */
32
33#ifndef RDMA_USER_CM_H
34#define RDMA_USER_CM_H
35
36#include <linux/types.h>
37#include <linux/in6.h>
38#include <rdma/ib_user_verbs.h>
39#include <rdma/ib_user_sa.h>
40
41#define RDMA_USER_CM_ABI_VERSION 3
42
43#define RDMA_MAX_PRIVATE_DATA 256
44
45enum {
46 RDMA_USER_CM_CMD_CREATE_ID,
47 RDMA_USER_CM_CMD_DESTROY_ID,
48 RDMA_USER_CM_CMD_BIND_ADDR,
49 RDMA_USER_CM_CMD_RESOLVE_ADDR,
50 RDMA_USER_CM_CMD_RESOLVE_ROUTE,
51 RDMA_USER_CM_CMD_QUERY_ROUTE,
52 RDMA_USER_CM_CMD_CONNECT,
53 RDMA_USER_CM_CMD_LISTEN,
54 RDMA_USER_CM_CMD_ACCEPT,
55 RDMA_USER_CM_CMD_REJECT,
56 RDMA_USER_CM_CMD_DISCONNECT,
57 RDMA_USER_CM_CMD_INIT_QP_ATTR,
58 RDMA_USER_CM_CMD_GET_EVENT,
59 RDMA_USER_CM_CMD_GET_OPTION,
60 RDMA_USER_CM_CMD_SET_OPTION,
61 RDMA_USER_CM_CMD_NOTIFY
62};
63
64/*
65 * command ABI structures.
66 */
67struct rdma_ucm_cmd_hdr {
68 __u32 cmd;
69 __u16 in;
70 __u16 out;
71};
72
73struct rdma_ucm_create_id {
74 __u64 uid;
75 __u64 response;
76 __u16 ps;
77 __u8 reserved[6];
78};
79
80struct rdma_ucm_create_id_resp {
81 __u32 id;
82};
83
84struct rdma_ucm_destroy_id {
85 __u64 response;
86 __u32 id;
87 __u32 reserved;
88};
89
90struct rdma_ucm_destroy_id_resp {
91 __u32 events_reported;
92};
93
94struct rdma_ucm_bind_addr {
95 __u64 response;
96 struct sockaddr_in6 addr;
97 __u32 id;
98};
99
100struct rdma_ucm_resolve_addr {
101 struct sockaddr_in6 src_addr;
102 struct sockaddr_in6 dst_addr;
103 __u32 id;
104 __u32 timeout_ms;
105};
106
107struct rdma_ucm_resolve_route {
108 __u32 id;
109 __u32 timeout_ms;
110};
111
112struct rdma_ucm_query_route {
113 __u64 response;
114 __u32 id;
115 __u32 reserved;
116};
117
118struct rdma_ucm_query_route_resp {
119 __u64 node_guid;
120 struct ib_user_path_rec ib_route[2];
121 struct sockaddr_in6 src_addr;
122 struct sockaddr_in6 dst_addr;
123 __u32 num_paths;
124 __u8 port_num;
125 __u8 reserved[3];
126};
127
128struct rdma_ucm_conn_param {
129 __u32 qp_num;
130 __u32 reserved;
131 __u8 private_data[RDMA_MAX_PRIVATE_DATA];
132 __u8 private_data_len;
133 __u8 srq;
134 __u8 responder_resources;
135 __u8 initiator_depth;
136 __u8 flow_control;
137 __u8 retry_count;
138 __u8 rnr_retry_count;
139 __u8 valid;
140};
141
142struct rdma_ucm_ud_param {
143 __u32 qp_num;
144 __u32 qkey;
145 struct ib_uverbs_ah_attr ah_attr;
146 __u8 private_data[RDMA_MAX_PRIVATE_DATA];
147 __u8 private_data_len;
148 __u8 reserved[7];
149};
150
151struct rdma_ucm_connect {
152 struct rdma_ucm_conn_param conn_param;
153 __u32 id;
154 __u32 reserved;
155};
156
157struct rdma_ucm_listen {
158 __u32 id;
159 __u32 backlog;
160};
161
162struct rdma_ucm_accept {
163 __u64 uid;
164 struct rdma_ucm_conn_param conn_param;
165 __u32 id;
166 __u32 reserved;
167};
168
169struct rdma_ucm_reject {
170 __u32 id;
171 __u8 private_data_len;
172 __u8 reserved[3];
173 __u8 private_data[RDMA_MAX_PRIVATE_DATA];
174};
175
176struct rdma_ucm_disconnect {
177 __u32 id;
178};
179
180struct rdma_ucm_init_qp_attr {
181 __u64 response;
182 __u32 id;
183 __u32 qp_state;
184};
185
186struct rdma_ucm_notify {
187 __u32 id;
188 __u32 event;
189};
190
191struct rdma_ucm_get_event {
192 __u64 response;
193};
194
195struct rdma_ucm_event_resp {
196 __u64 uid;
197 __u32 id;
198 __u32 event;
199 __u32 status;
200 union {
201 struct rdma_ucm_conn_param conn;
202 struct rdma_ucm_ud_param ud;
203 } param;
204};
205
206#endif /* RDMA_USER_CM_H */
diff --git a/init/Kconfig b/init/Kconfig
index 9edf103b3ec3..f000edb3bb7a 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -348,7 +348,7 @@ config SYSCTL_SYSCALL
348 If unsure say Y here. 348 If unsure say Y here.
349 349
350config KALLSYMS 350config KALLSYMS
351 bool "Load all symbols for debugging/kksymoops" if EMBEDDED 351 bool "Load all symbols for debugging/ksymoops" if EMBEDDED
352 default y 352 default y
353 help 353 help
354 Say Y here to let the kernel print out symbolic crash information and 354 Say Y here to let the kernel print out symbolic crash information and
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 0701ddda1df8..818e4589f718 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -437,7 +437,7 @@ config FAIL_PAGE_ALLOC
437 Provide fault-injection capability for alloc_pages(). 437 Provide fault-injection capability for alloc_pages().
438 438
439config FAIL_MAKE_REQUEST 439config FAIL_MAKE_REQUEST
440 bool "Fault-injection capabilitiy for disk IO" 440 bool "Fault-injection capability for disk IO"
441 depends on FAULT_INJECTION 441 depends on FAULT_INJECTION
442 help 442 help
443 Provide fault-injection capability for disk IO. 443 Provide fault-injection capability for disk IO.
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index 74046efdf875..8ce00d3703da 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -565,7 +565,7 @@ static void ip_frag_queue(struct ipq *qp, struct sk_buff *skb)
565 } else { 565 } else {
566 struct sk_buff *free_it = next; 566 struct sk_buff *free_it = next;
567 567
568 /* Old fragmnet is completely overridden with 568 /* Old fragment is completely overridden with
569 * new one drop it. 569 * new one drop it.
570 */ 570 */
571 next = next->next; 571 next = next->next;
diff --git a/sound/Kconfig b/sound/Kconfig
index 95949b6806ac..9d77300746c6 100644
--- a/sound/Kconfig
+++ b/sound/Kconfig
@@ -93,4 +93,12 @@ endmenu
93 93
94endif 94endif
95 95
96config AC97_BUS
97 tristate
98 help
99 This is used to avoid config and link hard dependencies between the
100 sound subsystem and other function drivers completely unrelated to
101 sound although they're sharing the AC97 bus. Concerned drivers
102 should "select" this.
103
96endmenu 104endmenu
diff --git a/sound/Makefile b/sound/Makefile
index 5f6bef57e825..9aee54c4882d 100644
--- a/sound/Makefile
+++ b/sound/Makefile
@@ -8,6 +8,9 @@ obj-$(CONFIG_DMASOUND) += oss/
8obj-$(CONFIG_SND) += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ synth/ usb/ sparc/ parisc/ pcmcia/ mips/ 8obj-$(CONFIG_SND) += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ synth/ usb/ sparc/ parisc/ pcmcia/ mips/
9obj-$(CONFIG_SND_AOA) += aoa/ 9obj-$(CONFIG_SND_AOA) += aoa/
10 10
11# This one must be compilable even if sound is configured out
12obj-$(CONFIG_AC97_BUS) += ac97_bus.o
13
11ifeq ($(CONFIG_SND),y) 14ifeq ($(CONFIG_SND),y)
12 obj-y += last.o 15 obj-y += last.o
13endif 16endif
diff --git a/sound/pci/ac97/ac97_bus.c b/sound/ac97_bus.c
index 66de2c2f1554..66de2c2f1554 100644
--- a/sound/pci/ac97/ac97_bus.c
+++ b/sound/ac97_bus.c
diff --git a/sound/aoa/fabrics/Kconfig b/sound/aoa/fabrics/Kconfig
index c3bc7705c86a..50d7021ff677 100644
--- a/sound/aoa/fabrics/Kconfig
+++ b/sound/aoa/fabrics/Kconfig
@@ -1,6 +1,6 @@
1config SND_AOA_FABRIC_LAYOUT 1config SND_AOA_FABRIC_LAYOUT
2 tristate "layout-id fabric" 2 tristate "layout-id fabric"
3 depends SND_AOA 3 depends on SND_AOA
4 select SND_AOA_SOUNDBUS 4 select SND_AOA_SOUNDBUS
5 select SND_AOA_SOUNDBUS_I2S 5 select SND_AOA_SOUNDBUS_I2S
6 ---help--- 6 ---help---
diff --git a/sound/drivers/Kconfig b/sound/drivers/Kconfig
index 7971285dfd5b..40ebd2f44056 100644
--- a/sound/drivers/Kconfig
+++ b/sound/drivers/Kconfig
@@ -26,11 +26,7 @@ config SND_VX_LIB
26config SND_AC97_CODEC 26config SND_AC97_CODEC
27 tristate 27 tristate
28 select SND_PCM 28 select SND_PCM
29 select SND_AC97_BUS 29 select AC97_BUS
30
31config SND_AC97_BUS
32 tristate
33
34 30
35config SND_DUMMY 31config SND_DUMMY
36 tristate "Dummy (/dev/null) soundcard" 32 tristate "Dummy (/dev/null) soundcard"
diff --git a/sound/pci/ac97/Makefile b/sound/pci/ac97/Makefile
index 77b3482cb133..3c3222122d8b 100644
--- a/sound/pci/ac97/Makefile
+++ b/sound/pci/ac97/Makefile
@@ -10,11 +10,9 @@ snd-ac97-codec-objs += ac97_proc.o
10endif 10endif
11 11
12snd-ak4531-codec-objs := ak4531_codec.o 12snd-ak4531-codec-objs := ak4531_codec.o
13snd-ac97-bus-objs := ac97_bus.o
14 13
15# Toplevel Module Dependency 14# Toplevel Module Dependency
16obj-$(CONFIG_SND_AC97_CODEC) += snd-ac97-codec.o 15obj-$(CONFIG_SND_AC97_CODEC) += snd-ac97-codec.o
17obj-$(CONFIG_SND_ENS1370) += snd-ak4531-codec.o 16obj-$(CONFIG_SND_ENS1370) += snd-ak4531-codec.o
18obj-$(CONFIG_SND_AC97_BUS) += snd-ac97-bus.o
19 17
20obj-m := $(sort $(obj-m)) 18obj-m := $(sort $(obj-m))