aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/ABI/testing/sysfs-devices-firmware_node17
-rw-r--r--Documentation/vfio.txt2
-rw-r--r--MAINTAINERS9
-rw-r--r--Makefile4
-rw-r--r--arch/arm/boot/compressed/head.S1
-rw-r--r--arch/arm/boot/dts/at91sam9260.dtsi3
-rw-r--r--arch/arm/boot/dts/at91sam9263.dtsi5
-rw-r--r--arch/arm/boot/dts/at91sam9g45.dtsi5
-rw-r--r--arch/arm/boot/dts/at91sam9n12.dtsi4
-rw-r--r--arch/arm/boot/dts/at91sam9x5.dtsi4
-rw-r--r--arch/arm/include/asm/unistd.h2
-rw-r--r--arch/arm/kernel/calls.S1
-rw-r--r--arch/arm/kernel/smp_twd.c48
-rw-r--r--arch/arm/mach-imx/clk-imx25.c2
-rw-r--r--arch/arm/mach-imx/mach-armadillo5x0.c3
-rw-r--r--arch/arm/mach-mxs/mach-mxs.c2
-rw-r--r--arch/arm/mach-orion5x/common.c7
-rw-r--r--arch/arm/mach-shmobile/board-kzm9g.c4
-rw-r--r--arch/arm/mm/dma-mapping.c2
-rw-r--r--arch/arm/plat-mxc/include/mach/mx25.h1
-rw-r--r--arch/arm/plat-samsung/clock.c10
-rw-r--r--arch/c6x/include/asm/Kbuild1
-rw-r--r--arch/c6x/include/asm/barrier.h27
-rw-r--r--arch/m68k/platform/coldfire/clk.c6
-rw-r--r--arch/mips/kernel/smp-cmp.c2
-rw-r--r--arch/mips/mm/gup.c2
-rw-r--r--arch/mips/mti-malta/malta-int.c9
-rw-r--r--arch/mips/mti-malta/malta-platform.c5
-rw-r--r--arch/s390/include/asm/hugetlb.h24
-rw-r--r--arch/s390/include/asm/tlbflush.h2
-rw-r--r--arch/s390/kernel/setup.c2
-rw-r--r--arch/s390/lib/uaccess_pt.c142
-rw-r--r--arch/sparc/kernel/module.c13
-rw-r--r--arch/tile/include/gxio/iorpc_trio.h24
-rw-r--r--arch/um/include/asm/processor-generic.h9
-rw-r--r--arch/um/include/shared/common-offsets.h10
-rw-r--r--arch/um/include/shared/user.h11
-rw-r--r--arch/um/kernel/exec.c25
-rw-r--r--arch/um/kernel/process.c8
-rw-r--r--arch/um/kernel/signal.c6
-rw-r--r--arch/um/kernel/syscall.c24
-rw-r--r--arch/um/scripts/Makefile.rules2
-rw-r--r--arch/x86/Kconfig8
-rw-r--r--arch/x86/Makefile2
-rw-r--r--arch/x86/include/asm/xen/page.h3
-rw-r--r--arch/x86/kernel/cpu/perf_event.h2
-rw-r--r--arch/x86/kernel/cpu/perf_event_amd_ibs.c12
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel.c24
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_ds.c14
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_uncore.c6
-rw-r--r--arch/x86/mm/init.c2
-rw-r--r--arch/x86/um/Kconfig1
-rw-r--r--arch/x86/um/shared/sysdep/kernel-offsets.h3
-rw-r--r--arch/x86/um/shared/sysdep/syscalls.h2
-rw-r--r--arch/x86/um/signal.c6
-rw-r--r--arch/x86/um/sys_call_table_32.c2
-rw-r--r--arch/x86/um/syscalls_32.c27
-rw-r--r--arch/x86/um/syscalls_64.c23
-rw-r--r--arch/x86/xen/enlighten.c4
-rw-r--r--arch/x86/xen/p2m.c27
-rw-r--r--arch/x86/xen/setup.c4
-rw-r--r--drivers/acpi/acpica/Makefile1
-rw-r--r--drivers/acpi/acpica/achware.h3
-rw-r--r--drivers/acpi/acpica/aclocal.h23
-rw-r--r--drivers/acpi/acpica/acmacros.h29
-rw-r--r--drivers/acpi/acpica/dswload.c14
-rw-r--r--drivers/acpi/acpica/dswload2.c14
-rw-r--r--drivers/acpi/acpica/evgpe.c24
-rw-r--r--drivers/acpi/acpica/evxfgpe.c3
-rw-r--r--drivers/acpi/acpica/hwgpe.c15
-rw-r--r--drivers/acpi/acpica/hwxfsleep.c1
-rw-r--r--drivers/acpi/acpica/nsdump.c2
-rw-r--r--drivers/acpi/acpica/tbinstal.c20
-rw-r--r--drivers/acpi/acpica/tbxface.c41
-rw-r--r--drivers/acpi/acpica/utosi.c1
-rw-r--r--drivers/acpi/acpica/utxface.c354
-rw-r--r--drivers/acpi/acpica/utxfinit.c317
-rw-r--r--drivers/acpi/bus.c8
-rw-r--r--drivers/acpi/glue.c135
-rw-r--r--drivers/acpi/proc.c57
-rw-r--r--drivers/acpi/scan.c56
-rw-r--r--drivers/acpi/tables.c18
-rw-r--r--drivers/acpi/utils.c11
-rw-r--r--drivers/block/aoe/aoecmd.c1
-rw-r--r--drivers/block/nvme.c153
-rw-r--r--drivers/block/rbd.c7
-rw-r--r--drivers/block/xen-blkback/blkback.c2
-rw-r--r--drivers/clk/Makefile1
-rw-r--r--drivers/clk/clk-devres.c55
-rw-r--r--drivers/clk/clkdev.c45
-rw-r--r--drivers/dma/at_hdmac.c13
-rw-r--r--drivers/dma/pl330.c21
-rw-r--r--drivers/edac/edac_mc.c57
-rw-r--r--drivers/edac/i3200_edac.c2
-rw-r--r--drivers/edac/i5000_edac.c4
-rw-r--r--drivers/edac/sb_edac.c7
-rw-r--r--drivers/gpio/gpio-lpc32xx.c5
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c3
-rw-r--r--drivers/gpu/drm/i915/intel_display.c12
-rw-r--r--drivers/gpu/drm/i915/intel_hdmi.c2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_abi16.c2
-rw-r--r--drivers/gpu/drm/nouveau/nv50_gpio.c15
-rw-r--r--drivers/gpu/drm/nouveau/nvc0_fb.c1
-rw-r--r--drivers/gpu/drm/nouveau/nvc0_fifo.c3
-rw-r--r--drivers/gpu/drm/nouveau/nve0_fifo.c3
-rw-r--r--drivers/gpu/drm/radeon/atombios_crtc.c163
-rw-r--r--drivers/gpu/drm/radeon/r100.c3
-rw-r--r--drivers/gpu/drm/udl/udl_connector.c7
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_fence.c2
-rw-r--r--drivers/hid/hid-lenovo-tpkbd.c2
-rw-r--r--drivers/hid/hid-logitech-dj.c45
-rw-r--r--drivers/hid/hid-logitech-dj.h1
-rw-r--r--drivers/hwmon/ad7314.c8
-rw-r--r--drivers/hwmon/ads7871.c9
-rw-r--r--drivers/hwmon/applesmc.c4
-rw-r--r--drivers/hwmon/coretemp.c5
-rw-r--r--drivers/hwmon/fam15h_power.c15
-rw-r--r--drivers/hwmon/via-cputemp.c5
-rw-r--r--drivers/idle/intel_idle.c1
-rw-r--r--drivers/input/keyboard/imx_keypad.c4
-rw-r--r--drivers/input/misc/ab8500-ponkey.c4
-rw-r--r--drivers/input/mouse/sentelic.c11
-rw-r--r--drivers/input/serio/ambakmi.c6
-rw-r--r--drivers/input/serio/i8042-x86ia64io.h6
-rw-r--r--drivers/input/touchscreen/edt-ft5x06.c9
-rw-r--r--drivers/input/touchscreen/usbtouchscreen.c40
-rw-r--r--drivers/iommu/amd_iommu.c6
-rw-r--r--drivers/md/dm-mpath.c11
-rw-r--r--drivers/md/dm-table.c61
-rw-r--r--drivers/md/dm-thin.c135
-rw-r--r--drivers/md/dm-verity.c8
-rw-r--r--drivers/md/dm.c71
-rw-r--r--drivers/md/dm.h1
-rw-r--r--drivers/md/raid10.c8
-rw-r--r--drivers/md/raid5.c1
-rw-r--r--drivers/mtd/mtdchar.c48
-rw-r--r--drivers/net/can/janz-ican3.c4
-rw-r--r--drivers/net/can/ti_hecc.c2
-rw-r--r--drivers/net/ethernet/broadcom/bnx2.c2
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c12
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c11
-rw-r--r--drivers/net/ethernet/cadence/at91_ether.c2
-rw-r--r--drivers/net/ethernet/freescale/gianfar_ethtool.c1
-rw-r--r--drivers/net/ethernet/freescale/gianfar_ptp.c4
-rw-r--r--drivers/net/ethernet/intel/e1000/e1000_main.c11
-rw-r--r--drivers/net/ethernet/octeon/octeon_mgmt.c4
-rw-r--r--drivers/net/ethernet/pasemi/pasemi_mac.c4
-rw-r--r--drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c4
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c4
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c10
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_timer.c8
-rw-r--r--drivers/net/irda/sh_sir.c2
-rw-r--r--drivers/net/phy/bcm87xx.c2
-rw-r--r--drivers/net/phy/micrel.c45
-rw-r--r--drivers/net/phy/smsc.c28
-rw-r--r--drivers/net/ppp/pppoe.c2
-rw-r--r--drivers/net/team/team.c44
-rw-r--r--drivers/net/usb/asix_devices.c4
-rw-r--r--drivers/net/usb/qmi_wwan.c11
-rw-r--r--drivers/net/usb/smsc75xx.c1
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_eeprom.c4
-rw-r--r--drivers/net/wireless/ath/ath9k/debug.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c4
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.h3
-rw-r--r--drivers/net/wireless/ath/ath9k/link.c2
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c2
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c26
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c6
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/channel.c2
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/trans.c1
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/def.h1
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/hw.c12
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/sw.c6
-rw-r--r--drivers/pnp/pnpacpi/core.c7
-rw-r--r--drivers/s390/block/dasd.c17
-rw-r--r--drivers/s390/block/dasd_alias.c27
-rw-r--r--drivers/s390/block/dasd_eckd.c32
-rw-r--r--drivers/s390/cio/device.c7
-rw-r--r--drivers/scsi/bnx2i/bnx2i_hwi.c3
-rw-r--r--drivers/scsi/hpsa.c3
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_base.c7
-rw-r--r--drivers/scsi/virtio_scsi.c2
-rw-r--r--drivers/sh/pfc/pinctrl.c2
-rw-r--r--drivers/usb/core/devices.c2
-rw-r--r--drivers/usb/core/hcd.c6
-rw-r--r--drivers/usb/core/usb-acpi.c5
-rw-r--r--drivers/usb/host/ohci-at91.c3
-rw-r--r--drivers/vfio/pci/vfio_pci_intrs.c76
-rw-r--r--drivers/watchdog/hpwdt.c3
-rw-r--r--drivers/watchdog/watchdog_core.c3
-rw-r--r--drivers/xen/gntdev.c5
-rw-r--r--drivers/xen/grant-table.c6
-rw-r--r--fs/cifs/cifs_unicode.c2
-rw-r--r--fs/dcache.c8
-rw-r--r--fs/debugfs/file.c76
-rw-r--r--fs/lockd/svclock.c3
-rw-r--r--fs/namespace.c10
-rw-r--r--fs/xfs/xfs_buf.c5
-rw-r--r--fs/xfs/xfs_buf.h41
-rw-r--r--fs/xfs/xfs_super.c1
-rw-r--r--include/acpi/acbuffer.h235
-rw-r--r--include/acpi/acnames.h3
-rw-r--r--include/acpi/acpi_bus.h47
-rw-r--r--include/acpi/acpixf.h7
-rw-r--r--include/acpi/actbl.h60
-rw-r--r--include/acpi/actbl1.h16
-rw-r--r--include/acpi/actbl2.h123
-rw-r--r--include/acpi/actbl3.h13
-rw-r--r--include/acpi/actypes.h7
-rw-r--r--include/asm-generic/unistd.h4
-rw-r--r--include/linux/iommu.h42
-rw-r--r--include/linux/kernel.h2
-rw-r--r--include/linux/micrel_phy.h19
-rw-r--r--include/linux/nvme.h2
-rw-r--r--include/linux/perf_event.h2
-rw-r--r--include/linux/security.h1
-rw-r--r--include/linux/xfrm.h2
-rw-r--r--include/net/ip6_fib.h5
-rw-r--r--include/net/net_namespace.h10
-rw-r--r--include/net/netns/ipv4.h1
-rw-r--r--include/net/route.h2
-rw-r--r--include/trace/events/kmem.h4
-rw-r--r--include/xen/grant_table.h3
-rw-r--r--kernel/time/timekeeping.c19
-rw-r--r--lib/flex_proportions.c2
-rw-r--r--mm/huge_memory.c1
-rw-r--r--net/batman-adv/bat_iv_ogm.c13
-rw-r--r--net/batman-adv/bitarray.h6
-rw-r--r--net/batman-adv/soft-interface.c7
-rw-r--r--net/bluetooth/bnep/sock.c4
-rw-r--r--net/bluetooth/cmtp/sock.c4
-rw-r--r--net/bluetooth/hci_core.c2
-rw-r--r--net/bluetooth/hci_sock.c16
-rw-r--r--net/bluetooth/hidp/sock.c4
-rw-r--r--net/bluetooth/l2cap_core.c2
-rw-r--r--net/bluetooth/mgmt.c16
-rw-r--r--net/ceph/messenger.c5
-rw-r--r--net/core/dev.c5
-rw-r--r--net/core/skbuff.c4
-rw-r--r--net/core/sock.c3
-rw-r--r--net/ipv4/arp.c2
-rw-r--r--net/ipv4/devinet.c10
-rw-r--r--net/ipv4/fib_frontend.c20
-rw-r--r--net/ipv4/fib_rules.c2
-rw-r--r--net/ipv4/fib_trie.c6
-rw-r--r--net/ipv4/inetpeer.c5
-rw-r--r--net/ipv4/raw.c14
-rw-r--r--net/ipv4/route.c43
-rw-r--r--net/ipv4/tcp.c23
-rw-r--r--net/ipv4/tcp_input.c5
-rw-r--r--net/ipv6/inet6_connection_sock.c23
-rw-r--r--net/ipv6/ip6_fib.c4
-rw-r--r--net/ipv6/mip6.c20
-rw-r--r--net/ipv6/raw.c21
-rw-r--r--net/ipv6/route.c19
-rw-r--r--net/l2tp/l2tp_netlink.c12
-rw-r--r--net/netfilter/xt_limit.c8
-rw-r--r--net/netrom/af_netrom.c2
-rw-r--r--net/sched/sch_qfq.c5
-rw-r--r--net/wireless/reg.c12
-rw-r--r--net/xfrm/xfrm_policy.c3
-rw-r--r--net/xfrm/xfrm_user.c57
-rw-r--r--scripts/Makefile.fwinst4
-rwxr-xr-xscripts/checksyscalls.sh2
-rw-r--r--security/selinux/include/xfrm.h1
-rw-r--r--sound/soc/codecs/wm2000.c2
-rw-r--r--sound/usb/endpoint.c8
-rw-r--r--tools/power/acpi/Makefile18
-rw-r--r--tools/power/acpi/acpidump.859
-rw-r--r--tools/power/acpi/acpidump.c560
-rw-r--r--tools/power/x86/turbostat/turbostat.855
-rw-r--r--tools/power/x86/turbostat/turbostat.c214
272 files changed, 3878 insertions, 1662 deletions
diff --git a/Documentation/ABI/testing/sysfs-devices-firmware_node b/Documentation/ABI/testing/sysfs-devices-firmware_node
new file mode 100644
index 000000000000..46badc9ea284
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-devices-firmware_node
@@ -0,0 +1,17 @@
1What: /sys/devices/.../firmware_node/
2Date: September 2012
3Contact: <>
4Description:
5 The /sys/devices/.../firmware_node directory contains attributes
6 allowing the user space to check and modify some firmware
7 related properties of given device.
8
9What: /sys/devices/.../firmware_node/description
10Date: September 2012
11Contact: Lance Ortiz <lance.ortiz@hp.com>
12Description:
13 The /sys/devices/.../firmware/description attribute contains a string
14 that describes the device as provided by the _STR method in the ACPI
15 namespace. This attribute is read-only. If the device does not have
16 an _STR method associated with it in the ACPI namespace, this
17 attribute is not present.
diff --git a/Documentation/vfio.txt b/Documentation/vfio.txt
index 0cb6685c8029..8eda3635a17d 100644
--- a/Documentation/vfio.txt
+++ b/Documentation/vfio.txt
@@ -133,7 +133,7 @@ character devices for this group:
133$ lspci -n -s 0000:06:0d.0 133$ lspci -n -s 0000:06:0d.0
13406:0d.0 0401: 1102:0002 (rev 08) 13406:0d.0 0401: 1102:0002 (rev 08)
135# echo 0000:06:0d.0 > /sys/bus/pci/devices/0000:06:0d.0/driver/unbind 135# echo 0000:06:0d.0 > /sys/bus/pci/devices/0000:06:0d.0/driver/unbind
136# echo 1102 0002 > /sys/bus/pci/drivers/vfio/new_id 136# echo 1102 0002 > /sys/bus/pci/drivers/vfio-pci/new_id
137 137
138Now we need to look at what other devices are in the group to free 138Now we need to look at what other devices are in the group to free
139it for use by VFIO: 139it for use by VFIO:
diff --git a/MAINTAINERS b/MAINTAINERS
index b17587d9412f..9a6c4da3b2ff 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3552,11 +3552,12 @@ K: \b(ABS|SYN)_MT_
3552 3552
3553INTEL C600 SERIES SAS CONTROLLER DRIVER 3553INTEL C600 SERIES SAS CONTROLLER DRIVER
3554M: Intel SCU Linux support <intel-linux-scu@intel.com> 3554M: Intel SCU Linux support <intel-linux-scu@intel.com>
3555M: Lukasz Dorau <lukasz.dorau@intel.com>
3556M: Maciej Patelczyk <maciej.patelczyk@intel.com>
3555M: Dave Jiang <dave.jiang@intel.com> 3557M: Dave Jiang <dave.jiang@intel.com>
3556M: Ed Nadolski <edmund.nadolski@intel.com>
3557L: linux-scsi@vger.kernel.org 3558L: linux-scsi@vger.kernel.org
3558T: git git://git.kernel.org/pub/scm/linux/kernel/git/djbw/isci.git 3559T: git git://git.code.sf.net/p/intel-sas/isci
3559S: Maintained 3560S: Supported
3560F: drivers/scsi/isci/ 3561F: drivers/scsi/isci/
3561F: firmware/isci/ 3562F: firmware/isci/
3562 3563
@@ -5544,6 +5545,8 @@ F: Documentation/devicetree/bindings/pwm/
5544F: include/linux/pwm.h 5545F: include/linux/pwm.h
5545F: include/linux/of_pwm.h 5546F: include/linux/of_pwm.h
5546F: drivers/pwm/ 5547F: drivers/pwm/
5548F: drivers/video/backlight/pwm_bl.c
5549F: include/linux/pwm_backlight.h
5547 5550
5548PXA2xx/PXA3xx SUPPORT 5551PXA2xx/PXA3xx SUPPORT
5549M: Eric Miao <eric.y.miao@gmail.com> 5552M: Eric Miao <eric.y.miao@gmail.com>
diff --git a/Makefile b/Makefile
index ae6928cc59d3..bb9fff26f078 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,8 @@
1VERSION = 3 1VERSION = 3
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc6 4EXTRAVERSION =
5NAME = Saber-toothed Squirrel 5NAME = Terrified Chipmunk
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
8# To see a list of typical targets execute "make help" 8# To see a list of typical targets execute "make help"
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index 81769c1341fa..bc67cbff3944 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -653,6 +653,7 @@ __armv7_mmu_cache_on:
653 mcrne p15, 0, r0, c8, c7, 0 @ flush I,D TLBs 653 mcrne p15, 0, r0, c8, c7, 0 @ flush I,D TLBs
654#endif 654#endif
655 mrc p15, 0, r0, c1, c0, 0 @ read control reg 655 mrc p15, 0, r0, c1, c0, 0 @ read control reg
656 bic r0, r0, #1 << 28 @ clear SCTLR.TRE
656 orr r0, r0, #0x5000 @ I-cache enable, RR cache replacement 657 orr r0, r0, #0x5000 @ I-cache enable, RR cache replacement
657 orr r0, r0, #0x003c @ write buffer 658 orr r0, r0, #0x003c @ write buffer
658#ifdef CONFIG_MMU 659#ifdef CONFIG_MMU
diff --git a/arch/arm/boot/dts/at91sam9260.dtsi b/arch/arm/boot/dts/at91sam9260.dtsi
index 66389c1c6f62..7c95f76398de 100644
--- a/arch/arm/boot/dts/at91sam9260.dtsi
+++ b/arch/arm/boot/dts/at91sam9260.dtsi
@@ -104,6 +104,7 @@
104 #gpio-cells = <2>; 104 #gpio-cells = <2>;
105 gpio-controller; 105 gpio-controller;
106 interrupt-controller; 106 interrupt-controller;
107 #interrupt-cells = <2>;
107 }; 108 };
108 109
109 pioB: gpio@fffff600 { 110 pioB: gpio@fffff600 {
@@ -113,6 +114,7 @@
113 #gpio-cells = <2>; 114 #gpio-cells = <2>;
114 gpio-controller; 115 gpio-controller;
115 interrupt-controller; 116 interrupt-controller;
117 #interrupt-cells = <2>;
116 }; 118 };
117 119
118 pioC: gpio@fffff800 { 120 pioC: gpio@fffff800 {
@@ -122,6 +124,7 @@
122 #gpio-cells = <2>; 124 #gpio-cells = <2>;
123 gpio-controller; 125 gpio-controller;
124 interrupt-controller; 126 interrupt-controller;
127 #interrupt-cells = <2>;
125 }; 128 };
126 129
127 dbgu: serial@fffff200 { 130 dbgu: serial@fffff200 {
diff --git a/arch/arm/boot/dts/at91sam9263.dtsi b/arch/arm/boot/dts/at91sam9263.dtsi
index b460d6ce9eb5..195019b7ca0e 100644
--- a/arch/arm/boot/dts/at91sam9263.dtsi
+++ b/arch/arm/boot/dts/at91sam9263.dtsi
@@ -95,6 +95,7 @@
95 #gpio-cells = <2>; 95 #gpio-cells = <2>;
96 gpio-controller; 96 gpio-controller;
97 interrupt-controller; 97 interrupt-controller;
98 #interrupt-cells = <2>;
98 }; 99 };
99 100
100 pioB: gpio@fffff400 { 101 pioB: gpio@fffff400 {
@@ -104,6 +105,7 @@
104 #gpio-cells = <2>; 105 #gpio-cells = <2>;
105 gpio-controller; 106 gpio-controller;
106 interrupt-controller; 107 interrupt-controller;
108 #interrupt-cells = <2>;
107 }; 109 };
108 110
109 pioC: gpio@fffff600 { 111 pioC: gpio@fffff600 {
@@ -113,6 +115,7 @@
113 #gpio-cells = <2>; 115 #gpio-cells = <2>;
114 gpio-controller; 116 gpio-controller;
115 interrupt-controller; 117 interrupt-controller;
118 #interrupt-cells = <2>;
116 }; 119 };
117 120
118 pioD: gpio@fffff800 { 121 pioD: gpio@fffff800 {
@@ -122,6 +125,7 @@
122 #gpio-cells = <2>; 125 #gpio-cells = <2>;
123 gpio-controller; 126 gpio-controller;
124 interrupt-controller; 127 interrupt-controller;
128 #interrupt-cells = <2>;
125 }; 129 };
126 130
127 pioE: gpio@fffffa00 { 131 pioE: gpio@fffffa00 {
@@ -131,6 +135,7 @@
131 #gpio-cells = <2>; 135 #gpio-cells = <2>;
132 gpio-controller; 136 gpio-controller;
133 interrupt-controller; 137 interrupt-controller;
138 #interrupt-cells = <2>;
134 }; 139 };
135 140
136 dbgu: serial@ffffee00 { 141 dbgu: serial@ffffee00 {
diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi
index bafa8806fc17..63751b1e744b 100644
--- a/arch/arm/boot/dts/at91sam9g45.dtsi
+++ b/arch/arm/boot/dts/at91sam9g45.dtsi
@@ -113,6 +113,7 @@
113 #gpio-cells = <2>; 113 #gpio-cells = <2>;
114 gpio-controller; 114 gpio-controller;
115 interrupt-controller; 115 interrupt-controller;
116 #interrupt-cells = <2>;
116 }; 117 };
117 118
118 pioB: gpio@fffff400 { 119 pioB: gpio@fffff400 {
@@ -122,6 +123,7 @@
122 #gpio-cells = <2>; 123 #gpio-cells = <2>;
123 gpio-controller; 124 gpio-controller;
124 interrupt-controller; 125 interrupt-controller;
126 #interrupt-cells = <2>;
125 }; 127 };
126 128
127 pioC: gpio@fffff600 { 129 pioC: gpio@fffff600 {
@@ -131,6 +133,7 @@
131 #gpio-cells = <2>; 133 #gpio-cells = <2>;
132 gpio-controller; 134 gpio-controller;
133 interrupt-controller; 135 interrupt-controller;
136 #interrupt-cells = <2>;
134 }; 137 };
135 138
136 pioD: gpio@fffff800 { 139 pioD: gpio@fffff800 {
@@ -140,6 +143,7 @@
140 #gpio-cells = <2>; 143 #gpio-cells = <2>;
141 gpio-controller; 144 gpio-controller;
142 interrupt-controller; 145 interrupt-controller;
146 #interrupt-cells = <2>;
143 }; 147 };
144 148
145 pioE: gpio@fffffa00 { 149 pioE: gpio@fffffa00 {
@@ -149,6 +153,7 @@
149 #gpio-cells = <2>; 153 #gpio-cells = <2>;
150 gpio-controller; 154 gpio-controller;
151 interrupt-controller; 155 interrupt-controller;
156 #interrupt-cells = <2>;
152 }; 157 };
153 158
154 dbgu: serial@ffffee00 { 159 dbgu: serial@ffffee00 {
diff --git a/arch/arm/boot/dts/at91sam9n12.dtsi b/arch/arm/boot/dts/at91sam9n12.dtsi
index bfac0dfc332c..ef9336ae9614 100644
--- a/arch/arm/boot/dts/at91sam9n12.dtsi
+++ b/arch/arm/boot/dts/at91sam9n12.dtsi
@@ -107,6 +107,7 @@
107 #gpio-cells = <2>; 107 #gpio-cells = <2>;
108 gpio-controller; 108 gpio-controller;
109 interrupt-controller; 109 interrupt-controller;
110 #interrupt-cells = <2>;
110 }; 111 };
111 112
112 pioB: gpio@fffff600 { 113 pioB: gpio@fffff600 {
@@ -116,6 +117,7 @@
116 #gpio-cells = <2>; 117 #gpio-cells = <2>;
117 gpio-controller; 118 gpio-controller;
118 interrupt-controller; 119 interrupt-controller;
120 #interrupt-cells = <2>;
119 }; 121 };
120 122
121 pioC: gpio@fffff800 { 123 pioC: gpio@fffff800 {
@@ -125,6 +127,7 @@
125 #gpio-cells = <2>; 127 #gpio-cells = <2>;
126 gpio-controller; 128 gpio-controller;
127 interrupt-controller; 129 interrupt-controller;
130 #interrupt-cells = <2>;
128 }; 131 };
129 132
130 pioD: gpio@fffffa00 { 133 pioD: gpio@fffffa00 {
@@ -134,6 +137,7 @@
134 #gpio-cells = <2>; 137 #gpio-cells = <2>;
135 gpio-controller; 138 gpio-controller;
136 interrupt-controller; 139 interrupt-controller;
140 #interrupt-cells = <2>;
137 }; 141 };
138 142
139 dbgu: serial@fffff200 { 143 dbgu: serial@fffff200 {
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi
index 4a18c393b136..8a387a8d61b7 100644
--- a/arch/arm/boot/dts/at91sam9x5.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5.dtsi
@@ -115,6 +115,7 @@
115 #gpio-cells = <2>; 115 #gpio-cells = <2>;
116 gpio-controller; 116 gpio-controller;
117 interrupt-controller; 117 interrupt-controller;
118 #interrupt-cells = <2>;
118 }; 119 };
119 120
120 pioB: gpio@fffff600 { 121 pioB: gpio@fffff600 {
@@ -124,6 +125,7 @@
124 #gpio-cells = <2>; 125 #gpio-cells = <2>;
125 gpio-controller; 126 gpio-controller;
126 interrupt-controller; 127 interrupt-controller;
128 #interrupt-cells = <2>;
127 }; 129 };
128 130
129 pioC: gpio@fffff800 { 131 pioC: gpio@fffff800 {
@@ -133,6 +135,7 @@
133 #gpio-cells = <2>; 135 #gpio-cells = <2>;
134 gpio-controller; 136 gpio-controller;
135 interrupt-controller; 137 interrupt-controller;
138 #interrupt-cells = <2>;
136 }; 139 };
137 140
138 pioD: gpio@fffffa00 { 141 pioD: gpio@fffffa00 {
@@ -142,6 +145,7 @@
142 #gpio-cells = <2>; 145 #gpio-cells = <2>;
143 gpio-controller; 146 gpio-controller;
144 interrupt-controller; 147 interrupt-controller;
148 #interrupt-cells = <2>;
145 }; 149 };
146 150
147 dbgu: serial@fffff200 { 151 dbgu: serial@fffff200 {
diff --git a/arch/arm/include/asm/unistd.h b/arch/arm/include/asm/unistd.h
index 0cab47d4a83f..2fde5fd1acce 100644
--- a/arch/arm/include/asm/unistd.h
+++ b/arch/arm/include/asm/unistd.h
@@ -404,6 +404,7 @@
404#define __NR_setns (__NR_SYSCALL_BASE+375) 404#define __NR_setns (__NR_SYSCALL_BASE+375)
405#define __NR_process_vm_readv (__NR_SYSCALL_BASE+376) 405#define __NR_process_vm_readv (__NR_SYSCALL_BASE+376)
406#define __NR_process_vm_writev (__NR_SYSCALL_BASE+377) 406#define __NR_process_vm_writev (__NR_SYSCALL_BASE+377)
407 /* 378 for kcmp */
407 408
408/* 409/*
409 * The following SWIs are ARM private. 410 * The following SWIs are ARM private.
@@ -483,6 +484,7 @@
483 */ 484 */
484#define __IGNORE_fadvise64_64 485#define __IGNORE_fadvise64_64
485#define __IGNORE_migrate_pages 486#define __IGNORE_migrate_pages
487#define __IGNORE_kcmp
486 488
487#endif /* __KERNEL__ */ 489#endif /* __KERNEL__ */
488#endif /* __ASM_ARM_UNISTD_H */ 490#endif /* __ASM_ARM_UNISTD_H */
diff --git a/arch/arm/kernel/calls.S b/arch/arm/kernel/calls.S
index 463ff4a0ec8a..e337879595e5 100644
--- a/arch/arm/kernel/calls.S
+++ b/arch/arm/kernel/calls.S
@@ -387,6 +387,7 @@
387/* 375 */ CALL(sys_setns) 387/* 375 */ CALL(sys_setns)
388 CALL(sys_process_vm_readv) 388 CALL(sys_process_vm_readv)
389 CALL(sys_process_vm_writev) 389 CALL(sys_process_vm_writev)
390 CALL(sys_ni_syscall) /* reserved for sys_kcmp */
390#ifndef syscalls_counted 391#ifndef syscalls_counted
391.equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls 392.equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls
392#define syscalls_counted 393#define syscalls_counted
diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c
index fef42b21cecb..e1f906989bb8 100644
--- a/arch/arm/kernel/smp_twd.c
+++ b/arch/arm/kernel/smp_twd.c
@@ -11,7 +11,6 @@
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/clk.h> 13#include <linux/clk.h>
14#include <linux/cpufreq.h>
15#include <linux/delay.h> 14#include <linux/delay.h>
16#include <linux/device.h> 15#include <linux/device.h>
17#include <linux/err.h> 16#include <linux/err.h>
@@ -96,7 +95,52 @@ static void twd_timer_stop(struct clock_event_device *clk)
96 disable_percpu_irq(clk->irq); 95 disable_percpu_irq(clk->irq);
97} 96}
98 97
99#ifdef CONFIG_CPU_FREQ 98#ifdef CONFIG_COMMON_CLK
99
100/*
101 * Updates clockevent frequency when the cpu frequency changes.
102 * Called on the cpu that is changing frequency with interrupts disabled.
103 */
104static void twd_update_frequency(void *new_rate)
105{
106 twd_timer_rate = *((unsigned long *) new_rate);
107
108 clockevents_update_freq(*__this_cpu_ptr(twd_evt), twd_timer_rate);
109}
110
111static int twd_rate_change(struct notifier_block *nb,
112 unsigned long flags, void *data)
113{
114 struct clk_notifier_data *cnd = data;
115
116 /*
117 * The twd clock events must be reprogrammed to account for the new
118 * frequency. The timer is local to a cpu, so cross-call to the
119 * changing cpu.
120 */
121 if (flags == POST_RATE_CHANGE)
122 smp_call_function(twd_update_frequency,
123 (void *)&cnd->new_rate, 1);
124
125 return NOTIFY_OK;
126}
127
128static struct notifier_block twd_clk_nb = {
129 .notifier_call = twd_rate_change,
130};
131
132static int twd_clk_init(void)
133{
134 if (twd_evt && *__this_cpu_ptr(twd_evt) && !IS_ERR(twd_clk))
135 return clk_notifier_register(twd_clk, &twd_clk_nb);
136
137 return 0;
138}
139core_initcall(twd_clk_init);
140
141#elif defined (CONFIG_CPU_FREQ)
142
143#include <linux/cpufreq.h>
100 144
101/* 145/*
102 * Updates clockevent frequency when the cpu frequency changes. 146 * Updates clockevent frequency when the cpu frequency changes.
diff --git a/arch/arm/mach-imx/clk-imx25.c b/arch/arm/mach-imx/clk-imx25.c
index 4431a62fff5b..d20d4795f4ea 100644
--- a/arch/arm/mach-imx/clk-imx25.c
+++ b/arch/arm/mach-imx/clk-imx25.c
@@ -241,6 +241,6 @@ int __init mx25_clocks_init(void)
241 clk_register_clkdev(clk[sdma_ahb], "ahb", "imx35-sdma"); 241 clk_register_clkdev(clk[sdma_ahb], "ahb", "imx35-sdma");
242 clk_register_clkdev(clk[iim_ipg], "iim", NULL); 242 clk_register_clkdev(clk[iim_ipg], "iim", NULL);
243 243
244 mxc_timer_init(MX25_IO_ADDRESS(MX25_GPT1_BASE_ADDR), 54); 244 mxc_timer_init(MX25_IO_ADDRESS(MX25_GPT1_BASE_ADDR), MX25_INT_GPT1);
245 return 0; 245 return 0;
246} 246}
diff --git a/arch/arm/mach-imx/mach-armadillo5x0.c b/arch/arm/mach-imx/mach-armadillo5x0.c
index 2c6ab3273f9e..5985ed1b8c98 100644
--- a/arch/arm/mach-imx/mach-armadillo5x0.c
+++ b/arch/arm/mach-imx/mach-armadillo5x0.c
@@ -526,7 +526,8 @@ static void __init armadillo5x0_init(void)
526 imx31_add_mxc_nand(&armadillo5x0_nand_board_info); 526 imx31_add_mxc_nand(&armadillo5x0_nand_board_info);
527 527
528 /* set NAND page size to 2k if not configured via boot mode pins */ 528 /* set NAND page size to 2k if not configured via boot mode pins */
529 __raw_writel(__raw_readl(MXC_CCM_RCSR) | (1 << 30), MXC_CCM_RCSR); 529 __raw_writel(__raw_readl(mx3_ccm_base + MXC_CCM_RCSR) |
530 (1 << 30), mx3_ccm_base + MXC_CCM_RCSR);
530 531
531 /* RTC */ 532 /* RTC */
532 /* Get RTC IRQ and register the chip */ 533 /* Get RTC IRQ and register the chip */
diff --git a/arch/arm/mach-mxs/mach-mxs.c b/arch/arm/mach-mxs/mach-mxs.c
index 8dabfe81d07c..ff886e01a0b0 100644
--- a/arch/arm/mach-mxs/mach-mxs.c
+++ b/arch/arm/mach-mxs/mach-mxs.c
@@ -261,7 +261,7 @@ static void __init apx4devkit_init(void)
261 enable_clk_enet_out(); 261 enable_clk_enet_out();
262 262
263 if (IS_BUILTIN(CONFIG_PHYLIB)) 263 if (IS_BUILTIN(CONFIG_PHYLIB))
264 phy_register_fixup_for_uid(PHY_ID_KS8051, MICREL_PHY_ID_MASK, 264 phy_register_fixup_for_uid(PHY_ID_KSZ8051, MICREL_PHY_ID_MASK,
265 apx4devkit_phy_fixup); 265 apx4devkit_phy_fixup);
266 266
267 mxsfb_pdata.mode_list = apx4devkit_video_modes; 267 mxsfb_pdata.mode_list = apx4devkit_video_modes;
diff --git a/arch/arm/mach-orion5x/common.c b/arch/arm/mach-orion5x/common.c
index 410291c67666..a6cd14ab1e4e 100644
--- a/arch/arm/mach-orion5x/common.c
+++ b/arch/arm/mach-orion5x/common.c
@@ -204,6 +204,13 @@ void __init orion5x_wdt_init(void)
204void __init orion5x_init_early(void) 204void __init orion5x_init_early(void)
205{ 205{
206 orion_time_set_base(TIMER_VIRT_BASE); 206 orion_time_set_base(TIMER_VIRT_BASE);
207
208 /*
209 * Some Orion5x devices allocate their coherent buffers from atomic
210 * context. Increase size of atomic coherent pool to make sure such
211 * the allocations won't fail.
212 */
213 init_dma_coherent_pool_size(SZ_1M);
207} 214}
208 215
209int orion5x_tclk; 216int orion5x_tclk;
diff --git a/arch/arm/mach-shmobile/board-kzm9g.c b/arch/arm/mach-shmobile/board-kzm9g.c
index 53b7ea92c32c..3b8a0171c3cb 100644
--- a/arch/arm/mach-shmobile/board-kzm9g.c
+++ b/arch/arm/mach-shmobile/board-kzm9g.c
@@ -346,11 +346,11 @@ static struct resource sh_mmcif_resources[] = {
346 .flags = IORESOURCE_MEM, 346 .flags = IORESOURCE_MEM,
347 }, 347 },
348 [1] = { 348 [1] = {
349 .start = gic_spi(141), 349 .start = gic_spi(140),
350 .flags = IORESOURCE_IRQ, 350 .flags = IORESOURCE_IRQ,
351 }, 351 },
352 [2] = { 352 [2] = {
353 .start = gic_spi(140), 353 .start = gic_spi(141),
354 .flags = IORESOURCE_IRQ, 354 .flags = IORESOURCE_IRQ,
355 }, 355 },
356}; 356};
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index e59c4ab71bcb..13f555d62491 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -346,6 +346,8 @@ static int __init atomic_pool_init(void)
346 (unsigned)pool->size / 1024); 346 (unsigned)pool->size / 1024);
347 return 0; 347 return 0;
348 } 348 }
349
350 kfree(pages);
349no_pages: 351no_pages:
350 kfree(bitmap); 352 kfree(bitmap);
351no_bitmap: 353no_bitmap:
diff --git a/arch/arm/plat-mxc/include/mach/mx25.h b/arch/arm/plat-mxc/include/mach/mx25.h
index 627d94f1b010..ec466400a200 100644
--- a/arch/arm/plat-mxc/include/mach/mx25.h
+++ b/arch/arm/plat-mxc/include/mach/mx25.h
@@ -98,6 +98,7 @@
98#define MX25_INT_UART1 (NR_IRQS_LEGACY + 45) 98#define MX25_INT_UART1 (NR_IRQS_LEGACY + 45)
99#define MX25_INT_GPIO2 (NR_IRQS_LEGACY + 51) 99#define MX25_INT_GPIO2 (NR_IRQS_LEGACY + 51)
100#define MX25_INT_GPIO1 (NR_IRQS_LEGACY + 52) 100#define MX25_INT_GPIO1 (NR_IRQS_LEGACY + 52)
101#define MX25_INT_GPT1 (NR_IRQS_LEGACY + 54)
101#define MX25_INT_FEC (NR_IRQS_LEGACY + 57) 102#define MX25_INT_FEC (NR_IRQS_LEGACY + 57)
102 103
103#define MX25_DMA_REQ_SSI2_RX1 22 104#define MX25_DMA_REQ_SSI2_RX1 22
diff --git a/arch/arm/plat-samsung/clock.c b/arch/arm/plat-samsung/clock.c
index 65c5eca475e7..d1116e2dfbea 100644
--- a/arch/arm/plat-samsung/clock.c
+++ b/arch/arm/plat-samsung/clock.c
@@ -144,6 +144,7 @@ long clk_round_rate(struct clk *clk, unsigned long rate)
144 144
145int clk_set_rate(struct clk *clk, unsigned long rate) 145int clk_set_rate(struct clk *clk, unsigned long rate)
146{ 146{
147 unsigned long flags;
147 int ret; 148 int ret;
148 149
149 if (IS_ERR(clk)) 150 if (IS_ERR(clk))
@@ -159,9 +160,9 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
159 if (clk->ops == NULL || clk->ops->set_rate == NULL) 160 if (clk->ops == NULL || clk->ops->set_rate == NULL)
160 return -EINVAL; 161 return -EINVAL;
161 162
162 spin_lock(&clocks_lock); 163 spin_lock_irqsave(&clocks_lock, flags);
163 ret = (clk->ops->set_rate)(clk, rate); 164 ret = (clk->ops->set_rate)(clk, rate);
164 spin_unlock(&clocks_lock); 165 spin_unlock_irqrestore(&clocks_lock, flags);
165 166
166 return ret; 167 return ret;
167} 168}
@@ -173,17 +174,18 @@ struct clk *clk_get_parent(struct clk *clk)
173 174
174int clk_set_parent(struct clk *clk, struct clk *parent) 175int clk_set_parent(struct clk *clk, struct clk *parent)
175{ 176{
177 unsigned long flags;
176 int ret = 0; 178 int ret = 0;
177 179
178 if (IS_ERR(clk)) 180 if (IS_ERR(clk))
179 return -EINVAL; 181 return -EINVAL;
180 182
181 spin_lock(&clocks_lock); 183 spin_lock_irqsave(&clocks_lock, flags);
182 184
183 if (clk->ops && clk->ops->set_parent) 185 if (clk->ops && clk->ops->set_parent)
184 ret = (clk->ops->set_parent)(clk, parent); 186 ret = (clk->ops->set_parent)(clk, parent);
185 187
186 spin_unlock(&clocks_lock); 188 spin_unlock_irqrestore(&clocks_lock, flags);
187 189
188 return ret; 190 return ret;
189} 191}
diff --git a/arch/c6x/include/asm/Kbuild b/arch/c6x/include/asm/Kbuild
index 3af601e31e66..f08e89183cda 100644
--- a/arch/c6x/include/asm/Kbuild
+++ b/arch/c6x/include/asm/Kbuild
@@ -2,6 +2,7 @@ include include/asm-generic/Kbuild.asm
2 2
3generic-y += atomic.h 3generic-y += atomic.h
4generic-y += auxvec.h 4generic-y += auxvec.h
5generic-y += barrier.h
5generic-y += bitsperlong.h 6generic-y += bitsperlong.h
6generic-y += bugs.h 7generic-y += bugs.h
7generic-y += cputime.h 8generic-y += cputime.h
diff --git a/arch/c6x/include/asm/barrier.h b/arch/c6x/include/asm/barrier.h
deleted file mode 100644
index 538240e85909..000000000000
--- a/arch/c6x/include/asm/barrier.h
+++ /dev/null
@@ -1,27 +0,0 @@
1/*
2 * Port on Texas Instruments TMS320C6x architecture
3 *
4 * Copyright (C) 2004, 2009, 2010, 2011 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#ifndef _ASM_C6X_BARRIER_H
12#define _ASM_C6X_BARRIER_H
13
14#define nop() asm("NOP\n");
15
16#define mb() barrier()
17#define rmb() barrier()
18#define wmb() barrier()
19#define set_mb(var, value) do { var = value; mb(); } while (0)
20#define set_wmb(var, value) do { var = value; wmb(); } while (0)
21
22#define smp_mb() barrier()
23#define smp_rmb() barrier()
24#define smp_wmb() barrier()
25#define smp_read_barrier_depends() do { } while (0)
26
27#endif /* _ASM_C6X_BARRIER_H */
diff --git a/arch/m68k/platform/coldfire/clk.c b/arch/m68k/platform/coldfire/clk.c
index 75f9ee967ea7..9cd13b4ce42b 100644
--- a/arch/m68k/platform/coldfire/clk.c
+++ b/arch/m68k/platform/coldfire/clk.c
@@ -146,9 +146,3 @@ struct clk_ops clk_ops1 = {
146}; 146};
147#endif /* MCFPM_PPMCR1 */ 147#endif /* MCFPM_PPMCR1 */
148#endif /* MCFPM_PPMCR0 */ 148#endif /* MCFPM_PPMCR0 */
149
150struct clk *devm_clk_get(struct device *dev, const char *id)
151{
152 return NULL;
153}
154EXPORT_SYMBOL(devm_clk_get);
diff --git a/arch/mips/kernel/smp-cmp.c b/arch/mips/kernel/smp-cmp.c
index e7e03ecf5495..afc379ca3753 100644
--- a/arch/mips/kernel/smp-cmp.c
+++ b/arch/mips/kernel/smp-cmp.c
@@ -102,7 +102,7 @@ static void cmp_init_secondary(void)
102 c->vpe_id = (read_c0_tcbind() >> TCBIND_CURVPE_SHIFT) & TCBIND_CURVPE; 102 c->vpe_id = (read_c0_tcbind() >> TCBIND_CURVPE_SHIFT) & TCBIND_CURVPE;
103#endif 103#endif
104#ifdef CONFIG_MIPS_MT_SMTC 104#ifdef CONFIG_MIPS_MT_SMTC
105 c->tc_id = (read_c0_tcbind() >> TCBIND_CURTC_SHIFT) & TCBIND_CURTC; 105 c->tc_id = (read_c0_tcbind() & TCBIND_CURTC) >> TCBIND_CURTC_SHIFT;
106#endif 106#endif
107} 107}
108 108
diff --git a/arch/mips/mm/gup.c b/arch/mips/mm/gup.c
index 33aadbcf170b..dcfd573871c1 100644
--- a/arch/mips/mm/gup.c
+++ b/arch/mips/mm/gup.c
@@ -152,6 +152,8 @@ static int gup_huge_pud(pud_t pud, unsigned long addr, unsigned long end,
152 do { 152 do {
153 VM_BUG_ON(compound_head(page) != head); 153 VM_BUG_ON(compound_head(page) != head);
154 pages[*nr] = page; 154 pages[*nr] = page;
155 if (PageTail(page))
156 get_huge_page_tail(page);
155 (*nr)++; 157 (*nr)++;
156 page++; 158 page++;
157 refs++; 159 refs++;
diff --git a/arch/mips/mti-malta/malta-int.c b/arch/mips/mti-malta/malta-int.c
index 7b13a4caeea4..fea823f18479 100644
--- a/arch/mips/mti-malta/malta-int.c
+++ b/arch/mips/mti-malta/malta-int.c
@@ -273,16 +273,19 @@ asmlinkage void plat_irq_dispatch(void)
273 unsigned int pending = read_c0_cause() & read_c0_status() & ST0_IM; 273 unsigned int pending = read_c0_cause() & read_c0_status() & ST0_IM;
274 int irq; 274 int irq;
275 275
276 if (unlikely(!pending)) {
277 spurious_interrupt();
278 return;
279 }
280
276 irq = irq_ffs(pending); 281 irq = irq_ffs(pending);
277 282
278 if (irq == MIPSCPU_INT_I8259A) 283 if (irq == MIPSCPU_INT_I8259A)
279 malta_hw0_irqdispatch(); 284 malta_hw0_irqdispatch();
280 else if (gic_present && ((1 << irq) & ipi_map[smp_processor_id()])) 285 else if (gic_present && ((1 << irq) & ipi_map[smp_processor_id()]))
281 malta_ipi_irqdispatch(); 286 malta_ipi_irqdispatch();
282 else if (irq >= 0)
283 do_IRQ(MIPS_CPU_IRQ_BASE + irq);
284 else 287 else
285 spurious_interrupt(); 288 do_IRQ(MIPS_CPU_IRQ_BASE + irq);
286} 289}
287 290
288#ifdef CONFIG_MIPS_MT_SMP 291#ifdef CONFIG_MIPS_MT_SMP
diff --git a/arch/mips/mti-malta/malta-platform.c b/arch/mips/mti-malta/malta-platform.c
index 4c35301720e7..80562b81f0f2 100644
--- a/arch/mips/mti-malta/malta-platform.c
+++ b/arch/mips/mti-malta/malta-platform.c
@@ -138,11 +138,6 @@ static int __init malta_add_devices(void)
138 if (err) 138 if (err)
139 return err; 139 return err;
140 140
141 /*
142 * Set RTC to BCD mode to support current alarm code.
143 */
144 CMOS_WRITE(CMOS_READ(RTC_CONTROL) & ~RTC_DM_BINARY, RTC_CONTROL);
145
146 return 0; 141 return 0;
147} 142}
148 143
diff --git a/arch/s390/include/asm/hugetlb.h b/arch/s390/include/asm/hugetlb.h
index 799ed0f1643d..2d6e6e380564 100644
--- a/arch/s390/include/asm/hugetlb.h
+++ b/arch/s390/include/asm/hugetlb.h
@@ -66,16 +66,6 @@ static inline pte_t huge_ptep_get(pte_t *ptep)
66 return pte; 66 return pte;
67} 67}
68 68
69static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
70 unsigned long addr, pte_t *ptep)
71{
72 pte_t pte = huge_ptep_get(ptep);
73
74 mm->context.flush_mm = 1;
75 pmd_clear((pmd_t *) ptep);
76 return pte;
77}
78
79static inline void __pmd_csp(pmd_t *pmdp) 69static inline void __pmd_csp(pmd_t *pmdp)
80{ 70{
81 register unsigned long reg2 asm("2") = pmd_val(*pmdp); 71 register unsigned long reg2 asm("2") = pmd_val(*pmdp);
@@ -117,6 +107,15 @@ static inline void huge_ptep_invalidate(struct mm_struct *mm,
117 __pmd_csp(pmdp); 107 __pmd_csp(pmdp);
118} 108}
119 109
110static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
111 unsigned long addr, pte_t *ptep)
112{
113 pte_t pte = huge_ptep_get(ptep);
114
115 huge_ptep_invalidate(mm, addr, ptep);
116 return pte;
117}
118
120#define huge_ptep_set_access_flags(__vma, __addr, __ptep, __entry, __dirty) \ 119#define huge_ptep_set_access_flags(__vma, __addr, __ptep, __entry, __dirty) \
121({ \ 120({ \
122 int __changed = !pte_same(huge_ptep_get(__ptep), __entry); \ 121 int __changed = !pte_same(huge_ptep_get(__ptep), __entry); \
@@ -131,10 +130,7 @@ static inline void huge_ptep_invalidate(struct mm_struct *mm,
131({ \ 130({ \
132 pte_t __pte = huge_ptep_get(__ptep); \ 131 pte_t __pte = huge_ptep_get(__ptep); \
133 if (pte_write(__pte)) { \ 132 if (pte_write(__pte)) { \
134 (__mm)->context.flush_mm = 1; \ 133 huge_ptep_invalidate(__mm, __addr, __ptep); \
135 if (atomic_read(&(__mm)->context.attach_count) > 1 || \
136 (__mm) != current->active_mm) \
137 huge_ptep_invalidate(__mm, __addr, __ptep); \
138 set_huge_pte_at(__mm, __addr, __ptep, \ 134 set_huge_pte_at(__mm, __addr, __ptep, \
139 huge_pte_wrprotect(__pte)); \ 135 huge_pte_wrprotect(__pte)); \
140 } \ 136 } \
diff --git a/arch/s390/include/asm/tlbflush.h b/arch/s390/include/asm/tlbflush.h
index 9fde315f3a7c..1d8fe2b17ef6 100644
--- a/arch/s390/include/asm/tlbflush.h
+++ b/arch/s390/include/asm/tlbflush.h
@@ -90,12 +90,10 @@ static inline void __tlb_flush_mm(struct mm_struct * mm)
90 90
91static inline void __tlb_flush_mm_cond(struct mm_struct * mm) 91static inline void __tlb_flush_mm_cond(struct mm_struct * mm)
92{ 92{
93 spin_lock(&mm->page_table_lock);
94 if (mm->context.flush_mm) { 93 if (mm->context.flush_mm) {
95 __tlb_flush_mm(mm); 94 __tlb_flush_mm(mm);
96 mm->context.flush_mm = 0; 95 mm->context.flush_mm = 0;
97 } 96 }
98 spin_unlock(&mm->page_table_lock);
99} 97}
100 98
101/* 99/*
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index f86c81e13c37..40b57693de38 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -974,11 +974,13 @@ static void __init setup_hwcaps(void)
974 if (MACHINE_HAS_HPAGE) 974 if (MACHINE_HAS_HPAGE)
975 elf_hwcap |= HWCAP_S390_HPAGE; 975 elf_hwcap |= HWCAP_S390_HPAGE;
976 976
977#if defined(CONFIG_64BIT)
977 /* 978 /*
978 * 64-bit register support for 31-bit processes 979 * 64-bit register support for 31-bit processes
979 * HWCAP_S390_HIGH_GPRS is bit 9. 980 * HWCAP_S390_HIGH_GPRS is bit 9.
980 */ 981 */
981 elf_hwcap |= HWCAP_S390_HIGH_GPRS; 982 elf_hwcap |= HWCAP_S390_HIGH_GPRS;
983#endif
982 984
983 get_cpu_id(&cpu_id); 985 get_cpu_id(&cpu_id);
984 switch (cpu_id.machine) { 986 switch (cpu_id.machine) {
diff --git a/arch/s390/lib/uaccess_pt.c b/arch/s390/lib/uaccess_pt.c
index 60ee2b883797..2d37bb861faf 100644
--- a/arch/s390/lib/uaccess_pt.c
+++ b/arch/s390/lib/uaccess_pt.c
@@ -2,69 +2,82 @@
2 * User access functions based on page table walks for enhanced 2 * User access functions based on page table walks for enhanced
3 * system layout without hardware support. 3 * system layout without hardware support.
4 * 4 *
5 * Copyright IBM Corp. 2006 5 * Copyright IBM Corp. 2006, 2012
6 * Author(s): Gerald Schaefer (gerald.schaefer@de.ibm.com) 6 * Author(s): Gerald Schaefer (gerald.schaefer@de.ibm.com)
7 */ 7 */
8 8
9#include <linux/errno.h> 9#include <linux/errno.h>
10#include <linux/hardirq.h> 10#include <linux/hardirq.h>
11#include <linux/mm.h> 11#include <linux/mm.h>
12#include <linux/hugetlb.h>
12#include <asm/uaccess.h> 13#include <asm/uaccess.h>
13#include <asm/futex.h> 14#include <asm/futex.h>
14#include "uaccess.h" 15#include "uaccess.h"
15 16
16static inline pte_t *follow_table(struct mm_struct *mm, unsigned long addr) 17
18/*
19 * Returns kernel address for user virtual address. If the returned address is
20 * >= -4095 (IS_ERR_VALUE(x) returns true), a fault has occured and the address
21 * contains the (negative) exception code.
22 */
23static __always_inline unsigned long follow_table(struct mm_struct *mm,
24 unsigned long addr, int write)
17{ 25{
18 pgd_t *pgd; 26 pgd_t *pgd;
19 pud_t *pud; 27 pud_t *pud;
20 pmd_t *pmd; 28 pmd_t *pmd;
29 pte_t *ptep;
21 30
22 pgd = pgd_offset(mm, addr); 31 pgd = pgd_offset(mm, addr);
23 if (pgd_none(*pgd) || unlikely(pgd_bad(*pgd))) 32 if (pgd_none(*pgd) || unlikely(pgd_bad(*pgd)))
24 return (pte_t *) 0x3a; 33 return -0x3aUL;
25 34
26 pud = pud_offset(pgd, addr); 35 pud = pud_offset(pgd, addr);
27 if (pud_none(*pud) || unlikely(pud_bad(*pud))) 36 if (pud_none(*pud) || unlikely(pud_bad(*pud)))
28 return (pte_t *) 0x3b; 37 return -0x3bUL;
29 38
30 pmd = pmd_offset(pud, addr); 39 pmd = pmd_offset(pud, addr);
31 if (pmd_none(*pmd) || unlikely(pmd_bad(*pmd))) 40 if (pmd_none(*pmd))
32 return (pte_t *) 0x10; 41 return -0x10UL;
42 if (pmd_huge(*pmd)) {
43 if (write && (pmd_val(*pmd) & _SEGMENT_ENTRY_RO))
44 return -0x04UL;
45 return (pmd_val(*pmd) & HPAGE_MASK) + (addr & ~HPAGE_MASK);
46 }
47 if (unlikely(pmd_bad(*pmd)))
48 return -0x10UL;
49
50 ptep = pte_offset_map(pmd, addr);
51 if (!pte_present(*ptep))
52 return -0x11UL;
53 if (write && !pte_write(*ptep))
54 return -0x04UL;
33 55
34 return pte_offset_map(pmd, addr); 56 return (pte_val(*ptep) & PAGE_MASK) + (addr & ~PAGE_MASK);
35} 57}
36 58
37static __always_inline size_t __user_copy_pt(unsigned long uaddr, void *kptr, 59static __always_inline size_t __user_copy_pt(unsigned long uaddr, void *kptr,
38 size_t n, int write_user) 60 size_t n, int write_user)
39{ 61{
40 struct mm_struct *mm = current->mm; 62 struct mm_struct *mm = current->mm;
41 unsigned long offset, pfn, done, size; 63 unsigned long offset, done, size, kaddr;
42 pte_t *pte;
43 void *from, *to; 64 void *from, *to;
44 65
45 done = 0; 66 done = 0;
46retry: 67retry:
47 spin_lock(&mm->page_table_lock); 68 spin_lock(&mm->page_table_lock);
48 do { 69 do {
49 pte = follow_table(mm, uaddr); 70 kaddr = follow_table(mm, uaddr, write_user);
50 if ((unsigned long) pte < 0x1000) 71 if (IS_ERR_VALUE(kaddr))
51 goto fault; 72 goto fault;
52 if (!pte_present(*pte)) {
53 pte = (pte_t *) 0x11;
54 goto fault;
55 } else if (write_user && !pte_write(*pte)) {
56 pte = (pte_t *) 0x04;
57 goto fault;
58 }
59 73
60 pfn = pte_pfn(*pte); 74 offset = uaddr & ~PAGE_MASK;
61 offset = uaddr & (PAGE_SIZE - 1);
62 size = min(n - done, PAGE_SIZE - offset); 75 size = min(n - done, PAGE_SIZE - offset);
63 if (write_user) { 76 if (write_user) {
64 to = (void *)((pfn << PAGE_SHIFT) + offset); 77 to = (void *) kaddr;
65 from = kptr + done; 78 from = kptr + done;
66 } else { 79 } else {
67 from = (void *)((pfn << PAGE_SHIFT) + offset); 80 from = (void *) kaddr;
68 to = kptr + done; 81 to = kptr + done;
69 } 82 }
70 memcpy(to, from, size); 83 memcpy(to, from, size);
@@ -75,7 +88,7 @@ retry:
75 return n - done; 88 return n - done;
76fault: 89fault:
77 spin_unlock(&mm->page_table_lock); 90 spin_unlock(&mm->page_table_lock);
78 if (__handle_fault(uaddr, (unsigned long) pte, write_user)) 91 if (__handle_fault(uaddr, -kaddr, write_user))
79 return n - done; 92 return n - done;
80 goto retry; 93 goto retry;
81} 94}
@@ -84,27 +97,22 @@ fault:
84 * Do DAT for user address by page table walk, return kernel address. 97 * Do DAT for user address by page table walk, return kernel address.
85 * This function needs to be called with current->mm->page_table_lock held. 98 * This function needs to be called with current->mm->page_table_lock held.
86 */ 99 */
87static __always_inline unsigned long __dat_user_addr(unsigned long uaddr) 100static __always_inline unsigned long __dat_user_addr(unsigned long uaddr,
101 int write)
88{ 102{
89 struct mm_struct *mm = current->mm; 103 struct mm_struct *mm = current->mm;
90 unsigned long pfn; 104 unsigned long kaddr;
91 pte_t *pte;
92 int rc; 105 int rc;
93 106
94retry: 107retry:
95 pte = follow_table(mm, uaddr); 108 kaddr = follow_table(mm, uaddr, write);
96 if ((unsigned long) pte < 0x1000) 109 if (IS_ERR_VALUE(kaddr))
97 goto fault;
98 if (!pte_present(*pte)) {
99 pte = (pte_t *) 0x11;
100 goto fault; 110 goto fault;
101 }
102 111
103 pfn = pte_pfn(*pte); 112 return kaddr;
104 return (pfn << PAGE_SHIFT) + (uaddr & (PAGE_SIZE - 1));
105fault: 113fault:
106 spin_unlock(&mm->page_table_lock); 114 spin_unlock(&mm->page_table_lock);
107 rc = __handle_fault(uaddr, (unsigned long) pte, 0); 115 rc = __handle_fault(uaddr, -kaddr, write);
108 spin_lock(&mm->page_table_lock); 116 spin_lock(&mm->page_table_lock);
109 if (!rc) 117 if (!rc)
110 goto retry; 118 goto retry;
@@ -159,11 +167,9 @@ static size_t clear_user_pt(size_t n, void __user *to)
159 167
160static size_t strnlen_user_pt(size_t count, const char __user *src) 168static size_t strnlen_user_pt(size_t count, const char __user *src)
161{ 169{
162 char *addr;
163 unsigned long uaddr = (unsigned long) src; 170 unsigned long uaddr = (unsigned long) src;
164 struct mm_struct *mm = current->mm; 171 struct mm_struct *mm = current->mm;
165 unsigned long offset, pfn, done, len; 172 unsigned long offset, done, len, kaddr;
166 pte_t *pte;
167 size_t len_str; 173 size_t len_str;
168 174
169 if (segment_eq(get_fs(), KERNEL_DS)) 175 if (segment_eq(get_fs(), KERNEL_DS))
@@ -172,19 +178,13 @@ static size_t strnlen_user_pt(size_t count, const char __user *src)
172retry: 178retry:
173 spin_lock(&mm->page_table_lock); 179 spin_lock(&mm->page_table_lock);
174 do { 180 do {
175 pte = follow_table(mm, uaddr); 181 kaddr = follow_table(mm, uaddr, 0);
176 if ((unsigned long) pte < 0x1000) 182 if (IS_ERR_VALUE(kaddr))
177 goto fault;
178 if (!pte_present(*pte)) {
179 pte = (pte_t *) 0x11;
180 goto fault; 183 goto fault;
181 }
182 184
183 pfn = pte_pfn(*pte); 185 offset = uaddr & ~PAGE_MASK;
184 offset = uaddr & (PAGE_SIZE-1);
185 addr = (char *)(pfn << PAGE_SHIFT) + offset;
186 len = min(count - done, PAGE_SIZE - offset); 186 len = min(count - done, PAGE_SIZE - offset);
187 len_str = strnlen(addr, len); 187 len_str = strnlen((char *) kaddr, len);
188 done += len_str; 188 done += len_str;
189 uaddr += len_str; 189 uaddr += len_str;
190 } while ((len_str == len) && (done < count)); 190 } while ((len_str == len) && (done < count));
@@ -192,7 +192,7 @@ retry:
192 return done + 1; 192 return done + 1;
193fault: 193fault:
194 spin_unlock(&mm->page_table_lock); 194 spin_unlock(&mm->page_table_lock);
195 if (__handle_fault(uaddr, (unsigned long) pte, 0)) 195 if (__handle_fault(uaddr, -kaddr, 0))
196 return 0; 196 return 0;
197 goto retry; 197 goto retry;
198} 198}
@@ -225,11 +225,10 @@ static size_t copy_in_user_pt(size_t n, void __user *to,
225 const void __user *from) 225 const void __user *from)
226{ 226{
227 struct mm_struct *mm = current->mm; 227 struct mm_struct *mm = current->mm;
228 unsigned long offset_from, offset_to, offset_max, pfn_from, pfn_to, 228 unsigned long offset_max, uaddr, done, size, error_code;
229 uaddr, done, size, error_code;
230 unsigned long uaddr_from = (unsigned long) from; 229 unsigned long uaddr_from = (unsigned long) from;
231 unsigned long uaddr_to = (unsigned long) to; 230 unsigned long uaddr_to = (unsigned long) to;
232 pte_t *pte_from, *pte_to; 231 unsigned long kaddr_to, kaddr_from;
233 int write_user; 232 int write_user;
234 233
235 if (segment_eq(get_fs(), KERNEL_DS)) { 234 if (segment_eq(get_fs(), KERNEL_DS)) {
@@ -242,38 +241,23 @@ retry:
242 do { 241 do {
243 write_user = 0; 242 write_user = 0;
244 uaddr = uaddr_from; 243 uaddr = uaddr_from;
245 pte_from = follow_table(mm, uaddr_from); 244 kaddr_from = follow_table(mm, uaddr_from, 0);
246 error_code = (unsigned long) pte_from; 245 error_code = kaddr_from;
247 if (error_code < 0x1000) 246 if (IS_ERR_VALUE(error_code))
248 goto fault;
249 if (!pte_present(*pte_from)) {
250 error_code = 0x11;
251 goto fault; 247 goto fault;
252 }
253 248
254 write_user = 1; 249 write_user = 1;
255 uaddr = uaddr_to; 250 uaddr = uaddr_to;
256 pte_to = follow_table(mm, uaddr_to); 251 kaddr_to = follow_table(mm, uaddr_to, 1);
257 error_code = (unsigned long) pte_to; 252 error_code = (unsigned long) kaddr_to;
258 if (error_code < 0x1000) 253 if (IS_ERR_VALUE(error_code))
259 goto fault;
260 if (!pte_present(*pte_to)) {
261 error_code = 0x11;
262 goto fault; 254 goto fault;
263 } else if (!pte_write(*pte_to)) {
264 error_code = 0x04;
265 goto fault;
266 }
267 255
268 pfn_from = pte_pfn(*pte_from); 256 offset_max = max(uaddr_from & ~PAGE_MASK,
269 pfn_to = pte_pfn(*pte_to); 257 uaddr_to & ~PAGE_MASK);
270 offset_from = uaddr_from & (PAGE_SIZE-1);
271 offset_to = uaddr_from & (PAGE_SIZE-1);
272 offset_max = max(offset_from, offset_to);
273 size = min(n - done, PAGE_SIZE - offset_max); 258 size = min(n - done, PAGE_SIZE - offset_max);
274 259
275 memcpy((void *)(pfn_to << PAGE_SHIFT) + offset_to, 260 memcpy((void *) kaddr_to, (void *) kaddr_from, size);
276 (void *)(pfn_from << PAGE_SHIFT) + offset_from, size);
277 done += size; 261 done += size;
278 uaddr_from += size; 262 uaddr_from += size;
279 uaddr_to += size; 263 uaddr_to += size;
@@ -282,7 +266,7 @@ retry:
282 return n - done; 266 return n - done;
283fault: 267fault:
284 spin_unlock(&mm->page_table_lock); 268 spin_unlock(&mm->page_table_lock);
285 if (__handle_fault(uaddr, error_code, write_user)) 269 if (__handle_fault(uaddr, -error_code, write_user))
286 return n - done; 270 return n - done;
287 goto retry; 271 goto retry;
288} 272}
@@ -341,7 +325,7 @@ int futex_atomic_op_pt(int op, u32 __user *uaddr, int oparg, int *old)
341 return __futex_atomic_op_pt(op, uaddr, oparg, old); 325 return __futex_atomic_op_pt(op, uaddr, oparg, old);
342 spin_lock(&current->mm->page_table_lock); 326 spin_lock(&current->mm->page_table_lock);
343 uaddr = (u32 __force __user *) 327 uaddr = (u32 __force __user *)
344 __dat_user_addr((__force unsigned long) uaddr); 328 __dat_user_addr((__force unsigned long) uaddr, 1);
345 if (!uaddr) { 329 if (!uaddr) {
346 spin_unlock(&current->mm->page_table_lock); 330 spin_unlock(&current->mm->page_table_lock);
347 return -EFAULT; 331 return -EFAULT;
@@ -378,7 +362,7 @@ int futex_atomic_cmpxchg_pt(u32 *uval, u32 __user *uaddr,
378 return __futex_atomic_cmpxchg_pt(uval, uaddr, oldval, newval); 362 return __futex_atomic_cmpxchg_pt(uval, uaddr, oldval, newval);
379 spin_lock(&current->mm->page_table_lock); 363 spin_lock(&current->mm->page_table_lock);
380 uaddr = (u32 __force __user *) 364 uaddr = (u32 __force __user *)
381 __dat_user_addr((__force unsigned long) uaddr); 365 __dat_user_addr((__force unsigned long) uaddr, 1);
382 if (!uaddr) { 366 if (!uaddr) {
383 spin_unlock(&current->mm->page_table_lock); 367 spin_unlock(&current->mm->page_table_lock);
384 return -EFAULT; 368 return -EFAULT;
diff --git a/arch/sparc/kernel/module.c b/arch/sparc/kernel/module.c
index 15e0a1693976..f1ddc0d23679 100644
--- a/arch/sparc/kernel/module.c
+++ b/arch/sparc/kernel/module.c
@@ -48,9 +48,7 @@ void *module_alloc(unsigned long size)
48 return NULL; 48 return NULL;
49 49
50 ret = module_map(size); 50 ret = module_map(size);
51 if (!ret) 51 if (ret)
52 ret = ERR_PTR(-ENOMEM);
53 else
54 memset(ret, 0, size); 52 memset(ret, 0, size);
55 53
56 return ret; 54 return ret;
@@ -116,6 +114,10 @@ int apply_relocate_add(Elf_Shdr *sechdrs,
116 v = sym->st_value + rel[i].r_addend; 114 v = sym->st_value + rel[i].r_addend;
117 115
118 switch (ELF_R_TYPE(rel[i].r_info) & 0xff) { 116 switch (ELF_R_TYPE(rel[i].r_info) & 0xff) {
117 case R_SPARC_DISP32:
118 v -= (Elf_Addr) location;
119 *loc32 = v;
120 break;
119#ifdef CONFIG_SPARC64 121#ifdef CONFIG_SPARC64
120 case R_SPARC_64: 122 case R_SPARC_64:
121 location[0] = v >> 56; 123 location[0] = v >> 56;
@@ -128,11 +130,6 @@ int apply_relocate_add(Elf_Shdr *sechdrs,
128 location[7] = v >> 0; 130 location[7] = v >> 0;
129 break; 131 break;
130 132
131 case R_SPARC_DISP32:
132 v -= (Elf_Addr) location;
133 *loc32 = v;
134 break;
135
136 case R_SPARC_WDISP19: 133 case R_SPARC_WDISP19:
137 v -= (Elf_Addr) location; 134 v -= (Elf_Addr) location;
138 *loc32 = (*loc32 & ~0x7ffff) | 135 *loc32 = (*loc32 & ~0x7ffff) |
diff --git a/arch/tile/include/gxio/iorpc_trio.h b/arch/tile/include/gxio/iorpc_trio.h
index 15fb77992083..58105c31228b 100644
--- a/arch/tile/include/gxio/iorpc_trio.h
+++ b/arch/tile/include/gxio/iorpc_trio.h
@@ -25,21 +25,23 @@
25#include <linux/module.h> 25#include <linux/module.h>
26#include <asm/pgtable.h> 26#include <asm/pgtable.h>
27 27
28#define GXIO_TRIO_OP_ALLOC_ASIDS IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1400) 28#define GXIO_TRIO_OP_DEALLOC_ASID IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1400)
29#define GXIO_TRIO_OP_ALLOC_ASIDS IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1401)
29 30
30#define GXIO_TRIO_OP_ALLOC_MEMORY_MAPS IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1402) 31#define GXIO_TRIO_OP_ALLOC_MEMORY_MAPS IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1404)
31 32
32#define GXIO_TRIO_OP_ALLOC_PIO_REGIONS IORPC_OPCODE(IORPC_FORMAT_NONE, 0x140e) 33#define GXIO_TRIO_OP_ALLOC_PIO_REGIONS IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1412)
33#define GXIO_TRIO_OP_INIT_PIO_REGION_AUX IORPC_OPCODE(IORPC_FORMAT_NONE, 0x140f)
34 34
35#define GXIO_TRIO_OP_INIT_MEMORY_MAP_MMU_AUX IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x1417) 35#define GXIO_TRIO_OP_INIT_PIO_REGION_AUX IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1414)
36#define GXIO_TRIO_OP_GET_PORT_PROPERTY IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x1418)
37#define GXIO_TRIO_OP_CONFIG_LEGACY_INTR IORPC_OPCODE(IORPC_FORMAT_KERNEL_INTERRUPT, 0x1419)
38#define GXIO_TRIO_OP_CONFIG_MSI_INTR IORPC_OPCODE(IORPC_FORMAT_KERNEL_INTERRUPT, 0x141a)
39 36
40#define GXIO_TRIO_OP_SET_MPS_MRS IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x141c) 37#define GXIO_TRIO_OP_INIT_MEMORY_MAP_MMU_AUX IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x141e)
41#define GXIO_TRIO_OP_FORCE_RC_LINK_UP IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x141d) 38#define GXIO_TRIO_OP_GET_PORT_PROPERTY IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x141f)
42#define GXIO_TRIO_OP_FORCE_EP_LINK_UP IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x141e) 39#define GXIO_TRIO_OP_CONFIG_LEGACY_INTR IORPC_OPCODE(IORPC_FORMAT_KERNEL_INTERRUPT, 0x1420)
40#define GXIO_TRIO_OP_CONFIG_MSI_INTR IORPC_OPCODE(IORPC_FORMAT_KERNEL_INTERRUPT, 0x1421)
41
42#define GXIO_TRIO_OP_SET_MPS_MRS IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x1423)
43#define GXIO_TRIO_OP_FORCE_RC_LINK_UP IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x1424)
44#define GXIO_TRIO_OP_FORCE_EP_LINK_UP IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x1425)
43#define GXIO_TRIO_OP_GET_MMIO_BASE IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8000) 45#define GXIO_TRIO_OP_GET_MMIO_BASE IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8000)
44#define GXIO_TRIO_OP_CHECK_MMIO_OFFSET IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8001) 46#define GXIO_TRIO_OP_CHECK_MMIO_OFFSET IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8001)
45 47
diff --git a/arch/um/include/asm/processor-generic.h b/arch/um/include/asm/processor-generic.h
index 69f1c57a8d0d..33a6a2423bd2 100644
--- a/arch/um/include/asm/processor-generic.h
+++ b/arch/um/include/asm/processor-generic.h
@@ -20,14 +20,6 @@ struct mm_struct;
20 20
21struct thread_struct { 21struct thread_struct {
22 struct task_struct *saved_task; 22 struct task_struct *saved_task;
23 /*
24 * This flag is set to 1 before calling do_fork (and analyzed in
25 * copy_thread) to mark that we are begin called from userspace (fork /
26 * vfork / clone), and reset to 0 after. It is left to 0 when called
27 * from kernelspace (i.e. kernel_thread() or fork_idle(),
28 * as of 2.6.11).
29 */
30 int forking;
31 struct pt_regs regs; 23 struct pt_regs regs;
32 int singlestep_syscall; 24 int singlestep_syscall;
33 void *fault_addr; 25 void *fault_addr;
@@ -58,7 +50,6 @@ struct thread_struct {
58 50
59#define INIT_THREAD \ 51#define INIT_THREAD \
60{ \ 52{ \
61 .forking = 0, \
62 .regs = EMPTY_REGS, \ 53 .regs = EMPTY_REGS, \
63 .fault_addr = NULL, \ 54 .fault_addr = NULL, \
64 .prev_sched = NULL, \ 55 .prev_sched = NULL, \
diff --git a/arch/um/include/shared/common-offsets.h b/arch/um/include/shared/common-offsets.h
index 40db8f71deae..2df313b6a586 100644
--- a/arch/um/include/shared/common-offsets.h
+++ b/arch/um/include/shared/common-offsets.h
@@ -7,16 +7,6 @@ DEFINE(UM_KERN_PAGE_MASK, PAGE_MASK);
7DEFINE(UM_KERN_PAGE_SHIFT, PAGE_SHIFT); 7DEFINE(UM_KERN_PAGE_SHIFT, PAGE_SHIFT);
8DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC); 8DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC);
9 9
10DEFINE_STR(UM_KERN_EMERG, KERN_EMERG);
11DEFINE_STR(UM_KERN_ALERT, KERN_ALERT);
12DEFINE_STR(UM_KERN_CRIT, KERN_CRIT);
13DEFINE_STR(UM_KERN_ERR, KERN_ERR);
14DEFINE_STR(UM_KERN_WARNING, KERN_WARNING);
15DEFINE_STR(UM_KERN_NOTICE, KERN_NOTICE);
16DEFINE_STR(UM_KERN_INFO, KERN_INFO);
17DEFINE_STR(UM_KERN_DEBUG, KERN_DEBUG);
18DEFINE_STR(UM_KERN_CONT, KERN_CONT);
19
20DEFINE(UM_ELF_CLASS, ELF_CLASS); 10DEFINE(UM_ELF_CLASS, ELF_CLASS);
21DEFINE(UM_ELFCLASS32, ELFCLASS32); 11DEFINE(UM_ELFCLASS32, ELFCLASS32);
22DEFINE(UM_ELFCLASS64, ELFCLASS64); 12DEFINE(UM_ELFCLASS64, ELFCLASS64);
diff --git a/arch/um/include/shared/user.h b/arch/um/include/shared/user.h
index 4fa82c055aab..cef068563336 100644
--- a/arch/um/include/shared/user.h
+++ b/arch/um/include/shared/user.h
@@ -26,6 +26,17 @@
26extern void panic(const char *fmt, ...) 26extern void panic(const char *fmt, ...)
27 __attribute__ ((format (printf, 1, 2))); 27 __attribute__ ((format (printf, 1, 2)));
28 28
29/* Requires preincluding include/linux/kern_levels.h */
30#define UM_KERN_EMERG KERN_EMERG
31#define UM_KERN_ALERT KERN_ALERT
32#define UM_KERN_CRIT KERN_CRIT
33#define UM_KERN_ERR KERN_ERR
34#define UM_KERN_WARNING KERN_WARNING
35#define UM_KERN_NOTICE KERN_NOTICE
36#define UM_KERN_INFO KERN_INFO
37#define UM_KERN_DEBUG KERN_DEBUG
38#define UM_KERN_CONT KERN_CONT
39
29#ifdef UML_CONFIG_PRINTK 40#ifdef UML_CONFIG_PRINTK
30extern int printk(const char *fmt, ...) 41extern int printk(const char *fmt, ...)
31 __attribute__ ((format (printf, 1, 2))); 42 __attribute__ ((format (printf, 1, 2)));
diff --git a/arch/um/kernel/exec.c b/arch/um/kernel/exec.c
index 6cade9366364..8c82786da823 100644
--- a/arch/um/kernel/exec.c
+++ b/arch/um/kernel/exec.c
@@ -39,34 +39,21 @@ void flush_thread(void)
39 39
40void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp) 40void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)
41{ 41{
42 get_safe_registers(regs->regs.gp, regs->regs.fp);
42 PT_REGS_IP(regs) = eip; 43 PT_REGS_IP(regs) = eip;
43 PT_REGS_SP(regs) = esp; 44 PT_REGS_SP(regs) = esp;
44} 45 current->ptrace &= ~PT_DTRACE;
45EXPORT_SYMBOL(start_thread);
46
47static long execve1(const char *file,
48 const char __user *const __user *argv,
49 const char __user *const __user *env)
50{
51 long error;
52
53 error = do_execve(file, argv, env, &current->thread.regs);
54 if (error == 0) {
55 task_lock(current);
56 current->ptrace &= ~PT_DTRACE;
57#ifdef SUBARCH_EXECVE1 46#ifdef SUBARCH_EXECVE1
58 SUBARCH_EXECVE1(&current->thread.regs.regs); 47 SUBARCH_EXECVE1(regs->regs);
59#endif 48#endif
60 task_unlock(current);
61 }
62 return error;
63} 49}
50EXPORT_SYMBOL(start_thread);
64 51
65long um_execve(const char *file, const char __user *const __user *argv, const char __user *const __user *env) 52long um_execve(const char *file, const char __user *const __user *argv, const char __user *const __user *env)
66{ 53{
67 long err; 54 long err;
68 55
69 err = execve1(file, argv, env); 56 err = do_execve(file, argv, env, &current->thread.regs);
70 if (!err) 57 if (!err)
71 UML_LONGJMP(current->thread.exec_buf, 1); 58 UML_LONGJMP(current->thread.exec_buf, 1);
72 return err; 59 return err;
@@ -81,7 +68,7 @@ long sys_execve(const char __user *file, const char __user *const __user *argv,
81 filename = getname(file); 68 filename = getname(file);
82 error = PTR_ERR(filename); 69 error = PTR_ERR(filename);
83 if (IS_ERR(filename)) goto out; 70 if (IS_ERR(filename)) goto out;
84 error = execve1(filename, argv, env); 71 error = do_execve(filename, argv, env, &current->thread.regs);
85 putname(filename); 72 putname(filename);
86 out: 73 out:
87 return error; 74 return error;
diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
index 57fc7028714a..c5f5afa50745 100644
--- a/arch/um/kernel/process.c
+++ b/arch/um/kernel/process.c
@@ -181,11 +181,12 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
181 struct pt_regs *regs) 181 struct pt_regs *regs)
182{ 182{
183 void (*handler)(void); 183 void (*handler)(void);
184 int kthread = current->flags & PF_KTHREAD;
184 int ret = 0; 185 int ret = 0;
185 186
186 p->thread = (struct thread_struct) INIT_THREAD; 187 p->thread = (struct thread_struct) INIT_THREAD;
187 188
188 if (current->thread.forking) { 189 if (!kthread) {
189 memcpy(&p->thread.regs.regs, &regs->regs, 190 memcpy(&p->thread.regs.regs, &regs->regs,
190 sizeof(p->thread.regs.regs)); 191 sizeof(p->thread.regs.regs));
191 PT_REGS_SET_SYSCALL_RETURN(&p->thread.regs, 0); 192 PT_REGS_SET_SYSCALL_RETURN(&p->thread.regs, 0);
@@ -195,8 +196,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
195 handler = fork_handler; 196 handler = fork_handler;
196 197
197 arch_copy_thread(&current->thread.arch, &p->thread.arch); 198 arch_copy_thread(&current->thread.arch, &p->thread.arch);
198 } 199 } else {
199 else {
200 get_safe_registers(p->thread.regs.regs.gp, p->thread.regs.regs.fp); 200 get_safe_registers(p->thread.regs.regs.gp, p->thread.regs.regs.fp);
201 p->thread.request.u.thread = current->thread.request.u.thread; 201 p->thread.request.u.thread = current->thread.request.u.thread;
202 handler = new_thread_handler; 202 handler = new_thread_handler;
@@ -204,7 +204,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
204 204
205 new_thread(task_stack_page(p), &p->thread.switch_buf, handler); 205 new_thread(task_stack_page(p), &p->thread.switch_buf, handler);
206 206
207 if (current->thread.forking) { 207 if (!kthread) {
208 clear_flushed_tls(p); 208 clear_flushed_tls(p);
209 209
210 /* 210 /*
diff --git a/arch/um/kernel/signal.c b/arch/um/kernel/signal.c
index 7362d58efc29..cc9c2350e417 100644
--- a/arch/um/kernel/signal.c
+++ b/arch/um/kernel/signal.c
@@ -22,9 +22,13 @@ static void handle_signal(struct pt_regs *regs, unsigned long signr,
22 struct k_sigaction *ka, siginfo_t *info) 22 struct k_sigaction *ka, siginfo_t *info)
23{ 23{
24 sigset_t *oldset = sigmask_to_save(); 24 sigset_t *oldset = sigmask_to_save();
25 int singlestep = 0;
25 unsigned long sp; 26 unsigned long sp;
26 int err; 27 int err;
27 28
29 if ((current->ptrace & PT_DTRACE) && (current->ptrace & PT_PTRACED))
30 singlestep = 1;
31
28 /* Did we come from a system call? */ 32 /* Did we come from a system call? */
29 if (PT_REGS_SYSCALL_NR(regs) >= 0) { 33 if (PT_REGS_SYSCALL_NR(regs) >= 0) {
30 /* If so, check system call restarting.. */ 34 /* If so, check system call restarting.. */
@@ -61,7 +65,7 @@ static void handle_signal(struct pt_regs *regs, unsigned long signr,
61 if (err) 65 if (err)
62 force_sigsegv(signr, current); 66 force_sigsegv(signr, current);
63 else 67 else
64 signal_delivered(signr, info, ka, regs, 0); 68 signal_delivered(signr, info, ka, regs, singlestep);
65} 69}
66 70
67static int kern_do_signal(struct pt_regs *regs) 71static int kern_do_signal(struct pt_regs *regs)
diff --git a/arch/um/kernel/syscall.c b/arch/um/kernel/syscall.c
index f958cb876ee3..a4c6d8eee74c 100644
--- a/arch/um/kernel/syscall.c
+++ b/arch/um/kernel/syscall.c
@@ -17,25 +17,25 @@
17 17
18long sys_fork(void) 18long sys_fork(void)
19{ 19{
20 long ret; 20 return do_fork(SIGCHLD, UPT_SP(&current->thread.regs.regs),
21
22 current->thread.forking = 1;
23 ret = do_fork(SIGCHLD, UPT_SP(&current->thread.regs.regs),
24 &current->thread.regs, 0, NULL, NULL); 21 &current->thread.regs, 0, NULL, NULL);
25 current->thread.forking = 0;
26 return ret;
27} 22}
28 23
29long sys_vfork(void) 24long sys_vfork(void)
30{ 25{
31 long ret; 26 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD,
32
33 current->thread.forking = 1;
34 ret = do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD,
35 UPT_SP(&current->thread.regs.regs), 27 UPT_SP(&current->thread.regs.regs),
36 &current->thread.regs, 0, NULL, NULL); 28 &current->thread.regs, 0, NULL, NULL);
37 current->thread.forking = 0; 29}
38 return ret; 30
31long sys_clone(unsigned long clone_flags, unsigned long newsp,
32 void __user *parent_tid, void __user *child_tid)
33{
34 if (!newsp)
35 newsp = UPT_SP(&current->thread.regs.regs);
36
37 return do_fork(clone_flags, newsp, &current->thread.regs, 0, parent_tid,
38 child_tid);
39} 39}
40 40
41long old_mmap(unsigned long addr, unsigned long len, 41long old_mmap(unsigned long addr, unsigned long len,
diff --git a/arch/um/scripts/Makefile.rules b/arch/um/scripts/Makefile.rules
index d50270d26b42..15889df9b466 100644
--- a/arch/um/scripts/Makefile.rules
+++ b/arch/um/scripts/Makefile.rules
@@ -8,7 +8,7 @@ USER_OBJS += $(filter %_user.o,$(obj-y) $(obj-m) $(USER_SINGLE_OBJS))
8USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file)) 8USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
9 9
10$(USER_OBJS:.o=.%): \ 10$(USER_OBJS:.o=.%): \
11 c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) -include user.h $(CFLAGS_$(basetarget).o) 11 c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) -include $(srctree)/include/linux/kern_levels.h -include user.h $(CFLAGS_$(basetarget).o)
12 12
13# These are like USER_OBJS but filter USER_CFLAGS through unprofile instead of 13# These are like USER_OBJS but filter USER_CFLAGS through unprofile instead of
14# using it directly. 14# using it directly.
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 8ec3a1aa4abd..50a1d1f9b6d3 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -746,10 +746,10 @@ config SWIOTLB
746 def_bool y if X86_64 746 def_bool y if X86_64
747 ---help--- 747 ---help---
748 Support for software bounce buffers used on x86-64 systems 748 Support for software bounce buffers used on x86-64 systems
749 which don't have a hardware IOMMU (e.g. the current generation 749 which don't have a hardware IOMMU. Using this PCI devices
750 of Intel's x86-64 CPUs). Using this PCI devices which can only 750 which can only access 32-bits of memory can be used on systems
751 access 32-bits of memory can be used on systems with more than 751 with more than 3 GB of memory.
752 3 GB of memory. If unsure, say Y. 752 If unsure, say Y.
753 753
754config IOMMU_HELPER 754config IOMMU_HELPER
755 def_bool (CALGARY_IOMMU || GART_IOMMU || SWIOTLB || AMD_IOMMU) 755 def_bool (CALGARY_IOMMU || GART_IOMMU || SWIOTLB || AMD_IOMMU)
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 682e9c210baa..474ca35b1bce 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -142,7 +142,7 @@ KBUILD_CFLAGS += $(call cc-option,-mno-avx,)
142KBUILD_CFLAGS += $(mflags-y) 142KBUILD_CFLAGS += $(mflags-y)
143KBUILD_AFLAGS += $(mflags-y) 143KBUILD_AFLAGS += $(mflags-y)
144 144
145archscripts: 145archscripts: scripts_basic
146 $(Q)$(MAKE) $(build)=arch/x86/tools relocs 146 $(Q)$(MAKE) $(build)=arch/x86/tools relocs
147 147
148### 148###
diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h
index 93971e841dd5..472b9b783019 100644
--- a/arch/x86/include/asm/xen/page.h
+++ b/arch/x86/include/asm/xen/page.h
@@ -51,7 +51,8 @@ extern unsigned long set_phys_range_identity(unsigned long pfn_s,
51 51
52extern int m2p_add_override(unsigned long mfn, struct page *page, 52extern int m2p_add_override(unsigned long mfn, struct page *page,
53 struct gnttab_map_grant_ref *kmap_op); 53 struct gnttab_map_grant_ref *kmap_op);
54extern int m2p_remove_override(struct page *page, bool clear_pte); 54extern int m2p_remove_override(struct page *page,
55 struct gnttab_map_grant_ref *kmap_op);
55extern struct page *m2p_find_override(unsigned long mfn); 56extern struct page *m2p_find_override(unsigned long mfn);
56extern unsigned long m2p_find_override_pfn(unsigned long mfn, unsigned long pfn); 57extern unsigned long m2p_find_override_pfn(unsigned long mfn, unsigned long pfn);
57 58
diff --git a/arch/x86/kernel/cpu/perf_event.h b/arch/x86/kernel/cpu/perf_event.h
index 6605a81ba339..8b6defe7eefc 100644
--- a/arch/x86/kernel/cpu/perf_event.h
+++ b/arch/x86/kernel/cpu/perf_event.h
@@ -586,6 +586,8 @@ extern struct event_constraint intel_westmere_pebs_event_constraints[];
586 586
587extern struct event_constraint intel_snb_pebs_event_constraints[]; 587extern struct event_constraint intel_snb_pebs_event_constraints[];
588 588
589extern struct event_constraint intel_ivb_pebs_event_constraints[];
590
589struct event_constraint *intel_pebs_constraints(struct perf_event *event); 591struct event_constraint *intel_pebs_constraints(struct perf_event *event);
590 592
591void intel_pmu_pebs_enable(struct perf_event *event); 593void intel_pmu_pebs_enable(struct perf_event *event);
diff --git a/arch/x86/kernel/cpu/perf_event_amd_ibs.c b/arch/x86/kernel/cpu/perf_event_amd_ibs.c
index 7bfb5bec8630..eebd5ffe1bba 100644
--- a/arch/x86/kernel/cpu/perf_event_amd_ibs.c
+++ b/arch/x86/kernel/cpu/perf_event_amd_ibs.c
@@ -209,6 +209,15 @@ static int perf_ibs_precise_event(struct perf_event *event, u64 *config)
209 return -EOPNOTSUPP; 209 return -EOPNOTSUPP;
210} 210}
211 211
212static const struct perf_event_attr ibs_notsupp = {
213 .exclude_user = 1,
214 .exclude_kernel = 1,
215 .exclude_hv = 1,
216 .exclude_idle = 1,
217 .exclude_host = 1,
218 .exclude_guest = 1,
219};
220
212static int perf_ibs_init(struct perf_event *event) 221static int perf_ibs_init(struct perf_event *event)
213{ 222{
214 struct hw_perf_event *hwc = &event->hw; 223 struct hw_perf_event *hwc = &event->hw;
@@ -229,6 +238,9 @@ static int perf_ibs_init(struct perf_event *event)
229 if (event->pmu != &perf_ibs->pmu) 238 if (event->pmu != &perf_ibs->pmu)
230 return -ENOENT; 239 return -ENOENT;
231 240
241 if (perf_flags(&event->attr) & perf_flags(&ibs_notsupp))
242 return -EINVAL;
243
232 if (config & ~perf_ibs->config_mask) 244 if (config & ~perf_ibs->config_mask)
233 return -EINVAL; 245 return -EINVAL;
234 246
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index 0d3d63afa76a..6bca492b8547 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -2048,7 +2048,6 @@ __init int intel_pmu_init(void)
2048 case 42: /* SandyBridge */ 2048 case 42: /* SandyBridge */
2049 case 45: /* SandyBridge, "Romely-EP" */ 2049 case 45: /* SandyBridge, "Romely-EP" */
2050 x86_add_quirk(intel_sandybridge_quirk); 2050 x86_add_quirk(intel_sandybridge_quirk);
2051 case 58: /* IvyBridge */
2052 memcpy(hw_cache_event_ids, snb_hw_cache_event_ids, 2051 memcpy(hw_cache_event_ids, snb_hw_cache_event_ids,
2053 sizeof(hw_cache_event_ids)); 2052 sizeof(hw_cache_event_ids));
2054 memcpy(hw_cache_extra_regs, snb_hw_cache_extra_regs, 2053 memcpy(hw_cache_extra_regs, snb_hw_cache_extra_regs,
@@ -2073,6 +2072,29 @@ __init int intel_pmu_init(void)
2073 2072
2074 pr_cont("SandyBridge events, "); 2073 pr_cont("SandyBridge events, ");
2075 break; 2074 break;
2075 case 58: /* IvyBridge */
2076 memcpy(hw_cache_event_ids, snb_hw_cache_event_ids,
2077 sizeof(hw_cache_event_ids));
2078 memcpy(hw_cache_extra_regs, snb_hw_cache_extra_regs,
2079 sizeof(hw_cache_extra_regs));
2080
2081 intel_pmu_lbr_init_snb();
2082
2083 x86_pmu.event_constraints = intel_snb_event_constraints;
2084 x86_pmu.pebs_constraints = intel_ivb_pebs_event_constraints;
2085 x86_pmu.pebs_aliases = intel_pebs_aliases_snb;
2086 x86_pmu.extra_regs = intel_snb_extra_regs;
2087 /* all extra regs are per-cpu when HT is on */
2088 x86_pmu.er_flags |= ERF_HAS_RSP_1;
2089 x86_pmu.er_flags |= ERF_NO_HT_SHARING;
2090
2091 /* UOPS_ISSUED.ANY,c=1,i=1 to count stall cycles */
2092 intel_perfmon_event_map[PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] =
2093 X86_CONFIG(.event=0x0e, .umask=0x01, .inv=1, .cmask=1);
2094
2095 pr_cont("IvyBridge events, ");
2096 break;
2097
2076 2098
2077 default: 2099 default:
2078 switch (x86_pmu.version) { 2100 switch (x86_pmu.version) {
diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c b/arch/x86/kernel/cpu/perf_event_intel_ds.c
index e38d97bf4259..826054a4f2ee 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_ds.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c
@@ -407,6 +407,20 @@ struct event_constraint intel_snb_pebs_event_constraints[] = {
407 EVENT_CONSTRAINT_END 407 EVENT_CONSTRAINT_END
408}; 408};
409 409
410struct event_constraint intel_ivb_pebs_event_constraints[] = {
411 INTEL_UEVENT_CONSTRAINT(0x01c0, 0x2), /* INST_RETIRED.PRECDIST */
412 INTEL_UEVENT_CONSTRAINT(0x01c2, 0xf), /* UOPS_RETIRED.ALL */
413 INTEL_UEVENT_CONSTRAINT(0x02c2, 0xf), /* UOPS_RETIRED.RETIRE_SLOTS */
414 INTEL_EVENT_CONSTRAINT(0xc4, 0xf), /* BR_INST_RETIRED.* */
415 INTEL_EVENT_CONSTRAINT(0xc5, 0xf), /* BR_MISP_RETIRED.* */
416 INTEL_EVENT_CONSTRAINT(0xcd, 0x8), /* MEM_TRANS_RETIRED.* */
417 INTEL_EVENT_CONSTRAINT(0xd0, 0xf), /* MEM_UOP_RETIRED.* */
418 INTEL_EVENT_CONSTRAINT(0xd1, 0xf), /* MEM_LOAD_UOPS_RETIRED.* */
419 INTEL_EVENT_CONSTRAINT(0xd2, 0xf), /* MEM_LOAD_UOPS_LLC_HIT_RETIRED.* */
420 INTEL_EVENT_CONSTRAINT(0xd3, 0xf), /* MEM_LOAD_UOPS_LLC_MISS_RETIRED.* */
421 EVENT_CONSTRAINT_END
422};
423
410struct event_constraint *intel_pebs_constraints(struct perf_event *event) 424struct event_constraint *intel_pebs_constraints(struct perf_event *event)
411{ 425{
412 struct event_constraint *c; 426 struct event_constraint *c;
diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
index 0a5571080e74..38e4894165b9 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
@@ -661,6 +661,11 @@ static void snb_uncore_msr_init_box(struct intel_uncore_box *box)
661 } 661 }
662} 662}
663 663
664static struct uncore_event_desc snb_uncore_events[] = {
665 INTEL_UNCORE_EVENT_DESC(clockticks, "event=0xff,umask=0x00"),
666 { /* end: all zeroes */ },
667};
668
664static struct attribute *snb_uncore_formats_attr[] = { 669static struct attribute *snb_uncore_formats_attr[] = {
665 &format_attr_event.attr, 670 &format_attr_event.attr,
666 &format_attr_umask.attr, 671 &format_attr_umask.attr,
@@ -704,6 +709,7 @@ static struct intel_uncore_type snb_uncore_cbox = {
704 .constraints = snb_uncore_cbox_constraints, 709 .constraints = snb_uncore_cbox_constraints,
705 .ops = &snb_uncore_msr_ops, 710 .ops = &snb_uncore_msr_ops,
706 .format_group = &snb_uncore_format_group, 711 .format_group = &snb_uncore_format_group,
712 .event_descs = snb_uncore_events,
707}; 713};
708 714
709static struct intel_uncore_type *snb_msr_uncores[] = { 715static struct intel_uncore_type *snb_msr_uncores[] = {
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index e0e6990723e9..ab1f6a93b527 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -319,7 +319,7 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
319 */ 319 */
320int devmem_is_allowed(unsigned long pagenr) 320int devmem_is_allowed(unsigned long pagenr)
321{ 321{
322 if (pagenr <= 256) 322 if (pagenr < 256)
323 return 1; 323 return 1;
324 if (iomem_is_exclusive(pagenr << PAGE_SHIFT)) 324 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
325 return 0; 325 return 0;
diff --git a/arch/x86/um/Kconfig b/arch/x86/um/Kconfig
index 9926e11a772d..aeaff8bef2f1 100644
--- a/arch/x86/um/Kconfig
+++ b/arch/x86/um/Kconfig
@@ -21,6 +21,7 @@ config 64BIT
21config X86_32 21config X86_32
22 def_bool !64BIT 22 def_bool !64BIT
23 select HAVE_AOUT 23 select HAVE_AOUT
24 select ARCH_WANT_IPC_PARSE_VERSION
24 25
25config X86_64 26config X86_64
26 def_bool 64BIT 27 def_bool 64BIT
diff --git a/arch/x86/um/shared/sysdep/kernel-offsets.h b/arch/x86/um/shared/sysdep/kernel-offsets.h
index 5868526b5eef..46a9df99f3c5 100644
--- a/arch/x86/um/shared/sysdep/kernel-offsets.h
+++ b/arch/x86/um/shared/sysdep/kernel-offsets.h
@@ -7,9 +7,6 @@
7#define DEFINE(sym, val) \ 7#define DEFINE(sym, val) \
8 asm volatile("\n->" #sym " %0 " #val : : "i" (val)) 8 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
9 9
10#define STR(x) #x
11#define DEFINE_STR(sym, val) asm volatile("\n->" #sym " " STR(val) " " #val: : )
12
13#define BLANK() asm volatile("\n->" : : ) 10#define BLANK() asm volatile("\n->" : : )
14 11
15#define OFFSET(sym, str, mem) \ 12#define OFFSET(sym, str, mem) \
diff --git a/arch/x86/um/shared/sysdep/syscalls.h b/arch/x86/um/shared/sysdep/syscalls.h
index bd9a89b67e41..ca255a805ed9 100644
--- a/arch/x86/um/shared/sysdep/syscalls.h
+++ b/arch/x86/um/shared/sysdep/syscalls.h
@@ -1,3 +1,5 @@
1extern long sys_clone(unsigned long clone_flags, unsigned long newsp,
2 void __user *parent_tid, void __user *child_tid);
1#ifdef __i386__ 3#ifdef __i386__
2#include "syscalls_32.h" 4#include "syscalls_32.h"
3#else 5#else
diff --git a/arch/x86/um/signal.c b/arch/x86/um/signal.c
index a508cea13503..ba7363ecf896 100644
--- a/arch/x86/um/signal.c
+++ b/arch/x86/um/signal.c
@@ -416,9 +416,6 @@ int setup_signal_stack_sc(unsigned long stack_top, int sig,
416 PT_REGS_AX(regs) = (unsigned long) sig; 416 PT_REGS_AX(regs) = (unsigned long) sig;
417 PT_REGS_DX(regs) = (unsigned long) 0; 417 PT_REGS_DX(regs) = (unsigned long) 0;
418 PT_REGS_CX(regs) = (unsigned long) 0; 418 PT_REGS_CX(regs) = (unsigned long) 0;
419
420 if ((current->ptrace & PT_DTRACE) && (current->ptrace & PT_PTRACED))
421 ptrace_notify(SIGTRAP);
422 return 0; 419 return 0;
423} 420}
424 421
@@ -466,9 +463,6 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
466 PT_REGS_AX(regs) = (unsigned long) sig; 463 PT_REGS_AX(regs) = (unsigned long) sig;
467 PT_REGS_DX(regs) = (unsigned long) &frame->info; 464 PT_REGS_DX(regs) = (unsigned long) &frame->info;
468 PT_REGS_CX(regs) = (unsigned long) &frame->uc; 465 PT_REGS_CX(regs) = (unsigned long) &frame->uc;
469
470 if ((current->ptrace & PT_DTRACE) && (current->ptrace & PT_PTRACED))
471 ptrace_notify(SIGTRAP);
472 return 0; 466 return 0;
473} 467}
474 468
diff --git a/arch/x86/um/sys_call_table_32.c b/arch/x86/um/sys_call_table_32.c
index 68d1dc91b37b..b5408cecac6c 100644
--- a/arch/x86/um/sys_call_table_32.c
+++ b/arch/x86/um/sys_call_table_32.c
@@ -28,7 +28,7 @@
28#define ptregs_execve sys_execve 28#define ptregs_execve sys_execve
29#define ptregs_iopl sys_iopl 29#define ptregs_iopl sys_iopl
30#define ptregs_vm86old sys_vm86old 30#define ptregs_vm86old sys_vm86old
31#define ptregs_clone sys_clone 31#define ptregs_clone i386_clone
32#define ptregs_vm86 sys_vm86 32#define ptregs_vm86 sys_vm86
33#define ptregs_sigaltstack sys_sigaltstack 33#define ptregs_sigaltstack sys_sigaltstack
34#define ptregs_vfork sys_vfork 34#define ptregs_vfork sys_vfork
diff --git a/arch/x86/um/syscalls_32.c b/arch/x86/um/syscalls_32.c
index b853e8600b9d..db444c7218fe 100644
--- a/arch/x86/um/syscalls_32.c
+++ b/arch/x86/um/syscalls_32.c
@@ -3,37 +3,24 @@
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
5 5
6#include "linux/sched.h" 6#include <linux/syscalls.h>
7#include "linux/shm.h" 7#include <sysdep/syscalls.h>
8#include "linux/ipc.h"
9#include "linux/syscalls.h"
10#include "asm/mman.h"
11#include "asm/uaccess.h"
12#include "asm/unistd.h"
13 8
14/* 9/*
15 * The prototype on i386 is: 10 * The prototype on i386 is:
16 * 11 *
17 * int clone(int flags, void * child_stack, int * parent_tidptr, struct user_desc * newtls, int * child_tidptr) 12 * int clone(int flags, void * child_stack, int * parent_tidptr, struct user_desc * newtls
18 * 13 *
19 * and the "newtls" arg. on i386 is read by copy_thread directly from the 14 * and the "newtls" arg. on i386 is read by copy_thread directly from the
20 * register saved on the stack. 15 * register saved on the stack.
21 */ 16 */
22long sys_clone(unsigned long clone_flags, unsigned long newsp, 17long i386_clone(unsigned long clone_flags, unsigned long newsp,
23 int __user *parent_tid, void *newtls, int __user *child_tid) 18 int __user *parent_tid, void *newtls, int __user *child_tid)
24{ 19{
25 long ret; 20 return sys_clone(clone_flags, newsp, parent_tid, child_tid);
26
27 if (!newsp)
28 newsp = UPT_SP(&current->thread.regs.regs);
29
30 current->thread.forking = 1;
31 ret = do_fork(clone_flags, newsp, &current->thread.regs, 0, parent_tid,
32 child_tid);
33 current->thread.forking = 0;
34 return ret;
35} 21}
36 22
23
37long sys_sigaction(int sig, const struct old_sigaction __user *act, 24long sys_sigaction(int sig, const struct old_sigaction __user *act,
38 struct old_sigaction __user *oact) 25 struct old_sigaction __user *oact)
39{ 26{
diff --git a/arch/x86/um/syscalls_64.c b/arch/x86/um/syscalls_64.c
index f3d82bb6e15a..adb08eb5c22a 100644
--- a/arch/x86/um/syscalls_64.c
+++ b/arch/x86/um/syscalls_64.c
@@ -5,12 +5,9 @@
5 * Licensed under the GPL 5 * Licensed under the GPL
6 */ 6 */
7 7
8#include "linux/linkage.h" 8#include <linux/sched.h>
9#include "linux/personality.h" 9#include <asm/prctl.h> /* XXX This should get the constants from libc */
10#include "linux/utsname.h" 10#include <os.h>
11#include "asm/prctl.h" /* XXX This should get the constants from libc */
12#include "asm/uaccess.h"
13#include "os.h"
14 11
15long arch_prctl(struct task_struct *task, int code, unsigned long __user *addr) 12long arch_prctl(struct task_struct *task, int code, unsigned long __user *addr)
16{ 13{
@@ -79,20 +76,6 @@ long sys_arch_prctl(int code, unsigned long addr)
79 return arch_prctl(current, code, (unsigned long __user *) addr); 76 return arch_prctl(current, code, (unsigned long __user *) addr);
80} 77}
81 78
82long sys_clone(unsigned long clone_flags, unsigned long newsp,
83 void __user *parent_tid, void __user *child_tid)
84{
85 long ret;
86
87 if (!newsp)
88 newsp = UPT_SP(&current->thread.regs.regs);
89 current->thread.forking = 1;
90 ret = do_fork(clone_flags, newsp, &current->thread.regs, 0, parent_tid,
91 child_tid);
92 current->thread.forking = 0;
93 return ret;
94}
95
96void arch_switch_to(struct task_struct *to) 79void arch_switch_to(struct task_struct *to)
97{ 80{
98 if ((to->thread.arch.fs == 0) || (to->mm == NULL)) 81 if ((to->thread.arch.fs == 0) || (to->mm == NULL))
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 9642d4a38602..1fbe75a95f15 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1452,6 +1452,10 @@ asmlinkage void __init xen_start_kernel(void)
1452 pci_request_acs(); 1452 pci_request_acs();
1453 1453
1454 xen_acpi_sleep_register(); 1454 xen_acpi_sleep_register();
1455
1456 /* Avoid searching for BIOS MP tables */
1457 x86_init.mpparse.find_smp_config = x86_init_noop;
1458 x86_init.mpparse.get_smp_config = x86_init_uint_noop;
1455 } 1459 }
1456#ifdef CONFIG_PCI 1460#ifdef CONFIG_PCI
1457 /* PCI BIOS service won't work from a PV guest. */ 1461 /* PCI BIOS service won't work from a PV guest. */
diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
index 76ba0e97e530..72213da605f5 100644
--- a/arch/x86/xen/p2m.c
+++ b/arch/x86/xen/p2m.c
@@ -828,9 +828,6 @@ int m2p_add_override(unsigned long mfn, struct page *page,
828 828
829 xen_mc_issue(PARAVIRT_LAZY_MMU); 829 xen_mc_issue(PARAVIRT_LAZY_MMU);
830 } 830 }
831 /* let's use dev_bus_addr to record the old mfn instead */
832 kmap_op->dev_bus_addr = page->index;
833 page->index = (unsigned long) kmap_op;
834 } 831 }
835 spin_lock_irqsave(&m2p_override_lock, flags); 832 spin_lock_irqsave(&m2p_override_lock, flags);
836 list_add(&page->lru, &m2p_overrides[mfn_hash(mfn)]); 833 list_add(&page->lru, &m2p_overrides[mfn_hash(mfn)]);
@@ -857,7 +854,8 @@ int m2p_add_override(unsigned long mfn, struct page *page,
857 return 0; 854 return 0;
858} 855}
859EXPORT_SYMBOL_GPL(m2p_add_override); 856EXPORT_SYMBOL_GPL(m2p_add_override);
860int m2p_remove_override(struct page *page, bool clear_pte) 857int m2p_remove_override(struct page *page,
858 struct gnttab_map_grant_ref *kmap_op)
861{ 859{
862 unsigned long flags; 860 unsigned long flags;
863 unsigned long mfn; 861 unsigned long mfn;
@@ -887,10 +885,8 @@ int m2p_remove_override(struct page *page, bool clear_pte)
887 WARN_ON(!PagePrivate(page)); 885 WARN_ON(!PagePrivate(page));
888 ClearPagePrivate(page); 886 ClearPagePrivate(page);
889 887
890 if (clear_pte) { 888 set_phys_to_machine(pfn, page->index);
891 struct gnttab_map_grant_ref *map_op = 889 if (kmap_op != NULL) {
892 (struct gnttab_map_grant_ref *) page->index;
893 set_phys_to_machine(pfn, map_op->dev_bus_addr);
894 if (!PageHighMem(page)) { 890 if (!PageHighMem(page)) {
895 struct multicall_space mcs; 891 struct multicall_space mcs;
896 struct gnttab_unmap_grant_ref *unmap_op; 892 struct gnttab_unmap_grant_ref *unmap_op;
@@ -902,13 +898,13 @@ int m2p_remove_override(struct page *page, bool clear_pte)
902 * issued. In this case handle is going to -1 because 898 * issued. In this case handle is going to -1 because
903 * it hasn't been modified yet. 899 * it hasn't been modified yet.
904 */ 900 */
905 if (map_op->handle == -1) 901 if (kmap_op->handle == -1)
906 xen_mc_flush(); 902 xen_mc_flush();
907 /* 903 /*
908 * Now if map_op->handle is negative it means that the 904 * Now if kmap_op->handle is negative it means that the
909 * hypercall actually returned an error. 905 * hypercall actually returned an error.
910 */ 906 */
911 if (map_op->handle == GNTST_general_error) { 907 if (kmap_op->handle == GNTST_general_error) {
912 printk(KERN_WARNING "m2p_remove_override: " 908 printk(KERN_WARNING "m2p_remove_override: "
913 "pfn %lx mfn %lx, failed to modify kernel mappings", 909 "pfn %lx mfn %lx, failed to modify kernel mappings",
914 pfn, mfn); 910 pfn, mfn);
@@ -918,8 +914,8 @@ int m2p_remove_override(struct page *page, bool clear_pte)
918 mcs = xen_mc_entry( 914 mcs = xen_mc_entry(
919 sizeof(struct gnttab_unmap_grant_ref)); 915 sizeof(struct gnttab_unmap_grant_ref));
920 unmap_op = mcs.args; 916 unmap_op = mcs.args;
921 unmap_op->host_addr = map_op->host_addr; 917 unmap_op->host_addr = kmap_op->host_addr;
922 unmap_op->handle = map_op->handle; 918 unmap_op->handle = kmap_op->handle;
923 unmap_op->dev_bus_addr = 0; 919 unmap_op->dev_bus_addr = 0;
924 920
925 MULTI_grant_table_op(mcs.mc, 921 MULTI_grant_table_op(mcs.mc,
@@ -930,10 +926,9 @@ int m2p_remove_override(struct page *page, bool clear_pte)
930 set_pte_at(&init_mm, address, ptep, 926 set_pte_at(&init_mm, address, ptep,
931 pfn_pte(pfn, PAGE_KERNEL)); 927 pfn_pte(pfn, PAGE_KERNEL));
932 __flush_tlb_single(address); 928 __flush_tlb_single(address);
933 map_op->host_addr = 0; 929 kmap_op->host_addr = 0;
934 } 930 }
935 } else 931 }
936 set_phys_to_machine(pfn, page->index);
937 932
938 /* p2m(m2p(mfn)) == FOREIGN_FRAME(mfn): the mfn is already present 933 /* p2m(m2p(mfn)) == FOREIGN_FRAME(mfn): the mfn is already present
939 * somewhere in this domain, even before being added to the 934 * somewhere in this domain, even before being added to the
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index d11ca11d14fc..e2d62d697b5d 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -17,6 +17,7 @@
17#include <asm/e820.h> 17#include <asm/e820.h>
18#include <asm/setup.h> 18#include <asm/setup.h>
19#include <asm/acpi.h> 19#include <asm/acpi.h>
20#include <asm/numa.h>
20#include <asm/xen/hypervisor.h> 21#include <asm/xen/hypervisor.h>
21#include <asm/xen/hypercall.h> 22#include <asm/xen/hypercall.h>
22 23
@@ -544,4 +545,7 @@ void __init xen_arch_setup(void)
544 disable_cpufreq(); 545 disable_cpufreq();
545 WARN_ON(set_pm_idle_to_default()); 546 WARN_ON(set_pm_idle_to_default());
546 fiddle_vdso(); 547 fiddle_vdso();
548#ifdef CONFIG_NUMA
549 numa_off = 1;
550#endif
547} 551}
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile
index 0a1b3435f920..7f1d40797e80 100644
--- a/drivers/acpi/acpica/Makefile
+++ b/drivers/acpi/acpica/Makefile
@@ -158,5 +158,6 @@ acpi-y += \
158 utresrc.o \ 158 utresrc.o \
159 utstate.o \ 159 utstate.o \
160 utxface.o \ 160 utxface.o \
161 utxfinit.o \
161 utxferror.o \ 162 utxferror.o \
162 utxfmutex.o 163 utxfmutex.o
diff --git a/drivers/acpi/acpica/achware.h b/drivers/acpi/acpica/achware.h
index 5de4ec72766d..d902d31abc6c 100644
--- a/drivers/acpi/acpica/achware.h
+++ b/drivers/acpi/acpica/achware.h
@@ -110,8 +110,7 @@ acpi_status acpi_hw_write_port(acpi_io_address address, u32 value, u32 width);
110/* 110/*
111 * hwgpe - GPE support 111 * hwgpe - GPE support
112 */ 112 */
113u32 acpi_hw_get_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info, 113u32 acpi_hw_get_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info);
114 struct acpi_gpe_register_info *gpe_register_info);
115 114
116acpi_status 115acpi_status
117acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u32 action); 116acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u32 action);
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index cc80fe10e8ea..c816ee675094 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -707,15 +707,18 @@ union acpi_parse_value {
707 u8 disasm_opcode; /* Subtype used for disassembly */\ 707 u8 disasm_opcode; /* Subtype used for disassembly */\
708 char aml_op_name[16]) /* Op name (debug only) */ 708 char aml_op_name[16]) /* Op name (debug only) */
709 709
710#define ACPI_DASM_BUFFER 0x00 710/* Flags for disasm_flags field above */
711#define ACPI_DASM_RESOURCE 0x01 711
712#define ACPI_DASM_STRING 0x02 712#define ACPI_DASM_BUFFER 0x00 /* Buffer is a simple data buffer */
713#define ACPI_DASM_UNICODE 0x03 713#define ACPI_DASM_RESOURCE 0x01 /* Buffer is a Resource Descriptor */
714#define ACPI_DASM_EISAID 0x04 714#define ACPI_DASM_STRING 0x02 /* Buffer is a ASCII string */
715#define ACPI_DASM_MATCHOP 0x05 715#define ACPI_DASM_UNICODE 0x03 /* Buffer is a Unicode string */
716#define ACPI_DASM_LNOT_PREFIX 0x06 716#define ACPI_DASM_PLD_METHOD 0x04 /* Buffer is a _PLD method bit-packed buffer */
717#define ACPI_DASM_LNOT_SUFFIX 0x07 717#define ACPI_DASM_EISAID 0x05 /* Integer is an EISAID */
718#define ACPI_DASM_IGNORE 0x08 718#define ACPI_DASM_MATCHOP 0x06 /* Parent opcode is a Match() operator */
719#define ACPI_DASM_LNOT_PREFIX 0x07 /* Start of a Lnot_equal (etc.) pair of opcodes */
720#define ACPI_DASM_LNOT_SUFFIX 0x08 /* End of a Lnot_equal (etc.) pair of opcodes */
721#define ACPI_DASM_IGNORE 0x09 /* Not used at this time */
719 722
720/* 723/*
721 * Generic operation (for example: If, While, Store) 724 * Generic operation (for example: If, While, Store)
@@ -932,6 +935,7 @@ struct acpi_bit_register_info {
932#define ACPI_OSI_WIN_VISTA_SP1 0x09 935#define ACPI_OSI_WIN_VISTA_SP1 0x09
933#define ACPI_OSI_WIN_VISTA_SP2 0x0A 936#define ACPI_OSI_WIN_VISTA_SP2 0x0A
934#define ACPI_OSI_WIN_7 0x0B 937#define ACPI_OSI_WIN_7 0x0B
938#define ACPI_OSI_WIN_8 0x0C
935 939
936#define ACPI_ALWAYS_ILLEGAL 0x00 940#define ACPI_ALWAYS_ILLEGAL 0x00
937 941
@@ -1024,6 +1028,7 @@ struct acpi_port_info {
1024 ****************************************************************************/ 1028 ****************************************************************************/
1025 1029
1026struct acpi_db_method_info { 1030struct acpi_db_method_info {
1031 acpi_handle method;
1027 acpi_handle main_thread_gate; 1032 acpi_handle main_thread_gate;
1028 acpi_handle thread_complete_gate; 1033 acpi_handle thread_complete_gate;
1029 acpi_thread_id *threads; 1034 acpi_thread_id *threads;
diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h
index 832b6198652e..a7f68c47f517 100644
--- a/drivers/acpi/acpica/acmacros.h
+++ b/drivers/acpi/acpica/acmacros.h
@@ -277,10 +277,33 @@
277 277
278/* Bitfields within ACPI registers */ 278/* Bitfields within ACPI registers */
279 279
280#define ACPI_REGISTER_PREPARE_BITS(val, pos, mask) ((val << pos) & mask) 280#define ACPI_REGISTER_PREPARE_BITS(val, pos, mask) \
281#define ACPI_REGISTER_INSERT_VALUE(reg, pos, mask, val) reg = (reg & (~(mask))) | ACPI_REGISTER_PREPARE_BITS(val, pos, mask) 281 ((val << pos) & mask)
282 282
283#define ACPI_INSERT_BITS(target, mask, source) target = ((target & (~(mask))) | (source & mask)) 283#define ACPI_REGISTER_INSERT_VALUE(reg, pos, mask, val) \
284 reg = (reg & (~(mask))) | ACPI_REGISTER_PREPARE_BITS(val, pos, mask)
285
286#define ACPI_INSERT_BITS(target, mask, source) \
287 target = ((target & (~(mask))) | (source & mask))
288
289/* Generic bitfield macros and masks */
290
291#define ACPI_GET_BITS(source_ptr, position, mask) \
292 ((*source_ptr >> position) & mask)
293
294#define ACPI_SET_BITS(target_ptr, position, mask, value) \
295 (*target_ptr |= ((value & mask) << position))
296
297#define ACPI_1BIT_MASK 0x00000001
298#define ACPI_2BIT_MASK 0x00000003
299#define ACPI_3BIT_MASK 0x00000007
300#define ACPI_4BIT_MASK 0x0000000F
301#define ACPI_5BIT_MASK 0x0000001F
302#define ACPI_6BIT_MASK 0x0000003F
303#define ACPI_7BIT_MASK 0x0000007F
304#define ACPI_8BIT_MASK 0x000000FF
305#define ACPI_16BIT_MASK 0x0000FFFF
306#define ACPI_24BIT_MASK 0x00FFFFFF
284 307
285/* 308/*
286 * An object of type struct acpi_namespace_node can appear in some contexts 309 * An object of type struct acpi_namespace_node can appear in some contexts
diff --git a/drivers/acpi/acpica/dswload.c b/drivers/acpi/acpica/dswload.c
index 552aa3a50c84..557510084c7a 100644
--- a/drivers/acpi/acpica/dswload.c
+++ b/drivers/acpi/acpica/dswload.c
@@ -230,6 +230,20 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
230 walk_state->scope_info->common.value = ACPI_TYPE_ANY; 230 walk_state->scope_info->common.value = ACPI_TYPE_ANY;
231 break; 231 break;
232 232
233 case ACPI_TYPE_METHOD:
234
235 /*
236 * Allow scope change to root during execution of module-level
237 * code. Root is typed METHOD during this time.
238 */
239 if ((node == acpi_gbl_root_node) &&
240 (walk_state->
241 parse_flags & ACPI_PARSE_MODULE_LEVEL)) {
242 break;
243 }
244
245 /*lint -fallthrough */
246
233 default: 247 default:
234 248
235 /* All other types are an error */ 249 /* All other types are an error */
diff --git a/drivers/acpi/acpica/dswload2.c b/drivers/acpi/acpica/dswload2.c
index ae7147724763..89c0114210c0 100644
--- a/drivers/acpi/acpica/dswload2.c
+++ b/drivers/acpi/acpica/dswload2.c
@@ -230,6 +230,20 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
230 walk_state->scope_info->common.value = ACPI_TYPE_ANY; 230 walk_state->scope_info->common.value = ACPI_TYPE_ANY;
231 break; 231 break;
232 232
233 case ACPI_TYPE_METHOD:
234
235 /*
236 * Allow scope change to root during execution of module-level
237 * code. Root is typed METHOD during this time.
238 */
239 if ((node == acpi_gbl_root_node) &&
240 (walk_state->
241 parse_flags & ACPI_PARSE_MODULE_LEVEL)) {
242 break;
243 }
244
245 /*lint -fallthrough */
246
233 default: 247 default:
234 248
235 /* All other types are an error */ 249 /* All other types are an error */
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c
index afbd5cb391f6..ef0193d74b5d 100644
--- a/drivers/acpi/acpica/evgpe.c
+++ b/drivers/acpi/acpica/evgpe.c
@@ -80,8 +80,7 @@ acpi_ev_update_gpe_enable_mask(struct acpi_gpe_event_info *gpe_event_info)
80 return_ACPI_STATUS(AE_NOT_EXIST); 80 return_ACPI_STATUS(AE_NOT_EXIST);
81 } 81 }
82 82
83 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info, 83 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info);
84 gpe_register_info);
85 84
86 /* Clear the run bit up front */ 85 /* Clear the run bit up front */
87 86
@@ -379,6 +378,18 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
379 */ 378 */
380 if (!(gpe_register_info->enable_for_run | 379 if (!(gpe_register_info->enable_for_run |
381 gpe_register_info->enable_for_wake)) { 380 gpe_register_info->enable_for_wake)) {
381 ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS,
382 "Ignore disabled registers for GPE%02X-GPE%02X: "
383 "RunEnable=%02X, WakeEnable=%02X\n",
384 gpe_register_info->
385 base_gpe_number,
386 gpe_register_info->
387 base_gpe_number +
388 (ACPI_GPE_REGISTER_WIDTH - 1),
389 gpe_register_info->
390 enable_for_run,
391 gpe_register_info->
392 enable_for_wake));
382 continue; 393 continue;
383 } 394 }
384 395
@@ -401,9 +412,14 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
401 } 412 }
402 413
403 ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS, 414 ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS,
404 "Read GPE Register at GPE%02X: Status=%02X, Enable=%02X\n", 415 "Read registers for GPE%02X-GPE%02X: Status=%02X, Enable=%02X, "
416 "RunEnable=%02X, WakeEnable=%02X\n",
405 gpe_register_info->base_gpe_number, 417 gpe_register_info->base_gpe_number,
406 status_reg, enable_reg)); 418 gpe_register_info->base_gpe_number +
419 (ACPI_GPE_REGISTER_WIDTH - 1),
420 status_reg, enable_reg,
421 gpe_register_info->enable_for_run,
422 gpe_register_info->enable_for_wake));
407 423
408 /* Check if there is anything active at all in this register */ 424 /* Check if there is anything active at all in this register */
409 425
diff --git a/drivers/acpi/acpica/evxfgpe.c b/drivers/acpi/acpica/evxfgpe.c
index 6affbdb4b88c..87c5f2332260 100644
--- a/drivers/acpi/acpica/evxfgpe.c
+++ b/drivers/acpi/acpica/evxfgpe.c
@@ -357,8 +357,7 @@ acpi_status acpi_set_gpe_wake_mask(acpi_handle gpe_device, u32 gpe_number, u8 ac
357 goto unlock_and_exit; 357 goto unlock_and_exit;
358 } 358 }
359 359
360 register_bit = 360 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info);
361 acpi_hw_get_gpe_register_bit(gpe_event_info, gpe_register_info);
362 361
363 /* Perform the action */ 362 /* Perform the action */
364 363
diff --git a/drivers/acpi/acpica/hwgpe.c b/drivers/acpi/acpica/hwgpe.c
index 25bd28c4ae8d..db4076580e2b 100644
--- a/drivers/acpi/acpica/hwgpe.c
+++ b/drivers/acpi/acpica/hwgpe.c
@@ -60,7 +60,6 @@ acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
60 * FUNCTION: acpi_hw_get_gpe_register_bit 60 * FUNCTION: acpi_hw_get_gpe_register_bit
61 * 61 *
62 * PARAMETERS: gpe_event_info - Info block for the GPE 62 * PARAMETERS: gpe_event_info - Info block for the GPE
63 * gpe_register_info - Info block for the GPE register
64 * 63 *
65 * RETURN: Register mask with a one in the GPE bit position 64 * RETURN: Register mask with a one in the GPE bit position
66 * 65 *
@@ -69,11 +68,10 @@ acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
69 * 68 *
70 ******************************************************************************/ 69 ******************************************************************************/
71 70
72u32 acpi_hw_get_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info, 71u32 acpi_hw_get_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info)
73 struct acpi_gpe_register_info *gpe_register_info)
74{ 72{
75 return (u32)1 << (gpe_event_info->gpe_number - 73 return (u32)1 << (gpe_event_info->gpe_number -
76 gpe_register_info->base_gpe_number); 74 gpe_event_info->register_info->base_gpe_number);
77} 75}
78 76
79/****************************************************************************** 77/******************************************************************************
@@ -115,8 +113,7 @@ acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u32 action)
115 113
116 /* Set or clear just the bit that corresponds to this GPE */ 114 /* Set or clear just the bit that corresponds to this GPE */
117 115
118 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info, 116 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info);
119 gpe_register_info);
120 switch (action) { 117 switch (action) {
121 case ACPI_GPE_CONDITIONAL_ENABLE: 118 case ACPI_GPE_CONDITIONAL_ENABLE:
122 119
@@ -178,8 +175,7 @@ acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info * gpe_event_info)
178 * Write a one to the appropriate bit in the status register to 175 * Write a one to the appropriate bit in the status register to
179 * clear this GPE. 176 * clear this GPE.
180 */ 177 */
181 register_bit = 178 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info);
182 acpi_hw_get_gpe_register_bit(gpe_event_info, gpe_register_info);
183 179
184 status = acpi_hw_write(register_bit, 180 status = acpi_hw_write(register_bit,
185 &gpe_register_info->status_address); 181 &gpe_register_info->status_address);
@@ -222,8 +218,7 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
222 218
223 /* Get the register bitmask for this GPE */ 219 /* Get the register bitmask for this GPE */
224 220
225 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info, 221 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info);
226 gpe_register_info);
227 222
228 /* GPE currently enabled? (enabled for runtime?) */ 223 /* GPE currently enabled? (enabled for runtime?) */
229 224
diff --git a/drivers/acpi/acpica/hwxfsleep.c b/drivers/acpi/acpica/hwxfsleep.c
index 1f165a750ae2..0ff1ecea5c3a 100644
--- a/drivers/acpi/acpica/hwxfsleep.c
+++ b/drivers/acpi/acpica/hwxfsleep.c
@@ -381,7 +381,6 @@ ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state)
381 * FUNCTION: acpi_leave_sleep_state_prep 381 * FUNCTION: acpi_leave_sleep_state_prep
382 * 382 *
383 * PARAMETERS: sleep_state - Which sleep state we are exiting 383 * PARAMETERS: sleep_state - Which sleep state we are exiting
384 * flags - ACPI_EXECUTE_BFS to run optional method
385 * 384 *
386 * RETURN: Status 385 * RETURN: Status
387 * 386 *
diff --git a/drivers/acpi/acpica/nsdump.c b/drivers/acpi/acpica/nsdump.c
index 7ee4e6aeb0a2..2526aaf945ee 100644
--- a/drivers/acpi/acpica/nsdump.c
+++ b/drivers/acpi/acpica/nsdump.c
@@ -264,7 +264,7 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
264 switch (type) { 264 switch (type) {
265 case ACPI_TYPE_PROCESSOR: 265 case ACPI_TYPE_PROCESSOR:
266 266
267 acpi_os_printf("ID %X Len %.4X Addr %p\n", 267 acpi_os_printf("ID %02X Len %02X Addr %p\n",
268 obj_desc->processor.proc_id, 268 obj_desc->processor.proc_id,
269 obj_desc->processor.length, 269 obj_desc->processor.length,
270 ACPI_CAST_PTR(void, 270 ACPI_CAST_PTR(void,
diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c
index 74f97d74db1c..70f9d787c82c 100644
--- a/drivers/acpi/acpica/tbinstal.c
+++ b/drivers/acpi/acpica/tbinstal.c
@@ -350,6 +350,7 @@ struct acpi_table_header *acpi_tb_table_override(struct acpi_table_header
350acpi_status acpi_tb_resize_root_table_list(void) 350acpi_status acpi_tb_resize_root_table_list(void)
351{ 351{
352 struct acpi_table_desc *tables; 352 struct acpi_table_desc *tables;
353 u32 table_count;
353 354
354 ACPI_FUNCTION_TRACE(tb_resize_root_table_list); 355 ACPI_FUNCTION_TRACE(tb_resize_root_table_list);
355 356
@@ -363,8 +364,13 @@ acpi_status acpi_tb_resize_root_table_list(void)
363 364
364 /* Increase the Table Array size */ 365 /* Increase the Table Array size */
365 366
366 tables = ACPI_ALLOCATE_ZEROED(((acpi_size) acpi_gbl_root_table_list. 367 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
367 max_table_count + 368 table_count = acpi_gbl_root_table_list.max_table_count;
369 } else {
370 table_count = acpi_gbl_root_table_list.current_table_count;
371 }
372
373 tables = ACPI_ALLOCATE_ZEROED(((acpi_size) table_count +
368 ACPI_ROOT_TABLE_SIZE_INCREMENT) * 374 ACPI_ROOT_TABLE_SIZE_INCREMENT) *
369 sizeof(struct acpi_table_desc)); 375 sizeof(struct acpi_table_desc));
370 if (!tables) { 376 if (!tables) {
@@ -377,8 +383,8 @@ acpi_status acpi_tb_resize_root_table_list(void)
377 383
378 if (acpi_gbl_root_table_list.tables) { 384 if (acpi_gbl_root_table_list.tables) {
379 ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables, 385 ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables,
380 (acpi_size) acpi_gbl_root_table_list. 386 (acpi_size) table_count *
381 max_table_count * sizeof(struct acpi_table_desc)); 387 sizeof(struct acpi_table_desc));
382 388
383 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { 389 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
384 ACPI_FREE(acpi_gbl_root_table_list.tables); 390 ACPI_FREE(acpi_gbl_root_table_list.tables);
@@ -386,9 +392,9 @@ acpi_status acpi_tb_resize_root_table_list(void)
386 } 392 }
387 393
388 acpi_gbl_root_table_list.tables = tables; 394 acpi_gbl_root_table_list.tables = tables;
389 acpi_gbl_root_table_list.max_table_count += 395 acpi_gbl_root_table_list.max_table_count =
390 ACPI_ROOT_TABLE_SIZE_INCREMENT; 396 table_count + ACPI_ROOT_TABLE_SIZE_INCREMENT;
391 acpi_gbl_root_table_list.flags |= (u8)ACPI_ROOT_ORIGIN_ALLOCATED; 397 acpi_gbl_root_table_list.flags |= ACPI_ROOT_ORIGIN_ALLOCATED;
392 398
393 return_ACPI_STATUS(AE_OK); 399 return_ACPI_STATUS(AE_OK);
394} 400}
diff --git a/drivers/acpi/acpica/tbxface.c b/drivers/acpi/acpica/tbxface.c
index 29e51bc01383..21101262e47a 100644
--- a/drivers/acpi/acpica/tbxface.c
+++ b/drivers/acpi/acpica/tbxface.c
@@ -159,14 +159,12 @@ acpi_initialize_tables(struct acpi_table_desc * initial_table_array,
159 * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the 159 * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the
160 * root list from the previously provided scratch area. Should 160 * root list from the previously provided scratch area. Should
161 * be called once dynamic memory allocation is available in the 161 * be called once dynamic memory allocation is available in the
162 * kernel 162 * kernel.
163 * 163 *
164 ******************************************************************************/ 164 ******************************************************************************/
165acpi_status acpi_reallocate_root_table(void) 165acpi_status acpi_reallocate_root_table(void)
166{ 166{
167 struct acpi_table_desc *tables; 167 acpi_status status;
168 acpi_size new_size;
169 acpi_size current_size;
170 168
171 ACPI_FUNCTION_TRACE(acpi_reallocate_root_table); 169 ACPI_FUNCTION_TRACE(acpi_reallocate_root_table);
172 170
@@ -178,39 +176,10 @@ acpi_status acpi_reallocate_root_table(void)
178 return_ACPI_STATUS(AE_SUPPORT); 176 return_ACPI_STATUS(AE_SUPPORT);
179 } 177 }
180 178
181 /* 179 acpi_gbl_root_table_list.flags |= ACPI_ROOT_ALLOW_RESIZE;
182 * Get the current size of the root table and add the default
183 * increment to create the new table size.
184 */
185 current_size = (acpi_size)
186 acpi_gbl_root_table_list.current_table_count *
187 sizeof(struct acpi_table_desc);
188
189 new_size = current_size +
190 (ACPI_ROOT_TABLE_SIZE_INCREMENT * sizeof(struct acpi_table_desc));
191
192 /* Create new array and copy the old array */
193
194 tables = ACPI_ALLOCATE_ZEROED(new_size);
195 if (!tables) {
196 return_ACPI_STATUS(AE_NO_MEMORY);
197 }
198 180
199 ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables, current_size); 181 status = acpi_tb_resize_root_table_list();
200 182 return_ACPI_STATUS(status);
201 /*
202 * Update the root table descriptor. The new size will be the current
203 * number of tables plus the increment, independent of the reserved
204 * size of the original table list.
205 */
206 acpi_gbl_root_table_list.tables = tables;
207 acpi_gbl_root_table_list.max_table_count =
208 acpi_gbl_root_table_list.current_table_count +
209 ACPI_ROOT_TABLE_SIZE_INCREMENT;
210 acpi_gbl_root_table_list.flags =
211 ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE;
212
213 return_ACPI_STATUS(AE_OK);
214} 183}
215 184
216/******************************************************************************* 185/*******************************************************************************
diff --git a/drivers/acpi/acpica/utosi.c b/drivers/acpi/acpica/utosi.c
index 34ef0bd7e4b4..676285d6116d 100644
--- a/drivers/acpi/acpica/utosi.c
+++ b/drivers/acpi/acpica/utosi.c
@@ -73,6 +73,7 @@ static struct acpi_interface_info acpi_default_supported_interfaces[] = {
73 {"Windows 2006 SP1", NULL, 0, ACPI_OSI_WIN_VISTA_SP1}, /* Windows Vista SP1 - Added 09/2009 */ 73 {"Windows 2006 SP1", NULL, 0, ACPI_OSI_WIN_VISTA_SP1}, /* Windows Vista SP1 - Added 09/2009 */
74 {"Windows 2006 SP2", NULL, 0, ACPI_OSI_WIN_VISTA_SP2}, /* Windows Vista SP2 - Added 09/2010 */ 74 {"Windows 2006 SP2", NULL, 0, ACPI_OSI_WIN_VISTA_SP2}, /* Windows Vista SP2 - Added 09/2010 */
75 {"Windows 2009", NULL, 0, ACPI_OSI_WIN_7}, /* Windows 7 and Server 2008 R2 - Added 09/2009 */ 75 {"Windows 2009", NULL, 0, ACPI_OSI_WIN_7}, /* Windows 7 and Server 2008 R2 - Added 09/2009 */
76 {"Windows 2012", NULL, 0, ACPI_OSI_WIN_8}, /* Windows 8 and Server 2012 - Added 08/2012 */
76 77
77 /* Feature Group Strings */ 78 /* Feature Group Strings */
78 79
diff --git a/drivers/acpi/acpica/utxface.c b/drivers/acpi/acpica/utxface.c
index 534179f1177b..b09632b4f5b3 100644
--- a/drivers/acpi/acpica/utxface.c
+++ b/drivers/acpi/acpica/utxface.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Module Name: utxface - External interfaces for "global" ACPI functions 3 * Module Name: utxface - External interfaces, miscellaneous utility functions
4 * 4 *
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
@@ -53,271 +53,6 @@
53#define _COMPONENT ACPI_UTILITIES 53#define _COMPONENT ACPI_UTILITIES
54ACPI_MODULE_NAME("utxface") 54ACPI_MODULE_NAME("utxface")
55 55
56#ifndef ACPI_ASL_COMPILER
57/*******************************************************************************
58 *
59 * FUNCTION: acpi_initialize_subsystem
60 *
61 * PARAMETERS: None
62 *
63 * RETURN: Status
64 *
65 * DESCRIPTION: Initializes all global variables. This is the first function
66 * called, so any early initialization belongs here.
67 *
68 ******************************************************************************/
69acpi_status __init acpi_initialize_subsystem(void)
70{
71 acpi_status status;
72
73 ACPI_FUNCTION_TRACE(acpi_initialize_subsystem);
74
75 acpi_gbl_startup_flags = ACPI_SUBSYSTEM_INITIALIZE;
76 ACPI_DEBUG_EXEC(acpi_ut_init_stack_ptr_trace());
77
78 /* Initialize the OS-Dependent layer */
79
80 status = acpi_os_initialize();
81 if (ACPI_FAILURE(status)) {
82 ACPI_EXCEPTION((AE_INFO, status, "During OSL initialization"));
83 return_ACPI_STATUS(status);
84 }
85
86 /* Initialize all globals used by the subsystem */
87
88 status = acpi_ut_init_globals();
89 if (ACPI_FAILURE(status)) {
90 ACPI_EXCEPTION((AE_INFO, status,
91 "During initialization of globals"));
92 return_ACPI_STATUS(status);
93 }
94
95 /* Create the default mutex objects */
96
97 status = acpi_ut_mutex_initialize();
98 if (ACPI_FAILURE(status)) {
99 ACPI_EXCEPTION((AE_INFO, status,
100 "During Global Mutex creation"));
101 return_ACPI_STATUS(status);
102 }
103
104 /*
105 * Initialize the namespace manager and
106 * the root of the namespace tree
107 */
108 status = acpi_ns_root_initialize();
109 if (ACPI_FAILURE(status)) {
110 ACPI_EXCEPTION((AE_INFO, status,
111 "During Namespace initialization"));
112 return_ACPI_STATUS(status);
113 }
114
115 /* Initialize the global OSI interfaces list with the static names */
116
117 status = acpi_ut_initialize_interfaces();
118 if (ACPI_FAILURE(status)) {
119 ACPI_EXCEPTION((AE_INFO, status,
120 "During OSI interfaces initialization"));
121 return_ACPI_STATUS(status);
122 }
123
124 /* If configured, initialize the AML debugger */
125
126 ACPI_DEBUGGER_EXEC(status = acpi_db_initialize());
127 return_ACPI_STATUS(status);
128}
129
130/*******************************************************************************
131 *
132 * FUNCTION: acpi_enable_subsystem
133 *
134 * PARAMETERS: flags - Init/enable Options
135 *
136 * RETURN: Status
137 *
138 * DESCRIPTION: Completes the subsystem initialization including hardware.
139 * Puts system into ACPI mode if it isn't already.
140 *
141 ******************************************************************************/
142acpi_status acpi_enable_subsystem(u32 flags)
143{
144 acpi_status status = AE_OK;
145
146 ACPI_FUNCTION_TRACE(acpi_enable_subsystem);
147
148#if (!ACPI_REDUCED_HARDWARE)
149
150 /* Enable ACPI mode */
151
152 if (!(flags & ACPI_NO_ACPI_ENABLE)) {
153 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
154 "[Init] Going into ACPI mode\n"));
155
156 acpi_gbl_original_mode = acpi_hw_get_mode();
157
158 status = acpi_enable();
159 if (ACPI_FAILURE(status)) {
160 ACPI_WARNING((AE_INFO, "AcpiEnable failed"));
161 return_ACPI_STATUS(status);
162 }
163 }
164
165 /*
166 * Obtain a permanent mapping for the FACS. This is required for the
167 * Global Lock and the Firmware Waking Vector
168 */
169 status = acpi_tb_initialize_facs();
170 if (ACPI_FAILURE(status)) {
171 ACPI_WARNING((AE_INFO, "Could not map the FACS table"));
172 return_ACPI_STATUS(status);
173 }
174#endif /* !ACPI_REDUCED_HARDWARE */
175
176 /*
177 * Install the default op_region handlers. These are installed unless
178 * other handlers have already been installed via the
179 * install_address_space_handler interface.
180 */
181 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
182 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
183 "[Init] Installing default address space handlers\n"));
184
185 status = acpi_ev_install_region_handlers();
186 if (ACPI_FAILURE(status)) {
187 return_ACPI_STATUS(status);
188 }
189 }
190#if (!ACPI_REDUCED_HARDWARE)
191 /*
192 * Initialize ACPI Event handling (Fixed and General Purpose)
193 *
194 * Note1: We must have the hardware and events initialized before we can
195 * execute any control methods safely. Any control method can require
196 * ACPI hardware support, so the hardware must be fully initialized before
197 * any method execution!
198 *
199 * Note2: Fixed events are initialized and enabled here. GPEs are
200 * initialized, but cannot be enabled until after the hardware is
201 * completely initialized (SCI and global_lock activated)
202 */
203 if (!(flags & ACPI_NO_EVENT_INIT)) {
204 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
205 "[Init] Initializing ACPI events\n"));
206
207 status = acpi_ev_initialize_events();
208 if (ACPI_FAILURE(status)) {
209 return_ACPI_STATUS(status);
210 }
211 }
212
213 /*
214 * Install the SCI handler and Global Lock handler. This completes the
215 * hardware initialization.
216 */
217 if (!(flags & ACPI_NO_HANDLER_INIT)) {
218 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
219 "[Init] Installing SCI/GL handlers\n"));
220
221 status = acpi_ev_install_xrupt_handlers();
222 if (ACPI_FAILURE(status)) {
223 return_ACPI_STATUS(status);
224 }
225 }
226#endif /* !ACPI_REDUCED_HARDWARE */
227
228 return_ACPI_STATUS(status);
229}
230
231ACPI_EXPORT_SYMBOL(acpi_enable_subsystem)
232
233/*******************************************************************************
234 *
235 * FUNCTION: acpi_initialize_objects
236 *
237 * PARAMETERS: flags - Init/enable Options
238 *
239 * RETURN: Status
240 *
241 * DESCRIPTION: Completes namespace initialization by initializing device
242 * objects and executing AML code for Regions, buffers, etc.
243 *
244 ******************************************************************************/
245acpi_status acpi_initialize_objects(u32 flags)
246{
247 acpi_status status = AE_OK;
248
249 ACPI_FUNCTION_TRACE(acpi_initialize_objects);
250
251 /*
252 * Run all _REG methods
253 *
254 * Note: Any objects accessed by the _REG methods will be automatically
255 * initialized, even if they contain executable AML (see the call to
256 * acpi_ns_initialize_objects below).
257 */
258 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
259 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
260 "[Init] Executing _REG OpRegion methods\n"));
261
262 status = acpi_ev_initialize_op_regions();
263 if (ACPI_FAILURE(status)) {
264 return_ACPI_STATUS(status);
265 }
266 }
267
268 /*
269 * Execute any module-level code that was detected during the table load
270 * phase. Although illegal since ACPI 2.0, there are many machines that
271 * contain this type of code. Each block of detected executable AML code
272 * outside of any control method is wrapped with a temporary control
273 * method object and placed on a global list. The methods on this list
274 * are executed below.
275 */
276 acpi_ns_exec_module_code_list();
277
278 /*
279 * Initialize the objects that remain uninitialized. This runs the
280 * executable AML that may be part of the declaration of these objects:
281 * operation_regions, buffer_fields, Buffers, and Packages.
282 */
283 if (!(flags & ACPI_NO_OBJECT_INIT)) {
284 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
285 "[Init] Completing Initialization of ACPI Objects\n"));
286
287 status = acpi_ns_initialize_objects();
288 if (ACPI_FAILURE(status)) {
289 return_ACPI_STATUS(status);
290 }
291 }
292
293 /*
294 * Initialize all device objects in the namespace. This runs the device
295 * _STA and _INI methods.
296 */
297 if (!(flags & ACPI_NO_DEVICE_INIT)) {
298 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
299 "[Init] Initializing ACPI Devices\n"));
300
301 status = acpi_ns_initialize_devices();
302 if (ACPI_FAILURE(status)) {
303 return_ACPI_STATUS(status);
304 }
305 }
306
307 /*
308 * Empty the caches (delete the cached objects) on the assumption that
309 * the table load filled them up more than they will be at runtime --
310 * thus wasting non-paged memory.
311 */
312 status = acpi_purge_cached_objects();
313
314 acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK;
315 return_ACPI_STATUS(status);
316}
317
318ACPI_EXPORT_SYMBOL(acpi_initialize_objects)
319
320#endif
321/******************************************************************************* 56/*******************************************************************************
322 * 57 *
323 * FUNCTION: acpi_terminate 58 * FUNCTION: acpi_terminate
@@ -683,3 +418,90 @@ acpi_check_address_range(acpi_adr_space_type space_id,
683 418
684ACPI_EXPORT_SYMBOL(acpi_check_address_range) 419ACPI_EXPORT_SYMBOL(acpi_check_address_range)
685#endif /* !ACPI_ASL_COMPILER */ 420#endif /* !ACPI_ASL_COMPILER */
421/*******************************************************************************
422 *
423 * FUNCTION: acpi_decode_pld_buffer
424 *
425 * PARAMETERS: in_buffer - Buffer returned by _PLD method
426 * length - Length of the in_buffer
427 * return_buffer - Where the decode buffer is returned
428 *
429 * RETURN: Status and the decoded _PLD buffer. User must deallocate
430 * the buffer via ACPI_FREE.
431 *
432 * DESCRIPTION: Decode the bit-packed buffer returned by the _PLD method into
433 * a local struct that is much more useful to an ACPI driver.
434 *
435 ******************************************************************************/
436acpi_status
437acpi_decode_pld_buffer(u8 *in_buffer,
438 acpi_size length, struct acpi_pld_info ** return_buffer)
439{
440 struct acpi_pld_info *pld_info;
441 u32 *buffer = ACPI_CAST_PTR(u32, in_buffer);
442 u32 dword;
443
444 /* Parameter validation */
445
446 if (!in_buffer || !return_buffer || (length < 16)) {
447 return (AE_BAD_PARAMETER);
448 }
449
450 pld_info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pld_info));
451 if (!pld_info) {
452 return (AE_NO_MEMORY);
453 }
454
455 /* First 32-bit DWord */
456
457 ACPI_MOVE_32_TO_32(&dword, &buffer[0]);
458 pld_info->revision = ACPI_PLD_GET_REVISION(&dword);
459 pld_info->ignore_color = ACPI_PLD_GET_IGNORE_COLOR(&dword);
460 pld_info->color = ACPI_PLD_GET_COLOR(&dword);
461
462 /* Second 32-bit DWord */
463
464 ACPI_MOVE_32_TO_32(&dword, &buffer[1]);
465 pld_info->width = ACPI_PLD_GET_WIDTH(&dword);
466 pld_info->height = ACPI_PLD_GET_HEIGHT(&dword);
467
468 /* Third 32-bit DWord */
469
470 ACPI_MOVE_32_TO_32(&dword, &buffer[2]);
471 pld_info->user_visible = ACPI_PLD_GET_USER_VISIBLE(&dword);
472 pld_info->dock = ACPI_PLD_GET_DOCK(&dword);
473 pld_info->lid = ACPI_PLD_GET_LID(&dword);
474 pld_info->panel = ACPI_PLD_GET_PANEL(&dword);
475 pld_info->vertical_position = ACPI_PLD_GET_VERTICAL(&dword);
476 pld_info->horizontal_position = ACPI_PLD_GET_HORIZONTAL(&dword);
477 pld_info->shape = ACPI_PLD_GET_SHAPE(&dword);
478 pld_info->group_orientation = ACPI_PLD_GET_ORIENTATION(&dword);
479 pld_info->group_token = ACPI_PLD_GET_TOKEN(&dword);
480 pld_info->group_position = ACPI_PLD_GET_POSITION(&dword);
481 pld_info->bay = ACPI_PLD_GET_BAY(&dword);
482
483 /* Fourth 32-bit DWord */
484
485 ACPI_MOVE_32_TO_32(&dword, &buffer[3]);
486 pld_info->ejectable = ACPI_PLD_GET_EJECTABLE(&dword);
487 pld_info->ospm_eject_required = ACPI_PLD_GET_OSPM_EJECT(&dword);
488 pld_info->cabinet_number = ACPI_PLD_GET_CABINET(&dword);
489 pld_info->card_cage_number = ACPI_PLD_GET_CARD_CAGE(&dword);
490 pld_info->reference = ACPI_PLD_GET_REFERENCE(&dword);
491 pld_info->rotation = ACPI_PLD_GET_ROTATION(&dword);
492 pld_info->order = ACPI_PLD_GET_ORDER(&dword);
493
494 if (length >= ACPI_PLD_BUFFER_SIZE) {
495
496 /* Fifth 32-bit DWord (Revision 2 of _PLD) */
497
498 ACPI_MOVE_32_TO_32(&dword, &buffer[4]);
499 pld_info->vertical_offset = ACPI_PLD_GET_VERT_OFFSET(&dword);
500 pld_info->horizontal_offset = ACPI_PLD_GET_HORIZ_OFFSET(&dword);
501 }
502
503 *return_buffer = pld_info;
504 return (AE_OK);
505}
506
507ACPI_EXPORT_SYMBOL(acpi_decode_pld_buffer)
diff --git a/drivers/acpi/acpica/utxfinit.c b/drivers/acpi/acpica/utxfinit.c
new file mode 100644
index 000000000000..14f523627a5e
--- /dev/null
+++ b/drivers/acpi/acpica/utxfinit.c
@@ -0,0 +1,317 @@
1/******************************************************************************
2 *
3 * Module Name: utxfinit - External interfaces for ACPICA initialization
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2012, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <linux/export.h>
45#include <acpi/acpi.h>
46#include "accommon.h"
47#include "acevents.h"
48#include "acnamesp.h"
49#include "acdebug.h"
50#include "actables.h"
51
52#define _COMPONENT ACPI_UTILITIES
53ACPI_MODULE_NAME("utxfinit")
54
55/*******************************************************************************
56 *
57 * FUNCTION: acpi_initialize_subsystem
58 *
59 * PARAMETERS: None
60 *
61 * RETURN: Status
62 *
63 * DESCRIPTION: Initializes all global variables. This is the first function
64 * called, so any early initialization belongs here.
65 *
66 ******************************************************************************/
67acpi_status acpi_initialize_subsystem(void)
68{
69 acpi_status status;
70
71 ACPI_FUNCTION_TRACE(acpi_initialize_subsystem);
72
73 acpi_gbl_startup_flags = ACPI_SUBSYSTEM_INITIALIZE;
74 ACPI_DEBUG_EXEC(acpi_ut_init_stack_ptr_trace());
75
76 /* Initialize the OS-Dependent layer */
77
78 status = acpi_os_initialize();
79 if (ACPI_FAILURE(status)) {
80 ACPI_EXCEPTION((AE_INFO, status, "During OSL initialization"));
81 return_ACPI_STATUS(status);
82 }
83
84 /* Initialize all globals used by the subsystem */
85
86 status = acpi_ut_init_globals();
87 if (ACPI_FAILURE(status)) {
88 ACPI_EXCEPTION((AE_INFO, status,
89 "During initialization of globals"));
90 return_ACPI_STATUS(status);
91 }
92
93 /* Create the default mutex objects */
94
95 status = acpi_ut_mutex_initialize();
96 if (ACPI_FAILURE(status)) {
97 ACPI_EXCEPTION((AE_INFO, status,
98 "During Global Mutex creation"));
99 return_ACPI_STATUS(status);
100 }
101
102 /*
103 * Initialize the namespace manager and
104 * the root of the namespace tree
105 */
106 status = acpi_ns_root_initialize();
107 if (ACPI_FAILURE(status)) {
108 ACPI_EXCEPTION((AE_INFO, status,
109 "During Namespace initialization"));
110 return_ACPI_STATUS(status);
111 }
112
113 /* Initialize the global OSI interfaces list with the static names */
114
115 status = acpi_ut_initialize_interfaces();
116 if (ACPI_FAILURE(status)) {
117 ACPI_EXCEPTION((AE_INFO, status,
118 "During OSI interfaces initialization"));
119 return_ACPI_STATUS(status);
120 }
121
122 /* If configured, initialize the AML debugger */
123
124 ACPI_DEBUGGER_EXEC(status = acpi_db_initialize());
125 return_ACPI_STATUS(status);
126}
127ACPI_EXPORT_SYMBOL(acpi_initialize_subsystem)
128
129/*******************************************************************************
130 *
131 * FUNCTION: acpi_enable_subsystem
132 *
133 * PARAMETERS: flags - Init/enable Options
134 *
135 * RETURN: Status
136 *
137 * DESCRIPTION: Completes the subsystem initialization including hardware.
138 * Puts system into ACPI mode if it isn't already.
139 *
140 ******************************************************************************/
141acpi_status acpi_enable_subsystem(u32 flags)
142{
143 acpi_status status = AE_OK;
144
145 ACPI_FUNCTION_TRACE(acpi_enable_subsystem);
146
147#if (!ACPI_REDUCED_HARDWARE)
148
149 /* Enable ACPI mode */
150
151 if (!(flags & ACPI_NO_ACPI_ENABLE)) {
152 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
153 "[Init] Going into ACPI mode\n"));
154
155 acpi_gbl_original_mode = acpi_hw_get_mode();
156
157 status = acpi_enable();
158 if (ACPI_FAILURE(status)) {
159 ACPI_WARNING((AE_INFO, "AcpiEnable failed"));
160 return_ACPI_STATUS(status);
161 }
162 }
163
164 /*
165 * Obtain a permanent mapping for the FACS. This is required for the
166 * Global Lock and the Firmware Waking Vector
167 */
168 status = acpi_tb_initialize_facs();
169 if (ACPI_FAILURE(status)) {
170 ACPI_WARNING((AE_INFO, "Could not map the FACS table"));
171 return_ACPI_STATUS(status);
172 }
173#endif /* !ACPI_REDUCED_HARDWARE */
174
175 /*
176 * Install the default op_region handlers. These are installed unless
177 * other handlers have already been installed via the
178 * install_address_space_handler interface.
179 */
180 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
181 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
182 "[Init] Installing default address space handlers\n"));
183
184 status = acpi_ev_install_region_handlers();
185 if (ACPI_FAILURE(status)) {
186 return_ACPI_STATUS(status);
187 }
188 }
189#if (!ACPI_REDUCED_HARDWARE)
190 /*
191 * Initialize ACPI Event handling (Fixed and General Purpose)
192 *
193 * Note1: We must have the hardware and events initialized before we can
194 * execute any control methods safely. Any control method can require
195 * ACPI hardware support, so the hardware must be fully initialized before
196 * any method execution!
197 *
198 * Note2: Fixed events are initialized and enabled here. GPEs are
199 * initialized, but cannot be enabled until after the hardware is
200 * completely initialized (SCI and global_lock activated) and the various
201 * initialization control methods are run (_REG, _STA, _INI) on the
202 * entire namespace.
203 */
204 if (!(flags & ACPI_NO_EVENT_INIT)) {
205 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
206 "[Init] Initializing ACPI events\n"));
207
208 status = acpi_ev_initialize_events();
209 if (ACPI_FAILURE(status)) {
210 return_ACPI_STATUS(status);
211 }
212 }
213
214 /*
215 * Install the SCI handler and Global Lock handler. This completes the
216 * hardware initialization.
217 */
218 if (!(flags & ACPI_NO_HANDLER_INIT)) {
219 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
220 "[Init] Installing SCI/GL handlers\n"));
221
222 status = acpi_ev_install_xrupt_handlers();
223 if (ACPI_FAILURE(status)) {
224 return_ACPI_STATUS(status);
225 }
226 }
227#endif /* !ACPI_REDUCED_HARDWARE */
228
229 return_ACPI_STATUS(status);
230}
231ACPI_EXPORT_SYMBOL(acpi_enable_subsystem)
232
233/*******************************************************************************
234 *
235 * FUNCTION: acpi_initialize_objects
236 *
237 * PARAMETERS: flags - Init/enable Options
238 *
239 * RETURN: Status
240 *
241 * DESCRIPTION: Completes namespace initialization by initializing device
242 * objects and executing AML code for Regions, buffers, etc.
243 *
244 ******************************************************************************/
245acpi_status acpi_initialize_objects(u32 flags)
246{
247 acpi_status status = AE_OK;
248
249 ACPI_FUNCTION_TRACE(acpi_initialize_objects);
250
251 /*
252 * Run all _REG methods
253 *
254 * Note: Any objects accessed by the _REG methods will be automatically
255 * initialized, even if they contain executable AML (see the call to
256 * acpi_ns_initialize_objects below).
257 */
258 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
259 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
260 "[Init] Executing _REG OpRegion methods\n"));
261
262 status = acpi_ev_initialize_op_regions();
263 if (ACPI_FAILURE(status)) {
264 return_ACPI_STATUS(status);
265 }
266 }
267
268 /*
269 * Execute any module-level code that was detected during the table load
270 * phase. Although illegal since ACPI 2.0, there are many machines that
271 * contain this type of code. Each block of detected executable AML code
272 * outside of any control method is wrapped with a temporary control
273 * method object and placed on a global list. The methods on this list
274 * are executed below.
275 */
276 acpi_ns_exec_module_code_list();
277
278 /*
279 * Initialize the objects that remain uninitialized. This runs the
280 * executable AML that may be part of the declaration of these objects:
281 * operation_regions, buffer_fields, Buffers, and Packages.
282 */
283 if (!(flags & ACPI_NO_OBJECT_INIT)) {
284 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
285 "[Init] Completing Initialization of ACPI Objects\n"));
286
287 status = acpi_ns_initialize_objects();
288 if (ACPI_FAILURE(status)) {
289 return_ACPI_STATUS(status);
290 }
291 }
292
293 /*
294 * Initialize all device objects in the namespace. This runs the device
295 * _STA and _INI methods.
296 */
297 if (!(flags & ACPI_NO_DEVICE_INIT)) {
298 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
299 "[Init] Initializing ACPI Devices\n"));
300
301 status = acpi_ns_initialize_devices();
302 if (ACPI_FAILURE(status)) {
303 return_ACPI_STATUS(status);
304 }
305 }
306
307 /*
308 * Empty the caches (delete the cached objects) on the assumption that
309 * the table load filled them up more than they will be at runtime --
310 * thus wasting non-paged memory.
311 */
312 status = acpi_purge_cached_objects();
313
314 acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK;
315 return_ACPI_STATUS(status);
316}
317ACPI_EXPORT_SYMBOL(acpi_initialize_objects)
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index e0596954290b..d59175efc428 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -994,8 +994,6 @@ static int __init acpi_bus_init(void)
994 status = acpi_ec_ecdt_probe(); 994 status = acpi_ec_ecdt_probe();
995 /* Ignore result. Not having an ECDT is not fatal. */ 995 /* Ignore result. Not having an ECDT is not fatal. */
996 996
997 acpi_bus_osc_support();
998
999 status = acpi_initialize_objects(ACPI_FULL_INITIALIZATION); 997 status = acpi_initialize_objects(ACPI_FULL_INITIALIZATION);
1000 if (ACPI_FAILURE(status)) { 998 if (ACPI_FAILURE(status)) {
1001 printk(KERN_ERR PREFIX "Unable to initialize ACPI objects\n"); 999 printk(KERN_ERR PREFIX "Unable to initialize ACPI objects\n");
@@ -1003,6 +1001,12 @@ static int __init acpi_bus_init(void)
1003 } 1001 }
1004 1002
1005 /* 1003 /*
1004 * _OSC method may exist in module level code,
1005 * so it must be run after ACPI_FULL_INITIALIZATION
1006 */
1007 acpi_bus_osc_support();
1008
1009 /*
1006 * _PDC control method may load dynamic SSDT tables, 1010 * _PDC control method may load dynamic SSDT tables,
1007 * and we need to install the table handler before that. 1011 * and we need to install the table handler before that.
1008 */ 1012 */
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 243ee85e4d2e..d1a2d74033e9 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -25,6 +25,8 @@
25static LIST_HEAD(bus_type_list); 25static LIST_HEAD(bus_type_list);
26static DECLARE_RWSEM(bus_type_sem); 26static DECLARE_RWSEM(bus_type_sem);
27 27
28#define PHYSICAL_NODE_STRING "physical_node"
29
28int register_acpi_bus_type(struct acpi_bus_type *type) 30int register_acpi_bus_type(struct acpi_bus_type *type)
29{ 31{
30 if (acpi_disabled) 32 if (acpi_disabled)
@@ -124,84 +126,119 @@ acpi_handle acpi_get_child(acpi_handle parent, u64 address)
124 126
125EXPORT_SYMBOL(acpi_get_child); 127EXPORT_SYMBOL(acpi_get_child);
126 128
127/* Link ACPI devices with physical devices */
128static void acpi_glue_data_handler(acpi_handle handle,
129 void *context)
130{
131 /* we provide an empty handler */
132}
133
134/* Note: a success call will increase reference count by one */
135struct device *acpi_get_physical_device(acpi_handle handle)
136{
137 acpi_status status;
138 struct device *dev;
139
140 status = acpi_get_data(handle, acpi_glue_data_handler, (void **)&dev);
141 if (ACPI_SUCCESS(status))
142 return get_device(dev);
143 return NULL;
144}
145
146EXPORT_SYMBOL(acpi_get_physical_device);
147
148static int acpi_bind_one(struct device *dev, acpi_handle handle) 129static int acpi_bind_one(struct device *dev, acpi_handle handle)
149{ 130{
150 struct acpi_device *acpi_dev; 131 struct acpi_device *acpi_dev;
151 acpi_status status; 132 acpi_status status;
133 struct acpi_device_physical_node *physical_node;
134 char physical_node_name[sizeof(PHYSICAL_NODE_STRING) + 2];
135 int retval = -EINVAL;
152 136
153 if (dev->archdata.acpi_handle) { 137 if (dev->archdata.acpi_handle) {
154 dev_warn(dev, "Drivers changed 'acpi_handle'\n"); 138 dev_warn(dev, "Drivers changed 'acpi_handle'\n");
155 return -EINVAL; 139 return -EINVAL;
156 } 140 }
141
157 get_device(dev); 142 get_device(dev);
158 status = acpi_attach_data(handle, acpi_glue_data_handler, dev); 143 status = acpi_bus_get_device(handle, &acpi_dev);
159 if (ACPI_FAILURE(status)) { 144 if (ACPI_FAILURE(status))
160 put_device(dev); 145 goto err;
161 return -EINVAL; 146
147 physical_node = kzalloc(sizeof(struct acpi_device_physical_node),
148 GFP_KERNEL);
149 if (!physical_node) {
150 retval = -ENOMEM;
151 goto err;
162 } 152 }
163 dev->archdata.acpi_handle = handle;
164 153
165 status = acpi_bus_get_device(handle, &acpi_dev); 154 mutex_lock(&acpi_dev->physical_node_lock);
166 if (!ACPI_FAILURE(status)) { 155 /* allocate physical node id according to physical_node_id_bitmap */
167 int ret; 156 physical_node->node_id =
168 157 find_first_zero_bit(acpi_dev->physical_node_id_bitmap,
169 ret = sysfs_create_link(&dev->kobj, &acpi_dev->dev.kobj, 158 ACPI_MAX_PHYSICAL_NODE);
170 "firmware_node"); 159 if (physical_node->node_id >= ACPI_MAX_PHYSICAL_NODE) {
171 ret = sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj, 160 retval = -ENOSPC;
172 "physical_node"); 161 mutex_unlock(&acpi_dev->physical_node_lock);
173 if (acpi_dev->wakeup.flags.valid) 162 goto err;
174 device_set_wakeup_capable(dev, true);
175 } 163 }
176 164
165 set_bit(physical_node->node_id, acpi_dev->physical_node_id_bitmap);
166 physical_node->dev = dev;
167 list_add_tail(&physical_node->node, &acpi_dev->physical_node_list);
168 acpi_dev->physical_node_count++;
169 mutex_unlock(&acpi_dev->physical_node_lock);
170
171 dev->archdata.acpi_handle = handle;
172
173 if (!physical_node->node_id)
174 strcpy(physical_node_name, PHYSICAL_NODE_STRING);
175 else
176 sprintf(physical_node_name,
177 "physical_node%d", physical_node->node_id);
178 retval = sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj,
179 physical_node_name);
180 retval = sysfs_create_link(&dev->kobj, &acpi_dev->dev.kobj,
181 "firmware_node");
182
183 if (acpi_dev->wakeup.flags.valid)
184 device_set_wakeup_capable(dev, true);
185
177 return 0; 186 return 0;
187
188 err:
189 put_device(dev);
190 return retval;
178} 191}
179 192
180static int acpi_unbind_one(struct device *dev) 193static int acpi_unbind_one(struct device *dev)
181{ 194{
195 struct acpi_device_physical_node *entry;
196 struct acpi_device *acpi_dev;
197 acpi_status status;
198 struct list_head *node, *next;
199
182 if (!dev->archdata.acpi_handle) 200 if (!dev->archdata.acpi_handle)
183 return 0; 201 return 0;
184 if (dev == acpi_get_physical_device(dev->archdata.acpi_handle)) {
185 struct acpi_device *acpi_dev;
186 202
187 /* acpi_get_physical_device increase refcnt by one */ 203 status = acpi_bus_get_device(dev->archdata.acpi_handle,
188 put_device(dev); 204 &acpi_dev);
205 if (ACPI_FAILURE(status))
206 goto err;
189 207
190 if (!acpi_bus_get_device(dev->archdata.acpi_handle, 208 mutex_lock(&acpi_dev->physical_node_lock);
191 &acpi_dev)) { 209 list_for_each_safe(node, next, &acpi_dev->physical_node_list) {
192 sysfs_remove_link(&dev->kobj, "firmware_node"); 210 char physical_node_name[sizeof(PHYSICAL_NODE_STRING) + 2];
193 sysfs_remove_link(&acpi_dev->dev.kobj, "physical_node"); 211
194 } 212 entry = list_entry(node, struct acpi_device_physical_node,
213 node);
214 if (entry->dev != dev)
215 continue;
216
217 list_del(node);
218 clear_bit(entry->node_id, acpi_dev->physical_node_id_bitmap);
195 219
196 acpi_detach_data(dev->archdata.acpi_handle, 220 acpi_dev->physical_node_count--;
197 acpi_glue_data_handler); 221
222 if (!entry->node_id)
223 strcpy(physical_node_name, PHYSICAL_NODE_STRING);
224 else
225 sprintf(physical_node_name,
226 "physical_node%d", entry->node_id);
227
228 sysfs_remove_link(&acpi_dev->dev.kobj, physical_node_name);
229 sysfs_remove_link(&dev->kobj, "firmware_node");
198 dev->archdata.acpi_handle = NULL; 230 dev->archdata.acpi_handle = NULL;
199 /* acpi_bind_one increase refcnt by one */ 231 /* acpi_bind_one increase refcnt by one */
200 put_device(dev); 232 put_device(dev);
201 } else { 233 kfree(entry);
202 dev_err(dev, "Oops, 'acpi_handle' corrupt\n");
203 } 234 }
235 mutex_unlock(&acpi_dev->physical_node_lock);
236
204 return 0; 237 return 0;
238
239err:
240 dev_err(dev, "Oops, 'acpi_handle' corrupt\n");
241 return -EINVAL;
205} 242}
206 243
207static int acpi_platform_notify(struct device *dev) 244static int acpi_platform_notify(struct device *dev)
diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c
index 251c7b6273a9..27adb090bb30 100644
--- a/drivers/acpi/proc.c
+++ b/drivers/acpi/proc.c
@@ -302,26 +302,41 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
302 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 302 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
303 struct acpi_device *dev = 303 struct acpi_device *dev =
304 container_of(node, struct acpi_device, wakeup_list); 304 container_of(node, struct acpi_device, wakeup_list);
305 struct device *ldev; 305 struct acpi_device_physical_node *entry;
306 306
307 if (!dev->wakeup.flags.valid) 307 if (!dev->wakeup.flags.valid)
308 continue; 308 continue;
309 309
310 ldev = acpi_get_physical_device(dev->handle); 310 seq_printf(seq, "%s\t S%d\t",
311 seq_printf(seq, "%s\t S%d\t%c%-8s ",
312 dev->pnp.bus_id, 311 dev->pnp.bus_id,
313 (u32) dev->wakeup.sleep_state, 312 (u32) dev->wakeup.sleep_state);
314 dev->wakeup.flags.run_wake ? '*' : ' ', 313
315 (device_may_wakeup(&dev->dev) 314 if (!dev->physical_node_count)
316 || (ldev && device_may_wakeup(ldev))) ? 315 seq_printf(seq, "%c%-8s\n",
317 "enabled" : "disabled"); 316 dev->wakeup.flags.run_wake ?
318 if (ldev) 317 '*' : ' ', "disabled");
319 seq_printf(seq, "%s:%s", 318 else {
320 ldev->bus ? ldev->bus->name : "no-bus", 319 struct device *ldev;
321 dev_name(ldev)); 320 list_for_each_entry(entry, &dev->physical_node_list,
322 seq_printf(seq, "\n"); 321 node) {
323 put_device(ldev); 322 ldev = get_device(entry->dev);
324 323 if (!ldev)
324 continue;
325
326 if (&entry->node !=
327 dev->physical_node_list.next)
328 seq_printf(seq, "\t\t");
329
330 seq_printf(seq, "%c%-8s %s:%s\n",
331 dev->wakeup.flags.run_wake ? '*' : ' ',
332 (device_may_wakeup(&dev->dev) ||
333 (ldev && device_may_wakeup(ldev))) ?
334 "enabled" : "disabled",
335 ldev->bus ? ldev->bus->name :
336 "no-bus", dev_name(ldev));
337 put_device(ldev);
338 }
339 }
325 } 340 }
326 mutex_unlock(&acpi_device_lock); 341 mutex_unlock(&acpi_device_lock);
327 return 0; 342 return 0;
@@ -329,12 +344,14 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
329 344
330static void physical_device_enable_wakeup(struct acpi_device *adev) 345static void physical_device_enable_wakeup(struct acpi_device *adev)
331{ 346{
332 struct device *dev = acpi_get_physical_device(adev->handle); 347 struct acpi_device_physical_node *entry;
333 348
334 if (dev && device_can_wakeup(dev)) { 349 list_for_each_entry(entry,
335 bool enable = !device_may_wakeup(dev); 350 &adev->physical_node_list, node)
336 device_set_wakeup_enable(dev, enable); 351 if (entry->dev && device_can_wakeup(entry->dev)) {
337 } 352 bool enable = !device_may_wakeup(entry->dev);
353 device_set_wakeup_enable(entry->dev, enable);
354 }
338} 355}
339 356
340static ssize_t 357static ssize_t
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index d1ecca2b641a..1fcb8678665c 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -10,6 +10,7 @@
10#include <linux/signal.h> 10#include <linux/signal.h>
11#include <linux/kthread.h> 11#include <linux/kthread.h>
12#include <linux/dmi.h> 12#include <linux/dmi.h>
13#include <linux/nls.h>
13 14
14#include <acpi/acpi_drivers.h> 15#include <acpi/acpi_drivers.h>
15 16
@@ -232,8 +233,35 @@ end:
232} 233}
233static DEVICE_ATTR(path, 0444, acpi_device_path_show, NULL); 234static DEVICE_ATTR(path, 0444, acpi_device_path_show, NULL);
234 235
236/* sysfs file that shows description text from the ACPI _STR method */
237static ssize_t description_show(struct device *dev,
238 struct device_attribute *attr,
239 char *buf) {
240 struct acpi_device *acpi_dev = to_acpi_device(dev);
241 int result;
242
243 if (acpi_dev->pnp.str_obj == NULL)
244 return 0;
245
246 /*
247 * The _STR object contains a Unicode identifier for a device.
248 * We need to convert to utf-8 so it can be displayed.
249 */
250 result = utf16s_to_utf8s(
251 (wchar_t *)acpi_dev->pnp.str_obj->buffer.pointer,
252 acpi_dev->pnp.str_obj->buffer.length,
253 UTF16_LITTLE_ENDIAN, buf,
254 PAGE_SIZE);
255
256 buf[result++] = '\n';
257
258 return result;
259}
260static DEVICE_ATTR(description, 0444, description_show, NULL);
261
235static int acpi_device_setup_files(struct acpi_device *dev) 262static int acpi_device_setup_files(struct acpi_device *dev)
236{ 263{
264 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
237 acpi_status status; 265 acpi_status status;
238 acpi_handle temp; 266 acpi_handle temp;
239 int result = 0; 267 int result = 0;
@@ -257,6 +285,21 @@ static int acpi_device_setup_files(struct acpi_device *dev)
257 goto end; 285 goto end;
258 } 286 }
259 287
288 /*
289 * If device has _STR, 'description' file is created
290 */
291 status = acpi_get_handle(dev->handle, "_STR", &temp);
292 if (ACPI_SUCCESS(status)) {
293 status = acpi_evaluate_object(dev->handle, "_STR",
294 NULL, &buffer);
295 if (ACPI_FAILURE(status))
296 buffer.pointer = NULL;
297 dev->pnp.str_obj = buffer.pointer;
298 result = device_create_file(&dev->dev, &dev_attr_description);
299 if (result)
300 goto end;
301 }
302
260 /* 303 /*
261 * If device has _EJ0, 'eject' file is created that is used to trigger 304 * If device has _EJ0, 'eject' file is created that is used to trigger
262 * hot-removal function from userland. 305 * hot-removal function from userland.
@@ -274,8 +317,15 @@ static void acpi_device_remove_files(struct acpi_device *dev)
274 acpi_handle temp; 317 acpi_handle temp;
275 318
276 /* 319 /*
277 * If device has _EJ0, 'eject' file is created that is used to trigger 320 * If device has _STR, remove 'description' file
278 * hot-removal function from userland. 321 */
322 status = acpi_get_handle(dev->handle, "_STR", &temp);
323 if (ACPI_SUCCESS(status)) {
324 kfree(dev->pnp.str_obj);
325 device_remove_file(&dev->dev, &dev_attr_description);
326 }
327 /*
328 * If device has _EJ0, remove 'eject' file.
279 */ 329 */
280 status = acpi_get_handle(dev->handle, "_EJ0", &temp); 330 status = acpi_get_handle(dev->handle, "_EJ0", &temp);
281 if (ACPI_SUCCESS(status)) 331 if (ACPI_SUCCESS(status))
@@ -481,6 +531,8 @@ static int acpi_device_register(struct acpi_device *device)
481 INIT_LIST_HEAD(&device->children); 531 INIT_LIST_HEAD(&device->children);
482 INIT_LIST_HEAD(&device->node); 532 INIT_LIST_HEAD(&device->node);
483 INIT_LIST_HEAD(&device->wakeup_list); 533 INIT_LIST_HEAD(&device->wakeup_list);
534 INIT_LIST_HEAD(&device->physical_node_list);
535 mutex_init(&device->physical_node_lock);
484 536
485 new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL); 537 new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL);
486 if (!new_bus_id) { 538 if (!new_bus_id) {
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index f336bca7c450..2572d9715bda 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -240,10 +240,17 @@ acpi_table_parse_entries(char *id,
240 table_end) { 240 table_end) {
241 if (entry->type == entry_id 241 if (entry->type == entry_id
242 && (!max_entries || count++ < max_entries)) 242 && (!max_entries || count++ < max_entries))
243 if (handler(entry, table_end)) { 243 if (handler(entry, table_end))
244 early_acpi_os_unmap_memory((char *)table_header, tbl_size); 244 goto err;
245 return -EINVAL; 245
246 } 246 /*
247 * If entry->length is 0, break from this loop to avoid
248 * infinite loop.
249 */
250 if (entry->length == 0) {
251 pr_err(PREFIX "[%4.4s:0x%02x] Invalid zero length\n", id, entry_id);
252 goto err;
253 }
247 254
248 entry = (struct acpi_subtable_header *) 255 entry = (struct acpi_subtable_header *)
249 ((unsigned long)entry + entry->length); 256 ((unsigned long)entry + entry->length);
@@ -255,6 +262,9 @@ acpi_table_parse_entries(char *id,
255 262
256 early_acpi_os_unmap_memory((char *)table_header, tbl_size); 263 early_acpi_os_unmap_memory((char *)table_header, tbl_size);
257 return count; 264 return count;
265err:
266 early_acpi_os_unmap_memory((char *)table_header, tbl_size);
267 return -EINVAL;
258} 268}
259 269
260int __init 270int __init
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 3e87c9c538aa..462f7e300363 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -384,7 +384,7 @@ acpi_evaluate_reference(acpi_handle handle,
384EXPORT_SYMBOL(acpi_evaluate_reference); 384EXPORT_SYMBOL(acpi_evaluate_reference);
385 385
386acpi_status 386acpi_status
387acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld *pld) 387acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld)
388{ 388{
389 acpi_status status; 389 acpi_status status;
390 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 390 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
@@ -400,13 +400,16 @@ acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld *pld)
400 if (!output || output->type != ACPI_TYPE_PACKAGE 400 if (!output || output->type != ACPI_TYPE_PACKAGE
401 || !output->package.count 401 || !output->package.count
402 || output->package.elements[0].type != ACPI_TYPE_BUFFER 402 || output->package.elements[0].type != ACPI_TYPE_BUFFER
403 || output->package.elements[0].buffer.length > sizeof(*pld)) { 403 || output->package.elements[0].buffer.length < ACPI_PLD_REV1_BUFFER_SIZE) {
404 status = AE_TYPE; 404 status = AE_TYPE;
405 goto out; 405 goto out;
406 } 406 }
407 407
408 memcpy(pld, output->package.elements[0].buffer.pointer, 408 status = acpi_decode_pld_buffer(
409 output->package.elements[0].buffer.length); 409 output->package.elements[0].buffer.pointer,
410 output->package.elements[0].buffer.length,
411 pld);
412
410out: 413out:
411 kfree(buffer.pointer); 414 kfree(buffer.pointer);
412 return status; 415 return status;
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index de0435e63b02..887f68f6d79a 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -35,6 +35,7 @@ new_skb(ulong len)
35 skb_reset_mac_header(skb); 35 skb_reset_mac_header(skb);
36 skb_reset_network_header(skb); 36 skb_reset_network_header(skb);
37 skb->protocol = __constant_htons(ETH_P_AOE); 37 skb->protocol = __constant_htons(ETH_P_AOE);
38 skb_checksum_none_assert(skb);
38 } 39 }
39 return skb; 40 return skb;
40} 41}
diff --git a/drivers/block/nvme.c b/drivers/block/nvme.c
index 38a2d0631882..ad16c68c8645 100644
--- a/drivers/block/nvme.c
+++ b/drivers/block/nvme.c
@@ -79,6 +79,7 @@ struct nvme_dev {
79 char serial[20]; 79 char serial[20];
80 char model[40]; 80 char model[40];
81 char firmware_rev[8]; 81 char firmware_rev[8];
82 u32 max_hw_sectors;
82}; 83};
83 84
84/* 85/*
@@ -835,15 +836,15 @@ static int nvme_identify(struct nvme_dev *dev, unsigned nsid, unsigned cns,
835} 836}
836 837
837static int nvme_get_features(struct nvme_dev *dev, unsigned fid, 838static int nvme_get_features(struct nvme_dev *dev, unsigned fid,
838 unsigned dword11, dma_addr_t dma_addr) 839 unsigned nsid, dma_addr_t dma_addr)
839{ 840{
840 struct nvme_command c; 841 struct nvme_command c;
841 842
842 memset(&c, 0, sizeof(c)); 843 memset(&c, 0, sizeof(c));
843 c.features.opcode = nvme_admin_get_features; 844 c.features.opcode = nvme_admin_get_features;
845 c.features.nsid = cpu_to_le32(nsid);
844 c.features.prp1 = cpu_to_le64(dma_addr); 846 c.features.prp1 = cpu_to_le64(dma_addr);
845 c.features.fid = cpu_to_le32(fid); 847 c.features.fid = cpu_to_le32(fid);
846 c.features.dword11 = cpu_to_le32(dword11);
847 848
848 return nvme_submit_admin_cmd(dev, &c, NULL); 849 return nvme_submit_admin_cmd(dev, &c, NULL);
849} 850}
@@ -862,11 +863,51 @@ static int nvme_set_features(struct nvme_dev *dev, unsigned fid,
862 return nvme_submit_admin_cmd(dev, &c, result); 863 return nvme_submit_admin_cmd(dev, &c, result);
863} 864}
864 865
866/**
867 * nvme_cancel_ios - Cancel outstanding I/Os
868 * @queue: The queue to cancel I/Os on
869 * @timeout: True to only cancel I/Os which have timed out
870 */
871static void nvme_cancel_ios(struct nvme_queue *nvmeq, bool timeout)
872{
873 int depth = nvmeq->q_depth - 1;
874 struct nvme_cmd_info *info = nvme_cmd_info(nvmeq);
875 unsigned long now = jiffies;
876 int cmdid;
877
878 for_each_set_bit(cmdid, nvmeq->cmdid_data, depth) {
879 void *ctx;
880 nvme_completion_fn fn;
881 static struct nvme_completion cqe = {
882 .status = cpu_to_le16(NVME_SC_ABORT_REQ) << 1,
883 };
884
885 if (timeout && !time_after(now, info[cmdid].timeout))
886 continue;
887 dev_warn(nvmeq->q_dmadev, "Cancelling I/O %d\n", cmdid);
888 ctx = cancel_cmdid(nvmeq, cmdid, &fn);
889 fn(nvmeq->dev, ctx, &cqe);
890 }
891}
892
893static void nvme_free_queue_mem(struct nvme_queue *nvmeq)
894{
895 dma_free_coherent(nvmeq->q_dmadev, CQ_SIZE(nvmeq->q_depth),
896 (void *)nvmeq->cqes, nvmeq->cq_dma_addr);
897 dma_free_coherent(nvmeq->q_dmadev, SQ_SIZE(nvmeq->q_depth),
898 nvmeq->sq_cmds, nvmeq->sq_dma_addr);
899 kfree(nvmeq);
900}
901
865static void nvme_free_queue(struct nvme_dev *dev, int qid) 902static void nvme_free_queue(struct nvme_dev *dev, int qid)
866{ 903{
867 struct nvme_queue *nvmeq = dev->queues[qid]; 904 struct nvme_queue *nvmeq = dev->queues[qid];
868 int vector = dev->entry[nvmeq->cq_vector].vector; 905 int vector = dev->entry[nvmeq->cq_vector].vector;
869 906
907 spin_lock_irq(&nvmeq->q_lock);
908 nvme_cancel_ios(nvmeq, false);
909 spin_unlock_irq(&nvmeq->q_lock);
910
870 irq_set_affinity_hint(vector, NULL); 911 irq_set_affinity_hint(vector, NULL);
871 free_irq(vector, nvmeq); 912 free_irq(vector, nvmeq);
872 913
@@ -876,18 +917,15 @@ static void nvme_free_queue(struct nvme_dev *dev, int qid)
876 adapter_delete_cq(dev, qid); 917 adapter_delete_cq(dev, qid);
877 } 918 }
878 919
879 dma_free_coherent(nvmeq->q_dmadev, CQ_SIZE(nvmeq->q_depth), 920 nvme_free_queue_mem(nvmeq);
880 (void *)nvmeq->cqes, nvmeq->cq_dma_addr);
881 dma_free_coherent(nvmeq->q_dmadev, SQ_SIZE(nvmeq->q_depth),
882 nvmeq->sq_cmds, nvmeq->sq_dma_addr);
883 kfree(nvmeq);
884} 921}
885 922
886static struct nvme_queue *nvme_alloc_queue(struct nvme_dev *dev, int qid, 923static struct nvme_queue *nvme_alloc_queue(struct nvme_dev *dev, int qid,
887 int depth, int vector) 924 int depth, int vector)
888{ 925{
889 struct device *dmadev = &dev->pci_dev->dev; 926 struct device *dmadev = &dev->pci_dev->dev;
890 unsigned extra = (depth / 8) + (depth * sizeof(struct nvme_cmd_info)); 927 unsigned extra = DIV_ROUND_UP(depth, 8) + (depth *
928 sizeof(struct nvme_cmd_info));
891 struct nvme_queue *nvmeq = kzalloc(sizeof(*nvmeq) + extra, GFP_KERNEL); 929 struct nvme_queue *nvmeq = kzalloc(sizeof(*nvmeq) + extra, GFP_KERNEL);
892 if (!nvmeq) 930 if (!nvmeq)
893 return NULL; 931 return NULL;
@@ -975,7 +1013,7 @@ static __devinit struct nvme_queue *nvme_create_queue(struct nvme_dev *dev,
975 1013
976static int __devinit nvme_configure_admin_queue(struct nvme_dev *dev) 1014static int __devinit nvme_configure_admin_queue(struct nvme_dev *dev)
977{ 1015{
978 int result; 1016 int result = 0;
979 u32 aqa; 1017 u32 aqa;
980 u64 cap; 1018 u64 cap;
981 unsigned long timeout; 1019 unsigned long timeout;
@@ -1005,17 +1043,22 @@ static int __devinit nvme_configure_admin_queue(struct nvme_dev *dev)
1005 timeout = ((NVME_CAP_TIMEOUT(cap) + 1) * HZ / 2) + jiffies; 1043 timeout = ((NVME_CAP_TIMEOUT(cap) + 1) * HZ / 2) + jiffies;
1006 dev->db_stride = NVME_CAP_STRIDE(cap); 1044 dev->db_stride = NVME_CAP_STRIDE(cap);
1007 1045
1008 while (!(readl(&dev->bar->csts) & NVME_CSTS_RDY)) { 1046 while (!result && !(readl(&dev->bar->csts) & NVME_CSTS_RDY)) {
1009 msleep(100); 1047 msleep(100);
1010 if (fatal_signal_pending(current)) 1048 if (fatal_signal_pending(current))
1011 return -EINTR; 1049 result = -EINTR;
1012 if (time_after(jiffies, timeout)) { 1050 if (time_after(jiffies, timeout)) {
1013 dev_err(&dev->pci_dev->dev, 1051 dev_err(&dev->pci_dev->dev,
1014 "Device not ready; aborting initialisation\n"); 1052 "Device not ready; aborting initialisation\n");
1015 return -ENODEV; 1053 result = -ENODEV;
1016 } 1054 }
1017 } 1055 }
1018 1056
1057 if (result) {
1058 nvme_free_queue_mem(nvmeq);
1059 return result;
1060 }
1061
1019 result = queue_request_irq(dev, nvmeq, "nvme admin"); 1062 result = queue_request_irq(dev, nvmeq, "nvme admin");
1020 dev->queues[0] = nvmeq; 1063 dev->queues[0] = nvmeq;
1021 return result; 1064 return result;
@@ -1037,6 +1080,8 @@ static struct nvme_iod *nvme_map_user_pages(struct nvme_dev *dev, int write,
1037 offset = offset_in_page(addr); 1080 offset = offset_in_page(addr);
1038 count = DIV_ROUND_UP(offset + length, PAGE_SIZE); 1081 count = DIV_ROUND_UP(offset + length, PAGE_SIZE);
1039 pages = kcalloc(count, sizeof(*pages), GFP_KERNEL); 1082 pages = kcalloc(count, sizeof(*pages), GFP_KERNEL);
1083 if (!pages)
1084 return ERR_PTR(-ENOMEM);
1040 1085
1041 err = get_user_pages_fast(addr, count, 1, pages); 1086 err = get_user_pages_fast(addr, count, 1, pages);
1042 if (err < count) { 1087 if (err < count) {
@@ -1146,14 +1191,13 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio)
1146 return status; 1191 return status;
1147} 1192}
1148 1193
1149static int nvme_user_admin_cmd(struct nvme_ns *ns, 1194static int nvme_user_admin_cmd(struct nvme_dev *dev,
1150 struct nvme_admin_cmd __user *ucmd) 1195 struct nvme_admin_cmd __user *ucmd)
1151{ 1196{
1152 struct nvme_dev *dev = ns->dev;
1153 struct nvme_admin_cmd cmd; 1197 struct nvme_admin_cmd cmd;
1154 struct nvme_command c; 1198 struct nvme_command c;
1155 int status, length; 1199 int status, length;
1156 struct nvme_iod *iod; 1200 struct nvme_iod *uninitialized_var(iod);
1157 1201
1158 if (!capable(CAP_SYS_ADMIN)) 1202 if (!capable(CAP_SYS_ADMIN))
1159 return -EACCES; 1203 return -EACCES;
@@ -1204,7 +1248,7 @@ static int nvme_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
1204 case NVME_IOCTL_ID: 1248 case NVME_IOCTL_ID:
1205 return ns->ns_id; 1249 return ns->ns_id;
1206 case NVME_IOCTL_ADMIN_CMD: 1250 case NVME_IOCTL_ADMIN_CMD:
1207 return nvme_user_admin_cmd(ns, (void __user *)arg); 1251 return nvme_user_admin_cmd(ns->dev, (void __user *)arg);
1208 case NVME_IOCTL_SUBMIT_IO: 1252 case NVME_IOCTL_SUBMIT_IO:
1209 return nvme_submit_io(ns, (void __user *)arg); 1253 return nvme_submit_io(ns, (void __user *)arg);
1210 default: 1254 default:
@@ -1218,26 +1262,6 @@ static const struct block_device_operations nvme_fops = {
1218 .compat_ioctl = nvme_ioctl, 1262 .compat_ioctl = nvme_ioctl,
1219}; 1263};
1220 1264
1221static void nvme_timeout_ios(struct nvme_queue *nvmeq)
1222{
1223 int depth = nvmeq->q_depth - 1;
1224 struct nvme_cmd_info *info = nvme_cmd_info(nvmeq);
1225 unsigned long now = jiffies;
1226 int cmdid;
1227
1228 for_each_set_bit(cmdid, nvmeq->cmdid_data, depth) {
1229 void *ctx;
1230 nvme_completion_fn fn;
1231 static struct nvme_completion cqe = { .status = cpu_to_le16(NVME_SC_ABORT_REQ) << 1, };
1232
1233 if (!time_after(now, info[cmdid].timeout))
1234 continue;
1235 dev_warn(nvmeq->q_dmadev, "Timing out I/O %d\n", cmdid);
1236 ctx = cancel_cmdid(nvmeq, cmdid, &fn);
1237 fn(nvmeq->dev, ctx, &cqe);
1238 }
1239}
1240
1241static void nvme_resubmit_bios(struct nvme_queue *nvmeq) 1265static void nvme_resubmit_bios(struct nvme_queue *nvmeq)
1242{ 1266{
1243 while (bio_list_peek(&nvmeq->sq_cong)) { 1267 while (bio_list_peek(&nvmeq->sq_cong)) {
@@ -1269,7 +1293,7 @@ static int nvme_kthread(void *data)
1269 spin_lock_irq(&nvmeq->q_lock); 1293 spin_lock_irq(&nvmeq->q_lock);
1270 if (nvme_process_cq(nvmeq)) 1294 if (nvme_process_cq(nvmeq))
1271 printk("process_cq did something\n"); 1295 printk("process_cq did something\n");
1272 nvme_timeout_ios(nvmeq); 1296 nvme_cancel_ios(nvmeq, true);
1273 nvme_resubmit_bios(nvmeq); 1297 nvme_resubmit_bios(nvmeq);
1274 spin_unlock_irq(&nvmeq->q_lock); 1298 spin_unlock_irq(&nvmeq->q_lock);
1275 } 1299 }
@@ -1339,6 +1363,9 @@ static struct nvme_ns *nvme_alloc_ns(struct nvme_dev *dev, int nsid,
1339 ns->disk = disk; 1363 ns->disk = disk;
1340 lbaf = id->flbas & 0xf; 1364 lbaf = id->flbas & 0xf;
1341 ns->lba_shift = id->lbaf[lbaf].ds; 1365 ns->lba_shift = id->lbaf[lbaf].ds;
1366 blk_queue_logical_block_size(ns->queue, 1 << ns->lba_shift);
1367 if (dev->max_hw_sectors)
1368 blk_queue_max_hw_sectors(ns->queue, dev->max_hw_sectors);
1342 1369
1343 disk->major = nvme_major; 1370 disk->major = nvme_major;
1344 disk->minors = NVME_MINORS; 1371 disk->minors = NVME_MINORS;
@@ -1383,7 +1410,7 @@ static int set_queue_count(struct nvme_dev *dev, int count)
1383 1410
1384static int __devinit nvme_setup_io_queues(struct nvme_dev *dev) 1411static int __devinit nvme_setup_io_queues(struct nvme_dev *dev)
1385{ 1412{
1386 int result, cpu, i, nr_io_queues, db_bar_size; 1413 int result, cpu, i, nr_io_queues, db_bar_size, q_depth;
1387 1414
1388 nr_io_queues = num_online_cpus(); 1415 nr_io_queues = num_online_cpus();
1389 result = set_queue_count(dev, nr_io_queues); 1416 result = set_queue_count(dev, nr_io_queues);
@@ -1429,9 +1456,10 @@ static int __devinit nvme_setup_io_queues(struct nvme_dev *dev)
1429 cpu = cpumask_next(cpu, cpu_online_mask); 1456 cpu = cpumask_next(cpu, cpu_online_mask);
1430 } 1457 }
1431 1458
1459 q_depth = min_t(int, NVME_CAP_MQES(readq(&dev->bar->cap)) + 1,
1460 NVME_Q_DEPTH);
1432 for (i = 0; i < nr_io_queues; i++) { 1461 for (i = 0; i < nr_io_queues; i++) {
1433 dev->queues[i + 1] = nvme_create_queue(dev, i + 1, 1462 dev->queues[i + 1] = nvme_create_queue(dev, i + 1, q_depth, i);
1434 NVME_Q_DEPTH, i);
1435 if (IS_ERR(dev->queues[i + 1])) 1463 if (IS_ERR(dev->queues[i + 1]))
1436 return PTR_ERR(dev->queues[i + 1]); 1464 return PTR_ERR(dev->queues[i + 1]);
1437 dev->queue_count++; 1465 dev->queue_count++;
@@ -1480,6 +1508,10 @@ static int __devinit nvme_dev_add(struct nvme_dev *dev)
1480 memcpy(dev->serial, ctrl->sn, sizeof(ctrl->sn)); 1508 memcpy(dev->serial, ctrl->sn, sizeof(ctrl->sn));
1481 memcpy(dev->model, ctrl->mn, sizeof(ctrl->mn)); 1509 memcpy(dev->model, ctrl->mn, sizeof(ctrl->mn));
1482 memcpy(dev->firmware_rev, ctrl->fr, sizeof(ctrl->fr)); 1510 memcpy(dev->firmware_rev, ctrl->fr, sizeof(ctrl->fr));
1511 if (ctrl->mdts) {
1512 int shift = NVME_CAP_MPSMIN(readq(&dev->bar->cap)) + 12;
1513 dev->max_hw_sectors = 1 << (ctrl->mdts + shift - 9);
1514 }
1483 1515
1484 id_ns = mem; 1516 id_ns = mem;
1485 for (i = 1; i <= nn; i++) { 1517 for (i = 1; i <= nn; i++) {
@@ -1523,8 +1555,6 @@ static int nvme_dev_remove(struct nvme_dev *dev)
1523 list_del(&dev->node); 1555 list_del(&dev->node);
1524 spin_unlock(&dev_list_lock); 1556 spin_unlock(&dev_list_lock);
1525 1557
1526 /* TODO: wait all I/O finished or cancel them */
1527
1528 list_for_each_entry_safe(ns, next, &dev->namespaces, list) { 1558 list_for_each_entry_safe(ns, next, &dev->namespaces, list) {
1529 list_del(&ns->list); 1559 list_del(&ns->list);
1530 del_gendisk(ns->disk); 1560 del_gendisk(ns->disk);
@@ -1560,15 +1590,33 @@ static void nvme_release_prp_pools(struct nvme_dev *dev)
1560 dma_pool_destroy(dev->prp_small_pool); 1590 dma_pool_destroy(dev->prp_small_pool);
1561} 1591}
1562 1592
1563/* XXX: Use an ida or something to let remove / add work correctly */ 1593static DEFINE_IDA(nvme_instance_ida);
1564static void nvme_set_instance(struct nvme_dev *dev) 1594
1595static int nvme_set_instance(struct nvme_dev *dev)
1565{ 1596{
1566 static int instance; 1597 int instance, error;
1567 dev->instance = instance++; 1598
1599 do {
1600 if (!ida_pre_get(&nvme_instance_ida, GFP_KERNEL))
1601 return -ENODEV;
1602
1603 spin_lock(&dev_list_lock);
1604 error = ida_get_new(&nvme_instance_ida, &instance);
1605 spin_unlock(&dev_list_lock);
1606 } while (error == -EAGAIN);
1607
1608 if (error)
1609 return -ENODEV;
1610
1611 dev->instance = instance;
1612 return 0;
1568} 1613}
1569 1614
1570static void nvme_release_instance(struct nvme_dev *dev) 1615static void nvme_release_instance(struct nvme_dev *dev)
1571{ 1616{
1617 spin_lock(&dev_list_lock);
1618 ida_remove(&nvme_instance_ida, dev->instance);
1619 spin_unlock(&dev_list_lock);
1572} 1620}
1573 1621
1574static int __devinit nvme_probe(struct pci_dev *pdev, 1622static int __devinit nvme_probe(struct pci_dev *pdev,
@@ -1601,7 +1649,10 @@ static int __devinit nvme_probe(struct pci_dev *pdev,
1601 pci_set_drvdata(pdev, dev); 1649 pci_set_drvdata(pdev, dev);
1602 dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)); 1650 dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));
1603 dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64)); 1651 dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
1604 nvme_set_instance(dev); 1652 result = nvme_set_instance(dev);
1653 if (result)
1654 goto disable;
1655
1605 dev->entry[0].vector = pdev->irq; 1656 dev->entry[0].vector = pdev->irq;
1606 1657
1607 result = nvme_setup_prp_pools(dev); 1658 result = nvme_setup_prp_pools(dev);
@@ -1704,15 +1755,17 @@ static struct pci_driver nvme_driver = {
1704 1755
1705static int __init nvme_init(void) 1756static int __init nvme_init(void)
1706{ 1757{
1707 int result = -EBUSY; 1758 int result;
1708 1759
1709 nvme_thread = kthread_run(nvme_kthread, NULL, "nvme"); 1760 nvme_thread = kthread_run(nvme_kthread, NULL, "nvme");
1710 if (IS_ERR(nvme_thread)) 1761 if (IS_ERR(nvme_thread))
1711 return PTR_ERR(nvme_thread); 1762 return PTR_ERR(nvme_thread);
1712 1763
1713 nvme_major = register_blkdev(nvme_major, "nvme"); 1764 result = register_blkdev(nvme_major, "nvme");
1714 if (nvme_major <= 0) 1765 if (result < 0)
1715 goto kill_kthread; 1766 goto kill_kthread;
1767 else if (result > 0)
1768 nvme_major = result;
1716 1769
1717 result = pci_register_driver(&nvme_driver); 1770 result = pci_register_driver(&nvme_driver);
1718 if (result) 1771 if (result)
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 9917943a3572..54a55f03115d 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -246,13 +246,12 @@ static int rbd_open(struct block_device *bdev, fmode_t mode)
246{ 246{
247 struct rbd_device *rbd_dev = bdev->bd_disk->private_data; 247 struct rbd_device *rbd_dev = bdev->bd_disk->private_data;
248 248
249 rbd_get_dev(rbd_dev);
250
251 set_device_ro(bdev, rbd_dev->read_only);
252
253 if ((mode & FMODE_WRITE) && rbd_dev->read_only) 249 if ((mode & FMODE_WRITE) && rbd_dev->read_only)
254 return -EROFS; 250 return -EROFS;
255 251
252 rbd_get_dev(rbd_dev);
253 set_device_ro(bdev, rbd_dev->read_only);
254
256 return 0; 255 return 0;
257} 256}
258 257
diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
index 73f196ca713f..c6decb901e5e 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -337,7 +337,7 @@ static void xen_blkbk_unmap(struct pending_req *req)
337 invcount++; 337 invcount++;
338 } 338 }
339 339
340 ret = gnttab_unmap_refs(unmap, pages, invcount, false); 340 ret = gnttab_unmap_refs(unmap, NULL, pages, invcount);
341 BUG_ON(ret); 341 BUG_ON(ret);
342} 342}
343 343
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 5869ea387054..72ce247a0e8d 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -1,4 +1,5 @@
1# common clock types 1# common clock types
2obj-$(CONFIG_HAVE_CLK) += clk-devres.o
2obj-$(CONFIG_CLKDEV_LOOKUP) += clkdev.o 3obj-$(CONFIG_CLKDEV_LOOKUP) += clkdev.o
3obj-$(CONFIG_COMMON_CLK) += clk.o clk-fixed-rate.o clk-gate.o \ 4obj-$(CONFIG_COMMON_CLK) += clk.o clk-fixed-rate.o clk-gate.o \
4 clk-mux.o clk-divider.o clk-fixed-factor.o 5 clk-mux.o clk-divider.o clk-fixed-factor.o
diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c
new file mode 100644
index 000000000000..8f571548870f
--- /dev/null
+++ b/drivers/clk/clk-devres.c
@@ -0,0 +1,55 @@
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License version 2 as
4 * published by the Free Software Foundation.
5 */
6
7#include <linux/clk.h>
8#include <linux/device.h>
9#include <linux/export.h>
10#include <linux/gfp.h>
11
12static void devm_clk_release(struct device *dev, void *res)
13{
14 clk_put(*(struct clk **)res);
15}
16
17struct clk *devm_clk_get(struct device *dev, const char *id)
18{
19 struct clk **ptr, *clk;
20
21 ptr = devres_alloc(devm_clk_release, sizeof(*ptr), GFP_KERNEL);
22 if (!ptr)
23 return ERR_PTR(-ENOMEM);
24
25 clk = clk_get(dev, id);
26 if (!IS_ERR(clk)) {
27 *ptr = clk;
28 devres_add(dev, ptr);
29 } else {
30 devres_free(ptr);
31 }
32
33 return clk;
34}
35EXPORT_SYMBOL(devm_clk_get);
36
37static int devm_clk_match(struct device *dev, void *res, void *data)
38{
39 struct clk **c = res;
40 if (!c || !*c) {
41 WARN_ON(!c || !*c);
42 return 0;
43 }
44 return *c == data;
45}
46
47void devm_clk_put(struct device *dev, struct clk *clk)
48{
49 int ret;
50
51 ret = devres_release(dev, devm_clk_release, devm_clk_match, clk);
52
53 WARN_ON(ret);
54}
55EXPORT_SYMBOL(devm_clk_put);
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index d423c9bdd71a..442a31363873 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -171,51 +171,6 @@ void clk_put(struct clk *clk)
171} 171}
172EXPORT_SYMBOL(clk_put); 172EXPORT_SYMBOL(clk_put);
173 173
174static void devm_clk_release(struct device *dev, void *res)
175{
176 clk_put(*(struct clk **)res);
177}
178
179struct clk *devm_clk_get(struct device *dev, const char *id)
180{
181 struct clk **ptr, *clk;
182
183 ptr = devres_alloc(devm_clk_release, sizeof(*ptr), GFP_KERNEL);
184 if (!ptr)
185 return ERR_PTR(-ENOMEM);
186
187 clk = clk_get(dev, id);
188 if (!IS_ERR(clk)) {
189 *ptr = clk;
190 devres_add(dev, ptr);
191 } else {
192 devres_free(ptr);
193 }
194
195 return clk;
196}
197EXPORT_SYMBOL(devm_clk_get);
198
199static int devm_clk_match(struct device *dev, void *res, void *data)
200{
201 struct clk **c = res;
202 if (!c || !*c) {
203 WARN_ON(!c || !*c);
204 return 0;
205 }
206 return *c == data;
207}
208
209void devm_clk_put(struct device *dev, struct clk *clk)
210{
211 int ret;
212
213 ret = devres_destroy(dev, devm_clk_release, devm_clk_match, clk);
214
215 WARN_ON(ret);
216}
217EXPORT_SYMBOL(devm_clk_put);
218
219void clkdev_add(struct clk_lookup *cl) 174void clkdev_add(struct clk_lookup *cl)
220{ 175{
221 mutex_lock(&clocks_mutex); 176 mutex_lock(&clocks_mutex);
diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index 3934fcc4e00b..7ab6e26664a7 100644
--- a/drivers/dma/at_hdmac.c
+++ b/drivers/dma/at_hdmac.c
@@ -661,7 +661,7 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
661 flags); 661 flags);
662 662
663 if (unlikely(!atslave || !sg_len)) { 663 if (unlikely(!atslave || !sg_len)) {
664 dev_dbg(chan2dev(chan), "prep_dma_memcpy: length is zero!\n"); 664 dev_dbg(chan2dev(chan), "prep_slave_sg: sg length is zero!\n");
665 return NULL; 665 return NULL;
666 } 666 }
667 667
@@ -689,6 +689,11 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
689 689
690 mem = sg_dma_address(sg); 690 mem = sg_dma_address(sg);
691 len = sg_dma_len(sg); 691 len = sg_dma_len(sg);
692 if (unlikely(!len)) {
693 dev_dbg(chan2dev(chan),
694 "prep_slave_sg: sg(%d) data length is zero\n", i);
695 goto err;
696 }
692 mem_width = 2; 697 mem_width = 2;
693 if (unlikely(mem & 3 || len & 3)) 698 if (unlikely(mem & 3 || len & 3))
694 mem_width = 0; 699 mem_width = 0;
@@ -724,6 +729,11 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
724 729
725 mem = sg_dma_address(sg); 730 mem = sg_dma_address(sg);
726 len = sg_dma_len(sg); 731 len = sg_dma_len(sg);
732 if (unlikely(!len)) {
733 dev_dbg(chan2dev(chan),
734 "prep_slave_sg: sg(%d) data length is zero\n", i);
735 goto err;
736 }
727 mem_width = 2; 737 mem_width = 2;
728 if (unlikely(mem & 3 || len & 3)) 738 if (unlikely(mem & 3 || len & 3))
729 mem_width = 0; 739 mem_width = 0;
@@ -757,6 +767,7 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
757 767
758err_desc_get: 768err_desc_get:
759 dev_err(chan2dev(chan), "not enough descriptors available\n"); 769 dev_err(chan2dev(chan), "not enough descriptors available\n");
770err:
760 atc_desc_put(atchan, first); 771 atc_desc_put(atchan, first);
761 return NULL; 772 return NULL;
762} 773}
diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index e4feba6b03c0..f5843bc80baa 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -1567,17 +1567,19 @@ static int pl330_submit_req(void *ch_id, struct pl330_req *r)
1567 goto xfer_exit; 1567 goto xfer_exit;
1568 } 1568 }
1569 1569
1570 /* Prefer Secure Channel */
1571 if (!_manager_ns(thrd))
1572 r->cfg->nonsecure = 0;
1573 else
1574 r->cfg->nonsecure = 1;
1575 1570
1576 /* Use last settings, if not provided */ 1571 /* Use last settings, if not provided */
1577 if (r->cfg) 1572 if (r->cfg) {
1573 /* Prefer Secure Channel */
1574 if (!_manager_ns(thrd))
1575 r->cfg->nonsecure = 0;
1576 else
1577 r->cfg->nonsecure = 1;
1578
1578 ccr = _prepare_ccr(r->cfg); 1579 ccr = _prepare_ccr(r->cfg);
1579 else 1580 } else {
1580 ccr = readl(regs + CC(thrd->id)); 1581 ccr = readl(regs + CC(thrd->id));
1582 }
1581 1583
1582 /* If this req doesn't have valid xfer settings */ 1584 /* If this req doesn't have valid xfer settings */
1583 if (!_is_valid(ccr)) { 1585 if (!_is_valid(ccr)) {
@@ -2928,6 +2930,11 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
2928 num_chan = max_t(int, pi->pcfg.num_peri, pi->pcfg.num_chan); 2930 num_chan = max_t(int, pi->pcfg.num_peri, pi->pcfg.num_chan);
2929 2931
2930 pdmac->peripherals = kzalloc(num_chan * sizeof(*pch), GFP_KERNEL); 2932 pdmac->peripherals = kzalloc(num_chan * sizeof(*pch), GFP_KERNEL);
2933 if (!pdmac->peripherals) {
2934 ret = -ENOMEM;
2935 dev_err(&adev->dev, "unable to allocate pdmac->peripherals\n");
2936 goto probe_err5;
2937 }
2931 2938
2932 for (i = 0; i < num_chan; i++) { 2939 for (i = 0; i < num_chan; i++) {
2933 pch = &pdmac->peripherals[i]; 2940 pch = &pdmac->peripherals[i];
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index 616d90bcb3a4..d5dc9da7f99f 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -199,6 +199,36 @@ void *edac_align_ptr(void **p, unsigned size, int n_elems)
199 return (void *)(((unsigned long)ptr) + align - r); 199 return (void *)(((unsigned long)ptr) + align - r);
200} 200}
201 201
202static void _edac_mc_free(struct mem_ctl_info *mci)
203{
204 int i, chn, row;
205 struct csrow_info *csr;
206 const unsigned int tot_dimms = mci->tot_dimms;
207 const unsigned int tot_channels = mci->num_cschannel;
208 const unsigned int tot_csrows = mci->nr_csrows;
209
210 if (mci->dimms) {
211 for (i = 0; i < tot_dimms; i++)
212 kfree(mci->dimms[i]);
213 kfree(mci->dimms);
214 }
215 if (mci->csrows) {
216 for (row = 0; row < tot_csrows; row++) {
217 csr = mci->csrows[row];
218 if (csr) {
219 if (csr->channels) {
220 for (chn = 0; chn < tot_channels; chn++)
221 kfree(csr->channels[chn]);
222 kfree(csr->channels);
223 }
224 kfree(csr);
225 }
226 }
227 kfree(mci->csrows);
228 }
229 kfree(mci);
230}
231
202/** 232/**
203 * edac_mc_alloc: Allocate and partially fill a struct mem_ctl_info structure 233 * edac_mc_alloc: Allocate and partially fill a struct mem_ctl_info structure
204 * @mc_num: Memory controller number 234 * @mc_num: Memory controller number
@@ -413,24 +443,7 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num,
413 return mci; 443 return mci;
414 444
415error: 445error:
416 if (mci->dimms) { 446 _edac_mc_free(mci);
417 for (i = 0; i < tot_dimms; i++)
418 kfree(mci->dimms[i]);
419 kfree(mci->dimms);
420 }
421 if (mci->csrows) {
422 for (chn = 0; chn < tot_channels; chn++) {
423 csr = mci->csrows[chn];
424 if (csr) {
425 for (chn = 0; chn < tot_channels; chn++)
426 kfree(csr->channels[chn]);
427 kfree(csr);
428 }
429 kfree(mci->csrows[i]);
430 }
431 kfree(mci->csrows);
432 }
433 kfree(mci);
434 447
435 return NULL; 448 return NULL;
436} 449}
@@ -445,6 +458,14 @@ void edac_mc_free(struct mem_ctl_info *mci)
445{ 458{
446 edac_dbg(1, "\n"); 459 edac_dbg(1, "\n");
447 460
461 /* If we're not yet registered with sysfs free only what was allocated
462 * in edac_mc_alloc().
463 */
464 if (!device_is_registered(&mci->dev)) {
465 _edac_mc_free(mci);
466 return;
467 }
468
448 /* the mci instance is freed here, when the sysfs object is dropped */ 469 /* the mci instance is freed here, when the sysfs object is dropped */
449 edac_unregister_sysfs(mci); 470 edac_unregister_sysfs(mci);
450} 471}
diff --git a/drivers/edac/i3200_edac.c b/drivers/edac/i3200_edac.c
index 47180a08edad..b6653a6fc5d5 100644
--- a/drivers/edac/i3200_edac.c
+++ b/drivers/edac/i3200_edac.c
@@ -391,7 +391,7 @@ static int i3200_probe1(struct pci_dev *pdev, int dev_idx)
391 for (j = 0; j < nr_channels; j++) { 391 for (j = 0; j < nr_channels; j++) {
392 struct dimm_info *dimm = csrow->channels[j]->dimm; 392 struct dimm_info *dimm = csrow->channels[j]->dimm;
393 393
394 dimm->nr_pages = nr_pages / nr_channels; 394 dimm->nr_pages = nr_pages;
395 dimm->grain = nr_pages << PAGE_SHIFT; 395 dimm->grain = nr_pages << PAGE_SHIFT;
396 dimm->mtype = MEM_DDR2; 396 dimm->mtype = MEM_DDR2;
397 dimm->dtype = DEV_UNKNOWN; 397 dimm->dtype = DEV_UNKNOWN;
diff --git a/drivers/edac/i5000_edac.c b/drivers/edac/i5000_edac.c
index 39c63757c2a1..6a49dd00b81b 100644
--- a/drivers/edac/i5000_edac.c
+++ b/drivers/edac/i5000_edac.c
@@ -1012,6 +1012,10 @@ static void handle_channel(struct i5000_pvt *pvt, int slot, int channel,
1012 /* add the number of COLUMN bits */ 1012 /* add the number of COLUMN bits */
1013 addrBits += MTR_DIMM_COLS_ADDR_BITS(mtr); 1013 addrBits += MTR_DIMM_COLS_ADDR_BITS(mtr);
1014 1014
1015 /* Dual-rank memories have twice the size */
1016 if (dinfo->dual_rank)
1017 addrBits++;
1018
1015 addrBits += 6; /* add 64 bits per DIMM */ 1019 addrBits += 6; /* add 64 bits per DIMM */
1016 addrBits -= 20; /* divide by 2^^20 */ 1020 addrBits -= 20; /* divide by 2^^20 */
1017 addrBits -= 3; /* 8 bits per bytes */ 1021 addrBits -= 3; /* 8 bits per bytes */
diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
index f3b1f9fafa4b..5715b7c2c517 100644
--- a/drivers/edac/sb_edac.c
+++ b/drivers/edac/sb_edac.c
@@ -513,7 +513,8 @@ static int get_dimm_config(struct mem_ctl_info *mci)
513{ 513{
514 struct sbridge_pvt *pvt = mci->pvt_info; 514 struct sbridge_pvt *pvt = mci->pvt_info;
515 struct dimm_info *dimm; 515 struct dimm_info *dimm;
516 int i, j, banks, ranks, rows, cols, size, npages; 516 unsigned i, j, banks, ranks, rows, cols, npages;
517 u64 size;
517 u32 reg; 518 u32 reg;
518 enum edac_type mode; 519 enum edac_type mode;
519 enum mem_type mtype; 520 enum mem_type mtype;
@@ -585,10 +586,10 @@ static int get_dimm_config(struct mem_ctl_info *mci)
585 cols = numcol(mtr); 586 cols = numcol(mtr);
586 587
587 /* DDR3 has 8 I/O banks */ 588 /* DDR3 has 8 I/O banks */
588 size = (rows * cols * banks * ranks) >> (20 - 3); 589 size = ((u64)rows * cols * banks * ranks) >> (20 - 3);
589 npages = MiB_TO_PAGES(size); 590 npages = MiB_TO_PAGES(size);
590 591
591 edac_dbg(0, "mc#%d: channel %d, dimm %d, %d Mb (%d pages) bank: %d, rank: %d, row: %#x, col: %#x\n", 592 edac_dbg(0, "mc#%d: channel %d, dimm %d, %Ld Mb (%d pages) bank: %d, rank: %d, row: %#x, col: %#x\n",
592 pvt->sbridge_dev->mc, i, j, 593 pvt->sbridge_dev->mc, i, j,
593 size, npages, 594 size, npages,
594 banks, ranks, rows, cols); 595 banks, ranks, rows, cols);
diff --git a/drivers/gpio/gpio-lpc32xx.c b/drivers/gpio/gpio-lpc32xx.c
index 8a420f13905e..ed94b4ea72e9 100644
--- a/drivers/gpio/gpio-lpc32xx.c
+++ b/drivers/gpio/gpio-lpc32xx.c
@@ -308,6 +308,7 @@ static int lpc32xx_gpio_dir_output_p012(struct gpio_chip *chip, unsigned pin,
308{ 308{
309 struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); 309 struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip);
310 310
311 __set_gpio_level_p012(group, pin, value);
311 __set_gpio_dir_p012(group, pin, 0); 312 __set_gpio_dir_p012(group, pin, 0);
312 313
313 return 0; 314 return 0;
@@ -318,6 +319,7 @@ static int lpc32xx_gpio_dir_output_p3(struct gpio_chip *chip, unsigned pin,
318{ 319{
319 struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); 320 struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip);
320 321
322 __set_gpio_level_p3(group, pin, value);
321 __set_gpio_dir_p3(group, pin, 0); 323 __set_gpio_dir_p3(group, pin, 0);
322 324
323 return 0; 325 return 0;
@@ -326,6 +328,9 @@ static int lpc32xx_gpio_dir_output_p3(struct gpio_chip *chip, unsigned pin,
326static int lpc32xx_gpio_dir_out_always(struct gpio_chip *chip, unsigned pin, 328static int lpc32xx_gpio_dir_out_always(struct gpio_chip *chip, unsigned pin,
327 int value) 329 int value)
328{ 330{
331 struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip);
332
333 __set_gpo_level_p3(group, pin, value);
329 return 0; 334 return 0;
330} 335}
331 336
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 489e2b162b27..274d25de521e 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -3242,7 +3242,8 @@ i915_gem_object_pin(struct drm_i915_gem_object *obj,
3242{ 3242{
3243 int ret; 3243 int ret;
3244 3244
3245 BUG_ON(obj->pin_count == DRM_I915_GEM_OBJECT_MAX_PIN_COUNT); 3245 if (WARN_ON(obj->pin_count == DRM_I915_GEM_OBJECT_MAX_PIN_COUNT))
3246 return -EBUSY;
3246 3247
3247 if (obj->gtt_space != NULL) { 3248 if (obj->gtt_space != NULL) {
3248 if ((alignment && obj->gtt_offset & (alignment - 1)) || 3249 if ((alignment && obj->gtt_offset & (alignment - 1)) ||
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index bc2ad348e5d8..c040aee1341c 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -4191,12 +4191,6 @@ static void i8xx_update_pll(struct drm_crtc *crtc,
4191 POSTING_READ(DPLL(pipe)); 4191 POSTING_READ(DPLL(pipe));
4192 udelay(150); 4192 udelay(150);
4193 4193
4194 I915_WRITE(DPLL(pipe), dpll);
4195
4196 /* Wait for the clocks to stabilize. */
4197 POSTING_READ(DPLL(pipe));
4198 udelay(150);
4199
4200 /* The LVDS pin pair needs to be on before the DPLLs are enabled. 4194 /* The LVDS pin pair needs to be on before the DPLLs are enabled.
4201 * This is an exception to the general rule that mode_set doesn't turn 4195 * This is an exception to the general rule that mode_set doesn't turn
4202 * things on. 4196 * things on.
@@ -4204,6 +4198,12 @@ static void i8xx_update_pll(struct drm_crtc *crtc,
4204 if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) 4198 if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS))
4205 intel_update_lvds(crtc, clock, adjusted_mode); 4199 intel_update_lvds(crtc, clock, adjusted_mode);
4206 4200
4201 I915_WRITE(DPLL(pipe), dpll);
4202
4203 /* Wait for the clocks to stabilize. */
4204 POSTING_READ(DPLL(pipe));
4205 udelay(150);
4206
4207 /* The pixel multiplier can only be updated once the 4207 /* The pixel multiplier can only be updated once the
4208 * DPLL is enabled and the clocks are stable. 4208 * DPLL is enabled and the clocks are stable.
4209 * 4209 *
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
index 98f602427eb8..12dc3308ab8c 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -609,7 +609,7 @@ static void intel_hdmi_dpms(struct drm_encoder *encoder, int mode)
609 u32 temp; 609 u32 temp;
610 u32 enable_bits = SDVO_ENABLE; 610 u32 enable_bits = SDVO_ENABLE;
611 611
612 if (intel_hdmi->has_audio) 612 if (intel_hdmi->has_audio || mode != DRM_MODE_DPMS_ON)
613 enable_bits |= SDVO_AUDIO_ENABLE; 613 enable_bits |= SDVO_AUDIO_ENABLE;
614 614
615 temp = I915_READ(intel_hdmi->sdvox_reg); 615 temp = I915_READ(intel_hdmi->sdvox_reg);
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c
index ff23d88880e5..3ca240b4413d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
@@ -179,7 +179,7 @@ nouveau_abi16_ioctl_grobj_alloc(ABI16_IOCTL_ARGS)
179 return 0; 179 return 0;
180 } else 180 } else
181 if (init->class == 0x906e) { 181 if (init->class == 0x906e) {
182 NV_ERROR(dev, "906e not supported yet\n"); 182 NV_DEBUG(dev, "906e not supported yet\n");
183 return -EINVAL; 183 return -EINVAL;
184 } 184 }
185 185
diff --git a/drivers/gpu/drm/nouveau/nv50_gpio.c b/drivers/gpu/drm/nouveau/nv50_gpio.c
index f03490534893..c399d510b27a 100644
--- a/drivers/gpu/drm/nouveau/nv50_gpio.c
+++ b/drivers/gpu/drm/nouveau/nv50_gpio.c
@@ -22,6 +22,7 @@
22 * Authors: Ben Skeggs 22 * Authors: Ben Skeggs
23 */ 23 */
24 24
25#include <linux/dmi.h>
25#include "drmP.h" 26#include "drmP.h"
26#include "nouveau_drv.h" 27#include "nouveau_drv.h"
27#include "nouveau_hw.h" 28#include "nouveau_hw.h"
@@ -110,13 +111,25 @@ nv50_gpio_isr(struct drm_device *dev)
110 nv_wr32(dev, 0xe074, intr1); 111 nv_wr32(dev, 0xe074, intr1);
111} 112}
112 113
114static struct dmi_system_id gpio_reset_ids[] = {
115 {
116 .ident = "Apple Macbook 10,1",
117 .matches = {
118 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
119 DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro10,1"),
120 }
121 },
122 { }
123};
124
113int 125int
114nv50_gpio_init(struct drm_device *dev) 126nv50_gpio_init(struct drm_device *dev)
115{ 127{
116 struct drm_nouveau_private *dev_priv = dev->dev_private; 128 struct drm_nouveau_private *dev_priv = dev->dev_private;
117 129
118 /* initialise gpios and routing to vbios defaults */ 130 /* initialise gpios and routing to vbios defaults */
119 nouveau_gpio_reset(dev); 131 if (dmi_check_system(gpio_reset_ids))
132 nouveau_gpio_reset(dev);
120 133
121 /* disable, and ack any pending gpio interrupts */ 134 /* disable, and ack any pending gpio interrupts */
122 nv_wr32(dev, 0xe050, 0x00000000); 135 nv_wr32(dev, 0xe050, 0x00000000);
diff --git a/drivers/gpu/drm/nouveau/nvc0_fb.c b/drivers/gpu/drm/nouveau/nvc0_fb.c
index f704e942372e..f376c39310df 100644
--- a/drivers/gpu/drm/nouveau/nvc0_fb.c
+++ b/drivers/gpu/drm/nouveau/nvc0_fb.c
@@ -124,6 +124,7 @@ nvc0_fb_init(struct drm_device *dev)
124 priv = dev_priv->engine.fb.priv; 124 priv = dev_priv->engine.fb.priv;
125 125
126 nv_wr32(dev, 0x100c10, priv->r100c10 >> 8); 126 nv_wr32(dev, 0x100c10, priv->r100c10 >> 8);
127 nv_mask(dev, 0x17e820, 0x00100000, 0x00000000); /* NV_PLTCG_INTR_EN */
127 return 0; 128 return 0;
128} 129}
129 130
diff --git a/drivers/gpu/drm/nouveau/nvc0_fifo.c b/drivers/gpu/drm/nouveau/nvc0_fifo.c
index 7d85553d518c..cd39eb99f5b1 100644
--- a/drivers/gpu/drm/nouveau/nvc0_fifo.c
+++ b/drivers/gpu/drm/nouveau/nvc0_fifo.c
@@ -373,7 +373,8 @@ nvc0_fifo_isr_subfifo_intr(struct drm_device *dev, int unit)
373static void 373static void
374nvc0_fifo_isr(struct drm_device *dev) 374nvc0_fifo_isr(struct drm_device *dev)
375{ 375{
376 u32 stat = nv_rd32(dev, 0x002100); 376 u32 mask = nv_rd32(dev, 0x002140);
377 u32 stat = nv_rd32(dev, 0x002100) & mask;
377 378
378 if (stat & 0x00000100) { 379 if (stat & 0x00000100) {
379 NV_INFO(dev, "PFIFO: unknown status 0x00000100\n"); 380 NV_INFO(dev, "PFIFO: unknown status 0x00000100\n");
diff --git a/drivers/gpu/drm/nouveau/nve0_fifo.c b/drivers/gpu/drm/nouveau/nve0_fifo.c
index e98d144e6eb9..281bece751b6 100644
--- a/drivers/gpu/drm/nouveau/nve0_fifo.c
+++ b/drivers/gpu/drm/nouveau/nve0_fifo.c
@@ -345,7 +345,8 @@ nve0_fifo_isr_subfifo_intr(struct drm_device *dev, int unit)
345static void 345static void
346nve0_fifo_isr(struct drm_device *dev) 346nve0_fifo_isr(struct drm_device *dev)
347{ 347{
348 u32 stat = nv_rd32(dev, 0x002100); 348 u32 mask = nv_rd32(dev, 0x002140);
349 u32 stat = nv_rd32(dev, 0x002100) & mask;
349 350
350 if (stat & 0x00000100) { 351 if (stat & 0x00000100) {
351 NV_INFO(dev, "PFIFO: unknown status 0x00000100\n"); 352 NV_INFO(dev, "PFIFO: unknown status 0x00000100\n");
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index e721e3087b99..2817101fb167 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -1479,98 +1479,14 @@ static void radeon_legacy_atom_fixup(struct drm_crtc *crtc)
1479 } 1479 }
1480} 1480}
1481 1481
1482/**
1483 * radeon_get_pll_use_mask - look up a mask of which pplls are in use
1484 *
1485 * @crtc: drm crtc
1486 *
1487 * Returns the mask of which PPLLs (Pixel PLLs) are in use.
1488 */
1489static u32 radeon_get_pll_use_mask(struct drm_crtc *crtc)
1490{
1491 struct drm_device *dev = crtc->dev;
1492 struct drm_crtc *test_crtc;
1493 struct radeon_crtc *radeon_test_crtc;
1494 u32 pll_in_use = 0;
1495
1496 list_for_each_entry(test_crtc, &dev->mode_config.crtc_list, head) {
1497 if (crtc == test_crtc)
1498 continue;
1499
1500 radeon_test_crtc = to_radeon_crtc(test_crtc);
1501 if (radeon_test_crtc->pll_id != ATOM_PPLL_INVALID)
1502 pll_in_use |= (1 << radeon_test_crtc->pll_id);
1503 }
1504 return pll_in_use;
1505}
1506
1507/**
1508 * radeon_get_shared_dp_ppll - return the PPLL used by another crtc for DP
1509 *
1510 * @crtc: drm crtc
1511 *
1512 * Returns the PPLL (Pixel PLL) used by another crtc/encoder which is
1513 * also in DP mode. For DP, a single PPLL can be used for all DP
1514 * crtcs/encoders.
1515 */
1516static int radeon_get_shared_dp_ppll(struct drm_crtc *crtc)
1517{
1518 struct drm_device *dev = crtc->dev;
1519 struct drm_encoder *test_encoder;
1520 struct radeon_crtc *radeon_test_crtc;
1521
1522 list_for_each_entry(test_encoder, &dev->mode_config.encoder_list, head) {
1523 if (test_encoder->crtc && (test_encoder->crtc != crtc)) {
1524 if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(test_encoder))) {
1525 /* for DP use the same PLL for all */
1526 radeon_test_crtc = to_radeon_crtc(test_encoder->crtc);
1527 if (radeon_test_crtc->pll_id != ATOM_PPLL_INVALID)
1528 return radeon_test_crtc->pll_id;
1529 }
1530 }
1531 }
1532 return ATOM_PPLL_INVALID;
1533}
1534
1535/**
1536 * radeon_atom_pick_pll - Allocate a PPLL for use by the crtc.
1537 *
1538 * @crtc: drm crtc
1539 *
1540 * Returns the PPLL (Pixel PLL) to be used by the crtc. For DP monitors
1541 * a single PPLL can be used for all DP crtcs/encoders. For non-DP
1542 * monitors a dedicated PPLL must be used. If a particular board has
1543 * an external DP PLL, return ATOM_PPLL_INVALID to skip PLL programming
1544 * as there is no need to program the PLL itself. If we are not able to
1545 * allocate a PLL, return ATOM_PPLL_INVALID to skip PLL programming to
1546 * avoid messing up an existing monitor.
1547 *
1548 * Asic specific PLL information
1549 *
1550 * DCE 6.1
1551 * - PPLL2 is only available to UNIPHYA (both DP and non-DP)
1552 * - PPLL0, PPLL1 are available for UNIPHYB/C/D/E/F (both DP and non-DP)
1553 *
1554 * DCE 6.0
1555 * - PPLL0 is available to all UNIPHY (DP only)
1556 * - PPLL1, PPLL2 are available for all UNIPHY (both DP and non-DP) and DAC
1557 *
1558 * DCE 5.0
1559 * - DCPLL is available to all UNIPHY (DP only)
1560 * - PPLL1, PPLL2 are available for all UNIPHY (both DP and non-DP) and DAC
1561 *
1562 * DCE 3.0/4.0/4.1
1563 * - PPLL1, PPLL2 are available for all UNIPHY (both DP and non-DP) and DAC
1564 *
1565 */
1566static int radeon_atom_pick_pll(struct drm_crtc *crtc) 1482static int radeon_atom_pick_pll(struct drm_crtc *crtc)
1567{ 1483{
1568 struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); 1484 struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
1569 struct drm_device *dev = crtc->dev; 1485 struct drm_device *dev = crtc->dev;
1570 struct radeon_device *rdev = dev->dev_private; 1486 struct radeon_device *rdev = dev->dev_private;
1571 struct drm_encoder *test_encoder; 1487 struct drm_encoder *test_encoder;
1572 u32 pll_in_use; 1488 struct drm_crtc *test_crtc;
1573 int pll; 1489 uint32_t pll_in_use = 0;
1574 1490
1575 if (ASIC_IS_DCE61(rdev)) { 1491 if (ASIC_IS_DCE61(rdev)) {
1576 list_for_each_entry(test_encoder, &dev->mode_config.encoder_list, head) { 1492 list_for_each_entry(test_encoder, &dev->mode_config.encoder_list, head) {
@@ -1582,40 +1498,32 @@ static int radeon_atom_pick_pll(struct drm_crtc *crtc)
1582 1498
1583 if ((test_radeon_encoder->encoder_id == 1499 if ((test_radeon_encoder->encoder_id ==
1584 ENCODER_OBJECT_ID_INTERNAL_UNIPHY) && 1500 ENCODER_OBJECT_ID_INTERNAL_UNIPHY) &&
1585 (dig->linkb == false)) 1501 (dig->linkb == false)) /* UNIPHY A uses PPLL2 */
1586 /* UNIPHY A uses PPLL2 */
1587 return ATOM_PPLL2; 1502 return ATOM_PPLL2;
1588 else if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(test_encoder))) {
1589 /* UNIPHY B/C/D/E/F */
1590 if (rdev->clock.dp_extclk)
1591 /* skip PPLL programming if using ext clock */
1592 return ATOM_PPLL_INVALID;
1593 else {
1594 /* use the same PPLL for all DP monitors */
1595 pll = radeon_get_shared_dp_ppll(crtc);
1596 if (pll != ATOM_PPLL_INVALID)
1597 return pll;
1598 }
1599 }
1600 break;
1601 } 1503 }
1602 } 1504 }
1603 /* UNIPHY B/C/D/E/F */ 1505 /* UNIPHY B/C/D/E/F */
1604 pll_in_use = radeon_get_pll_use_mask(crtc); 1506 list_for_each_entry(test_crtc, &dev->mode_config.crtc_list, head) {
1605 if (!(pll_in_use & (1 << ATOM_PPLL0))) 1507 struct radeon_crtc *radeon_test_crtc;
1508
1509 if (crtc == test_crtc)
1510 continue;
1511
1512 radeon_test_crtc = to_radeon_crtc(test_crtc);
1513 if ((radeon_test_crtc->pll_id == ATOM_PPLL0) ||
1514 (radeon_test_crtc->pll_id == ATOM_PPLL1))
1515 pll_in_use |= (1 << radeon_test_crtc->pll_id);
1516 }
1517 if (!(pll_in_use & 4))
1606 return ATOM_PPLL0; 1518 return ATOM_PPLL0;
1607 if (!(pll_in_use & (1 << ATOM_PPLL1))) 1519 return ATOM_PPLL1;
1608 return ATOM_PPLL1;
1609 DRM_ERROR("unable to allocate a PPLL\n");
1610 return ATOM_PPLL_INVALID;
1611 } else if (ASIC_IS_DCE4(rdev)) { 1520 } else if (ASIC_IS_DCE4(rdev)) {
1612 list_for_each_entry(test_encoder, &dev->mode_config.encoder_list, head) { 1521 list_for_each_entry(test_encoder, &dev->mode_config.encoder_list, head) {
1613 if (test_encoder->crtc && (test_encoder->crtc == crtc)) { 1522 if (test_encoder->crtc && (test_encoder->crtc == crtc)) {
1614 /* in DP mode, the DP ref clock can come from PPLL, DCPLL, or ext clock, 1523 /* in DP mode, the DP ref clock can come from PPLL, DCPLL, or ext clock,
1615 * depending on the asic: 1524 * depending on the asic:
1616 * DCE4: PPLL or ext clock 1525 * DCE4: PPLL or ext clock
1617 * DCE5: PPLL, DCPLL, or ext clock 1526 * DCE5: DCPLL or ext clock
1618 * DCE6: PPLL, PPLL0, or ext clock
1619 * 1527 *
1620 * Setting ATOM_PPLL_INVALID will cause SetPixelClock to skip 1528 * Setting ATOM_PPLL_INVALID will cause SetPixelClock to skip
1621 * PPLL/DCPLL programming and only program the DP DTO for the 1529 * PPLL/DCPLL programming and only program the DP DTO for the
@@ -1623,34 +1531,31 @@ static int radeon_atom_pick_pll(struct drm_crtc *crtc)
1623 */ 1531 */
1624 if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(test_encoder))) { 1532 if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(test_encoder))) {
1625 if (rdev->clock.dp_extclk) 1533 if (rdev->clock.dp_extclk)
1626 /* skip PPLL programming if using ext clock */
1627 return ATOM_PPLL_INVALID; 1534 return ATOM_PPLL_INVALID;
1628 else if (ASIC_IS_DCE6(rdev)) 1535 else if (ASIC_IS_DCE6(rdev))
1629 /* use PPLL0 for all DP */
1630 return ATOM_PPLL0; 1536 return ATOM_PPLL0;
1631 else if (ASIC_IS_DCE5(rdev)) 1537 else if (ASIC_IS_DCE5(rdev))
1632 /* use DCPLL for all DP */
1633 return ATOM_DCPLL; 1538 return ATOM_DCPLL;
1634 else {
1635 /* use the same PPLL for all DP monitors */
1636 pll = radeon_get_shared_dp_ppll(crtc);
1637 if (pll != ATOM_PPLL_INVALID)
1638 return pll;
1639 }
1640 } 1539 }
1641 break;
1642 } 1540 }
1643 } 1541 }
1644 /* all other cases */ 1542
1645 pll_in_use = radeon_get_pll_use_mask(crtc); 1543 /* otherwise, pick one of the plls */
1646 if (!(pll_in_use & (1 << ATOM_PPLL2))) 1544 list_for_each_entry(test_crtc, &dev->mode_config.crtc_list, head) {
1647 return ATOM_PPLL2; 1545 struct radeon_crtc *radeon_test_crtc;
1648 if (!(pll_in_use & (1 << ATOM_PPLL1))) 1546
1547 if (crtc == test_crtc)
1548 continue;
1549
1550 radeon_test_crtc = to_radeon_crtc(test_crtc);
1551 if ((radeon_test_crtc->pll_id >= ATOM_PPLL1) &&
1552 (radeon_test_crtc->pll_id <= ATOM_PPLL2))
1553 pll_in_use |= (1 << radeon_test_crtc->pll_id);
1554 }
1555 if (!(pll_in_use & 1))
1649 return ATOM_PPLL1; 1556 return ATOM_PPLL1;
1650 DRM_ERROR("unable to allocate a PPLL\n"); 1557 return ATOM_PPLL2;
1651 return ATOM_PPLL_INVALID;
1652 } else 1558 } else
1653 /* use PPLL1 or PPLL2 */
1654 return radeon_crtc->crtc_id; 1559 return radeon_crtc->crtc_id;
1655 1560
1656} 1561}
@@ -1792,7 +1697,7 @@ static void atombios_crtc_disable(struct drm_crtc *crtc)
1792 break; 1697 break;
1793 } 1698 }
1794done: 1699done:
1795 radeon_crtc->pll_id = ATOM_PPLL_INVALID; 1700 radeon_crtc->pll_id = -1;
1796} 1701}
1797 1702
1798static const struct drm_crtc_helper_funcs atombios_helper_funcs = { 1703static const struct drm_crtc_helper_funcs atombios_helper_funcs = {
@@ -1841,6 +1746,6 @@ void radeon_atombios_init_crtc(struct drm_device *dev,
1841 else 1746 else
1842 radeon_crtc->crtc_offset = 0; 1747 radeon_crtc->crtc_offset = 0;
1843 } 1748 }
1844 radeon_crtc->pll_id = ATOM_PPLL_INVALID; 1749 radeon_crtc->pll_id = -1;
1845 drm_crtc_helper_add(&radeon_crtc->base, &atombios_helper_funcs); 1750 drm_crtc_helper_add(&radeon_crtc->base, &atombios_helper_funcs);
1846} 1751}
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 8acb34fd3fd5..8d7e33a0b243 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -1182,7 +1182,8 @@ int r100_cp_init(struct radeon_device *rdev, unsigned ring_size)
1182 ring->ready = true; 1182 ring->ready = true;
1183 radeon_ttm_set_active_vram_size(rdev, rdev->mc.real_vram_size); 1183 radeon_ttm_set_active_vram_size(rdev, rdev->mc.real_vram_size);
1184 1184
1185 if (radeon_ring_supports_scratch_reg(rdev, ring)) { 1185 if (!ring->rptr_save_reg /* not resuming from suspend */
1186 && radeon_ring_supports_scratch_reg(rdev, ring)) {
1186 r = radeon_scratch_get(rdev, &ring->rptr_save_reg); 1187 r = radeon_scratch_get(rdev, &ring->rptr_save_reg);
1187 if (r) { 1188 if (r) {
1188 DRM_ERROR("failed to get scratch reg for rptr save (%d).\n", r); 1189 DRM_ERROR("failed to get scratch reg for rptr save (%d).\n", r);
diff --git a/drivers/gpu/drm/udl/udl_connector.c b/drivers/gpu/drm/udl/udl_connector.c
index ba055e9ca007..8d9dc44f1f94 100644
--- a/drivers/gpu/drm/udl/udl_connector.c
+++ b/drivers/gpu/drm/udl/udl_connector.c
@@ -69,6 +69,13 @@ static int udl_get_modes(struct drm_connector *connector)
69static int udl_mode_valid(struct drm_connector *connector, 69static int udl_mode_valid(struct drm_connector *connector,
70 struct drm_display_mode *mode) 70 struct drm_display_mode *mode)
71{ 71{
72 struct udl_device *udl = connector->dev->dev_private;
73 if (!udl->sku_pixel_limit)
74 return 0;
75
76 if (mode->vdisplay * mode->hdisplay > udl->sku_pixel_limit)
77 return MODE_VIRTUAL_Y;
78
72 return 0; 79 return 0;
73} 80}
74 81
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
index f2fb8f15e2f1..7e0743358dff 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
@@ -1018,7 +1018,7 @@ int vmw_event_fence_action_create(struct drm_file *file_priv,
1018 } 1018 }
1019 1019
1020 1020
1021 event = kzalloc(sizeof(event->event), GFP_KERNEL); 1021 event = kzalloc(sizeof(*event), GFP_KERNEL);
1022 if (unlikely(event == NULL)) { 1022 if (unlikely(event == NULL)) {
1023 DRM_ERROR("Failed to allocate an event.\n"); 1023 DRM_ERROR("Failed to allocate an event.\n");
1024 ret = -ENOMEM; 1024 ret = -ENOMEM;
diff --git a/drivers/hid/hid-lenovo-tpkbd.c b/drivers/hid/hid-lenovo-tpkbd.c
index 77d2df04c97b..60c4e1e85913 100644
--- a/drivers/hid/hid-lenovo-tpkbd.c
+++ b/drivers/hid/hid-lenovo-tpkbd.c
@@ -519,6 +519,8 @@ static void tpkbd_remove_tp(struct hid_device *hdev)
519 led_classdev_unregister(&data_pointer->led_mute); 519 led_classdev_unregister(&data_pointer->led_mute);
520 520
521 hid_set_drvdata(hdev, NULL); 521 hid_set_drvdata(hdev, NULL);
522 kfree(data_pointer->led_micmute.name);
523 kfree(data_pointer->led_mute.name);
522 kfree(data_pointer); 524 kfree(data_pointer);
523} 525}
524 526
diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
index 4d524b5f52f5..9500f2f3f8fe 100644
--- a/drivers/hid/hid-logitech-dj.c
+++ b/drivers/hid/hid-logitech-dj.c
@@ -193,6 +193,7 @@ static struct hid_ll_driver logi_dj_ll_driver;
193static int logi_dj_output_hidraw_report(struct hid_device *hid, u8 * buf, 193static int logi_dj_output_hidraw_report(struct hid_device *hid, u8 * buf,
194 size_t count, 194 size_t count,
195 unsigned char report_type); 195 unsigned char report_type);
196static int logi_dj_recv_query_paired_devices(struct dj_receiver_dev *djrcv_dev);
196 197
197static void logi_dj_recv_destroy_djhid_device(struct dj_receiver_dev *djrcv_dev, 198static void logi_dj_recv_destroy_djhid_device(struct dj_receiver_dev *djrcv_dev,
198 struct dj_report *dj_report) 199 struct dj_report *dj_report)
@@ -233,6 +234,7 @@ static void logi_dj_recv_add_djhid_device(struct dj_receiver_dev *djrcv_dev,
233 if (dj_report->report_params[DEVICE_PAIRED_PARAM_SPFUNCTION] & 234 if (dj_report->report_params[DEVICE_PAIRED_PARAM_SPFUNCTION] &
234 SPFUNCTION_DEVICE_LIST_EMPTY) { 235 SPFUNCTION_DEVICE_LIST_EMPTY) {
235 dbg_hid("%s: device list is empty\n", __func__); 236 dbg_hid("%s: device list is empty\n", __func__);
237 djrcv_dev->querying_devices = false;
236 return; 238 return;
237 } 239 }
238 240
@@ -243,6 +245,12 @@ static void logi_dj_recv_add_djhid_device(struct dj_receiver_dev *djrcv_dev,
243 return; 245 return;
244 } 246 }
245 247
248 if (djrcv_dev->paired_dj_devices[dj_report->device_index]) {
249 /* The device is already known. No need to reallocate it. */
250 dbg_hid("%s: device is already known\n", __func__);
251 return;
252 }
253
246 dj_hiddev = hid_allocate_device(); 254 dj_hiddev = hid_allocate_device();
247 if (IS_ERR(dj_hiddev)) { 255 if (IS_ERR(dj_hiddev)) {
248 dev_err(&djrcv_hdev->dev, "%s: hid_allocate_device failed\n", 256 dev_err(&djrcv_hdev->dev, "%s: hid_allocate_device failed\n",
@@ -306,6 +314,7 @@ static void delayedwork_callback(struct work_struct *work)
306 struct dj_report dj_report; 314 struct dj_report dj_report;
307 unsigned long flags; 315 unsigned long flags;
308 int count; 316 int count;
317 int retval;
309 318
310 dbg_hid("%s\n", __func__); 319 dbg_hid("%s\n", __func__);
311 320
@@ -338,6 +347,25 @@ static void delayedwork_callback(struct work_struct *work)
338 logi_dj_recv_destroy_djhid_device(djrcv_dev, &dj_report); 347 logi_dj_recv_destroy_djhid_device(djrcv_dev, &dj_report);
339 break; 348 break;
340 default: 349 default:
350 /* A normal report (i. e. not belonging to a pair/unpair notification)
351 * arriving here, means that the report arrived but we did not have a
352 * paired dj_device associated to the report's device_index, this
353 * means that the original "device paired" notification corresponding
354 * to this dj_device never arrived to this driver. The reason is that
355 * hid-core discards all packets coming from a device while probe() is
356 * executing. */
357 if (!djrcv_dev->paired_dj_devices[dj_report.device_index]) {
358 /* ok, we don't know the device, just re-ask the
359 * receiver for the list of connected devices. */
360 retval = logi_dj_recv_query_paired_devices(djrcv_dev);
361 if (!retval) {
362 /* everything went fine, so just leave */
363 break;
364 }
365 dev_err(&djrcv_dev->hdev->dev,
366 "%s:logi_dj_recv_query_paired_devices "
367 "error:%d\n", __func__, retval);
368 }
341 dbg_hid("%s: unexpected report type\n", __func__); 369 dbg_hid("%s: unexpected report type\n", __func__);
342 } 370 }
343} 371}
@@ -368,6 +396,12 @@ static void logi_dj_recv_forward_null_report(struct dj_receiver_dev *djrcv_dev,
368 if (!djdev) { 396 if (!djdev) {
369 dbg_hid("djrcv_dev->paired_dj_devices[dj_report->device_index]" 397 dbg_hid("djrcv_dev->paired_dj_devices[dj_report->device_index]"
370 " is NULL, index %d\n", dj_report->device_index); 398 " is NULL, index %d\n", dj_report->device_index);
399 kfifo_in(&djrcv_dev->notif_fifo, dj_report, sizeof(struct dj_report));
400
401 if (schedule_work(&djrcv_dev->work) == 0) {
402 dbg_hid("%s: did not schedule the work item, was already "
403 "queued\n", __func__);
404 }
371 return; 405 return;
372 } 406 }
373 407
@@ -398,6 +432,12 @@ static void logi_dj_recv_forward_report(struct dj_receiver_dev *djrcv_dev,
398 if (dj_device == NULL) { 432 if (dj_device == NULL) {
399 dbg_hid("djrcv_dev->paired_dj_devices[dj_report->device_index]" 433 dbg_hid("djrcv_dev->paired_dj_devices[dj_report->device_index]"
400 " is NULL, index %d\n", dj_report->device_index); 434 " is NULL, index %d\n", dj_report->device_index);
435 kfifo_in(&djrcv_dev->notif_fifo, dj_report, sizeof(struct dj_report));
436
437 if (schedule_work(&djrcv_dev->work) == 0) {
438 dbg_hid("%s: did not schedule the work item, was already "
439 "queued\n", __func__);
440 }
401 return; 441 return;
402 } 442 }
403 443
@@ -439,6 +479,10 @@ static int logi_dj_recv_query_paired_devices(struct dj_receiver_dev *djrcv_dev)
439 struct dj_report *dj_report; 479 struct dj_report *dj_report;
440 int retval; 480 int retval;
441 481
482 /* no need to protect djrcv_dev->querying_devices */
483 if (djrcv_dev->querying_devices)
484 return 0;
485
442 dj_report = kzalloc(sizeof(struct dj_report), GFP_KERNEL); 486 dj_report = kzalloc(sizeof(struct dj_report), GFP_KERNEL);
443 if (!dj_report) 487 if (!dj_report)
444 return -ENOMEM; 488 return -ENOMEM;
@@ -450,6 +494,7 @@ static int logi_dj_recv_query_paired_devices(struct dj_receiver_dev *djrcv_dev)
450 return retval; 494 return retval;
451} 495}
452 496
497
453static int logi_dj_recv_switch_to_dj_mode(struct dj_receiver_dev *djrcv_dev, 498static int logi_dj_recv_switch_to_dj_mode(struct dj_receiver_dev *djrcv_dev,
454 unsigned timeout) 499 unsigned timeout)
455{ 500{
diff --git a/drivers/hid/hid-logitech-dj.h b/drivers/hid/hid-logitech-dj.h
index fd28a5e0ca3b..4a4000340ce1 100644
--- a/drivers/hid/hid-logitech-dj.h
+++ b/drivers/hid/hid-logitech-dj.h
@@ -101,6 +101,7 @@ struct dj_receiver_dev {
101 struct work_struct work; 101 struct work_struct work;
102 struct kfifo notif_fifo; 102 struct kfifo notif_fifo;
103 spinlock_t lock; 103 spinlock_t lock;
104 bool querying_devices;
104}; 105};
105 106
106struct dj_device { 107struct dj_device {
diff --git a/drivers/hwmon/ad7314.c b/drivers/hwmon/ad7314.c
index cfec802cf9ca..f915eb1c29f7 100644
--- a/drivers/hwmon/ad7314.c
+++ b/drivers/hwmon/ad7314.c
@@ -87,10 +87,18 @@ static ssize_t ad7314_show_temperature(struct device *dev,
87 } 87 }
88} 88}
89 89
90static ssize_t ad7314_show_name(struct device *dev,
91 struct device_attribute *devattr, char *buf)
92{
93 return sprintf(buf, "%s\n", to_spi_device(dev)->modalias);
94}
95
96static DEVICE_ATTR(name, S_IRUGO, ad7314_show_name, NULL);
90static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, 97static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO,
91 ad7314_show_temperature, NULL, 0); 98 ad7314_show_temperature, NULL, 0);
92 99
93static struct attribute *ad7314_attributes[] = { 100static struct attribute *ad7314_attributes[] = {
101 &dev_attr_name.attr,
94 &sensor_dev_attr_temp1_input.dev_attr.attr, 102 &sensor_dev_attr_temp1_input.dev_attr.attr,
95 NULL, 103 NULL,
96}; 104};
diff --git a/drivers/hwmon/ads7871.c b/drivers/hwmon/ads7871.c
index e65c6e45d36b..7bf4ce3d405e 100644
--- a/drivers/hwmon/ads7871.c
+++ b/drivers/hwmon/ads7871.c
@@ -139,6 +139,12 @@ static ssize_t show_voltage(struct device *dev,
139 } 139 }
140} 140}
141 141
142static ssize_t ads7871_show_name(struct device *dev,
143 struct device_attribute *devattr, char *buf)
144{
145 return sprintf(buf, "%s\n", to_spi_device(dev)->modalias);
146}
147
142static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, show_voltage, NULL, 0); 148static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, show_voltage, NULL, 0);
143static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_voltage, NULL, 1); 149static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_voltage, NULL, 1);
144static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_voltage, NULL, 2); 150static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_voltage, NULL, 2);
@@ -148,6 +154,8 @@ static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, show_voltage, NULL, 5);
148static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, show_voltage, NULL, 6); 154static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, show_voltage, NULL, 6);
149static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, show_voltage, NULL, 7); 155static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, show_voltage, NULL, 7);
150 156
157static DEVICE_ATTR(name, S_IRUGO, ads7871_show_name, NULL);
158
151static struct attribute *ads7871_attributes[] = { 159static struct attribute *ads7871_attributes[] = {
152 &sensor_dev_attr_in0_input.dev_attr.attr, 160 &sensor_dev_attr_in0_input.dev_attr.attr,
153 &sensor_dev_attr_in1_input.dev_attr.attr, 161 &sensor_dev_attr_in1_input.dev_attr.attr,
@@ -157,6 +165,7 @@ static struct attribute *ads7871_attributes[] = {
157 &sensor_dev_attr_in5_input.dev_attr.attr, 165 &sensor_dev_attr_in5_input.dev_attr.attr,
158 &sensor_dev_attr_in6_input.dev_attr.attr, 166 &sensor_dev_attr_in6_input.dev_attr.attr,
159 &sensor_dev_attr_in7_input.dev_attr.attr, 167 &sensor_dev_attr_in7_input.dev_attr.attr,
168 &dev_attr_name.attr,
160 NULL 169 NULL
161}; 170};
162 171
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index 282708860517..8f3f6f2c45fd 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -53,10 +53,10 @@
53 53
54#define APPLESMC_MAX_DATA_LENGTH 32 54#define APPLESMC_MAX_DATA_LENGTH 32
55 55
56/* wait up to 32 ms for a status change. */ 56/* wait up to 128 ms for a status change. */
57#define APPLESMC_MIN_WAIT 0x0010 57#define APPLESMC_MIN_WAIT 0x0010
58#define APPLESMC_RETRY_WAIT 0x0100 58#define APPLESMC_RETRY_WAIT 0x0100
59#define APPLESMC_MAX_WAIT 0x8000 59#define APPLESMC_MAX_WAIT 0x20000
60 60
61#define APPLESMC_READ_CMD 0x10 61#define APPLESMC_READ_CMD 0x10
62#define APPLESMC_WRITE_CMD 0x11 62#define APPLESMC_WRITE_CMD 0x11
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 0fa356fe82cc..984a3f13923b 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -815,17 +815,20 @@ static int __init coretemp_init(void)
815 if (err) 815 if (err)
816 goto exit; 816 goto exit;
817 817
818 get_online_cpus();
818 for_each_online_cpu(i) 819 for_each_online_cpu(i)
819 get_core_online(i); 820 get_core_online(i);
820 821
821#ifndef CONFIG_HOTPLUG_CPU 822#ifndef CONFIG_HOTPLUG_CPU
822 if (list_empty(&pdev_list)) { 823 if (list_empty(&pdev_list)) {
824 put_online_cpus();
823 err = -ENODEV; 825 err = -ENODEV;
824 goto exit_driver_unreg; 826 goto exit_driver_unreg;
825 } 827 }
826#endif 828#endif
827 829
828 register_hotcpu_notifier(&coretemp_cpu_notifier); 830 register_hotcpu_notifier(&coretemp_cpu_notifier);
831 put_online_cpus();
829 return 0; 832 return 0;
830 833
831#ifndef CONFIG_HOTPLUG_CPU 834#ifndef CONFIG_HOTPLUG_CPU
@@ -840,6 +843,7 @@ static void __exit coretemp_exit(void)
840{ 843{
841 struct pdev_entry *p, *n; 844 struct pdev_entry *p, *n;
842 845
846 get_online_cpus();
843 unregister_hotcpu_notifier(&coretemp_cpu_notifier); 847 unregister_hotcpu_notifier(&coretemp_cpu_notifier);
844 mutex_lock(&pdev_list_mutex); 848 mutex_lock(&pdev_list_mutex);
845 list_for_each_entry_safe(p, n, &pdev_list, list) { 849 list_for_each_entry_safe(p, n, &pdev_list, list) {
@@ -848,6 +852,7 @@ static void __exit coretemp_exit(void)
848 kfree(p); 852 kfree(p);
849 } 853 }
850 mutex_unlock(&pdev_list_mutex); 854 mutex_unlock(&pdev_list_mutex);
855 put_online_cpus();
851 platform_driver_unregister(&coretemp_driver); 856 platform_driver_unregister(&coretemp_driver);
852} 857}
853 858
diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c
index 2764b78a784b..af69073b3fe8 100644
--- a/drivers/hwmon/fam15h_power.c
+++ b/drivers/hwmon/fam15h_power.c
@@ -129,12 +129,12 @@ static bool __devinit fam15h_power_is_internal_node0(struct pci_dev *f4)
129 * counter saturations resulting in bogus power readings. 129 * counter saturations resulting in bogus power readings.
130 * We correct this value ourselves to cope with older BIOSes. 130 * We correct this value ourselves to cope with older BIOSes.
131 */ 131 */
132static DEFINE_PCI_DEVICE_TABLE(affected_device) = { 132static const struct pci_device_id affected_device[] = {
133 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F4) }, 133 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F4) },
134 { 0 } 134 { 0 }
135}; 135};
136 136
137static void __devinit tweak_runavg_range(struct pci_dev *pdev) 137static void tweak_runavg_range(struct pci_dev *pdev)
138{ 138{
139 u32 val; 139 u32 val;
140 140
@@ -158,6 +158,16 @@ static void __devinit tweak_runavg_range(struct pci_dev *pdev)
158 REG_TDP_RUNNING_AVERAGE, val); 158 REG_TDP_RUNNING_AVERAGE, val);
159} 159}
160 160
161#ifdef CONFIG_PM
162static int fam15h_power_resume(struct pci_dev *pdev)
163{
164 tweak_runavg_range(pdev);
165 return 0;
166}
167#else
168#define fam15h_power_resume NULL
169#endif
170
161static void __devinit fam15h_power_init_data(struct pci_dev *f4, 171static void __devinit fam15h_power_init_data(struct pci_dev *f4,
162 struct fam15h_power_data *data) 172 struct fam15h_power_data *data)
163{ 173{
@@ -256,6 +266,7 @@ static struct pci_driver fam15h_power_driver = {
256 .id_table = fam15h_power_id_table, 266 .id_table = fam15h_power_id_table,
257 .probe = fam15h_power_probe, 267 .probe = fam15h_power_probe,
258 .remove = __devexit_p(fam15h_power_remove), 268 .remove = __devexit_p(fam15h_power_remove),
269 .resume = fam15h_power_resume,
259}; 270};
260 271
261module_pci_driver(fam15h_power_driver); 272module_pci_driver(fam15h_power_driver);
diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
index ee4ebc198a94..2e56c6ce9fb6 100644
--- a/drivers/hwmon/via-cputemp.c
+++ b/drivers/hwmon/via-cputemp.c
@@ -328,6 +328,7 @@ static int __init via_cputemp_init(void)
328 if (err) 328 if (err)
329 goto exit; 329 goto exit;
330 330
331 get_online_cpus();
331 for_each_online_cpu(i) { 332 for_each_online_cpu(i) {
332 struct cpuinfo_x86 *c = &cpu_data(i); 333 struct cpuinfo_x86 *c = &cpu_data(i);
333 334
@@ -347,12 +348,14 @@ static int __init via_cputemp_init(void)
347 348
348#ifndef CONFIG_HOTPLUG_CPU 349#ifndef CONFIG_HOTPLUG_CPU
349 if (list_empty(&pdev_list)) { 350 if (list_empty(&pdev_list)) {
351 put_online_cpus();
350 err = -ENODEV; 352 err = -ENODEV;
351 goto exit_driver_unreg; 353 goto exit_driver_unreg;
352 } 354 }
353#endif 355#endif
354 356
355 register_hotcpu_notifier(&via_cputemp_cpu_notifier); 357 register_hotcpu_notifier(&via_cputemp_cpu_notifier);
358 put_online_cpus();
356 return 0; 359 return 0;
357 360
358#ifndef CONFIG_HOTPLUG_CPU 361#ifndef CONFIG_HOTPLUG_CPU
@@ -367,6 +370,7 @@ static void __exit via_cputemp_exit(void)
367{ 370{
368 struct pdev_entry *p, *n; 371 struct pdev_entry *p, *n;
369 372
373 get_online_cpus();
370 unregister_hotcpu_notifier(&via_cputemp_cpu_notifier); 374 unregister_hotcpu_notifier(&via_cputemp_cpu_notifier);
371 mutex_lock(&pdev_list_mutex); 375 mutex_lock(&pdev_list_mutex);
372 list_for_each_entry_safe(p, n, &pdev_list, list) { 376 list_for_each_entry_safe(p, n, &pdev_list, list) {
@@ -375,6 +379,7 @@ static void __exit via_cputemp_exit(void)
375 kfree(p); 379 kfree(p);
376 } 380 }
377 mutex_unlock(&pdev_list_mutex); 381 mutex_unlock(&pdev_list_mutex);
382 put_online_cpus();
378 platform_driver_unregister(&via_cputemp_driver); 383 platform_driver_unregister(&via_cputemp_driver);
379} 384}
380 385
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index e8726177d103..b0f6b4c8ee14 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -413,6 +413,7 @@ static const struct x86_cpu_id intel_idle_ids[] = {
413 ICPU(0x2a, idle_cpu_snb), 413 ICPU(0x2a, idle_cpu_snb),
414 ICPU(0x2d, idle_cpu_snb), 414 ICPU(0x2d, idle_cpu_snb),
415 ICPU(0x3a, idle_cpu_ivb), 415 ICPU(0x3a, idle_cpu_ivb),
416 ICPU(0x3e, idle_cpu_ivb),
416 {} 417 {}
417}; 418};
418MODULE_DEVICE_TABLE(x86cpu, intel_idle_ids); 419MODULE_DEVICE_TABLE(x86cpu, intel_idle_ids);
diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c
index ce68e361558c..cdc252612c0b 100644
--- a/drivers/input/keyboard/imx_keypad.c
+++ b/drivers/input/keyboard/imx_keypad.c
@@ -516,9 +516,9 @@ static int __devinit imx_keypad_probe(struct platform_device *pdev)
516 input_set_drvdata(input_dev, keypad); 516 input_set_drvdata(input_dev, keypad);
517 517
518 /* Ensure that the keypad will stay dormant until opened */ 518 /* Ensure that the keypad will stay dormant until opened */
519 clk_enable(keypad->clk); 519 clk_prepare_enable(keypad->clk);
520 imx_keypad_inhibit(keypad); 520 imx_keypad_inhibit(keypad);
521 clk_disable(keypad->clk); 521 clk_disable_unprepare(keypad->clk);
522 522
523 error = request_irq(irq, imx_keypad_irq_handler, 0, 523 error = request_irq(irq, imx_keypad_irq_handler, 0,
524 pdev->name, keypad); 524 pdev->name, keypad);
diff --git a/drivers/input/misc/ab8500-ponkey.c b/drivers/input/misc/ab8500-ponkey.c
index f06231b7cab1..84ec691c05aa 100644
--- a/drivers/input/misc/ab8500-ponkey.c
+++ b/drivers/input/misc/ab8500-ponkey.c
@@ -74,8 +74,8 @@ static int __devinit ab8500_ponkey_probe(struct platform_device *pdev)
74 74
75 ponkey->idev = input; 75 ponkey->idev = input;
76 ponkey->ab8500 = ab8500; 76 ponkey->ab8500 = ab8500;
77 ponkey->irq_dbf = ab8500_irq_get_virq(ab8500, irq_dbf); 77 ponkey->irq_dbf = irq_dbf;
78 ponkey->irq_dbr = ab8500_irq_get_virq(ab8500, irq_dbr); 78 ponkey->irq_dbr = irq_dbr;
79 79
80 input->name = "AB8500 POn(PowerOn) Key"; 80 input->name = "AB8500 POn(PowerOn) Key";
81 input->dev.parent = &pdev->dev; 81 input->dev.parent = &pdev->dev;
diff --git a/drivers/input/mouse/sentelic.c b/drivers/input/mouse/sentelic.c
index 3f5649f19082..a261d8576919 100644
--- a/drivers/input/mouse/sentelic.c
+++ b/drivers/input/mouse/sentelic.c
@@ -721,6 +721,17 @@ static psmouse_ret_t fsp_process_byte(struct psmouse *psmouse)
721 721
722 switch (psmouse->packet[0] >> FSP_PKT_TYPE_SHIFT) { 722 switch (psmouse->packet[0] >> FSP_PKT_TYPE_SHIFT) {
723 case FSP_PKT_TYPE_ABS: 723 case FSP_PKT_TYPE_ABS:
724
725 if ((packet[0] == 0x48 || packet[0] == 0x49) &&
726 packet[1] == 0 && packet[2] == 0) {
727 /*
728 * Ignore coordinate noise when finger leaving the
729 * surface, otherwise cursor may jump to upper-left
730 * corner.
731 */
732 packet[3] &= 0xf0;
733 }
734
724 abs_x = GET_ABS_X(packet); 735 abs_x = GET_ABS_X(packet);
725 abs_y = GET_ABS_Y(packet); 736 abs_y = GET_ABS_Y(packet);
726 737
diff --git a/drivers/input/serio/ambakmi.c b/drivers/input/serio/ambakmi.c
index 2ffd110bd5bc..2e77246c2e5a 100644
--- a/drivers/input/serio/ambakmi.c
+++ b/drivers/input/serio/ambakmi.c
@@ -72,7 +72,7 @@ static int amba_kmi_open(struct serio *io)
72 unsigned int divisor; 72 unsigned int divisor;
73 int ret; 73 int ret;
74 74
75 ret = clk_enable(kmi->clk); 75 ret = clk_prepare_enable(kmi->clk);
76 if (ret) 76 if (ret)
77 goto out; 77 goto out;
78 78
@@ -92,7 +92,7 @@ static int amba_kmi_open(struct serio *io)
92 return 0; 92 return 0;
93 93
94 clk_disable: 94 clk_disable:
95 clk_disable(kmi->clk); 95 clk_disable_unprepare(kmi->clk);
96 out: 96 out:
97 return ret; 97 return ret;
98} 98}
@@ -104,7 +104,7 @@ static void amba_kmi_close(struct serio *io)
104 writeb(0, KMICR); 104 writeb(0, KMICR);
105 105
106 free_irq(kmi->irq, kmi); 106 free_irq(kmi->irq, kmi);
107 clk_disable(kmi->clk); 107 clk_disable_unprepare(kmi->clk);
108} 108}
109 109
110static int __devinit amba_kmi_probe(struct amba_device *dev, 110static int __devinit amba_kmi_probe(struct amba_device *dev,
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index 6918773ce024..d6cc77a53c7e 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -335,6 +335,12 @@ static const struct dmi_system_id __initconst i8042_dmi_nomux_table[] = {
335 }, 335 },
336 { 336 {
337 .matches = { 337 .matches = {
338 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
339 DMI_MATCH(DMI_PRODUCT_NAME, "SATELLITE C850D"),
340 },
341 },
342 {
343 .matches = {
338 DMI_MATCH(DMI_SYS_VENDOR, "ALIENWARE"), 344 DMI_MATCH(DMI_SYS_VENDOR, "ALIENWARE"),
339 DMI_MATCH(DMI_PRODUCT_NAME, "Sentia"), 345 DMI_MATCH(DMI_PRODUCT_NAME, "Sentia"),
340 }, 346 },
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index b06a5e3a665e..64957770b522 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -566,9 +566,12 @@ static ssize_t edt_ft5x06_debugfs_raw_data_read(struct file *file,
566 } 566 }
567 567
568 read = min_t(size_t, count, tsdata->raw_bufsize - *off); 568 read = min_t(size_t, count, tsdata->raw_bufsize - *off);
569 error = copy_to_user(buf, tsdata->raw_buffer + *off, read); 569 if (copy_to_user(buf, tsdata->raw_buffer + *off, read)) {
570 if (!error) 570 error = -EFAULT;
571 *off += read; 571 goto out;
572 }
573
574 *off += read;
572out: 575out:
573 mutex_unlock(&tsdata->mutex); 576 mutex_unlock(&tsdata->mutex);
574 return error ?: read; 577 return error ?: read;
diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
index e32709e0dd65..721fdb3597ca 100644
--- a/drivers/input/touchscreen/usbtouchscreen.c
+++ b/drivers/input/touchscreen/usbtouchscreen.c
@@ -304,6 +304,45 @@ static int e2i_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
304#define EGALAX_PKT_TYPE_REPT 0x80 304#define EGALAX_PKT_TYPE_REPT 0x80
305#define EGALAX_PKT_TYPE_DIAG 0x0A 305#define EGALAX_PKT_TYPE_DIAG 0x0A
306 306
307static int egalax_init(struct usbtouch_usb *usbtouch)
308{
309 int ret, i;
310 unsigned char *buf;
311 struct usb_device *udev = interface_to_usbdev(usbtouch->interface);
312
313 /*
314 * An eGalax diagnostic packet kicks the device into using the right
315 * protocol. We send a "check active" packet. The response will be
316 * read later and ignored.
317 */
318
319 buf = kmalloc(3, GFP_KERNEL);
320 if (!buf)
321 return -ENOMEM;
322
323 buf[0] = EGALAX_PKT_TYPE_DIAG;
324 buf[1] = 1; /* length */
325 buf[2] = 'A'; /* command - check active */
326
327 for (i = 0; i < 3; i++) {
328 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
329 0,
330 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
331 0, 0, buf, 3,
332 USB_CTRL_SET_TIMEOUT);
333 if (ret >= 0) {
334 ret = 0;
335 break;
336 }
337 if (ret != -EPIPE)
338 break;
339 }
340
341 kfree(buf);
342
343 return ret;
344}
345
307static int egalax_read_data(struct usbtouch_usb *dev, unsigned char *pkt) 346static int egalax_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
308{ 347{
309 if ((pkt[0] & EGALAX_PKT_TYPE_MASK) != EGALAX_PKT_TYPE_REPT) 348 if ((pkt[0] & EGALAX_PKT_TYPE_MASK) != EGALAX_PKT_TYPE_REPT)
@@ -1056,6 +1095,7 @@ static struct usbtouch_device_info usbtouch_dev_info[] = {
1056 .process_pkt = usbtouch_process_multi, 1095 .process_pkt = usbtouch_process_multi,
1057 .get_pkt_len = egalax_get_pkt_len, 1096 .get_pkt_len = egalax_get_pkt_len,
1058 .read_data = egalax_read_data, 1097 .read_data = egalax_read_data,
1098 .init = egalax_init,
1059 }, 1099 },
1060#endif 1100#endif
1061 1101
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index b64502dfa9f4..e89daf1b21b4 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -266,7 +266,7 @@ static void swap_pci_ref(struct pci_dev **from, struct pci_dev *to)
266 266
267static int iommu_init_device(struct device *dev) 267static int iommu_init_device(struct device *dev)
268{ 268{
269 struct pci_dev *dma_pdev, *pdev = to_pci_dev(dev); 269 struct pci_dev *dma_pdev = NULL, *pdev = to_pci_dev(dev);
270 struct iommu_dev_data *dev_data; 270 struct iommu_dev_data *dev_data;
271 struct iommu_group *group; 271 struct iommu_group *group;
272 u16 alias; 272 u16 alias;
@@ -293,7 +293,9 @@ static int iommu_init_device(struct device *dev)
293 dev_data->alias_data = alias_data; 293 dev_data->alias_data = alias_data;
294 294
295 dma_pdev = pci_get_bus_and_slot(alias >> 8, alias & 0xff); 295 dma_pdev = pci_get_bus_and_slot(alias >> 8, alias & 0xff);
296 } else 296 }
297
298 if (dma_pdev == NULL)
297 dma_pdev = pci_dev_get(pdev); 299 dma_pdev = pci_dev_get(pdev);
298 300
299 /* Account for quirked devices */ 301 /* Account for quirked devices */
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index d8abb90a6c2f..034233eefc82 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -1555,6 +1555,7 @@ static int multipath_ioctl(struct dm_target *ti, unsigned int cmd,
1555 unsigned long arg) 1555 unsigned long arg)
1556{ 1556{
1557 struct multipath *m = ti->private; 1557 struct multipath *m = ti->private;
1558 struct pgpath *pgpath;
1558 struct block_device *bdev; 1559 struct block_device *bdev;
1559 fmode_t mode; 1560 fmode_t mode;
1560 unsigned long flags; 1561 unsigned long flags;
@@ -1570,12 +1571,14 @@ again:
1570 if (!m->current_pgpath) 1571 if (!m->current_pgpath)
1571 __choose_pgpath(m, 0); 1572 __choose_pgpath(m, 0);
1572 1573
1573 if (m->current_pgpath) { 1574 pgpath = m->current_pgpath;
1574 bdev = m->current_pgpath->path.dev->bdev; 1575
1575 mode = m->current_pgpath->path.dev->mode; 1576 if (pgpath) {
1577 bdev = pgpath->path.dev->bdev;
1578 mode = pgpath->path.dev->mode;
1576 } 1579 }
1577 1580
1578 if (m->queue_io) 1581 if ((pgpath && m->queue_io) || (!pgpath && m->queue_if_no_path))
1579 r = -EAGAIN; 1582 r = -EAGAIN;
1580 else if (!bdev) 1583 else if (!bdev)
1581 r = -EIO; 1584 r = -EIO;
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index f90069029aae..100368eb7991 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -1212,6 +1212,41 @@ struct dm_target *dm_table_find_target(struct dm_table *t, sector_t sector)
1212 return &t->targets[(KEYS_PER_NODE * n) + k]; 1212 return &t->targets[(KEYS_PER_NODE * n) + k];
1213} 1213}
1214 1214
1215static int count_device(struct dm_target *ti, struct dm_dev *dev,
1216 sector_t start, sector_t len, void *data)
1217{
1218 unsigned *num_devices = data;
1219
1220 (*num_devices)++;
1221
1222 return 0;
1223}
1224
1225/*
1226 * Check whether a table has no data devices attached using each
1227 * target's iterate_devices method.
1228 * Returns false if the result is unknown because a target doesn't
1229 * support iterate_devices.
1230 */
1231bool dm_table_has_no_data_devices(struct dm_table *table)
1232{
1233 struct dm_target *uninitialized_var(ti);
1234 unsigned i = 0, num_devices = 0;
1235
1236 while (i < dm_table_get_num_targets(table)) {
1237 ti = dm_table_get_target(table, i++);
1238
1239 if (!ti->type->iterate_devices)
1240 return false;
1241
1242 ti->type->iterate_devices(ti, count_device, &num_devices);
1243 if (num_devices)
1244 return false;
1245 }
1246
1247 return true;
1248}
1249
1215/* 1250/*
1216 * Establish the new table's queue_limits and validate them. 1251 * Establish the new table's queue_limits and validate them.
1217 */ 1252 */
@@ -1354,17 +1389,25 @@ static int device_is_nonrot(struct dm_target *ti, struct dm_dev *dev,
1354 return q && blk_queue_nonrot(q); 1389 return q && blk_queue_nonrot(q);
1355} 1390}
1356 1391
1357static bool dm_table_is_nonrot(struct dm_table *t) 1392static int device_is_not_random(struct dm_target *ti, struct dm_dev *dev,
1393 sector_t start, sector_t len, void *data)
1394{
1395 struct request_queue *q = bdev_get_queue(dev->bdev);
1396
1397 return q && !blk_queue_add_random(q);
1398}
1399
1400static bool dm_table_all_devices_attribute(struct dm_table *t,
1401 iterate_devices_callout_fn func)
1358{ 1402{
1359 struct dm_target *ti; 1403 struct dm_target *ti;
1360 unsigned i = 0; 1404 unsigned i = 0;
1361 1405
1362 /* Ensure that all underlying device are non-rotational. */
1363 while (i < dm_table_get_num_targets(t)) { 1406 while (i < dm_table_get_num_targets(t)) {
1364 ti = dm_table_get_target(t, i++); 1407 ti = dm_table_get_target(t, i++);
1365 1408
1366 if (!ti->type->iterate_devices || 1409 if (!ti->type->iterate_devices ||
1367 !ti->type->iterate_devices(ti, device_is_nonrot, NULL)) 1410 !ti->type->iterate_devices(ti, func, NULL))
1368 return 0; 1411 return 0;
1369 } 1412 }
1370 1413
@@ -1396,7 +1439,8 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
1396 if (!dm_table_discard_zeroes_data(t)) 1439 if (!dm_table_discard_zeroes_data(t))
1397 q->limits.discard_zeroes_data = 0; 1440 q->limits.discard_zeroes_data = 0;
1398 1441
1399 if (dm_table_is_nonrot(t)) 1442 /* Ensure that all underlying devices are non-rotational. */
1443 if (dm_table_all_devices_attribute(t, device_is_nonrot))
1400 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q); 1444 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q);
1401 else 1445 else
1402 queue_flag_clear_unlocked(QUEUE_FLAG_NONROT, q); 1446 queue_flag_clear_unlocked(QUEUE_FLAG_NONROT, q);
@@ -1404,6 +1448,15 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
1404 dm_table_set_integrity(t); 1448 dm_table_set_integrity(t);
1405 1449
1406 /* 1450 /*
1451 * Determine whether or not this queue's I/O timings contribute
1452 * to the entropy pool, Only request-based targets use this.
1453 * Clear QUEUE_FLAG_ADD_RANDOM if any underlying device does not
1454 * have it set.
1455 */
1456 if (blk_queue_add_random(q) && dm_table_all_devices_attribute(t, device_is_not_random))
1457 queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, q);
1458
1459 /*
1407 * QUEUE_FLAG_STACKABLE must be set after all queue settings are 1460 * QUEUE_FLAG_STACKABLE must be set after all queue settings are
1408 * visible to other CPUs because, once the flag is set, incoming bios 1461 * visible to other CPUs because, once the flag is set, incoming bios
1409 * are processed by request-based dm, which refers to the queue 1462 * are processed by request-based dm, which refers to the queue
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index af1fc3b2c2ad..c29410af1e22 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -509,9 +509,9 @@ enum pool_mode {
509struct pool_features { 509struct pool_features {
510 enum pool_mode mode; 510 enum pool_mode mode;
511 511
512 unsigned zero_new_blocks:1; 512 bool zero_new_blocks:1;
513 unsigned discard_enabled:1; 513 bool discard_enabled:1;
514 unsigned discard_passdown:1; 514 bool discard_passdown:1;
515}; 515};
516 516
517struct thin_c; 517struct thin_c;
@@ -580,7 +580,8 @@ struct pool_c {
580 struct dm_target_callbacks callbacks; 580 struct dm_target_callbacks callbacks;
581 581
582 dm_block_t low_water_blocks; 582 dm_block_t low_water_blocks;
583 struct pool_features pf; 583 struct pool_features requested_pf; /* Features requested during table load */
584 struct pool_features adjusted_pf; /* Features used after adjusting for constituent devices */
584}; 585};
585 586
586/* 587/*
@@ -1839,6 +1840,47 @@ static void __requeue_bios(struct pool *pool)
1839/*---------------------------------------------------------------- 1840/*----------------------------------------------------------------
1840 * Binding of control targets to a pool object 1841 * Binding of control targets to a pool object
1841 *--------------------------------------------------------------*/ 1842 *--------------------------------------------------------------*/
1843static bool data_dev_supports_discard(struct pool_c *pt)
1844{
1845 struct request_queue *q = bdev_get_queue(pt->data_dev->bdev);
1846
1847 return q && blk_queue_discard(q);
1848}
1849
1850/*
1851 * If discard_passdown was enabled verify that the data device
1852 * supports discards. Disable discard_passdown if not.
1853 */
1854static void disable_passdown_if_not_supported(struct pool_c *pt)
1855{
1856 struct pool *pool = pt->pool;
1857 struct block_device *data_bdev = pt->data_dev->bdev;
1858 struct queue_limits *data_limits = &bdev_get_queue(data_bdev)->limits;
1859 sector_t block_size = pool->sectors_per_block << SECTOR_SHIFT;
1860 const char *reason = NULL;
1861 char buf[BDEVNAME_SIZE];
1862
1863 if (!pt->adjusted_pf.discard_passdown)
1864 return;
1865
1866 if (!data_dev_supports_discard(pt))
1867 reason = "discard unsupported";
1868
1869 else if (data_limits->max_discard_sectors < pool->sectors_per_block)
1870 reason = "max discard sectors smaller than a block";
1871
1872 else if (data_limits->discard_granularity > block_size)
1873 reason = "discard granularity larger than a block";
1874
1875 else if (block_size & (data_limits->discard_granularity - 1))
1876 reason = "discard granularity not a factor of block size";
1877
1878 if (reason) {
1879 DMWARN("Data device (%s) %s: Disabling discard passdown.", bdevname(data_bdev, buf), reason);
1880 pt->adjusted_pf.discard_passdown = false;
1881 }
1882}
1883
1842static int bind_control_target(struct pool *pool, struct dm_target *ti) 1884static int bind_control_target(struct pool *pool, struct dm_target *ti)
1843{ 1885{
1844 struct pool_c *pt = ti->private; 1886 struct pool_c *pt = ti->private;
@@ -1847,31 +1889,16 @@ static int bind_control_target(struct pool *pool, struct dm_target *ti)
1847 * We want to make sure that degraded pools are never upgraded. 1889 * We want to make sure that degraded pools are never upgraded.
1848 */ 1890 */
1849 enum pool_mode old_mode = pool->pf.mode; 1891 enum pool_mode old_mode = pool->pf.mode;
1850 enum pool_mode new_mode = pt->pf.mode; 1892 enum pool_mode new_mode = pt->adjusted_pf.mode;
1851 1893
1852 if (old_mode > new_mode) 1894 if (old_mode > new_mode)
1853 new_mode = old_mode; 1895 new_mode = old_mode;
1854 1896
1855 pool->ti = ti; 1897 pool->ti = ti;
1856 pool->low_water_blocks = pt->low_water_blocks; 1898 pool->low_water_blocks = pt->low_water_blocks;
1857 pool->pf = pt->pf; 1899 pool->pf = pt->adjusted_pf;
1858 set_pool_mode(pool, new_mode);
1859 1900
1860 /* 1901 set_pool_mode(pool, new_mode);
1861 * If discard_passdown was enabled verify that the data device
1862 * supports discards. Disable discard_passdown if not; otherwise
1863 * -EOPNOTSUPP will be returned.
1864 */
1865 /* FIXME: pull this out into a sep fn. */
1866 if (pt->pf.discard_passdown) {
1867 struct request_queue *q = bdev_get_queue(pt->data_dev->bdev);
1868 if (!q || !blk_queue_discard(q)) {
1869 char buf[BDEVNAME_SIZE];
1870 DMWARN("Discard unsupported by data device (%s): Disabling discard passdown.",
1871 bdevname(pt->data_dev->bdev, buf));
1872 pool->pf.discard_passdown = 0;
1873 }
1874 }
1875 1902
1876 return 0; 1903 return 0;
1877} 1904}
@@ -1889,9 +1916,9 @@ static void unbind_control_target(struct pool *pool, struct dm_target *ti)
1889static void pool_features_init(struct pool_features *pf) 1916static void pool_features_init(struct pool_features *pf)
1890{ 1917{
1891 pf->mode = PM_WRITE; 1918 pf->mode = PM_WRITE;
1892 pf->zero_new_blocks = 1; 1919 pf->zero_new_blocks = true;
1893 pf->discard_enabled = 1; 1920 pf->discard_enabled = true;
1894 pf->discard_passdown = 1; 1921 pf->discard_passdown = true;
1895} 1922}
1896 1923
1897static void __pool_destroy(struct pool *pool) 1924static void __pool_destroy(struct pool *pool)
@@ -2119,13 +2146,13 @@ static int parse_pool_features(struct dm_arg_set *as, struct pool_features *pf,
2119 argc--; 2146 argc--;
2120 2147
2121 if (!strcasecmp(arg_name, "skip_block_zeroing")) 2148 if (!strcasecmp(arg_name, "skip_block_zeroing"))
2122 pf->zero_new_blocks = 0; 2149 pf->zero_new_blocks = false;
2123 2150
2124 else if (!strcasecmp(arg_name, "ignore_discard")) 2151 else if (!strcasecmp(arg_name, "ignore_discard"))
2125 pf->discard_enabled = 0; 2152 pf->discard_enabled = false;
2126 2153
2127 else if (!strcasecmp(arg_name, "no_discard_passdown")) 2154 else if (!strcasecmp(arg_name, "no_discard_passdown"))
2128 pf->discard_passdown = 0; 2155 pf->discard_passdown = false;
2129 2156
2130 else if (!strcasecmp(arg_name, "read_only")) 2157 else if (!strcasecmp(arg_name, "read_only"))
2131 pf->mode = PM_READ_ONLY; 2158 pf->mode = PM_READ_ONLY;
@@ -2259,8 +2286,9 @@ static int pool_ctr(struct dm_target *ti, unsigned argc, char **argv)
2259 pt->metadata_dev = metadata_dev; 2286 pt->metadata_dev = metadata_dev;
2260 pt->data_dev = data_dev; 2287 pt->data_dev = data_dev;
2261 pt->low_water_blocks = low_water_blocks; 2288 pt->low_water_blocks = low_water_blocks;
2262 pt->pf = pf; 2289 pt->adjusted_pf = pt->requested_pf = pf;
2263 ti->num_flush_requests = 1; 2290 ti->num_flush_requests = 1;
2291
2264 /* 2292 /*
2265 * Only need to enable discards if the pool should pass 2293 * Only need to enable discards if the pool should pass
2266 * them down to the data device. The thin device's discard 2294 * them down to the data device. The thin device's discard
@@ -2268,12 +2296,14 @@ static int pool_ctr(struct dm_target *ti, unsigned argc, char **argv)
2268 */ 2296 */
2269 if (pf.discard_enabled && pf.discard_passdown) { 2297 if (pf.discard_enabled && pf.discard_passdown) {
2270 ti->num_discard_requests = 1; 2298 ti->num_discard_requests = 1;
2299
2271 /* 2300 /*
2272 * Setting 'discards_supported' circumvents the normal 2301 * Setting 'discards_supported' circumvents the normal
2273 * stacking of discard limits (this keeps the pool and 2302 * stacking of discard limits (this keeps the pool and
2274 * thin devices' discard limits consistent). 2303 * thin devices' discard limits consistent).
2275 */ 2304 */
2276 ti->discards_supported = true; 2305 ti->discards_supported = true;
2306 ti->discard_zeroes_data_unsupported = true;
2277 } 2307 }
2278 ti->private = pt; 2308 ti->private = pt;
2279 2309
@@ -2703,7 +2733,7 @@ static int pool_status(struct dm_target *ti, status_type_t type,
2703 format_dev_t(buf2, pt->data_dev->bdev->bd_dev), 2733 format_dev_t(buf2, pt->data_dev->bdev->bd_dev),
2704 (unsigned long)pool->sectors_per_block, 2734 (unsigned long)pool->sectors_per_block,
2705 (unsigned long long)pt->low_water_blocks); 2735 (unsigned long long)pt->low_water_blocks);
2706 emit_flags(&pt->pf, result, sz, maxlen); 2736 emit_flags(&pt->requested_pf, result, sz, maxlen);
2707 break; 2737 break;
2708 } 2738 }
2709 2739
@@ -2732,20 +2762,21 @@ static int pool_merge(struct dm_target *ti, struct bvec_merge_data *bvm,
2732 return min(max_size, q->merge_bvec_fn(q, bvm, biovec)); 2762 return min(max_size, q->merge_bvec_fn(q, bvm, biovec));
2733} 2763}
2734 2764
2735static void set_discard_limits(struct pool *pool, struct queue_limits *limits) 2765static void set_discard_limits(struct pool_c *pt, struct queue_limits *limits)
2736{ 2766{
2737 /* 2767 struct pool *pool = pt->pool;
2738 * FIXME: these limits may be incompatible with the pool's data device 2768 struct queue_limits *data_limits;
2739 */ 2769
2740 limits->max_discard_sectors = pool->sectors_per_block; 2770 limits->max_discard_sectors = pool->sectors_per_block;
2741 2771
2742 /* 2772 /*
2743 * This is just a hint, and not enforced. We have to cope with 2773 * discard_granularity is just a hint, and not enforced.
2744 * bios that cover a block partially. A discard that spans a block
2745 * boundary is not sent to this target.
2746 */ 2774 */
2747 limits->discard_granularity = pool->sectors_per_block << SECTOR_SHIFT; 2775 if (pt->adjusted_pf.discard_passdown) {
2748 limits->discard_zeroes_data = pool->pf.zero_new_blocks; 2776 data_limits = &bdev_get_queue(pt->data_dev->bdev)->limits;
2777 limits->discard_granularity = data_limits->discard_granularity;
2778 } else
2779 limits->discard_granularity = pool->sectors_per_block << SECTOR_SHIFT;
2749} 2780}
2750 2781
2751static void pool_io_hints(struct dm_target *ti, struct queue_limits *limits) 2782static void pool_io_hints(struct dm_target *ti, struct queue_limits *limits)
@@ -2755,15 +2786,25 @@ static void pool_io_hints(struct dm_target *ti, struct queue_limits *limits)
2755 2786
2756 blk_limits_io_min(limits, 0); 2787 blk_limits_io_min(limits, 0);
2757 blk_limits_io_opt(limits, pool->sectors_per_block << SECTOR_SHIFT); 2788 blk_limits_io_opt(limits, pool->sectors_per_block << SECTOR_SHIFT);
2758 if (pool->pf.discard_enabled) 2789
2759 set_discard_limits(pool, limits); 2790 /*
2791 * pt->adjusted_pf is a staging area for the actual features to use.
2792 * They get transferred to the live pool in bind_control_target()
2793 * called from pool_preresume().
2794 */
2795 if (!pt->adjusted_pf.discard_enabled)
2796 return;
2797
2798 disable_passdown_if_not_supported(pt);
2799
2800 set_discard_limits(pt, limits);
2760} 2801}
2761 2802
2762static struct target_type pool_target = { 2803static struct target_type pool_target = {
2763 .name = "thin-pool", 2804 .name = "thin-pool",
2764 .features = DM_TARGET_SINGLETON | DM_TARGET_ALWAYS_WRITEABLE | 2805 .features = DM_TARGET_SINGLETON | DM_TARGET_ALWAYS_WRITEABLE |
2765 DM_TARGET_IMMUTABLE, 2806 DM_TARGET_IMMUTABLE,
2766 .version = {1, 3, 0}, 2807 .version = {1, 4, 0},
2767 .module = THIS_MODULE, 2808 .module = THIS_MODULE,
2768 .ctr = pool_ctr, 2809 .ctr = pool_ctr,
2769 .dtr = pool_dtr, 2810 .dtr = pool_dtr,
@@ -3042,19 +3083,19 @@ static int thin_iterate_devices(struct dm_target *ti,
3042 return 0; 3083 return 0;
3043} 3084}
3044 3085
3086/*
3087 * A thin device always inherits its queue limits from its pool.
3088 */
3045static void thin_io_hints(struct dm_target *ti, struct queue_limits *limits) 3089static void thin_io_hints(struct dm_target *ti, struct queue_limits *limits)
3046{ 3090{
3047 struct thin_c *tc = ti->private; 3091 struct thin_c *tc = ti->private;
3048 struct pool *pool = tc->pool;
3049 3092
3050 blk_limits_io_min(limits, 0); 3093 *limits = bdev_get_queue(tc->pool_dev->bdev)->limits;
3051 blk_limits_io_opt(limits, pool->sectors_per_block << SECTOR_SHIFT);
3052 set_discard_limits(pool, limits);
3053} 3094}
3054 3095
3055static struct target_type thin_target = { 3096static struct target_type thin_target = {
3056 .name = "thin", 3097 .name = "thin",
3057 .version = {1, 3, 0}, 3098 .version = {1, 4, 0},
3058 .module = THIS_MODULE, 3099 .module = THIS_MODULE,
3059 .ctr = thin_ctr, 3100 .ctr = thin_ctr,
3060 .dtr = thin_dtr, 3101 .dtr = thin_dtr,
diff --git a/drivers/md/dm-verity.c b/drivers/md/dm-verity.c
index 254d19268ad2..892ae2766aa6 100644
--- a/drivers/md/dm-verity.c
+++ b/drivers/md/dm-verity.c
@@ -718,8 +718,8 @@ static int verity_ctr(struct dm_target *ti, unsigned argc, char **argv)
718 v->hash_dev_block_bits = ffs(num) - 1; 718 v->hash_dev_block_bits = ffs(num) - 1;
719 719
720 if (sscanf(argv[5], "%llu%c", &num_ll, &dummy) != 1 || 720 if (sscanf(argv[5], "%llu%c", &num_ll, &dummy) != 1 ||
721 num_ll << (v->data_dev_block_bits - SECTOR_SHIFT) != 721 (sector_t)(num_ll << (v->data_dev_block_bits - SECTOR_SHIFT))
722 (sector_t)num_ll << (v->data_dev_block_bits - SECTOR_SHIFT)) { 722 >> (v->data_dev_block_bits - SECTOR_SHIFT) != num_ll) {
723 ti->error = "Invalid data blocks"; 723 ti->error = "Invalid data blocks";
724 r = -EINVAL; 724 r = -EINVAL;
725 goto bad; 725 goto bad;
@@ -733,8 +733,8 @@ static int verity_ctr(struct dm_target *ti, unsigned argc, char **argv)
733 } 733 }
734 734
735 if (sscanf(argv[6], "%llu%c", &num_ll, &dummy) != 1 || 735 if (sscanf(argv[6], "%llu%c", &num_ll, &dummy) != 1 ||
736 num_ll << (v->hash_dev_block_bits - SECTOR_SHIFT) != 736 (sector_t)(num_ll << (v->hash_dev_block_bits - SECTOR_SHIFT))
737 (sector_t)num_ll << (v->hash_dev_block_bits - SECTOR_SHIFT)) { 737 >> (v->hash_dev_block_bits - SECTOR_SHIFT) != num_ll) {
738 ti->error = "Invalid hash start"; 738 ti->error = "Invalid hash start";
739 r = -EINVAL; 739 r = -EINVAL;
740 goto bad; 740 goto bad;
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 4e09b6ff5b49..67ffa391edcf 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -865,10 +865,14 @@ static void dm_done(struct request *clone, int error, bool mapped)
865{ 865{
866 int r = error; 866 int r = error;
867 struct dm_rq_target_io *tio = clone->end_io_data; 867 struct dm_rq_target_io *tio = clone->end_io_data;
868 dm_request_endio_fn rq_end_io = tio->ti->type->rq_end_io; 868 dm_request_endio_fn rq_end_io = NULL;
869 869
870 if (mapped && rq_end_io) 870 if (tio->ti) {
871 r = rq_end_io(tio->ti, clone, error, &tio->info); 871 rq_end_io = tio->ti->type->rq_end_io;
872
873 if (mapped && rq_end_io)
874 r = rq_end_io(tio->ti, clone, error, &tio->info);
875 }
872 876
873 if (r <= 0) 877 if (r <= 0)
874 /* The target wants to complete the I/O */ 878 /* The target wants to complete the I/O */
@@ -1588,15 +1592,6 @@ static int map_request(struct dm_target *ti, struct request *clone,
1588 int r, requeued = 0; 1592 int r, requeued = 0;
1589 struct dm_rq_target_io *tio = clone->end_io_data; 1593 struct dm_rq_target_io *tio = clone->end_io_data;
1590 1594
1591 /*
1592 * Hold the md reference here for the in-flight I/O.
1593 * We can't rely on the reference count by device opener,
1594 * because the device may be closed during the request completion
1595 * when all bios are completed.
1596 * See the comment in rq_completed() too.
1597 */
1598 dm_get(md);
1599
1600 tio->ti = ti; 1595 tio->ti = ti;
1601 r = ti->type->map_rq(ti, clone, &tio->info); 1596 r = ti->type->map_rq(ti, clone, &tio->info);
1602 switch (r) { 1597 switch (r) {
@@ -1628,6 +1623,26 @@ static int map_request(struct dm_target *ti, struct request *clone,
1628 return requeued; 1623 return requeued;
1629} 1624}
1630 1625
1626static struct request *dm_start_request(struct mapped_device *md, struct request *orig)
1627{
1628 struct request *clone;
1629
1630 blk_start_request(orig);
1631 clone = orig->special;
1632 atomic_inc(&md->pending[rq_data_dir(clone)]);
1633
1634 /*
1635 * Hold the md reference here for the in-flight I/O.
1636 * We can't rely on the reference count by device opener,
1637 * because the device may be closed during the request completion
1638 * when all bios are completed.
1639 * See the comment in rq_completed() too.
1640 */
1641 dm_get(md);
1642
1643 return clone;
1644}
1645
1631/* 1646/*
1632 * q->request_fn for request-based dm. 1647 * q->request_fn for request-based dm.
1633 * Called with the queue lock held. 1648 * Called with the queue lock held.
@@ -1657,14 +1672,21 @@ static void dm_request_fn(struct request_queue *q)
1657 pos = blk_rq_pos(rq); 1672 pos = blk_rq_pos(rq);
1658 1673
1659 ti = dm_table_find_target(map, pos); 1674 ti = dm_table_find_target(map, pos);
1660 BUG_ON(!dm_target_is_valid(ti)); 1675 if (!dm_target_is_valid(ti)) {
1676 /*
1677 * Must perform setup, that dm_done() requires,
1678 * before calling dm_kill_unmapped_request
1679 */
1680 DMERR_LIMIT("request attempted access beyond the end of device");
1681 clone = dm_start_request(md, rq);
1682 dm_kill_unmapped_request(clone, -EIO);
1683 continue;
1684 }
1661 1685
1662 if (ti->type->busy && ti->type->busy(ti)) 1686 if (ti->type->busy && ti->type->busy(ti))
1663 goto delay_and_out; 1687 goto delay_and_out;
1664 1688
1665 blk_start_request(rq); 1689 clone = dm_start_request(md, rq);
1666 clone = rq->special;
1667 atomic_inc(&md->pending[rq_data_dir(clone)]);
1668 1690
1669 spin_unlock(q->queue_lock); 1691 spin_unlock(q->queue_lock);
1670 if (map_request(ti, clone, md)) 1692 if (map_request(ti, clone, md))
@@ -1684,8 +1706,6 @@ delay_and_out:
1684 blk_delay_queue(q, HZ / 10); 1706 blk_delay_queue(q, HZ / 10);
1685out: 1707out:
1686 dm_table_put(map); 1708 dm_table_put(map);
1687
1688 return;
1689} 1709}
1690 1710
1691int dm_underlying_device_busy(struct request_queue *q) 1711int dm_underlying_device_busy(struct request_queue *q)
@@ -2409,7 +2429,7 @@ static void dm_queue_flush(struct mapped_device *md)
2409 */ 2429 */
2410struct dm_table *dm_swap_table(struct mapped_device *md, struct dm_table *table) 2430struct dm_table *dm_swap_table(struct mapped_device *md, struct dm_table *table)
2411{ 2431{
2412 struct dm_table *map = ERR_PTR(-EINVAL); 2432 struct dm_table *live_map, *map = ERR_PTR(-EINVAL);
2413 struct queue_limits limits; 2433 struct queue_limits limits;
2414 int r; 2434 int r;
2415 2435
@@ -2419,6 +2439,19 @@ struct dm_table *dm_swap_table(struct mapped_device *md, struct dm_table *table)
2419 if (!dm_suspended_md(md)) 2439 if (!dm_suspended_md(md))
2420 goto out; 2440 goto out;
2421 2441
2442 /*
2443 * If the new table has no data devices, retain the existing limits.
2444 * This helps multipath with queue_if_no_path if all paths disappear,
2445 * then new I/O is queued based on these limits, and then some paths
2446 * reappear.
2447 */
2448 if (dm_table_has_no_data_devices(table)) {
2449 live_map = dm_get_live_table(md);
2450 if (live_map)
2451 limits = md->queue->limits;
2452 dm_table_put(live_map);
2453 }
2454
2422 r = dm_calculate_queue_limits(table, &limits); 2455 r = dm_calculate_queue_limits(table, &limits);
2423 if (r) { 2456 if (r) {
2424 map = ERR_PTR(r); 2457 map = ERR_PTR(r);
diff --git a/drivers/md/dm.h b/drivers/md/dm.h
index 52eef493d266..6a99fefaa743 100644
--- a/drivers/md/dm.h
+++ b/drivers/md/dm.h
@@ -54,6 +54,7 @@ void dm_table_event_callback(struct dm_table *t,
54 void (*fn)(void *), void *context); 54 void (*fn)(void *), void *context);
55struct dm_target *dm_table_get_target(struct dm_table *t, unsigned int index); 55struct dm_target *dm_table_get_target(struct dm_table *t, unsigned int index);
56struct dm_target *dm_table_find_target(struct dm_table *t, sector_t sector); 56struct dm_target *dm_table_find_target(struct dm_table *t, sector_t sector);
57bool dm_table_has_no_data_devices(struct dm_table *table);
57int dm_calculate_queue_limits(struct dm_table *table, 58int dm_calculate_queue_limits(struct dm_table *table,
58 struct queue_limits *limits); 59 struct queue_limits *limits);
59void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, 60void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 1c2eb38f3c51..0138a727c1f3 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1512,14 +1512,16 @@ static int _enough(struct r10conf *conf, struct geom *geo, int ignore)
1512 do { 1512 do {
1513 int n = conf->copies; 1513 int n = conf->copies;
1514 int cnt = 0; 1514 int cnt = 0;
1515 int this = first;
1515 while (n--) { 1516 while (n--) {
1516 if (conf->mirrors[first].rdev && 1517 if (conf->mirrors[this].rdev &&
1517 first != ignore) 1518 this != ignore)
1518 cnt++; 1519 cnt++;
1519 first = (first+1) % geo->raid_disks; 1520 this = (this+1) % geo->raid_disks;
1520 } 1521 }
1521 if (cnt == 0) 1522 if (cnt == 0)
1522 return 0; 1523 return 0;
1524 first = (first + geo->near_copies) % geo->raid_disks;
1523 } while (first != 0); 1525 } while (first != 0);
1524 return 1; 1526 return 1;
1525} 1527}
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 7031b865b3a0..0689173fd9f5 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -1591,6 +1591,7 @@ static int resize_stripes(struct r5conf *conf, int newsize)
1591 #ifdef CONFIG_MULTICORE_RAID456 1591 #ifdef CONFIG_MULTICORE_RAID456
1592 init_waitqueue_head(&nsh->ops.wait_for_ops); 1592 init_waitqueue_head(&nsh->ops.wait_for_ops);
1593 #endif 1593 #endif
1594 spin_lock_init(&nsh->stripe_lock);
1594 1595
1595 list_add(&nsh->lru, &newstripes); 1596 list_add(&nsh->lru, &newstripes);
1596 } 1597 }
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index f2f482bec573..a6e74514e662 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -1123,6 +1123,33 @@ static unsigned long mtdchar_get_unmapped_area(struct file *file,
1123} 1123}
1124#endif 1124#endif
1125 1125
1126static inline unsigned long get_vm_size(struct vm_area_struct *vma)
1127{
1128 return vma->vm_end - vma->vm_start;
1129}
1130
1131static inline resource_size_t get_vm_offset(struct vm_area_struct *vma)
1132{
1133 return (resource_size_t) vma->vm_pgoff << PAGE_SHIFT;
1134}
1135
1136/*
1137 * Set a new vm offset.
1138 *
1139 * Verify that the incoming offset really works as a page offset,
1140 * and that the offset and size fit in a resource_size_t.
1141 */
1142static inline int set_vm_offset(struct vm_area_struct *vma, resource_size_t off)
1143{
1144 pgoff_t pgoff = off >> PAGE_SHIFT;
1145 if (off != (resource_size_t) pgoff << PAGE_SHIFT)
1146 return -EINVAL;
1147 if (off + get_vm_size(vma) - 1 < off)
1148 return -EINVAL;
1149 vma->vm_pgoff = pgoff;
1150 return 0;
1151}
1152
1126/* 1153/*
1127 * set up a mapping for shared memory segments 1154 * set up a mapping for shared memory segments
1128 */ 1155 */
@@ -1132,20 +1159,29 @@ static int mtdchar_mmap(struct file *file, struct vm_area_struct *vma)
1132 struct mtd_file_info *mfi = file->private_data; 1159 struct mtd_file_info *mfi = file->private_data;
1133 struct mtd_info *mtd = mfi->mtd; 1160 struct mtd_info *mtd = mfi->mtd;
1134 struct map_info *map = mtd->priv; 1161 struct map_info *map = mtd->priv;
1135 unsigned long start; 1162 resource_size_t start, off;
1136 unsigned long off; 1163 unsigned long len, vma_len;
1137 u32 len;
1138 1164
1139 if (mtd->type == MTD_RAM || mtd->type == MTD_ROM) { 1165 if (mtd->type == MTD_RAM || mtd->type == MTD_ROM) {
1140 off = vma->vm_pgoff << PAGE_SHIFT; 1166 off = get_vm_offset(vma);
1141 start = map->phys; 1167 start = map->phys;
1142 len = PAGE_ALIGN((start & ~PAGE_MASK) + map->size); 1168 len = PAGE_ALIGN((start & ~PAGE_MASK) + map->size);
1143 start &= PAGE_MASK; 1169 start &= PAGE_MASK;
1144 if ((vma->vm_end - vma->vm_start + off) > len) 1170 vma_len = get_vm_size(vma);
1171
1172 /* Overflow in off+len? */
1173 if (vma_len + off < off)
1174 return -EINVAL;
1175 /* Does it fit in the mapping? */
1176 if (vma_len + off > len)
1145 return -EINVAL; 1177 return -EINVAL;
1146 1178
1147 off += start; 1179 off += start;
1148 vma->vm_pgoff = off >> PAGE_SHIFT; 1180 /* Did that overflow? */
1181 if (off < start)
1182 return -EINVAL;
1183 if (set_vm_offset(vma, off) < 0)
1184 return -EINVAL;
1149 vma->vm_flags |= VM_IO | VM_RESERVED; 1185 vma->vm_flags |= VM_IO | VM_RESERVED;
1150 1186
1151#ifdef pgprot_noncached 1187#ifdef pgprot_noncached
diff --git a/drivers/net/can/janz-ican3.c b/drivers/net/can/janz-ican3.c
index 98ee43819911..7edadee487ba 100644
--- a/drivers/net/can/janz-ican3.c
+++ b/drivers/net/can/janz-ican3.c
@@ -1391,7 +1391,6 @@ static irqreturn_t ican3_irq(int irq, void *dev_id)
1391 */ 1391 */
1392static int ican3_reset_module(struct ican3_dev *mod) 1392static int ican3_reset_module(struct ican3_dev *mod)
1393{ 1393{
1394 u8 val = 1 << mod->num;
1395 unsigned long start; 1394 unsigned long start;
1396 u8 runold, runnew; 1395 u8 runold, runnew;
1397 1396
@@ -1405,8 +1404,7 @@ static int ican3_reset_module(struct ican3_dev *mod)
1405 runold = ioread8(mod->dpm + TARGET_RUNNING); 1404 runold = ioread8(mod->dpm + TARGET_RUNNING);
1406 1405
1407 /* reset the module */ 1406 /* reset the module */
1408 iowrite8(val, &mod->ctrl->reset_assert); 1407 iowrite8(0x00, &mod->dpmctrl->hwreset);
1409 iowrite8(val, &mod->ctrl->reset_deassert);
1410 1408
1411 /* wait until the module has finished resetting and is running */ 1409 /* wait until the module has finished resetting and is running */
1412 start = jiffies; 1410 start = jiffies;
diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
index 527dbcf95335..9ded21e79db5 100644
--- a/drivers/net/can/ti_hecc.c
+++ b/drivers/net/can/ti_hecc.c
@@ -984,12 +984,12 @@ static int __devexit ti_hecc_remove(struct platform_device *pdev)
984 struct net_device *ndev = platform_get_drvdata(pdev); 984 struct net_device *ndev = platform_get_drvdata(pdev);
985 struct ti_hecc_priv *priv = netdev_priv(ndev); 985 struct ti_hecc_priv *priv = netdev_priv(ndev);
986 986
987 unregister_candev(ndev);
987 clk_disable(priv->clk); 988 clk_disable(priv->clk);
988 clk_put(priv->clk); 989 clk_put(priv->clk);
989 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 990 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
990 iounmap(priv->base); 991 iounmap(priv->base);
991 release_mem_region(res->start, resource_size(res)); 992 release_mem_region(res->start, resource_size(res));
992 unregister_candev(ndev);
993 free_candev(ndev); 993 free_candev(ndev);
994 platform_set_drvdata(pdev, NULL); 994 platform_set_drvdata(pdev, NULL);
995 995
diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c
index 79cebd8525ce..e48312f2305d 100644
--- a/drivers/net/ethernet/broadcom/bnx2.c
+++ b/drivers/net/ethernet/broadcom/bnx2.c
@@ -8564,7 +8564,7 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
8564 return 0; 8564 return 0;
8565 8565
8566error: 8566error:
8567 iounmap(bp->regview); 8567 pci_iounmap(pdev, bp->regview);
8568 pci_release_regions(pdev); 8568 pci_release_regions(pdev);
8569 pci_disable_device(pdev); 8569 pci_disable_device(pdev);
8570 pci_set_drvdata(pdev, NULL); 8570 pci_set_drvdata(pdev, NULL);
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index af20c6ee2cd9..e8e97a7d1d06 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -662,14 +662,16 @@ void bnx2x_csum_validate(struct sk_buff *skb, union eth_rx_cqe *cqe,
662 struct bnx2x_fastpath *fp, 662 struct bnx2x_fastpath *fp,
663 struct bnx2x_eth_q_stats *qstats) 663 struct bnx2x_eth_q_stats *qstats)
664{ 664{
665 /* Do nothing if no IP/L4 csum validation was done */ 665 /* Do nothing if no L4 csum validation was done.
666 666 * We do not check whether IP csum was validated. For IPv4 we assume
667 * that if the card got as far as validating the L4 csum, it also
668 * validated the IP csum. IPv6 has no IP csum.
669 */
667 if (cqe->fast_path_cqe.status_flags & 670 if (cqe->fast_path_cqe.status_flags &
668 (ETH_FAST_PATH_RX_CQE_IP_XSUM_NO_VALIDATION_FLG | 671 ETH_FAST_PATH_RX_CQE_L4_XSUM_NO_VALIDATION_FLG)
669 ETH_FAST_PATH_RX_CQE_L4_XSUM_NO_VALIDATION_FLG))
670 return; 672 return;
671 673
672 /* If both IP/L4 validation were done, check if an error was found. */ 674 /* If L4 validation was done, check if an error was found. */
673 675
674 if (cqe->fast_path_cqe.type_error_flags & 676 if (cqe->fast_path_cqe.type_error_flags &
675 (ETH_FAST_PATH_RX_CQE_IP_BAD_XSUM_FLG | 677 (ETH_FAST_PATH_RX_CQE_IP_BAD_XSUM_FLG |
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 211753e01f81..0875ecfe3372 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -9831,12 +9831,13 @@ static void __devinit bnx2x_get_igu_cam_info(struct bnx2x *bp)
9831 } 9831 }
9832 9832
9833#ifdef CONFIG_PCI_MSI 9833#ifdef CONFIG_PCI_MSI
9834 /* 9834 /* Due to new PF resource allocation by MFW T7.4 and above, it's
9835 * It's expected that number of CAM entries for this functions is equal 9835 * optional that number of CAM entries will not be equal to the value
9836 * to the number evaluated based on the MSI-X table size. We want a 9836 * advertised in PCI.
9837 * harsh warning if these values are different! 9837 * Driver should use the minimal value of both as the actual status
9838 * block count
9838 */ 9839 */
9839 WARN_ON(bp->igu_sb_cnt != igu_sb_cnt); 9840 bp->igu_sb_cnt = min_t(int, bp->igu_sb_cnt, igu_sb_cnt);
9840#endif 9841#endif
9841 9842
9842 if (igu_sb_cnt == 0) 9843 if (igu_sb_cnt == 0)
diff --git a/drivers/net/ethernet/cadence/at91_ether.c b/drivers/net/ethernet/cadence/at91_ether.c
index 77884191a8c6..4e980a7886fb 100644
--- a/drivers/net/ethernet/cadence/at91_ether.c
+++ b/drivers/net/ethernet/cadence/at91_ether.c
@@ -1086,7 +1086,7 @@ static int __init at91ether_probe(struct platform_device *pdev)
1086 /* Clock */ 1086 /* Clock */
1087 lp->ether_clk = clk_get(&pdev->dev, "ether_clk"); 1087 lp->ether_clk = clk_get(&pdev->dev, "ether_clk");
1088 if (IS_ERR(lp->ether_clk)) { 1088 if (IS_ERR(lp->ether_clk)) {
1089 res = -ENODEV; 1089 res = PTR_ERR(lp->ether_clk);
1090 goto err_ioumap; 1090 goto err_ioumap;
1091 } 1091 }
1092 clk_enable(lp->ether_clk); 1092 clk_enable(lp->ether_clk);
diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
index 8971921cc1c8..ab6762caa957 100644
--- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
+++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
@@ -1773,6 +1773,7 @@ static int gfar_get_nfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
1773} 1773}
1774 1774
1775int gfar_phc_index = -1; 1775int gfar_phc_index = -1;
1776EXPORT_SYMBOL(gfar_phc_index);
1776 1777
1777static int gfar_get_ts_info(struct net_device *dev, 1778static int gfar_get_ts_info(struct net_device *dev,
1778 struct ethtool_ts_info *info) 1779 struct ethtool_ts_info *info)
diff --git a/drivers/net/ethernet/freescale/gianfar_ptp.c b/drivers/net/ethernet/freescale/gianfar_ptp.c
index c08e5d40fecb..0daa66b8eca0 100644
--- a/drivers/net/ethernet/freescale/gianfar_ptp.c
+++ b/drivers/net/ethernet/freescale/gianfar_ptp.c
@@ -515,7 +515,7 @@ static int gianfar_ptp_probe(struct platform_device *dev)
515 err = PTR_ERR(etsects->clock); 515 err = PTR_ERR(etsects->clock);
516 goto no_clock; 516 goto no_clock;
517 } 517 }
518 gfar_phc_clock = ptp_clock_index(etsects->clock); 518 gfar_phc_index = ptp_clock_index(etsects->clock);
519 519
520 dev_set_drvdata(&dev->dev, etsects); 520 dev_set_drvdata(&dev->dev, etsects);
521 521
@@ -539,7 +539,7 @@ static int gianfar_ptp_remove(struct platform_device *dev)
539 gfar_write(&etsects->regs->tmr_temask, 0); 539 gfar_write(&etsects->regs->tmr_temask, 0);
540 gfar_write(&etsects->regs->tmr_ctrl, 0); 540 gfar_write(&etsects->regs->tmr_ctrl, 0);
541 541
542 gfar_phc_clock = -1; 542 gfar_phc_index = -1;
543 ptp_clock_unregister(etsects->clock); 543 ptp_clock_unregister(etsects->clock);
544 iounmap(etsects->regs); 544 iounmap(etsects->regs);
545 release_resource(etsects->rsrc); 545 release_resource(etsects->rsrc);
diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c
index 3bfbb8df8989..bde337ee1a34 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_main.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
@@ -3149,6 +3149,17 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
3149 return NETDEV_TX_OK; 3149 return NETDEV_TX_OK;
3150 } 3150 }
3151 3151
3152 /* On PCI/PCI-X HW, if packet size is less than ETH_ZLEN,
3153 * packets may get corrupted during padding by HW.
3154 * To WA this issue, pad all small packets manually.
3155 */
3156 if (skb->len < ETH_ZLEN) {
3157 if (skb_pad(skb, ETH_ZLEN - skb->len))
3158 return NETDEV_TX_OK;
3159 skb->len = ETH_ZLEN;
3160 skb_set_tail_pointer(skb, ETH_ZLEN);
3161 }
3162
3152 mss = skb_shinfo(skb)->gso_size; 3163 mss = skb_shinfo(skb)->gso_size;
3153 /* The controller does a simple calculation to 3164 /* The controller does a simple calculation to
3154 * make sure there is enough room in the FIFO before 3165 * make sure there is enough room in the FIFO before
diff --git a/drivers/net/ethernet/octeon/octeon_mgmt.c b/drivers/net/ethernet/octeon/octeon_mgmt.c
index c42bbb16cdae..a688a2ddcfd6 100644
--- a/drivers/net/ethernet/octeon/octeon_mgmt.c
+++ b/drivers/net/ethernet/octeon/octeon_mgmt.c
@@ -722,10 +722,8 @@ static int octeon_mgmt_init_phy(struct net_device *netdev)
722 octeon_mgmt_adjust_link, 0, 722 octeon_mgmt_adjust_link, 0,
723 PHY_INTERFACE_MODE_MII); 723 PHY_INTERFACE_MODE_MII);
724 724
725 if (IS_ERR(p->phydev)) { 725 if (!p->phydev)
726 p->phydev = NULL;
727 return -1; 726 return -1;
728 }
729 727
730 phy_start_aneg(p->phydev); 728 phy_start_aneg(p->phydev);
731 729
diff --git a/drivers/net/ethernet/pasemi/pasemi_mac.c b/drivers/net/ethernet/pasemi/pasemi_mac.c
index e559dfa06d6a..6fa74d530e44 100644
--- a/drivers/net/ethernet/pasemi/pasemi_mac.c
+++ b/drivers/net/ethernet/pasemi/pasemi_mac.c
@@ -1101,9 +1101,9 @@ static int pasemi_mac_phy_init(struct net_device *dev)
1101 phydev = of_phy_connect(dev, phy_dn, &pasemi_adjust_link, 0, 1101 phydev = of_phy_connect(dev, phy_dn, &pasemi_adjust_link, 0,
1102 PHY_INTERFACE_MODE_SGMII); 1102 PHY_INTERFACE_MODE_SGMII);
1103 1103
1104 if (IS_ERR(phydev)) { 1104 if (!phydev) {
1105 printk(KERN_ERR "%s: Could not attach to phy\n", dev->name); 1105 printk(KERN_ERR "%s: Could not attach to phy\n", dev->name);
1106 return PTR_ERR(phydev); 1106 return -ENODEV;
1107 } 1107 }
1108 1108
1109 mac->phydev = phydev; 1109 mac->phydev = phydev;
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
index 342b3a79bd0f..a77c558d8f40 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
@@ -1378,6 +1378,10 @@ static void netxen_mask_aer_correctable(struct netxen_adapter *adapter)
1378 struct pci_dev *root = pdev->bus->self; 1378 struct pci_dev *root = pdev->bus->self;
1379 u32 aer_pos; 1379 u32 aer_pos;
1380 1380
1381 /* root bus? */
1382 if (!root)
1383 return;
1384
1381 if (adapter->ahw.board_type != NETXEN_BRDTYPE_P3_4_GB_MM && 1385 if (adapter->ahw.board_type != NETXEN_BRDTYPE_P3_4_GB_MM &&
1382 adapter->ahw.board_type != NETXEN_BRDTYPE_P3_10G_TP) 1386 adapter->ahw.board_type != NETXEN_BRDTYPE_P3_10G_TP)
1383 return; 1387 return;
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c
index b8ead696141e..2a179d087207 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c
@@ -15,7 +15,7 @@ qlcnic_poll_rsp(struct qlcnic_adapter *adapter)
15 15
16 do { 16 do {
17 /* give atleast 1ms for firmware to respond */ 17 /* give atleast 1ms for firmware to respond */
18 msleep(1); 18 mdelay(1);
19 19
20 if (++timeout > QLCNIC_OS_CRB_RETRY_COUNT) 20 if (++timeout > QLCNIC_OS_CRB_RETRY_COUNT)
21 return QLCNIC_CDRP_RSP_TIMEOUT; 21 return QLCNIC_CDRP_RSP_TIMEOUT;
@@ -601,7 +601,7 @@ void qlcnic_fw_destroy_ctx(struct qlcnic_adapter *adapter)
601 qlcnic_fw_cmd_destroy_tx_ctx(adapter); 601 qlcnic_fw_cmd_destroy_tx_ctx(adapter);
602 602
603 /* Allow dma queues to drain after context reset */ 603 /* Allow dma queues to drain after context reset */
604 msleep(20); 604 mdelay(20);
605 } 605 }
606} 606}
607 607
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index c136162e6473..3be88331d17a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1066,7 +1066,7 @@ static int stmmac_open(struct net_device *dev)
1066 } else 1066 } else
1067 priv->tm->enable = 1; 1067 priv->tm->enable = 1;
1068#endif 1068#endif
1069 clk_enable(priv->stmmac_clk); 1069 clk_prepare_enable(priv->stmmac_clk);
1070 1070
1071 stmmac_check_ether_addr(priv); 1071 stmmac_check_ether_addr(priv);
1072 1072
@@ -1188,7 +1188,7 @@ open_error:
1188 if (priv->phydev) 1188 if (priv->phydev)
1189 phy_disconnect(priv->phydev); 1189 phy_disconnect(priv->phydev);
1190 1190
1191 clk_disable(priv->stmmac_clk); 1191 clk_disable_unprepare(priv->stmmac_clk);
1192 1192
1193 return ret; 1193 return ret;
1194} 1194}
@@ -1246,7 +1246,7 @@ static int stmmac_release(struct net_device *dev)
1246#ifdef CONFIG_STMMAC_DEBUG_FS 1246#ifdef CONFIG_STMMAC_DEBUG_FS
1247 stmmac_exit_fs(); 1247 stmmac_exit_fs();
1248#endif 1248#endif
1249 clk_disable(priv->stmmac_clk); 1249 clk_disable_unprepare(priv->stmmac_clk);
1250 1250
1251 return 0; 1251 return 0;
1252} 1252}
@@ -2178,7 +2178,7 @@ int stmmac_suspend(struct net_device *ndev)
2178 else { 2178 else {
2179 stmmac_set_mac(priv->ioaddr, false); 2179 stmmac_set_mac(priv->ioaddr, false);
2180 /* Disable clock in case of PWM is off */ 2180 /* Disable clock in case of PWM is off */
2181 clk_disable(priv->stmmac_clk); 2181 clk_disable_unprepare(priv->stmmac_clk);
2182 } 2182 }
2183 spin_unlock_irqrestore(&priv->lock, flags); 2183 spin_unlock_irqrestore(&priv->lock, flags);
2184 return 0; 2184 return 0;
@@ -2203,7 +2203,7 @@ int stmmac_resume(struct net_device *ndev)
2203 priv->hw->mac->pmt(priv->ioaddr, 0); 2203 priv->hw->mac->pmt(priv->ioaddr, 0);
2204 else 2204 else
2205 /* enable the clk prevously disabled */ 2205 /* enable the clk prevously disabled */
2206 clk_enable(priv->stmmac_clk); 2206 clk_prepare_enable(priv->stmmac_clk);
2207 2207
2208 netif_device_attach(ndev); 2208 netif_device_attach(ndev);
2209 2209
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_timer.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_timer.c
index 2a0e1abde7e7..4ccd4e2977b7 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_timer.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_timer.c
@@ -97,19 +97,19 @@ static struct clk *timer_clock;
97static void stmmac_tmu_start(unsigned int new_freq) 97static void stmmac_tmu_start(unsigned int new_freq)
98{ 98{
99 clk_set_rate(timer_clock, new_freq); 99 clk_set_rate(timer_clock, new_freq);
100 clk_enable(timer_clock); 100 clk_prepare_enable(timer_clock);
101} 101}
102 102
103static void stmmac_tmu_stop(void) 103static void stmmac_tmu_stop(void)
104{ 104{
105 clk_disable(timer_clock); 105 clk_disable_unprepare(timer_clock);
106} 106}
107 107
108int stmmac_open_ext_timer(struct net_device *dev, struct stmmac_timer *tm) 108int stmmac_open_ext_timer(struct net_device *dev, struct stmmac_timer *tm)
109{ 109{
110 timer_clock = clk_get(NULL, TMU_CHANNEL); 110 timer_clock = clk_get(NULL, TMU_CHANNEL);
111 111
112 if (timer_clock == NULL) 112 if (IS_ERR(timer_clock))
113 return -1; 113 return -1;
114 114
115 if (tmu2_register_user(stmmac_timer_handler, (void *)dev) < 0) { 115 if (tmu2_register_user(stmmac_timer_handler, (void *)dev) < 0) {
@@ -126,7 +126,7 @@ int stmmac_open_ext_timer(struct net_device *dev, struct stmmac_timer *tm)
126 126
127int stmmac_close_ext_timer(void) 127int stmmac_close_ext_timer(void)
128{ 128{
129 clk_disable(timer_clock); 129 clk_disable_unprepare(timer_clock);
130 tmu2_unregister_user(); 130 tmu2_unregister_user();
131 clk_put(timer_clock); 131 clk_put(timer_clock);
132 return 0; 132 return 0;
diff --git a/drivers/net/irda/sh_sir.c b/drivers/net/irda/sh_sir.c
index 256eddf1f75a..795109425568 100644
--- a/drivers/net/irda/sh_sir.c
+++ b/drivers/net/irda/sh_sir.c
@@ -280,7 +280,7 @@ static int sh_sir_set_baudrate(struct sh_sir_self *self, u32 baudrate)
280 } 280 }
281 281
282 clk = clk_get(NULL, "irda_clk"); 282 clk = clk_get(NULL, "irda_clk");
283 if (!clk) { 283 if (IS_ERR(clk)) {
284 dev_err(dev, "can not get irda_clk\n"); 284 dev_err(dev, "can not get irda_clk\n");
285 return -EIO; 285 return -EIO;
286 } 286 }
diff --git a/drivers/net/phy/bcm87xx.c b/drivers/net/phy/bcm87xx.c
index 2346b38b9837..799789518e87 100644
--- a/drivers/net/phy/bcm87xx.c
+++ b/drivers/net/phy/bcm87xx.c
@@ -229,3 +229,5 @@ static void __exit bcm87xx_exit(void)
229 ARRAY_SIZE(bcm87xx_driver)); 229 ARRAY_SIZE(bcm87xx_driver));
230} 230}
231module_exit(bcm87xx_exit); 231module_exit(bcm87xx_exit);
232
233MODULE_LICENSE("GPL");
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index cf287e0eb408..2165d5fdb8c0 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -21,6 +21,12 @@
21#include <linux/phy.h> 21#include <linux/phy.h>
22#include <linux/micrel_phy.h> 22#include <linux/micrel_phy.h>
23 23
24/* Operation Mode Strap Override */
25#define MII_KSZPHY_OMSO 0x16
26#define KSZPHY_OMSO_B_CAST_OFF (1 << 9)
27#define KSZPHY_OMSO_RMII_OVERRIDE (1 << 1)
28#define KSZPHY_OMSO_MII_OVERRIDE (1 << 0)
29
24/* general Interrupt control/status reg in vendor specific block. */ 30/* general Interrupt control/status reg in vendor specific block. */
25#define MII_KSZPHY_INTCS 0x1B 31#define MII_KSZPHY_INTCS 0x1B
26#define KSZPHY_INTCS_JABBER (1 << 15) 32#define KSZPHY_INTCS_JABBER (1 << 15)
@@ -101,6 +107,13 @@ static int kszphy_config_init(struct phy_device *phydev)
101 return 0; 107 return 0;
102} 108}
103 109
110static int ksz8021_config_init(struct phy_device *phydev)
111{
112 const u16 val = KSZPHY_OMSO_B_CAST_OFF | KSZPHY_OMSO_RMII_OVERRIDE;
113 phy_write(phydev, MII_KSZPHY_OMSO, val);
114 return 0;
115}
116
104static int ks8051_config_init(struct phy_device *phydev) 117static int ks8051_config_init(struct phy_device *phydev)
105{ 118{
106 int regval; 119 int regval;
@@ -128,9 +141,22 @@ static struct phy_driver ksphy_driver[] = {
128 .config_intr = ks8737_config_intr, 141 .config_intr = ks8737_config_intr,
129 .driver = { .owner = THIS_MODULE,}, 142 .driver = { .owner = THIS_MODULE,},
130}, { 143}, {
131 .phy_id = PHY_ID_KS8041, 144 .phy_id = PHY_ID_KSZ8021,
145 .phy_id_mask = 0x00ffffff,
146 .name = "Micrel KSZ8021",
147 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause |
148 SUPPORTED_Asym_Pause),
149 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
150 .config_init = ksz8021_config_init,
151 .config_aneg = genphy_config_aneg,
152 .read_status = genphy_read_status,
153 .ack_interrupt = kszphy_ack_interrupt,
154 .config_intr = kszphy_config_intr,
155 .driver = { .owner = THIS_MODULE,},
156}, {
157 .phy_id = PHY_ID_KSZ8041,
132 .phy_id_mask = 0x00fffff0, 158 .phy_id_mask = 0x00fffff0,
133 .name = "Micrel KS8041", 159 .name = "Micrel KSZ8041",
134 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause 160 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause
135 | SUPPORTED_Asym_Pause), 161 | SUPPORTED_Asym_Pause),
136 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 162 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
@@ -141,9 +167,9 @@ static struct phy_driver ksphy_driver[] = {
141 .config_intr = kszphy_config_intr, 167 .config_intr = kszphy_config_intr,
142 .driver = { .owner = THIS_MODULE,}, 168 .driver = { .owner = THIS_MODULE,},
143}, { 169}, {
144 .phy_id = PHY_ID_KS8051, 170 .phy_id = PHY_ID_KSZ8051,
145 .phy_id_mask = 0x00fffff0, 171 .phy_id_mask = 0x00fffff0,
146 .name = "Micrel KS8051", 172 .name = "Micrel KSZ8051",
147 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause 173 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause
148 | SUPPORTED_Asym_Pause), 174 | SUPPORTED_Asym_Pause),
149 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 175 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
@@ -154,8 +180,8 @@ static struct phy_driver ksphy_driver[] = {
154 .config_intr = kszphy_config_intr, 180 .config_intr = kszphy_config_intr,
155 .driver = { .owner = THIS_MODULE,}, 181 .driver = { .owner = THIS_MODULE,},
156}, { 182}, {
157 .phy_id = PHY_ID_KS8001, 183 .phy_id = PHY_ID_KSZ8001,
158 .name = "Micrel KS8001 or KS8721", 184 .name = "Micrel KSZ8001 or KS8721",
159 .phy_id_mask = 0x00ffffff, 185 .phy_id_mask = 0x00ffffff,
160 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause), 186 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
161 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 187 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
@@ -201,10 +227,11 @@ MODULE_LICENSE("GPL");
201 227
202static struct mdio_device_id __maybe_unused micrel_tbl[] = { 228static struct mdio_device_id __maybe_unused micrel_tbl[] = {
203 { PHY_ID_KSZ9021, 0x000ffffe }, 229 { PHY_ID_KSZ9021, 0x000ffffe },
204 { PHY_ID_KS8001, 0x00ffffff }, 230 { PHY_ID_KSZ8001, 0x00ffffff },
205 { PHY_ID_KS8737, 0x00fffff0 }, 231 { PHY_ID_KS8737, 0x00fffff0 },
206 { PHY_ID_KS8041, 0x00fffff0 }, 232 { PHY_ID_KSZ8021, 0x00ffffff },
207 { PHY_ID_KS8051, 0x00fffff0 }, 233 { PHY_ID_KSZ8041, 0x00fffff0 },
234 { PHY_ID_KSZ8051, 0x00fffff0 },
208 { } 235 { }
209}; 236};
210 237
diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
index 6d6192316b30..88e3991464e7 100644
--- a/drivers/net/phy/smsc.c
+++ b/drivers/net/phy/smsc.c
@@ -56,6 +56,32 @@ static int smsc_phy_config_init(struct phy_device *phydev)
56 return smsc_phy_ack_interrupt (phydev); 56 return smsc_phy_ack_interrupt (phydev);
57} 57}
58 58
59static int lan87xx_config_init(struct phy_device *phydev)
60{
61 /*
62 * Make sure the EDPWRDOWN bit is NOT set. Setting this bit on
63 * LAN8710/LAN8720 PHY causes the PHY to misbehave, likely due
64 * to a bug on the chip.
65 *
66 * When the system is powered on with the network cable being
67 * disconnected all the way until after ifconfig ethX up is
68 * issued for the LAN port with this PHY, connecting the cable
69 * afterwards does not cause LINK change detection, while the
70 * expected behavior is the Link UP being detected.
71 */
72 int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
73 if (rc < 0)
74 return rc;
75
76 rc &= ~MII_LAN83C185_EDPWRDOWN;
77
78 rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS, rc);
79 if (rc < 0)
80 return rc;
81
82 return smsc_phy_ack_interrupt(phydev);
83}
84
59static int lan911x_config_init(struct phy_device *phydev) 85static int lan911x_config_init(struct phy_device *phydev)
60{ 86{
61 return smsc_phy_ack_interrupt(phydev); 87 return smsc_phy_ack_interrupt(phydev);
@@ -162,7 +188,7 @@ static struct phy_driver smsc_phy_driver[] = {
162 /* basic functions */ 188 /* basic functions */
163 .config_aneg = genphy_config_aneg, 189 .config_aneg = genphy_config_aneg,
164 .read_status = genphy_read_status, 190 .read_status = genphy_read_status,
165 .config_init = smsc_phy_config_init, 191 .config_init = lan87xx_config_init,
166 192
167 /* IRQ related */ 193 /* IRQ related */
168 .ack_interrupt = smsc_phy_ack_interrupt, 194 .ack_interrupt = smsc_phy_ack_interrupt,
diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c
index cbf7047decc0..20f31d0d1536 100644
--- a/drivers/net/ppp/pppoe.c
+++ b/drivers/net/ppp/pppoe.c
@@ -570,7 +570,7 @@ static int pppoe_release(struct socket *sock)
570 570
571 po = pppox_sk(sk); 571 po = pppox_sk(sk);
572 572
573 if (sk->sk_state & (PPPOX_CONNECTED | PPPOX_BOUND)) { 573 if (sk->sk_state & (PPPOX_CONNECTED | PPPOX_BOUND | PPPOX_ZOMBIE)) {
574 dev_put(po->pppoe_dev); 574 dev_put(po->pppoe_dev);
575 po->pppoe_dev = NULL; 575 po->pppoe_dev = NULL;
576 } 576 }
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index 341b65dbbcd3..f8cd61f449a4 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -848,7 +848,7 @@ static struct netpoll_info *team_netpoll_info(struct team *team)
848} 848}
849#endif 849#endif
850 850
851static void __team_port_change_check(struct team_port *port, bool linkup); 851static void __team_port_change_port_added(struct team_port *port, bool linkup);
852 852
853static int team_port_add(struct team *team, struct net_device *port_dev) 853static int team_port_add(struct team *team, struct net_device *port_dev)
854{ 854{
@@ -948,7 +948,7 @@ static int team_port_add(struct team *team, struct net_device *port_dev)
948 team_port_enable(team, port); 948 team_port_enable(team, port);
949 list_add_tail_rcu(&port->list, &team->port_list); 949 list_add_tail_rcu(&port->list, &team->port_list);
950 __team_compute_features(team); 950 __team_compute_features(team);
951 __team_port_change_check(port, !!netif_carrier_ok(port_dev)); 951 __team_port_change_port_added(port, !!netif_carrier_ok(port_dev));
952 __team_options_change_check(team); 952 __team_options_change_check(team);
953 953
954 netdev_info(dev, "Port device %s added\n", portname); 954 netdev_info(dev, "Port device %s added\n", portname);
@@ -983,6 +983,8 @@ err_set_mtu:
983 return err; 983 return err;
984} 984}
985 985
986static void __team_port_change_port_removed(struct team_port *port);
987
986static int team_port_del(struct team *team, struct net_device *port_dev) 988static int team_port_del(struct team *team, struct net_device *port_dev)
987{ 989{
988 struct net_device *dev = team->dev; 990 struct net_device *dev = team->dev;
@@ -999,8 +1001,7 @@ static int team_port_del(struct team *team, struct net_device *port_dev)
999 __team_option_inst_mark_removed_port(team, port); 1001 __team_option_inst_mark_removed_port(team, port);
1000 __team_options_change_check(team); 1002 __team_options_change_check(team);
1001 __team_option_inst_del_port(team, port); 1003 __team_option_inst_del_port(team, port);
1002 port->removed = true; 1004 __team_port_change_port_removed(port);
1003 __team_port_change_check(port, false);
1004 team_port_disable(team, port); 1005 team_port_disable(team, port);
1005 list_del_rcu(&port->list); 1006 list_del_rcu(&port->list);
1006 netdev_rx_handler_unregister(port_dev); 1007 netdev_rx_handler_unregister(port_dev);
@@ -1652,8 +1653,8 @@ static int team_nl_cmd_noop(struct sk_buff *skb, struct genl_info *info)
1652 1653
1653 hdr = genlmsg_put(msg, info->snd_pid, info->snd_seq, 1654 hdr = genlmsg_put(msg, info->snd_pid, info->snd_seq,
1654 &team_nl_family, 0, TEAM_CMD_NOOP); 1655 &team_nl_family, 0, TEAM_CMD_NOOP);
1655 if (IS_ERR(hdr)) { 1656 if (!hdr) {
1656 err = PTR_ERR(hdr); 1657 err = -EMSGSIZE;
1657 goto err_msg_put; 1658 goto err_msg_put;
1658 } 1659 }
1659 1660
@@ -1847,8 +1848,8 @@ start_again:
1847 1848
1848 hdr = genlmsg_put(skb, pid, seq, &team_nl_family, flags | NLM_F_MULTI, 1849 hdr = genlmsg_put(skb, pid, seq, &team_nl_family, flags | NLM_F_MULTI,
1849 TEAM_CMD_OPTIONS_GET); 1850 TEAM_CMD_OPTIONS_GET);
1850 if (IS_ERR(hdr)) 1851 if (!hdr)
1851 return PTR_ERR(hdr); 1852 return -EMSGSIZE;
1852 1853
1853 if (nla_put_u32(skb, TEAM_ATTR_TEAM_IFINDEX, team->dev->ifindex)) 1854 if (nla_put_u32(skb, TEAM_ATTR_TEAM_IFINDEX, team->dev->ifindex))
1854 goto nla_put_failure; 1855 goto nla_put_failure;
@@ -2067,8 +2068,8 @@ static int team_nl_fill_port_list_get(struct sk_buff *skb,
2067 2068
2068 hdr = genlmsg_put(skb, pid, seq, &team_nl_family, flags, 2069 hdr = genlmsg_put(skb, pid, seq, &team_nl_family, flags,
2069 TEAM_CMD_PORT_LIST_GET); 2070 TEAM_CMD_PORT_LIST_GET);
2070 if (IS_ERR(hdr)) 2071 if (!hdr)
2071 return PTR_ERR(hdr); 2072 return -EMSGSIZE;
2072 2073
2073 if (nla_put_u32(skb, TEAM_ATTR_TEAM_IFINDEX, team->dev->ifindex)) 2074 if (nla_put_u32(skb, TEAM_ATTR_TEAM_IFINDEX, team->dev->ifindex))
2074 goto nla_put_failure; 2075 goto nla_put_failure;
@@ -2251,13 +2252,11 @@ static void __team_options_change_check(struct team *team)
2251} 2252}
2252 2253
2253/* rtnl lock is held */ 2254/* rtnl lock is held */
2254static void __team_port_change_check(struct team_port *port, bool linkup) 2255
2256static void __team_port_change_send(struct team_port *port, bool linkup)
2255{ 2257{
2256 int err; 2258 int err;
2257 2259
2258 if (!port->removed && port->state.linkup == linkup)
2259 return;
2260
2261 port->changed = true; 2260 port->changed = true;
2262 port->state.linkup = linkup; 2261 port->state.linkup = linkup;
2263 team_refresh_port_linkup(port); 2262 team_refresh_port_linkup(port);
@@ -2282,6 +2281,23 @@ send_event:
2282 2281
2283} 2282}
2284 2283
2284static void __team_port_change_check(struct team_port *port, bool linkup)
2285{
2286 if (port->state.linkup != linkup)
2287 __team_port_change_send(port, linkup);
2288}
2289
2290static void __team_port_change_port_added(struct team_port *port, bool linkup)
2291{
2292 __team_port_change_send(port, linkup);
2293}
2294
2295static void __team_port_change_port_removed(struct team_port *port)
2296{
2297 port->removed = true;
2298 __team_port_change_send(port, false);
2299}
2300
2285static void team_port_change_check(struct team_port *port, bool linkup) 2301static void team_port_change_check(struct team_port *port, bool linkup)
2286{ 2302{
2287 struct team *team = port->team; 2303 struct team *team = port->team;
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 4fd48df6b989..32e31c5c5dc6 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -962,6 +962,10 @@ static const struct usb_device_id products [] = {
962 USB_DEVICE (0x2001, 0x3c05), 962 USB_DEVICE (0x2001, 0x3c05),
963 .driver_info = (unsigned long) &ax88772_info, 963 .driver_info = (unsigned long) &ax88772_info,
964}, { 964}, {
965 // DLink DUB-E100 H/W Ver C1
966 USB_DEVICE (0x2001, 0x1a02),
967 .driver_info = (unsigned long) &ax88772_info,
968}, {
965 // Linksys USB1000 969 // Linksys USB1000
966 USB_DEVICE (0x1737, 0x0039), 970 USB_DEVICE (0x1737, 0x0039),
967 .driver_info = (unsigned long) &ax88178_info, 971 .driver_info = (unsigned long) &ax88178_info,
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index b1ba68f1a049..3543c9e57824 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -366,16 +366,20 @@ static const struct usb_device_id products[] = {
366 }, 366 },
367 367
368 /* 2. Combined interface devices matching on class+protocol */ 368 /* 2. Combined interface devices matching on class+protocol */
369 { /* Huawei E367 and possibly others in "Windows mode" */
370 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 7),
371 .driver_info = (unsigned long)&qmi_wwan_info,
372 },
369 { /* Huawei E392, E398 and possibly others in "Windows mode" */ 373 { /* Huawei E392, E398 and possibly others in "Windows mode" */
370 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 17), 374 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 17),
371 .driver_info = (unsigned long)&qmi_wwan_shared, 375 .driver_info = (unsigned long)&qmi_wwan_shared,
372 }, 376 },
373 { /* Pantech UML290 */ 377 { /* Pantech UML290, P4200 and more */
374 USB_DEVICE_AND_INTERFACE_INFO(0x106c, 0x3718, USB_CLASS_VENDOR_SPEC, 0xf0, 0xff), 378 USB_VENDOR_AND_INTERFACE_INFO(0x106c, USB_CLASS_VENDOR_SPEC, 0xf0, 0xff),
375 .driver_info = (unsigned long)&qmi_wwan_shared, 379 .driver_info = (unsigned long)&qmi_wwan_shared,
376 }, 380 },
377 { /* Pantech UML290 - newer firmware */ 381 { /* Pantech UML290 - newer firmware */
378 USB_DEVICE_AND_INTERFACE_INFO(0x106c, 0x3718, USB_CLASS_VENDOR_SPEC, 0xf1, 0xff), 382 USB_VENDOR_AND_INTERFACE_INFO(0x106c, USB_CLASS_VENDOR_SPEC, 0xf1, 0xff),
379 .driver_info = (unsigned long)&qmi_wwan_shared, 383 .driver_info = (unsigned long)&qmi_wwan_shared,
380 }, 384 },
381 385
@@ -383,6 +387,7 @@ static const struct usb_device_id products[] = {
383 {QMI_FIXED_INTF(0x19d2, 0x0055, 1)}, /* ZTE (Vodafone) K3520-Z */ 387 {QMI_FIXED_INTF(0x19d2, 0x0055, 1)}, /* ZTE (Vodafone) K3520-Z */
384 {QMI_FIXED_INTF(0x19d2, 0x0063, 4)}, /* ZTE (Vodafone) K3565-Z */ 388 {QMI_FIXED_INTF(0x19d2, 0x0063, 4)}, /* ZTE (Vodafone) K3565-Z */
385 {QMI_FIXED_INTF(0x19d2, 0x0104, 4)}, /* ZTE (Vodafone) K4505-Z */ 389 {QMI_FIXED_INTF(0x19d2, 0x0104, 4)}, /* ZTE (Vodafone) K4505-Z */
390 {QMI_FIXED_INTF(0x19d2, 0x0157, 5)}, /* ZTE MF683 */
386 {QMI_FIXED_INTF(0x19d2, 0x0167, 4)}, /* ZTE MF820D */ 391 {QMI_FIXED_INTF(0x19d2, 0x0167, 4)}, /* ZTE MF820D */
387 {QMI_FIXED_INTF(0x19d2, 0x0326, 4)}, /* ZTE MF821D */ 392 {QMI_FIXED_INTF(0x19d2, 0x0326, 4)}, /* ZTE MF821D */
388 {QMI_FIXED_INTF(0x19d2, 0x1008, 4)}, /* ZTE (Vodafone) K3570-Z */ 393 {QMI_FIXED_INTF(0x19d2, 0x1008, 4)}, /* ZTE (Vodafone) K3570-Z */
diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index f5ab6e613ec8..376143e8a1aa 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -1253,6 +1253,7 @@ static struct usb_driver smsc75xx_driver = {
1253 .probe = usbnet_probe, 1253 .probe = usbnet_probe,
1254 .suspend = usbnet_suspend, 1254 .suspend = usbnet_suspend,
1255 .resume = usbnet_resume, 1255 .resume = usbnet_resume,
1256 .reset_resume = usbnet_resume,
1256 .disconnect = usbnet_disconnect, 1257 .disconnect = usbnet_disconnect,
1257 .disable_hub_initiated_lpm = 1, 1258 .disable_hub_initiated_lpm = 1,
1258}; 1259};
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index 2588848f4a82..d066f2516e47 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -2982,6 +2982,10 @@ static u32 ath9k_hw_ar9300_get_eeprom(struct ath_hw *ah,
2982 case EEP_RX_MASK: 2982 case EEP_RX_MASK:
2983 return pBase->txrxMask & 0xf; 2983 return pBase->txrxMask & 0xf;
2984 case EEP_PAPRD: 2984 case EEP_PAPRD:
2985 if (AR_SREV_9462(ah))
2986 return false;
2987 if (!ah->config.enable_paprd);
2988 return false;
2985 return !!(pBase->featureEnable & BIT(5)); 2989 return !!(pBase->featureEnable & BIT(5));
2986 case EEP_CHAIN_MASK_REDUCE: 2990 case EEP_CHAIN_MASK_REDUCE:
2987 return (pBase->miscConfiguration >> 0x3) & 0x1; 2991 return (pBase->miscConfiguration >> 0x3) & 0x1;
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index 68b643c8943c..c8ef30127adb 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -1577,6 +1577,8 @@ int ath9k_init_debug(struct ath_hw *ah)
1577 sc->debug.debugfs_phy, sc, &fops_tx_chainmask); 1577 sc->debug.debugfs_phy, sc, &fops_tx_chainmask);
1578 debugfs_create_file("disable_ani", S_IRUSR | S_IWUSR, 1578 debugfs_create_file("disable_ani", S_IRUSR | S_IWUSR,
1579 sc->debug.debugfs_phy, sc, &fops_disable_ani); 1579 sc->debug.debugfs_phy, sc, &fops_disable_ani);
1580 debugfs_create_bool("paprd", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1581 &sc->sc_ah->config.enable_paprd);
1580 debugfs_create_file("regidx", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1582 debugfs_create_file("regidx", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1581 sc, &fops_regidx); 1583 sc, &fops_regidx);
1582 debugfs_create_file("regval", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1584 debugfs_create_file("regval", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 48af40151d23..4faf0a395876 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -2497,10 +2497,6 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
2497 pCap->rx_status_len = sizeof(struct ar9003_rxs); 2497 pCap->rx_status_len = sizeof(struct ar9003_rxs);
2498 pCap->tx_desc_len = sizeof(struct ar9003_txc); 2498 pCap->tx_desc_len = sizeof(struct ar9003_txc);
2499 pCap->txs_len = sizeof(struct ar9003_txs); 2499 pCap->txs_len = sizeof(struct ar9003_txs);
2500 if (!ah->config.paprd_disable &&
2501 ah->eep_ops->get_eeprom(ah, EEP_PAPRD) &&
2502 !AR_SREV_9462(ah))
2503 pCap->hw_caps |= ATH9K_HW_CAP_PAPRD;
2504 } else { 2500 } else {
2505 pCap->tx_desc_len = sizeof(struct ath_desc); 2501 pCap->tx_desc_len = sizeof(struct ath_desc);
2506 if (AR_SREV_9280_20(ah)) 2502 if (AR_SREV_9280_20(ah))
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 6599a75f01fe..de6968fc64f4 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -236,7 +236,6 @@ enum ath9k_hw_caps {
236 ATH9K_HW_CAP_LDPC = BIT(6), 236 ATH9K_HW_CAP_LDPC = BIT(6),
237 ATH9K_HW_CAP_FASTCLOCK = BIT(7), 237 ATH9K_HW_CAP_FASTCLOCK = BIT(7),
238 ATH9K_HW_CAP_SGI_20 = BIT(8), 238 ATH9K_HW_CAP_SGI_20 = BIT(8),
239 ATH9K_HW_CAP_PAPRD = BIT(9),
240 ATH9K_HW_CAP_ANT_DIV_COMB = BIT(10), 239 ATH9K_HW_CAP_ANT_DIV_COMB = BIT(10),
241 ATH9K_HW_CAP_2GHZ = BIT(11), 240 ATH9K_HW_CAP_2GHZ = BIT(11),
242 ATH9K_HW_CAP_5GHZ = BIT(12), 241 ATH9K_HW_CAP_5GHZ = BIT(12),
@@ -287,12 +286,12 @@ struct ath9k_ops_config {
287 u8 pcie_clock_req; 286 u8 pcie_clock_req;
288 u32 pcie_waen; 287 u32 pcie_waen;
289 u8 analog_shiftreg; 288 u8 analog_shiftreg;
290 u8 paprd_disable;
291 u32 ofdm_trig_low; 289 u32 ofdm_trig_low;
292 u32 ofdm_trig_high; 290 u32 ofdm_trig_high;
293 u32 cck_trig_high; 291 u32 cck_trig_high;
294 u32 cck_trig_low; 292 u32 cck_trig_low;
295 u32 enable_ani; 293 u32 enable_ani;
294 u32 enable_paprd;
296 int serialize_regmode; 295 int serialize_regmode;
297 bool rx_intr_mitigation; 296 bool rx_intr_mitigation;
298 bool tx_intr_mitigation; 297 bool tx_intr_mitigation;
diff --git a/drivers/net/wireless/ath/ath9k/link.c b/drivers/net/wireless/ath/ath9k/link.c
index 825a29cc9313..7b88b9c39ccd 100644
--- a/drivers/net/wireless/ath/ath9k/link.c
+++ b/drivers/net/wireless/ath/ath9k/link.c
@@ -423,7 +423,7 @@ set_timer:
423 cal_interval = min(cal_interval, (u32)short_cal_interval); 423 cal_interval = min(cal_interval, (u32)short_cal_interval);
424 424
425 mod_timer(&common->ani.timer, jiffies + msecs_to_jiffies(cal_interval)); 425 mod_timer(&common->ani.timer, jiffies + msecs_to_jiffies(cal_interval));
426 if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_PAPRD) && ah->caldata) { 426 if (ah->eep_ops->get_eeprom(ah, EEP_PAPRD) && ah->caldata) {
427 if (!ah->caldata->paprd_done) 427 if (!ah->caldata->paprd_done)
428 ieee80211_queue_work(sc->hw, &sc->paprd_work); 428 ieee80211_queue_work(sc->hw, &sc->paprd_work);
429 else if (!ah->paprd_table_write_done) 429 else if (!ah->paprd_table_write_done)
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c
index 49765d34b4e0..7c4ee72f9d56 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c
@@ -638,6 +638,8 @@ static int brcmf_sdio_pd_probe(struct platform_device *pdev)
638 638
639 oobirq_entry = kzalloc(sizeof(struct brcmf_sdio_oobirq), 639 oobirq_entry = kzalloc(sizeof(struct brcmf_sdio_oobirq),
640 GFP_KERNEL); 640 GFP_KERNEL);
641 if (!oobirq_entry)
642 return -ENOMEM;
641 oobirq_entry->irq = res->start; 643 oobirq_entry->irq = res->start;
642 oobirq_entry->flags = res->flags & IRQF_TRIGGER_MASK; 644 oobirq_entry->flags = res->flags & IRQF_TRIGGER_MASK;
643 list_add_tail(&oobirq_entry->list, &oobirq_lh); 645 list_add_tail(&oobirq_entry->list, &oobirq_lh);
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c
index 2621dd3d7dcd..6f70953f0bad 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c
@@ -764,8 +764,11 @@ static void brcmf_c_arp_offload_set(struct brcmf_pub *drvr, int arp_mode)
764{ 764{
765 char iovbuf[32]; 765 char iovbuf[32];
766 int retcode; 766 int retcode;
767 __le32 arp_mode_le;
767 768
768 brcmf_c_mkiovar("arp_ol", (char *)&arp_mode, 4, iovbuf, sizeof(iovbuf)); 769 arp_mode_le = cpu_to_le32(arp_mode);
770 brcmf_c_mkiovar("arp_ol", (char *)&arp_mode_le, 4, iovbuf,
771 sizeof(iovbuf));
769 retcode = brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, 772 retcode = brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR,
770 iovbuf, sizeof(iovbuf)); 773 iovbuf, sizeof(iovbuf));
771 retcode = retcode >= 0 ? 0 : retcode; 774 retcode = retcode >= 0 ? 0 : retcode;
@@ -781,8 +784,11 @@ static void brcmf_c_arp_offload_enable(struct brcmf_pub *drvr, int arp_enable)
781{ 784{
782 char iovbuf[32]; 785 char iovbuf[32];
783 int retcode; 786 int retcode;
787 __le32 arp_enable_le;
784 788
785 brcmf_c_mkiovar("arpoe", (char *)&arp_enable, 4, 789 arp_enable_le = cpu_to_le32(arp_enable);
790
791 brcmf_c_mkiovar("arpoe", (char *)&arp_enable_le, 4,
786 iovbuf, sizeof(iovbuf)); 792 iovbuf, sizeof(iovbuf));
787 retcode = brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, 793 retcode = brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR,
788 iovbuf, sizeof(iovbuf)); 794 iovbuf, sizeof(iovbuf));
@@ -800,10 +806,10 @@ int brcmf_c_preinit_dcmds(struct brcmf_pub *drvr)
800 char iovbuf[BRCMF_EVENTING_MASK_LEN + 12]; /* Room for 806 char iovbuf[BRCMF_EVENTING_MASK_LEN + 12]; /* Room for
801 "event_msgs" + '\0' + bitvec */ 807 "event_msgs" + '\0' + bitvec */
802 char buf[128], *ptr; 808 char buf[128], *ptr;
803 u32 roaming = 1; 809 __le32 roaming_le = cpu_to_le32(1);
804 uint bcn_timeout = 3; 810 __le32 bcn_timeout_le = cpu_to_le32(3);
805 int scan_assoc_time = 40; 811 __le32 scan_assoc_time_le = cpu_to_le32(40);
806 int scan_unassoc_time = 40; 812 __le32 scan_unassoc_time_le = cpu_to_le32(40);
807 int i; 813 int i;
808 struct brcmf_bus_dcmd *cmdlst; 814 struct brcmf_bus_dcmd *cmdlst;
809 struct list_head *cur, *q; 815 struct list_head *cur, *q;
@@ -829,14 +835,14 @@ int brcmf_c_preinit_dcmds(struct brcmf_pub *drvr)
829 835
830 /* Setup timeout if Beacons are lost and roam is off to report 836 /* Setup timeout if Beacons are lost and roam is off to report
831 link down */ 837 link down */
832 brcmf_c_mkiovar("bcn_timeout", (char *)&bcn_timeout, 4, iovbuf, 838 brcmf_c_mkiovar("bcn_timeout", (char *)&bcn_timeout_le, 4, iovbuf,
833 sizeof(iovbuf)); 839 sizeof(iovbuf));
834 brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf, 840 brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf,
835 sizeof(iovbuf)); 841 sizeof(iovbuf));
836 842
837 /* Enable/Disable build-in roaming to allowed ext supplicant to take 843 /* Enable/Disable build-in roaming to allowed ext supplicant to take
838 of romaing */ 844 of romaing */
839 brcmf_c_mkiovar("roam_off", (char *)&roaming, 4, 845 brcmf_c_mkiovar("roam_off", (char *)&roaming_le, 4,
840 iovbuf, sizeof(iovbuf)); 846 iovbuf, sizeof(iovbuf));
841 brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf, 847 brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, iovbuf,
842 sizeof(iovbuf)); 848 sizeof(iovbuf));
@@ -848,9 +854,9 @@ int brcmf_c_preinit_dcmds(struct brcmf_pub *drvr)
848 sizeof(iovbuf)); 854 sizeof(iovbuf));
849 855
850 brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_SCAN_CHANNEL_TIME, 856 brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_SCAN_CHANNEL_TIME,
851 (char *)&scan_assoc_time, sizeof(scan_assoc_time)); 857 (char *)&scan_assoc_time_le, sizeof(scan_assoc_time_le));
852 brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_SCAN_UNASSOC_TIME, 858 brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_SCAN_UNASSOC_TIME,
853 (char *)&scan_unassoc_time, sizeof(scan_unassoc_time)); 859 (char *)&scan_unassoc_time_le, sizeof(scan_unassoc_time_le));
854 860
855 /* Set and enable ARP offload feature */ 861 /* Set and enable ARP offload feature */
856 brcmf_c_arp_offload_set(drvr, BRCMF_ARPOL_MODE); 862 brcmf_c_arp_offload_set(drvr, BRCMF_ARPOL_MODE);
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
index c36e92312443..50b5553b6964 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
@@ -500,8 +500,10 @@ static void wl_iscan_prep(struct brcmf_scan_params_le *params_le,
500 params_le->active_time = cpu_to_le32(-1); 500 params_le->active_time = cpu_to_le32(-1);
501 params_le->passive_time = cpu_to_le32(-1); 501 params_le->passive_time = cpu_to_le32(-1);
502 params_le->home_time = cpu_to_le32(-1); 502 params_le->home_time = cpu_to_le32(-1);
503 if (ssid && ssid->SSID_len) 503 if (ssid && ssid->SSID_len) {
504 memcpy(&params_le->ssid_le, ssid, sizeof(struct brcmf_ssid)); 504 params_le->ssid_le.SSID_len = cpu_to_le32(ssid->SSID_len);
505 memcpy(&params_le->ssid_le.SSID, ssid->SSID, ssid->SSID_len);
506 }
505} 507}
506 508
507static s32 509static s32
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/channel.c b/drivers/net/wireless/brcm80211/brcmsmac/channel.c
index 7ed7d7577024..64a48f06d68b 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/channel.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/channel.c
@@ -77,7 +77,7 @@
77 NL80211_RRF_NO_IBSS) 77 NL80211_RRF_NO_IBSS)
78 78
79static const struct ieee80211_regdomain brcms_regdom_x2 = { 79static const struct ieee80211_regdomain brcms_regdom_x2 = {
80 .n_reg_rules = 7, 80 .n_reg_rules = 6,
81 .alpha2 = "X2", 81 .alpha2 = "X2",
82 .reg_rules = { 82 .reg_rules = {
83 BRCM_2GHZ_2412_2462, 83 BRCM_2GHZ_2412_2462,
diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
index 1e86ea2266d4..dbeebef562d5 100644
--- a/drivers/net/wireless/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
@@ -1442,6 +1442,7 @@ static int iwl_trans_pcie_start_hw(struct iwl_trans *trans)
1442 return err; 1442 return err;
1443 1443
1444err_free_irq: 1444err_free_irq:
1445 trans_pcie->irq_requested = false;
1445 free_irq(trans_pcie->irq, trans); 1446 free_irq(trans_pcie->irq, trans);
1446error: 1447error:
1447 iwl_free_isr_ict(trans); 1448 iwl_free_isr_ict(trans);
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/def.h b/drivers/net/wireless/rtlwifi/rtl8192ce/def.h
index 04c3aef8a4f6..2925094b2d91 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/def.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/def.h
@@ -117,6 +117,7 @@
117 117
118#define CHIP_VER_B BIT(4) 118#define CHIP_VER_B BIT(4)
119#define CHIP_92C_BITMASK BIT(0) 119#define CHIP_92C_BITMASK BIT(0)
120#define CHIP_UNKNOWN BIT(7)
120#define CHIP_92C_1T2R 0x03 121#define CHIP_92C_1T2R 0x03
121#define CHIP_92C 0x01 122#define CHIP_92C 0x01
122#define CHIP_88C 0x00 123#define CHIP_88C 0x00
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
index bd0da7ef290b..dd4bb0950a57 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
@@ -994,8 +994,16 @@ static enum version_8192c _rtl92ce_read_chip_version(struct ieee80211_hw *hw)
994 version = (value32 & TYPE_ID) ? VERSION_A_CHIP_92C : 994 version = (value32 & TYPE_ID) ? VERSION_A_CHIP_92C :
995 VERSION_A_CHIP_88C; 995 VERSION_A_CHIP_88C;
996 } else { 996 } else {
997 version = (value32 & TYPE_ID) ? VERSION_B_CHIP_92C : 997 version = (enum version_8192c) (CHIP_VER_B |
998 VERSION_B_CHIP_88C; 998 ((value32 & TYPE_ID) ? CHIP_92C_BITMASK : 0) |
999 ((value32 & VENDOR_ID) ? CHIP_VENDOR_UMC : 0));
1000 if ((!IS_CHIP_VENDOR_UMC(version)) && (value32 &
1001 CHIP_VER_RTL_MASK)) {
1002 version = (enum version_8192c)(version |
1003 ((((value32 & CHIP_VER_RTL_MASK) == BIT(12))
1004 ? CHIP_VENDOR_UMC_B_CUT : CHIP_UNKNOWN) |
1005 CHIP_VENDOR_UMC));
1006 }
999 } 1007 }
1000 1008
1001 switch (version) { 1009 switch (version) {
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
index 3aa927f8b9b9..7d8f96405f42 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
@@ -162,10 +162,12 @@ int rtl92c_init_sw_vars(struct ieee80211_hw *hw)
162 162
163 /* request fw */ 163 /* request fw */
164 if (IS_VENDOR_UMC_A_CUT(rtlhal->version) && 164 if (IS_VENDOR_UMC_A_CUT(rtlhal->version) &&
165 !IS_92C_SERIAL(rtlhal->version)) 165 !IS_92C_SERIAL(rtlhal->version)) {
166 rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cfwU.bin"; 166 rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cfwU.bin";
167 else if (IS_81xxC_VENDOR_UMC_B_CUT(rtlhal->version)) 167 } else if (IS_81xxC_VENDOR_UMC_B_CUT(rtlhal->version)) {
168 rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cfwU_B.bin"; 168 rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cfwU_B.bin";
169 pr_info("****** This B_CUT device may not work with kernels 3.6 and earlier\n");
170 }
169 171
170 rtlpriv->max_fw_size = 0x4000; 172 rtlpriv->max_fw_size = 0x4000;
171 pr_info("Using firmware %s\n", rtlpriv->cfg->fw_name); 173 pr_info("Using firmware %s\n", rtlpriv->cfg->fw_name);
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index 507a8e2b9a4c..26b5d4b18dd7 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -321,14 +321,9 @@ static int __init acpi_pnp_match(struct device *dev, void *_pnp)
321{ 321{
322 struct acpi_device *acpi = to_acpi_device(dev); 322 struct acpi_device *acpi = to_acpi_device(dev);
323 struct pnp_dev *pnp = _pnp; 323 struct pnp_dev *pnp = _pnp;
324 struct device *physical_device;
325
326 physical_device = acpi_get_physical_device(acpi->handle);
327 if (physical_device)
328 put_device(physical_device);
329 324
330 /* true means it matched */ 325 /* true means it matched */
331 return !physical_device 326 return !acpi->physical_node_count
332 && compare_pnp_id(pnp->id, acpi_device_hid(acpi)); 327 && compare_pnp_id(pnp->id, acpi_device_hid(acpi));
333} 328}
334 329
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 15370a2c5ff0..0595c763dafd 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -534,11 +534,11 @@ static void dasd_change_state(struct dasd_device *device)
534 if (rc) 534 if (rc)
535 device->target = device->state; 535 device->target = device->state;
536 536
537 if (device->state == device->target)
538 wake_up(&dasd_init_waitq);
539
540 /* let user-space know that the device status changed */ 537 /* let user-space know that the device status changed */
541 kobject_uevent(&device->cdev->dev.kobj, KOBJ_CHANGE); 538 kobject_uevent(&device->cdev->dev.kobj, KOBJ_CHANGE);
539
540 if (device->state == device->target)
541 wake_up(&dasd_init_waitq);
542} 542}
543 543
544/* 544/*
@@ -2157,6 +2157,7 @@ static int _dasd_sleep_on(struct dasd_ccw_req *maincqr, int interruptible)
2157 test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags) && 2157 test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags) &&
2158 (!dasd_eer_enabled(device))) { 2158 (!dasd_eer_enabled(device))) {
2159 cqr->status = DASD_CQR_FAILED; 2159 cqr->status = DASD_CQR_FAILED;
2160 cqr->intrc = -EAGAIN;
2160 continue; 2161 continue;
2161 } 2162 }
2162 /* Don't try to start requests if device is stopped */ 2163 /* Don't try to start requests if device is stopped */
@@ -3270,6 +3271,16 @@ void dasd_generic_path_event(struct ccw_device *cdev, int *path_event)
3270 dasd_schedule_device_bh(device); 3271 dasd_schedule_device_bh(device);
3271 } 3272 }
3272 if (path_event[chp] & PE_PATHGROUP_ESTABLISHED) { 3273 if (path_event[chp] & PE_PATHGROUP_ESTABLISHED) {
3274 if (!(device->path_data.opm & eventlpm) &&
3275 !(device->path_data.tbvpm & eventlpm)) {
3276 /*
3277 * we can not establish a pathgroup on an
3278 * unavailable path, so trigger a path
3279 * verification first
3280 */
3281 device->path_data.tbvpm |= eventlpm;
3282 dasd_schedule_device_bh(device);
3283 }
3273 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 3284 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
3274 "Pathgroup re-established\n"); 3285 "Pathgroup re-established\n");
3275 if (device->discipline->kick_validate) 3286 if (device->discipline->kick_validate)
diff --git a/drivers/s390/block/dasd_alias.c b/drivers/s390/block/dasd_alias.c
index 157defe5e069..6b556995bb33 100644
--- a/drivers/s390/block/dasd_alias.c
+++ b/drivers/s390/block/dasd_alias.c
@@ -384,6 +384,29 @@ static void _remove_device_from_lcu(struct alias_lcu *lcu,
384 group->next = NULL; 384 group->next = NULL;
385}; 385};
386 386
387static int
388suborder_not_supported(struct dasd_ccw_req *cqr)
389{
390 char *sense;
391 char reason;
392 char msg_format;
393 char msg_no;
394
395 sense = dasd_get_sense(&cqr->irb);
396 if (!sense)
397 return 0;
398
399 reason = sense[0];
400 msg_format = (sense[7] & 0xF0);
401 msg_no = (sense[7] & 0x0F);
402
403 /* command reject, Format 0 MSG 4 - invalid parameter */
404 if ((reason == 0x80) && (msg_format == 0x00) && (msg_no == 0x04))
405 return 1;
406
407 return 0;
408}
409
387static int read_unit_address_configuration(struct dasd_device *device, 410static int read_unit_address_configuration(struct dasd_device *device,
388 struct alias_lcu *lcu) 411 struct alias_lcu *lcu)
389{ 412{
@@ -435,6 +458,8 @@ static int read_unit_address_configuration(struct dasd_device *device,
435 458
436 do { 459 do {
437 rc = dasd_sleep_on(cqr); 460 rc = dasd_sleep_on(cqr);
461 if (rc && suborder_not_supported(cqr))
462 return -EOPNOTSUPP;
438 } while (rc && (cqr->retries > 0)); 463 } while (rc && (cqr->retries > 0));
439 if (rc) { 464 if (rc) {
440 spin_lock_irqsave(&lcu->lock, flags); 465 spin_lock_irqsave(&lcu->lock, flags);
@@ -521,7 +546,7 @@ static void lcu_update_work(struct work_struct *work)
521 * processing the data 546 * processing the data
522 */ 547 */
523 spin_lock_irqsave(&lcu->lock, flags); 548 spin_lock_irqsave(&lcu->lock, flags);
524 if (rc || (lcu->flags & NEED_UAC_UPDATE)) { 549 if ((rc && (rc != -EOPNOTSUPP)) || (lcu->flags & NEED_UAC_UPDATE)) {
525 DBF_DEV_EVENT(DBF_WARNING, device, "could not update" 550 DBF_DEV_EVENT(DBF_WARNING, device, "could not update"
526 " alias data in lcu (rc = %d), retry later", rc); 551 " alias data in lcu (rc = %d), retry later", rc);
527 schedule_delayed_work(&lcu->ruac_data.dwork, 30*HZ); 552 schedule_delayed_work(&lcu->ruac_data.dwork, 30*HZ);
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index 2fb2b9ea97ec..c48c72abbefc 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -1507,7 +1507,8 @@ static struct dasd_ccw_req *dasd_eckd_build_psf_ssc(struct dasd_device *device,
1507 * call might change behaviour of DASD devices. 1507 * call might change behaviour of DASD devices.
1508 */ 1508 */
1509static int 1509static int
1510dasd_eckd_psf_ssc(struct dasd_device *device, int enable_pav) 1510dasd_eckd_psf_ssc(struct dasd_device *device, int enable_pav,
1511 unsigned long flags)
1511{ 1512{
1512 struct dasd_ccw_req *cqr; 1513 struct dasd_ccw_req *cqr;
1513 int rc; 1514 int rc;
@@ -1516,10 +1517,19 @@ dasd_eckd_psf_ssc(struct dasd_device *device, int enable_pav)
1516 if (IS_ERR(cqr)) 1517 if (IS_ERR(cqr))
1517 return PTR_ERR(cqr); 1518 return PTR_ERR(cqr);
1518 1519
1520 /*
1521 * set flags e.g. turn on failfast, to prevent blocking
1522 * the calling function should handle failed requests
1523 */
1524 cqr->flags |= flags;
1525
1519 rc = dasd_sleep_on(cqr); 1526 rc = dasd_sleep_on(cqr);
1520 if (!rc) 1527 if (!rc)
1521 /* trigger CIO to reprobe devices */ 1528 /* trigger CIO to reprobe devices */
1522 css_schedule_reprobe(); 1529 css_schedule_reprobe();
1530 else if (cqr->intrc == -EAGAIN)
1531 rc = -EAGAIN;
1532
1523 dasd_sfree_request(cqr, cqr->memdev); 1533 dasd_sfree_request(cqr, cqr->memdev);
1524 return rc; 1534 return rc;
1525} 1535}
@@ -1527,7 +1537,8 @@ dasd_eckd_psf_ssc(struct dasd_device *device, int enable_pav)
1527/* 1537/*
1528 * Valide storage server of current device. 1538 * Valide storage server of current device.
1529 */ 1539 */
1530static void dasd_eckd_validate_server(struct dasd_device *device) 1540static int dasd_eckd_validate_server(struct dasd_device *device,
1541 unsigned long flags)
1531{ 1542{
1532 int rc; 1543 int rc;
1533 struct dasd_eckd_private *private; 1544 struct dasd_eckd_private *private;
@@ -1536,17 +1547,18 @@ static void dasd_eckd_validate_server(struct dasd_device *device)
1536 private = (struct dasd_eckd_private *) device->private; 1547 private = (struct dasd_eckd_private *) device->private;
1537 if (private->uid.type == UA_BASE_PAV_ALIAS || 1548 if (private->uid.type == UA_BASE_PAV_ALIAS ||
1538 private->uid.type == UA_HYPER_PAV_ALIAS) 1549 private->uid.type == UA_HYPER_PAV_ALIAS)
1539 return; 1550 return 0;
1540 if (dasd_nopav || MACHINE_IS_VM) 1551 if (dasd_nopav || MACHINE_IS_VM)
1541 enable_pav = 0; 1552 enable_pav = 0;
1542 else 1553 else
1543 enable_pav = 1; 1554 enable_pav = 1;
1544 rc = dasd_eckd_psf_ssc(device, enable_pav); 1555 rc = dasd_eckd_psf_ssc(device, enable_pav, flags);
1545 1556
1546 /* may be requested feature is not available on server, 1557 /* may be requested feature is not available on server,
1547 * therefore just report error and go ahead */ 1558 * therefore just report error and go ahead */
1548 DBF_EVENT_DEVID(DBF_WARNING, device->cdev, "PSF-SSC for SSID %04x " 1559 DBF_EVENT_DEVID(DBF_WARNING, device->cdev, "PSF-SSC for SSID %04x "
1549 "returned rc=%d", private->uid.ssid, rc); 1560 "returned rc=%d", private->uid.ssid, rc);
1561 return rc;
1550} 1562}
1551 1563
1552/* 1564/*
@@ -1556,7 +1568,13 @@ static void dasd_eckd_do_validate_server(struct work_struct *work)
1556{ 1568{
1557 struct dasd_device *device = container_of(work, struct dasd_device, 1569 struct dasd_device *device = container_of(work, struct dasd_device,
1558 kick_validate); 1570 kick_validate);
1559 dasd_eckd_validate_server(device); 1571 if (dasd_eckd_validate_server(device, DASD_CQR_FLAGS_FAILFAST)
1572 == -EAGAIN) {
1573 /* schedule worker again if failed */
1574 schedule_work(&device->kick_validate);
1575 return;
1576 }
1577
1560 dasd_put_device(device); 1578 dasd_put_device(device);
1561} 1579}
1562 1580
@@ -1685,7 +1703,7 @@ dasd_eckd_check_characteristics(struct dasd_device *device)
1685 if (rc) 1703 if (rc)
1686 goto out_err2; 1704 goto out_err2;
1687 1705
1688 dasd_eckd_validate_server(device); 1706 dasd_eckd_validate_server(device, 0);
1689 1707
1690 /* device may report different configuration data after LCU setup */ 1708 /* device may report different configuration data after LCU setup */
1691 rc = dasd_eckd_read_conf(device); 1709 rc = dasd_eckd_read_conf(device);
@@ -4153,7 +4171,7 @@ static int dasd_eckd_restore_device(struct dasd_device *device)
4153 rc = dasd_alias_make_device_known_to_lcu(device); 4171 rc = dasd_alias_make_device_known_to_lcu(device);
4154 if (rc) 4172 if (rc)
4155 return rc; 4173 return rc;
4156 dasd_eckd_validate_server(device); 4174 dasd_eckd_validate_server(device, DASD_CQR_FLAGS_FAILFAST);
4157 4175
4158 /* RE-Read Configuration Data */ 4176 /* RE-Read Configuration Data */
4159 rc = dasd_eckd_read_conf(device); 4177 rc = dasd_eckd_read_conf(device);
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index ed25c8740a9c..fc916f5d7314 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -1426,6 +1426,8 @@ static enum io_sch_action sch_get_action(struct subchannel *sch)
1426 return IO_SCH_REPROBE; 1426 return IO_SCH_REPROBE;
1427 if (cdev->online) 1427 if (cdev->online)
1428 return IO_SCH_VERIFY; 1428 return IO_SCH_VERIFY;
1429 if (cdev->private->state == DEV_STATE_NOT_OPER)
1430 return IO_SCH_UNREG_ATTACH;
1429 return IO_SCH_NOP; 1431 return IO_SCH_NOP;
1430} 1432}
1431 1433
@@ -1519,11 +1521,14 @@ static int io_subchannel_sch_event(struct subchannel *sch, int process)
1519 goto out; 1521 goto out;
1520 break; 1522 break;
1521 case IO_SCH_UNREG_ATTACH: 1523 case IO_SCH_UNREG_ATTACH:
1524 spin_lock_irqsave(sch->lock, flags);
1522 if (cdev->private->flags.resuming) { 1525 if (cdev->private->flags.resuming) {
1523 /* Device will be handled later. */ 1526 /* Device will be handled later. */
1524 rc = 0; 1527 rc = 0;
1525 goto out; 1528 goto out_unlock;
1526 } 1529 }
1530 sch_set_cdev(sch, NULL);
1531 spin_unlock_irqrestore(sch->lock, flags);
1527 /* Unregister ccw device. */ 1532 /* Unregister ccw device. */
1528 ccw_device_unregister(cdev); 1533 ccw_device_unregister(cdev);
1529 break; 1534 break;
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 33d6630529de..91eec60252ee 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -1264,6 +1264,9 @@ int bnx2i_send_fw_iscsi_init_msg(struct bnx2i_hba *hba)
1264 int rc = 0; 1264 int rc = 0;
1265 u64 mask64; 1265 u64 mask64;
1266 1266
1267 memset(&iscsi_init, 0x00, sizeof(struct iscsi_kwqe_init1));
1268 memset(&iscsi_init2, 0x00, sizeof(struct iscsi_kwqe_init2));
1269
1267 bnx2i_adjust_qp_size(hba); 1270 bnx2i_adjust_qp_size(hba);
1268 1271
1269 iscsi_init.flags = 1272 iscsi_init.flags =
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 796482badf13..2b4261cb7742 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -1315,8 +1315,9 @@ static void complete_scsi_command(struct CommandList *cp)
1315 } 1315 }
1316 break; 1316 break;
1317 case CMD_PROTOCOL_ERR: 1317 case CMD_PROTOCOL_ERR:
1318 cmd->result = DID_ERROR << 16;
1318 dev_warn(&h->pdev->dev, "cp %p has " 1319 dev_warn(&h->pdev->dev, "cp %p has "
1319 "protocol error \n", cp); 1320 "protocol error\n", cp);
1320 break; 1321 break;
1321 case CMD_HARDWARE_ERR: 1322 case CMD_HARDWARE_ERR:
1322 cmd->result = DID_ERROR << 16; 1323 cmd->result = DID_ERROR << 16;
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c
index b25757d1e91b..9d5a56c4b332 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
@@ -1209,6 +1209,13 @@ _base_check_enable_msix(struct MPT2SAS_ADAPTER *ioc)
1209 u16 message_control; 1209 u16 message_control;
1210 1210
1211 1211
1212 /* Check whether controller SAS2008 B0 controller,
1213 if it is SAS2008 B0 controller use IO-APIC instead of MSIX */
1214 if (ioc->pdev->device == MPI2_MFGPAGE_DEVID_SAS2008 &&
1215 ioc->pdev->revision == 0x01) {
1216 return -EINVAL;
1217 }
1218
1212 base = pci_find_capability(ioc->pdev, PCI_CAP_ID_MSIX); 1219 base = pci_find_capability(ioc->pdev, PCI_CAP_ID_MSIX);
1213 if (!base) { 1220 if (!base) {
1214 dfailprintk(ioc, printk(MPT2SAS_INFO_FMT "msix not " 1221 dfailprintk(ioc, printk(MPT2SAS_INFO_FMT "msix not "
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index c7030fbee79c..3e79a2f00042 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -331,7 +331,7 @@ static void virtscsi_map_sgl(struct scatterlist *sg, unsigned int *p_idx,
331 int i; 331 int i;
332 332
333 for_each_sg(table->sgl, sg_elem, table->nents, i) 333 for_each_sg(table->sgl, sg_elem, table->nents, i)
334 sg_set_buf(&sg[idx++], sg_virt(sg_elem), sg_elem->length); 334 sg[idx++] = *sg_elem;
335 335
336 *p_idx = idx; 336 *p_idx = idx;
337} 337}
diff --git a/drivers/sh/pfc/pinctrl.c b/drivers/sh/pfc/pinctrl.c
index a3ac39b79192..0646bf6e7889 100644
--- a/drivers/sh/pfc/pinctrl.c
+++ b/drivers/sh/pfc/pinctrl.c
@@ -208,6 +208,8 @@ static int sh_pfc_gpio_request_enable(struct pinctrl_dev *pctldev,
208 208
209 break; 209 break;
210 case PINMUX_TYPE_GPIO: 210 case PINMUX_TYPE_GPIO:
211 case PINMUX_TYPE_INPUT:
212 case PINMUX_TYPE_OUTPUT:
211 break; 213 break;
212 default: 214 default:
213 pr_err("Unsupported mux type (%d), bailing...\n", pinmux_type); 215 pr_err("Unsupported mux type (%d), bailing...\n", pinmux_type);
diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
index d95696584762..3440812b4a84 100644
--- a/drivers/usb/core/devices.c
+++ b/drivers/usb/core/devices.c
@@ -624,7 +624,7 @@ static ssize_t usb_device_read(struct file *file, char __user *buf,
624 /* print devices for all busses */ 624 /* print devices for all busses */
625 list_for_each_entry(bus, &usb_bus_list, bus_list) { 625 list_for_each_entry(bus, &usb_bus_list, bus_list) {
626 /* recurse through all children of the root hub */ 626 /* recurse through all children of the root hub */
627 if (!bus->root_hub) 627 if (!bus_to_hcd(bus)->rh_registered)
628 continue; 628 continue;
629 usb_lock_device(bus->root_hub); 629 usb_lock_device(bus->root_hub);
630 ret = usb_device_dump(&buf, &nbytes, &skip_bytes, ppos, 630 ret = usb_device_dump(&buf, &nbytes, &skip_bytes, ppos,
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index bc84106ac057..75ba2091f9b4 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1011,10 +1011,7 @@ static int register_root_hub(struct usb_hcd *hcd)
1011 if (retval) { 1011 if (retval) {
1012 dev_err (parent_dev, "can't register root hub for %s, %d\n", 1012 dev_err (parent_dev, "can't register root hub for %s, %d\n",
1013 dev_name(&usb_dev->dev), retval); 1013 dev_name(&usb_dev->dev), retval);
1014 } 1014 } else {
1015 mutex_unlock(&usb_bus_list_lock);
1016
1017 if (retval == 0) {
1018 spin_lock_irq (&hcd_root_hub_lock); 1015 spin_lock_irq (&hcd_root_hub_lock);
1019 hcd->rh_registered = 1; 1016 hcd->rh_registered = 1;
1020 spin_unlock_irq (&hcd_root_hub_lock); 1017 spin_unlock_irq (&hcd_root_hub_lock);
@@ -1023,6 +1020,7 @@ static int register_root_hub(struct usb_hcd *hcd)
1023 if (HCD_DEAD(hcd)) 1020 if (HCD_DEAD(hcd))
1024 usb_hc_died (hcd); /* This time clean up */ 1021 usb_hc_died (hcd); /* This time clean up */
1025 } 1022 }
1023 mutex_unlock(&usb_bus_list_lock);
1026 1024
1027 return retval; 1025 return retval;
1028} 1026}
diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c
index 8947b203d5a4..ce45f5535236 100644
--- a/drivers/usb/core/usb-acpi.c
+++ b/drivers/usb/core/usb-acpi.c
@@ -52,18 +52,19 @@ out:
52static int usb_acpi_check_pld(struct usb_device *udev, acpi_handle handle) 52static int usb_acpi_check_pld(struct usb_device *udev, acpi_handle handle)
53{ 53{
54 acpi_status status; 54 acpi_status status;
55 struct acpi_pld pld; 55 struct acpi_pld_info *pld;
56 56
57 status = acpi_get_physical_device_location(handle, &pld); 57 status = acpi_get_physical_device_location(handle, &pld);
58 58
59 if (ACPI_FAILURE(status)) 59 if (ACPI_FAILURE(status))
60 return -ENODEV; 60 return -ENODEV;
61 61
62 if (pld.user_visible) 62 if (pld->user_visible)
63 udev->removable = USB_DEVICE_REMOVABLE; 63 udev->removable = USB_DEVICE_REMOVABLE;
64 else 64 else
65 udev->removable = USB_DEVICE_FIXED; 65 udev->removable = USB_DEVICE_FIXED;
66 66
67 ACPI_FREE(pld);
67 return 0; 68 return 0;
68} 69}
69 70
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index aaa8d2bce217..0bf72f943b00 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -467,7 +467,8 @@ static irqreturn_t ohci_hcd_at91_overcurrent_irq(int irq, void *data)
467 /* From the GPIO notifying the over-current situation, find 467 /* From the GPIO notifying the over-current situation, find
468 * out the corresponding port */ 468 * out the corresponding port */
469 at91_for_each_port(port) { 469 at91_for_each_port(port) {
470 if (gpio_to_irq(pdata->overcurrent_pin[port]) == irq) { 470 if (gpio_is_valid(pdata->overcurrent_pin[port]) &&
471 gpio_to_irq(pdata->overcurrent_pin[port]) == irq) {
471 gpio = pdata->overcurrent_pin[port]; 472 gpio = pdata->overcurrent_pin[port];
472 break; 473 break;
473 } 474 }
diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c
index 211a4920b88a..d8dedc7d3910 100644
--- a/drivers/vfio/pci/vfio_pci_intrs.c
+++ b/drivers/vfio/pci/vfio_pci_intrs.c
@@ -76,9 +76,24 @@ static int virqfd_wakeup(wait_queue_t *wait, unsigned mode, int sync, void *key)
76 schedule_work(&virqfd->inject); 76 schedule_work(&virqfd->inject);
77 } 77 }
78 78
79 if (flags & POLLHUP) 79 if (flags & POLLHUP) {
80 /* The eventfd is closing, detach from VFIO */ 80 unsigned long flags;
81 virqfd_deactivate(virqfd); 81 spin_lock_irqsave(&virqfd->vdev->irqlock, flags);
82
83 /*
84 * The eventfd is closing, if the virqfd has not yet been
85 * queued for release, as determined by testing whether the
86 * vdev pointer to it is still valid, queue it now. As
87 * with kvm irqfds, we know we won't race against the virqfd
88 * going away because we hold wqh->lock to get here.
89 */
90 if (*(virqfd->pvirqfd) == virqfd) {
91 *(virqfd->pvirqfd) = NULL;
92 virqfd_deactivate(virqfd);
93 }
94
95 spin_unlock_irqrestore(&virqfd->vdev->irqlock, flags);
96 }
82 97
83 return 0; 98 return 0;
84} 99}
@@ -93,7 +108,6 @@ static void virqfd_ptable_queue_proc(struct file *file,
93static void virqfd_shutdown(struct work_struct *work) 108static void virqfd_shutdown(struct work_struct *work)
94{ 109{
95 struct virqfd *virqfd = container_of(work, struct virqfd, shutdown); 110 struct virqfd *virqfd = container_of(work, struct virqfd, shutdown);
96 struct virqfd **pvirqfd = virqfd->pvirqfd;
97 u64 cnt; 111 u64 cnt;
98 112
99 eventfd_ctx_remove_wait_queue(virqfd->eventfd, &virqfd->wait, &cnt); 113 eventfd_ctx_remove_wait_queue(virqfd->eventfd, &virqfd->wait, &cnt);
@@ -101,7 +115,6 @@ static void virqfd_shutdown(struct work_struct *work)
101 eventfd_ctx_put(virqfd->eventfd); 115 eventfd_ctx_put(virqfd->eventfd);
102 116
103 kfree(virqfd); 117 kfree(virqfd);
104 *pvirqfd = NULL;
105} 118}
106 119
107static void virqfd_inject(struct work_struct *work) 120static void virqfd_inject(struct work_struct *work)
@@ -122,15 +135,11 @@ static int virqfd_enable(struct vfio_pci_device *vdev,
122 int ret = 0; 135 int ret = 0;
123 unsigned int events; 136 unsigned int events;
124 137
125 if (*pvirqfd)
126 return -EBUSY;
127
128 virqfd = kzalloc(sizeof(*virqfd), GFP_KERNEL); 138 virqfd = kzalloc(sizeof(*virqfd), GFP_KERNEL);
129 if (!virqfd) 139 if (!virqfd)
130 return -ENOMEM; 140 return -ENOMEM;
131 141
132 virqfd->pvirqfd = pvirqfd; 142 virqfd->pvirqfd = pvirqfd;
133 *pvirqfd = virqfd;
134 virqfd->vdev = vdev; 143 virqfd->vdev = vdev;
135 virqfd->handler = handler; 144 virqfd->handler = handler;
136 virqfd->thread = thread; 145 virqfd->thread = thread;
@@ -154,6 +163,23 @@ static int virqfd_enable(struct vfio_pci_device *vdev,
154 virqfd->eventfd = ctx; 163 virqfd->eventfd = ctx;
155 164
156 /* 165 /*
166 * virqfds can be released by closing the eventfd or directly
167 * through ioctl. These are both done through a workqueue, so
168 * we update the pointer to the virqfd under lock to avoid
169 * pushing multiple jobs to release the same virqfd.
170 */
171 spin_lock_irq(&vdev->irqlock);
172
173 if (*pvirqfd) {
174 spin_unlock_irq(&vdev->irqlock);
175 ret = -EBUSY;
176 goto fail;
177 }
178 *pvirqfd = virqfd;
179
180 spin_unlock_irq(&vdev->irqlock);
181
182 /*
157 * Install our own custom wake-up handling so we are notified via 183 * Install our own custom wake-up handling so we are notified via
158 * a callback whenever someone signals the underlying eventfd. 184 * a callback whenever someone signals the underlying eventfd.
159 */ 185 */
@@ -187,19 +213,29 @@ fail:
187 fput(file); 213 fput(file);
188 214
189 kfree(virqfd); 215 kfree(virqfd);
190 *pvirqfd = NULL;
191 216
192 return ret; 217 return ret;
193} 218}
194 219
195static void virqfd_disable(struct virqfd *virqfd) 220static void virqfd_disable(struct vfio_pci_device *vdev,
221 struct virqfd **pvirqfd)
196{ 222{
197 if (!virqfd) 223 unsigned long flags;
198 return; 224
225 spin_lock_irqsave(&vdev->irqlock, flags);
226
227 if (*pvirqfd) {
228 virqfd_deactivate(*pvirqfd);
229 *pvirqfd = NULL;
230 }
199 231
200 virqfd_deactivate(virqfd); 232 spin_unlock_irqrestore(&vdev->irqlock, flags);
201 233
202 /* Block until we know all outstanding shutdown jobs have completed. */ 234 /*
235 * Block until we know all outstanding shutdown jobs have completed.
236 * Even if we don't queue the job, flush the wq to be sure it's
237 * been released.
238 */
203 flush_workqueue(vfio_irqfd_cleanup_wq); 239 flush_workqueue(vfio_irqfd_cleanup_wq);
204} 240}
205 241
@@ -392,8 +428,8 @@ static int vfio_intx_set_signal(struct vfio_pci_device *vdev, int fd)
392static void vfio_intx_disable(struct vfio_pci_device *vdev) 428static void vfio_intx_disable(struct vfio_pci_device *vdev)
393{ 429{
394 vfio_intx_set_signal(vdev, -1); 430 vfio_intx_set_signal(vdev, -1);
395 virqfd_disable(vdev->ctx[0].unmask); 431 virqfd_disable(vdev, &vdev->ctx[0].unmask);
396 virqfd_disable(vdev->ctx[0].mask); 432 virqfd_disable(vdev, &vdev->ctx[0].mask);
397 vdev->irq_type = VFIO_PCI_NUM_IRQS; 433 vdev->irq_type = VFIO_PCI_NUM_IRQS;
398 vdev->num_ctx = 0; 434 vdev->num_ctx = 0;
399 kfree(vdev->ctx); 435 kfree(vdev->ctx);
@@ -539,8 +575,8 @@ static void vfio_msi_disable(struct vfio_pci_device *vdev, bool msix)
539 vfio_msi_set_block(vdev, 0, vdev->num_ctx, NULL, msix); 575 vfio_msi_set_block(vdev, 0, vdev->num_ctx, NULL, msix);
540 576
541 for (i = 0; i < vdev->num_ctx; i++) { 577 for (i = 0; i < vdev->num_ctx; i++) {
542 virqfd_disable(vdev->ctx[i].unmask); 578 virqfd_disable(vdev, &vdev->ctx[i].unmask);
543 virqfd_disable(vdev->ctx[i].mask); 579 virqfd_disable(vdev, &vdev->ctx[i].mask);
544 } 580 }
545 581
546 if (msix) { 582 if (msix) {
@@ -577,7 +613,7 @@ static int vfio_pci_set_intx_unmask(struct vfio_pci_device *vdev,
577 vfio_send_intx_eventfd, NULL, 613 vfio_send_intx_eventfd, NULL,
578 &vdev->ctx[0].unmask, fd); 614 &vdev->ctx[0].unmask, fd);
579 615
580 virqfd_disable(vdev->ctx[0].unmask); 616 virqfd_disable(vdev, &vdev->ctx[0].unmask);
581 } 617 }
582 618
583 return 0; 619 return 0;
diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c
index 1eff743ec497..ae60406ea8a1 100644
--- a/drivers/watchdog/hpwdt.c
+++ b/drivers/watchdog/hpwdt.c
@@ -814,6 +814,9 @@ static int __devinit hpwdt_init_one(struct pci_dev *dev,
814 hpwdt_timer_reg = pci_mem_addr + 0x70; 814 hpwdt_timer_reg = pci_mem_addr + 0x70;
815 hpwdt_timer_con = pci_mem_addr + 0x72; 815 hpwdt_timer_con = pci_mem_addr + 0x72;
816 816
817 /* Make sure that timer is disabled until /dev/watchdog is opened */
818 hpwdt_stop();
819
817 /* Make sure that we have a valid soft_margin */ 820 /* Make sure that we have a valid soft_margin */
818 if (hpwdt_change_timer(soft_margin)) 821 if (hpwdt_change_timer(soft_margin))
819 hpwdt_change_timer(DEFAULT_MARGIN); 822 hpwdt_change_timer(DEFAULT_MARGIN);
diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c
index 6aa46a90ff02..3796434991fa 100644
--- a/drivers/watchdog/watchdog_core.c
+++ b/drivers/watchdog/watchdog_core.c
@@ -128,11 +128,12 @@ EXPORT_SYMBOL_GPL(watchdog_register_device);
128void watchdog_unregister_device(struct watchdog_device *wdd) 128void watchdog_unregister_device(struct watchdog_device *wdd)
129{ 129{
130 int ret; 130 int ret;
131 int devno = wdd->cdev.dev; 131 int devno;
132 132
133 if (wdd == NULL) 133 if (wdd == NULL)
134 return; 134 return;
135 135
136 devno = wdd->cdev.dev;
136 ret = watchdog_dev_unregister(wdd); 137 ret = watchdog_dev_unregister(wdd);
137 if (ret) 138 if (ret)
138 pr_err("error unregistering /dev/watchdog (err=%d)\n", ret); 139 pr_err("error unregistering /dev/watchdog (err=%d)\n", ret);
diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
index 1ffd03bf8e10..7f1241608489 100644
--- a/drivers/xen/gntdev.c
+++ b/drivers/xen/gntdev.c
@@ -314,8 +314,9 @@ static int __unmap_grant_pages(struct grant_map *map, int offset, int pages)
314 } 314 }
315 } 315 }
316 316
317 err = gnttab_unmap_refs(map->unmap_ops + offset, map->pages + offset, 317 err = gnttab_unmap_refs(map->unmap_ops + offset,
318 pages, true); 318 use_ptemod ? map->kmap_ops + offset : NULL, map->pages + offset,
319 pages);
319 if (err) 320 if (err)
320 return err; 321 return err;
321 322
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 0bfc1ef11259..006726688baf 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -870,7 +870,8 @@ int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
870EXPORT_SYMBOL_GPL(gnttab_map_refs); 870EXPORT_SYMBOL_GPL(gnttab_map_refs);
871 871
872int gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops, 872int gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops,
873 struct page **pages, unsigned int count, bool clear_pte) 873 struct gnttab_map_grant_ref *kmap_ops,
874 struct page **pages, unsigned int count)
874{ 875{
875 int i, ret; 876 int i, ret;
876 bool lazy = false; 877 bool lazy = false;
@@ -888,7 +889,8 @@ int gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops,
888 } 889 }
889 890
890 for (i = 0; i < count; i++) { 891 for (i = 0; i < count; i++) {
891 ret = m2p_remove_override(pages[i], clear_pte); 892 ret = m2p_remove_override(pages[i], kmap_ops ?
893 &kmap_ops[i] : NULL);
892 if (ret) 894 if (ret)
893 return ret; 895 return ret;
894 } 896 }
diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c
index 7dab9c04ad52..53cf2aabce87 100644
--- a/fs/cifs/cifs_unicode.c
+++ b/fs/cifs/cifs_unicode.c
@@ -328,7 +328,7 @@ cifsConvertToUTF16(__le16 *target, const char *source, int srclen,
328 } 328 }
329 329
330ctoUTF16_out: 330ctoUTF16_out:
331 return i; 331 return j;
332} 332}
333 333
334#ifdef CONFIG_CIFS_SMB2 334#ifdef CONFIG_CIFS_SMB2
diff --git a/fs/dcache.c b/fs/dcache.c
index 16521a9f2038..693f95bf1cae 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1134,6 +1134,8 @@ positive:
1134 return 1; 1134 return 1;
1135 1135
1136rename_retry: 1136rename_retry:
1137 if (locked)
1138 goto again;
1137 locked = 1; 1139 locked = 1;
1138 write_seqlock(&rename_lock); 1140 write_seqlock(&rename_lock);
1139 goto again; 1141 goto again;
@@ -1141,7 +1143,7 @@ rename_retry:
1141EXPORT_SYMBOL(have_submounts); 1143EXPORT_SYMBOL(have_submounts);
1142 1144
1143/* 1145/*
1144 * Search the dentry child list for the specified parent, 1146 * Search the dentry child list of the specified parent,
1145 * and move any unused dentries to the end of the unused 1147 * and move any unused dentries to the end of the unused
1146 * list for prune_dcache(). We descend to the next level 1148 * list for prune_dcache(). We descend to the next level
1147 * whenever the d_subdirs list is non-empty and continue 1149 * whenever the d_subdirs list is non-empty and continue
@@ -1236,6 +1238,8 @@ out:
1236rename_retry: 1238rename_retry:
1237 if (found) 1239 if (found)
1238 return found; 1240 return found;
1241 if (locked)
1242 goto again;
1239 locked = 1; 1243 locked = 1;
1240 write_seqlock(&rename_lock); 1244 write_seqlock(&rename_lock);
1241 goto again; 1245 goto again;
@@ -3035,6 +3039,8 @@ resume:
3035 return; 3039 return;
3036 3040
3037rename_retry: 3041rename_retry:
3042 if (locked)
3043 goto again;
3038 locked = 1; 3044 locked = 1;
3039 write_seqlock(&rename_lock); 3045 write_seqlock(&rename_lock);
3040 goto again; 3046 goto again;
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index 2340f6978d6e..c5ca6ae5a30c 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -526,73 +526,51 @@ struct array_data {
526 u32 elements; 526 u32 elements;
527}; 527};
528 528
529static int u32_array_open(struct inode *inode, struct file *file) 529static size_t u32_format_array(char *buf, size_t bufsize,
530{ 530 u32 *array, int array_size)
531 file->private_data = NULL;
532 return nonseekable_open(inode, file);
533}
534
535static size_t format_array(char *buf, size_t bufsize, const char *fmt,
536 u32 *array, u32 array_size)
537{ 531{
538 size_t ret = 0; 532 size_t ret = 0;
539 u32 i;
540 533
541 for (i = 0; i < array_size; i++) { 534 while (--array_size >= 0) {
542 size_t len; 535 size_t len;
536 char term = array_size ? ' ' : '\n';
543 537
544 len = snprintf(buf, bufsize, fmt, array[i]); 538 len = snprintf(buf, bufsize, "%u%c", *array++, term);
545 len++; /* ' ' or '\n' */
546 ret += len; 539 ret += len;
547 540
548 if (buf) { 541 buf += len;
549 buf += len; 542 bufsize -= len;
550 bufsize -= len;
551 buf[-1] = (i == array_size-1) ? '\n' : ' ';
552 }
553 } 543 }
554
555 ret++; /* \0 */
556 if (buf)
557 *buf = '\0';
558
559 return ret; 544 return ret;
560} 545}
561 546
562static char *format_array_alloc(const char *fmt, u32 *array, 547static int u32_array_open(struct inode *inode, struct file *file)
563 u32 array_size)
564{ 548{
565 size_t len = format_array(NULL, 0, fmt, array, array_size); 549 struct array_data *data = inode->i_private;
566 char *ret; 550 int size, elements = data->elements;
567 551 char *buf;
568 ret = kmalloc(len, GFP_KERNEL); 552
569 if (ret == NULL) 553 /*
570 return NULL; 554 * Max size:
555 * - 10 digits + ' '/'\n' = 11 bytes per number
556 * - terminating NUL character
557 */
558 size = elements*11;
559 buf = kmalloc(size+1, GFP_KERNEL);
560 if (!buf)
561 return -ENOMEM;
562 buf[size] = 0;
563
564 file->private_data = buf;
565 u32_format_array(buf, size, data->array, data->elements);
571 566
572 format_array(ret, len, fmt, array, array_size); 567 return nonseekable_open(inode, file);
573 return ret;
574} 568}
575 569
576static ssize_t u32_array_read(struct file *file, char __user *buf, size_t len, 570static ssize_t u32_array_read(struct file *file, char __user *buf, size_t len,
577 loff_t *ppos) 571 loff_t *ppos)
578{ 572{
579 struct inode *inode = file->f_path.dentry->d_inode; 573 size_t size = strlen(file->private_data);
580 struct array_data *data = inode->i_private;
581 size_t size;
582
583 if (*ppos == 0) {
584 if (file->private_data) {
585 kfree(file->private_data);
586 file->private_data = NULL;
587 }
588
589 file->private_data = format_array_alloc("%u", data->array,
590 data->elements);
591 }
592
593 size = 0;
594 if (file->private_data)
595 size = strlen(file->private_data);
596 574
597 return simple_read_from_buffer(buf, len, ppos, 575 return simple_read_from_buffer(buf, len, ppos,
598 file->private_data, size); 576 file->private_data, size);
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index fb1a2bedbe97..8d80c990dffd 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -289,7 +289,6 @@ static void nlmsvc_free_block(struct kref *kref)
289 dprintk("lockd: freeing block %p...\n", block); 289 dprintk("lockd: freeing block %p...\n", block);
290 290
291 /* Remove block from file's list of blocks */ 291 /* Remove block from file's list of blocks */
292 mutex_lock(&file->f_mutex);
293 list_del_init(&block->b_flist); 292 list_del_init(&block->b_flist);
294 mutex_unlock(&file->f_mutex); 293 mutex_unlock(&file->f_mutex);
295 294
@@ -303,7 +302,7 @@ static void nlmsvc_free_block(struct kref *kref)
303static void nlmsvc_release_block(struct nlm_block *block) 302static void nlmsvc_release_block(struct nlm_block *block)
304{ 303{
305 if (block != NULL) 304 if (block != NULL)
306 kref_put(&block->b_count, nlmsvc_free_block); 305 kref_put_mutex(&block->b_count, nlmsvc_free_block, &block->b_file->f_mutex);
307} 306}
308 307
309/* 308/*
diff --git a/fs/namespace.c b/fs/namespace.c
index 4d31f73e2561..7bdf7907413f 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1886,8 +1886,14 @@ static int do_add_mount(struct mount *newmnt, struct path *path, int mnt_flags)
1886 return err; 1886 return err;
1887 1887
1888 err = -EINVAL; 1888 err = -EINVAL;
1889 if (!(mnt_flags & MNT_SHRINKABLE) && !check_mnt(real_mount(path->mnt))) 1889 if (unlikely(!check_mnt(real_mount(path->mnt)))) {
1890 goto unlock; 1890 /* that's acceptable only for automounts done in private ns */
1891 if (!(mnt_flags & MNT_SHRINKABLE))
1892 goto unlock;
1893 /* ... and for those we'd better have mountpoint still alive */
1894 if (!real_mount(path->mnt)->mnt_ns)
1895 goto unlock;
1896 }
1891 1897
1892 /* Refuse the same filesystem on the same mount point */ 1898 /* Refuse the same filesystem on the same mount point */
1893 err = -EBUSY; 1899 err = -EBUSY;
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index d7a9dd735e1e..933b7930b863 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -96,6 +96,7 @@ xfs_buf_lru_add(
96 atomic_inc(&bp->b_hold); 96 atomic_inc(&bp->b_hold);
97 list_add_tail(&bp->b_lru, &btp->bt_lru); 97 list_add_tail(&bp->b_lru, &btp->bt_lru);
98 btp->bt_lru_nr++; 98 btp->bt_lru_nr++;
99 bp->b_lru_flags &= ~_XBF_LRU_DISPOSE;
99 } 100 }
100 spin_unlock(&btp->bt_lru_lock); 101 spin_unlock(&btp->bt_lru_lock);
101} 102}
@@ -154,7 +155,8 @@ xfs_buf_stale(
154 struct xfs_buftarg *btp = bp->b_target; 155 struct xfs_buftarg *btp = bp->b_target;
155 156
156 spin_lock(&btp->bt_lru_lock); 157 spin_lock(&btp->bt_lru_lock);
157 if (!list_empty(&bp->b_lru)) { 158 if (!list_empty(&bp->b_lru) &&
159 !(bp->b_lru_flags & _XBF_LRU_DISPOSE)) {
158 list_del_init(&bp->b_lru); 160 list_del_init(&bp->b_lru);
159 btp->bt_lru_nr--; 161 btp->bt_lru_nr--;
160 atomic_dec(&bp->b_hold); 162 atomic_dec(&bp->b_hold);
@@ -1501,6 +1503,7 @@ xfs_buftarg_shrink(
1501 */ 1503 */
1502 list_move(&bp->b_lru, &dispose); 1504 list_move(&bp->b_lru, &dispose);
1503 btp->bt_lru_nr--; 1505 btp->bt_lru_nr--;
1506 bp->b_lru_flags |= _XBF_LRU_DISPOSE;
1504 } 1507 }
1505 spin_unlock(&btp->bt_lru_lock); 1508 spin_unlock(&btp->bt_lru_lock);
1506 1509
diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
index d03b73b9604e..7c0b6a0a1557 100644
--- a/fs/xfs/xfs_buf.h
+++ b/fs/xfs/xfs_buf.h
@@ -38,27 +38,28 @@ typedef enum {
38 XBRW_ZERO = 3, /* Zero target memory */ 38 XBRW_ZERO = 3, /* Zero target memory */
39} xfs_buf_rw_t; 39} xfs_buf_rw_t;
40 40
41#define XBF_READ (1 << 0) /* buffer intended for reading from device */ 41#define XBF_READ (1 << 0) /* buffer intended for reading from device */
42#define XBF_WRITE (1 << 1) /* buffer intended for writing to device */ 42#define XBF_WRITE (1 << 1) /* buffer intended for writing to device */
43#define XBF_READ_AHEAD (1 << 2) /* asynchronous read-ahead */ 43#define XBF_READ_AHEAD (1 << 2) /* asynchronous read-ahead */
44#define XBF_ASYNC (1 << 4) /* initiator will not wait for completion */ 44#define XBF_ASYNC (1 << 4) /* initiator will not wait for completion */
45#define XBF_DONE (1 << 5) /* all pages in the buffer uptodate */ 45#define XBF_DONE (1 << 5) /* all pages in the buffer uptodate */
46#define XBF_STALE (1 << 6) /* buffer has been staled, do not find it */ 46#define XBF_STALE (1 << 6) /* buffer has been staled, do not find it */
47 47
48/* I/O hints for the BIO layer */ 48/* I/O hints for the BIO layer */
49#define XBF_SYNCIO (1 << 10)/* treat this buffer as synchronous I/O */ 49#define XBF_SYNCIO (1 << 10)/* treat this buffer as synchronous I/O */
50#define XBF_FUA (1 << 11)/* force cache write through mode */ 50#define XBF_FUA (1 << 11)/* force cache write through mode */
51#define XBF_FLUSH (1 << 12)/* flush the disk cache before a write */ 51#define XBF_FLUSH (1 << 12)/* flush the disk cache before a write */
52 52
53/* flags used only as arguments to access routines */ 53/* flags used only as arguments to access routines */
54#define XBF_TRYLOCK (1 << 16)/* lock requested, but do not wait */ 54#define XBF_TRYLOCK (1 << 16)/* lock requested, but do not wait */
55#define XBF_UNMAPPED (1 << 17)/* do not map the buffer */ 55#define XBF_UNMAPPED (1 << 17)/* do not map the buffer */
56 56
57/* flags used only internally */ 57/* flags used only internally */
58#define _XBF_PAGES (1 << 20)/* backed by refcounted pages */ 58#define _XBF_PAGES (1 << 20)/* backed by refcounted pages */
59#define _XBF_KMEM (1 << 21)/* backed by heap memory */ 59#define _XBF_KMEM (1 << 21)/* backed by heap memory */
60#define _XBF_DELWRI_Q (1 << 22)/* buffer on a delwri queue */ 60#define _XBF_DELWRI_Q (1 << 22)/* buffer on a delwri queue */
61#define _XBF_COMPOUND (1 << 23)/* compound buffer */ 61#define _XBF_COMPOUND (1 << 23)/* compound buffer */
62#define _XBF_LRU_DISPOSE (1 << 24)/* buffer being discarded */
62 63
63typedef unsigned int xfs_buf_flags_t; 64typedef unsigned int xfs_buf_flags_t;
64 65
@@ -72,12 +73,13 @@ typedef unsigned int xfs_buf_flags_t;
72 { XBF_SYNCIO, "SYNCIO" }, \ 73 { XBF_SYNCIO, "SYNCIO" }, \
73 { XBF_FUA, "FUA" }, \ 74 { XBF_FUA, "FUA" }, \
74 { XBF_FLUSH, "FLUSH" }, \ 75 { XBF_FLUSH, "FLUSH" }, \
75 { XBF_TRYLOCK, "TRYLOCK" }, /* should never be set */\ 76 { XBF_TRYLOCK, "TRYLOCK" }, /* should never be set */\
76 { XBF_UNMAPPED, "UNMAPPED" }, /* ditto */\ 77 { XBF_UNMAPPED, "UNMAPPED" }, /* ditto */\
77 { _XBF_PAGES, "PAGES" }, \ 78 { _XBF_PAGES, "PAGES" }, \
78 { _XBF_KMEM, "KMEM" }, \ 79 { _XBF_KMEM, "KMEM" }, \
79 { _XBF_DELWRI_Q, "DELWRI_Q" }, \ 80 { _XBF_DELWRI_Q, "DELWRI_Q" }, \
80 { _XBF_COMPOUND, "COMPOUND" } 81 { _XBF_COMPOUND, "COMPOUND" }, \
82 { _XBF_LRU_DISPOSE, "LRU_DISPOSE" }
81 83
82typedef struct xfs_buftarg { 84typedef struct xfs_buftarg {
83 dev_t bt_dev; 85 dev_t bt_dev;
@@ -124,7 +126,12 @@ typedef struct xfs_buf {
124 xfs_buf_flags_t b_flags; /* status flags */ 126 xfs_buf_flags_t b_flags; /* status flags */
125 struct semaphore b_sema; /* semaphore for lockables */ 127 struct semaphore b_sema; /* semaphore for lockables */
126 128
129 /*
130 * concurrent access to b_lru and b_lru_flags are protected by
131 * bt_lru_lock and not by b_sema
132 */
127 struct list_head b_lru; /* lru list */ 133 struct list_head b_lru; /* lru list */
134 xfs_buf_flags_t b_lru_flags; /* internal lru status flags */
128 wait_queue_head_t b_waiters; /* unpin waiters */ 135 wait_queue_head_t b_waiters; /* unpin waiters */
129 struct list_head b_list; 136 struct list_head b_list;
130 struct xfs_perag *b_pag; /* contains rbtree root */ 137 struct xfs_perag *b_pag; /* contains rbtree root */
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index bdaf4cb9f4a2..19e2380fb867 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -919,6 +919,7 @@ xfs_fs_put_super(
919 struct xfs_mount *mp = XFS_M(sb); 919 struct xfs_mount *mp = XFS_M(sb);
920 920
921 xfs_filestream_unmount(mp); 921 xfs_filestream_unmount(mp);
922 cancel_delayed_work_sync(&mp->m_sync_work);
922 xfs_unmountfs(mp); 923 xfs_unmountfs(mp);
923 xfs_syncd_stop(mp); 924 xfs_syncd_stop(mp);
924 xfs_freesb(mp); 925 xfs_freesb(mp);
diff --git a/include/acpi/acbuffer.h b/include/acpi/acbuffer.h
new file mode 100644
index 000000000000..a1e45cdd729a
--- /dev/null
+++ b/include/acpi/acbuffer.h
@@ -0,0 +1,235 @@
1/******************************************************************************
2 *
3 * Name: acbuffer.h - Support for buffers returned by ACPI predefined names
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2012, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACBUFFER_H__
45#define __ACBUFFER_H__
46
47/*
48 * Contains buffer structures for these predefined names:
49 * _FDE, _GRT, _GTM, _PLD, _SRT
50 */
51
52/*
53 * Note: C bitfields are not used for this reason:
54 *
55 * "Bitfields are great and easy to read, but unfortunately the C language
56 * does not specify the layout of bitfields in memory, which means they are
57 * essentially useless for dealing with packed data in on-disk formats or
58 * binary wire protocols." (Or ACPI tables and buffers.) "If you ask me,
59 * this decision was a design error in C. Ritchie could have picked an order
60 * and stuck with it." Norman Ramsey.
61 * See http://stackoverflow.com/a/1053662/41661
62 */
63
64/* _FDE return value */
65
66struct acpi_fde_info {
67 u32 floppy0;
68 u32 floppy1;
69 u32 floppy2;
70 u32 floppy3;
71 u32 tape;
72};
73
74/*
75 * _GRT return value
76 * _SRT input value
77 */
78struct acpi_grt_info {
79 u16 year;
80 u8 month;
81 u8 day;
82 u8 hour;
83 u8 minute;
84 u8 second;
85 u8 valid;
86 u16 milliseconds;
87 u16 timezone;
88 u8 daylight;
89 u8 reserved[3];
90};
91
92/* _GTM return value */
93
94struct acpi_gtm_info {
95 u32 pio_speed0;
96 u32 dma_speed0;
97 u32 pio_speed1;
98 u32 dma_speed1;
99 u32 flags;
100};
101
102/*
103 * Formatted _PLD return value. The minimum size is a package containing
104 * one buffer.
105 * Revision 1: Buffer is 16 bytes (128 bits)
106 * Revision 2: Buffer is 20 bytes (160 bits)
107 *
108 * Note: This structure is returned from the acpi_decode_pld_buffer
109 * interface.
110 */
111struct acpi_pld_info {
112 u8 revision;
113 u8 ignore_color;
114 u32 color;
115 u16 width;
116 u16 height;
117 u8 user_visible;
118 u8 dock;
119 u8 lid;
120 u8 panel;
121 u8 vertical_position;
122 u8 horizontal_position;
123 u8 shape;
124 u8 group_orientation;
125 u8 group_token;
126 u8 group_position;
127 u8 bay;
128 u8 ejectable;
129 u8 ospm_eject_required;
130 u8 cabinet_number;
131 u8 card_cage_number;
132 u8 reference;
133 u8 rotation;
134 u8 order;
135 u8 reserved;
136 u16 vertical_offset;
137 u16 horizontal_offset;
138};
139
140/*
141 * Macros to:
142 * 1) Convert a _PLD buffer to internal struct acpi_pld_info format - ACPI_PLD_GET*
143 * (Used by acpi_decode_pld_buffer)
144 * 2) Construct a _PLD buffer - ACPI_PLD_SET*
145 * (Intended for BIOS use only)
146 */
147#define ACPI_PLD_REV1_BUFFER_SIZE 16 /* For Revision 1 of the buffer (From ACPI spec) */
148#define ACPI_PLD_BUFFER_SIZE 20 /* For Revision 2 of the buffer (From ACPI spec) */
149
150/* First 32-bit dword, bits 0:32 */
151
152#define ACPI_PLD_GET_REVISION(dword) ACPI_GET_BITS (dword, 0, ACPI_7BIT_MASK)
153#define ACPI_PLD_SET_REVISION(dword,value) ACPI_SET_BITS (dword, 0, ACPI_7BIT_MASK, value) /* Offset 0, Len 7 */
154
155#define ACPI_PLD_GET_IGNORE_COLOR(dword) ACPI_GET_BITS (dword, 7, ACPI_1BIT_MASK)
156#define ACPI_PLD_SET_IGNORE_COLOR(dword,value) ACPI_SET_BITS (dword, 7, ACPI_1BIT_MASK, value) /* Offset 7, Len 1 */
157
158#define ACPI_PLD_GET_COLOR(dword) ACPI_GET_BITS (dword, 8, ACPI_24BIT_MASK)
159#define ACPI_PLD_SET_COLOR(dword,value) ACPI_SET_BITS (dword, 8, ACPI_24BIT_MASK, value) /* Offset 8, Len 24 */
160
161/* Second 32-bit dword, bits 33:63 */
162
163#define ACPI_PLD_GET_WIDTH(dword) ACPI_GET_BITS (dword, 0, ACPI_16BIT_MASK)
164#define ACPI_PLD_SET_WIDTH(dword,value) ACPI_SET_BITS (dword, 0, ACPI_16BIT_MASK, value) /* Offset 32+0=32, Len 16 */
165
166#define ACPI_PLD_GET_HEIGHT(dword) ACPI_GET_BITS (dword, 16, ACPI_16BIT_MASK)
167#define ACPI_PLD_SET_HEIGHT(dword,value) ACPI_SET_BITS (dword, 16, ACPI_16BIT_MASK, value) /* Offset 32+16=48, Len 16 */
168
169/* Third 32-bit dword, bits 64:95 */
170
171#define ACPI_PLD_GET_USER_VISIBLE(dword) ACPI_GET_BITS (dword, 0, ACPI_1BIT_MASK)
172#define ACPI_PLD_SET_USER_VISIBLE(dword,value) ACPI_SET_BITS (dword, 0, ACPI_1BIT_MASK, value) /* Offset 64+0=64, Len 1 */
173
174#define ACPI_PLD_GET_DOCK(dword) ACPI_GET_BITS (dword, 1, ACPI_1BIT_MASK)
175#define ACPI_PLD_SET_DOCK(dword,value) ACPI_SET_BITS (dword, 1, ACPI_1BIT_MASK, value) /* Offset 64+1=65, Len 1 */
176
177#define ACPI_PLD_GET_LID(dword) ACPI_GET_BITS (dword, 2, ACPI_1BIT_MASK)
178#define ACPI_PLD_SET_LID(dword,value) ACPI_SET_BITS (dword, 2, ACPI_1BIT_MASK, value) /* Offset 64+2=66, Len 1 */
179
180#define ACPI_PLD_GET_PANEL(dword) ACPI_GET_BITS (dword, 3, ACPI_3BIT_MASK)
181#define ACPI_PLD_SET_PANEL(dword,value) ACPI_SET_BITS (dword, 3, ACPI_3BIT_MASK, value) /* Offset 64+3=67, Len 3 */
182
183#define ACPI_PLD_GET_VERTICAL(dword) ACPI_GET_BITS (dword, 6, ACPI_2BIT_MASK)
184#define ACPI_PLD_SET_VERTICAL(dword,value) ACPI_SET_BITS (dword, 6, ACPI_2BIT_MASK, value) /* Offset 64+6=70, Len 2 */
185
186#define ACPI_PLD_GET_HORIZONTAL(dword) ACPI_GET_BITS (dword, 8, ACPI_2BIT_MASK)
187#define ACPI_PLD_SET_HORIZONTAL(dword,value) ACPI_SET_BITS (dword, 8, ACPI_2BIT_MASK, value) /* Offset 64+8=72, Len 2 */
188
189#define ACPI_PLD_GET_SHAPE(dword) ACPI_GET_BITS (dword, 10, ACPI_4BIT_MASK)
190#define ACPI_PLD_SET_SHAPE(dword,value) ACPI_SET_BITS (dword, 10, ACPI_4BIT_MASK, value) /* Offset 64+10=74, Len 4 */
191
192#define ACPI_PLD_GET_ORIENTATION(dword) ACPI_GET_BITS (dword, 14, ACPI_1BIT_MASK)
193#define ACPI_PLD_SET_ORIENTATION(dword,value) ACPI_SET_BITS (dword, 14, ACPI_1BIT_MASK, value) /* Offset 64+14=78, Len 1 */
194
195#define ACPI_PLD_GET_TOKEN(dword) ACPI_GET_BITS (dword, 15, ACPI_8BIT_MASK)
196#define ACPI_PLD_SET_TOKEN(dword,value) ACPI_SET_BITS (dword, 15, ACPI_8BIT_MASK, value) /* Offset 64+15=79, Len 8 */
197
198#define ACPI_PLD_GET_POSITION(dword) ACPI_GET_BITS (dword, 23, ACPI_8BIT_MASK)
199#define ACPI_PLD_SET_POSITION(dword,value) ACPI_SET_BITS (dword, 23, ACPI_8BIT_MASK, value) /* Offset 64+23=87, Len 8 */
200
201#define ACPI_PLD_GET_BAY(dword) ACPI_GET_BITS (dword, 31, ACPI_1BIT_MASK)
202#define ACPI_PLD_SET_BAY(dword,value) ACPI_SET_BITS (dword, 31, ACPI_1BIT_MASK, value) /* Offset 64+31=95, Len 1 */
203
204/* Fourth 32-bit dword, bits 96:127 */
205
206#define ACPI_PLD_GET_EJECTABLE(dword) ACPI_GET_BITS (dword, 0, ACPI_1BIT_MASK)
207#define ACPI_PLD_SET_EJECTABLE(dword,value) ACPI_SET_BITS (dword, 0, ACPI_1BIT_MASK, value) /* Offset 96+0=96, Len 1 */
208
209#define ACPI_PLD_GET_OSPM_EJECT(dword) ACPI_GET_BITS (dword, 1, ACPI_1BIT_MASK)
210#define ACPI_PLD_SET_OSPM_EJECT(dword,value) ACPI_SET_BITS (dword, 1, ACPI_1BIT_MASK, value) /* Offset 96+1=97, Len 1 */
211
212#define ACPI_PLD_GET_CABINET(dword) ACPI_GET_BITS (dword, 2, ACPI_8BIT_MASK)
213#define ACPI_PLD_SET_CABINET(dword,value) ACPI_SET_BITS (dword, 2, ACPI_8BIT_MASK, value) /* Offset 96+2=98, Len 8 */
214
215#define ACPI_PLD_GET_CARD_CAGE(dword) ACPI_GET_BITS (dword, 10, ACPI_8BIT_MASK)
216#define ACPI_PLD_SET_CARD_CAGE(dword,value) ACPI_SET_BITS (dword, 10, ACPI_8BIT_MASK, value) /* Offset 96+10=106, Len 8 */
217
218#define ACPI_PLD_GET_REFERENCE(dword) ACPI_GET_BITS (dword, 18, ACPI_1BIT_MASK)
219#define ACPI_PLD_SET_REFERENCE(dword,value) ACPI_SET_BITS (dword, 18, ACPI_1BIT_MASK, value) /* Offset 96+18=114, Len 1 */
220
221#define ACPI_PLD_GET_ROTATION(dword) ACPI_GET_BITS (dword, 19, ACPI_4BIT_MASK)
222#define ACPI_PLD_SET_ROTATION(dword,value) ACPI_SET_BITS (dword, 19, ACPI_4BIT_MASK, value) /* Offset 96+19=115, Len 4 */
223
224#define ACPI_PLD_GET_ORDER(dword) ACPI_GET_BITS (dword, 23, ACPI_5BIT_MASK)
225#define ACPI_PLD_SET_ORDER(dword,value) ACPI_SET_BITS (dword, 23, ACPI_5BIT_MASK, value) /* Offset 96+23=119, Len 5 */
226
227/* Fifth 32-bit dword, bits 128:159 (Revision 2 of _PLD only) */
228
229#define ACPI_PLD_GET_VERT_OFFSET(dword) ACPI_GET_BITS (dword, 0, ACPI_16BIT_MASK)
230#define ACPI_PLD_SET_VERT_OFFSET(dword,value) ACPI_SET_BITS (dword, 0, ACPI_16BIT_MASK, value) /* Offset 128+0=128, Len 16 */
231
232#define ACPI_PLD_GET_HORIZ_OFFSET(dword) ACPI_GET_BITS (dword, 16, ACPI_16BIT_MASK)
233#define ACPI_PLD_SET_HORIZ_OFFSET(dword,value) ACPI_SET_BITS (dword, 16, ACPI_16BIT_MASK, value) /* Offset 128+16=144, Len 16 */
234
235#endif /* ACBUFFER_H */
diff --git a/include/acpi/acnames.h b/include/acpi/acnames.h
index d988ac54f41e..745dd24e3cb5 100644
--- a/include/acpi/acnames.h
+++ b/include/acpi/acnames.h
@@ -63,11 +63,10 @@
63#define METHOD_NAME__PRW "_PRW" 63#define METHOD_NAME__PRW "_PRW"
64#define METHOD_NAME__SRS "_SRS" 64#define METHOD_NAME__SRS "_SRS"
65#define METHOD_NAME__CBA "_CBA" 65#define METHOD_NAME__CBA "_CBA"
66#define METHOD_NAME__PLD "_PLD"
66 67
67/* Method names - these methods must appear at the namespace root */ 68/* Method names - these methods must appear at the namespace root */
68 69
69#define METHOD_PATHNAME__BFS "\\_BFS"
70#define METHOD_PATHNAME__GTS "\\_GTS"
71#define METHOD_PATHNAME__PTS "\\_PTS" 70#define METHOD_PATHNAME__PTS "\\_PTS"
72#define METHOD_PATHNAME__SST "\\_SI._SST" 71#define METHOD_PATHNAME__SST "\\_SI._SST"
73#define METHOD_PATHNAME__WAK "\\_WAK" 72#define METHOD_PATHNAME__WAK "\\_WAK"
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index bddd90975e4e..0daa0fbd8654 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -54,37 +54,8 @@ acpi_status
54acpi_evaluate_hotplug_ost(acpi_handle handle, u32 source_event, 54acpi_evaluate_hotplug_ost(acpi_handle handle, u32 source_event,
55 u32 status_code, struct acpi_buffer *status_buf); 55 u32 status_code, struct acpi_buffer *status_buf);
56 56
57struct acpi_pld {
58 unsigned int revision:7; /* 0 */
59 unsigned int ignore_colour:1; /* 7 */
60 unsigned int colour:24; /* 8 */
61 unsigned int width:16; /* 32 */
62 unsigned int height:16; /* 48 */
63 unsigned int user_visible:1; /* 64 */
64 unsigned int dock:1; /* 65 */
65 unsigned int lid:1; /* 66 */
66 unsigned int panel:3; /* 67 */
67 unsigned int vertical_pos:2; /* 70 */
68 unsigned int horizontal_pos:2; /* 72 */
69 unsigned int shape:4; /* 74 */
70 unsigned int group_orientation:1; /* 78 */
71 unsigned int group_token:8; /* 79 */
72 unsigned int group_position:8; /* 87 */
73 unsigned int bay:1; /* 95 */
74 unsigned int ejectable:1; /* 96 */
75 unsigned int ospm_eject_required:1; /* 97 */
76 unsigned int cabinet_number:8; /* 98 */
77 unsigned int card_cage_number:8; /* 106 */
78 unsigned int reference:1; /* 114 */
79 unsigned int rotation:4; /* 115 */
80 unsigned int order:5; /* 119 */
81 unsigned int reserved:4; /* 124 */
82 unsigned int vertical_offset:16; /* 128 */
83 unsigned int horizontal_offset:16; /* 144 */
84} __attribute__((__packed__));
85
86acpi_status 57acpi_status
87acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld *pld); 58acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld);
88#ifdef CONFIG_ACPI 59#ifdef CONFIG_ACPI
89 60
90#include <linux/proc_fs.h> 61#include <linux/proc_fs.h>
@@ -208,6 +179,7 @@ struct acpi_device_pnp {
208 struct list_head ids; /* _HID and _CIDs */ 179 struct list_head ids; /* _HID and _CIDs */
209 acpi_device_name device_name; /* Driver-determined */ 180 acpi_device_name device_name; /* Driver-determined */
210 acpi_device_class device_class; /* " */ 181 acpi_device_class device_class; /* " */
182 union acpi_object *str_obj; /* unicode string for _STR method */
211}; 183};
212 184
213#define acpi_device_bid(d) ((d)->pnp.bus_id) 185#define acpi_device_bid(d) ((d)->pnp.bus_id)
@@ -282,8 +254,16 @@ struct acpi_device_wakeup {
282 int prepare_count; 254 int prepare_count;
283}; 255};
284 256
285/* Device */ 257struct acpi_device_physical_node {
258 u8 node_id;
259 struct list_head node;
260 struct device *dev;
261};
262
263/* set maximum of physical nodes to 32 for expansibility */
264#define ACPI_MAX_PHYSICAL_NODE 32
286 265
266/* Device */
287struct acpi_device { 267struct acpi_device {
288 int device_type; 268 int device_type;
289 acpi_handle handle; /* no handle for fixed hardware */ 269 acpi_handle handle; /* no handle for fixed hardware */
@@ -304,6 +284,10 @@ struct acpi_device {
304 struct device dev; 284 struct device dev;
305 struct acpi_bus_ops bus_ops; /* workaround for different code path for hotplug */ 285 struct acpi_bus_ops bus_ops; /* workaround for different code path for hotplug */
306 enum acpi_bus_removal_type removal_type; /* indicate for different removal type */ 286 enum acpi_bus_removal_type removal_type; /* indicate for different removal type */
287 u8 physical_node_count;
288 struct list_head physical_node_list;
289 struct mutex physical_node_lock;
290 DECLARE_BITMAP(physical_node_id_bitmap, ACPI_MAX_PHYSICAL_NODE);
307}; 291};
308 292
309static inline void *acpi_driver_data(struct acpi_device *d) 293static inline void *acpi_driver_data(struct acpi_device *d)
@@ -407,7 +391,6 @@ struct acpi_bus_type {
407}; 391};
408int register_acpi_bus_type(struct acpi_bus_type *); 392int register_acpi_bus_type(struct acpi_bus_type *);
409int unregister_acpi_bus_type(struct acpi_bus_type *); 393int unregister_acpi_bus_type(struct acpi_bus_type *);
410struct device *acpi_get_physical_device(acpi_handle);
411 394
412struct acpi_pci_root { 395struct acpi_pci_root {
413 struct list_head node; 396 struct list_head node;
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index 26a92fc28a59..267bfc4b26a9 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -47,11 +47,12 @@
47 47
48/* Current ACPICA subsystem version in YYYYMMDD format */ 48/* Current ACPICA subsystem version in YYYYMMDD format */
49 49
50#define ACPI_CA_VERSION 0x20120711 50#define ACPI_CA_VERSION 0x20120913
51 51
52#include "acconfig.h" 52#include "acconfig.h"
53#include "actypes.h" 53#include "actypes.h"
54#include "actbl.h" 54#include "actbl.h"
55#include "acbuffer.h"
55 56
56extern u8 acpi_gbl_permanent_mmap; 57extern u8 acpi_gbl_permanent_mmap;
57 58
@@ -144,6 +145,10 @@ acpi_check_address_range(acpi_adr_space_type space_id,
144 acpi_physical_address address, 145 acpi_physical_address address,
145 acpi_size length, u8 warn); 146 acpi_size length, u8 warn);
146 147
148acpi_status
149acpi_decode_pld_buffer(u8 *in_buffer,
150 acpi_size length, struct acpi_pld_info **return_buffer);
151
147/* 152/*
148 * ACPI Memory management 153 * ACPI Memory management
149 */ 154 */
diff --git a/include/acpi/actbl.h b/include/acpi/actbl.h
index 59a73e1b2845..4f94b1d812d5 100644
--- a/include/acpi/actbl.h
+++ b/include/acpi/actbl.h
@@ -79,9 +79,15 @@
79#pragma pack(1) 79#pragma pack(1)
80 80
81/* 81/*
82 * Note about bitfields: The u8 type is used for bitfields in ACPI tables. 82 * Note: C bitfields are not used for this reason:
83 * This is the only type that is even remotely portable. Anything else is not 83 *
84 * portable, so do not use any other bitfield types. 84 * "Bitfields are great and easy to read, but unfortunately the C language
85 * does not specify the layout of bitfields in memory, which means they are
86 * essentially useless for dealing with packed data in on-disk formats or
87 * binary wire protocols." (Or ACPI tables and buffers.) "If you ask me,
88 * this decision was a design error in C. Ritchie could have picked an order
89 * and stuck with it." Norman Ramsey.
90 * See http://stackoverflow.com/a/1053662/41661
85 */ 91 */
86 92
87/******************************************************************************* 93/*******************************************************************************
@@ -94,7 +100,7 @@
94struct acpi_table_header { 100struct acpi_table_header {
95 char signature[ACPI_NAME_SIZE]; /* ASCII table signature */ 101 char signature[ACPI_NAME_SIZE]; /* ASCII table signature */
96 u32 length; /* Length of table in bytes, including this header */ 102 u32 length; /* Length of table in bytes, including this header */
97 u8 revision; /* ACPI Specification minor version # */ 103 u8 revision; /* ACPI Specification minor version number */
98 u8 checksum; /* To make sum of entire table == 0 */ 104 u8 checksum; /* To make sum of entire table == 0 */
99 char oem_id[ACPI_OEM_ID_SIZE]; /* ASCII OEM identification */ 105 char oem_id[ACPI_OEM_ID_SIZE]; /* ASCII OEM identification */
100 char oem_table_id[ACPI_OEM_TABLE_ID_SIZE]; /* ASCII OEM table identification */ 106 char oem_table_id[ACPI_OEM_TABLE_ID_SIZE]; /* ASCII OEM table identification */
@@ -108,7 +114,7 @@ struct acpi_table_header {
108 * GAS - Generic Address Structure (ACPI 2.0+) 114 * GAS - Generic Address Structure (ACPI 2.0+)
109 * 115 *
110 * Note: Since this structure is used in the ACPI tables, it is byte aligned. 116 * Note: Since this structure is used in the ACPI tables, it is byte aligned.
111 * If misaliged access is not supported by the hardware, accesses to the 117 * If misaligned access is not supported by the hardware, accesses to the
112 * 64-bit Address field must be performed with care. 118 * 64-bit Address field must be performed with care.
113 * 119 *
114 ******************************************************************************/ 120 ******************************************************************************/
@@ -210,18 +216,18 @@ struct acpi_table_fadt {
210 u8 preferred_profile; /* Conveys preferred power management profile to OSPM. */ 216 u8 preferred_profile; /* Conveys preferred power management profile to OSPM. */
211 u16 sci_interrupt; /* System vector of SCI interrupt */ 217 u16 sci_interrupt; /* System vector of SCI interrupt */
212 u32 smi_command; /* 32-bit Port address of SMI command port */ 218 u32 smi_command; /* 32-bit Port address of SMI command port */
213 u8 acpi_enable; /* Value to write to smi_cmd to enable ACPI */ 219 u8 acpi_enable; /* Value to write to SMI_CMD to enable ACPI */
214 u8 acpi_disable; /* Value to write to smi_cmd to disable ACPI */ 220 u8 acpi_disable; /* Value to write to SMI_CMD to disable ACPI */
215 u8 s4_bios_request; /* Value to write to SMI CMD to enter S4BIOS state */ 221 u8 s4_bios_request; /* Value to write to SMI_CMD to enter S4BIOS state */
216 u8 pstate_control; /* Processor performance state control */ 222 u8 pstate_control; /* Processor performance state control */
217 u32 pm1a_event_block; /* 32-bit Port address of Power Mgt 1a Event Reg Blk */ 223 u32 pm1a_event_block; /* 32-bit port address of Power Mgt 1a Event Reg Blk */
218 u32 pm1b_event_block; /* 32-bit Port address of Power Mgt 1b Event Reg Blk */ 224 u32 pm1b_event_block; /* 32-bit port address of Power Mgt 1b Event Reg Blk */
219 u32 pm1a_control_block; /* 32-bit Port address of Power Mgt 1a Control Reg Blk */ 225 u32 pm1a_control_block; /* 32-bit port address of Power Mgt 1a Control Reg Blk */
220 u32 pm1b_control_block; /* 32-bit Port address of Power Mgt 1b Control Reg Blk */ 226 u32 pm1b_control_block; /* 32-bit port address of Power Mgt 1b Control Reg Blk */
221 u32 pm2_control_block; /* 32-bit Port address of Power Mgt 2 Control Reg Blk */ 227 u32 pm2_control_block; /* 32-bit port address of Power Mgt 2 Control Reg Blk */
222 u32 pm_timer_block; /* 32-bit Port address of Power Mgt Timer Ctrl Reg Blk */ 228 u32 pm_timer_block; /* 32-bit port address of Power Mgt Timer Ctrl Reg Blk */
223 u32 gpe0_block; /* 32-bit Port address of General Purpose Event 0 Reg Blk */ 229 u32 gpe0_block; /* 32-bit port address of General Purpose Event 0 Reg Blk */
224 u32 gpe1_block; /* 32-bit Port address of General Purpose Event 1 Reg Blk */ 230 u32 gpe1_block; /* 32-bit port address of General Purpose Event 1 Reg Blk */
225 u8 pm1_event_length; /* Byte Length of ports at pm1x_event_block */ 231 u8 pm1_event_length; /* Byte Length of ports at pm1x_event_block */
226 u8 pm1_control_length; /* Byte Length of ports at pm1x_control_block */ 232 u8 pm1_control_length; /* Byte Length of ports at pm1x_control_block */
227 u8 pm2_control_length; /* Byte Length of ports at pm2_control_block */ 233 u8 pm2_control_length; /* Byte Length of ports at pm2_control_block */
@@ -229,12 +235,12 @@ struct acpi_table_fadt {
229 u8 gpe0_block_length; /* Byte Length of ports at gpe0_block */ 235 u8 gpe0_block_length; /* Byte Length of ports at gpe0_block */
230 u8 gpe1_block_length; /* Byte Length of ports at gpe1_block */ 236 u8 gpe1_block_length; /* Byte Length of ports at gpe1_block */
231 u8 gpe1_base; /* Offset in GPE number space where GPE1 events start */ 237 u8 gpe1_base; /* Offset in GPE number space where GPE1 events start */
232 u8 cst_control; /* Support for the _CST object and C States change notification */ 238 u8 cst_control; /* Support for the _CST object and C-States change notification */
233 u16 c2_latency; /* Worst case HW latency to enter/exit C2 state */ 239 u16 c2_latency; /* Worst case HW latency to enter/exit C2 state */
234 u16 c3_latency; /* Worst case HW latency to enter/exit C3 state */ 240 u16 c3_latency; /* Worst case HW latency to enter/exit C3 state */
235 u16 flush_size; /* Processor's memory cache line width, in bytes */ 241 u16 flush_size; /* Processor memory cache line width, in bytes */
236 u16 flush_stride; /* Number of flush strides that need to be read */ 242 u16 flush_stride; /* Number of flush strides that need to be read */
237 u8 duty_offset; /* Processor duty cycle index in processor's P_CNT reg */ 243 u8 duty_offset; /* Processor duty cycle index in processor P_CNT reg */
238 u8 duty_width; /* Processor duty cycle value bit width in P_CNT register */ 244 u8 duty_width; /* Processor duty cycle value bit width in P_CNT register */
239 u8 day_alarm; /* Index to day-of-month alarm in RTC CMOS RAM */ 245 u8 day_alarm; /* Index to day-of-month alarm in RTC CMOS RAM */
240 u8 month_alarm; /* Index to month-of-year alarm in RTC CMOS RAM */ 246 u8 month_alarm; /* Index to month-of-year alarm in RTC CMOS RAM */
@@ -255,11 +261,11 @@ struct acpi_table_fadt {
255 struct acpi_generic_address xpm_timer_block; /* 64-bit Extended Power Mgt Timer Ctrl Reg Blk address */ 261 struct acpi_generic_address xpm_timer_block; /* 64-bit Extended Power Mgt Timer Ctrl Reg Blk address */
256 struct acpi_generic_address xgpe0_block; /* 64-bit Extended General Purpose Event 0 Reg Blk address */ 262 struct acpi_generic_address xgpe0_block; /* 64-bit Extended General Purpose Event 0 Reg Blk address */
257 struct acpi_generic_address xgpe1_block; /* 64-bit Extended General Purpose Event 1 Reg Blk address */ 263 struct acpi_generic_address xgpe1_block; /* 64-bit Extended General Purpose Event 1 Reg Blk address */
258 struct acpi_generic_address sleep_control; /* 64-bit Sleep Control register */ 264 struct acpi_generic_address sleep_control; /* 64-bit Sleep Control register (ACPI 5.0) */
259 struct acpi_generic_address sleep_status; /* 64-bit Sleep Status register */ 265 struct acpi_generic_address sleep_status; /* 64-bit Sleep Status register (ACPI 5.0) */
260}; 266};
261 267
262/* Masks for FADT Boot Architecture Flags (boot_flags) */ 268/* Masks for FADT Boot Architecture Flags (boot_flags) [Vx]=Introduced in this FADT revision */
263 269
264#define ACPI_FADT_LEGACY_DEVICES (1) /* 00: [V2] System has LPC or ISA bus devices */ 270#define ACPI_FADT_LEGACY_DEVICES (1) /* 00: [V2] System has LPC or ISA bus devices */
265#define ACPI_FADT_8042 (1<<1) /* 01: [V3] System has an 8042 controller on port 60/64 */ 271#define ACPI_FADT_8042 (1<<1) /* 01: [V3] System has an 8042 controller on port 60/64 */
@@ -272,13 +278,13 @@ struct acpi_table_fadt {
272 278
273/* Masks for FADT flags */ 279/* Masks for FADT flags */
274 280
275#define ACPI_FADT_WBINVD (1) /* 00: [V1] The wbinvd instruction works properly */ 281#define ACPI_FADT_WBINVD (1) /* 00: [V1] The WBINVD instruction works properly */
276#define ACPI_FADT_WBINVD_FLUSH (1<<1) /* 01: [V1] wbinvd flushes but does not invalidate caches */ 282#define ACPI_FADT_WBINVD_FLUSH (1<<1) /* 01: [V1] WBINVD flushes but does not invalidate caches */
277#define ACPI_FADT_C1_SUPPORTED (1<<2) /* 02: [V1] All processors support C1 state */ 283#define ACPI_FADT_C1_SUPPORTED (1<<2) /* 02: [V1] All processors support C1 state */
278#define ACPI_FADT_C2_MP_SUPPORTED (1<<3) /* 03: [V1] C2 state works on MP system */ 284#define ACPI_FADT_C2_MP_SUPPORTED (1<<3) /* 03: [V1] C2 state works on MP system */
279#define ACPI_FADT_POWER_BUTTON (1<<4) /* 04: [V1] Power button is handled as a control method device */ 285#define ACPI_FADT_POWER_BUTTON (1<<4) /* 04: [V1] Power button is handled as a control method device */
280#define ACPI_FADT_SLEEP_BUTTON (1<<5) /* 05: [V1] Sleep button is handled as a control method device */ 286#define ACPI_FADT_SLEEP_BUTTON (1<<5) /* 05: [V1] Sleep button is handled as a control method device */
281#define ACPI_FADT_FIXED_RTC (1<<6) /* 06: [V1] RTC wakeup status not in fixed register space */ 287#define ACPI_FADT_FIXED_RTC (1<<6) /* 06: [V1] RTC wakeup status is not in fixed register space */
282#define ACPI_FADT_S4_RTC_WAKE (1<<7) /* 07: [V1] RTC alarm can wake system from S4 */ 288#define ACPI_FADT_S4_RTC_WAKE (1<<7) /* 07: [V1] RTC alarm can wake system from S4 */
283#define ACPI_FADT_32BIT_TIMER (1<<8) /* 08: [V1] ACPI timer width is 32-bit (0=24-bit) */ 289#define ACPI_FADT_32BIT_TIMER (1<<8) /* 08: [V1] ACPI timer width is 32-bit (0=24-bit) */
284#define ACPI_FADT_DOCKING_SUPPORTED (1<<9) /* 09: [V1] Docking supported */ 290#define ACPI_FADT_DOCKING_SUPPORTED (1<<9) /* 09: [V1] Docking supported */
@@ -297,7 +303,7 @@ struct acpi_table_fadt {
297 303
298/* Values for preferred_profile (Preferred Power Management Profiles) */ 304/* Values for preferred_profile (Preferred Power Management Profiles) */
299 305
300enum acpi_prefered_pm_profiles { 306enum acpi_preferred_pm_profiles {
301 PM_UNSPECIFIED = 0, 307 PM_UNSPECIFIED = 0,
302 PM_DESKTOP = 1, 308 PM_DESKTOP = 1,
303 PM_MOBILE = 2, 309 PM_MOBILE = 2,
@@ -335,7 +341,7 @@ union acpi_name_union {
335struct acpi_table_desc { 341struct acpi_table_desc {
336 acpi_physical_address address; 342 acpi_physical_address address;
337 struct acpi_table_header *pointer; 343 struct acpi_table_header *pointer;
338 u32 length; /* Length fixed at 32 bits */ 344 u32 length; /* Length fixed at 32 bits (fixed in table header) */
339 union acpi_name_union signature; 345 union acpi_name_union signature;
340 acpi_owner_id owner_id; 346 acpi_owner_id owner_id;
341 u8 flags; 347 u8 flags;
diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h
index 300d14e7c5d5..280fc45b59dd 100644
--- a/include/acpi/actbl1.h
+++ b/include/acpi/actbl1.h
@@ -79,9 +79,15 @@
79#pragma pack(1) 79#pragma pack(1)
80 80
81/* 81/*
82 * Note about bitfields: The u8 type is used for bitfields in ACPI tables. 82 * Note: C bitfields are not used for this reason:
83 * This is the only type that is even remotely portable. Anything else is not 83 *
84 * portable, so do not use any other bitfield types. 84 * "Bitfields are great and easy to read, but unfortunately the C language
85 * does not specify the layout of bitfields in memory, which means they are
86 * essentially useless for dealing with packed data in on-disk formats or
87 * binary wire protocols." (Or ACPI tables and buffers.) "If you ask me,
88 * this decision was a design error in C. Ritchie could have picked an order
89 * and stuck with it." Norman Ramsey.
90 * See http://stackoverflow.com/a/1053662/41661
85 */ 91 */
86 92
87/******************************************************************************* 93/*******************************************************************************
@@ -489,7 +495,9 @@ enum acpi_hest_notify_types {
489 ACPI_HEST_NOTIFY_LOCAL = 2, 495 ACPI_HEST_NOTIFY_LOCAL = 2,
490 ACPI_HEST_NOTIFY_SCI = 3, 496 ACPI_HEST_NOTIFY_SCI = 3,
491 ACPI_HEST_NOTIFY_NMI = 4, 497 ACPI_HEST_NOTIFY_NMI = 4,
492 ACPI_HEST_NOTIFY_RESERVED = 5 /* 5 and greater are reserved */ 498 ACPI_HEST_NOTIFY_CMCI = 5, /* ACPI 5.0 */
499 ACPI_HEST_NOTIFY_MCE = 6, /* ACPI 5.0 */
500 ACPI_HEST_NOTIFY_RESERVED = 7 /* 7 and greater are reserved */
493}; 501};
494 502
495/* Values for config_write_enable bitfield above */ 503/* Values for config_write_enable bitfield above */
diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h
index d9ceb3d31629..1b2b356486d1 100644
--- a/include/acpi/actbl2.h
+++ b/include/acpi/actbl2.h
@@ -63,6 +63,8 @@
63 */ 63 */
64#define ACPI_SIG_ASF "ASF!" /* Alert Standard Format table */ 64#define ACPI_SIG_ASF "ASF!" /* Alert Standard Format table */
65#define ACPI_SIG_BOOT "BOOT" /* Simple Boot Flag Table */ 65#define ACPI_SIG_BOOT "BOOT" /* Simple Boot Flag Table */
66#define ACPI_SIG_CSRT "CSRT" /* Core System Resource Table */
67#define ACPI_SIG_DBG2 "DBG2" /* Debug Port table type 2 */
66#define ACPI_SIG_DBGP "DBGP" /* Debug Port table */ 68#define ACPI_SIG_DBGP "DBGP" /* Debug Port table */
67#define ACPI_SIG_DMAR "DMAR" /* DMA Remapping table */ 69#define ACPI_SIG_DMAR "DMAR" /* DMA Remapping table */
68#define ACPI_SIG_HPET "HPET" /* High Precision Event Timer table */ 70#define ACPI_SIG_HPET "HPET" /* High Precision Event Timer table */
@@ -96,9 +98,15 @@
96#pragma pack(1) 98#pragma pack(1)
97 99
98/* 100/*
99 * Note about bitfields: The u8 type is used for bitfields in ACPI tables. 101 * Note: C bitfields are not used for this reason:
100 * This is the only type that is even remotely portable. Anything else is not 102 *
101 * portable, so do not use any other bitfield types. 103 * "Bitfields are great and easy to read, but unfortunately the C language
104 * does not specify the layout of bitfields in memory, which means they are
105 * essentially useless for dealing with packed data in on-disk formats or
106 * binary wire protocols." (Or ACPI tables and buffers.) "If you ask me,
107 * this decision was a design error in C. Ritchie could have picked an order
108 * and stuck with it." Norman Ramsey.
109 * See http://stackoverflow.com/a/1053662/41661
102 */ 110 */
103 111
104/******************************************************************************* 112/*******************************************************************************
@@ -232,6 +240,115 @@ struct acpi_table_boot {
232 240
233/******************************************************************************* 241/*******************************************************************************
234 * 242 *
243 * CSRT - Core System Resource Table
244 * Version 0
245 *
246 * Conforms to the "Core System Resource Table (CSRT)", November 14, 2011
247 *
248 ******************************************************************************/
249
250struct acpi_table_csrt {
251 struct acpi_table_header header; /* Common ACPI table header */
252};
253
254/* Resource Group subtable */
255
256struct acpi_csrt_group {
257 u32 length;
258 u32 vendor_id;
259 u32 subvendor_id;
260 u16 device_id;
261 u16 subdevice_id;
262 u16 revision;
263 u16 reserved;
264 u32 info_length;
265
266 /* Shared data (length = info_length) immediately follows */
267};
268
269/* Resource Descriptor subtable */
270
271struct acpi_csrt_descriptor {
272 u32 length;
273 u16 type;
274 u16 subtype;
275 u32 uid;
276
277 /* Resource-specific information immediately follows */
278};
279
280/* Resource Types */
281
282#define ACPI_CSRT_TYPE_INTERRUPT 0x0001
283#define ACPI_CSRT_TYPE_TIMER 0x0002
284#define ACPI_CSRT_TYPE_DMA 0x0003
285
286/* Resource Subtypes */
287
288#define ACPI_CSRT_XRUPT_LINE 0x0000
289#define ACPI_CSRT_XRUPT_CONTROLLER 0x0001
290#define ACPI_CSRT_TIMER 0x0000
291#define ACPI_CSRT_DMA_CHANNEL 0x0000
292#define ACPI_CSRT_DMA_CONTROLLER 0x0001
293
294/*******************************************************************************
295 *
296 * DBG2 - Debug Port Table 2
297 * Version 0 (Both main table and subtables)
298 *
299 * Conforms to "Microsoft Debug Port Table 2 (DBG2)", May 22 2012.
300 *
301 ******************************************************************************/
302
303struct acpi_table_dbg2 {
304 struct acpi_table_header header; /* Common ACPI table header */
305 u32 info_offset;
306 u32 info_count;
307};
308
309/* Debug Device Information Subtable */
310
311struct acpi_dbg2_device {
312 u8 revision;
313 u16 length;
314 u8 register_count; /* Number of base_address registers */
315 u16 namepath_length;
316 u16 namepath_offset;
317 u16 oem_data_length;
318 u16 oem_data_offset;
319 u16 port_type;
320 u16 port_subtype;
321 u16 reserved;
322 u16 base_address_offset;
323 u16 address_size_offset;
324 /*
325 * Data that follows:
326 * base_address (required) - Each in 12-byte Generic Address Structure format.
327 * address_size (required) - Array of u32 sizes corresponding to each base_address register.
328 * Namepath (required) - Null terminated string. Single dot if not supported.
329 * oem_data (optional) - Length is oem_data_length.
330 */
331};
332
333/* Types for port_type field above */
334
335#define ACPI_DBG2_SERIAL_PORT 0x8000
336#define ACPI_DBG2_1394_PORT 0x8001
337#define ACPI_DBG2_USB_PORT 0x8002
338#define ACPI_DBG2_NET_PORT 0x8003
339
340/* Subtypes for port_subtype field above */
341
342#define ACPI_DBG2_16550_COMPATIBLE 0x0000
343#define ACPI_DBG2_16550_SUBSET 0x0001
344
345#define ACPI_DBG2_1394_STANDARD 0x0000
346
347#define ACPI_DBG2_USB_XHCI 0x0000
348#define ACPI_DBG2_USB_EHCI 0x0001
349
350/*******************************************************************************
351 *
235 * DBGP - Debug Port table 352 * DBGP - Debug Port table
236 * Version 1 353 * Version 1
237 * 354 *
diff --git a/include/acpi/actbl3.h b/include/acpi/actbl3.h
index f65a0ed869eb..8c61b5fe42a4 100644
--- a/include/acpi/actbl3.h
+++ b/include/acpi/actbl3.h
@@ -75,7 +75,6 @@
75/* Reserved table signatures */ 75/* Reserved table signatures */
76 76
77#define ACPI_SIG_CSRT "CSRT" /* Core System Resources Table */ 77#define ACPI_SIG_CSRT "CSRT" /* Core System Resources Table */
78#define ACPI_SIG_DBG2 "DBG2" /* Debug Port table 2 */
79#define ACPI_SIG_MATR "MATR" /* Memory Address Translation Table */ 78#define ACPI_SIG_MATR "MATR" /* Memory Address Translation Table */
80#define ACPI_SIG_MSDM "MSDM" /* Microsoft Data Management Table */ 79#define ACPI_SIG_MSDM "MSDM" /* Microsoft Data Management Table */
81#define ACPI_SIG_WPBT "WPBT" /* Windows Platform Binary Table */ 80#define ACPI_SIG_WPBT "WPBT" /* Windows Platform Binary Table */
@@ -87,9 +86,15 @@
87#pragma pack(1) 86#pragma pack(1)
88 87
89/* 88/*
90 * Note about bitfields: The u8 type is used for bitfields in ACPI tables. 89 * Note: C bitfields are not used for this reason:
91 * This is the only type that is even remotely portable. Anything else is not 90 *
92 * portable, so do not use any other bitfield types. 91 * "Bitfields are great and easy to read, but unfortunately the C language
92 * does not specify the layout of bitfields in memory, which means they are
93 * essentially useless for dealing with packed data in on-disk formats or
94 * binary wire protocols." (Or ACPI tables and buffers.) "If you ask me,
95 * this decision was a design error in C. Ritchie could have picked an order
96 * and stuck with it." Norman Ramsey.
97 * See http://stackoverflow.com/a/1053662/41661
93 */ 98 */
94 99
95/******************************************************************************* 100/*******************************************************************************
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h
index 3d00bd5bd7e3..a85bae968262 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -519,13 +519,6 @@ typedef u64 acpi_integer;
519#define ACPI_SLEEP_TYPE_INVALID 0xFF 519#define ACPI_SLEEP_TYPE_INVALID 0xFF
520 520
521/* 521/*
522 * Sleep/Wake flags
523 */
524#define ACPI_NO_OPTIONAL_METHODS 0x00 /* Do not execute any optional methods */
525#define ACPI_EXECUTE_GTS 0x01 /* For enter sleep interface */
526#define ACPI_EXECUTE_BFS 0x02 /* For leave sleep prep interface */
527
528/*
529 * Standard notify values 522 * Standard notify values
530 */ 523 */
531#define ACPI_NOTIFY_BUS_CHECK (u8) 0x00 524#define ACPI_NOTIFY_BUS_CHECK (u8) 0x00
diff --git a/include/asm-generic/unistd.h b/include/asm-generic/unistd.h
index 991ef01cd77e..3748ec92dcbc 100644
--- a/include/asm-generic/unistd.h
+++ b/include/asm-generic/unistd.h
@@ -691,9 +691,11 @@ __SC_COMP(__NR_process_vm_readv, sys_process_vm_readv, \
691#define __NR_process_vm_writev 271 691#define __NR_process_vm_writev 271
692__SC_COMP(__NR_process_vm_writev, sys_process_vm_writev, \ 692__SC_COMP(__NR_process_vm_writev, sys_process_vm_writev, \
693 compat_sys_process_vm_writev) 693 compat_sys_process_vm_writev)
694#define __NR_kcmp 272
695__SYSCALL(__NR_kcmp, sys_kcmp)
694 696
695#undef __NR_syscalls 697#undef __NR_syscalls
696#define __NR_syscalls 272 698#define __NR_syscalls 273
697 699
698/* 700/*
699 * All syscalls below here should go away really, 701 * All syscalls below here should go away really,
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 7e83370e6fd2..f3b99e1c1042 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -256,72 +256,78 @@ static inline void iommu_set_fault_handler(struct iommu_domain *domain,
256{ 256{
257} 257}
258 258
259int iommu_attach_group(struct iommu_domain *domain, struct iommu_group *group) 259static inline int iommu_attach_group(struct iommu_domain *domain,
260 struct iommu_group *group)
260{ 261{
261 return -ENODEV; 262 return -ENODEV;
262} 263}
263 264
264void iommu_detach_group(struct iommu_domain *domain, struct iommu_group *group) 265static inline void iommu_detach_group(struct iommu_domain *domain,
266 struct iommu_group *group)
265{ 267{
266} 268}
267 269
268struct iommu_group *iommu_group_alloc(void) 270static inline struct iommu_group *iommu_group_alloc(void)
269{ 271{
270 return ERR_PTR(-ENODEV); 272 return ERR_PTR(-ENODEV);
271} 273}
272 274
273void *iommu_group_get_iommudata(struct iommu_group *group) 275static inline void *iommu_group_get_iommudata(struct iommu_group *group)
274{ 276{
275 return NULL; 277 return NULL;
276} 278}
277 279
278void iommu_group_set_iommudata(struct iommu_group *group, void *iommu_data, 280static inline void iommu_group_set_iommudata(struct iommu_group *group,
279 void (*release)(void *iommu_data)) 281 void *iommu_data,
282 void (*release)(void *iommu_data))
280{ 283{
281} 284}
282 285
283int iommu_group_set_name(struct iommu_group *group, const char *name) 286static inline int iommu_group_set_name(struct iommu_group *group,
287 const char *name)
284{ 288{
285 return -ENODEV; 289 return -ENODEV;
286} 290}
287 291
288int iommu_group_add_device(struct iommu_group *group, struct device *dev) 292static inline int iommu_group_add_device(struct iommu_group *group,
293 struct device *dev)
289{ 294{
290 return -ENODEV; 295 return -ENODEV;
291} 296}
292 297
293void iommu_group_remove_device(struct device *dev) 298static inline void iommu_group_remove_device(struct device *dev)
294{ 299{
295} 300}
296 301
297int iommu_group_for_each_dev(struct iommu_group *group, void *data, 302static inline int iommu_group_for_each_dev(struct iommu_group *group,
298 int (*fn)(struct device *, void *)) 303 void *data,
304 int (*fn)(struct device *, void *))
299{ 305{
300 return -ENODEV; 306 return -ENODEV;
301} 307}
302 308
303struct iommu_group *iommu_group_get(struct device *dev) 309static inline struct iommu_group *iommu_group_get(struct device *dev)
304{ 310{
305 return NULL; 311 return NULL;
306} 312}
307 313
308void iommu_group_put(struct iommu_group *group) 314static inline void iommu_group_put(struct iommu_group *group)
309{ 315{
310} 316}
311 317
312int iommu_group_register_notifier(struct iommu_group *group, 318static inline int iommu_group_register_notifier(struct iommu_group *group,
313 struct notifier_block *nb) 319 struct notifier_block *nb)
314{ 320{
315 return -ENODEV; 321 return -ENODEV;
316} 322}
317 323
318int iommu_group_unregister_notifier(struct iommu_group *group, 324static inline int iommu_group_unregister_notifier(struct iommu_group *group,
319 struct notifier_block *nb) 325 struct notifier_block *nb)
320{ 326{
321 return 0; 327 return 0;
322} 328}
323 329
324int iommu_group_id(struct iommu_group *group) 330static inline int iommu_group_id(struct iommu_group *group)
325{ 331{
326 return -ENODEV; 332 return -ENODEV;
327} 333}
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 594b419b7d20..2451f1f7a1d9 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -91,7 +91,7 @@
91{ \ 91{ \
92 typeof(x) __x = x; \ 92 typeof(x) __x = x; \
93 typeof(divisor) __d = divisor; \ 93 typeof(divisor) __d = divisor; \
94 (((typeof(x))-1) >= 0 || (__x) >= 0) ? \ 94 (((typeof(x))-1) > 0 || (__x) > 0) ? \
95 (((__x) + ((__d) / 2)) / (__d)) : \ 95 (((__x) + ((__d) / 2)) / (__d)) : \
96 (((__x) - ((__d) / 2)) / (__d)); \ 96 (((__x) - ((__d) / 2)) / (__d)); \
97} \ 97} \
diff --git a/include/linux/micrel_phy.h b/include/linux/micrel_phy.h
index 61f0905bdc48..de201203bc7c 100644
--- a/include/linux/micrel_phy.h
+++ b/include/linux/micrel_phy.h
@@ -1,3 +1,15 @@
1/*
2 * include/linux/micrel_phy.h
3 *
4 * Micrel PHY IDs
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 */
12
1#ifndef _MICREL_PHY_H 13#ifndef _MICREL_PHY_H
2#define _MICREL_PHY_H 14#define _MICREL_PHY_H
3 15
@@ -5,10 +17,11 @@
5 17
6#define PHY_ID_KSZ9021 0x00221610 18#define PHY_ID_KSZ9021 0x00221610
7#define PHY_ID_KS8737 0x00221720 19#define PHY_ID_KS8737 0x00221720
8#define PHY_ID_KS8041 0x00221510 20#define PHY_ID_KSZ8021 0x00221555
9#define PHY_ID_KS8051 0x00221550 21#define PHY_ID_KSZ8041 0x00221510
22#define PHY_ID_KSZ8051 0x00221550
10/* both for ks8001 Rev. A/B, and for ks8721 Rev 3. */ 23/* both for ks8001 Rev. A/B, and for ks8721 Rev 3. */
11#define PHY_ID_KS8001 0x0022161A 24#define PHY_ID_KSZ8001 0x0022161A
12 25
13/* struct phy_device dev_flags definitions */ 26/* struct phy_device dev_flags definitions */
14#define MICREL_PHY_50MHZ_CLK 0x00000001 27#define MICREL_PHY_50MHZ_CLK 0x00000001
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index 9490a00529f4..c25cccaa555a 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -35,8 +35,10 @@ struct nvme_bar {
35 __u64 acq; /* Admin CQ Base Address */ 35 __u64 acq; /* Admin CQ Base Address */
36}; 36};
37 37
38#define NVME_CAP_MQES(cap) ((cap) & 0xffff)
38#define NVME_CAP_TIMEOUT(cap) (((cap) >> 24) & 0xff) 39#define NVME_CAP_TIMEOUT(cap) (((cap) >> 24) & 0xff)
39#define NVME_CAP_STRIDE(cap) (((cap) >> 32) & 0xf) 40#define NVME_CAP_STRIDE(cap) (((cap) >> 32) & 0xf)
41#define NVME_CAP_MPSMIN(cap) (((cap) >> 48) & 0xf)
40 42
41enum { 43enum {
42 NVME_CC_ENABLE = 1 << 0, 44 NVME_CC_ENABLE = 1 << 0,
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 33ed9d605f91..bdb41612bfec 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -274,6 +274,8 @@ struct perf_event_attr {
274 __u64 branch_sample_type; /* enum branch_sample_type */ 274 __u64 branch_sample_type; /* enum branch_sample_type */
275}; 275};
276 276
277#define perf_flags(attr) (*(&(attr)->read_format + 1))
278
277/* 279/*
278 * Ioctls that can be done on a perf event fd: 280 * Ioctls that can be done on a perf event fd:
279 */ 281 */
diff --git a/include/linux/security.h b/include/linux/security.h
index 3dea6a9d568f..d143b8e01954 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -118,6 +118,7 @@ void reset_security_ops(void);
118extern unsigned long mmap_min_addr; 118extern unsigned long mmap_min_addr;
119extern unsigned long dac_mmap_min_addr; 119extern unsigned long dac_mmap_min_addr;
120#else 120#else
121#define mmap_min_addr 0UL
121#define dac_mmap_min_addr 0UL 122#define dac_mmap_min_addr 0UL
122#endif 123#endif
123 124
diff --git a/include/linux/xfrm.h b/include/linux/xfrm.h
index 22e61fdf75a2..28e493b5b94c 100644
--- a/include/linux/xfrm.h
+++ b/include/linux/xfrm.h
@@ -84,6 +84,8 @@ struct xfrm_replay_state {
84 __u32 bitmap; 84 __u32 bitmap;
85}; 85};
86 86
87#define XFRMA_REPLAY_ESN_MAX 4096
88
87struct xfrm_replay_state_esn { 89struct xfrm_replay_state_esn {
88 unsigned int bmp_len; 90 unsigned int bmp_len;
89 __u32 oseq; 91 __u32 oseq;
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index 0fedbd8d747a..9fc7114159e8 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -111,9 +111,8 @@ struct rt6_info {
111 struct inet6_dev *rt6i_idev; 111 struct inet6_dev *rt6i_idev;
112 unsigned long _rt6i_peer; 112 unsigned long _rt6i_peer;
113 113
114#ifdef CONFIG_XFRM 114 u32 rt6i_genid;
115 u32 rt6i_flow_cache_genid; 115
116#endif
117 /* more non-fragment space at head required */ 116 /* more non-fragment space at head required */
118 unsigned short rt6i_nfheader_len; 117 unsigned short rt6i_nfheader_len;
119 118
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index ae1cd6c9ba52..fd87963a0ea5 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -102,6 +102,7 @@ struct net {
102#endif 102#endif
103 struct netns_ipvs *ipvs; 103 struct netns_ipvs *ipvs;
104 struct sock *diag_nlsk; 104 struct sock *diag_nlsk;
105 atomic_t rt_genid;
105}; 106};
106 107
107 108
@@ -300,5 +301,14 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
300} 301}
301#endif 302#endif
302 303
304static inline int rt_genid(struct net *net)
305{
306 return atomic_read(&net->rt_genid);
307}
308
309static inline void rt_genid_bump(struct net *net)
310{
311 atomic_inc(&net->rt_genid);
312}
303 313
304#endif /* __NET_NET_NAMESPACE_H */ 314#endif /* __NET_NET_NAMESPACE_H */
diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
index 1474dd65c66f..eb24dbccd81e 100644
--- a/include/net/netns/ipv4.h
+++ b/include/net/netns/ipv4.h
@@ -65,7 +65,6 @@ struct netns_ipv4 {
65 unsigned int sysctl_ping_group_range[2]; 65 unsigned int sysctl_ping_group_range[2];
66 long sysctl_tcp_mem[3]; 66 long sysctl_tcp_mem[3];
67 67
68 atomic_t rt_genid;
69 atomic_t dev_addr_genid; 68 atomic_t dev_addr_genid;
70 69
71#ifdef CONFIG_IP_MROUTE 70#ifdef CONFIG_IP_MROUTE
diff --git a/include/net/route.h b/include/net/route.h
index 776a27f1ab78..da22243d2760 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -108,7 +108,7 @@ extern struct ip_rt_acct __percpu *ip_rt_acct;
108 108
109struct in_device; 109struct in_device;
110extern int ip_rt_init(void); 110extern int ip_rt_init(void);
111extern void rt_cache_flush(struct net *net, int how); 111extern void rt_cache_flush(struct net *net);
112extern void rt_flush_dev(struct net_device *dev); 112extern void rt_flush_dev(struct net_device *dev);
113extern struct rtable *__ip_route_output_key(struct net *, struct flowi4 *flp); 113extern struct rtable *__ip_route_output_key(struct net *, struct flowi4 *flp);
114extern struct rtable *ip_route_output_flow(struct net *, struct flowi4 *flp, 114extern struct rtable *ip_route_output_flow(struct net *, struct flowi4 *flp,
diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h
index 5f889f16b0c8..08fa27244da7 100644
--- a/include/trace/events/kmem.h
+++ b/include/trace/events/kmem.h
@@ -214,7 +214,7 @@ TRACE_EVENT(mm_page_alloc,
214 214
215 TP_printk("page=%p pfn=%lu order=%d migratetype=%d gfp_flags=%s", 215 TP_printk("page=%p pfn=%lu order=%d migratetype=%d gfp_flags=%s",
216 __entry->page, 216 __entry->page,
217 page_to_pfn(__entry->page), 217 __entry->page ? page_to_pfn(__entry->page) : 0,
218 __entry->order, 218 __entry->order,
219 __entry->migratetype, 219 __entry->migratetype,
220 show_gfp_flags(__entry->gfp_flags)) 220 show_gfp_flags(__entry->gfp_flags))
@@ -240,7 +240,7 @@ DECLARE_EVENT_CLASS(mm_page,
240 240
241 TP_printk("page=%p pfn=%lu order=%u migratetype=%d percpu_refill=%d", 241 TP_printk("page=%p pfn=%lu order=%u migratetype=%d percpu_refill=%d",
242 __entry->page, 242 __entry->page,
243 page_to_pfn(__entry->page), 243 __entry->page ? page_to_pfn(__entry->page) : 0,
244 __entry->order, 244 __entry->order,
245 __entry->migratetype, 245 __entry->migratetype,
246 __entry->order == 0) 246 __entry->order == 0)
diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h
index 11e27c3af3cb..f19fff8650e9 100644
--- a/include/xen/grant_table.h
+++ b/include/xen/grant_table.h
@@ -187,6 +187,7 @@ int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
187 struct gnttab_map_grant_ref *kmap_ops, 187 struct gnttab_map_grant_ref *kmap_ops,
188 struct page **pages, unsigned int count); 188 struct page **pages, unsigned int count);
189int gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops, 189int gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops,
190 struct page **pages, unsigned int count, bool clear_pte); 190 struct gnttab_map_grant_ref *kunmap_ops,
191 struct page **pages, unsigned int count);
191 192
192#endif /* __ASM_GNTTAB_H__ */ 193#endif /* __ASM_GNTTAB_H__ */
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 34e5eac81424..d3b91e75cecd 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -303,10 +303,11 @@ void getnstimeofday(struct timespec *ts)
303 seq = read_seqbegin(&tk->lock); 303 seq = read_seqbegin(&tk->lock);
304 304
305 ts->tv_sec = tk->xtime_sec; 305 ts->tv_sec = tk->xtime_sec;
306 ts->tv_nsec = timekeeping_get_ns(tk); 306 nsecs = timekeeping_get_ns(tk);
307 307
308 } while (read_seqretry(&tk->lock, seq)); 308 } while (read_seqretry(&tk->lock, seq));
309 309
310 ts->tv_nsec = 0;
310 timespec_add_ns(ts, nsecs); 311 timespec_add_ns(ts, nsecs);
311} 312}
312EXPORT_SYMBOL(getnstimeofday); 313EXPORT_SYMBOL(getnstimeofday);
@@ -345,6 +346,7 @@ void ktime_get_ts(struct timespec *ts)
345{ 346{
346 struct timekeeper *tk = &timekeeper; 347 struct timekeeper *tk = &timekeeper;
347 struct timespec tomono; 348 struct timespec tomono;
349 s64 nsec;
348 unsigned int seq; 350 unsigned int seq;
349 351
350 WARN_ON(timekeeping_suspended); 352 WARN_ON(timekeeping_suspended);
@@ -352,13 +354,14 @@ void ktime_get_ts(struct timespec *ts)
352 do { 354 do {
353 seq = read_seqbegin(&tk->lock); 355 seq = read_seqbegin(&tk->lock);
354 ts->tv_sec = tk->xtime_sec; 356 ts->tv_sec = tk->xtime_sec;
355 ts->tv_nsec = timekeeping_get_ns(tk); 357 nsec = timekeeping_get_ns(tk);
356 tomono = tk->wall_to_monotonic; 358 tomono = tk->wall_to_monotonic;
357 359
358 } while (read_seqretry(&tk->lock, seq)); 360 } while (read_seqretry(&tk->lock, seq));
359 361
360 set_normalized_timespec(ts, ts->tv_sec + tomono.tv_sec, 362 ts->tv_sec += tomono.tv_sec;
361 ts->tv_nsec + tomono.tv_nsec); 363 ts->tv_nsec = 0;
364 timespec_add_ns(ts, nsec + tomono.tv_nsec);
362} 365}
363EXPORT_SYMBOL_GPL(ktime_get_ts); 366EXPORT_SYMBOL_GPL(ktime_get_ts);
364 367
@@ -1244,6 +1247,7 @@ void get_monotonic_boottime(struct timespec *ts)
1244{ 1247{
1245 struct timekeeper *tk = &timekeeper; 1248 struct timekeeper *tk = &timekeeper;
1246 struct timespec tomono, sleep; 1249 struct timespec tomono, sleep;
1250 s64 nsec;
1247 unsigned int seq; 1251 unsigned int seq;
1248 1252
1249 WARN_ON(timekeeping_suspended); 1253 WARN_ON(timekeeping_suspended);
@@ -1251,14 +1255,15 @@ void get_monotonic_boottime(struct timespec *ts)
1251 do { 1255 do {
1252 seq = read_seqbegin(&tk->lock); 1256 seq = read_seqbegin(&tk->lock);
1253 ts->tv_sec = tk->xtime_sec; 1257 ts->tv_sec = tk->xtime_sec;
1254 ts->tv_nsec = timekeeping_get_ns(tk); 1258 nsec = timekeeping_get_ns(tk);
1255 tomono = tk->wall_to_monotonic; 1259 tomono = tk->wall_to_monotonic;
1256 sleep = tk->total_sleep_time; 1260 sleep = tk->total_sleep_time;
1257 1261
1258 } while (read_seqretry(&tk->lock, seq)); 1262 } while (read_seqretry(&tk->lock, seq));
1259 1263
1260 set_normalized_timespec(ts, ts->tv_sec + tomono.tv_sec + sleep.tv_sec, 1264 ts->tv_sec += tomono.tv_sec + sleep.tv_sec;
1261 ts->tv_nsec + tomono.tv_nsec + sleep.tv_nsec); 1265 ts->tv_nsec = 0;
1266 timespec_add_ns(ts, nsec + tomono.tv_nsec + sleep.tv_nsec);
1262} 1267}
1263EXPORT_SYMBOL_GPL(get_monotonic_boottime); 1268EXPORT_SYMBOL_GPL(get_monotonic_boottime);
1264 1269
diff --git a/lib/flex_proportions.c b/lib/flex_proportions.c
index c785554f9523..ebf3bac460b0 100644
--- a/lib/flex_proportions.c
+++ b/lib/flex_proportions.c
@@ -62,7 +62,7 @@ void fprop_global_destroy(struct fprop_global *p)
62 */ 62 */
63bool fprop_new_period(struct fprop_global *p, int periods) 63bool fprop_new_period(struct fprop_global *p, int periods)
64{ 64{
65 u64 events; 65 s64 events;
66 unsigned long flags; 66 unsigned long flags;
67 67
68 local_irq_save(flags); 68 local_irq_save(flags);
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 57c4b9309015..141dbb695097 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1811,7 +1811,6 @@ static void __collapse_huge_page_copy(pte_t *pte, struct page *page,
1811 src_page = pte_page(pteval); 1811 src_page = pte_page(pteval);
1812 copy_user_highpage(page, src_page, address, vma); 1812 copy_user_highpage(page, src_page, address, vma);
1813 VM_BUG_ON(page_mapcount(src_page) != 1); 1813 VM_BUG_ON(page_mapcount(src_page) != 1);
1814 VM_BUG_ON(page_count(src_page) != 2);
1815 release_pte_page(src_page); 1814 release_pte_page(src_page);
1816 /* 1815 /*
1817 * ptl mostly unnecessary, but preempt has to 1816 * ptl mostly unnecessary, but preempt has to
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index e877af8bdd1e..469daabd90c7 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -642,7 +642,8 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
642 struct batadv_neigh_node *router = NULL; 642 struct batadv_neigh_node *router = NULL;
643 struct batadv_orig_node *orig_node_tmp; 643 struct batadv_orig_node *orig_node_tmp;
644 struct hlist_node *node; 644 struct hlist_node *node;
645 uint8_t bcast_own_sum_orig, bcast_own_sum_neigh; 645 int if_num;
646 uint8_t sum_orig, sum_neigh;
646 uint8_t *neigh_addr; 647 uint8_t *neigh_addr;
647 648
648 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 649 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
@@ -727,17 +728,17 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
727 if (router && (neigh_node->tq_avg == router->tq_avg)) { 728 if (router && (neigh_node->tq_avg == router->tq_avg)) {
728 orig_node_tmp = router->orig_node; 729 orig_node_tmp = router->orig_node;
729 spin_lock_bh(&orig_node_tmp->ogm_cnt_lock); 730 spin_lock_bh(&orig_node_tmp->ogm_cnt_lock);
730 bcast_own_sum_orig = 731 if_num = router->if_incoming->if_num;
731 orig_node_tmp->bcast_own_sum[if_incoming->if_num]; 732 sum_orig = orig_node_tmp->bcast_own_sum[if_num];
732 spin_unlock_bh(&orig_node_tmp->ogm_cnt_lock); 733 spin_unlock_bh(&orig_node_tmp->ogm_cnt_lock);
733 734
734 orig_node_tmp = neigh_node->orig_node; 735 orig_node_tmp = neigh_node->orig_node;
735 spin_lock_bh(&orig_node_tmp->ogm_cnt_lock); 736 spin_lock_bh(&orig_node_tmp->ogm_cnt_lock);
736 bcast_own_sum_neigh = 737 if_num = neigh_node->if_incoming->if_num;
737 orig_node_tmp->bcast_own_sum[if_incoming->if_num]; 738 sum_neigh = orig_node_tmp->bcast_own_sum[if_num];
738 spin_unlock_bh(&orig_node_tmp->ogm_cnt_lock); 739 spin_unlock_bh(&orig_node_tmp->ogm_cnt_lock);
739 740
740 if (bcast_own_sum_orig >= bcast_own_sum_neigh) 741 if (sum_orig >= sum_neigh)
741 goto update_tt; 742 goto update_tt;
742 } 743 }
743 744
diff --git a/net/batman-adv/bitarray.h b/net/batman-adv/bitarray.h
index a081ce1c0514..cebaae7e148b 100644
--- a/net/batman-adv/bitarray.h
+++ b/net/batman-adv/bitarray.h
@@ -20,8 +20,8 @@
20#ifndef _NET_BATMAN_ADV_BITARRAY_H_ 20#ifndef _NET_BATMAN_ADV_BITARRAY_H_
21#define _NET_BATMAN_ADV_BITARRAY_H_ 21#define _NET_BATMAN_ADV_BITARRAY_H_
22 22
23/* returns true if the corresponding bit in the given seq_bits indicates true 23/* Returns 1 if the corresponding bit in the given seq_bits indicates true
24 * and curr_seqno is within range of last_seqno 24 * and curr_seqno is within range of last_seqno. Otherwise returns 0.
25 */ 25 */
26static inline int batadv_test_bit(const unsigned long *seq_bits, 26static inline int batadv_test_bit(const unsigned long *seq_bits,
27 uint32_t last_seqno, uint32_t curr_seqno) 27 uint32_t last_seqno, uint32_t curr_seqno)
@@ -32,7 +32,7 @@ static inline int batadv_test_bit(const unsigned long *seq_bits,
32 if (diff < 0 || diff >= BATADV_TQ_LOCAL_WINDOW_SIZE) 32 if (diff < 0 || diff >= BATADV_TQ_LOCAL_WINDOW_SIZE)
33 return 0; 33 return 0;
34 else 34 else
35 return test_bit(diff, seq_bits); 35 return test_bit(diff, seq_bits) != 0;
36} 36}
37 37
38/* turn corresponding bit on, so we can remember that we got the packet */ 38/* turn corresponding bit on, so we can remember that we got the packet */
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 109ea2aae96c..21c53577c8d6 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -100,18 +100,21 @@ static int batadv_interface_set_mac_addr(struct net_device *dev, void *p)
100{ 100{
101 struct batadv_priv *bat_priv = netdev_priv(dev); 101 struct batadv_priv *bat_priv = netdev_priv(dev);
102 struct sockaddr *addr = p; 102 struct sockaddr *addr = p;
103 uint8_t old_addr[ETH_ALEN];
103 104
104 if (!is_valid_ether_addr(addr->sa_data)) 105 if (!is_valid_ether_addr(addr->sa_data))
105 return -EADDRNOTAVAIL; 106 return -EADDRNOTAVAIL;
106 107
108 memcpy(old_addr, dev->dev_addr, ETH_ALEN);
109 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
110
107 /* only modify transtable if it has been initialized before */ 111 /* only modify transtable if it has been initialized before */
108 if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_ACTIVE) { 112 if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_ACTIVE) {
109 batadv_tt_local_remove(bat_priv, dev->dev_addr, 113 batadv_tt_local_remove(bat_priv, old_addr,
110 "mac address changed", false); 114 "mac address changed", false);
111 batadv_tt_local_add(dev, addr->sa_data, BATADV_NULL_IFINDEX); 115 batadv_tt_local_add(dev, addr->sa_data, BATADV_NULL_IFINDEX);
112 } 116 }
113 117
114 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
115 dev->addr_assign_type &= ~NET_ADDR_RANDOM; 118 dev->addr_assign_type &= ~NET_ADDR_RANDOM;
116 return 0; 119 return 0;
117} 120}
diff --git a/net/bluetooth/bnep/sock.c b/net/bluetooth/bnep/sock.c
index 5e5f5b410e0b..1eaacf10d19d 100644
--- a/net/bluetooth/bnep/sock.c
+++ b/net/bluetooth/bnep/sock.c
@@ -58,7 +58,7 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
58 switch (cmd) { 58 switch (cmd) {
59 case BNEPCONNADD: 59 case BNEPCONNADD:
60 if (!capable(CAP_NET_ADMIN)) 60 if (!capable(CAP_NET_ADMIN))
61 return -EACCES; 61 return -EPERM;
62 62
63 if (copy_from_user(&ca, argp, sizeof(ca))) 63 if (copy_from_user(&ca, argp, sizeof(ca)))
64 return -EFAULT; 64 return -EFAULT;
@@ -84,7 +84,7 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
84 84
85 case BNEPCONNDEL: 85 case BNEPCONNDEL:
86 if (!capable(CAP_NET_ADMIN)) 86 if (!capable(CAP_NET_ADMIN))
87 return -EACCES; 87 return -EPERM;
88 88
89 if (copy_from_user(&cd, argp, sizeof(cd))) 89 if (copy_from_user(&cd, argp, sizeof(cd)))
90 return -EFAULT; 90 return -EFAULT;
diff --git a/net/bluetooth/cmtp/sock.c b/net/bluetooth/cmtp/sock.c
index 311668d14571..32dc83dcb6b2 100644
--- a/net/bluetooth/cmtp/sock.c
+++ b/net/bluetooth/cmtp/sock.c
@@ -72,7 +72,7 @@ static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
72 switch (cmd) { 72 switch (cmd) {
73 case CMTPCONNADD: 73 case CMTPCONNADD:
74 if (!capable(CAP_NET_ADMIN)) 74 if (!capable(CAP_NET_ADMIN))
75 return -EACCES; 75 return -EPERM;
76 76
77 if (copy_from_user(&ca, argp, sizeof(ca))) 77 if (copy_from_user(&ca, argp, sizeof(ca)))
78 return -EFAULT; 78 return -EFAULT;
@@ -97,7 +97,7 @@ static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
97 97
98 case CMTPCONNDEL: 98 case CMTPCONNDEL:
99 if (!capable(CAP_NET_ADMIN)) 99 if (!capable(CAP_NET_ADMIN))
100 return -EACCES; 100 return -EPERM;
101 101
102 if (copy_from_user(&cd, argp, sizeof(cd))) 102 if (copy_from_user(&cd, argp, sizeof(cd)))
103 return -EFAULT; 103 return -EFAULT;
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index d4de5db18d5a..0b997c8f9655 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -734,6 +734,8 @@ static int hci_dev_do_close(struct hci_dev *hdev)
734 734
735 cancel_work_sync(&hdev->le_scan); 735 cancel_work_sync(&hdev->le_scan);
736 736
737 cancel_delayed_work(&hdev->power_off);
738
737 hci_req_cancel(hdev, ENODEV); 739 hci_req_cancel(hdev, ENODEV);
738 hci_req_lock(hdev); 740 hci_req_lock(hdev);
739 741
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 19fdac78e555..d5ace1eda3ed 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -490,7 +490,7 @@ static int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd,
490 switch (cmd) { 490 switch (cmd) {
491 case HCISETRAW: 491 case HCISETRAW:
492 if (!capable(CAP_NET_ADMIN)) 492 if (!capable(CAP_NET_ADMIN))
493 return -EACCES; 493 return -EPERM;
494 494
495 if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) 495 if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks))
496 return -EPERM; 496 return -EPERM;
@@ -510,12 +510,12 @@ static int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd,
510 510
511 case HCIBLOCKADDR: 511 case HCIBLOCKADDR:
512 if (!capable(CAP_NET_ADMIN)) 512 if (!capable(CAP_NET_ADMIN))
513 return -EACCES; 513 return -EPERM;
514 return hci_sock_blacklist_add(hdev, (void __user *) arg); 514 return hci_sock_blacklist_add(hdev, (void __user *) arg);
515 515
516 case HCIUNBLOCKADDR: 516 case HCIUNBLOCKADDR:
517 if (!capable(CAP_NET_ADMIN)) 517 if (!capable(CAP_NET_ADMIN))
518 return -EACCES; 518 return -EPERM;
519 return hci_sock_blacklist_del(hdev, (void __user *) arg); 519 return hci_sock_blacklist_del(hdev, (void __user *) arg);
520 520
521 default: 521 default:
@@ -546,22 +546,22 @@ static int hci_sock_ioctl(struct socket *sock, unsigned int cmd,
546 546
547 case HCIDEVUP: 547 case HCIDEVUP:
548 if (!capable(CAP_NET_ADMIN)) 548 if (!capable(CAP_NET_ADMIN))
549 return -EACCES; 549 return -EPERM;
550 return hci_dev_open(arg); 550 return hci_dev_open(arg);
551 551
552 case HCIDEVDOWN: 552 case HCIDEVDOWN:
553 if (!capable(CAP_NET_ADMIN)) 553 if (!capable(CAP_NET_ADMIN))
554 return -EACCES; 554 return -EPERM;
555 return hci_dev_close(arg); 555 return hci_dev_close(arg);
556 556
557 case HCIDEVRESET: 557 case HCIDEVRESET:
558 if (!capable(CAP_NET_ADMIN)) 558 if (!capable(CAP_NET_ADMIN))
559 return -EACCES; 559 return -EPERM;
560 return hci_dev_reset(arg); 560 return hci_dev_reset(arg);
561 561
562 case HCIDEVRESTAT: 562 case HCIDEVRESTAT:
563 if (!capable(CAP_NET_ADMIN)) 563 if (!capable(CAP_NET_ADMIN))
564 return -EACCES; 564 return -EPERM;
565 return hci_dev_reset_stat(arg); 565 return hci_dev_reset_stat(arg);
566 566
567 case HCISETSCAN: 567 case HCISETSCAN:
@@ -573,7 +573,7 @@ static int hci_sock_ioctl(struct socket *sock, unsigned int cmd,
573 case HCISETACLMTU: 573 case HCISETACLMTU:
574 case HCISETSCOMTU: 574 case HCISETSCOMTU:
575 if (!capable(CAP_NET_ADMIN)) 575 if (!capable(CAP_NET_ADMIN))
576 return -EACCES; 576 return -EPERM;
577 return hci_dev_cmd(cmd, argp); 577 return hci_dev_cmd(cmd, argp);
578 578
579 case HCIINQUIRY: 579 case HCIINQUIRY:
diff --git a/net/bluetooth/hidp/sock.c b/net/bluetooth/hidp/sock.c
index 18b3f6892a36..b24fb3bd8625 100644
--- a/net/bluetooth/hidp/sock.c
+++ b/net/bluetooth/hidp/sock.c
@@ -56,7 +56,7 @@ static int hidp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
56 switch (cmd) { 56 switch (cmd) {
57 case HIDPCONNADD: 57 case HIDPCONNADD:
58 if (!capable(CAP_NET_ADMIN)) 58 if (!capable(CAP_NET_ADMIN))
59 return -EACCES; 59 return -EPERM;
60 60
61 if (copy_from_user(&ca, argp, sizeof(ca))) 61 if (copy_from_user(&ca, argp, sizeof(ca)))
62 return -EFAULT; 62 return -EFAULT;
@@ -91,7 +91,7 @@ static int hidp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
91 91
92 case HIDPCONNDEL: 92 case HIDPCONNDEL:
93 if (!capable(CAP_NET_ADMIN)) 93 if (!capable(CAP_NET_ADMIN))
94 return -EACCES; 94 return -EPERM;
95 95
96 if (copy_from_user(&cd, argp, sizeof(cd))) 96 if (copy_from_user(&cd, argp, sizeof(cd)))
97 return -EFAULT; 97 return -EFAULT;
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 4ea1710a4783..38c00f142203 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1008,7 +1008,7 @@ static void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *c
1008 if (!conn) 1008 if (!conn)
1009 return; 1009 return;
1010 1010
1011 if (chan->mode == L2CAP_MODE_ERTM) { 1011 if (chan->mode == L2CAP_MODE_ERTM && chan->state == BT_CONNECTED) {
1012 __clear_retrans_timer(chan); 1012 __clear_retrans_timer(chan);
1013 __clear_monitor_timer(chan); 1013 __clear_monitor_timer(chan);
1014 __clear_ack_timer(chan); 1014 __clear_ack_timer(chan);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index ad6613d17ca6..eba022de3c20 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2875,6 +2875,22 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered)
2875 if (scan) 2875 if (scan)
2876 hci_send_cmd(hdev, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan); 2876 hci_send_cmd(hdev, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan);
2877 2877
2878 if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) {
2879 u8 ssp = 1;
2880
2881 hci_send_cmd(hdev, HCI_OP_WRITE_SSP_MODE, 1, &ssp);
2882 }
2883
2884 if (test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) {
2885 struct hci_cp_write_le_host_supported cp;
2886
2887 cp.le = 1;
2888 cp.simul = !!(hdev->features[6] & LMP_SIMUL_LE_BR);
2889
2890 hci_send_cmd(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED,
2891 sizeof(cp), &cp);
2892 }
2893
2878 update_class(hdev); 2894 update_class(hdev);
2879 update_name(hdev, hdev->dev_name); 2895 update_name(hdev, hdev->dev_name);
2880 update_eir(hdev); 2896 update_eir(hdev);
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 24c5eea8c45b..159aa8bef9e7 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -1073,16 +1073,13 @@ static int write_partial_msg_pages(struct ceph_connection *con)
1073 BUG_ON(kaddr == NULL); 1073 BUG_ON(kaddr == NULL);
1074 base = kaddr + con->out_msg_pos.page_pos + bio_offset; 1074 base = kaddr + con->out_msg_pos.page_pos + bio_offset;
1075 crc = crc32c(crc, base, len); 1075 crc = crc32c(crc, base, len);
1076 kunmap(page);
1076 msg->footer.data_crc = cpu_to_le32(crc); 1077 msg->footer.data_crc = cpu_to_le32(crc);
1077 con->out_msg_pos.did_page_crc = true; 1078 con->out_msg_pos.did_page_crc = true;
1078 } 1079 }
1079 ret = ceph_tcp_sendpage(con->sock, page, 1080 ret = ceph_tcp_sendpage(con->sock, page,
1080 con->out_msg_pos.page_pos + bio_offset, 1081 con->out_msg_pos.page_pos + bio_offset,
1081 len, 1); 1082 len, 1);
1082
1083 if (do_datacrc)
1084 kunmap(page);
1085
1086 if (ret <= 0) 1083 if (ret <= 0)
1087 goto out; 1084 goto out;
1088 1085
diff --git a/net/core/dev.c b/net/core/dev.c
index d7fe32c946c1..89e33a5d4d93 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2134,7 +2134,8 @@ static bool can_checksum_protocol(netdev_features_t features, __be16 protocol)
2134static netdev_features_t harmonize_features(struct sk_buff *skb, 2134static netdev_features_t harmonize_features(struct sk_buff *skb,
2135 __be16 protocol, netdev_features_t features) 2135 __be16 protocol, netdev_features_t features)
2136{ 2136{
2137 if (!can_checksum_protocol(features, protocol)) { 2137 if (skb->ip_summed != CHECKSUM_NONE &&
2138 !can_checksum_protocol(features, protocol)) {
2138 features &= ~NETIF_F_ALL_CSUM; 2139 features &= ~NETIF_F_ALL_CSUM;
2139 features &= ~NETIF_F_SG; 2140 features &= ~NETIF_F_SG;
2140 } else if (illegal_highdma(skb->dev, skb)) { 2141 } else if (illegal_highdma(skb->dev, skb)) {
@@ -3322,7 +3323,7 @@ ncls:
3322 3323
3323 if (pt_prev) { 3324 if (pt_prev) {
3324 if (unlikely(skb_orphan_frags(skb, GFP_ATOMIC))) 3325 if (unlikely(skb_orphan_frags(skb, GFP_ATOMIC)))
3325 ret = -ENOMEM; 3326 goto drop;
3326 else 3327 else
3327 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev); 3328 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
3328 } else { 3329 } else {
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index fe00d1208167..e33ebae519c8 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -3502,7 +3502,9 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
3502 if (!skb_cloned(from)) 3502 if (!skb_cloned(from))
3503 skb_shinfo(from)->nr_frags = 0; 3503 skb_shinfo(from)->nr_frags = 0;
3504 3504
3505 /* if the skb is cloned this does nothing since we set nr_frags to 0 */ 3505 /* if the skb is not cloned this does nothing
3506 * since we set nr_frags to 0.
3507 */
3506 for (i = 0; i < skb_shinfo(from)->nr_frags; i++) 3508 for (i = 0; i < skb_shinfo(from)->nr_frags; i++)
3507 skb_frag_ref(from, i); 3509 skb_frag_ref(from, i);
3508 3510
diff --git a/net/core/sock.c b/net/core/sock.c
index 305792076121..a6000fbad294 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -691,7 +691,8 @@ set_rcvbuf:
691 691
692 case SO_KEEPALIVE: 692 case SO_KEEPALIVE:
693#ifdef CONFIG_INET 693#ifdef CONFIG_INET
694 if (sk->sk_protocol == IPPROTO_TCP) 694 if (sk->sk_protocol == IPPROTO_TCP &&
695 sk->sk_type == SOCK_STREAM)
695 tcp_set_keepalive(sk, valbool); 696 tcp_set_keepalive(sk, valbool);
696#endif 697#endif
697 sock_valbool_flag(sk, SOCK_KEEPOPEN, valbool); 698 sock_valbool_flag(sk, SOCK_KEEPOPEN, valbool);
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index 77e87aff419a..47800459e4cb 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -1225,7 +1225,7 @@ static int arp_netdev_event(struct notifier_block *this, unsigned long event,
1225 switch (event) { 1225 switch (event) {
1226 case NETDEV_CHANGEADDR: 1226 case NETDEV_CHANGEADDR:
1227 neigh_changeaddr(&arp_tbl, dev); 1227 neigh_changeaddr(&arp_tbl, dev);
1228 rt_cache_flush(dev_net(dev), 0); 1228 rt_cache_flush(dev_net(dev));
1229 break; 1229 break;
1230 default: 1230 default:
1231 break; 1231 break;
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 44bf82e3aef7..e12fad773852 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -725,7 +725,7 @@ int devinet_ioctl(struct net *net, unsigned int cmd, void __user *arg)
725 break; 725 break;
726 726
727 case SIOCSIFFLAGS: 727 case SIOCSIFFLAGS:
728 ret = -EACCES; 728 ret = -EPERM;
729 if (!capable(CAP_NET_ADMIN)) 729 if (!capable(CAP_NET_ADMIN))
730 goto out; 730 goto out;
731 break; 731 break;
@@ -733,7 +733,7 @@ int devinet_ioctl(struct net *net, unsigned int cmd, void __user *arg)
733 case SIOCSIFBRDADDR: /* Set the broadcast address */ 733 case SIOCSIFBRDADDR: /* Set the broadcast address */
734 case SIOCSIFDSTADDR: /* Set the destination address */ 734 case SIOCSIFDSTADDR: /* Set the destination address */
735 case SIOCSIFNETMASK: /* Set the netmask for the interface */ 735 case SIOCSIFNETMASK: /* Set the netmask for the interface */
736 ret = -EACCES; 736 ret = -EPERM;
737 if (!capable(CAP_NET_ADMIN)) 737 if (!capable(CAP_NET_ADMIN))
738 goto out; 738 goto out;
739 ret = -EINVAL; 739 ret = -EINVAL;
@@ -1503,7 +1503,7 @@ static int devinet_conf_proc(ctl_table *ctl, int write,
1503 if (i == IPV4_DEVCONF_ACCEPT_LOCAL - 1 || 1503 if (i == IPV4_DEVCONF_ACCEPT_LOCAL - 1 ||
1504 i == IPV4_DEVCONF_ROUTE_LOCALNET - 1) 1504 i == IPV4_DEVCONF_ROUTE_LOCALNET - 1)
1505 if ((new_value == 0) && (old_value != 0)) 1505 if ((new_value == 0) && (old_value != 0))
1506 rt_cache_flush(net, 0); 1506 rt_cache_flush(net);
1507 } 1507 }
1508 1508
1509 return ret; 1509 return ret;
@@ -1537,7 +1537,7 @@ static int devinet_sysctl_forward(ctl_table *ctl, int write,
1537 dev_disable_lro(idev->dev); 1537 dev_disable_lro(idev->dev);
1538 } 1538 }
1539 rtnl_unlock(); 1539 rtnl_unlock();
1540 rt_cache_flush(net, 0); 1540 rt_cache_flush(net);
1541 } 1541 }
1542 } 1542 }
1543 1543
@@ -1554,7 +1554,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
1554 struct net *net = ctl->extra2; 1554 struct net *net = ctl->extra2;
1555 1555
1556 if (write && *valp != val) 1556 if (write && *valp != val)
1557 rt_cache_flush(net, 0); 1557 rt_cache_flush(net);
1558 1558
1559 return ret; 1559 return ret;
1560} 1560}
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index c43ae3fba792..8e2b475da9fa 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -148,7 +148,7 @@ static void fib_flush(struct net *net)
148 } 148 }
149 149
150 if (flushed) 150 if (flushed)
151 rt_cache_flush(net, -1); 151 rt_cache_flush(net);
152} 152}
153 153
154/* 154/*
@@ -999,11 +999,11 @@ static void nl_fib_lookup_exit(struct net *net)
999 net->ipv4.fibnl = NULL; 999 net->ipv4.fibnl = NULL;
1000} 1000}
1001 1001
1002static void fib_disable_ip(struct net_device *dev, int force, int delay) 1002static void fib_disable_ip(struct net_device *dev, int force)
1003{ 1003{
1004 if (fib_sync_down_dev(dev, force)) 1004 if (fib_sync_down_dev(dev, force))
1005 fib_flush(dev_net(dev)); 1005 fib_flush(dev_net(dev));
1006 rt_cache_flush(dev_net(dev), delay); 1006 rt_cache_flush(dev_net(dev));
1007 arp_ifdown(dev); 1007 arp_ifdown(dev);
1008} 1008}
1009 1009
@@ -1020,7 +1020,7 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
1020 fib_sync_up(dev); 1020 fib_sync_up(dev);
1021#endif 1021#endif
1022 atomic_inc(&net->ipv4.dev_addr_genid); 1022 atomic_inc(&net->ipv4.dev_addr_genid);
1023 rt_cache_flush(dev_net(dev), -1); 1023 rt_cache_flush(dev_net(dev));
1024 break; 1024 break;
1025 case NETDEV_DOWN: 1025 case NETDEV_DOWN:
1026 fib_del_ifaddr(ifa, NULL); 1026 fib_del_ifaddr(ifa, NULL);
@@ -1029,9 +1029,9 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
1029 /* Last address was deleted from this interface. 1029 /* Last address was deleted from this interface.
1030 * Disable IP. 1030 * Disable IP.
1031 */ 1031 */
1032 fib_disable_ip(dev, 1, 0); 1032 fib_disable_ip(dev, 1);
1033 } else { 1033 } else {
1034 rt_cache_flush(dev_net(dev), -1); 1034 rt_cache_flush(dev_net(dev));
1035 } 1035 }
1036 break; 1036 break;
1037 } 1037 }
@@ -1045,7 +1045,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
1045 struct net *net = dev_net(dev); 1045 struct net *net = dev_net(dev);
1046 1046
1047 if (event == NETDEV_UNREGISTER) { 1047 if (event == NETDEV_UNREGISTER) {
1048 fib_disable_ip(dev, 2, -1); 1048 fib_disable_ip(dev, 2);
1049 rt_flush_dev(dev); 1049 rt_flush_dev(dev);
1050 return NOTIFY_DONE; 1050 return NOTIFY_DONE;
1051 } 1051 }
@@ -1062,14 +1062,14 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
1062 fib_sync_up(dev); 1062 fib_sync_up(dev);
1063#endif 1063#endif
1064 atomic_inc(&net->ipv4.dev_addr_genid); 1064 atomic_inc(&net->ipv4.dev_addr_genid);
1065 rt_cache_flush(dev_net(dev), -1); 1065 rt_cache_flush(dev_net(dev));
1066 break; 1066 break;
1067 case NETDEV_DOWN: 1067 case NETDEV_DOWN:
1068 fib_disable_ip(dev, 0, 0); 1068 fib_disable_ip(dev, 0);
1069 break; 1069 break;
1070 case NETDEV_CHANGEMTU: 1070 case NETDEV_CHANGEMTU:
1071 case NETDEV_CHANGE: 1071 case NETDEV_CHANGE:
1072 rt_cache_flush(dev_net(dev), 0); 1072 rt_cache_flush(dev_net(dev));
1073 break; 1073 break;
1074 case NETDEV_UNREGISTER_BATCH: 1074 case NETDEV_UNREGISTER_BATCH:
1075 break; 1075 break;
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c
index a83d74e498d2..274309d3aded 100644
--- a/net/ipv4/fib_rules.c
+++ b/net/ipv4/fib_rules.c
@@ -259,7 +259,7 @@ static size_t fib4_rule_nlmsg_payload(struct fib_rule *rule)
259 259
260static void fib4_rule_flush_cache(struct fib_rules_ops *ops) 260static void fib4_rule_flush_cache(struct fib_rules_ops *ops)
261{ 261{
262 rt_cache_flush(ops->fro_net, -1); 262 rt_cache_flush(ops->fro_net);
263} 263}
264 264
265static const struct fib_rules_ops __net_initdata fib4_rules_ops_template = { 265static const struct fib_rules_ops __net_initdata fib4_rules_ops_template = {
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 57bd978483e1..d1b93595b4a7 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -1286,7 +1286,7 @@ int fib_table_insert(struct fib_table *tb, struct fib_config *cfg)
1286 1286
1287 fib_release_info(fi_drop); 1287 fib_release_info(fi_drop);
1288 if (state & FA_S_ACCESSED) 1288 if (state & FA_S_ACCESSED)
1289 rt_cache_flush(cfg->fc_nlinfo.nl_net, -1); 1289 rt_cache_flush(cfg->fc_nlinfo.nl_net);
1290 rtmsg_fib(RTM_NEWROUTE, htonl(key), new_fa, plen, 1290 rtmsg_fib(RTM_NEWROUTE, htonl(key), new_fa, plen,
1291 tb->tb_id, &cfg->fc_nlinfo, NLM_F_REPLACE); 1291 tb->tb_id, &cfg->fc_nlinfo, NLM_F_REPLACE);
1292 1292
@@ -1333,7 +1333,7 @@ int fib_table_insert(struct fib_table *tb, struct fib_config *cfg)
1333 list_add_tail_rcu(&new_fa->fa_list, 1333 list_add_tail_rcu(&new_fa->fa_list,
1334 (fa ? &fa->fa_list : fa_head)); 1334 (fa ? &fa->fa_list : fa_head));
1335 1335
1336 rt_cache_flush(cfg->fc_nlinfo.nl_net, -1); 1336 rt_cache_flush(cfg->fc_nlinfo.nl_net);
1337 rtmsg_fib(RTM_NEWROUTE, htonl(key), new_fa, plen, tb->tb_id, 1337 rtmsg_fib(RTM_NEWROUTE, htonl(key), new_fa, plen, tb->tb_id,
1338 &cfg->fc_nlinfo, 0); 1338 &cfg->fc_nlinfo, 0);
1339succeeded: 1339succeeded:
@@ -1708,7 +1708,7 @@ int fib_table_delete(struct fib_table *tb, struct fib_config *cfg)
1708 trie_leaf_remove(t, l); 1708 trie_leaf_remove(t, l);
1709 1709
1710 if (fa->fa_state & FA_S_ACCESSED) 1710 if (fa->fa_state & FA_S_ACCESSED)
1711 rt_cache_flush(cfg->fc_nlinfo.nl_net, -1); 1711 rt_cache_flush(cfg->fc_nlinfo.nl_net);
1712 1712
1713 fib_release_info(fa->fa_info); 1713 fib_release_info(fa->fa_info);
1714 alias_free_mem_rcu(fa); 1714 alias_free_mem_rcu(fa);
diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
index e1e0a4e8fd34..c7527f6b9ad9 100644
--- a/net/ipv4/inetpeer.c
+++ b/net/ipv4/inetpeer.c
@@ -510,7 +510,10 @@ relookup:
510 secure_ipv6_id(daddr->addr.a6)); 510 secure_ipv6_id(daddr->addr.a6));
511 p->metrics[RTAX_LOCK-1] = INETPEER_METRICS_NEW; 511 p->metrics[RTAX_LOCK-1] = INETPEER_METRICS_NEW;
512 p->rate_tokens = 0; 512 p->rate_tokens = 0;
513 p->rate_last = 0; 513 /* 60*HZ is arbitrary, but chosen enough high so that the first
514 * calculation of tokens is at its maximum.
515 */
516 p->rate_last = jiffies - 60*HZ;
514 INIT_LIST_HEAD(&p->gc_list); 517 INIT_LIST_HEAD(&p->gc_list);
515 518
516 /* Link the node. */ 519 /* Link the node. */
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index ff0f071969ea..d23c6571ba1c 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -131,18 +131,20 @@ found:
131 * 0 - deliver 131 * 0 - deliver
132 * 1 - block 132 * 1 - block
133 */ 133 */
134static __inline__ int icmp_filter(struct sock *sk, struct sk_buff *skb) 134static int icmp_filter(const struct sock *sk, const struct sk_buff *skb)
135{ 135{
136 int type; 136 struct icmphdr _hdr;
137 const struct icmphdr *hdr;
137 138
138 if (!pskb_may_pull(skb, sizeof(struct icmphdr))) 139 hdr = skb_header_pointer(skb, skb_transport_offset(skb),
140 sizeof(_hdr), &_hdr);
141 if (!hdr)
139 return 1; 142 return 1;
140 143
141 type = icmp_hdr(skb)->type; 144 if (hdr->type < 32) {
142 if (type < 32) {
143 __u32 data = raw_sk(sk)->filter.data; 145 __u32 data = raw_sk(sk)->filter.data;
144 146
145 return ((1 << type) & data) != 0; 147 return ((1U << hdr->type) & data) != 0;
146 } 148 }
147 149
148 /* Do not block unknown ICMP types */ 150 /* Do not block unknown ICMP types */
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 82cf2a722b23..fd9af60397b5 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -202,11 +202,6 @@ EXPORT_SYMBOL(ip_tos2prio);
202static DEFINE_PER_CPU(struct rt_cache_stat, rt_cache_stat); 202static DEFINE_PER_CPU(struct rt_cache_stat, rt_cache_stat);
203#define RT_CACHE_STAT_INC(field) __this_cpu_inc(rt_cache_stat.field) 203#define RT_CACHE_STAT_INC(field) __this_cpu_inc(rt_cache_stat.field)
204 204
205static inline int rt_genid(struct net *net)
206{
207 return atomic_read(&net->ipv4.rt_genid);
208}
209
210#ifdef CONFIG_PROC_FS 205#ifdef CONFIG_PROC_FS
211static void *rt_cache_seq_start(struct seq_file *seq, loff_t *pos) 206static void *rt_cache_seq_start(struct seq_file *seq, loff_t *pos)
212{ 207{
@@ -447,27 +442,9 @@ static inline bool rt_is_expired(const struct rtable *rth)
447 return rth->rt_genid != rt_genid(dev_net(rth->dst.dev)); 442 return rth->rt_genid != rt_genid(dev_net(rth->dst.dev));
448} 443}
449 444
450/* 445void rt_cache_flush(struct net *net)
451 * Perturbation of rt_genid by a small quantity [1..256]
452 * Using 8 bits of shuffling ensure we can call rt_cache_invalidate()
453 * many times (2^24) without giving recent rt_genid.
454 * Jenkins hash is strong enough that litle changes of rt_genid are OK.
455 */
456static void rt_cache_invalidate(struct net *net)
457{ 446{
458 unsigned char shuffle; 447 rt_genid_bump(net);
459
460 get_random_bytes(&shuffle, sizeof(shuffle));
461 atomic_add(shuffle + 1U, &net->ipv4.rt_genid);
462}
463
464/*
465 * delay < 0 : invalidate cache (fast : entries will be deleted later)
466 * delay >= 0 : invalidate & flush cache (can be long)
467 */
468void rt_cache_flush(struct net *net, int delay)
469{
470 rt_cache_invalidate(net);
471} 448}
472 449
473static struct neighbour *ipv4_neigh_lookup(const struct dst_entry *dst, 450static struct neighbour *ipv4_neigh_lookup(const struct dst_entry *dst,
@@ -2345,7 +2322,7 @@ int ip_rt_dump(struct sk_buff *skb, struct netlink_callback *cb)
2345 2322
2346void ip_rt_multicast_event(struct in_device *in_dev) 2323void ip_rt_multicast_event(struct in_device *in_dev)
2347{ 2324{
2348 rt_cache_flush(dev_net(in_dev->dev), 0); 2325 rt_cache_flush(dev_net(in_dev->dev));
2349} 2326}
2350 2327
2351#ifdef CONFIG_SYSCTL 2328#ifdef CONFIG_SYSCTL
@@ -2354,16 +2331,7 @@ static int ipv4_sysctl_rtcache_flush(ctl_table *__ctl, int write,
2354 size_t *lenp, loff_t *ppos) 2331 size_t *lenp, loff_t *ppos)
2355{ 2332{
2356 if (write) { 2333 if (write) {
2357 int flush_delay; 2334 rt_cache_flush((struct net *)__ctl->extra1);
2358 ctl_table ctl;
2359 struct net *net;
2360
2361 memcpy(&ctl, __ctl, sizeof(ctl));
2362 ctl.data = &flush_delay;
2363 proc_dointvec(&ctl, write, buffer, lenp, ppos);
2364
2365 net = (struct net *)__ctl->extra1;
2366 rt_cache_flush(net, flush_delay);
2367 return 0; 2335 return 0;
2368 } 2336 }
2369 2337
@@ -2533,8 +2501,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
2533 2501
2534static __net_init int rt_genid_init(struct net *net) 2502static __net_init int rt_genid_init(struct net *net)
2535{ 2503{
2536 get_random_bytes(&net->ipv4.rt_genid, 2504 atomic_set(&net->rt_genid, 0);
2537 sizeof(net->ipv4.rt_genid));
2538 get_random_bytes(&net->ipv4.dev_addr_genid, 2505 get_random_bytes(&net->ipv4.dev_addr_genid,
2539 sizeof(net->ipv4.dev_addr_genid)); 2506 sizeof(net->ipv4.dev_addr_genid));
2540 return 0; 2507 return 0;
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 2109ff4a1daf..5f6419341821 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1762,8 +1762,14 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
1762 } 1762 }
1763 1763
1764#ifdef CONFIG_NET_DMA 1764#ifdef CONFIG_NET_DMA
1765 if (tp->ucopy.dma_chan) 1765 if (tp->ucopy.dma_chan) {
1766 dma_async_memcpy_issue_pending(tp->ucopy.dma_chan); 1766 if (tp->rcv_wnd == 0 &&
1767 !skb_queue_empty(&sk->sk_async_wait_queue)) {
1768 tcp_service_net_dma(sk, true);
1769 tcp_cleanup_rbuf(sk, copied);
1770 } else
1771 dma_async_memcpy_issue_pending(tp->ucopy.dma_chan);
1772 }
1767#endif 1773#endif
1768 if (copied >= target) { 1774 if (copied >= target) {
1769 /* Do not sleep, just process backlog. */ 1775 /* Do not sleep, just process backlog. */
@@ -2325,10 +2331,17 @@ static int tcp_repair_options_est(struct tcp_sock *tp,
2325 tp->rx_opt.mss_clamp = opt.opt_val; 2331 tp->rx_opt.mss_clamp = opt.opt_val;
2326 break; 2332 break;
2327 case TCPOPT_WINDOW: 2333 case TCPOPT_WINDOW:
2328 if (opt.opt_val > 14) 2334 {
2329 return -EFBIG; 2335 u16 snd_wscale = opt.opt_val & 0xFFFF;
2336 u16 rcv_wscale = opt.opt_val >> 16;
2337
2338 if (snd_wscale > 14 || rcv_wscale > 14)
2339 return -EFBIG;
2330 2340
2331 tp->rx_opt.snd_wscale = opt.opt_val; 2341 tp->rx_opt.snd_wscale = snd_wscale;
2342 tp->rx_opt.rcv_wscale = rcv_wscale;
2343 tp->rx_opt.wscale_ok = 1;
2344 }
2332 break; 2345 break;
2333 case TCPOPT_SACK_PERM: 2346 case TCPOPT_SACK_PERM:
2334 if (opt.opt_val != 0) 2347 if (opt.opt_val != 0)
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 6e38c6c23caa..d377f4854cb8 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -4661,7 +4661,7 @@ queue_and_out:
4661 4661
4662 if (eaten > 0) 4662 if (eaten > 0)
4663 kfree_skb_partial(skb, fragstolen); 4663 kfree_skb_partial(skb, fragstolen);
4664 else if (!sock_flag(sk, SOCK_DEAD)) 4664 if (!sock_flag(sk, SOCK_DEAD))
4665 sk->sk_data_ready(sk, 0); 4665 sk->sk_data_ready(sk, 0);
4666 return; 4666 return;
4667 } 4667 }
@@ -5556,8 +5556,7 @@ no_ack:
5556#endif 5556#endif
5557 if (eaten) 5557 if (eaten)
5558 kfree_skb_partial(skb, fragstolen); 5558 kfree_skb_partial(skb, fragstolen);
5559 else 5559 sk->sk_data_ready(sk, 0);
5560 sk->sk_data_ready(sk, 0);
5561 return 0; 5560 return 0;
5562 } 5561 }
5563 } 5562 }
diff --git a/net/ipv6/inet6_connection_sock.c b/net/ipv6/inet6_connection_sock.c
index 0251a6005be8..c4f934176cab 100644
--- a/net/ipv6/inet6_connection_sock.c
+++ b/net/ipv6/inet6_connection_sock.c
@@ -175,33 +175,12 @@ void __inet6_csk_dst_store(struct sock *sk, struct dst_entry *dst,
175 const struct in6_addr *saddr) 175 const struct in6_addr *saddr)
176{ 176{
177 __ip6_dst_store(sk, dst, daddr, saddr); 177 __ip6_dst_store(sk, dst, daddr, saddr);
178
179#ifdef CONFIG_XFRM
180 {
181 struct rt6_info *rt = (struct rt6_info *)dst;
182 rt->rt6i_flow_cache_genid = atomic_read(&flow_cache_genid);
183 }
184#endif
185} 178}
186 179
187static inline 180static inline
188struct dst_entry *__inet6_csk_dst_check(struct sock *sk, u32 cookie) 181struct dst_entry *__inet6_csk_dst_check(struct sock *sk, u32 cookie)
189{ 182{
190 struct dst_entry *dst; 183 return __sk_dst_check(sk, cookie);
191
192 dst = __sk_dst_check(sk, cookie);
193
194#ifdef CONFIG_XFRM
195 if (dst) {
196 struct rt6_info *rt = (struct rt6_info *)dst;
197 if (rt->rt6i_flow_cache_genid != atomic_read(&flow_cache_genid)) {
198 __sk_dst_reset(sk);
199 dst = NULL;
200 }
201 }
202#endif
203
204 return dst;
205} 184}
206 185
207static struct dst_entry *inet6_csk_route_socket(struct sock *sk, 186static struct dst_entry *inet6_csk_route_socket(struct sock *sk,
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 13690d650c3e..286acfc21250 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -819,6 +819,10 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info)
819 offsetof(struct rt6_info, rt6i_src), 819 offsetof(struct rt6_info, rt6i_src),
820 allow_create, replace_required); 820 allow_create, replace_required);
821 821
822 if (IS_ERR(sn)) {
823 err = PTR_ERR(sn);
824 sn = NULL;
825 }
822 if (!sn) { 826 if (!sn) {
823 /* If it is failed, discard just allocated 827 /* If it is failed, discard just allocated
824 root, and then (in st_failure) stale node 828 root, and then (in st_failure) stale node
diff --git a/net/ipv6/mip6.c b/net/ipv6/mip6.c
index 5b087c31d87b..0f9bdc5ee9f3 100644
--- a/net/ipv6/mip6.c
+++ b/net/ipv6/mip6.c
@@ -86,28 +86,30 @@ static int mip6_mh_len(int type)
86 86
87static int mip6_mh_filter(struct sock *sk, struct sk_buff *skb) 87static int mip6_mh_filter(struct sock *sk, struct sk_buff *skb)
88{ 88{
89 struct ip6_mh *mh; 89 struct ip6_mh _hdr;
90 const struct ip6_mh *mh;
90 91
91 if (!pskb_may_pull(skb, (skb_transport_offset(skb)) + 8) || 92 mh = skb_header_pointer(skb, skb_transport_offset(skb),
92 !pskb_may_pull(skb, (skb_transport_offset(skb) + 93 sizeof(_hdr), &_hdr);
93 ((skb_transport_header(skb)[1] + 1) << 3)))) 94 if (!mh)
94 return -1; 95 return -1;
95 96
96 mh = (struct ip6_mh *)skb_transport_header(skb); 97 if (((mh->ip6mh_hdrlen + 1) << 3) > skb->len)
98 return -1;
97 99
98 if (mh->ip6mh_hdrlen < mip6_mh_len(mh->ip6mh_type)) { 100 if (mh->ip6mh_hdrlen < mip6_mh_len(mh->ip6mh_type)) {
99 LIMIT_NETDEBUG(KERN_DEBUG "mip6: MH message too short: %d vs >=%d\n", 101 LIMIT_NETDEBUG(KERN_DEBUG "mip6: MH message too short: %d vs >=%d\n",
100 mh->ip6mh_hdrlen, mip6_mh_len(mh->ip6mh_type)); 102 mh->ip6mh_hdrlen, mip6_mh_len(mh->ip6mh_type));
101 mip6_param_prob(skb, 0, ((&mh->ip6mh_hdrlen) - 103 mip6_param_prob(skb, 0, offsetof(struct ip6_mh, ip6mh_hdrlen) +
102 skb_network_header(skb))); 104 skb_network_header_len(skb));
103 return -1; 105 return -1;
104 } 106 }
105 107
106 if (mh->ip6mh_proto != IPPROTO_NONE) { 108 if (mh->ip6mh_proto != IPPROTO_NONE) {
107 LIMIT_NETDEBUG(KERN_DEBUG "mip6: MH invalid payload proto = %d\n", 109 LIMIT_NETDEBUG(KERN_DEBUG "mip6: MH invalid payload proto = %d\n",
108 mh->ip6mh_proto); 110 mh->ip6mh_proto);
109 mip6_param_prob(skb, 0, ((&mh->ip6mh_proto) - 111 mip6_param_prob(skb, 0, offsetof(struct ip6_mh, ip6mh_proto) +
110 skb_network_header(skb))); 112 skb_network_header_len(skb));
111 return -1; 113 return -1;
112 } 114 }
113 115
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index ef0579d5bca6..4a5f78b50495 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -107,21 +107,20 @@ found:
107 * 0 - deliver 107 * 0 - deliver
108 * 1 - block 108 * 1 - block
109 */ 109 */
110static __inline__ int icmpv6_filter(struct sock *sk, struct sk_buff *skb) 110static int icmpv6_filter(const struct sock *sk, const struct sk_buff *skb)
111{ 111{
112 struct icmp6hdr *icmph; 112 struct icmp6hdr *_hdr;
113 struct raw6_sock *rp = raw6_sk(sk); 113 const struct icmp6hdr *hdr;
114
115 if (pskb_may_pull(skb, sizeof(struct icmp6hdr))) {
116 __u32 *data = &rp->filter.data[0];
117 int bit_nr;
118 114
119 icmph = (struct icmp6hdr *) skb->data; 115 hdr = skb_header_pointer(skb, skb_transport_offset(skb),
120 bit_nr = icmph->icmp6_type; 116 sizeof(_hdr), &_hdr);
117 if (hdr) {
118 const __u32 *data = &raw6_sk(sk)->filter.data[0];
119 unsigned int type = hdr->icmp6_type;
121 120
122 return (data[bit_nr >> 5] & (1 << (bit_nr & 31))) != 0; 121 return (data[type >> 5] & (1U << (type & 31))) != 0;
123 } 122 }
124 return 0; 123 return 1;
125} 124}
126 125
127#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE) 126#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 8e80fd279100..854e4018d205 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -226,7 +226,7 @@ static struct rt6_info ip6_null_entry_template = {
226 .dst = { 226 .dst = {
227 .__refcnt = ATOMIC_INIT(1), 227 .__refcnt = ATOMIC_INIT(1),
228 .__use = 1, 228 .__use = 1,
229 .obsolete = -1, 229 .obsolete = DST_OBSOLETE_FORCE_CHK,
230 .error = -ENETUNREACH, 230 .error = -ENETUNREACH,
231 .input = ip6_pkt_discard, 231 .input = ip6_pkt_discard,
232 .output = ip6_pkt_discard_out, 232 .output = ip6_pkt_discard_out,
@@ -246,7 +246,7 @@ static struct rt6_info ip6_prohibit_entry_template = {
246 .dst = { 246 .dst = {
247 .__refcnt = ATOMIC_INIT(1), 247 .__refcnt = ATOMIC_INIT(1),
248 .__use = 1, 248 .__use = 1,
249 .obsolete = -1, 249 .obsolete = DST_OBSOLETE_FORCE_CHK,
250 .error = -EACCES, 250 .error = -EACCES,
251 .input = ip6_pkt_prohibit, 251 .input = ip6_pkt_prohibit,
252 .output = ip6_pkt_prohibit_out, 252 .output = ip6_pkt_prohibit_out,
@@ -261,7 +261,7 @@ static struct rt6_info ip6_blk_hole_entry_template = {
261 .dst = { 261 .dst = {
262 .__refcnt = ATOMIC_INIT(1), 262 .__refcnt = ATOMIC_INIT(1),
263 .__use = 1, 263 .__use = 1,
264 .obsolete = -1, 264 .obsolete = DST_OBSOLETE_FORCE_CHK,
265 .error = -EINVAL, 265 .error = -EINVAL,
266 .input = dst_discard, 266 .input = dst_discard,
267 .output = dst_discard, 267 .output = dst_discard,
@@ -281,13 +281,14 @@ static inline struct rt6_info *ip6_dst_alloc(struct net *net,
281 struct fib6_table *table) 281 struct fib6_table *table)
282{ 282{
283 struct rt6_info *rt = dst_alloc(&net->ipv6.ip6_dst_ops, dev, 283 struct rt6_info *rt = dst_alloc(&net->ipv6.ip6_dst_ops, dev,
284 0, DST_OBSOLETE_NONE, flags); 284 0, DST_OBSOLETE_FORCE_CHK, flags);
285 285
286 if (rt) { 286 if (rt) {
287 struct dst_entry *dst = &rt->dst; 287 struct dst_entry *dst = &rt->dst;
288 288
289 memset(dst + 1, 0, sizeof(*rt) - sizeof(*dst)); 289 memset(dst + 1, 0, sizeof(*rt) - sizeof(*dst));
290 rt6_init_peer(rt, table ? &table->tb6_peers : net->ipv6.peers); 290 rt6_init_peer(rt, table ? &table->tb6_peers : net->ipv6.peers);
291 rt->rt6i_genid = rt_genid(net);
291 } 292 }
292 return rt; 293 return rt;
293} 294}
@@ -1031,6 +1032,13 @@ static struct dst_entry *ip6_dst_check(struct dst_entry *dst, u32 cookie)
1031 1032
1032 rt = (struct rt6_info *) dst; 1033 rt = (struct rt6_info *) dst;
1033 1034
1035 /* All IPV6 dsts are created with ->obsolete set to the value
1036 * DST_OBSOLETE_FORCE_CHK which forces validation calls down
1037 * into this function always.
1038 */
1039 if (rt->rt6i_genid != rt_genid(dev_net(rt->dst.dev)))
1040 return NULL;
1041
1034 if (rt->rt6i_node && (rt->rt6i_node->fn_sernum == cookie)) { 1042 if (rt->rt6i_node && (rt->rt6i_node->fn_sernum == cookie)) {
1035 if (rt->rt6i_peer_genid != rt6_peer_genid()) { 1043 if (rt->rt6i_peer_genid != rt6_peer_genid()) {
1036 if (!rt6_has_peer(rt)) 1044 if (!rt6_has_peer(rt))
@@ -1397,8 +1405,6 @@ int ip6_route_add(struct fib6_config *cfg)
1397 goto out; 1405 goto out;
1398 } 1406 }
1399 1407
1400 rt->dst.obsolete = -1;
1401
1402 if (cfg->fc_flags & RTF_EXPIRES) 1408 if (cfg->fc_flags & RTF_EXPIRES)
1403 rt6_set_expires(rt, jiffies + 1409 rt6_set_expires(rt, jiffies +
1404 clock_t_to_jiffies(cfg->fc_expires)); 1410 clock_t_to_jiffies(cfg->fc_expires));
@@ -2080,7 +2086,6 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
2080 rt->dst.input = ip6_input; 2086 rt->dst.input = ip6_input;
2081 rt->dst.output = ip6_output; 2087 rt->dst.output = ip6_output;
2082 rt->rt6i_idev = idev; 2088 rt->rt6i_idev = idev;
2083 rt->dst.obsolete = -1;
2084 2089
2085 rt->rt6i_flags = RTF_UP | RTF_NONEXTHOP; 2090 rt->rt6i_flags = RTF_UP | RTF_NONEXTHOP;
2086 if (anycast) 2091 if (anycast)
diff --git a/net/l2tp/l2tp_netlink.c b/net/l2tp/l2tp_netlink.c
index d71cd9229a47..6f936358d664 100644
--- a/net/l2tp/l2tp_netlink.c
+++ b/net/l2tp/l2tp_netlink.c
@@ -80,8 +80,8 @@ static int l2tp_nl_cmd_noop(struct sk_buff *skb, struct genl_info *info)
80 80
81 hdr = genlmsg_put(msg, info->snd_pid, info->snd_seq, 81 hdr = genlmsg_put(msg, info->snd_pid, info->snd_seq,
82 &l2tp_nl_family, 0, L2TP_CMD_NOOP); 82 &l2tp_nl_family, 0, L2TP_CMD_NOOP);
83 if (IS_ERR(hdr)) { 83 if (!hdr) {
84 ret = PTR_ERR(hdr); 84 ret = -EMSGSIZE;
85 goto err_out; 85 goto err_out;
86 } 86 }
87 87
@@ -250,8 +250,8 @@ static int l2tp_nl_tunnel_send(struct sk_buff *skb, u32 pid, u32 seq, int flags,
250 250
251 hdr = genlmsg_put(skb, pid, seq, &l2tp_nl_family, flags, 251 hdr = genlmsg_put(skb, pid, seq, &l2tp_nl_family, flags,
252 L2TP_CMD_TUNNEL_GET); 252 L2TP_CMD_TUNNEL_GET);
253 if (IS_ERR(hdr)) 253 if (!hdr)
254 return PTR_ERR(hdr); 254 return -EMSGSIZE;
255 255
256 if (nla_put_u8(skb, L2TP_ATTR_PROTO_VERSION, tunnel->version) || 256 if (nla_put_u8(skb, L2TP_ATTR_PROTO_VERSION, tunnel->version) ||
257 nla_put_u32(skb, L2TP_ATTR_CONN_ID, tunnel->tunnel_id) || 257 nla_put_u32(skb, L2TP_ATTR_CONN_ID, tunnel->tunnel_id) ||
@@ -617,8 +617,8 @@ static int l2tp_nl_session_send(struct sk_buff *skb, u32 pid, u32 seq, int flags
617 sk = tunnel->sock; 617 sk = tunnel->sock;
618 618
619 hdr = genlmsg_put(skb, pid, seq, &l2tp_nl_family, flags, L2TP_CMD_SESSION_GET); 619 hdr = genlmsg_put(skb, pid, seq, &l2tp_nl_family, flags, L2TP_CMD_SESSION_GET);
620 if (IS_ERR(hdr)) 620 if (!hdr)
621 return PTR_ERR(hdr); 621 return -EMSGSIZE;
622 622
623 if (nla_put_u32(skb, L2TP_ATTR_CONN_ID, tunnel->tunnel_id) || 623 if (nla_put_u32(skb, L2TP_ATTR_CONN_ID, tunnel->tunnel_id) ||
624 nla_put_u32(skb, L2TP_ATTR_SESSION_ID, session->session_id) || 624 nla_put_u32(skb, L2TP_ATTR_SESSION_ID, session->session_id) ||
diff --git a/net/netfilter/xt_limit.c b/net/netfilter/xt_limit.c
index 5c22ce8ab309..a4c1e4528cac 100644
--- a/net/netfilter/xt_limit.c
+++ b/net/netfilter/xt_limit.c
@@ -117,11 +117,11 @@ static int limit_mt_check(const struct xt_mtchk_param *par)
117 117
118 /* For SMP, we only want to use one set of state. */ 118 /* For SMP, we only want to use one set of state. */
119 r->master = priv; 119 r->master = priv;
120 /* User avg in seconds * XT_LIMIT_SCALE: convert to jiffies *
121 128. */
122 priv->prev = jiffies;
123 priv->credit = user2credits(r->avg * r->burst); /* Credits full. */
120 if (r->cost == 0) { 124 if (r->cost == 0) {
121 /* User avg in seconds * XT_LIMIT_SCALE: convert to jiffies *
122 128. */
123 priv->prev = jiffies;
124 priv->credit = user2credits(r->avg * r->burst); /* Credits full. */
125 r->credit_cap = priv->credit; /* Credits full. */ 125 r->credit_cap = priv->credit; /* Credits full. */
126 r->cost = user2credits(r->avg); 126 r->cost = user2credits(r->avg);
127 } 127 }
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
index 1b9024ee963c..7261eb81974f 100644
--- a/net/netrom/af_netrom.c
+++ b/net/netrom/af_netrom.c
@@ -601,7 +601,7 @@ static int nr_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
601 if (!capable(CAP_NET_BIND_SERVICE)) { 601 if (!capable(CAP_NET_BIND_SERVICE)) {
602 dev_put(dev); 602 dev_put(dev);
603 release_sock(sk); 603 release_sock(sk);
604 return -EACCES; 604 return -EPERM;
605 } 605 }
606 nr->user_addr = addr->fsa_digipeater[0]; 606 nr->user_addr = addr->fsa_digipeater[0];
607 nr->source_addr = addr->fsa_ax25.sax25_call; 607 nr->source_addr = addr->fsa_ax25.sax25_call;
diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c
index e4723d31fdd5..211a21217045 100644
--- a/net/sched/sch_qfq.c
+++ b/net/sched/sch_qfq.c
@@ -865,7 +865,10 @@ static void qfq_update_start(struct qfq_sched *q, struct qfq_class *cl)
865 if (mask) { 865 if (mask) {
866 struct qfq_group *next = qfq_ffs(q, mask); 866 struct qfq_group *next = qfq_ffs(q, mask);
867 if (qfq_gt(roundedF, next->F)) { 867 if (qfq_gt(roundedF, next->F)) {
868 cl->S = next->F; 868 if (qfq_gt(limit, next->F))
869 cl->S = next->F;
870 else /* preserve timestamp correctness */
871 cl->S = limit;
869 return; 872 return;
870 } 873 }
871 } 874 }
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 2ded3c7fad06..72d170ca3406 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -350,6 +350,9 @@ static void reg_regdb_search(struct work_struct *work)
350 struct reg_regdb_search_request *request; 350 struct reg_regdb_search_request *request;
351 const struct ieee80211_regdomain *curdom, *regdom; 351 const struct ieee80211_regdomain *curdom, *regdom;
352 int i, r; 352 int i, r;
353 bool set_reg = false;
354
355 mutex_lock(&cfg80211_mutex);
353 356
354 mutex_lock(&reg_regdb_search_mutex); 357 mutex_lock(&reg_regdb_search_mutex);
355 while (!list_empty(&reg_regdb_search_list)) { 358 while (!list_empty(&reg_regdb_search_list)) {
@@ -365,9 +368,7 @@ static void reg_regdb_search(struct work_struct *work)
365 r = reg_copy_regd(&regdom, curdom); 368 r = reg_copy_regd(&regdom, curdom);
366 if (r) 369 if (r)
367 break; 370 break;
368 mutex_lock(&cfg80211_mutex); 371 set_reg = true;
369 set_regdom(regdom);
370 mutex_unlock(&cfg80211_mutex);
371 break; 372 break;
372 } 373 }
373 } 374 }
@@ -375,6 +376,11 @@ static void reg_regdb_search(struct work_struct *work)
375 kfree(request); 376 kfree(request);
376 } 377 }
377 mutex_unlock(&reg_regdb_search_mutex); 378 mutex_unlock(&reg_regdb_search_mutex);
379
380 if (set_reg)
381 set_regdom(regdom);
382
383 mutex_unlock(&cfg80211_mutex);
378} 384}
379 385
380static DECLARE_WORK(reg_regdb_work, reg_regdb_search); 386static DECLARE_WORK(reg_regdb_work, reg_regdb_search);
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 5a2aa17e4d3c..387848e90078 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -585,6 +585,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
585 xfrm_pol_hold(policy); 585 xfrm_pol_hold(policy);
586 net->xfrm.policy_count[dir]++; 586 net->xfrm.policy_count[dir]++;
587 atomic_inc(&flow_cache_genid); 587 atomic_inc(&flow_cache_genid);
588 rt_genid_bump(net);
588 if (delpol) 589 if (delpol)
589 __xfrm_policy_unlink(delpol, dir); 590 __xfrm_policy_unlink(delpol, dir);
590 policy->index = delpol ? delpol->index : xfrm_gen_index(net, dir); 591 policy->index = delpol ? delpol->index : xfrm_gen_index(net, dir);
@@ -1763,7 +1764,7 @@ static struct dst_entry *make_blackhole(struct net *net, u16 family,
1763 1764
1764 if (!afinfo) { 1765 if (!afinfo) {
1765 dst_release(dst_orig); 1766 dst_release(dst_orig);
1766 ret = ERR_PTR(-EINVAL); 1767 return ERR_PTR(-EINVAL);
1767 } else { 1768 } else {
1768 ret = afinfo->blackhole_route(net, dst_orig); 1769 ret = afinfo->blackhole_route(net, dst_orig);
1769 } 1770 }
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index e75d8e47f35c..289f4bf18ff0 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -123,9 +123,21 @@ static inline int verify_replay(struct xfrm_usersa_info *p,
123 struct nlattr **attrs) 123 struct nlattr **attrs)
124{ 124{
125 struct nlattr *rt = attrs[XFRMA_REPLAY_ESN_VAL]; 125 struct nlattr *rt = attrs[XFRMA_REPLAY_ESN_VAL];
126 struct xfrm_replay_state_esn *rs;
126 127
127 if ((p->flags & XFRM_STATE_ESN) && !rt) 128 if (p->flags & XFRM_STATE_ESN) {
128 return -EINVAL; 129 if (!rt)
130 return -EINVAL;
131
132 rs = nla_data(rt);
133
134 if (rs->bmp_len > XFRMA_REPLAY_ESN_MAX / sizeof(rs->bmp[0]) / 8)
135 return -EINVAL;
136
137 if (nla_len(rt) < xfrm_replay_state_esn_len(rs) &&
138 nla_len(rt) != sizeof(*rs))
139 return -EINVAL;
140 }
129 141
130 if (!rt) 142 if (!rt)
131 return 0; 143 return 0;
@@ -370,14 +382,15 @@ static inline int xfrm_replay_verify_len(struct xfrm_replay_state_esn *replay_es
370 struct nlattr *rp) 382 struct nlattr *rp)
371{ 383{
372 struct xfrm_replay_state_esn *up; 384 struct xfrm_replay_state_esn *up;
385 int ulen;
373 386
374 if (!replay_esn || !rp) 387 if (!replay_esn || !rp)
375 return 0; 388 return 0;
376 389
377 up = nla_data(rp); 390 up = nla_data(rp);
391 ulen = xfrm_replay_state_esn_len(up);
378 392
379 if (xfrm_replay_state_esn_len(replay_esn) != 393 if (nla_len(rp) < ulen || xfrm_replay_state_esn_len(replay_esn) != ulen)
380 xfrm_replay_state_esn_len(up))
381 return -EINVAL; 394 return -EINVAL;
382 395
383 return 0; 396 return 0;
@@ -388,22 +401,28 @@ static int xfrm_alloc_replay_state_esn(struct xfrm_replay_state_esn **replay_esn
388 struct nlattr *rta) 401 struct nlattr *rta)
389{ 402{
390 struct xfrm_replay_state_esn *p, *pp, *up; 403 struct xfrm_replay_state_esn *p, *pp, *up;
404 int klen, ulen;
391 405
392 if (!rta) 406 if (!rta)
393 return 0; 407 return 0;
394 408
395 up = nla_data(rta); 409 up = nla_data(rta);
410 klen = xfrm_replay_state_esn_len(up);
411 ulen = nla_len(rta) >= klen ? klen : sizeof(*up);
396 412
397 p = kmemdup(up, xfrm_replay_state_esn_len(up), GFP_KERNEL); 413 p = kzalloc(klen, GFP_KERNEL);
398 if (!p) 414 if (!p)
399 return -ENOMEM; 415 return -ENOMEM;
400 416
401 pp = kmemdup(up, xfrm_replay_state_esn_len(up), GFP_KERNEL); 417 pp = kzalloc(klen, GFP_KERNEL);
402 if (!pp) { 418 if (!pp) {
403 kfree(p); 419 kfree(p);
404 return -ENOMEM; 420 return -ENOMEM;
405 } 421 }
406 422
423 memcpy(p, up, ulen);
424 memcpy(pp, up, ulen);
425
407 *replay_esn = p; 426 *replay_esn = p;
408 *preplay_esn = pp; 427 *preplay_esn = pp;
409 428
@@ -442,10 +461,11 @@ static void copy_from_user_state(struct xfrm_state *x, struct xfrm_usersa_info *
442 * somehow made shareable and move it to xfrm_state.c - JHS 461 * somehow made shareable and move it to xfrm_state.c - JHS
443 * 462 *
444*/ 463*/
445static void xfrm_update_ae_params(struct xfrm_state *x, struct nlattr **attrs) 464static void xfrm_update_ae_params(struct xfrm_state *x, struct nlattr **attrs,
465 int update_esn)
446{ 466{
447 struct nlattr *rp = attrs[XFRMA_REPLAY_VAL]; 467 struct nlattr *rp = attrs[XFRMA_REPLAY_VAL];
448 struct nlattr *re = attrs[XFRMA_REPLAY_ESN_VAL]; 468 struct nlattr *re = update_esn ? attrs[XFRMA_REPLAY_ESN_VAL] : NULL;
449 struct nlattr *lt = attrs[XFRMA_LTIME_VAL]; 469 struct nlattr *lt = attrs[XFRMA_LTIME_VAL];
450 struct nlattr *et = attrs[XFRMA_ETIMER_THRESH]; 470 struct nlattr *et = attrs[XFRMA_ETIMER_THRESH];
451 struct nlattr *rt = attrs[XFRMA_REPLAY_THRESH]; 471 struct nlattr *rt = attrs[XFRMA_REPLAY_THRESH];
@@ -555,7 +575,7 @@ static struct xfrm_state *xfrm_state_construct(struct net *net,
555 goto error; 575 goto error;
556 576
557 /* override default values from above */ 577 /* override default values from above */
558 xfrm_update_ae_params(x, attrs); 578 xfrm_update_ae_params(x, attrs, 0);
559 579
560 return x; 580 return x;
561 581
@@ -689,6 +709,7 @@ out:
689 709
690static void copy_to_user_state(struct xfrm_state *x, struct xfrm_usersa_info *p) 710static void copy_to_user_state(struct xfrm_state *x, struct xfrm_usersa_info *p)
691{ 711{
712 memset(p, 0, sizeof(*p));
692 memcpy(&p->id, &x->id, sizeof(p->id)); 713 memcpy(&p->id, &x->id, sizeof(p->id));
693 memcpy(&p->sel, &x->sel, sizeof(p->sel)); 714 memcpy(&p->sel, &x->sel, sizeof(p->sel));
694 memcpy(&p->lft, &x->lft, sizeof(p->lft)); 715 memcpy(&p->lft, &x->lft, sizeof(p->lft));
@@ -742,7 +763,7 @@ static int copy_to_user_auth(struct xfrm_algo_auth *auth, struct sk_buff *skb)
742 return -EMSGSIZE; 763 return -EMSGSIZE;
743 764
744 algo = nla_data(nla); 765 algo = nla_data(nla);
745 strcpy(algo->alg_name, auth->alg_name); 766 strncpy(algo->alg_name, auth->alg_name, sizeof(algo->alg_name));
746 memcpy(algo->alg_key, auth->alg_key, (auth->alg_key_len + 7) / 8); 767 memcpy(algo->alg_key, auth->alg_key, (auth->alg_key_len + 7) / 8);
747 algo->alg_key_len = auth->alg_key_len; 768 algo->alg_key_len = auth->alg_key_len;
748 769
@@ -878,6 +899,7 @@ static struct sk_buff *xfrm_state_netlink(struct sk_buff *in_skb,
878{ 899{
879 struct xfrm_dump_info info; 900 struct xfrm_dump_info info;
880 struct sk_buff *skb; 901 struct sk_buff *skb;
902 int err;
881 903
882 skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC); 904 skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
883 if (!skb) 905 if (!skb)
@@ -888,9 +910,10 @@ static struct sk_buff *xfrm_state_netlink(struct sk_buff *in_skb,
888 info.nlmsg_seq = seq; 910 info.nlmsg_seq = seq;
889 info.nlmsg_flags = 0; 911 info.nlmsg_flags = 0;
890 912
891 if (dump_one_state(x, 0, &info)) { 913 err = dump_one_state(x, 0, &info);
914 if (err) {
892 kfree_skb(skb); 915 kfree_skb(skb);
893 return NULL; 916 return ERR_PTR(err);
894 } 917 }
895 918
896 return skb; 919 return skb;
@@ -1317,6 +1340,7 @@ static void copy_from_user_policy(struct xfrm_policy *xp, struct xfrm_userpolicy
1317 1340
1318static void copy_to_user_policy(struct xfrm_policy *xp, struct xfrm_userpolicy_info *p, int dir) 1341static void copy_to_user_policy(struct xfrm_policy *xp, struct xfrm_userpolicy_info *p, int dir)
1319{ 1342{
1343 memset(p, 0, sizeof(*p));
1320 memcpy(&p->sel, &xp->selector, sizeof(p->sel)); 1344 memcpy(&p->sel, &xp->selector, sizeof(p->sel));
1321 memcpy(&p->lft, &xp->lft, sizeof(p->lft)); 1345 memcpy(&p->lft, &xp->lft, sizeof(p->lft));
1322 memcpy(&p->curlft, &xp->curlft, sizeof(p->curlft)); 1346 memcpy(&p->curlft, &xp->curlft, sizeof(p->curlft));
@@ -1421,6 +1445,7 @@ static int copy_to_user_tmpl(struct xfrm_policy *xp, struct sk_buff *skb)
1421 struct xfrm_user_tmpl *up = &vec[i]; 1445 struct xfrm_user_tmpl *up = &vec[i];
1422 struct xfrm_tmpl *kp = &xp->xfrm_vec[i]; 1446 struct xfrm_tmpl *kp = &xp->xfrm_vec[i];
1423 1447
1448 memset(up, 0, sizeof(*up));
1424 memcpy(&up->id, &kp->id, sizeof(up->id)); 1449 memcpy(&up->id, &kp->id, sizeof(up->id));
1425 up->family = kp->encap_family; 1450 up->family = kp->encap_family;
1426 memcpy(&up->saddr, &kp->saddr, sizeof(up->saddr)); 1451 memcpy(&up->saddr, &kp->saddr, sizeof(up->saddr));
@@ -1546,6 +1571,7 @@ static struct sk_buff *xfrm_policy_netlink(struct sk_buff *in_skb,
1546{ 1571{
1547 struct xfrm_dump_info info; 1572 struct xfrm_dump_info info;
1548 struct sk_buff *skb; 1573 struct sk_buff *skb;
1574 int err;
1549 1575
1550 skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); 1576 skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
1551 if (!skb) 1577 if (!skb)
@@ -1556,9 +1582,10 @@ static struct sk_buff *xfrm_policy_netlink(struct sk_buff *in_skb,
1556 info.nlmsg_seq = seq; 1582 info.nlmsg_seq = seq;
1557 info.nlmsg_flags = 0; 1583 info.nlmsg_flags = 0;
1558 1584
1559 if (dump_one_policy(xp, dir, 0, &info) < 0) { 1585 err = dump_one_policy(xp, dir, 0, &info);
1586 if (err) {
1560 kfree_skb(skb); 1587 kfree_skb(skb);
1561 return NULL; 1588 return ERR_PTR(err);
1562 } 1589 }
1563 1590
1564 return skb; 1591 return skb;
@@ -1822,7 +1849,7 @@ static int xfrm_new_ae(struct sk_buff *skb, struct nlmsghdr *nlh,
1822 goto out; 1849 goto out;
1823 1850
1824 spin_lock_bh(&x->lock); 1851 spin_lock_bh(&x->lock);
1825 xfrm_update_ae_params(x, attrs); 1852 xfrm_update_ae_params(x, attrs, 1);
1826 spin_unlock_bh(&x->lock); 1853 spin_unlock_bh(&x->lock);
1827 1854
1828 c.event = nlh->nlmsg_type; 1855 c.event = nlh->nlmsg_type;
diff --git a/scripts/Makefile.fwinst b/scripts/Makefile.fwinst
index c3f69ae275d1..4d908d16c035 100644
--- a/scripts/Makefile.fwinst
+++ b/scripts/Makefile.fwinst
@@ -27,7 +27,7 @@ endif
27installed-mod-fw := $(addprefix $(INSTALL_FW_PATH)/,$(mod-fw)) 27installed-mod-fw := $(addprefix $(INSTALL_FW_PATH)/,$(mod-fw))
28 28
29installed-fw := $(addprefix $(INSTALL_FW_PATH)/,$(fw-shipped-all)) 29installed-fw := $(addprefix $(INSTALL_FW_PATH)/,$(fw-shipped-all))
30installed-fw-dirs := $(sort $(dir $(installed-fw))) $(INSTALL_FW_PATH)/. 30installed-fw-dirs := $(sort $(dir $(installed-fw))) $(INSTALL_FW_PATH)/./
31 31
32# Workaround for make < 3.81, where .SECONDEXPANSION doesn't work. 32# Workaround for make < 3.81, where .SECONDEXPANSION doesn't work.
33PHONY += $(INSTALL_FW_PATH)/$$(%) install-all-dirs 33PHONY += $(INSTALL_FW_PATH)/$$(%) install-all-dirs
@@ -42,7 +42,7 @@ quiet_cmd_install = INSTALL $(subst $(srctree)/,,$@)
42$(installed-fw-dirs): 42$(installed-fw-dirs):
43 $(call cmd,mkdir) 43 $(call cmd,mkdir)
44 44
45$(installed-fw): $(INSTALL_FW_PATH)/%: $(obj)/% | $$(dir $(INSTALL_FW_PATH)/%) 45$(installed-fw): $(INSTALL_FW_PATH)/%: $(obj)/% | $(INSTALL_FW_PATH)/$$(dir %)
46 $(call cmd,install) 46 $(call cmd,install)
47 47
48PHONY += __fw_install __fw_modinst FORCE 48PHONY += __fw_install __fw_modinst FORCE
diff --git a/scripts/checksyscalls.sh b/scripts/checksyscalls.sh
index d24810fc6af6..fd8fa9aa7c4e 100755
--- a/scripts/checksyscalls.sh
+++ b/scripts/checksyscalls.sh
@@ -200,7 +200,7 @@ EOF
200syscall_list() { 200syscall_list() {
201 grep '^[0-9]' "$1" | sort -n | ( 201 grep '^[0-9]' "$1" | sort -n | (
202 while read nr abi name entry ; do 202 while read nr abi name entry ; do
203 echo <<EOF 203 cat <<EOF
204#if !defined(__NR_${name}) && !defined(__IGNORE_${name}) 204#if !defined(__NR_${name}) && !defined(__IGNORE_${name})
205#warning syscall ${name} not implemented 205#warning syscall ${name} not implemented
206#endif 206#endif
diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
index c220f314709c..65f67cb0aefb 100644
--- a/security/selinux/include/xfrm.h
+++ b/security/selinux/include/xfrm.h
@@ -51,6 +51,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
51static inline void selinux_xfrm_notify_policyload(void) 51static inline void selinux_xfrm_notify_policyload(void)
52{ 52{
53 atomic_inc(&flow_cache_genid); 53 atomic_inc(&flow_cache_genid);
54 rt_genid_bump(&init_net);
54} 55}
55#else 56#else
56static inline int selinux_xfrm_enabled(void) 57static inline int selinux_xfrm_enabled(void)
diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c
index 3fd5b29dc933..a3acb7a85f6a 100644
--- a/sound/soc/codecs/wm2000.c
+++ b/sound/soc/codecs/wm2000.c
@@ -702,7 +702,7 @@ static bool wm2000_readable_reg(struct device *dev, unsigned int reg)
702} 702}
703 703
704static const struct regmap_config wm2000_regmap = { 704static const struct regmap_config wm2000_regmap = {
705 .reg_bits = 8, 705 .reg_bits = 16,
706 .val_bits = 8, 706 .val_bits = 8,
707 707
708 .max_register = WM2000_REG_IF_CTL, 708 .max_register = WM2000_REG_IF_CTL,
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index d6e2bb49c59c..060dccb9ec75 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -197,7 +197,13 @@ static void prepare_outbound_urb(struct snd_usb_endpoint *ep,
197 /* no data provider, so send silence */ 197 /* no data provider, so send silence */
198 unsigned int offs = 0; 198 unsigned int offs = 0;
199 for (i = 0; i < ctx->packets; ++i) { 199 for (i = 0; i < ctx->packets; ++i) {
200 int counts = ctx->packet_size[i]; 200 int counts;
201
202 if (ctx->packet_size[i])
203 counts = ctx->packet_size[i];
204 else
205 counts = snd_usb_endpoint_next_packet_size(ep);
206
201 urb->iso_frame_desc[i].offset = offs * ep->stride; 207 urb->iso_frame_desc[i].offset = offs * ep->stride;
202 urb->iso_frame_desc[i].length = counts * ep->stride; 208 urb->iso_frame_desc[i].length = counts * ep->stride;
203 offs += counts; 209 offs += counts;
diff --git a/tools/power/acpi/Makefile b/tools/power/acpi/Makefile
new file mode 100644
index 000000000000..6b9cf7a987c7
--- /dev/null
+++ b/tools/power/acpi/Makefile
@@ -0,0 +1,18 @@
1PROG= acpidump
2SRCS= acpidump.c
3KERNEL_INCLUDE := ../../../include
4CFLAGS += -Wall -Wstrict-prototypes -Wdeclaration-after-statement -Os -s -D_LINUX -DDEFINE_ALTERNATE_TYPES -I$(KERNEL_INCLUDE)
5
6all: acpidump
7$(PROG) : $(SRCS)
8 $(CC) $(CFLAGS) $(SRCS) -o $(PROG)
9
10CLEANFILES= $(PROG)
11
12clean :
13 rm -f $(CLEANFILES) $(patsubst %.c,%.o, $(SRCS)) *~
14
15install :
16 install acpidump /usr/bin/acpidump
17 install acpidump.8 /usr/share/man/man8
18
diff --git a/tools/power/acpi/acpidump.8 b/tools/power/acpi/acpidump.8
new file mode 100644
index 000000000000..adfa99166e5e
--- /dev/null
+++ b/tools/power/acpi/acpidump.8
@@ -0,0 +1,59 @@
1.TH ACPIDUMP 8
2.SH NAME
3acpidump \- Dump system's ACPI tables to an ASCII file.
4.SH SYNOPSIS
5.ft B
6.B acpidump > acpidump.out
7.SH DESCRIPTION
8\fBacpidump \fP dumps the systems ACPI tables to an ASCII file
9appropriate for attaching to a bug report.
10
11Subsequently, they can be processed by utilities in the ACPICA package.
12.SS Options
13no options worth worrying about.
14.PP
15.SH EXAMPLE
16
17.nf
18# acpidump > acpidump.out
19
20$ acpixtract -a acpidump.out
21 Acpi table [DSDT] - 15974 bytes written to DSDT.dat
22 Acpi table [FACS] - 64 bytes written to FACS.dat
23 Acpi table [FACP] - 116 bytes written to FACP.dat
24 Acpi table [APIC] - 120 bytes written to APIC.dat
25 Acpi table [MCFG] - 60 bytes written to MCFG.dat
26 Acpi table [SSDT] - 444 bytes written to SSDT1.dat
27 Acpi table [SSDT] - 439 bytes written to SSDT2.dat
28 Acpi table [SSDT] - 439 bytes written to SSDT3.dat
29 Acpi table [SSDT] - 439 bytes written to SSDT4.dat
30 Acpi table [SSDT] - 439 bytes written to SSDT5.dat
31 Acpi table [RSDT] - 76 bytes written to RSDT.dat
32 Acpi table [RSDP] - 20 bytes written to RSDP.dat
33
34$ iasl -d *.dat
35...
36.fi
37creates *.dsl, a human readable form which can be edited
38and compiled using iasl.
39
40
41.SH NOTES
42
43.B "acpidump "
44must be run as root.
45
46.SH REFERENCES
47ACPICA: https://acpica.org/
48
49.SH FILES
50.ta
51.nf
52/dev/mem
53/sys/firmware/acpi/tables/dynamic/*
54.fi
55
56.PP
57.SH AUTHOR
58.nf
59Written by Len Brown <len.brown@intel.com>
diff --git a/tools/power/acpi/acpidump.c b/tools/power/acpi/acpidump.c
new file mode 100644
index 000000000000..07779871421c
--- /dev/null
+++ b/tools/power/acpi/acpidump.c
@@ -0,0 +1,560 @@
1/*
2 * (c) Alexey Starikovskiy, Intel, 2005-2006.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions, and the following disclaimer,
10 * without modification.
11 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12 * substantially similar to the "NO WARRANTY" disclaimer below
13 * ("Disclaimer") and any redistribution must be conditioned upon
14 * including a substantially similar Disclaimer requirement for further
15 * binary redistribution.
16 * 3. Neither the names of the above-listed copyright holders nor the names
17 * of any contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * Alternatively, this software may be distributed under the terms of the
21 * GNU General Public License ("GPL") version 2 as published by the Free
22 * Software Foundation.
23 *
24 * NO WARRANTY
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
33 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
34 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGES.
36 */
37
38#ifdef DEFINE_ALTERNATE_TYPES
39/* hack to enable building old application with new headers -lenb */
40#define acpi_fadt_descriptor acpi_table_fadt
41#define acpi_rsdp_descriptor acpi_table_rsdp
42#define DSDT_SIG ACPI_SIG_DSDT
43#define FACS_SIG ACPI_SIG_FACS
44#define FADT_SIG ACPI_SIG_FADT
45#define xfirmware_ctrl Xfacs
46#define firmware_ctrl facs
47
48typedef int s32;
49typedef unsigned char u8;
50typedef unsigned short u16;
51typedef unsigned int u32;
52typedef unsigned long long u64;
53typedef long long s64;
54#endif
55
56#include <sys/mman.h>
57#include <sys/types.h>
58#include <sys/stat.h>
59#include <fcntl.h>
60#include <stdio.h>
61#include <string.h>
62#include <unistd.h>
63#include <getopt.h>
64
65#include <sys/types.h>
66#include <dirent.h>
67
68#include <acpi/acconfig.h>
69#include <acpi/platform/acenv.h>
70#include <acpi/actypes.h>
71#include <acpi/actbl.h>
72
73static inline u8 checksum(u8 * buffer, u32 length)
74{
75 u8 sum = 0, *i = buffer;
76 buffer += length;
77 for (; i < buffer; sum += *(i++));
78 return sum;
79}
80
81static unsigned long psz, addr, length;
82static int print, connect, skip;
83static u8 select_sig[4];
84
85static unsigned long read_efi_systab( void )
86{
87 char buffer[80];
88 unsigned long addr;
89 FILE *f = fopen("/sys/firmware/efi/systab", "r");
90 if (f) {
91 while (fgets(buffer, 80, f)) {
92 if (sscanf(buffer, "ACPI20=0x%lx", &addr) == 1)
93 return addr;
94 }
95 fclose(f);
96 }
97 return 0;
98}
99
100static u8 *acpi_map_memory(unsigned long where, unsigned length)
101{
102 unsigned long offset;
103 u8 *there;
104 int fd = open("/dev/mem", O_RDONLY);
105 if (fd < 0) {
106 fprintf(stderr, "acpi_os_map_memory: cannot open /dev/mem\n");
107 exit(1);
108 }
109 offset = where % psz;
110 there = mmap(NULL, length + offset, PROT_READ, MAP_PRIVATE,
111 fd, where - offset);
112 close(fd);
113 if (there == MAP_FAILED) return 0;
114 return (there + offset);
115}
116
117static void acpi_unmap_memory(u8 * there, unsigned length)
118{
119 unsigned long offset = (unsigned long)there % psz;
120 munmap(there - offset, length + offset);
121}
122
123static struct acpi_table_header *acpi_map_table(unsigned long where, char *sig)
124{
125 unsigned size;
126 struct acpi_table_header *tbl = (struct acpi_table_header *)
127 acpi_map_memory(where, sizeof(struct acpi_table_header));
128 if (!tbl || (sig && memcmp(sig, tbl->signature, 4))) return 0;
129 size = tbl->length;
130 acpi_unmap_memory((u8 *) tbl, sizeof(struct acpi_table_header));
131 return (struct acpi_table_header *)acpi_map_memory(where, size);
132}
133
134static void acpi_unmap_table(struct acpi_table_header *tbl)
135{
136 acpi_unmap_memory((u8 *)tbl, tbl->length);
137}
138
139static struct acpi_rsdp_descriptor *acpi_scan_for_rsdp(u8 *begin, u32 length)
140{
141 struct acpi_rsdp_descriptor *rsdp;
142 u8 *i, *end = begin + length;
143 /* Search from given start address for the requested length */
144 for (i = begin; i < end; i += ACPI_RSDP_SCAN_STEP) {
145 /* The signature and checksum must both be correct */
146 if (memcmp((char *)i, "RSD PTR ", 8)) continue;
147 rsdp = (struct acpi_rsdp_descriptor *)i;
148 /* Signature matches, check the appropriate checksum */
149 if (!checksum((u8 *) rsdp, (rsdp->revision < 2) ?
150 ACPI_RSDP_CHECKSUM_LENGTH :
151 ACPI_RSDP_XCHECKSUM_LENGTH))
152 /* Checksum valid, we have found a valid RSDP */
153 return rsdp;
154 }
155 /* Searched entire block, no RSDP was found */
156 return 0;
157}
158
159/*
160 * Output data
161 */
162static void acpi_show_data(int fd, u8 * data, int size)
163{
164 char buffer[256];
165 int len;
166 int i, remain = size;
167 while (remain > 0) {
168 len = snprintf(buffer, 256, " %04x:", size - remain);
169 for (i = 0; i < 16 && i < remain; i++) {
170 len +=
171 snprintf(&buffer[len], 256 - len, " %02x", data[i]);
172 }
173 for (; i < 16; i++) {
174 len += snprintf(&buffer[len], 256 - len, " ");
175 }
176 len += snprintf(&buffer[len], 256 - len, " ");
177 for (i = 0; i < 16 && i < remain; i++) {
178 buffer[len++] = (isprint(data[i])) ? data[i] : '.';
179 }
180 buffer[len++] = '\n';
181 write(fd, buffer, len);
182 data += 16;
183 remain -= 16;
184 }
185}
186
187/*
188 * Output ACPI table
189 */
190static void acpi_show_table(int fd, struct acpi_table_header *table, unsigned long addr)
191{
192 char buff[80];
193 int len = snprintf(buff, 80, "%.4s @ %p\n", table->signature, (void *)addr);
194 write(fd, buff, len);
195 acpi_show_data(fd, (u8 *) table, table->length);
196 buff[0] = '\n';
197 write(fd, buff, 1);
198}
199
200static void write_table(int fd, struct acpi_table_header *tbl, unsigned long addr)
201{
202 static int select_done = 0;
203 if (!select_sig[0]) {
204 if (print) {
205 acpi_show_table(fd, tbl, addr);
206 } else {
207 write(fd, tbl, tbl->length);
208 }
209 } else if (!select_done && !memcmp(select_sig, tbl->signature, 4)) {
210 if (skip > 0) {
211 --skip;
212 return;
213 }
214 if (print) {
215 acpi_show_table(fd, tbl, addr);
216 } else {
217 write(fd, tbl, tbl->length);
218 }
219 select_done = 1;
220 }
221}
222
223static void acpi_dump_FADT(int fd, struct acpi_table_header *tbl, unsigned long xaddr) {
224 struct acpi_fadt_descriptor x;
225 unsigned long addr;
226 size_t len = sizeof(struct acpi_fadt_descriptor);
227 if (len > tbl->length) len = tbl->length;
228 memcpy(&x, tbl, len);
229 x.header.length = len;
230 if (checksum((u8 *)tbl, len)) {
231 fprintf(stderr, "Wrong checksum for FADT!\n");
232 }
233 if (x.header.length >= 148 && x.Xdsdt) {
234 addr = (unsigned long)x.Xdsdt;
235 if (connect) {
236 x.Xdsdt = lseek(fd, 0, SEEK_CUR);
237 }
238 } else if (x.header.length >= 44 && x.dsdt) {
239 addr = (unsigned long)x.dsdt;
240 if (connect) {
241 x.dsdt = lseek(fd, 0, SEEK_CUR);
242 }
243 } else {
244 fprintf(stderr, "No DSDT in FADT!\n");
245 goto no_dsdt;
246 }
247 tbl = acpi_map_table(addr, DSDT_SIG);
248 if (!tbl) goto no_dsdt;
249 if (checksum((u8 *)tbl, tbl->length))
250 fprintf(stderr, "Wrong checksum for DSDT!\n");
251 write_table(fd, tbl, addr);
252 acpi_unmap_table(tbl);
253no_dsdt:
254 if (x.header.length >= 140 && x.xfirmware_ctrl) {
255 addr = (unsigned long)x.xfirmware_ctrl;
256 if (connect) {
257 x.xfirmware_ctrl = lseek(fd, 0, SEEK_CUR);
258 }
259 } else if (x.header.length >= 40 && x.firmware_ctrl) {
260 addr = (unsigned long)x.firmware_ctrl;
261 if (connect) {
262 x.firmware_ctrl = lseek(fd, 0, SEEK_CUR);
263 }
264 } else {
265 fprintf(stderr, "No FACS in FADT!\n");
266 goto no_facs;
267 }
268 tbl = acpi_map_table(addr, FACS_SIG);
269 if (!tbl) goto no_facs;
270 /* do not checksum FACS */
271 write_table(fd, tbl, addr);
272 acpi_unmap_table(tbl);
273no_facs:
274 write_table(fd, (struct acpi_table_header *)&x, xaddr);
275}
276
277static int acpi_dump_SDT(int fd, struct acpi_rsdp_descriptor *rsdp)
278{
279 struct acpi_table_header *sdt, *tbl = 0;
280 int xsdt = 1, i, num;
281 char *offset;
282 unsigned long addr;
283 if (rsdp->revision > 1 && rsdp->xsdt_physical_address) {
284 tbl = acpi_map_table(rsdp->xsdt_physical_address, "XSDT");
285 }
286 if (!tbl && rsdp->rsdt_physical_address) {
287 xsdt = 0;
288 tbl = acpi_map_table(rsdp->rsdt_physical_address, "RSDT");
289 }
290 if (!tbl) return 0;
291 sdt = malloc(tbl->length);
292 memcpy(sdt, tbl, tbl->length);
293 acpi_unmap_table(tbl);
294 if (checksum((u8 *)sdt, sdt->length))
295 fprintf(stderr, "Wrong checksum for %s!\n", (xsdt)?"XSDT":"RSDT");
296 num = (sdt->length - sizeof(struct acpi_table_header))/((xsdt)?sizeof(u64):sizeof(u32));
297 offset = (char *)sdt + sizeof(struct acpi_table_header);
298 for (i = 0; i < num; ++i, offset += ((xsdt) ? sizeof(u64) : sizeof(u32))) {
299 addr = (xsdt) ? (unsigned long)(*(u64 *)offset):
300 (unsigned long)(*(u32 *)offset);
301 if (!addr) continue;
302 tbl = acpi_map_table(addr, 0);
303 if (!tbl) continue;
304 if (!memcmp(tbl->signature, FADT_SIG, 4)) {
305 acpi_dump_FADT(fd, tbl, addr);
306 } else {
307 if (checksum((u8 *)tbl, tbl->length))
308 fprintf(stderr, "Wrong checksum for generic table!\n");
309 write_table(fd, tbl, addr);
310 }
311 acpi_unmap_table(tbl);
312 if (connect) {
313 if (xsdt)
314 (*(u64*)offset) = lseek(fd, 0, SEEK_CUR);
315 else
316 (*(u32*)offset) = lseek(fd, 0, SEEK_CUR);
317 }
318 }
319 if (xsdt) {
320 addr = (unsigned long)rsdp->xsdt_physical_address;
321 if (connect) {
322 rsdp->xsdt_physical_address = lseek(fd, 0, SEEK_CUR);
323 }
324 } else {
325 addr = (unsigned long)rsdp->rsdt_physical_address;
326 if (connect) {
327 rsdp->rsdt_physical_address = lseek(fd, 0, SEEK_CUR);
328 }
329 }
330 write_table(fd, sdt, addr);
331 free (sdt);
332 return 1;
333}
334
335#define DYNAMIC_SSDT "/sys/firmware/acpi/tables/dynamic"
336
337static void acpi_dump_dynamic_SSDT(int fd)
338{
339 struct stat file_stat;
340 char filename[256], *ptr;
341 DIR *tabledir;
342 struct dirent *entry;
343 FILE *fp;
344 int count, readcount, length;
345 struct acpi_table_header table_header, *ptable;
346
347 if (stat(DYNAMIC_SSDT, &file_stat) == -1) {
348 /* The directory doesn't exist */
349 return;
350 }
351 tabledir = opendir(DYNAMIC_SSDT);
352 if(!tabledir){
353 /*can't open the directory */
354 return;
355 }
356
357 while ((entry = readdir(tabledir)) != 0){
358 /* skip the file of . /.. */
359 if (entry->d_name[0] == '.')
360 continue;
361
362 sprintf(filename, "%s/%s", DYNAMIC_SSDT, entry->d_name);
363 fp = fopen(filename, "r");
364 if (fp == NULL) {
365 fprintf(stderr, "Can't open the file of %s\n",
366 filename);
367 continue;
368 }
369 /* Read the Table header to parse the table length */
370 count = fread(&table_header, 1, sizeof(struct acpi_table_header), fp);
371 if (count < sizeof(table_header)) {
372 /* the length is lessn than ACPI table header. skip it */
373 fclose(fp);
374 continue;
375 }
376 length = table_header.length;
377 ptr = malloc(table_header.length);
378 fseek(fp, 0, SEEK_SET);
379 readcount = 0;
380 while(!feof(fp) && readcount < length) {
381 count = fread(ptr + readcount, 1, 256, fp);
382 readcount += count;
383 }
384 fclose(fp);
385 ptable = (struct acpi_table_header *) ptr;
386 if (checksum((u8 *) ptable, ptable->length))
387 fprintf(stderr, "Wrong checksum "
388 "for dynamic SSDT table!\n");
389 write_table(fd, ptable, 0);
390 free(ptr);
391 }
392 closedir(tabledir);
393 return;
394}
395
396static void usage(const char *progname)
397{
398 puts("Usage:");
399 printf("%s [--addr 0x1234][--table DSDT][--output filename]"
400 "[--binary][--length 0x456][--help]\n", progname);
401 puts("\t--addr 0x1234 or -a 0x1234 -- look for tables at this physical address");
402 puts("\t--table DSDT or -t DSDT -- only dump table with DSDT signature");
403 puts("\t--output filename or -o filename -- redirect output from stdin to filename");
404 puts("\t--binary or -b -- dump data in binary form rather than in hex-dump format");
405 puts("\t--length 0x456 or -l 0x456 -- works only with --addr, dump physical memory"
406 "\n\t\tregion without trying to understand it's contents");
407 puts("\t--skip 2 or -s 2 -- skip 2 tables of the given name and output only 3rd one");
408 puts("\t--help or -h -- this help message");
409 exit(0);
410}
411
412static struct option long_options[] = {
413 {"addr", 1, 0, 0},
414 {"table", 1, 0, 0},
415 {"output", 1, 0, 0},
416 {"binary", 0, 0, 0},
417 {"length", 1, 0, 0},
418 {"skip", 1, 0, 0},
419 {"help", 0, 0, 0},
420 {0, 0, 0, 0}
421};
422int main(int argc, char **argv)
423{
424 int option_index, c, fd;
425 u8 *raw;
426 struct acpi_rsdp_descriptor rsdpx, *x = 0;
427 char *filename = 0;
428 char buff[80];
429 memset(select_sig, 0, 4);
430 print = 1;
431 connect = 0;
432 addr = length = 0;
433 skip = 0;
434 while (1) {
435 option_index = 0;
436 c = getopt_long(argc, argv, "a:t:o:bl:s:h",
437 long_options, &option_index);
438 if (c == -1)
439 break;
440
441 switch (c) {
442 case 0:
443 switch (option_index) {
444 case 0:
445 addr = strtoul(optarg, (char **)NULL, 16);
446 break;
447 case 1:
448 memcpy(select_sig, optarg, 4);
449 break;
450 case 2:
451 filename = optarg;
452 break;
453 case 3:
454 print = 0;
455 break;
456 case 4:
457 length = strtoul(optarg, (char **)NULL, 16);
458 break;
459 case 5:
460 skip = strtoul(optarg, (char **)NULL, 10);
461 break;
462 case 6:
463 usage(argv[0]);
464 exit(0);
465 }
466 break;
467 case 'a':
468 addr = strtoul(optarg, (char **)NULL, 16);
469 break;
470 case 't':
471 memcpy(select_sig, optarg, 4);
472 break;
473 case 'o':
474 filename = optarg;
475 break;
476 case 'b':
477 print = 0;
478 break;
479 case 'l':
480 length = strtoul(optarg, (char **)NULL, 16);
481 break;
482 case 's':
483 skip = strtoul(optarg, (char **)NULL, 10);
484 break;
485 case 'h':
486 usage(argv[0]);
487 exit(0);
488 default:
489 printf("Unknown option!\n");
490 usage(argv[0]);
491 exit(0);
492 }
493 }
494
495 fd = STDOUT_FILENO;
496 if (filename) {
497 fd = creat(filename, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
498 if (fd < 0)
499 return fd;
500 }
501
502 if (!select_sig[0] && !print) {
503 connect = 1;
504 }
505
506 psz = sysconf(_SC_PAGESIZE);
507 if (length && addr) {
508 /* We know length and address, it means we just want a memory dump */
509 if (!(raw = acpi_map_memory(addr, length)))
510 goto not_found;
511 write(fd, raw, length);
512 acpi_unmap_memory(raw, length);
513 close(fd);
514 return 0;
515 }
516
517 length = sizeof(struct acpi_rsdp_descriptor);
518 if (!addr) {
519 addr = read_efi_systab();
520 if (!addr) {
521 addr = ACPI_HI_RSDP_WINDOW_BASE;
522 length = ACPI_HI_RSDP_WINDOW_SIZE;
523 }
524 }
525
526 if (!(raw = acpi_map_memory(addr, length)) ||
527 !(x = acpi_scan_for_rsdp(raw, length)))
528 goto not_found;
529
530 /* Find RSDP and print all found tables */
531 memcpy(&rsdpx, x, sizeof(struct acpi_rsdp_descriptor));
532 acpi_unmap_memory(raw, length);
533 if (connect) {
534 lseek(fd, sizeof(struct acpi_rsdp_descriptor), SEEK_SET);
535 }
536 if (!acpi_dump_SDT(fd, &rsdpx))
537 goto not_found;
538 if (connect) {
539 lseek(fd, 0, SEEK_SET);
540 write(fd, x, (rsdpx.revision < 2) ?
541 ACPI_RSDP_CHECKSUM_LENGTH : ACPI_RSDP_XCHECKSUM_LENGTH);
542 } else if (!select_sig[0] || !memcmp("RSD PTR ", select_sig, 4)) {
543 addr += (long)x - (long)raw;
544 length = snprintf(buff, 80, "RSD PTR @ %p\n", (void *)addr);
545 write(fd, buff, length);
546 acpi_show_data(fd, (u8 *) & rsdpx, (rsdpx.revision < 2) ?
547 ACPI_RSDP_CHECKSUM_LENGTH : ACPI_RSDP_XCHECKSUM_LENGTH);
548 buff[0] = '\n';
549 write(fd, buff, 1);
550 }
551 acpi_dump_dynamic_SSDT(fd);
552 close(fd);
553 return 0;
554not_found:
555 close(fd);
556 fprintf(stderr, "ACPI tables were not found. If you know location "
557 "of RSD PTR table (from dmesg, etc), "
558 "supply it with either --addr or -a option\n");
559 return 1;
560}
diff --git a/tools/power/x86/turbostat/turbostat.8 b/tools/power/x86/turbostat/turbostat.8
index 74e44507dfe9..e4d0690cccf9 100644
--- a/tools/power/x86/turbostat/turbostat.8
+++ b/tools/power/x86/turbostat/turbostat.8
@@ -4,15 +4,11 @@ turbostat \- Report processor frequency and idle statistics
4.SH SYNOPSIS 4.SH SYNOPSIS
5.ft B 5.ft B
6.B turbostat 6.B turbostat
7.RB [ "\-s" ] 7.RB [ Options ]
8.RB [ "\-v" ]
9.RB [ "\-M MSR#" ]
10.RB command 8.RB command
11.br 9.br
12.B turbostat 10.B turbostat
13.RB [ "\-s" ] 11.RB [ Options ]
14.RB [ "\-v" ]
15.RB [ "\-M MSR#" ]
16.RB [ "\-i interval_sec" ] 12.RB [ "\-i interval_sec" ]
17.SH DESCRIPTION 13.SH DESCRIPTION
18\fBturbostat \fP reports processor topology, frequency 14\fBturbostat \fP reports processor topology, frequency
@@ -27,16 +23,23 @@ supports an "invariant" TSC, plus the APERF and MPERF MSRs.
27on processors that additionally support C-state residency counters. 23on processors that additionally support C-state residency counters.
28 24
29.SS Options 25.SS Options
30The \fB-s\fP option limits output to a 1-line system summary for each interval. 26The \fB-p\fP option limits output to the 1st thread in 1st core of each package.
31.PP 27.PP
32The \fB-c\fP option limits output to the 1st thread in each core. 28The \fB-P\fP option limits output to the 1st thread in each Package.
33.PP 29.PP
34The \fB-p\fP option limits output to the 1st thread in each package. 30The \fB-S\fP option limits output to a 1-line System Summary for each interval.
35.PP 31.PP
36The \fB-v\fP option increases verbosity. 32The \fB-v\fP option increases verbosity.
37.PP 33.PP
38The \fB-M MSR#\fP option dumps the specified MSR, 34The \fB-s\fP option prints the SMI counter, equivalent to "-c 0x34"
39in addition to the usual frequency and idle statistics. 35.PP
36The \fB-c MSR#\fP option includes the delta of the specified 32-bit MSR counter.
37.PP
38The \fB-C MSR#\fP option includes the delta of the specified 64-bit MSR counter.
39.PP
40The \fB-m MSR#\fP option includes the the specified 32-bit MSR value.
41.PP
42The \fB-M MSR#\fP option includes the the specified 64-bit MSR value.
40.PP 43.PP
41The \fB-i interval_sec\fP option prints statistics every \fiinterval_sec\fP seconds. 44The \fB-i interval_sec\fP option prints statistics every \fiinterval_sec\fP seconds.
42The default is 5 seconds. 45The default is 5 seconds.
@@ -150,6 +153,29 @@ Note that turbostat reports average GHz of 3.63, while
150the arithmetic average of the GHz column above is lower. 153the arithmetic average of the GHz column above is lower.
151This is a weighted average, where the weight is %c0. ie. it is the total number of 154This is a weighted average, where the weight is %c0. ie. it is the total number of
152un-halted cycles elapsed per time divided by the number of CPUs. 155un-halted cycles elapsed per time divided by the number of CPUs.
156.SH SMI COUNTING EXAMPLE
157On Intel Nehalem and newer processors, MSR 0x34 is a System Management Mode Interrupt (SMI) counter.
158Using the -m option, you can display how many SMIs have fired since reset, or if there
159are SMIs during the measurement interval, you can display the delta using the -d option.
160.nf
161[root@x980 ~]# turbostat -m 0x34
162cor CPU %c0 GHz TSC MSR 0x034 %c1 %c3 %c6 %pc3 %pc6
163 1.41 1.82 3.38 0x00000000 8.92 37.82 51.85 17.37 0.55
164 0 0 3.73 2.03 3.38 0x00000055 1.72 48.25 46.31 17.38 0.55
165 0 6 0.14 1.63 3.38 0x00000056 5.30
166 1 2 2.51 1.80 3.38 0x00000056 15.65 29.33 52.52
167 1 8 0.10 1.65 3.38 0x00000056 18.05
168 2 4 1.16 1.68 3.38 0x00000056 5.87 24.47 68.50
169 2 10 0.10 1.63 3.38 0x00000056 6.93
170 8 1 3.84 1.91 3.38 0x00000056 1.36 50.65 44.16
171 8 7 0.08 1.64 3.38 0x00000056 5.12
172 9 3 1.82 1.73 3.38 0x00000056 7.59 24.21 66.38
173 9 9 0.09 1.68 3.38 0x00000056 9.32
174 10 5 1.66 1.65 3.38 0x00000056 15.10 50.00 33.23
175 10 11 1.72 1.65 3.38 0x00000056 15.05
176^C
177[root@x980 ~]#
178.fi
153.SH NOTES 179.SH NOTES
154 180
155.B "turbostat " 181.B "turbostat "
@@ -165,6 +191,13 @@ may work poorly on Linux-2.6.20 through 2.6.29,
165as \fBacpi-cpufreq \fPperiodically cleared the APERF and MPERF 191as \fBacpi-cpufreq \fPperiodically cleared the APERF and MPERF
166in those kernels. 192in those kernels.
167 193
194If the TSC column does not make sense, then
195the other numbers will also make no sense.
196Turbostat is lightweight, and its data collection is not atomic.
197These issues are usually caused by an extremely short measurement
198interval (much less than 1 second), or system activity that prevents
199turbostat from being able to run on all CPUS to quickly collect data.
200
168The APERF, MPERF MSRs are defined to count non-halted cycles. 201The APERF, MPERF MSRs are defined to count non-halted cycles.
169Although it is not guaranteed by the architecture, turbostat assumes 202Although it is not guaranteed by the architecture, turbostat assumes
170that they count at TSC rate, which is true on all processors tested to date. 203that they count at TSC rate, which is true on all processors tested to date.
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 861d77190206..2655ae9a3ad8 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -35,9 +35,9 @@
35#include <ctype.h> 35#include <ctype.h>
36#include <sched.h> 36#include <sched.h>
37 37
38#define MSR_TSC 0x10
39#define MSR_NEHALEM_PLATFORM_INFO 0xCE 38#define MSR_NEHALEM_PLATFORM_INFO 0xCE
40#define MSR_NEHALEM_TURBO_RATIO_LIMIT 0x1AD 39#define MSR_NEHALEM_TURBO_RATIO_LIMIT 0x1AD
40#define MSR_IVT_TURBO_RATIO_LIMIT 0x1AE
41#define MSR_APERF 0xE8 41#define MSR_APERF 0xE8
42#define MSR_MPERF 0xE7 42#define MSR_MPERF 0xE7
43#define MSR_PKG_C2_RESIDENCY 0x60D /* SNB only */ 43#define MSR_PKG_C2_RESIDENCY 0x60D /* SNB only */
@@ -62,7 +62,11 @@ unsigned int genuine_intel;
62unsigned int has_invariant_tsc; 62unsigned int has_invariant_tsc;
63unsigned int do_nehalem_platform_info; 63unsigned int do_nehalem_platform_info;
64unsigned int do_nehalem_turbo_ratio_limit; 64unsigned int do_nehalem_turbo_ratio_limit;
65unsigned int extra_msr_offset; 65unsigned int do_ivt_turbo_ratio_limit;
66unsigned int extra_msr_offset32;
67unsigned int extra_msr_offset64;
68unsigned int extra_delta_offset32;
69unsigned int extra_delta_offset64;
66double bclk; 70double bclk;
67unsigned int show_pkg; 71unsigned int show_pkg;
68unsigned int show_core; 72unsigned int show_core;
@@ -83,7 +87,10 @@ struct thread_data {
83 unsigned long long aperf; 87 unsigned long long aperf;
84 unsigned long long mperf; 88 unsigned long long mperf;
85 unsigned long long c1; /* derived */ 89 unsigned long long c1; /* derived */
86 unsigned long long extra_msr; 90 unsigned long long extra_msr64;
91 unsigned long long extra_delta64;
92 unsigned long long extra_msr32;
93 unsigned long long extra_delta32;
87 unsigned int cpu_id; 94 unsigned int cpu_id;
88 unsigned int flags; 95 unsigned int flags;
89#define CPU_IS_FIRST_THREAD_IN_CORE 0x2 96#define CPU_IS_FIRST_THREAD_IN_CORE 0x2
@@ -222,6 +229,14 @@ void print_header(void)
222 if (has_aperf) 229 if (has_aperf)
223 outp += sprintf(outp, " GHz"); 230 outp += sprintf(outp, " GHz");
224 outp += sprintf(outp, " TSC"); 231 outp += sprintf(outp, " TSC");
232 if (extra_delta_offset32)
233 outp += sprintf(outp, " count 0x%03X", extra_delta_offset32);
234 if (extra_delta_offset64)
235 outp += sprintf(outp, " COUNT 0x%03X", extra_delta_offset64);
236 if (extra_msr_offset32)
237 outp += sprintf(outp, " MSR 0x%03X", extra_msr_offset32);
238 if (extra_msr_offset64)
239 outp += sprintf(outp, " MSR 0x%03X", extra_msr_offset64);
225 if (do_nhm_cstates) 240 if (do_nhm_cstates)
226 outp += sprintf(outp, " %%c1"); 241 outp += sprintf(outp, " %%c1");
227 if (do_nhm_cstates) 242 if (do_nhm_cstates)
@@ -238,8 +253,6 @@ void print_header(void)
238 outp += sprintf(outp, " %%pc6"); 253 outp += sprintf(outp, " %%pc6");
239 if (do_snb_cstates) 254 if (do_snb_cstates)
240 outp += sprintf(outp, " %%pc7"); 255 outp += sprintf(outp, " %%pc7");
241 if (extra_msr_offset)
242 outp += sprintf(outp, " MSR 0x%x ", extra_msr_offset);
243 256
244 outp += sprintf(outp, "\n"); 257 outp += sprintf(outp, "\n");
245} 258}
@@ -255,8 +268,14 @@ int dump_counters(struct thread_data *t, struct core_data *c,
255 fprintf(stderr, "aperf: %016llX\n", t->aperf); 268 fprintf(stderr, "aperf: %016llX\n", t->aperf);
256 fprintf(stderr, "mperf: %016llX\n", t->mperf); 269 fprintf(stderr, "mperf: %016llX\n", t->mperf);
257 fprintf(stderr, "c1: %016llX\n", t->c1); 270 fprintf(stderr, "c1: %016llX\n", t->c1);
271 fprintf(stderr, "msr0x%x: %08llX\n",
272 extra_delta_offset32, t->extra_delta32);
258 fprintf(stderr, "msr0x%x: %016llX\n", 273 fprintf(stderr, "msr0x%x: %016llX\n",
259 extra_msr_offset, t->extra_msr); 274 extra_delta_offset64, t->extra_delta64);
275 fprintf(stderr, "msr0x%x: %08llX\n",
276 extra_msr_offset32, t->extra_msr32);
277 fprintf(stderr, "msr0x%x: %016llX\n",
278 extra_msr_offset64, t->extra_msr64);
260 } 279 }
261 280
262 if (c) { 281 if (c) {
@@ -360,6 +379,21 @@ int format_counters(struct thread_data *t, struct core_data *c,
360 /* TSC */ 379 /* TSC */
361 outp += sprintf(outp, "%5.2f", 1.0 * t->tsc/units/interval_float); 380 outp += sprintf(outp, "%5.2f", 1.0 * t->tsc/units/interval_float);
362 381
382 /* delta */
383 if (extra_delta_offset32)
384 outp += sprintf(outp, " %11llu", t->extra_delta32);
385
386 /* DELTA */
387 if (extra_delta_offset64)
388 outp += sprintf(outp, " %11llu", t->extra_delta64);
389 /* msr */
390 if (extra_msr_offset32)
391 outp += sprintf(outp, " 0x%08llx", t->extra_msr32);
392
393 /* MSR */
394 if (extra_msr_offset64)
395 outp += sprintf(outp, " 0x%016llx", t->extra_msr64);
396
363 if (do_nhm_cstates) { 397 if (do_nhm_cstates) {
364 if (!skip_c1) 398 if (!skip_c1)
365 outp += sprintf(outp, " %6.2f", 100.0 * t->c1/t->tsc); 399 outp += sprintf(outp, " %6.2f", 100.0 * t->c1/t->tsc);
@@ -391,8 +425,6 @@ int format_counters(struct thread_data *t, struct core_data *c,
391 if (do_snb_cstates) 425 if (do_snb_cstates)
392 outp += sprintf(outp, " %6.2f", 100.0 * p->pc7/t->tsc); 426 outp += sprintf(outp, " %6.2f", 100.0 * p->pc7/t->tsc);
393done: 427done:
394 if (extra_msr_offset)
395 outp += sprintf(outp, " 0x%016llx", t->extra_msr);
396 outp += sprintf(outp, "\n"); 428 outp += sprintf(outp, "\n");
397 429
398 return 0; 430 return 0;
@@ -502,10 +534,16 @@ delta_thread(struct thread_data *new, struct thread_data *old,
502 old->mperf = 1; /* divide by 0 protection */ 534 old->mperf = 1; /* divide by 0 protection */
503 } 535 }
504 536
537 old->extra_delta32 = new->extra_delta32 - old->extra_delta32;
538 old->extra_delta32 &= 0xFFFFFFFF;
539
540 old->extra_delta64 = new->extra_delta64 - old->extra_delta64;
541
505 /* 542 /*
506 * for "extra msr", just copy the latest w/o subtracting 543 * Extra MSR is just a snapshot, simply copy latest w/o subtracting
507 */ 544 */
508 old->extra_msr = new->extra_msr; 545 old->extra_msr32 = new->extra_msr32;
546 old->extra_msr64 = new->extra_msr64;
509} 547}
510 548
511int delta_cpu(struct thread_data *t, struct core_data *c, 549int delta_cpu(struct thread_data *t, struct core_data *c,
@@ -533,6 +571,9 @@ void clear_counters(struct thread_data *t, struct core_data *c, struct pkg_data
533 t->mperf = 0; 571 t->mperf = 0;
534 t->c1 = 0; 572 t->c1 = 0;
535 573
574 t->extra_delta32 = 0;
575 t->extra_delta64 = 0;
576
536 /* tells format_counters to dump all fields from this set */ 577 /* tells format_counters to dump all fields from this set */
537 t->flags = CPU_IS_FIRST_THREAD_IN_CORE | CPU_IS_FIRST_CORE_IN_PACKAGE; 578 t->flags = CPU_IS_FIRST_THREAD_IN_CORE | CPU_IS_FIRST_CORE_IN_PACKAGE;
538 579
@@ -553,6 +594,9 @@ int sum_counters(struct thread_data *t, struct core_data *c,
553 average.threads.mperf += t->mperf; 594 average.threads.mperf += t->mperf;
554 average.threads.c1 += t->c1; 595 average.threads.c1 += t->c1;
555 596
597 average.threads.extra_delta32 += t->extra_delta32;
598 average.threads.extra_delta64 += t->extra_delta64;
599
556 /* sum per-core values only for 1st thread in core */ 600 /* sum per-core values only for 1st thread in core */
557 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) 601 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE))
558 return 0; 602 return 0;
@@ -588,6 +632,11 @@ void compute_average(struct thread_data *t, struct core_data *c,
588 average.threads.mperf /= topo.num_cpus; 632 average.threads.mperf /= topo.num_cpus;
589 average.threads.c1 /= topo.num_cpus; 633 average.threads.c1 /= topo.num_cpus;
590 634
635 average.threads.extra_delta32 /= topo.num_cpus;
636 average.threads.extra_delta32 &= 0xFFFFFFFF;
637
638 average.threads.extra_delta64 /= topo.num_cpus;
639
591 average.cores.c3 /= topo.num_cores; 640 average.cores.c3 /= topo.num_cores;
592 average.cores.c6 /= topo.num_cores; 641 average.cores.c6 /= topo.num_cores;
593 average.cores.c7 /= topo.num_cores; 642 average.cores.c7 /= topo.num_cores;
@@ -629,8 +678,24 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
629 return -4; 678 return -4;
630 } 679 }
631 680
632 if (extra_msr_offset) 681 if (extra_delta_offset32) {
633 if (get_msr(cpu, extra_msr_offset, &t->extra_msr)) 682 if (get_msr(cpu, extra_delta_offset32, &t->extra_delta32))
683 return -5;
684 t->extra_delta32 &= 0xFFFFFFFF;
685 }
686
687 if (extra_delta_offset64)
688 if (get_msr(cpu, extra_delta_offset64, &t->extra_delta64))
689 return -5;
690
691 if (extra_msr_offset32) {
692 if (get_msr(cpu, extra_msr_offset32, &t->extra_msr32))
693 return -5;
694 t->extra_msr32 &= 0xFFFFFFFF;
695 }
696
697 if (extra_msr_offset64)
698 if (get_msr(cpu, extra_msr_offset64, &t->extra_msr64))
634 return -5; 699 return -5;
635 700
636 /* collect core counters only for 1st thread in core */ 701 /* collect core counters only for 1st thread in core */
@@ -677,6 +742,9 @@ void print_verbose_header(void)
677 742
678 get_msr(0, MSR_NEHALEM_PLATFORM_INFO, &msr); 743 get_msr(0, MSR_NEHALEM_PLATFORM_INFO, &msr);
679 744
745 if (verbose > 1)
746 fprintf(stderr, "MSR_NEHALEM_PLATFORM_INFO: 0x%llx\n", msr);
747
680 ratio = (msr >> 40) & 0xFF; 748 ratio = (msr >> 40) & 0xFF;
681 fprintf(stderr, "%d * %.0f = %.0f MHz max efficiency\n", 749 fprintf(stderr, "%d * %.0f = %.0f MHz max efficiency\n",
682 ratio, bclk, ratio * bclk); 750 ratio, bclk, ratio * bclk);
@@ -685,14 +753,84 @@ void print_verbose_header(void)
685 fprintf(stderr, "%d * %.0f = %.0f MHz TSC frequency\n", 753 fprintf(stderr, "%d * %.0f = %.0f MHz TSC frequency\n",
686 ratio, bclk, ratio * bclk); 754 ratio, bclk, ratio * bclk);
687 755
756 if (!do_ivt_turbo_ratio_limit)
757 goto print_nhm_turbo_ratio_limits;
758
759 get_msr(0, MSR_IVT_TURBO_RATIO_LIMIT, &msr);
760
688 if (verbose > 1) 761 if (verbose > 1)
689 fprintf(stderr, "MSR_NEHALEM_PLATFORM_INFO: 0x%llx\n", msr); 762 fprintf(stderr, "MSR_IVT_TURBO_RATIO_LIMIT: 0x%llx\n", msr);
763
764 ratio = (msr >> 56) & 0xFF;
765 if (ratio)
766 fprintf(stderr, "%d * %.0f = %.0f MHz max turbo 16 active cores\n",
767 ratio, bclk, ratio * bclk);
768
769 ratio = (msr >> 48) & 0xFF;
770 if (ratio)
771 fprintf(stderr, "%d * %.0f = %.0f MHz max turbo 15 active cores\n",
772 ratio, bclk, ratio * bclk);
773
774 ratio = (msr >> 40) & 0xFF;
775 if (ratio)
776 fprintf(stderr, "%d * %.0f = %.0f MHz max turbo 14 active cores\n",
777 ratio, bclk, ratio * bclk);
778
779 ratio = (msr >> 32) & 0xFF;
780 if (ratio)
781 fprintf(stderr, "%d * %.0f = %.0f MHz max turbo 13 active cores\n",
782 ratio, bclk, ratio * bclk);
783
784 ratio = (msr >> 24) & 0xFF;
785 if (ratio)
786 fprintf(stderr, "%d * %.0f = %.0f MHz max turbo 12 active cores\n",
787 ratio, bclk, ratio * bclk);
788
789 ratio = (msr >> 16) & 0xFF;
790 if (ratio)
791 fprintf(stderr, "%d * %.0f = %.0f MHz max turbo 11 active cores\n",
792 ratio, bclk, ratio * bclk);
793
794 ratio = (msr >> 8) & 0xFF;
795 if (ratio)
796 fprintf(stderr, "%d * %.0f = %.0f MHz max turbo 10 active cores\n",
797 ratio, bclk, ratio * bclk);
798
799 ratio = (msr >> 0) & 0xFF;
800 if (ratio)
801 fprintf(stderr, "%d * %.0f = %.0f MHz max turbo 9 active cores\n",
802 ratio, bclk, ratio * bclk);
803
804print_nhm_turbo_ratio_limits:
690 805
691 if (!do_nehalem_turbo_ratio_limit) 806 if (!do_nehalem_turbo_ratio_limit)
692 return; 807 return;
693 808
694 get_msr(0, MSR_NEHALEM_TURBO_RATIO_LIMIT, &msr); 809 get_msr(0, MSR_NEHALEM_TURBO_RATIO_LIMIT, &msr);
695 810
811 if (verbose > 1)
812 fprintf(stderr, "MSR_NEHALEM_TURBO_RATIO_LIMIT: 0x%llx\n", msr);
813
814 ratio = (msr >> 56) & 0xFF;
815 if (ratio)
816 fprintf(stderr, "%d * %.0f = %.0f MHz max turbo 8 active cores\n",
817 ratio, bclk, ratio * bclk);
818
819 ratio = (msr >> 48) & 0xFF;
820 if (ratio)
821 fprintf(stderr, "%d * %.0f = %.0f MHz max turbo 7 active cores\n",
822 ratio, bclk, ratio * bclk);
823
824 ratio = (msr >> 40) & 0xFF;
825 if (ratio)
826 fprintf(stderr, "%d * %.0f = %.0f MHz max turbo 6 active cores\n",
827 ratio, bclk, ratio * bclk);
828
829 ratio = (msr >> 32) & 0xFF;
830 if (ratio)
831 fprintf(stderr, "%d * %.0f = %.0f MHz max turbo 5 active cores\n",
832 ratio, bclk, ratio * bclk);
833
696 ratio = (msr >> 24) & 0xFF; 834 ratio = (msr >> 24) & 0xFF;
697 if (ratio) 835 if (ratio)
698 fprintf(stderr, "%d * %.0f = %.0f MHz max turbo 4 active cores\n", 836 fprintf(stderr, "%d * %.0f = %.0f MHz max turbo 4 active cores\n",
@@ -712,7 +850,6 @@ void print_verbose_header(void)
712 if (ratio) 850 if (ratio)
713 fprintf(stderr, "%d * %.0f = %.0f MHz max turbo 1 active cores\n", 851 fprintf(stderr, "%d * %.0f = %.0f MHz max turbo 1 active cores\n",
714 ratio, bclk, ratio * bclk); 852 ratio, bclk, ratio * bclk);
715
716} 853}
717 854
718void free_all_buffers(void) 855void free_all_buffers(void)
@@ -1038,7 +1175,7 @@ int has_nehalem_turbo_ratio_limit(unsigned int family, unsigned int model)
1038 case 0x2A: /* SNB */ 1175 case 0x2A: /* SNB */
1039 case 0x2D: /* SNB Xeon */ 1176 case 0x2D: /* SNB Xeon */
1040 case 0x3A: /* IVB */ 1177 case 0x3A: /* IVB */
1041 case 0x3D: /* IVB Xeon */ 1178 case 0x3E: /* IVB Xeon */
1042 return 1; 1179 return 1;
1043 case 0x2E: /* Nehalem-EX Xeon - Beckton */ 1180 case 0x2E: /* Nehalem-EX Xeon - Beckton */
1044 case 0x2F: /* Westmere-EX Xeon - Eagleton */ 1181 case 0x2F: /* Westmere-EX Xeon - Eagleton */
@@ -1046,6 +1183,22 @@ int has_nehalem_turbo_ratio_limit(unsigned int family, unsigned int model)
1046 return 0; 1183 return 0;
1047 } 1184 }
1048} 1185}
1186int has_ivt_turbo_ratio_limit(unsigned int family, unsigned int model)
1187{
1188 if (!genuine_intel)
1189 return 0;
1190
1191 if (family != 6)
1192 return 0;
1193
1194 switch (model) {
1195 case 0x3E: /* IVB Xeon */
1196 return 1;
1197 default:
1198 return 0;
1199 }
1200}
1201
1049 1202
1050int is_snb(unsigned int family, unsigned int model) 1203int is_snb(unsigned int family, unsigned int model)
1051{ 1204{
@@ -1056,7 +1209,7 @@ int is_snb(unsigned int family, unsigned int model)
1056 case 0x2A: 1209 case 0x2A:
1057 case 0x2D: 1210 case 0x2D:
1058 case 0x3A: /* IVB */ 1211 case 0x3A: /* IVB */
1059 case 0x3D: /* IVB Xeon */ 1212 case 0x3E: /* IVB Xeon */
1060 return 1; 1213 return 1;
1061 } 1214 }
1062 return 0; 1215 return 0;
@@ -1145,12 +1298,13 @@ void check_cpuid()
1145 bclk = discover_bclk(family, model); 1298 bclk = discover_bclk(family, model);
1146 1299
1147 do_nehalem_turbo_ratio_limit = has_nehalem_turbo_ratio_limit(family, model); 1300 do_nehalem_turbo_ratio_limit = has_nehalem_turbo_ratio_limit(family, model);
1301 do_ivt_turbo_ratio_limit = has_ivt_turbo_ratio_limit(family, model);
1148} 1302}
1149 1303
1150 1304
1151void usage() 1305void usage()
1152{ 1306{
1153 fprintf(stderr, "%s: [-v] [-M MSR#] [-i interval_sec | command ...]\n", 1307 fprintf(stderr, "%s: [-v][-p|-P|-S][-c MSR# | -s]][-C MSR#][-m MSR#][-M MSR#][-i interval_sec | command ...]\n",
1154 progname); 1308 progname);
1155 exit(1); 1309 exit(1);
1156} 1310}
@@ -1440,15 +1594,15 @@ void cmdline(int argc, char **argv)
1440 1594
1441 progname = argv[0]; 1595 progname = argv[0];
1442 1596
1443 while ((opt = getopt(argc, argv, "+cpsvi:M:")) != -1) { 1597 while ((opt = getopt(argc, argv, "+pPSvisc:sC:m:M:")) != -1) {
1444 switch (opt) { 1598 switch (opt) {
1445 case 'c': 1599 case 'p':
1446 show_core_only++; 1600 show_core_only++;
1447 break; 1601 break;
1448 case 'p': 1602 case 'P':
1449 show_pkg_only++; 1603 show_pkg_only++;
1450 break; 1604 break;
1451 case 's': 1605 case 'S':
1452 summary_only++; 1606 summary_only++;
1453 break; 1607 break;
1454 case 'v': 1608 case 'v':
@@ -1457,10 +1611,20 @@ void cmdline(int argc, char **argv)
1457 case 'i': 1611 case 'i':
1458 interval_sec = atoi(optarg); 1612 interval_sec = atoi(optarg);
1459 break; 1613 break;
1614 case 'c':
1615 sscanf(optarg, "%x", &extra_delta_offset32);
1616 break;
1617 case 's':
1618 extra_delta_offset32 = 0x34; /* SMI counter */
1619 break;
1620 case 'C':
1621 sscanf(optarg, "%x", &extra_delta_offset64);
1622 break;
1623 case 'm':
1624 sscanf(optarg, "%x", &extra_msr_offset32);
1625 break;
1460 case 'M': 1626 case 'M':
1461 sscanf(optarg, "%x", &extra_msr_offset); 1627 sscanf(optarg, "%x", &extra_msr_offset64);
1462 if (verbose > 1)
1463 fprintf(stderr, "MSR 0x%X\n", extra_msr_offset);
1464 break; 1628 break;
1465 default: 1629 default:
1466 usage(); 1630 usage();
@@ -1473,7 +1637,7 @@ int main(int argc, char **argv)
1473 cmdline(argc, argv); 1637 cmdline(argc, argv);
1474 1638
1475 if (verbose > 1) 1639 if (verbose > 1)
1476 fprintf(stderr, "turbostat v2.0 May 16, 2012" 1640 fprintf(stderr, "turbostat v2.1 October 6, 2012"
1477 " - Len Brown <lenb@kernel.org>\n"); 1641 " - Len Brown <lenb@kernel.org>\n");
1478 1642
1479 turbostat_init(); 1643 turbostat_init();