aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/networking/00-INDEX116
-rw-r--r--Documentation/networking/ip-sysctl.txt2
-rw-r--r--Documentation/networking/scaling.txt23
-rw-r--r--MAINTAINERS7
-rw-r--r--arch/alpha/include/asm/sysinfo.h9
-rw-r--r--arch/alpha/include/asm/thread_info.h8
-rw-r--r--arch/alpha/kernel/osf_sys.c12
-rw-r--r--arch/cris/include/asm/serial.h9
-rw-r--r--arch/m68k/include/asm/page_mm.h2
-rw-r--r--arch/powerpc/sysdev/fsl_rio.c5
-rw-r--r--arch/s390/kernel/early.c14
-rw-r--r--arch/s390/kernel/ipl.c7
-rw-r--r--arch/sparc/include/asm/sigcontext.h14
-rw-r--r--arch/sparc/kernel/Makefile1
-rw-r--r--arch/sparc/kernel/signal32.c184
-rw-r--r--arch/sparc/kernel/signal_32.c172
-rw-r--r--arch/sparc/kernel/signal_64.c108
-rw-r--r--arch/sparc/kernel/sigutil.h9
-rw-r--r--arch/sparc/kernel/sigutil_32.c120
-rw-r--r--arch/sparc/kernel/sigutil_64.c93
-rw-r--r--arch/x86/kernel/apic/x2apic_uv_x.c1
-rw-r--r--arch/x86/kernel/cpu/mtrr/main.c2
-rw-r--r--arch/x86/kernel/entry_32.S8
-rw-r--r--arch/x86/platform/mrst/mrst.c4
-rw-r--r--arch/x86/platform/olpc/olpc.c4
-rw-r--r--arch/x86/vdso/vdso32/sysenter.S2
-rw-r--r--drivers/base/firmware_class.c11
-rw-r--r--drivers/char/msm_smd_pkt.c5
-rw-r--r--drivers/gpu/drm/radeon/radeon_connectors.c10
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_test.c34
-rw-r--r--drivers/gpu/drm/radeon/radeon_ttm.c23
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo.c14
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo_util.c2
-rw-r--r--drivers/hid/Kconfig1
-rw-r--r--drivers/hid/hid-apple.c6
-rw-r--r--drivers/hid/hid-core.c3
-rw-r--r--drivers/hid/hid-ids.h6
-rw-r--r--drivers/hid/hid-wiimote.c277
-rw-r--r--drivers/hid/usbhid/hid-quirks.c1
-rw-r--r--drivers/hwmon/i5k_amb.c42
-rw-r--r--drivers/hwmon/ntc_thermistor.c3
-rw-r--r--drivers/i2c/busses/i2c-nomadik.c9
-rw-r--r--drivers/i2c/busses/i2c-omap.c29
-rw-r--r--drivers/input/joystick/analog.c2
-rw-r--r--drivers/input/keyboard/ep93xx_keypad.c1
-rw-r--r--drivers/input/keyboard/tegra-kbc.c2
-rw-r--r--drivers/input/misc/ad714x-i2c.c81
-rw-r--r--drivers/input/misc/ad714x-spi.c68
-rw-r--r--drivers/input/misc/ad714x.c116
-rw-r--r--drivers/input/misc/ad714x.h35
-rw-r--r--drivers/input/misc/mma8450.c2
-rw-r--r--drivers/input/misc/mpu3050.c2
-rw-r--r--drivers/input/mouse/bcm5974.c40
-rw-r--r--drivers/input/tablet/wacom_sys.c17
-rw-r--r--drivers/input/tablet/wacom_wac.c4
-rw-r--r--drivers/input/touchscreen/atmel_mxt_ts.c12
-rw-r--r--drivers/input/touchscreen/max11801_ts.c3
-rw-r--r--drivers/input/touchscreen/tnetv107x-ts.c1
-rw-r--r--drivers/leds/leds-ams-delta.c1
-rw-r--r--drivers/leds/leds-bd2802.c5
-rw-r--r--drivers/leds/leds-hp6xx.c1
-rw-r--r--drivers/misc/ab8500-pwm.c2
-rw-r--r--drivers/misc/fsa9480.c4
-rw-r--r--drivers/misc/pti.c2
-rw-r--r--drivers/net/bonding/bond_main.c18
-rw-r--r--drivers/net/can/sja1000/plx_pci.c4
-rw-r--r--drivers/net/e1000e/e1000.h4
-rw-r--r--drivers/net/e1000e/ich8lan.c65
-rw-r--r--drivers/net/e1000e/netdev.c80
-rw-r--r--drivers/net/forcedeth.c3
-rw-r--r--drivers/net/gianfar.c9
-rw-r--r--drivers/net/gianfar_ethtool.c26
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c4
-rw-r--r--drivers/net/rionet.c23
-rw-r--r--drivers/net/sh_eth.c1
-rw-r--r--drivers/net/usb/cdc_ncm.c47
-rw-r--r--drivers/net/via-velocity.c4
-rw-r--r--drivers/net/vmxnet3/vmxnet3_drv.c34
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-pci.c25
-rw-r--r--drivers/net/wireless/rt2x00/rt2800usb.c20
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00usb.c17
-rw-r--r--drivers/net/wireless/wl12xx/acx.c6
-rw-r--r--drivers/net/wireless/wl12xx/testmode.c5
-rw-r--r--drivers/power/max8997_charger.c1
-rw-r--r--drivers/power/max8998_charger.c1
-rw-r--r--drivers/power/s3c_adc_battery.c1
-rw-r--r--drivers/rapidio/rio-scan.c3
-rw-r--r--drivers/rtc/rtc-s3c.c79
-rw-r--r--drivers/s390/block/dasd_ioctl.c10
-rw-r--r--drivers/s390/char/sclp_cmd.c6
-rw-r--r--drivers/target/iscsi/iscsi_target.c1
-rw-r--r--drivers/target/iscsi/iscsi_target_configfs.c4
-rw-r--r--drivers/target/iscsi/iscsi_target_erl1.c2
-rw-r--r--drivers/target/iscsi/iscsi_target_login.c16
-rw-r--r--drivers/target/iscsi/iscsi_target_parameters.c43
-rw-r--r--drivers/target/iscsi/iscsi_target_util.c4
-rw-r--r--drivers/target/target_core_cdb.c57
-rw-r--r--drivers/target/target_core_device.c48
-rw-r--r--drivers/target/target_core_fabric_configfs.c2
-rw-r--r--drivers/target/target_core_pr.c8
-rw-r--r--drivers/target/target_core_rd.c24
-rw-r--r--drivers/target/target_core_tpg.c64
-rw-r--r--drivers/target/target_core_transport.c206
-rw-r--r--drivers/target/tcm_fc/tfc_conf.c6
-rw-r--r--drivers/video/backlight/adp8870_bl.c2
-rw-r--r--drivers/video/backlight/ep93xx_bl.c2
-rw-r--r--drivers/video/backlight/pwm_bl.c9
-rw-r--r--drivers/w1/masters/ds2490.c4
-rw-r--r--drivers/w1/masters/matrox_w1.c4
-rw-r--r--drivers/w1/slaves/w1_ds2408.c2
-rw-r--r--drivers/w1/slaves/w1_smem.c4
-rw-r--r--drivers/w1/slaves/w1_therm.c4
-rw-r--r--drivers/w1/w1.c4
-rw-r--r--drivers/w1/w1.h2
-rw-r--r--drivers/w1/w1_family.c2
-rw-r--r--drivers/w1/w1_family.h2
-rw-r--r--drivers/w1/w1_int.c2
-rw-r--r--drivers/w1/w1_int.h2
-rw-r--r--drivers/w1/w1_io.c2
-rw-r--r--drivers/w1/w1_log.h2
-rw-r--r--drivers/w1/w1_netlink.c2
-rw-r--r--drivers/w1/w1_netlink.h2
-rw-r--r--fs/fuse/dev.c4
-rw-r--r--fs/fuse/file.c84
-rw-r--r--fs/fuse/fuse_i.h8
-rw-r--r--fs/fuse/inode.c10
-rw-r--r--fs/hugetlbfs/inode.c1
-rw-r--r--fs/inode.c24
-rw-r--r--fs/xfs/Makefile119
-rw-r--r--fs/xfs/kmem.c (renamed from fs/xfs/linux-2.6/kmem.c)0
-rw-r--r--fs/xfs/kmem.h (renamed from fs/xfs/linux-2.6/kmem.h)0
-rw-r--r--fs/xfs/mrlock.h (renamed from fs/xfs/linux-2.6/mrlock.h)0
-rw-r--r--fs/xfs/time.h (renamed from fs/xfs/linux-2.6/time.h)0
-rw-r--r--fs/xfs/uuid.c (renamed from fs/xfs/support/uuid.c)0
-rw-r--r--fs/xfs/uuid.h (renamed from fs/xfs/support/uuid.h)0
-rw-r--r--fs/xfs/xfs.h3
-rw-r--r--fs/xfs/xfs_acl.c (renamed from fs/xfs/linux-2.6/xfs_acl.c)0
-rw-r--r--fs/xfs/xfs_aops.c (renamed from fs/xfs/linux-2.6/xfs_aops.c)0
-rw-r--r--fs/xfs/xfs_aops.h (renamed from fs/xfs/linux-2.6/xfs_aops.h)0
-rw-r--r--fs/xfs/xfs_buf.c (renamed from fs/xfs/linux-2.6/xfs_buf.c)0
-rw-r--r--fs/xfs/xfs_buf.h (renamed from fs/xfs/linux-2.6/xfs_buf.h)0
-rw-r--r--fs/xfs/xfs_discard.c (renamed from fs/xfs/linux-2.6/xfs_discard.c)0
-rw-r--r--fs/xfs/xfs_discard.h (renamed from fs/xfs/linux-2.6/xfs_discard.h)0
-rw-r--r--fs/xfs/xfs_dquot.c (renamed from fs/xfs/quota/xfs_dquot.c)0
-rw-r--r--fs/xfs/xfs_dquot.h (renamed from fs/xfs/quota/xfs_dquot.h)0
-rw-r--r--fs/xfs/xfs_dquot_item.c (renamed from fs/xfs/quota/xfs_dquot_item.c)0
-rw-r--r--fs/xfs/xfs_dquot_item.h (renamed from fs/xfs/quota/xfs_dquot_item.h)0
-rw-r--r--fs/xfs/xfs_export.c (renamed from fs/xfs/linux-2.6/xfs_export.c)0
-rw-r--r--fs/xfs/xfs_export.h (renamed from fs/xfs/linux-2.6/xfs_export.h)0
-rw-r--r--fs/xfs/xfs_file.c (renamed from fs/xfs/linux-2.6/xfs_file.c)0
-rw-r--r--fs/xfs/xfs_fs_subr.c (renamed from fs/xfs/linux-2.6/xfs_fs_subr.c)0
-rw-r--r--fs/xfs/xfs_globals.c (renamed from fs/xfs/linux-2.6/xfs_globals.c)0
-rw-r--r--fs/xfs/xfs_ioctl.c (renamed from fs/xfs/linux-2.6/xfs_ioctl.c)0
-rw-r--r--fs/xfs/xfs_ioctl.h (renamed from fs/xfs/linux-2.6/xfs_ioctl.h)0
-rw-r--r--fs/xfs/xfs_ioctl32.c (renamed from fs/xfs/linux-2.6/xfs_ioctl32.c)0
-rw-r--r--fs/xfs/xfs_ioctl32.h (renamed from fs/xfs/linux-2.6/xfs_ioctl32.h)0
-rw-r--r--fs/xfs/xfs_iops.c (renamed from fs/xfs/linux-2.6/xfs_iops.c)0
-rw-r--r--fs/xfs/xfs_iops.h (renamed from fs/xfs/linux-2.6/xfs_iops.h)0
-rw-r--r--fs/xfs/xfs_linux.h (renamed from fs/xfs/linux-2.6/xfs_linux.h)27
-rw-r--r--fs/xfs/xfs_message.c (renamed from fs/xfs/linux-2.6/xfs_message.c)0
-rw-r--r--fs/xfs/xfs_message.h (renamed from fs/xfs/linux-2.6/xfs_message.h)0
-rw-r--r--fs/xfs/xfs_qm.c (renamed from fs/xfs/quota/xfs_qm.c)0
-rw-r--r--fs/xfs/xfs_qm.h (renamed from fs/xfs/quota/xfs_qm.h)0
-rw-r--r--fs/xfs/xfs_qm_bhv.c (renamed from fs/xfs/quota/xfs_qm_bhv.c)0
-rw-r--r--fs/xfs/xfs_qm_stats.c (renamed from fs/xfs/quota/xfs_qm_stats.c)0
-rw-r--r--fs/xfs/xfs_qm_stats.h (renamed from fs/xfs/quota/xfs_qm_stats.h)0
-rw-r--r--fs/xfs/xfs_qm_syscalls.c (renamed from fs/xfs/quota/xfs_qm_syscalls.c)0
-rw-r--r--fs/xfs/xfs_quota_priv.h (renamed from fs/xfs/quota/xfs_quota_priv.h)0
-rw-r--r--fs/xfs/xfs_quotaops.c (renamed from fs/xfs/linux-2.6/xfs_quotaops.c)2
-rw-r--r--fs/xfs/xfs_stats.c (renamed from fs/xfs/linux-2.6/xfs_stats.c)0
-rw-r--r--fs/xfs/xfs_stats.h (renamed from fs/xfs/linux-2.6/xfs_stats.h)0
-rw-r--r--fs/xfs/xfs_super.c (renamed from fs/xfs/linux-2.6/xfs_super.c)0
-rw-r--r--fs/xfs/xfs_super.h (renamed from fs/xfs/linux-2.6/xfs_super.h)0
-rw-r--r--fs/xfs/xfs_sync.c (renamed from fs/xfs/linux-2.6/xfs_sync.c)0
-rw-r--r--fs/xfs/xfs_sync.h (renamed from fs/xfs/linux-2.6/xfs_sync.h)0
-rw-r--r--fs/xfs/xfs_sysctl.c (renamed from fs/xfs/linux-2.6/xfs_sysctl.c)0
-rw-r--r--fs/xfs/xfs_sysctl.h (renamed from fs/xfs/linux-2.6/xfs_sysctl.h)0
-rw-r--r--fs/xfs/xfs_trace.c (renamed from fs/xfs/linux-2.6/xfs_trace.c)4
-rw-r--r--fs/xfs/xfs_trace.h (renamed from fs/xfs/linux-2.6/xfs_trace.h)0
-rw-r--r--fs/xfs/xfs_trans_dquot.c (renamed from fs/xfs/quota/xfs_trans_dquot.c)0
-rw-r--r--fs/xfs/xfs_vnode.h (renamed from fs/xfs/linux-2.6/xfs_vnode.h)0
-rw-r--r--fs/xfs/xfs_xattr.c (renamed from fs/xfs/linux-2.6/xfs_xattr.c)0
-rw-r--r--include/linux/connector.h2
-rw-r--r--include/linux/fs.h5
-rw-r--r--include/linux/fuse.h9
-rw-r--r--include/linux/personality.h1
-rw-r--r--include/linux/pwm_backlight.h1
-rw-r--r--include/linux/rio_regs.h18
-rw-r--r--include/linux/writeback.h11
-rw-r--r--include/target/target_core_fabric_ops.h6
-rw-r--r--kernel/irq/manage.c1
-rw-r--r--kernel/printk.c2
-rw-r--r--kernel/sys.c38
-rw-r--r--kernel/sysctl_binary.c2
-rw-r--r--kernel/sysctl_check.c2
-rw-r--r--mm/memcontrol.c26
-rw-r--r--mm/page-writeback.c15
-rw-r--r--mm/vmscan.c19
-rw-r--r--net/8021q/vlan_core.c2
-rw-r--r--net/atm/br2684.c7
-rw-r--r--net/bridge/br_if.c6
-rw-r--r--net/ipv6/ipv6_sockglue.c9
-rw-r--r--net/ipv6/sit.c3
-rw-r--r--net/sched/act_mirred.c3
-rwxr-xr-xscripts/checkpatch.pl3
-rwxr-xr-xscripts/get_maintainer.pl2
-rw-r--r--sound/pci/hda/patch_conexant.c57
-rw-r--r--sound/pci/hda/patch_realtek.c28
-rw-r--r--sound/soc/blackfin/bf5xx-ad193x.c2
-rw-r--r--sound/soc/codecs/ad193x.c11
-rw-r--r--sound/soc/codecs/ad193x.h5
-rw-r--r--sound/soc/codecs/sta32x.c1
-rw-r--r--sound/soc/codecs/wm8962.c12
-rw-r--r--sound/soc/codecs/wm8996.c28
-rw-r--r--sound/soc/ep93xx/ep93xx-i2s.c5
-rw-r--r--sound/soc/fsl/fsl_dma.c2
-rw-r--r--sound/soc/fsl/mpc8610_hpcd.c18
-rw-r--r--sound/soc/fsl/p1022_ds.c4
-rw-r--r--sound/soc/kirkwood/kirkwood-i2s.c2
-rw-r--r--sound/soc/omap/ams-delta.c6
-rw-r--r--sound/soc/samsung/Kconfig1
-rw-r--r--sound/soc/samsung/h1940_uda1380.c1
-rw-r--r--sound/soc/samsung/rx1950_uda1380.c1
-rw-r--r--sound/soc/samsung/speyside_wm8962.c6
-rw-r--r--sound/soc/soc-core.c2
-rw-r--r--sound/soc/soc-io.c23
-rw-r--r--sound/soc/soc-jack.c2
-rw-r--r--sound/soc/soc-pcm.c3
-rw-r--r--sound/soc/tegra/tegra_wm8903.c4
-rw-r--r--tools/power/cpupower/Makefile7
-rw-r--r--tools/power/cpupower/debug/x86_64/Makefile8
l---------tools/power/cpupower/debug/x86_64/centrino-decode.c1
l---------tools/power/cpupower/debug/x86_64/powernow-k8-decode.c1
-rw-r--r--tools/power/cpupower/man/cpupower-frequency-info.16
-rw-r--r--tools/power/cpupower/man/cpupower-frequency-set.18
-rw-r--r--tools/power/cpupower/man/cpupower.114
-rw-r--r--tools/power/cpupower/utils/builtin.h7
-rw-r--r--tools/power/cpupower/utils/cpufreq-info.c42
-rw-r--r--tools/power/cpupower/utils/cpufreq-set.c29
-rw-r--r--tools/power/cpupower/utils/cpuidle-info.c24
-rw-r--r--tools/power/cpupower/utils/cpupower-info.c20
-rw-r--r--tools/power/cpupower/utils/cpupower-set.c25
-rw-r--r--tools/power/cpupower/utils/cpupower.c91
-rw-r--r--tools/power/cpupower/utils/helpers/helpers.h12
-rw-r--r--tools/power/cpupower/utils/helpers/sysfs.c50
-rw-r--r--tools/power/cpupower/utils/helpers/sysfs.h2
-rw-r--r--tools/power/cpupower/utils/helpers/topology.c5
-rw-r--r--tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c2
-rw-r--r--tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c66
-rw-r--r--tools/power/cpupower/utils/idle_monitor/mperf_monitor.c177
251 files changed, 2528 insertions, 1621 deletions
diff --git a/Documentation/networking/00-INDEX b/Documentation/networking/00-INDEX
index 4edd78dfb362..bbce1215434a 100644
--- a/Documentation/networking/00-INDEX
+++ b/Documentation/networking/00-INDEX
@@ -1,13 +1,21 @@
100-INDEX 100-INDEX
2 - this file 2 - this file
33c359.txt
4 - information on the 3Com TokenLink Velocity XL (3c5359) driver.
33c505.txt 53c505.txt
4 - information on the 3Com EtherLink Plus (3c505) driver. 6 - information on the 3Com EtherLink Plus (3c505) driver.
73c509.txt
8 - information on the 3Com Etherlink III Series Ethernet cards.
56pack.txt 96pack.txt
6 - info on the 6pack protocol, an alternative to KISS for AX.25 10 - info on the 6pack protocol, an alternative to KISS for AX.25
7DLINK.txt 11DLINK.txt
8 - info on the D-Link DE-600/DE-620 parallel port pocket adapters 12 - info on the D-Link DE-600/DE-620 parallel port pocket adapters
9PLIP.txt 13PLIP.txt
10 - PLIP: The Parallel Line Internet Protocol device driver 14 - PLIP: The Parallel Line Internet Protocol device driver
15README.ipw2100
16 - README for the Intel PRO/Wireless 2100 driver.
17README.ipw2200
18 - README for the Intel PRO/Wireless 2915ABG and 2200BG driver.
11README.sb1000 19README.sb1000
12 - info on General Instrument/NextLevel SURFboard1000 cable modem. 20 - info on General Instrument/NextLevel SURFboard1000 cable modem.
13alias.txt 21alias.txt
@@ -20,8 +28,12 @@ atm.txt
20 - info on where to get ATM programs and support for Linux. 28 - info on where to get ATM programs and support for Linux.
21ax25.txt 29ax25.txt
22 - info on using AX.25 and NET/ROM code for Linux 30 - info on using AX.25 and NET/ROM code for Linux
31batman-adv.txt
32 - B.A.T.M.A.N routing protocol on top of layer 2 Ethernet Frames.
23baycom.txt 33baycom.txt
24 - info on the driver for Baycom style amateur radio modems 34 - info on the driver for Baycom style amateur radio modems
35bonding.txt
36 - Linux Ethernet Bonding Driver HOWTO: link aggregation in Linux.
25bridge.txt 37bridge.txt
26 - where to get user space programs for ethernet bridging with Linux. 38 - where to get user space programs for ethernet bridging with Linux.
27can.txt 39can.txt
@@ -34,32 +46,60 @@ cxacru.txt
34 - Conexant AccessRunner USB ADSL Modem 46 - Conexant AccessRunner USB ADSL Modem
35cxacru-cf.py 47cxacru-cf.py
36 - Conexant AccessRunner USB ADSL Modem configuration file parser 48 - Conexant AccessRunner USB ADSL Modem configuration file parser
49cxgb.txt
50 - Release Notes for the Chelsio N210 Linux device driver.
51dccp.txt
52 - the Datagram Congestion Control Protocol (DCCP) (RFC 4340..42).
37de4x5.txt 53de4x5.txt
38 - the Digital EtherWORKS DE4?? and DE5?? PCI Ethernet driver 54 - the Digital EtherWORKS DE4?? and DE5?? PCI Ethernet driver
39decnet.txt 55decnet.txt
40 - info on using the DECnet networking layer in Linux. 56 - info on using the DECnet networking layer in Linux.
41depca.txt 57depca.txt
42 - the Digital DEPCA/EtherWORKS DE1?? and DE2?? LANCE Ethernet driver 58 - the Digital DEPCA/EtherWORKS DE1?? and DE2?? LANCE Ethernet driver
59dl2k.txt
60 - README for D-Link DL2000-based Gigabit Ethernet Adapters (dl2k.ko).
61dm9000.txt
62 - README for the Simtec DM9000 Network driver.
43dmfe.txt 63dmfe.txt
44 - info on the Davicom DM9102(A)/DM9132/DM9801 fast ethernet driver. 64 - info on the Davicom DM9102(A)/DM9132/DM9801 fast ethernet driver.
65dns_resolver.txt
66 - The DNS resolver module allows kernel servies to make DNS queries.
67driver.txt
68 - Softnet driver issues.
45e100.txt 69e100.txt
46 - info on Intel's EtherExpress PRO/100 line of 10/100 boards 70 - info on Intel's EtherExpress PRO/100 line of 10/100 boards
47e1000.txt 71e1000.txt
48 - info on Intel's E1000 line of gigabit ethernet boards 72 - info on Intel's E1000 line of gigabit ethernet boards
73e1000e.txt
74 - README for the Intel Gigabit Ethernet Driver (e1000e).
49eql.txt 75eql.txt
50 - serial IP load balancing 76 - serial IP load balancing
51ewrk3.txt 77ewrk3.txt
52 - the Digital EtherWORKS 3 DE203/4/5 Ethernet driver 78 - the Digital EtherWORKS 3 DE203/4/5 Ethernet driver
79fib_trie.txt
80 - Level Compressed Trie (LC-trie) notes: a structure for routing.
53filter.txt 81filter.txt
54 - Linux Socket Filtering 82 - Linux Socket Filtering
55fore200e.txt 83fore200e.txt
56 - FORE Systems PCA-200E/SBA-200E ATM NIC driver info. 84 - FORE Systems PCA-200E/SBA-200E ATM NIC driver info.
57framerelay.txt 85framerelay.txt
58 - info on using Frame Relay/Data Link Connection Identifier (DLCI). 86 - info on using Frame Relay/Data Link Connection Identifier (DLCI).
87gen_stats.txt
88 - Generic networking statistics for netlink users.
89generic_hdlc.txt
90 - The generic High Level Data Link Control (HDLC) layer.
59generic_netlink.txt 91generic_netlink.txt
60 - info on Generic Netlink 92 - info on Generic Netlink
93gianfar.txt
94 - Gianfar Ethernet Driver.
61ieee802154.txt 95ieee802154.txt
62 - Linux IEEE 802.15.4 implementation, API and drivers 96 - Linux IEEE 802.15.4 implementation, API and drivers
97ifenslave.c
98 - Configure network interfaces for parallel routing (bonding).
99igb.txt
100 - README for the Intel Gigabit Ethernet Driver (igb).
101igbvf.txt
102 - README for the Intel Gigabit Ethernet Driver (igbvf).
63ip-sysctl.txt 103ip-sysctl.txt
64 - /proc/sys/net/ipv4/* variables 104 - /proc/sys/net/ipv4/* variables
65ip_dynaddr.txt 105ip_dynaddr.txt
@@ -68,41 +108,117 @@ ipddp.txt
68 - AppleTalk-IP Decapsulation and AppleTalk-IP Encapsulation 108 - AppleTalk-IP Decapsulation and AppleTalk-IP Encapsulation
69iphase.txt 109iphase.txt
70 - Interphase PCI ATM (i)Chip IA Linux driver info. 110 - Interphase PCI ATM (i)Chip IA Linux driver info.
111ipv6.txt
112 - Options to the ipv6 kernel module.
113ipvs-sysctl.txt
114 - Per-inode explanation of the /proc/sys/net/ipv4/vs interface.
71irda.txt 115irda.txt
72 - where to get IrDA (infrared) utilities and info for Linux. 116 - where to get IrDA (infrared) utilities and info for Linux.
117ixgb.txt
118 - README for the Intel 10 Gigabit Ethernet Driver (ixgb).
119ixgbe.txt
120 - README for the Intel 10 Gigabit Ethernet Driver (ixgbe).
121ixgbevf.txt
122 - README for the Intel Virtual Function (VF) Driver (ixgbevf).
123l2tp.txt
124 - User guide to the L2TP tunnel protocol.
73lapb-module.txt 125lapb-module.txt
74 - programming information of the LAPB module. 126 - programming information of the LAPB module.
75ltpc.txt 127ltpc.txt
76 - the Apple or Farallon LocalTalk PC card driver 128 - the Apple or Farallon LocalTalk PC card driver
129mac80211-injection.txt
130 - HOWTO use packet injection with mac80211
77multicast.txt 131multicast.txt
78 - Behaviour of cards under Multicast 132 - Behaviour of cards under Multicast
133multiqueue.txt
134 - HOWTO for multiqueue network device support.
135netconsole.txt
136 - The network console module netconsole.ko: configuration and notes.
137netdev-features.txt
138 - Network interface features API description.
79netdevices.txt 139netdevices.txt
80 - info on network device driver functions exported to the kernel. 140 - info on network device driver functions exported to the kernel.
141netif-msg.txt
142 - Design of the network interface message level setting (NETIF_MSG_*).
143nfc.txt
144 - The Linux Near Field Communication (NFS) subsystem.
81olympic.txt 145olympic.txt
82 - IBM PCI Pit/Pit-Phy/Olympic Token Ring driver info. 146 - IBM PCI Pit/Pit-Phy/Olympic Token Ring driver info.
147operstates.txt
148 - Overview of network interface operational states.
149packet_mmap.txt
150 - User guide to memory mapped packet socket rings (PACKET_[RT]X_RING).
151phonet.txt
152 - The Phonet packet protocol used in Nokia cellular modems.
153phy.txt
154 - The PHY abstraction layer.
155pktgen.txt
156 - User guide to the kernel packet generator (pktgen.ko).
83policy-routing.txt 157policy-routing.txt
84 - IP policy-based routing 158 - IP policy-based routing
159ppp_generic.txt
160 - Information about the generic PPP driver.
161proc_net_tcp.txt
162 - Per inode overview of the /proc/net/tcp and /proc/net/tcp6 interfaces.
163radiotap-headers.txt
164 - Background on radiotap headers.
85ray_cs.txt 165ray_cs.txt
86 - Raylink Wireless LAN card driver info. 166 - Raylink Wireless LAN card driver info.
167rds.txt
168 - Background on the reliable, ordered datagram delivery method RDS.
169regulatory.txt
170 - Overview of the Linux wireless regulatory infrastructure.
171rxrpc.txt
172 - Guide to the RxRPC protocol.
173s2io.txt
174 - Release notes for Neterion Xframe I/II 10GbE driver.
175scaling.txt
176 - Explanation of network scaling techniques: RSS, RPS, RFS, aRFS, XPS.
177sctp.txt
178 - Notes on the Linux kernel implementation of the SCTP protocol.
179secid.txt
180 - Explanation of the secid member in flow structures.
87skfp.txt 181skfp.txt
88 - SysKonnect FDDI (SK-5xxx, Compaq Netelligent) driver info. 182 - SysKonnect FDDI (SK-5xxx, Compaq Netelligent) driver info.
89smc9.txt 183smc9.txt
90 - the driver for SMC's 9000 series of Ethernet cards 184 - the driver for SMC's 9000 series of Ethernet cards
91smctr.txt 185smctr.txt
92 - SMC TokenCard TokenRing Linux driver info. 186 - SMC TokenCard TokenRing Linux driver info.
187spider-net.txt
188 - README for the Spidernet Driver (as found in PS3 / Cell BE).
189stmmac.txt
190 - README for the STMicro Synopsys Ethernet driver.
191tc-actions-env-rules.txt
192 - rules for traffic control (tc) actions.
193timestamping.txt
194 - overview of network packet timestamping variants.
93tcp.txt 195tcp.txt
94 - short blurb on how TCP output takes place. 196 - short blurb on how TCP output takes place.
197tcp-thin.txt
198 - kernel tuning options for low rate 'thin' TCP streams.
95tlan.txt 199tlan.txt
96 - ThunderLAN (Compaq Netelligent 10/100, Olicom OC-2xxx) driver info. 200 - ThunderLAN (Compaq Netelligent 10/100, Olicom OC-2xxx) driver info.
97tms380tr.txt 201tms380tr.txt
98 - SysKonnect Token Ring ISA/PCI adapter driver info. 202 - SysKonnect Token Ring ISA/PCI adapter driver info.
203tproxy.txt
204 - Transparent proxy support user guide.
99tuntap.txt 205tuntap.txt
100 - TUN/TAP device driver, allowing user space Rx/Tx of packets. 206 - TUN/TAP device driver, allowing user space Rx/Tx of packets.
207udplite.txt
208 - UDP-Lite protocol (RFC 3828) introduction.
101vortex.txt 209vortex.txt
102 - info on using 3Com Vortex (3c590, 3c592, 3c595, 3c597) Ethernet cards. 210 - info on using 3Com Vortex (3c590, 3c592, 3c595, 3c597) Ethernet cards.
211vxge.txt
212 - README for the Neterion X3100 PCIe Server Adapter.
103x25.txt 213x25.txt
104 - general info on X.25 development. 214 - general info on X.25 development.
105x25-iface.txt 215x25-iface.txt
106 - description of the X.25 Packet Layer to LAPB device interface. 216 - description of the X.25 Packet Layer to LAPB device interface.
217xfrm_proc.txt
218 - description of the statistics package for XFRM.
219xfrm_sync.txt
220 - sync patches for XFRM enable migration of an SA between hosts.
221xfrm_sysctl.txt
222 - description of the XFRM configuration options.
107z8530drv.txt 223z8530drv.txt
108 - info about Linux driver for Z8530 based HDLC cards for AX.25 224 - info about Linux driver for Z8530 based HDLC cards for AX.25
diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
index db2a4067013c..81546990f41c 100644
--- a/Documentation/networking/ip-sysctl.txt
+++ b/Documentation/networking/ip-sysctl.txt
@@ -992,7 +992,7 @@ bindv6only - BOOLEAN
992 TRUE: disable IPv4-mapped address feature 992 TRUE: disable IPv4-mapped address feature
993 FALSE: enable IPv4-mapped address feature 993 FALSE: enable IPv4-mapped address feature
994 994
995 Default: FALSE (as specified in RFC2553bis) 995 Default: FALSE (as specified in RFC3493)
996 996
997IPv6 Fragmentation: 997IPv6 Fragmentation:
998 998
diff --git a/Documentation/networking/scaling.txt b/Documentation/networking/scaling.txt
index 7254b4b5910e..58fd7414e6c0 100644
--- a/Documentation/networking/scaling.txt
+++ b/Documentation/networking/scaling.txt
@@ -52,7 +52,8 @@ module parameter for specifying the number of hardware queues to
52configure. In the bnx2x driver, for instance, this parameter is called 52configure. In the bnx2x driver, for instance, this parameter is called
53num_queues. A typical RSS configuration would be to have one receive queue 53num_queues. A typical RSS configuration would be to have one receive queue
54for each CPU if the device supports enough queues, or otherwise at least 54for each CPU if the device supports enough queues, or otherwise at least
55one for each cache domain at a particular cache level (L1, L2, etc.). 55one for each memory domain, where a memory domain is a set of CPUs that
56share a particular memory level (L1, L2, NUMA node, etc.).
56 57
57The indirection table of an RSS device, which resolves a queue by masked 58The indirection table of an RSS device, which resolves a queue by masked
58hash, is usually programmed by the driver at initialization. The 59hash, is usually programmed by the driver at initialization. The
@@ -82,11 +83,17 @@ RSS should be enabled when latency is a concern or whenever receive
82interrupt processing forms a bottleneck. Spreading load between CPUs 83interrupt processing forms a bottleneck. Spreading load between CPUs
83decreases queue length. For low latency networking, the optimal setting 84decreases queue length. For low latency networking, the optimal setting
84is to allocate as many queues as there are CPUs in the system (or the 85is to allocate as many queues as there are CPUs in the system (or the
85NIC maximum, if lower). Because the aggregate number of interrupts grows 86NIC maximum, if lower). The most efficient high-rate configuration
86with each additional queue, the most efficient high-rate configuration
87is likely the one with the smallest number of receive queues where no 87is likely the one with the smallest number of receive queues where no
88CPU that processes receive interrupts reaches 100% utilization. Per-cpu 88receive queue overflows due to a saturated CPU, because in default
89load can be observed using the mpstat utility. 89mode with interrupt coalescing enabled, the aggregate number of
90interrupts (and thus work) grows with each additional queue.
91
92Per-cpu load can be observed using the mpstat utility, but note that on
93processors with hyperthreading (HT), each hyperthread is represented as
94a separate CPU. For interrupt handling, HT has shown no benefit in
95initial tests, so limit the number of queues to the number of CPU cores
96in the system.
90 97
91 98
92RPS: Receive Packet Steering 99RPS: Receive Packet Steering
@@ -145,7 +152,7 @@ the bitmap.
145== Suggested Configuration 152== Suggested Configuration
146 153
147For a single queue device, a typical RPS configuration would be to set 154For a single queue device, a typical RPS configuration would be to set
148the rps_cpus to the CPUs in the same cache domain of the interrupting 155the rps_cpus to the CPUs in the same memory domain of the interrupting
149CPU. If NUMA locality is not an issue, this could also be all CPUs in 156CPU. If NUMA locality is not an issue, this could also be all CPUs in
150the system. At high interrupt rate, it might be wise to exclude the 157the system. At high interrupt rate, it might be wise to exclude the
151interrupting CPU from the map since that already performs much work. 158interrupting CPU from the map since that already performs much work.
@@ -154,7 +161,7 @@ For a multi-queue system, if RSS is configured so that a hardware
154receive queue is mapped to each CPU, then RPS is probably redundant 161receive queue is mapped to each CPU, then RPS is probably redundant
155and unnecessary. If there are fewer hardware queues than CPUs, then 162and unnecessary. If there are fewer hardware queues than CPUs, then
156RPS might be beneficial if the rps_cpus for each queue are the ones that 163RPS might be beneficial if the rps_cpus for each queue are the ones that
157share the same cache domain as the interrupting CPU for that queue. 164share the same memory domain as the interrupting CPU for that queue.
158 165
159 166
160RFS: Receive Flow Steering 167RFS: Receive Flow Steering
@@ -326,7 +333,7 @@ The queue chosen for transmitting a particular flow is saved in the
326corresponding socket structure for the flow (e.g. a TCP connection). 333corresponding socket structure for the flow (e.g. a TCP connection).
327This transmit queue is used for subsequent packets sent on the flow to 334This transmit queue is used for subsequent packets sent on the flow to
328prevent out of order (ooo) packets. The choice also amortizes the cost 335prevent out of order (ooo) packets. The choice also amortizes the cost
329of calling get_xps_queues() over all packets in the connection. To avoid 336of calling get_xps_queues() over all packets in the flow. To avoid
330ooo packets, the queue for a flow can subsequently only be changed if 337ooo packets, the queue for a flow can subsequently only be changed if
331skb->ooo_okay is set for a packet in the flow. This flag indicates that 338skb->ooo_okay is set for a packet in the flow. This flag indicates that
332there are no outstanding packets in the flow, so the transmit queue can 339there are no outstanding packets in the flow, so the transmit queue can
diff --git a/MAINTAINERS b/MAINTAINERS
index 069ee3b5c651..1a8cc600067d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1883,7 +1883,7 @@ S: Maintained
1883F: drivers/connector/ 1883F: drivers/connector/
1884 1884
1885CONTROL GROUPS (CGROUPS) 1885CONTROL GROUPS (CGROUPS)
1886M: Paul Menage <menage@google.com> 1886M: Paul Menage <paul@paulmenage.org>
1887M: Li Zefan <lizf@cn.fujitsu.com> 1887M: Li Zefan <lizf@cn.fujitsu.com>
1888L: containers@lists.linux-foundation.org 1888L: containers@lists.linux-foundation.org
1889S: Maintained 1889S: Maintained
@@ -1932,7 +1932,7 @@ S: Maintained
1932F: tools/power/cpupower 1932F: tools/power/cpupower
1933 1933
1934CPUSETS 1934CPUSETS
1935M: Paul Menage <menage@google.com> 1935M: Paul Menage <paul@paulmenage.org>
1936W: http://www.bullopensource.org/cpuset/ 1936W: http://www.bullopensource.org/cpuset/
1937W: http://oss.sgi.com/projects/cpusets/ 1937W: http://oss.sgi.com/projects/cpusets/
1938S: Supported 1938S: Supported
@@ -5532,6 +5532,7 @@ F: include/media/*7146*
5532 5532
5533SAMSUNG AUDIO (ASoC) DRIVERS 5533SAMSUNG AUDIO (ASoC) DRIVERS
5534M: Jassi Brar <jassisinghbrar@gmail.com> 5534M: Jassi Brar <jassisinghbrar@gmail.com>
5535M: Sangbeom Kim <sbkim73@samsung.com>
5535L: alsa-devel@alsa-project.org (moderated for non-subscribers) 5536L: alsa-devel@alsa-project.org (moderated for non-subscribers)
5536S: Supported 5537S: Supported
5537F: sound/soc/samsung 5538F: sound/soc/samsung
@@ -7087,7 +7088,7 @@ S: Supported
7087F: drivers/mmc/host/vub300.c 7088F: drivers/mmc/host/vub300.c
7088 7089
7089W1 DALLAS'S 1-WIRE BUS 7090W1 DALLAS'S 1-WIRE BUS
7090M: Evgeniy Polyakov <johnpol@2ka.mipt.ru> 7091M: Evgeniy Polyakov <zbr@ioremap.net>
7091S: Maintained 7092S: Maintained
7092F: Documentation/w1/ 7093F: Documentation/w1/
7093F: drivers/w1/ 7094F: drivers/w1/
diff --git a/arch/alpha/include/asm/sysinfo.h b/arch/alpha/include/asm/sysinfo.h
index 086aba284df2..e77d77cd07b8 100644
--- a/arch/alpha/include/asm/sysinfo.h
+++ b/arch/alpha/include/asm/sysinfo.h
@@ -27,13 +27,4 @@
27#define UAC_NOFIX 2 27#define UAC_NOFIX 2
28#define UAC_SIGBUS 4 28#define UAC_SIGBUS 4
29 29
30
31#ifdef __KERNEL__
32
33/* This is the shift that is applied to the UAC bits as stored in the
34 per-thread flags. See thread_info.h. */
35#define UAC_SHIFT 6
36
37#endif
38
39#endif /* __ASM_ALPHA_SYSINFO_H */ 30#endif /* __ASM_ALPHA_SYSINFO_H */
diff --git a/arch/alpha/include/asm/thread_info.h b/arch/alpha/include/asm/thread_info.h
index 6f32f9c84a2d..ff73db022342 100644
--- a/arch/alpha/include/asm/thread_info.h
+++ b/arch/alpha/include/asm/thread_info.h
@@ -74,9 +74,9 @@ register struct thread_info *__current_thread_info __asm__("$8");
74#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 74#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
75#define TIF_POLLING_NRFLAG 8 /* poll_idle is polling NEED_RESCHED */ 75#define TIF_POLLING_NRFLAG 8 /* poll_idle is polling NEED_RESCHED */
76#define TIF_DIE_IF_KERNEL 9 /* dik recursion lock */ 76#define TIF_DIE_IF_KERNEL 9 /* dik recursion lock */
77#define TIF_UAC_NOPRINT 10 /* see sysinfo.h */ 77#define TIF_UAC_NOPRINT 10 /* ! Preserve sequence of following */
78#define TIF_UAC_NOFIX 11 78#define TIF_UAC_NOFIX 11 /* ! flags as they match */
79#define TIF_UAC_SIGBUS 12 79#define TIF_UAC_SIGBUS 12 /* ! userspace part of 'osf_sysinfo' */
80#define TIF_MEMDIE 13 /* is terminating due to OOM killer */ 80#define TIF_MEMDIE 13 /* is terminating due to OOM killer */
81#define TIF_RESTORE_SIGMASK 14 /* restore signal mask in do_signal */ 81#define TIF_RESTORE_SIGMASK 14 /* restore signal mask in do_signal */
82#define TIF_FREEZE 16 /* is freezing for suspend */ 82#define TIF_FREEZE 16 /* is freezing for suspend */
@@ -97,7 +97,7 @@ register struct thread_info *__current_thread_info __asm__("$8");
97#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK \ 97#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK \
98 | _TIF_SYSCALL_TRACE) 98 | _TIF_SYSCALL_TRACE)
99 99
100#define ALPHA_UAC_SHIFT 10 100#define ALPHA_UAC_SHIFT TIF_UAC_NOPRINT
101#define ALPHA_UAC_MASK (1 << TIF_UAC_NOPRINT | 1 << TIF_UAC_NOFIX | \ 101#define ALPHA_UAC_MASK (1 << TIF_UAC_NOPRINT | 1 << TIF_UAC_NOFIX | \
102 1 << TIF_UAC_SIGBUS) 102 1 << TIF_UAC_SIGBUS)
103 103
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
index 326f0a2d56e5..01e8715e26d9 100644
--- a/arch/alpha/kernel/osf_sys.c
+++ b/arch/alpha/kernel/osf_sys.c
@@ -42,6 +42,7 @@
42#include <asm/uaccess.h> 42#include <asm/uaccess.h>
43#include <asm/system.h> 43#include <asm/system.h>
44#include <asm/sysinfo.h> 44#include <asm/sysinfo.h>
45#include <asm/thread_info.h>
45#include <asm/hwrpb.h> 46#include <asm/hwrpb.h>
46#include <asm/processor.h> 47#include <asm/processor.h>
47 48
@@ -633,9 +634,10 @@ SYSCALL_DEFINE5(osf_getsysinfo, unsigned long, op, void __user *, buffer,
633 case GSI_UACPROC: 634 case GSI_UACPROC:
634 if (nbytes < sizeof(unsigned int)) 635 if (nbytes < sizeof(unsigned int))
635 return -EINVAL; 636 return -EINVAL;
636 w = (current_thread_info()->flags >> UAC_SHIFT) & UAC_BITMASK; 637 w = (current_thread_info()->flags >> ALPHA_UAC_SHIFT) &
637 if (put_user(w, (unsigned int __user *)buffer)) 638 UAC_BITMASK;
638 return -EFAULT; 639 if (put_user(w, (unsigned int __user *)buffer))
640 return -EFAULT;
639 return 1; 641 return 1;
640 642
641 case GSI_PROC_TYPE: 643 case GSI_PROC_TYPE:
@@ -756,8 +758,8 @@ SYSCALL_DEFINE5(osf_setsysinfo, unsigned long, op, void __user *, buffer,
756 case SSIN_UACPROC: 758 case SSIN_UACPROC:
757 again: 759 again:
758 old = current_thread_info()->flags; 760 old = current_thread_info()->flags;
759 new = old & ~(UAC_BITMASK << UAC_SHIFT); 761 new = old & ~(UAC_BITMASK << ALPHA_UAC_SHIFT);
760 new = new | (w & UAC_BITMASK) << UAC_SHIFT; 762 new = new | (w & UAC_BITMASK) << ALPHA_UAC_SHIFT;
761 if (cmpxchg(&current_thread_info()->flags, 763 if (cmpxchg(&current_thread_info()->flags,
762 old, new) != old) 764 old, new) != old)
763 goto again; 765 goto again;
diff --git a/arch/cris/include/asm/serial.h b/arch/cris/include/asm/serial.h
new file mode 100644
index 000000000000..af7535a955fb
--- /dev/null
+++ b/arch/cris/include/asm/serial.h
@@ -0,0 +1,9 @@
1#ifndef _ASM_SERIAL_H
2#define _ASM_SERIAL_H
3
4/*
5 * This assumes you have a 1.8432 MHz clock for your UART.
6 */
7#define BASE_BAUD (1843200 / 16)
8
9#endif /* _ASM_SERIAL_H */
diff --git a/arch/m68k/include/asm/page_mm.h b/arch/m68k/include/asm/page_mm.h
index 31d5570d6567..89f201434b5a 100644
--- a/arch/m68k/include/asm/page_mm.h
+++ b/arch/m68k/include/asm/page_mm.h
@@ -162,7 +162,7 @@ static inline __attribute_const__ int __virt_to_node_shift(void)
162 pgdat->node_mem_map + (__pfn - pgdat->node_start_pfn); \ 162 pgdat->node_mem_map + (__pfn - pgdat->node_start_pfn); \
163}) 163})
164#define page_to_pfn(_page) ({ \ 164#define page_to_pfn(_page) ({ \
165 struct page *__p = (_page); \ 165 const struct page *__p = (_page); \
166 struct pglist_data *pgdat; \ 166 struct pglist_data *pgdat; \
167 pgdat = &pg_data_map[page_to_nid(__p)]; \ 167 pgdat = &pg_data_map[page_to_nid(__p)]; \
168 ((__p) - pgdat->node_mem_map) + pgdat->node_start_pfn; \ 168 ((__p) - pgdat->node_mem_map) + pgdat->node_start_pfn; \
diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
index 2de8551df40f..c65f75aa7ff7 100644
--- a/arch/powerpc/sysdev/fsl_rio.c
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -54,6 +54,7 @@
54#define ODSR_CLEAR 0x1c00 54#define ODSR_CLEAR 0x1c00
55#define LTLEECSR_ENABLE_ALL 0xFFC000FC 55#define LTLEECSR_ENABLE_ALL 0xFFC000FC
56#define ESCSR_CLEAR 0x07120204 56#define ESCSR_CLEAR 0x07120204
57#define IECSR_CLEAR 0x80000000
57 58
58#define RIO_PORT1_EDCSR 0x0640 59#define RIO_PORT1_EDCSR 0x0640
59#define RIO_PORT2_EDCSR 0x0680 60#define RIO_PORT2_EDCSR 0x0680
@@ -1089,11 +1090,11 @@ static void port_error_handler(struct rio_mport *port, int offset)
1089 1090
1090 if (offset == 0) { 1091 if (offset == 0) {
1091 out_be32((u32 *)(rio_regs_win + RIO_PORT1_EDCSR), 0); 1092 out_be32((u32 *)(rio_regs_win + RIO_PORT1_EDCSR), 0);
1092 out_be32((u32 *)(rio_regs_win + RIO_PORT1_IECSR), 0); 1093 out_be32((u32 *)(rio_regs_win + RIO_PORT1_IECSR), IECSR_CLEAR);
1093 out_be32((u32 *)(rio_regs_win + RIO_ESCSR), ESCSR_CLEAR); 1094 out_be32((u32 *)(rio_regs_win + RIO_ESCSR), ESCSR_CLEAR);
1094 } else { 1095 } else {
1095 out_be32((u32 *)(rio_regs_win + RIO_PORT2_EDCSR), 0); 1096 out_be32((u32 *)(rio_regs_win + RIO_PORT2_EDCSR), 0);
1096 out_be32((u32 *)(rio_regs_win + RIO_PORT2_IECSR), 0); 1097 out_be32((u32 *)(rio_regs_win + RIO_PORT2_IECSR), IECSR_CLEAR);
1097 out_be32((u32 *)(rio_regs_win + RIO_PORT2_ESCSR), ESCSR_CLEAR); 1098 out_be32((u32 *)(rio_regs_win + RIO_PORT2_ESCSR), ESCSR_CLEAR);
1098 } 1099 }
1099} 1100}
diff --git a/arch/s390/kernel/early.c b/arch/s390/kernel/early.c
index 068f8465c4ee..f297456dba7a 100644
--- a/arch/s390/kernel/early.c
+++ b/arch/s390/kernel/early.c
@@ -396,17 +396,19 @@ static __init void detect_machine_facilities(void)
396static __init void rescue_initrd(void) 396static __init void rescue_initrd(void)
397{ 397{
398#ifdef CONFIG_BLK_DEV_INITRD 398#ifdef CONFIG_BLK_DEV_INITRD
399 unsigned long min_initrd_addr = (unsigned long) _end + (4UL << 20);
399 /* 400 /*
400 * Move the initrd right behind the bss section in case it starts 401 * Just like in case of IPL from VM reader we make sure there is a
401 * within the bss section. So we don't overwrite it when the bss 402 * gap of 4MB between end of kernel and start of initrd.
402 * section gets cleared. 403 * That way we can also be sure that saving an NSS will succeed,
404 * which however only requires different segments.
403 */ 405 */
404 if (!INITRD_START || !INITRD_SIZE) 406 if (!INITRD_START || !INITRD_SIZE)
405 return; 407 return;
406 if (INITRD_START >= (unsigned long) __bss_stop) 408 if (INITRD_START >= min_initrd_addr)
407 return; 409 return;
408 memmove(__bss_stop, (void *) INITRD_START, INITRD_SIZE); 410 memmove((void *) min_initrd_addr, (void *) INITRD_START, INITRD_SIZE);
409 INITRD_START = (unsigned long) __bss_stop; 411 INITRD_START = min_initrd_addr;
410#endif 412#endif
411} 413}
412 414
diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c
index 04361d5a4279..48c710206366 100644
--- a/arch/s390/kernel/ipl.c
+++ b/arch/s390/kernel/ipl.c
@@ -1220,7 +1220,7 @@ static int __init reipl_fcp_init(void)
1220 /* sysfs: create fcp kset for mixing attr group and bin attrs */ 1220 /* sysfs: create fcp kset for mixing attr group and bin attrs */
1221 reipl_fcp_kset = kset_create_and_add(IPL_FCP_STR, NULL, 1221 reipl_fcp_kset = kset_create_and_add(IPL_FCP_STR, NULL,
1222 &reipl_kset->kobj); 1222 &reipl_kset->kobj);
1223 if (!reipl_kset) { 1223 if (!reipl_fcp_kset) {
1224 free_page((unsigned long) reipl_block_fcp); 1224 free_page((unsigned long) reipl_block_fcp);
1225 return -ENOMEM; 1225 return -ENOMEM;
1226 } 1226 }
@@ -1618,7 +1618,8 @@ static struct shutdown_action vmcmd_action = {SHUTDOWN_ACTION_VMCMD_STR,
1618 1618
1619static void stop_run(struct shutdown_trigger *trigger) 1619static void stop_run(struct shutdown_trigger *trigger)
1620{ 1620{
1621 if (strcmp(trigger->name, ON_PANIC_STR) == 0) 1621 if (strcmp(trigger->name, ON_PANIC_STR) == 0 ||
1622 strcmp(trigger->name, ON_RESTART_STR) == 0)
1622 disabled_wait((unsigned long) __builtin_return_address(0)); 1623 disabled_wait((unsigned long) __builtin_return_address(0));
1623 while (sigp(smp_processor_id(), sigp_stop) == sigp_busy) 1624 while (sigp(smp_processor_id(), sigp_stop) == sigp_busy)
1624 cpu_relax(); 1625 cpu_relax();
@@ -1717,7 +1718,7 @@ static void do_panic(void)
1717/* on restart */ 1718/* on restart */
1718 1719
1719static struct shutdown_trigger on_restart_trigger = {ON_RESTART_STR, 1720static struct shutdown_trigger on_restart_trigger = {ON_RESTART_STR,
1720 &reipl_action}; 1721 &stop_action};
1721 1722
1722static ssize_t on_restart_show(struct kobject *kobj, 1723static ssize_t on_restart_show(struct kobject *kobj,
1723 struct kobj_attribute *attr, char *page) 1724 struct kobj_attribute *attr, char *page)
diff --git a/arch/sparc/include/asm/sigcontext.h b/arch/sparc/include/asm/sigcontext.h
index a1607d180354..69914d748130 100644
--- a/arch/sparc/include/asm/sigcontext.h
+++ b/arch/sparc/include/asm/sigcontext.h
@@ -45,6 +45,19 @@ typedef struct {
45 int si_mask; 45 int si_mask;
46} __siginfo32_t; 46} __siginfo32_t;
47 47
48#define __SIGC_MAXWIN 7
49
50typedef struct {
51 unsigned long locals[8];
52 unsigned long ins[8];
53} __siginfo_reg_window;
54
55typedef struct {
56 int wsaved;
57 __siginfo_reg_window reg_window[__SIGC_MAXWIN];
58 unsigned long rwbuf_stkptrs[__SIGC_MAXWIN];
59} __siginfo_rwin_t;
60
48#ifdef CONFIG_SPARC64 61#ifdef CONFIG_SPARC64
49typedef struct { 62typedef struct {
50 unsigned int si_float_regs [64]; 63 unsigned int si_float_regs [64];
@@ -73,6 +86,7 @@ struct sigcontext {
73 unsigned long ss_size; 86 unsigned long ss_size;
74 } sigc_stack; 87 } sigc_stack;
75 unsigned long sigc_mask; 88 unsigned long sigc_mask;
89 __siginfo_rwin_t * sigc_rwin_save;
76}; 90};
77 91
78#else 92#else
diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
index b90b4a1d070a..cb85458f89d2 100644
--- a/arch/sparc/kernel/Makefile
+++ b/arch/sparc/kernel/Makefile
@@ -32,6 +32,7 @@ obj-$(CONFIG_SPARC32) += sun4m_irq.o sun4c_irq.o sun4d_irq.o
32 32
33obj-y += process_$(BITS).o 33obj-y += process_$(BITS).o
34obj-y += signal_$(BITS).o 34obj-y += signal_$(BITS).o
35obj-y += sigutil_$(BITS).o
35obj-$(CONFIG_SPARC32) += ioport.o 36obj-$(CONFIG_SPARC32) += ioport.o
36obj-y += setup_$(BITS).o 37obj-y += setup_$(BITS).o
37obj-y += idprom.o 38obj-y += idprom.o
diff --git a/arch/sparc/kernel/signal32.c b/arch/sparc/kernel/signal32.c
index 75fad425e249..1ba95aff5d59 100644
--- a/arch/sparc/kernel/signal32.c
+++ b/arch/sparc/kernel/signal32.c
@@ -29,6 +29,8 @@
29#include <asm/visasm.h> 29#include <asm/visasm.h>
30#include <asm/compat_signal.h> 30#include <asm/compat_signal.h>
31 31
32#include "sigutil.h"
33
32#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) 34#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
33 35
34/* This magic should be in g_upper[0] for all upper parts 36/* This magic should be in g_upper[0] for all upper parts
@@ -44,14 +46,14 @@ typedef struct {
44struct signal_frame32 { 46struct signal_frame32 {
45 struct sparc_stackf32 ss; 47 struct sparc_stackf32 ss;
46 __siginfo32_t info; 48 __siginfo32_t info;
47 /* __siginfo_fpu32_t * */ u32 fpu_save; 49 /* __siginfo_fpu_t * */ u32 fpu_save;
48 unsigned int insns[2]; 50 unsigned int insns[2];
49 unsigned int extramask[_COMPAT_NSIG_WORDS - 1]; 51 unsigned int extramask[_COMPAT_NSIG_WORDS - 1];
50 unsigned int extra_size; /* Should be sizeof(siginfo_extra_v8plus_t) */ 52 unsigned int extra_size; /* Should be sizeof(siginfo_extra_v8plus_t) */
51 /* Only valid if (info.si_regs.psr & (PSR_VERS|PSR_IMPL)) == PSR_V8PLUS */ 53 /* Only valid if (info.si_regs.psr & (PSR_VERS|PSR_IMPL)) == PSR_V8PLUS */
52 siginfo_extra_v8plus_t v8plus; 54 siginfo_extra_v8plus_t v8plus;
53 __siginfo_fpu_t fpu_state; 55 /* __siginfo_rwin_t * */u32 rwin_save;
54}; 56} __attribute__((aligned(8)));
55 57
56typedef struct compat_siginfo{ 58typedef struct compat_siginfo{
57 int si_signo; 59 int si_signo;
@@ -110,18 +112,14 @@ struct rt_signal_frame32 {
110 compat_siginfo_t info; 112 compat_siginfo_t info;
111 struct pt_regs32 regs; 113 struct pt_regs32 regs;
112 compat_sigset_t mask; 114 compat_sigset_t mask;
113 /* __siginfo_fpu32_t * */ u32 fpu_save; 115 /* __siginfo_fpu_t * */ u32 fpu_save;
114 unsigned int insns[2]; 116 unsigned int insns[2];
115 stack_t32 stack; 117 stack_t32 stack;
116 unsigned int extra_size; /* Should be sizeof(siginfo_extra_v8plus_t) */ 118 unsigned int extra_size; /* Should be sizeof(siginfo_extra_v8plus_t) */
117 /* Only valid if (regs.psr & (PSR_VERS|PSR_IMPL)) == PSR_V8PLUS */ 119 /* Only valid if (regs.psr & (PSR_VERS|PSR_IMPL)) == PSR_V8PLUS */
118 siginfo_extra_v8plus_t v8plus; 120 siginfo_extra_v8plus_t v8plus;
119 __siginfo_fpu_t fpu_state; 121 /* __siginfo_rwin_t * */u32 rwin_save;
120}; 122} __attribute__((aligned(8)));
121
122/* Align macros */
123#define SF_ALIGNEDSZ (((sizeof(struct signal_frame32) + 15) & (~15)))
124#define RT_ALIGNEDSZ (((sizeof(struct rt_signal_frame32) + 15) & (~15)))
125 123
126int copy_siginfo_to_user32(compat_siginfo_t __user *to, siginfo_t *from) 124int copy_siginfo_to_user32(compat_siginfo_t __user *to, siginfo_t *from)
127{ 125{
@@ -192,30 +190,13 @@ int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
192 return 0; 190 return 0;
193} 191}
194 192
195static int restore_fpu_state32(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
196{
197 unsigned long *fpregs = current_thread_info()->fpregs;
198 unsigned long fprs;
199 int err;
200
201 err = __get_user(fprs, &fpu->si_fprs);
202 fprs_write(0);
203 regs->tstate &= ~TSTATE_PEF;
204 if (fprs & FPRS_DL)
205 err |= copy_from_user(fpregs, &fpu->si_float_regs[0], (sizeof(unsigned int) * 32));
206 if (fprs & FPRS_DU)
207 err |= copy_from_user(fpregs+16, &fpu->si_float_regs[32], (sizeof(unsigned int) * 32));
208 err |= __get_user(current_thread_info()->xfsr[0], &fpu->si_fsr);
209 err |= __get_user(current_thread_info()->gsr[0], &fpu->si_gsr);
210 current_thread_info()->fpsaved[0] |= fprs;
211 return err;
212}
213
214void do_sigreturn32(struct pt_regs *regs) 193void do_sigreturn32(struct pt_regs *regs)
215{ 194{
216 struct signal_frame32 __user *sf; 195 struct signal_frame32 __user *sf;
196 compat_uptr_t fpu_save;
197 compat_uptr_t rwin_save;
217 unsigned int psr; 198 unsigned int psr;
218 unsigned pc, npc, fpu_save; 199 unsigned pc, npc;
219 sigset_t set; 200 sigset_t set;
220 unsigned seta[_COMPAT_NSIG_WORDS]; 201 unsigned seta[_COMPAT_NSIG_WORDS];
221 int err, i; 202 int err, i;
@@ -273,8 +254,13 @@ void do_sigreturn32(struct pt_regs *regs)
273 pt_regs_clear_syscall(regs); 254 pt_regs_clear_syscall(regs);
274 255
275 err |= __get_user(fpu_save, &sf->fpu_save); 256 err |= __get_user(fpu_save, &sf->fpu_save);
276 if (fpu_save) 257 if (!err && fpu_save)
277 err |= restore_fpu_state32(regs, &sf->fpu_state); 258 err |= restore_fpu_state(regs, compat_ptr(fpu_save));
259 err |= __get_user(rwin_save, &sf->rwin_save);
260 if (!err && rwin_save) {
261 if (restore_rwin_state(compat_ptr(rwin_save)))
262 goto segv;
263 }
278 err |= __get_user(seta[0], &sf->info.si_mask); 264 err |= __get_user(seta[0], &sf->info.si_mask);
279 err |= copy_from_user(seta+1, &sf->extramask, 265 err |= copy_from_user(seta+1, &sf->extramask,
280 (_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int)); 266 (_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int));
@@ -300,7 +286,9 @@ segv:
300asmlinkage void do_rt_sigreturn32(struct pt_regs *regs) 286asmlinkage void do_rt_sigreturn32(struct pt_regs *regs)
301{ 287{
302 struct rt_signal_frame32 __user *sf; 288 struct rt_signal_frame32 __user *sf;
303 unsigned int psr, pc, npc, fpu_save, u_ss_sp; 289 unsigned int psr, pc, npc, u_ss_sp;
290 compat_uptr_t fpu_save;
291 compat_uptr_t rwin_save;
304 mm_segment_t old_fs; 292 mm_segment_t old_fs;
305 sigset_t set; 293 sigset_t set;
306 compat_sigset_t seta; 294 compat_sigset_t seta;
@@ -359,8 +347,8 @@ asmlinkage void do_rt_sigreturn32(struct pt_regs *regs)
359 pt_regs_clear_syscall(regs); 347 pt_regs_clear_syscall(regs);
360 348
361 err |= __get_user(fpu_save, &sf->fpu_save); 349 err |= __get_user(fpu_save, &sf->fpu_save);
362 if (fpu_save) 350 if (!err && fpu_save)
363 err |= restore_fpu_state32(regs, &sf->fpu_state); 351 err |= restore_fpu_state(regs, compat_ptr(fpu_save));
364 err |= copy_from_user(&seta, &sf->mask, sizeof(compat_sigset_t)); 352 err |= copy_from_user(&seta, &sf->mask, sizeof(compat_sigset_t));
365 err |= __get_user(u_ss_sp, &sf->stack.ss_sp); 353 err |= __get_user(u_ss_sp, &sf->stack.ss_sp);
366 st.ss_sp = compat_ptr(u_ss_sp); 354 st.ss_sp = compat_ptr(u_ss_sp);
@@ -376,6 +364,12 @@ asmlinkage void do_rt_sigreturn32(struct pt_regs *regs)
376 do_sigaltstack((stack_t __user *) &st, NULL, (unsigned long)sf); 364 do_sigaltstack((stack_t __user *) &st, NULL, (unsigned long)sf);
377 set_fs(old_fs); 365 set_fs(old_fs);
378 366
367 err |= __get_user(rwin_save, &sf->rwin_save);
368 if (!err && rwin_save) {
369 if (restore_rwin_state(compat_ptr(rwin_save)))
370 goto segv;
371 }
372
379 switch (_NSIG_WORDS) { 373 switch (_NSIG_WORDS) {
380 case 4: set.sig[3] = seta.sig[6] + (((long)seta.sig[7]) << 32); 374 case 4: set.sig[3] = seta.sig[6] + (((long)seta.sig[7]) << 32);
381 case 3: set.sig[2] = seta.sig[4] + (((long)seta.sig[5]) << 32); 375 case 3: set.sig[2] = seta.sig[4] + (((long)seta.sig[5]) << 32);
@@ -433,26 +427,6 @@ static void __user *get_sigframe(struct sigaction *sa, struct pt_regs *regs, uns
433 return (void __user *) sp; 427 return (void __user *) sp;
434} 428}
435 429
436static int save_fpu_state32(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
437{
438 unsigned long *fpregs = current_thread_info()->fpregs;
439 unsigned long fprs;
440 int err = 0;
441
442 fprs = current_thread_info()->fpsaved[0];
443 if (fprs & FPRS_DL)
444 err |= copy_to_user(&fpu->si_float_regs[0], fpregs,
445 (sizeof(unsigned int) * 32));
446 if (fprs & FPRS_DU)
447 err |= copy_to_user(&fpu->si_float_regs[32], fpregs+16,
448 (sizeof(unsigned int) * 32));
449 err |= __put_user(current_thread_info()->xfsr[0], &fpu->si_fsr);
450 err |= __put_user(current_thread_info()->gsr[0], &fpu->si_gsr);
451 err |= __put_user(fprs, &fpu->si_fprs);
452
453 return err;
454}
455
456/* The I-cache flush instruction only works in the primary ASI, which 430/* The I-cache flush instruction only works in the primary ASI, which
457 * right now is the nucleus, aka. kernel space. 431 * right now is the nucleus, aka. kernel space.
458 * 432 *
@@ -515,18 +489,23 @@ static int setup_frame32(struct k_sigaction *ka, struct pt_regs *regs,
515 int signo, sigset_t *oldset) 489 int signo, sigset_t *oldset)
516{ 490{
517 struct signal_frame32 __user *sf; 491 struct signal_frame32 __user *sf;
492 int i, err, wsaved;
493 void __user *tail;
518 int sigframe_size; 494 int sigframe_size;
519 u32 psr; 495 u32 psr;
520 int i, err;
521 unsigned int seta[_COMPAT_NSIG_WORDS]; 496 unsigned int seta[_COMPAT_NSIG_WORDS];
522 497
523 /* 1. Make sure everything is clean */ 498 /* 1. Make sure everything is clean */
524 synchronize_user_stack(); 499 synchronize_user_stack();
525 save_and_clear_fpu(); 500 save_and_clear_fpu();
526 501
527 sigframe_size = SF_ALIGNEDSZ; 502 wsaved = get_thread_wsaved();
528 if (!(current_thread_info()->fpsaved[0] & FPRS_FEF)) 503
529 sigframe_size -= sizeof(__siginfo_fpu_t); 504 sigframe_size = sizeof(*sf);
505 if (current_thread_info()->fpsaved[0] & FPRS_FEF)
506 sigframe_size += sizeof(__siginfo_fpu_t);
507 if (wsaved)
508 sigframe_size += sizeof(__siginfo_rwin_t);
530 509
531 sf = (struct signal_frame32 __user *) 510 sf = (struct signal_frame32 __user *)
532 get_sigframe(&ka->sa, regs, sigframe_size); 511 get_sigframe(&ka->sa, regs, sigframe_size);
@@ -534,8 +513,7 @@ static int setup_frame32(struct k_sigaction *ka, struct pt_regs *regs,
534 if (invalid_frame_pointer(sf, sigframe_size)) 513 if (invalid_frame_pointer(sf, sigframe_size))
535 goto sigill; 514 goto sigill;
536 515
537 if (get_thread_wsaved() != 0) 516 tail = (sf + 1);
538 goto sigill;
539 517
540 /* 2. Save the current process state */ 518 /* 2. Save the current process state */
541 if (test_thread_flag(TIF_32BIT)) { 519 if (test_thread_flag(TIF_32BIT)) {
@@ -560,11 +538,22 @@ static int setup_frame32(struct k_sigaction *ka, struct pt_regs *regs,
560 &sf->v8plus.asi); 538 &sf->v8plus.asi);
561 539
562 if (psr & PSR_EF) { 540 if (psr & PSR_EF) {
563 err |= save_fpu_state32(regs, &sf->fpu_state); 541 __siginfo_fpu_t __user *fp = tail;
564 err |= __put_user((u64)&sf->fpu_state, &sf->fpu_save); 542 tail += sizeof(*fp);
543 err |= save_fpu_state(regs, fp);
544 err |= __put_user((u64)fp, &sf->fpu_save);
565 } else { 545 } else {
566 err |= __put_user(0, &sf->fpu_save); 546 err |= __put_user(0, &sf->fpu_save);
567 } 547 }
548 if (wsaved) {
549 __siginfo_rwin_t __user *rwp = tail;
550 tail += sizeof(*rwp);
551 err |= save_rwin_state(wsaved, rwp);
552 err |= __put_user((u64)rwp, &sf->rwin_save);
553 set_thread_wsaved(0);
554 } else {
555 err |= __put_user(0, &sf->rwin_save);
556 }
568 557
569 switch (_NSIG_WORDS) { 558 switch (_NSIG_WORDS) {
570 case 4: seta[7] = (oldset->sig[3] >> 32); 559 case 4: seta[7] = (oldset->sig[3] >> 32);
@@ -580,10 +569,21 @@ static int setup_frame32(struct k_sigaction *ka, struct pt_regs *regs,
580 err |= __copy_to_user(sf->extramask, seta + 1, 569 err |= __copy_to_user(sf->extramask, seta + 1,
581 (_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int)); 570 (_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int));
582 571
583 err |= copy_in_user((u32 __user *)sf, 572 if (!wsaved) {
584 (u32 __user *)(regs->u_regs[UREG_FP]), 573 err |= copy_in_user((u32 __user *)sf,
585 sizeof(struct reg_window32)); 574 (u32 __user *)(regs->u_regs[UREG_FP]),
586 575 sizeof(struct reg_window32));
576 } else {
577 struct reg_window *rp;
578
579 rp = &current_thread_info()->reg_window[wsaved - 1];
580 for (i = 0; i < 8; i++)
581 err |= __put_user(rp->locals[i], &sf->ss.locals[i]);
582 for (i = 0; i < 6; i++)
583 err |= __put_user(rp->ins[i], &sf->ss.ins[i]);
584 err |= __put_user(rp->ins[6], &sf->ss.fp);
585 err |= __put_user(rp->ins[7], &sf->ss.callers_pc);
586 }
587 if (err) 587 if (err)
588 goto sigsegv; 588 goto sigsegv;
589 589
@@ -613,7 +613,6 @@ static int setup_frame32(struct k_sigaction *ka, struct pt_regs *regs,
613 err |= __put_user(0x91d02010, &sf->insns[1]); /*t 0x10*/ 613 err |= __put_user(0x91d02010, &sf->insns[1]); /*t 0x10*/
614 if (err) 614 if (err)
615 goto sigsegv; 615 goto sigsegv;
616
617 flush_signal_insns(address); 616 flush_signal_insns(address);
618 } 617 }
619 return 0; 618 return 0;
@@ -632,18 +631,23 @@ static int setup_rt_frame32(struct k_sigaction *ka, struct pt_regs *regs,
632 siginfo_t *info) 631 siginfo_t *info)
633{ 632{
634 struct rt_signal_frame32 __user *sf; 633 struct rt_signal_frame32 __user *sf;
634 int i, err, wsaved;
635 void __user *tail;
635 int sigframe_size; 636 int sigframe_size;
636 u32 psr; 637 u32 psr;
637 int i, err;
638 compat_sigset_t seta; 638 compat_sigset_t seta;
639 639
640 /* 1. Make sure everything is clean */ 640 /* 1. Make sure everything is clean */
641 synchronize_user_stack(); 641 synchronize_user_stack();
642 save_and_clear_fpu(); 642 save_and_clear_fpu();
643 643
644 sigframe_size = RT_ALIGNEDSZ; 644 wsaved = get_thread_wsaved();
645 if (!(current_thread_info()->fpsaved[0] & FPRS_FEF)) 645
646 sigframe_size -= sizeof(__siginfo_fpu_t); 646 sigframe_size = sizeof(*sf);
647 if (current_thread_info()->fpsaved[0] & FPRS_FEF)
648 sigframe_size += sizeof(__siginfo_fpu_t);
649 if (wsaved)
650 sigframe_size += sizeof(__siginfo_rwin_t);
647 651
648 sf = (struct rt_signal_frame32 __user *) 652 sf = (struct rt_signal_frame32 __user *)
649 get_sigframe(&ka->sa, regs, sigframe_size); 653 get_sigframe(&ka->sa, regs, sigframe_size);
@@ -651,8 +655,7 @@ static int setup_rt_frame32(struct k_sigaction *ka, struct pt_regs *regs,
651 if (invalid_frame_pointer(sf, sigframe_size)) 655 if (invalid_frame_pointer(sf, sigframe_size))
652 goto sigill; 656 goto sigill;
653 657
654 if (get_thread_wsaved() != 0) 658 tail = (sf + 1);
655 goto sigill;
656 659
657 /* 2. Save the current process state */ 660 /* 2. Save the current process state */
658 if (test_thread_flag(TIF_32BIT)) { 661 if (test_thread_flag(TIF_32BIT)) {
@@ -677,11 +680,22 @@ static int setup_rt_frame32(struct k_sigaction *ka, struct pt_regs *regs,
677 &sf->v8plus.asi); 680 &sf->v8plus.asi);
678 681
679 if (psr & PSR_EF) { 682 if (psr & PSR_EF) {
680 err |= save_fpu_state32(regs, &sf->fpu_state); 683 __siginfo_fpu_t __user *fp = tail;
681 err |= __put_user((u64)&sf->fpu_state, &sf->fpu_save); 684 tail += sizeof(*fp);
685 err |= save_fpu_state(regs, fp);
686 err |= __put_user((u64)fp, &sf->fpu_save);
682 } else { 687 } else {
683 err |= __put_user(0, &sf->fpu_save); 688 err |= __put_user(0, &sf->fpu_save);
684 } 689 }
690 if (wsaved) {
691 __siginfo_rwin_t __user *rwp = tail;
692 tail += sizeof(*rwp);
693 err |= save_rwin_state(wsaved, rwp);
694 err |= __put_user((u64)rwp, &sf->rwin_save);
695 set_thread_wsaved(0);
696 } else {
697 err |= __put_user(0, &sf->rwin_save);
698 }
685 699
686 /* Update the siginfo structure. */ 700 /* Update the siginfo structure. */
687 err |= copy_siginfo_to_user32(&sf->info, info); 701 err |= copy_siginfo_to_user32(&sf->info, info);
@@ -703,9 +717,21 @@ static int setup_rt_frame32(struct k_sigaction *ka, struct pt_regs *regs,
703 } 717 }
704 err |= __copy_to_user(&sf->mask, &seta, sizeof(compat_sigset_t)); 718 err |= __copy_to_user(&sf->mask, &seta, sizeof(compat_sigset_t));
705 719
706 err |= copy_in_user((u32 __user *)sf, 720 if (!wsaved) {
707 (u32 __user *)(regs->u_regs[UREG_FP]), 721 err |= copy_in_user((u32 __user *)sf,
708 sizeof(struct reg_window32)); 722 (u32 __user *)(regs->u_regs[UREG_FP]),
723 sizeof(struct reg_window32));
724 } else {
725 struct reg_window *rp;
726
727 rp = &current_thread_info()->reg_window[wsaved - 1];
728 for (i = 0; i < 8; i++)
729 err |= __put_user(rp->locals[i], &sf->ss.locals[i]);
730 for (i = 0; i < 6; i++)
731 err |= __put_user(rp->ins[i], &sf->ss.ins[i]);
732 err |= __put_user(rp->ins[6], &sf->ss.fp);
733 err |= __put_user(rp->ins[7], &sf->ss.callers_pc);
734 }
709 if (err) 735 if (err)
710 goto sigsegv; 736 goto sigsegv;
711 737
diff --git a/arch/sparc/kernel/signal_32.c b/arch/sparc/kernel/signal_32.c
index 5e5c5fd03783..04ede8f04add 100644
--- a/arch/sparc/kernel/signal_32.c
+++ b/arch/sparc/kernel/signal_32.c
@@ -26,6 +26,8 @@
26#include <asm/pgtable.h> 26#include <asm/pgtable.h>
27#include <asm/cacheflush.h> /* flush_sig_insns */ 27#include <asm/cacheflush.h> /* flush_sig_insns */
28 28
29#include "sigutil.h"
30
29#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) 31#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
30 32
31extern void fpsave(unsigned long *fpregs, unsigned long *fsr, 33extern void fpsave(unsigned long *fpregs, unsigned long *fsr,
@@ -39,8 +41,8 @@ struct signal_frame {
39 unsigned long insns[2] __attribute__ ((aligned (8))); 41 unsigned long insns[2] __attribute__ ((aligned (8)));
40 unsigned int extramask[_NSIG_WORDS - 1]; 42 unsigned int extramask[_NSIG_WORDS - 1];
41 unsigned int extra_size; /* Should be 0 */ 43 unsigned int extra_size; /* Should be 0 */
42 __siginfo_fpu_t fpu_state; 44 __siginfo_rwin_t __user *rwin_save;
43}; 45} __attribute__((aligned(8)));
44 46
45struct rt_signal_frame { 47struct rt_signal_frame {
46 struct sparc_stackf ss; 48 struct sparc_stackf ss;
@@ -51,8 +53,8 @@ struct rt_signal_frame {
51 unsigned int insns[2]; 53 unsigned int insns[2];
52 stack_t stack; 54 stack_t stack;
53 unsigned int extra_size; /* Should be 0 */ 55 unsigned int extra_size; /* Should be 0 */
54 __siginfo_fpu_t fpu_state; 56 __siginfo_rwin_t __user *rwin_save;
55}; 57} __attribute__((aligned(8)));
56 58
57/* Align macros */ 59/* Align macros */
58#define SF_ALIGNEDSZ (((sizeof(struct signal_frame) + 7) & (~7))) 60#define SF_ALIGNEDSZ (((sizeof(struct signal_frame) + 7) & (~7)))
@@ -79,43 +81,13 @@ asmlinkage int sys_sigsuspend(old_sigset_t set)
79 return _sigpause_common(set); 81 return _sigpause_common(set);
80} 82}
81 83
82static inline int
83restore_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
84{
85 int err;
86#ifdef CONFIG_SMP
87 if (test_tsk_thread_flag(current, TIF_USEDFPU))
88 regs->psr &= ~PSR_EF;
89#else
90 if (current == last_task_used_math) {
91 last_task_used_math = NULL;
92 regs->psr &= ~PSR_EF;
93 }
94#endif
95 set_used_math();
96 clear_tsk_thread_flag(current, TIF_USEDFPU);
97
98 if (!access_ok(VERIFY_READ, fpu, sizeof(*fpu)))
99 return -EFAULT;
100
101 err = __copy_from_user(&current->thread.float_regs[0], &fpu->si_float_regs[0],
102 (sizeof(unsigned long) * 32));
103 err |= __get_user(current->thread.fsr, &fpu->si_fsr);
104 err |= __get_user(current->thread.fpqdepth, &fpu->si_fpqdepth);
105 if (current->thread.fpqdepth != 0)
106 err |= __copy_from_user(&current->thread.fpqueue[0],
107 &fpu->si_fpqueue[0],
108 ((sizeof(unsigned long) +
109 (sizeof(unsigned long *)))*16));
110 return err;
111}
112
113asmlinkage void do_sigreturn(struct pt_regs *regs) 84asmlinkage void do_sigreturn(struct pt_regs *regs)
114{ 85{
115 struct signal_frame __user *sf; 86 struct signal_frame __user *sf;
116 unsigned long up_psr, pc, npc; 87 unsigned long up_psr, pc, npc;
117 sigset_t set; 88 sigset_t set;
118 __siginfo_fpu_t __user *fpu_save; 89 __siginfo_fpu_t __user *fpu_save;
90 __siginfo_rwin_t __user *rwin_save;
119 int err; 91 int err;
120 92
121 /* Always make any pending restarted system calls return -EINTR */ 93 /* Always make any pending restarted system calls return -EINTR */
@@ -150,9 +122,11 @@ asmlinkage void do_sigreturn(struct pt_regs *regs)
150 pt_regs_clear_syscall(regs); 122 pt_regs_clear_syscall(regs);
151 123
152 err |= __get_user(fpu_save, &sf->fpu_save); 124 err |= __get_user(fpu_save, &sf->fpu_save);
153
154 if (fpu_save) 125 if (fpu_save)
155 err |= restore_fpu_state(regs, fpu_save); 126 err |= restore_fpu_state(regs, fpu_save);
127 err |= __get_user(rwin_save, &sf->rwin_save);
128 if (rwin_save)
129 err |= restore_rwin_state(rwin_save);
156 130
157 /* This is pretty much atomic, no amount locking would prevent 131 /* This is pretty much atomic, no amount locking would prevent
158 * the races which exist anyways. 132 * the races which exist anyways.
@@ -180,6 +154,7 @@ asmlinkage void do_rt_sigreturn(struct pt_regs *regs)
180 struct rt_signal_frame __user *sf; 154 struct rt_signal_frame __user *sf;
181 unsigned int psr, pc, npc; 155 unsigned int psr, pc, npc;
182 __siginfo_fpu_t __user *fpu_save; 156 __siginfo_fpu_t __user *fpu_save;
157 __siginfo_rwin_t __user *rwin_save;
183 mm_segment_t old_fs; 158 mm_segment_t old_fs;
184 sigset_t set; 159 sigset_t set;
185 stack_t st; 160 stack_t st;
@@ -207,8 +182,7 @@ asmlinkage void do_rt_sigreturn(struct pt_regs *regs)
207 pt_regs_clear_syscall(regs); 182 pt_regs_clear_syscall(regs);
208 183
209 err |= __get_user(fpu_save, &sf->fpu_save); 184 err |= __get_user(fpu_save, &sf->fpu_save);
210 185 if (!err && fpu_save)
211 if (fpu_save)
212 err |= restore_fpu_state(regs, fpu_save); 186 err |= restore_fpu_state(regs, fpu_save);
213 err |= __copy_from_user(&set, &sf->mask, sizeof(sigset_t)); 187 err |= __copy_from_user(&set, &sf->mask, sizeof(sigset_t));
214 188
@@ -228,6 +202,12 @@ asmlinkage void do_rt_sigreturn(struct pt_regs *regs)
228 do_sigaltstack((const stack_t __user *) &st, NULL, (unsigned long)sf); 202 do_sigaltstack((const stack_t __user *) &st, NULL, (unsigned long)sf);
229 set_fs(old_fs); 203 set_fs(old_fs);
230 204
205 err |= __get_user(rwin_save, &sf->rwin_save);
206 if (!err && rwin_save) {
207 if (restore_rwin_state(rwin_save))
208 goto segv;
209 }
210
231 sigdelsetmask(&set, ~_BLOCKABLE); 211 sigdelsetmask(&set, ~_BLOCKABLE);
232 spin_lock_irq(&current->sighand->siglock); 212 spin_lock_irq(&current->sighand->siglock);
233 current->blocked = set; 213 current->blocked = set;
@@ -280,53 +260,23 @@ static inline void __user *get_sigframe(struct sigaction *sa, struct pt_regs *re
280 return (void __user *) sp; 260 return (void __user *) sp;
281} 261}
282 262
283static inline int
284save_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
285{
286 int err = 0;
287#ifdef CONFIG_SMP
288 if (test_tsk_thread_flag(current, TIF_USEDFPU)) {
289 put_psr(get_psr() | PSR_EF);
290 fpsave(&current->thread.float_regs[0], &current->thread.fsr,
291 &current->thread.fpqueue[0], &current->thread.fpqdepth);
292 regs->psr &= ~(PSR_EF);
293 clear_tsk_thread_flag(current, TIF_USEDFPU);
294 }
295#else
296 if (current == last_task_used_math) {
297 put_psr(get_psr() | PSR_EF);
298 fpsave(&current->thread.float_regs[0], &current->thread.fsr,
299 &current->thread.fpqueue[0], &current->thread.fpqdepth);
300 last_task_used_math = NULL;
301 regs->psr &= ~(PSR_EF);
302 }
303#endif
304 err |= __copy_to_user(&fpu->si_float_regs[0],
305 &current->thread.float_regs[0],
306 (sizeof(unsigned long) * 32));
307 err |= __put_user(current->thread.fsr, &fpu->si_fsr);
308 err |= __put_user(current->thread.fpqdepth, &fpu->si_fpqdepth);
309 if (current->thread.fpqdepth != 0)
310 err |= __copy_to_user(&fpu->si_fpqueue[0],
311 &current->thread.fpqueue[0],
312 ((sizeof(unsigned long) +
313 (sizeof(unsigned long *)))*16));
314 clear_used_math();
315 return err;
316}
317
318static int setup_frame(struct k_sigaction *ka, struct pt_regs *regs, 263static int setup_frame(struct k_sigaction *ka, struct pt_regs *regs,
319 int signo, sigset_t *oldset) 264 int signo, sigset_t *oldset)
320{ 265{
321 struct signal_frame __user *sf; 266 struct signal_frame __user *sf;
322 int sigframe_size, err; 267 int sigframe_size, err, wsaved;
268 void __user *tail;
323 269
324 /* 1. Make sure everything is clean */ 270 /* 1. Make sure everything is clean */
325 synchronize_user_stack(); 271 synchronize_user_stack();
326 272
327 sigframe_size = SF_ALIGNEDSZ; 273 wsaved = current_thread_info()->w_saved;
328 if (!used_math()) 274
329 sigframe_size -= sizeof(__siginfo_fpu_t); 275 sigframe_size = sizeof(*sf);
276 if (used_math())
277 sigframe_size += sizeof(__siginfo_fpu_t);
278 if (wsaved)
279 sigframe_size += sizeof(__siginfo_rwin_t);
330 280
331 sf = (struct signal_frame __user *) 281 sf = (struct signal_frame __user *)
332 get_sigframe(&ka->sa, regs, sigframe_size); 282 get_sigframe(&ka->sa, regs, sigframe_size);
@@ -334,8 +284,7 @@ static int setup_frame(struct k_sigaction *ka, struct pt_regs *regs,
334 if (invalid_frame_pointer(sf, sigframe_size)) 284 if (invalid_frame_pointer(sf, sigframe_size))
335 goto sigill_and_return; 285 goto sigill_and_return;
336 286
337 if (current_thread_info()->w_saved != 0) 287 tail = sf + 1;
338 goto sigill_and_return;
339 288
340 /* 2. Save the current process state */ 289 /* 2. Save the current process state */
341 err = __copy_to_user(&sf->info.si_regs, regs, sizeof(struct pt_regs)); 290 err = __copy_to_user(&sf->info.si_regs, regs, sizeof(struct pt_regs));
@@ -343,17 +292,34 @@ static int setup_frame(struct k_sigaction *ka, struct pt_regs *regs,
343 err |= __put_user(0, &sf->extra_size); 292 err |= __put_user(0, &sf->extra_size);
344 293
345 if (used_math()) { 294 if (used_math()) {
346 err |= save_fpu_state(regs, &sf->fpu_state); 295 __siginfo_fpu_t __user *fp = tail;
347 err |= __put_user(&sf->fpu_state, &sf->fpu_save); 296 tail += sizeof(*fp);
297 err |= save_fpu_state(regs, fp);
298 err |= __put_user(fp, &sf->fpu_save);
348 } else { 299 } else {
349 err |= __put_user(0, &sf->fpu_save); 300 err |= __put_user(0, &sf->fpu_save);
350 } 301 }
302 if (wsaved) {
303 __siginfo_rwin_t __user *rwp = tail;
304 tail += sizeof(*rwp);
305 err |= save_rwin_state(wsaved, rwp);
306 err |= __put_user(rwp, &sf->rwin_save);
307 } else {
308 err |= __put_user(0, &sf->rwin_save);
309 }
351 310
352 err |= __put_user(oldset->sig[0], &sf->info.si_mask); 311 err |= __put_user(oldset->sig[0], &sf->info.si_mask);
353 err |= __copy_to_user(sf->extramask, &oldset->sig[1], 312 err |= __copy_to_user(sf->extramask, &oldset->sig[1],
354 (_NSIG_WORDS - 1) * sizeof(unsigned int)); 313 (_NSIG_WORDS - 1) * sizeof(unsigned int));
355 err |= __copy_to_user(sf, (char *) regs->u_regs[UREG_FP], 314 if (!wsaved) {
356 sizeof(struct reg_window32)); 315 err |= __copy_to_user(sf, (char *) regs->u_regs[UREG_FP],
316 sizeof(struct reg_window32));
317 } else {
318 struct reg_window32 *rp;
319
320 rp = &current_thread_info()->reg_window[wsaved - 1];
321 err |= __copy_to_user(sf, rp, sizeof(struct reg_window32));
322 }
357 if (err) 323 if (err)
358 goto sigsegv; 324 goto sigsegv;
359 325
@@ -399,21 +365,24 @@ static int setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs,
399 int signo, sigset_t *oldset, siginfo_t *info) 365 int signo, sigset_t *oldset, siginfo_t *info)
400{ 366{
401 struct rt_signal_frame __user *sf; 367 struct rt_signal_frame __user *sf;
402 int sigframe_size; 368 int sigframe_size, wsaved;
369 void __user *tail;
403 unsigned int psr; 370 unsigned int psr;
404 int err; 371 int err;
405 372
406 synchronize_user_stack(); 373 synchronize_user_stack();
407 sigframe_size = RT_ALIGNEDSZ; 374 wsaved = current_thread_info()->w_saved;
408 if (!used_math()) 375 sigframe_size = sizeof(*sf);
409 sigframe_size -= sizeof(__siginfo_fpu_t); 376 if (used_math())
377 sigframe_size += sizeof(__siginfo_fpu_t);
378 if (wsaved)
379 sigframe_size += sizeof(__siginfo_rwin_t);
410 sf = (struct rt_signal_frame __user *) 380 sf = (struct rt_signal_frame __user *)
411 get_sigframe(&ka->sa, regs, sigframe_size); 381 get_sigframe(&ka->sa, regs, sigframe_size);
412 if (invalid_frame_pointer(sf, sigframe_size)) 382 if (invalid_frame_pointer(sf, sigframe_size))
413 goto sigill; 383 goto sigill;
414 if (current_thread_info()->w_saved != 0)
415 goto sigill;
416 384
385 tail = sf + 1;
417 err = __put_user(regs->pc, &sf->regs.pc); 386 err = __put_user(regs->pc, &sf->regs.pc);
418 err |= __put_user(regs->npc, &sf->regs.npc); 387 err |= __put_user(regs->npc, &sf->regs.npc);
419 err |= __put_user(regs->y, &sf->regs.y); 388 err |= __put_user(regs->y, &sf->regs.y);
@@ -425,11 +394,21 @@ static int setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs,
425 err |= __put_user(0, &sf->extra_size); 394 err |= __put_user(0, &sf->extra_size);
426 395
427 if (psr & PSR_EF) { 396 if (psr & PSR_EF) {
428 err |= save_fpu_state(regs, &sf->fpu_state); 397 __siginfo_fpu_t *fp = tail;
429 err |= __put_user(&sf->fpu_state, &sf->fpu_save); 398 tail += sizeof(*fp);
399 err |= save_fpu_state(regs, fp);
400 err |= __put_user(fp, &sf->fpu_save);
430 } else { 401 } else {
431 err |= __put_user(0, &sf->fpu_save); 402 err |= __put_user(0, &sf->fpu_save);
432 } 403 }
404 if (wsaved) {
405 __siginfo_rwin_t *rwp = tail;
406 tail += sizeof(*rwp);
407 err |= save_rwin_state(wsaved, rwp);
408 err |= __put_user(rwp, &sf->rwin_save);
409 } else {
410 err |= __put_user(0, &sf->rwin_save);
411 }
433 err |= __copy_to_user(&sf->mask, &oldset->sig[0], sizeof(sigset_t)); 412 err |= __copy_to_user(&sf->mask, &oldset->sig[0], sizeof(sigset_t));
434 413
435 /* Setup sigaltstack */ 414 /* Setup sigaltstack */
@@ -437,8 +416,15 @@ static int setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs,
437 err |= __put_user(sas_ss_flags(regs->u_regs[UREG_FP]), &sf->stack.ss_flags); 416 err |= __put_user(sas_ss_flags(regs->u_regs[UREG_FP]), &sf->stack.ss_flags);
438 err |= __put_user(current->sas_ss_size, &sf->stack.ss_size); 417 err |= __put_user(current->sas_ss_size, &sf->stack.ss_size);
439 418
440 err |= __copy_to_user(sf, (char *) regs->u_regs[UREG_FP], 419 if (!wsaved) {
441 sizeof(struct reg_window32)); 420 err |= __copy_to_user(sf, (char *) regs->u_regs[UREG_FP],
421 sizeof(struct reg_window32));
422 } else {
423 struct reg_window32 *rp;
424
425 rp = &current_thread_info()->reg_window[wsaved - 1];
426 err |= __copy_to_user(sf, rp, sizeof(struct reg_window32));
427 }
442 428
443 err |= copy_siginfo_to_user(&sf->info, info); 429 err |= copy_siginfo_to_user(&sf->info, info);
444 430
diff --git a/arch/sparc/kernel/signal_64.c b/arch/sparc/kernel/signal_64.c
index 006fe4515886..47509df3b893 100644
--- a/arch/sparc/kernel/signal_64.c
+++ b/arch/sparc/kernel/signal_64.c
@@ -34,6 +34,7 @@
34 34
35#include "entry.h" 35#include "entry.h"
36#include "systbls.h" 36#include "systbls.h"
37#include "sigutil.h"
37 38
38#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) 39#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
39 40
@@ -236,7 +237,7 @@ struct rt_signal_frame {
236 __siginfo_fpu_t __user *fpu_save; 237 __siginfo_fpu_t __user *fpu_save;
237 stack_t stack; 238 stack_t stack;
238 sigset_t mask; 239 sigset_t mask;
239 __siginfo_fpu_t fpu_state; 240 __siginfo_rwin_t *rwin_save;
240}; 241};
241 242
242static long _sigpause_common(old_sigset_t set) 243static long _sigpause_common(old_sigset_t set)
@@ -266,33 +267,12 @@ asmlinkage long sys_sigsuspend(old_sigset_t set)
266 return _sigpause_common(set); 267 return _sigpause_common(set);
267} 268}
268 269
269static inline int
270restore_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
271{
272 unsigned long *fpregs = current_thread_info()->fpregs;
273 unsigned long fprs;
274 int err;
275
276 err = __get_user(fprs, &fpu->si_fprs);
277 fprs_write(0);
278 regs->tstate &= ~TSTATE_PEF;
279 if (fprs & FPRS_DL)
280 err |= copy_from_user(fpregs, &fpu->si_float_regs[0],
281 (sizeof(unsigned int) * 32));
282 if (fprs & FPRS_DU)
283 err |= copy_from_user(fpregs+16, &fpu->si_float_regs[32],
284 (sizeof(unsigned int) * 32));
285 err |= __get_user(current_thread_info()->xfsr[0], &fpu->si_fsr);
286 err |= __get_user(current_thread_info()->gsr[0], &fpu->si_gsr);
287 current_thread_info()->fpsaved[0] |= fprs;
288 return err;
289}
290
291void do_rt_sigreturn(struct pt_regs *regs) 270void do_rt_sigreturn(struct pt_regs *regs)
292{ 271{
293 struct rt_signal_frame __user *sf; 272 struct rt_signal_frame __user *sf;
294 unsigned long tpc, tnpc, tstate; 273 unsigned long tpc, tnpc, tstate;
295 __siginfo_fpu_t __user *fpu_save; 274 __siginfo_fpu_t __user *fpu_save;
275 __siginfo_rwin_t __user *rwin_save;
296 sigset_t set; 276 sigset_t set;
297 int err; 277 int err;
298 278
@@ -325,8 +305,8 @@ void do_rt_sigreturn(struct pt_regs *regs)
325 regs->tstate |= (tstate & (TSTATE_ASI | TSTATE_ICC | TSTATE_XCC)); 305 regs->tstate |= (tstate & (TSTATE_ASI | TSTATE_ICC | TSTATE_XCC));
326 306
327 err |= __get_user(fpu_save, &sf->fpu_save); 307 err |= __get_user(fpu_save, &sf->fpu_save);
328 if (fpu_save) 308 if (!err && fpu_save)
329 err |= restore_fpu_state(regs, &sf->fpu_state); 309 err |= restore_fpu_state(regs, fpu_save);
330 310
331 err |= __copy_from_user(&set, &sf->mask, sizeof(sigset_t)); 311 err |= __copy_from_user(&set, &sf->mask, sizeof(sigset_t));
332 err |= do_sigaltstack(&sf->stack, NULL, (unsigned long)sf); 312 err |= do_sigaltstack(&sf->stack, NULL, (unsigned long)sf);
@@ -334,6 +314,12 @@ void do_rt_sigreturn(struct pt_regs *regs)
334 if (err) 314 if (err)
335 goto segv; 315 goto segv;
336 316
317 err |= __get_user(rwin_save, &sf->rwin_save);
318 if (!err && rwin_save) {
319 if (restore_rwin_state(rwin_save))
320 goto segv;
321 }
322
337 regs->tpc = tpc; 323 regs->tpc = tpc;
338 regs->tnpc = tnpc; 324 regs->tnpc = tnpc;
339 325
@@ -351,34 +337,13 @@ segv:
351} 337}
352 338
353/* Checks if the fp is valid */ 339/* Checks if the fp is valid */
354static int invalid_frame_pointer(void __user *fp, int fplen) 340static int invalid_frame_pointer(void __user *fp)
355{ 341{
356 if (((unsigned long) fp) & 15) 342 if (((unsigned long) fp) & 15)
357 return 1; 343 return 1;
358 return 0; 344 return 0;
359} 345}
360 346
361static inline int
362save_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
363{
364 unsigned long *fpregs = current_thread_info()->fpregs;
365 unsigned long fprs;
366 int err = 0;
367
368 fprs = current_thread_info()->fpsaved[0];
369 if (fprs & FPRS_DL)
370 err |= copy_to_user(&fpu->si_float_regs[0], fpregs,
371 (sizeof(unsigned int) * 32));
372 if (fprs & FPRS_DU)
373 err |= copy_to_user(&fpu->si_float_regs[32], fpregs+16,
374 (sizeof(unsigned int) * 32));
375 err |= __put_user(current_thread_info()->xfsr[0], &fpu->si_fsr);
376 err |= __put_user(current_thread_info()->gsr[0], &fpu->si_gsr);
377 err |= __put_user(fprs, &fpu->si_fprs);
378
379 return err;
380}
381
382static inline void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, unsigned long framesize) 347static inline void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, unsigned long framesize)
383{ 348{
384 unsigned long sp = regs->u_regs[UREG_FP] + STACK_BIAS; 349 unsigned long sp = regs->u_regs[UREG_FP] + STACK_BIAS;
@@ -414,34 +379,48 @@ setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs,
414 int signo, sigset_t *oldset, siginfo_t *info) 379 int signo, sigset_t *oldset, siginfo_t *info)
415{ 380{
416 struct rt_signal_frame __user *sf; 381 struct rt_signal_frame __user *sf;
417 int sigframe_size, err; 382 int wsaved, err, sf_size;
383 void __user *tail;
418 384
419 /* 1. Make sure everything is clean */ 385 /* 1. Make sure everything is clean */
420 synchronize_user_stack(); 386 synchronize_user_stack();
421 save_and_clear_fpu(); 387 save_and_clear_fpu();
422 388
423 sigframe_size = sizeof(struct rt_signal_frame); 389 wsaved = get_thread_wsaved();
424 if (!(current_thread_info()->fpsaved[0] & FPRS_FEF))
425 sigframe_size -= sizeof(__siginfo_fpu_t);
426 390
391 sf_size = sizeof(struct rt_signal_frame);
392 if (current_thread_info()->fpsaved[0] & FPRS_FEF)
393 sf_size += sizeof(__siginfo_fpu_t);
394 if (wsaved)
395 sf_size += sizeof(__siginfo_rwin_t);
427 sf = (struct rt_signal_frame __user *) 396 sf = (struct rt_signal_frame __user *)
428 get_sigframe(ka, regs, sigframe_size); 397 get_sigframe(ka, regs, sf_size);
429
430 if (invalid_frame_pointer (sf, sigframe_size))
431 goto sigill;
432 398
433 if (get_thread_wsaved() != 0) 399 if (invalid_frame_pointer (sf))
434 goto sigill; 400 goto sigill;
435 401
402 tail = (sf + 1);
403
436 /* 2. Save the current process state */ 404 /* 2. Save the current process state */
437 err = copy_to_user(&sf->regs, regs, sizeof (*regs)); 405 err = copy_to_user(&sf->regs, regs, sizeof (*regs));
438 406
439 if (current_thread_info()->fpsaved[0] & FPRS_FEF) { 407 if (current_thread_info()->fpsaved[0] & FPRS_FEF) {
440 err |= save_fpu_state(regs, &sf->fpu_state); 408 __siginfo_fpu_t __user *fpu_save = tail;
441 err |= __put_user((u64)&sf->fpu_state, &sf->fpu_save); 409 tail += sizeof(__siginfo_fpu_t);
410 err |= save_fpu_state(regs, fpu_save);
411 err |= __put_user((u64)fpu_save, &sf->fpu_save);
442 } else { 412 } else {
443 err |= __put_user(0, &sf->fpu_save); 413 err |= __put_user(0, &sf->fpu_save);
444 } 414 }
415 if (wsaved) {
416 __siginfo_rwin_t __user *rwin_save = tail;
417 tail += sizeof(__siginfo_rwin_t);
418 err |= save_rwin_state(wsaved, rwin_save);
419 err |= __put_user((u64)rwin_save, &sf->rwin_save);
420 set_thread_wsaved(0);
421 } else {
422 err |= __put_user(0, &sf->rwin_save);
423 }
445 424
446 /* Setup sigaltstack */ 425 /* Setup sigaltstack */
447 err |= __put_user(current->sas_ss_sp, &sf->stack.ss_sp); 426 err |= __put_user(current->sas_ss_sp, &sf->stack.ss_sp);
@@ -450,10 +429,17 @@ setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs,
450 429
451 err |= copy_to_user(&sf->mask, oldset, sizeof(sigset_t)); 430 err |= copy_to_user(&sf->mask, oldset, sizeof(sigset_t));
452 431
453 err |= copy_in_user((u64 __user *)sf, 432 if (!wsaved) {
454 (u64 __user *)(regs->u_regs[UREG_FP]+STACK_BIAS), 433 err |= copy_in_user((u64 __user *)sf,
455 sizeof(struct reg_window)); 434 (u64 __user *)(regs->u_regs[UREG_FP] +
435 STACK_BIAS),
436 sizeof(struct reg_window));
437 } else {
438 struct reg_window *rp;
456 439
440 rp = &current_thread_info()->reg_window[wsaved - 1];
441 err |= copy_to_user(sf, rp, sizeof(struct reg_window));
442 }
457 if (info) 443 if (info)
458 err |= copy_siginfo_to_user(&sf->info, info); 444 err |= copy_siginfo_to_user(&sf->info, info);
459 else { 445 else {
diff --git a/arch/sparc/kernel/sigutil.h b/arch/sparc/kernel/sigutil.h
new file mode 100644
index 000000000000..d223aa432bb6
--- /dev/null
+++ b/arch/sparc/kernel/sigutil.h
@@ -0,0 +1,9 @@
1#ifndef _SIGUTIL_H
2#define _SIGUTIL_H
3
4int save_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu);
5int restore_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu);
6int save_rwin_state(int wsaved, __siginfo_rwin_t __user *rwin);
7int restore_rwin_state(__siginfo_rwin_t __user *rp);
8
9#endif /* _SIGUTIL_H */
diff --git a/arch/sparc/kernel/sigutil_32.c b/arch/sparc/kernel/sigutil_32.c
new file mode 100644
index 000000000000..35c7897b009a
--- /dev/null
+++ b/arch/sparc/kernel/sigutil_32.c
@@ -0,0 +1,120 @@
1#include <linux/kernel.h>
2#include <linux/types.h>
3#include <linux/thread_info.h>
4#include <linux/uaccess.h>
5#include <linux/sched.h>
6
7#include <asm/sigcontext.h>
8#include <asm/fpumacro.h>
9#include <asm/ptrace.h>
10
11#include "sigutil.h"
12
13int save_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
14{
15 int err = 0;
16#ifdef CONFIG_SMP
17 if (test_tsk_thread_flag(current, TIF_USEDFPU)) {
18 put_psr(get_psr() | PSR_EF);
19 fpsave(&current->thread.float_regs[0], &current->thread.fsr,
20 &current->thread.fpqueue[0], &current->thread.fpqdepth);
21 regs->psr &= ~(PSR_EF);
22 clear_tsk_thread_flag(current, TIF_USEDFPU);
23 }
24#else
25 if (current == last_task_used_math) {
26 put_psr(get_psr() | PSR_EF);
27 fpsave(&current->thread.float_regs[0], &current->thread.fsr,
28 &current->thread.fpqueue[0], &current->thread.fpqdepth);
29 last_task_used_math = NULL;
30 regs->psr &= ~(PSR_EF);
31 }
32#endif
33 err |= __copy_to_user(&fpu->si_float_regs[0],
34 &current->thread.float_regs[0],
35 (sizeof(unsigned long) * 32));
36 err |= __put_user(current->thread.fsr, &fpu->si_fsr);
37 err |= __put_user(current->thread.fpqdepth, &fpu->si_fpqdepth);
38 if (current->thread.fpqdepth != 0)
39 err |= __copy_to_user(&fpu->si_fpqueue[0],
40 &current->thread.fpqueue[0],
41 ((sizeof(unsigned long) +
42 (sizeof(unsigned long *)))*16));
43 clear_used_math();
44 return err;
45}
46
47int restore_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
48{
49 int err;
50#ifdef CONFIG_SMP
51 if (test_tsk_thread_flag(current, TIF_USEDFPU))
52 regs->psr &= ~PSR_EF;
53#else
54 if (current == last_task_used_math) {
55 last_task_used_math = NULL;
56 regs->psr &= ~PSR_EF;
57 }
58#endif
59 set_used_math();
60 clear_tsk_thread_flag(current, TIF_USEDFPU);
61
62 if (!access_ok(VERIFY_READ, fpu, sizeof(*fpu)))
63 return -EFAULT;
64
65 err = __copy_from_user(&current->thread.float_regs[0], &fpu->si_float_regs[0],
66 (sizeof(unsigned long) * 32));
67 err |= __get_user(current->thread.fsr, &fpu->si_fsr);
68 err |= __get_user(current->thread.fpqdepth, &fpu->si_fpqdepth);
69 if (current->thread.fpqdepth != 0)
70 err |= __copy_from_user(&current->thread.fpqueue[0],
71 &fpu->si_fpqueue[0],
72 ((sizeof(unsigned long) +
73 (sizeof(unsigned long *)))*16));
74 return err;
75}
76
77int save_rwin_state(int wsaved, __siginfo_rwin_t __user *rwin)
78{
79 int i, err = __put_user(wsaved, &rwin->wsaved);
80
81 for (i = 0; i < wsaved; i++) {
82 struct reg_window32 *rp;
83 unsigned long fp;
84
85 rp = &current_thread_info()->reg_window[i];
86 fp = current_thread_info()->rwbuf_stkptrs[i];
87 err |= copy_to_user(&rwin->reg_window[i], rp,
88 sizeof(struct reg_window32));
89 err |= __put_user(fp, &rwin->rwbuf_stkptrs[i]);
90 }
91 return err;
92}
93
94int restore_rwin_state(__siginfo_rwin_t __user *rp)
95{
96 struct thread_info *t = current_thread_info();
97 int i, wsaved, err;
98
99 __get_user(wsaved, &rp->wsaved);
100 if (wsaved > NSWINS)
101 return -EFAULT;
102
103 err = 0;
104 for (i = 0; i < wsaved; i++) {
105 err |= copy_from_user(&t->reg_window[i],
106 &rp->reg_window[i],
107 sizeof(struct reg_window32));
108 err |= __get_user(t->rwbuf_stkptrs[i],
109 &rp->rwbuf_stkptrs[i]);
110 }
111 if (err)
112 return err;
113
114 t->w_saved = wsaved;
115 synchronize_user_stack();
116 if (t->w_saved)
117 return -EFAULT;
118 return 0;
119
120}
diff --git a/arch/sparc/kernel/sigutil_64.c b/arch/sparc/kernel/sigutil_64.c
new file mode 100644
index 000000000000..e7dc508c38eb
--- /dev/null
+++ b/arch/sparc/kernel/sigutil_64.c
@@ -0,0 +1,93 @@
1#include <linux/kernel.h>
2#include <linux/types.h>
3#include <linux/thread_info.h>
4#include <linux/uaccess.h>
5
6#include <asm/sigcontext.h>
7#include <asm/fpumacro.h>
8#include <asm/ptrace.h>
9
10#include "sigutil.h"
11
12int save_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
13{
14 unsigned long *fpregs = current_thread_info()->fpregs;
15 unsigned long fprs;
16 int err = 0;
17
18 fprs = current_thread_info()->fpsaved[0];
19 if (fprs & FPRS_DL)
20 err |= copy_to_user(&fpu->si_float_regs[0], fpregs,
21 (sizeof(unsigned int) * 32));
22 if (fprs & FPRS_DU)
23 err |= copy_to_user(&fpu->si_float_regs[32], fpregs+16,
24 (sizeof(unsigned int) * 32));
25 err |= __put_user(current_thread_info()->xfsr[0], &fpu->si_fsr);
26 err |= __put_user(current_thread_info()->gsr[0], &fpu->si_gsr);
27 err |= __put_user(fprs, &fpu->si_fprs);
28
29 return err;
30}
31
32int restore_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
33{
34 unsigned long *fpregs = current_thread_info()->fpregs;
35 unsigned long fprs;
36 int err;
37
38 err = __get_user(fprs, &fpu->si_fprs);
39 fprs_write(0);
40 regs->tstate &= ~TSTATE_PEF;
41 if (fprs & FPRS_DL)
42 err |= copy_from_user(fpregs, &fpu->si_float_regs[0],
43 (sizeof(unsigned int) * 32));
44 if (fprs & FPRS_DU)
45 err |= copy_from_user(fpregs+16, &fpu->si_float_regs[32],
46 (sizeof(unsigned int) * 32));
47 err |= __get_user(current_thread_info()->xfsr[0], &fpu->si_fsr);
48 err |= __get_user(current_thread_info()->gsr[0], &fpu->si_gsr);
49 current_thread_info()->fpsaved[0] |= fprs;
50 return err;
51}
52
53int save_rwin_state(int wsaved, __siginfo_rwin_t __user *rwin)
54{
55 int i, err = __put_user(wsaved, &rwin->wsaved);
56
57 for (i = 0; i < wsaved; i++) {
58 struct reg_window *rp = &current_thread_info()->reg_window[i];
59 unsigned long fp = current_thread_info()->rwbuf_stkptrs[i];
60
61 err |= copy_to_user(&rwin->reg_window[i], rp,
62 sizeof(struct reg_window));
63 err |= __put_user(fp, &rwin->rwbuf_stkptrs[i]);
64 }
65 return err;
66}
67
68int restore_rwin_state(__siginfo_rwin_t __user *rp)
69{
70 struct thread_info *t = current_thread_info();
71 int i, wsaved, err;
72
73 __get_user(wsaved, &rp->wsaved);
74 if (wsaved > NSWINS)
75 return -EFAULT;
76
77 err = 0;
78 for (i = 0; i < wsaved; i++) {
79 err |= copy_from_user(&t->reg_window[i],
80 &rp->reg_window[i],
81 sizeof(struct reg_window));
82 err |= __get_user(t->rwbuf_stkptrs[i],
83 &rp->rwbuf_stkptrs[i]);
84 }
85 if (err)
86 return err;
87
88 set_thread_wsaved(wsaved);
89 synchronize_user_stack();
90 if (get_thread_wsaved())
91 return -EFAULT;
92 return 0;
93}
diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
index adc66c3a1fef..34b18594e724 100644
--- a/arch/x86/kernel/apic/x2apic_uv_x.c
+++ b/arch/x86/kernel/apic/x2apic_uv_x.c
@@ -207,7 +207,6 @@ static int __cpuinit uv_wakeup_secondary(int phys_apicid, unsigned long start_ri
207 ((start_rip << UVH_IPI_INT_VECTOR_SHFT) >> 12) | 207 ((start_rip << UVH_IPI_INT_VECTOR_SHFT) >> 12) |
208 APIC_DM_INIT; 208 APIC_DM_INIT;
209 uv_write_global_mmr64(pnode, UVH_IPI_INT, val); 209 uv_write_global_mmr64(pnode, UVH_IPI_INT, val);
210 mdelay(10);
211 210
212 val = (1UL << UVH_IPI_INT_SEND_SHFT) | 211 val = (1UL << UVH_IPI_INT_SEND_SHFT) |
213 (phys_apicid << UVH_IPI_INT_APIC_ID_SHFT) | 212 (phys_apicid << UVH_IPI_INT_APIC_ID_SHFT) |
diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
index 08119a37e53c..6b96110bb0c3 100644
--- a/arch/x86/kernel/cpu/mtrr/main.c
+++ b/arch/x86/kernel/cpu/mtrr/main.c
@@ -149,7 +149,6 @@ struct set_mtrr_data {
149 */ 149 */
150static int mtrr_rendezvous_handler(void *info) 150static int mtrr_rendezvous_handler(void *info)
151{ 151{
152#ifdef CONFIG_SMP
153 struct set_mtrr_data *data = info; 152 struct set_mtrr_data *data = info;
154 153
155 /* 154 /*
@@ -171,7 +170,6 @@ static int mtrr_rendezvous_handler(void *info)
171 } else if (mtrr_aps_delayed_init || !cpu_online(smp_processor_id())) { 170 } else if (mtrr_aps_delayed_init || !cpu_online(smp_processor_id())) {
172 mtrr_if->set_all(); 171 mtrr_if->set_all();
173 } 172 }
174#endif
175 return 0; 173 return 0;
176} 174}
177 175
diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 5c1a91974918..f3f6f5344001 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -54,6 +54,7 @@
54#include <asm/ftrace.h> 54#include <asm/ftrace.h>
55#include <asm/irq_vectors.h> 55#include <asm/irq_vectors.h>
56#include <asm/cpufeature.h> 56#include <asm/cpufeature.h>
57#include <asm/alternative-asm.h>
57 58
58/* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */ 59/* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
59#include <linux/elf-em.h> 60#include <linux/elf-em.h>
@@ -873,12 +874,7 @@ ENTRY(simd_coprocessor_error)
873661: pushl_cfi $do_general_protection 874661: pushl_cfi $do_general_protection
874662: 875662:
875.section .altinstructions,"a" 876.section .altinstructions,"a"
876 .balign 4 877 altinstruction_entry 661b, 663f, X86_FEATURE_XMM, 662b-661b, 664f-663f
877 .long 661b
878 .long 663f
879 .word X86_FEATURE_XMM
880 .byte 662b-661b
881 .byte 664f-663f
882.previous 878.previous
883.section .altinstr_replacement,"ax" 879.section .altinstr_replacement,"ax"
884663: pushl $do_simd_coprocessor_error 880663: pushl $do_simd_coprocessor_error
diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
index 7000e74b3087..58425adc22c6 100644
--- a/arch/x86/platform/mrst/mrst.c
+++ b/arch/x86/platform/mrst/mrst.c
@@ -689,7 +689,9 @@ static int __init sfi_parse_devs(struct sfi_table_header *table)
689 irq_attr.trigger = 1; 689 irq_attr.trigger = 1;
690 irq_attr.polarity = 1; 690 irq_attr.polarity = 1;
691 io_apic_set_pci_routing(NULL, pentry->irq, &irq_attr); 691 io_apic_set_pci_routing(NULL, pentry->irq, &irq_attr);
692 } 692 } else
693 pentry->irq = 0; /* No irq */
694
693 switch (pentry->type) { 695 switch (pentry->type) {
694 case SFI_DEV_TYPE_IPC: 696 case SFI_DEV_TYPE_IPC:
695 /* ID as IRQ is a hack that will go away */ 697 /* ID as IRQ is a hack that will go away */
diff --git a/arch/x86/platform/olpc/olpc.c b/arch/x86/platform/olpc/olpc.c
index 8b9940e78e2f..7cce722667b8 100644
--- a/arch/x86/platform/olpc/olpc.c
+++ b/arch/x86/platform/olpc/olpc.c
@@ -161,13 +161,13 @@ restart:
161 if (inbuf && inlen) { 161 if (inbuf && inlen) {
162 /* write data to EC */ 162 /* write data to EC */
163 for (i = 0; i < inlen; i++) { 163 for (i = 0; i < inlen; i++) {
164 pr_devel("olpc-ec: sending cmd arg 0x%x\n", inbuf[i]);
165 outb(inbuf[i], 0x68);
164 if (wait_on_ibf(0x6c, 0)) { 166 if (wait_on_ibf(0x6c, 0)) {
165 printk(KERN_ERR "olpc-ec: timeout waiting for" 167 printk(KERN_ERR "olpc-ec: timeout waiting for"
166 " EC accept data!\n"); 168 " EC accept data!\n");
167 goto err; 169 goto err;
168 } 170 }
169 pr_devel("olpc-ec: sending cmd arg 0x%x\n", inbuf[i]);
170 outb(inbuf[i], 0x68);
171 } 171 }
172 } 172 }
173 if (outbuf && outlen) { 173 if (outbuf && outlen) {
diff --git a/arch/x86/vdso/vdso32/sysenter.S b/arch/x86/vdso/vdso32/sysenter.S
index e2800affa754..e354bceee0e0 100644
--- a/arch/x86/vdso/vdso32/sysenter.S
+++ b/arch/x86/vdso/vdso32/sysenter.S
@@ -43,7 +43,7 @@ __kernel_vsyscall:
43 .space 7,0x90 43 .space 7,0x90
44 44
45 /* 14: System call restart point is here! (SYSENTER_RETURN-2) */ 45 /* 14: System call restart point is here! (SYSENTER_RETURN-2) */
46 jmp .Lenter_kernel 46 int $0x80
47 /* 16: System call normal return point is here! */ 47 /* 16: System call normal return point is here! */
48VDSO32_SYSENTER_RETURN: /* Symbol used by sysenter.c via vdso32-syms.h */ 48VDSO32_SYSENTER_RETURN: /* Symbol used by sysenter.c via vdso32-syms.h */
49 pop %ebp 49 pop %ebp
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index bbb03e6f7255..06ed6b4e7df5 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -521,11 +521,6 @@ static int _request_firmware(const struct firmware **firmware_p,
521 if (!firmware_p) 521 if (!firmware_p)
522 return -EINVAL; 522 return -EINVAL;
523 523
524 if (WARN_ON(usermodehelper_is_disabled())) {
525 dev_err(device, "firmware: %s will not be loaded\n", name);
526 return -EBUSY;
527 }
528
529 *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL); 524 *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL);
530 if (!firmware) { 525 if (!firmware) {
531 dev_err(device, "%s: kmalloc(struct firmware) failed\n", 526 dev_err(device, "%s: kmalloc(struct firmware) failed\n",
@@ -539,6 +534,12 @@ static int _request_firmware(const struct firmware **firmware_p,
539 return 0; 534 return 0;
540 } 535 }
541 536
537 if (WARN_ON(usermodehelper_is_disabled())) {
538 dev_err(device, "firmware: %s will not be loaded\n", name);
539 retval = -EBUSY;
540 goto out;
541 }
542
542 if (uevent) 543 if (uevent)
543 dev_dbg(device, "firmware: requesting %s\n", name); 544 dev_dbg(device, "firmware: requesting %s\n", name);
544 545
diff --git a/drivers/char/msm_smd_pkt.c b/drivers/char/msm_smd_pkt.c
index b6f8a65c9960..8eca55deb3a3 100644
--- a/drivers/char/msm_smd_pkt.c
+++ b/drivers/char/msm_smd_pkt.c
@@ -379,9 +379,8 @@ static int __init smd_pkt_init(void)
379 for (i = 0; i < NUM_SMD_PKT_PORTS; ++i) { 379 for (i = 0; i < NUM_SMD_PKT_PORTS; ++i) {
380 smd_pkt_devp[i] = kzalloc(sizeof(struct smd_pkt_dev), 380 smd_pkt_devp[i] = kzalloc(sizeof(struct smd_pkt_dev),
381 GFP_KERNEL); 381 GFP_KERNEL);
382 if (IS_ERR(smd_pkt_devp[i])) { 382 if (!smd_pkt_devp[i]) {
383 r = PTR_ERR(smd_pkt_devp[i]); 383 pr_err("kmalloc() failed\n");
384 pr_err("kmalloc() failed %d\n", r);
385 goto clean_cdevs; 384 goto clean_cdevs;
386 } 385 }
387 386
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index 7f65940f918f..4f0c1ecac72e 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -466,6 +466,16 @@ static bool radeon_connector_needs_extended_probe(struct radeon_device *dev,
466 (supported_device == ATOM_DEVICE_DFP2_SUPPORT)) 466 (supported_device == ATOM_DEVICE_DFP2_SUPPORT))
467 return true; 467 return true;
468 } 468 }
469 /* TOSHIBA Satellite L300D with ATI Mobility Radeon x1100
470 * (RS690M) sends data to i2c bus for a HDMI connector that
471 * is not implemented */
472 if ((dev->pdev->device == 0x791f) &&
473 (dev->pdev->subsystem_vendor == 0x1179) &&
474 (dev->pdev->subsystem_device == 0xff68)) {
475 if ((connector_type == DRM_MODE_CONNECTOR_HDMIA) &&
476 (supported_device == ATOM_DEVICE_DFP2_SUPPORT))
477 return true;
478 }
469 479
470 /* Default: no EDID header probe required for DDC probing */ 480 /* Default: no EDID header probe required for DDC probing */
471 return false; 481 return false;
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index a3b011b49465..b51e15725c6e 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -301,6 +301,8 @@ void radeon_vram_location(struct radeon_device *rdev, struct radeon_mc *mc, u64
301 mc->mc_vram_size = mc->aper_size; 301 mc->mc_vram_size = mc->aper_size;
302 } 302 }
303 mc->vram_end = mc->vram_start + mc->mc_vram_size - 1; 303 mc->vram_end = mc->vram_start + mc->mc_vram_size - 1;
304 if (radeon_vram_limit && radeon_vram_limit < mc->real_vram_size)
305 mc->real_vram_size = radeon_vram_limit;
304 dev_info(rdev->dev, "VRAM: %lluM 0x%016llX - 0x%016llX (%lluM used)\n", 306 dev_info(rdev->dev, "VRAM: %lluM 0x%016llX - 0x%016llX (%lluM used)\n",
305 mc->mc_vram_size >> 20, mc->vram_start, 307 mc->mc_vram_size >> 20, mc->vram_start,
306 mc->vram_end, mc->real_vram_size >> 20); 308 mc->vram_end, mc->real_vram_size >> 20);
diff --git a/drivers/gpu/drm/radeon/radeon_test.c b/drivers/gpu/drm/radeon/radeon_test.c
index dee4a0c1b4b2..602fa3541c45 100644
--- a/drivers/gpu/drm/radeon/radeon_test.c
+++ b/drivers/gpu/drm/radeon/radeon_test.c
@@ -40,10 +40,14 @@ void radeon_test_moves(struct radeon_device *rdev)
40 size = 1024 * 1024; 40 size = 1024 * 1024;
41 41
42 /* Number of tests = 42 /* Number of tests =
43 * (Total GTT - IB pool - writeback page - ring buffer) / test size 43 * (Total GTT - IB pool - writeback page - ring buffers) / test size
44 */ 44 */
45 n = ((u32)(rdev->mc.gtt_size - RADEON_IB_POOL_SIZE*64*1024 - RADEON_GPU_PAGE_SIZE - 45 n = rdev->mc.gtt_size - RADEON_IB_POOL_SIZE*64*1024 - rdev->cp.ring_size;
46 rdev->cp.ring_size)) / size; 46 if (rdev->wb.wb_obj)
47 n -= RADEON_GPU_PAGE_SIZE;
48 if (rdev->ih.ring_obj)
49 n -= rdev->ih.ring_size;
50 n /= size;
47 51
48 gtt_obj = kzalloc(n * sizeof(*gtt_obj), GFP_KERNEL); 52 gtt_obj = kzalloc(n * sizeof(*gtt_obj), GFP_KERNEL);
49 if (!gtt_obj) { 53 if (!gtt_obj) {
@@ -132,9 +136,15 @@ void radeon_test_moves(struct radeon_device *rdev)
132 gtt_start++, vram_start++) { 136 gtt_start++, vram_start++) {
133 if (*vram_start != gtt_start) { 137 if (*vram_start != gtt_start) {
134 DRM_ERROR("Incorrect GTT->VRAM copy %d: Got 0x%p, " 138 DRM_ERROR("Incorrect GTT->VRAM copy %d: Got 0x%p, "
135 "expected 0x%p (GTT map 0x%p-0x%p)\n", 139 "expected 0x%p (GTT/VRAM offset "
136 i, *vram_start, gtt_start, gtt_map, 140 "0x%16llx/0x%16llx)\n",
137 gtt_end); 141 i, *vram_start, gtt_start,
142 (unsigned long long)
143 (gtt_addr - rdev->mc.gtt_start +
144 (void*)gtt_start - gtt_map),
145 (unsigned long long)
146 (vram_addr - rdev->mc.vram_start +
147 (void*)gtt_start - gtt_map));
138 radeon_bo_kunmap(vram_obj); 148 radeon_bo_kunmap(vram_obj);
139 goto out_cleanup; 149 goto out_cleanup;
140 } 150 }
@@ -175,9 +185,15 @@ void radeon_test_moves(struct radeon_device *rdev)
175 gtt_start++, vram_start++) { 185 gtt_start++, vram_start++) {
176 if (*gtt_start != vram_start) { 186 if (*gtt_start != vram_start) {
177 DRM_ERROR("Incorrect VRAM->GTT copy %d: Got 0x%p, " 187 DRM_ERROR("Incorrect VRAM->GTT copy %d: Got 0x%p, "
178 "expected 0x%p (VRAM map 0x%p-0x%p)\n", 188 "expected 0x%p (VRAM/GTT offset "
179 i, *gtt_start, vram_start, vram_map, 189 "0x%16llx/0x%16llx)\n",
180 vram_end); 190 i, *gtt_start, vram_start,
191 (unsigned long long)
192 (vram_addr - rdev->mc.vram_start +
193 (void*)vram_start - vram_map),
194 (unsigned long long)
195 (gtt_addr - rdev->mc.gtt_start +
196 (void*)vram_start - vram_map));
181 radeon_bo_kunmap(gtt_obj[i]); 197 radeon_bo_kunmap(gtt_obj[i]);
182 goto out_cleanup; 198 goto out_cleanup;
183 } 199 }
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index 60125ddba1e9..9b86fb0e4122 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -450,6 +450,29 @@ static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_
450 return -EINVAL; 450 return -EINVAL;
451 mem->bus.base = rdev->mc.aper_base; 451 mem->bus.base = rdev->mc.aper_base;
452 mem->bus.is_iomem = true; 452 mem->bus.is_iomem = true;
453#ifdef __alpha__
454 /*
455 * Alpha: use bus.addr to hold the ioremap() return,
456 * so we can modify bus.base below.
457 */
458 if (mem->placement & TTM_PL_FLAG_WC)
459 mem->bus.addr =
460 ioremap_wc(mem->bus.base + mem->bus.offset,
461 mem->bus.size);
462 else
463 mem->bus.addr =
464 ioremap_nocache(mem->bus.base + mem->bus.offset,
465 mem->bus.size);
466
467 /*
468 * Alpha: Use just the bus offset plus
469 * the hose/domain memory base for bus.base.
470 * It then can be used to build PTEs for VRAM
471 * access, as done in ttm_bo_vm_fault().
472 */
473 mem->bus.base = (mem->bus.base & 0x0ffffffffUL) +
474 rdev->ddev->hose->dense_mem_base;
475#endif
453 break; 476 break;
454 default: 477 default:
455 return -EINVAL; 478 return -EINVAL;
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 56619f64b6bf..a4d38d85909a 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -353,8 +353,10 @@ static int ttm_bo_add_ttm(struct ttm_buffer_object *bo, bool zero_alloc)
353 353
354 ret = ttm_tt_set_user(bo->ttm, current, 354 ret = ttm_tt_set_user(bo->ttm, current,
355 bo->buffer_start, bo->num_pages); 355 bo->buffer_start, bo->num_pages);
356 if (unlikely(ret != 0)) 356 if (unlikely(ret != 0)) {
357 ttm_tt_destroy(bo->ttm); 357 ttm_tt_destroy(bo->ttm);
358 bo->ttm = NULL;
359 }
358 break; 360 break;
359 default: 361 default:
360 printk(KERN_ERR TTM_PFX "Illegal buffer object type\n"); 362 printk(KERN_ERR TTM_PFX "Illegal buffer object type\n");
@@ -390,10 +392,12 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
390 * Create and bind a ttm if required. 392 * Create and bind a ttm if required.
391 */ 393 */
392 394
393 if (!(new_man->flags & TTM_MEMTYPE_FLAG_FIXED) && (bo->ttm == NULL)) { 395 if (!(new_man->flags & TTM_MEMTYPE_FLAG_FIXED)) {
394 ret = ttm_bo_add_ttm(bo, false); 396 if (bo->ttm == NULL) {
395 if (ret) 397 ret = ttm_bo_add_ttm(bo, false);
396 goto out_err; 398 if (ret)
399 goto out_err;
400 }
397 401
398 ret = ttm_tt_set_placement_caching(bo->ttm, mem->placement); 402 ret = ttm_tt_set_placement_caching(bo->ttm, mem->placement);
399 if (ret) 403 if (ret)
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 77dbf408c0d0..ae3c6f5dd2b7 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -635,13 +635,13 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
635 if (ret) 635 if (ret)
636 return ret; 636 return ret;
637 637
638 ttm_bo_free_old_node(bo);
639 if ((man->flags & TTM_MEMTYPE_FLAG_FIXED) && 638 if ((man->flags & TTM_MEMTYPE_FLAG_FIXED) &&
640 (bo->ttm != NULL)) { 639 (bo->ttm != NULL)) {
641 ttm_tt_unbind(bo->ttm); 640 ttm_tt_unbind(bo->ttm);
642 ttm_tt_destroy(bo->ttm); 641 ttm_tt_destroy(bo->ttm);
643 bo->ttm = NULL; 642 bo->ttm = NULL;
644 } 643 }
644 ttm_bo_free_old_node(bo);
645 } else { 645 } else {
646 /** 646 /**
647 * This should help pipeline ordinary buffer moves. 647 * This should help pipeline ordinary buffer moves.
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 306b15f39c9c..1130a8987125 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -589,6 +589,7 @@ config HID_WACOM_POWER_SUPPLY
589config HID_WIIMOTE 589config HID_WIIMOTE
590 tristate "Nintendo Wii Remote support" 590 tristate "Nintendo Wii Remote support"
591 depends on BT_HIDP 591 depends on BT_HIDP
592 depends on LEDS_CLASS
592 ---help--- 593 ---help---
593 Support for the Nintendo Wii Remote bluetooth device. 594 Support for the Nintendo Wii Remote bluetooth device.
594 595
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
index b85744fe8464..18b3bc646bf3 100644
--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@ -444,6 +444,12 @@ static const struct hid_device_id apple_devices[] = {
444 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS), 444 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS),
445 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | 445 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
446 APPLE_RDESC_JIS }, 446 APPLE_RDESC_JIS },
447 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI),
448 .driver_data = APPLE_HAS_FN },
449 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ISO),
450 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
451 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_JIS),
452 .driver_data = APPLE_HAS_FN },
447 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI), 453 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI),
448 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, 454 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
449 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO), 455 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO),
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 1a5cf0c9cfca..242353df3dc4 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1340,6 +1340,9 @@ static const struct hid_device_id hid_have_special_driver[] = {
1340 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) }, 1340 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) },
1341 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) }, 1341 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) },
1342 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) }, 1342 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) },
1343 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI) },
1344 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ISO) },
1345 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_JIS) },
1343 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) }, 1346 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) },
1344 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) }, 1347 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) },
1345 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) }, 1348 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) },
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index db63ccf21cc8..7d27d2b0445a 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -109,6 +109,9 @@
109#define USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI 0x0245 109#define USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI 0x0245
110#define USB_DEVICE_ID_APPLE_WELLSPRING5_ISO 0x0246 110#define USB_DEVICE_ID_APPLE_WELLSPRING5_ISO 0x0246
111#define USB_DEVICE_ID_APPLE_WELLSPRING5_JIS 0x0247 111#define USB_DEVICE_ID_APPLE_WELLSPRING5_JIS 0x0247
112#define USB_DEVICE_ID_APPLE_ALU_REVB_ANSI 0x024f
113#define USB_DEVICE_ID_APPLE_ALU_REVB_ISO 0x0250
114#define USB_DEVICE_ID_APPLE_ALU_REVB_JIS 0x0251
112#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI 0x0239 115#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI 0x0239
113#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO 0x023a 116#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO 0x023a
114#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS 0x023b 117#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS 0x023b
@@ -576,6 +579,9 @@
576#define USB_DEVICE_ID_SAMSUNG_IR_REMOTE 0x0001 579#define USB_DEVICE_ID_SAMSUNG_IR_REMOTE 0x0001
577#define USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE 0x0600 580#define USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE 0x0600
578 581
582#define USB_VENDOR_ID_SIGMA_MICRO 0x1c4f
583#define USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD 0x0002
584
579#define USB_VENDOR_ID_SKYCABLE 0x1223 585#define USB_VENDOR_ID_SKYCABLE 0x1223
580#define USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER 0x3F07 586#define USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER 0x3F07
581 587
diff --git a/drivers/hid/hid-wiimote.c b/drivers/hid/hid-wiimote.c
index a594383ce03d..85a02e5f9fe8 100644
--- a/drivers/hid/hid-wiimote.c
+++ b/drivers/hid/hid-wiimote.c
@@ -10,10 +10,10 @@
10 * any later version. 10 * any later version.
11 */ 11 */
12 12
13#include <linux/atomic.h>
14#include <linux/device.h> 13#include <linux/device.h>
15#include <linux/hid.h> 14#include <linux/hid.h>
16#include <linux/input.h> 15#include <linux/input.h>
16#include <linux/leds.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/spinlock.h> 18#include <linux/spinlock.h>
19#include "hid-ids.h" 19#include "hid-ids.h"
@@ -33,9 +33,9 @@ struct wiimote_state {
33}; 33};
34 34
35struct wiimote_data { 35struct wiimote_data {
36 atomic_t ready;
37 struct hid_device *hdev; 36 struct hid_device *hdev;
38 struct input_dev *input; 37 struct input_dev *input;
38 struct led_classdev *leds[4];
39 39
40 spinlock_t qlock; 40 spinlock_t qlock;
41 __u8 head; 41 __u8 head;
@@ -53,8 +53,15 @@ struct wiimote_data {
53#define WIIPROTO_FLAGS_LEDS (WIIPROTO_FLAG_LED1 | WIIPROTO_FLAG_LED2 | \ 53#define WIIPROTO_FLAGS_LEDS (WIIPROTO_FLAG_LED1 | WIIPROTO_FLAG_LED2 | \
54 WIIPROTO_FLAG_LED3 | WIIPROTO_FLAG_LED4) 54 WIIPROTO_FLAG_LED3 | WIIPROTO_FLAG_LED4)
55 55
56/* return flag for led \num */
57#define WIIPROTO_FLAG_LED(num) (WIIPROTO_FLAG_LED1 << (num - 1))
58
56enum wiiproto_reqs { 59enum wiiproto_reqs {
60 WIIPROTO_REQ_NULL = 0x0,
57 WIIPROTO_REQ_LED = 0x11, 61 WIIPROTO_REQ_LED = 0x11,
62 WIIPROTO_REQ_DRM = 0x12,
63 WIIPROTO_REQ_STATUS = 0x20,
64 WIIPROTO_REQ_RETURN = 0x22,
58 WIIPROTO_REQ_DRM_K = 0x30, 65 WIIPROTO_REQ_DRM_K = 0x30,
59}; 66};
60 67
@@ -87,9 +94,6 @@ static __u16 wiiproto_keymap[] = {
87 BTN_MODE, /* WIIPROTO_KEY_HOME */ 94 BTN_MODE, /* WIIPROTO_KEY_HOME */
88}; 95};
89 96
90#define dev_to_wii(pdev) hid_get_drvdata(container_of(pdev, struct hid_device, \
91 dev))
92
93static ssize_t wiimote_hid_send(struct hid_device *hdev, __u8 *buffer, 97static ssize_t wiimote_hid_send(struct hid_device *hdev, __u8 *buffer,
94 size_t count) 98 size_t count)
95{ 99{
@@ -192,66 +196,96 @@ static void wiiproto_req_leds(struct wiimote_data *wdata, int leds)
192 wiimote_queue(wdata, cmd, sizeof(cmd)); 196 wiimote_queue(wdata, cmd, sizeof(cmd));
193} 197}
194 198
195#define wiifs_led_show_set(num) \ 199/*
196static ssize_t wiifs_led_show_##num(struct device *dev, \ 200 * Check what peripherals of the wiimote are currently
197 struct device_attribute *attr, char *buf) \ 201 * active and select a proper DRM that supports all of
198{ \ 202 * the requested data inputs.
199 struct wiimote_data *wdata = dev_to_wii(dev); \ 203 */
200 unsigned long flags; \ 204static __u8 select_drm(struct wiimote_data *wdata)
201 int state; \ 205{
202 \ 206 return WIIPROTO_REQ_DRM_K;
203 if (!atomic_read(&wdata->ready)) \ 207}
204 return -EBUSY; \ 208
205 \ 209static void wiiproto_req_drm(struct wiimote_data *wdata, __u8 drm)
206 spin_lock_irqsave(&wdata->state.lock, flags); \ 210{
207 state = !!(wdata->state.flags & WIIPROTO_FLAG_LED##num); \ 211 __u8 cmd[3];
208 spin_unlock_irqrestore(&wdata->state.lock, flags); \ 212
209 \ 213 if (drm == WIIPROTO_REQ_NULL)
210 return sprintf(buf, "%d\n", state); \ 214 drm = select_drm(wdata);
211} \ 215
212static ssize_t wiifs_led_set_##num(struct device *dev, \ 216 cmd[0] = WIIPROTO_REQ_DRM;
213 struct device_attribute *attr, const char *buf, size_t count) \ 217 cmd[1] = 0;
214{ \ 218 cmd[2] = drm;
215 struct wiimote_data *wdata = dev_to_wii(dev); \ 219
216 int tmp = simple_strtoul(buf, NULL, 10); \ 220 wiimote_queue(wdata, cmd, sizeof(cmd));
217 unsigned long flags; \ 221}
218 __u8 state; \ 222
219 \ 223static enum led_brightness wiimote_leds_get(struct led_classdev *led_dev)
220 if (!atomic_read(&wdata->ready)) \ 224{
221 return -EBUSY; \ 225 struct wiimote_data *wdata;
222 \ 226 struct device *dev = led_dev->dev->parent;
223 spin_lock_irqsave(&wdata->state.lock, flags); \ 227 int i;
224 \ 228 unsigned long flags;
225 state = wdata->state.flags; \ 229 bool value = false;
226 \ 230
227 if (tmp) \ 231 wdata = hid_get_drvdata(container_of(dev, struct hid_device, dev));
228 wiiproto_req_leds(wdata, state | WIIPROTO_FLAG_LED##num);\ 232
229 else \ 233 for (i = 0; i < 4; ++i) {
230 wiiproto_req_leds(wdata, state & ~WIIPROTO_FLAG_LED##num);\ 234 if (wdata->leds[i] == led_dev) {
231 \ 235 spin_lock_irqsave(&wdata->state.lock, flags);
232 spin_unlock_irqrestore(&wdata->state.lock, flags); \ 236 value = wdata->state.flags & WIIPROTO_FLAG_LED(i + 1);
233 \ 237 spin_unlock_irqrestore(&wdata->state.lock, flags);
234 return count; \ 238 break;
235} \ 239 }
236static DEVICE_ATTR(led##num, S_IRUGO | S_IWUSR, wiifs_led_show_##num, \ 240 }
237 wiifs_led_set_##num) 241
238 242 return value ? LED_FULL : LED_OFF;
239wiifs_led_show_set(1); 243}
240wiifs_led_show_set(2); 244
241wiifs_led_show_set(3); 245static void wiimote_leds_set(struct led_classdev *led_dev,
242wiifs_led_show_set(4); 246 enum led_brightness value)
247{
248 struct wiimote_data *wdata;
249 struct device *dev = led_dev->dev->parent;
250 int i;
251 unsigned long flags;
252 __u8 state, flag;
253
254 wdata = hid_get_drvdata(container_of(dev, struct hid_device, dev));
255
256 for (i = 0; i < 4; ++i) {
257 if (wdata->leds[i] == led_dev) {
258 flag = WIIPROTO_FLAG_LED(i + 1);
259 spin_lock_irqsave(&wdata->state.lock, flags);
260 state = wdata->state.flags;
261 if (value == LED_OFF)
262 wiiproto_req_leds(wdata, state & ~flag);
263 else
264 wiiproto_req_leds(wdata, state | flag);
265 spin_unlock_irqrestore(&wdata->state.lock, flags);
266 break;
267 }
268 }
269}
243 270
244static int wiimote_input_event(struct input_dev *dev, unsigned int type, 271static int wiimote_input_event(struct input_dev *dev, unsigned int type,
245 unsigned int code, int value) 272 unsigned int code, int value)
246{ 273{
274 return 0;
275}
276
277static int wiimote_input_open(struct input_dev *dev)
278{
247 struct wiimote_data *wdata = input_get_drvdata(dev); 279 struct wiimote_data *wdata = input_get_drvdata(dev);
248 280
249 if (!atomic_read(&wdata->ready)) 281 return hid_hw_open(wdata->hdev);
250 return -EBUSY; 282}
251 /* smp_rmb: Make sure wdata->xy is available when wdata->ready is 1 */
252 smp_rmb();
253 283
254 return 0; 284static void wiimote_input_close(struct input_dev *dev)
285{
286 struct wiimote_data *wdata = input_get_drvdata(dev);
287
288 hid_hw_close(wdata->hdev);
255} 289}
256 290
257static void handler_keys(struct wiimote_data *wdata, const __u8 *payload) 291static void handler_keys(struct wiimote_data *wdata, const __u8 *payload)
@@ -281,6 +315,26 @@ static void handler_keys(struct wiimote_data *wdata, const __u8 *payload)
281 input_sync(wdata->input); 315 input_sync(wdata->input);
282} 316}
283 317
318static void handler_status(struct wiimote_data *wdata, const __u8 *payload)
319{
320 handler_keys(wdata, payload);
321
322 /* on status reports the drm is reset so we need to resend the drm */
323 wiiproto_req_drm(wdata, WIIPROTO_REQ_NULL);
324}
325
326static void handler_return(struct wiimote_data *wdata, const __u8 *payload)
327{
328 __u8 err = payload[3];
329 __u8 cmd = payload[2];
330
331 handler_keys(wdata, payload);
332
333 if (err)
334 hid_warn(wdata->hdev, "Remote error %hhu on req %hhu\n", err,
335 cmd);
336}
337
284struct wiiproto_handler { 338struct wiiproto_handler {
285 __u8 id; 339 __u8 id;
286 size_t size; 340 size_t size;
@@ -288,6 +342,8 @@ struct wiiproto_handler {
288}; 342};
289 343
290static struct wiiproto_handler handlers[] = { 344static struct wiiproto_handler handlers[] = {
345 { .id = WIIPROTO_REQ_STATUS, .size = 6, .func = handler_status },
346 { .id = WIIPROTO_REQ_RETURN, .size = 4, .func = handler_return },
291 { .id = WIIPROTO_REQ_DRM_K, .size = 2, .func = handler_keys }, 347 { .id = WIIPROTO_REQ_DRM_K, .size = 2, .func = handler_keys },
292 { .id = 0 } 348 { .id = 0 }
293}; 349};
@@ -300,11 +356,6 @@ static int wiimote_hid_event(struct hid_device *hdev, struct hid_report *report,
300 int i; 356 int i;
301 unsigned long flags; 357 unsigned long flags;
302 358
303 if (!atomic_read(&wdata->ready))
304 return -EBUSY;
305 /* smp_rmb: Make sure wdata->xy is available when wdata->ready is 1 */
306 smp_rmb();
307
308 if (size < 1) 359 if (size < 1)
309 return -EINVAL; 360 return -EINVAL;
310 361
@@ -321,6 +372,58 @@ static int wiimote_hid_event(struct hid_device *hdev, struct hid_report *report,
321 return 0; 372 return 0;
322} 373}
323 374
375static void wiimote_leds_destroy(struct wiimote_data *wdata)
376{
377 int i;
378 struct led_classdev *led;
379
380 for (i = 0; i < 4; ++i) {
381 if (wdata->leds[i]) {
382 led = wdata->leds[i];
383 wdata->leds[i] = NULL;
384 led_classdev_unregister(led);
385 kfree(led);
386 }
387 }
388}
389
390static int wiimote_leds_create(struct wiimote_data *wdata)
391{
392 int i, ret;
393 struct device *dev = &wdata->hdev->dev;
394 size_t namesz = strlen(dev_name(dev)) + 9;
395 struct led_classdev *led;
396 char *name;
397
398 for (i = 0; i < 4; ++i) {
399 led = kzalloc(sizeof(struct led_classdev) + namesz, GFP_KERNEL);
400 if (!led) {
401 ret = -ENOMEM;
402 goto err;
403 }
404 name = (void*)&led[1];
405 snprintf(name, namesz, "%s:blue:p%d", dev_name(dev), i);
406 led->name = name;
407 led->brightness = 0;
408 led->max_brightness = 1;
409 led->brightness_get = wiimote_leds_get;
410 led->brightness_set = wiimote_leds_set;
411
412 ret = led_classdev_register(dev, led);
413 if (ret) {
414 kfree(led);
415 goto err;
416 }
417 wdata->leds[i] = led;
418 }
419
420 return 0;
421
422err:
423 wiimote_leds_destroy(wdata);
424 return ret;
425}
426
324static struct wiimote_data *wiimote_create(struct hid_device *hdev) 427static struct wiimote_data *wiimote_create(struct hid_device *hdev)
325{ 428{
326 struct wiimote_data *wdata; 429 struct wiimote_data *wdata;
@@ -341,6 +444,8 @@ static struct wiimote_data *wiimote_create(struct hid_device *hdev)
341 444
342 input_set_drvdata(wdata->input, wdata); 445 input_set_drvdata(wdata->input, wdata);
343 wdata->input->event = wiimote_input_event; 446 wdata->input->event = wiimote_input_event;
447 wdata->input->open = wiimote_input_open;
448 wdata->input->close = wiimote_input_close;
344 wdata->input->dev.parent = &wdata->hdev->dev; 449 wdata->input->dev.parent = &wdata->hdev->dev;
345 wdata->input->id.bustype = wdata->hdev->bus; 450 wdata->input->id.bustype = wdata->hdev->bus;
346 wdata->input->id.vendor = wdata->hdev->vendor; 451 wdata->input->id.vendor = wdata->hdev->vendor;
@@ -362,6 +467,12 @@ static struct wiimote_data *wiimote_create(struct hid_device *hdev)
362 467
363static void wiimote_destroy(struct wiimote_data *wdata) 468static void wiimote_destroy(struct wiimote_data *wdata)
364{ 469{
470 wiimote_leds_destroy(wdata);
471
472 input_unregister_device(wdata->input);
473 cancel_work_sync(&wdata->worker);
474 hid_hw_stop(wdata->hdev);
475
365 kfree(wdata); 476 kfree(wdata);
366} 477}
367 478
@@ -377,19 +488,6 @@ static int wiimote_hid_probe(struct hid_device *hdev,
377 return -ENOMEM; 488 return -ENOMEM;
378 } 489 }
379 490
380 ret = device_create_file(&hdev->dev, &dev_attr_led1);
381 if (ret)
382 goto err;
383 ret = device_create_file(&hdev->dev, &dev_attr_led2);
384 if (ret)
385 goto err;
386 ret = device_create_file(&hdev->dev, &dev_attr_led3);
387 if (ret)
388 goto err;
389 ret = device_create_file(&hdev->dev, &dev_attr_led4);
390 if (ret)
391 goto err;
392
393 ret = hid_parse(hdev); 491 ret = hid_parse(hdev);
394 if (ret) { 492 if (ret) {
395 hid_err(hdev, "HID parse failed\n"); 493 hid_err(hdev, "HID parse failed\n");
@@ -408,9 +506,10 @@ static int wiimote_hid_probe(struct hid_device *hdev,
408 goto err_stop; 506 goto err_stop;
409 } 507 }
410 508
411 /* smp_wmb: Write wdata->xy first before wdata->ready is set to 1 */ 509 ret = wiimote_leds_create(wdata);
412 smp_wmb(); 510 if (ret)
413 atomic_set(&wdata->ready, 1); 511 goto err_free;
512
414 hid_info(hdev, "New device registered\n"); 513 hid_info(hdev, "New device registered\n");
415 514
416 /* by default set led1 after device initialization */ 515 /* by default set led1 after device initialization */
@@ -420,15 +519,15 @@ static int wiimote_hid_probe(struct hid_device *hdev,
420 519
421 return 0; 520 return 0;
422 521
522err_free:
523 wiimote_destroy(wdata);
524 return ret;
525
423err_stop: 526err_stop:
424 hid_hw_stop(hdev); 527 hid_hw_stop(hdev);
425err: 528err:
426 input_free_device(wdata->input); 529 input_free_device(wdata->input);
427 device_remove_file(&hdev->dev, &dev_attr_led1); 530 kfree(wdata);
428 device_remove_file(&hdev->dev, &dev_attr_led2);
429 device_remove_file(&hdev->dev, &dev_attr_led3);
430 device_remove_file(&hdev->dev, &dev_attr_led4);
431 wiimote_destroy(wdata);
432 return ret; 531 return ret;
433} 532}
434 533
@@ -437,16 +536,6 @@ static void wiimote_hid_remove(struct hid_device *hdev)
437 struct wiimote_data *wdata = hid_get_drvdata(hdev); 536 struct wiimote_data *wdata = hid_get_drvdata(hdev);
438 537
439 hid_info(hdev, "Device removed\n"); 538 hid_info(hdev, "Device removed\n");
440
441 device_remove_file(&hdev->dev, &dev_attr_led1);
442 device_remove_file(&hdev->dev, &dev_attr_led2);
443 device_remove_file(&hdev->dev, &dev_attr_led3);
444 device_remove_file(&hdev->dev, &dev_attr_led4);
445
446 hid_hw_stop(hdev);
447 input_unregister_device(wdata->input);
448
449 cancel_work_sync(&wdata->worker);
450 wiimote_destroy(wdata); 539 wiimote_destroy(wdata);
451} 540}
452 541
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index 621959d5cc42..4bdb5d46c52c 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -89,6 +89,7 @@ static const struct hid_blacklist {
89 89
90 { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_MULTI_TOUCH, HID_QUIRK_MULTI_INPUT }, 90 { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_MULTI_TOUCH, HID_QUIRK_MULTI_INPUT },
91 { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS, HID_QUIRK_MULTI_INPUT }, 91 { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS, HID_QUIRK_MULTI_INPUT },
92 { USB_VENDOR_ID_SIGMA_MICRO, USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD, HID_QUIRK_NO_INIT_REPORTS },
92 { 0, 0 } 93 { 0, 0 }
93}; 94};
94 95
diff --git a/drivers/hwmon/i5k_amb.c b/drivers/hwmon/i5k_amb.c
index c4c40be0edbf..d22f241b6a67 100644
--- a/drivers/hwmon/i5k_amb.c
+++ b/drivers/hwmon/i5k_amb.c
@@ -114,7 +114,6 @@ struct i5k_amb_data {
114 void __iomem *amb_mmio; 114 void __iomem *amb_mmio;
115 struct i5k_device_attribute *attrs; 115 struct i5k_device_attribute *attrs;
116 unsigned int num_attrs; 116 unsigned int num_attrs;
117 unsigned long chipset_id;
118}; 117};
119 118
120static ssize_t show_name(struct device *dev, struct device_attribute *devattr, 119static ssize_t show_name(struct device *dev, struct device_attribute *devattr,
@@ -444,8 +443,6 @@ static int __devinit i5k_find_amb_registers(struct i5k_amb_data *data,
444 goto out; 443 goto out;
445 } 444 }
446 445
447 data->chipset_id = devid;
448
449 res = 0; 446 res = 0;
450out: 447out:
451 pci_dev_put(pcidev); 448 pci_dev_put(pcidev);
@@ -478,23 +475,13 @@ out:
478 return res; 475 return res;
479} 476}
480 477
481static unsigned long i5k_channel_pci_id(struct i5k_amb_data *data, 478static struct {
482 unsigned long channel) 479 unsigned long err;
483{ 480 unsigned long fbd0;
484 switch (data->chipset_id) { 481} chipset_ids[] __devinitdata = {
485 case PCI_DEVICE_ID_INTEL_5000_ERR: 482 { PCI_DEVICE_ID_INTEL_5000_ERR, PCI_DEVICE_ID_INTEL_5000_FBD0 },
486 return PCI_DEVICE_ID_INTEL_5000_FBD0 + channel; 483 { PCI_DEVICE_ID_INTEL_5400_ERR, PCI_DEVICE_ID_INTEL_5400_FBD0 },
487 case PCI_DEVICE_ID_INTEL_5400_ERR: 484 { 0, 0 }
488 return PCI_DEVICE_ID_INTEL_5400_FBD0 + channel;
489 default:
490 BUG();
491 }
492}
493
494static unsigned long chipset_ids[] = {
495 PCI_DEVICE_ID_INTEL_5000_ERR,
496 PCI_DEVICE_ID_INTEL_5400_ERR,
497 0
498}; 485};
499 486
500#ifdef MODULE 487#ifdef MODULE
@@ -510,8 +497,7 @@ static int __devinit i5k_amb_probe(struct platform_device *pdev)
510{ 497{
511 struct i5k_amb_data *data; 498 struct i5k_amb_data *data;
512 struct resource *reso; 499 struct resource *reso;
513 int i; 500 int i, res;
514 int res = -ENODEV;
515 501
516 data = kzalloc(sizeof(*data), GFP_KERNEL); 502 data = kzalloc(sizeof(*data), GFP_KERNEL);
517 if (!data) 503 if (!data)
@@ -520,22 +506,22 @@ static int __devinit i5k_amb_probe(struct platform_device *pdev)
520 /* Figure out where the AMB registers live */ 506 /* Figure out where the AMB registers live */
521 i = 0; 507 i = 0;
522 do { 508 do {
523 res = i5k_find_amb_registers(data, chipset_ids[i]); 509 res = i5k_find_amb_registers(data, chipset_ids[i].err);
510 if (res == 0)
511 break;
524 i++; 512 i++;
525 } while (res && chipset_ids[i]); 513 } while (chipset_ids[i].err);
526 514
527 if (res) 515 if (res)
528 goto err; 516 goto err;
529 517
530 /* Copy the DIMM presence map for the first two channels */ 518 /* Copy the DIMM presence map for the first two channels */
531 res = i5k_channel_probe(&data->amb_present[0], 519 res = i5k_channel_probe(&data->amb_present[0], chipset_ids[i].fbd0);
532 i5k_channel_pci_id(data, 0));
533 if (res) 520 if (res)
534 goto err; 521 goto err;
535 522
536 /* Copy the DIMM presence map for the optional second two channels */ 523 /* Copy the DIMM presence map for the optional second two channels */
537 i5k_channel_probe(&data->amb_present[2], 524 i5k_channel_probe(&data->amb_present[2], chipset_ids[i].fbd0 + 1);
538 i5k_channel_pci_id(data, 1));
539 525
540 /* Set up resource regions */ 526 /* Set up resource regions */
541 reso = request_mem_region(data->amb_base, data->amb_len, DRVNAME); 527 reso = request_mem_region(data->amb_base, data->amb_len, DRVNAME);
diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c
index d7926f4336b5..eab11615dced 100644
--- a/drivers/hwmon/ntc_thermistor.c
+++ b/drivers/hwmon/ntc_thermistor.c
@@ -211,8 +211,7 @@ static int lookup_comp(struct ntc_data *data,
211 if (data->comp[mid].ohm <= ohm) { 211 if (data->comp[mid].ohm <= ohm) {
212 *i_low = mid; 212 *i_low = mid;
213 *i_high = mid - 1; 213 *i_high = mid - 1;
214 } 214 } else {
215 if (data->comp[mid].ohm > ohm) {
216 *i_low = mid + 1; 215 *i_low = mid + 1;
217 *i_high = mid; 216 *i_high = mid;
218 } 217 }
diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index 0c731ca69f15..b228e09c5d05 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -146,6 +146,7 @@ struct i2c_nmk_client {
146 * @stop: stop condition 146 * @stop: stop condition
147 * @xfer_complete: acknowledge completion for a I2C message 147 * @xfer_complete: acknowledge completion for a I2C message
148 * @result: controller propogated result 148 * @result: controller propogated result
149 * @regulator: pointer to i2c regulator
149 * @busy: Busy doing transfer 150 * @busy: Busy doing transfer
150 */ 151 */
151struct nmk_i2c_dev { 152struct nmk_i2c_dev {
@@ -417,12 +418,12 @@ static int read_i2c(struct nmk_i2c_dev *dev)
417 writel(readl(dev->virtbase + I2C_IMSCR) | irq_mask, 418 writel(readl(dev->virtbase + I2C_IMSCR) | irq_mask,
418 dev->virtbase + I2C_IMSCR); 419 dev->virtbase + I2C_IMSCR);
419 420
420 timeout = wait_for_completion_interruptible_timeout( 421 timeout = wait_for_completion_timeout(
421 &dev->xfer_complete, dev->adap.timeout); 422 &dev->xfer_complete, dev->adap.timeout);
422 423
423 if (timeout < 0) { 424 if (timeout < 0) {
424 dev_err(&dev->pdev->dev, 425 dev_err(&dev->pdev->dev,
425 "wait_for_completion_interruptible_timeout" 426 "wait_for_completion_timeout"
426 "returned %d waiting for event\n", timeout); 427 "returned %d waiting for event\n", timeout);
427 status = timeout; 428 status = timeout;
428 } 429 }
@@ -504,12 +505,12 @@ static int write_i2c(struct nmk_i2c_dev *dev)
504 writel(readl(dev->virtbase + I2C_IMSCR) | irq_mask, 505 writel(readl(dev->virtbase + I2C_IMSCR) | irq_mask,
505 dev->virtbase + I2C_IMSCR); 506 dev->virtbase + I2C_IMSCR);
506 507
507 timeout = wait_for_completion_interruptible_timeout( 508 timeout = wait_for_completion_timeout(
508 &dev->xfer_complete, dev->adap.timeout); 509 &dev->xfer_complete, dev->adap.timeout);
509 510
510 if (timeout < 0) { 511 if (timeout < 0) {
511 dev_err(&dev->pdev->dev, 512 dev_err(&dev->pdev->dev,
512 "wait_for_completion_interruptible_timeout" 513 "wait_for_completion_timeout "
513 "returned %d waiting for event\n", timeout); 514 "returned %d waiting for event\n", timeout);
514 status = timeout; 515 status = timeout;
515 } 516 }
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 1a766cf74f6b..2dfb63176856 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -1139,41 +1139,12 @@ omap_i2c_remove(struct platform_device *pdev)
1139 return 0; 1139 return 0;
1140} 1140}
1141 1141
1142#ifdef CONFIG_SUSPEND
1143static int omap_i2c_suspend(struct device *dev)
1144{
1145 if (!pm_runtime_suspended(dev))
1146 if (dev->bus && dev->bus->pm && dev->bus->pm->runtime_suspend)
1147 dev->bus->pm->runtime_suspend(dev);
1148
1149 return 0;
1150}
1151
1152static int omap_i2c_resume(struct device *dev)
1153{
1154 if (!pm_runtime_suspended(dev))
1155 if (dev->bus && dev->bus->pm && dev->bus->pm->runtime_resume)
1156 dev->bus->pm->runtime_resume(dev);
1157
1158 return 0;
1159}
1160
1161static struct dev_pm_ops omap_i2c_pm_ops = {
1162 .suspend = omap_i2c_suspend,
1163 .resume = omap_i2c_resume,
1164};
1165#define OMAP_I2C_PM_OPS (&omap_i2c_pm_ops)
1166#else
1167#define OMAP_I2C_PM_OPS NULL
1168#endif
1169
1170static struct platform_driver omap_i2c_driver = { 1142static struct platform_driver omap_i2c_driver = {
1171 .probe = omap_i2c_probe, 1143 .probe = omap_i2c_probe,
1172 .remove = omap_i2c_remove, 1144 .remove = omap_i2c_remove,
1173 .driver = { 1145 .driver = {
1174 .name = "omap_i2c", 1146 .name = "omap_i2c",
1175 .owner = THIS_MODULE, 1147 .owner = THIS_MODULE,
1176 .pm = OMAP_I2C_PM_OPS,
1177 }, 1148 },
1178}; 1149};
1179 1150
diff --git a/drivers/input/joystick/analog.c b/drivers/input/joystick/analog.c
index 9882971827e6..358cd7ee905b 100644
--- a/drivers/input/joystick/analog.c
+++ b/drivers/input/joystick/analog.c
@@ -139,7 +139,7 @@ struct analog_port {
139#include <linux/i8253.h> 139#include <linux/i8253.h>
140 140
141#define GET_TIME(x) do { if (cpu_has_tsc) rdtscl(x); else x = get_time_pit(); } while (0) 141#define GET_TIME(x) do { if (cpu_has_tsc) rdtscl(x); else x = get_time_pit(); } while (0)
142#define DELTA(x,y) (cpu_has_tsc ? ((y) - (x)) : ((x) - (y) + ((x) < (y) ? CLOCK_TICK_RATE / HZ : 0))) 142#define DELTA(x,y) (cpu_has_tsc ? ((y) - (x)) : ((x) - (y) + ((x) < (y) ? PIT_TICK_RATE / HZ : 0)))
143#define TIME_NAME (cpu_has_tsc?"TSC":"PIT") 143#define TIME_NAME (cpu_has_tsc?"TSC":"PIT")
144static unsigned int get_time_pit(void) 144static unsigned int get_time_pit(void)
145{ 145{
diff --git a/drivers/input/keyboard/ep93xx_keypad.c b/drivers/input/keyboard/ep93xx_keypad.c
index c8242dd190d0..aa17e024d803 100644
--- a/drivers/input/keyboard/ep93xx_keypad.c
+++ b/drivers/input/keyboard/ep93xx_keypad.c
@@ -20,6 +20,7 @@
20 * flag. 20 * flag.
21 */ 21 */
22 22
23#include <linux/module.h>
23#include <linux/platform_device.h> 24#include <linux/platform_device.h>
24#include <linux/interrupt.h> 25#include <linux/interrupt.h>
25#include <linux/clk.h> 26#include <linux/clk.h>
diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c
index f270447ba951..a5a77915c650 100644
--- a/drivers/input/keyboard/tegra-kbc.c
+++ b/drivers/input/keyboard/tegra-kbc.c
@@ -702,7 +702,7 @@ err_iounmap:
702err_free_mem_region: 702err_free_mem_region:
703 release_mem_region(res->start, resource_size(res)); 703 release_mem_region(res->start, resource_size(res));
704err_free_mem: 704err_free_mem:
705 input_free_device(kbc->idev); 705 input_free_device(input_dev);
706 kfree(kbc); 706 kfree(kbc);
707 707
708 return err; 708 return err;
diff --git a/drivers/input/misc/ad714x-i2c.c b/drivers/input/misc/ad714x-i2c.c
index e21deb1baa8a..025417d74ca2 100644
--- a/drivers/input/misc/ad714x-i2c.c
+++ b/drivers/input/misc/ad714x-i2c.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * AD714X CapTouch Programmable Controller driver (I2C bus) 2 * AD714X CapTouch Programmable Controller driver (I2C bus)
3 * 3 *
4 * Copyright 2009 Analog Devices Inc. 4 * Copyright 2009-2011 Analog Devices Inc.
5 * 5 *
6 * Licensed under the GPL-2 or later. 6 * Licensed under the GPL-2 or later.
7 */ 7 */
@@ -27,54 +27,49 @@ static int ad714x_i2c_resume(struct device *dev)
27 27
28static SIMPLE_DEV_PM_OPS(ad714x_i2c_pm, ad714x_i2c_suspend, ad714x_i2c_resume); 28static SIMPLE_DEV_PM_OPS(ad714x_i2c_pm, ad714x_i2c_suspend, ad714x_i2c_resume);
29 29
30static int ad714x_i2c_write(struct device *dev, unsigned short reg, 30static int ad714x_i2c_write(struct ad714x_chip *chip,
31 unsigned short data) 31 unsigned short reg, unsigned short data)
32{ 32{
33 struct i2c_client *client = to_i2c_client(dev); 33 struct i2c_client *client = to_i2c_client(chip->dev);
34 int ret = 0; 34 int error;
35 u8 *_reg = (u8 *)&reg; 35
36 u8 *_data = (u8 *)&data; 36 chip->xfer_buf[0] = cpu_to_be16(reg);
37 37 chip->xfer_buf[1] = cpu_to_be16(data);
38 u8 tx[4] = { 38
39 _reg[1], 39 error = i2c_master_send(client, (u8 *)chip->xfer_buf,
40 _reg[0], 40 2 * sizeof(*chip->xfer_buf));
41 _data[1], 41 if (unlikely(error < 0)) {
42 _data[0] 42 dev_err(&client->dev, "I2C write error: %d\n", error);
43 }; 43 return error;
44 44 }
45 ret = i2c_master_send(client, tx, 4); 45
46 if (ret < 0) 46 return 0;
47 dev_err(&client->dev, "I2C write error\n");
48
49 return ret;
50} 47}
51 48
52static int ad714x_i2c_read(struct device *dev, unsigned short reg, 49static int ad714x_i2c_read(struct ad714x_chip *chip,
53 unsigned short *data) 50 unsigned short reg, unsigned short *data, size_t len)
54{ 51{
55 struct i2c_client *client = to_i2c_client(dev); 52 struct i2c_client *client = to_i2c_client(chip->dev);
56 int ret = 0; 53 int i;
57 u8 *_reg = (u8 *)&reg; 54 int error;
58 u8 *_data = (u8 *)data; 55
59 56 chip->xfer_buf[0] = cpu_to_be16(reg);
60 u8 tx[2] = { 57
61 _reg[1], 58 error = i2c_master_send(client, (u8 *)chip->xfer_buf,
62 _reg[0] 59 sizeof(*chip->xfer_buf));
63 }; 60 if (error >= 0)
64 u8 rx[2]; 61 error = i2c_master_recv(client, (u8 *)chip->xfer_buf,
65 62 len * sizeof(*chip->xfer_buf));
66 ret = i2c_master_send(client, tx, 2); 63
67 if (ret >= 0) 64 if (unlikely(error < 0)) {
68 ret = i2c_master_recv(client, rx, 2); 65 dev_err(&client->dev, "I2C read error: %d\n", error);
69 66 return error;
70 if (unlikely(ret < 0)) {
71 dev_err(&client->dev, "I2C read error\n");
72 } else {
73 _data[0] = rx[1];
74 _data[1] = rx[0];
75 } 67 }
76 68
77 return ret; 69 for (i = 0; i < len; i++)
70 data[i] = be16_to_cpu(chip->xfer_buf[i]);
71
72 return 0;
78} 73}
79 74
80static int __devinit ad714x_i2c_probe(struct i2c_client *client, 75static int __devinit ad714x_i2c_probe(struct i2c_client *client,
diff --git a/drivers/input/misc/ad714x-spi.c b/drivers/input/misc/ad714x-spi.c
index 4120dd549305..875b50811361 100644
--- a/drivers/input/misc/ad714x-spi.c
+++ b/drivers/input/misc/ad714x-spi.c
@@ -1,12 +1,12 @@
1/* 1/*
2 * AD714X CapTouch Programmable Controller driver (SPI bus) 2 * AD714X CapTouch Programmable Controller driver (SPI bus)
3 * 3 *
4 * Copyright 2009 Analog Devices Inc. 4 * Copyright 2009-2011 Analog Devices Inc.
5 * 5 *
6 * Licensed under the GPL-2 or later. 6 * Licensed under the GPL-2 or later.
7 */ 7 */
8 8
9#include <linux/input.h> /* BUS_I2C */ 9#include <linux/input.h> /* BUS_SPI */
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/spi/spi.h> 11#include <linux/spi/spi.h>
12#include <linux/pm.h> 12#include <linux/pm.h>
@@ -30,30 +30,68 @@ static int ad714x_spi_resume(struct device *dev)
30 30
31static SIMPLE_DEV_PM_OPS(ad714x_spi_pm, ad714x_spi_suspend, ad714x_spi_resume); 31static SIMPLE_DEV_PM_OPS(ad714x_spi_pm, ad714x_spi_suspend, ad714x_spi_resume);
32 32
33static int ad714x_spi_read(struct device *dev, unsigned short reg, 33static int ad714x_spi_read(struct ad714x_chip *chip,
34 unsigned short *data) 34 unsigned short reg, unsigned short *data, size_t len)
35{ 35{
36 struct spi_device *spi = to_spi_device(dev); 36 struct spi_device *spi = to_spi_device(chip->dev);
37 unsigned short tx = AD714x_SPI_CMD_PREFIX | AD714x_SPI_READ | reg; 37 struct spi_message message;
38 struct spi_transfer xfer[2];
39 int i;
40 int error;
41
42 spi_message_init(&message);
43 memset(xfer, 0, sizeof(xfer));
44
45 chip->xfer_buf[0] = cpu_to_be16(AD714x_SPI_CMD_PREFIX |
46 AD714x_SPI_READ | reg);
47 xfer[0].tx_buf = &chip->xfer_buf[0];
48 xfer[0].len = sizeof(chip->xfer_buf[0]);
49 spi_message_add_tail(&xfer[0], &message);
50
51 xfer[1].rx_buf = &chip->xfer_buf[1];
52 xfer[1].len = sizeof(chip->xfer_buf[1]) * len;
53 spi_message_add_tail(&xfer[1], &message);
54
55 error = spi_sync(spi, &message);
56 if (unlikely(error)) {
57 dev_err(chip->dev, "SPI read error: %d\n", error);
58 return error;
59 }
60
61 for (i = 0; i < len; i++)
62 data[i] = be16_to_cpu(chip->xfer_buf[i + 1]);
38 63
39 return spi_write_then_read(spi, (u8 *)&tx, 2, (u8 *)data, 2); 64 return 0;
40} 65}
41 66
42static int ad714x_spi_write(struct device *dev, unsigned short reg, 67static int ad714x_spi_write(struct ad714x_chip *chip,
43 unsigned short data) 68 unsigned short reg, unsigned short data)
44{ 69{
45 struct spi_device *spi = to_spi_device(dev); 70 struct spi_device *spi = to_spi_device(chip->dev);
46 unsigned short tx[2] = { 71 int error;
47 AD714x_SPI_CMD_PREFIX | reg, 72
48 data 73 chip->xfer_buf[0] = cpu_to_be16(AD714x_SPI_CMD_PREFIX | reg);
49 }; 74 chip->xfer_buf[1] = cpu_to_be16(data);
75
76 error = spi_write(spi, (u8 *)chip->xfer_buf,
77 2 * sizeof(*chip->xfer_buf));
78 if (unlikely(error)) {
79 dev_err(chip->dev, "SPI write error: %d\n", error);
80 return error;
81 }
50 82
51 return spi_write(spi, (u8 *)tx, 4); 83 return 0;
52} 84}
53 85
54static int __devinit ad714x_spi_probe(struct spi_device *spi) 86static int __devinit ad714x_spi_probe(struct spi_device *spi)
55{ 87{
56 struct ad714x_chip *chip; 88 struct ad714x_chip *chip;
89 int err;
90
91 spi->bits_per_word = 8;
92 err = spi_setup(spi);
93 if (err < 0)
94 return err;
57 95
58 chip = ad714x_probe(&spi->dev, BUS_SPI, spi->irq, 96 chip = ad714x_probe(&spi->dev, BUS_SPI, spi->irq,
59 ad714x_spi_read, ad714x_spi_write); 97 ad714x_spi_read, ad714x_spi_write);
diff --git a/drivers/input/misc/ad714x.c b/drivers/input/misc/ad714x.c
index c3a62c42cd28..ca42c7d2a3c7 100644
--- a/drivers/input/misc/ad714x.c
+++ b/drivers/input/misc/ad714x.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * AD714X CapTouch Programmable Controller driver supporting AD7142/3/7/8/7A 2 * AD714X CapTouch Programmable Controller driver supporting AD7142/3/7/8/7A
3 * 3 *
4 * Copyright 2009 Analog Devices Inc. 4 * Copyright 2009-2011 Analog Devices Inc.
5 * 5 *
6 * Licensed under the GPL-2 or later. 6 * Licensed under the GPL-2 or later.
7 */ 7 */
@@ -59,7 +59,6 @@
59#define STAGE11_AMBIENT 0x27D 59#define STAGE11_AMBIENT 0x27D
60 60
61#define PER_STAGE_REG_NUM 36 61#define PER_STAGE_REG_NUM 36
62#define STAGE_NUM 12
63#define STAGE_CFGREG_NUM 8 62#define STAGE_CFGREG_NUM 8
64#define SYS_CFGREG_NUM 8 63#define SYS_CFGREG_NUM 8
65 64
@@ -124,27 +123,6 @@ struct ad714x_driver_data {
124 * information to integrate all things which will be private data 123 * information to integrate all things which will be private data
125 * of spi/i2c device 124 * of spi/i2c device
126 */ 125 */
127struct ad714x_chip {
128 unsigned short h_state;
129 unsigned short l_state;
130 unsigned short c_state;
131 unsigned short adc_reg[STAGE_NUM];
132 unsigned short amb_reg[STAGE_NUM];
133 unsigned short sensor_val[STAGE_NUM];
134
135 struct ad714x_platform_data *hw;
136 struct ad714x_driver_data *sw;
137
138 int irq;
139 struct device *dev;
140 ad714x_read_t read;
141 ad714x_write_t write;
142
143 struct mutex mutex;
144
145 unsigned product;
146 unsigned version;
147};
148 126
149static void ad714x_use_com_int(struct ad714x_chip *ad714x, 127static void ad714x_use_com_int(struct ad714x_chip *ad714x,
150 int start_stage, int end_stage) 128 int start_stage, int end_stage)
@@ -154,13 +132,13 @@ static void ad714x_use_com_int(struct ad714x_chip *ad714x,
154 132
155 mask = ((1 << (end_stage + 1)) - 1) - ((1 << start_stage) - 1); 133 mask = ((1 << (end_stage + 1)) - 1) - ((1 << start_stage) - 1);
156 134
157 ad714x->read(ad714x->dev, STG_COM_INT_EN_REG, &data); 135 ad714x->read(ad714x, STG_COM_INT_EN_REG, &data, 1);
158 data |= 1 << end_stage; 136 data |= 1 << end_stage;
159 ad714x->write(ad714x->dev, STG_COM_INT_EN_REG, data); 137 ad714x->write(ad714x, STG_COM_INT_EN_REG, data);
160 138
161 ad714x->read(ad714x->dev, STG_HIGH_INT_EN_REG, &data); 139 ad714x->read(ad714x, STG_HIGH_INT_EN_REG, &data, 1);
162 data &= ~mask; 140 data &= ~mask;
163 ad714x->write(ad714x->dev, STG_HIGH_INT_EN_REG, data); 141 ad714x->write(ad714x, STG_HIGH_INT_EN_REG, data);
164} 142}
165 143
166static void ad714x_use_thr_int(struct ad714x_chip *ad714x, 144static void ad714x_use_thr_int(struct ad714x_chip *ad714x,
@@ -171,13 +149,13 @@ static void ad714x_use_thr_int(struct ad714x_chip *ad714x,
171 149
172 mask = ((1 << (end_stage + 1)) - 1) - ((1 << start_stage) - 1); 150 mask = ((1 << (end_stage + 1)) - 1) - ((1 << start_stage) - 1);
173 151
174 ad714x->read(ad714x->dev, STG_COM_INT_EN_REG, &data); 152 ad714x->read(ad714x, STG_COM_INT_EN_REG, &data, 1);
175 data &= ~(1 << end_stage); 153 data &= ~(1 << end_stage);
176 ad714x->write(ad714x->dev, STG_COM_INT_EN_REG, data); 154 ad714x->write(ad714x, STG_COM_INT_EN_REG, data);
177 155
178 ad714x->read(ad714x->dev, STG_HIGH_INT_EN_REG, &data); 156 ad714x->read(ad714x, STG_HIGH_INT_EN_REG, &data, 1);
179 data |= mask; 157 data |= mask;
180 ad714x->write(ad714x->dev, STG_HIGH_INT_EN_REG, data); 158 ad714x->write(ad714x, STG_HIGH_INT_EN_REG, data);
181} 159}
182 160
183static int ad714x_cal_highest_stage(struct ad714x_chip *ad714x, 161static int ad714x_cal_highest_stage(struct ad714x_chip *ad714x,
@@ -273,15 +251,16 @@ static void ad714x_slider_cal_sensor_val(struct ad714x_chip *ad714x, int idx)
273 struct ad714x_slider_plat *hw = &ad714x->hw->slider[idx]; 251 struct ad714x_slider_plat *hw = &ad714x->hw->slider[idx];
274 int i; 252 int i;
275 253
254 ad714x->read(ad714x, CDC_RESULT_S0 + hw->start_stage,
255 &ad714x->adc_reg[hw->start_stage],
256 hw->end_stage - hw->start_stage + 1);
257
276 for (i = hw->start_stage; i <= hw->end_stage; i++) { 258 for (i = hw->start_stage; i <= hw->end_stage; i++) {
277 ad714x->read(ad714x->dev, CDC_RESULT_S0 + i, 259 ad714x->read(ad714x, STAGE0_AMBIENT + i * PER_STAGE_REG_NUM,
278 &ad714x->adc_reg[i]); 260 &ad714x->amb_reg[i], 1);
279 ad714x->read(ad714x->dev, 261
280 STAGE0_AMBIENT + i * PER_STAGE_REG_NUM, 262 ad714x->sensor_val[i] =
281 &ad714x->amb_reg[i]); 263 abs(ad714x->adc_reg[i] - ad714x->amb_reg[i]);
282
283 ad714x->sensor_val[i] = abs(ad714x->adc_reg[i] -
284 ad714x->amb_reg[i]);
285 } 264 }
286} 265}
287 266
@@ -444,15 +423,16 @@ static void ad714x_wheel_cal_sensor_val(struct ad714x_chip *ad714x, int idx)
444 struct ad714x_wheel_plat *hw = &ad714x->hw->wheel[idx]; 423 struct ad714x_wheel_plat *hw = &ad714x->hw->wheel[idx];
445 int i; 424 int i;
446 425
426 ad714x->read(ad714x, CDC_RESULT_S0 + hw->start_stage,
427 &ad714x->adc_reg[hw->start_stage],
428 hw->end_stage - hw->start_stage + 1);
429
447 for (i = hw->start_stage; i <= hw->end_stage; i++) { 430 for (i = hw->start_stage; i <= hw->end_stage; i++) {
448 ad714x->read(ad714x->dev, CDC_RESULT_S0 + i, 431 ad714x->read(ad714x, STAGE0_AMBIENT + i * PER_STAGE_REG_NUM,
449 &ad714x->adc_reg[i]); 432 &ad714x->amb_reg[i], 1);
450 ad714x->read(ad714x->dev,
451 STAGE0_AMBIENT + i * PER_STAGE_REG_NUM,
452 &ad714x->amb_reg[i]);
453 if (ad714x->adc_reg[i] > ad714x->amb_reg[i]) 433 if (ad714x->adc_reg[i] > ad714x->amb_reg[i])
454 ad714x->sensor_val[i] = ad714x->adc_reg[i] - 434 ad714x->sensor_val[i] =
455 ad714x->amb_reg[i]; 435 ad714x->adc_reg[i] - ad714x->amb_reg[i];
456 else 436 else
457 ad714x->sensor_val[i] = 0; 437 ad714x->sensor_val[i] = 0;
458 } 438 }
@@ -597,15 +577,16 @@ static void touchpad_cal_sensor_val(struct ad714x_chip *ad714x, int idx)
597 struct ad714x_touchpad_plat *hw = &ad714x->hw->touchpad[idx]; 577 struct ad714x_touchpad_plat *hw = &ad714x->hw->touchpad[idx];
598 int i; 578 int i;
599 579
580 ad714x->read(ad714x, CDC_RESULT_S0 + hw->x_start_stage,
581 &ad714x->adc_reg[hw->x_start_stage],
582 hw->x_end_stage - hw->x_start_stage + 1);
583
600 for (i = hw->x_start_stage; i <= hw->x_end_stage; i++) { 584 for (i = hw->x_start_stage; i <= hw->x_end_stage; i++) {
601 ad714x->read(ad714x->dev, CDC_RESULT_S0 + i, 585 ad714x->read(ad714x, STAGE0_AMBIENT + i * PER_STAGE_REG_NUM,
602 &ad714x->adc_reg[i]); 586 &ad714x->amb_reg[i], 1);
603 ad714x->read(ad714x->dev,
604 STAGE0_AMBIENT + i * PER_STAGE_REG_NUM,
605 &ad714x->amb_reg[i]);
606 if (ad714x->adc_reg[i] > ad714x->amb_reg[i]) 587 if (ad714x->adc_reg[i] > ad714x->amb_reg[i])
607 ad714x->sensor_val[i] = ad714x->adc_reg[i] - 588 ad714x->sensor_val[i] =
608 ad714x->amb_reg[i]; 589 ad714x->adc_reg[i] - ad714x->amb_reg[i];
609 else 590 else
610 ad714x->sensor_val[i] = 0; 591 ad714x->sensor_val[i] = 0;
611 } 592 }
@@ -891,7 +872,7 @@ static int ad714x_hw_detect(struct ad714x_chip *ad714x)
891{ 872{
892 unsigned short data; 873 unsigned short data;
893 874
894 ad714x->read(ad714x->dev, AD714X_PARTID_REG, &data); 875 ad714x->read(ad714x, AD714X_PARTID_REG, &data, 1);
895 switch (data & 0xFFF0) { 876 switch (data & 0xFFF0) {
896 case AD7142_PARTID: 877 case AD7142_PARTID:
897 ad714x->product = 0x7142; 878 ad714x->product = 0x7142;
@@ -940,23 +921,20 @@ static void ad714x_hw_init(struct ad714x_chip *ad714x)
940 for (i = 0; i < STAGE_NUM; i++) { 921 for (i = 0; i < STAGE_NUM; i++) {
941 reg_base = AD714X_STAGECFG_REG + i * STAGE_CFGREG_NUM; 922 reg_base = AD714X_STAGECFG_REG + i * STAGE_CFGREG_NUM;
942 for (j = 0; j < STAGE_CFGREG_NUM; j++) 923 for (j = 0; j < STAGE_CFGREG_NUM; j++)
943 ad714x->write(ad714x->dev, reg_base + j, 924 ad714x->write(ad714x, reg_base + j,
944 ad714x->hw->stage_cfg_reg[i][j]); 925 ad714x->hw->stage_cfg_reg[i][j]);
945 } 926 }
946 927
947 for (i = 0; i < SYS_CFGREG_NUM; i++) 928 for (i = 0; i < SYS_CFGREG_NUM; i++)
948 ad714x->write(ad714x->dev, AD714X_SYSCFG_REG + i, 929 ad714x->write(ad714x, AD714X_SYSCFG_REG + i,
949 ad714x->hw->sys_cfg_reg[i]); 930 ad714x->hw->sys_cfg_reg[i]);
950 for (i = 0; i < SYS_CFGREG_NUM; i++) 931 for (i = 0; i < SYS_CFGREG_NUM; i++)
951 ad714x->read(ad714x->dev, AD714X_SYSCFG_REG + i, 932 ad714x->read(ad714x, AD714X_SYSCFG_REG + i, &data, 1);
952 &data);
953 933
954 ad714x->write(ad714x->dev, AD714X_STG_CAL_EN_REG, 0xFFF); 934 ad714x->write(ad714x, AD714X_STG_CAL_EN_REG, 0xFFF);
955 935
956 /* clear all interrupts */ 936 /* clear all interrupts */
957 ad714x->read(ad714x->dev, STG_LOW_INT_STA_REG, &data); 937 ad714x->read(ad714x, STG_LOW_INT_STA_REG, &ad714x->l_state, 3);
958 ad714x->read(ad714x->dev, STG_HIGH_INT_STA_REG, &data);
959 ad714x->read(ad714x->dev, STG_COM_INT_STA_REG, &data);
960} 938}
961 939
962static irqreturn_t ad714x_interrupt_thread(int irq, void *data) 940static irqreturn_t ad714x_interrupt_thread(int irq, void *data)
@@ -966,9 +944,7 @@ static irqreturn_t ad714x_interrupt_thread(int irq, void *data)
966 944
967 mutex_lock(&ad714x->mutex); 945 mutex_lock(&ad714x->mutex);
968 946
969 ad714x->read(ad714x->dev, STG_LOW_INT_STA_REG, &ad714x->l_state); 947 ad714x->read(ad714x, STG_LOW_INT_STA_REG, &ad714x->l_state, 3);
970 ad714x->read(ad714x->dev, STG_HIGH_INT_STA_REG, &ad714x->h_state);
971 ad714x->read(ad714x->dev, STG_COM_INT_STA_REG, &ad714x->c_state);
972 948
973 for (i = 0; i < ad714x->hw->button_num; i++) 949 for (i = 0; i < ad714x->hw->button_num; i++)
974 ad714x_button_state_machine(ad714x, i); 950 ad714x_button_state_machine(ad714x, i);
@@ -1245,7 +1221,7 @@ int ad714x_disable(struct ad714x_chip *ad714x)
1245 mutex_lock(&ad714x->mutex); 1221 mutex_lock(&ad714x->mutex);
1246 1222
1247 data = ad714x->hw->sys_cfg_reg[AD714X_PWR_CTRL] | 0x3; 1223 data = ad714x->hw->sys_cfg_reg[AD714X_PWR_CTRL] | 0x3;
1248 ad714x->write(ad714x->dev, AD714X_PWR_CTRL, data); 1224 ad714x->write(ad714x, AD714X_PWR_CTRL, data);
1249 1225
1250 mutex_unlock(&ad714x->mutex); 1226 mutex_unlock(&ad714x->mutex);
1251 1227
@@ -1255,24 +1231,20 @@ EXPORT_SYMBOL(ad714x_disable);
1255 1231
1256int ad714x_enable(struct ad714x_chip *ad714x) 1232int ad714x_enable(struct ad714x_chip *ad714x)
1257{ 1233{
1258 unsigned short data;
1259
1260 dev_dbg(ad714x->dev, "%s enter\n", __func__); 1234 dev_dbg(ad714x->dev, "%s enter\n", __func__);
1261 1235
1262 mutex_lock(&ad714x->mutex); 1236 mutex_lock(&ad714x->mutex);
1263 1237
1264 /* resume to non-shutdown mode */ 1238 /* resume to non-shutdown mode */
1265 1239
1266 ad714x->write(ad714x->dev, AD714X_PWR_CTRL, 1240 ad714x->write(ad714x, AD714X_PWR_CTRL,
1267 ad714x->hw->sys_cfg_reg[AD714X_PWR_CTRL]); 1241 ad714x->hw->sys_cfg_reg[AD714X_PWR_CTRL]);
1268 1242
1269 /* make sure the interrupt output line is not low level after resume, 1243 /* make sure the interrupt output line is not low level after resume,
1270 * otherwise we will get no chance to enter falling-edge irq again 1244 * otherwise we will get no chance to enter falling-edge irq again
1271 */ 1245 */
1272 1246
1273 ad714x->read(ad714x->dev, STG_LOW_INT_STA_REG, &data); 1247 ad714x->read(ad714x, STG_LOW_INT_STA_REG, &ad714x->l_state, 3);
1274 ad714x->read(ad714x->dev, STG_HIGH_INT_STA_REG, &data);
1275 ad714x->read(ad714x->dev, STG_COM_INT_STA_REG, &data);
1276 1248
1277 mutex_unlock(&ad714x->mutex); 1249 mutex_unlock(&ad714x->mutex);
1278 1250
diff --git a/drivers/input/misc/ad714x.h b/drivers/input/misc/ad714x.h
index 45c54fb13f07..3c85455aa66d 100644
--- a/drivers/input/misc/ad714x.h
+++ b/drivers/input/misc/ad714x.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * AD714X CapTouch Programmable Controller driver (bus interfaces) 2 * AD714X CapTouch Programmable Controller driver (bus interfaces)
3 * 3 *
4 * Copyright 2009 Analog Devices Inc. 4 * Copyright 2009-2011 Analog Devices Inc.
5 * 5 *
6 * Licensed under the GPL-2 or later. 6 * Licensed under the GPL-2 or later.
7 */ 7 */
@@ -11,11 +11,40 @@
11 11
12#include <linux/types.h> 12#include <linux/types.h>
13 13
14#define STAGE_NUM 12
15
14struct device; 16struct device;
17struct ad714x_platform_data;
18struct ad714x_driver_data;
15struct ad714x_chip; 19struct ad714x_chip;
16 20
17typedef int (*ad714x_read_t)(struct device *, unsigned short, unsigned short *); 21typedef int (*ad714x_read_t)(struct ad714x_chip *, unsigned short, unsigned short *, size_t);
18typedef int (*ad714x_write_t)(struct device *, unsigned short, unsigned short); 22typedef int (*ad714x_write_t)(struct ad714x_chip *, unsigned short, unsigned short);
23
24struct ad714x_chip {
25 unsigned short l_state;
26 unsigned short h_state;
27 unsigned short c_state;
28 unsigned short adc_reg[STAGE_NUM];
29 unsigned short amb_reg[STAGE_NUM];
30 unsigned short sensor_val[STAGE_NUM];
31
32 struct ad714x_platform_data *hw;
33 struct ad714x_driver_data *sw;
34
35 int irq;
36 struct device *dev;
37 ad714x_read_t read;
38 ad714x_write_t write;
39
40 struct mutex mutex;
41
42 unsigned product;
43 unsigned version;
44
45 __be16 xfer_buf[16] ____cacheline_aligned;
46
47};
19 48
20int ad714x_disable(struct ad714x_chip *ad714x); 49int ad714x_disable(struct ad714x_chip *ad714x);
21int ad714x_enable(struct ad714x_chip *ad714x); 50int ad714x_enable(struct ad714x_chip *ad714x);
diff --git a/drivers/input/misc/mma8450.c b/drivers/input/misc/mma8450.c
index 6c76cf792991..0794778295fc 100644
--- a/drivers/input/misc/mma8450.c
+++ b/drivers/input/misc/mma8450.c
@@ -234,7 +234,7 @@ static const struct of_device_id mma8450_dt_ids[] = {
234 { .compatible = "fsl,mma8450", }, 234 { .compatible = "fsl,mma8450", },
235 { /* sentinel */ } 235 { /* sentinel */ }
236}; 236};
237MODULE_DEVICE_TABLE(i2c, mma8450_dt_ids); 237MODULE_DEVICE_TABLE(of, mma8450_dt_ids);
238 238
239static struct i2c_driver mma8450_driver = { 239static struct i2c_driver mma8450_driver = {
240 .driver = { 240 .driver = {
diff --git a/drivers/input/misc/mpu3050.c b/drivers/input/misc/mpu3050.c
index b95fac15b2ea..f71dc728da58 100644
--- a/drivers/input/misc/mpu3050.c
+++ b/drivers/input/misc/mpu3050.c
@@ -282,7 +282,7 @@ err_free_irq:
282err_pm_set_suspended: 282err_pm_set_suspended:
283 pm_runtime_set_suspended(&client->dev); 283 pm_runtime_set_suspended(&client->dev);
284err_free_mem: 284err_free_mem:
285 input_unregister_device(idev); 285 input_free_device(idev);
286 kfree(sensor); 286 kfree(sensor);
287 return error; 287 return error;
288} 288}
diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
index 3126983c004a..da280189ef07 100644
--- a/drivers/input/mouse/bcm5974.c
+++ b/drivers/input/mouse/bcm5974.c
@@ -67,6 +67,14 @@
67#define USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI 0x0245 67#define USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI 0x0245
68#define USB_DEVICE_ID_APPLE_WELLSPRING5_ISO 0x0246 68#define USB_DEVICE_ID_APPLE_WELLSPRING5_ISO 0x0246
69#define USB_DEVICE_ID_APPLE_WELLSPRING5_JIS 0x0247 69#define USB_DEVICE_ID_APPLE_WELLSPRING5_JIS 0x0247
70/* MacbookAir4,2 (unibody, July 2011) */
71#define USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI 0x024c
72#define USB_DEVICE_ID_APPLE_WELLSPRING6_ISO 0x024d
73#define USB_DEVICE_ID_APPLE_WELLSPRING6_JIS 0x024e
74/* Macbook8,2 (unibody) */
75#define USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI 0x0252
76#define USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO 0x0253
77#define USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS 0x0254
70 78
71#define BCM5974_DEVICE(prod) { \ 79#define BCM5974_DEVICE(prod) { \
72 .match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \ 80 .match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \
@@ -104,6 +112,14 @@ static const struct usb_device_id bcm5974_table[] = {
104 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI), 112 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI),
105 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5_ISO), 113 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5_ISO),
106 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5_JIS), 114 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5_JIS),
115 /* MacbookAir4,2 */
116 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI),
117 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING6_ISO),
118 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING6_JIS),
119 /* MacbookPro8,2 */
120 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI),
121 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO),
122 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS),
107 /* Terminating entry */ 123 /* Terminating entry */
108 {} 124 {}
109}; 125};
@@ -294,6 +310,30 @@ static const struct bcm5974_config bcm5974_config_table[] = {
294 { DIM_X, DIM_X / SN_COORD, -4415, 5050 }, 310 { DIM_X, DIM_X / SN_COORD, -4415, 5050 },
295 { DIM_Y, DIM_Y / SN_COORD, -55, 6680 } 311 { DIM_Y, DIM_Y / SN_COORD, -55, 6680 }
296 }, 312 },
313 {
314 USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI,
315 USB_DEVICE_ID_APPLE_WELLSPRING6_ISO,
316 USB_DEVICE_ID_APPLE_WELLSPRING6_JIS,
317 HAS_INTEGRATED_BUTTON,
318 0x84, sizeof(struct bt_data),
319 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
320 { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 300 },
321 { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 },
322 { DIM_X, DIM_X / SN_COORD, -4620, 5140 },
323 { DIM_Y, DIM_Y / SN_COORD, -150, 6600 }
324 },
325 {
326 USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI,
327 USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO,
328 USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS,
329 HAS_INTEGRATED_BUTTON,
330 0x84, sizeof(struct bt_data),
331 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
332 { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 300 },
333 { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 },
334 { DIM_X, DIM_X / SN_COORD, -4750, 5280 },
335 { DIM_Y, DIM_Y / SN_COORD, -150, 6730 }
336 },
297 {} 337 {}
298}; 338};
299 339
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index 449c0a46dbac..d27c9d91630b 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -49,6 +49,7 @@ struct hid_descriptor {
49#define USB_REQ_GET_REPORT 0x01 49#define USB_REQ_GET_REPORT 0x01
50#define USB_REQ_SET_REPORT 0x09 50#define USB_REQ_SET_REPORT 0x09
51#define WAC_HID_FEATURE_REPORT 0x03 51#define WAC_HID_FEATURE_REPORT 0x03
52#define WAC_MSG_RETRIES 5
52 53
53static int usb_get_report(struct usb_interface *intf, unsigned char type, 54static int usb_get_report(struct usb_interface *intf, unsigned char type,
54 unsigned char id, void *buf, int size) 55 unsigned char id, void *buf, int size)
@@ -165,7 +166,7 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi
165 report, 166 report,
166 hid_desc->wDescriptorLength, 167 hid_desc->wDescriptorLength,
167 5000); /* 5 secs */ 168 5000); /* 5 secs */
168 } while (result < 0 && limit++ < 5); 169 } while (result < 0 && limit++ < WAC_MSG_RETRIES);
169 170
170 /* No need to parse the Descriptor. It isn't an error though */ 171 /* No need to parse the Descriptor. It isn't an error though */
171 if (result < 0) 172 if (result < 0)
@@ -319,24 +320,26 @@ static int wacom_query_tablet_data(struct usb_interface *intf, struct wacom_feat
319 int limit = 0, report_id = 2; 320 int limit = 0, report_id = 2;
320 int error = -ENOMEM; 321 int error = -ENOMEM;
321 322
322 rep_data = kmalloc(2, GFP_KERNEL); 323 rep_data = kmalloc(4, GFP_KERNEL);
323 if (!rep_data) 324 if (!rep_data)
324 return error; 325 return error;
325 326
326 /* ask to report tablet data if it is 2FGT Tablet PC or 327 /* ask to report tablet data if it is MT Tablet PC or
327 * not a Tablet PC */ 328 * not a Tablet PC */
328 if (features->type == TABLETPC2FG) { 329 if (features->type == TABLETPC2FG) {
329 do { 330 do {
330 rep_data[0] = 3; 331 rep_data[0] = 3;
331 rep_data[1] = 4; 332 rep_data[1] = 4;
333 rep_data[2] = 0;
334 rep_data[3] = 0;
332 report_id = 3; 335 report_id = 3;
333 error = usb_set_report(intf, WAC_HID_FEATURE_REPORT, 336 error = usb_set_report(intf, WAC_HID_FEATURE_REPORT,
334 report_id, rep_data, 2); 337 report_id, rep_data, 4);
335 if (error >= 0) 338 if (error >= 0)
336 error = usb_get_report(intf, 339 error = usb_get_report(intf,
337 WAC_HID_FEATURE_REPORT, report_id, 340 WAC_HID_FEATURE_REPORT, report_id,
338 rep_data, 3); 341 rep_data, 4);
339 } while ((error < 0 || rep_data[1] != 4) && limit++ < 5); 342 } while ((error < 0 || rep_data[1] != 4) && limit++ < WAC_MSG_RETRIES);
340 } else if (features->type != TABLETPC) { 343 } else if (features->type != TABLETPC) {
341 do { 344 do {
342 rep_data[0] = 2; 345 rep_data[0] = 2;
@@ -347,7 +350,7 @@ static int wacom_query_tablet_data(struct usb_interface *intf, struct wacom_feat
347 error = usb_get_report(intf, 350 error = usb_get_report(intf,
348 WAC_HID_FEATURE_REPORT, report_id, 351 WAC_HID_FEATURE_REPORT, report_id,
349 rep_data, 2); 352 rep_data, 2);
350 } while ((error < 0 || rep_data[1] != 2) && limit++ < 5); 353 } while ((error < 0 || rep_data[1] != 2) && limit++ < WAC_MSG_RETRIES);
351 } 354 }
352 355
353 kfree(rep_data); 356 kfree(rep_data);
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index 03ebcc8b24b5..c1c2f7b28d89 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -1460,6 +1460,9 @@ static const struct wacom_features wacom_features_0xD3 =
1460static const struct wacom_features wacom_features_0xD4 = 1460static const struct wacom_features wacom_features_0xD4 =
1461 { "Wacom Bamboo Pen", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 1461 { "Wacom Bamboo Pen", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
1462 63, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 1462 63, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1463static const struct wacom_features wacom_features_0xD5 =
1464 { "Wacom Bamboo Pen 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023,
1465 63, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1463static const struct wacom_features wacom_features_0xD6 = 1466static const struct wacom_features wacom_features_0xD6 =
1464 { "Wacom BambooPT 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 1467 { "Wacom BambooPT 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
1465 63, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 1468 63, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
@@ -1564,6 +1567,7 @@ const struct usb_device_id wacom_ids[] = {
1564 { USB_DEVICE_WACOM(0xD2) }, 1567 { USB_DEVICE_WACOM(0xD2) },
1565 { USB_DEVICE_WACOM(0xD3) }, 1568 { USB_DEVICE_WACOM(0xD3) },
1566 { USB_DEVICE_WACOM(0xD4) }, 1569 { USB_DEVICE_WACOM(0xD4) },
1570 { USB_DEVICE_WACOM(0xD5) },
1567 { USB_DEVICE_WACOM(0xD6) }, 1571 { USB_DEVICE_WACOM(0xD6) },
1568 { USB_DEVICE_WACOM(0xD7) }, 1572 { USB_DEVICE_WACOM(0xD7) },
1569 { USB_DEVICE_WACOM(0xD8) }, 1573 { USB_DEVICE_WACOM(0xD8) },
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index ae00604a6a81..f5d66859f232 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -244,6 +244,7 @@ struct mxt_finger {
244 int x; 244 int x;
245 int y; 245 int y;
246 int area; 246 int area;
247 int pressure;
247}; 248};
248 249
249/* Each client has this additional data */ 250/* Each client has this additional data */
@@ -536,6 +537,8 @@ static void mxt_input_report(struct mxt_data *data, int single_id)
536 finger[id].x); 537 finger[id].x);
537 input_report_abs(input_dev, ABS_MT_POSITION_Y, 538 input_report_abs(input_dev, ABS_MT_POSITION_Y,
538 finger[id].y); 539 finger[id].y);
540 input_report_abs(input_dev, ABS_MT_PRESSURE,
541 finger[id].pressure);
539 } else { 542 } else {
540 finger[id].status = 0; 543 finger[id].status = 0;
541 } 544 }
@@ -546,6 +549,8 @@ static void mxt_input_report(struct mxt_data *data, int single_id)
546 if (status != MXT_RELEASE) { 549 if (status != MXT_RELEASE) {
547 input_report_abs(input_dev, ABS_X, finger[single_id].x); 550 input_report_abs(input_dev, ABS_X, finger[single_id].x);
548 input_report_abs(input_dev, ABS_Y, finger[single_id].y); 551 input_report_abs(input_dev, ABS_Y, finger[single_id].y);
552 input_report_abs(input_dev,
553 ABS_PRESSURE, finger[single_id].pressure);
549 } 554 }
550 555
551 input_sync(input_dev); 556 input_sync(input_dev);
@@ -560,6 +565,7 @@ static void mxt_input_touchevent(struct mxt_data *data,
560 int x; 565 int x;
561 int y; 566 int y;
562 int area; 567 int area;
568 int pressure;
563 569
564 /* Check the touch is present on the screen */ 570 /* Check the touch is present on the screen */
565 if (!(status & MXT_DETECT)) { 571 if (!(status & MXT_DETECT)) {
@@ -584,6 +590,7 @@ static void mxt_input_touchevent(struct mxt_data *data,
584 y = y >> 2; 590 y = y >> 2;
585 591
586 area = message->message[4]; 592 area = message->message[4];
593 pressure = message->message[5];
587 594
588 dev_dbg(dev, "[%d] %s x: %d, y: %d, area: %d\n", id, 595 dev_dbg(dev, "[%d] %s x: %d, y: %d, area: %d\n", id,
589 status & MXT_MOVE ? "moved" : "pressed", 596 status & MXT_MOVE ? "moved" : "pressed",
@@ -594,6 +601,7 @@ static void mxt_input_touchevent(struct mxt_data *data,
594 finger[id].x = x; 601 finger[id].x = x;
595 finger[id].y = y; 602 finger[id].y = y;
596 finger[id].area = area; 603 finger[id].area = area;
604 finger[id].pressure = pressure;
597 605
598 mxt_input_report(data, id); 606 mxt_input_report(data, id);
599} 607}
@@ -1116,6 +1124,8 @@ static int __devinit mxt_probe(struct i2c_client *client,
1116 0, data->max_x, 0, 0); 1124 0, data->max_x, 0, 0);
1117 input_set_abs_params(input_dev, ABS_Y, 1125 input_set_abs_params(input_dev, ABS_Y,
1118 0, data->max_y, 0, 0); 1126 0, data->max_y, 0, 0);
1127 input_set_abs_params(input_dev, ABS_PRESSURE,
1128 0, 255, 0, 0);
1119 1129
1120 /* For multi touch */ 1130 /* For multi touch */
1121 input_mt_init_slots(input_dev, MXT_MAX_FINGER); 1131 input_mt_init_slots(input_dev, MXT_MAX_FINGER);
@@ -1125,6 +1135,8 @@ static int __devinit mxt_probe(struct i2c_client *client,
1125 0, data->max_x, 0, 0); 1135 0, data->max_x, 0, 0);
1126 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 1136 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
1127 0, data->max_y, 0, 0); 1137 0, data->max_y, 0, 0);
1138 input_set_abs_params(input_dev, ABS_MT_PRESSURE,
1139 0, 255, 0, 0);
1128 1140
1129 input_set_drvdata(input_dev, data); 1141 input_set_drvdata(input_dev, data);
1130 i2c_set_clientdata(client, data); 1142 i2c_set_clientdata(client, data);
diff --git a/drivers/input/touchscreen/max11801_ts.c b/drivers/input/touchscreen/max11801_ts.c
index 4f2713d92791..4627fe55b401 100644
--- a/drivers/input/touchscreen/max11801_ts.c
+++ b/drivers/input/touchscreen/max11801_ts.c
@@ -9,7 +9,8 @@
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 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 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. 12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
13 */ 14 */
14 15
15/* 16/*
diff --git a/drivers/input/touchscreen/tnetv107x-ts.c b/drivers/input/touchscreen/tnetv107x-ts.c
index 089b0a0f3d8c..0e8f63e5b36f 100644
--- a/drivers/input/touchscreen/tnetv107x-ts.c
+++ b/drivers/input/touchscreen/tnetv107x-ts.c
@@ -13,6 +13,7 @@
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 */ 14 */
15 15
16#include <linux/module.h>
16#include <linux/kernel.h> 17#include <linux/kernel.h>
17#include <linux/err.h> 18#include <linux/err.h>
18#include <linux/errno.h> 19#include <linux/errno.h>
diff --git a/drivers/leds/leds-ams-delta.c b/drivers/leds/leds-ams-delta.c
index b9826032450b..8c00937bf7e7 100644
--- a/drivers/leds/leds-ams-delta.c
+++ b/drivers/leds/leds-ams-delta.c
@@ -8,6 +8,7 @@
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10 10
11#include <linux/module.h>
11#include <linux/kernel.h> 12#include <linux/kernel.h>
12#include <linux/init.h> 13#include <linux/init.h>
13#include <linux/platform_device.h> 14#include <linux/platform_device.h>
diff --git a/drivers/leds/leds-bd2802.c b/drivers/leds/leds-bd2802.c
index 3ebe3824662d..ea2185531f82 100644
--- a/drivers/leds/leds-bd2802.c
+++ b/drivers/leds/leds-bd2802.c
@@ -662,6 +662,11 @@ failed_unregister_led1_R:
662static void bd2802_unregister_led_classdev(struct bd2802_led *led) 662static void bd2802_unregister_led_classdev(struct bd2802_led *led)
663{ 663{
664 cancel_work_sync(&led->work); 664 cancel_work_sync(&led->work);
665 led_classdev_unregister(&led->cdev_led2b);
666 led_classdev_unregister(&led->cdev_led2g);
667 led_classdev_unregister(&led->cdev_led2r);
668 led_classdev_unregister(&led->cdev_led1b);
669 led_classdev_unregister(&led->cdev_led1g);
665 led_classdev_unregister(&led->cdev_led1r); 670 led_classdev_unregister(&led->cdev_led1r);
666} 671}
667 672
diff --git a/drivers/leds/leds-hp6xx.c b/drivers/leds/leds-hp6xx.c
index e4ce1fd46338..bcfbd3a60eab 100644
--- a/drivers/leds/leds-hp6xx.c
+++ b/drivers/leds/leds-hp6xx.c
@@ -10,6 +10,7 @@
10 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
11 */ 11 */
12 12
13#include <linux/module.h>
13#include <linux/kernel.h> 14#include <linux/kernel.h>
14#include <linux/init.h> 15#include <linux/init.h>
15#include <linux/platform_device.h> 16#include <linux/platform_device.h>
diff --git a/drivers/misc/ab8500-pwm.c b/drivers/misc/ab8500-pwm.c
index 54e3d05b63cc..35903154ca2e 100644
--- a/drivers/misc/ab8500-pwm.c
+++ b/drivers/misc/ab8500-pwm.c
@@ -164,5 +164,5 @@ subsys_initcall(ab8500_pwm_init);
164module_exit(ab8500_pwm_exit); 164module_exit(ab8500_pwm_exit);
165MODULE_AUTHOR("Arun MURTHY <arun.murthy@stericsson.com>"); 165MODULE_AUTHOR("Arun MURTHY <arun.murthy@stericsson.com>");
166MODULE_DESCRIPTION("AB8500 Pulse Width Modulation Driver"); 166MODULE_DESCRIPTION("AB8500 Pulse Width Modulation Driver");
167MODULE_ALIAS("AB8500 PWM driver"); 167MODULE_ALIAS("platform:ab8500-pwm");
168MODULE_LICENSE("GPL v2"); 168MODULE_LICENSE("GPL v2");
diff --git a/drivers/misc/fsa9480.c b/drivers/misc/fsa9480.c
index 5325a7e70dcf..27dc0d21aafa 100644
--- a/drivers/misc/fsa9480.c
+++ b/drivers/misc/fsa9480.c
@@ -455,7 +455,7 @@ static int __devinit fsa9480_probe(struct i2c_client *client,
455 455
456fail2: 456fail2:
457 if (client->irq) 457 if (client->irq)
458 free_irq(client->irq, NULL); 458 free_irq(client->irq, usbsw);
459fail1: 459fail1:
460 i2c_set_clientdata(client, NULL); 460 i2c_set_clientdata(client, NULL);
461 kfree(usbsw); 461 kfree(usbsw);
@@ -466,7 +466,7 @@ static int __devexit fsa9480_remove(struct i2c_client *client)
466{ 466{
467 struct fsa9480_usbsw *usbsw = i2c_get_clientdata(client); 467 struct fsa9480_usbsw *usbsw = i2c_get_clientdata(client);
468 if (client->irq) 468 if (client->irq)
469 free_irq(client->irq, NULL); 469 free_irq(client->irq, usbsw);
470 i2c_set_clientdata(client, NULL); 470 i2c_set_clientdata(client, NULL);
471 471
472 sysfs_remove_group(&client->dev.kobj, &fsa9480_group); 472 sysfs_remove_group(&client->dev.kobj, &fsa9480_group);
diff --git a/drivers/misc/pti.c b/drivers/misc/pti.c
index 8653bd0b1a33..06df1877ad0f 100644
--- a/drivers/misc/pti.c
+++ b/drivers/misc/pti.c
@@ -33,6 +33,8 @@
33#include <linux/mutex.h> 33#include <linux/mutex.h>
34#include <linux/miscdevice.h> 34#include <linux/miscdevice.h>
35#include <linux/pti.h> 35#include <linux/pti.h>
36#include <linux/slab.h>
37#include <linux/uaccess.h>
36 38
37#define DRIVERNAME "pti" 39#define DRIVERNAME "pti"
38#define PCINAME "pciPTI" 40#define PCINAME "pciPTI"
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 38a83acd502e..43f2ea541088 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3419,9 +3419,27 @@ static int bond_xmit_hash_policy_l2(struct sk_buff *skb, int count)
3419static int bond_open(struct net_device *bond_dev) 3419static int bond_open(struct net_device *bond_dev)
3420{ 3420{
3421 struct bonding *bond = netdev_priv(bond_dev); 3421 struct bonding *bond = netdev_priv(bond_dev);
3422 struct slave *slave;
3423 int i;
3422 3424
3423 bond->kill_timers = 0; 3425 bond->kill_timers = 0;
3424 3426
3427 /* reset slave->backup and slave->inactive */
3428 read_lock(&bond->lock);
3429 if (bond->slave_cnt > 0) {
3430 read_lock(&bond->curr_slave_lock);
3431 bond_for_each_slave(bond, slave, i) {
3432 if ((bond->params.mode == BOND_MODE_ACTIVEBACKUP)
3433 && (slave != bond->curr_active_slave)) {
3434 bond_set_slave_inactive_flags(slave);
3435 } else {
3436 bond_set_slave_active_flags(slave);
3437 }
3438 }
3439 read_unlock(&bond->curr_slave_lock);
3440 }
3441 read_unlock(&bond->lock);
3442
3425 INIT_DELAYED_WORK(&bond->mcast_work, bond_resend_igmp_join_requests_delayed); 3443 INIT_DELAYED_WORK(&bond->mcast_work, bond_resend_igmp_join_requests_delayed);
3426 3444
3427 if (bond_is_lb(bond)) { 3445 if (bond_is_lb(bond)) {
diff --git a/drivers/net/can/sja1000/plx_pci.c b/drivers/net/can/sja1000/plx_pci.c
index 231385b8e08f..c7f3d4ea1167 100644
--- a/drivers/net/can/sja1000/plx_pci.c
+++ b/drivers/net/can/sja1000/plx_pci.c
@@ -408,7 +408,7 @@ static void plx_pci_del_card(struct pci_dev *pdev)
408 struct sja1000_priv *priv; 408 struct sja1000_priv *priv;
409 int i = 0; 409 int i = 0;
410 410
411 for (i = 0; i < card->channels; i++) { 411 for (i = 0; i < PLX_PCI_MAX_CHAN; i++) {
412 dev = card->net_dev[i]; 412 dev = card->net_dev[i];
413 if (!dev) 413 if (!dev)
414 continue; 414 continue;
@@ -536,7 +536,6 @@ static int __devinit plx_pci_add_card(struct pci_dev *pdev,
536 if (err) { 536 if (err) {
537 dev_err(&pdev->dev, "Registering device failed " 537 dev_err(&pdev->dev, "Registering device failed "
538 "(err=%d)\n", err); 538 "(err=%d)\n", err);
539 free_sja1000dev(dev);
540 goto failure_cleanup; 539 goto failure_cleanup;
541 } 540 }
542 541
@@ -549,6 +548,7 @@ static int __devinit plx_pci_add_card(struct pci_dev *pdev,
549 dev_err(&pdev->dev, "Channel #%d not detected\n", 548 dev_err(&pdev->dev, "Channel #%d not detected\n",
550 i + 1); 549 i + 1);
551 free_sja1000dev(dev); 550 free_sja1000dev(dev);
551 card->net_dev[i] = NULL;
552 } 552 }
553 } 553 }
554 554
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index 35916f485028..8533ad7f3559 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -155,6 +155,9 @@ struct e1000_info;
155#define HV_M_STATUS_SPEED_1000 0x0200 155#define HV_M_STATUS_SPEED_1000 0x0200
156#define HV_M_STATUS_LINK_UP 0x0040 156#define HV_M_STATUS_LINK_UP 0x0040
157 157
158#define E1000_ICH_FWSM_PCIM2PCI 0x01000000 /* ME PCIm-to-PCI active */
159#define E1000_ICH_FWSM_PCIM2PCI_COUNT 2000
160
158/* Time to wait before putting the device into D3 if there's no link (in ms). */ 161/* Time to wait before putting the device into D3 if there's no link (in ms). */
159#define LINK_TIMEOUT 100 162#define LINK_TIMEOUT 100
160 163
@@ -454,6 +457,7 @@ struct e1000_info {
454#define FLAG2_DISABLE_AIM (1 << 8) 457#define FLAG2_DISABLE_AIM (1 << 8)
455#define FLAG2_CHECK_PHY_HANG (1 << 9) 458#define FLAG2_CHECK_PHY_HANG (1 << 9)
456#define FLAG2_NO_DISABLE_RX (1 << 10) 459#define FLAG2_NO_DISABLE_RX (1 << 10)
460#define FLAG2_PCIM2PCI_ARBITER_WA (1 << 11)
457 461
458#define E1000_RX_DESC_PS(R, i) \ 462#define E1000_RX_DESC_PS(R, i) \
459 (&(((union e1000_rx_desc_packet_split *)((R).desc))[i])) 463 (&(((union e1000_rx_desc_packet_split *)((R).desc))[i]))
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index 4e36978b8fd8..54add27c8f76 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -137,8 +137,9 @@
137#define HV_PM_CTRL PHY_REG(770, 17) 137#define HV_PM_CTRL PHY_REG(770, 17)
138 138
139/* PHY Low Power Idle Control */ 139/* PHY Low Power Idle Control */
140#define I82579_LPI_CTRL PHY_REG(772, 20) 140#define I82579_LPI_CTRL PHY_REG(772, 20)
141#define I82579_LPI_CTRL_ENABLE_MASK 0x6000 141#define I82579_LPI_CTRL_ENABLE_MASK 0x6000
142#define I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT 0x80
142 143
143/* EMI Registers */ 144/* EMI Registers */
144#define I82579_EMI_ADDR 0x10 145#define I82579_EMI_ADDR 0x10
@@ -163,6 +164,11 @@
163#define HV_KMRN_MODE_CTRL PHY_REG(769, 16) 164#define HV_KMRN_MODE_CTRL PHY_REG(769, 16)
164#define HV_KMRN_MDIO_SLOW 0x0400 165#define HV_KMRN_MDIO_SLOW 0x0400
165 166
167/* KMRN FIFO Control and Status */
168#define HV_KMRN_FIFO_CTRLSTA PHY_REG(770, 16)
169#define HV_KMRN_FIFO_CTRLSTA_PREAMBLE_MASK 0x7000
170#define HV_KMRN_FIFO_CTRLSTA_PREAMBLE_SHIFT 12
171
166/* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */ 172/* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */
167/* Offset 04h HSFSTS */ 173/* Offset 04h HSFSTS */
168union ich8_hws_flash_status { 174union ich8_hws_flash_status {
@@ -657,6 +663,7 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
657 struct e1000_mac_info *mac = &hw->mac; 663 struct e1000_mac_info *mac = &hw->mac;
658 s32 ret_val; 664 s32 ret_val;
659 bool link; 665 bool link;
666 u16 phy_reg;
660 667
661 /* 668 /*
662 * We only want to go out to the PHY registers to see if Auto-Neg 669 * We only want to go out to the PHY registers to see if Auto-Neg
@@ -689,16 +696,35 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
689 696
690 mac->get_link_status = false; 697 mac->get_link_status = false;
691 698
692 if (hw->phy.type == e1000_phy_82578) { 699 switch (hw->mac.type) {
693 ret_val = e1000_link_stall_workaround_hv(hw); 700 case e1000_pch2lan:
694 if (ret_val)
695 goto out;
696 }
697
698 if (hw->mac.type == e1000_pch2lan) {
699 ret_val = e1000_k1_workaround_lv(hw); 701 ret_val = e1000_k1_workaround_lv(hw);
700 if (ret_val) 702 if (ret_val)
701 goto out; 703 goto out;
704 /* fall-thru */
705 case e1000_pchlan:
706 if (hw->phy.type == e1000_phy_82578) {
707 ret_val = e1000_link_stall_workaround_hv(hw);
708 if (ret_val)
709 goto out;
710 }
711
712 /*
713 * Workaround for PCHx parts in half-duplex:
714 * Set the number of preambles removed from the packet
715 * when it is passed from the PHY to the MAC to prevent
716 * the MAC from misinterpreting the packet type.
717 */
718 e1e_rphy(hw, HV_KMRN_FIFO_CTRLSTA, &phy_reg);
719 phy_reg &= ~HV_KMRN_FIFO_CTRLSTA_PREAMBLE_MASK;
720
721 if ((er32(STATUS) & E1000_STATUS_FD) != E1000_STATUS_FD)
722 phy_reg |= (1 << HV_KMRN_FIFO_CTRLSTA_PREAMBLE_SHIFT);
723
724 e1e_wphy(hw, HV_KMRN_FIFO_CTRLSTA, phy_reg);
725 break;
726 default:
727 break;
702 } 728 }
703 729
704 /* 730 /*
@@ -788,6 +814,11 @@ static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter)
788 (adapter->hw.phy.type == e1000_phy_igp_3)) 814 (adapter->hw.phy.type == e1000_phy_igp_3))
789 adapter->flags |= FLAG_LSC_GIG_SPEED_DROP; 815 adapter->flags |= FLAG_LSC_GIG_SPEED_DROP;
790 816
817 /* Enable workaround for 82579 w/ ME enabled */
818 if ((adapter->hw.mac.type == e1000_pch2lan) &&
819 (er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
820 adapter->flags2 |= FLAG2_PCIM2PCI_ARBITER_WA;
821
791 /* Disable EEE by default until IEEE802.3az spec is finalized */ 822 /* Disable EEE by default until IEEE802.3az spec is finalized */
792 if (adapter->flags2 & FLAG2_HAS_EEE) 823 if (adapter->flags2 & FLAG2_HAS_EEE)
793 adapter->hw.dev_spec.ich8lan.eee_disable = true; 824 adapter->hw.dev_spec.ich8lan.eee_disable = true;
@@ -1355,7 +1386,7 @@ static s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)
1355 return ret_val; 1386 return ret_val;
1356 1387
1357 /* Preamble tuning for SSC */ 1388 /* Preamble tuning for SSC */
1358 ret_val = e1e_wphy(hw, PHY_REG(770, 16), 0xA204); 1389 ret_val = e1e_wphy(hw, HV_KMRN_FIFO_CTRLSTA, 0xA204);
1359 if (ret_val) 1390 if (ret_val)
1360 return ret_val; 1391 return ret_val;
1361 } 1392 }
@@ -1645,6 +1676,7 @@ static s32 e1000_k1_workaround_lv(struct e1000_hw *hw)
1645 s32 ret_val = 0; 1676 s32 ret_val = 0;
1646 u16 status_reg = 0; 1677 u16 status_reg = 0;
1647 u32 mac_reg; 1678 u32 mac_reg;
1679 u16 phy_reg;
1648 1680
1649 if (hw->mac.type != e1000_pch2lan) 1681 if (hw->mac.type != e1000_pch2lan)
1650 goto out; 1682 goto out;
@@ -1659,12 +1691,19 @@ static s32 e1000_k1_workaround_lv(struct e1000_hw *hw)
1659 mac_reg = er32(FEXTNVM4); 1691 mac_reg = er32(FEXTNVM4);
1660 mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK; 1692 mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK;
1661 1693
1662 if (status_reg & HV_M_STATUS_SPEED_1000) 1694 ret_val = e1e_rphy(hw, I82579_LPI_CTRL, &phy_reg);
1695 if (ret_val)
1696 goto out;
1697
1698 if (status_reg & HV_M_STATUS_SPEED_1000) {
1663 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_8USEC; 1699 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_8USEC;
1664 else 1700 phy_reg &= ~I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT;
1701 } else {
1665 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_16USEC; 1702 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_16USEC;
1666 1703 phy_reg |= I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT;
1704 }
1667 ew32(FEXTNVM4, mac_reg); 1705 ew32(FEXTNVM4, mac_reg);
1706 ret_val = e1e_wphy(hw, I82579_LPI_CTRL, phy_reg);
1668 } 1707 }
1669 1708
1670out: 1709out:
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 362f70382cdd..2198e615f241 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -519,6 +519,63 @@ static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err,
519} 519}
520 520
521/** 521/**
522 * e1000e_update_tail_wa - helper function for e1000e_update_[rt]dt_wa()
523 * @hw: pointer to the HW structure
524 * @tail: address of tail descriptor register
525 * @i: value to write to tail descriptor register
526 *
527 * When updating the tail register, the ME could be accessing Host CSR
528 * registers at the same time. Normally, this is handled in h/w by an
529 * arbiter but on some parts there is a bug that acknowledges Host accesses
530 * later than it should which could result in the descriptor register to
531 * have an incorrect value. Workaround this by checking the FWSM register
532 * which has bit 24 set while ME is accessing Host CSR registers, wait
533 * if it is set and try again a number of times.
534 **/
535static inline s32 e1000e_update_tail_wa(struct e1000_hw *hw, u8 __iomem * tail,
536 unsigned int i)
537{
538 unsigned int j = 0;
539
540 while ((j++ < E1000_ICH_FWSM_PCIM2PCI_COUNT) &&
541 (er32(FWSM) & E1000_ICH_FWSM_PCIM2PCI))
542 udelay(50);
543
544 writel(i, tail);
545
546 if ((j == E1000_ICH_FWSM_PCIM2PCI_COUNT) && (i != readl(tail)))
547 return E1000_ERR_SWFW_SYNC;
548
549 return 0;
550}
551
552static void e1000e_update_rdt_wa(struct e1000_adapter *adapter, unsigned int i)
553{
554 u8 __iomem *tail = (adapter->hw.hw_addr + adapter->rx_ring->tail);
555 struct e1000_hw *hw = &adapter->hw;
556
557 if (e1000e_update_tail_wa(hw, tail, i)) {
558 u32 rctl = er32(RCTL);
559 ew32(RCTL, rctl & ~E1000_RCTL_EN);
560 e_err("ME firmware caused invalid RDT - resetting\n");
561 schedule_work(&adapter->reset_task);
562 }
563}
564
565static void e1000e_update_tdt_wa(struct e1000_adapter *adapter, unsigned int i)
566{
567 u8 __iomem *tail = (adapter->hw.hw_addr + adapter->tx_ring->tail);
568 struct e1000_hw *hw = &adapter->hw;
569
570 if (e1000e_update_tail_wa(hw, tail, i)) {
571 u32 tctl = er32(TCTL);
572 ew32(TCTL, tctl & ~E1000_TCTL_EN);
573 e_err("ME firmware caused invalid TDT - resetting\n");
574 schedule_work(&adapter->reset_task);
575 }
576}
577
578/**
522 * e1000_alloc_rx_buffers - Replace used receive buffers; legacy & extended 579 * e1000_alloc_rx_buffers - Replace used receive buffers; legacy & extended
523 * @adapter: address of board private structure 580 * @adapter: address of board private structure
524 **/ 581 **/
@@ -573,7 +630,10 @@ map_skb:
573 * such as IA-64). 630 * such as IA-64).
574 */ 631 */
575 wmb(); 632 wmb();
576 writel(i, adapter->hw.hw_addr + rx_ring->tail); 633 if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA)
634 e1000e_update_rdt_wa(adapter, i);
635 else
636 writel(i, adapter->hw.hw_addr + rx_ring->tail);
577 } 637 }
578 i++; 638 i++;
579 if (i == rx_ring->count) 639 if (i == rx_ring->count)
@@ -673,7 +733,11 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
673 * such as IA-64). 733 * such as IA-64).
674 */ 734 */
675 wmb(); 735 wmb();
676 writel(i << 1, adapter->hw.hw_addr + rx_ring->tail); 736 if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA)
737 e1000e_update_rdt_wa(adapter, i << 1);
738 else
739 writel(i << 1,
740 adapter->hw.hw_addr + rx_ring->tail);
677 } 741 }
678 742
679 i++; 743 i++;
@@ -756,7 +820,10 @@ check_page:
756 * applicable for weak-ordered memory model archs, 820 * applicable for weak-ordered memory model archs,
757 * such as IA-64). */ 821 * such as IA-64). */
758 wmb(); 822 wmb();
759 writel(i, adapter->hw.hw_addr + rx_ring->tail); 823 if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA)
824 e1000e_update_rdt_wa(adapter, i);
825 else
826 writel(i, adapter->hw.hw_addr + rx_ring->tail);
760 } 827 }
761} 828}
762 829
@@ -4689,7 +4756,12 @@ static void e1000_tx_queue(struct e1000_adapter *adapter,
4689 wmb(); 4756 wmb();
4690 4757
4691 tx_ring->next_to_use = i; 4758 tx_ring->next_to_use = i;
4692 writel(i, adapter->hw.hw_addr + tx_ring->tail); 4759
4760 if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA)
4761 e1000e_update_tdt_wa(adapter, i);
4762 else
4763 writel(i, adapter->hw.hw_addr + tx_ring->tail);
4764
4693 /* 4765 /*
4694 * we need this if more than one processor can write to our tail 4766 * we need this if more than one processor can write to our tail
4695 * at a time, it synchronizes IO on IA64/Altix systems 4767 * at a time, it synchronizes IO on IA64/Altix systems
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index e55df308a3af..6d5fbd4d4256 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -5615,7 +5615,8 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
5615 goto out_error; 5615 goto out_error;
5616 } 5616 }
5617 5617
5618 nv_vlan_mode(dev, dev->features); 5618 if (id->driver_data & DEV_HAS_VLAN)
5619 nv_vlan_mode(dev, dev->features);
5619 5620
5620 netif_carrier_off(dev); 5621 netif_carrier_off(dev);
5621 5622
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 2659daad783d..31d5c574e5a9 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -2710,8 +2710,13 @@ static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb,
2710 /* Tell the skb what kind of packet this is */ 2710 /* Tell the skb what kind of packet this is */
2711 skb->protocol = eth_type_trans(skb, dev); 2711 skb->protocol = eth_type_trans(skb, dev);
2712 2712
2713 /* Set vlan tag */ 2713 /*
2714 if (fcb->flags & RXFCB_VLN) 2714 * There's need to check for NETIF_F_HW_VLAN_RX here.
2715 * Even if vlan rx accel is disabled, on some chips
2716 * RXFCB_VLN is pseudo randomly set.
2717 */
2718 if (dev->features & NETIF_F_HW_VLAN_RX &&
2719 fcb->flags & RXFCB_VLN)
2715 __vlan_hwaccel_put_tag(skb, fcb->vlctl); 2720 __vlan_hwaccel_put_tag(skb, fcb->vlctl);
2716 2721
2717 /* Send the packet up the stack */ 2722 /* Send the packet up the stack */
diff --git a/drivers/net/gianfar_ethtool.c b/drivers/net/gianfar_ethtool.c
index 6e350692d118..25a8c2adb001 100644
--- a/drivers/net/gianfar_ethtool.c
+++ b/drivers/net/gianfar_ethtool.c
@@ -686,10 +686,21 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow, u
686{ 686{
687 unsigned int last_rule_idx = priv->cur_filer_idx; 687 unsigned int last_rule_idx = priv->cur_filer_idx;
688 unsigned int cmp_rqfpr; 688 unsigned int cmp_rqfpr;
689 unsigned int local_rqfpr[MAX_FILER_IDX + 1]; 689 unsigned int *local_rqfpr;
690 unsigned int local_rqfcr[MAX_FILER_IDX + 1]; 690 unsigned int *local_rqfcr;
691 int i = 0x0, k = 0x0; 691 int i = 0x0, k = 0x0;
692 int j = MAX_FILER_IDX, l = 0x0; 692 int j = MAX_FILER_IDX, l = 0x0;
693 int ret = 1;
694
695 local_rqfpr = kmalloc(sizeof(unsigned int) * (MAX_FILER_IDX + 1),
696 GFP_KERNEL);
697 local_rqfcr = kmalloc(sizeof(unsigned int) * (MAX_FILER_IDX + 1),
698 GFP_KERNEL);
699 if (!local_rqfpr || !local_rqfcr) {
700 pr_err("Out of memory\n");
701 ret = 0;
702 goto err;
703 }
693 704
694 switch (class) { 705 switch (class) {
695 case TCP_V4_FLOW: 706 case TCP_V4_FLOW:
@@ -706,7 +717,8 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow, u
706 break; 717 break;
707 default: 718 default:
708 pr_err("Right now this class is not supported\n"); 719 pr_err("Right now this class is not supported\n");
709 return 0; 720 ret = 0;
721 goto err;
710 } 722 }
711 723
712 for (i = 0; i < MAX_FILER_IDX + 1; i++) { 724 for (i = 0; i < MAX_FILER_IDX + 1; i++) {
@@ -721,7 +733,8 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow, u
721 733
722 if (i == MAX_FILER_IDX + 1) { 734 if (i == MAX_FILER_IDX + 1) {
723 pr_err("No parse rule found, can't create hash rules\n"); 735 pr_err("No parse rule found, can't create hash rules\n");
724 return 0; 736 ret = 0;
737 goto err;
725 } 738 }
726 739
727 /* If a match was found, then it begins the starting of a cluster rule 740 /* If a match was found, then it begins the starting of a cluster rule
@@ -765,7 +778,10 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow, u
765 priv->cur_filer_idx = priv->cur_filer_idx - 1; 778 priv->cur_filer_idx = priv->cur_filer_idx - 1;
766 } 779 }
767 780
768 return 1; 781err:
782 kfree(local_rqfcr);
783 kfree(local_rqfpr);
784 return ret;
769} 785}
770 786
771static int gfar_set_hash_opts(struct gfar_private *priv, struct ethtool_rxnfc *cmd) 787static int gfar_set_hash_opts(struct gfar_private *priv, struct ethtool_rxnfc *cmd)
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index e86297b32733..22790394318a 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -1459,8 +1459,10 @@ static void ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,
1459 if (ixgbe_rx_is_fcoe(adapter, rx_desc)) { 1459 if (ixgbe_rx_is_fcoe(adapter, rx_desc)) {
1460 ddp_bytes = ixgbe_fcoe_ddp(adapter, rx_desc, skb, 1460 ddp_bytes = ixgbe_fcoe_ddp(adapter, rx_desc, skb,
1461 staterr); 1461 staterr);
1462 if (!ddp_bytes) 1462 if (!ddp_bytes) {
1463 dev_kfree_skb_any(skb);
1463 goto next_desc; 1464 goto next_desc;
1465 }
1464 } 1466 }
1465#endif /* IXGBE_FCOE */ 1467#endif /* IXGBE_FCOE */
1466 ixgbe_receive_skb(q_vector, skb, staterr, rx_ring, rx_desc); 1468 ixgbe_receive_skb(q_vector, skb, staterr, rx_ring, rx_desc);
diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c
index 86ac38c96bcf..3bb131137033 100644
--- a/drivers/net/rionet.c
+++ b/drivers/net/rionet.c
@@ -80,13 +80,13 @@ static int rionet_capable = 1;
80 */ 80 */
81static struct rio_dev **rionet_active; 81static struct rio_dev **rionet_active;
82 82
83#define is_rionet_capable(pef, src_ops, dst_ops) \ 83#define is_rionet_capable(src_ops, dst_ops) \
84 ((pef & RIO_PEF_INB_MBOX) && \ 84 ((src_ops & RIO_SRC_OPS_DATA_MSG) && \
85 (pef & RIO_PEF_INB_DOORBELL) && \ 85 (dst_ops & RIO_DST_OPS_DATA_MSG) && \
86 (src_ops & RIO_SRC_OPS_DOORBELL) && \ 86 (src_ops & RIO_SRC_OPS_DOORBELL) && \
87 (dst_ops & RIO_DST_OPS_DOORBELL)) 87 (dst_ops & RIO_DST_OPS_DOORBELL))
88#define dev_rionet_capable(dev) \ 88#define dev_rionet_capable(dev) \
89 is_rionet_capable(dev->pef, dev->src_ops, dev->dst_ops) 89 is_rionet_capable(dev->src_ops, dev->dst_ops)
90 90
91#define RIONET_MAC_MATCH(x) (*(u32 *)x == 0x00010001) 91#define RIONET_MAC_MATCH(x) (*(u32 *)x == 0x00010001)
92#define RIONET_GET_DESTID(x) (*(u16 *)(x + 4)) 92#define RIONET_GET_DESTID(x) (*(u16 *)(x + 4))
@@ -282,7 +282,6 @@ static int rionet_open(struct net_device *ndev)
282{ 282{
283 int i, rc = 0; 283 int i, rc = 0;
284 struct rionet_peer *peer, *tmp; 284 struct rionet_peer *peer, *tmp;
285 u32 pwdcsr;
286 struct rionet_private *rnet = netdev_priv(ndev); 285 struct rionet_private *rnet = netdev_priv(ndev);
287 286
288 if (netif_msg_ifup(rnet)) 287 if (netif_msg_ifup(rnet))
@@ -332,13 +331,8 @@ static int rionet_open(struct net_device *ndev)
332 continue; 331 continue;
333 } 332 }
334 333
335 /* 334 /* Send a join message */
336 * If device has initialized inbound doorbells, 335 rio_send_doorbell(peer->rdev, RIONET_DOORBELL_JOIN);
337 * send a join message
338 */
339 rio_read_config_32(peer->rdev, RIO_WRITE_PORT_CSR, &pwdcsr);
340 if (pwdcsr & RIO_DOORBELL_AVAIL)
341 rio_send_doorbell(peer->rdev, RIONET_DOORBELL_JOIN);
342 } 336 }
343 337
344 out: 338 out:
@@ -492,7 +486,7 @@ static int rionet_setup_netdev(struct rio_mport *mport, struct net_device *ndev)
492static int rionet_probe(struct rio_dev *rdev, const struct rio_device_id *id) 486static int rionet_probe(struct rio_dev *rdev, const struct rio_device_id *id)
493{ 487{
494 int rc = -ENODEV; 488 int rc = -ENODEV;
495 u32 lpef, lsrc_ops, ldst_ops; 489 u32 lsrc_ops, ldst_ops;
496 struct rionet_peer *peer; 490 struct rionet_peer *peer;
497 struct net_device *ndev = NULL; 491 struct net_device *ndev = NULL;
498 492
@@ -515,12 +509,11 @@ static int rionet_probe(struct rio_dev *rdev, const struct rio_device_id *id)
515 * on later probes 509 * on later probes
516 */ 510 */
517 if (!rionet_check) { 511 if (!rionet_check) {
518 rio_local_read_config_32(rdev->net->hport, RIO_PEF_CAR, &lpef);
519 rio_local_read_config_32(rdev->net->hport, RIO_SRC_OPS_CAR, 512 rio_local_read_config_32(rdev->net->hport, RIO_SRC_OPS_CAR,
520 &lsrc_ops); 513 &lsrc_ops);
521 rio_local_read_config_32(rdev->net->hport, RIO_DST_OPS_CAR, 514 rio_local_read_config_32(rdev->net->hport, RIO_DST_OPS_CAR,
522 &ldst_ops); 515 &ldst_ops);
523 if (!is_rionet_capable(lpef, lsrc_ops, ldst_ops)) { 516 if (!is_rionet_capable(lsrc_ops, ldst_ops)) {
524 printk(KERN_ERR 517 printk(KERN_ERR
525 "%s: local device is not network capable\n", 518 "%s: local device is not network capable\n",
526 DRV_NAME); 519 DRV_NAME);
diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c
index ad35c210b839..190f619e4215 100644
--- a/drivers/net/sh_eth.c
+++ b/drivers/net/sh_eth.c
@@ -21,6 +21,7 @@
21 */ 21 */
22 22
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/interrupt.h>
24#include <linux/dma-mapping.h> 25#include <linux/dma-mapping.h>
25#include <linux/etherdevice.h> 26#include <linux/etherdevice.h>
26#include <linux/delay.h> 27#include <linux/delay.h>
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index a03336e086d5..f06fb78383a1 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -228,23 +228,40 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
228 if (ctx->rx_max != le32_to_cpu(ctx->ncm_parm.dwNtbInMaxSize)) { 228 if (ctx->rx_max != le32_to_cpu(ctx->ncm_parm.dwNtbInMaxSize)) {
229 229
230 if (flags & USB_CDC_NCM_NCAP_NTB_INPUT_SIZE) { 230 if (flags & USB_CDC_NCM_NCAP_NTB_INPUT_SIZE) {
231 struct usb_cdc_ncm_ndp_input_size ndp_in_sz; 231 struct usb_cdc_ncm_ndp_input_size *ndp_in_sz;
232
233 ndp_in_sz = kzalloc(sizeof(*ndp_in_sz), GFP_KERNEL);
234 if (!ndp_in_sz) {
235 err = -ENOMEM;
236 goto size_err;
237 }
238
232 err = usb_control_msg(ctx->udev, 239 err = usb_control_msg(ctx->udev,
233 usb_sndctrlpipe(ctx->udev, 0), 240 usb_sndctrlpipe(ctx->udev, 0),
234 USB_CDC_SET_NTB_INPUT_SIZE, 241 USB_CDC_SET_NTB_INPUT_SIZE,
235 USB_TYPE_CLASS | USB_DIR_OUT 242 USB_TYPE_CLASS | USB_DIR_OUT
236 | USB_RECIP_INTERFACE, 243 | USB_RECIP_INTERFACE,
237 0, iface_no, &ndp_in_sz, 8, 1000); 244 0, iface_no, ndp_in_sz, 8, 1000);
245 kfree(ndp_in_sz);
238 } else { 246 } else {
239 __le32 dwNtbInMaxSize = cpu_to_le32(ctx->rx_max); 247 __le32 *dwNtbInMaxSize;
248 dwNtbInMaxSize = kzalloc(sizeof(*dwNtbInMaxSize),
249 GFP_KERNEL);
250 if (!dwNtbInMaxSize) {
251 err = -ENOMEM;
252 goto size_err;
253 }
254 *dwNtbInMaxSize = cpu_to_le32(ctx->rx_max);
255
240 err = usb_control_msg(ctx->udev, 256 err = usb_control_msg(ctx->udev,
241 usb_sndctrlpipe(ctx->udev, 0), 257 usb_sndctrlpipe(ctx->udev, 0),
242 USB_CDC_SET_NTB_INPUT_SIZE, 258 USB_CDC_SET_NTB_INPUT_SIZE,
243 USB_TYPE_CLASS | USB_DIR_OUT 259 USB_TYPE_CLASS | USB_DIR_OUT
244 | USB_RECIP_INTERFACE, 260 | USB_RECIP_INTERFACE,
245 0, iface_no, &dwNtbInMaxSize, 4, 1000); 261 0, iface_no, dwNtbInMaxSize, 4, 1000);
262 kfree(dwNtbInMaxSize);
246 } 263 }
247 264size_err:
248 if (err < 0) 265 if (err < 0)
249 pr_debug("Setting NTB Input Size failed\n"); 266 pr_debug("Setting NTB Input Size failed\n");
250 } 267 }
@@ -325,19 +342,29 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
325 342
326 /* set Max Datagram Size (MTU) */ 343 /* set Max Datagram Size (MTU) */
327 if (flags & USB_CDC_NCM_NCAP_MAX_DATAGRAM_SIZE) { 344 if (flags & USB_CDC_NCM_NCAP_MAX_DATAGRAM_SIZE) {
328 __le16 max_datagram_size; 345 __le16 *max_datagram_size;
329 u16 eth_max_sz = le16_to_cpu(ctx->ether_desc->wMaxSegmentSize); 346 u16 eth_max_sz = le16_to_cpu(ctx->ether_desc->wMaxSegmentSize);
347
348 max_datagram_size = kzalloc(sizeof(*max_datagram_size),
349 GFP_KERNEL);
350 if (!max_datagram_size) {
351 err = -ENOMEM;
352 goto max_dgram_err;
353 }
354
330 err = usb_control_msg(ctx->udev, usb_rcvctrlpipe(ctx->udev, 0), 355 err = usb_control_msg(ctx->udev, usb_rcvctrlpipe(ctx->udev, 0),
331 USB_CDC_GET_MAX_DATAGRAM_SIZE, 356 USB_CDC_GET_MAX_DATAGRAM_SIZE,
332 USB_TYPE_CLASS | USB_DIR_IN 357 USB_TYPE_CLASS | USB_DIR_IN
333 | USB_RECIP_INTERFACE, 358 | USB_RECIP_INTERFACE,
334 0, iface_no, &max_datagram_size, 359 0, iface_no, max_datagram_size,
335 2, 1000); 360 2, 1000);
336 if (err < 0) { 361 if (err < 0) {
337 pr_debug("GET_MAX_DATAGRAM_SIZE failed, use size=%u\n", 362 pr_debug("GET_MAX_DATAGRAM_SIZE failed, use size=%u\n",
338 CDC_NCM_MIN_DATAGRAM_SIZE); 363 CDC_NCM_MIN_DATAGRAM_SIZE);
364 kfree(max_datagram_size);
339 } else { 365 } else {
340 ctx->max_datagram_size = le16_to_cpu(max_datagram_size); 366 ctx->max_datagram_size =
367 le16_to_cpu(*max_datagram_size);
341 /* Check Eth descriptor value */ 368 /* Check Eth descriptor value */
342 if (eth_max_sz < CDC_NCM_MAX_DATAGRAM_SIZE) { 369 if (eth_max_sz < CDC_NCM_MAX_DATAGRAM_SIZE) {
343 if (ctx->max_datagram_size > eth_max_sz) 370 if (ctx->max_datagram_size > eth_max_sz)
@@ -360,8 +387,10 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
360 USB_TYPE_CLASS | USB_DIR_OUT 387 USB_TYPE_CLASS | USB_DIR_OUT
361 | USB_RECIP_INTERFACE, 388 | USB_RECIP_INTERFACE,
362 0, 389 0,
363 iface_no, &max_datagram_size, 390 iface_no, max_datagram_size,
364 2, 1000); 391 2, 1000);
392 kfree(max_datagram_size);
393max_dgram_err:
365 if (err < 0) 394 if (err < 0)
366 pr_debug("SET_MAX_DATAGRAM_SIZE failed\n"); 395 pr_debug("SET_MAX_DATAGRAM_SIZE failed\n");
367 } 396 }
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c
index deb1eca13c9f..7c5336c5c37f 100644
--- a/drivers/net/via-velocity.c
+++ b/drivers/net/via-velocity.c
@@ -515,10 +515,6 @@ static void velocity_init_cam_filter(struct velocity_info *vptr)
515 mac_set_cam_mask(regs, vptr->mCAMmask); 515 mac_set_cam_mask(regs, vptr->mCAMmask);
516 516
517 /* Enable VCAMs */ 517 /* Enable VCAMs */
518
519 if (test_bit(0, vptr->active_vlans))
520 WORD_REG_BITS_ON(MCFG_RTGOPT, &regs->MCFG);
521
522 for_each_set_bit(vid, vptr->active_vlans, VLAN_N_VID) { 518 for_each_set_bit(vid, vptr->active_vlans, VLAN_N_VID) {
523 mac_set_vlan_cam(regs, i, (u8 *) &vid); 519 mac_set_vlan_cam(regs, i, (u8 *) &vid);
524 vptr->vCAMmask[i / 8] |= 0x1 << (i % 8); 520 vptr->vCAMmask[i / 8] |= 0x1 << (i % 8);
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index 1cbacb389652..0959583feb27 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1929,14 +1929,17 @@ static void
1929vmxnet3_vlan_rx_add_vid(struct net_device *netdev, u16 vid) 1929vmxnet3_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
1930{ 1930{
1931 struct vmxnet3_adapter *adapter = netdev_priv(netdev); 1931 struct vmxnet3_adapter *adapter = netdev_priv(netdev);
1932 u32 *vfTable = adapter->shared->devRead.rxFilterConf.vfTable;
1933 unsigned long flags;
1934 1932
1935 VMXNET3_SET_VFTABLE_ENTRY(vfTable, vid); 1933 if (!(netdev->flags & IFF_PROMISC)) {
1936 spin_lock_irqsave(&adapter->cmd_lock, flags); 1934 u32 *vfTable = adapter->shared->devRead.rxFilterConf.vfTable;
1937 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, 1935 unsigned long flags;
1938 VMXNET3_CMD_UPDATE_VLAN_FILTERS); 1936
1939 spin_unlock_irqrestore(&adapter->cmd_lock, flags); 1937 VMXNET3_SET_VFTABLE_ENTRY(vfTable, vid);
1938 spin_lock_irqsave(&adapter->cmd_lock, flags);
1939 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
1940 VMXNET3_CMD_UPDATE_VLAN_FILTERS);
1941 spin_unlock_irqrestore(&adapter->cmd_lock, flags);
1942 }
1940 1943
1941 set_bit(vid, adapter->active_vlans); 1944 set_bit(vid, adapter->active_vlans);
1942} 1945}
@@ -1946,14 +1949,17 @@ static void
1946vmxnet3_vlan_rx_kill_vid(struct net_device *netdev, u16 vid) 1949vmxnet3_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
1947{ 1950{
1948 struct vmxnet3_adapter *adapter = netdev_priv(netdev); 1951 struct vmxnet3_adapter *adapter = netdev_priv(netdev);
1949 u32 *vfTable = adapter->shared->devRead.rxFilterConf.vfTable;
1950 unsigned long flags;
1951 1952
1952 VMXNET3_CLEAR_VFTABLE_ENTRY(vfTable, vid); 1953 if (!(netdev->flags & IFF_PROMISC)) {
1953 spin_lock_irqsave(&adapter->cmd_lock, flags); 1954 u32 *vfTable = adapter->shared->devRead.rxFilterConf.vfTable;
1954 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, 1955 unsigned long flags;
1955 VMXNET3_CMD_UPDATE_VLAN_FILTERS); 1956
1956 spin_unlock_irqrestore(&adapter->cmd_lock, flags); 1957 VMXNET3_CLEAR_VFTABLE_ENTRY(vfTable, vid);
1958 spin_lock_irqsave(&adapter->cmd_lock, flags);
1959 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
1960 VMXNET3_CMD_UPDATE_VLAN_FILTERS);
1961 spin_unlock_irqrestore(&adapter->cmd_lock, flags);
1962 }
1957 1963
1958 clear_bit(vid, adapter->active_vlans); 1964 clear_bit(vid, adapter->active_vlans);
1959} 1965}
diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c
index 69d4ec467dca..2fdbffa079c1 100644
--- a/drivers/net/wireless/iwlwifi/iwl-pci.c
+++ b/drivers/net/wireless/iwlwifi/iwl-pci.c
@@ -478,27 +478,22 @@ out_no_pci:
478 return err; 478 return err;
479} 479}
480 480
481static void iwl_pci_down(struct iwl_bus *bus)
482{
483 struct iwl_pci_bus *pci_bus = (struct iwl_pci_bus *) bus->bus_specific;
484
485 pci_disable_msi(pci_bus->pci_dev);
486 pci_iounmap(pci_bus->pci_dev, pci_bus->hw_base);
487 pci_release_regions(pci_bus->pci_dev);
488 pci_disable_device(pci_bus->pci_dev);
489 pci_set_drvdata(pci_bus->pci_dev, NULL);
490
491 kfree(bus);
492}
493
494static void __devexit iwl_pci_remove(struct pci_dev *pdev) 481static void __devexit iwl_pci_remove(struct pci_dev *pdev)
495{ 482{
496 struct iwl_priv *priv = pci_get_drvdata(pdev); 483 struct iwl_priv *priv = pci_get_drvdata(pdev);
497 void *bus_specific = priv->bus->bus_specific; 484 struct iwl_bus *bus = priv->bus;
485 struct iwl_pci_bus *pci_bus = IWL_BUS_GET_PCI_BUS(bus);
486 struct pci_dev *pci_dev = IWL_BUS_GET_PCI_DEV(bus);
498 487
499 iwl_remove(priv); 488 iwl_remove(priv);
500 489
501 iwl_pci_down(bus_specific); 490 pci_disable_msi(pci_dev);
491 pci_iounmap(pci_dev, pci_bus->hw_base);
492 pci_release_regions(pci_dev);
493 pci_disable_device(pci_dev);
494 pci_set_drvdata(pci_dev, NULL);
495
496 kfree(bus);
502} 497}
503 498
504#ifdef CONFIG_PM 499#ifdef CONFIG_PM
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
index 939563162fb3..dbf501ca317f 100644
--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -464,6 +464,15 @@ static bool rt2800usb_txdone_entry_check(struct queue_entry *entry, u32 reg)
464 int wcid, ack, pid; 464 int wcid, ack, pid;
465 int tx_wcid, tx_ack, tx_pid; 465 int tx_wcid, tx_ack, tx_pid;
466 466
467 if (test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) ||
468 !test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags)) {
469 WARNING(entry->queue->rt2x00dev,
470 "Data pending for entry %u in queue %u\n",
471 entry->entry_idx, entry->queue->qid);
472 cond_resched();
473 return false;
474 }
475
467 wcid = rt2x00_get_field32(reg, TX_STA_FIFO_WCID); 476 wcid = rt2x00_get_field32(reg, TX_STA_FIFO_WCID);
468 ack = rt2x00_get_field32(reg, TX_STA_FIFO_TX_ACK_REQUIRED); 477 ack = rt2x00_get_field32(reg, TX_STA_FIFO_TX_ACK_REQUIRED);
469 pid = rt2x00_get_field32(reg, TX_STA_FIFO_PID_TYPE); 478 pid = rt2x00_get_field32(reg, TX_STA_FIFO_PID_TYPE);
@@ -529,12 +538,11 @@ static void rt2800usb_txdone(struct rt2x00_dev *rt2x00dev)
529 entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); 538 entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE);
530 if (rt2800usb_txdone_entry_check(entry, reg)) 539 if (rt2800usb_txdone_entry_check(entry, reg))
531 break; 540 break;
541 entry = NULL;
532 } 542 }
533 543
534 if (!entry || rt2x00queue_empty(queue)) 544 if (entry)
535 break; 545 rt2800_txdone_entry(entry, reg);
536
537 rt2800_txdone_entry(entry, reg);
538 } 546 }
539} 547}
540 548
@@ -558,8 +566,10 @@ static void rt2800usb_work_txdone(struct work_struct *work)
558 while (!rt2x00queue_empty(queue)) { 566 while (!rt2x00queue_empty(queue)) {
559 entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); 567 entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE);
560 568
561 if (test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags)) 569 if (test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) ||
570 !test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags))
562 break; 571 break;
572
563 if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags)) 573 if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags))
564 rt2x00lib_txdone_noinfo(entry, TXDONE_FAILURE); 574 rt2x00lib_txdone_noinfo(entry, TXDONE_FAILURE);
565 else if (rt2x00queue_status_timeout(entry)) 575 else if (rt2x00queue_status_timeout(entry))
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c
index b6b4542c2460..7fbb55c9da82 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.c
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.c
@@ -262,23 +262,20 @@ static void rt2x00usb_interrupt_txdone(struct urb *urb)
262 struct queue_entry *entry = (struct queue_entry *)urb->context; 262 struct queue_entry *entry = (struct queue_entry *)urb->context;
263 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 263 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
264 264
265 if (!test_and_clear_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags)) 265 if (!test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags))
266 return; 266 return;
267
268 if (rt2x00dev->ops->lib->tx_dma_done)
269 rt2x00dev->ops->lib->tx_dma_done(entry);
270
271 /*
272 * Report the frame as DMA done
273 */
274 rt2x00lib_dmadone(entry);
275
276 /* 267 /*
277 * Check if the frame was correctly uploaded 268 * Check if the frame was correctly uploaded
278 */ 269 */
279 if (urb->status) 270 if (urb->status)
280 set_bit(ENTRY_DATA_IO_FAILED, &entry->flags); 271 set_bit(ENTRY_DATA_IO_FAILED, &entry->flags);
272 /*
273 * Report the frame as DMA done
274 */
275 rt2x00lib_dmadone(entry);
281 276
277 if (rt2x00dev->ops->lib->tx_dma_done)
278 rt2x00dev->ops->lib->tx_dma_done(entry);
282 /* 279 /*
283 * Schedule the delayed work for reading the TX status 280 * Schedule the delayed work for reading the TX status
284 * from the device. 281 * from the device.
diff --git a/drivers/net/wireless/wl12xx/acx.c b/drivers/net/wireless/wl12xx/acx.c
index 7e33f1f4f3d4..34f6ab53e519 100644
--- a/drivers/net/wireless/wl12xx/acx.c
+++ b/drivers/net/wireless/wl12xx/acx.c
@@ -77,8 +77,6 @@ int wl1271_acx_sleep_auth(struct wl1271 *wl, u8 sleep_auth)
77 auth->sleep_auth = sleep_auth; 77 auth->sleep_auth = sleep_auth;
78 78
79 ret = wl1271_cmd_configure(wl, ACX_SLEEP_AUTH, auth, sizeof(*auth)); 79 ret = wl1271_cmd_configure(wl, ACX_SLEEP_AUTH, auth, sizeof(*auth));
80 if (ret < 0)
81 return ret;
82 80
83out: 81out:
84 kfree(auth); 82 kfree(auth);
@@ -624,10 +622,8 @@ int wl1271_acx_cca_threshold(struct wl1271 *wl)
624 622
625 ret = wl1271_cmd_configure(wl, ACX_CCA_THRESHOLD, 623 ret = wl1271_cmd_configure(wl, ACX_CCA_THRESHOLD,
626 detection, sizeof(*detection)); 624 detection, sizeof(*detection));
627 if (ret < 0) { 625 if (ret < 0)
628 wl1271_warning("failed to set cca threshold: %d", ret); 626 wl1271_warning("failed to set cca threshold: %d", ret);
629 return ret;
630 }
631 627
632out: 628out:
633 kfree(detection); 629 kfree(detection);
diff --git a/drivers/net/wireless/wl12xx/testmode.c b/drivers/net/wireless/wl12xx/testmode.c
index 5d5e1ef87206..88add68bd9ac 100644
--- a/drivers/net/wireless/wl12xx/testmode.c
+++ b/drivers/net/wireless/wl12xx/testmode.c
@@ -139,12 +139,15 @@ static int wl1271_tm_cmd_interrogate(struct wl1271 *wl, struct nlattr *tb[])
139 139
140 if (ret < 0) { 140 if (ret < 0) {
141 wl1271_warning("testmode cmd interrogate failed: %d", ret); 141 wl1271_warning("testmode cmd interrogate failed: %d", ret);
142 kfree(cmd);
142 return ret; 143 return ret;
143 } 144 }
144 145
145 skb = cfg80211_testmode_alloc_reply_skb(wl->hw->wiphy, sizeof(*cmd)); 146 skb = cfg80211_testmode_alloc_reply_skb(wl->hw->wiphy, sizeof(*cmd));
146 if (!skb) 147 if (!skb) {
148 kfree(cmd);
147 return -ENOMEM; 149 return -ENOMEM;
150 }
148 151
149 NLA_PUT(skb, WL1271_TM_ATTR_DATA, sizeof(*cmd), cmd); 152 NLA_PUT(skb, WL1271_TM_ATTR_DATA, sizeof(*cmd), cmd);
150 153
diff --git a/drivers/power/max8997_charger.c b/drivers/power/max8997_charger.c
index 7106b49b26e4..ffc5033ea9c9 100644
--- a/drivers/power/max8997_charger.c
+++ b/drivers/power/max8997_charger.c
@@ -20,6 +20,7 @@
20 */ 20 */
21 21
22#include <linux/err.h> 22#include <linux/err.h>
23#include <linux/module.h>
23#include <linux/slab.h> 24#include <linux/slab.h>
24#include <linux/platform_device.h> 25#include <linux/platform_device.h>
25#include <linux/power_supply.h> 26#include <linux/power_supply.h>
diff --git a/drivers/power/max8998_charger.c b/drivers/power/max8998_charger.c
index cc21fa2120be..ef8efadb58cb 100644
--- a/drivers/power/max8998_charger.c
+++ b/drivers/power/max8998_charger.c
@@ -20,6 +20,7 @@
20 */ 20 */
21 21
22#include <linux/err.h> 22#include <linux/err.h>
23#include <linux/module.h>
23#include <linux/slab.h> 24#include <linux/slab.h>
24#include <linux/platform_device.h> 25#include <linux/platform_device.h>
25#include <linux/power_supply.h> 26#include <linux/power_supply.h>
diff --git a/drivers/power/s3c_adc_battery.c b/drivers/power/s3c_adc_battery.c
index a675e31b4f13..d32d0d70f9ba 100644
--- a/drivers/power/s3c_adc_battery.c
+++ b/drivers/power/s3c_adc_battery.c
@@ -20,6 +20,7 @@
20#include <linux/s3c_adc_battery.h> 20#include <linux/s3c_adc_battery.h>
21#include <linux/errno.h> 21#include <linux/errno.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/module.h>
23 24
24#include <plat/adc.h> 25#include <plat/adc.h>
25 26
diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c
index ee893581d4b7..ebe77dd87daf 100644
--- a/drivers/rapidio/rio-scan.c
+++ b/drivers/rapidio/rio-scan.c
@@ -505,8 +505,7 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net,
505 rdev->dev.dma_mask = &rdev->dma_mask; 505 rdev->dev.dma_mask = &rdev->dma_mask;
506 rdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); 506 rdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
507 507
508 if ((rdev->pef & RIO_PEF_INB_DOORBELL) && 508 if (rdev->dst_ops & RIO_DST_OPS_DOORBELL)
509 (rdev->dst_ops & RIO_DST_OPS_DOORBELL))
510 rio_init_dbell_res(&rdev->riores[RIO_DOORBELL_RESOURCE], 509 rio_init_dbell_res(&rdev->riores[RIO_DOORBELL_RESOURCE],
511 0, 0xffff); 510 0, 0xffff);
512 511
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index 9329dbb9ebab..4e7c04e773e0 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -152,10 +152,6 @@ static int s3c_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm)
152 goto retry_get_time; 152 goto retry_get_time;
153 } 153 }
154 154
155 pr_debug("read time %04d.%02d.%02d %02d:%02d:%02d\n",
156 1900 + rtc_tm->tm_year, rtc_tm->tm_mon, rtc_tm->tm_mday,
157 rtc_tm->tm_hour, rtc_tm->tm_min, rtc_tm->tm_sec);
158
159 rtc_tm->tm_sec = bcd2bin(rtc_tm->tm_sec); 155 rtc_tm->tm_sec = bcd2bin(rtc_tm->tm_sec);
160 rtc_tm->tm_min = bcd2bin(rtc_tm->tm_min); 156 rtc_tm->tm_min = bcd2bin(rtc_tm->tm_min);
161 rtc_tm->tm_hour = bcd2bin(rtc_tm->tm_hour); 157 rtc_tm->tm_hour = bcd2bin(rtc_tm->tm_hour);
@@ -164,6 +160,11 @@ static int s3c_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm)
164 rtc_tm->tm_year = bcd2bin(rtc_tm->tm_year); 160 rtc_tm->tm_year = bcd2bin(rtc_tm->tm_year);
165 161
166 rtc_tm->tm_year += 100; 162 rtc_tm->tm_year += 100;
163
164 pr_debug("read time %04d.%02d.%02d %02d:%02d:%02d\n",
165 1900 + rtc_tm->tm_year, rtc_tm->tm_mon, rtc_tm->tm_mday,
166 rtc_tm->tm_hour, rtc_tm->tm_min, rtc_tm->tm_sec);
167
167 rtc_tm->tm_mon -= 1; 168 rtc_tm->tm_mon -= 1;
168 169
169 clk_disable(rtc_clk); 170 clk_disable(rtc_clk);
@@ -269,10 +270,9 @@ static int s3c_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
269 clk_enable(rtc_clk); 270 clk_enable(rtc_clk);
270 pr_debug("s3c_rtc_setalarm: %d, %04d.%02d.%02d %02d:%02d:%02d\n", 271 pr_debug("s3c_rtc_setalarm: %d, %04d.%02d.%02d %02d:%02d:%02d\n",
271 alrm->enabled, 272 alrm->enabled,
272 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, 273 1900 + tm->tm_year, tm->tm_mon + 1, tm->tm_mday,
273 tm->tm_hour, tm->tm_min, tm->tm_sec); 274 tm->tm_hour, tm->tm_min, tm->tm_sec);
274 275
275
276 alrm_en = readb(base + S3C2410_RTCALM) & S3C2410_RTCALM_ALMEN; 276 alrm_en = readb(base + S3C2410_RTCALM) & S3C2410_RTCALM_ALMEN;
277 writeb(0x00, base + S3C2410_RTCALM); 277 writeb(0x00, base + S3C2410_RTCALM);
278 278
@@ -319,49 +319,7 @@ static int s3c_rtc_proc(struct device *dev, struct seq_file *seq)
319 return 0; 319 return 0;
320} 320}
321 321
322static int s3c_rtc_open(struct device *dev)
323{
324 struct platform_device *pdev = to_platform_device(dev);
325 struct rtc_device *rtc_dev = platform_get_drvdata(pdev);
326 int ret;
327
328 ret = request_irq(s3c_rtc_alarmno, s3c_rtc_alarmirq,
329 IRQF_DISABLED, "s3c2410-rtc alarm", rtc_dev);
330
331 if (ret) {
332 dev_err(dev, "IRQ%d error %d\n", s3c_rtc_alarmno, ret);
333 return ret;
334 }
335
336 ret = request_irq(s3c_rtc_tickno, s3c_rtc_tickirq,
337 IRQF_DISABLED, "s3c2410-rtc tick", rtc_dev);
338
339 if (ret) {
340 dev_err(dev, "IRQ%d error %d\n", s3c_rtc_tickno, ret);
341 goto tick_err;
342 }
343
344 return ret;
345
346 tick_err:
347 free_irq(s3c_rtc_alarmno, rtc_dev);
348 return ret;
349}
350
351static void s3c_rtc_release(struct device *dev)
352{
353 struct platform_device *pdev = to_platform_device(dev);
354 struct rtc_device *rtc_dev = platform_get_drvdata(pdev);
355
356 /* do not clear AIE here, it may be needed for wake */
357
358 free_irq(s3c_rtc_alarmno, rtc_dev);
359 free_irq(s3c_rtc_tickno, rtc_dev);
360}
361
362static const struct rtc_class_ops s3c_rtcops = { 322static const struct rtc_class_ops s3c_rtcops = {
363 .open = s3c_rtc_open,
364 .release = s3c_rtc_release,
365 .read_time = s3c_rtc_gettime, 323 .read_time = s3c_rtc_gettime,
366 .set_time = s3c_rtc_settime, 324 .set_time = s3c_rtc_settime,
367 .read_alarm = s3c_rtc_getalarm, 325 .read_alarm = s3c_rtc_getalarm,
@@ -425,6 +383,9 @@ static int __devexit s3c_rtc_remove(struct platform_device *dev)
425{ 383{
426 struct rtc_device *rtc = platform_get_drvdata(dev); 384 struct rtc_device *rtc = platform_get_drvdata(dev);
427 385
386 free_irq(s3c_rtc_alarmno, rtc);
387 free_irq(s3c_rtc_tickno, rtc);
388
428 platform_set_drvdata(dev, NULL); 389 platform_set_drvdata(dev, NULL);
429 rtc_device_unregister(rtc); 390 rtc_device_unregister(rtc);
430 391
@@ -548,10 +509,32 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev)
548 509
549 s3c_rtc_setfreq(&pdev->dev, 1); 510 s3c_rtc_setfreq(&pdev->dev, 1);
550 511
512 ret = request_irq(s3c_rtc_alarmno, s3c_rtc_alarmirq,
513 IRQF_DISABLED, "s3c2410-rtc alarm", rtc);
514 if (ret) {
515 dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_alarmno, ret);
516 goto err_alarm_irq;
517 }
518
519 ret = request_irq(s3c_rtc_tickno, s3c_rtc_tickirq,
520 IRQF_DISABLED, "s3c2410-rtc tick", rtc);
521 if (ret) {
522 dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_tickno, ret);
523 free_irq(s3c_rtc_alarmno, rtc);
524 goto err_tick_irq;
525 }
526
551 clk_disable(rtc_clk); 527 clk_disable(rtc_clk);
552 528
553 return 0; 529 return 0;
554 530
531 err_tick_irq:
532 free_irq(s3c_rtc_alarmno, rtc);
533
534 err_alarm_irq:
535 platform_set_drvdata(pdev, NULL);
536 rtc_device_unregister(rtc);
537
555 err_nortc: 538 err_nortc:
556 s3c_rtc_enable(pdev, 0); 539 s3c_rtc_enable(pdev, 0);
557 clk_disable(rtc_clk); 540 clk_disable(rtc_clk);
diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c
index eb4e034378cd..f1a2016829fc 100644
--- a/drivers/s390/block/dasd_ioctl.c
+++ b/drivers/s390/block/dasd_ioctl.c
@@ -249,6 +249,7 @@ static int dasd_ioctl_reset_profile(struct dasd_block *block)
249static int dasd_ioctl_read_profile(struct dasd_block *block, void __user *argp) 249static int dasd_ioctl_read_profile(struct dasd_block *block, void __user *argp)
250{ 250{
251 struct dasd_profile_info_t *data; 251 struct dasd_profile_info_t *data;
252 int rc = 0;
252 253
253 data = kmalloc(sizeof(*data), GFP_KERNEL); 254 data = kmalloc(sizeof(*data), GFP_KERNEL);
254 if (!data) 255 if (!data)
@@ -279,11 +280,14 @@ static int dasd_ioctl_read_profile(struct dasd_block *block, void __user *argp)
279 spin_unlock_bh(&block->profile.lock); 280 spin_unlock_bh(&block->profile.lock);
280 } else { 281 } else {
281 spin_unlock_bh(&block->profile.lock); 282 spin_unlock_bh(&block->profile.lock);
282 return -EIO; 283 rc = -EIO;
284 goto out;
283 } 285 }
284 if (copy_to_user(argp, data, sizeof(*data))) 286 if (copy_to_user(argp, data, sizeof(*data)))
285 return -EFAULT; 287 rc = -EFAULT;
286 return 0; 288out:
289 kfree(data);
290 return rc;
287} 291}
288#else 292#else
289static int dasd_ioctl_reset_profile(struct dasd_block *block) 293static int dasd_ioctl_reset_profile(struct dasd_block *block)
diff --git a/drivers/s390/char/sclp_cmd.c b/drivers/s390/char/sclp_cmd.c
index be55fb2b1b1c..837e010299a8 100644
--- a/drivers/s390/char/sclp_cmd.c
+++ b/drivers/s390/char/sclp_cmd.c
@@ -383,8 +383,10 @@ static int sclp_attach_storage(u8 id)
383 switch (sccb->header.response_code) { 383 switch (sccb->header.response_code) {
384 case 0x0020: 384 case 0x0020:
385 set_bit(id, sclp_storage_ids); 385 set_bit(id, sclp_storage_ids);
386 for (i = 0; i < sccb->assigned; i++) 386 for (i = 0; i < sccb->assigned; i++) {
387 sclp_unassign_storage(sccb->entries[i] >> 16); 387 if (sccb->entries[i])
388 sclp_unassign_storage(sccb->entries[i] >> 16);
389 }
388 break; 390 break;
389 default: 391 default:
390 rc = -EIO; 392 rc = -EIO;
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index c24fb10de60b..6a4ea29c2f36 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -2243,7 +2243,6 @@ static int iscsit_handle_snack(
2243 case 0: 2243 case 0:
2244 return iscsit_handle_recovery_datain_or_r2t(conn, buf, 2244 return iscsit_handle_recovery_datain_or_r2t(conn, buf,
2245 hdr->itt, hdr->ttt, hdr->begrun, hdr->runlength); 2245 hdr->itt, hdr->ttt, hdr->begrun, hdr->runlength);
2246 return 0;
2247 case ISCSI_FLAG_SNACK_TYPE_STATUS: 2246 case ISCSI_FLAG_SNACK_TYPE_STATUS:
2248 return iscsit_handle_status_snack(conn, hdr->itt, hdr->ttt, 2247 return iscsit_handle_status_snack(conn, hdr->itt, hdr->ttt,
2249 hdr->begrun, hdr->runlength); 2248 hdr->begrun, hdr->runlength);
diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c
index f095e65b1ccf..f1643dbf6a92 100644
--- a/drivers/target/iscsi/iscsi_target_configfs.c
+++ b/drivers/target/iscsi/iscsi_target_configfs.c
@@ -268,7 +268,7 @@ struct se_tpg_np *lio_target_call_addnptotpg(
268 ISCSI_TCP); 268 ISCSI_TCP);
269 if (IS_ERR(tpg_np)) { 269 if (IS_ERR(tpg_np)) {
270 iscsit_put_tpg(tpg); 270 iscsit_put_tpg(tpg);
271 return ERR_PTR(PTR_ERR(tpg_np)); 271 return ERR_CAST(tpg_np);
272 } 272 }
273 pr_debug("LIO_Target_ConfigFS: addnptotpg done!\n"); 273 pr_debug("LIO_Target_ConfigFS: addnptotpg done!\n");
274 274
@@ -1285,7 +1285,7 @@ struct se_wwn *lio_target_call_coreaddtiqn(
1285 1285
1286 tiqn = iscsit_add_tiqn((unsigned char *)name); 1286 tiqn = iscsit_add_tiqn((unsigned char *)name);
1287 if (IS_ERR(tiqn)) 1287 if (IS_ERR(tiqn))
1288 return ERR_PTR(PTR_ERR(tiqn)); 1288 return ERR_CAST(tiqn);
1289 /* 1289 /*
1290 * Setup struct iscsi_wwn_stat_grps for se_wwn->fabric_stat_group. 1290 * Setup struct iscsi_wwn_stat_grps for se_wwn->fabric_stat_group.
1291 */ 1291 */
diff --git a/drivers/target/iscsi/iscsi_target_erl1.c b/drivers/target/iscsi/iscsi_target_erl1.c
index 980650792cf6..c4c68da3e500 100644
--- a/drivers/target/iscsi/iscsi_target_erl1.c
+++ b/drivers/target/iscsi/iscsi_target_erl1.c
@@ -834,7 +834,7 @@ static int iscsit_attach_ooo_cmdsn(
834 */ 834 */
835 list_for_each_entry(ooo_tmp, &sess->sess_ooo_cmdsn_list, 835 list_for_each_entry(ooo_tmp, &sess->sess_ooo_cmdsn_list,
836 ooo_list) { 836 ooo_list) {
837 while (ooo_tmp->cmdsn < ooo_cmdsn->cmdsn) 837 if (ooo_tmp->cmdsn < ooo_cmdsn->cmdsn)
838 continue; 838 continue;
839 839
840 list_add(&ooo_cmdsn->ooo_list, 840 list_add(&ooo_cmdsn->ooo_list,
diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c
index bcaf82f47037..daad362a93ce 100644
--- a/drivers/target/iscsi/iscsi_target_login.c
+++ b/drivers/target/iscsi/iscsi_target_login.c
@@ -1013,19 +1013,9 @@ static int __iscsi_target_login_thread(struct iscsi_np *np)
1013 ISCSI_LOGIN_STATUS_TARGET_ERROR); 1013 ISCSI_LOGIN_STATUS_TARGET_ERROR);
1014 goto new_sess_out; 1014 goto new_sess_out;
1015 } 1015 }
1016#if 0 1016 snprintf(conn->login_ip, sizeof(conn->login_ip), "%pI6c",
1017 if (!iscsi_ntop6((const unsigned char *) 1017 &sock_in6.sin6_addr.in6_u);
1018 &sock_in6.sin6_addr.in6_u, 1018 conn->login_port = ntohs(sock_in6.sin6_port);
1019 (char *)&conn->ipv6_login_ip[0],
1020 IPV6_ADDRESS_SPACE)) {
1021 pr_err("iscsi_ntop6() failed\n");
1022 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
1023 ISCSI_LOGIN_STATUS_TARGET_ERROR);
1024 goto new_sess_out;
1025 }
1026#else
1027 pr_debug("Skipping iscsi_ntop6()\n");
1028#endif
1029 } else { 1019 } else {
1030 memset(&sock_in, 0, sizeof(struct sockaddr_in)); 1020 memset(&sock_in, 0, sizeof(struct sockaddr_in));
1031 1021
diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c
index 252e246cf51e..497b2e718a76 100644
--- a/drivers/target/iscsi/iscsi_target_parameters.c
+++ b/drivers/target/iscsi/iscsi_target_parameters.c
@@ -545,13 +545,13 @@ int iscsi_copy_param_list(
545 struct iscsi_param_list *src_param_list, 545 struct iscsi_param_list *src_param_list,
546 int leading) 546 int leading)
547{ 547{
548 struct iscsi_param *new_param = NULL, *param = NULL; 548 struct iscsi_param *param = NULL;
549 struct iscsi_param *new_param = NULL;
549 struct iscsi_param_list *param_list = NULL; 550 struct iscsi_param_list *param_list = NULL;
550 551
551 param_list = kzalloc(sizeof(struct iscsi_param_list), GFP_KERNEL); 552 param_list = kzalloc(sizeof(struct iscsi_param_list), GFP_KERNEL);
552 if (!param_list) { 553 if (!param_list) {
553 pr_err("Unable to allocate memory for" 554 pr_err("Unable to allocate memory for struct iscsi_param_list.\n");
554 " struct iscsi_param_list.\n");
555 goto err_out; 555 goto err_out;
556 } 556 }
557 INIT_LIST_HEAD(&param_list->param_list); 557 INIT_LIST_HEAD(&param_list->param_list);
@@ -567,8 +567,17 @@ int iscsi_copy_param_list(
567 567
568 new_param = kzalloc(sizeof(struct iscsi_param), GFP_KERNEL); 568 new_param = kzalloc(sizeof(struct iscsi_param), GFP_KERNEL);
569 if (!new_param) { 569 if (!new_param) {
570 pr_err("Unable to allocate memory for" 570 pr_err("Unable to allocate memory for struct iscsi_param.\n");
571 " struct iscsi_param.\n"); 571 goto err_out;
572 }
573
574 new_param->name = kstrdup(param->name, GFP_KERNEL);
575 new_param->value = kstrdup(param->value, GFP_KERNEL);
576 if (!new_param->value || !new_param->name) {
577 kfree(new_param->value);
578 kfree(new_param->name);
579 kfree(new_param);
580 pr_err("Unable to allocate memory for parameter name/value.\n");
572 goto err_out; 581 goto err_out;
573 } 582 }
574 583
@@ -580,32 +589,12 @@ int iscsi_copy_param_list(
580 new_param->use = param->use; 589 new_param->use = param->use;
581 new_param->type_range = param->type_range; 590 new_param->type_range = param->type_range;
582 591
583 new_param->name = kzalloc(strlen(param->name) + 1, GFP_KERNEL);
584 if (!new_param->name) {
585 pr_err("Unable to allocate memory for"
586 " parameter name.\n");
587 goto err_out;
588 }
589
590 new_param->value = kzalloc(strlen(param->value) + 1,
591 GFP_KERNEL);
592 if (!new_param->value) {
593 pr_err("Unable to allocate memory for"
594 " parameter value.\n");
595 goto err_out;
596 }
597
598 memcpy(new_param->name, param->name, strlen(param->name));
599 new_param->name[strlen(param->name)] = '\0';
600 memcpy(new_param->value, param->value, strlen(param->value));
601 new_param->value[strlen(param->value)] = '\0';
602
603 list_add_tail(&new_param->p_list, &param_list->param_list); 592 list_add_tail(&new_param->p_list, &param_list->param_list);
604 } 593 }
605 594
606 if (!list_empty(&param_list->param_list)) 595 if (!list_empty(&param_list->param_list)) {
607 *dst_param_list = param_list; 596 *dst_param_list = param_list;
608 else { 597 } else {
609 pr_err("No parameters allocated.\n"); 598 pr_err("No parameters allocated.\n");
610 goto err_out; 599 goto err_out;
611 } 600 }
diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c
index a1acb0167902..a0d23bc0fc98 100644
--- a/drivers/target/iscsi/iscsi_target_util.c
+++ b/drivers/target/iscsi/iscsi_target_util.c
@@ -243,7 +243,7 @@ struct iscsi_cmd *iscsit_allocate_se_cmd_for_tmr(
243 if (!cmd->tmr_req) { 243 if (!cmd->tmr_req) {
244 pr_err("Unable to allocate memory for" 244 pr_err("Unable to allocate memory for"
245 " Task Management command!\n"); 245 " Task Management command!\n");
246 return NULL; 246 goto out;
247 } 247 }
248 /* 248 /*
249 * TASK_REASSIGN for ERL=2 / connection stays inside of 249 * TASK_REASSIGN for ERL=2 / connection stays inside of
@@ -298,8 +298,6 @@ struct iscsi_cmd *iscsit_allocate_se_cmd_for_tmr(
298 return cmd; 298 return cmd;
299out: 299out:
300 iscsit_release_cmd(cmd); 300 iscsit_release_cmd(cmd);
301 if (se_cmd)
302 transport_free_se_cmd(se_cmd);
303 return NULL; 301 return NULL;
304} 302}
305 303
diff --git a/drivers/target/target_core_cdb.c b/drivers/target/target_core_cdb.c
index 8ae09a1bdf74..89ae923c5da6 100644
--- a/drivers/target/target_core_cdb.c
+++ b/drivers/target/target_core_cdb.c
@@ -67,6 +67,7 @@ target_emulate_inquiry_std(struct se_cmd *cmd)
67{ 67{
68 struct se_lun *lun = cmd->se_lun; 68 struct se_lun *lun = cmd->se_lun;
69 struct se_device *dev = cmd->se_dev; 69 struct se_device *dev = cmd->se_dev;
70 struct se_portal_group *tpg = lun->lun_sep->sep_tpg;
70 unsigned char *buf; 71 unsigned char *buf;
71 72
72 /* 73 /*
@@ -81,9 +82,13 @@ target_emulate_inquiry_std(struct se_cmd *cmd)
81 82
82 buf = transport_kmap_first_data_page(cmd); 83 buf = transport_kmap_first_data_page(cmd);
83 84
84 buf[0] = dev->transport->get_device_type(dev); 85 if (dev == tpg->tpg_virt_lun0.lun_se_dev) {
85 if (buf[0] == TYPE_TAPE) 86 buf[0] = 0x3f; /* Not connected */
86 buf[1] = 0x80; 87 } else {
88 buf[0] = dev->transport->get_device_type(dev);
89 if (buf[0] == TYPE_TAPE)
90 buf[1] = 0x80;
91 }
87 buf[2] = dev->transport->get_device_rev(dev); 92 buf[2] = dev->transport->get_device_rev(dev);
88 93
89 /* 94 /*
@@ -915,8 +920,8 @@ target_emulate_modesense(struct se_cmd *cmd, int ten)
915 length += target_modesense_control(dev, &buf[offset+length]); 920 length += target_modesense_control(dev, &buf[offset+length]);
916 break; 921 break;
917 default: 922 default:
918 pr_err("Got Unknown Mode Page: 0x%02x\n", 923 pr_err("MODE SENSE: unimplemented page/subpage: 0x%02x/0x%02x\n",
919 cdb[2] & 0x3f); 924 cdb[2] & 0x3f, cdb[3]);
920 return PYX_TRANSPORT_UNKNOWN_MODE_PAGE; 925 return PYX_TRANSPORT_UNKNOWN_MODE_PAGE;
921 } 926 }
922 offset += length; 927 offset += length;
@@ -1072,8 +1077,6 @@ target_emulate_unmap(struct se_task *task)
1072 size -= 16; 1077 size -= 16;
1073 } 1078 }
1074 1079
1075 task->task_scsi_status = GOOD;
1076 transport_complete_task(task, 1);
1077err: 1080err:
1078 transport_kunmap_first_data_page(cmd); 1081 transport_kunmap_first_data_page(cmd);
1079 1082
@@ -1085,24 +1088,17 @@ err:
1085 * Note this is not used for TCM/pSCSI passthrough 1088 * Note this is not used for TCM/pSCSI passthrough
1086 */ 1089 */
1087static int 1090static int
1088target_emulate_write_same(struct se_task *task, int write_same32) 1091target_emulate_write_same(struct se_task *task, u32 num_blocks)
1089{ 1092{
1090 struct se_cmd *cmd = task->task_se_cmd; 1093 struct se_cmd *cmd = task->task_se_cmd;
1091 struct se_device *dev = cmd->se_dev; 1094 struct se_device *dev = cmd->se_dev;
1092 sector_t range; 1095 sector_t range;
1093 sector_t lba = cmd->t_task_lba; 1096 sector_t lba = cmd->t_task_lba;
1094 unsigned int num_blocks;
1095 int ret; 1097 int ret;
1096 /* 1098 /*
1097 * Extract num_blocks from the WRITE_SAME_* CDB. Then use the explict 1099 * Use the explicit range when non zero is supplied, otherwise calculate
1098 * range when non zero is supplied, otherwise calculate the remaining 1100 * the remaining range based on ->get_blocks() - starting LBA.
1099 * range based on ->get_blocks() - starting LBA.
1100 */ 1101 */
1101 if (write_same32)
1102 num_blocks = get_unaligned_be32(&cmd->t_task_cdb[28]);
1103 else
1104 num_blocks = get_unaligned_be32(&cmd->t_task_cdb[10]);
1105
1106 if (num_blocks != 0) 1102 if (num_blocks != 0)
1107 range = num_blocks; 1103 range = num_blocks;
1108 else 1104 else
@@ -1117,8 +1113,6 @@ target_emulate_write_same(struct se_task *task, int write_same32)
1117 return ret; 1113 return ret;
1118 } 1114 }
1119 1115
1120 task->task_scsi_status = GOOD;
1121 transport_complete_task(task, 1);
1122 return 0; 1116 return 0;
1123} 1117}
1124 1118
@@ -1165,13 +1159,23 @@ transport_emulate_control_cdb(struct se_task *task)
1165 } 1159 }
1166 ret = target_emulate_unmap(task); 1160 ret = target_emulate_unmap(task);
1167 break; 1161 break;
1162 case WRITE_SAME:
1163 if (!dev->transport->do_discard) {
1164 pr_err("WRITE_SAME emulation not supported"
1165 " for: %s\n", dev->transport->name);
1166 return PYX_TRANSPORT_UNKNOWN_SAM_OPCODE;
1167 }
1168 ret = target_emulate_write_same(task,
1169 get_unaligned_be16(&cmd->t_task_cdb[7]));
1170 break;
1168 case WRITE_SAME_16: 1171 case WRITE_SAME_16:
1169 if (!dev->transport->do_discard) { 1172 if (!dev->transport->do_discard) {
1170 pr_err("WRITE_SAME_16 emulation not supported" 1173 pr_err("WRITE_SAME_16 emulation not supported"
1171 " for: %s\n", dev->transport->name); 1174 " for: %s\n", dev->transport->name);
1172 return PYX_TRANSPORT_UNKNOWN_SAM_OPCODE; 1175 return PYX_TRANSPORT_UNKNOWN_SAM_OPCODE;
1173 } 1176 }
1174 ret = target_emulate_write_same(task, 0); 1177 ret = target_emulate_write_same(task,
1178 get_unaligned_be32(&cmd->t_task_cdb[10]));
1175 break; 1179 break;
1176 case VARIABLE_LENGTH_CMD: 1180 case VARIABLE_LENGTH_CMD:
1177 service_action = 1181 service_action =
@@ -1184,7 +1188,8 @@ transport_emulate_control_cdb(struct se_task *task)
1184 dev->transport->name); 1188 dev->transport->name);
1185 return PYX_TRANSPORT_UNKNOWN_SAM_OPCODE; 1189 return PYX_TRANSPORT_UNKNOWN_SAM_OPCODE;
1186 } 1190 }
1187 ret = target_emulate_write_same(task, 1); 1191 ret = target_emulate_write_same(task,
1192 get_unaligned_be32(&cmd->t_task_cdb[28]));
1188 break; 1193 break;
1189 default: 1194 default:
1190 pr_err("Unsupported VARIABLE_LENGTH_CMD SA:" 1195 pr_err("Unsupported VARIABLE_LENGTH_CMD SA:"
@@ -1219,8 +1224,14 @@ transport_emulate_control_cdb(struct se_task *task)
1219 1224
1220 if (ret < 0) 1225 if (ret < 0)
1221 return ret; 1226 return ret;
1222 task->task_scsi_status = GOOD; 1227 /*
1223 transport_complete_task(task, 1); 1228 * Handle the successful completion here unless a caller
1229 * has explictly requested an asychronous completion.
1230 */
1231 if (!(cmd->se_cmd_flags & SCF_EMULATE_CDB_ASYNC)) {
1232 task->task_scsi_status = GOOD;
1233 transport_complete_task(task, 1);
1234 }
1224 1235
1225 return PYX_TRANSPORT_SENT_TO_TRANSPORT; 1236 return PYX_TRANSPORT_SENT_TO_TRANSPORT;
1226} 1237}
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index b38b6c993e65..ca6e4a4df134 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -472,9 +472,9 @@ void core_clear_lun_from_tpg(struct se_lun *lun, struct se_portal_group *tpg)
472 struct se_dev_entry *deve; 472 struct se_dev_entry *deve;
473 u32 i; 473 u32 i;
474 474
475 spin_lock_bh(&tpg->acl_node_lock); 475 spin_lock_irq(&tpg->acl_node_lock);
476 list_for_each_entry(nacl, &tpg->acl_node_list, acl_list) { 476 list_for_each_entry(nacl, &tpg->acl_node_list, acl_list) {
477 spin_unlock_bh(&tpg->acl_node_lock); 477 spin_unlock_irq(&tpg->acl_node_lock);
478 478
479 spin_lock_irq(&nacl->device_list_lock); 479 spin_lock_irq(&nacl->device_list_lock);
480 for (i = 0; i < TRANSPORT_MAX_LUNS_PER_TPG; i++) { 480 for (i = 0; i < TRANSPORT_MAX_LUNS_PER_TPG; i++) {
@@ -491,9 +491,9 @@ void core_clear_lun_from_tpg(struct se_lun *lun, struct se_portal_group *tpg)
491 } 491 }
492 spin_unlock_irq(&nacl->device_list_lock); 492 spin_unlock_irq(&nacl->device_list_lock);
493 493
494 spin_lock_bh(&tpg->acl_node_lock); 494 spin_lock_irq(&tpg->acl_node_lock);
495 } 495 }
496 spin_unlock_bh(&tpg->acl_node_lock); 496 spin_unlock_irq(&tpg->acl_node_lock);
497} 497}
498 498
499static struct se_port *core_alloc_port(struct se_device *dev) 499static struct se_port *core_alloc_port(struct se_device *dev)
@@ -839,6 +839,24 @@ int se_dev_check_shutdown(struct se_device *dev)
839 return ret; 839 return ret;
840} 840}
841 841
842u32 se_dev_align_max_sectors(u32 max_sectors, u32 block_size)
843{
844 u32 tmp, aligned_max_sectors;
845 /*
846 * Limit max_sectors to a PAGE_SIZE aligned value for modern
847 * transport_allocate_data_tasks() operation.
848 */
849 tmp = rounddown((max_sectors * block_size), PAGE_SIZE);
850 aligned_max_sectors = (tmp / block_size);
851 if (max_sectors != aligned_max_sectors) {
852 printk(KERN_INFO "Rounding down aligned max_sectors from %u"
853 " to %u\n", max_sectors, aligned_max_sectors);
854 return aligned_max_sectors;
855 }
856
857 return max_sectors;
858}
859
842void se_dev_set_default_attribs( 860void se_dev_set_default_attribs(
843 struct se_device *dev, 861 struct se_device *dev,
844 struct se_dev_limits *dev_limits) 862 struct se_dev_limits *dev_limits)
@@ -878,6 +896,11 @@ void se_dev_set_default_attribs(
878 * max_sectors is based on subsystem plugin dependent requirements. 896 * max_sectors is based on subsystem plugin dependent requirements.
879 */ 897 */
880 dev->se_sub_dev->se_dev_attrib.hw_max_sectors = limits->max_hw_sectors; 898 dev->se_sub_dev->se_dev_attrib.hw_max_sectors = limits->max_hw_sectors;
899 /*
900 * Align max_sectors down to PAGE_SIZE to follow transport_allocate_data_tasks()
901 */
902 limits->max_sectors = se_dev_align_max_sectors(limits->max_sectors,
903 limits->logical_block_size);
881 dev->se_sub_dev->se_dev_attrib.max_sectors = limits->max_sectors; 904 dev->se_sub_dev->se_dev_attrib.max_sectors = limits->max_sectors;
882 /* 905 /*
883 * Set optimal_sectors from max_sectors, which can be lowered via 906 * Set optimal_sectors from max_sectors, which can be lowered via
@@ -1242,6 +1265,11 @@ int se_dev_set_max_sectors(struct se_device *dev, u32 max_sectors)
1242 return -EINVAL; 1265 return -EINVAL;
1243 } 1266 }
1244 } 1267 }
1268 /*
1269 * Align max_sectors down to PAGE_SIZE to follow transport_allocate_data_tasks()
1270 */
1271 max_sectors = se_dev_align_max_sectors(max_sectors,
1272 dev->se_sub_dev->se_dev_attrib.block_size);
1245 1273
1246 dev->se_sub_dev->se_dev_attrib.max_sectors = max_sectors; 1274 dev->se_sub_dev->se_dev_attrib.max_sectors = max_sectors;
1247 pr_debug("dev[%p]: SE Device max_sectors changed to %u\n", 1275 pr_debug("dev[%p]: SE Device max_sectors changed to %u\n",
@@ -1344,15 +1372,17 @@ struct se_lun *core_dev_add_lun(
1344 */ 1372 */
1345 if (tpg->se_tpg_tfo->tpg_check_demo_mode(tpg)) { 1373 if (tpg->se_tpg_tfo->tpg_check_demo_mode(tpg)) {
1346 struct se_node_acl *acl; 1374 struct se_node_acl *acl;
1347 spin_lock_bh(&tpg->acl_node_lock); 1375 spin_lock_irq(&tpg->acl_node_lock);
1348 list_for_each_entry(acl, &tpg->acl_node_list, acl_list) { 1376 list_for_each_entry(acl, &tpg->acl_node_list, acl_list) {
1349 if (acl->dynamic_node_acl) { 1377 if (acl->dynamic_node_acl &&
1350 spin_unlock_bh(&tpg->acl_node_lock); 1378 (!tpg->se_tpg_tfo->tpg_check_demo_mode_login_only ||
1379 !tpg->se_tpg_tfo->tpg_check_demo_mode_login_only(tpg))) {
1380 spin_unlock_irq(&tpg->acl_node_lock);
1351 core_tpg_add_node_to_devs(acl, tpg); 1381 core_tpg_add_node_to_devs(acl, tpg);
1352 spin_lock_bh(&tpg->acl_node_lock); 1382 spin_lock_irq(&tpg->acl_node_lock);
1353 } 1383 }
1354 } 1384 }
1355 spin_unlock_bh(&tpg->acl_node_lock); 1385 spin_unlock_irq(&tpg->acl_node_lock);
1356 } 1386 }
1357 1387
1358 return lun_p; 1388 return lun_p;
diff --git a/drivers/target/target_core_fabric_configfs.c b/drivers/target/target_core_fabric_configfs.c
index f1654694f4ea..55bbe0847a6d 100644
--- a/drivers/target/target_core_fabric_configfs.c
+++ b/drivers/target/target_core_fabric_configfs.c
@@ -481,7 +481,7 @@ static struct config_group *target_fabric_make_nodeacl(
481 481
482 se_nacl = tf->tf_ops.fabric_make_nodeacl(se_tpg, group, name); 482 se_nacl = tf->tf_ops.fabric_make_nodeacl(se_tpg, group, name);
483 if (IS_ERR(se_nacl)) 483 if (IS_ERR(se_nacl))
484 return ERR_PTR(PTR_ERR(se_nacl)); 484 return ERR_CAST(se_nacl);
485 485
486 nacl_cg = &se_nacl->acl_group; 486 nacl_cg = &se_nacl->acl_group;
487 nacl_cg->default_groups = se_nacl->acl_default_groups; 487 nacl_cg->default_groups = se_nacl->acl_default_groups;
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index 1c1b849cd4fb..7fd3a161f7cc 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -1598,14 +1598,14 @@ static int core_scsi3_decode_spec_i_port(
1598 * from the decoded fabric module specific TransportID 1598 * from the decoded fabric module specific TransportID
1599 * at *i_str. 1599 * at *i_str.
1600 */ 1600 */
1601 spin_lock_bh(&tmp_tpg->acl_node_lock); 1601 spin_lock_irq(&tmp_tpg->acl_node_lock);
1602 dest_node_acl = __core_tpg_get_initiator_node_acl( 1602 dest_node_acl = __core_tpg_get_initiator_node_acl(
1603 tmp_tpg, i_str); 1603 tmp_tpg, i_str);
1604 if (dest_node_acl) { 1604 if (dest_node_acl) {
1605 atomic_inc(&dest_node_acl->acl_pr_ref_count); 1605 atomic_inc(&dest_node_acl->acl_pr_ref_count);
1606 smp_mb__after_atomic_inc(); 1606 smp_mb__after_atomic_inc();
1607 } 1607 }
1608 spin_unlock_bh(&tmp_tpg->acl_node_lock); 1608 spin_unlock_irq(&tmp_tpg->acl_node_lock);
1609 1609
1610 if (!dest_node_acl) { 1610 if (!dest_node_acl) {
1611 core_scsi3_tpg_undepend_item(tmp_tpg); 1611 core_scsi3_tpg_undepend_item(tmp_tpg);
@@ -3496,14 +3496,14 @@ after_iport_check:
3496 /* 3496 /*
3497 * Locate the destination struct se_node_acl from the received Transport ID 3497 * Locate the destination struct se_node_acl from the received Transport ID
3498 */ 3498 */
3499 spin_lock_bh(&dest_se_tpg->acl_node_lock); 3499 spin_lock_irq(&dest_se_tpg->acl_node_lock);
3500 dest_node_acl = __core_tpg_get_initiator_node_acl(dest_se_tpg, 3500 dest_node_acl = __core_tpg_get_initiator_node_acl(dest_se_tpg,
3501 initiator_str); 3501 initiator_str);
3502 if (dest_node_acl) { 3502 if (dest_node_acl) {
3503 atomic_inc(&dest_node_acl->acl_pr_ref_count); 3503 atomic_inc(&dest_node_acl->acl_pr_ref_count);
3504 smp_mb__after_atomic_inc(); 3504 smp_mb__after_atomic_inc();
3505 } 3505 }
3506 spin_unlock_bh(&dest_se_tpg->acl_node_lock); 3506 spin_unlock_irq(&dest_se_tpg->acl_node_lock);
3507 3507
3508 if (!dest_node_acl) { 3508 if (!dest_node_acl) {
3509 pr_err("Unable to locate %s dest_node_acl for" 3509 pr_err("Unable to locate %s dest_node_acl for"
diff --git a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c
index 3dd81d24d9a9..e567e129c697 100644
--- a/drivers/target/target_core_rd.c
+++ b/drivers/target/target_core_rd.c
@@ -390,12 +390,10 @@ static int rd_MEMCPY_read(struct rd_request *req)
390 length = req->rd_size; 390 length = req->rd_size;
391 391
392 dst = sg_virt(&sg_d[i++]) + dst_offset; 392 dst = sg_virt(&sg_d[i++]) + dst_offset;
393 if (!dst) 393 BUG_ON(!dst);
394 BUG();
395 394
396 src = sg_virt(&sg_s[j]) + src_offset; 395 src = sg_virt(&sg_s[j]) + src_offset;
397 if (!src) 396 BUG_ON(!src);
398 BUG();
399 397
400 dst_offset = 0; 398 dst_offset = 0;
401 src_offset = length; 399 src_offset = length;
@@ -415,8 +413,7 @@ static int rd_MEMCPY_read(struct rd_request *req)
415 length = req->rd_size; 413 length = req->rd_size;
416 414
417 dst = sg_virt(&sg_d[i]) + dst_offset; 415 dst = sg_virt(&sg_d[i]) + dst_offset;
418 if (!dst) 416 BUG_ON(!dst);
419 BUG();
420 417
421 if (sg_d[i].length == length) { 418 if (sg_d[i].length == length) {
422 i++; 419 i++;
@@ -425,8 +422,7 @@ static int rd_MEMCPY_read(struct rd_request *req)
425 dst_offset = length; 422 dst_offset = length;
426 423
427 src = sg_virt(&sg_s[j++]) + src_offset; 424 src = sg_virt(&sg_s[j++]) + src_offset;
428 if (!src) 425 BUG_ON(!src);
429 BUG();
430 426
431 src_offset = 0; 427 src_offset = 0;
432 page_end = 1; 428 page_end = 1;
@@ -510,12 +506,10 @@ static int rd_MEMCPY_write(struct rd_request *req)
510 length = req->rd_size; 506 length = req->rd_size;
511 507
512 src = sg_virt(&sg_s[i++]) + src_offset; 508 src = sg_virt(&sg_s[i++]) + src_offset;
513 if (!src) 509 BUG_ON(!src);
514 BUG();
515 510
516 dst = sg_virt(&sg_d[j]) + dst_offset; 511 dst = sg_virt(&sg_d[j]) + dst_offset;
517 if (!dst) 512 BUG_ON(!dst);
518 BUG();
519 513
520 src_offset = 0; 514 src_offset = 0;
521 dst_offset = length; 515 dst_offset = length;
@@ -535,8 +529,7 @@ static int rd_MEMCPY_write(struct rd_request *req)
535 length = req->rd_size; 529 length = req->rd_size;
536 530
537 src = sg_virt(&sg_s[i]) + src_offset; 531 src = sg_virt(&sg_s[i]) + src_offset;
538 if (!src) 532 BUG_ON(!src);
539 BUG();
540 533
541 if (sg_s[i].length == length) { 534 if (sg_s[i].length == length) {
542 i++; 535 i++;
@@ -545,8 +538,7 @@ static int rd_MEMCPY_write(struct rd_request *req)
545 src_offset = length; 538 src_offset = length;
546 539
547 dst = sg_virt(&sg_d[j++]) + dst_offset; 540 dst = sg_virt(&sg_d[j++]) + dst_offset;
548 if (!dst) 541 BUG_ON(!dst);
549 BUG();
550 542
551 dst_offset = 0; 543 dst_offset = 0;
552 page_end = 1; 544 page_end = 1;
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
index 4f1ba4c5ef11..162b736c7342 100644
--- a/drivers/target/target_core_tpg.c
+++ b/drivers/target/target_core_tpg.c
@@ -137,15 +137,15 @@ struct se_node_acl *core_tpg_get_initiator_node_acl(
137{ 137{
138 struct se_node_acl *acl; 138 struct se_node_acl *acl;
139 139
140 spin_lock_bh(&tpg->acl_node_lock); 140 spin_lock_irq(&tpg->acl_node_lock);
141 list_for_each_entry(acl, &tpg->acl_node_list, acl_list) { 141 list_for_each_entry(acl, &tpg->acl_node_list, acl_list) {
142 if (!strcmp(acl->initiatorname, initiatorname) && 142 if (!strcmp(acl->initiatorname, initiatorname) &&
143 !acl->dynamic_node_acl) { 143 !acl->dynamic_node_acl) {
144 spin_unlock_bh(&tpg->acl_node_lock); 144 spin_unlock_irq(&tpg->acl_node_lock);
145 return acl; 145 return acl;
146 } 146 }
147 } 147 }
148 spin_unlock_bh(&tpg->acl_node_lock); 148 spin_unlock_irq(&tpg->acl_node_lock);
149 149
150 return NULL; 150 return NULL;
151} 151}
@@ -298,13 +298,21 @@ struct se_node_acl *core_tpg_check_initiator_node_acl(
298 tpg->se_tpg_tfo->tpg_release_fabric_acl(tpg, acl); 298 tpg->se_tpg_tfo->tpg_release_fabric_acl(tpg, acl);
299 return NULL; 299 return NULL;
300 } 300 }
301 /*
302 * Here we only create demo-mode MappedLUNs from the active
303 * TPG LUNs if the fabric is not explictly asking for
304 * tpg_check_demo_mode_login_only() == 1.
305 */
306 if ((tpg->se_tpg_tfo->tpg_check_demo_mode_login_only != NULL) &&
307 (tpg->se_tpg_tfo->tpg_check_demo_mode_login_only(tpg) == 1))
308 do { ; } while (0);
309 else
310 core_tpg_add_node_to_devs(acl, tpg);
301 311
302 core_tpg_add_node_to_devs(acl, tpg); 312 spin_lock_irq(&tpg->acl_node_lock);
303
304 spin_lock_bh(&tpg->acl_node_lock);
305 list_add_tail(&acl->acl_list, &tpg->acl_node_list); 313 list_add_tail(&acl->acl_list, &tpg->acl_node_list);
306 tpg->num_node_acls++; 314 tpg->num_node_acls++;
307 spin_unlock_bh(&tpg->acl_node_lock); 315 spin_unlock_irq(&tpg->acl_node_lock);
308 316
309 pr_debug("%s_TPG[%u] - Added DYNAMIC ACL with TCQ Depth: %d for %s" 317 pr_debug("%s_TPG[%u] - Added DYNAMIC ACL with TCQ Depth: %d for %s"
310 " Initiator Node: %s\n", tpg->se_tpg_tfo->get_fabric_name(), 318 " Initiator Node: %s\n", tpg->se_tpg_tfo->get_fabric_name(),
@@ -354,7 +362,7 @@ struct se_node_acl *core_tpg_add_initiator_node_acl(
354{ 362{
355 struct se_node_acl *acl = NULL; 363 struct se_node_acl *acl = NULL;
356 364
357 spin_lock_bh(&tpg->acl_node_lock); 365 spin_lock_irq(&tpg->acl_node_lock);
358 acl = __core_tpg_get_initiator_node_acl(tpg, initiatorname); 366 acl = __core_tpg_get_initiator_node_acl(tpg, initiatorname);
359 if (acl) { 367 if (acl) {
360 if (acl->dynamic_node_acl) { 368 if (acl->dynamic_node_acl) {
@@ -362,7 +370,7 @@ struct se_node_acl *core_tpg_add_initiator_node_acl(
362 pr_debug("%s_TPG[%u] - Replacing dynamic ACL" 370 pr_debug("%s_TPG[%u] - Replacing dynamic ACL"
363 " for %s\n", tpg->se_tpg_tfo->get_fabric_name(), 371 " for %s\n", tpg->se_tpg_tfo->get_fabric_name(),
364 tpg->se_tpg_tfo->tpg_get_tag(tpg), initiatorname); 372 tpg->se_tpg_tfo->tpg_get_tag(tpg), initiatorname);
365 spin_unlock_bh(&tpg->acl_node_lock); 373 spin_unlock_irq(&tpg->acl_node_lock);
366 /* 374 /*
367 * Release the locally allocated struct se_node_acl 375 * Release the locally allocated struct se_node_acl
368 * because * core_tpg_add_initiator_node_acl() returned 376 * because * core_tpg_add_initiator_node_acl() returned
@@ -378,10 +386,10 @@ struct se_node_acl *core_tpg_add_initiator_node_acl(
378 " Node %s already exists for TPG %u, ignoring" 386 " Node %s already exists for TPG %u, ignoring"
379 " request.\n", tpg->se_tpg_tfo->get_fabric_name(), 387 " request.\n", tpg->se_tpg_tfo->get_fabric_name(),
380 initiatorname, tpg->se_tpg_tfo->tpg_get_tag(tpg)); 388 initiatorname, tpg->se_tpg_tfo->tpg_get_tag(tpg));
381 spin_unlock_bh(&tpg->acl_node_lock); 389 spin_unlock_irq(&tpg->acl_node_lock);
382 return ERR_PTR(-EEXIST); 390 return ERR_PTR(-EEXIST);
383 } 391 }
384 spin_unlock_bh(&tpg->acl_node_lock); 392 spin_unlock_irq(&tpg->acl_node_lock);
385 393
386 if (!se_nacl) { 394 if (!se_nacl) {
387 pr_err("struct se_node_acl pointer is NULL\n"); 395 pr_err("struct se_node_acl pointer is NULL\n");
@@ -418,10 +426,10 @@ struct se_node_acl *core_tpg_add_initiator_node_acl(
418 return ERR_PTR(-EINVAL); 426 return ERR_PTR(-EINVAL);
419 } 427 }
420 428
421 spin_lock_bh(&tpg->acl_node_lock); 429 spin_lock_irq(&tpg->acl_node_lock);
422 list_add_tail(&acl->acl_list, &tpg->acl_node_list); 430 list_add_tail(&acl->acl_list, &tpg->acl_node_list);
423 tpg->num_node_acls++; 431 tpg->num_node_acls++;
424 spin_unlock_bh(&tpg->acl_node_lock); 432 spin_unlock_irq(&tpg->acl_node_lock);
425 433
426done: 434done:
427 pr_debug("%s_TPG[%hu] - Added ACL with TCQ Depth: %d for %s" 435 pr_debug("%s_TPG[%hu] - Added ACL with TCQ Depth: %d for %s"
@@ -445,14 +453,14 @@ int core_tpg_del_initiator_node_acl(
445 struct se_session *sess, *sess_tmp; 453 struct se_session *sess, *sess_tmp;
446 int dynamic_acl = 0; 454 int dynamic_acl = 0;
447 455
448 spin_lock_bh(&tpg->acl_node_lock); 456 spin_lock_irq(&tpg->acl_node_lock);
449 if (acl->dynamic_node_acl) { 457 if (acl->dynamic_node_acl) {
450 acl->dynamic_node_acl = 0; 458 acl->dynamic_node_acl = 0;
451 dynamic_acl = 1; 459 dynamic_acl = 1;
452 } 460 }
453 list_del(&acl->acl_list); 461 list_del(&acl->acl_list);
454 tpg->num_node_acls--; 462 tpg->num_node_acls--;
455 spin_unlock_bh(&tpg->acl_node_lock); 463 spin_unlock_irq(&tpg->acl_node_lock);
456 464
457 spin_lock_bh(&tpg->session_lock); 465 spin_lock_bh(&tpg->session_lock);
458 list_for_each_entry_safe(sess, sess_tmp, 466 list_for_each_entry_safe(sess, sess_tmp,
@@ -503,21 +511,21 @@ int core_tpg_set_initiator_node_queue_depth(
503 struct se_node_acl *acl; 511 struct se_node_acl *acl;
504 int dynamic_acl = 0; 512 int dynamic_acl = 0;
505 513
506 spin_lock_bh(&tpg->acl_node_lock); 514 spin_lock_irq(&tpg->acl_node_lock);
507 acl = __core_tpg_get_initiator_node_acl(tpg, initiatorname); 515 acl = __core_tpg_get_initiator_node_acl(tpg, initiatorname);
508 if (!acl) { 516 if (!acl) {
509 pr_err("Access Control List entry for %s Initiator" 517 pr_err("Access Control List entry for %s Initiator"
510 " Node %s does not exists for TPG %hu, ignoring" 518 " Node %s does not exists for TPG %hu, ignoring"
511 " request.\n", tpg->se_tpg_tfo->get_fabric_name(), 519 " request.\n", tpg->se_tpg_tfo->get_fabric_name(),
512 initiatorname, tpg->se_tpg_tfo->tpg_get_tag(tpg)); 520 initiatorname, tpg->se_tpg_tfo->tpg_get_tag(tpg));
513 spin_unlock_bh(&tpg->acl_node_lock); 521 spin_unlock_irq(&tpg->acl_node_lock);
514 return -ENODEV; 522 return -ENODEV;
515 } 523 }
516 if (acl->dynamic_node_acl) { 524 if (acl->dynamic_node_acl) {
517 acl->dynamic_node_acl = 0; 525 acl->dynamic_node_acl = 0;
518 dynamic_acl = 1; 526 dynamic_acl = 1;
519 } 527 }
520 spin_unlock_bh(&tpg->acl_node_lock); 528 spin_unlock_irq(&tpg->acl_node_lock);
521 529
522 spin_lock_bh(&tpg->session_lock); 530 spin_lock_bh(&tpg->session_lock);
523 list_for_each_entry(sess, &tpg->tpg_sess_list, sess_list) { 531 list_for_each_entry(sess, &tpg->tpg_sess_list, sess_list) {
@@ -533,10 +541,10 @@ int core_tpg_set_initiator_node_queue_depth(
533 tpg->se_tpg_tfo->get_fabric_name(), initiatorname); 541 tpg->se_tpg_tfo->get_fabric_name(), initiatorname);
534 spin_unlock_bh(&tpg->session_lock); 542 spin_unlock_bh(&tpg->session_lock);
535 543
536 spin_lock_bh(&tpg->acl_node_lock); 544 spin_lock_irq(&tpg->acl_node_lock);
537 if (dynamic_acl) 545 if (dynamic_acl)
538 acl->dynamic_node_acl = 1; 546 acl->dynamic_node_acl = 1;
539 spin_unlock_bh(&tpg->acl_node_lock); 547 spin_unlock_irq(&tpg->acl_node_lock);
540 return -EEXIST; 548 return -EEXIST;
541 } 549 }
542 /* 550 /*
@@ -571,10 +579,10 @@ int core_tpg_set_initiator_node_queue_depth(
571 if (init_sess) 579 if (init_sess)
572 tpg->se_tpg_tfo->close_session(init_sess); 580 tpg->se_tpg_tfo->close_session(init_sess);
573 581
574 spin_lock_bh(&tpg->acl_node_lock); 582 spin_lock_irq(&tpg->acl_node_lock);
575 if (dynamic_acl) 583 if (dynamic_acl)
576 acl->dynamic_node_acl = 1; 584 acl->dynamic_node_acl = 1;
577 spin_unlock_bh(&tpg->acl_node_lock); 585 spin_unlock_irq(&tpg->acl_node_lock);
578 return -EINVAL; 586 return -EINVAL;
579 } 587 }
580 spin_unlock_bh(&tpg->session_lock); 588 spin_unlock_bh(&tpg->session_lock);
@@ -590,10 +598,10 @@ int core_tpg_set_initiator_node_queue_depth(
590 initiatorname, tpg->se_tpg_tfo->get_fabric_name(), 598 initiatorname, tpg->se_tpg_tfo->get_fabric_name(),
591 tpg->se_tpg_tfo->tpg_get_tag(tpg)); 599 tpg->se_tpg_tfo->tpg_get_tag(tpg));
592 600
593 spin_lock_bh(&tpg->acl_node_lock); 601 spin_lock_irq(&tpg->acl_node_lock);
594 if (dynamic_acl) 602 if (dynamic_acl)
595 acl->dynamic_node_acl = 1; 603 acl->dynamic_node_acl = 1;
596 spin_unlock_bh(&tpg->acl_node_lock); 604 spin_unlock_irq(&tpg->acl_node_lock);
597 605
598 return 0; 606 return 0;
599} 607}
@@ -717,20 +725,20 @@ int core_tpg_deregister(struct se_portal_group *se_tpg)
717 * not been released because of TFO->tpg_check_demo_mode_cache() == 1 725 * not been released because of TFO->tpg_check_demo_mode_cache() == 1
718 * in transport_deregister_session(). 726 * in transport_deregister_session().
719 */ 727 */
720 spin_lock_bh(&se_tpg->acl_node_lock); 728 spin_lock_irq(&se_tpg->acl_node_lock);
721 list_for_each_entry_safe(nacl, nacl_tmp, &se_tpg->acl_node_list, 729 list_for_each_entry_safe(nacl, nacl_tmp, &se_tpg->acl_node_list,
722 acl_list) { 730 acl_list) {
723 list_del(&nacl->acl_list); 731 list_del(&nacl->acl_list);
724 se_tpg->num_node_acls--; 732 se_tpg->num_node_acls--;
725 spin_unlock_bh(&se_tpg->acl_node_lock); 733 spin_unlock_irq(&se_tpg->acl_node_lock);
726 734
727 core_tpg_wait_for_nacl_pr_ref(nacl); 735 core_tpg_wait_for_nacl_pr_ref(nacl);
728 core_free_device_list_for_node(nacl, se_tpg); 736 core_free_device_list_for_node(nacl, se_tpg);
729 se_tpg->se_tpg_tfo->tpg_release_fabric_acl(se_tpg, nacl); 737 se_tpg->se_tpg_tfo->tpg_release_fabric_acl(se_tpg, nacl);
730 738
731 spin_lock_bh(&se_tpg->acl_node_lock); 739 spin_lock_irq(&se_tpg->acl_node_lock);
732 } 740 }
733 spin_unlock_bh(&se_tpg->acl_node_lock); 741 spin_unlock_irq(&se_tpg->acl_node_lock);
734 742
735 if (se_tpg->se_tpg_type == TRANSPORT_TPG_TYPE_NORMAL) 743 if (se_tpg->se_tpg_type == TRANSPORT_TPG_TYPE_NORMAL)
736 core_tpg_release_virtual_lun0(se_tpg); 744 core_tpg_release_virtual_lun0(se_tpg);
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 89760329d5d0..8d0c58ea6316 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -389,17 +389,18 @@ void transport_deregister_session(struct se_session *se_sess)
389{ 389{
390 struct se_portal_group *se_tpg = se_sess->se_tpg; 390 struct se_portal_group *se_tpg = se_sess->se_tpg;
391 struct se_node_acl *se_nacl; 391 struct se_node_acl *se_nacl;
392 unsigned long flags;
392 393
393 if (!se_tpg) { 394 if (!se_tpg) {
394 transport_free_session(se_sess); 395 transport_free_session(se_sess);
395 return; 396 return;
396 } 397 }
397 398
398 spin_lock_bh(&se_tpg->session_lock); 399 spin_lock_irqsave(&se_tpg->session_lock, flags);
399 list_del(&se_sess->sess_list); 400 list_del(&se_sess->sess_list);
400 se_sess->se_tpg = NULL; 401 se_sess->se_tpg = NULL;
401 se_sess->fabric_sess_ptr = NULL; 402 se_sess->fabric_sess_ptr = NULL;
402 spin_unlock_bh(&se_tpg->session_lock); 403 spin_unlock_irqrestore(&se_tpg->session_lock, flags);
403 404
404 /* 405 /*
405 * Determine if we need to do extra work for this initiator node's 406 * Determine if we need to do extra work for this initiator node's
@@ -407,22 +408,22 @@ void transport_deregister_session(struct se_session *se_sess)
407 */ 408 */
408 se_nacl = se_sess->se_node_acl; 409 se_nacl = se_sess->se_node_acl;
409 if (se_nacl) { 410 if (se_nacl) {
410 spin_lock_bh(&se_tpg->acl_node_lock); 411 spin_lock_irqsave(&se_tpg->acl_node_lock, flags);
411 if (se_nacl->dynamic_node_acl) { 412 if (se_nacl->dynamic_node_acl) {
412 if (!se_tpg->se_tpg_tfo->tpg_check_demo_mode_cache( 413 if (!se_tpg->se_tpg_tfo->tpg_check_demo_mode_cache(
413 se_tpg)) { 414 se_tpg)) {
414 list_del(&se_nacl->acl_list); 415 list_del(&se_nacl->acl_list);
415 se_tpg->num_node_acls--; 416 se_tpg->num_node_acls--;
416 spin_unlock_bh(&se_tpg->acl_node_lock); 417 spin_unlock_irqrestore(&se_tpg->acl_node_lock, flags);
417 418
418 core_tpg_wait_for_nacl_pr_ref(se_nacl); 419 core_tpg_wait_for_nacl_pr_ref(se_nacl);
419 core_free_device_list_for_node(se_nacl, se_tpg); 420 core_free_device_list_for_node(se_nacl, se_tpg);
420 se_tpg->se_tpg_tfo->tpg_release_fabric_acl(se_tpg, 421 se_tpg->se_tpg_tfo->tpg_release_fabric_acl(se_tpg,
421 se_nacl); 422 se_nacl);
422 spin_lock_bh(&se_tpg->acl_node_lock); 423 spin_lock_irqsave(&se_tpg->acl_node_lock, flags);
423 } 424 }
424 } 425 }
425 spin_unlock_bh(&se_tpg->acl_node_lock); 426 spin_unlock_irqrestore(&se_tpg->acl_node_lock, flags);
426 } 427 }
427 428
428 transport_free_session(se_sess); 429 transport_free_session(se_sess);
@@ -2053,8 +2054,14 @@ static void transport_generic_request_failure(
2053 cmd->scsi_sense_reason = TCM_UNSUPPORTED_SCSI_OPCODE; 2054 cmd->scsi_sense_reason = TCM_UNSUPPORTED_SCSI_OPCODE;
2054 break; 2055 break;
2055 } 2056 }
2056 2057 /*
2057 if (!sc) 2058 * If a fabric does not define a cmd->se_tfo->new_cmd_map caller,
2059 * make the call to transport_send_check_condition_and_sense()
2060 * directly. Otherwise expect the fabric to make the call to
2061 * transport_send_check_condition_and_sense() after handling
2062 * possible unsoliticied write data payloads.
2063 */
2064 if (!sc && !cmd->se_tfo->new_cmd_map)
2058 transport_new_cmd_failure(cmd); 2065 transport_new_cmd_failure(cmd);
2059 else { 2066 else {
2060 ret = transport_send_check_condition_and_sense(cmd, 2067 ret = transport_send_check_condition_and_sense(cmd,
@@ -2847,12 +2854,42 @@ static int transport_cmd_get_valid_sectors(struct se_cmd *cmd)
2847 " transport_dev_end_lba(): %llu\n", 2854 " transport_dev_end_lba(): %llu\n",
2848 cmd->t_task_lba, sectors, 2855 cmd->t_task_lba, sectors,
2849 transport_dev_end_lba(dev)); 2856 transport_dev_end_lba(dev));
2850 pr_err(" We should return CHECK_CONDITION" 2857 return -EINVAL;
2851 " but we don't yet\n");
2852 return 0;
2853 } 2858 }
2854 2859
2855 return sectors; 2860 return 0;
2861}
2862
2863static int target_check_write_same_discard(unsigned char *flags, struct se_device *dev)
2864{
2865 /*
2866 * Determine if the received WRITE_SAME is used to for direct
2867 * passthrough into Linux/SCSI with struct request via TCM/pSCSI
2868 * or we are signaling the use of internal WRITE_SAME + UNMAP=1
2869 * emulation for -> Linux/BLOCK disbard with TCM/IBLOCK code.
2870 */
2871 int passthrough = (dev->transport->transport_type ==
2872 TRANSPORT_PLUGIN_PHBA_PDEV);
2873
2874 if (!passthrough) {
2875 if ((flags[0] & 0x04) || (flags[0] & 0x02)) {
2876 pr_err("WRITE_SAME PBDATA and LBDATA"
2877 " bits not supported for Block Discard"
2878 " Emulation\n");
2879 return -ENOSYS;
2880 }
2881 /*
2882 * Currently for the emulated case we only accept
2883 * tpws with the UNMAP=1 bit set.
2884 */
2885 if (!(flags[0] & 0x08)) {
2886 pr_err("WRITE_SAME w/o UNMAP bit not"
2887 " supported for Block Discard Emulation\n");
2888 return -ENOSYS;
2889 }
2890 }
2891
2892 return 0;
2856} 2893}
2857 2894
2858/* transport_generic_cmd_sequencer(): 2895/* transport_generic_cmd_sequencer():
@@ -3065,7 +3102,7 @@ static int transport_generic_cmd_sequencer(
3065 goto out_unsupported_cdb; 3102 goto out_unsupported_cdb;
3066 3103
3067 if (sectors) 3104 if (sectors)
3068 size = transport_get_size(sectors, cdb, cmd); 3105 size = transport_get_size(1, cdb, cmd);
3069 else { 3106 else {
3070 pr_err("WSNZ=1, WRITE_SAME w/sectors=0 not" 3107 pr_err("WSNZ=1, WRITE_SAME w/sectors=0 not"
3071 " supported\n"); 3108 " supported\n");
@@ -3075,27 +3112,9 @@ static int transport_generic_cmd_sequencer(
3075 cmd->t_task_lba = get_unaligned_be64(&cdb[12]); 3112 cmd->t_task_lba = get_unaligned_be64(&cdb[12]);
3076 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB; 3113 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
3077 3114
3078 /* 3115 if (target_check_write_same_discard(&cdb[10], dev) < 0)
3079 * Skip the remaining assignments for TCM/PSCSI passthrough
3080 */
3081 if (passthrough)
3082 break;
3083
3084 if ((cdb[10] & 0x04) || (cdb[10] & 0x02)) {
3085 pr_err("WRITE_SAME PBDATA and LBDATA"
3086 " bits not supported for Block Discard"
3087 " Emulation\n");
3088 goto out_invalid_cdb_field; 3116 goto out_invalid_cdb_field;
3089 } 3117
3090 /*
3091 * Currently for the emulated case we only accept
3092 * tpws with the UNMAP=1 bit set.
3093 */
3094 if (!(cdb[10] & 0x08)) {
3095 pr_err("WRITE_SAME w/o UNMAP bit not"
3096 " supported for Block Discard Emulation\n");
3097 goto out_invalid_cdb_field;
3098 }
3099 break; 3118 break;
3100 default: 3119 default:
3101 pr_err("VARIABLE_LENGTH_CMD service action" 3120 pr_err("VARIABLE_LENGTH_CMD service action"
@@ -3330,10 +3349,12 @@ static int transport_generic_cmd_sequencer(
3330 cmd->se_cmd_flags |= SCF_EMULATE_CDB_ASYNC; 3349 cmd->se_cmd_flags |= SCF_EMULATE_CDB_ASYNC;
3331 /* 3350 /*
3332 * Check to ensure that LBA + Range does not exceed past end of 3351 * Check to ensure that LBA + Range does not exceed past end of
3333 * device. 3352 * device for IBLOCK and FILEIO ->do_sync_cache() backend calls
3334 */ 3353 */
3335 if (!transport_cmd_get_valid_sectors(cmd)) 3354 if ((cmd->t_task_lba != 0) || (sectors != 0)) {
3336 goto out_invalid_cdb_field; 3355 if (transport_cmd_get_valid_sectors(cmd) < 0)
3356 goto out_invalid_cdb_field;
3357 }
3337 break; 3358 break;
3338 case UNMAP: 3359 case UNMAP:
3339 size = get_unaligned_be16(&cdb[7]); 3360 size = get_unaligned_be16(&cdb[7]);
@@ -3345,40 +3366,38 @@ static int transport_generic_cmd_sequencer(
3345 goto out_unsupported_cdb; 3366 goto out_unsupported_cdb;
3346 3367
3347 if (sectors) 3368 if (sectors)
3348 size = transport_get_size(sectors, cdb, cmd); 3369 size = transport_get_size(1, cdb, cmd);
3349 else { 3370 else {
3350 pr_err("WSNZ=1, WRITE_SAME w/sectors=0 not supported\n"); 3371 pr_err("WSNZ=1, WRITE_SAME w/sectors=0 not supported\n");
3351 goto out_invalid_cdb_field; 3372 goto out_invalid_cdb_field;
3352 } 3373 }
3353 3374
3354 cmd->t_task_lba = get_unaligned_be64(&cdb[2]); 3375 cmd->t_task_lba = get_unaligned_be64(&cdb[2]);
3355 passthrough = (dev->transport->transport_type == 3376 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
3356 TRANSPORT_PLUGIN_PHBA_PDEV); 3377
3357 /* 3378 if (target_check_write_same_discard(&cdb[1], dev) < 0)
3358 * Determine if the received WRITE_SAME_16 is used to for direct 3379 goto out_invalid_cdb_field;
3359 * passthrough into Linux/SCSI with struct request via TCM/pSCSI 3380 break;
3360 * or we are signaling the use of internal WRITE_SAME + UNMAP=1 3381 case WRITE_SAME:
3361 * emulation for -> Linux/BLOCK disbard with TCM/IBLOCK and 3382 sectors = transport_get_sectors_10(cdb, cmd, &sector_ret);
3362 * TCM/FILEIO subsystem plugin backstores. 3383 if (sector_ret)
3363 */ 3384 goto out_unsupported_cdb;
3364 if (!passthrough) { 3385
3365 if ((cdb[1] & 0x04) || (cdb[1] & 0x02)) { 3386 if (sectors)
3366 pr_err("WRITE_SAME PBDATA and LBDATA" 3387 size = transport_get_size(1, cdb, cmd);
3367 " bits not supported for Block Discard" 3388 else {
3368 " Emulation\n"); 3389 pr_err("WSNZ=1, WRITE_SAME w/sectors=0 not supported\n");
3369 goto out_invalid_cdb_field; 3390 goto out_invalid_cdb_field;
3370 }
3371 /*
3372 * Currently for the emulated case we only accept
3373 * tpws with the UNMAP=1 bit set.
3374 */
3375 if (!(cdb[1] & 0x08)) {
3376 pr_err("WRITE_SAME w/o UNMAP bit not "
3377 " supported for Block Discard Emulation\n");
3378 goto out_invalid_cdb_field;
3379 }
3380 } 3391 }
3392
3393 cmd->t_task_lba = get_unaligned_be32(&cdb[2]);
3381 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB; 3394 cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
3395 /*
3396 * Follow sbcr26 with WRITE_SAME (10) and check for the existence
3397 * of byte 1 bit 3 UNMAP instead of original reserved field
3398 */
3399 if (target_check_write_same_discard(&cdb[1], dev) < 0)
3400 goto out_invalid_cdb_field;
3382 break; 3401 break;
3383 case ALLOW_MEDIUM_REMOVAL: 3402 case ALLOW_MEDIUM_REMOVAL:
3384 case GPCMD_CLOSE_TRACK: 3403 case GPCMD_CLOSE_TRACK:
@@ -3873,9 +3892,7 @@ EXPORT_SYMBOL(transport_generic_map_mem_to_cmd);
3873static int transport_new_cmd_obj(struct se_cmd *cmd) 3892static int transport_new_cmd_obj(struct se_cmd *cmd)
3874{ 3893{
3875 struct se_device *dev = cmd->se_dev; 3894 struct se_device *dev = cmd->se_dev;
3876 u32 task_cdbs; 3895 int set_counts = 1, rc, task_cdbs;
3877 u32 rc;
3878 int set_counts = 1;
3879 3896
3880 /* 3897 /*
3881 * Setup any BIDI READ tasks and memory from 3898 * Setup any BIDI READ tasks and memory from
@@ -3893,7 +3910,7 @@ static int transport_new_cmd_obj(struct se_cmd *cmd)
3893 cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; 3910 cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
3894 cmd->scsi_sense_reason = 3911 cmd->scsi_sense_reason =
3895 TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; 3912 TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
3896 return PYX_TRANSPORT_LU_COMM_FAILURE; 3913 return -EINVAL;
3897 } 3914 }
3898 atomic_inc(&cmd->t_fe_count); 3915 atomic_inc(&cmd->t_fe_count);
3899 atomic_inc(&cmd->t_se_count); 3916 atomic_inc(&cmd->t_se_count);
@@ -3912,7 +3929,7 @@ static int transport_new_cmd_obj(struct se_cmd *cmd)
3912 cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; 3929 cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
3913 cmd->scsi_sense_reason = 3930 cmd->scsi_sense_reason =
3914 TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; 3931 TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
3915 return PYX_TRANSPORT_LU_COMM_FAILURE; 3932 return -EINVAL;
3916 } 3933 }
3917 3934
3918 if (set_counts) { 3935 if (set_counts) {
@@ -4028,8 +4045,6 @@ void transport_do_task_sg_chain(struct se_cmd *cmd)
4028 if (!task->task_sg) 4045 if (!task->task_sg)
4029 continue; 4046 continue;
4030 4047
4031 BUG_ON(!task->task_padded_sg);
4032
4033 if (!sg_first) { 4048 if (!sg_first) {
4034 sg_first = task->task_sg; 4049 sg_first = task->task_sg;
4035 chained_nents = task->task_sg_nents; 4050 chained_nents = task->task_sg_nents;
@@ -4037,9 +4052,19 @@ void transport_do_task_sg_chain(struct se_cmd *cmd)
4037 sg_chain(sg_prev, sg_prev_nents, task->task_sg); 4052 sg_chain(sg_prev, sg_prev_nents, task->task_sg);
4038 chained_nents += task->task_sg_nents; 4053 chained_nents += task->task_sg_nents;
4039 } 4054 }
4055 /*
4056 * For the padded tasks, use the extra SGL vector allocated
4057 * in transport_allocate_data_tasks() for the sg_prev_nents
4058 * offset into sg_chain() above.. The last task of a
4059 * multi-task list, or a single task will not have
4060 * task->task_sg_padded set..
4061 */
4062 if (task->task_padded_sg)
4063 sg_prev_nents = (task->task_sg_nents + 1);
4064 else
4065 sg_prev_nents = task->task_sg_nents;
4040 4066
4041 sg_prev = task->task_sg; 4067 sg_prev = task->task_sg;
4042 sg_prev_nents = task->task_sg_nents;
4043 } 4068 }
4044 /* 4069 /*
4045 * Setup the starting pointer and total t_tasks_sg_linked_no including 4070 * Setup the starting pointer and total t_tasks_sg_linked_no including
@@ -4091,7 +4116,7 @@ static int transport_allocate_data_tasks(
4091 4116
4092 cmd_sg = sgl; 4117 cmd_sg = sgl;
4093 for (i = 0; i < task_count; i++) { 4118 for (i = 0; i < task_count; i++) {
4094 unsigned int task_size; 4119 unsigned int task_size, task_sg_nents_padded;
4095 int count; 4120 int count;
4096 4121
4097 task = transport_generic_get_task(cmd, data_direction); 4122 task = transport_generic_get_task(cmd, data_direction);
@@ -4110,30 +4135,33 @@ static int transport_allocate_data_tasks(
4110 4135
4111 /* Update new cdb with updated lba/sectors */ 4136 /* Update new cdb with updated lba/sectors */
4112 cmd->transport_split_cdb(task->task_lba, task->task_sectors, cdb); 4137 cmd->transport_split_cdb(task->task_lba, task->task_sectors, cdb);
4113 4138 /*
4139 * This now assumes that passed sg_ents are in PAGE_SIZE chunks
4140 * in order to calculate the number per task SGL entries
4141 */
4142 task->task_sg_nents = DIV_ROUND_UP(task->task_size, PAGE_SIZE);
4114 /* 4143 /*
4115 * Check if the fabric module driver is requesting that all 4144 * Check if the fabric module driver is requesting that all
4116 * struct se_task->task_sg[] be chained together.. If so, 4145 * struct se_task->task_sg[] be chained together.. If so,
4117 * then allocate an extra padding SG entry for linking and 4146 * then allocate an extra padding SG entry for linking and
4118 * marking the end of the chained SGL. 4147 * marking the end of the chained SGL for every task except
4119 * Possibly over-allocate task sgl size by using cmd sgl size. 4148 * the last one for (task_count > 1) operation, or skipping
4120 * It's so much easier and only a waste when task_count > 1. 4149 * the extra padding for the (task_count == 1) case.
4121 * That is extremely rare.
4122 */ 4150 */
4123 task->task_sg_nents = sgl_nents; 4151 if (cmd->se_tfo->task_sg_chaining && (i < (task_count - 1))) {
4124 if (cmd->se_tfo->task_sg_chaining) { 4152 task_sg_nents_padded = (task->task_sg_nents + 1);
4125 task->task_sg_nents++;
4126 task->task_padded_sg = 1; 4153 task->task_padded_sg = 1;
4127 } 4154 } else
4155 task_sg_nents_padded = task->task_sg_nents;
4128 4156
4129 task->task_sg = kmalloc(sizeof(struct scatterlist) * 4157 task->task_sg = kmalloc(sizeof(struct scatterlist) *
4130 task->task_sg_nents, GFP_KERNEL); 4158 task_sg_nents_padded, GFP_KERNEL);
4131 if (!task->task_sg) { 4159 if (!task->task_sg) {
4132 cmd->se_dev->transport->free_task(task); 4160 cmd->se_dev->transport->free_task(task);
4133 return -ENOMEM; 4161 return -ENOMEM;
4134 } 4162 }
4135 4163
4136 sg_init_table(task->task_sg, task->task_sg_nents); 4164 sg_init_table(task->task_sg, task_sg_nents_padded);
4137 4165
4138 task_size = task->task_size; 4166 task_size = task->task_size;
4139 4167
@@ -4230,10 +4258,13 @@ static u32 transport_allocate_tasks(
4230 struct scatterlist *sgl, 4258 struct scatterlist *sgl,
4231 unsigned int sgl_nents) 4259 unsigned int sgl_nents)
4232{ 4260{
4233 if (cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB) 4261 if (cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB) {
4262 if (transport_cmd_get_valid_sectors(cmd) < 0)
4263 return -EINVAL;
4264
4234 return transport_allocate_data_tasks(cmd, lba, data_direction, 4265 return transport_allocate_data_tasks(cmd, lba, data_direction,
4235 sgl, sgl_nents); 4266 sgl, sgl_nents);
4236 else 4267 } else
4237 return transport_allocate_control_task(cmd); 4268 return transport_allocate_control_task(cmd);
4238 4269
4239} 4270}
@@ -4726,6 +4757,13 @@ int transport_send_check_condition_and_sense(
4726 */ 4757 */
4727 switch (reason) { 4758 switch (reason) {
4728 case TCM_NON_EXISTENT_LUN: 4759 case TCM_NON_EXISTENT_LUN:
4760 /* CURRENT ERROR */
4761 buffer[offset] = 0x70;
4762 /* ILLEGAL REQUEST */
4763 buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST;
4764 /* LOGICAL UNIT NOT SUPPORTED */
4765 buffer[offset+SPC_ASC_KEY_OFFSET] = 0x25;
4766 break;
4729 case TCM_UNSUPPORTED_SCSI_OPCODE: 4767 case TCM_UNSUPPORTED_SCSI_OPCODE:
4730 case TCM_SECTOR_COUNT_TOO_MANY: 4768 case TCM_SECTOR_COUNT_TOO_MANY:
4731 /* CURRENT ERROR */ 4769 /* CURRENT ERROR */
diff --git a/drivers/target/tcm_fc/tfc_conf.c b/drivers/target/tcm_fc/tfc_conf.c
index 8781d1e423df..b15879d43e22 100644
--- a/drivers/target/tcm_fc/tfc_conf.c
+++ b/drivers/target/tcm_fc/tfc_conf.c
@@ -256,7 +256,7 @@ struct ft_node_acl *ft_acl_get(struct ft_tpg *tpg, struct fc_rport_priv *rdata)
256 struct se_portal_group *se_tpg = &tpg->se_tpg; 256 struct se_portal_group *se_tpg = &tpg->se_tpg;
257 struct se_node_acl *se_acl; 257 struct se_node_acl *se_acl;
258 258
259 spin_lock_bh(&se_tpg->acl_node_lock); 259 spin_lock_irq(&se_tpg->acl_node_lock);
260 list_for_each_entry(se_acl, &se_tpg->acl_node_list, acl_list) { 260 list_for_each_entry(se_acl, &se_tpg->acl_node_list, acl_list) {
261 acl = container_of(se_acl, struct ft_node_acl, se_node_acl); 261 acl = container_of(se_acl, struct ft_node_acl, se_node_acl);
262 pr_debug("acl %p port_name %llx\n", 262 pr_debug("acl %p port_name %llx\n",
@@ -270,7 +270,7 @@ struct ft_node_acl *ft_acl_get(struct ft_tpg *tpg, struct fc_rport_priv *rdata)
270 break; 270 break;
271 } 271 }
272 } 272 }
273 spin_unlock_bh(&se_tpg->acl_node_lock); 273 spin_unlock_irq(&se_tpg->acl_node_lock);
274 return found; 274 return found;
275} 275}
276 276
@@ -655,9 +655,7 @@ static void __exit ft_exit(void)
655 synchronize_rcu(); 655 synchronize_rcu();
656} 656}
657 657
658#ifdef MODULE
659MODULE_DESCRIPTION("FC TCM fabric driver " FT_VERSION); 658MODULE_DESCRIPTION("FC TCM fabric driver " FT_VERSION);
660MODULE_LICENSE("GPL"); 659MODULE_LICENSE("GPL");
661module_init(ft_init); 660module_init(ft_init);
662module_exit(ft_exit); 661module_exit(ft_exit);
663#endif /* MODULE */
diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c
index 05a8832bb3eb..d06886a2bfb5 100644
--- a/drivers/video/backlight/adp8870_bl.c
+++ b/drivers/video/backlight/adp8870_bl.c
@@ -1009,4 +1009,4 @@ module_exit(adp8870_exit);
1009MODULE_LICENSE("GPL v2"); 1009MODULE_LICENSE("GPL v2");
1010MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); 1010MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
1011MODULE_DESCRIPTION("ADP8870 Backlight driver"); 1011MODULE_DESCRIPTION("ADP8870 Backlight driver");
1012MODULE_ALIAS("platform:adp8870-backlight"); 1012MODULE_ALIAS("i2c:adp8870-backlight");
diff --git a/drivers/video/backlight/ep93xx_bl.c b/drivers/video/backlight/ep93xx_bl.c
index 9f1e389d51d2..b0582917f0c8 100644
--- a/drivers/video/backlight/ep93xx_bl.c
+++ b/drivers/video/backlight/ep93xx_bl.c
@@ -11,7 +11,7 @@
11 * BRIGHT, on the Cirrus EP9307, EP9312, and EP9315 processors. 11 * BRIGHT, on the Cirrus EP9307, EP9312, and EP9315 processors.
12 */ 12 */
13 13
14 14#include <linux/module.h>
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/io.h> 16#include <linux/io.h>
17#include <linux/fb.h> 17#include <linux/fb.h>
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index b8f38ec6eb18..8b5b2a4124c7 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -28,6 +28,8 @@ struct pwm_bl_data {
28 unsigned int lth_brightness; 28 unsigned int lth_brightness;
29 int (*notify)(struct device *, 29 int (*notify)(struct device *,
30 int brightness); 30 int brightness);
31 void (*notify_after)(struct device *,
32 int brightness);
31 int (*check_fb)(struct device *, struct fb_info *); 33 int (*check_fb)(struct device *, struct fb_info *);
32}; 34};
33 35
@@ -55,6 +57,10 @@ static int pwm_backlight_update_status(struct backlight_device *bl)
55 pwm_config(pb->pwm, brightness, pb->period); 57 pwm_config(pb->pwm, brightness, pb->period);
56 pwm_enable(pb->pwm); 58 pwm_enable(pb->pwm);
57 } 59 }
60
61 if (pb->notify_after)
62 pb->notify_after(pb->dev, brightness);
63
58 return 0; 64 return 0;
59} 65}
60 66
@@ -105,6 +111,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
105 111
106 pb->period = data->pwm_period_ns; 112 pb->period = data->pwm_period_ns;
107 pb->notify = data->notify; 113 pb->notify = data->notify;
114 pb->notify_after = data->notify_after;
108 pb->check_fb = data->check_fb; 115 pb->check_fb = data->check_fb;
109 pb->lth_brightness = data->lth_brightness * 116 pb->lth_brightness = data->lth_brightness *
110 (data->pwm_period_ns / data->max_brightness); 117 (data->pwm_period_ns / data->max_brightness);
@@ -172,6 +179,8 @@ static int pwm_backlight_suspend(struct platform_device *pdev,
172 pb->notify(pb->dev, 0); 179 pb->notify(pb->dev, 0);
173 pwm_config(pb->pwm, 0, pb->period); 180 pwm_config(pb->pwm, 0, pb->period);
174 pwm_disable(pb->pwm); 181 pwm_disable(pb->pwm);
182 if (pb->notify_after)
183 pb->notify_after(pb->dev, 0);
175 return 0; 184 return 0;
176} 185}
177 186
diff --git a/drivers/w1/masters/ds2490.c b/drivers/w1/masters/ds2490.c
index 02bf7bf7160b..b5abaae38e97 100644
--- a/drivers/w1/masters/ds2490.c
+++ b/drivers/w1/masters/ds2490.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * dscore.c 2 * dscore.c
3 * 3 *
4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -1024,5 +1024,5 @@ module_init(ds_init);
1024module_exit(ds_fini); 1024module_exit(ds_fini);
1025 1025
1026MODULE_LICENSE("GPL"); 1026MODULE_LICENSE("GPL");
1027MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>"); 1027MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>");
1028MODULE_DESCRIPTION("DS2490 USB <-> W1 bus master driver (DS9490*)"); 1028MODULE_DESCRIPTION("DS2490 USB <-> W1 bus master driver (DS9490*)");
diff --git a/drivers/w1/masters/matrox_w1.c b/drivers/w1/masters/matrox_w1.c
index 334d1ccf9c92..f667c26b2195 100644
--- a/drivers/w1/masters/matrox_w1.c
+++ b/drivers/w1/masters/matrox_w1.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * matrox_w1.c 2 * matrox_w1.c
3 * 3 *
4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -39,7 +39,7 @@
39#include "../w1_log.h" 39#include "../w1_log.h"
40 40
41MODULE_LICENSE("GPL"); 41MODULE_LICENSE("GPL");
42MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>"); 42MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>");
43MODULE_DESCRIPTION("Driver for transport(Dallas 1-wire prtocol) over VGA DDC(matrox gpio)."); 43MODULE_DESCRIPTION("Driver for transport(Dallas 1-wire prtocol) over VGA DDC(matrox gpio).");
44 44
45static struct pci_device_id matrox_w1_tbl[] = { 45static struct pci_device_id matrox_w1_tbl[] = {
diff --git a/drivers/w1/slaves/w1_ds2408.c b/drivers/w1/slaves/w1_ds2408.c
index c37781899d90..7c8cdb8aed26 100644
--- a/drivers/w1/slaves/w1_ds2408.c
+++ b/drivers/w1/slaves/w1_ds2408.c
@@ -373,7 +373,7 @@ static int w1_f29_add_slave(struct w1_slave *sl)
373static void w1_f29_remove_slave(struct w1_slave *sl) 373static void w1_f29_remove_slave(struct w1_slave *sl)
374{ 374{
375 int i; 375 int i;
376 for (i = NB_SYSFS_BIN_FILES; i <= 0; --i) 376 for (i = NB_SYSFS_BIN_FILES - 1; i >= 0; --i)
377 sysfs_remove_bin_file(&sl->dev.kobj, 377 sysfs_remove_bin_file(&sl->dev.kobj,
378 &(w1_f29_sysfs_bin_files[i])); 378 &(w1_f29_sysfs_bin_files[i]));
379} 379}
diff --git a/drivers/w1/slaves/w1_smem.c b/drivers/w1/slaves/w1_smem.c
index cc8c02e92593..84655625c870 100644
--- a/drivers/w1/slaves/w1_smem.c
+++ b/drivers/w1/slaves/w1_smem.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * w1_smem.c 2 * w1_smem.c
3 * 3 *
4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -32,7 +32,7 @@
32#include "../w1_family.h" 32#include "../w1_family.h"
33 33
34MODULE_LICENSE("GPL"); 34MODULE_LICENSE("GPL");
35MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>"); 35MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>");
36MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol, 64bit memory family."); 36MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol, 64bit memory family.");
37 37
38static struct w1_family w1_smem_family_01 = { 38static struct w1_family w1_smem_family_01 = {
diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c
index 402928b135d1..a1ef9b5b38cf 100644
--- a/drivers/w1/slaves/w1_therm.c
+++ b/drivers/w1/slaves/w1_therm.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * w1_therm.c 2 * w1_therm.c
3 * 3 *
4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -34,7 +34,7 @@
34#include "../w1_family.h" 34#include "../w1_family.h"
35 35
36MODULE_LICENSE("GPL"); 36MODULE_LICENSE("GPL");
37MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>"); 37MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>");
38MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol, temperature family."); 38MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol, temperature family.");
39 39
40/* Allow the strong pullup to be disabled, but default to enabled. 40/* Allow the strong pullup to be disabled, but default to enabled.
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 6c136c19e982..c37497823851 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * w1.c 2 * w1.c
3 * 3 *
4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -42,7 +42,7 @@
42#include "w1_netlink.h" 42#include "w1_netlink.h"
43 43
44MODULE_LICENSE("GPL"); 44MODULE_LICENSE("GPL");
45MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>"); 45MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>");
46MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol."); 46MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol.");
47 47
48static int w1_timeout = 10; 48static int w1_timeout = 10;
diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h
index 1ce23fc6186c..4d012ca3f32c 100644
--- a/drivers/w1/w1.h
+++ b/drivers/w1/w1.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * w1.h 2 * w1.h
3 * 3 *
4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
diff --git a/drivers/w1/w1_family.c b/drivers/w1/w1_family.c
index 4a099041f28a..63359797c8b1 100644
--- a/drivers/w1/w1_family.c
+++ b/drivers/w1/w1_family.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * w1_family.c 2 * w1_family.c
3 * 3 *
4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
diff --git a/drivers/w1/w1_family.h b/drivers/w1/w1_family.h
index 98a1ac0f4693..490cda2281bc 100644
--- a/drivers/w1/w1_family.h
+++ b/drivers/w1/w1_family.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * w1_family.h 2 * w1_family.h
3 * 3 *
4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index b50be3f1073d..d220bce2cee4 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * w1_int.c 2 * w1_int.c
3 * 3 *
4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
diff --git a/drivers/w1/w1_int.h b/drivers/w1/w1_int.h
index 4274082d2262..2ad7d4414bed 100644
--- a/drivers/w1/w1_int.h
+++ b/drivers/w1/w1_int.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * w1_int.h 2 * w1_int.h
3 * 3 *
4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c
index 8e8b64cfafb6..765b37b62a4f 100644
--- a/drivers/w1/w1_io.c
+++ b/drivers/w1/w1_io.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * w1_io.c 2 * w1_io.c
3 * 3 *
4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
diff --git a/drivers/w1/w1_log.h b/drivers/w1/w1_log.h
index e6ab7cf08f88..9c7bd62e6bdc 100644
--- a/drivers/w1/w1_log.h
+++ b/drivers/w1/w1_log.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * w1_log.h 2 * w1_log.h
3 * 3 *
4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
diff --git a/drivers/w1/w1_netlink.c b/drivers/w1/w1_netlink.c
index 55aabd927c60..40788c925d1c 100644
--- a/drivers/w1/w1_netlink.c
+++ b/drivers/w1/w1_netlink.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * w1_netlink.c 2 * w1_netlink.c
3 * 3 *
4 * Copyright (c) 2003 Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * Copyright (c) 2003 Evgeniy Polyakov <zbr@ioremap.net>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
diff --git a/drivers/w1/w1_netlink.h b/drivers/w1/w1_netlink.h
index 27e950f935b1..b0922dc29658 100644
--- a/drivers/w1/w1_netlink.h
+++ b/drivers/w1/w1_netlink.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * w1_netlink.h 2 * w1_netlink.h
3 * 3 *
4 * Copyright (c) 2003 Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * Copyright (c) 2003 Evgeniy Polyakov <zbr@ioremap.net>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 640fc229df10..168a80f7f12b 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1358,6 +1358,10 @@ static int fuse_notify_inval_entry(struct fuse_conn *fc, unsigned int size,
1358 if (outarg.namelen > FUSE_NAME_MAX) 1358 if (outarg.namelen > FUSE_NAME_MAX)
1359 goto err; 1359 goto err;
1360 1360
1361 err = -EINVAL;
1362 if (size != sizeof(outarg) + outarg.namelen + 1)
1363 goto err;
1364
1361 name.name = buf; 1365 name.name = buf;
1362 name.len = outarg.namelen; 1366 name.len = outarg.namelen;
1363 err = fuse_copy_one(cs, buf, outarg.namelen + 1); 1367 err = fuse_copy_one(cs, buf, outarg.namelen + 1);
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index d480d9af46c9..594f07a81c28 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -14,6 +14,7 @@
14#include <linux/sched.h> 14#include <linux/sched.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/compat.h> 16#include <linux/compat.h>
17#include <linux/swap.h>
17 18
18static const struct file_operations fuse_direct_io_file_operations; 19static const struct file_operations fuse_direct_io_file_operations;
19 20
@@ -245,6 +246,12 @@ void fuse_release_common(struct file *file, int opcode)
245 req = ff->reserved_req; 246 req = ff->reserved_req;
246 fuse_prepare_release(ff, file->f_flags, opcode); 247 fuse_prepare_release(ff, file->f_flags, opcode);
247 248
249 if (ff->flock) {
250 struct fuse_release_in *inarg = &req->misc.release.in;
251 inarg->release_flags |= FUSE_RELEASE_FLOCK_UNLOCK;
252 inarg->lock_owner = fuse_lock_owner_id(ff->fc,
253 (fl_owner_t) file);
254 }
248 /* Hold vfsmount and dentry until release is finished */ 255 /* Hold vfsmount and dentry until release is finished */
249 path_get(&file->f_path); 256 path_get(&file->f_path);
250 req->misc.release.path = file->f_path; 257 req->misc.release.path = file->f_path;
@@ -755,18 +762,6 @@ static size_t fuse_send_write(struct fuse_req *req, struct file *file,
755 return req->misc.write.out.size; 762 return req->misc.write.out.size;
756} 763}
757 764
758static int fuse_write_begin(struct file *file, struct address_space *mapping,
759 loff_t pos, unsigned len, unsigned flags,
760 struct page **pagep, void **fsdata)
761{
762 pgoff_t index = pos >> PAGE_CACHE_SHIFT;
763
764 *pagep = grab_cache_page_write_begin(mapping, index, flags);
765 if (!*pagep)
766 return -ENOMEM;
767 return 0;
768}
769
770void fuse_write_update_size(struct inode *inode, loff_t pos) 765void fuse_write_update_size(struct inode *inode, loff_t pos)
771{ 766{
772 struct fuse_conn *fc = get_fuse_conn(inode); 767 struct fuse_conn *fc = get_fuse_conn(inode);
@@ -779,62 +774,6 @@ void fuse_write_update_size(struct inode *inode, loff_t pos)
779 spin_unlock(&fc->lock); 774 spin_unlock(&fc->lock);
780} 775}
781 776
782static int fuse_buffered_write(struct file *file, struct inode *inode,
783 loff_t pos, unsigned count, struct page *page)
784{
785 int err;
786 size_t nres;
787 struct fuse_conn *fc = get_fuse_conn(inode);
788 unsigned offset = pos & (PAGE_CACHE_SIZE - 1);
789 struct fuse_req *req;
790
791 if (is_bad_inode(inode))
792 return -EIO;
793
794 /*
795 * Make sure writepages on the same page are not mixed up with
796 * plain writes.
797 */
798 fuse_wait_on_page_writeback(inode, page->index);
799
800 req = fuse_get_req(fc);
801 if (IS_ERR(req))
802 return PTR_ERR(req);
803
804 req->in.argpages = 1;
805 req->num_pages = 1;
806 req->pages[0] = page;
807 req->page_offset = offset;
808 nres = fuse_send_write(req, file, pos, count, NULL);
809 err = req->out.h.error;
810 fuse_put_request(fc, req);
811 if (!err && !nres)
812 err = -EIO;
813 if (!err) {
814 pos += nres;
815 fuse_write_update_size(inode, pos);
816 if (count == PAGE_CACHE_SIZE)
817 SetPageUptodate(page);
818 }
819 fuse_invalidate_attr(inode);
820 return err ? err : nres;
821}
822
823static int fuse_write_end(struct file *file, struct address_space *mapping,
824 loff_t pos, unsigned len, unsigned copied,
825 struct page *page, void *fsdata)
826{
827 struct inode *inode = mapping->host;
828 int res = 0;
829
830 if (copied)
831 res = fuse_buffered_write(file, inode, pos, copied, page);
832
833 unlock_page(page);
834 page_cache_release(page);
835 return res;
836}
837
838static size_t fuse_send_write_pages(struct fuse_req *req, struct file *file, 777static size_t fuse_send_write_pages(struct fuse_req *req, struct file *file,
839 struct inode *inode, loff_t pos, 778 struct inode *inode, loff_t pos,
840 size_t count) 779 size_t count)
@@ -908,6 +847,8 @@ static ssize_t fuse_fill_write_pages(struct fuse_req *req,
908 pagefault_enable(); 847 pagefault_enable();
909 flush_dcache_page(page); 848 flush_dcache_page(page);
910 849
850 mark_page_accessed(page);
851
911 if (!tmp) { 852 if (!tmp) {
912 unlock_page(page); 853 unlock_page(page);
913 page_cache_release(page); 854 page_cache_release(page);
@@ -1559,11 +1500,14 @@ static int fuse_file_flock(struct file *file, int cmd, struct file_lock *fl)
1559 struct fuse_conn *fc = get_fuse_conn(inode); 1500 struct fuse_conn *fc = get_fuse_conn(inode);
1560 int err; 1501 int err;
1561 1502
1562 if (fc->no_lock) { 1503 if (fc->no_flock) {
1563 err = flock_lock_file_wait(file, fl); 1504 err = flock_lock_file_wait(file, fl);
1564 } else { 1505 } else {
1506 struct fuse_file *ff = file->private_data;
1507
1565 /* emulate flock with POSIX locks */ 1508 /* emulate flock with POSIX locks */
1566 fl->fl_owner = (fl_owner_t) file; 1509 fl->fl_owner = (fl_owner_t) file;
1510 ff->flock = true;
1567 err = fuse_setlk(file, fl, 1); 1511 err = fuse_setlk(file, fl, 1);
1568 } 1512 }
1569 1513
@@ -2201,8 +2145,6 @@ static const struct address_space_operations fuse_file_aops = {
2201 .readpage = fuse_readpage, 2145 .readpage = fuse_readpage,
2202 .writepage = fuse_writepage, 2146 .writepage = fuse_writepage,
2203 .launder_page = fuse_launder_page, 2147 .launder_page = fuse_launder_page,
2204 .write_begin = fuse_write_begin,
2205 .write_end = fuse_write_end,
2206 .readpages = fuse_readpages, 2148 .readpages = fuse_readpages,
2207 .set_page_dirty = __set_page_dirty_nobuffers, 2149 .set_page_dirty = __set_page_dirty_nobuffers,
2208 .bmap = fuse_bmap, 2150 .bmap = fuse_bmap,
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index c6aa2d4b8517..cf6db0a93219 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -135,6 +135,9 @@ struct fuse_file {
135 135
136 /** Wait queue head for poll */ 136 /** Wait queue head for poll */
137 wait_queue_head_t poll_wait; 137 wait_queue_head_t poll_wait;
138
139 /** Has flock been performed on this file? */
140 bool flock:1;
138}; 141};
139 142
140/** One input argument of a request */ 143/** One input argument of a request */
@@ -448,7 +451,7 @@ struct fuse_conn {
448 /** Is removexattr not implemented by fs? */ 451 /** Is removexattr not implemented by fs? */
449 unsigned no_removexattr:1; 452 unsigned no_removexattr:1;
450 453
451 /** Are file locking primitives not implemented by fs? */ 454 /** Are posix file locking primitives not implemented by fs? */
452 unsigned no_lock:1; 455 unsigned no_lock:1;
453 456
454 /** Is access not implemented by fs? */ 457 /** Is access not implemented by fs? */
@@ -472,6 +475,9 @@ struct fuse_conn {
472 /** Don't apply umask to creation modes */ 475 /** Don't apply umask to creation modes */
473 unsigned dont_mask:1; 476 unsigned dont_mask:1;
474 477
478 /** Are BSD file locking primitives not implemented by fs? */
479 unsigned no_flock:1;
480
475 /** The number of requests waiting for completion */ 481 /** The number of requests waiting for completion */
476 atomic_t num_waiting; 482 atomic_t num_waiting;
477 483
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 38f84cd48b67..12b502929da9 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -71,7 +71,7 @@ struct fuse_mount_data {
71 unsigned blksize; 71 unsigned blksize;
72}; 72};
73 73
74struct fuse_forget_link *fuse_alloc_forget() 74struct fuse_forget_link *fuse_alloc_forget(void)
75{ 75{
76 return kzalloc(sizeof(struct fuse_forget_link), GFP_KERNEL); 76 return kzalloc(sizeof(struct fuse_forget_link), GFP_KERNEL);
77} 77}
@@ -809,6 +809,10 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
809 fc->async_read = 1; 809 fc->async_read = 1;
810 if (!(arg->flags & FUSE_POSIX_LOCKS)) 810 if (!(arg->flags & FUSE_POSIX_LOCKS))
811 fc->no_lock = 1; 811 fc->no_lock = 1;
812 if (arg->minor >= 17) {
813 if (!(arg->flags & FUSE_FLOCK_LOCKS))
814 fc->no_flock = 1;
815 }
812 if (arg->flags & FUSE_ATOMIC_O_TRUNC) 816 if (arg->flags & FUSE_ATOMIC_O_TRUNC)
813 fc->atomic_o_trunc = 1; 817 fc->atomic_o_trunc = 1;
814 if (arg->minor >= 9) { 818 if (arg->minor >= 9) {
@@ -823,6 +827,7 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
823 } else { 827 } else {
824 ra_pages = fc->max_read / PAGE_CACHE_SIZE; 828 ra_pages = fc->max_read / PAGE_CACHE_SIZE;
825 fc->no_lock = 1; 829 fc->no_lock = 1;
830 fc->no_flock = 1;
826 } 831 }
827 832
828 fc->bdi.ra_pages = min(fc->bdi.ra_pages, ra_pages); 833 fc->bdi.ra_pages = min(fc->bdi.ra_pages, ra_pages);
@@ -843,7 +848,8 @@ static void fuse_send_init(struct fuse_conn *fc, struct fuse_req *req)
843 arg->minor = FUSE_KERNEL_MINOR_VERSION; 848 arg->minor = FUSE_KERNEL_MINOR_VERSION;
844 arg->max_readahead = fc->bdi.ra_pages * PAGE_CACHE_SIZE; 849 arg->max_readahead = fc->bdi.ra_pages * PAGE_CACHE_SIZE;
845 arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC | 850 arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC |
846 FUSE_EXPORT_SUPPORT | FUSE_BIG_WRITES | FUSE_DONT_MASK; 851 FUSE_EXPORT_SUPPORT | FUSE_BIG_WRITES | FUSE_DONT_MASK |
852 FUSE_FLOCK_LOCKS;
847 req->in.h.opcode = FUSE_INIT; 853 req->in.h.opcode = FUSE_INIT;
848 req->in.numargs = 1; 854 req->in.numargs = 1;
849 req->in.args[0].size = sizeof(*arg); 855 req->in.args[0].size = sizeof(*arg);
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 87b6e0421c12..ec889538e5a6 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -491,6 +491,7 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, uid_t uid,
491 inode->i_op = &page_symlink_inode_operations; 491 inode->i_op = &page_symlink_inode_operations;
492 break; 492 break;
493 } 493 }
494 lockdep_annotate_inode_mutex_key(inode);
494 } 495 }
495 return inode; 496 return inode;
496} 497}
diff --git a/fs/inode.c b/fs/inode.c
index 73920d555c88..ec7924696a13 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -848,16 +848,9 @@ struct inode *new_inode(struct super_block *sb)
848} 848}
849EXPORT_SYMBOL(new_inode); 849EXPORT_SYMBOL(new_inode);
850 850
851/**
852 * unlock_new_inode - clear the I_NEW state and wake up any waiters
853 * @inode: new inode to unlock
854 *
855 * Called when the inode is fully initialised to clear the new state of the
856 * inode and wake up anyone waiting for the inode to finish initialisation.
857 */
858void unlock_new_inode(struct inode *inode)
859{
860#ifdef CONFIG_DEBUG_LOCK_ALLOC 851#ifdef CONFIG_DEBUG_LOCK_ALLOC
852void lockdep_annotate_inode_mutex_key(struct inode *inode)
853{
861 if (S_ISDIR(inode->i_mode)) { 854 if (S_ISDIR(inode->i_mode)) {
862 struct file_system_type *type = inode->i_sb->s_type; 855 struct file_system_type *type = inode->i_sb->s_type;
863 856
@@ -873,7 +866,20 @@ void unlock_new_inode(struct inode *inode)
873 &type->i_mutex_dir_key); 866 &type->i_mutex_dir_key);
874 } 867 }
875 } 868 }
869}
870EXPORT_SYMBOL(lockdep_annotate_inode_mutex_key);
876#endif 871#endif
872
873/**
874 * unlock_new_inode - clear the I_NEW state and wake up any waiters
875 * @inode: new inode to unlock
876 *
877 * Called when the inode is fully initialised to clear the new state of the
878 * inode and wake up anyone waiting for the inode to finish initialisation.
879 */
880void unlock_new_inode(struct inode *inode)
881{
882 lockdep_annotate_inode_mutex_key(inode);
877 spin_lock(&inode->i_lock); 883 spin_lock(&inode->i_lock);
878 WARN_ON(!(inode->i_state & I_NEW)); 884 WARN_ON(!(inode->i_state & I_NEW));
879 inode->i_state &= ~I_NEW; 885 inode->i_state &= ~I_NEW;
diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile
index 75bb316529dd..427a4e82a588 100644
--- a/fs/xfs/Makefile
+++ b/fs/xfs/Makefile
@@ -16,44 +16,53 @@
16# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17# 17#
18 18
19ccflags-y := -I$(src) -I$(src)/linux-2.6 19ccflags-y += -I$(src) # needed for trace events
20ccflags-$(CONFIG_XFS_DEBUG) += -g
21 20
22XFS_LINUX := linux-2.6 21ccflags-$(CONFIG_XFS_DEBUG) += -g
23 22
24obj-$(CONFIG_XFS_FS) += xfs.o 23obj-$(CONFIG_XFS_FS) += xfs.o
25 24
26xfs-y += linux-2.6/xfs_trace.o 25# this one should be compiled first, as the tracing macros can easily blow up
27 26xfs-y += xfs_trace.o
28xfs-$(CONFIG_XFS_QUOTA) += $(addprefix quota/, \
29 xfs_dquot.o \
30 xfs_dquot_item.o \
31 xfs_trans_dquot.o \
32 xfs_qm_syscalls.o \
33 xfs_qm_bhv.o \
34 xfs_qm.o)
35xfs-$(CONFIG_XFS_QUOTA) += linux-2.6/xfs_quotaops.o
36
37ifeq ($(CONFIG_XFS_QUOTA),y)
38xfs-$(CONFIG_PROC_FS) += quota/xfs_qm_stats.o
39endif
40
41xfs-$(CONFIG_XFS_RT) += xfs_rtalloc.o
42xfs-$(CONFIG_XFS_POSIX_ACL) += $(XFS_LINUX)/xfs_acl.o
43xfs-$(CONFIG_PROC_FS) += $(XFS_LINUX)/xfs_stats.o
44xfs-$(CONFIG_SYSCTL) += $(XFS_LINUX)/xfs_sysctl.o
45xfs-$(CONFIG_COMPAT) += $(XFS_LINUX)/xfs_ioctl32.o
46 27
28# highlevel code
29xfs-y += xfs_aops.o \
30 xfs_bit.o \
31 xfs_buf.o \
32 xfs_dfrag.o \
33 xfs_discard.o \
34 xfs_error.o \
35 xfs_export.o \
36 xfs_file.o \
37 xfs_filestream.o \
38 xfs_fsops.o \
39 xfs_fs_subr.o \
40 xfs_globals.o \
41 xfs_iget.o \
42 xfs_ioctl.o \
43 xfs_iomap.o \
44 xfs_iops.o \
45 xfs_itable.o \
46 xfs_message.o \
47 xfs_mru_cache.o \
48 xfs_super.o \
49 xfs_sync.o \
50 xfs_xattr.o \
51 xfs_rename.o \
52 xfs_rw.o \
53 xfs_utils.o \
54 xfs_vnodeops.o \
55 kmem.o \
56 uuid.o
47 57
58# code shared with libxfs
48xfs-y += xfs_alloc.o \ 59xfs-y += xfs_alloc.o \
49 xfs_alloc_btree.o \ 60 xfs_alloc_btree.o \
50 xfs_attr.o \ 61 xfs_attr.o \
51 xfs_attr_leaf.o \ 62 xfs_attr_leaf.o \
52 xfs_bit.o \
53 xfs_bmap.o \ 63 xfs_bmap.o \
54 xfs_bmap_btree.o \ 64 xfs_bmap_btree.o \
55 xfs_btree.o \ 65 xfs_btree.o \
56 xfs_buf_item.o \
57 xfs_da_btree.o \ 66 xfs_da_btree.o \
58 xfs_dir2.o \ 67 xfs_dir2.o \
59 xfs_dir2_block.o \ 68 xfs_dir2_block.o \
@@ -61,49 +70,37 @@ xfs-y += xfs_alloc.o \
61 xfs_dir2_leaf.o \ 70 xfs_dir2_leaf.o \
62 xfs_dir2_node.o \ 71 xfs_dir2_node.o \
63 xfs_dir2_sf.o \ 72 xfs_dir2_sf.o \
64 xfs_error.o \
65 xfs_extfree_item.o \
66 xfs_filestream.o \
67 xfs_fsops.o \
68 xfs_ialloc.o \ 73 xfs_ialloc.o \
69 xfs_ialloc_btree.o \ 74 xfs_ialloc_btree.o \
70 xfs_iget.o \
71 xfs_inode.o \ 75 xfs_inode.o \
72 xfs_inode_item.o \
73 xfs_iomap.o \
74 xfs_itable.o \
75 xfs_dfrag.o \
76 xfs_log.o \
77 xfs_log_cil.o \
78 xfs_log_recover.o \ 76 xfs_log_recover.o \
79 xfs_mount.o \ 77 xfs_mount.o \
80 xfs_mru_cache.o \ 78 xfs_trans.o
81 xfs_rename.o \ 79
82 xfs_trans.o \ 80# low-level transaction/log code
81xfs-y += xfs_log.o \
82 xfs_log_cil.o \
83 xfs_buf_item.o \
84 xfs_extfree_item.o \
85 xfs_inode_item.o \
83 xfs_trans_ail.o \ 86 xfs_trans_ail.o \
84 xfs_trans_buf.o \ 87 xfs_trans_buf.o \
85 xfs_trans_extfree.o \ 88 xfs_trans_extfree.o \
86 xfs_trans_inode.o \ 89 xfs_trans_inode.o \
87 xfs_utils.o \
88 xfs_vnodeops.o \
89 xfs_rw.o
90
91# Objects in linux/
92xfs-y += $(addprefix $(XFS_LINUX)/, \
93 kmem.o \
94 xfs_aops.o \
95 xfs_buf.o \
96 xfs_discard.o \
97 xfs_export.o \
98 xfs_file.o \
99 xfs_fs_subr.o \
100 xfs_globals.o \
101 xfs_ioctl.o \
102 xfs_iops.o \
103 xfs_message.o \
104 xfs_super.o \
105 xfs_sync.o \
106 xfs_xattr.o)
107 90
108# Objects in support/ 91# optional features
109xfs-y += support/uuid.o 92xfs-$(CONFIG_XFS_QUOTA) += xfs_dquot.o \
93 xfs_dquot_item.o \
94 xfs_trans_dquot.o \
95 xfs_qm_syscalls.o \
96 xfs_qm_bhv.o \
97 xfs_qm.o \
98 xfs_quotaops.o
99ifeq ($(CONFIG_XFS_QUOTA),y)
100xfs-$(CONFIG_PROC_FS) += xfs_qm_stats.o
101endif
102xfs-$(CONFIG_XFS_RT) += xfs_rtalloc.o
103xfs-$(CONFIG_XFS_POSIX_ACL) += xfs_acl.o
104xfs-$(CONFIG_PROC_FS) += xfs_stats.o
105xfs-$(CONFIG_SYSCTL) += xfs_sysctl.o
106xfs-$(CONFIG_COMPAT) += xfs_ioctl32.o
diff --git a/fs/xfs/linux-2.6/kmem.c b/fs/xfs/kmem.c
index a907de565db3..a907de565db3 100644
--- a/fs/xfs/linux-2.6/kmem.c
+++ b/fs/xfs/kmem.c
diff --git a/fs/xfs/linux-2.6/kmem.h b/fs/xfs/kmem.h
index f7c8f7a9ea6d..f7c8f7a9ea6d 100644
--- a/fs/xfs/linux-2.6/kmem.h
+++ b/fs/xfs/kmem.h
diff --git a/fs/xfs/linux-2.6/mrlock.h b/fs/xfs/mrlock.h
index ff6a19873e5c..ff6a19873e5c 100644
--- a/fs/xfs/linux-2.6/mrlock.h
+++ b/fs/xfs/mrlock.h
diff --git a/fs/xfs/linux-2.6/time.h b/fs/xfs/time.h
index 387e695a184c..387e695a184c 100644
--- a/fs/xfs/linux-2.6/time.h
+++ b/fs/xfs/time.h
diff --git a/fs/xfs/support/uuid.c b/fs/xfs/uuid.c
index b83f76b6d410..b83f76b6d410 100644
--- a/fs/xfs/support/uuid.c
+++ b/fs/xfs/uuid.c
diff --git a/fs/xfs/support/uuid.h b/fs/xfs/uuid.h
index 4732d71262cc..4732d71262cc 100644
--- a/fs/xfs/support/uuid.h
+++ b/fs/xfs/uuid.h
diff --git a/fs/xfs/xfs.h b/fs/xfs/xfs.h
index 53ec3ea9a625..d8b11b7f94aa 100644
--- a/fs/xfs/xfs.h
+++ b/fs/xfs/xfs.h
@@ -24,5 +24,6 @@
24#define XFS_BUF_LOCK_TRACKING 1 24#define XFS_BUF_LOCK_TRACKING 1
25#endif 25#endif
26 26
27#include <linux-2.6/xfs_linux.h> 27#include "xfs_linux.h"
28
28#endif /* __XFS_H__ */ 29#endif /* __XFS_H__ */
diff --git a/fs/xfs/linux-2.6/xfs_acl.c b/fs/xfs/xfs_acl.c
index b6c4b3795c4a..b6c4b3795c4a 100644
--- a/fs/xfs/linux-2.6/xfs_acl.c
+++ b/fs/xfs/xfs_acl.c
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/xfs_aops.c
index 63e971e2b837..63e971e2b837 100644
--- a/fs/xfs/linux-2.6/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
diff --git a/fs/xfs/linux-2.6/xfs_aops.h b/fs/xfs/xfs_aops.h
index 71f721e1a71f..71f721e1a71f 100644
--- a/fs/xfs/linux-2.6/xfs_aops.h
+++ b/fs/xfs/xfs_aops.h
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/xfs_buf.c
index c57836dc778f..c57836dc778f 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
diff --git a/fs/xfs/linux-2.6/xfs_buf.h b/fs/xfs/xfs_buf.h
index 620972b8094d..620972b8094d 100644
--- a/fs/xfs/linux-2.6/xfs_buf.h
+++ b/fs/xfs/xfs_buf.h
diff --git a/fs/xfs/linux-2.6/xfs_discard.c b/fs/xfs/xfs_discard.c
index 244e797dae32..244e797dae32 100644
--- a/fs/xfs/linux-2.6/xfs_discard.c
+++ b/fs/xfs/xfs_discard.c
diff --git a/fs/xfs/linux-2.6/xfs_discard.h b/fs/xfs/xfs_discard.h
index 344879aea646..344879aea646 100644
--- a/fs/xfs/linux-2.6/xfs_discard.h
+++ b/fs/xfs/xfs_discard.h
diff --git a/fs/xfs/quota/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index db62959bed13..db62959bed13 100644
--- a/fs/xfs/quota/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
diff --git a/fs/xfs/quota/xfs_dquot.h b/fs/xfs/xfs_dquot.h
index 34b7e945dbfa..34b7e945dbfa 100644
--- a/fs/xfs/quota/xfs_dquot.h
+++ b/fs/xfs/xfs_dquot.h
diff --git a/fs/xfs/quota/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c
index 9e0e2fa3f2c8..9e0e2fa3f2c8 100644
--- a/fs/xfs/quota/xfs_dquot_item.c
+++ b/fs/xfs/xfs_dquot_item.c
diff --git a/fs/xfs/quota/xfs_dquot_item.h b/fs/xfs/xfs_dquot_item.h
index 5acae2ada70b..5acae2ada70b 100644
--- a/fs/xfs/quota/xfs_dquot_item.h
+++ b/fs/xfs/xfs_dquot_item.h
diff --git a/fs/xfs/linux-2.6/xfs_export.c b/fs/xfs/xfs_export.c
index 75e5d322e48f..75e5d322e48f 100644
--- a/fs/xfs/linux-2.6/xfs_export.c
+++ b/fs/xfs/xfs_export.c
diff --git a/fs/xfs/linux-2.6/xfs_export.h b/fs/xfs/xfs_export.h
index 3272b6ae7a35..3272b6ae7a35 100644
--- a/fs/xfs/linux-2.6/xfs_export.h
+++ b/fs/xfs/xfs_export.h
diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/xfs_file.c
index 7f7b42469ea7..7f7b42469ea7 100644
--- a/fs/xfs/linux-2.6/xfs_file.c
+++ b/fs/xfs/xfs_file.c
diff --git a/fs/xfs/linux-2.6/xfs_fs_subr.c b/fs/xfs/xfs_fs_subr.c
index ed88ed16811c..ed88ed16811c 100644
--- a/fs/xfs/linux-2.6/xfs_fs_subr.c
+++ b/fs/xfs/xfs_fs_subr.c
diff --git a/fs/xfs/linux-2.6/xfs_globals.c b/fs/xfs/xfs_globals.c
index 76e81cff70b9..76e81cff70b9 100644
--- a/fs/xfs/linux-2.6/xfs_globals.c
+++ b/fs/xfs/xfs_globals.c
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index f7ce7debe14c..f7ce7debe14c 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.h b/fs/xfs/xfs_ioctl.h
index d56173b34a2a..d56173b34a2a 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl.h
+++ b/fs/xfs/xfs_ioctl.h
diff --git a/fs/xfs/linux-2.6/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c
index 54e623bfbb85..54e623bfbb85 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl32.c
+++ b/fs/xfs/xfs_ioctl32.c
diff --git a/fs/xfs/linux-2.6/xfs_ioctl32.h b/fs/xfs/xfs_ioctl32.h
index 80f4060e8970..80f4060e8970 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl32.h
+++ b/fs/xfs/xfs_ioctl32.h
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/xfs_iops.c
index b9c172b3fbbe..b9c172b3fbbe 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
diff --git a/fs/xfs/linux-2.6/xfs_iops.h b/fs/xfs/xfs_iops.h
index ef41c92ce66e..ef41c92ce66e 100644
--- a/fs/xfs/linux-2.6/xfs_iops.h
+++ b/fs/xfs/xfs_iops.h
diff --git a/fs/xfs/linux-2.6/xfs_linux.h b/fs/xfs/xfs_linux.h
index d42f814e4d35..1e8a45e74c3e 100644
--- a/fs/xfs/linux-2.6/xfs_linux.h
+++ b/fs/xfs/xfs_linux.h
@@ -32,13 +32,12 @@
32# define XFS_BIG_INUMS 0 32# define XFS_BIG_INUMS 0
33#endif 33#endif
34 34
35#include <xfs_types.h> 35#include "xfs_types.h"
36 36
37#include <kmem.h> 37#include "kmem.h"
38#include <mrlock.h> 38#include "mrlock.h"
39#include <time.h> 39#include "time.h"
40 40#include "uuid.h"
41#include <support/uuid.h>
42 41
43#include <linux/semaphore.h> 42#include <linux/semaphore.h>
44#include <linux/mm.h> 43#include <linux/mm.h>
@@ -78,14 +77,14 @@
78#include <asm/byteorder.h> 77#include <asm/byteorder.h>
79#include <asm/unaligned.h> 78#include <asm/unaligned.h>
80 79
81#include <xfs_vnode.h> 80#include "xfs_vnode.h"
82#include <xfs_stats.h> 81#include "xfs_stats.h"
83#include <xfs_sysctl.h> 82#include "xfs_sysctl.h"
84#include <xfs_iops.h> 83#include "xfs_iops.h"
85#include <xfs_aops.h> 84#include "xfs_aops.h"
86#include <xfs_super.h> 85#include "xfs_super.h"
87#include <xfs_buf.h> 86#include "xfs_buf.h"
88#include <xfs_message.h> 87#include "xfs_message.h"
89 88
90#ifdef __BIG_ENDIAN 89#ifdef __BIG_ENDIAN
91#define XFS_NATIVE_HOST 1 90#define XFS_NATIVE_HOST 1
diff --git a/fs/xfs/linux-2.6/xfs_message.c b/fs/xfs/xfs_message.c
index bd672def95ac..bd672def95ac 100644
--- a/fs/xfs/linux-2.6/xfs_message.c
+++ b/fs/xfs/xfs_message.c
diff --git a/fs/xfs/linux-2.6/xfs_message.h b/fs/xfs/xfs_message.h
index 7fb7ea007672..7fb7ea007672 100644
--- a/fs/xfs/linux-2.6/xfs_message.h
+++ b/fs/xfs/xfs_message.h
diff --git a/fs/xfs/quota/xfs_qm.c b/fs/xfs/xfs_qm.c
index 9a0aa76facdf..9a0aa76facdf 100644
--- a/fs/xfs/quota/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
diff --git a/fs/xfs/quota/xfs_qm.h b/fs/xfs/xfs_qm.h
index 43b9abe1052c..43b9abe1052c 100644
--- a/fs/xfs/quota/xfs_qm.h
+++ b/fs/xfs/xfs_qm.h
diff --git a/fs/xfs/quota/xfs_qm_bhv.c b/fs/xfs/xfs_qm_bhv.c
index a0a829addca9..a0a829addca9 100644
--- a/fs/xfs/quota/xfs_qm_bhv.c
+++ b/fs/xfs/xfs_qm_bhv.c
diff --git a/fs/xfs/quota/xfs_qm_stats.c b/fs/xfs/xfs_qm_stats.c
index 8671a0b32644..8671a0b32644 100644
--- a/fs/xfs/quota/xfs_qm_stats.c
+++ b/fs/xfs/xfs_qm_stats.c
diff --git a/fs/xfs/quota/xfs_qm_stats.h b/fs/xfs/xfs_qm_stats.h
index 5b964fc0dc09..5b964fc0dc09 100644
--- a/fs/xfs/quota/xfs_qm_stats.h
+++ b/fs/xfs/xfs_qm_stats.h
diff --git a/fs/xfs/quota/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c
index 609246f42e6c..609246f42e6c 100644
--- a/fs/xfs/quota/xfs_qm_syscalls.c
+++ b/fs/xfs/xfs_qm_syscalls.c
diff --git a/fs/xfs/quota/xfs_quota_priv.h b/fs/xfs/xfs_quota_priv.h
index 94a3d927d716..94a3d927d716 100644
--- a/fs/xfs/quota/xfs_quota_priv.h
+++ b/fs/xfs/xfs_quota_priv.h
diff --git a/fs/xfs/linux-2.6/xfs_quotaops.c b/fs/xfs/xfs_quotaops.c
index 29b9d642e93d..7e76f537abb7 100644
--- a/fs/xfs/linux-2.6/xfs_quotaops.c
+++ b/fs/xfs/xfs_quotaops.c
@@ -25,7 +25,7 @@
25#include "xfs_trans.h" 25#include "xfs_trans.h"
26#include "xfs_bmap_btree.h" 26#include "xfs_bmap_btree.h"
27#include "xfs_inode.h" 27#include "xfs_inode.h"
28#include "quota/xfs_qm.h" 28#include "xfs_qm.h"
29#include <linux/quota.h> 29#include <linux/quota.h>
30 30
31 31
diff --git a/fs/xfs/linux-2.6/xfs_stats.c b/fs/xfs/xfs_stats.c
index 76fdc5861932..76fdc5861932 100644
--- a/fs/xfs/linux-2.6/xfs_stats.c
+++ b/fs/xfs/xfs_stats.c
diff --git a/fs/xfs/linux-2.6/xfs_stats.h b/fs/xfs/xfs_stats.h
index 736854b1ca1a..736854b1ca1a 100644
--- a/fs/xfs/linux-2.6/xfs_stats.h
+++ b/fs/xfs/xfs_stats.h
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/xfs_super.c
index 9a72dda58bd0..9a72dda58bd0 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/xfs_super.c
diff --git a/fs/xfs/linux-2.6/xfs_super.h b/fs/xfs/xfs_super.h
index 50a3266c999e..50a3266c999e 100644
--- a/fs/xfs/linux-2.6/xfs_super.h
+++ b/fs/xfs/xfs_super.h
diff --git a/fs/xfs/linux-2.6/xfs_sync.c b/fs/xfs/xfs_sync.c
index 4604f90f86a3..4604f90f86a3 100644
--- a/fs/xfs/linux-2.6/xfs_sync.c
+++ b/fs/xfs/xfs_sync.c
diff --git a/fs/xfs/linux-2.6/xfs_sync.h b/fs/xfs/xfs_sync.h
index 941202e7ac6e..941202e7ac6e 100644
--- a/fs/xfs/linux-2.6/xfs_sync.h
+++ b/fs/xfs/xfs_sync.h
diff --git a/fs/xfs/linux-2.6/xfs_sysctl.c b/fs/xfs/xfs_sysctl.c
index ee2d2adaa438..ee2d2adaa438 100644
--- a/fs/xfs/linux-2.6/xfs_sysctl.c
+++ b/fs/xfs/xfs_sysctl.c
diff --git a/fs/xfs/linux-2.6/xfs_sysctl.h b/fs/xfs/xfs_sysctl.h
index b9937d450f8e..b9937d450f8e 100644
--- a/fs/xfs/linux-2.6/xfs_sysctl.h
+++ b/fs/xfs/xfs_sysctl.h
diff --git a/fs/xfs/linux-2.6/xfs_trace.c b/fs/xfs/xfs_trace.c
index 88d25d4aa56e..9010ce885e6a 100644
--- a/fs/xfs/linux-2.6/xfs_trace.c
+++ b/fs/xfs/xfs_trace.c
@@ -43,8 +43,8 @@
43#include "xfs_quota.h" 43#include "xfs_quota.h"
44#include "xfs_iomap.h" 44#include "xfs_iomap.h"
45#include "xfs_aops.h" 45#include "xfs_aops.h"
46#include "quota/xfs_dquot_item.h" 46#include "xfs_dquot_item.h"
47#include "quota/xfs_dquot.h" 47#include "xfs_dquot.h"
48#include "xfs_log_recover.h" 48#include "xfs_log_recover.h"
49#include "xfs_inode_item.h" 49#include "xfs_inode_item.h"
50 50
diff --git a/fs/xfs/linux-2.6/xfs_trace.h b/fs/xfs/xfs_trace.h
index 690fc7a7bd72..690fc7a7bd72 100644
--- a/fs/xfs/linux-2.6/xfs_trace.h
+++ b/fs/xfs/xfs_trace.h
diff --git a/fs/xfs/quota/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c
index 4d00ee67792d..4d00ee67792d 100644
--- a/fs/xfs/quota/xfs_trans_dquot.c
+++ b/fs/xfs/xfs_trans_dquot.c
diff --git a/fs/xfs/linux-2.6/xfs_vnode.h b/fs/xfs/xfs_vnode.h
index 7c220b4227bc..7c220b4227bc 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.h
+++ b/fs/xfs/xfs_vnode.h
diff --git a/fs/xfs/linux-2.6/xfs_xattr.c b/fs/xfs/xfs_xattr.c
index 87d3e03878c8..87d3e03878c8 100644
--- a/fs/xfs/linux-2.6/xfs_xattr.c
+++ b/fs/xfs/xfs_xattr.c
diff --git a/include/linux/connector.h b/include/linux/connector.h
index 0c69ad825b39..3c9c54fd5690 100644
--- a/include/linux/connector.h
+++ b/include/linux/connector.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * connector.h 2 * connector.h
3 * 3 *
4 * 2004-2005 Copyright (c) Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * 2004-2005 Copyright (c) Evgeniy Polyakov <zbr@ioremap.net>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 178cdb4f1d4a..c2bd68f2277a 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2318,6 +2318,11 @@ extern struct inode * iget5_locked(struct super_block *, unsigned long, int (*te
2318extern struct inode * iget_locked(struct super_block *, unsigned long); 2318extern struct inode * iget_locked(struct super_block *, unsigned long);
2319extern int insert_inode_locked4(struct inode *, unsigned long, int (*test)(struct inode *, void *), void *); 2319extern int insert_inode_locked4(struct inode *, unsigned long, int (*test)(struct inode *, void *), void *);
2320extern int insert_inode_locked(struct inode *); 2320extern int insert_inode_locked(struct inode *);
2321#ifdef CONFIG_DEBUG_LOCK_ALLOC
2322extern void lockdep_annotate_inode_mutex_key(struct inode *inode);
2323#else
2324static inline void lockdep_annotate_inode_mutex_key(struct inode *inode) { };
2325#endif
2321extern void unlock_new_inode(struct inode *); 2326extern void unlock_new_inode(struct inode *);
2322extern unsigned int get_next_ino(void); 2327extern unsigned int get_next_ino(void);
2323 2328
diff --git a/include/linux/fuse.h b/include/linux/fuse.h
index d464de53db43..464cff526860 100644
--- a/include/linux/fuse.h
+++ b/include/linux/fuse.h
@@ -47,6 +47,9 @@
47 * - FUSE_IOCTL_UNRESTRICTED shall now return with array of 'struct 47 * - FUSE_IOCTL_UNRESTRICTED shall now return with array of 'struct
48 * fuse_ioctl_iovec' instead of ambiguous 'struct iovec' 48 * fuse_ioctl_iovec' instead of ambiguous 'struct iovec'
49 * - add FUSE_IOCTL_32BIT flag 49 * - add FUSE_IOCTL_32BIT flag
50 *
51 * 7.17
52 * - add FUSE_FLOCK_LOCKS and FUSE_RELEASE_FLOCK_UNLOCK
50 */ 53 */
51 54
52#ifndef _LINUX_FUSE_H 55#ifndef _LINUX_FUSE_H
@@ -78,7 +81,7 @@
78#define FUSE_KERNEL_VERSION 7 81#define FUSE_KERNEL_VERSION 7
79 82
80/** Minor version number of this interface */ 83/** Minor version number of this interface */
81#define FUSE_KERNEL_MINOR_VERSION 16 84#define FUSE_KERNEL_MINOR_VERSION 17
82 85
83/** The node ID of the root inode */ 86/** The node ID of the root inode */
84#define FUSE_ROOT_ID 1 87#define FUSE_ROOT_ID 1
@@ -153,8 +156,10 @@ struct fuse_file_lock {
153/** 156/**
154 * INIT request/reply flags 157 * INIT request/reply flags
155 * 158 *
159 * FUSE_POSIX_LOCKS: remote locking for POSIX file locks
156 * FUSE_EXPORT_SUPPORT: filesystem handles lookups of "." and ".." 160 * FUSE_EXPORT_SUPPORT: filesystem handles lookups of "." and ".."
157 * FUSE_DONT_MASK: don't apply umask to file mode on create operations 161 * FUSE_DONT_MASK: don't apply umask to file mode on create operations
162 * FUSE_FLOCK_LOCKS: remote locking for BSD style file locks
158 */ 163 */
159#define FUSE_ASYNC_READ (1 << 0) 164#define FUSE_ASYNC_READ (1 << 0)
160#define FUSE_POSIX_LOCKS (1 << 1) 165#define FUSE_POSIX_LOCKS (1 << 1)
@@ -163,6 +168,7 @@ struct fuse_file_lock {
163#define FUSE_EXPORT_SUPPORT (1 << 4) 168#define FUSE_EXPORT_SUPPORT (1 << 4)
164#define FUSE_BIG_WRITES (1 << 5) 169#define FUSE_BIG_WRITES (1 << 5)
165#define FUSE_DONT_MASK (1 << 6) 170#define FUSE_DONT_MASK (1 << 6)
171#define FUSE_FLOCK_LOCKS (1 << 10)
166 172
167/** 173/**
168 * CUSE INIT request/reply flags 174 * CUSE INIT request/reply flags
@@ -175,6 +181,7 @@ struct fuse_file_lock {
175 * Release flags 181 * Release flags
176 */ 182 */
177#define FUSE_RELEASE_FLUSH (1 << 0) 183#define FUSE_RELEASE_FLUSH (1 << 0)
184#define FUSE_RELEASE_FLOCK_UNLOCK (1 << 1)
178 185
179/** 186/**
180 * Getattr flags 187 * Getattr flags
diff --git a/include/linux/personality.h b/include/linux/personality.h
index eec3bae164d4..8fc7dd1a57ff 100644
--- a/include/linux/personality.h
+++ b/include/linux/personality.h
@@ -22,6 +22,7 @@ extern int __set_personality(unsigned int);
22 * These occupy the top three bytes. 22 * These occupy the top three bytes.
23 */ 23 */
24enum { 24enum {
25 UNAME26 = 0x0020000,
25 ADDR_NO_RANDOMIZE = 0x0040000, /* disable randomization of VA space */ 26 ADDR_NO_RANDOMIZE = 0x0040000, /* disable randomization of VA space */
26 FDPIC_FUNCPTRS = 0x0080000, /* userspace function ptrs point to descriptors 27 FDPIC_FUNCPTRS = 0x0080000, /* userspace function ptrs point to descriptors
27 * (signal handling) 28 * (signal handling)
diff --git a/include/linux/pwm_backlight.h b/include/linux/pwm_backlight.h
index 5e3e25a3c9c3..63d2df43e61a 100644
--- a/include/linux/pwm_backlight.h
+++ b/include/linux/pwm_backlight.h
@@ -14,6 +14,7 @@ struct platform_pwm_backlight_data {
14 unsigned int pwm_period_ns; 14 unsigned int pwm_period_ns;
15 int (*init)(struct device *dev); 15 int (*init)(struct device *dev);
16 int (*notify)(struct device *dev, int brightness); 16 int (*notify)(struct device *dev, int brightness);
17 void (*notify_after)(struct device *dev, int brightness);
17 void (*exit)(struct device *dev); 18 void (*exit)(struct device *dev);
18 int (*check_fb)(struct device *dev, struct fb_info *info); 19 int (*check_fb)(struct device *dev, struct fb_info *info);
19}; 20};
diff --git a/include/linux/rio_regs.h b/include/linux/rio_regs.h
index 9026b30238f3..218168a2b5e9 100644
--- a/include/linux/rio_regs.h
+++ b/include/linux/rio_regs.h
@@ -36,12 +36,12 @@
36#define RIO_PEF_PROCESSOR 0x20000000 /* [I] Processor */ 36#define RIO_PEF_PROCESSOR 0x20000000 /* [I] Processor */
37#define RIO_PEF_SWITCH 0x10000000 /* [I] Switch */ 37#define RIO_PEF_SWITCH 0x10000000 /* [I] Switch */
38#define RIO_PEF_MULTIPORT 0x08000000 /* [VI, 2.1] Multiport */ 38#define RIO_PEF_MULTIPORT 0x08000000 /* [VI, 2.1] Multiport */
39#define RIO_PEF_INB_MBOX 0x00f00000 /* [II] Mailboxes */ 39#define RIO_PEF_INB_MBOX 0x00f00000 /* [II, <= 1.2] Mailboxes */
40#define RIO_PEF_INB_MBOX0 0x00800000 /* [II] Mailbox 0 */ 40#define RIO_PEF_INB_MBOX0 0x00800000 /* [II, <= 1.2] Mailbox 0 */
41#define RIO_PEF_INB_MBOX1 0x00400000 /* [II] Mailbox 1 */ 41#define RIO_PEF_INB_MBOX1 0x00400000 /* [II, <= 1.2] Mailbox 1 */
42#define RIO_PEF_INB_MBOX2 0x00200000 /* [II] Mailbox 2 */ 42#define RIO_PEF_INB_MBOX2 0x00200000 /* [II, <= 1.2] Mailbox 2 */
43#define RIO_PEF_INB_MBOX3 0x00100000 /* [II] Mailbox 3 */ 43#define RIO_PEF_INB_MBOX3 0x00100000 /* [II, <= 1.2] Mailbox 3 */
44#define RIO_PEF_INB_DOORBELL 0x00080000 /* [II] Doorbells */ 44#define RIO_PEF_INB_DOORBELL 0x00080000 /* [II, <= 1.2] Doorbells */
45#define RIO_PEF_EXT_RT 0x00000200 /* [III, 1.3] Extended route table support */ 45#define RIO_PEF_EXT_RT 0x00000200 /* [III, 1.3] Extended route table support */
46#define RIO_PEF_STD_RT 0x00000100 /* [III, 1.3] Standard route table support */ 46#define RIO_PEF_STD_RT 0x00000100 /* [III, 1.3] Standard route table support */
47#define RIO_PEF_CTLS 0x00000010 /* [III] CTLS */ 47#define RIO_PEF_CTLS 0x00000010 /* [III] CTLS */
@@ -102,7 +102,7 @@
102#define RIO_SWITCH_RT_LIMIT 0x34 /* [III, 1.3] Switch Route Table Destination ID Limit CAR */ 102#define RIO_SWITCH_RT_LIMIT 0x34 /* [III, 1.3] Switch Route Table Destination ID Limit CAR */
103#define RIO_RT_MAX_DESTID 0x0000ffff 103#define RIO_RT_MAX_DESTID 0x0000ffff
104 104
105#define RIO_MBOX_CSR 0x40 /* [II] Mailbox CSR */ 105#define RIO_MBOX_CSR 0x40 /* [II, <= 1.2] Mailbox CSR */
106#define RIO_MBOX0_AVAIL 0x80000000 /* [II] Mbox 0 avail */ 106#define RIO_MBOX0_AVAIL 0x80000000 /* [II] Mbox 0 avail */
107#define RIO_MBOX0_FULL 0x40000000 /* [II] Mbox 0 full */ 107#define RIO_MBOX0_FULL 0x40000000 /* [II] Mbox 0 full */
108#define RIO_MBOX0_EMPTY 0x20000000 /* [II] Mbox 0 empty */ 108#define RIO_MBOX0_EMPTY 0x20000000 /* [II] Mbox 0 empty */
@@ -128,8 +128,8 @@
128#define RIO_MBOX3_FAIL 0x00000008 /* [II] Mbox 3 fail */ 128#define RIO_MBOX3_FAIL 0x00000008 /* [II] Mbox 3 fail */
129#define RIO_MBOX3_ERROR 0x00000004 /* [II] Mbox 3 error */ 129#define RIO_MBOX3_ERROR 0x00000004 /* [II] Mbox 3 error */
130 130
131#define RIO_WRITE_PORT_CSR 0x44 /* [I] Write Port CSR */ 131#define RIO_WRITE_PORT_CSR 0x44 /* [I, <= 1.2] Write Port CSR */
132#define RIO_DOORBELL_CSR 0x44 /* [II] Doorbell CSR */ 132#define RIO_DOORBELL_CSR 0x44 /* [II, <= 1.2] Doorbell CSR */
133#define RIO_DOORBELL_AVAIL 0x80000000 /* [II] Doorbell avail */ 133#define RIO_DOORBELL_AVAIL 0x80000000 /* [II] Doorbell avail */
134#define RIO_DOORBELL_FULL 0x40000000 /* [II] Doorbell full */ 134#define RIO_DOORBELL_FULL 0x40000000 /* [II] Doorbell full */
135#define RIO_DOORBELL_EMPTY 0x20000000 /* [II] Doorbell empty */ 135#define RIO_DOORBELL_EMPTY 0x20000000 /* [II] Doorbell empty */
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index f1bfa12ea246..2b8963ff0f35 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -12,15 +12,6 @@
12 * 12 *
13 * (thresh - thresh/DIRTY_FULL_SCOPE, thresh) 13 * (thresh - thresh/DIRTY_FULL_SCOPE, thresh)
14 * 14 *
15 * The 1/16 region above the global dirty limit will be put to maximum pauses:
16 *
17 * (limit, limit + limit/DIRTY_MAXPAUSE_AREA)
18 *
19 * The 1/16 region above the max-pause region, dirty exceeded bdi's will be put
20 * to loops:
21 *
22 * (limit + limit/DIRTY_MAXPAUSE_AREA, limit + limit/DIRTY_PASSGOOD_AREA)
23 *
24 * Further beyond, all dirtier tasks will enter a loop waiting (possibly long 15 * Further beyond, all dirtier tasks will enter a loop waiting (possibly long
25 * time) for the dirty pages to drop, unless written enough pages. 16 * time) for the dirty pages to drop, unless written enough pages.
26 * 17 *
@@ -31,8 +22,6 @@
31 */ 22 */
32#define DIRTY_SCOPE 8 23#define DIRTY_SCOPE 8
33#define DIRTY_FULL_SCOPE (DIRTY_SCOPE / 2) 24#define DIRTY_FULL_SCOPE (DIRTY_SCOPE / 2)
34#define DIRTY_MAXPAUSE_AREA 16
35#define DIRTY_PASSGOOD_AREA 8
36 25
37/* 26/*
38 * 4MB minimal write chunk size 27 * 4MB minimal write chunk size
diff --git a/include/target/target_core_fabric_ops.h b/include/target/target_core_fabric_ops.h
index 2de8fe907596..126c675f4f14 100644
--- a/include/target/target_core_fabric_ops.h
+++ b/include/target/target_core_fabric_ops.h
@@ -27,6 +27,12 @@ struct target_core_fabric_ops {
27 int (*tpg_check_demo_mode_cache)(struct se_portal_group *); 27 int (*tpg_check_demo_mode_cache)(struct se_portal_group *);
28 int (*tpg_check_demo_mode_write_protect)(struct se_portal_group *); 28 int (*tpg_check_demo_mode_write_protect)(struct se_portal_group *);
29 int (*tpg_check_prod_mode_write_protect)(struct se_portal_group *); 29 int (*tpg_check_prod_mode_write_protect)(struct se_portal_group *);
30 /*
31 * Optionally used by fabrics to allow demo-mode login, but not
32 * expose any TPG LUNs, and return 'not connected' in standard
33 * inquiry response
34 */
35 int (*tpg_check_demo_mode_login_only)(struct se_portal_group *);
30 struct se_node_acl *(*tpg_alloc_fabric_acl)( 36 struct se_node_acl *(*tpg_alloc_fabric_acl)(
31 struct se_portal_group *); 37 struct se_portal_group *);
32 void (*tpg_release_fabric_acl)(struct se_portal_group *, 38 void (*tpg_release_fabric_acl)(struct se_portal_group *,
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 2e9425889fa8..9b956fa20308 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -1331,7 +1331,6 @@ int request_threaded_irq(unsigned int irq, irq_handler_t handler,
1331 if (!thread_fn) 1331 if (!thread_fn)
1332 return -EINVAL; 1332 return -EINVAL;
1333 handler = irq_default_primary_handler; 1333 handler = irq_default_primary_handler;
1334 irqflags |= IRQF_ONESHOT;
1335 } 1334 }
1336 1335
1337 action = kzalloc(sizeof(struct irqaction), GFP_KERNEL); 1336 action = kzalloc(sizeof(struct irqaction), GFP_KERNEL);
diff --git a/kernel/printk.c b/kernel/printk.c
index 836a2ae0ac31..28a40d8171b8 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -1604,7 +1604,7 @@ static int __init printk_late_init(void)
1604 struct console *con; 1604 struct console *con;
1605 1605
1606 for_each_console(con) { 1606 for_each_console(con) {
1607 if (con->flags & CON_BOOT) { 1607 if (!keep_bootcon && con->flags & CON_BOOT) {
1608 printk(KERN_INFO "turn off boot console %s%d\n", 1608 printk(KERN_INFO "turn off boot console %s%d\n",
1609 con->name, con->index); 1609 con->name, con->index);
1610 unregister_console(con); 1610 unregister_console(con);
diff --git a/kernel/sys.c b/kernel/sys.c
index dd948a1fca4c..18ee1d2f6474 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -37,6 +37,8 @@
37#include <linux/fs_struct.h> 37#include <linux/fs_struct.h>
38#include <linux/gfp.h> 38#include <linux/gfp.h>
39#include <linux/syscore_ops.h> 39#include <linux/syscore_ops.h>
40#include <linux/version.h>
41#include <linux/ctype.h>
40 42
41#include <linux/compat.h> 43#include <linux/compat.h>
42#include <linux/syscalls.h> 44#include <linux/syscalls.h>
@@ -44,6 +46,8 @@
44#include <linux/user_namespace.h> 46#include <linux/user_namespace.h>
45 47
46#include <linux/kmsg_dump.h> 48#include <linux/kmsg_dump.h>
49/* Move somewhere else to avoid recompiling? */
50#include <generated/utsrelease.h>
47 51
48#include <asm/uaccess.h> 52#include <asm/uaccess.h>
49#include <asm/io.h> 53#include <asm/io.h>
@@ -1161,6 +1165,34 @@ DECLARE_RWSEM(uts_sem);
1161#define override_architecture(name) 0 1165#define override_architecture(name) 0
1162#endif 1166#endif
1163 1167
1168/*
1169 * Work around broken programs that cannot handle "Linux 3.0".
1170 * Instead we map 3.x to 2.6.40+x, so e.g. 3.0 would be 2.6.40
1171 */
1172static int override_release(char __user *release, int len)
1173{
1174 int ret = 0;
1175 char buf[len];
1176
1177 if (current->personality & UNAME26) {
1178 char *rest = UTS_RELEASE;
1179 int ndots = 0;
1180 unsigned v;
1181
1182 while (*rest) {
1183 if (*rest == '.' && ++ndots >= 3)
1184 break;
1185 if (!isdigit(*rest) && *rest != '.')
1186 break;
1187 rest++;
1188 }
1189 v = ((LINUX_VERSION_CODE >> 8) & 0xff) + 40;
1190 snprintf(buf, len, "2.6.%u%s", v, rest);
1191 ret = copy_to_user(release, buf, len);
1192 }
1193 return ret;
1194}
1195
1164SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name) 1196SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name)
1165{ 1197{
1166 int errno = 0; 1198 int errno = 0;
@@ -1170,6 +1202,8 @@ SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name)
1170 errno = -EFAULT; 1202 errno = -EFAULT;
1171 up_read(&uts_sem); 1203 up_read(&uts_sem);
1172 1204
1205 if (!errno && override_release(name->release, sizeof(name->release)))
1206 errno = -EFAULT;
1173 if (!errno && override_architecture(name)) 1207 if (!errno && override_architecture(name))
1174 errno = -EFAULT; 1208 errno = -EFAULT;
1175 return errno; 1209 return errno;
@@ -1191,6 +1225,8 @@ SYSCALL_DEFINE1(uname, struct old_utsname __user *, name)
1191 error = -EFAULT; 1225 error = -EFAULT;
1192 up_read(&uts_sem); 1226 up_read(&uts_sem);
1193 1227
1228 if (!error && override_release(name->release, sizeof(name->release)))
1229 error = -EFAULT;
1194 if (!error && override_architecture(name)) 1230 if (!error && override_architecture(name))
1195 error = -EFAULT; 1231 error = -EFAULT;
1196 return error; 1232 return error;
@@ -1225,6 +1261,8 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
1225 1261
1226 if (!error && override_architecture(name)) 1262 if (!error && override_architecture(name))
1227 error = -EFAULT; 1263 error = -EFAULT;
1264 if (!error && override_release(name->release, sizeof(name->release)))
1265 error = -EFAULT;
1228 return error ? -EFAULT : 0; 1266 return error ? -EFAULT : 0;
1229} 1267}
1230#endif 1268#endif
diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c
index 3b8e028b9601..e8bffbe2ba4b 100644
--- a/kernel/sysctl_binary.c
+++ b/kernel/sysctl_binary.c
@@ -1,6 +1,6 @@
1#include <linux/stat.h> 1#include <linux/stat.h>
2#include <linux/sysctl.h> 2#include <linux/sysctl.h>
3#include "../fs/xfs/linux-2.6/xfs_sysctl.h" 3#include "../fs/xfs/xfs_sysctl.h"
4#include <linux/sunrpc/debug.h> 4#include <linux/sunrpc/debug.h>
5#include <linux/string.h> 5#include <linux/string.h>
6#include <net/ip_vs.h> 6#include <net/ip_vs.h>
diff --git a/kernel/sysctl_check.c b/kernel/sysctl_check.c
index 4e4932a7b360..362da653813d 100644
--- a/kernel/sysctl_check.c
+++ b/kernel/sysctl_check.c
@@ -1,6 +1,6 @@
1#include <linux/stat.h> 1#include <linux/stat.h>
2#include <linux/sysctl.h> 2#include <linux/sysctl.h>
3#include "../fs/xfs/linux-2.6/xfs_sysctl.h" 3#include "../fs/xfs/xfs_sysctl.h"
4#include <linux/sunrpc/debug.h> 4#include <linux/sunrpc/debug.h>
5#include <linux/string.h> 5#include <linux/string.h>
6#include <net/ip_vs.h> 6#include <net/ip_vs.h>
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 930de9437271..ebd1e86bef1c 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1841,29 +1841,23 @@ static int mem_cgroup_hierarchical_reclaim(struct mem_cgroup *root_mem,
1841 */ 1841 */
1842static bool mem_cgroup_oom_lock(struct mem_cgroup *mem) 1842static bool mem_cgroup_oom_lock(struct mem_cgroup *mem)
1843{ 1843{
1844 int lock_count = -1;
1845 struct mem_cgroup *iter, *failed = NULL; 1844 struct mem_cgroup *iter, *failed = NULL;
1846 bool cond = true; 1845 bool cond = true;
1847 1846
1848 for_each_mem_cgroup_tree_cond(iter, mem, cond) { 1847 for_each_mem_cgroup_tree_cond(iter, mem, cond) {
1849 bool locked = iter->oom_lock; 1848 if (iter->oom_lock) {
1850
1851 iter->oom_lock = true;
1852 if (lock_count == -1)
1853 lock_count = iter->oom_lock;
1854 else if (lock_count != locked) {
1855 /* 1849 /*
1856 * this subtree of our hierarchy is already locked 1850 * this subtree of our hierarchy is already locked
1857 * so we cannot give a lock. 1851 * so we cannot give a lock.
1858 */ 1852 */
1859 lock_count = 0;
1860 failed = iter; 1853 failed = iter;
1861 cond = false; 1854 cond = false;
1862 } 1855 } else
1856 iter->oom_lock = true;
1863 } 1857 }
1864 1858
1865 if (!failed) 1859 if (!failed)
1866 goto done; 1860 return true;
1867 1861
1868 /* 1862 /*
1869 * OK, we failed to lock the whole subtree so we have to clean up 1863 * OK, we failed to lock the whole subtree so we have to clean up
@@ -1877,8 +1871,7 @@ static bool mem_cgroup_oom_lock(struct mem_cgroup *mem)
1877 } 1871 }
1878 iter->oom_lock = false; 1872 iter->oom_lock = false;
1879 } 1873 }
1880done: 1874 return false;
1881 return lock_count;
1882} 1875}
1883 1876
1884/* 1877/*
@@ -2169,13 +2162,7 @@ static void drain_all_stock(struct mem_cgroup *root_mem, bool sync)
2169 2162
2170 /* Notify other cpus that system-wide "drain" is running */ 2163 /* Notify other cpus that system-wide "drain" is running */
2171 get_online_cpus(); 2164 get_online_cpus();
2172 /* 2165 curcpu = get_cpu();
2173 * Get a hint for avoiding draining charges on the current cpu,
2174 * which must be exhausted by our charging. It is not required that
2175 * this be a precise check, so we use raw_smp_processor_id() instead of
2176 * getcpu()/putcpu().
2177 */
2178 curcpu = raw_smp_processor_id();
2179 for_each_online_cpu(cpu) { 2166 for_each_online_cpu(cpu) {
2180 struct memcg_stock_pcp *stock = &per_cpu(memcg_stock, cpu); 2167 struct memcg_stock_pcp *stock = &per_cpu(memcg_stock, cpu);
2181 struct mem_cgroup *mem; 2168 struct mem_cgroup *mem;
@@ -2192,6 +2179,7 @@ static void drain_all_stock(struct mem_cgroup *root_mem, bool sync)
2192 schedule_work_on(cpu, &stock->work); 2179 schedule_work_on(cpu, &stock->work);
2193 } 2180 }
2194 } 2181 }
2182 put_cpu();
2195 2183
2196 if (!sync) 2184 if (!sync)
2197 goto out; 2185 goto out;
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index d1960744f881..0e309cd1b5b9 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -754,21 +754,10 @@ static void balance_dirty_pages(struct address_space *mapping,
754 * 200ms is typically more than enough to curb heavy dirtiers; 754 * 200ms is typically more than enough to curb heavy dirtiers;
755 * (b) the pause time limit makes the dirtiers more responsive. 755 * (b) the pause time limit makes the dirtiers more responsive.
756 */ 756 */
757 if (nr_dirty < dirty_thresh + 757 if (nr_dirty < dirty_thresh &&
758 dirty_thresh / DIRTY_MAXPAUSE_AREA && 758 bdi_dirty < (task_bdi_thresh + bdi_thresh) / 2 &&
759 time_after(jiffies, start_time + MAX_PAUSE)) 759 time_after(jiffies, start_time + MAX_PAUSE))
760 break; 760 break;
761 /*
762 * pass-good area. When some bdi gets blocked (eg. NFS server
763 * not responding), or write bandwidth dropped dramatically due
764 * to concurrent reads, or dirty threshold suddenly dropped and
765 * the dirty pages cannot be brought down anytime soon (eg. on
766 * slow USB stick), at least let go of the good bdi's.
767 */
768 if (nr_dirty < dirty_thresh +
769 dirty_thresh / DIRTY_PASSGOOD_AREA &&
770 bdi_dirty < bdi_thresh)
771 break;
772 761
773 /* 762 /*
774 * Increase the delay for each loop, up to our previous 763 * Increase the delay for each loop, up to our previous
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 7ef69124fa3e..b7719ec10dc5 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2283,7 +2283,7 @@ unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem,
2283 .mem_cgroup = mem, 2283 .mem_cgroup = mem,
2284 .memcg_record = rec, 2284 .memcg_record = rec,
2285 }; 2285 };
2286 unsigned long start, end; 2286 ktime_t start, end;
2287 2287
2288 sc.gfp_mask = (gfp_mask & GFP_RECLAIM_MASK) | 2288 sc.gfp_mask = (gfp_mask & GFP_RECLAIM_MASK) |
2289 (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK); 2289 (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK);
@@ -2292,7 +2292,7 @@ unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem,
2292 sc.may_writepage, 2292 sc.may_writepage,
2293 sc.gfp_mask); 2293 sc.gfp_mask);
2294 2294
2295 start = sched_clock(); 2295 start = ktime_get();
2296 /* 2296 /*
2297 * NOTE: Although we can get the priority field, using it 2297 * NOTE: Although we can get the priority field, using it
2298 * here is not a good idea, since it limits the pages we can scan. 2298 * here is not a good idea, since it limits the pages we can scan.
@@ -2301,10 +2301,10 @@ unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem,
2301 * the priority and make it zero. 2301 * the priority and make it zero.
2302 */ 2302 */
2303 shrink_zone(0, zone, &sc); 2303 shrink_zone(0, zone, &sc);
2304 end = sched_clock(); 2304 end = ktime_get();
2305 2305
2306 if (rec) 2306 if (rec)
2307 rec->elapsed += end - start; 2307 rec->elapsed += ktime_to_ns(ktime_sub(end, start));
2308 *scanned = sc.nr_scanned; 2308 *scanned = sc.nr_scanned;
2309 2309
2310 trace_mm_vmscan_memcg_softlimit_reclaim_end(sc.nr_reclaimed); 2310 trace_mm_vmscan_memcg_softlimit_reclaim_end(sc.nr_reclaimed);
@@ -2319,7 +2319,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont,
2319{ 2319{
2320 struct zonelist *zonelist; 2320 struct zonelist *zonelist;
2321 unsigned long nr_reclaimed; 2321 unsigned long nr_reclaimed;
2322 unsigned long start, end; 2322 ktime_t start, end;
2323 int nid; 2323 int nid;
2324 struct scan_control sc = { 2324 struct scan_control sc = {
2325 .may_writepage = !laptop_mode, 2325 .may_writepage = !laptop_mode,
@@ -2337,7 +2337,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont,
2337 .gfp_mask = sc.gfp_mask, 2337 .gfp_mask = sc.gfp_mask,
2338 }; 2338 };
2339 2339
2340 start = sched_clock(); 2340 start = ktime_get();
2341 /* 2341 /*
2342 * Unlike direct reclaim via alloc_pages(), memcg's reclaim doesn't 2342 * Unlike direct reclaim via alloc_pages(), memcg's reclaim doesn't
2343 * take care of from where we get pages. So the node where we start the 2343 * take care of from where we get pages. So the node where we start the
@@ -2352,9 +2352,9 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont,
2352 sc.gfp_mask); 2352 sc.gfp_mask);
2353 2353
2354 nr_reclaimed = do_try_to_free_pages(zonelist, &sc, &shrink); 2354 nr_reclaimed = do_try_to_free_pages(zonelist, &sc, &shrink);
2355 end = sched_clock(); 2355 end = ktime_get();
2356 if (rec) 2356 if (rec)
2357 rec->elapsed += end - start; 2357 rec->elapsed += ktime_to_ns(ktime_sub(end, start));
2358 2358
2359 trace_mm_vmscan_memcg_reclaim_end(nr_reclaimed); 2359 trace_mm_vmscan_memcg_reclaim_end(nr_reclaimed);
2360 2360
@@ -2529,6 +2529,9 @@ loop_again:
2529 high_wmark_pages(zone), 0, 0)) { 2529 high_wmark_pages(zone), 0, 0)) {
2530 end_zone = i; 2530 end_zone = i;
2531 break; 2531 break;
2532 } else {
2533 /* If balanced, clear the congested flag */
2534 zone_clear_flag(zone, ZONE_CONGESTED);
2532 } 2535 }
2533 } 2536 }
2534 if (i < 0) 2537 if (i < 0)
diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
index 5f27f8e30254..f1f2f7bb6661 100644
--- a/net/8021q/vlan_core.c
+++ b/net/8021q/vlan_core.c
@@ -167,6 +167,8 @@ struct sk_buff *vlan_untag(struct sk_buff *skb)
167 if (unlikely(!skb)) 167 if (unlikely(!skb))
168 goto err_free; 168 goto err_free;
169 169
170 skb_reset_network_header(skb);
171 skb_reset_transport_header(skb);
170 return skb; 172 return skb;
171 173
172err_free: 174err_free:
diff --git a/net/atm/br2684.c b/net/atm/br2684.c
index 52cfd0c3ea71..d07223c834af 100644
--- a/net/atm/br2684.c
+++ b/net/atm/br2684.c
@@ -558,12 +558,13 @@ static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg)
558 spin_unlock_irqrestore(&rq->lock, flags); 558 spin_unlock_irqrestore(&rq->lock, flags);
559 559
560 skb_queue_walk_safe(&queue, skb, tmp) { 560 skb_queue_walk_safe(&queue, skb, tmp) {
561 struct net_device *dev = skb->dev; 561 struct net_device *dev;
562
563 br2684_push(atmvcc, skb);
564 dev = skb->dev;
562 565
563 dev->stats.rx_bytes -= skb->len; 566 dev->stats.rx_bytes -= skb->len;
564 dev->stats.rx_packets--; 567 dev->stats.rx_packets--;
565
566 br2684_push(atmvcc, skb);
567 } 568 }
568 569
569 /* initialize netdev carrier state */ 570 /* initialize netdev carrier state */
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index 2cdf0070419f..e73815456adf 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -231,6 +231,7 @@ static struct net_bridge_port *new_nbp(struct net_bridge *br,
231int br_add_bridge(struct net *net, const char *name) 231int br_add_bridge(struct net *net, const char *name)
232{ 232{
233 struct net_device *dev; 233 struct net_device *dev;
234 int res;
234 235
235 dev = alloc_netdev(sizeof(struct net_bridge), name, 236 dev = alloc_netdev(sizeof(struct net_bridge), name,
236 br_dev_setup); 237 br_dev_setup);
@@ -240,7 +241,10 @@ int br_add_bridge(struct net *net, const char *name)
240 241
241 dev_net_set(dev, net); 242 dev_net_set(dev, net);
242 243
243 return register_netdev(dev); 244 res = register_netdev(dev);
245 if (res)
246 free_netdev(dev);
247 return res;
244} 248}
245 249
246int br_del_bridge(struct net *net, const char *name) 250int br_del_bridge(struct net *net, const char *name)
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 9cb191ecaba8..147ede38ab48 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -913,7 +913,7 @@ static int ipv6_getsockopt_sticky(struct sock *sk, struct ipv6_txoptions *opt,
913} 913}
914 914
915static int do_ipv6_getsockopt(struct sock *sk, int level, int optname, 915static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
916 char __user *optval, int __user *optlen) 916 char __user *optval, int __user *optlen, unsigned flags)
917{ 917{
918 struct ipv6_pinfo *np = inet6_sk(sk); 918 struct ipv6_pinfo *np = inet6_sk(sk);
919 int len; 919 int len;
@@ -962,7 +962,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
962 962
963 msg.msg_control = optval; 963 msg.msg_control = optval;
964 msg.msg_controllen = len; 964 msg.msg_controllen = len;
965 msg.msg_flags = 0; 965 msg.msg_flags = flags;
966 966
967 lock_sock(sk); 967 lock_sock(sk);
968 skb = np->pktoptions; 968 skb = np->pktoptions;
@@ -1222,7 +1222,7 @@ int ipv6_getsockopt(struct sock *sk, int level, int optname,
1222 if(level != SOL_IPV6) 1222 if(level != SOL_IPV6)
1223 return -ENOPROTOOPT; 1223 return -ENOPROTOOPT;
1224 1224
1225 err = do_ipv6_getsockopt(sk, level, optname, optval, optlen); 1225 err = do_ipv6_getsockopt(sk, level, optname, optval, optlen, 0);
1226#ifdef CONFIG_NETFILTER 1226#ifdef CONFIG_NETFILTER
1227 /* we need to exclude all possible ENOPROTOOPTs except default case */ 1227 /* we need to exclude all possible ENOPROTOOPTs except default case */
1228 if (err == -ENOPROTOOPT && optname != IPV6_2292PKTOPTIONS) { 1228 if (err == -ENOPROTOOPT && optname != IPV6_2292PKTOPTIONS) {
@@ -1264,7 +1264,8 @@ int compat_ipv6_getsockopt(struct sock *sk, int level, int optname,
1264 return compat_mc_getsockopt(sk, level, optname, optval, optlen, 1264 return compat_mc_getsockopt(sk, level, optname, optval, optlen,
1265 ipv6_getsockopt); 1265 ipv6_getsockopt);
1266 1266
1267 err = do_ipv6_getsockopt(sk, level, optname, optval, optlen); 1267 err = do_ipv6_getsockopt(sk, level, optname, optval, optlen,
1268 MSG_CMSG_COMPAT);
1268#ifdef CONFIG_NETFILTER 1269#ifdef CONFIG_NETFILTER
1269 /* we need to exclude all possible ENOPROTOOPTs except default case */ 1270 /* we need to exclude all possible ENOPROTOOPTs except default case */
1270 if (err == -ENOPROTOOPT && optname != IPV6_2292PKTOPTIONS) { 1271 if (err == -ENOPROTOOPT && optname != IPV6_2292PKTOPTIONS) {
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 07bf1085458f..00b15ac7a702 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -672,6 +672,9 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
672 if (skb->protocol != htons(ETH_P_IPV6)) 672 if (skb->protocol != htons(ETH_P_IPV6))
673 goto tx_error; 673 goto tx_error;
674 674
675 if (tos == 1)
676 tos = ipv6_get_dsfield(iph6);
677
675 /* ISATAP (RFC4214) - must come before 6to4 */ 678 /* ISATAP (RFC4214) - must come before 6to4 */
676 if (dev->priv_flags & IFF_ISATAP) { 679 if (dev->priv_flags & IFF_ISATAP) {
677 struct neighbour *neigh = NULL; 680 struct neighbour *neigh = NULL;
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
index 102fc212cd64..e051398fdf6b 100644
--- a/net/sched/act_mirred.c
+++ b/net/sched/act_mirred.c
@@ -196,8 +196,7 @@ static int tcf_mirred(struct sk_buff *skb, const struct tc_action *a,
196 196
197 skb2->skb_iif = skb->dev->ifindex; 197 skb2->skb_iif = skb->dev->ifindex;
198 skb2->dev = dev; 198 skb2->dev = dev;
199 dev_queue_xmit(skb2); 199 err = dev_queue_xmit(skb2);
200 err = 0;
201 200
202out: 201out:
203 if (err) { 202 if (err) {
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 9d761c95eca2..3dfc47134e51 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2574,7 +2574,8 @@ sub process {
2574 } else { 2574 } else {
2575 $cast = $cast2; 2575 $cast = $cast2;
2576 } 2576 }
2577 WARN("$call() should probably be ${call}_t($cast, $arg1, $arg2)\n" . $herecurr); 2577 WARN("MINMAX",
2578 "$call() should probably be ${call}_t($cast, $arg1, $arg2)\n" . $herecurr);
2578 } 2579 }
2579 } 2580 }
2580 2581
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index eb2f1e64edf7..4594f3341051 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -1389,7 +1389,7 @@ sub vcs_exists {
1389 warn("$P: No supported VCS found. Add --nogit to options?\n"); 1389 warn("$P: No supported VCS found. Add --nogit to options?\n");
1390 warn("Using a git repository produces better results.\n"); 1390 warn("Using a git repository produces better results.\n");
1391 warn("Try Linus Torvalds' latest git repository using:\n"); 1391 warn("Try Linus Torvalds' latest git repository using:\n");
1392 warn("git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git\n"); 1392 warn("git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git\n");
1393 $printed_novcs = 1; 1393 $printed_novcs = 1;
1394 } 1394 }
1395 return 0; 1395 return 0;
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 502fc9499453..7696d05b9356 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -3348,6 +3348,8 @@ static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t pin,
3348 3348
3349#define MAX_AUTO_DACS 5 3349#define MAX_AUTO_DACS 5
3350 3350
3351#define DAC_SLAVE_FLAG 0x8000 /* filled dac is a slave */
3352
3351/* fill analog DAC list from the widget tree */ 3353/* fill analog DAC list from the widget tree */
3352static int fill_cx_auto_dacs(struct hda_codec *codec, hda_nid_t *dacs) 3354static int fill_cx_auto_dacs(struct hda_codec *codec, hda_nid_t *dacs)
3353{ 3355{
@@ -3370,16 +3372,26 @@ static int fill_cx_auto_dacs(struct hda_codec *codec, hda_nid_t *dacs)
3370/* fill pin_dac_pair list from the pin and dac list */ 3372/* fill pin_dac_pair list from the pin and dac list */
3371static int fill_dacs_for_pins(struct hda_codec *codec, hda_nid_t *pins, 3373static int fill_dacs_for_pins(struct hda_codec *codec, hda_nid_t *pins,
3372 int num_pins, hda_nid_t *dacs, int *rest, 3374 int num_pins, hda_nid_t *dacs, int *rest,
3373 struct pin_dac_pair *filled, int type) 3375 struct pin_dac_pair *filled, int nums,
3376 int type)
3374{ 3377{
3375 int i, nums; 3378 int i, start = nums;
3376 3379
3377 nums = 0; 3380 for (i = 0; i < num_pins; i++, nums++) {
3378 for (i = 0; i < num_pins; i++) {
3379 filled[nums].pin = pins[i]; 3381 filled[nums].pin = pins[i];
3380 filled[nums].type = type; 3382 filled[nums].type = type;
3381 filled[nums].dac = get_unassigned_dac(codec, pins[i], dacs, rest); 3383 filled[nums].dac = get_unassigned_dac(codec, pins[i], dacs, rest);
3382 nums++; 3384 if (filled[nums].dac)
3385 continue;
3386 if (filled[start].dac && get_connection_index(codec, pins[i], filled[start].dac) >= 0) {
3387 filled[nums].dac = filled[start].dac | DAC_SLAVE_FLAG;
3388 continue;
3389 }
3390 if (filled[0].dac && get_connection_index(codec, pins[i], filled[0].dac) >= 0) {
3391 filled[nums].dac = filled[0].dac | DAC_SLAVE_FLAG;
3392 continue;
3393 }
3394 snd_printdd("Failed to find a DAC for pin 0x%x", pins[i]);
3383 } 3395 }
3384 return nums; 3396 return nums;
3385} 3397}
@@ -3395,19 +3407,19 @@ static void cx_auto_parse_output(struct hda_codec *codec)
3395 rest = fill_cx_auto_dacs(codec, dacs); 3407 rest = fill_cx_auto_dacs(codec, dacs);
3396 /* parse all analog output pins */ 3408 /* parse all analog output pins */
3397 nums = fill_dacs_for_pins(codec, cfg->line_out_pins, cfg->line_outs, 3409 nums = fill_dacs_for_pins(codec, cfg->line_out_pins, cfg->line_outs,
3398 dacs, &rest, spec->dac_info, 3410 dacs, &rest, spec->dac_info, 0,
3399 AUTO_PIN_LINE_OUT); 3411 AUTO_PIN_LINE_OUT);
3400 nums += fill_dacs_for_pins(codec, cfg->hp_pins, cfg->hp_outs, 3412 nums = fill_dacs_for_pins(codec, cfg->hp_pins, cfg->hp_outs,
3401 dacs, &rest, spec->dac_info + nums, 3413 dacs, &rest, spec->dac_info, nums,
3402 AUTO_PIN_HP_OUT); 3414 AUTO_PIN_HP_OUT);
3403 nums += fill_dacs_for_pins(codec, cfg->speaker_pins, cfg->speaker_outs, 3415 nums = fill_dacs_for_pins(codec, cfg->speaker_pins, cfg->speaker_outs,
3404 dacs, &rest, spec->dac_info + nums, 3416 dacs, &rest, spec->dac_info, nums,
3405 AUTO_PIN_SPEAKER_OUT); 3417 AUTO_PIN_SPEAKER_OUT);
3406 spec->dac_info_filled = nums; 3418 spec->dac_info_filled = nums;
3407 /* fill multiout struct */ 3419 /* fill multiout struct */
3408 for (i = 0; i < nums; i++) { 3420 for (i = 0; i < nums; i++) {
3409 hda_nid_t dac = spec->dac_info[i].dac; 3421 hda_nid_t dac = spec->dac_info[i].dac;
3410 if (!dac) 3422 if (!dac || (dac & DAC_SLAVE_FLAG))
3411 continue; 3423 continue;
3412 switch (spec->dac_info[i].type) { 3424 switch (spec->dac_info[i].type) {
3413 case AUTO_PIN_LINE_OUT: 3425 case AUTO_PIN_LINE_OUT:
@@ -3862,7 +3874,7 @@ static void cx_auto_parse_input(struct hda_codec *codec)
3862 } 3874 }
3863 if (imux->num_items >= 2 && cfg->num_inputs == imux->num_items) 3875 if (imux->num_items >= 2 && cfg->num_inputs == imux->num_items)
3864 cx_auto_check_auto_mic(codec); 3876 cx_auto_check_auto_mic(codec);
3865 if (imux->num_items > 1 && !spec->auto_mic) { 3877 if (imux->num_items > 1) {
3866 for (i = 1; i < imux->num_items; i++) { 3878 for (i = 1; i < imux->num_items; i++) {
3867 if (spec->imux_info[i].adc != spec->imux_info[0].adc) { 3879 if (spec->imux_info[i].adc != spec->imux_info[0].adc) {
3868 spec->adc_switching = 1; 3880 spec->adc_switching = 1;
@@ -4035,6 +4047,8 @@ static void cx_auto_init_output(struct hda_codec *codec)
4035 nid = spec->dac_info[i].dac; 4047 nid = spec->dac_info[i].dac;
4036 if (!nid) 4048 if (!nid)
4037 nid = spec->multiout.dac_nids[0]; 4049 nid = spec->multiout.dac_nids[0];
4050 else if (nid & DAC_SLAVE_FLAG)
4051 nid &= ~DAC_SLAVE_FLAG;
4038 select_connection(codec, spec->dac_info[i].pin, nid); 4052 select_connection(codec, spec->dac_info[i].pin, nid);
4039 } 4053 }
4040 if (spec->auto_mute) { 4054 if (spec->auto_mute) {
@@ -4167,9 +4181,11 @@ static int try_add_pb_volume(struct hda_codec *codec, hda_nid_t dac,
4167 hda_nid_t pin, const char *name, int idx) 4181 hda_nid_t pin, const char *name, int idx)
4168{ 4182{
4169 unsigned int caps; 4183 unsigned int caps;
4170 caps = query_amp_caps(codec, dac, HDA_OUTPUT); 4184 if (dac && !(dac & DAC_SLAVE_FLAG)) {
4171 if (caps & AC_AMPCAP_NUM_STEPS) 4185 caps = query_amp_caps(codec, dac, HDA_OUTPUT);
4172 return cx_auto_add_pb_volume(codec, dac, name, idx); 4186 if (caps & AC_AMPCAP_NUM_STEPS)
4187 return cx_auto_add_pb_volume(codec, dac, name, idx);
4188 }
4173 caps = query_amp_caps(codec, pin, HDA_OUTPUT); 4189 caps = query_amp_caps(codec, pin, HDA_OUTPUT);
4174 if (caps & AC_AMPCAP_NUM_STEPS) 4190 if (caps & AC_AMPCAP_NUM_STEPS)
4175 return cx_auto_add_pb_volume(codec, pin, name, idx); 4191 return cx_auto_add_pb_volume(codec, pin, name, idx);
@@ -4191,8 +4207,7 @@ static int cx_auto_build_output_controls(struct hda_codec *codec)
4191 for (i = 0; i < spec->dac_info_filled; i++) { 4207 for (i = 0; i < spec->dac_info_filled; i++) {
4192 const char *label; 4208 const char *label;
4193 int idx, type; 4209 int idx, type;
4194 if (!spec->dac_info[i].dac) 4210 hda_nid_t dac = spec->dac_info[i].dac;
4195 continue;
4196 type = spec->dac_info[i].type; 4211 type = spec->dac_info[i].type;
4197 if (type == AUTO_PIN_LINE_OUT) 4212 if (type == AUTO_PIN_LINE_OUT)
4198 type = spec->autocfg.line_out_type; 4213 type = spec->autocfg.line_out_type;
@@ -4211,7 +4226,7 @@ static int cx_auto_build_output_controls(struct hda_codec *codec)
4211 idx = num_spk++; 4226 idx = num_spk++;
4212 break; 4227 break;
4213 } 4228 }
4214 err = try_add_pb_volume(codec, spec->dac_info[i].dac, 4229 err = try_add_pb_volume(codec, dac,
4215 spec->dac_info[i].pin, 4230 spec->dac_info[i].pin,
4216 label, idx); 4231 label, idx);
4217 if (err < 0) 4232 if (err < 0)
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index fcb11af9ad24..7cabd7317163 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -565,11 +565,11 @@ static void alc_hp_automute(struct hda_codec *codec)
565{ 565{
566 struct alc_spec *spec = codec->spec; 566 struct alc_spec *spec = codec->spec;
567 567
568 if (!spec->automute)
569 return;
570 spec->jack_present = 568 spec->jack_present =
571 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.hp_pins), 569 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.hp_pins),
572 spec->autocfg.hp_pins); 570 spec->autocfg.hp_pins);
571 if (!spec->automute)
572 return;
573 update_speakers(codec); 573 update_speakers(codec);
574} 574}
575 575
@@ -578,11 +578,11 @@ static void alc_line_automute(struct hda_codec *codec)
578{ 578{
579 struct alc_spec *spec = codec->spec; 579 struct alc_spec *spec = codec->spec;
580 580
581 if (!spec->automute || !spec->detect_line)
582 return;
583 spec->line_jack_present = 581 spec->line_jack_present =
584 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), 582 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins),
585 spec->autocfg.line_out_pins); 583 spec->autocfg.line_out_pins);
584 if (!spec->automute || !spec->detect_line)
585 return;
586 update_speakers(codec); 586 update_speakers(codec);
587} 587}
588 588
@@ -3083,16 +3083,22 @@ static void alc_auto_init_multi_out(struct hda_codec *codec)
3083static void alc_auto_init_extra_out(struct hda_codec *codec) 3083static void alc_auto_init_extra_out(struct hda_codec *codec)
3084{ 3084{
3085 struct alc_spec *spec = codec->spec; 3085 struct alc_spec *spec = codec->spec;
3086 hda_nid_t pin; 3086 hda_nid_t pin, dac;
3087 3087
3088 pin = spec->autocfg.hp_pins[0]; 3088 pin = spec->autocfg.hp_pins[0];
3089 if (pin) 3089 if (pin) {
3090 alc_auto_set_output_and_unmute(codec, pin, PIN_HP, 3090 dac = spec->multiout.hp_nid;
3091 spec->multiout.hp_nid); 3091 if (!dac)
3092 dac = spec->multiout.dac_nids[0];
3093 alc_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
3094 }
3092 pin = spec->autocfg.speaker_pins[0]; 3095 pin = spec->autocfg.speaker_pins[0];
3093 if (pin) 3096 if (pin) {
3094 alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, 3097 dac = spec->multiout.extra_out_nid[0];
3095 spec->multiout.extra_out_nid[0]); 3098 if (!dac)
3099 dac = spec->multiout.dac_nids[0];
3100 alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
3101 }
3096} 3102}
3097 3103
3098/* 3104/*
diff --git a/sound/soc/blackfin/bf5xx-ad193x.c b/sound/soc/blackfin/bf5xx-ad193x.c
index d6651c033cb7..a118a0fb9d81 100644
--- a/sound/soc/blackfin/bf5xx-ad193x.c
+++ b/sound/soc/blackfin/bf5xx-ad193x.c
@@ -56,7 +56,7 @@ static int bf5xx_ad193x_hw_params(struct snd_pcm_substream *substream,
56 56
57 switch (params_rate(params)) { 57 switch (params_rate(params)) {
58 case 48000: 58 case 48000:
59 clk = 12288000; 59 clk = 24576000;
60 break; 60 break;
61 } 61 }
62 62
diff --git a/sound/soc/codecs/ad193x.c b/sound/soc/codecs/ad193x.c
index 2374ca5ffe68..eedb6f5e5823 100644
--- a/sound/soc/codecs/ad193x.c
+++ b/sound/soc/codecs/ad193x.c
@@ -27,11 +27,6 @@ struct ad193x_priv {
27 int sysclk; 27 int sysclk;
28}; 28};
29 29
30/* ad193x register cache & default register settings */
31static const u8 ad193x_reg[AD193X_NUM_REGS] = {
32 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0, 0,
33};
34
35/* 30/*
36 * AD193X volume/mute/de-emphasis etc. controls 31 * AD193X volume/mute/de-emphasis etc. controls
37 */ 32 */
@@ -307,7 +302,8 @@ static int ad193x_hw_params(struct snd_pcm_substream *substream,
307 snd_soc_write(codec, AD193X_PLL_CLK_CTRL0, reg); 302 snd_soc_write(codec, AD193X_PLL_CLK_CTRL0, reg);
308 303
309 reg = snd_soc_read(codec, AD193X_DAC_CTRL2); 304 reg = snd_soc_read(codec, AD193X_DAC_CTRL2);
310 reg = (reg & (~AD193X_DAC_WORD_LEN_MASK)) | word_len; 305 reg = (reg & (~AD193X_DAC_WORD_LEN_MASK))
306 | (word_len << AD193X_DAC_WORD_LEN_SHFT);
311 snd_soc_write(codec, AD193X_DAC_CTRL2, reg); 307 snd_soc_write(codec, AD193X_DAC_CTRL2, reg);
312 308
313 reg = snd_soc_read(codec, AD193X_ADC_CTRL1); 309 reg = snd_soc_read(codec, AD193X_ADC_CTRL1);
@@ -389,9 +385,6 @@ static int ad193x_probe(struct snd_soc_codec *codec)
389 385
390static struct snd_soc_codec_driver soc_codec_dev_ad193x = { 386static struct snd_soc_codec_driver soc_codec_dev_ad193x = {
391 .probe = ad193x_probe, 387 .probe = ad193x_probe,
392 .reg_cache_default = ad193x_reg,
393 .reg_cache_size = AD193X_NUM_REGS,
394 .reg_word_size = sizeof(u16),
395}; 388};
396 389
397#if defined(CONFIG_SPI_MASTER) 390#if defined(CONFIG_SPI_MASTER)
diff --git a/sound/soc/codecs/ad193x.h b/sound/soc/codecs/ad193x.h
index 9747b5497877..cccc2e8e5fbd 100644
--- a/sound/soc/codecs/ad193x.h
+++ b/sound/soc/codecs/ad193x.h
@@ -34,7 +34,8 @@
34#define AD193X_DAC_LEFT_HIGH (1 << 3) 34#define AD193X_DAC_LEFT_HIGH (1 << 3)
35#define AD193X_DAC_BCLK_INV (1 << 7) 35#define AD193X_DAC_BCLK_INV (1 << 7)
36#define AD193X_DAC_CTRL2 0x804 36#define AD193X_DAC_CTRL2 0x804
37#define AD193X_DAC_WORD_LEN_MASK 0xC 37#define AD193X_DAC_WORD_LEN_SHFT 3
38#define AD193X_DAC_WORD_LEN_MASK 0x18
38#define AD193X_DAC_MASTER_MUTE 1 39#define AD193X_DAC_MASTER_MUTE 1
39#define AD193X_DAC_CHNL_MUTE 0x805 40#define AD193X_DAC_CHNL_MUTE 0x805
40#define AD193X_DACL1_MUTE 0 41#define AD193X_DACL1_MUTE 0
@@ -63,7 +64,7 @@
63#define AD193X_ADC_CTRL1 0x80f 64#define AD193X_ADC_CTRL1 0x80f
64#define AD193X_ADC_SERFMT_MASK 0x60 65#define AD193X_ADC_SERFMT_MASK 0x60
65#define AD193X_ADC_SERFMT_STEREO (0 << 5) 66#define AD193X_ADC_SERFMT_STEREO (0 << 5)
66#define AD193X_ADC_SERFMT_TDM (1 << 2) 67#define AD193X_ADC_SERFMT_TDM (1 << 5)
67#define AD193X_ADC_SERFMT_AUX (2 << 5) 68#define AD193X_ADC_SERFMT_AUX (2 << 5)
68#define AD193X_ADC_WORD_LEN_MASK 0x3 69#define AD193X_ADC_WORD_LEN_MASK 0x3
69#define AD193X_ADC_CTRL2 0x810 70#define AD193X_ADC_CTRL2 0x810
diff --git a/sound/soc/codecs/sta32x.c b/sound/soc/codecs/sta32x.c
index 409d89d1f34c..fbd7eb9e61ce 100644
--- a/sound/soc/codecs/sta32x.c
+++ b/sound/soc/codecs/sta32x.c
@@ -857,6 +857,7 @@ static __devinit int sta32x_i2c_probe(struct i2c_client *i2c,
857 ret = snd_soc_register_codec(&i2c->dev, &sta32x_codec, &sta32x_dai, 1); 857 ret = snd_soc_register_codec(&i2c->dev, &sta32x_codec, &sta32x_dai, 1);
858 if (ret != 0) { 858 if (ret != 0) {
859 dev_err(&i2c->dev, "Failed to register codec (%d)\n", ret); 859 dev_err(&i2c->dev, "Failed to register codec (%d)\n", ret);
860 kfree(sta32x);
860 return ret; 861 return ret;
861 } 862 }
862 863
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index 60d740ebeb5b..1725550c293e 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -2221,6 +2221,8 @@ static int sysclk_event(struct snd_soc_dapm_widget *w,
2221 switch (event) { 2221 switch (event) {
2222 case SND_SOC_DAPM_PRE_PMU: 2222 case SND_SOC_DAPM_PRE_PMU:
2223 if (fll) { 2223 if (fll) {
2224 try_wait_for_completion(&wm8962->fll_lock);
2225
2224 snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, 2226 snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1,
2225 WM8962_FLL_ENA, WM8962_FLL_ENA); 2227 WM8962_FLL_ENA, WM8962_FLL_ENA);
2226 if (wm8962->irq) { 2228 if (wm8962->irq) {
@@ -2927,10 +2929,6 @@ static int wm8962_set_bias_level(struct snd_soc_codec *codec,
2927 WM8962_BIAS_ENA | 0x180); 2929 WM8962_BIAS_ENA | 0x180);
2928 2930
2929 msleep(5); 2931 msleep(5);
2930
2931 snd_soc_update_bits(codec, WM8962_CLOCKING2,
2932 WM8962_CLKREG_OVD,
2933 WM8962_CLKREG_OVD);
2934 } 2932 }
2935 2933
2936 /* VMID 2*250k */ 2934 /* VMID 2*250k */
@@ -3288,6 +3286,8 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
3288 snd_soc_write(codec, WM8962_FLL_CONTROL_7, fll_div.lambda); 3286 snd_soc_write(codec, WM8962_FLL_CONTROL_7, fll_div.lambda);
3289 snd_soc_write(codec, WM8962_FLL_CONTROL_8, fll_div.n); 3287 snd_soc_write(codec, WM8962_FLL_CONTROL_8, fll_div.n);
3290 3288
3289 try_wait_for_completion(&wm8962->fll_lock);
3290
3291 snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, 3291 snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1,
3292 WM8962_FLL_FRAC | WM8962_FLL_REFCLK_SRC_MASK | 3292 WM8962_FLL_FRAC | WM8962_FLL_REFCLK_SRC_MASK |
3293 WM8962_FLL_ENA, fll1); 3293 WM8962_FLL_ENA, fll1);
@@ -3868,6 +3868,10 @@ static int wm8962_probe(struct snd_soc_codec *codec)
3868 */ 3868 */
3869 snd_soc_update_bits(codec, WM8962_CLOCKING2, WM8962_SYSCLK_ENA, 0); 3869 snd_soc_update_bits(codec, WM8962_CLOCKING2, WM8962_SYSCLK_ENA, 0);
3870 3870
3871 /* Ensure we have soft control over all registers */
3872 snd_soc_update_bits(codec, WM8962_CLOCKING2,
3873 WM8962_CLKREG_OVD, WM8962_CLKREG_OVD);
3874
3871 regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies), wm8962->supplies); 3875 regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies), wm8962->supplies);
3872 3876
3873 if (pdata) { 3877 if (pdata) {
diff --git a/sound/soc/codecs/wm8996.c b/sound/soc/codecs/wm8996.c
index ab8e9d1aaff0..0cdb9d105671 100644
--- a/sound/soc/codecs/wm8996.c
+++ b/sound/soc/codecs/wm8996.c
@@ -420,7 +420,7 @@ static const char *sidetone_hpf_text[] = {
420}; 420};
421 421
422static const struct soc_enum sidetone_hpf = 422static const struct soc_enum sidetone_hpf =
423 SOC_ENUM_SINGLE(WM8996_SIDETONE, 7, 6, sidetone_hpf_text); 423 SOC_ENUM_SINGLE(WM8996_SIDETONE, 7, 7, sidetone_hpf_text);
424 424
425static const char *hpf_mode_text[] = { 425static const char *hpf_mode_text[] = {
426 "HiFi", "Custom", "Voice" 426 "HiFi", "Custom", "Voice"
@@ -988,15 +988,10 @@ SND_SOC_DAPM_MICBIAS("MICB1", WM8996_POWER_MANAGEMENT_1, 8, 0),
988SND_SOC_DAPM_PGA("IN1L PGA", WM8996_POWER_MANAGEMENT_2, 5, 0, NULL, 0), 988SND_SOC_DAPM_PGA("IN1L PGA", WM8996_POWER_MANAGEMENT_2, 5, 0, NULL, 0),
989SND_SOC_DAPM_PGA("IN1R PGA", WM8996_POWER_MANAGEMENT_2, 4, 0, NULL, 0), 989SND_SOC_DAPM_PGA("IN1R PGA", WM8996_POWER_MANAGEMENT_2, 4, 0, NULL, 0),
990 990
991SND_SOC_DAPM_MUX("IN1L Mux", SND_SOC_NOPM, 0, 0, &in1_mux), 991SND_SOC_DAPM_MUX("IN1L Mux", WM8996_POWER_MANAGEMENT_7, 2, 0, &in1_mux),
992SND_SOC_DAPM_MUX("IN1R Mux", SND_SOC_NOPM, 0, 0, &in1_mux), 992SND_SOC_DAPM_MUX("IN1R Mux", WM8996_POWER_MANAGEMENT_7, 3, 0, &in1_mux),
993SND_SOC_DAPM_MUX("IN2L Mux", SND_SOC_NOPM, 0, 0, &in2_mux), 993SND_SOC_DAPM_MUX("IN2L Mux", WM8996_POWER_MANAGEMENT_7, 6, 0, &in2_mux),
994SND_SOC_DAPM_MUX("IN2R Mux", SND_SOC_NOPM, 0, 0, &in2_mux), 994SND_SOC_DAPM_MUX("IN2R Mux", WM8996_POWER_MANAGEMENT_7, 7, 0, &in2_mux),
995
996SND_SOC_DAPM_PGA("IN1L", WM8996_POWER_MANAGEMENT_7, 2, 0, NULL, 0),
997SND_SOC_DAPM_PGA("IN1R", WM8996_POWER_MANAGEMENT_7, 3, 0, NULL, 0),
998SND_SOC_DAPM_PGA("IN2L", WM8996_POWER_MANAGEMENT_7, 6, 0, NULL, 0),
999SND_SOC_DAPM_PGA("IN2R", WM8996_POWER_MANAGEMENT_7, 7, 0, NULL, 0),
1000 995
1001SND_SOC_DAPM_SUPPLY("DMIC2", WM8996_POWER_MANAGEMENT_7, 9, 0, NULL, 0), 996SND_SOC_DAPM_SUPPLY("DMIC2", WM8996_POWER_MANAGEMENT_7, 9, 0, NULL, 0),
1002SND_SOC_DAPM_SUPPLY("DMIC1", WM8996_POWER_MANAGEMENT_7, 8, 0, NULL, 0), 997SND_SOC_DAPM_SUPPLY("DMIC1", WM8996_POWER_MANAGEMENT_7, 8, 0, NULL, 0),
@@ -1213,6 +1208,16 @@ static const struct snd_soc_dapm_route wm8996_dapm_routes[] = {
1213 { "AIF2RX0", NULL, "AIFCLK" }, 1208 { "AIF2RX0", NULL, "AIFCLK" },
1214 { "AIF2RX1", NULL, "AIFCLK" }, 1209 { "AIF2RX1", NULL, "AIFCLK" },
1215 1210
1211 { "AIF1TX0", NULL, "AIFCLK" },
1212 { "AIF1TX1", NULL, "AIFCLK" },
1213 { "AIF1TX2", NULL, "AIFCLK" },
1214 { "AIF1TX3", NULL, "AIFCLK" },
1215 { "AIF1TX4", NULL, "AIFCLK" },
1216 { "AIF1TX5", NULL, "AIFCLK" },
1217
1218 { "AIF2TX0", NULL, "AIFCLK" },
1219 { "AIF2TX1", NULL, "AIFCLK" },
1220
1216 { "DSP1RXL", NULL, "SYSDSPCLK" }, 1221 { "DSP1RXL", NULL, "SYSDSPCLK" },
1217 { "DSP1RXR", NULL, "SYSDSPCLK" }, 1222 { "DSP1RXR", NULL, "SYSDSPCLK" },
1218 { "DSP2RXL", NULL, "SYSDSPCLK" }, 1223 { "DSP2RXL", NULL, "SYSDSPCLK" },
@@ -2106,6 +2111,9 @@ static int wm8996_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
2106 2111
2107 snd_soc_write(codec, WM8996_FLL_EFS_1, fll_div.lambda); 2112 snd_soc_write(codec, WM8996_FLL_EFS_1, fll_div.lambda);
2108 2113
2114 /* Clear any pending completions (eg, from failed startups) */
2115 try_wait_for_completion(&wm8996->fll_lock);
2116
2109 snd_soc_update_bits(codec, WM8996_FLL_CONTROL_1, 2117 snd_soc_update_bits(codec, WM8996_FLL_CONTROL_1,
2110 WM8996_FLL_ENA, WM8996_FLL_ENA); 2118 WM8996_FLL_ENA, WM8996_FLL_ENA);
2111 2119
diff --git a/sound/soc/ep93xx/ep93xx-i2s.c b/sound/soc/ep93xx/ep93xx-i2s.c
index 56efa0c1c9a9..099614e16651 100644
--- a/sound/soc/ep93xx/ep93xx-i2s.c
+++ b/sound/soc/ep93xx/ep93xx-i2s.c
@@ -385,14 +385,14 @@ static int ep93xx_i2s_probe(struct platform_device *pdev)
385 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 385 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
386 if (!res) { 386 if (!res) {
387 err = -ENODEV; 387 err = -ENODEV;
388 goto fail; 388 goto fail_free_info;
389 } 389 }
390 390
391 info->mem = request_mem_region(res->start, resource_size(res), 391 info->mem = request_mem_region(res->start, resource_size(res),
392 pdev->name); 392 pdev->name);
393 if (!info->mem) { 393 if (!info->mem) {
394 err = -EBUSY; 394 err = -EBUSY;
395 goto fail; 395 goto fail_free_info;
396 } 396 }
397 397
398 info->regs = ioremap(info->mem->start, resource_size(info->mem)); 398 info->regs = ioremap(info->mem->start, resource_size(info->mem));
@@ -435,6 +435,7 @@ fail_unmap_mem:
435 iounmap(info->regs); 435 iounmap(info->regs);
436fail_release_mem: 436fail_release_mem:
437 release_mem_region(info->mem->start, resource_size(info->mem)); 437 release_mem_region(info->mem->start, resource_size(info->mem));
438fail_free_info:
438 kfree(info); 439 kfree(info);
439fail: 440fail:
440 return err; 441 return err;
diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c
index 732208c8c0b4..cb50598338e9 100644
--- a/sound/soc/fsl/fsl_dma.c
+++ b/sound/soc/fsl/fsl_dma.c
@@ -879,10 +879,12 @@ static struct device_node *find_ssi_node(struct device_node *dma_channel_np)
879 * assume that device_node pointers are a valid comparison. 879 * assume that device_node pointers are a valid comparison.
880 */ 880 */
881 np = of_parse_phandle(ssi_np, "fsl,playback-dma", 0); 881 np = of_parse_phandle(ssi_np, "fsl,playback-dma", 0);
882 of_node_put(np);
882 if (np == dma_channel_np) 883 if (np == dma_channel_np)
883 return ssi_np; 884 return ssi_np;
884 885
885 np = of_parse_phandle(ssi_np, "fsl,capture-dma", 0); 886 np = of_parse_phandle(ssi_np, "fsl,capture-dma", 0);
887 of_node_put(np);
886 if (np == dma_channel_np) 888 if (np == dma_channel_np)
887 return ssi_np; 889 return ssi_np;
888 } 890 }
diff --git a/sound/soc/fsl/mpc8610_hpcd.c b/sound/soc/fsl/mpc8610_hpcd.c
index a19297959587..358f0baaf71b 100644
--- a/sound/soc/fsl/mpc8610_hpcd.c
+++ b/sound/soc/fsl/mpc8610_hpcd.c
@@ -345,8 +345,10 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev)
345 } 345 }
346 346
347 machine_data = kzalloc(sizeof(struct mpc8610_hpcd_data), GFP_KERNEL); 347 machine_data = kzalloc(sizeof(struct mpc8610_hpcd_data), GFP_KERNEL);
348 if (!machine_data) 348 if (!machine_data) {
349 return -ENOMEM; 349 ret = -ENOMEM;
350 goto error_alloc;
351 }
350 352
351 machine_data->dai[0].cpu_dai_name = dev_name(&ssi_pdev->dev); 353 machine_data->dai[0].cpu_dai_name = dev_name(&ssi_pdev->dev);
352 machine_data->dai[0].ops = &mpc8610_hpcd_ops; 354 machine_data->dai[0].ops = &mpc8610_hpcd_ops;
@@ -494,7 +496,7 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev)
494 ret = platform_device_add(sound_device); 496 ret = platform_device_add(sound_device);
495 if (ret) { 497 if (ret) {
496 dev_err(&pdev->dev, "platform device add failed\n"); 498 dev_err(&pdev->dev, "platform device add failed\n");
497 goto error; 499 goto error_sound;
498 } 500 }
499 dev_set_drvdata(&pdev->dev, sound_device); 501 dev_set_drvdata(&pdev->dev, sound_device);
500 502
@@ -502,14 +504,12 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev)
502 504
503 return 0; 505 return 0;
504 506
507error_sound:
508 platform_device_unregister(sound_device);
505error: 509error:
506 of_node_put(codec_np);
507
508 if (sound_device)
509 platform_device_unregister(sound_device);
510
511 kfree(machine_data); 510 kfree(machine_data);
512 511error_alloc:
512 of_node_put(codec_np);
513 return ret; 513 return ret;
514} 514}
515 515
diff --git a/sound/soc/fsl/p1022_ds.c b/sound/soc/fsl/p1022_ds.c
index 8fa4d5f8eda1..fcb862eb0c73 100644
--- a/sound/soc/fsl/p1022_ds.c
+++ b/sound/soc/fsl/p1022_ds.c
@@ -297,8 +297,10 @@ static int get_dma_channel(struct device_node *ssi_np,
297 * dai->platform name should already point to an allocated buffer. 297 * dai->platform name should already point to an allocated buffer.
298 */ 298 */
299 ret = of_address_to_resource(dma_channel_np, 0, &res); 299 ret = of_address_to_resource(dma_channel_np, 0, &res);
300 if (ret) 300 if (ret) {
301 of_node_put(dma_channel_np);
301 return ret; 302 return ret;
303 }
302 snprintf((char *)dai->platform_name, DAI_NAME_SIZE, "%llx.%s", 304 snprintf((char *)dai->platform_name, DAI_NAME_SIZE, "%llx.%s",
303 (unsigned long long) res.start, dma_channel_np->name); 305 (unsigned long long) res.start, dma_channel_np->name);
304 306
diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c
index a33fc51f363b..8f16cd37c2af 100644
--- a/sound/soc/kirkwood/kirkwood-i2s.c
+++ b/sound/soc/kirkwood/kirkwood-i2s.c
@@ -424,7 +424,7 @@ static __devinit int kirkwood_i2s_dev_probe(struct platform_device *pdev)
424 if (!priv->mem) { 424 if (!priv->mem) {
425 dev_err(&pdev->dev, "request_mem_region failed\n"); 425 dev_err(&pdev->dev, "request_mem_region failed\n");
426 err = -EBUSY; 426 err = -EBUSY;
427 goto error; 427 goto error_alloc;
428 } 428 }
429 429
430 priv->io = ioremap(priv->mem->start, SZ_16K); 430 priv->io = ioremap(priv->mem->start, SZ_16K);
diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c
index 30fe0d0efe1c..0aa475f92efa 100644
--- a/sound/soc/omap/ams-delta.c
+++ b/sound/soc/omap/ams-delta.c
@@ -514,7 +514,7 @@ static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd)
514 } 514 }
515 515
516 /* Set codec bias level */ 516 /* Set codec bias level */
517 ams_delta_set_bias_level(card, SND_SOC_BIAS_STANDBY); 517 ams_delta_set_bias_level(card, dapm, SND_SOC_BIAS_STANDBY);
518 518
519 /* Add hook switch - can be used to control the codec from userspace 519 /* Add hook switch - can be used to control the codec from userspace
520 * even if line discipline fails */ 520 * even if line discipline fails */
@@ -649,7 +649,9 @@ static void __exit ams_delta_module_exit(void)
649 ams_delta_hook_switch_gpios); 649 ams_delta_hook_switch_gpios);
650 650
651 /* Keep modem power on */ 651 /* Keep modem power on */
652 ams_delta_set_bias_level(&ams_delta_audio_card, SND_SOC_BIAS_STANDBY); 652 ams_delta_set_bias_level(&ams_delta_audio_card,
653 &ams_delta_audio_card.rtd[0].codec->dapm,
654 SND_SOC_BIAS_STANDBY);
653 655
654 platform_device_unregister(cx20442_platform_device); 656 platform_device_unregister(cx20442_platform_device);
655 platform_device_unregister(ams_delta_audio_platform_device); 657 platform_device_unregister(ams_delta_audio_platform_device);
diff --git a/sound/soc/samsung/Kconfig b/sound/soc/samsung/Kconfig
index b99091fc34eb..65f980ef2870 100644
--- a/sound/soc/samsung/Kconfig
+++ b/sound/soc/samsung/Kconfig
@@ -185,6 +185,7 @@ config SND_SOC_SPEYSIDE
185 select SND_SAMSUNG_I2S 185 select SND_SAMSUNG_I2S
186 select SND_SOC_WM8996 186 select SND_SOC_WM8996
187 select SND_SOC_WM9081 187 select SND_SOC_WM9081
188 select SND_SOC_WM1250_EV1
188 189
189config SND_SOC_SPEYSIDE_WM8962 190config SND_SOC_SPEYSIDE_WM8962
190 tristate "Audio support for Wolfson Speyside with WM8962" 191 tristate "Audio support for Wolfson Speyside with WM8962"
diff --git a/sound/soc/samsung/h1940_uda1380.c b/sound/soc/samsung/h1940_uda1380.c
index 241f55d00660..c6c65892294e 100644
--- a/sound/soc/samsung/h1940_uda1380.c
+++ b/sound/soc/samsung/h1940_uda1380.c
@@ -13,6 +13,7 @@
13 * 13 *
14 */ 14 */
15 15
16#include <linux/types.h>
16#include <linux/gpio.h> 17#include <linux/gpio.h>
17 18
18#include <sound/soc.h> 19#include <sound/soc.h>
diff --git a/sound/soc/samsung/rx1950_uda1380.c b/sound/soc/samsung/rx1950_uda1380.c
index 1e574a5d440d..bc8c1676459f 100644
--- a/sound/soc/samsung/rx1950_uda1380.c
+++ b/sound/soc/samsung/rx1950_uda1380.c
@@ -17,6 +17,7 @@
17 * 17 *
18 */ 18 */
19 19
20#include <linux/types.h>
20#include <linux/gpio.h> 21#include <linux/gpio.h>
21 22
22#include <sound/soc.h> 23#include <sound/soc.h>
diff --git a/sound/soc/samsung/speyside_wm8962.c b/sound/soc/samsung/speyside_wm8962.c
index 0b9eb5f7ec4c..72535f2daaf2 100644
--- a/sound/soc/samsung/speyside_wm8962.c
+++ b/sound/soc/samsung/speyside_wm8962.c
@@ -23,6 +23,9 @@ static int speyside_wm8962_set_bias_level(struct snd_soc_card *card,
23 struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai; 23 struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
24 int ret; 24 int ret;
25 25
26 if (dapm->dev != codec_dai->dev)
27 return 0;
28
26 switch (level) { 29 switch (level) {
27 case SND_SOC_BIAS_PREPARE: 30 case SND_SOC_BIAS_PREPARE:
28 if (dapm->bias_level == SND_SOC_BIAS_STANDBY) { 31 if (dapm->bias_level == SND_SOC_BIAS_STANDBY) {
@@ -57,6 +60,9 @@ static int speyside_wm8962_set_bias_level_post(struct snd_soc_card *card,
57 struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai; 60 struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
58 int ret; 61 int ret;
59 62
63 if (dapm->dev != codec_dai->dev)
64 return 0;
65
60 switch (level) { 66 switch (level) {
61 case SND_SOC_BIAS_STANDBY: 67 case SND_SOC_BIAS_STANDBY:
62 ret = snd_soc_dai_set_sysclk(codec_dai, WM8962_SYSCLK_MCLK, 68 ret = snd_soc_dai_set_sysclk(codec_dai, WM8962_SYSCLK_MCLK,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 83ad8ca27490..b085d8e87574 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1913,7 +1913,7 @@ struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
1913 1913
1914 if (prefix) { 1914 if (prefix) {
1915 name_len = strlen(long_name) + strlen(prefix) + 2; 1915 name_len = strlen(long_name) + strlen(prefix) + 2;
1916 name = kmalloc(name_len, GFP_ATOMIC); 1916 name = kmalloc(name_len, GFP_KERNEL);
1917 if (!name) 1917 if (!name)
1918 return NULL; 1918 return NULL;
1919 1919
diff --git a/sound/soc/soc-io.c b/sound/soc/soc-io.c
index cca490c80589..a62f7dd4ba96 100644
--- a/sound/soc/soc-io.c
+++ b/sound/soc/soc-io.c
@@ -205,6 +205,25 @@ static unsigned int snd_soc_16_8_read_i2c(struct snd_soc_codec *codec,
205#define snd_soc_16_8_read_i2c NULL 205#define snd_soc_16_8_read_i2c NULL
206#endif 206#endif
207 207
208#if defined(CONFIG_SPI_MASTER)
209static unsigned int snd_soc_16_8_read_spi(struct snd_soc_codec *codec,
210 unsigned int r)
211{
212 struct spi_device *spi = codec->control_data;
213
214 const u16 reg = cpu_to_be16(r | 0x100);
215 u8 data;
216 int ret;
217
218 ret = spi_write_then_read(spi, &reg, 2, &data, 1);
219 if (ret < 0)
220 return 0;
221 return data;
222}
223#else
224#define snd_soc_16_8_read_spi NULL
225#endif
226
208static int snd_soc_16_8_write(struct snd_soc_codec *codec, unsigned int reg, 227static int snd_soc_16_8_write(struct snd_soc_codec *codec, unsigned int reg,
209 unsigned int value) 228 unsigned int value)
210{ 229{
@@ -295,6 +314,7 @@ static struct {
295 int (*write)(struct snd_soc_codec *codec, unsigned int, unsigned int); 314 int (*write)(struct snd_soc_codec *codec, unsigned int, unsigned int);
296 unsigned int (*read)(struct snd_soc_codec *, unsigned int); 315 unsigned int (*read)(struct snd_soc_codec *, unsigned int);
297 unsigned int (*i2c_read)(struct snd_soc_codec *, unsigned int); 316 unsigned int (*i2c_read)(struct snd_soc_codec *, unsigned int);
317 unsigned int (*spi_read)(struct snd_soc_codec *, unsigned int);
298} io_types[] = { 318} io_types[] = {
299 { 319 {
300 .addr_bits = 4, .data_bits = 12, 320 .addr_bits = 4, .data_bits = 12,
@@ -318,6 +338,7 @@ static struct {
318 .addr_bits = 16, .data_bits = 8, 338 .addr_bits = 16, .data_bits = 8,
319 .write = snd_soc_16_8_write, 339 .write = snd_soc_16_8_write,
320 .i2c_read = snd_soc_16_8_read_i2c, 340 .i2c_read = snd_soc_16_8_read_i2c,
341 .spi_read = snd_soc_16_8_read_spi,
321 }, 342 },
322 { 343 {
323 .addr_bits = 16, .data_bits = 16, 344 .addr_bits = 16, .data_bits = 16,
@@ -383,6 +404,8 @@ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
383#ifdef CONFIG_SPI_MASTER 404#ifdef CONFIG_SPI_MASTER
384 codec->hw_write = do_spi_write; 405 codec->hw_write = do_spi_write;
385#endif 406#endif
407 if (io_types[i].spi_read)
408 codec->hw_read = io_types[i].spi_read;
386 409
387 codec->control_data = container_of(codec->dev, 410 codec->control_data = container_of(codec->dev,
388 struct spi_device, 411 struct spi_device,
diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c
index 7c17b98d5846..38b00131b2fe 100644
--- a/sound/soc/soc-jack.c
+++ b/sound/soc/soc-jack.c
@@ -327,7 +327,7 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
327 IRQF_TRIGGER_FALLING, 327 IRQF_TRIGGER_FALLING,
328 gpios[i].name, 328 gpios[i].name,
329 &gpios[i]); 329 &gpios[i]);
330 if (ret) 330 if (ret < 0)
331 goto err; 331 goto err;
332 332
333 if (gpios[i].wake) { 333 if (gpios[i].wake) {
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index b5759397afa3..2879c883eebc 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -290,6 +290,9 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
290 codec_dai->active--; 290 codec_dai->active--;
291 codec->active--; 291 codec->active--;
292 292
293 if (!cpu_dai->active && !codec_dai->active)
294 rtd->rate = 0;
295
293 /* Muting the DAC suppresses artifacts caused during digital 296 /* Muting the DAC suppresses artifacts caused during digital
294 * shutdown, for example from stopping clocks. 297 * shutdown, for example from stopping clocks.
295 */ 298 */
diff --git a/sound/soc/tegra/tegra_wm8903.c b/sound/soc/tegra/tegra_wm8903.c
index 661373c2352a..be27f1d229af 100644
--- a/sound/soc/tegra/tegra_wm8903.c
+++ b/sound/soc/tegra/tegra_wm8903.c
@@ -319,7 +319,7 @@ static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd)
319 snd_soc_dapm_force_enable_pin(dapm, "Mic Bias"); 319 snd_soc_dapm_force_enable_pin(dapm, "Mic Bias");
320 320
321 /* FIXME: Calculate automatically based on DAPM routes? */ 321 /* FIXME: Calculate automatically based on DAPM routes? */
322 if (!machine_is_harmony() && !machine_is_ventana()) 322 if (!machine_is_harmony())
323 snd_soc_dapm_nc_pin(dapm, "IN1L"); 323 snd_soc_dapm_nc_pin(dapm, "IN1L");
324 if (!machine_is_seaboard() && !machine_is_aebl()) 324 if (!machine_is_seaboard() && !machine_is_aebl())
325 snd_soc_dapm_nc_pin(dapm, "IN1R"); 325 snd_soc_dapm_nc_pin(dapm, "IN1R");
@@ -395,7 +395,7 @@ static __devinit int tegra_wm8903_driver_probe(struct platform_device *pdev)
395 platform_set_drvdata(pdev, card); 395 platform_set_drvdata(pdev, card);
396 snd_soc_card_set_drvdata(card, machine); 396 snd_soc_card_set_drvdata(card, machine);
397 397
398 if (machine_is_harmony() || machine_is_ventana()) { 398 if (machine_is_harmony()) {
399 card->dapm_routes = harmony_audio_map; 399 card->dapm_routes = harmony_audio_map;
400 card->num_dapm_routes = ARRAY_SIZE(harmony_audio_map); 400 card->num_dapm_routes = ARRAY_SIZE(harmony_audio_map);
401 } else if (machine_is_seaboard()) { 401 } else if (machine_is_seaboard()) {
diff --git a/tools/power/cpupower/Makefile b/tools/power/cpupower/Makefile
index 94c2cf0a98b8..e8a03aceceb1 100644
--- a/tools/power/cpupower/Makefile
+++ b/tools/power/cpupower/Makefile
@@ -24,7 +24,7 @@
24 24
25# Set the following to `true' to make a unstripped, unoptimized 25# Set the following to `true' to make a unstripped, unoptimized
26# binary. Leave this set to `false' for production use. 26# binary. Leave this set to `false' for production use.
27DEBUG ?= false 27DEBUG ?= true
28 28
29# make the build silent. Set this to something else to make it noisy again. 29# make the build silent. Set this to something else to make it noisy again.
30V ?= false 30V ?= false
@@ -35,7 +35,7 @@ NLS ?= true
35 35
36# Set the following to 'true' to build/install the 36# Set the following to 'true' to build/install the
37# cpufreq-bench benchmarking tool 37# cpufreq-bench benchmarking tool
38CPUFRQ_BENCH ?= true 38CPUFREQ_BENCH ?= true
39 39
40# Prefix to the directories we're installing to 40# Prefix to the directories we're installing to
41DESTDIR ?= 41DESTDIR ?=
@@ -137,9 +137,10 @@ CFLAGS += -pipe
137ifeq ($(strip $(NLS)),true) 137ifeq ($(strip $(NLS)),true)
138 INSTALL_NLS += install-gmo 138 INSTALL_NLS += install-gmo
139 COMPILE_NLS += create-gmo 139 COMPILE_NLS += create-gmo
140 CFLAGS += -DNLS
140endif 141endif
141 142
142ifeq ($(strip $(CPUFRQ_BENCH)),true) 143ifeq ($(strip $(CPUFREQ_BENCH)),true)
143 INSTALL_BENCH += install-bench 144 INSTALL_BENCH += install-bench
144 COMPILE_BENCH += compile-bench 145 COMPILE_BENCH += compile-bench
145endif 146endif
diff --git a/tools/power/cpupower/debug/x86_64/Makefile b/tools/power/cpupower/debug/x86_64/Makefile
index dbf13998462a..3326217dd311 100644
--- a/tools/power/cpupower/debug/x86_64/Makefile
+++ b/tools/power/cpupower/debug/x86_64/Makefile
@@ -1,10 +1,10 @@
1default: all 1default: all
2 2
3centrino-decode: centrino-decode.c 3centrino-decode: ../i386/centrino-decode.c
4 $(CC) $(CFLAGS) -o centrino-decode centrino-decode.c 4 $(CC) $(CFLAGS) -o $@ $<
5 5
6powernow-k8-decode: powernow-k8-decode.c 6powernow-k8-decode: ../i386/powernow-k8-decode.c
7 $(CC) $(CFLAGS) -o powernow-k8-decode powernow-k8-decode.c 7 $(CC) $(CFLAGS) -o $@ $<
8 8
9all: centrino-decode powernow-k8-decode 9all: centrino-decode powernow-k8-decode
10 10
diff --git a/tools/power/cpupower/debug/x86_64/centrino-decode.c b/tools/power/cpupower/debug/x86_64/centrino-decode.c
deleted file mode 120000
index 26fb3f1d8fc7..000000000000
--- a/tools/power/cpupower/debug/x86_64/centrino-decode.c
+++ /dev/null
@@ -1 +0,0 @@
1../i386/centrino-decode.c \ No newline at end of file
diff --git a/tools/power/cpupower/debug/x86_64/powernow-k8-decode.c b/tools/power/cpupower/debug/x86_64/powernow-k8-decode.c
deleted file mode 120000
index eb30c79cf9df..000000000000
--- a/tools/power/cpupower/debug/x86_64/powernow-k8-decode.c
+++ /dev/null
@@ -1 +0,0 @@
1../i386/powernow-k8-decode.c \ No newline at end of file
diff --git a/tools/power/cpupower/man/cpupower-frequency-info.1 b/tools/power/cpupower/man/cpupower-frequency-info.1
index 3194811d58f5..bb60a8d1e45a 100644
--- a/tools/power/cpupower/man/cpupower-frequency-info.1
+++ b/tools/power/cpupower/man/cpupower-frequency-info.1
@@ -1,10 +1,10 @@
1.TH "cpufreq-info" "1" "0.1" "Mattia Dongili" "" 1.TH "cpupower-frequency-info" "1" "0.1" "Mattia Dongili" ""
2.SH "NAME" 2.SH "NAME"
3.LP 3.LP
4cpufreq\-info \- Utility to retrieve cpufreq kernel information 4cpupower frequency\-info \- Utility to retrieve cpufreq kernel information
5.SH "SYNTAX" 5.SH "SYNTAX"
6.LP 6.LP
7cpufreq\-info [\fIoptions\fP] 7cpupower [ \-c cpulist ] frequency\-info [\fIoptions\fP]
8.SH "DESCRIPTION" 8.SH "DESCRIPTION"
9.LP 9.LP
10A small tool which prints out cpufreq information helpful to developers and interested users. 10A small tool which prints out cpufreq information helpful to developers and interested users.
diff --git a/tools/power/cpupower/man/cpupower-frequency-set.1 b/tools/power/cpupower/man/cpupower-frequency-set.1
index 26e3e13eee3b..685f469093ad 100644
--- a/tools/power/cpupower/man/cpupower-frequency-set.1
+++ b/tools/power/cpupower/man/cpupower-frequency-set.1
@@ -1,13 +1,13 @@
1.TH "cpufreq-set" "1" "0.1" "Mattia Dongili" "" 1.TH "cpupower-freqency-set" "1" "0.1" "Mattia Dongili" ""
2.SH "NAME" 2.SH "NAME"
3.LP 3.LP
4cpufreq\-set \- A small tool which allows to modify cpufreq settings. 4cpupower frequency\-set \- A small tool which allows to modify cpufreq settings.
5.SH "SYNTAX" 5.SH "SYNTAX"
6.LP 6.LP
7cpufreq\-set [\fIoptions\fP] 7cpupower [ \-c cpu ] frequency\-set [\fIoptions\fP]
8.SH "DESCRIPTION" 8.SH "DESCRIPTION"
9.LP 9.LP
10cpufreq\-set allows you to modify cpufreq settings without having to type e.g. "/sys/devices/system/cpu/cpu0/cpufreq/scaling_set_speed" all the time. 10cpupower frequency\-set allows you to modify cpufreq settings without having to type e.g. "/sys/devices/system/cpu/cpu0/cpufreq/scaling_set_speed" all the time.
11.SH "OPTIONS" 11.SH "OPTIONS"
12.LP 12.LP
13.TP 13.TP
diff --git a/tools/power/cpupower/man/cpupower.1 b/tools/power/cpupower/man/cpupower.1
index 78c20feab85c..baf741d06e82 100644
--- a/tools/power/cpupower/man/cpupower.1
+++ b/tools/power/cpupower/man/cpupower.1
@@ -3,7 +3,7 @@
3cpupower \- Shows and sets processor power related values 3cpupower \- Shows and sets processor power related values
4.SH SYNOPSIS 4.SH SYNOPSIS
5.ft B 5.ft B
6.B cpupower [ \-c cpulist ] subcommand [ARGS] 6.B cpupower [ \-c cpulist ] <command> [ARGS]
7 7
8.B cpupower \-v|\-\-version 8.B cpupower \-v|\-\-version
9 9
@@ -13,24 +13,24 @@ cpupower \- Shows and sets processor power related values
13\fBcpupower \fP is a collection of tools to examine and tune power saving 13\fBcpupower \fP is a collection of tools to examine and tune power saving
14related features of your processor. 14related features of your processor.
15 15
16The manpages of the subcommands (cpupower\-<subcommand>(1)) provide detailed 16The manpages of the commands (cpupower\-<command>(1)) provide detailed
17descriptions of supported features. Run \fBcpupower help\fP to get an overview 17descriptions of supported features. Run \fBcpupower help\fP to get an overview
18of supported subcommands. 18of supported commands.
19 19
20.SH Options 20.SH Options
21.PP 21.PP
22\-\-help, \-h 22\-\-help, \-h
23.RS 4 23.RS 4
24Shows supported subcommands and general usage. 24Shows supported commands and general usage.
25.RE 25.RE
26.PP 26.PP
27\-\-cpu cpulist, \-c cpulist 27\-\-cpu cpulist, \-c cpulist
28.RS 4 28.RS 4
29Only show or set values for specific cores. 29Only show or set values for specific cores.
30This option is not supported by all subcommands, details can be found in the 30This option is not supported by all commands, details can be found in the
31manpages of the subcommands. 31manpages of the commands.
32 32
33Some subcommands access all cores (typically the *\-set commands), some only 33Some commands access all cores (typically the *\-set commands), some only
34the first core (typically the *\-info commands) by default. 34the first core (typically the *\-info commands) by default.
35 35
36The syntax for <cpulist> is based on how the kernel exports CPU bitmasks via 36The syntax for <cpulist> is based on how the kernel exports CPU bitmasks via
diff --git a/tools/power/cpupower/utils/builtin.h b/tools/power/cpupower/utils/builtin.h
index c870ffba5219..c10496fbe3c6 100644
--- a/tools/power/cpupower/utils/builtin.h
+++ b/tools/power/cpupower/utils/builtin.h
@@ -8,11 +8,4 @@ extern int cmd_freq_info(int argc, const char **argv);
8extern int cmd_idle_info(int argc, const char **argv); 8extern int cmd_idle_info(int argc, const char **argv);
9extern int cmd_monitor(int argc, const char **argv); 9extern int cmd_monitor(int argc, const char **argv);
10 10
11extern void set_help(void);
12extern void info_help(void);
13extern void freq_set_help(void);
14extern void freq_info_help(void);
15extern void idle_info_help(void);
16extern void monitor_help(void);
17
18#endif 11#endif
diff --git a/tools/power/cpupower/utils/cpufreq-info.c b/tools/power/cpupower/utils/cpufreq-info.c
index 5a1d25f056b3..28953c9a7bd5 100644
--- a/tools/power/cpupower/utils/cpufreq-info.c
+++ b/tools/power/cpupower/utils/cpufreq-info.c
@@ -510,37 +510,6 @@ static int get_latency(unsigned int cpu, unsigned int human)
510 return 0; 510 return 0;
511} 511}
512 512
513void freq_info_help(void)
514{
515 printf(_("Usage: cpupower freqinfo [options]\n"));
516 printf(_("Options:\n"));
517 printf(_(" -e, --debug Prints out debug information [default]\n"));
518 printf(_(" -f, --freq Get frequency the CPU currently runs at, according\n"
519 " to the cpufreq core *\n"));
520 printf(_(" -w, --hwfreq Get frequency the CPU currently runs at, by reading\n"
521 " it from hardware (only available to root) *\n"));
522 printf(_(" -l, --hwlimits Determine the minimum and maximum CPU frequency allowed *\n"));
523 printf(_(" -d, --driver Determines the used cpufreq kernel driver *\n"));
524 printf(_(" -p, --policy Gets the currently used cpufreq policy *\n"));
525 printf(_(" -g, --governors Determines available cpufreq governors *\n"));
526 printf(_(" -r, --related-cpus Determines which CPUs run at the same hardware frequency *\n"));
527 printf(_(" -a, --affected-cpus Determines which CPUs need to have their frequency\n"
528 " coordinated by software *\n"));
529 printf(_(" -s, --stats Shows cpufreq statistics if available\n"));
530 printf(_(" -y, --latency Determines the maximum latency on CPU frequency changes *\n"));
531 printf(_(" -b, --boost Checks for turbo or boost modes *\n"));
532 printf(_(" -o, --proc Prints out information like provided by the /proc/cpufreq\n"
533 " interface in 2.4. and early 2.6. kernels\n"));
534 printf(_(" -m, --human human-readable output for the -f, -w, -s and -y parameters\n"));
535 printf(_(" -h, --help Prints out this screen\n"));
536
537 printf("\n");
538 printf(_("If no argument is given, full output about\n"
539 "cpufreq is printed which is useful e.g. for reporting bugs.\n\n"));
540 printf(_("By default info of CPU 0 is shown which can be overridden\n"
541 "with the cpupower --cpu main command option.\n"));
542}
543
544static struct option info_opts[] = { 513static struct option info_opts[] = {
545 { .name = "debug", .has_arg = no_argument, .flag = NULL, .val = 'e'}, 514 { .name = "debug", .has_arg = no_argument, .flag = NULL, .val = 'e'},
546 { .name = "boost", .has_arg = no_argument, .flag = NULL, .val = 'b'}, 515 { .name = "boost", .has_arg = no_argument, .flag = NULL, .val = 'b'},
@@ -556,7 +525,6 @@ static struct option info_opts[] = {
556 { .name = "latency", .has_arg = no_argument, .flag = NULL, .val = 'y'}, 525 { .name = "latency", .has_arg = no_argument, .flag = NULL, .val = 'y'},
557 { .name = "proc", .has_arg = no_argument, .flag = NULL, .val = 'o'}, 526 { .name = "proc", .has_arg = no_argument, .flag = NULL, .val = 'o'},
558 { .name = "human", .has_arg = no_argument, .flag = NULL, .val = 'm'}, 527 { .name = "human", .has_arg = no_argument, .flag = NULL, .val = 'm'},
559 { .name = "help", .has_arg = no_argument, .flag = NULL, .val = 'h'},
560 { }, 528 { },
561}; 529};
562 530
@@ -570,16 +538,12 @@ int cmd_freq_info(int argc, char **argv)
570 int output_param = 0; 538 int output_param = 0;
571 539
572 do { 540 do {
573 ret = getopt_long(argc, argv, "hoefwldpgrasmyb", info_opts, NULL); 541 ret = getopt_long(argc, argv, "oefwldpgrasmyb", info_opts, NULL);
574 switch (ret) { 542 switch (ret) {
575 case '?': 543 case '?':
576 output_param = '?'; 544 output_param = '?';
577 cont = 0; 545 cont = 0;
578 break; 546 break;
579 case 'h':
580 output_param = 'h';
581 cont = 0;
582 break;
583 case -1: 547 case -1:
584 cont = 0; 548 cont = 0;
585 break; 549 break;
@@ -642,11 +606,7 @@ int cmd_freq_info(int argc, char **argv)
642 return -EINVAL; 606 return -EINVAL;
643 case '?': 607 case '?':
644 printf(_("invalid or unknown argument\n")); 608 printf(_("invalid or unknown argument\n"));
645 freq_info_help();
646 return -EINVAL; 609 return -EINVAL;
647 case 'h':
648 freq_info_help();
649 return EXIT_SUCCESS;
650 case 'o': 610 case 'o':
651 proc_cpufreq_output(); 611 proc_cpufreq_output();
652 return EXIT_SUCCESS; 612 return EXIT_SUCCESS;
diff --git a/tools/power/cpupower/utils/cpufreq-set.c b/tools/power/cpupower/utils/cpufreq-set.c
index 5f783622bf31..dd1539eb8c63 100644
--- a/tools/power/cpupower/utils/cpufreq-set.c
+++ b/tools/power/cpupower/utils/cpufreq-set.c
@@ -20,34 +20,11 @@
20 20
21#define NORM_FREQ_LEN 32 21#define NORM_FREQ_LEN 32
22 22
23void freq_set_help(void)
24{
25 printf(_("Usage: cpupower frequency-set [options]\n"));
26 printf(_("Options:\n"));
27 printf(_(" -d FREQ, --min FREQ new minimum CPU frequency the governor may select\n"));
28 printf(_(" -u FREQ, --max FREQ new maximum CPU frequency the governor may select\n"));
29 printf(_(" -g GOV, --governor GOV new cpufreq governor\n"));
30 printf(_(" -f FREQ, --freq FREQ specific frequency to be set. Requires userspace\n"
31 " governor to be available and loaded\n"));
32 printf(_(" -r, --related Switches all hardware-related CPUs\n"));
33 printf(_(" -h, --help Prints out this screen\n"));
34 printf("\n");
35 printf(_("Notes:\n"
36 "1. Omitting the -c or --cpu argument is equivalent to setting it to \"all\"\n"));
37 printf(_("2. The -f FREQ, --freq FREQ parameter cannot be combined with any other parameter\n"
38 " except the -c CPU, --cpu CPU parameter\n"
39 "3. FREQuencies can be passed in Hz, kHz (default), MHz, GHz, or THz\n"
40 " by postfixing the value with the wanted unit name, without any space\n"
41 " (FREQuency in kHz =^ Hz * 0.001 =^ MHz * 1000 =^ GHz * 1000000).\n"));
42
43}
44
45static struct option set_opts[] = { 23static struct option set_opts[] = {
46 { .name = "min", .has_arg = required_argument, .flag = NULL, .val = 'd'}, 24 { .name = "min", .has_arg = required_argument, .flag = NULL, .val = 'd'},
47 { .name = "max", .has_arg = required_argument, .flag = NULL, .val = 'u'}, 25 { .name = "max", .has_arg = required_argument, .flag = NULL, .val = 'u'},
48 { .name = "governor", .has_arg = required_argument, .flag = NULL, .val = 'g'}, 26 { .name = "governor", .has_arg = required_argument, .flag = NULL, .val = 'g'},
49 { .name = "freq", .has_arg = required_argument, .flag = NULL, .val = 'f'}, 27 { .name = "freq", .has_arg = required_argument, .flag = NULL, .val = 'f'},
50 { .name = "help", .has_arg = no_argument, .flag = NULL, .val = 'h'},
51 { .name = "related", .has_arg = no_argument, .flag = NULL, .val='r'}, 28 { .name = "related", .has_arg = no_argument, .flag = NULL, .val='r'},
52 { }, 29 { },
53}; 30};
@@ -80,7 +57,6 @@ const struct freq_units def_units[] = {
80static void print_unknown_arg(void) 57static void print_unknown_arg(void)
81{ 58{
82 printf(_("invalid or unknown argument\n")); 59 printf(_("invalid or unknown argument\n"));
83 freq_set_help();
84} 60}
85 61
86static unsigned long string_to_frequency(const char *str) 62static unsigned long string_to_frequency(const char *str)
@@ -231,14 +207,11 @@ int cmd_freq_set(int argc, char **argv)
231 207
232 /* parameter parsing */ 208 /* parameter parsing */
233 do { 209 do {
234 ret = getopt_long(argc, argv, "d:u:g:f:hr", set_opts, NULL); 210 ret = getopt_long(argc, argv, "d:u:g:f:r", set_opts, NULL);
235 switch (ret) { 211 switch (ret) {
236 case '?': 212 case '?':
237 print_unknown_arg(); 213 print_unknown_arg();
238 return -EINVAL; 214 return -EINVAL;
239 case 'h':
240 freq_set_help();
241 return 0;
242 case -1: 215 case -1:
243 cont = 0; 216 cont = 0;
244 break; 217 break;
diff --git a/tools/power/cpupower/utils/cpuidle-info.c b/tools/power/cpupower/utils/cpuidle-info.c
index 70da3574f1e9..b028267c1376 100644
--- a/tools/power/cpupower/utils/cpuidle-info.c
+++ b/tools/power/cpupower/utils/cpuidle-info.c
@@ -139,30 +139,14 @@ static void proc_cpuidle_cpu_output(unsigned int cpu)
139 } 139 }
140} 140}
141 141
142/* --freq / -f */
143
144void idle_info_help(void)
145{
146 printf(_ ("Usage: cpupower idleinfo [options]\n"));
147 printf(_ ("Options:\n"));
148 printf(_ (" -s, --silent Only show general C-state information\n"));
149 printf(_ (" -o, --proc Prints out information like provided by the /proc/acpi/processor/*/power\n"
150 " interface in older kernels\n"));
151 printf(_ (" -h, --help Prints out this screen\n"));
152
153 printf("\n");
154}
155
156static struct option info_opts[] = { 142static struct option info_opts[] = {
157 { .name = "silent", .has_arg = no_argument, .flag = NULL, .val = 's'}, 143 { .name = "silent", .has_arg = no_argument, .flag = NULL, .val = 's'},
158 { .name = "proc", .has_arg = no_argument, .flag = NULL, .val = 'o'}, 144 { .name = "proc", .has_arg = no_argument, .flag = NULL, .val = 'o'},
159 { .name = "help", .has_arg = no_argument, .flag = NULL, .val = 'h'},
160 { }, 145 { },
161}; 146};
162 147
163static inline void cpuidle_exit(int fail) 148static inline void cpuidle_exit(int fail)
164{ 149{
165 idle_info_help();
166 exit(EXIT_FAILURE); 150 exit(EXIT_FAILURE);
167} 151}
168 152
@@ -174,7 +158,7 @@ int cmd_idle_info(int argc, char **argv)
174 unsigned int cpu = 0; 158 unsigned int cpu = 0;
175 159
176 do { 160 do {
177 ret = getopt_long(argc, argv, "hos", info_opts, NULL); 161 ret = getopt_long(argc, argv, "os", info_opts, NULL);
178 if (ret == -1) 162 if (ret == -1)
179 break; 163 break;
180 switch (ret) { 164 switch (ret) {
@@ -182,10 +166,6 @@ int cmd_idle_info(int argc, char **argv)
182 output_param = '?'; 166 output_param = '?';
183 cont = 0; 167 cont = 0;
184 break; 168 break;
185 case 'h':
186 output_param = 'h';
187 cont = 0;
188 break;
189 case 's': 169 case 's':
190 verbose = 0; 170 verbose = 0;
191 break; 171 break;
@@ -211,8 +191,6 @@ int cmd_idle_info(int argc, char **argv)
211 case '?': 191 case '?':
212 printf(_("invalid or unknown argument\n")); 192 printf(_("invalid or unknown argument\n"));
213 cpuidle_exit(EXIT_FAILURE); 193 cpuidle_exit(EXIT_FAILURE);
214 case 'h':
215 cpuidle_exit(EXIT_SUCCESS);
216 } 194 }
217 195
218 /* Default is: show output of CPU 0 only */ 196 /* Default is: show output of CPU 0 only */
diff --git a/tools/power/cpupower/utils/cpupower-info.c b/tools/power/cpupower/utils/cpupower-info.c
index 85253cb7600e..3f68632c28c7 100644
--- a/tools/power/cpupower/utils/cpupower-info.c
+++ b/tools/power/cpupower/utils/cpupower-info.c
@@ -16,31 +16,16 @@
16#include "helpers/helpers.h" 16#include "helpers/helpers.h"
17#include "helpers/sysfs.h" 17#include "helpers/sysfs.h"
18 18
19void info_help(void)
20{
21 printf(_("Usage: cpupower info [ -b ] [ -m ] [ -s ]\n"));
22 printf(_("Options:\n"));
23 printf(_(" -b, --perf-bias Gets CPU's power vs performance policy on some\n"
24 " Intel models [0-15], see manpage for details\n"));
25 printf(_(" -m, --sched-mc Gets the kernel's multi core scheduler policy.\n"));
26 printf(_(" -s, --sched-smt Gets the kernel's thread sibling scheduler policy.\n"));
27 printf(_(" -h, --help Prints out this screen\n"));
28 printf(_("\nPassing no option will show all info, by default only on core 0\n"));
29 printf("\n");
30}
31
32static struct option set_opts[] = { 19static struct option set_opts[] = {
33 { .name = "perf-bias", .has_arg = optional_argument, .flag = NULL, .val = 'b'}, 20 { .name = "perf-bias", .has_arg = optional_argument, .flag = NULL, .val = 'b'},
34 { .name = "sched-mc", .has_arg = optional_argument, .flag = NULL, .val = 'm'}, 21 { .name = "sched-mc", .has_arg = optional_argument, .flag = NULL, .val = 'm'},
35 { .name = "sched-smt", .has_arg = optional_argument, .flag = NULL, .val = 's'}, 22 { .name = "sched-smt", .has_arg = optional_argument, .flag = NULL, .val = 's'},
36 { .name = "help", .has_arg = no_argument, .flag = NULL, .val = 'h'},
37 { }, 23 { },
38}; 24};
39 25
40static void print_wrong_arg_exit(void) 26static void print_wrong_arg_exit(void)
41{ 27{
42 printf(_("invalid or unknown argument\n")); 28 printf(_("invalid or unknown argument\n"));
43 info_help();
44 exit(EXIT_FAILURE); 29 exit(EXIT_FAILURE);
45} 30}
46 31
@@ -64,11 +49,8 @@ int cmd_info(int argc, char **argv)
64 textdomain(PACKAGE); 49 textdomain(PACKAGE);
65 50
66 /* parameter parsing */ 51 /* parameter parsing */
67 while ((ret = getopt_long(argc, argv, "msbh", set_opts, NULL)) != -1) { 52 while ((ret = getopt_long(argc, argv, "msb", set_opts, NULL)) != -1) {
68 switch (ret) { 53 switch (ret) {
69 case 'h':
70 info_help();
71 return 0;
72 case 'b': 54 case 'b':
73 if (params.perf_bias) 55 if (params.perf_bias)
74 print_wrong_arg_exit(); 56 print_wrong_arg_exit();
diff --git a/tools/power/cpupower/utils/cpupower-set.c b/tools/power/cpupower/utils/cpupower-set.c
index bc1b391e46f0..dc4de3762111 100644
--- a/tools/power/cpupower/utils/cpupower-set.c
+++ b/tools/power/cpupower/utils/cpupower-set.c
@@ -17,30 +17,16 @@
17#include "helpers/sysfs.h" 17#include "helpers/sysfs.h"
18#include "helpers/bitmask.h" 18#include "helpers/bitmask.h"
19 19
20void set_help(void)
21{
22 printf(_("Usage: cpupower set [ -b val ] [ -m val ] [ -s val ]\n"));
23 printf(_("Options:\n"));
24 printf(_(" -b, --perf-bias [VAL] Sets CPU's power vs performance policy on some\n"
25 " Intel models [0-15], see manpage for details\n"));
26 printf(_(" -m, --sched-mc [VAL] Sets the kernel's multi core scheduler policy.\n"));
27 printf(_(" -s, --sched-smt [VAL] Sets the kernel's thread sibling scheduler policy.\n"));
28 printf(_(" -h, --help Prints out this screen\n"));
29 printf("\n");
30}
31
32static struct option set_opts[] = { 20static struct option set_opts[] = {
33 { .name = "perf-bias", .has_arg = optional_argument, .flag = NULL, .val = 'b'}, 21 { .name = "perf-bias", .has_arg = optional_argument, .flag = NULL, .val = 'b'},
34 { .name = "sched-mc", .has_arg = optional_argument, .flag = NULL, .val = 'm'}, 22 { .name = "sched-mc", .has_arg = optional_argument, .flag = NULL, .val = 'm'},
35 { .name = "sched-smt", .has_arg = optional_argument, .flag = NULL, .val = 's'}, 23 { .name = "sched-smt", .has_arg = optional_argument, .flag = NULL, .val = 's'},
36 { .name = "help", .has_arg = no_argument, .flag = NULL, .val = 'h'},
37 { }, 24 { },
38}; 25};
39 26
40static void print_wrong_arg_exit(void) 27static void print_wrong_arg_exit(void)
41{ 28{
42 printf(_("invalid or unknown argument\n")); 29 printf(_("invalid or unknown argument\n"));
43 set_help();
44 exit(EXIT_FAILURE); 30 exit(EXIT_FAILURE);
45} 31}
46 32
@@ -66,12 +52,9 @@ int cmd_set(int argc, char **argv)
66 52
67 params.params = 0; 53 params.params = 0;
68 /* parameter parsing */ 54 /* parameter parsing */
69 while ((ret = getopt_long(argc, argv, "m:s:b:h", 55 while ((ret = getopt_long(argc, argv, "m:s:b:",
70 set_opts, NULL)) != -1) { 56 set_opts, NULL)) != -1) {
71 switch (ret) { 57 switch (ret) {
72 case 'h':
73 set_help();
74 return 0;
75 case 'b': 58 case 'b':
76 if (params.perf_bias) 59 if (params.perf_bias)
77 print_wrong_arg_exit(); 60 print_wrong_arg_exit();
@@ -110,10 +93,8 @@ int cmd_set(int argc, char **argv)
110 } 93 }
111 }; 94 };
112 95
113 if (!params.params) { 96 if (!params.params)
114 set_help(); 97 print_wrong_arg_exit();
115 return -EINVAL;
116 }
117 98
118 if (params.sched_mc) { 99 if (params.sched_mc) {
119 ret = sysfs_set_sched("mc", sched_mc); 100 ret = sysfs_set_sched("mc", sched_mc);
diff --git a/tools/power/cpupower/utils/cpupower.c b/tools/power/cpupower/utils/cpupower.c
index 5844ae0f786f..52bee591c1c5 100644
--- a/tools/power/cpupower/utils/cpupower.c
+++ b/tools/power/cpupower/utils/cpupower.c
@@ -11,6 +11,7 @@
11#include <stdlib.h> 11#include <stdlib.h>
12#include <string.h> 12#include <string.h>
13#include <unistd.h> 13#include <unistd.h>
14#include <errno.h>
14 15
15#include "builtin.h" 16#include "builtin.h"
16#include "helpers/helpers.h" 17#include "helpers/helpers.h"
@@ -19,13 +20,12 @@
19struct cmd_struct { 20struct cmd_struct {
20 const char *cmd; 21 const char *cmd;
21 int (*main)(int, const char **); 22 int (*main)(int, const char **);
22 void (*usage)(void);
23 int needs_root; 23 int needs_root;
24}; 24};
25 25
26#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) 26#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
27 27
28int cmd_help(int argc, const char **argv); 28static int cmd_help(int argc, const char **argv);
29 29
30/* Global cpu_info object available for all binaries 30/* Global cpu_info object available for all binaries
31 * Info only retrieved from CPU 0 31 * Info only retrieved from CPU 0
@@ -44,55 +44,66 @@ int be_verbose;
44static void print_help(void); 44static void print_help(void);
45 45
46static struct cmd_struct commands[] = { 46static struct cmd_struct commands[] = {
47 { "frequency-info", cmd_freq_info, freq_info_help, 0 }, 47 { "frequency-info", cmd_freq_info, 0 },
48 { "frequency-set", cmd_freq_set, freq_set_help, 1 }, 48 { "frequency-set", cmd_freq_set, 1 },
49 { "idle-info", cmd_idle_info, idle_info_help, 0 }, 49 { "idle-info", cmd_idle_info, 0 },
50 { "set", cmd_set, set_help, 1 }, 50 { "set", cmd_set, 1 },
51 { "info", cmd_info, info_help, 0 }, 51 { "info", cmd_info, 0 },
52 { "monitor", cmd_monitor, monitor_help, 0 }, 52 { "monitor", cmd_monitor, 0 },
53 { "help", cmd_help, print_help, 0 }, 53 { "help", cmd_help, 0 },
54 /* { "bench", cmd_bench, NULL, 1 }, */ 54 /* { "bench", cmd_bench, 1 }, */
55}; 55};
56 56
57int cmd_help(int argc, const char **argv)
58{
59 unsigned int i;
60
61 if (argc > 1) {
62 for (i = 0; i < ARRAY_SIZE(commands); i++) {
63 struct cmd_struct *p = commands + i;
64 if (strcmp(p->cmd, argv[1]))
65 continue;
66 if (p->usage) {
67 p->usage();
68 return EXIT_SUCCESS;
69 }
70 }
71 }
72 print_help();
73 if (argc == 1)
74 return EXIT_SUCCESS; /* cpupower help */
75 return EXIT_FAILURE;
76}
77
78static void print_help(void) 57static void print_help(void)
79{ 58{
80 unsigned int i; 59 unsigned int i;
81 60
82#ifdef DEBUG 61#ifdef DEBUG
83 printf(_("cpupower [ -d ][ -c cpulist ] subcommand [ARGS]\n")); 62 printf(_("Usage:\tcpupower [-d|--debug] [-c|--cpu cpulist ] <command> [<args>]\n"));
84 printf(_(" -d, --debug May increase output (stderr) on some subcommands\n"));
85#else 63#else
86 printf(_("cpupower [ -c cpulist ] subcommand [ARGS]\n")); 64 printf(_("Usage:\tcpupower [-c|--cpu cpulist ] <command> [<args>]\n"));
87#endif 65#endif
88 printf(_("cpupower --version\n")); 66 printf(_("Supported commands are:\n"));
89 printf(_("Supported subcommands are:\n"));
90 for (i = 0; i < ARRAY_SIZE(commands); i++) 67 for (i = 0; i < ARRAY_SIZE(commands); i++)
91 printf("\t%s\n", commands[i].cmd); 68 printf("\t%s\n", commands[i].cmd);
92 printf(_("\nSome subcommands can make use of the -c cpulist option.\n")); 69 printf(_("\nNot all commands can make use of the -c cpulist option.\n"));
93 printf(_("Look at the general cpupower manpage how to use it\n")); 70 printf(_("\nUse 'cpupower help <command>' for getting help for above commands.\n"));
94 printf(_("and read up the subcommand's manpage whether it is supported.\n")); 71}
95 printf(_("\nUse cpupower help subcommand for getting help for above subcommands.\n")); 72
73static int print_man_page(const char *subpage)
74{
75 int len;
76 char *page;
77
78 len = 10; /* enough for "cpupower-" */
79 if (subpage != NULL)
80 len += strlen(subpage);
81
82 page = malloc(len);
83 if (!page)
84 return -ENOMEM;
85
86 sprintf(page, "cpupower");
87 if ((subpage != NULL) && strcmp(subpage, "help")) {
88 strcat(page, "-");
89 strcat(page, subpage);
90 }
91
92 execlp("man", "man", page, NULL);
93
94 /* should not be reached */
95 return -EINVAL;
96}
97
98static int cmd_help(int argc, const char **argv)
99{
100 if (argc > 1) {
101 print_man_page(argv[1]); /* exits within execlp() */
102 return EXIT_FAILURE;
103 }
104
105 print_help();
106 return EXIT_SUCCESS;
96} 107}
97 108
98static void print_version(void) 109static void print_version(void)
diff --git a/tools/power/cpupower/utils/helpers/helpers.h b/tools/power/cpupower/utils/helpers/helpers.h
index 592ee362b877..2747e738efb0 100644
--- a/tools/power/cpupower/utils/helpers/helpers.h
+++ b/tools/power/cpupower/utils/helpers/helpers.h
@@ -16,11 +16,20 @@
16#include "helpers/bitmask.h" 16#include "helpers/bitmask.h"
17 17
18/* Internationalization ****************************/ 18/* Internationalization ****************************/
19#ifdef NLS
20
19#define _(String) gettext(String) 21#define _(String) gettext(String)
20#ifndef gettext_noop 22#ifndef gettext_noop
21#define gettext_noop(String) String 23#define gettext_noop(String) String
22#endif 24#endif
23#define N_(String) gettext_noop(String) 25#define N_(String) gettext_noop(String)
26
27#else /* !NLS */
28
29#define _(String) String
30#define N_(String) String
31
32#endif
24/* Internationalization ****************************/ 33/* Internationalization ****************************/
25 34
26extern int run_as_root; 35extern int run_as_root;
@@ -96,6 +105,9 @@ struct cpupower_topology {
96 int pkg; 105 int pkg;
97 int core; 106 int core;
98 int cpu; 107 int cpu;
108
109 /* flags */
110 unsigned int is_online:1;
99 } *core_info; 111 } *core_info;
100}; 112};
101 113
diff --git a/tools/power/cpupower/utils/helpers/sysfs.c b/tools/power/cpupower/utils/helpers/sysfs.c
index 55e2466674c6..c6343024a611 100644
--- a/tools/power/cpupower/utils/helpers/sysfs.c
+++ b/tools/power/cpupower/utils/helpers/sysfs.c
@@ -56,6 +56,56 @@ static unsigned int sysfs_write_file(const char *path,
56 return (unsigned int) numwrite; 56 return (unsigned int) numwrite;
57} 57}
58 58
59/*
60 * Detect whether a CPU is online
61 *
62 * Returns:
63 * 1 -> if CPU is online
64 * 0 -> if CPU is offline
65 * negative errno values in error case
66 */
67int sysfs_is_cpu_online(unsigned int cpu)
68{
69 char path[SYSFS_PATH_MAX];
70 int fd;
71 ssize_t numread;
72 unsigned long long value;
73 char linebuf[MAX_LINE_LEN];
74 char *endp;
75 struct stat statbuf;
76
77 snprintf(path, sizeof(path), PATH_TO_CPU "cpu%u", cpu);
78
79 if (stat(path, &statbuf) != 0)
80 return 0;
81
82 /*
83 * kernel without CONFIG_HOTPLUG_CPU
84 * -> cpuX directory exists, but not cpuX/online file
85 */
86 snprintf(path, sizeof(path), PATH_TO_CPU "cpu%u/online", cpu);
87 if (stat(path, &statbuf) != 0)
88 return 1;
89
90 fd = open(path, O_RDONLY);
91 if (fd == -1)
92 return -errno;
93
94 numread = read(fd, linebuf, MAX_LINE_LEN - 1);
95 if (numread < 1) {
96 close(fd);
97 return -EIO;
98 }
99 linebuf[numread] = '\0';
100 close(fd);
101
102 value = strtoull(linebuf, &endp, 0);
103 if (value > 1 || value < 0)
104 return -EINVAL;
105
106 return value;
107}
108
59/* CPUidle idlestate specific /sys/devices/system/cpu/cpuX/cpuidle/ access */ 109/* CPUidle idlestate specific /sys/devices/system/cpu/cpuX/cpuidle/ access */
60 110
61/* 111/*
diff --git a/tools/power/cpupower/utils/helpers/sysfs.h b/tools/power/cpupower/utils/helpers/sysfs.h
index f9373e090637..8cb797bbceb0 100644
--- a/tools/power/cpupower/utils/helpers/sysfs.h
+++ b/tools/power/cpupower/utils/helpers/sysfs.h
@@ -7,6 +7,8 @@
7 7
8extern unsigned int sysfs_read_file(const char *path, char *buf, size_t buflen); 8extern unsigned int sysfs_read_file(const char *path, char *buf, size_t buflen);
9 9
10extern int sysfs_is_cpu_online(unsigned int cpu);
11
10extern unsigned long sysfs_get_idlestate_latency(unsigned int cpu, 12extern unsigned long sysfs_get_idlestate_latency(unsigned int cpu,
11 unsigned int idlestate); 13 unsigned int idlestate);
12extern unsigned long sysfs_get_idlestate_usage(unsigned int cpu, 14extern unsigned long sysfs_get_idlestate_usage(unsigned int cpu,
diff --git a/tools/power/cpupower/utils/helpers/topology.c b/tools/power/cpupower/utils/helpers/topology.c
index 385ee5c7570c..4eae2c47ba48 100644
--- a/tools/power/cpupower/utils/helpers/topology.c
+++ b/tools/power/cpupower/utils/helpers/topology.c
@@ -41,6 +41,8 @@ struct cpuid_core_info {
41 unsigned int pkg; 41 unsigned int pkg;
42 unsigned int thread; 42 unsigned int thread;
43 unsigned int cpu; 43 unsigned int cpu;
44 /* flags */
45 unsigned int is_online:1;
44}; 46};
45 47
46static int __compare(const void *t1, const void *t2) 48static int __compare(const void *t1, const void *t2)
@@ -78,6 +80,8 @@ int get_cpu_topology(struct cpupower_topology *cpu_top)
78 return -ENOMEM; 80 return -ENOMEM;
79 cpu_top->pkgs = cpu_top->cores = 0; 81 cpu_top->pkgs = cpu_top->cores = 0;
80 for (cpu = 0; cpu < cpus; cpu++) { 82 for (cpu = 0; cpu < cpus; cpu++) {
83 cpu_top->core_info[cpu].cpu = cpu;
84 cpu_top->core_info[cpu].is_online = sysfs_is_cpu_online(cpu);
81 cpu_top->core_info[cpu].pkg = 85 cpu_top->core_info[cpu].pkg =
82 sysfs_topology_read_file(cpu, "physical_package_id"); 86 sysfs_topology_read_file(cpu, "physical_package_id");
83 if ((int)cpu_top->core_info[cpu].pkg != -1 && 87 if ((int)cpu_top->core_info[cpu].pkg != -1 &&
@@ -85,7 +89,6 @@ int get_cpu_topology(struct cpupower_topology *cpu_top)
85 cpu_top->pkgs = cpu_top->core_info[cpu].pkg; 89 cpu_top->pkgs = cpu_top->core_info[cpu].pkg;
86 cpu_top->core_info[cpu].core = 90 cpu_top->core_info[cpu].core =
87 sysfs_topology_read_file(cpu, "core_id"); 91 sysfs_topology_read_file(cpu, "core_id");
88 cpu_top->core_info[cpu].cpu = cpu;
89 } 92 }
90 cpu_top->pkgs++; 93 cpu_top->pkgs++;
91 94
diff --git a/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c b/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c
index d048b96a6155..bcd22a1a3970 100644
--- a/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c
+++ b/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c
@@ -134,7 +134,7 @@ static struct cpuidle_monitor *cpuidle_register(void)
134 /* Assume idle state count is the same for all CPUs */ 134 /* Assume idle state count is the same for all CPUs */
135 cpuidle_sysfs_monitor.hw_states_num = sysfs_get_idlestate_count(0); 135 cpuidle_sysfs_monitor.hw_states_num = sysfs_get_idlestate_count(0);
136 136
137 if (cpuidle_sysfs_monitor.hw_states_num == 0) 137 if (cpuidle_sysfs_monitor.hw_states_num <= 0)
138 return NULL; 138 return NULL;
139 139
140 for (num = 0; num < cpuidle_sysfs_monitor.hw_states_num; num++) { 140 for (num = 0; num < cpuidle_sysfs_monitor.hw_states_num; num++) {
diff --git a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
index ba4bf068380d..0d6571e418db 100644
--- a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
+++ b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
@@ -43,6 +43,12 @@ static struct cpupower_topology cpu_top;
43/* ToDo: Document this in the manpage */ 43/* ToDo: Document this in the manpage */
44static char range_abbr[RANGE_MAX] = { 'T', 'C', 'P', 'M', }; 44static char range_abbr[RANGE_MAX] = { 'T', 'C', 'P', 'M', };
45 45
46static void print_wrong_arg_exit(void)
47{
48 printf(_("invalid or unknown argument\n"));
49 exit(EXIT_FAILURE);
50}
51
46long long timespec_diff_us(struct timespec start, struct timespec end) 52long long timespec_diff_us(struct timespec start, struct timespec end)
47{ 53{
48 struct timespec temp; 54 struct timespec temp;
@@ -56,21 +62,6 @@ long long timespec_diff_us(struct timespec start, struct timespec end)
56 return (temp.tv_sec * 1000000) + (temp.tv_nsec / 1000); 62 return (temp.tv_sec * 1000000) + (temp.tv_nsec / 1000);
57} 63}
58 64
59void monitor_help(void)
60{
61 printf(_("cpupower monitor: [-m <mon1>,[<mon2>],.. ] command\n"));
62 printf(_("cpupower monitor: [-m <mon1>,[<mon2>],.. ] [ -i interval_sec ]\n"));
63 printf(_("cpupower monitor: -l\n"));
64 printf(_("\t command: pass an arbitrary command to measure specific workload\n"));
65 printf(_("\t -i: time intervall to measure for in seconds (default 1)\n"));
66 printf(_("\t -l: list available CPU sleep monitors (for use with -m)\n"));
67 printf(_("\t -m: show specific CPU sleep monitors only (in same order)\n"));
68 printf(_("\t -h: print this help\n"));
69 printf("\n");
70 printf(_("only one of: -l, -m are allowed\nIf none of them is passed,"));
71 printf(_(" all supported monitors are shown\n"));
72}
73
74void print_n_spaces(int n) 65void print_n_spaces(int n)
75{ 66{
76 int x; 67 int x;
@@ -149,6 +140,10 @@ void print_results(int topology_depth, int cpu)
149 unsigned long long result; 140 unsigned long long result;
150 cstate_t s; 141 cstate_t s;
151 142
143 /* Be careful CPUs may got resorted for pkg value do not just use cpu */
144 if (!bitmask_isbitset(cpus_chosen, cpu_top.core_info[cpu].cpu))
145 return;
146
152 if (topology_depth > 2) 147 if (topology_depth > 2)
153 printf("%4d|", cpu_top.core_info[cpu].pkg); 148 printf("%4d|", cpu_top.core_info[cpu].pkg);
154 if (topology_depth > 1) 149 if (topology_depth > 1)
@@ -190,9 +185,13 @@ void print_results(int topology_depth, int cpu)
190 } 185 }
191 } 186 }
192 } 187 }
193 /* cpu offline */ 188 /*
194 if (cpu_top.core_info[cpu].pkg == -1 || 189 * The monitor could still provide useful data, for example
195 cpu_top.core_info[cpu].core == -1) { 190 * AMD HW counters partly sit in PCI config space.
191 * It's up to the monitor plug-in to check .is_online, this one
192 * is just for additional info.
193 */
194 if (!cpu_top.core_info[cpu].is_online) {
196 printf(_(" *is offline\n")); 195 printf(_(" *is offline\n"));
197 return; 196 return;
198 } else 197 } else
@@ -238,7 +237,6 @@ static void parse_monitor_param(char *param)
238 if (hits == 0) { 237 if (hits == 0) {
239 printf(_("No matching monitor found in %s, " 238 printf(_("No matching monitor found in %s, "
240 "try -l option\n"), param); 239 "try -l option\n"), param);
241 monitor_help();
242 exit(EXIT_FAILURE); 240 exit(EXIT_FAILURE);
243 } 241 }
244 /* Override detected/registerd monitors array with requested one */ 242 /* Override detected/registerd monitors array with requested one */
@@ -335,37 +333,27 @@ static void cmdline(int argc, char *argv[])
335 int opt; 333 int opt;
336 progname = basename(argv[0]); 334 progname = basename(argv[0]);
337 335
338 while ((opt = getopt(argc, argv, "+hli:m:")) != -1) { 336 while ((opt = getopt(argc, argv, "+li:m:")) != -1) {
339 switch (opt) { 337 switch (opt) {
340 case 'h':
341 monitor_help();
342 exit(EXIT_SUCCESS);
343 case 'l': 338 case 'l':
344 if (mode) { 339 if (mode)
345 monitor_help(); 340 print_wrong_arg_exit();
346 exit(EXIT_FAILURE);
347 }
348 mode = list; 341 mode = list;
349 break; 342 break;
350 case 'i': 343 case 'i':
351 /* only allow -i with -m or no option */ 344 /* only allow -i with -m or no option */
352 if (mode && mode != show) { 345 if (mode && mode != show)
353 monitor_help(); 346 print_wrong_arg_exit();
354 exit(EXIT_FAILURE);
355 }
356 interval = atoi(optarg); 347 interval = atoi(optarg);
357 break; 348 break;
358 case 'm': 349 case 'm':
359 if (mode) { 350 if (mode)
360 monitor_help(); 351 print_wrong_arg_exit();
361 exit(EXIT_FAILURE);
362 }
363 mode = show; 352 mode = show;
364 show_monitors_param = optarg; 353 show_monitors_param = optarg;
365 break; 354 break;
366 default: 355 default:
367 monitor_help(); 356 print_wrong_arg_exit();
368 exit(EXIT_FAILURE);
369 } 357 }
370 } 358 }
371 if (!mode) 359 if (!mode)
@@ -385,6 +373,10 @@ int cmd_monitor(int argc, char **argv)
385 return EXIT_FAILURE; 373 return EXIT_FAILURE;
386 } 374 }
387 375
376 /* Default is: monitor all CPUs */
377 if (bitmask_isallclear(cpus_chosen))
378 bitmask_setall(cpus_chosen);
379
388 dprint("System has up to %d CPU cores\n", cpu_count); 380 dprint("System has up to %d CPU cores\n", cpu_count);
389 381
390 for (num = 0; all_monitors[num]; num++) { 382 for (num = 0; all_monitors[num]; num++) {
diff --git a/tools/power/cpupower/utils/idle_monitor/mperf_monitor.c b/tools/power/cpupower/utils/idle_monitor/mperf_monitor.c
index 63ca87a05e5f..5650ab5a2c20 100644
--- a/tools/power/cpupower/utils/idle_monitor/mperf_monitor.c
+++ b/tools/power/cpupower/utils/idle_monitor/mperf_monitor.c
@@ -22,12 +22,15 @@
22 22
23#define MSR_TSC 0x10 23#define MSR_TSC 0x10
24 24
25#define MSR_AMD_HWCR 0xc0010015
26
25enum mperf_id { C0 = 0, Cx, AVG_FREQ, MPERF_CSTATE_COUNT }; 27enum mperf_id { C0 = 0, Cx, AVG_FREQ, MPERF_CSTATE_COUNT };
26 28
27static int mperf_get_count_percent(unsigned int self_id, double *percent, 29static int mperf_get_count_percent(unsigned int self_id, double *percent,
28 unsigned int cpu); 30 unsigned int cpu);
29static int mperf_get_count_freq(unsigned int id, unsigned long long *count, 31static int mperf_get_count_freq(unsigned int id, unsigned long long *count,
30 unsigned int cpu); 32 unsigned int cpu);
33static struct timespec time_start, time_end;
31 34
32static cstate_t mperf_cstates[MPERF_CSTATE_COUNT] = { 35static cstate_t mperf_cstates[MPERF_CSTATE_COUNT] = {
33 { 36 {
@@ -54,19 +57,33 @@ static cstate_t mperf_cstates[MPERF_CSTATE_COUNT] = {
54 }, 57 },
55}; 58};
56 59
60enum MAX_FREQ_MODE { MAX_FREQ_SYSFS, MAX_FREQ_TSC_REF };
61static int max_freq_mode;
62/*
63 * The max frequency mperf is ticking at (in C0), either retrieved via:
64 * 1) calculated after measurements if we know TSC ticks at mperf/P0 frequency
65 * 2) cpufreq /sys/devices/.../cpu0/cpufreq/cpuinfo_max_freq at init time
66 * 1. Is preferred as it also works without cpufreq subsystem (e.g. on Xen)
67 */
68static unsigned long max_frequency;
69
57static unsigned long long tsc_at_measure_start; 70static unsigned long long tsc_at_measure_start;
58static unsigned long long tsc_at_measure_end; 71static unsigned long long tsc_at_measure_end;
59static unsigned long max_frequency;
60static unsigned long long *mperf_previous_count; 72static unsigned long long *mperf_previous_count;
61static unsigned long long *aperf_previous_count; 73static unsigned long long *aperf_previous_count;
62static unsigned long long *mperf_current_count; 74static unsigned long long *mperf_current_count;
63static unsigned long long *aperf_current_count; 75static unsigned long long *aperf_current_count;
76
64/* valid flag for all CPUs. If a MSR read failed it will be zero */ 77/* valid flag for all CPUs. If a MSR read failed it will be zero */
65static int *is_valid; 78static int *is_valid;
66 79
67static int mperf_get_tsc(unsigned long long *tsc) 80static int mperf_get_tsc(unsigned long long *tsc)
68{ 81{
69 return read_msr(0, MSR_TSC, tsc); 82 int ret;
83 ret = read_msr(0, MSR_TSC, tsc);
84 if (ret)
85 dprint("Reading TSC MSR failed, returning %llu\n", *tsc);
86 return ret;
70} 87}
71 88
72static int mperf_init_stats(unsigned int cpu) 89static int mperf_init_stats(unsigned int cpu)
@@ -97,36 +114,11 @@ static int mperf_measure_stats(unsigned int cpu)
97 return 0; 114 return 0;
98} 115}
99 116
100/*
101 * get_average_perf()
102 *
103 * Returns the average performance (also considers boosted frequencies)
104 *
105 * Input:
106 * aperf_diff: Difference of the aperf register over a time period
107 * mperf_diff: Difference of the mperf register over the same time period
108 * max_freq: Maximum frequency (P0)
109 *
110 * Returns:
111 * Average performance over the time period
112 */
113static unsigned long get_average_perf(unsigned long long aperf_diff,
114 unsigned long long mperf_diff)
115{
116 unsigned int perf_percent = 0;
117 if (((unsigned long)(-1) / 100) < aperf_diff) {
118 int shift_count = 7;
119 aperf_diff >>= shift_count;
120 mperf_diff >>= shift_count;
121 }
122 perf_percent = (aperf_diff * 100) / mperf_diff;
123 return (max_frequency * perf_percent) / 100;
124}
125
126static int mperf_get_count_percent(unsigned int id, double *percent, 117static int mperf_get_count_percent(unsigned int id, double *percent,
127 unsigned int cpu) 118 unsigned int cpu)
128{ 119{
129 unsigned long long aperf_diff, mperf_diff, tsc_diff; 120 unsigned long long aperf_diff, mperf_diff, tsc_diff;
121 unsigned long long timediff;
130 122
131 if (!is_valid[cpu]) 123 if (!is_valid[cpu])
132 return -1; 124 return -1;
@@ -136,11 +128,19 @@ static int mperf_get_count_percent(unsigned int id, double *percent,
136 128
137 mperf_diff = mperf_current_count[cpu] - mperf_previous_count[cpu]; 129 mperf_diff = mperf_current_count[cpu] - mperf_previous_count[cpu];
138 aperf_diff = aperf_current_count[cpu] - aperf_previous_count[cpu]; 130 aperf_diff = aperf_current_count[cpu] - aperf_previous_count[cpu];
139 tsc_diff = tsc_at_measure_end - tsc_at_measure_start;
140 131
141 *percent = 100.0 * mperf_diff / tsc_diff; 132 if (max_freq_mode == MAX_FREQ_TSC_REF) {
142 dprint("%s: mperf_diff: %llu, tsc_diff: %llu\n", 133 tsc_diff = tsc_at_measure_end - tsc_at_measure_start;
143 mperf_cstates[id].name, mperf_diff, tsc_diff); 134 *percent = 100.0 * mperf_diff / tsc_diff;
135 dprint("%s: TSC Ref - mperf_diff: %llu, tsc_diff: %llu\n",
136 mperf_cstates[id].name, mperf_diff, tsc_diff);
137 } else if (max_freq_mode == MAX_FREQ_SYSFS) {
138 timediff = timespec_diff_us(time_start, time_end);
139 *percent = 100.0 * mperf_diff / timediff;
140 dprint("%s: MAXFREQ - mperf_diff: %llu, time_diff: %llu\n",
141 mperf_cstates[id].name, mperf_diff, timediff);
142 } else
143 return -1;
144 144
145 if (id == Cx) 145 if (id == Cx)
146 *percent = 100.0 - *percent; 146 *percent = 100.0 - *percent;
@@ -154,7 +154,7 @@ static int mperf_get_count_percent(unsigned int id, double *percent,
154static int mperf_get_count_freq(unsigned int id, unsigned long long *count, 154static int mperf_get_count_freq(unsigned int id, unsigned long long *count,
155 unsigned int cpu) 155 unsigned int cpu)
156{ 156{
157 unsigned long long aperf_diff, mperf_diff; 157 unsigned long long aperf_diff, mperf_diff, time_diff, tsc_diff;
158 158
159 if (id != AVG_FREQ) 159 if (id != AVG_FREQ)
160 return 1; 160 return 1;
@@ -165,11 +165,21 @@ static int mperf_get_count_freq(unsigned int id, unsigned long long *count,
165 mperf_diff = mperf_current_count[cpu] - mperf_previous_count[cpu]; 165 mperf_diff = mperf_current_count[cpu] - mperf_previous_count[cpu];
166 aperf_diff = aperf_current_count[cpu] - aperf_previous_count[cpu]; 166 aperf_diff = aperf_current_count[cpu] - aperf_previous_count[cpu];
167 167
168 /* Return MHz for now, might want to return KHz if column width is more 168 if (max_freq_mode == MAX_FREQ_TSC_REF) {
169 generic */ 169 /* Calculate max_freq from TSC count */
170 *count = get_average_perf(aperf_diff, mperf_diff) / 1000; 170 tsc_diff = tsc_at_measure_end - tsc_at_measure_start;
171 dprint("%s: %llu\n", mperf_cstates[id].name, *count); 171 time_diff = timespec_diff_us(time_start, time_end);
172 max_frequency = tsc_diff / time_diff;
173 }
172 174
175 *count = max_frequency * ((double)aperf_diff / mperf_diff);
176 dprint("%s: Average freq based on %s maximum frequency:\n",
177 mperf_cstates[id].name,
178 (max_freq_mode == MAX_FREQ_TSC_REF) ? "TSC calculated" : "sysfs read");
179 dprint("%max_frequency: %lu", max_frequency);
180 dprint("aperf_diff: %llu\n", aperf_diff);
181 dprint("mperf_diff: %llu\n", mperf_diff);
182 dprint("avg freq: %llu\n", *count);
173 return 0; 183 return 0;
174} 184}
175 185
@@ -178,6 +188,7 @@ static int mperf_start(void)
178 int cpu; 188 int cpu;
179 unsigned long long dbg; 189 unsigned long long dbg;
180 190
191 clock_gettime(CLOCK_REALTIME, &time_start);
181 mperf_get_tsc(&tsc_at_measure_start); 192 mperf_get_tsc(&tsc_at_measure_start);
182 193
183 for (cpu = 0; cpu < cpu_count; cpu++) 194 for (cpu = 0; cpu < cpu_count; cpu++)
@@ -193,32 +204,104 @@ static int mperf_stop(void)
193 unsigned long long dbg; 204 unsigned long long dbg;
194 int cpu; 205 int cpu;
195 206
196 mperf_get_tsc(&tsc_at_measure_end);
197
198 for (cpu = 0; cpu < cpu_count; cpu++) 207 for (cpu = 0; cpu < cpu_count; cpu++)
199 mperf_measure_stats(cpu); 208 mperf_measure_stats(cpu);
200 209
210 mperf_get_tsc(&tsc_at_measure_end);
211 clock_gettime(CLOCK_REALTIME, &time_end);
212
201 mperf_get_tsc(&dbg); 213 mperf_get_tsc(&dbg);
202 dprint("TSC diff: %llu\n", dbg - tsc_at_measure_end); 214 dprint("TSC diff: %llu\n", dbg - tsc_at_measure_end);
203 215
204 return 0; 216 return 0;
205} 217}
206 218
207struct cpuidle_monitor mperf_monitor; 219/*
208 220 * Mperf register is defined to tick at P0 (maximum) frequency
209struct cpuidle_monitor *mperf_register(void) 221 *
222 * Instead of reading out P0 which can be tricky to read out from HW,
223 * we use TSC counter if it reliably ticks at P0/mperf frequency.
224 *
225 * Still try to fall back to:
226 * /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
227 * on older Intel HW without invariant TSC feature.
228 * Or on AMD machines where TSC does not tick at P0 (do not exist yet, but
229 * it's still double checked (MSR_AMD_HWCR)).
230 *
231 * On these machines the user would still get useful mperf
232 * stats when acpi-cpufreq driver is loaded.
233 */
234static int init_maxfreq_mode(void)
210{ 235{
236 int ret;
237 unsigned long long hwcr;
211 unsigned long min; 238 unsigned long min;
212 239
213 if (!(cpupower_cpu_info.caps & CPUPOWER_CAP_APERF)) 240 if (!cpupower_cpu_info.caps & CPUPOWER_CAP_INV_TSC)
214 return NULL; 241 goto use_sysfs;
215 242
216 /* Assume min/max all the same on all cores */ 243 if (cpupower_cpu_info.vendor == X86_VENDOR_AMD) {
244 /* MSR_AMD_HWCR tells us whether TSC runs at P0/mperf
245 * freq.
246 * A test whether hwcr is accessable/available would be:
247 * (cpupower_cpu_info.family > 0x10 ||
248 * cpupower_cpu_info.family == 0x10 &&
249 * cpupower_cpu_info.model >= 0x2))
250 * This should be the case for all aperf/mperf
251 * capable AMD machines and is therefore safe to test here.
252 * Compare with Linus kernel git commit: acf01734b1747b1ec4
253 */
254 ret = read_msr(0, MSR_AMD_HWCR, &hwcr);
255 /*
256 * If the MSR read failed, assume a Xen system that did
257 * not explicitly provide access to it and assume TSC works
258 */
259 if (ret != 0) {
260 dprint("TSC read 0x%x failed - assume TSC working\n",
261 MSR_AMD_HWCR);
262 return 0;
263 } else if (1 & (hwcr >> 24)) {
264 max_freq_mode = MAX_FREQ_TSC_REF;
265 return 0;
266 } else { /* Use sysfs max frequency if available */ }
267 } else if (cpupower_cpu_info.vendor == X86_VENDOR_INTEL) {
268 /*
269 * On Intel we assume mperf (in C0) is ticking at same
270 * rate than TSC
271 */
272 max_freq_mode = MAX_FREQ_TSC_REF;
273 return 0;
274 }
275use_sysfs:
217 if (cpufreq_get_hardware_limits(0, &min, &max_frequency)) { 276 if (cpufreq_get_hardware_limits(0, &min, &max_frequency)) {
218 dprint("Cannot retrieve max freq from cpufreq kernel " 277 dprint("Cannot retrieve max freq from cpufreq kernel "
219 "subsystem\n"); 278 "subsystem\n");
220 return NULL; 279 return -1;
221 } 280 }
281 max_freq_mode = MAX_FREQ_SYSFS;
282 return 0;
283}
284
285/*
286 * This monitor provides:
287 *
288 * 1) Average frequency a CPU resided in
289 * This always works if the CPU has aperf/mperf capabilities
290 *
291 * 2) C0 and Cx (any sleep state) time a CPU resided in
292 * Works if mperf timer stops ticking in sleep states which
293 * seem to be the case on all current HW.
294 * Both is directly retrieved from HW registers and is independent
295 * from kernel statistics.
296 */
297struct cpuidle_monitor mperf_monitor;
298struct cpuidle_monitor *mperf_register(void)
299{
300 if (!(cpupower_cpu_info.caps & CPUPOWER_CAP_APERF))
301 return NULL;
302
303 if (init_maxfreq_mode())
304 return NULL;
222 305
223 /* Free this at program termination */ 306 /* Free this at program termination */
224 is_valid = calloc(cpu_count, sizeof(int)); 307 is_valid = calloc(cpu_count, sizeof(int));