aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2011-06-29 13:34:54 -0400
committerKeith Packard <keithp@keithp.com>2011-06-29 13:34:54 -0400
commit8eb2c0ee67f4853c0e433394f65ef8143a748c80 (patch)
treeea74ea0878b2f07eb70f2d5b42be5ec42f3bdb5f
parent3e0dc6b01f5301d63046f6deddde2c7f5c57d67a (diff)
parent0d72c6fcb5cd215eeab824fac216ea42c5b574aa (diff)
Merge branch 'drm-intel-fixes' into drm-intel-next
-rw-r--r--Documentation/power/devices.txt67
-rw-r--r--Documentation/power/runtime_pm.txt5
-rw-r--r--Documentation/usb/error-codes.txt9
-rw-r--r--MAINTAINERS12
-rw-r--r--Makefile2
-rw-r--r--arch/alpha/include/asm/mmzone.h1
-rw-r--r--arch/arm/boot/compressed/head.S14
-rw-r--r--arch/arm/include/asm/assembler.h4
-rw-r--r--arch/arm/include/asm/entry-macro-multi.S2
-rw-r--r--arch/arm/kernel/module.c13
-rw-r--r--arch/arm/kernel/smp.c6
-rw-r--r--arch/arm/mach-exynos4/init.c1
-rw-r--r--arch/arm/mach-h720x/Kconfig2
-rw-r--r--arch/arm/mach-ux500/board-mop500-pins.c16
-rw-r--r--arch/arm/mach-ux500/board-mop500.c54
-rw-r--r--arch/arm/mm/proc-v7.S16
-rw-r--r--arch/arm/plat-iop/cp6.c1
-rw-r--r--arch/arm/plat-samsung/include/plat/regs-serial.h2
-rw-r--r--arch/m32r/include/asm/mmzone.h8
-rw-r--r--arch/mn10300/include/asm/uaccess.h1
-rw-r--r--arch/parisc/include/asm/mmzone.h7
-rw-r--r--arch/powerpc/include/asm/mmzone.h7
-rw-r--r--arch/s390/Kconfig1
-rw-r--r--arch/s390/kernel/smp.c4
-rw-r--r--arch/s390/oprofile/init.c8
-rw-r--r--arch/sh/include/asm/mmzone.h4
-rw-r--r--arch/sparc/include/asm/mmzone.h2
-rw-r--r--arch/tile/include/asm/mmzone.h11
-rw-r--r--arch/um/include/asm/percpu.h6
-rw-r--r--arch/x86/include/asm/mmzone_32.h11
-rw-r--r--arch/x86/include/asm/mmzone_64.h3
-rw-r--r--arch/x86/pci/acpi.c2
-rw-r--r--block/blk-throttle.c4
-rw-r--r--block/cfq-iosched.c16
-rw-r--r--block/genhd.c79
-rw-r--r--drivers/ata/libata-core.c6
-rw-r--r--drivers/ata/libata-scsi.c6
-rw-r--r--drivers/ata/pata_marvell.c3
-rw-r--r--drivers/ata/sata_dwc_460ex.c2
-rw-r--r--drivers/base/platform.c2
-rw-r--r--drivers/base/power/clock_ops.c4
-rw-r--r--drivers/base/power/main.c28
-rw-r--r--drivers/connector/connector.c1
-rw-r--r--drivers/firmware/google/Kconfig1
-rw-r--r--drivers/gpu/drm/drm_gem.c1
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c38
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon.h1
-rw-r--r--drivers/gpu/drm/radeon/radeon_atombios.c36
-rw-r--r--drivers/gpu/drm/ttm/ttm_tt.c5
-rw-r--r--drivers/hid/hid-core.c1
-rw-r--r--drivers/hid/hid-ids.h1
-rw-r--r--drivers/hid/hid-multitouch.c12
-rw-r--r--drivers/infiniband/hw/cxgb4/cm.c46
-rw-r--r--drivers/infiniband/hw/cxgb4/cq.c4
-rw-r--r--drivers/infiniband/hw/cxgb4/mem.c2
-rw-r--r--drivers/infiniband/hw/cxgb4/qp.c5
-rw-r--r--drivers/infiniband/hw/qib/qib_iba7322.c25
-rw-r--r--drivers/infiniband/hw/qib/qib_intr.c6
-rw-r--r--drivers/leds/leds-lp5521.c4
-rw-r--r--drivers/leds/leds-lp5523.c4
-rw-r--r--drivers/md/md.c1
-rw-r--r--drivers/misc/cb710/sgbuf2.c2
-rw-r--r--drivers/misc/ioc4.c2
-rw-r--r--drivers/misc/lkdtm.c8
-rw-r--r--drivers/misc/pti.c11
-rw-r--r--drivers/misc/ti-st/st_core.c2
-rw-r--r--drivers/misc/ti-st/st_kim.c8
-rw-r--r--drivers/mmc/card/block.c5
-rw-r--r--drivers/mmc/card/queue.c15
-rw-r--r--drivers/mmc/card/queue.h3
-rw-r--r--drivers/mmc/core/core.c2
-rw-r--r--drivers/mmc/core/sdio.c39
-rw-r--r--drivers/mmc/core/sdio_bus.c2
-rw-r--r--drivers/mmc/host/of_mmc_spi.c5
-rw-r--r--drivers/mmc/host/omap_hsmmc.c6
-rw-r--r--drivers/mmc/host/sh_mobile_sdhi.c5
-rw-r--r--drivers/mmc/host/tmio_mmc_pio.c4
-rw-r--r--drivers/mmc/host/vub300.c11
-rw-r--r--drivers/pci/pci-driver.c4
-rw-r--r--drivers/pci/pci.c2
-rw-r--r--drivers/pci/probe.c2
-rw-r--r--drivers/pci/quirks.c2
-rw-r--r--drivers/rtc/rtc-ds1307.c1
-rw-r--r--drivers/rtc/rtc-vt8500.c45
-rw-r--r--drivers/staging/brcm80211/Kconfig2
-rw-r--r--drivers/staging/comedi/Kconfig22
-rw-r--r--drivers/staging/iio/Kconfig2
-rw-r--r--drivers/staging/iio/accel/adis16204.h2
-rw-r--r--drivers/staging/iio/accel/adis16209.h4
-rw-r--r--drivers/staging/iio/gyro/adis16260.h2
-rw-r--r--drivers/staging/iio/imu/adis16400.h2
-rw-r--r--drivers/staging/mei/init.c2
-rw-r--r--drivers/staging/mei/wd.c13
-rw-r--r--drivers/target/loopback/tcm_loop.c13
-rw-r--r--drivers/target/target_core_configfs.c24
-rw-r--r--drivers/target/target_core_device.c5
-rw-r--r--drivers/target/target_core_pr.c6
-rw-r--r--drivers/target/target_core_tmr.c8
-rw-r--r--drivers/target/target_core_transport.c6
-rw-r--r--drivers/target/tcm_fc/tcm_fc.h2
-rw-r--r--drivers/target/tcm_fc/tfc_cmd.c64
-rw-r--r--drivers/target/tcm_fc/tfc_io.c2
-rw-r--r--drivers/target/tcm_fc/tfc_sess.c4
-rw-r--r--drivers/tty/n_gsm.c26
-rw-r--r--drivers/tty/n_tty.c1
-rw-r--r--drivers/tty/serial/8250.c1
-rw-r--r--drivers/tty/serial/8250_pci.c61
-rw-r--r--drivers/tty/serial/amba-pl011.c123
-rw-r--r--drivers/tty/serial/bcm63xx_uart.c18
-rw-r--r--drivers/tty/serial/jsm/jsm_driver.c2
-rw-r--r--drivers/tty/serial/mrst_max3110.c5
-rw-r--r--drivers/tty/serial/s5pv210.c4
-rw-r--r--drivers/tty/tty_ldisc.c4
-rw-r--r--drivers/usb/core/driver.c17
-rw-r--r--drivers/usb/core/hub.c16
-rw-r--r--drivers/usb/core/message.c15
-rw-r--r--drivers/usb/host/ehci-ath79.c10
-rw-r--r--drivers/usb/host/ehci-hcd.c4
-rw-r--r--drivers/usb/host/isp1760-hcd.c2
-rw-r--r--drivers/usb/host/ohci-hcd.c4
-rw-r--r--drivers/usb/host/r8a66597-hcd.c1
-rw-r--r--drivers/usb/host/xhci-mem.c2
-rw-r--r--drivers/usb/host/xhci-pci.c8
-rw-r--r--drivers/usb/host/xhci-ring.c30
-rw-r--r--drivers/usb/host/xhci.c39
-rw-r--r--drivers/usb/host/xhci.h3
-rw-r--r--drivers/usb/musb/musb_gadget.c6
-rw-r--r--drivers/usb/musb/musb_host.c2
-rw-r--r--drivers/usb/serial/ftdi_sio.c19
-rw-r--r--drivers/usb/serial/ftdi_sio.h3
-rw-r--r--drivers/usb/serial/ftdi_sio_ids.h1
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c1
-rw-r--r--fs/block_dev.c14
-rw-r--r--fs/btrfs/ctree.h1
-rw-r--r--fs/btrfs/delayed-inode.c104
-rw-r--r--fs/btrfs/delayed-inode.h1
-rw-r--r--fs/btrfs/extent-tree.c4
-rw-r--r--fs/btrfs/free-space-cache.c9
-rw-r--r--fs/btrfs/inode.c13
-rw-r--r--fs/cifs/Kconfig2
-rw-r--r--fs/cifs/cifs_fs_sb.h1
-rw-r--r--fs/cifs/cifsfs.c156
-rw-r--r--fs/cifs/cifsproto.h8
-rw-r--r--fs/cifs/connect.c88
-rw-r--r--fs/cifs/smbencrypt.c6
-rw-r--r--fs/ext4/ext4_extents.h9
-rw-r--r--fs/ext4/extents.c42
-rw-r--r--fs/ext4/inode.c2
-rw-r--r--fs/ext4/mballoc.c8
-rw-r--r--fs/ext4/move_extent.c10
-rw-r--r--fs/ext4/super.c15
-rw-r--r--fs/inode.c7
-rw-r--r--fs/jbd2/checkpoint.c28
-rw-r--r--fs/jbd2/commit.c33
-rw-r--r--fs/jbd2/journal.c91
-rw-r--r--fs/jbd2/transaction.c69
-rw-r--r--fs/jfs/file.c6
-rw-r--r--fs/jfs/jfs_imap.c12
-rw-r--r--fs/jfs/jfs_incore.h3
-rw-r--r--fs/jfs/resize.c2
-rw-r--r--fs/lockd/clntproc.c8
-rw-r--r--fs/nfs/inode.c6
-rw-r--r--fs/nfs/internal.h11
-rw-r--r--fs/nfs/nfs4filelayout.c21
-rw-r--r--fs/nfs/nfs4proc.c45
-rw-r--r--fs/nfs/nfs4xdr.c26
-rw-r--r--fs/nfs/objlayout/objio_osd.c4
-rw-r--r--fs/nfs/objlayout/objlayout.c2
-rw-r--r--fs/nfs/pagelist.c3
-rw-r--r--fs/nfs/pnfs.c44
-rw-r--r--fs/nfs/pnfs.h1
-rw-r--r--fs/nfs/pnfs_dev.c17
-rw-r--r--fs/omfs/file.c1
-rw-r--r--fs/proc/base.c7
-rw-r--r--fs/romfs/mmap-nommu.c8
-rw-r--r--fs/xfs/xfs_attr.c7
-rw-r--r--fs/xfs/xfs_iget.c13
-rw-r--r--fs/xfs/xfs_inode.h10
-rw-r--r--fs/xfs/xfs_vnodeops.c7
-rw-r--r--include/linux/amba/serial.h3
-rw-r--r--include/linux/blk_types.h2
-rw-r--r--include/linux/blktrace_api.h3
-rw-r--r--include/linux/compat.h2
-rw-r--r--include/linux/connector.h2
-rw-r--r--include/linux/device.h5
-rw-r--r--include/linux/fs.h1
-rw-r--r--include/linux/hrtimer.h1
-rw-r--r--include/linux/jbd2.h2
-rw-r--r--include/linux/mmzone.h7
-rw-r--r--include/linux/nfs_page.h3
-rw-r--r--include/linux/nfs_xdr.h1
-rw-r--r--include/linux/pci_ids.h1
-rw-r--r--include/linux/pm.h3
-rw-r--r--include/linux/shmem_fs.h21
-rw-r--r--include/linux/sunrpc/sched.h3
-rw-r--r--include/linux/swap.h10
-rw-r--r--include/net/sock.h1
-rw-r--r--include/sound/soc.h3
-rw-r--r--include/trace/events/ext4.h179
-rw-r--r--init/calibrate.c14
-rw-r--r--kernel/power/user.c4
-rw-r--r--kernel/taskstats.c15
-rw-r--r--kernel/time/alarmtimer.c158
-rw-r--r--mm/memcontrol.c1
-rw-r--r--mm/memory-failure.c21
-rw-r--r--mm/memory.c24
-rw-r--r--mm/memory_hotplug.c4
-rw-r--r--mm/rmap.c5
-rw-r--r--mm/shmem.c74
-rw-r--r--mm/swapfile.c2
-rw-r--r--mm/truncate.c29
-rw-r--r--mm/vmscan.c27
-rw-r--r--net/sunrpc/auth_gss/auth_gss.c4
-rw-r--r--net/sunrpc/clnt.c5
-rw-r--r--net/sunrpc/sched.c1
-rw-r--r--security/keys/request_key.c3
-rw-r--r--sound/pci/asihpi/asihpi.c1
-rw-r--r--sound/pci/hda/patch_realtek.c13
-rw-r--r--sound/pci/hda/patch_via.c35
-rw-r--r--sound/soc/codecs/wm8991.c1
-rw-r--r--sound/soc/imx/Kconfig7
-rw-r--r--sound/soc/imx/imx-pcm-dma-mx2.c2
-rw-r--r--sound/soc/imx/imx-ssi.c2
-rw-r--r--sound/soc/pxa/pxa2xx-pcm.c4
-rw-r--r--sound/soc/soc-cache.c3
226 files changed, 1969 insertions, 1177 deletions
diff --git a/Documentation/power/devices.txt b/Documentation/power/devices.txt
index 88880839ece4..64565aac6e40 100644
--- a/Documentation/power/devices.txt
+++ b/Documentation/power/devices.txt
@@ -520,59 +520,20 @@ Support for power domains is provided through the pwr_domain field of struct
520device. This field is a pointer to an object of type struct dev_power_domain, 520device. This field is a pointer to an object of type struct dev_power_domain,
521defined in include/linux/pm.h, providing a set of power management callbacks 521defined in include/linux/pm.h, providing a set of power management callbacks
522analogous to the subsystem-level and device driver callbacks that are executed 522analogous to the subsystem-level and device driver callbacks that are executed
523for the given device during all power transitions, in addition to the respective 523for the given device during all power transitions, instead of the respective
524subsystem-level callbacks. Specifically, the power domain "suspend" callbacks 524subsystem-level callbacks. Specifically, if a device's pm_domain pointer is
525(i.e. ->runtime_suspend(), ->suspend(), ->freeze(), ->poweroff(), etc.) are 525not NULL, the ->suspend() callback from the object pointed to by it will be
526executed after the analogous subsystem-level callbacks, while the power domain 526executed instead of its subsystem's (e.g. bus type's) ->suspend() callback and
527"resume" callbacks (i.e. ->runtime_resume(), ->resume(), ->thaw(), ->restore, 527anlogously for all of the remaining callbacks. In other words, power management
528etc.) are executed before the analogous subsystem-level callbacks. Error codes 528domain callbacks, if defined for the given device, always take precedence over
529returned by the "suspend" and "resume" power domain callbacks are ignored. 529the callbacks provided by the device's subsystem (e.g. bus type).
530 530
531Power domain ->runtime_idle() callback is executed before the subsystem-level 531The support for device power management domains is only relevant to platforms
532->runtime_idle() callback and the result returned by it is not ignored. Namely, 532needing to use the same device driver power management callbacks in many
533if it returns error code, the subsystem-level ->runtime_idle() callback will not 533different power domain configurations and wanting to avoid incorporating the
534be called and the helper function rpm_idle() executing it will return error 534support for power domains into subsystem-level callbacks, for example by
535code. This mechanism is intended to help platforms where saving device state 535modifying the platform bus type. Other platforms need not implement it or take
536is a time consuming operation and should only be carried out if all devices 536it into account in any way.
537in the power domain are idle, before turning off the shared power resource(s).
538Namely, the power domain ->runtime_idle() callback may return error code until
539the pm_runtime_idle() helper (or its asychronous version) has been called for
540all devices in the power domain (it is recommended that the returned error code
541be -EBUSY in those cases), preventing the subsystem-level ->runtime_idle()
542callback from being run prematurely.
543
544The support for device power domains is only relevant to platforms needing to
545use the same subsystem-level (e.g. platform bus type) and device driver power
546management callbacks in many different power domain configurations and wanting
547to avoid incorporating the support for power domains into the subsystem-level
548callbacks. The other platforms need not implement it or take it into account
549in any way.
550
551
552System Devices
553--------------
554System devices (sysdevs) follow a slightly different API, which can be found in
555
556 include/linux/sysdev.h
557 drivers/base/sys.c
558
559System devices will be suspended with interrupts disabled, and after all other
560devices have been suspended. On resume, they will be resumed before any other
561devices, and also with interrupts disabled. These things occur in special
562"sysdev_driver" phases, which affect only system devices.
563
564Thus, after the suspend_noirq (or freeze_noirq or poweroff_noirq) phase, when
565the non-boot CPUs are all offline and IRQs are disabled on the remaining online
566CPU, then a sysdev_driver.suspend phase is carried out, and the system enters a
567sleep state (or a system image is created). During resume (or after the image
568has been created or loaded) a sysdev_driver.resume phase is carried out, IRQs
569are enabled on the only online CPU, the non-boot CPUs are enabled, and the
570resume_noirq (or thaw_noirq or restore_noirq) phase begins.
571
572Code to actually enter and exit the system-wide low power state sometimes
573involves hardware details that are only known to the boot firmware, and
574may leave a CPU running software (from SRAM or flash memory) that monitors
575the system and manages its wakeup sequence.
576 537
577 538
578Device Low Power (suspend) States 539Device Low Power (suspend) States
diff --git a/Documentation/power/runtime_pm.txt b/Documentation/power/runtime_pm.txt
index 654097b130b4..22accb3eb40e 100644
--- a/Documentation/power/runtime_pm.txt
+++ b/Documentation/power/runtime_pm.txt
@@ -566,11 +566,6 @@ to do this is:
566 pm_runtime_set_active(dev); 566 pm_runtime_set_active(dev);
567 pm_runtime_enable(dev); 567 pm_runtime_enable(dev);
568 568
569The PM core always increments the run-time usage counter before calling the
570->prepare() callback and decrements it after calling the ->complete() callback.
571Hence disabling run-time PM temporarily like this will not cause any run-time
572suspend callbacks to be lost.
573
5747. Generic subsystem callbacks 5697. Generic subsystem callbacks
575 570
576Subsystems may wish to conserve code space by using the set of generic power 571Subsystems may wish to conserve code space by using the set of generic power
diff --git a/Documentation/usb/error-codes.txt b/Documentation/usb/error-codes.txt
index d83703ea74b2..b3f606b81a03 100644
--- a/Documentation/usb/error-codes.txt
+++ b/Documentation/usb/error-codes.txt
@@ -76,6 +76,13 @@ A transfer's actual_length may be positive even when an error has been
76reported. That's because transfers often involve several packets, so that 76reported. That's because transfers often involve several packets, so that
77one or more packets could finish before an error stops further endpoint I/O. 77one or more packets could finish before an error stops further endpoint I/O.
78 78
79For isochronous URBs, the urb status value is non-zero only if the URB is
80unlinked, the device is removed, the host controller is disabled, or the total
81transferred length is less than the requested length and the URB_SHORT_NOT_OK
82flag is set. Completion handlers for isochronous URBs should only see
83urb->status set to zero, -ENOENT, -ECONNRESET, -ESHUTDOWN, or -EREMOTEIO.
84Individual frame descriptor status fields may report more status codes.
85
79 86
800 Transfer completed successfully 870 Transfer completed successfully
81 88
@@ -132,7 +139,7 @@ one or more packets could finish before an error stops further endpoint I/O.
132 device removal events immediately. 139 device removal events immediately.
133 140
134-EXDEV ISO transfer only partially completed 141-EXDEV ISO transfer only partially completed
135 look at individual frame status for details 142 (only set in iso_frame_desc[n].status, not urb->status)
136 143
137-EINVAL ISO madness, if this happens: Log off and go home 144-EINVAL ISO madness, if this happens: Log off and go home
138 145
diff --git a/MAINTAINERS b/MAINTAINERS
index f0358cd91de3..d2dcef7cd9b2 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6434,8 +6434,9 @@ S: Maintained
6434F: drivers/usb/misc/rio500* 6434F: drivers/usb/misc/rio500*
6435 6435
6436USB EHCI DRIVER 6436USB EHCI DRIVER
6437M: Alan Stern <stern@rowland.harvard.edu>
6437L: linux-usb@vger.kernel.org 6438L: linux-usb@vger.kernel.org
6438S: Orphan 6439S: Maintained
6439F: Documentation/usb/ehci.txt 6440F: Documentation/usb/ehci.txt
6440F: drivers/usb/host/ehci* 6441F: drivers/usb/host/ehci*
6441 6442
@@ -6465,6 +6466,12 @@ S: Maintained
6465F: Documentation/hid/hiddev.txt 6466F: Documentation/hid/hiddev.txt
6466F: drivers/hid/usbhid/ 6467F: drivers/hid/usbhid/
6467 6468
6469USB/IP DRIVERS
6470M: Matt Mooney <mfm@muteddisk.com>
6471L: linux-usb@vger.kernel.org
6472S: Maintained
6473F: drivers/staging/usbip/
6474
6468USB ISP116X DRIVER 6475USB ISP116X DRIVER
6469M: Olav Kongas <ok@artecdesign.ee> 6476M: Olav Kongas <ok@artecdesign.ee>
6470L: linux-usb@vger.kernel.org 6477L: linux-usb@vger.kernel.org
@@ -6494,8 +6501,9 @@ S: Maintained
6494F: sound/usb/midi.* 6501F: sound/usb/midi.*
6495 6502
6496USB OHCI DRIVER 6503USB OHCI DRIVER
6504M: Alan Stern <stern@rowland.harvard.edu>
6497L: linux-usb@vger.kernel.org 6505L: linux-usb@vger.kernel.org
6498S: Orphan 6506S: Maintained
6499F: Documentation/usb/ohci.txt 6507F: Documentation/usb/ohci.txt
6500F: drivers/usb/host/ohci* 6508F: drivers/usb/host/ohci*
6501 6509
diff --git a/Makefile b/Makefile
index 41330a06e4ec..dc670467fb8c 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 3 1VERSION = 3
2PATCHLEVEL = 0 2PATCHLEVEL = 0
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc4 4EXTRAVERSION = -rc5
5NAME = Sneaky Weasel 5NAME = Sneaky Weasel
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/alpha/include/asm/mmzone.h b/arch/alpha/include/asm/mmzone.h
index 8af56ce346ad..445dc42e0334 100644
--- a/arch/alpha/include/asm/mmzone.h
+++ b/arch/alpha/include/asm/mmzone.h
@@ -56,7 +56,6 @@ PLAT_NODE_DATA_LOCALNR(unsigned long p, int n)
56 * Given a kernel address, find the home node of the underlying memory. 56 * Given a kernel address, find the home node of the underlying memory.
57 */ 57 */
58#define kvaddr_to_nid(kaddr) pa_to_nid(__pa(kaddr)) 58#define kvaddr_to_nid(kaddr) pa_to_nid(__pa(kaddr))
59#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
60 59
61/* 60/*
62 * Given a kaddr, LOCAL_BASE_ADDR finds the owning node of the memory 61 * Given a kaddr, LOCAL_BASE_ADDR finds the owning node of the memory
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index 942fad97e447..940b20178107 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -597,6 +597,8 @@ __common_mmu_cache_on:
597 sub pc, lr, r0, lsr #32 @ properly flush pipeline 597 sub pc, lr, r0, lsr #32 @ properly flush pipeline
598#endif 598#endif
599 599
600#define PROC_ENTRY_SIZE (4*5)
601
600/* 602/*
601 * Here follow the relocatable cache support functions for the 603 * Here follow the relocatable cache support functions for the
602 * various processors. This is a generic hook for locating an 604 * various processors. This is a generic hook for locating an
@@ -624,7 +626,7 @@ call_cache_fn: adr r12, proc_types
624 ARM( addeq pc, r12, r3 ) @ call cache function 626 ARM( addeq pc, r12, r3 ) @ call cache function
625 THUMB( addeq r12, r3 ) 627 THUMB( addeq r12, r3 )
626 THUMB( moveq pc, r12 ) @ call cache function 628 THUMB( moveq pc, r12 ) @ call cache function
627 add r12, r12, #4*5 629 add r12, r12, #PROC_ENTRY_SIZE
628 b 1b 630 b 1b
629 631
630/* 632/*
@@ -794,6 +796,16 @@ proc_types:
794 796
795 .size proc_types, . - proc_types 797 .size proc_types, . - proc_types
796 798
799 /*
800 * If you get a "non-constant expression in ".if" statement"
801 * error from the assembler on this line, check that you have
802 * not accidentally written a "b" instruction where you should
803 * have written W(b).
804 */
805 .if (. - proc_types) % PROC_ENTRY_SIZE != 0
806 .error "The size of one or more proc_types entries is wrong."
807 .endif
808
797/* 809/*
798 * Turn off the Cache and MMU. ARMv3 does not support 810 * Turn off the Cache and MMU. ARMv3 does not support
799 * reading the control register, but ARMv4 does. 811 * reading the control register, but ARMv4 does.
diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h
index bc2d2d75f706..65c3f2474f5e 100644
--- a/arch/arm/include/asm/assembler.h
+++ b/arch/arm/include/asm/assembler.h
@@ -13,6 +13,9 @@
13 * Do not include any C declarations in this file - it is included by 13 * Do not include any C declarations in this file - it is included by
14 * assembler source. 14 * assembler source.
15 */ 15 */
16#ifndef __ASM_ASSEMBLER_H__
17#define __ASM_ASSEMBLER_H__
18
16#ifndef __ASSEMBLY__ 19#ifndef __ASSEMBLY__
17#error "Only include this from assembly code" 20#error "Only include this from assembly code"
18#endif 21#endif
@@ -290,3 +293,4 @@
290 .macro ldrusr, reg, ptr, inc, cond=al, rept=1, abort=9001f 293 .macro ldrusr, reg, ptr, inc, cond=al, rept=1, abort=9001f
291 usracc ldr, \reg, \ptr, \inc, \cond, \rept, \abort 294 usracc ldr, \reg, \ptr, \inc, \cond, \rept, \abort
292 .endm 295 .endm
296#endif /* __ASM_ASSEMBLER_H__ */
diff --git a/arch/arm/include/asm/entry-macro-multi.S b/arch/arm/include/asm/entry-macro-multi.S
index ec0bbf79c71f..2da8547de6d6 100644
--- a/arch/arm/include/asm/entry-macro-multi.S
+++ b/arch/arm/include/asm/entry-macro-multi.S
@@ -1,3 +1,5 @@
1#include <asm/assembler.h>
2
1/* 3/*
2 * Interrupt handling. Preserves r7, r8, r9 4 * Interrupt handling. Preserves r7, r8, r9
3 */ 5 */
diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
index fee7c36349eb..016d6a0830a3 100644
--- a/arch/arm/kernel/module.c
+++ b/arch/arm/kernel/module.c
@@ -193,8 +193,17 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
193 offset -= 0x02000000; 193 offset -= 0x02000000;
194 offset += sym->st_value - loc; 194 offset += sym->st_value - loc;
195 195
196 /* only Thumb addresses allowed (no interworking) */ 196 /*
197 if (!(offset & 1) || 197 * For function symbols, only Thumb addresses are
198 * allowed (no interworking).
199 *
200 * For non-function symbols, the destination
201 * has no specific ARM/Thumb disposition, so
202 * the branch is resolved under the assumption
203 * that interworking is not required.
204 */
205 if ((ELF32_ST_TYPE(sym->st_info) == STT_FUNC &&
206 !(offset & 1)) ||
198 offset <= (s32)0xff000000 || 207 offset <= (s32)0xff000000 ||
199 offset >= (s32)0x01000000) { 208 offset >= (s32)0x01000000) {
200 pr_err("%s: section %u reloc %u sym '%s': relocation %u out of range (%#lx -> %#x)\n", 209 pr_err("%s: section %u reloc %u sym '%s': relocation %u out of range (%#lx -> %#x)\n",
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 344e52b16c8c..e7f92a4321f3 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -318,9 +318,13 @@ asmlinkage void __cpuinit secondary_start_kernel(void)
318 smp_store_cpu_info(cpu); 318 smp_store_cpu_info(cpu);
319 319
320 /* 320 /*
321 * OK, now it's safe to let the boot CPU continue 321 * OK, now it's safe to let the boot CPU continue. Wait for
322 * the CPU migration code to notice that the CPU is online
323 * before we continue.
322 */ 324 */
323 set_cpu_online(cpu, true); 325 set_cpu_online(cpu, true);
326 while (!cpu_active(cpu))
327 cpu_relax();
324 328
325 /* 329 /*
326 * OK, it's off to the idle thread for us 330 * OK, it's off to the idle thread for us
diff --git a/arch/arm/mach-exynos4/init.c b/arch/arm/mach-exynos4/init.c
index cf91f50e43ab..a8a83e3881a4 100644
--- a/arch/arm/mach-exynos4/init.c
+++ b/arch/arm/mach-exynos4/init.c
@@ -35,6 +35,7 @@ void __init exynos4_common_init_uarts(struct s3c2410_uartcfg *cfg, int no)
35 tcfg->clocks = exynos4_serial_clocks; 35 tcfg->clocks = exynos4_serial_clocks;
36 tcfg->clocks_size = ARRAY_SIZE(exynos4_serial_clocks); 36 tcfg->clocks_size = ARRAY_SIZE(exynos4_serial_clocks);
37 } 37 }
38 tcfg->flags |= NO_NEED_CHECK_CLKSRC;
38 } 39 }
39 40
40 s3c24xx_init_uartdevs("s5pv210-uart", s5p_uart_resources, cfg, no); 41 s3c24xx_init_uartdevs("s5pv210-uart", s5p_uart_resources, cfg, no);
diff --git a/arch/arm/mach-h720x/Kconfig b/arch/arm/mach-h720x/Kconfig
index 9b6982efbd22..abf356c02343 100644
--- a/arch/arm/mach-h720x/Kconfig
+++ b/arch/arm/mach-h720x/Kconfig
@@ -6,12 +6,14 @@ config ARCH_H7201
6 bool "gms30c7201" 6 bool "gms30c7201"
7 depends on ARCH_H720X 7 depends on ARCH_H720X
8 select CPU_H7201 8 select CPU_H7201
9 select ZONE_DMA
9 help 10 help
10 Say Y here if you are using the Hynix GMS30C7201 Reference Board 11 Say Y here if you are using the Hynix GMS30C7201 Reference Board
11 12
12config ARCH_H7202 13config ARCH_H7202
13 bool "hms30c7202" 14 bool "hms30c7202"
14 select CPU_H7202 15 select CPU_H7202
16 select ZONE_DMA
15 depends on ARCH_H720X 17 depends on ARCH_H720X
16 help 18 help
17 Say Y here if you are using the Hynix HMS30C7202 Reference Board 19 Say Y here if you are using the Hynix HMS30C7202 Reference Board
diff --git a/arch/arm/mach-ux500/board-mop500-pins.c b/arch/arm/mach-ux500/board-mop500-pins.c
index fd4cf1ca5efd..70cdbd60596a 100644
--- a/arch/arm/mach-ux500/board-mop500-pins.c
+++ b/arch/arm/mach-ux500/board-mop500-pins.c
@@ -110,10 +110,18 @@ static pin_cfg_t mop500_pins_common[] = {
110 GPIO168_KP_O0, 110 GPIO168_KP_O0,
111 111
112 /* UART */ 112 /* UART */
113 GPIO0_U0_CTSn | PIN_INPUT_PULLUP, 113 /* uart-0 pins gpio configuration should be
114 GPIO1_U0_RTSn | PIN_OUTPUT_HIGH, 114 * kept intact to prevent glitch in tx line
115 GPIO2_U0_RXD | PIN_INPUT_PULLUP, 115 * when tty dev is opened. Later these pins
116 GPIO3_U0_TXD | PIN_OUTPUT_HIGH, 116 * are configured to uart mop500_pins_uart0
117 *
118 * It will be replaced with uart configuration
119 * once the issue is solved.
120 */
121 GPIO0_GPIO | PIN_INPUT_PULLUP,
122 GPIO1_GPIO | PIN_OUTPUT_HIGH,
123 GPIO2_GPIO | PIN_INPUT_PULLUP,
124 GPIO3_GPIO | PIN_OUTPUT_HIGH,
117 125
118 GPIO29_U2_RXD | PIN_INPUT_PULLUP, 126 GPIO29_U2_RXD | PIN_INPUT_PULLUP,
119 GPIO30_U2_TXD | PIN_OUTPUT_HIGH, 127 GPIO30_U2_TXD | PIN_OUTPUT_HIGH,
diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c
index bb26f40493e6..2a08c07dec6d 100644
--- a/arch/arm/mach-ux500/board-mop500.c
+++ b/arch/arm/mach-ux500/board-mop500.c
@@ -27,18 +27,21 @@
27#include <linux/leds-lp5521.h> 27#include <linux/leds-lp5521.h>
28#include <linux/input.h> 28#include <linux/input.h>
29#include <linux/gpio_keys.h> 29#include <linux/gpio_keys.h>
30#include <linux/delay.h>
30 31
31#include <asm/mach-types.h> 32#include <asm/mach-types.h>
32#include <asm/mach/arch.h> 33#include <asm/mach/arch.h>
33 34
34#include <plat/i2c.h> 35#include <plat/i2c.h>
35#include <plat/ste_dma40.h> 36#include <plat/ste_dma40.h>
37#include <plat/pincfg.h>
36 38
37#include <mach/hardware.h> 39#include <mach/hardware.h>
38#include <mach/setup.h> 40#include <mach/setup.h>
39#include <mach/devices.h> 41#include <mach/devices.h>
40#include <mach/irqs.h> 42#include <mach/irqs.h>
41 43
44#include "pins-db8500.h"
42#include "ste-dma40-db8500.h" 45#include "ste-dma40-db8500.h"
43#include "devices-db8500.h" 46#include "devices-db8500.h"
44#include "board-mop500.h" 47#include "board-mop500.h"
@@ -393,12 +396,63 @@ static struct stedma40_chan_cfg uart2_dma_cfg_tx = {
393}; 396};
394#endif 397#endif
395 398
399
400static pin_cfg_t mop500_pins_uart0[] = {
401 GPIO0_U0_CTSn | PIN_INPUT_PULLUP,
402 GPIO1_U0_RTSn | PIN_OUTPUT_HIGH,
403 GPIO2_U0_RXD | PIN_INPUT_PULLUP,
404 GPIO3_U0_TXD | PIN_OUTPUT_HIGH,
405};
406
407#define PRCC_K_SOFTRST_SET 0x18
408#define PRCC_K_SOFTRST_CLEAR 0x1C
409static void ux500_uart0_reset(void)
410{
411 void __iomem *prcc_rst_set, *prcc_rst_clr;
412
413 prcc_rst_set = (void __iomem *)IO_ADDRESS(U8500_CLKRST1_BASE +
414 PRCC_K_SOFTRST_SET);
415 prcc_rst_clr = (void __iomem *)IO_ADDRESS(U8500_CLKRST1_BASE +
416 PRCC_K_SOFTRST_CLEAR);
417
418 /* Activate soft reset PRCC_K_SOFTRST_CLEAR */
419 writel((readl(prcc_rst_clr) | 0x1), prcc_rst_clr);
420 udelay(1);
421
422 /* Release soft reset PRCC_K_SOFTRST_SET */
423 writel((readl(prcc_rst_set) | 0x1), prcc_rst_set);
424 udelay(1);
425}
426
427static void ux500_uart0_init(void)
428{
429 int ret;
430
431 ret = nmk_config_pins(mop500_pins_uart0,
432 ARRAY_SIZE(mop500_pins_uart0));
433 if (ret < 0)
434 pr_err("pl011: uart pins_enable failed\n");
435}
436
437static void ux500_uart0_exit(void)
438{
439 int ret;
440
441 ret = nmk_config_pins_sleep(mop500_pins_uart0,
442 ARRAY_SIZE(mop500_pins_uart0));
443 if (ret < 0)
444 pr_err("pl011: uart pins_disable failed\n");
445}
446
396static struct amba_pl011_data uart0_plat = { 447static struct amba_pl011_data uart0_plat = {
397#ifdef CONFIG_STE_DMA40 448#ifdef CONFIG_STE_DMA40
398 .dma_filter = stedma40_filter, 449 .dma_filter = stedma40_filter,
399 .dma_rx_param = &uart0_dma_cfg_rx, 450 .dma_rx_param = &uart0_dma_cfg_rx,
400 .dma_tx_param = &uart0_dma_cfg_tx, 451 .dma_tx_param = &uart0_dma_cfg_tx,
401#endif 452#endif
453 .init = ux500_uart0_init,
454 .exit = ux500_uart0_exit,
455 .reset = ux500_uart0_reset,
402}; 456};
403 457
404static struct amba_pl011_data uart1_plat = { 458static struct amba_pl011_data uart1_plat = {
diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S
index 3c3867850a30..089c0b5e454f 100644
--- a/arch/arm/mm/proc-v7.S
+++ b/arch/arm/mm/proc-v7.S
@@ -210,19 +210,21 @@ cpu_v7_name:
210 210
211/* Suspend/resume support: derived from arch/arm/mach-s5pv210/sleep.S */ 211/* Suspend/resume support: derived from arch/arm/mach-s5pv210/sleep.S */
212.globl cpu_v7_suspend_size 212.globl cpu_v7_suspend_size
213.equ cpu_v7_suspend_size, 4 * 8 213.equ cpu_v7_suspend_size, 4 * 9
214#ifdef CONFIG_PM_SLEEP 214#ifdef CONFIG_PM_SLEEP
215ENTRY(cpu_v7_do_suspend) 215ENTRY(cpu_v7_do_suspend)
216 stmfd sp!, {r4 - r11, lr} 216 stmfd sp!, {r4 - r11, lr}
217 mrc p15, 0, r4, c13, c0, 0 @ FCSE/PID 217 mrc p15, 0, r4, c13, c0, 0 @ FCSE/PID
218 mrc p15, 0, r5, c13, c0, 1 @ Context ID 218 mrc p15, 0, r5, c13, c0, 1 @ Context ID
219 mrc p15, 0, r6, c13, c0, 3 @ User r/o thread ID
220 stmia r0!, {r4 - r6}
219 mrc p15, 0, r6, c3, c0, 0 @ Domain ID 221 mrc p15, 0, r6, c3, c0, 0 @ Domain ID
220 mrc p15, 0, r7, c2, c0, 0 @ TTB 0 222 mrc p15, 0, r7, c2, c0, 0 @ TTB 0
221 mrc p15, 0, r8, c2, c0, 1 @ TTB 1 223 mrc p15, 0, r8, c2, c0, 1 @ TTB 1
222 mrc p15, 0, r9, c1, c0, 0 @ Control register 224 mrc p15, 0, r9, c1, c0, 0 @ Control register
223 mrc p15, 0, r10, c1, c0, 1 @ Auxiliary control register 225 mrc p15, 0, r10, c1, c0, 1 @ Auxiliary control register
224 mrc p15, 0, r11, c1, c0, 2 @ Co-processor access control 226 mrc p15, 0, r11, c1, c0, 2 @ Co-processor access control
225 stmia r0, {r4 - r11} 227 stmia r0, {r6 - r11}
226 ldmfd sp!, {r4 - r11, pc} 228 ldmfd sp!, {r4 - r11, pc}
227ENDPROC(cpu_v7_do_suspend) 229ENDPROC(cpu_v7_do_suspend)
228 230
@@ -230,9 +232,11 @@ ENTRY(cpu_v7_do_resume)
230 mov ip, #0 232 mov ip, #0
231 mcr p15, 0, ip, c8, c7, 0 @ invalidate TLBs 233 mcr p15, 0, ip, c8, c7, 0 @ invalidate TLBs
232 mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache 234 mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
233 ldmia r0, {r4 - r11} 235 ldmia r0!, {r4 - r6}
234 mcr p15, 0, r4, c13, c0, 0 @ FCSE/PID 236 mcr p15, 0, r4, c13, c0, 0 @ FCSE/PID
235 mcr p15, 0, r5, c13, c0, 1 @ Context ID 237 mcr p15, 0, r5, c13, c0, 1 @ Context ID
238 mcr p15, 0, r6, c13, c0, 3 @ User r/o thread ID
239 ldmia r0, {r6 - r11}
236 mcr p15, 0, r6, c3, c0, 0 @ Domain ID 240 mcr p15, 0, r6, c3, c0, 0 @ Domain ID
237 mcr p15, 0, r7, c2, c0, 0 @ TTB 0 241 mcr p15, 0, r7, c2, c0, 0 @ TTB 0
238 mcr p15, 0, r8, c2, c0, 1 @ TTB 1 242 mcr p15, 0, r8, c2, c0, 1 @ TTB 1
@@ -418,9 +422,9 @@ ENTRY(v7_processor_functions)
418 .word cpu_v7_dcache_clean_area 422 .word cpu_v7_dcache_clean_area
419 .word cpu_v7_switch_mm 423 .word cpu_v7_switch_mm
420 .word cpu_v7_set_pte_ext 424 .word cpu_v7_set_pte_ext
421 .word 0 425 .word cpu_v7_suspend_size
422 .word 0 426 .word cpu_v7_do_suspend
423 .word 0 427 .word cpu_v7_do_resume
424 .size v7_processor_functions, . - v7_processor_functions 428 .size v7_processor_functions, . - v7_processor_functions
425 429
426 .section ".rodata" 430 .section ".rodata"
diff --git a/arch/arm/plat-iop/cp6.c b/arch/arm/plat-iop/cp6.c
index 9612a87e2a88..bab73e2c79db 100644
--- a/arch/arm/plat-iop/cp6.c
+++ b/arch/arm/plat-iop/cp6.c
@@ -18,6 +18,7 @@
18 */ 18 */
19#include <linux/init.h> 19#include <linux/init.h>
20#include <asm/traps.h> 20#include <asm/traps.h>
21#include <asm/ptrace.h>
21 22
22static int cp6_trap(struct pt_regs *regs, unsigned int instr) 23static int cp6_trap(struct pt_regs *regs, unsigned int instr)
23{ 24{
diff --git a/arch/arm/plat-samsung/include/plat/regs-serial.h b/arch/arm/plat-samsung/include/plat/regs-serial.h
index c151c5f94a87..116edfe120b9 100644
--- a/arch/arm/plat-samsung/include/plat/regs-serial.h
+++ b/arch/arm/plat-samsung/include/plat/regs-serial.h
@@ -224,6 +224,8 @@
224#define S5PV210_UFSTAT_RXMASK (255<<0) 224#define S5PV210_UFSTAT_RXMASK (255<<0)
225#define S5PV210_UFSTAT_RXSHIFT (0) 225#define S5PV210_UFSTAT_RXSHIFT (0)
226 226
227#define NO_NEED_CHECK_CLKSRC 1
228
227#ifndef __ASSEMBLY__ 229#ifndef __ASSEMBLY__
228 230
229/* struct s3c24xx_uart_clksrc 231/* struct s3c24xx_uart_clksrc
diff --git a/arch/m32r/include/asm/mmzone.h b/arch/m32r/include/asm/mmzone.h
index 9f3b5accda88..115ced33febd 100644
--- a/arch/m32r/include/asm/mmzone.h
+++ b/arch/m32r/include/asm/mmzone.h
@@ -14,12 +14,6 @@ extern struct pglist_data *node_data[];
14#define NODE_DATA(nid) (node_data[nid]) 14#define NODE_DATA(nid) (node_data[nid])
15 15
16#define node_localnr(pfn, nid) ((pfn) - NODE_DATA(nid)->node_start_pfn) 16#define node_localnr(pfn, nid) ((pfn) - NODE_DATA(nid)->node_start_pfn)
17#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
18#define node_end_pfn(nid) \
19({ \
20 pg_data_t *__pgdat = NODE_DATA(nid); \
21 __pgdat->node_start_pfn + __pgdat->node_spanned_pages - 1; \
22})
23 17
24#define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT)) 18#define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
25/* 19/*
@@ -44,7 +38,7 @@ static __inline__ int pfn_to_nid(unsigned long pfn)
44 int node; 38 int node;
45 39
46 for (node = 0 ; node < MAX_NUMNODES ; node++) 40 for (node = 0 ; node < MAX_NUMNODES ; node++)
47 if (pfn >= node_start_pfn(node) && pfn <= node_end_pfn(node)) 41 if (pfn >= node_start_pfn(node) && pfn < node_end_pfn(node))
48 break; 42 break;
49 43
50 return node; 44 return node;
diff --git a/arch/mn10300/include/asm/uaccess.h b/arch/mn10300/include/asm/uaccess.h
index 3d6e60dad9d9..780560b330d9 100644
--- a/arch/mn10300/include/asm/uaccess.h
+++ b/arch/mn10300/include/asm/uaccess.h
@@ -15,6 +15,7 @@
15 * User space memory access functions 15 * User space memory access functions
16 */ 16 */
17#include <linux/thread_info.h> 17#include <linux/thread_info.h>
18#include <linux/kernel.h>
18#include <asm/page.h> 19#include <asm/page.h>
19#include <asm/errno.h> 20#include <asm/errno.h>
20 21
diff --git a/arch/parisc/include/asm/mmzone.h b/arch/parisc/include/asm/mmzone.h
index 9608d2cf214a..e67eb9c3d1bf 100644
--- a/arch/parisc/include/asm/mmzone.h
+++ b/arch/parisc/include/asm/mmzone.h
@@ -14,13 +14,6 @@ extern struct node_map_data node_data[];
14 14
15#define NODE_DATA(nid) (&node_data[nid].pg_data) 15#define NODE_DATA(nid) (&node_data[nid].pg_data)
16 16
17#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
18#define node_end_pfn(nid) \
19({ \
20 pg_data_t *__pgdat = NODE_DATA(nid); \
21 __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \
22})
23
24/* We have these possible memory map layouts: 17/* We have these possible memory map layouts:
25 * Astro: 0-3.75, 67.75-68, 4-64 18 * Astro: 0-3.75, 67.75-68, 4-64
26 * zx1: 0-1, 257-260, 4-256 19 * zx1: 0-1, 257-260, 4-256
diff --git a/arch/powerpc/include/asm/mmzone.h b/arch/powerpc/include/asm/mmzone.h
index fd3fd58bad84..7b589178be46 100644
--- a/arch/powerpc/include/asm/mmzone.h
+++ b/arch/powerpc/include/asm/mmzone.h
@@ -38,13 +38,6 @@ u64 memory_hotplug_max(void);
38#define memory_hotplug_max() memblock_end_of_DRAM() 38#define memory_hotplug_max() memblock_end_of_DRAM()
39#endif 39#endif
40 40
41/*
42 * Following are macros that each numa implmentation must define.
43 */
44
45#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
46#define node_end_pfn(nid) (NODE_DATA(nid)->node_end_pfn)
47
48#else 41#else
49#define memory_hotplug_max() memblock_end_of_DRAM() 42#define memory_hotplug_max() memblock_end_of_DRAM()
50#endif /* CONFIG_NEED_MULTIPLE_NODES */ 43#endif /* CONFIG_NEED_MULTIPLE_NODES */
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 90d77bd078f5..c03fef7a9c22 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -579,6 +579,7 @@ config S390_GUEST
579 def_bool y 579 def_bool y
580 prompt "s390 guest support for KVM (EXPERIMENTAL)" 580 prompt "s390 guest support for KVM (EXPERIMENTAL)"
581 depends on 64BIT && EXPERIMENTAL 581 depends on 64BIT && EXPERIMENTAL
582 select VIRTUALIZATION
582 select VIRTIO 583 select VIRTIO
583 select VIRTIO_RING 584 select VIRTIO_RING
584 select VIRTIO_CONSOLE 585 select VIRTIO_CONSOLE
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index 52420d2785b3..1d55c95f617c 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -262,7 +262,7 @@ void smp_ctl_set_bit(int cr, int bit)
262 262
263 memset(&parms.orvals, 0, sizeof(parms.orvals)); 263 memset(&parms.orvals, 0, sizeof(parms.orvals));
264 memset(&parms.andvals, 0xff, sizeof(parms.andvals)); 264 memset(&parms.andvals, 0xff, sizeof(parms.andvals));
265 parms.orvals[cr] = 1 << bit; 265 parms.orvals[cr] = 1UL << bit;
266 on_each_cpu(smp_ctl_bit_callback, &parms, 1); 266 on_each_cpu(smp_ctl_bit_callback, &parms, 1);
267} 267}
268EXPORT_SYMBOL(smp_ctl_set_bit); 268EXPORT_SYMBOL(smp_ctl_set_bit);
@@ -276,7 +276,7 @@ void smp_ctl_clear_bit(int cr, int bit)
276 276
277 memset(&parms.orvals, 0, sizeof(parms.orvals)); 277 memset(&parms.orvals, 0, sizeof(parms.orvals));
278 memset(&parms.andvals, 0xff, sizeof(parms.andvals)); 278 memset(&parms.andvals, 0xff, sizeof(parms.andvals));
279 parms.andvals[cr] = ~(1L << bit); 279 parms.andvals[cr] = ~(1UL << bit);
280 on_each_cpu(smp_ctl_bit_callback, &parms, 1); 280 on_each_cpu(smp_ctl_bit_callback, &parms, 1);
281} 281}
282EXPORT_SYMBOL(smp_ctl_clear_bit); 282EXPORT_SYMBOL(smp_ctl_clear_bit);
diff --git a/arch/s390/oprofile/init.c b/arch/s390/oprofile/init.c
index 5995e9bc72d9..0e358c2cffeb 100644
--- a/arch/s390/oprofile/init.c
+++ b/arch/s390/oprofile/init.c
@@ -25,7 +25,7 @@ extern void s390_backtrace(struct pt_regs * const regs, unsigned int depth);
25 25
26#include "hwsampler.h" 26#include "hwsampler.h"
27 27
28#define DEFAULT_INTERVAL 4096 28#define DEFAULT_INTERVAL 4127518
29 29
30#define DEFAULT_SDBT_BLOCKS 1 30#define DEFAULT_SDBT_BLOCKS 1
31#define DEFAULT_SDB_BLOCKS 511 31#define DEFAULT_SDB_BLOCKS 511
@@ -151,6 +151,12 @@ static int oprofile_hwsampler_init(struct oprofile_operations *ops)
151 if (oprofile_max_interval == 0) 151 if (oprofile_max_interval == 0)
152 return -ENODEV; 152 return -ENODEV;
153 153
154 /* The initial value should be sane */
155 if (oprofile_hw_interval < oprofile_min_interval)
156 oprofile_hw_interval = oprofile_min_interval;
157 if (oprofile_hw_interval > oprofile_max_interval)
158 oprofile_hw_interval = oprofile_max_interval;
159
154 if (oprofile_timer_init(ops)) 160 if (oprofile_timer_init(ops))
155 return -ENODEV; 161 return -ENODEV;
156 162
diff --git a/arch/sh/include/asm/mmzone.h b/arch/sh/include/asm/mmzone.h
index 8887baff5eff..15a8496960e6 100644
--- a/arch/sh/include/asm/mmzone.h
+++ b/arch/sh/include/asm/mmzone.h
@@ -9,10 +9,6 @@
9extern struct pglist_data *node_data[]; 9extern struct pglist_data *node_data[];
10#define NODE_DATA(nid) (node_data[nid]) 10#define NODE_DATA(nid) (node_data[nid])
11 11
12#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
13#define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \
14 NODE_DATA(nid)->node_spanned_pages)
15
16static inline int pfn_to_nid(unsigned long pfn) 12static inline int pfn_to_nid(unsigned long pfn)
17{ 13{
18 int nid; 14 int nid;
diff --git a/arch/sparc/include/asm/mmzone.h b/arch/sparc/include/asm/mmzone.h
index e8c648741ed4..99d9b9f577bf 100644
--- a/arch/sparc/include/asm/mmzone.h
+++ b/arch/sparc/include/asm/mmzone.h
@@ -8,8 +8,6 @@
8extern struct pglist_data *node_data[]; 8extern struct pglist_data *node_data[];
9 9
10#define NODE_DATA(nid) (node_data[nid]) 10#define NODE_DATA(nid) (node_data[nid])
11#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
12#define node_end_pfn(nid) (NODE_DATA(nid)->node_end_pfn)
13 11
14extern int numa_cpu_lookup_table[]; 12extern int numa_cpu_lookup_table[];
15extern cpumask_t numa_cpumask_lookup_table[]; 13extern cpumask_t numa_cpumask_lookup_table[];
diff --git a/arch/tile/include/asm/mmzone.h b/arch/tile/include/asm/mmzone.h
index c6344c4f32ac..9d3dbce8f953 100644
--- a/arch/tile/include/asm/mmzone.h
+++ b/arch/tile/include/asm/mmzone.h
@@ -40,17 +40,6 @@ static inline int pfn_to_nid(unsigned long pfn)
40 return highbits_to_node[__pfn_to_highbits(pfn)]; 40 return highbits_to_node[__pfn_to_highbits(pfn)];
41} 41}
42 42
43/*
44 * Following are macros that each numa implmentation must define.
45 */
46
47#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
48#define node_end_pfn(nid) \
49({ \
50 pg_data_t *__pgdat = NODE_DATA(nid); \
51 __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \
52})
53
54#define kern_addr_valid(kaddr) virt_addr_valid((void *)kaddr) 43#define kern_addr_valid(kaddr) virt_addr_valid((void *)kaddr)
55 44
56static inline int pfn_valid(int pfn) 45static inline int pfn_valid(int pfn)
diff --git a/arch/um/include/asm/percpu.h b/arch/um/include/asm/percpu.h
new file mode 100644
index 000000000000..efe7508d8abd
--- /dev/null
+++ b/arch/um/include/asm/percpu.h
@@ -0,0 +1,6 @@
1#ifndef __UM_PERCPU_H
2#define __UM_PERCPU_H
3
4#include <asm-generic/percpu.h>
5
6#endif /* __UM_PERCPU_H */
diff --git a/arch/x86/include/asm/mmzone_32.h b/arch/x86/include/asm/mmzone_32.h
index 5e83a416eca8..224e8c5eb307 100644
--- a/arch/x86/include/asm/mmzone_32.h
+++ b/arch/x86/include/asm/mmzone_32.h
@@ -48,17 +48,6 @@ static inline int pfn_to_nid(unsigned long pfn)
48#endif 48#endif
49} 49}
50 50
51/*
52 * Following are macros that each numa implmentation must define.
53 */
54
55#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
56#define node_end_pfn(nid) \
57({ \
58 pg_data_t *__pgdat = NODE_DATA(nid); \
59 __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \
60})
61
62static inline int pfn_valid(int pfn) 51static inline int pfn_valid(int pfn)
63{ 52{
64 int nid = pfn_to_nid(pfn); 53 int nid = pfn_to_nid(pfn);
diff --git a/arch/x86/include/asm/mmzone_64.h b/arch/x86/include/asm/mmzone_64.h
index b3f88d7867c7..129d9aa3ceb3 100644
--- a/arch/x86/include/asm/mmzone_64.h
+++ b/arch/x86/include/asm/mmzone_64.h
@@ -13,8 +13,5 @@ extern struct pglist_data *node_data[];
13 13
14#define NODE_DATA(nid) (node_data[nid]) 14#define NODE_DATA(nid) (node_data[nid])
15 15
16#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
17#define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \
18 NODE_DATA(nid)->node_spanned_pages)
19#endif 16#endif
20#endif /* _ASM_X86_MMZONE_64_H */ 17#endif /* _ASM_X86_MMZONE_64_H */
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 0972315c3860..68c3c1395202 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -188,7 +188,7 @@ static bool resource_contains(struct resource *res, resource_size_t point)
188 return false; 188 return false;
189} 189}
190 190
191static void coalesce_windows(struct pci_root_info *info, int type) 191static void coalesce_windows(struct pci_root_info *info, unsigned long type)
192{ 192{
193 int i, j; 193 int i, j;
194 struct resource *res1, *res2; 194 struct resource *res1, *res2;
diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index a62be8d0dc1b..3689f833afdc 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -927,7 +927,7 @@ static int throtl_dispatch(struct request_queue *q)
927 927
928 bio_list_init(&bio_list_on_stack); 928 bio_list_init(&bio_list_on_stack);
929 929
930 throtl_log(td, "dispatch nr_queued=%lu read=%u write=%u", 930 throtl_log(td, "dispatch nr_queued=%d read=%u write=%u",
931 total_nr_queued(td), td->nr_queued[READ], 931 total_nr_queued(td), td->nr_queued[READ],
932 td->nr_queued[WRITE]); 932 td->nr_queued[WRITE]);
933 933
@@ -1204,7 +1204,7 @@ int blk_throtl_bio(struct request_queue *q, struct bio **biop)
1204 } 1204 }
1205 1205
1206queue_bio: 1206queue_bio:
1207 throtl_log_tg(td, tg, "[%c] bio. bdisp=%u sz=%u bps=%llu" 1207 throtl_log_tg(td, tg, "[%c] bio. bdisp=%llu sz=%u bps=%llu"
1208 " iodisp=%u iops=%u queued=%d/%d", 1208 " iodisp=%u iops=%u queued=%d/%d",
1209 rw == READ ? 'R' : 'W', 1209 rw == READ ? 'R' : 'W',
1210 tg->bytes_disp[rw], bio->bi_size, tg->bps[rw], 1210 tg->bytes_disp[rw], bio->bi_size, tg->bps[rw],
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 3c7b537bf908..f3799432676d 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -988,9 +988,10 @@ static void cfq_group_served(struct cfq_data *cfqd, struct cfq_group *cfqg,
988 988
989 cfq_log_cfqg(cfqd, cfqg, "served: vt=%llu min_vt=%llu", cfqg->vdisktime, 989 cfq_log_cfqg(cfqd, cfqg, "served: vt=%llu min_vt=%llu", cfqg->vdisktime,
990 st->min_vdisktime); 990 st->min_vdisktime);
991 cfq_log_cfqq(cfqq->cfqd, cfqq, "sl_used=%u disp=%u charge=%u iops=%u" 991 cfq_log_cfqq(cfqq->cfqd, cfqq,
992 " sect=%u", used_sl, cfqq->slice_dispatch, charge, 992 "sl_used=%u disp=%u charge=%u iops=%u sect=%lu",
993 iops_mode(cfqd), cfqq->nr_sectors); 993 used_sl, cfqq->slice_dispatch, charge,
994 iops_mode(cfqd), cfqq->nr_sectors);
994 cfq_blkiocg_update_timeslice_used(&cfqg->blkg, used_sl, 995 cfq_blkiocg_update_timeslice_used(&cfqg->blkg, used_sl,
995 unaccounted_sl); 996 unaccounted_sl);
996 cfq_blkiocg_set_start_empty_time(&cfqg->blkg); 997 cfq_blkiocg_set_start_empty_time(&cfqg->blkg);
@@ -2023,8 +2024,8 @@ static void cfq_arm_slice_timer(struct cfq_data *cfqd)
2023 */ 2024 */
2024 if (sample_valid(cic->ttime_samples) && 2025 if (sample_valid(cic->ttime_samples) &&
2025 (cfqq->slice_end - jiffies < cic->ttime_mean)) { 2026 (cfqq->slice_end - jiffies < cic->ttime_mean)) {
2026 cfq_log_cfqq(cfqd, cfqq, "Not idling. think_time:%d", 2027 cfq_log_cfqq(cfqd, cfqq, "Not idling. think_time:%lu",
2027 cic->ttime_mean); 2028 cic->ttime_mean);
2028 return; 2029 return;
2029 } 2030 }
2030 2031
@@ -2772,8 +2773,11 @@ static void __cfq_exit_single_io_context(struct cfq_data *cfqd,
2772 smp_wmb(); 2773 smp_wmb();
2773 cic->key = cfqd_dead_key(cfqd); 2774 cic->key = cfqd_dead_key(cfqd);
2774 2775
2775 if (ioc->ioc_data == cic) 2776 if (rcu_dereference(ioc->ioc_data) == cic) {
2777 spin_lock(&ioc->lock);
2776 rcu_assign_pointer(ioc->ioc_data, NULL); 2778 rcu_assign_pointer(ioc->ioc_data, NULL);
2779 spin_unlock(&ioc->lock);
2780 }
2777 2781
2778 if (cic->cfqq[BLK_RW_ASYNC]) { 2782 if (cic->cfqq[BLK_RW_ASYNC]) {
2779 cfq_exit_cfqq(cfqd, cic->cfqq[BLK_RW_ASYNC]); 2783 cfq_exit_cfqq(cfqd, cic->cfqq[BLK_RW_ASYNC]);
diff --git a/block/genhd.c b/block/genhd.c
index 95822ae25cfe..3608289c8ecd 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1371,6 +1371,7 @@ struct disk_events {
1371 struct gendisk *disk; /* the associated disk */ 1371 struct gendisk *disk; /* the associated disk */
1372 spinlock_t lock; 1372 spinlock_t lock;
1373 1373
1374 struct mutex block_mutex; /* protects blocking */
1374 int block; /* event blocking depth */ 1375 int block; /* event blocking depth */
1375 unsigned int pending; /* events already sent out */ 1376 unsigned int pending; /* events already sent out */
1376 unsigned int clearing; /* events being cleared */ 1377 unsigned int clearing; /* events being cleared */
@@ -1414,22 +1415,44 @@ static unsigned long disk_events_poll_jiffies(struct gendisk *disk)
1414 return msecs_to_jiffies(intv_msecs); 1415 return msecs_to_jiffies(intv_msecs);
1415} 1416}
1416 1417
1417static void __disk_block_events(struct gendisk *disk, bool sync) 1418/**
1419 * disk_block_events - block and flush disk event checking
1420 * @disk: disk to block events for
1421 *
1422 * On return from this function, it is guaranteed that event checking
1423 * isn't in progress and won't happen until unblocked by
1424 * disk_unblock_events(). Events blocking is counted and the actual
1425 * unblocking happens after the matching number of unblocks are done.
1426 *
1427 * Note that this intentionally does not block event checking from
1428 * disk_clear_events().
1429 *
1430 * CONTEXT:
1431 * Might sleep.
1432 */
1433void disk_block_events(struct gendisk *disk)
1418{ 1434{
1419 struct disk_events *ev = disk->ev; 1435 struct disk_events *ev = disk->ev;
1420 unsigned long flags; 1436 unsigned long flags;
1421 bool cancel; 1437 bool cancel;
1422 1438
1439 if (!ev)
1440 return;
1441
1442 /*
1443 * Outer mutex ensures that the first blocker completes canceling
1444 * the event work before further blockers are allowed to finish.
1445 */
1446 mutex_lock(&ev->block_mutex);
1447
1423 spin_lock_irqsave(&ev->lock, flags); 1448 spin_lock_irqsave(&ev->lock, flags);
1424 cancel = !ev->block++; 1449 cancel = !ev->block++;
1425 spin_unlock_irqrestore(&ev->lock, flags); 1450 spin_unlock_irqrestore(&ev->lock, flags);
1426 1451
1427 if (cancel) { 1452 if (cancel)
1428 if (sync) 1453 cancel_delayed_work_sync(&disk->ev->dwork);
1429 cancel_delayed_work_sync(&disk->ev->dwork); 1454
1430 else 1455 mutex_unlock(&ev->block_mutex);
1431 cancel_delayed_work(&disk->ev->dwork);
1432 }
1433} 1456}
1434 1457
1435static void __disk_unblock_events(struct gendisk *disk, bool check_now) 1458static void __disk_unblock_events(struct gendisk *disk, bool check_now)
@@ -1461,27 +1484,6 @@ out_unlock:
1461} 1484}
1462 1485
1463/** 1486/**
1464 * disk_block_events - block and flush disk event checking
1465 * @disk: disk to block events for
1466 *
1467 * On return from this function, it is guaranteed that event checking
1468 * isn't in progress and won't happen until unblocked by
1469 * disk_unblock_events(). Events blocking is counted and the actual
1470 * unblocking happens after the matching number of unblocks are done.
1471 *
1472 * Note that this intentionally does not block event checking from
1473 * disk_clear_events().
1474 *
1475 * CONTEXT:
1476 * Might sleep.
1477 */
1478void disk_block_events(struct gendisk *disk)
1479{
1480 if (disk->ev)
1481 __disk_block_events(disk, true);
1482}
1483
1484/**
1485 * disk_unblock_events - unblock disk event checking 1487 * disk_unblock_events - unblock disk event checking
1486 * @disk: disk to unblock events for 1488 * @disk: disk to unblock events for
1487 * 1489 *
@@ -1508,10 +1510,18 @@ void disk_unblock_events(struct gendisk *disk)
1508 */ 1510 */
1509void disk_check_events(struct gendisk *disk) 1511void disk_check_events(struct gendisk *disk)
1510{ 1512{
1511 if (disk->ev) { 1513 struct disk_events *ev = disk->ev;
1512 __disk_block_events(disk, false); 1514 unsigned long flags;
1513 __disk_unblock_events(disk, true); 1515
1516 if (!ev)
1517 return;
1518
1519 spin_lock_irqsave(&ev->lock, flags);
1520 if (!ev->block) {
1521 cancel_delayed_work(&ev->dwork);
1522 queue_delayed_work(system_nrt_wq, &ev->dwork, 0);
1514 } 1523 }
1524 spin_unlock_irqrestore(&ev->lock, flags);
1515} 1525}
1516EXPORT_SYMBOL_GPL(disk_check_events); 1526EXPORT_SYMBOL_GPL(disk_check_events);
1517 1527
@@ -1546,7 +1556,7 @@ unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask)
1546 spin_unlock_irq(&ev->lock); 1556 spin_unlock_irq(&ev->lock);
1547 1557
1548 /* uncondtionally schedule event check and wait for it to finish */ 1558 /* uncondtionally schedule event check and wait for it to finish */
1549 __disk_block_events(disk, true); 1559 disk_block_events(disk);
1550 queue_delayed_work(system_nrt_wq, &ev->dwork, 0); 1560 queue_delayed_work(system_nrt_wq, &ev->dwork, 0);
1551 flush_delayed_work(&ev->dwork); 1561 flush_delayed_work(&ev->dwork);
1552 __disk_unblock_events(disk, false); 1562 __disk_unblock_events(disk, false);
@@ -1664,7 +1674,7 @@ static ssize_t disk_events_poll_msecs_store(struct device *dev,
1664 if (intv < 0 && intv != -1) 1674 if (intv < 0 && intv != -1)
1665 return -EINVAL; 1675 return -EINVAL;
1666 1676
1667 __disk_block_events(disk, true); 1677 disk_block_events(disk);
1668 disk->ev->poll_msecs = intv; 1678 disk->ev->poll_msecs = intv;
1669 __disk_unblock_events(disk, true); 1679 __disk_unblock_events(disk, true);
1670 1680
@@ -1750,6 +1760,7 @@ static void disk_add_events(struct gendisk *disk)
1750 INIT_LIST_HEAD(&ev->node); 1760 INIT_LIST_HEAD(&ev->node);
1751 ev->disk = disk; 1761 ev->disk = disk;
1752 spin_lock_init(&ev->lock); 1762 spin_lock_init(&ev->lock);
1763 mutex_init(&ev->block_mutex);
1753 ev->block = 1; 1764 ev->block = 1;
1754 ev->poll_msecs = -1; 1765 ev->poll_msecs = -1;
1755 INIT_DELAYED_WORK(&ev->dwork, disk_events_workfn); 1766 INIT_DELAYED_WORK(&ev->dwork, disk_events_workfn);
@@ -1770,7 +1781,7 @@ static void disk_del_events(struct gendisk *disk)
1770 if (!disk->ev) 1781 if (!disk->ev)
1771 return; 1782 return;
1772 1783
1773 __disk_block_events(disk, true); 1784 disk_block_events(disk);
1774 1785
1775 mutex_lock(&disk_events_mutex); 1786 mutex_lock(&disk_events_mutex);
1776 list_del_init(&disk->ev->node); 1787 list_del_init(&disk->ev->node);
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 736bee5dafeb..000d03ae6653 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -4143,9 +4143,9 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
4143 * Devices which choke on SETXFER. Applies only if both the 4143 * Devices which choke on SETXFER. Applies only if both the
4144 * device and controller are SATA. 4144 * device and controller are SATA.
4145 */ 4145 */
4146 { "PIONEER DVD-RW DVRTD08", "1.00", ATA_HORKAGE_NOSETXFER }, 4146 { "PIONEER DVD-RW DVRTD08", NULL, ATA_HORKAGE_NOSETXFER },
4147 { "PIONEER DVD-RW DVR-212D", "1.28", ATA_HORKAGE_NOSETXFER }, 4147 { "PIONEER DVD-RW DVR-212D", NULL, ATA_HORKAGE_NOSETXFER },
4148 { "PIONEER DVD-RW DVR-216D", "1.08", ATA_HORKAGE_NOSETXFER }, 4148 { "PIONEER DVD-RW DVR-216D", NULL, ATA_HORKAGE_NOSETXFER },
4149 4149
4150 /* End Marker */ 4150 /* End Marker */
4151 { } 4151 { }
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index d51f9795c064..927f968e99d9 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -3797,6 +3797,12 @@ EXPORT_SYMBOL_GPL(ata_sas_port_alloc);
3797 */ 3797 */
3798int ata_sas_port_start(struct ata_port *ap) 3798int ata_sas_port_start(struct ata_port *ap)
3799{ 3799{
3800 /*
3801 * the port is marked as frozen at allocation time, but if we don't
3802 * have new eh, we won't thaw it
3803 */
3804 if (!ap->ops->error_handler)
3805 ap->pflags &= ~ATA_PFLAG_FROZEN;
3800 return 0; 3806 return 0;
3801} 3807}
3802EXPORT_SYMBOL_GPL(ata_sas_port_start); 3808EXPORT_SYMBOL_GPL(ata_sas_port_start);
diff --git a/drivers/ata/pata_marvell.c b/drivers/ata/pata_marvell.c
index 75a6a0c0094f..5d7f58a7e34d 100644
--- a/drivers/ata/pata_marvell.c
+++ b/drivers/ata/pata_marvell.c
@@ -161,6 +161,9 @@ static const struct pci_device_id marvell_pci_tbl[] = {
161 { PCI_DEVICE(0x11AB, 0x6121), }, 161 { PCI_DEVICE(0x11AB, 0x6121), },
162 { PCI_DEVICE(0x11AB, 0x6123), }, 162 { PCI_DEVICE(0x11AB, 0x6123), },
163 { PCI_DEVICE(0x11AB, 0x6145), }, 163 { PCI_DEVICE(0x11AB, 0x6145), },
164 { PCI_DEVICE(0x1B4B, 0x91A0), },
165 { PCI_DEVICE(0x1B4B, 0x91A4), },
166
164 { } /* terminate list */ 167 { } /* terminate list */
165}; 168};
166 169
diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
index 1c4b3aa4c7c4..dc88a39e7db8 100644
--- a/drivers/ata/sata_dwc_460ex.c
+++ b/drivers/ata/sata_dwc_460ex.c
@@ -389,7 +389,7 @@ static void sata_dwc_tf_dump(struct ata_taskfile *tf)
389/* 389/*
390 * Function: get_burst_length_encode 390 * Function: get_burst_length_encode
391 * arguments: datalength: length in bytes of data 391 * arguments: datalength: length in bytes of data
392 * returns value to be programmed in register corrresponding to data length 392 * returns value to be programmed in register corresponding to data length
393 * This value is effectively the log(base 2) of the length 393 * This value is effectively the log(base 2) of the length
394 */ 394 */
395static int get_burst_length_encode(int datalength) 395static int get_burst_length_encode(int datalength)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 1c291af637b3..6040717b62bb 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -367,7 +367,7 @@ EXPORT_SYMBOL_GPL(platform_device_unregister);
367 * 367 *
368 * Returns &struct platform_device pointer on success, or ERR_PTR() on error. 368 * Returns &struct platform_device pointer on success, or ERR_PTR() on error.
369 */ 369 */
370struct platform_device *__init_or_module platform_device_register_resndata( 370struct platform_device *platform_device_register_resndata(
371 struct device *parent, 371 struct device *parent,
372 const char *name, int id, 372 const char *name, int id,
373 const struct resource *res, unsigned int num, 373 const struct resource *res, unsigned int num,
diff --git a/drivers/base/power/clock_ops.c b/drivers/base/power/clock_ops.c
index eaa8a854af03..ad367c4139b1 100644
--- a/drivers/base/power/clock_ops.c
+++ b/drivers/base/power/clock_ops.c
@@ -387,7 +387,7 @@ static int pm_runtime_clk_notify(struct notifier_block *nb,
387 clknb = container_of(nb, struct pm_clk_notifier_block, nb); 387 clknb = container_of(nb, struct pm_clk_notifier_block, nb);
388 388
389 switch (action) { 389 switch (action) {
390 case BUS_NOTIFY_ADD_DEVICE: 390 case BUS_NOTIFY_BIND_DRIVER:
391 if (clknb->con_ids[0]) { 391 if (clknb->con_ids[0]) {
392 for (con_id = clknb->con_ids; *con_id; con_id++) 392 for (con_id = clknb->con_ids; *con_id; con_id++)
393 enable_clock(dev, *con_id); 393 enable_clock(dev, *con_id);
@@ -395,7 +395,7 @@ static int pm_runtime_clk_notify(struct notifier_block *nb,
395 enable_clock(dev, NULL); 395 enable_clock(dev, NULL);
396 } 396 }
397 break; 397 break;
398 case BUS_NOTIFY_DEL_DEVICE: 398 case BUS_NOTIFY_UNBOUND_DRIVER:
399 if (clknb->con_ids[0]) { 399 if (clknb->con_ids[0]) {
400 for (con_id = clknb->con_ids; *con_id; con_id++) 400 for (con_id = clknb->con_ids; *con_id; con_id++)
401 disable_clock(dev, *con_id); 401 disable_clock(dev, *con_id);
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index aa6320207745..06f09bf89cb2 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -57,7 +57,8 @@ static int async_error;
57 */ 57 */
58void device_pm_init(struct device *dev) 58void device_pm_init(struct device *dev)
59{ 59{
60 dev->power.in_suspend = false; 60 dev->power.is_prepared = false;
61 dev->power.is_suspended = false;
61 init_completion(&dev->power.completion); 62 init_completion(&dev->power.completion);
62 complete_all(&dev->power.completion); 63 complete_all(&dev->power.completion);
63 dev->power.wakeup = NULL; 64 dev->power.wakeup = NULL;
@@ -91,7 +92,7 @@ void device_pm_add(struct device *dev)
91 pr_debug("PM: Adding info for %s:%s\n", 92 pr_debug("PM: Adding info for %s:%s\n",
92 dev->bus ? dev->bus->name : "No Bus", dev_name(dev)); 93 dev->bus ? dev->bus->name : "No Bus", dev_name(dev));
93 mutex_lock(&dpm_list_mtx); 94 mutex_lock(&dpm_list_mtx);
94 if (dev->parent && dev->parent->power.in_suspend) 95 if (dev->parent && dev->parent->power.is_prepared)
95 dev_warn(dev, "parent %s should not be sleeping\n", 96 dev_warn(dev, "parent %s should not be sleeping\n",
96 dev_name(dev->parent)); 97 dev_name(dev->parent));
97 list_add_tail(&dev->power.entry, &dpm_list); 98 list_add_tail(&dev->power.entry, &dpm_list);
@@ -511,7 +512,14 @@ static int device_resume(struct device *dev, pm_message_t state, bool async)
511 dpm_wait(dev->parent, async); 512 dpm_wait(dev->parent, async);
512 device_lock(dev); 513 device_lock(dev);
513 514
514 dev->power.in_suspend = false; 515 /*
516 * This is a fib. But we'll allow new children to be added below
517 * a resumed device, even if the device hasn't been completed yet.
518 */
519 dev->power.is_prepared = false;
520
521 if (!dev->power.is_suspended)
522 goto Unlock;
515 523
516 if (dev->pwr_domain) { 524 if (dev->pwr_domain) {
517 pm_dev_dbg(dev, state, "power domain "); 525 pm_dev_dbg(dev, state, "power domain ");
@@ -548,6 +556,9 @@ static int device_resume(struct device *dev, pm_message_t state, bool async)
548 } 556 }
549 557
550 End: 558 End:
559 dev->power.is_suspended = false;
560
561 Unlock:
551 device_unlock(dev); 562 device_unlock(dev);
552 complete_all(&dev->power.completion); 563 complete_all(&dev->power.completion);
553 564
@@ -670,7 +681,7 @@ void dpm_complete(pm_message_t state)
670 struct device *dev = to_device(dpm_prepared_list.prev); 681 struct device *dev = to_device(dpm_prepared_list.prev);
671 682
672 get_device(dev); 683 get_device(dev);
673 dev->power.in_suspend = false; 684 dev->power.is_prepared = false;
674 list_move(&dev->power.entry, &list); 685 list_move(&dev->power.entry, &list);
675 mutex_unlock(&dpm_list_mtx); 686 mutex_unlock(&dpm_list_mtx);
676 687
@@ -835,11 +846,11 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
835 device_lock(dev); 846 device_lock(dev);
836 847
837 if (async_error) 848 if (async_error)
838 goto End; 849 goto Unlock;
839 850
840 if (pm_wakeup_pending()) { 851 if (pm_wakeup_pending()) {
841 async_error = -EBUSY; 852 async_error = -EBUSY;
842 goto End; 853 goto Unlock;
843 } 854 }
844 855
845 if (dev->pwr_domain) { 856 if (dev->pwr_domain) {
@@ -877,6 +888,9 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
877 } 888 }
878 889
879 End: 890 End:
891 dev->power.is_suspended = !error;
892
893 Unlock:
880 device_unlock(dev); 894 device_unlock(dev);
881 complete_all(&dev->power.completion); 895 complete_all(&dev->power.completion);
882 896
@@ -1042,7 +1056,7 @@ int dpm_prepare(pm_message_t state)
1042 put_device(dev); 1056 put_device(dev);
1043 break; 1057 break;
1044 } 1058 }
1045 dev->power.in_suspend = true; 1059 dev->power.is_prepared = true;
1046 if (!list_empty(&dev->power.entry)) 1060 if (!list_empty(&dev->power.entry))
1047 list_move_tail(&dev->power.entry, &dpm_prepared_list); 1061 list_move_tail(&dev->power.entry, &dpm_prepared_list);
1048 put_device(dev); 1062 put_device(dev);
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index 219d88a0eeae..dde6a0fad408 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -139,6 +139,7 @@ static int cn_call_callback(struct sk_buff *skb)
139 spin_unlock_bh(&dev->cbdev->queue_lock); 139 spin_unlock_bh(&dev->cbdev->queue_lock);
140 140
141 if (cbq != NULL) { 141 if (cbq != NULL) {
142 err = 0;
142 cbq->callback(msg, nsp); 143 cbq->callback(msg, nsp);
143 kfree_skb(skb); 144 kfree_skb(skb);
144 cn_queue_release_callback(cbq); 145 cn_queue_release_callback(cbq);
diff --git a/drivers/firmware/google/Kconfig b/drivers/firmware/google/Kconfig
index 87096b6ca5c9..2f21b0bfe653 100644
--- a/drivers/firmware/google/Kconfig
+++ b/drivers/firmware/google/Kconfig
@@ -13,6 +13,7 @@ menu "Google Firmware Drivers"
13config GOOGLE_SMI 13config GOOGLE_SMI
14 tristate "SMI interface for Google platforms" 14 tristate "SMI interface for Google platforms"
15 depends on ACPI && DMI 15 depends on ACPI && DMI
16 select EFI
16 select EFI_VARS 17 select EFI_VARS
17 help 18 help
18 Say Y here if you want to enable SMI callbacks for Google 19 Say Y here if you want to enable SMI callbacks for Google
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 74e4ff578017..4012fe423460 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -34,6 +34,7 @@
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/mman.h> 35#include <linux/mman.h>
36#include <linux/pagemap.h> 36#include <linux/pagemap.h>
37#include <linux/shmem_fs.h>
37#include "drmP.h" 38#include "drmP.h"
38 39
39/** @file drm_gem.c 40/** @file drm_gem.c
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 8b670e7ee404..e9d1d5c3a696 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -31,6 +31,7 @@
31#include "i915_drv.h" 31#include "i915_drv.h"
32#include "i915_trace.h" 32#include "i915_trace.h"
33#include "intel_drv.h" 33#include "intel_drv.h"
34#include <linux/shmem_fs.h>
34#include <linux/slab.h> 35#include <linux/slab.h>
35#include <linux/swap.h> 36#include <linux/swap.h>
36#include <linux/pci.h> 37#include <linux/pci.h>
@@ -359,8 +360,7 @@ i915_gem_shmem_pread_fast(struct drm_device *dev,
359 if ((page_offset + remain) > PAGE_SIZE) 360 if ((page_offset + remain) > PAGE_SIZE)
360 page_length = PAGE_SIZE - page_offset; 361 page_length = PAGE_SIZE - page_offset;
361 362
362 page = read_cache_page_gfp(mapping, offset >> PAGE_SHIFT, 363 page = shmem_read_mapping_page(mapping, offset >> PAGE_SHIFT);
363 GFP_HIGHUSER | __GFP_RECLAIMABLE);
364 if (IS_ERR(page)) 364 if (IS_ERR(page))
365 return PTR_ERR(page); 365 return PTR_ERR(page);
366 366
@@ -463,8 +463,7 @@ i915_gem_shmem_pread_slow(struct drm_device *dev,
463 if ((data_page_offset + page_length) > PAGE_SIZE) 463 if ((data_page_offset + page_length) > PAGE_SIZE)
464 page_length = PAGE_SIZE - data_page_offset; 464 page_length = PAGE_SIZE - data_page_offset;
465 465
466 page = read_cache_page_gfp(mapping, offset >> PAGE_SHIFT, 466 page = shmem_read_mapping_page(mapping, offset >> PAGE_SHIFT);
467 GFP_HIGHUSER | __GFP_RECLAIMABLE);
468 if (IS_ERR(page)) { 467 if (IS_ERR(page)) {
469 ret = PTR_ERR(page); 468 ret = PTR_ERR(page);
470 goto out; 469 goto out;
@@ -797,8 +796,7 @@ i915_gem_shmem_pwrite_fast(struct drm_device *dev,
797 if ((page_offset + remain) > PAGE_SIZE) 796 if ((page_offset + remain) > PAGE_SIZE)
798 page_length = PAGE_SIZE - page_offset; 797 page_length = PAGE_SIZE - page_offset;
799 798
800 page = read_cache_page_gfp(mapping, offset >> PAGE_SHIFT, 799 page = shmem_read_mapping_page(mapping, offset >> PAGE_SHIFT);
801 GFP_HIGHUSER | __GFP_RECLAIMABLE);
802 if (IS_ERR(page)) 800 if (IS_ERR(page))
803 return PTR_ERR(page); 801 return PTR_ERR(page);
804 802
@@ -907,8 +905,7 @@ i915_gem_shmem_pwrite_slow(struct drm_device *dev,
907 if ((data_page_offset + page_length) > PAGE_SIZE) 905 if ((data_page_offset + page_length) > PAGE_SIZE)
908 page_length = PAGE_SIZE - data_page_offset; 906 page_length = PAGE_SIZE - data_page_offset;
909 907
910 page = read_cache_page_gfp(mapping, offset >> PAGE_SHIFT, 908 page = shmem_read_mapping_page(mapping, offset >> PAGE_SHIFT);
911 GFP_HIGHUSER | __GFP_RECLAIMABLE);
912 if (IS_ERR(page)) { 909 if (IS_ERR(page)) {
913 ret = PTR_ERR(page); 910 ret = PTR_ERR(page);
914 goto out; 911 goto out;
@@ -1558,12 +1555,10 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj,
1558 1555
1559 inode = obj->base.filp->f_path.dentry->d_inode; 1556 inode = obj->base.filp->f_path.dentry->d_inode;
1560 mapping = inode->i_mapping; 1557 mapping = inode->i_mapping;
1558 gfpmask |= mapping_gfp_mask(mapping);
1559
1561 for (i = 0; i < page_count; i++) { 1560 for (i = 0; i < page_count; i++) {
1562 page = read_cache_page_gfp(mapping, i, 1561 page = shmem_read_mapping_page_gfp(mapping, i, gfpmask);
1563 GFP_HIGHUSER |
1564 __GFP_COLD |
1565 __GFP_RECLAIMABLE |
1566 gfpmask);
1567 if (IS_ERR(page)) 1562 if (IS_ERR(page))
1568 goto err_pages; 1563 goto err_pages;
1569 1564
@@ -1701,13 +1696,10 @@ i915_gem_object_truncate(struct drm_i915_gem_object *obj)
1701 /* Our goal here is to return as much of the memory as 1696 /* Our goal here is to return as much of the memory as
1702 * is possible back to the system as we are called from OOM. 1697 * is possible back to the system as we are called from OOM.
1703 * To do this we must instruct the shmfs to drop all of its 1698 * To do this we must instruct the shmfs to drop all of its
1704 * backing pages, *now*. Here we mirror the actions taken 1699 * backing pages, *now*.
1705 * when by shmem_delete_inode() to release the backing store.
1706 */ 1700 */
1707 inode = obj->base.filp->f_path.dentry->d_inode; 1701 inode = obj->base.filp->f_path.dentry->d_inode;
1708 truncate_inode_pages(inode->i_mapping, 0); 1702 shmem_truncate_range(inode, 0, (loff_t)-1);
1709 if (inode->i_op->truncate_range)
1710 inode->i_op->truncate_range(inode, 0, (loff_t)-1);
1711 1703
1712 obj->madv = __I915_MADV_PURGED; 1704 obj->madv = __I915_MADV_PURGED;
1713} 1705}
@@ -3688,6 +3680,7 @@ struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev,
3688{ 3680{
3689 struct drm_i915_private *dev_priv = dev->dev_private; 3681 struct drm_i915_private *dev_priv = dev->dev_private;
3690 struct drm_i915_gem_object *obj; 3682 struct drm_i915_gem_object *obj;
3683 struct address_space *mapping;
3691 3684
3692 obj = kzalloc(sizeof(*obj), GFP_KERNEL); 3685 obj = kzalloc(sizeof(*obj), GFP_KERNEL);
3693 if (obj == NULL) 3686 if (obj == NULL)
@@ -3698,6 +3691,9 @@ struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev,
3698 return NULL; 3691 return NULL;
3699 } 3692 }
3700 3693
3694 mapping = obj->base.filp->f_path.dentry->d_inode->i_mapping;
3695 mapping_set_gfp_mask(mapping, GFP_HIGHUSER | __GFP_RECLAIMABLE);
3696
3701 i915_gem_info_add_obj(dev_priv, size); 3697 i915_gem_info_add_obj(dev_priv, size);
3702 3698
3703 obj->base.write_domain = I915_GEM_DOMAIN_CPU; 3699 obj->base.write_domain = I915_GEM_DOMAIN_CPU;
@@ -4089,8 +4085,7 @@ void i915_gem_detach_phys_object(struct drm_device *dev,
4089 4085
4090 page_count = obj->base.size / PAGE_SIZE; 4086 page_count = obj->base.size / PAGE_SIZE;
4091 for (i = 0; i < page_count; i++) { 4087 for (i = 0; i < page_count; i++) {
4092 struct page *page = read_cache_page_gfp(mapping, i, 4088 struct page *page = shmem_read_mapping_page(mapping, i);
4093 GFP_HIGHUSER | __GFP_RECLAIMABLE);
4094 if (!IS_ERR(page)) { 4089 if (!IS_ERR(page)) {
4095 char *dst = kmap_atomic(page); 4090 char *dst = kmap_atomic(page);
4096 memcpy(dst, vaddr + i*PAGE_SIZE, PAGE_SIZE); 4091 memcpy(dst, vaddr + i*PAGE_SIZE, PAGE_SIZE);
@@ -4151,8 +4146,7 @@ i915_gem_attach_phys_object(struct drm_device *dev,
4151 struct page *page; 4146 struct page *page;
4152 char *dst, *src; 4147 char *dst, *src;
4153 4148
4154 page = read_cache_page_gfp(mapping, i, 4149 page = shmem_read_mapping_page(mapping, i);
4155 GFP_HIGHUSER | __GFP_RECLAIMABLE);
4156 if (IS_ERR(page)) 4150 if (IS_ERR(page))
4157 return PTR_ERR(page); 4151 return PTR_ERR(page);
4158 4152
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index 445af7981637..12d2fdc52414 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -2013,9 +2013,9 @@ static void evergreen_gpu_init(struct radeon_device *rdev)
2013 rdev->config.evergreen.tile_config |= (3 << 0); 2013 rdev->config.evergreen.tile_config |= (3 << 0);
2014 break; 2014 break;
2015 } 2015 }
2016 /* num banks is 8 on all fusion asics */ 2016 /* num banks is 8 on all fusion asics. 0 = 4, 1 = 8, 2 = 16 */
2017 if (rdev->flags & RADEON_IS_IGP) 2017 if (rdev->flags & RADEON_IS_IGP)
2018 rdev->config.evergreen.tile_config |= 8 << 4; 2018 rdev->config.evergreen.tile_config |= 1 << 4;
2019 else 2019 else
2020 rdev->config.evergreen.tile_config |= 2020 rdev->config.evergreen.tile_config |=
2021 ((mc_arb_ramcfg & NOOFBANK_MASK) >> NOOFBANK_SHIFT) << 4; 2021 ((mc_arb_ramcfg & NOOFBANK_MASK) >> NOOFBANK_SHIFT) << 4;
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 27f45579e64b..ef0e0e016914 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -179,6 +179,7 @@ void radeon_pm_resume(struct radeon_device *rdev);
179void radeon_combios_get_power_modes(struct radeon_device *rdev); 179void radeon_combios_get_power_modes(struct radeon_device *rdev);
180void radeon_atombios_get_power_modes(struct radeon_device *rdev); 180void radeon_atombios_get_power_modes(struct radeon_device *rdev);
181void radeon_atom_set_voltage(struct radeon_device *rdev, u16 voltage_level, u8 voltage_type); 181void radeon_atom_set_voltage(struct radeon_device *rdev, u16 voltage_level, u8 voltage_type);
182int radeon_atom_get_max_vddc(struct radeon_device *rdev, u16 *voltage);
182void rs690_pm_info(struct radeon_device *rdev); 183void rs690_pm_info(struct radeon_device *rdev);
183extern int rv6xx_get_temp(struct radeon_device *rdev); 184extern int rv6xx_get_temp(struct radeon_device *rdev);
184extern int rv770_get_temp(struct radeon_device *rdev); 185extern int rv770_get_temp(struct radeon_device *rdev);
diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c
index 1e725d9f767f..bf2b61584cdb 100644
--- a/drivers/gpu/drm/radeon/radeon_atombios.c
+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
@@ -2320,6 +2320,14 @@ static bool radeon_atombios_parse_pplib_clock_info(struct radeon_device *rdev,
2320 le16_to_cpu(clock_info->r600.usVDDC); 2320 le16_to_cpu(clock_info->r600.usVDDC);
2321 } 2321 }
2322 2322
2323 /* patch up vddc if necessary */
2324 if (rdev->pm.power_state[state_index].clock_info[mode_index].voltage.voltage == 0xff01) {
2325 u16 vddc;
2326
2327 if (radeon_atom_get_max_vddc(rdev, &vddc) == 0)
2328 rdev->pm.power_state[state_index].clock_info[mode_index].voltage.voltage = vddc;
2329 }
2330
2323 if (rdev->flags & RADEON_IS_IGP) { 2331 if (rdev->flags & RADEON_IS_IGP) {
2324 /* skip invalid modes */ 2332 /* skip invalid modes */
2325 if (rdev->pm.power_state[state_index].clock_info[mode_index].sclk == 0) 2333 if (rdev->pm.power_state[state_index].clock_info[mode_index].sclk == 0)
@@ -2630,7 +2638,35 @@ void radeon_atom_set_voltage(struct radeon_device *rdev, u16 voltage_level, u8 v
2630 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); 2638 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
2631} 2639}
2632 2640
2641int radeon_atom_get_max_vddc(struct radeon_device *rdev,
2642 u16 *voltage)
2643{
2644 union set_voltage args;
2645 int index = GetIndexIntoMasterTable(COMMAND, SetVoltage);
2646 u8 frev, crev;
2647
2648 if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev))
2649 return -EINVAL;
2650
2651 switch (crev) {
2652 case 1:
2653 return -EINVAL;
2654 case 2:
2655 args.v2.ucVoltageType = SET_VOLTAGE_GET_MAX_VOLTAGE;
2656 args.v2.ucVoltageMode = 0;
2657 args.v2.usVoltageLevel = 0;
2658
2659 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
2660
2661 *voltage = le16_to_cpu(args.v2.usVoltageLevel);
2662 break;
2663 default:
2664 DRM_ERROR("Unknown table version %d, %d\n", frev, crev);
2665 return -EINVAL;
2666 }
2633 2667
2668 return 0;
2669}
2634 2670
2635void radeon_atom_initialize_bios_scratch_regs(struct drm_device *dev) 2671void radeon_atom_initialize_bios_scratch_regs(struct drm_device *dev)
2636{ 2672{
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index 90e23e0bfadb..58c271ebc0f7 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -31,6 +31,7 @@
31#include <linux/sched.h> 31#include <linux/sched.h>
32#include <linux/highmem.h> 32#include <linux/highmem.h>
33#include <linux/pagemap.h> 33#include <linux/pagemap.h>
34#include <linux/shmem_fs.h>
34#include <linux/file.h> 35#include <linux/file.h>
35#include <linux/swap.h> 36#include <linux/swap.h>
36#include <linux/slab.h> 37#include <linux/slab.h>
@@ -484,7 +485,7 @@ static int ttm_tt_swapin(struct ttm_tt *ttm)
484 swap_space = swap_storage->f_path.dentry->d_inode->i_mapping; 485 swap_space = swap_storage->f_path.dentry->d_inode->i_mapping;
485 486
486 for (i = 0; i < ttm->num_pages; ++i) { 487 for (i = 0; i < ttm->num_pages; ++i) {
487 from_page = read_mapping_page(swap_space, i, NULL); 488 from_page = shmem_read_mapping_page(swap_space, i);
488 if (IS_ERR(from_page)) { 489 if (IS_ERR(from_page)) {
489 ret = PTR_ERR(from_page); 490 ret = PTR_ERR(from_page);
490 goto out_err; 491 goto out_err;
@@ -557,7 +558,7 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage)
557 from_page = ttm->pages[i]; 558 from_page = ttm->pages[i];
558 if (unlikely(from_page == NULL)) 559 if (unlikely(from_page == NULL))
559 continue; 560 continue;
560 to_page = read_mapping_page(swap_space, i, NULL); 561 to_page = shmem_read_mapping_page(swap_space, i);
561 if (unlikely(IS_ERR(to_page))) { 562 if (unlikely(IS_ERR(to_page))) {
562 ret = PTR_ERR(to_page); 563 ret = PTR_ERR(to_page);
563 goto out_err; 564 goto out_err;
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index f7440e8ce3e7..6f3289a57888 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1423,6 +1423,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
1423 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACETRAVELLER) }, 1423 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACETRAVELLER) },
1424 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACENAVIGATOR) }, 1424 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACENAVIGATOR) },
1425 { HID_USB_DEVICE(USB_VENDOR_ID_LUMIO, USB_DEVICE_ID_CRYSTALTOUCH) }, 1425 { HID_USB_DEVICE(USB_VENDOR_ID_LUMIO, USB_DEVICE_ID_CRYSTALTOUCH) },
1426 { HID_USB_DEVICE(USB_VENDOR_ID_LUMIO, USB_DEVICE_ID_CRYSTALTOUCH_DUAL) },
1426 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD) }, 1427 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD) },
1427 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD_BOOTLOADER) }, 1428 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD_BOOTLOADER) },
1428 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) }, 1429 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) },
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index aecb5a4b8d6d..a756ee6c7df5 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -449,6 +449,7 @@
449 449
450#define USB_VENDOR_ID_LUMIO 0x202e 450#define USB_VENDOR_ID_LUMIO 0x202e
451#define USB_DEVICE_ID_CRYSTALTOUCH 0x0006 451#define USB_DEVICE_ID_CRYSTALTOUCH 0x0006
452#define USB_DEVICE_ID_CRYSTALTOUCH_DUAL 0x0007
452 453
453#define USB_VENDOR_ID_MCC 0x09db 454#define USB_VENDOR_ID_MCC 0x09db
454#define USB_DEVICE_ID_MCC_PMD1024LS 0x0076 455#define USB_DEVICE_ID_MCC_PMD1024LS 0x0076
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 0b2dcd0ee591..62cac4dc3b62 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -271,6 +271,8 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
271 } 271 }
272 return 1; 272 return 1;
273 case HID_DG_CONTACTID: 273 case HID_DG_CONTACTID:
274 if (!td->maxcontacts)
275 td->maxcontacts = MT_DEFAULT_MAXCONTACT;
274 input_mt_init_slots(hi->input, td->maxcontacts); 276 input_mt_init_slots(hi->input, td->maxcontacts);
275 td->last_slot_field = usage->hid; 277 td->last_slot_field = usage->hid;
276 td->last_field_index = field->index; 278 td->last_field_index = field->index;
@@ -547,9 +549,6 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
547 if (ret) 549 if (ret)
548 goto fail; 550 goto fail;
549 551
550 if (!td->maxcontacts)
551 td->maxcontacts = MT_DEFAULT_MAXCONTACT;
552
553 td->slots = kzalloc(td->maxcontacts * sizeof(struct mt_slot), 552 td->slots = kzalloc(td->maxcontacts * sizeof(struct mt_slot),
554 GFP_KERNEL); 553 GFP_KERNEL);
555 if (!td->slots) { 554 if (!td->slots) {
@@ -677,6 +676,9 @@ static const struct hid_device_id mt_devices[] = {
677 { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, 676 { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
678 HID_USB_DEVICE(USB_VENDOR_ID_LUMIO, 677 HID_USB_DEVICE(USB_VENDOR_ID_LUMIO,
679 USB_DEVICE_ID_CRYSTALTOUCH) }, 678 USB_DEVICE_ID_CRYSTALTOUCH) },
679 { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
680 HID_USB_DEVICE(USB_VENDOR_ID_LUMIO,
681 USB_DEVICE_ID_CRYSTALTOUCH_DUAL) },
680 682
681 /* MosArt panels */ 683 /* MosArt panels */
682 { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, 684 { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
@@ -707,10 +709,10 @@ static const struct hid_device_id mt_devices[] = {
707 HID_USB_DEVICE(USB_VENDOR_ID_STANTUM, 709 HID_USB_DEVICE(USB_VENDOR_ID_STANTUM,
708 USB_DEVICE_ID_MTP)}, 710 USB_DEVICE_ID_MTP)},
709 { .driver_data = MT_CLS_CONFIDENCE, 711 { .driver_data = MT_CLS_CONFIDENCE,
710 HID_USB_DEVICE(USB_VENDOR_ID_STANTUM, 712 HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM,
711 USB_DEVICE_ID_MTP_STM)}, 713 USB_DEVICE_ID_MTP_STM)},
712 { .driver_data = MT_CLS_CONFIDENCE, 714 { .driver_data = MT_CLS_CONFIDENCE,
713 HID_USB_DEVICE(USB_VENDOR_ID_STANTUM, 715 HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_SITRONIX,
714 USB_DEVICE_ID_MTP_SITRONIX)}, 716 USB_DEVICE_ID_MTP_SITRONIX)},
715 717
716 /* Touch International panels */ 718 /* Touch International panels */
diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index f660cd04ec2f..31fb44085c9b 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -1463,9 +1463,9 @@ static int peer_close(struct c4iw_dev *dev, struct sk_buff *skb)
1463 struct c4iw_qp_attributes attrs; 1463 struct c4iw_qp_attributes attrs;
1464 int disconnect = 1; 1464 int disconnect = 1;
1465 int release = 0; 1465 int release = 0;
1466 int abort = 0;
1467 struct tid_info *t = dev->rdev.lldi.tids; 1466 struct tid_info *t = dev->rdev.lldi.tids;
1468 unsigned int tid = GET_TID(hdr); 1467 unsigned int tid = GET_TID(hdr);
1468 int ret;
1469 1469
1470 ep = lookup_tid(t, tid); 1470 ep = lookup_tid(t, tid);
1471 PDBG("%s ep %p tid %u\n", __func__, ep, ep->hwtid); 1471 PDBG("%s ep %p tid %u\n", __func__, ep, ep->hwtid);
@@ -1501,10 +1501,12 @@ static int peer_close(struct c4iw_dev *dev, struct sk_buff *skb)
1501 start_ep_timer(ep); 1501 start_ep_timer(ep);
1502 __state_set(&ep->com, CLOSING); 1502 __state_set(&ep->com, CLOSING);
1503 attrs.next_state = C4IW_QP_STATE_CLOSING; 1503 attrs.next_state = C4IW_QP_STATE_CLOSING;
1504 abort = c4iw_modify_qp(ep->com.qp->rhp, ep->com.qp, 1504 ret = c4iw_modify_qp(ep->com.qp->rhp, ep->com.qp,
1505 C4IW_QP_ATTR_NEXT_STATE, &attrs, 1); 1505 C4IW_QP_ATTR_NEXT_STATE, &attrs, 1);
1506 peer_close_upcall(ep); 1506 if (ret != -ECONNRESET) {
1507 disconnect = 1; 1507 peer_close_upcall(ep);
1508 disconnect = 1;
1509 }
1508 break; 1510 break;
1509 case ABORTING: 1511 case ABORTING:
1510 disconnect = 0; 1512 disconnect = 0;
@@ -2109,15 +2111,16 @@ int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp)
2109 break; 2111 break;
2110 } 2112 }
2111 2113
2112 mutex_unlock(&ep->com.mutex);
2113 if (close) { 2114 if (close) {
2114 if (abrupt) 2115 if (abrupt) {
2115 ret = abort_connection(ep, NULL, gfp); 2116 close_complete_upcall(ep);
2116 else 2117 ret = send_abort(ep, NULL, gfp);
2118 } else
2117 ret = send_halfclose(ep, gfp); 2119 ret = send_halfclose(ep, gfp);
2118 if (ret) 2120 if (ret)
2119 fatal = 1; 2121 fatal = 1;
2120 } 2122 }
2123 mutex_unlock(&ep->com.mutex);
2121 if (fatal) 2124 if (fatal)
2122 release_ep_resources(ep); 2125 release_ep_resources(ep);
2123 return ret; 2126 return ret;
@@ -2301,6 +2304,31 @@ static int fw6_msg(struct c4iw_dev *dev, struct sk_buff *skb)
2301 return 0; 2304 return 0;
2302} 2305}
2303 2306
2307static int peer_abort_intr(struct c4iw_dev *dev, struct sk_buff *skb)
2308{
2309 struct cpl_abort_req_rss *req = cplhdr(skb);
2310 struct c4iw_ep *ep;
2311 struct tid_info *t = dev->rdev.lldi.tids;
2312 unsigned int tid = GET_TID(req);
2313
2314 ep = lookup_tid(t, tid);
2315 if (is_neg_adv_abort(req->status)) {
2316 PDBG("%s neg_adv_abort ep %p tid %u\n", __func__, ep,
2317 ep->hwtid);
2318 kfree_skb(skb);
2319 return 0;
2320 }
2321 PDBG("%s ep %p tid %u state %u\n", __func__, ep, ep->hwtid,
2322 ep->com.state);
2323
2324 /*
2325 * Wake up any threads in rdma_init() or rdma_fini().
2326 */
2327 c4iw_wake_up(&ep->com.wr_wait, -ECONNRESET);
2328 sched(dev, skb);
2329 return 0;
2330}
2331
2304/* 2332/*
2305 * Most upcalls from the T4 Core go to sched() to 2333 * Most upcalls from the T4 Core go to sched() to
2306 * schedule the processing on a work queue. 2334 * schedule the processing on a work queue.
@@ -2317,7 +2345,7 @@ c4iw_handler_func c4iw_handlers[NUM_CPL_CMDS] = {
2317 [CPL_PASS_ESTABLISH] = sched, 2345 [CPL_PASS_ESTABLISH] = sched,
2318 [CPL_PEER_CLOSE] = sched, 2346 [CPL_PEER_CLOSE] = sched,
2319 [CPL_CLOSE_CON_RPL] = sched, 2347 [CPL_CLOSE_CON_RPL] = sched,
2320 [CPL_ABORT_REQ_RSS] = sched, 2348 [CPL_ABORT_REQ_RSS] = peer_abort_intr,
2321 [CPL_RDMA_TERMINATE] = sched, 2349 [CPL_RDMA_TERMINATE] = sched,
2322 [CPL_FW4_ACK] = sched, 2350 [CPL_FW4_ACK] = sched,
2323 [CPL_SET_TCB_RPL] = set_tcb_rpl, 2351 [CPL_SET_TCB_RPL] = set_tcb_rpl,
diff --git a/drivers/infiniband/hw/cxgb4/cq.c b/drivers/infiniband/hw/cxgb4/cq.c
index 8d8f8add6fcd..1720dc790d13 100644
--- a/drivers/infiniband/hw/cxgb4/cq.c
+++ b/drivers/infiniband/hw/cxgb4/cq.c
@@ -801,6 +801,10 @@ struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, int entries,
801 if (ucontext) { 801 if (ucontext) {
802 memsize = roundup(memsize, PAGE_SIZE); 802 memsize = roundup(memsize, PAGE_SIZE);
803 hwentries = memsize / sizeof *chp->cq.queue; 803 hwentries = memsize / sizeof *chp->cq.queue;
804 while (hwentries > T4_MAX_IQ_SIZE) {
805 memsize -= PAGE_SIZE;
806 hwentries = memsize / sizeof *chp->cq.queue;
807 }
804 } 808 }
805 chp->cq.size = hwentries; 809 chp->cq.size = hwentries;
806 chp->cq.memsize = memsize; 810 chp->cq.memsize = memsize;
diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
index 273ffe49525a..0347eed4a167 100644
--- a/drivers/infiniband/hw/cxgb4/mem.c
+++ b/drivers/infiniband/hw/cxgb4/mem.c
@@ -625,7 +625,7 @@ pbl_done:
625 mhp->attr.perms = c4iw_ib_to_tpt_access(acc); 625 mhp->attr.perms = c4iw_ib_to_tpt_access(acc);
626 mhp->attr.va_fbo = virt; 626 mhp->attr.va_fbo = virt;
627 mhp->attr.page_size = shift - 12; 627 mhp->attr.page_size = shift - 12;
628 mhp->attr.len = (u32) length; 628 mhp->attr.len = length;
629 629
630 err = register_mem(rhp, php, mhp, shift); 630 err = register_mem(rhp, php, mhp, shift);
631 if (err) 631 if (err)
diff --git a/drivers/infiniband/hw/cxgb4/qp.c b/drivers/infiniband/hw/cxgb4/qp.c
index 3b773b05a898..a41578e48c7b 100644
--- a/drivers/infiniband/hw/cxgb4/qp.c
+++ b/drivers/infiniband/hw/cxgb4/qp.c
@@ -1207,11 +1207,8 @@ int c4iw_modify_qp(struct c4iw_dev *rhp, struct c4iw_qp *qhp,
1207 c4iw_get_ep(&qhp->ep->com); 1207 c4iw_get_ep(&qhp->ep->com);
1208 } 1208 }
1209 ret = rdma_fini(rhp, qhp, ep); 1209 ret = rdma_fini(rhp, qhp, ep);
1210 if (ret) { 1210 if (ret)
1211 if (internal)
1212 c4iw_get_ep(&qhp->ep->com);
1213 goto err; 1211 goto err;
1214 }
1215 break; 1212 break;
1216 case C4IW_QP_STATE_TERMINATE: 1213 case C4IW_QP_STATE_TERMINATE:
1217 set_state(qhp, C4IW_QP_STATE_TERMINATE); 1214 set_state(qhp, C4IW_QP_STATE_TERMINATE);
diff --git a/drivers/infiniband/hw/qib/qib_iba7322.c b/drivers/infiniband/hw/qib/qib_iba7322.c
index 9f53e68a096a..8ec5237031a0 100644
--- a/drivers/infiniband/hw/qib/qib_iba7322.c
+++ b/drivers/infiniband/hw/qib/qib_iba7322.c
@@ -469,6 +469,8 @@ static u8 ib_rate_to_delay[IB_RATE_120_GBPS + 1] = {
469#define IB_7322_LT_STATE_RECOVERIDLE 0x0f 469#define IB_7322_LT_STATE_RECOVERIDLE 0x0f
470#define IB_7322_LT_STATE_CFGENH 0x10 470#define IB_7322_LT_STATE_CFGENH 0x10
471#define IB_7322_LT_STATE_CFGTEST 0x11 471#define IB_7322_LT_STATE_CFGTEST 0x11
472#define IB_7322_LT_STATE_CFGWAITRMTTEST 0x12
473#define IB_7322_LT_STATE_CFGWAITENH 0x13
472 474
473/* link state machine states from IBC */ 475/* link state machine states from IBC */
474#define IB_7322_L_STATE_DOWN 0x0 476#define IB_7322_L_STATE_DOWN 0x0
@@ -498,8 +500,10 @@ static const u8 qib_7322_physportstate[0x20] = {
498 IB_PHYSPORTSTATE_LINK_ERR_RECOVER, 500 IB_PHYSPORTSTATE_LINK_ERR_RECOVER,
499 [IB_7322_LT_STATE_CFGENH] = IB_PHYSPORTSTATE_CFG_ENH, 501 [IB_7322_LT_STATE_CFGENH] = IB_PHYSPORTSTATE_CFG_ENH,
500 [IB_7322_LT_STATE_CFGTEST] = IB_PHYSPORTSTATE_CFG_TRAIN, 502 [IB_7322_LT_STATE_CFGTEST] = IB_PHYSPORTSTATE_CFG_TRAIN,
501 [0x12] = IB_PHYSPORTSTATE_CFG_TRAIN, 503 [IB_7322_LT_STATE_CFGWAITRMTTEST] =
502 [0x13] = IB_PHYSPORTSTATE_CFG_WAIT_ENH, 504 IB_PHYSPORTSTATE_CFG_TRAIN,
505 [IB_7322_LT_STATE_CFGWAITENH] =
506 IB_PHYSPORTSTATE_CFG_WAIT_ENH,
503 [0x14] = IB_PHYSPORTSTATE_CFG_TRAIN, 507 [0x14] = IB_PHYSPORTSTATE_CFG_TRAIN,
504 [0x15] = IB_PHYSPORTSTATE_CFG_TRAIN, 508 [0x15] = IB_PHYSPORTSTATE_CFG_TRAIN,
505 [0x16] = IB_PHYSPORTSTATE_CFG_TRAIN, 509 [0x16] = IB_PHYSPORTSTATE_CFG_TRAIN,
@@ -1692,7 +1696,9 @@ static void handle_serdes_issues(struct qib_pportdata *ppd, u64 ibcst)
1692 break; 1696 break;
1693 } 1697 }
1694 1698
1695 if (ibclt == IB_7322_LT_STATE_CFGTEST && 1699 if (((ibclt >= IB_7322_LT_STATE_CFGTEST &&
1700 ibclt <= IB_7322_LT_STATE_CFGWAITENH) ||
1701 ibclt == IB_7322_LT_STATE_LINKUP) &&
1696 (ibcst & SYM_MASK(IBCStatusA_0, LinkSpeedQDR))) { 1702 (ibcst & SYM_MASK(IBCStatusA_0, LinkSpeedQDR))) {
1697 force_h1(ppd); 1703 force_h1(ppd);
1698 ppd->cpspec->qdr_reforce = 1; 1704 ppd->cpspec->qdr_reforce = 1;
@@ -7301,12 +7307,17 @@ static void ibsd_wr_allchans(struct qib_pportdata *ppd, int addr, unsigned data,
7301static void serdes_7322_los_enable(struct qib_pportdata *ppd, int enable) 7307static void serdes_7322_los_enable(struct qib_pportdata *ppd, int enable)
7302{ 7308{
7303 u64 data = qib_read_kreg_port(ppd, krp_serdesctrl); 7309 u64 data = qib_read_kreg_port(ppd, krp_serdesctrl);
7304 printk(KERN_INFO QIB_DRV_NAME " IB%u:%u Turning LOS %s\n", 7310 u8 state = SYM_FIELD(data, IBSerdesCtrl_0, RXLOSEN);
7305 ppd->dd->unit, ppd->port, (enable ? "on" : "off")); 7311
7306 if (enable) 7312 if (enable && !state) {
7313 printk(KERN_INFO QIB_DRV_NAME " IB%u:%u Turning LOS on\n",
7314 ppd->dd->unit, ppd->port);
7307 data |= SYM_MASK(IBSerdesCtrl_0, RXLOSEN); 7315 data |= SYM_MASK(IBSerdesCtrl_0, RXLOSEN);
7308 else 7316 } else if (!enable && state) {
7317 printk(KERN_INFO QIB_DRV_NAME " IB%u:%u Turning LOS off\n",
7318 ppd->dd->unit, ppd->port);
7309 data &= ~SYM_MASK(IBSerdesCtrl_0, RXLOSEN); 7319 data &= ~SYM_MASK(IBSerdesCtrl_0, RXLOSEN);
7320 }
7310 qib_write_kreg_port(ppd, krp_serdesctrl, data); 7321 qib_write_kreg_port(ppd, krp_serdesctrl, data);
7311} 7322}
7312 7323
diff --git a/drivers/infiniband/hw/qib/qib_intr.c b/drivers/infiniband/hw/qib/qib_intr.c
index a693c56ec8a6..6ae57d23004a 100644
--- a/drivers/infiniband/hw/qib/qib_intr.c
+++ b/drivers/infiniband/hw/qib/qib_intr.c
@@ -96,8 +96,12 @@ void qib_handle_e_ibstatuschanged(struct qib_pportdata *ppd, u64 ibcs)
96 * states, or if it transitions from any of the up (INIT or better) 96 * states, or if it transitions from any of the up (INIT or better)
97 * states into any of the down states (except link recovery), then 97 * states into any of the down states (except link recovery), then
98 * call the chip-specific code to take appropriate actions. 98 * call the chip-specific code to take appropriate actions.
99 *
100 * ppd->lflags could be 0 if this is the first time the interrupt
101 * handlers has been called but the link is already up.
99 */ 102 */
100 if (lstate >= IB_PORT_INIT && (ppd->lflags & QIBL_LINKDOWN) && 103 if (lstate >= IB_PORT_INIT &&
104 (!ppd->lflags || (ppd->lflags & QIBL_LINKDOWN)) &&
101 ltstate == IB_PHYSPORTSTATE_LINKUP) { 105 ltstate == IB_PHYSPORTSTATE_LINKUP) {
102 /* transitioned to UP */ 106 /* transitioned to UP */
103 if (dd->f_ib_updown(ppd, 1, ibcs)) 107 if (dd->f_ib_updown(ppd, 1, ibcs))
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
index c0cff64a1ae6..cc1dc4817fac 100644
--- a/drivers/leds/leds-lp5521.c
+++ b/drivers/leds/leds-lp5521.c
@@ -593,7 +593,7 @@ static void lp5521_unregister_sysfs(struct i2c_client *client)
593 &lp5521_led_attribute_group); 593 &lp5521_led_attribute_group);
594} 594}
595 595
596static int __init lp5521_init_led(struct lp5521_led *led, 596static int __devinit lp5521_init_led(struct lp5521_led *led,
597 struct i2c_client *client, 597 struct i2c_client *client,
598 int chan, struct lp5521_platform_data *pdata) 598 int chan, struct lp5521_platform_data *pdata)
599{ 599{
@@ -637,7 +637,7 @@ static int __init lp5521_init_led(struct lp5521_led *led,
637 return 0; 637 return 0;
638} 638}
639 639
640static int lp5521_probe(struct i2c_client *client, 640static int __devinit lp5521_probe(struct i2c_client *client,
641 const struct i2c_device_id *id) 641 const struct i2c_device_id *id)
642{ 642{
643 struct lp5521_chip *chip; 643 struct lp5521_chip *chip;
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c
index e19fed25f137..5971e309b234 100644
--- a/drivers/leds/leds-lp5523.c
+++ b/drivers/leds/leds-lp5523.c
@@ -826,7 +826,7 @@ static int __init lp5523_init_engine(struct lp5523_engine *engine, int id)
826 return 0; 826 return 0;
827} 827}
828 828
829static int __init lp5523_init_led(struct lp5523_led *led, struct device *dev, 829static int __devinit lp5523_init_led(struct lp5523_led *led, struct device *dev,
830 int chan, struct lp5523_platform_data *pdata) 830 int chan, struct lp5523_platform_data *pdata)
831{ 831{
832 char name[32]; 832 char name[32];
@@ -872,7 +872,7 @@ static int __init lp5523_init_led(struct lp5523_led *led, struct device *dev,
872 872
873static struct i2c_driver lp5523_driver; 873static struct i2c_driver lp5523_driver;
874 874
875static int lp5523_probe(struct i2c_client *client, 875static int __devinit lp5523_probe(struct i2c_client *client,
876 const struct i2c_device_id *id) 876 const struct i2c_device_id *id)
877{ 877{
878 struct lp5523_chip *chip; 878 struct lp5523_chip *chip;
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 4332fc2f25d4..91e31e260b4a 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -7088,6 +7088,7 @@ static int remove_and_add_spares(mddev_t *mddev)
7088 list_for_each_entry(rdev, &mddev->disks, same_set) { 7088 list_for_each_entry(rdev, &mddev->disks, same_set) {
7089 if (rdev->raid_disk >= 0 && 7089 if (rdev->raid_disk >= 0 &&
7090 !test_bit(In_sync, &rdev->flags) && 7090 !test_bit(In_sync, &rdev->flags) &&
7091 !test_bit(Faulty, &rdev->flags) &&
7091 !test_bit(Blocked, &rdev->flags)) 7092 !test_bit(Blocked, &rdev->flags))
7092 spares++; 7093 spares++;
7093 if (rdev->raid_disk < 0 7094 if (rdev->raid_disk < 0
diff --git a/drivers/misc/cb710/sgbuf2.c b/drivers/misc/cb710/sgbuf2.c
index d019746551f3..2a40d0efdff5 100644
--- a/drivers/misc/cb710/sgbuf2.c
+++ b/drivers/misc/cb710/sgbuf2.c
@@ -47,7 +47,7 @@ static uint32_t sg_dwiter_read_buffer(struct sg_mapping_iter *miter)
47 47
48static inline bool needs_unaligned_copy(const void *ptr) 48static inline bool needs_unaligned_copy(const void *ptr)
49{ 49{
50#ifdef HAVE_EFFICIENT_UNALIGNED_ACCESS 50#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
51 return false; 51 return false;
52#else 52#else
53 return ((ptr - NULL) & 3) != 0; 53 return ((ptr - NULL) & 3) != 0;
diff --git a/drivers/misc/ioc4.c b/drivers/misc/ioc4.c
index 668d41e594a9..df03dd3bd0e2 100644
--- a/drivers/misc/ioc4.c
+++ b/drivers/misc/ioc4.c
@@ -270,7 +270,7 @@ ioc4_variant(struct ioc4_driver_data *idd)
270 return IOC4_VARIANT_PCI_RT; 270 return IOC4_VARIANT_PCI_RT;
271} 271}
272 272
273static void __devinit 273static void
274ioc4_load_modules(struct work_struct *work) 274ioc4_load_modules(struct work_struct *work)
275{ 275{
276 request_module("sgiioc4"); 276 request_module("sgiioc4");
diff --git a/drivers/misc/lkdtm.c b/drivers/misc/lkdtm.c
index 81d7fa4ec0db..150cd7061b80 100644
--- a/drivers/misc/lkdtm.c
+++ b/drivers/misc/lkdtm.c
@@ -120,6 +120,7 @@ static int recur_count = REC_NUM_DEFAULT;
120static enum cname cpoint = CN_INVALID; 120static enum cname cpoint = CN_INVALID;
121static enum ctype cptype = CT_NONE; 121static enum ctype cptype = CT_NONE;
122static int count = DEFAULT_COUNT; 122static int count = DEFAULT_COUNT;
123static DEFINE_SPINLOCK(count_lock);
123 124
124module_param(recur_count, int, 0644); 125module_param(recur_count, int, 0644);
125MODULE_PARM_DESC(recur_count, " Recursion level for the stack overflow test, "\ 126MODULE_PARM_DESC(recur_count, " Recursion level for the stack overflow test, "\
@@ -230,11 +231,14 @@ static const char *cp_name_to_str(enum cname name)
230static int lkdtm_parse_commandline(void) 231static int lkdtm_parse_commandline(void)
231{ 232{
232 int i; 233 int i;
234 unsigned long flags;
233 235
234 if (cpoint_count < 1 || recur_count < 1) 236 if (cpoint_count < 1 || recur_count < 1)
235 return -EINVAL; 237 return -EINVAL;
236 238
239 spin_lock_irqsave(&count_lock, flags);
237 count = cpoint_count; 240 count = cpoint_count;
241 spin_unlock_irqrestore(&count_lock, flags);
238 242
239 /* No special parameters */ 243 /* No special parameters */
240 if (!cpoint_type && !cpoint_name) 244 if (!cpoint_type && !cpoint_name)
@@ -349,6 +353,9 @@ static void lkdtm_do_action(enum ctype which)
349 353
350static void lkdtm_handler(void) 354static void lkdtm_handler(void)
351{ 355{
356 unsigned long flags;
357
358 spin_lock_irqsave(&count_lock, flags);
352 count--; 359 count--;
353 printk(KERN_INFO "lkdtm: Crash point %s of type %s hit, trigger in %d rounds\n", 360 printk(KERN_INFO "lkdtm: Crash point %s of type %s hit, trigger in %d rounds\n",
354 cp_name_to_str(cpoint), cp_type_to_str(cptype), count); 361 cp_name_to_str(cpoint), cp_type_to_str(cptype), count);
@@ -357,6 +364,7 @@ static void lkdtm_handler(void)
357 lkdtm_do_action(cptype); 364 lkdtm_do_action(cptype);
358 count = cpoint_count; 365 count = cpoint_count;
359 } 366 }
367 spin_unlock_irqrestore(&count_lock, flags);
360} 368}
361 369
362static int lkdtm_register_cpoint(enum cname which) 370static int lkdtm_register_cpoint(enum cname which)
diff --git a/drivers/misc/pti.c b/drivers/misc/pti.c
index bb6f9255c17c..374dfcfccd07 100644
--- a/drivers/misc/pti.c
+++ b/drivers/misc/pti.c
@@ -317,7 +317,8 @@ EXPORT_SYMBOL_GPL(pti_request_masterchannel);
317 * a master, channel ID address 317 * a master, channel ID address
318 * used to write to PTI HW. 318 * used to write to PTI HW.
319 * 319 *
320 * @mc: master, channel apeture ID address to be released. 320 * @mc: master, channel apeture ID address to be released. This
321 * will de-allocate the structure via kfree().
321 */ 322 */
322void pti_release_masterchannel(struct pti_masterchannel *mc) 323void pti_release_masterchannel(struct pti_masterchannel *mc)
323{ 324{
@@ -475,8 +476,10 @@ static int pti_tty_install(struct tty_driver *driver, struct tty_struct *tty)
475 else 476 else
476 pti_tty_data->mc = pti_request_masterchannel(2); 477 pti_tty_data->mc = pti_request_masterchannel(2);
477 478
478 if (pti_tty_data->mc == NULL) 479 if (pti_tty_data->mc == NULL) {
480 kfree(pti_tty_data);
479 return -ENXIO; 481 return -ENXIO;
482 }
480 tty->driver_data = pti_tty_data; 483 tty->driver_data = pti_tty_data;
481 } 484 }
482 485
@@ -495,7 +498,7 @@ static void pti_tty_cleanup(struct tty_struct *tty)
495 if (pti_tty_data == NULL) 498 if (pti_tty_data == NULL)
496 return; 499 return;
497 pti_release_masterchannel(pti_tty_data->mc); 500 pti_release_masterchannel(pti_tty_data->mc);
498 kfree(tty->driver_data); 501 kfree(pti_tty_data);
499 tty->driver_data = NULL; 502 tty->driver_data = NULL;
500} 503}
501 504
@@ -581,7 +584,7 @@ static int pti_char_open(struct inode *inode, struct file *filp)
581static int pti_char_release(struct inode *inode, struct file *filp) 584static int pti_char_release(struct inode *inode, struct file *filp)
582{ 585{
583 pti_release_masterchannel(filp->private_data); 586 pti_release_masterchannel(filp->private_data);
584 kfree(filp->private_data); 587 filp->private_data = NULL;
585 return 0; 588 return 0;
586} 589}
587 590
diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c
index f91f82eabda7..54c91ffe4a91 100644
--- a/drivers/misc/ti-st/st_core.c
+++ b/drivers/misc/ti-st/st_core.c
@@ -605,7 +605,7 @@ long st_unregister(struct st_proto_s *proto)
605 pr_debug("%s: %d ", __func__, proto->chnl_id); 605 pr_debug("%s: %d ", __func__, proto->chnl_id);
606 606
607 st_kim_ref(&st_gdata, 0); 607 st_kim_ref(&st_gdata, 0);
608 if (proto->chnl_id >= ST_MAX_CHANNELS) { 608 if (!st_gdata || proto->chnl_id >= ST_MAX_CHANNELS) {
609 pr_err(" chnl_id %d not supported", proto->chnl_id); 609 pr_err(" chnl_id %d not supported", proto->chnl_id);
610 return -EPROTONOSUPPORT; 610 return -EPROTONOSUPPORT;
611 } 611 }
diff --git a/drivers/misc/ti-st/st_kim.c b/drivers/misc/ti-st/st_kim.c
index 5da93ee6f6be..38fd2f04c07e 100644
--- a/drivers/misc/ti-st/st_kim.c
+++ b/drivers/misc/ti-st/st_kim.c
@@ -245,9 +245,9 @@ void skip_change_remote_baud(unsigned char **ptr, long *len)
245 pr_err("invalid action after change remote baud command"); 245 pr_err("invalid action after change remote baud command");
246 } else { 246 } else {
247 *ptr = *ptr + sizeof(struct bts_action) + 247 *ptr = *ptr + sizeof(struct bts_action) +
248 ((struct bts_action *)nxt_action)->size; 248 ((struct bts_action *)cur_action)->size;
249 *len = *len - (sizeof(struct bts_action) + 249 *len = *len - (sizeof(struct bts_action) +
250 ((struct bts_action *)nxt_action)->size); 250 ((struct bts_action *)cur_action)->size);
251 /* warn user on not commenting these in firmware */ 251 /* warn user on not commenting these in firmware */
252 pr_warn("skipping the wait event of change remote baud"); 252 pr_warn("skipping the wait event of change remote baud");
253 } 253 }
@@ -604,6 +604,10 @@ void st_kim_ref(struct st_data_s **core_data, int id)
604 struct kim_data_s *kim_gdata; 604 struct kim_data_s *kim_gdata;
605 /* get kim_gdata reference from platform device */ 605 /* get kim_gdata reference from platform device */
606 pdev = st_get_plat_device(id); 606 pdev = st_get_plat_device(id);
607 if (!pdev) {
608 *core_data = NULL;
609 return;
610 }
607 kim_gdata = dev_get_drvdata(&pdev->dev); 611 kim_gdata = dev_get_drvdata(&pdev->dev);
608 *core_data = kim_gdata->core_data; 612 *core_data = kim_gdata->core_data;
609} 613}
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 71da5641e258..f85e42224559 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -1024,7 +1024,7 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
1024 INIT_LIST_HEAD(&md->part); 1024 INIT_LIST_HEAD(&md->part);
1025 md->usage = 1; 1025 md->usage = 1;
1026 1026
1027 ret = mmc_init_queue(&md->queue, card, &md->lock); 1027 ret = mmc_init_queue(&md->queue, card, &md->lock, subname);
1028 if (ret) 1028 if (ret)
1029 goto err_putdisk; 1029 goto err_putdisk;
1030 1030
@@ -1297,6 +1297,9 @@ static void mmc_blk_remove(struct mmc_card *card)
1297 struct mmc_blk_data *md = mmc_get_drvdata(card); 1297 struct mmc_blk_data *md = mmc_get_drvdata(card);
1298 1298
1299 mmc_blk_remove_parts(card, md); 1299 mmc_blk_remove_parts(card, md);
1300 mmc_claim_host(card->host);
1301 mmc_blk_part_switch(card, md);
1302 mmc_release_host(card->host);
1300 mmc_blk_remove_req(md); 1303 mmc_blk_remove_req(md);
1301 mmc_set_drvdata(card, NULL); 1304 mmc_set_drvdata(card, NULL);
1302} 1305}
diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c
index c07322c2658c..6413afa318d2 100644
--- a/drivers/mmc/card/queue.c
+++ b/drivers/mmc/card/queue.c
@@ -106,10 +106,12 @@ static void mmc_request(struct request_queue *q)
106 * @mq: mmc queue 106 * @mq: mmc queue
107 * @card: mmc card to attach this queue 107 * @card: mmc card to attach this queue
108 * @lock: queue lock 108 * @lock: queue lock
109 * @subname: partition subname
109 * 110 *
110 * Initialise a MMC card request queue. 111 * Initialise a MMC card request queue.
111 */ 112 */
112int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock) 113int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card,
114 spinlock_t *lock, const char *subname)
113{ 115{
114 struct mmc_host *host = card->host; 116 struct mmc_host *host = card->host;
115 u64 limit = BLK_BOUNCE_HIGH; 117 u64 limit = BLK_BOUNCE_HIGH;
@@ -133,12 +135,7 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock
133 mq->queue->limits.max_discard_sectors = UINT_MAX; 135 mq->queue->limits.max_discard_sectors = UINT_MAX;
134 if (card->erased_byte == 0) 136 if (card->erased_byte == 0)
135 mq->queue->limits.discard_zeroes_data = 1; 137 mq->queue->limits.discard_zeroes_data = 1;
136 if (!mmc_can_trim(card) && is_power_of_2(card->erase_size)) { 138 mq->queue->limits.discard_granularity = card->pref_erase << 9;
137 mq->queue->limits.discard_granularity =
138 card->erase_size << 9;
139 mq->queue->limits.discard_alignment =
140 card->erase_size << 9;
141 }
142 if (mmc_can_secure_erase_trim(card)) 139 if (mmc_can_secure_erase_trim(card))
143 queue_flag_set_unlocked(QUEUE_FLAG_SECDISCARD, 140 queue_flag_set_unlocked(QUEUE_FLAG_SECDISCARD,
144 mq->queue); 141 mq->queue);
@@ -209,8 +206,8 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock
209 206
210 sema_init(&mq->thread_sem, 1); 207 sema_init(&mq->thread_sem, 1);
211 208
212 mq->thread = kthread_run(mmc_queue_thread, mq, "mmcqd/%d", 209 mq->thread = kthread_run(mmc_queue_thread, mq, "mmcqd/%d%s",
213 host->index); 210 host->index, subname ? subname : "");
214 211
215 if (IS_ERR(mq->thread)) { 212 if (IS_ERR(mq->thread)) {
216 ret = PTR_ERR(mq->thread); 213 ret = PTR_ERR(mq->thread);
diff --git a/drivers/mmc/card/queue.h b/drivers/mmc/card/queue.h
index 64e66e0d4994..6223ef8dc9cd 100644
--- a/drivers/mmc/card/queue.h
+++ b/drivers/mmc/card/queue.h
@@ -19,7 +19,8 @@ struct mmc_queue {
19 unsigned int bounce_sg_len; 19 unsigned int bounce_sg_len;
20}; 20};
21 21
22extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *); 22extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
23 const char *);
23extern void mmc_cleanup_queue(struct mmc_queue *); 24extern void mmc_cleanup_queue(struct mmc_queue *);
24extern void mmc_queue_suspend(struct mmc_queue *); 25extern void mmc_queue_suspend(struct mmc_queue *);
25extern void mmc_queue_resume(struct mmc_queue *); 26extern void mmc_queue_resume(struct mmc_queue *);
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 68091dda3f31..7843efe22359 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1245,7 +1245,7 @@ static unsigned int mmc_mmc_erase_timeout(struct mmc_card *card,
1245 */ 1245 */
1246 timeout_clks <<= 1; 1246 timeout_clks <<= 1;
1247 timeout_us += (timeout_clks * 1000) / 1247 timeout_us += (timeout_clks * 1000) /
1248 (card->host->ios.clock / 1000); 1248 (mmc_host_clk_rate(card->host) / 1000);
1249 1249
1250 erase_timeout = timeout_us / 1000; 1250 erase_timeout = timeout_us / 1000;
1251 1251
diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
index 4d0c15bfa514..262fff019177 100644
--- a/drivers/mmc/core/sdio.c
+++ b/drivers/mmc/core/sdio.c
@@ -691,15 +691,54 @@ static int mmc_sdio_resume(struct mmc_host *host)
691static int mmc_sdio_power_restore(struct mmc_host *host) 691static int mmc_sdio_power_restore(struct mmc_host *host)
692{ 692{
693 int ret; 693 int ret;
694 u32 ocr;
694 695
695 BUG_ON(!host); 696 BUG_ON(!host);
696 BUG_ON(!host->card); 697 BUG_ON(!host->card);
697 698
698 mmc_claim_host(host); 699 mmc_claim_host(host);
700
701 /*
702 * Reset the card by performing the same steps that are taken by
703 * mmc_rescan_try_freq() and mmc_attach_sdio() during a "normal" probe.
704 *
705 * sdio_reset() is technically not needed. Having just powered up the
706 * hardware, it should already be in reset state. However, some
707 * platforms (such as SD8686 on OLPC) do not instantly cut power,
708 * meaning that a reset is required when restoring power soon after
709 * powering off. It is harmless in other cases.
710 *
711 * The CMD5 reset (mmc_send_io_op_cond()), according to the SDIO spec,
712 * is not necessary for non-removable cards. However, it is required
713 * for OLPC SD8686 (which expects a [CMD5,5,3,7] init sequence), and
714 * harmless in other situations.
715 *
716 * With these steps taken, mmc_select_voltage() is also required to
717 * restore the correct voltage setting of the card.
718 */
719 sdio_reset(host);
720 mmc_go_idle(host);
721 mmc_send_if_cond(host, host->ocr_avail);
722
723 ret = mmc_send_io_op_cond(host, 0, &ocr);
724 if (ret)
725 goto out;
726
727 if (host->ocr_avail_sdio)
728 host->ocr_avail = host->ocr_avail_sdio;
729
730 host->ocr = mmc_select_voltage(host, ocr & ~0x7F);
731 if (!host->ocr) {
732 ret = -EINVAL;
733 goto out;
734 }
735
699 ret = mmc_sdio_init_card(host, host->ocr, host->card, 736 ret = mmc_sdio_init_card(host, host->ocr, host->card,
700 mmc_card_keep_power(host)); 737 mmc_card_keep_power(host));
701 if (!ret && host->sdio_irqs) 738 if (!ret && host->sdio_irqs)
702 mmc_signal_sdio_irq(host); 739 mmc_signal_sdio_irq(host);
740
741out:
703 mmc_release_host(host); 742 mmc_release_host(host);
704 743
705 return ret; 744 return ret;
diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c
index d29b9c36919a..d2565df8a7fb 100644
--- a/drivers/mmc/core/sdio_bus.c
+++ b/drivers/mmc/core/sdio_bus.c
@@ -189,7 +189,7 @@ static int sdio_bus_remove(struct device *dev)
189 189
190 /* Then undo the runtime PM settings in sdio_bus_probe() */ 190 /* Then undo the runtime PM settings in sdio_bus_probe() */
191 if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD) 191 if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD)
192 pm_runtime_put_noidle(dev); 192 pm_runtime_put_sync(dev);
193 193
194out: 194out:
195 return ret; 195 return ret;
diff --git a/drivers/mmc/host/of_mmc_spi.c b/drivers/mmc/host/of_mmc_spi.c
index e2aecb7f1d5c..ab66f2454dc4 100644
--- a/drivers/mmc/host/of_mmc_spi.c
+++ b/drivers/mmc/host/of_mmc_spi.c
@@ -25,6 +25,11 @@
25#include <linux/mmc/core.h> 25#include <linux/mmc/core.h>
26#include <linux/mmc/host.h> 26#include <linux/mmc/host.h>
27 27
28/* For archs that don't support NO_IRQ (such as mips), provide a dummy value */
29#ifndef NO_IRQ
30#define NO_IRQ 0
31#endif
32
28MODULE_LICENSE("GPL"); 33MODULE_LICENSE("GPL");
29 34
30enum { 35enum {
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 5b2e2155b413..dedf3dab8a3b 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -429,7 +429,6 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
429 return -EINVAL; 429 return -EINVAL;
430 } 430 }
431 } 431 }
432 mmc_slot(host).ocr_mask = mmc_regulator_get_ocrmask(reg);
433 432
434 /* Allow an aux regulator */ 433 /* Allow an aux regulator */
435 reg = regulator_get(host->dev, "vmmc_aux"); 434 reg = regulator_get(host->dev, "vmmc_aux");
@@ -962,7 +961,8 @@ static void omap_hsmmc_dma_cleanup(struct omap_hsmmc_host *host, int errno)
962 spin_unlock(&host->irq_lock); 961 spin_unlock(&host->irq_lock);
963 962
964 if (host->use_dma && dma_ch != -1) { 963 if (host->use_dma && dma_ch != -1) {
965 dma_unmap_sg(mmc_dev(host->mmc), host->data->sg, host->dma_len, 964 dma_unmap_sg(mmc_dev(host->mmc), host->data->sg,
965 host->data->sg_len,
966 omap_hsmmc_get_dma_dir(host, host->data)); 966 omap_hsmmc_get_dma_dir(host, host->data));
967 omap_free_dma(dma_ch); 967 omap_free_dma(dma_ch);
968 } 968 }
@@ -1346,7 +1346,7 @@ static void omap_hsmmc_dma_cb(int lch, u16 ch_status, void *cb_data)
1346 return; 1346 return;
1347 } 1347 }
1348 1348
1349 dma_unmap_sg(mmc_dev(host->mmc), data->sg, host->dma_len, 1349 dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len,
1350 omap_hsmmc_get_dma_dir(host, data)); 1350 omap_hsmmc_get_dma_dir(host, data));
1351 1351
1352 req_in_progress = host->req_in_progress; 1352 req_in_progress = host->req_in_progress;
diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index b3654293017b..ce500f03df85 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -92,7 +92,7 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev)
92 mmc_data->ocr_mask = p->tmio_ocr_mask; 92 mmc_data->ocr_mask = p->tmio_ocr_mask;
93 mmc_data->capabilities |= p->tmio_caps; 93 mmc_data->capabilities |= p->tmio_caps;
94 94
95 if (p->dma_slave_tx >= 0 && p->dma_slave_rx >= 0) { 95 if (p->dma_slave_tx > 0 && p->dma_slave_rx > 0) {
96 priv->param_tx.slave_id = p->dma_slave_tx; 96 priv->param_tx.slave_id = p->dma_slave_tx;
97 priv->param_rx.slave_id = p->dma_slave_rx; 97 priv->param_rx.slave_id = p->dma_slave_rx;
98 priv->dma_priv.chan_priv_tx = &priv->param_tx; 98 priv->dma_priv.chan_priv_tx = &priv->param_tx;
@@ -165,13 +165,14 @@ static int sh_mobile_sdhi_remove(struct platform_device *pdev)
165 165
166 p->pdata = NULL; 166 p->pdata = NULL;
167 167
168 tmio_mmc_host_remove(host);
169
168 for (i = 0; i < 3; i++) { 170 for (i = 0; i < 3; i++) {
169 irq = platform_get_irq(pdev, i); 171 irq = platform_get_irq(pdev, i);
170 if (irq >= 0) 172 if (irq >= 0)
171 free_irq(irq, host); 173 free_irq(irq, host);
172 } 174 }
173 175
174 tmio_mmc_host_remove(host);
175 clk_disable(priv->clk); 176 clk_disable(priv->clk);
176 clk_put(priv->clk); 177 clk_put(priv->clk);
177 kfree(priv); 178 kfree(priv);
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index ad6347bb02dd..0b09e8239aa0 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -824,8 +824,8 @@ static int tmio_mmc_get_ro(struct mmc_host *mmc)
824 struct tmio_mmc_host *host = mmc_priv(mmc); 824 struct tmio_mmc_host *host = mmc_priv(mmc);
825 struct tmio_mmc_data *pdata = host->pdata; 825 struct tmio_mmc_data *pdata = host->pdata;
826 826
827 return ((pdata->flags & TMIO_MMC_WRPROTECT_DISABLE) || 827 return !((pdata->flags & TMIO_MMC_WRPROTECT_DISABLE) ||
828 !(sd_ctrl_read32(host, CTL_STATUS) & TMIO_STAT_WRPROTECT)); 828 (sd_ctrl_read32(host, CTL_STATUS) & TMIO_STAT_WRPROTECT));
829} 829}
830 830
831static int tmio_mmc_get_cd(struct mmc_host *mmc) 831static int tmio_mmc_get_cd(struct mmc_host *mmc)
diff --git a/drivers/mmc/host/vub300.c b/drivers/mmc/host/vub300.c
index cbb03305b77b..d4455ffbefd8 100644
--- a/drivers/mmc/host/vub300.c
+++ b/drivers/mmc/host/vub300.c
@@ -2096,7 +2096,7 @@ static struct mmc_host_ops vub300_mmc_ops = {
2096static int vub300_probe(struct usb_interface *interface, 2096static int vub300_probe(struct usb_interface *interface,
2097 const struct usb_device_id *id) 2097 const struct usb_device_id *id)
2098{ /* NOT irq */ 2098{ /* NOT irq */
2099 struct vub300_mmc_host *vub300 = NULL; 2099 struct vub300_mmc_host *vub300;
2100 struct usb_host_interface *iface_desc; 2100 struct usb_host_interface *iface_desc;
2101 struct usb_device *udev = usb_get_dev(interface_to_usbdev(interface)); 2101 struct usb_device *udev = usb_get_dev(interface_to_usbdev(interface));
2102 int i; 2102 int i;
@@ -2118,23 +2118,20 @@ static int vub300_probe(struct usb_interface *interface,
2118 command_out_urb = usb_alloc_urb(0, GFP_KERNEL); 2118 command_out_urb = usb_alloc_urb(0, GFP_KERNEL);
2119 if (!command_out_urb) { 2119 if (!command_out_urb) {
2120 retval = -ENOMEM; 2120 retval = -ENOMEM;
2121 dev_err(&vub300->udev->dev, 2121 dev_err(&udev->dev, "not enough memory for command_out_urb\n");
2122 "not enough memory for the command_out_urb\n");
2123 goto error0; 2122 goto error0;
2124 } 2123 }
2125 command_res_urb = usb_alloc_urb(0, GFP_KERNEL); 2124 command_res_urb = usb_alloc_urb(0, GFP_KERNEL);
2126 if (!command_res_urb) { 2125 if (!command_res_urb) {
2127 retval = -ENOMEM; 2126 retval = -ENOMEM;
2128 dev_err(&vub300->udev->dev, 2127 dev_err(&udev->dev, "not enough memory for command_res_urb\n");
2129 "not enough memory for the command_res_urb\n");
2130 goto error1; 2128 goto error1;
2131 } 2129 }
2132 /* this also allocates memory for our VUB300 mmc host device */ 2130 /* this also allocates memory for our VUB300 mmc host device */
2133 mmc = mmc_alloc_host(sizeof(struct vub300_mmc_host), &udev->dev); 2131 mmc = mmc_alloc_host(sizeof(struct vub300_mmc_host), &udev->dev);
2134 if (!mmc) { 2132 if (!mmc) {
2135 retval = -ENOMEM; 2133 retval = -ENOMEM;
2136 dev_err(&vub300->udev->dev, 2134 dev_err(&udev->dev, "not enough memory for the mmc_host\n");
2137 "not enough memory for the mmc_host\n");
2138 goto error4; 2135 goto error4;
2139 } 2136 }
2140 /* MMC core transfer sizes tunable parameters */ 2137 /* MMC core transfer sizes tunable parameters */
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 135df164a4c1..46767c53917a 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -624,7 +624,7 @@ static int pci_pm_prepare(struct device *dev)
624 * system from the sleep state, we'll have to prevent it from signaling 624 * system from the sleep state, we'll have to prevent it from signaling
625 * wake-up. 625 * wake-up.
626 */ 626 */
627 pm_runtime_resume(dev); 627 pm_runtime_get_sync(dev);
628 628
629 if (drv && drv->pm && drv->pm->prepare) 629 if (drv && drv->pm && drv->pm->prepare)
630 error = drv->pm->prepare(dev); 630 error = drv->pm->prepare(dev);
@@ -638,6 +638,8 @@ static void pci_pm_complete(struct device *dev)
638 638
639 if (drv && drv->pm && drv->pm->complete) 639 if (drv && drv->pm && drv->pm->complete)
640 drv->pm->complete(dev); 640 drv->pm->complete(dev);
641
642 pm_runtime_put_sync(dev);
641} 643}
642 644
643#else /* !CONFIG_PM_SLEEP */ 645#else /* !CONFIG_PM_SLEEP */
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 5f10c23dff94..2c5b9b991279 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -3284,7 +3284,7 @@ static int pci_set_vga_state_arch(struct pci_dev *dev, bool decode,
3284 * @dev: the PCI device 3284 * @dev: the PCI device
3285 * @decode: true = enable decoding, false = disable decoding 3285 * @decode: true = enable decoding, false = disable decoding
3286 * @command_bits: PCI_COMMAND_IO and/or PCI_COMMAND_MEMORY 3286 * @command_bits: PCI_COMMAND_IO and/or PCI_COMMAND_MEMORY
3287 * @change_bridge_flags: traverse ancestors and change bridges 3287 * @flags: traverse ancestors and change bridges
3288 * CHANGE_BRIDGE_ONLY / CHANGE_BRIDGE 3288 * CHANGE_BRIDGE_ONLY / CHANGE_BRIDGE
3289 */ 3289 */
3290int pci_set_vga_state(struct pci_dev *dev, bool decode, 3290int pci_set_vga_state(struct pci_dev *dev, bool decode,
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 48849ffdd672..bafb3c3d4a89 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -168,7 +168,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
168 res->flags |= pci_calc_resource_flags(l) | IORESOURCE_SIZEALIGN; 168 res->flags |= pci_calc_resource_flags(l) | IORESOURCE_SIZEALIGN;
169 if (type == pci_bar_io) { 169 if (type == pci_bar_io) {
170 l &= PCI_BASE_ADDRESS_IO_MASK; 170 l &= PCI_BASE_ADDRESS_IO_MASK;
171 mask = PCI_BASE_ADDRESS_IO_MASK & IO_SPACE_LIMIT; 171 mask = PCI_BASE_ADDRESS_IO_MASK & (u32) IO_SPACE_LIMIT;
172 } else { 172 } else {
173 l &= PCI_BASE_ADDRESS_MEM_MASK; 173 l &= PCI_BASE_ADDRESS_MEM_MASK;
174 mask = (u32)PCI_BASE_ADDRESS_MEM_MASK; 174 mask = (u32)PCI_BASE_ADDRESS_MEM_MASK;
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index e8a140669f90..02145e9697a9 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -2761,6 +2761,8 @@ static void ricoh_mmc_fixup_r5c832(struct pci_dev *dev)
2761} 2761}
2762DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C832, ricoh_mmc_fixup_r5c832); 2762DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C832, ricoh_mmc_fixup_r5c832);
2763DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C832, ricoh_mmc_fixup_r5c832); 2763DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C832, ricoh_mmc_fixup_r5c832);
2764DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5CE823, ricoh_mmc_fixup_r5c832);
2765DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5CE823, ricoh_mmc_fixup_r5c832);
2764#endif /*CONFIG_MMC_RICOH_MMC*/ 2766#endif /*CONFIG_MMC_RICOH_MMC*/
2765 2767
2766#if defined(CONFIG_DMAR) || defined(CONFIG_INTR_REMAP) 2768#if defined(CONFIG_DMAR) || defined(CONFIG_INTR_REMAP)
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 4724ba3acf1a..b2005b44e4f7 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -149,6 +149,7 @@ static const struct i2c_device_id ds1307_id[] = {
149 { "ds1340", ds_1340 }, 149 { "ds1340", ds_1340 },
150 { "ds3231", ds_3231 }, 150 { "ds3231", ds_3231 },
151 { "m41t00", m41t00 }, 151 { "m41t00", m41t00 },
152 { "pt7c4338", ds_1307 },
152 { "rx8025", rx_8025 }, 153 { "rx8025", rx_8025 },
153 { } 154 { }
154}; 155};
diff --git a/drivers/rtc/rtc-vt8500.c b/drivers/rtc/rtc-vt8500.c
index b8bc862903ae..efd6066b5cd2 100644
--- a/drivers/rtc/rtc-vt8500.c
+++ b/drivers/rtc/rtc-vt8500.c
@@ -78,7 +78,6 @@ struct vt8500_rtc {
78 void __iomem *regbase; 78 void __iomem *regbase;
79 struct resource *res; 79 struct resource *res;
80 int irq_alarm; 80 int irq_alarm;
81 int irq_hz;
82 struct rtc_device *rtc; 81 struct rtc_device *rtc;
83 spinlock_t lock; /* Protects this structure */ 82 spinlock_t lock; /* Protects this structure */
84}; 83};
@@ -100,10 +99,6 @@ static irqreturn_t vt8500_rtc_irq(int irq, void *dev_id)
100 if (isr & 1) 99 if (isr & 1)
101 events |= RTC_AF | RTC_IRQF; 100 events |= RTC_AF | RTC_IRQF;
102 101
103 /* Only second/minute interrupts are supported */
104 if (isr & 2)
105 events |= RTC_UF | RTC_IRQF;
106
107 rtc_update_irq(vt8500_rtc->rtc, 1, events); 102 rtc_update_irq(vt8500_rtc->rtc, 1, events);
108 103
109 return IRQ_HANDLED; 104 return IRQ_HANDLED;
@@ -199,27 +194,12 @@ static int vt8500_alarm_irq_enable(struct device *dev, unsigned int enabled)
199 return 0; 194 return 0;
200} 195}
201 196
202static int vt8500_update_irq_enable(struct device *dev, unsigned int enabled)
203{
204 struct vt8500_rtc *vt8500_rtc = dev_get_drvdata(dev);
205 unsigned long tmp = readl(vt8500_rtc->regbase + VT8500_RTC_CR);
206
207 if (enabled)
208 tmp |= VT8500_RTC_CR_SM_SEC | VT8500_RTC_CR_SM_ENABLE;
209 else
210 tmp &= ~VT8500_RTC_CR_SM_ENABLE;
211
212 writel(tmp, vt8500_rtc->regbase + VT8500_RTC_CR);
213 return 0;
214}
215
216static const struct rtc_class_ops vt8500_rtc_ops = { 197static const struct rtc_class_ops vt8500_rtc_ops = {
217 .read_time = vt8500_rtc_read_time, 198 .read_time = vt8500_rtc_read_time,
218 .set_time = vt8500_rtc_set_time, 199 .set_time = vt8500_rtc_set_time,
219 .read_alarm = vt8500_rtc_read_alarm, 200 .read_alarm = vt8500_rtc_read_alarm,
220 .set_alarm = vt8500_rtc_set_alarm, 201 .set_alarm = vt8500_rtc_set_alarm,
221 .alarm_irq_enable = vt8500_alarm_irq_enable, 202 .alarm_irq_enable = vt8500_alarm_irq_enable,
222 .update_irq_enable = vt8500_update_irq_enable,
223}; 203};
224 204
225static int __devinit vt8500_rtc_probe(struct platform_device *pdev) 205static int __devinit vt8500_rtc_probe(struct platform_device *pdev)
@@ -248,13 +228,6 @@ static int __devinit vt8500_rtc_probe(struct platform_device *pdev)
248 goto err_free; 228 goto err_free;
249 } 229 }
250 230
251 vt8500_rtc->irq_hz = platform_get_irq(pdev, 1);
252 if (vt8500_rtc->irq_hz < 0) {
253 dev_err(&pdev->dev, "No 1Hz IRQ resource defined\n");
254 ret = -ENXIO;
255 goto err_free;
256 }
257
258 vt8500_rtc->res = request_mem_region(vt8500_rtc->res->start, 231 vt8500_rtc->res = request_mem_region(vt8500_rtc->res->start,
259 resource_size(vt8500_rtc->res), 232 resource_size(vt8500_rtc->res),
260 "vt8500-rtc"); 233 "vt8500-rtc");
@@ -272,9 +245,8 @@ static int __devinit vt8500_rtc_probe(struct platform_device *pdev)
272 goto err_release; 245 goto err_release;
273 } 246 }
274 247
275 /* Enable the second/minute interrupt generation and enable RTC */ 248 /* Enable RTC and set it to 24-hour mode */
276 writel(VT8500_RTC_CR_ENABLE | VT8500_RTC_CR_24H 249 writel(VT8500_RTC_CR_ENABLE | VT8500_RTC_CR_24H,
277 | VT8500_RTC_CR_SM_ENABLE | VT8500_RTC_CR_SM_SEC,
278 vt8500_rtc->regbase + VT8500_RTC_CR); 250 vt8500_rtc->regbase + VT8500_RTC_CR);
279 251
280 vt8500_rtc->rtc = rtc_device_register("vt8500-rtc", &pdev->dev, 252 vt8500_rtc->rtc = rtc_device_register("vt8500-rtc", &pdev->dev,
@@ -286,26 +258,16 @@ static int __devinit vt8500_rtc_probe(struct platform_device *pdev)
286 goto err_unmap; 258 goto err_unmap;
287 } 259 }
288 260
289 ret = request_irq(vt8500_rtc->irq_hz, vt8500_rtc_irq, 0,
290 "rtc 1Hz", vt8500_rtc);
291 if (ret < 0) {
292 dev_err(&pdev->dev, "can't get irq %i, err %d\n",
293 vt8500_rtc->irq_hz, ret);
294 goto err_unreg;
295 }
296
297 ret = request_irq(vt8500_rtc->irq_alarm, vt8500_rtc_irq, 0, 261 ret = request_irq(vt8500_rtc->irq_alarm, vt8500_rtc_irq, 0,
298 "rtc alarm", vt8500_rtc); 262 "rtc alarm", vt8500_rtc);
299 if (ret < 0) { 263 if (ret < 0) {
300 dev_err(&pdev->dev, "can't get irq %i, err %d\n", 264 dev_err(&pdev->dev, "can't get irq %i, err %d\n",
301 vt8500_rtc->irq_alarm, ret); 265 vt8500_rtc->irq_alarm, ret);
302 goto err_free_hz; 266 goto err_unreg;
303 } 267 }
304 268
305 return 0; 269 return 0;
306 270
307err_free_hz:
308 free_irq(vt8500_rtc->irq_hz, vt8500_rtc);
309err_unreg: 271err_unreg:
310 rtc_device_unregister(vt8500_rtc->rtc); 272 rtc_device_unregister(vt8500_rtc->rtc);
311err_unmap: 273err_unmap:
@@ -323,7 +285,6 @@ static int __devexit vt8500_rtc_remove(struct platform_device *pdev)
323 struct vt8500_rtc *vt8500_rtc = platform_get_drvdata(pdev); 285 struct vt8500_rtc *vt8500_rtc = platform_get_drvdata(pdev);
324 286
325 free_irq(vt8500_rtc->irq_alarm, vt8500_rtc); 287 free_irq(vt8500_rtc->irq_alarm, vt8500_rtc);
326 free_irq(vt8500_rtc->irq_hz, vt8500_rtc);
327 288
328 rtc_device_unregister(vt8500_rtc->rtc); 289 rtc_device_unregister(vt8500_rtc->rtc);
329 290
diff --git a/drivers/staging/brcm80211/Kconfig b/drivers/staging/brcm80211/Kconfig
index f4cf9b23481e..379cf16e89f7 100644
--- a/drivers/staging/brcm80211/Kconfig
+++ b/drivers/staging/brcm80211/Kconfig
@@ -7,6 +7,7 @@ config BRCMSMAC
7 default n 7 default n
8 depends on PCI 8 depends on PCI
9 depends on WLAN && MAC80211 9 depends on WLAN && MAC80211
10 depends on X86 || MIPS
10 select BRCMUTIL 11 select BRCMUTIL
11 select FW_LOADER 12 select FW_LOADER
12 select CRC_CCITT 13 select CRC_CCITT
@@ -20,6 +21,7 @@ config BRCMFMAC
20 default n 21 default n
21 depends on MMC 22 depends on MMC
22 depends on WLAN && CFG80211 23 depends on WLAN && CFG80211
24 depends on X86 || MIPS
23 select BRCMUTIL 25 select BRCMUTIL
24 select FW_LOADER 26 select FW_LOADER
25 select WIRELESS_EXT 27 select WIRELESS_EXT
diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig
index 1502d80f6f78..20008a4376e8 100644
--- a/drivers/staging/comedi/Kconfig
+++ b/drivers/staging/comedi/Kconfig
@@ -2,6 +2,7 @@ config COMEDI
2 tristate "Data acquisition support (comedi)" 2 tristate "Data acquisition support (comedi)"
3 default N 3 default N
4 depends on m 4 depends on m
5 depends on BROKEN || FRV || M32R || MN10300 || SUPERH || TILE || X86
5 ---help--- 6 ---help---
6 Enable support a wide range of data acquisition devices 7 Enable support a wide range of data acquisition devices
7 for Linux. 8 for Linux.
@@ -160,6 +161,7 @@ config COMEDI_PCL730
160 161
161config COMEDI_PCL812 162config COMEDI_PCL812
162 tristate "Advantech PCL-812/813 and ADlink ACL-8112/8113/8113/8216" 163 tristate "Advantech PCL-812/813 and ADlink ACL-8112/8113/8113/8216"
164 depends on VIRT_TO_BUS
163 default N 165 default N
164 ---help--- 166 ---help---
165 Enable support for Advantech PCL-812/PG, PCL-813/B, ADLink 167 Enable support for Advantech PCL-812/PG, PCL-813/B, ADLink
@@ -171,6 +173,7 @@ config COMEDI_PCL812
171 173
172config COMEDI_PCL816 174config COMEDI_PCL816
173 tristate "Advantech PCL-814 and PCL-816 ISA card support" 175 tristate "Advantech PCL-814 and PCL-816 ISA card support"
176 depends on VIRT_TO_BUS
174 default N 177 default N
175 ---help--- 178 ---help---
176 Enable support for Advantech PCL-814 and PCL-816 ISA cards 179 Enable support for Advantech PCL-814 and PCL-816 ISA cards
@@ -180,6 +183,7 @@ config COMEDI_PCL816
180 183
181config COMEDI_PCL818 184config COMEDI_PCL818
182 tristate "Advantech PCL-718 and PCL-818 ISA card support" 185 tristate "Advantech PCL-718 and PCL-818 ISA card support"
186 depends on VIRT_TO_BUS
183 default N 187 default N
184 ---help--- 188 ---help---
185 Enable support for Advantech PCL-818 ISA cards 189 Enable support for Advantech PCL-818 ISA cards
@@ -269,6 +273,7 @@ config COMEDI_DAS800
269 273
270config COMEDI_DAS1800 274config COMEDI_DAS1800
271 tristate "DAS1800 and compatible ISA card support" 275 tristate "DAS1800 and compatible ISA card support"
276 depends on VIRT_TO_BUS
272 select COMEDI_FC 277 select COMEDI_FC
273 default N 278 default N
274 ---help--- 279 ---help---
@@ -340,6 +345,7 @@ config COMEDI_DT2817
340config COMEDI_DT282X 345config COMEDI_DT282X
341 tristate "Data Translation DT2821 series and DT-EZ ISA card support" 346 tristate "Data Translation DT2821 series and DT-EZ ISA card support"
342 select COMEDI_FC 347 select COMEDI_FC
348 depends on VIRT_TO_BUS
343 default N 349 default N
344 ---help--- 350 ---help---
345 Enable support for Data Translation DT2821 series including DT-EZ 351 Enable support for Data Translation DT2821 series including DT-EZ
@@ -419,6 +425,7 @@ config COMEDI_ADQ12B
419config COMEDI_NI_AT_A2150 425config COMEDI_NI_AT_A2150
420 tristate "NI AT-A2150 ISA card support" 426 tristate "NI AT-A2150 ISA card support"
421 depends on COMEDI_NI_COMMON 427 depends on COMEDI_NI_COMMON
428 depends on VIRT_TO_BUS
422 default N 429 default N
423 ---help--- 430 ---help---
424 Enable support for National Instruments AT-A2150 cards 431 Enable support for National Instruments AT-A2150 cards
@@ -536,6 +543,7 @@ if COMEDI_PCI_DRIVERS && PCI
536 543
537config COMEDI_ADDI_APCI_035 544config COMEDI_ADDI_APCI_035
538 tristate "ADDI-DATA APCI_035 support" 545 tristate "ADDI-DATA APCI_035 support"
546 depends on VIRT_TO_BUS
539 default N 547 default N
540 ---help--- 548 ---help---
541 Enable support for ADDI-DATA APCI_035 cards 549 Enable support for ADDI-DATA APCI_035 cards
@@ -545,6 +553,7 @@ config COMEDI_ADDI_APCI_035
545 553
546config COMEDI_ADDI_APCI_1032 554config COMEDI_ADDI_APCI_1032
547 tristate "ADDI-DATA APCI_1032 support" 555 tristate "ADDI-DATA APCI_1032 support"
556 depends on VIRT_TO_BUS
548 default N 557 default N
549 ---help--- 558 ---help---
550 Enable support for ADDI-DATA APCI_1032 cards 559 Enable support for ADDI-DATA APCI_1032 cards
@@ -554,6 +563,7 @@ config COMEDI_ADDI_APCI_1032
554 563
555config COMEDI_ADDI_APCI_1500 564config COMEDI_ADDI_APCI_1500
556 tristate "ADDI-DATA APCI_1500 support" 565 tristate "ADDI-DATA APCI_1500 support"
566 depends on VIRT_TO_BUS
557 default N 567 default N
558 ---help--- 568 ---help---
559 Enable support for ADDI-DATA APCI_1500 cards 569 Enable support for ADDI-DATA APCI_1500 cards
@@ -563,6 +573,7 @@ config COMEDI_ADDI_APCI_1500
563 573
564config COMEDI_ADDI_APCI_1516 574config COMEDI_ADDI_APCI_1516
565 tristate "ADDI-DATA APCI_1516 support" 575 tristate "ADDI-DATA APCI_1516 support"
576 depends on VIRT_TO_BUS
566 default N 577 default N
567 ---help--- 578 ---help---
568 Enable support for ADDI-DATA APCI_1516 cards 579 Enable support for ADDI-DATA APCI_1516 cards
@@ -572,6 +583,7 @@ config COMEDI_ADDI_APCI_1516
572 583
573config COMEDI_ADDI_APCI_1564 584config COMEDI_ADDI_APCI_1564
574 tristate "ADDI-DATA APCI_1564 support" 585 tristate "ADDI-DATA APCI_1564 support"
586 depends on VIRT_TO_BUS
575 default N 587 default N
576 ---help--- 588 ---help---
577 Enable support for ADDI-DATA APCI_1564 cards 589 Enable support for ADDI-DATA APCI_1564 cards
@@ -581,6 +593,7 @@ config COMEDI_ADDI_APCI_1564
581 593
582config COMEDI_ADDI_APCI_16XX 594config COMEDI_ADDI_APCI_16XX
583 tristate "ADDI-DATA APCI_16xx support" 595 tristate "ADDI-DATA APCI_16xx support"
596 depends on VIRT_TO_BUS
584 default N 597 default N
585 ---help--- 598 ---help---
586 Enable support for ADDI-DATA APCI_16xx cards 599 Enable support for ADDI-DATA APCI_16xx cards
@@ -590,6 +603,7 @@ config COMEDI_ADDI_APCI_16XX
590 603
591config COMEDI_ADDI_APCI_2016 604config COMEDI_ADDI_APCI_2016
592 tristate "ADDI-DATA APCI_2016 support" 605 tristate "ADDI-DATA APCI_2016 support"
606 depends on VIRT_TO_BUS
593 default N 607 default N
594 ---help--- 608 ---help---
595 Enable support for ADDI-DATA APCI_2016 cards 609 Enable support for ADDI-DATA APCI_2016 cards
@@ -599,6 +613,7 @@ config COMEDI_ADDI_APCI_2016
599 613
600config COMEDI_ADDI_APCI_2032 614config COMEDI_ADDI_APCI_2032
601 tristate "ADDI-DATA APCI_2032 support" 615 tristate "ADDI-DATA APCI_2032 support"
616 depends on VIRT_TO_BUS
602 default N 617 default N
603 ---help--- 618 ---help---
604 Enable support for ADDI-DATA APCI_2032 cards 619 Enable support for ADDI-DATA APCI_2032 cards
@@ -608,6 +623,7 @@ config COMEDI_ADDI_APCI_2032
608 623
609config COMEDI_ADDI_APCI_2200 624config COMEDI_ADDI_APCI_2200
610 tristate "ADDI-DATA APCI_2200 support" 625 tristate "ADDI-DATA APCI_2200 support"
626 depends on VIRT_TO_BUS
611 default N 627 default N
612 ---help--- 628 ---help---
613 Enable support for ADDI-DATA APCI_2200 cards 629 Enable support for ADDI-DATA APCI_2200 cards
@@ -617,6 +633,7 @@ config COMEDI_ADDI_APCI_2200
617 633
618config COMEDI_ADDI_APCI_3001 634config COMEDI_ADDI_APCI_3001
619 tristate "ADDI-DATA APCI_3001 support" 635 tristate "ADDI-DATA APCI_3001 support"
636 depends on VIRT_TO_BUS
620 select COMEDI_FC 637 select COMEDI_FC
621 default N 638 default N
622 ---help--- 639 ---help---
@@ -627,6 +644,7 @@ config COMEDI_ADDI_APCI_3001
627 644
628config COMEDI_ADDI_APCI_3120 645config COMEDI_ADDI_APCI_3120
629 tristate "ADDI-DATA APCI_3520 support" 646 tristate "ADDI-DATA APCI_3520 support"
647 depends on VIRT_TO_BUS
630 select COMEDI_FC 648 select COMEDI_FC
631 default N 649 default N
632 ---help--- 650 ---help---
@@ -637,6 +655,7 @@ config COMEDI_ADDI_APCI_3120
637 655
638config COMEDI_ADDI_APCI_3501 656config COMEDI_ADDI_APCI_3501
639 tristate "ADDI-DATA APCI_3501 support" 657 tristate "ADDI-DATA APCI_3501 support"
658 depends on VIRT_TO_BUS
640 default N 659 default N
641 ---help--- 660 ---help---
642 Enable support for ADDI-DATA APCI_3501 cards 661 Enable support for ADDI-DATA APCI_3501 cards
@@ -646,6 +665,7 @@ config COMEDI_ADDI_APCI_3501
646 665
647config COMEDI_ADDI_APCI_3XXX 666config COMEDI_ADDI_APCI_3XXX
648 tristate "ADDI-DATA APCI_3xxx support" 667 tristate "ADDI-DATA APCI_3xxx support"
668 depends on VIRT_TO_BUS
649 default N 669 default N
650 ---help--- 670 ---help---
651 Enable support for ADDI-DATA APCI_3xxx cards 671 Enable support for ADDI-DATA APCI_3xxx cards
@@ -712,6 +732,7 @@ config COMEDI_ADL_PCI9111
712config COMEDI_ADL_PCI9118 732config COMEDI_ADL_PCI9118
713 tristate "ADLink PCI-9118DG, PCI-9118HG, PCI-9118HR support" 733 tristate "ADLink PCI-9118DG, PCI-9118HG, PCI-9118HR support"
714 select COMEDI_FC 734 select COMEDI_FC
735 depends on VIRT_TO_BUS
715 default N 736 default N
716 ---help--- 737 ---help---
717 Enable support for ADlink PCI-9118DG, PCI-9118HG, PCI-9118HR cards 738 Enable support for ADlink PCI-9118DG, PCI-9118HG, PCI-9118HR cards
@@ -1287,6 +1308,7 @@ config COMEDI_NI_LABPC
1287 depends on COMEDI_MITE 1308 depends on COMEDI_MITE
1288 select COMEDI_8255 1309 select COMEDI_8255
1289 select COMEDI_FC 1310 select COMEDI_FC
1311 depends on VIRT_TO_BUS
1290 default N 1312 default N
1291 ---help--- 1313 ---help---
1292 Enable support for National Instruments Lab-PC and compatibles 1314 Enable support for National Instruments Lab-PC and compatibles
diff --git a/drivers/staging/iio/Kconfig b/drivers/staging/iio/Kconfig
index f96d5b5d5141..d329635fb5c4 100644
--- a/drivers/staging/iio/Kconfig
+++ b/drivers/staging/iio/Kconfig
@@ -4,7 +4,7 @@
4 4
5menuconfig IIO 5menuconfig IIO
6 tristate "Industrial I/O support" 6 tristate "Industrial I/O support"
7 depends on !S390 7 depends on GENERIC_HARDIRQS
8 help 8 help
9 The industrial I/O subsystem provides a unified framework for 9 The industrial I/O subsystem provides a unified framework for
10 drivers for many different types of embedded sensors using a 10 drivers for many different types of embedded sensors using a
diff --git a/drivers/staging/iio/accel/adis16204.h b/drivers/staging/iio/accel/adis16204.h
index 5310a4297688..1690c0d15690 100644
--- a/drivers/staging/iio/accel/adis16204.h
+++ b/drivers/staging/iio/accel/adis16204.h
@@ -84,7 +84,6 @@ struct adis16204_state {
84 84
85int adis16204_set_irq(struct iio_dev *indio_dev, bool enable); 85int adis16204_set_irq(struct iio_dev *indio_dev, bool enable);
86 86
87#ifdef CONFIG_IIO_RING_BUFFER
88enum adis16204_scan { 87enum adis16204_scan {
89 ADIS16204_SCAN_SUPPLY, 88 ADIS16204_SCAN_SUPPLY,
90 ADIS16204_SCAN_ACC_X, 89 ADIS16204_SCAN_ACC_X,
@@ -93,6 +92,7 @@ enum adis16204_scan {
93 ADIS16204_SCAN_TEMP, 92 ADIS16204_SCAN_TEMP,
94}; 93};
95 94
95#ifdef CONFIG_IIO_RING_BUFFER
96void adis16204_remove_trigger(struct iio_dev *indio_dev); 96void adis16204_remove_trigger(struct iio_dev *indio_dev);
97int adis16204_probe_trigger(struct iio_dev *indio_dev); 97int adis16204_probe_trigger(struct iio_dev *indio_dev);
98 98
diff --git a/drivers/staging/iio/accel/adis16209.h b/drivers/staging/iio/accel/adis16209.h
index 58d08db6f9b5..3153cbee0957 100644
--- a/drivers/staging/iio/accel/adis16209.h
+++ b/drivers/staging/iio/accel/adis16209.h
@@ -121,8 +121,6 @@ struct adis16209_state {
121 121
122int adis16209_set_irq(struct iio_dev *indio_dev, bool enable); 122int adis16209_set_irq(struct iio_dev *indio_dev, bool enable);
123 123
124#ifdef CONFIG_IIO_RING_BUFFER
125
126#define ADIS16209_SCAN_SUPPLY 0 124#define ADIS16209_SCAN_SUPPLY 0
127#define ADIS16209_SCAN_ACC_X 1 125#define ADIS16209_SCAN_ACC_X 1
128#define ADIS16209_SCAN_ACC_Y 2 126#define ADIS16209_SCAN_ACC_Y 2
@@ -132,6 +130,8 @@ int adis16209_set_irq(struct iio_dev *indio_dev, bool enable);
132#define ADIS16209_SCAN_INCLI_Y 6 130#define ADIS16209_SCAN_INCLI_Y 6
133#define ADIS16209_SCAN_ROT 7 131#define ADIS16209_SCAN_ROT 7
134 132
133#ifdef CONFIG_IIO_RING_BUFFER
134
135void adis16209_remove_trigger(struct iio_dev *indio_dev); 135void adis16209_remove_trigger(struct iio_dev *indio_dev);
136int adis16209_probe_trigger(struct iio_dev *indio_dev); 136int adis16209_probe_trigger(struct iio_dev *indio_dev);
137 137
diff --git a/drivers/staging/iio/gyro/adis16260.h b/drivers/staging/iio/gyro/adis16260.h
index 702dc982f62f..24bf70e4b29b 100644
--- a/drivers/staging/iio/gyro/adis16260.h
+++ b/drivers/staging/iio/gyro/adis16260.h
@@ -104,7 +104,6 @@ struct adis16260_state {
104 104
105int adis16260_set_irq(struct iio_dev *indio_dev, bool enable); 105int adis16260_set_irq(struct iio_dev *indio_dev, bool enable);
106 106
107#ifdef CONFIG_IIO_RING_BUFFER
108/* At the moment triggers are only used for ring buffer 107/* At the moment triggers are only used for ring buffer
109 * filling. This may change! 108 * filling. This may change!
110 */ 109 */
@@ -115,6 +114,7 @@ int adis16260_set_irq(struct iio_dev *indio_dev, bool enable);
115#define ADIS16260_SCAN_TEMP 3 114#define ADIS16260_SCAN_TEMP 3
116#define ADIS16260_SCAN_ANGL 4 115#define ADIS16260_SCAN_ANGL 4
117 116
117#ifdef CONFIG_IIO_RING_BUFFER
118void adis16260_remove_trigger(struct iio_dev *indio_dev); 118void adis16260_remove_trigger(struct iio_dev *indio_dev);
119int adis16260_probe_trigger(struct iio_dev *indio_dev); 119int adis16260_probe_trigger(struct iio_dev *indio_dev);
120 120
diff --git a/drivers/staging/iio/imu/adis16400.h b/drivers/staging/iio/imu/adis16400.h
index db184d11dfc0..e87715b9acc6 100644
--- a/drivers/staging/iio/imu/adis16400.h
+++ b/drivers/staging/iio/imu/adis16400.h
@@ -158,7 +158,6 @@ struct adis16400_state {
158 158
159int adis16400_set_irq(struct iio_dev *indio_dev, bool enable); 159int adis16400_set_irq(struct iio_dev *indio_dev, bool enable);
160 160
161#ifdef CONFIG_IIO_RING_BUFFER
162/* At the moment triggers are only used for ring buffer 161/* At the moment triggers are only used for ring buffer
163 * filling. This may change! 162 * filling. This may change!
164 */ 163 */
@@ -182,6 +181,7 @@ int adis16400_set_irq(struct iio_dev *indio_dev, bool enable);
182#define ADIS16300_SCAN_INCLI_X 12 181#define ADIS16300_SCAN_INCLI_X 12
183#define ADIS16300_SCAN_INCLI_Y 13 182#define ADIS16300_SCAN_INCLI_Y 13
184 183
184#ifdef CONFIG_IIO_RING_BUFFER
185void adis16400_remove_trigger(struct iio_dev *indio_dev); 185void adis16400_remove_trigger(struct iio_dev *indio_dev);
186int adis16400_probe_trigger(struct iio_dev *indio_dev); 186int adis16400_probe_trigger(struct iio_dev *indio_dev);
187 187
diff --git a/drivers/staging/mei/init.c b/drivers/staging/mei/init.c
index d1ffa32cd141..685fcf639644 100644
--- a/drivers/staging/mei/init.c
+++ b/drivers/staging/mei/init.c
@@ -189,7 +189,7 @@ int mei_hw_init(struct mei_device *dev)
189 mutex_lock(&dev->device_lock); 189 mutex_lock(&dev->device_lock);
190 } 190 }
191 191
192 if (!err && !dev->recvd_msg) { 192 if (err <= 0 && !dev->recvd_msg) {
193 dev->mei_state = MEI_DISABLED; 193 dev->mei_state = MEI_DISABLED;
194 dev_dbg(&dev->pdev->dev, 194 dev_dbg(&dev->pdev->dev,
195 "wait_event_interruptible_timeout failed" 195 "wait_event_interruptible_timeout failed"
diff --git a/drivers/staging/mei/wd.c b/drivers/staging/mei/wd.c
index 2564b038636a..fff53d0b5c6e 100644
--- a/drivers/staging/mei/wd.c
+++ b/drivers/staging/mei/wd.c
@@ -169,10 +169,15 @@ int mei_wd_stop(struct mei_device *dev, bool preserve)
169 ret = wait_event_interruptible_timeout(dev->wait_stop_wd, 169 ret = wait_event_interruptible_timeout(dev->wait_stop_wd,
170 dev->wd_stopped, 10 * HZ); 170 dev->wd_stopped, 10 * HZ);
171 mutex_lock(&dev->device_lock); 171 mutex_lock(&dev->device_lock);
172 if (!dev->wd_stopped) 172 if (dev->wd_stopped) {
173 dev_dbg(&dev->pdev->dev, "stop wd failed to complete.\n"); 173 dev_dbg(&dev->pdev->dev, "stop wd complete ret=%d.\n", ret);
174 else 174 ret = 0;
175 dev_dbg(&dev->pdev->dev, "stop wd complete.\n"); 175 } else {
176 if (!ret)
177 ret = -ETIMEDOUT;
178 dev_warn(&dev->pdev->dev,
179 "stop wd failed to complete ret=%d.\n", ret);
180 }
176 181
177 if (preserve) 182 if (preserve)
178 dev->wd_timeout = wd_timeout; 183 dev->wd_timeout = wd_timeout;
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index dee2a2c909f5..70c2e7fa6664 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -386,7 +386,7 @@ static int tcm_loop_device_reset(struct scsi_cmnd *sc)
386 */ 386 */
387 se_cmd->se_tmr_req = core_tmr_alloc_req(se_cmd, (void *)tl_tmr, 387 se_cmd->se_tmr_req = core_tmr_alloc_req(se_cmd, (void *)tl_tmr,
388 TMR_LUN_RESET); 388 TMR_LUN_RESET);
389 if (!se_cmd->se_tmr_req) 389 if (IS_ERR(se_cmd->se_tmr_req))
390 goto release; 390 goto release;
391 /* 391 /*
392 * Locate the underlying TCM struct se_lun from sc->device->lun 392 * Locate the underlying TCM struct se_lun from sc->device->lun
@@ -1017,6 +1017,7 @@ static int tcm_loop_make_nexus(
1017 struct se_portal_group *se_tpg; 1017 struct se_portal_group *se_tpg;
1018 struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; 1018 struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba;
1019 struct tcm_loop_nexus *tl_nexus; 1019 struct tcm_loop_nexus *tl_nexus;
1020 int ret = -ENOMEM;
1020 1021
1021 if (tl_tpg->tl_hba->tl_nexus) { 1022 if (tl_tpg->tl_hba->tl_nexus) {
1022 printk(KERN_INFO "tl_tpg->tl_hba->tl_nexus already exists\n"); 1023 printk(KERN_INFO "tl_tpg->tl_hba->tl_nexus already exists\n");
@@ -1033,8 +1034,10 @@ static int tcm_loop_make_nexus(
1033 * Initialize the struct se_session pointer 1034 * Initialize the struct se_session pointer
1034 */ 1035 */
1035 tl_nexus->se_sess = transport_init_session(); 1036 tl_nexus->se_sess = transport_init_session();
1036 if (!tl_nexus->se_sess) 1037 if (IS_ERR(tl_nexus->se_sess)) {
1038 ret = PTR_ERR(tl_nexus->se_sess);
1037 goto out; 1039 goto out;
1040 }
1038 /* 1041 /*
1039 * Since we are running in 'demo mode' this call with generate a 1042 * Since we are running in 'demo mode' this call with generate a
1040 * struct se_node_acl for the tcm_loop struct se_portal_group with the SCSI 1043 * struct se_node_acl for the tcm_loop struct se_portal_group with the SCSI
@@ -1060,7 +1063,7 @@ static int tcm_loop_make_nexus(
1060 1063
1061out: 1064out:
1062 kfree(tl_nexus); 1065 kfree(tl_nexus);
1063 return -ENOMEM; 1066 return ret;
1064} 1067}
1065 1068
1066static int tcm_loop_drop_nexus( 1069static int tcm_loop_drop_nexus(
@@ -1140,7 +1143,7 @@ static ssize_t tcm_loop_tpg_store_nexus(
1140 * the fabric protocol_id set in tcm_loop_make_scsi_hba(), and call 1143 * the fabric protocol_id set in tcm_loop_make_scsi_hba(), and call
1141 * tcm_loop_make_nexus() 1144 * tcm_loop_make_nexus()
1142 */ 1145 */
1143 if (strlen(page) > TL_WWN_ADDR_LEN) { 1146 if (strlen(page) >= TL_WWN_ADDR_LEN) {
1144 printk(KERN_ERR "Emulated NAA Sas Address: %s, exceeds" 1147 printk(KERN_ERR "Emulated NAA Sas Address: %s, exceeds"
1145 " max: %d\n", page, TL_WWN_ADDR_LEN); 1148 " max: %d\n", page, TL_WWN_ADDR_LEN);
1146 return -EINVAL; 1149 return -EINVAL;
@@ -1321,7 +1324,7 @@ struct se_wwn *tcm_loop_make_scsi_hba(
1321 return ERR_PTR(-EINVAL); 1324 return ERR_PTR(-EINVAL);
1322 1325
1323check_len: 1326check_len:
1324 if (strlen(name) > TL_WWN_ADDR_LEN) { 1327 if (strlen(name) >= TL_WWN_ADDR_LEN) {
1325 printk(KERN_ERR "Emulated NAA %s Address: %s, exceeds" 1328 printk(KERN_ERR "Emulated NAA %s Address: %s, exceeds"
1326 " max: %d\n", name, tcm_loop_dump_proto_id(tl_hba), 1329 " max: %d\n", name, tcm_loop_dump_proto_id(tl_hba),
1327 TL_WWN_ADDR_LEN); 1330 TL_WWN_ADDR_LEN);
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index ee6fad979b50..25c1f49a7d8b 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -304,7 +304,7 @@ struct target_fabric_configfs *target_fabric_configfs_init(
304 printk(KERN_ERR "Unable to locate passed fabric name\n"); 304 printk(KERN_ERR "Unable to locate passed fabric name\n");
305 return NULL; 305 return NULL;
306 } 306 }
307 if (strlen(name) > TARGET_FABRIC_NAME_SIZE) { 307 if (strlen(name) >= TARGET_FABRIC_NAME_SIZE) {
308 printk(KERN_ERR "Passed name: %s exceeds TARGET_FABRIC" 308 printk(KERN_ERR "Passed name: %s exceeds TARGET_FABRIC"
309 "_NAME_SIZE\n", name); 309 "_NAME_SIZE\n", name);
310 return NULL; 310 return NULL;
@@ -312,7 +312,7 @@ struct target_fabric_configfs *target_fabric_configfs_init(
312 312
313 tf = kzalloc(sizeof(struct target_fabric_configfs), GFP_KERNEL); 313 tf = kzalloc(sizeof(struct target_fabric_configfs), GFP_KERNEL);
314 if (!(tf)) 314 if (!(tf))
315 return ERR_PTR(-ENOMEM); 315 return NULL;
316 316
317 INIT_LIST_HEAD(&tf->tf_list); 317 INIT_LIST_HEAD(&tf->tf_list);
318 atomic_set(&tf->tf_access_cnt, 0); 318 atomic_set(&tf->tf_access_cnt, 0);
@@ -851,7 +851,7 @@ static ssize_t target_core_dev_wwn_store_attr_vpd_unit_serial(
851 return -EOPNOTSUPP; 851 return -EOPNOTSUPP;
852 } 852 }
853 853
854 if ((strlen(page) + 1) > INQUIRY_VPD_SERIAL_LEN) { 854 if (strlen(page) >= INQUIRY_VPD_SERIAL_LEN) {
855 printk(KERN_ERR "Emulated VPD Unit Serial exceeds" 855 printk(KERN_ERR "Emulated VPD Unit Serial exceeds"
856 " INQUIRY_VPD_SERIAL_LEN: %d\n", INQUIRY_VPD_SERIAL_LEN); 856 " INQUIRY_VPD_SERIAL_LEN: %d\n", INQUIRY_VPD_SERIAL_LEN);
857 return -EOVERFLOW; 857 return -EOVERFLOW;
@@ -917,7 +917,7 @@ static ssize_t target_core_dev_wwn_show_attr_vpd_protocol_identifier(
917 917
918 transport_dump_vpd_proto_id(vpd, buf, VPD_TMP_BUF_SIZE); 918 transport_dump_vpd_proto_id(vpd, buf, VPD_TMP_BUF_SIZE);
919 919
920 if ((len + strlen(buf) > PAGE_SIZE)) 920 if ((len + strlen(buf) >= PAGE_SIZE))
921 break; 921 break;
922 922
923 len += sprintf(page+len, "%s", buf); 923 len += sprintf(page+len, "%s", buf);
@@ -962,19 +962,19 @@ static ssize_t target_core_dev_wwn_show_attr_##_name( \
962 \ 962 \
963 memset(buf, 0, VPD_TMP_BUF_SIZE); \ 963 memset(buf, 0, VPD_TMP_BUF_SIZE); \
964 transport_dump_vpd_assoc(vpd, buf, VPD_TMP_BUF_SIZE); \ 964 transport_dump_vpd_assoc(vpd, buf, VPD_TMP_BUF_SIZE); \
965 if ((len + strlen(buf) > PAGE_SIZE)) \ 965 if ((len + strlen(buf) >= PAGE_SIZE)) \
966 break; \ 966 break; \
967 len += sprintf(page+len, "%s", buf); \ 967 len += sprintf(page+len, "%s", buf); \
968 \ 968 \
969 memset(buf, 0, VPD_TMP_BUF_SIZE); \ 969 memset(buf, 0, VPD_TMP_BUF_SIZE); \
970 transport_dump_vpd_ident_type(vpd, buf, VPD_TMP_BUF_SIZE); \ 970 transport_dump_vpd_ident_type(vpd, buf, VPD_TMP_BUF_SIZE); \
971 if ((len + strlen(buf) > PAGE_SIZE)) \ 971 if ((len + strlen(buf) >= PAGE_SIZE)) \
972 break; \ 972 break; \
973 len += sprintf(page+len, "%s", buf); \ 973 len += sprintf(page+len, "%s", buf); \
974 \ 974 \
975 memset(buf, 0, VPD_TMP_BUF_SIZE); \ 975 memset(buf, 0, VPD_TMP_BUF_SIZE); \
976 transport_dump_vpd_ident(vpd, buf, VPD_TMP_BUF_SIZE); \ 976 transport_dump_vpd_ident(vpd, buf, VPD_TMP_BUF_SIZE); \
977 if ((len + strlen(buf) > PAGE_SIZE)) \ 977 if ((len + strlen(buf) >= PAGE_SIZE)) \
978 break; \ 978 break; \
979 len += sprintf(page+len, "%s", buf); \ 979 len += sprintf(page+len, "%s", buf); \
980 } \ 980 } \
@@ -1299,7 +1299,7 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_registered_i_pts(
1299 &i_buf[0] : "", pr_reg->pr_res_key, 1299 &i_buf[0] : "", pr_reg->pr_res_key,
1300 pr_reg->pr_res_generation); 1300 pr_reg->pr_res_generation);
1301 1301
1302 if ((len + strlen(buf) > PAGE_SIZE)) 1302 if ((len + strlen(buf) >= PAGE_SIZE))
1303 break; 1303 break;
1304 1304
1305 len += sprintf(page+len, "%s", buf); 1305 len += sprintf(page+len, "%s", buf);
@@ -1496,7 +1496,7 @@ static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata(
1496 ret = -ENOMEM; 1496 ret = -ENOMEM;
1497 goto out; 1497 goto out;
1498 } 1498 }
1499 if (strlen(i_port) > PR_APTPL_MAX_IPORT_LEN) { 1499 if (strlen(i_port) >= PR_APTPL_MAX_IPORT_LEN) {
1500 printk(KERN_ERR "APTPL metadata initiator_node=" 1500 printk(KERN_ERR "APTPL metadata initiator_node="
1501 " exceeds PR_APTPL_MAX_IPORT_LEN: %d\n", 1501 " exceeds PR_APTPL_MAX_IPORT_LEN: %d\n",
1502 PR_APTPL_MAX_IPORT_LEN); 1502 PR_APTPL_MAX_IPORT_LEN);
@@ -1510,7 +1510,7 @@ static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata(
1510 ret = -ENOMEM; 1510 ret = -ENOMEM;
1511 goto out; 1511 goto out;
1512 } 1512 }
1513 if (strlen(isid) > PR_REG_ISID_LEN) { 1513 if (strlen(isid) >= PR_REG_ISID_LEN) {
1514 printk(KERN_ERR "APTPL metadata initiator_isid" 1514 printk(KERN_ERR "APTPL metadata initiator_isid"
1515 "= exceeds PR_REG_ISID_LEN: %d\n", 1515 "= exceeds PR_REG_ISID_LEN: %d\n",
1516 PR_REG_ISID_LEN); 1516 PR_REG_ISID_LEN);
@@ -1571,7 +1571,7 @@ static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata(
1571 ret = -ENOMEM; 1571 ret = -ENOMEM;
1572 goto out; 1572 goto out;
1573 } 1573 }
1574 if (strlen(t_port) > PR_APTPL_MAX_TPORT_LEN) { 1574 if (strlen(t_port) >= PR_APTPL_MAX_TPORT_LEN) {
1575 printk(KERN_ERR "APTPL metadata target_node=" 1575 printk(KERN_ERR "APTPL metadata target_node="
1576 " exceeds PR_APTPL_MAX_TPORT_LEN: %d\n", 1576 " exceeds PR_APTPL_MAX_TPORT_LEN: %d\n",
1577 PR_APTPL_MAX_TPORT_LEN); 1577 PR_APTPL_MAX_TPORT_LEN);
@@ -3052,7 +3052,7 @@ static struct config_group *target_core_call_addhbatotarget(
3052 int ret; 3052 int ret;
3053 3053
3054 memset(buf, 0, TARGET_CORE_NAME_MAX_LEN); 3054 memset(buf, 0, TARGET_CORE_NAME_MAX_LEN);
3055 if (strlen(name) > TARGET_CORE_NAME_MAX_LEN) { 3055 if (strlen(name) >= TARGET_CORE_NAME_MAX_LEN) {
3056 printk(KERN_ERR "Passed *name strlen(): %d exceeds" 3056 printk(KERN_ERR "Passed *name strlen(): %d exceeds"
3057 " TARGET_CORE_NAME_MAX_LEN: %d\n", (int)strlen(name), 3057 " TARGET_CORE_NAME_MAX_LEN: %d\n", (int)strlen(name),
3058 TARGET_CORE_NAME_MAX_LEN); 3058 TARGET_CORE_NAME_MAX_LEN);
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index 8407f9ca2b31..ba698ea62bb2 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -192,7 +192,7 @@ int transport_get_lun_for_tmr(
192 &SE_NODE_ACL(se_sess)->device_list[unpacked_lun]; 192 &SE_NODE_ACL(se_sess)->device_list[unpacked_lun];
193 if (deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) { 193 if (deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) {
194 se_lun = se_cmd->se_lun = se_tmr->tmr_lun = deve->se_lun; 194 se_lun = se_cmd->se_lun = se_tmr->tmr_lun = deve->se_lun;
195 dev = se_tmr->tmr_dev = se_lun->lun_se_dev; 195 dev = se_lun->lun_se_dev;
196 se_cmd->pr_res_key = deve->pr_res_key; 196 se_cmd->pr_res_key = deve->pr_res_key;
197 se_cmd->orig_fe_lun = unpacked_lun; 197 se_cmd->orig_fe_lun = unpacked_lun;
198 se_cmd->se_orig_obj_ptr = SE_LUN(se_cmd)->lun_se_dev; 198 se_cmd->se_orig_obj_ptr = SE_LUN(se_cmd)->lun_se_dev;
@@ -216,6 +216,7 @@ int transport_get_lun_for_tmr(
216 se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; 216 se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
217 return -1; 217 return -1;
218 } 218 }
219 se_tmr->tmr_dev = dev;
219 220
220 spin_lock(&dev->se_tmr_lock); 221 spin_lock(&dev->se_tmr_lock);
221 list_add_tail(&se_tmr->tmr_list, &dev->dev_tmr_list); 222 list_add_tail(&se_tmr->tmr_list, &dev->dev_tmr_list);
@@ -1430,7 +1431,7 @@ struct se_lun_acl *core_dev_init_initiator_node_lun_acl(
1430 struct se_lun_acl *lacl; 1431 struct se_lun_acl *lacl;
1431 struct se_node_acl *nacl; 1432 struct se_node_acl *nacl;
1432 1433
1433 if (strlen(initiatorname) > TRANSPORT_IQN_LEN) { 1434 if (strlen(initiatorname) >= TRANSPORT_IQN_LEN) {
1434 printk(KERN_ERR "%s InitiatorName exceeds maximum size.\n", 1435 printk(KERN_ERR "%s InitiatorName exceeds maximum size.\n",
1435 TPG_TFO(tpg)->get_fabric_name()); 1436 TPG_TFO(tpg)->get_fabric_name());
1436 *ret = -EOVERFLOW; 1437 *ret = -EOVERFLOW;
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index a79f518ca6e2..b662db3a320b 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -1916,7 +1916,7 @@ static int __core_scsi3_update_aptpl_buf(
1916 pr_reg->pr_res_mapped_lun); 1916 pr_reg->pr_res_mapped_lun);
1917 } 1917 }
1918 1918
1919 if ((len + strlen(tmp) > pr_aptpl_buf_len)) { 1919 if ((len + strlen(tmp) >= pr_aptpl_buf_len)) {
1920 printk(KERN_ERR "Unable to update renaming" 1920 printk(KERN_ERR "Unable to update renaming"
1921 " APTPL metadata\n"); 1921 " APTPL metadata\n");
1922 spin_unlock(&T10_RES(su_dev)->registration_lock); 1922 spin_unlock(&T10_RES(su_dev)->registration_lock);
@@ -1934,7 +1934,7 @@ static int __core_scsi3_update_aptpl_buf(
1934 TPG_TFO(tpg)->tpg_get_tag(tpg), 1934 TPG_TFO(tpg)->tpg_get_tag(tpg),
1935 lun->lun_sep->sep_rtpi, lun->unpacked_lun, reg_count); 1935 lun->lun_sep->sep_rtpi, lun->unpacked_lun, reg_count);
1936 1936
1937 if ((len + strlen(tmp) > pr_aptpl_buf_len)) { 1937 if ((len + strlen(tmp) >= pr_aptpl_buf_len)) {
1938 printk(KERN_ERR "Unable to update renaming" 1938 printk(KERN_ERR "Unable to update renaming"
1939 " APTPL metadata\n"); 1939 " APTPL metadata\n");
1940 spin_unlock(&T10_RES(su_dev)->registration_lock); 1940 spin_unlock(&T10_RES(su_dev)->registration_lock);
@@ -1986,7 +1986,7 @@ static int __core_scsi3_write_aptpl_to_file(
1986 memset(iov, 0, sizeof(struct iovec)); 1986 memset(iov, 0, sizeof(struct iovec));
1987 memset(path, 0, 512); 1987 memset(path, 0, 512);
1988 1988
1989 if (strlen(&wwn->unit_serial[0]) > 512) { 1989 if (strlen(&wwn->unit_serial[0]) >= 512) {
1990 printk(KERN_ERR "WWN value for struct se_device does not fit" 1990 printk(KERN_ERR "WWN value for struct se_device does not fit"
1991 " into path buffer\n"); 1991 " into path buffer\n");
1992 return -1; 1992 return -1;
diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c
index 59b8b9c5ad72..179063d81cdd 100644
--- a/drivers/target/target_core_tmr.c
+++ b/drivers/target/target_core_tmr.c
@@ -75,10 +75,16 @@ void core_tmr_release_req(
75{ 75{
76 struct se_device *dev = tmr->tmr_dev; 76 struct se_device *dev = tmr->tmr_dev;
77 77
78 if (!dev) {
79 kmem_cache_free(se_tmr_req_cache, tmr);
80 return;
81 }
82
78 spin_lock(&dev->se_tmr_lock); 83 spin_lock(&dev->se_tmr_lock);
79 list_del(&tmr->tmr_list); 84 list_del(&tmr->tmr_list);
80 kmem_cache_free(se_tmr_req_cache, tmr);
81 spin_unlock(&dev->se_tmr_lock); 85 spin_unlock(&dev->se_tmr_lock);
86
87 kmem_cache_free(se_tmr_req_cache, tmr);
82} 88}
83 89
84static void core_tmr_handle_tas_abort( 90static void core_tmr_handle_tas_abort(
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 4dafeb8b5638..4b9b7169bdd9 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -536,13 +536,13 @@ EXPORT_SYMBOL(transport_register_session);
536void transport_deregister_session_configfs(struct se_session *se_sess) 536void transport_deregister_session_configfs(struct se_session *se_sess)
537{ 537{
538 struct se_node_acl *se_nacl; 538 struct se_node_acl *se_nacl;
539 539 unsigned long flags;
540 /* 540 /*
541 * Used by struct se_node_acl's under ConfigFS to locate active struct se_session 541 * Used by struct se_node_acl's under ConfigFS to locate active struct se_session
542 */ 542 */
543 se_nacl = se_sess->se_node_acl; 543 se_nacl = se_sess->se_node_acl;
544 if ((se_nacl)) { 544 if ((se_nacl)) {
545 spin_lock_irq(&se_nacl->nacl_sess_lock); 545 spin_lock_irqsave(&se_nacl->nacl_sess_lock, flags);
546 list_del(&se_sess->sess_acl_list); 546 list_del(&se_sess->sess_acl_list);
547 /* 547 /*
548 * If the session list is empty, then clear the pointer. 548 * If the session list is empty, then clear the pointer.
@@ -556,7 +556,7 @@ void transport_deregister_session_configfs(struct se_session *se_sess)
556 se_nacl->acl_sess_list.prev, 556 se_nacl->acl_sess_list.prev,
557 struct se_session, sess_acl_list); 557 struct se_session, sess_acl_list);
558 } 558 }
559 spin_unlock_irq(&se_nacl->nacl_sess_lock); 559 spin_unlock_irqrestore(&se_nacl->nacl_sess_lock, flags);
560 } 560 }
561} 561}
562EXPORT_SYMBOL(transport_deregister_session_configfs); 562EXPORT_SYMBOL(transport_deregister_session_configfs);
diff --git a/drivers/target/tcm_fc/tcm_fc.h b/drivers/target/tcm_fc/tcm_fc.h
index defff32b7880..7b82f1b7fef8 100644
--- a/drivers/target/tcm_fc/tcm_fc.h
+++ b/drivers/target/tcm_fc/tcm_fc.h
@@ -144,7 +144,7 @@ enum ft_cmd_state {
144 */ 144 */
145struct ft_cmd { 145struct ft_cmd {
146 enum ft_cmd_state state; 146 enum ft_cmd_state state;
147 u16 lun; /* LUN from request */ 147 u32 lun; /* LUN from request */
148 struct ft_sess *sess; /* session held for cmd */ 148 struct ft_sess *sess; /* session held for cmd */
149 struct fc_seq *seq; /* sequence in exchange mgr */ 149 struct fc_seq *seq; /* sequence in exchange mgr */
150 struct se_cmd se_cmd; /* Local TCM I/O descriptor */ 150 struct se_cmd se_cmd; /* Local TCM I/O descriptor */
diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c
index c056a1132ae1..b2a106729d49 100644
--- a/drivers/target/tcm_fc/tfc_cmd.c
+++ b/drivers/target/tcm_fc/tfc_cmd.c
@@ -94,29 +94,6 @@ void ft_dump_cmd(struct ft_cmd *cmd, const char *caller)
94 16, 4, cmd->cdb, MAX_COMMAND_SIZE, 0); 94 16, 4, cmd->cdb, MAX_COMMAND_SIZE, 0);
95} 95}
96 96
97/*
98 * Get LUN from CDB.
99 */
100static int ft_get_lun_for_cmd(struct ft_cmd *cmd, u8 *lunp)
101{
102 u64 lun;
103
104 lun = lunp[1];
105 switch (lunp[0] >> 6) {
106 case 0:
107 break;
108 case 1:
109 lun |= (lunp[0] & 0x3f) << 8;
110 break;
111 default:
112 return -1;
113 }
114 if (lun >= TRANSPORT_MAX_LUNS_PER_TPG)
115 return -1;
116 cmd->lun = lun;
117 return transport_get_lun_for_cmd(&cmd->se_cmd, NULL, lun);
118}
119
120static void ft_queue_cmd(struct ft_sess *sess, struct ft_cmd *cmd) 97static void ft_queue_cmd(struct ft_sess *sess, struct ft_cmd *cmd)
121{ 98{
122 struct se_queue_obj *qobj; 99 struct se_queue_obj *qobj;
@@ -418,6 +395,7 @@ static void ft_send_tm(struct ft_cmd *cmd)
418{ 395{
419 struct se_tmr_req *tmr; 396 struct se_tmr_req *tmr;
420 struct fcp_cmnd *fcp; 397 struct fcp_cmnd *fcp;
398 struct ft_sess *sess;
421 u8 tm_func; 399 u8 tm_func;
422 400
423 fcp = fc_frame_payload_get(cmd->req_frame, sizeof(*fcp)); 401 fcp = fc_frame_payload_get(cmd->req_frame, sizeof(*fcp));
@@ -425,13 +403,6 @@ static void ft_send_tm(struct ft_cmd *cmd)
425 switch (fcp->fc_tm_flags) { 403 switch (fcp->fc_tm_flags) {
426 case FCP_TMF_LUN_RESET: 404 case FCP_TMF_LUN_RESET:
427 tm_func = TMR_LUN_RESET; 405 tm_func = TMR_LUN_RESET;
428 if (ft_get_lun_for_cmd(cmd, fcp->fc_lun) < 0) {
429 ft_dump_cmd(cmd, __func__);
430 transport_send_check_condition_and_sense(&cmd->se_cmd,
431 cmd->se_cmd.scsi_sense_reason, 0);
432 ft_sess_put(cmd->sess);
433 return;
434 }
435 break; 406 break;
436 case FCP_TMF_TGT_RESET: 407 case FCP_TMF_TGT_RESET:
437 tm_func = TMR_TARGET_WARM_RESET; 408 tm_func = TMR_TARGET_WARM_RESET;
@@ -463,6 +434,36 @@ static void ft_send_tm(struct ft_cmd *cmd)
463 return; 434 return;
464 } 435 }
465 cmd->se_cmd.se_tmr_req = tmr; 436 cmd->se_cmd.se_tmr_req = tmr;
437
438 switch (fcp->fc_tm_flags) {
439 case FCP_TMF_LUN_RESET:
440 cmd->lun = scsilun_to_int((struct scsi_lun *)fcp->fc_lun);
441 if (transport_get_lun_for_tmr(&cmd->se_cmd, cmd->lun) < 0) {
442 /*
443 * Make sure to clean up newly allocated TMR request
444 * since "unable to handle TMR request because failed
445 * to get to LUN"
446 */
447 FT_TM_DBG("Failed to get LUN for TMR func %d, "
448 "se_cmd %p, unpacked_lun %d\n",
449 tm_func, &cmd->se_cmd, cmd->lun);
450 ft_dump_cmd(cmd, __func__);
451 sess = cmd->sess;
452 transport_send_check_condition_and_sense(&cmd->se_cmd,
453 cmd->se_cmd.scsi_sense_reason, 0);
454 transport_generic_free_cmd(&cmd->se_cmd, 0, 1, 0);
455 ft_sess_put(sess);
456 return;
457 }
458 break;
459 case FCP_TMF_TGT_RESET:
460 case FCP_TMF_CLR_TASK_SET:
461 case FCP_TMF_ABT_TASK_SET:
462 case FCP_TMF_CLR_ACA:
463 break;
464 default:
465 return;
466 }
466 transport_generic_handle_tmr(&cmd->se_cmd); 467 transport_generic_handle_tmr(&cmd->se_cmd);
467} 468}
468 469
@@ -635,7 +636,8 @@ static void ft_send_cmd(struct ft_cmd *cmd)
635 636
636 fc_seq_exch(cmd->seq)->lp->tt.seq_set_resp(cmd->seq, ft_recv_seq, cmd); 637 fc_seq_exch(cmd->seq)->lp->tt.seq_set_resp(cmd->seq, ft_recv_seq, cmd);
637 638
638 ret = ft_get_lun_for_cmd(cmd, fcp->fc_lun); 639 cmd->lun = scsilun_to_int((struct scsi_lun *)fcp->fc_lun);
640 ret = transport_get_lun_for_cmd(&cmd->se_cmd, NULL, cmd->lun);
639 if (ret < 0) { 641 if (ret < 0) {
640 ft_dump_cmd(cmd, __func__); 642 ft_dump_cmd(cmd, __func__);
641 transport_send_check_condition_and_sense(&cmd->se_cmd, 643 transport_send_check_condition_and_sense(&cmd->se_cmd,
diff --git a/drivers/target/tcm_fc/tfc_io.c b/drivers/target/tcm_fc/tfc_io.c
index 4c3c0efbe13f..8c4a24077d9d 100644
--- a/drivers/target/tcm_fc/tfc_io.c
+++ b/drivers/target/tcm_fc/tfc_io.c
@@ -203,7 +203,7 @@ int ft_queue_data_in(struct se_cmd *se_cmd)
203 /* XXX For now, initiator will retry */ 203 /* XXX For now, initiator will retry */
204 if (printk_ratelimit()) 204 if (printk_ratelimit())
205 printk(KERN_ERR "%s: Failed to send frame %p, " 205 printk(KERN_ERR "%s: Failed to send frame %p, "
206 "xid <0x%x>, remaining <0x%x>, " 206 "xid <0x%x>, remaining %zu, "
207 "lso_max <0x%x>\n", 207 "lso_max <0x%x>\n",
208 __func__, fp, ep->xid, 208 __func__, fp, ep->xid,
209 remaining, lport->lso_max); 209 remaining, lport->lso_max);
diff --git a/drivers/target/tcm_fc/tfc_sess.c b/drivers/target/tcm_fc/tfc_sess.c
index a3bd57f2ea32..7491e21cc6ae 100644
--- a/drivers/target/tcm_fc/tfc_sess.c
+++ b/drivers/target/tcm_fc/tfc_sess.c
@@ -229,7 +229,7 @@ static struct ft_sess *ft_sess_create(struct ft_tport *tport, u32 port_id,
229 return NULL; 229 return NULL;
230 230
231 sess->se_sess = transport_init_session(); 231 sess->se_sess = transport_init_session();
232 if (!sess->se_sess) { 232 if (IS_ERR(sess->se_sess)) {
233 kfree(sess); 233 kfree(sess);
234 return NULL; 234 return NULL;
235 } 235 }
@@ -332,7 +332,7 @@ void ft_sess_close(struct se_session *se_sess)
332 lport = sess->tport->lport; 332 lport = sess->tport->lport;
333 port_id = sess->port_id; 333 port_id = sess->port_id;
334 if (port_id == -1) { 334 if (port_id == -1) {
335 mutex_lock(&ft_lport_lock); 335 mutex_unlock(&ft_lport_lock);
336 return; 336 return;
337 } 337 }
338 FT_SESS_DBG("port_id %x\n", port_id); 338 FT_SESS_DBG("port_id %x\n", port_id);
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 09e8c7d53af3..19b4ae052af8 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -875,7 +875,8 @@ static int gsm_dlci_data_output_framed(struct gsm_mux *gsm,
875 *dp++ = last << 7 | first << 6 | 1; /* EA */ 875 *dp++ = last << 7 | first << 6 | 1; /* EA */
876 len--; 876 len--;
877 } 877 }
878 memcpy(dp, skb_pull(dlci->skb, len), len); 878 memcpy(dp, dlci->skb->data, len);
879 skb_pull(dlci->skb, len);
879 __gsm_data_queue(dlci, msg); 880 __gsm_data_queue(dlci, msg);
880 if (last) 881 if (last)
881 dlci->skb = NULL; 882 dlci->skb = NULL;
@@ -984,10 +985,22 @@ static void gsm_control_reply(struct gsm_mux *gsm, int cmd, u8 *data,
984 */ 985 */
985 986
986static void gsm_process_modem(struct tty_struct *tty, struct gsm_dlci *dlci, 987static void gsm_process_modem(struct tty_struct *tty, struct gsm_dlci *dlci,
987 u32 modem) 988 u32 modem, int clen)
988{ 989{
989 int mlines = 0; 990 int mlines = 0;
990 u8 brk = modem >> 6; 991 u8 brk = 0;
992
993 /* The modem status command can either contain one octet (v.24 signals)
994 or two octets (v.24 signals + break signals). The length field will
995 either be 2 or 3 respectively. This is specified in section
996 5.4.6.3.7 of the 27.010 mux spec. */
997
998 if (clen == 2)
999 modem = modem & 0x7f;
1000 else {
1001 brk = modem & 0x7f;
1002 modem = (modem >> 7) & 0x7f;
1003 };
991 1004
992 /* Flow control/ready to communicate */ 1005 /* Flow control/ready to communicate */
993 if (modem & MDM_FC) { 1006 if (modem & MDM_FC) {
@@ -1061,7 +1074,7 @@ static void gsm_control_modem(struct gsm_mux *gsm, u8 *data, int clen)
1061 return; 1074 return;
1062 } 1075 }
1063 tty = tty_port_tty_get(&dlci->port); 1076 tty = tty_port_tty_get(&dlci->port);
1064 gsm_process_modem(tty, dlci, modem); 1077 gsm_process_modem(tty, dlci, modem, clen);
1065 if (tty) { 1078 if (tty) {
1066 tty_wakeup(tty); 1079 tty_wakeup(tty);
1067 tty_kref_put(tty); 1080 tty_kref_put(tty);
@@ -1482,12 +1495,13 @@ static void gsm_dlci_begin_close(struct gsm_dlci *dlci)
1482 * open we shovel the bits down it, if not we drop them. 1495 * open we shovel the bits down it, if not we drop them.
1483 */ 1496 */
1484 1497
1485static void gsm_dlci_data(struct gsm_dlci *dlci, u8 *data, int len) 1498static void gsm_dlci_data(struct gsm_dlci *dlci, u8 *data, int clen)
1486{ 1499{
1487 /* krefs .. */ 1500 /* krefs .. */
1488 struct tty_port *port = &dlci->port; 1501 struct tty_port *port = &dlci->port;
1489 struct tty_struct *tty = tty_port_tty_get(port); 1502 struct tty_struct *tty = tty_port_tty_get(port);
1490 unsigned int modem = 0; 1503 unsigned int modem = 0;
1504 int len = clen;
1491 1505
1492 if (debug & 16) 1506 if (debug & 16)
1493 pr_debug("%d bytes for tty %p\n", len, tty); 1507 pr_debug("%d bytes for tty %p\n", len, tty);
@@ -1507,7 +1521,7 @@ static void gsm_dlci_data(struct gsm_dlci *dlci, u8 *data, int len)
1507 if (len == 0) 1521 if (len == 0)
1508 return; 1522 return;
1509 } 1523 }
1510 gsm_process_modem(tty, dlci, modem); 1524 gsm_process_modem(tty, dlci, modem, clen);
1511 /* Line state will go via DLCI 0 controls only */ 1525 /* Line state will go via DLCI 0 controls only */
1512 case 1: 1526 case 1:
1513 default: 1527 default:
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 0ad32888091c..c3954fbf6ac4 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -1815,6 +1815,7 @@ do_it_again:
1815 /* FIXME: does n_tty_set_room need locking ? */ 1815 /* FIXME: does n_tty_set_room need locking ? */
1816 n_tty_set_room(tty); 1816 n_tty_set_room(tty);
1817 timeout = schedule_timeout(timeout); 1817 timeout = schedule_timeout(timeout);
1818 BUG_ON(!tty->read_buf);
1818 continue; 1819 continue;
1819 } 1820 }
1820 __set_current_state(TASK_RUNNING); 1821 __set_current_state(TASK_RUNNING);
diff --git a/drivers/tty/serial/8250.c b/drivers/tty/serial/8250.c
index b40f7b90c81d..b4129f53fb1b 100644
--- a/drivers/tty/serial/8250.c
+++ b/drivers/tty/serial/8250.c
@@ -3318,6 +3318,7 @@ void serial8250_unregister_port(int line)
3318 uart->port.flags &= ~UPF_BOOT_AUTOCONF; 3318 uart->port.flags &= ~UPF_BOOT_AUTOCONF;
3319 uart->port.type = PORT_UNKNOWN; 3319 uart->port.type = PORT_UNKNOWN;
3320 uart->port.dev = &serial8250_isa_devs->dev; 3320 uart->port.dev = &serial8250_isa_devs->dev;
3321 uart->capabilities = uart_config[uart->port.type].flags;
3321 uart_add_one_port(&serial8250_reg, &uart->port); 3322 uart_add_one_port(&serial8250_reg, &uart->port);
3322 } else { 3323 } else {
3323 uart->port.dev = NULL; 3324 uart->port.dev = NULL;
diff --git a/drivers/tty/serial/8250_pci.c b/drivers/tty/serial/8250_pci.c
index 4b4968a294b2..f41b4259ecdd 100644
--- a/drivers/tty/serial/8250_pci.c
+++ b/drivers/tty/serial/8250_pci.c
@@ -973,7 +973,7 @@ ce4100_serial_setup(struct serial_private *priv,
973 973
974static int 974static int
975pci_omegapci_setup(struct serial_private *priv, 975pci_omegapci_setup(struct serial_private *priv,
976 struct pciserial_board *board, 976 const struct pciserial_board *board,
977 struct uart_port *port, int idx) 977 struct uart_port *port, int idx)
978{ 978{
979 return setup_port(priv, port, 2, idx * 8, 0); 979 return setup_port(priv, port, 2, idx * 8, 0);
@@ -994,6 +994,15 @@ static int skip_tx_en_setup(struct serial_private *priv,
994 return pci_default_setup(priv, board, port, idx); 994 return pci_default_setup(priv, board, port, idx);
995} 995}
996 996
997static int pci_eg20t_init(struct pci_dev *dev)
998{
999#if defined(CONFIG_SERIAL_PCH_UART) || defined(CONFIG_SERIAL_PCH_UART_MODULE)
1000 return -ENODEV;
1001#else
1002 return 0;
1003#endif
1004}
1005
997/* This should be in linux/pci_ids.h */ 1006/* This should be in linux/pci_ids.h */
998#define PCI_VENDOR_ID_SBSMODULARIO 0x124B 1007#define PCI_VENDOR_ID_SBSMODULARIO 0x124B
999#define PCI_SUBVENDOR_ID_SBSMODULARIO 0x124B 1008#define PCI_SUBVENDOR_ID_SBSMODULARIO 0x124B
@@ -1446,6 +1455,56 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1446 .init = pci_oxsemi_tornado_init, 1455 .init = pci_oxsemi_tornado_init,
1447 .setup = pci_default_setup, 1456 .setup = pci_default_setup,
1448 }, 1457 },
1458 {
1459 .vendor = PCI_VENDOR_ID_INTEL,
1460 .device = 0x8811,
1461 .init = pci_eg20t_init,
1462 },
1463 {
1464 .vendor = PCI_VENDOR_ID_INTEL,
1465 .device = 0x8812,
1466 .init = pci_eg20t_init,
1467 },
1468 {
1469 .vendor = PCI_VENDOR_ID_INTEL,
1470 .device = 0x8813,
1471 .init = pci_eg20t_init,
1472 },
1473 {
1474 .vendor = PCI_VENDOR_ID_INTEL,
1475 .device = 0x8814,
1476 .init = pci_eg20t_init,
1477 },
1478 {
1479 .vendor = 0x10DB,
1480 .device = 0x8027,
1481 .init = pci_eg20t_init,
1482 },
1483 {
1484 .vendor = 0x10DB,
1485 .device = 0x8028,
1486 .init = pci_eg20t_init,
1487 },
1488 {
1489 .vendor = 0x10DB,
1490 .device = 0x8029,
1491 .init = pci_eg20t_init,
1492 },
1493 {
1494 .vendor = 0x10DB,
1495 .device = 0x800C,
1496 .init = pci_eg20t_init,
1497 },
1498 {
1499 .vendor = 0x10DB,
1500 .device = 0x800D,
1501 .init = pci_eg20t_init,
1502 },
1503 {
1504 .vendor = 0x10DB,
1505 .device = 0x800D,
1506 .init = pci_eg20t_init,
1507 },
1449 /* 1508 /*
1450 * Cronyx Omega PCI (PLX-chip based) 1509 * Cronyx Omega PCI (PLX-chip based)
1451 */ 1510 */
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 8dc0541feecc..f5f6831b0a64 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -50,6 +50,7 @@
50#include <linux/dmaengine.h> 50#include <linux/dmaengine.h>
51#include <linux/dma-mapping.h> 51#include <linux/dma-mapping.h>
52#include <linux/scatterlist.h> 52#include <linux/scatterlist.h>
53#include <linux/delay.h>
53 54
54#include <asm/io.h> 55#include <asm/io.h>
55#include <asm/sizes.h> 56#include <asm/sizes.h>
@@ -65,6 +66,30 @@
65#define UART_DR_ERROR (UART011_DR_OE|UART011_DR_BE|UART011_DR_PE|UART011_DR_FE) 66#define UART_DR_ERROR (UART011_DR_OE|UART011_DR_BE|UART011_DR_PE|UART011_DR_FE)
66#define UART_DUMMY_DR_RX (1 << 16) 67#define UART_DUMMY_DR_RX (1 << 16)
67 68
69
70#define UART_WA_SAVE_NR 14
71
72static void pl011_lockup_wa(unsigned long data);
73static const u32 uart_wa_reg[UART_WA_SAVE_NR] = {
74 ST_UART011_DMAWM,
75 ST_UART011_TIMEOUT,
76 ST_UART011_LCRH_RX,
77 UART011_IBRD,
78 UART011_FBRD,
79 ST_UART011_LCRH_TX,
80 UART011_IFLS,
81 ST_UART011_XFCR,
82 ST_UART011_XON1,
83 ST_UART011_XON2,
84 ST_UART011_XOFF1,
85 ST_UART011_XOFF2,
86 UART011_CR,
87 UART011_IMSC
88};
89
90static u32 uart_wa_regdata[UART_WA_SAVE_NR];
91static DECLARE_TASKLET(pl011_lockup_tlet, pl011_lockup_wa, 0);
92
68/* There is by now at least one vendor with differing details, so handle it */ 93/* There is by now at least one vendor with differing details, so handle it */
69struct vendor_data { 94struct vendor_data {
70 unsigned int ifls; 95 unsigned int ifls;
@@ -72,6 +97,7 @@ struct vendor_data {
72 unsigned int lcrh_tx; 97 unsigned int lcrh_tx;
73 unsigned int lcrh_rx; 98 unsigned int lcrh_rx;
74 bool oversampling; 99 bool oversampling;
100 bool interrupt_may_hang; /* vendor-specific */
75 bool dma_threshold; 101 bool dma_threshold;
76}; 102};
77 103
@@ -90,9 +116,12 @@ static struct vendor_data vendor_st = {
90 .lcrh_tx = ST_UART011_LCRH_TX, 116 .lcrh_tx = ST_UART011_LCRH_TX,
91 .lcrh_rx = ST_UART011_LCRH_RX, 117 .lcrh_rx = ST_UART011_LCRH_RX,
92 .oversampling = true, 118 .oversampling = true,
119 .interrupt_may_hang = true,
93 .dma_threshold = true, 120 .dma_threshold = true,
94}; 121};
95 122
123static struct uart_amba_port *amba_ports[UART_NR];
124
96/* Deals with DMA transactions */ 125/* Deals with DMA transactions */
97 126
98struct pl011_sgbuf { 127struct pl011_sgbuf {
@@ -132,6 +161,7 @@ struct uart_amba_port {
132 unsigned int lcrh_rx; /* vendor-specific */ 161 unsigned int lcrh_rx; /* vendor-specific */
133 bool autorts; 162 bool autorts;
134 char type[12]; 163 char type[12];
164 bool interrupt_may_hang; /* vendor-specific */
135#ifdef CONFIG_DMA_ENGINE 165#ifdef CONFIG_DMA_ENGINE
136 /* DMA stuff */ 166 /* DMA stuff */
137 bool using_tx_dma; 167 bool using_tx_dma;
@@ -1008,6 +1038,68 @@ static inline bool pl011_dma_rx_running(struct uart_amba_port *uap)
1008#endif 1038#endif
1009 1039
1010 1040
1041/*
1042 * pl011_lockup_wa
1043 * This workaround aims to break the deadlock situation
1044 * when after long transfer over uart in hardware flow
1045 * control, uart interrupt registers cannot be cleared.
1046 * Hence uart transfer gets blocked.
1047 *
1048 * It is seen that during such deadlock condition ICR
1049 * don't get cleared even on multiple write. This leads
1050 * pass_counter to decrease and finally reach zero. This
1051 * can be taken as trigger point to run this UART_BT_WA.
1052 *
1053 */
1054static void pl011_lockup_wa(unsigned long data)
1055{
1056 struct uart_amba_port *uap = amba_ports[0];
1057 void __iomem *base = uap->port.membase;
1058 struct circ_buf *xmit = &uap->port.state->xmit;
1059 struct tty_struct *tty = uap->port.state->port.tty;
1060 int buf_empty_retries = 200;
1061 int loop;
1062
1063 /* Stop HCI layer from submitting data for tx */
1064 tty->hw_stopped = 1;
1065 while (!uart_circ_empty(xmit)) {
1066 if (buf_empty_retries-- == 0)
1067 break;
1068 udelay(100);
1069 }
1070
1071 /* Backup registers */
1072 for (loop = 0; loop < UART_WA_SAVE_NR; loop++)
1073 uart_wa_regdata[loop] = readl(base + uart_wa_reg[loop]);
1074
1075 /* Disable UART so that FIFO data is flushed out */
1076 writew(0x00, uap->port.membase + UART011_CR);
1077
1078 /* Soft reset UART module */
1079 if (uap->port.dev->platform_data) {
1080 struct amba_pl011_data *plat;
1081
1082 plat = uap->port.dev->platform_data;
1083 if (plat->reset)
1084 plat->reset();
1085 }
1086
1087 /* Restore registers */
1088 for (loop = 0; loop < UART_WA_SAVE_NR; loop++)
1089 writew(uart_wa_regdata[loop] ,
1090 uap->port.membase + uart_wa_reg[loop]);
1091
1092 /* Initialise the old status of the modem signals */
1093 uap->old_status = readw(uap->port.membase + UART01x_FR) &
1094 UART01x_FR_MODEM_ANY;
1095
1096 if (readl(base + UART011_MIS) & 0x2)
1097 printk(KERN_EMERG "UART_BT_WA: ***FAILED***\n");
1098
1099 /* Start Tx/Rx */
1100 tty->hw_stopped = 0;
1101}
1102
1011static void pl011_stop_tx(struct uart_port *port) 1103static void pl011_stop_tx(struct uart_port *port)
1012{ 1104{
1013 struct uart_amba_port *uap = (struct uart_amba_port *)port; 1105 struct uart_amba_port *uap = (struct uart_amba_port *)port;
@@ -1158,8 +1250,11 @@ static irqreturn_t pl011_int(int irq, void *dev_id)
1158 if (status & UART011_TXIS) 1250 if (status & UART011_TXIS)
1159 pl011_tx_chars(uap); 1251 pl011_tx_chars(uap);
1160 1252
1161 if (pass_counter-- == 0) 1253 if (pass_counter-- == 0) {
1254 if (uap->interrupt_may_hang)
1255 tasklet_schedule(&pl011_lockup_tlet);
1162 break; 1256 break;
1257 }
1163 1258
1164 status = readw(uap->port.membase + UART011_MIS); 1259 status = readw(uap->port.membase + UART011_MIS);
1165 } while (status != 0); 1260 } while (status != 0);
@@ -1339,6 +1434,14 @@ static int pl011_startup(struct uart_port *port)
1339 writew(uap->im, uap->port.membase + UART011_IMSC); 1434 writew(uap->im, uap->port.membase + UART011_IMSC);
1340 spin_unlock_irq(&uap->port.lock); 1435 spin_unlock_irq(&uap->port.lock);
1341 1436
1437 if (uap->port.dev->platform_data) {
1438 struct amba_pl011_data *plat;
1439
1440 plat = uap->port.dev->platform_data;
1441 if (plat->init)
1442 plat->init();
1443 }
1444
1342 return 0; 1445 return 0;
1343 1446
1344 clk_dis: 1447 clk_dis:
@@ -1394,6 +1497,15 @@ static void pl011_shutdown(struct uart_port *port)
1394 * Shut down the clock producer 1497 * Shut down the clock producer
1395 */ 1498 */
1396 clk_disable(uap->clk); 1499 clk_disable(uap->clk);
1500
1501 if (uap->port.dev->platform_data) {
1502 struct amba_pl011_data *plat;
1503
1504 plat = uap->port.dev->platform_data;
1505 if (plat->exit)
1506 plat->exit();
1507 }
1508
1397} 1509}
1398 1510
1399static void 1511static void
@@ -1700,6 +1812,14 @@ static int __init pl011_console_setup(struct console *co, char *options)
1700 if (!uap) 1812 if (!uap)
1701 return -ENODEV; 1813 return -ENODEV;
1702 1814
1815 if (uap->port.dev->platform_data) {
1816 struct amba_pl011_data *plat;
1817
1818 plat = uap->port.dev->platform_data;
1819 if (plat->init)
1820 plat->init();
1821 }
1822
1703 uap->port.uartclk = clk_get_rate(uap->clk); 1823 uap->port.uartclk = clk_get_rate(uap->clk);
1704 1824
1705 if (options) 1825 if (options)
@@ -1774,6 +1894,7 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
1774 uap->lcrh_rx = vendor->lcrh_rx; 1894 uap->lcrh_rx = vendor->lcrh_rx;
1775 uap->lcrh_tx = vendor->lcrh_tx; 1895 uap->lcrh_tx = vendor->lcrh_tx;
1776 uap->fifosize = vendor->fifosize; 1896 uap->fifosize = vendor->fifosize;
1897 uap->interrupt_may_hang = vendor->interrupt_may_hang;
1777 uap->port.dev = &dev->dev; 1898 uap->port.dev = &dev->dev;
1778 uap->port.mapbase = dev->res.start; 1899 uap->port.mapbase = dev->res.start;
1779 uap->port.membase = base; 1900 uap->port.membase = base;
diff --git a/drivers/tty/serial/bcm63xx_uart.c b/drivers/tty/serial/bcm63xx_uart.c
index a1a0e55d0807..c0b68b9cad91 100644
--- a/drivers/tty/serial/bcm63xx_uart.c
+++ b/drivers/tty/serial/bcm63xx_uart.c
@@ -250,6 +250,20 @@ static void bcm_uart_do_rx(struct uart_port *port)
250 /* get overrun/fifo empty information from ier 250 /* get overrun/fifo empty information from ier
251 * register */ 251 * register */
252 iestat = bcm_uart_readl(port, UART_IR_REG); 252 iestat = bcm_uart_readl(port, UART_IR_REG);
253
254 if (unlikely(iestat & UART_IR_STAT(UART_IR_RXOVER))) {
255 unsigned int val;
256
257 /* fifo reset is required to clear
258 * interrupt */
259 val = bcm_uart_readl(port, UART_CTL_REG);
260 val |= UART_CTL_RSTRXFIFO_MASK;
261 bcm_uart_writel(port, val, UART_CTL_REG);
262
263 port->icount.overrun++;
264 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
265 }
266
253 if (!(iestat & UART_IR_STAT(UART_IR_RXNOTEMPTY))) 267 if (!(iestat & UART_IR_STAT(UART_IR_RXNOTEMPTY)))
254 break; 268 break;
255 269
@@ -284,10 +298,6 @@ static void bcm_uart_do_rx(struct uart_port *port)
284 if (uart_handle_sysrq_char(port, c)) 298 if (uart_handle_sysrq_char(port, c))
285 continue; 299 continue;
286 300
287 if (unlikely(iestat & UART_IR_STAT(UART_IR_RXOVER))) {
288 port->icount.overrun++;
289 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
290 }
291 301
292 if ((cstat & port->ignore_status_mask) == 0) 302 if ((cstat & port->ignore_status_mask) == 0)
293 tty_insert_flip_char(tty, c, flag); 303 tty_insert_flip_char(tty, c, flag);
diff --git a/drivers/tty/serial/jsm/jsm_driver.c b/drivers/tty/serial/jsm/jsm_driver.c
index 18f548449c63..96da17868cf3 100644
--- a/drivers/tty/serial/jsm/jsm_driver.c
+++ b/drivers/tty/serial/jsm/jsm_driver.c
@@ -125,7 +125,7 @@ static int __devinit jsm_probe_one(struct pci_dev *pdev, const struct pci_device
125 brd->bd_uart_offset = 0x200; 125 brd->bd_uart_offset = 0x200;
126 brd->bd_dividend = 921600; 126 brd->bd_dividend = 921600;
127 127
128 brd->re_map_membase = ioremap(brd->membase, 0x1000); 128 brd->re_map_membase = ioremap(brd->membase, pci_resource_len(pdev, 0));
129 if (!brd->re_map_membase) { 129 if (!brd->re_map_membase) {
130 dev_err(&pdev->dev, 130 dev_err(&pdev->dev,
131 "card has no PCI Memory resources, " 131 "card has no PCI Memory resources, "
diff --git a/drivers/tty/serial/mrst_max3110.c b/drivers/tty/serial/mrst_max3110.c
index 1bd28450ca40..a764bf99743b 100644
--- a/drivers/tty/serial/mrst_max3110.c
+++ b/drivers/tty/serial/mrst_max3110.c
@@ -421,7 +421,6 @@ static int max3110_main_thread(void *_max)
421 int ret = 0; 421 int ret = 0;
422 struct circ_buf *xmit = &max->con_xmit; 422 struct circ_buf *xmit = &max->con_xmit;
423 423
424 init_waitqueue_head(wq);
425 pr_info(PR_FMT "start main thread\n"); 424 pr_info(PR_FMT "start main thread\n");
426 425
427 do { 426 do {
@@ -823,7 +822,7 @@ static int __devinit serial_m3110_probe(struct spi_device *spi)
823 res = RC_TAG; 822 res = RC_TAG;
824 ret = max3110_write_then_read(max, (u8 *)&res, (u8 *)&res, 2, 0); 823 ret = max3110_write_then_read(max, (u8 *)&res, (u8 *)&res, 2, 0);
825 if (ret < 0 || res == 0 || res == 0xffff) { 824 if (ret < 0 || res == 0 || res == 0xffff) {
826 printk(KERN_ERR "MAX3111 deemed not present (conf reg %04x)", 825 dev_dbg(&spi->dev, "MAX3111 deemed not present (conf reg %04x)",
827 res); 826 res);
828 ret = -ENODEV; 827 ret = -ENODEV;
829 goto err_get_page; 828 goto err_get_page;
@@ -838,6 +837,8 @@ static int __devinit serial_m3110_probe(struct spi_device *spi)
838 max->con_xmit.head = 0; 837 max->con_xmit.head = 0;
839 max->con_xmit.tail = 0; 838 max->con_xmit.tail = 0;
840 839
840 init_waitqueue_head(&max->wq);
841
841 max->main_thread = kthread_run(max3110_main_thread, 842 max->main_thread = kthread_run(max3110_main_thread,
842 max, "max3110_main"); 843 max, "max3110_main");
843 if (IS_ERR(max->main_thread)) { 844 if (IS_ERR(max->main_thread)) {
diff --git a/drivers/tty/serial/s5pv210.c b/drivers/tty/serial/s5pv210.c
index fb2619f93d84..dd194dc80ee9 100644
--- a/drivers/tty/serial/s5pv210.c
+++ b/drivers/tty/serial/s5pv210.c
@@ -30,7 +30,7 @@ static int s5pv210_serial_setsource(struct uart_port *port,
30 struct s3c2410_uartcfg *cfg = port->dev->platform_data; 30 struct s3c2410_uartcfg *cfg = port->dev->platform_data;
31 unsigned long ucon = rd_regl(port, S3C2410_UCON); 31 unsigned long ucon = rd_regl(port, S3C2410_UCON);
32 32
33 if ((cfg->clocks_size) == 1) 33 if (cfg->flags & NO_NEED_CHECK_CLKSRC)
34 return 0; 34 return 0;
35 35
36 if (strcmp(clk->name, "pclk") == 0) 36 if (strcmp(clk->name, "pclk") == 0)
@@ -55,7 +55,7 @@ static int s5pv210_serial_getsource(struct uart_port *port,
55 55
56 clk->divisor = 1; 56 clk->divisor = 1;
57 57
58 if ((cfg->clocks_size) == 1) 58 if (cfg->flags & NO_NEED_CHECK_CLKSRC)
59 return 0; 59 return 0;
60 60
61 switch (ucon & S5PV210_UCON_CLKMASK) { 61 switch (ucon & S5PV210_UCON_CLKMASK) {
diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index 5d01d32e2cf0..ef925d581713 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -555,7 +555,7 @@ static void tty_ldisc_flush_works(struct tty_struct *tty)
555static int tty_ldisc_wait_idle(struct tty_struct *tty) 555static int tty_ldisc_wait_idle(struct tty_struct *tty)
556{ 556{
557 int ret; 557 int ret;
558 ret = wait_event_interruptible_timeout(tty_ldisc_idle, 558 ret = wait_event_timeout(tty_ldisc_idle,
559 atomic_read(&tty->ldisc->users) == 1, 5 * HZ); 559 atomic_read(&tty->ldisc->users) == 1, 5 * HZ);
560 if (ret < 0) 560 if (ret < 0)
561 return ret; 561 return ret;
@@ -763,6 +763,8 @@ static int tty_ldisc_reinit(struct tty_struct *tty, int ldisc)
763 if (IS_ERR(ld)) 763 if (IS_ERR(ld))
764 return -1; 764 return -1;
765 765
766 WARN_ON_ONCE(tty_ldisc_wait_idle(tty));
767
766 tty_ldisc_close(tty, tty->ldisc); 768 tty_ldisc_close(tty, tty->ldisc);
767 tty_ldisc_put(tty->ldisc); 769 tty_ldisc_put(tty->ldisc);
768 tty->ldisc = NULL; 770 tty->ldisc = NULL;
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index e35a17687c05..34e3da5aa72a 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -375,7 +375,7 @@ static int usb_unbind_interface(struct device *dev)
375 * Just re-enable it without affecting the endpoint toggles. 375 * Just re-enable it without affecting the endpoint toggles.
376 */ 376 */
377 usb_enable_interface(udev, intf, false); 377 usb_enable_interface(udev, intf, false);
378 } else if (!error && !intf->dev.power.in_suspend) { 378 } else if (!error && !intf->dev.power.is_prepared) {
379 r = usb_set_interface(udev, intf->altsetting[0]. 379 r = usb_set_interface(udev, intf->altsetting[0].
380 desc.bInterfaceNumber, 0); 380 desc.bInterfaceNumber, 0);
381 if (r < 0) 381 if (r < 0)
@@ -960,7 +960,7 @@ void usb_rebind_intf(struct usb_interface *intf)
960 } 960 }
961 961
962 /* Try to rebind the interface */ 962 /* Try to rebind the interface */
963 if (!intf->dev.power.in_suspend) { 963 if (!intf->dev.power.is_prepared) {
964 intf->needs_binding = 0; 964 intf->needs_binding = 0;
965 rc = device_attach(&intf->dev); 965 rc = device_attach(&intf->dev);
966 if (rc < 0) 966 if (rc < 0)
@@ -1107,7 +1107,7 @@ static int usb_resume_interface(struct usb_device *udev,
1107 if (intf->condition == USB_INTERFACE_UNBOUND) { 1107 if (intf->condition == USB_INTERFACE_UNBOUND) {
1108 1108
1109 /* Carry out a deferred switch to altsetting 0 */ 1109 /* Carry out a deferred switch to altsetting 0 */
1110 if (intf->needs_altsetting0 && !intf->dev.power.in_suspend) { 1110 if (intf->needs_altsetting0 && !intf->dev.power.is_prepared) {
1111 usb_set_interface(udev, intf->altsetting[0]. 1111 usb_set_interface(udev, intf->altsetting[0].
1112 desc.bInterfaceNumber, 0); 1112 desc.bInterfaceNumber, 0);
1113 intf->needs_altsetting0 = 0; 1113 intf->needs_altsetting0 = 0;
@@ -1187,13 +1187,22 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
1187 for (i = n - 1; i >= 0; --i) { 1187 for (i = n - 1; i >= 0; --i) {
1188 intf = udev->actconfig->interface[i]; 1188 intf = udev->actconfig->interface[i];
1189 status = usb_suspend_interface(udev, intf, msg); 1189 status = usb_suspend_interface(udev, intf, msg);
1190
1191 /* Ignore errors during system sleep transitions */
1192 if (!(msg.event & PM_EVENT_AUTO))
1193 status = 0;
1190 if (status != 0) 1194 if (status != 0)
1191 break; 1195 break;
1192 } 1196 }
1193 } 1197 }
1194 if (status == 0) 1198 if (status == 0) {
1195 status = usb_suspend_device(udev, msg); 1199 status = usb_suspend_device(udev, msg);
1196 1200
1201 /* Again, ignore errors during system sleep transitions */
1202 if (!(msg.event & PM_EVENT_AUTO))
1203 status = 0;
1204 }
1205
1197 /* If the suspend failed, resume interfaces that did get suspended */ 1206 /* If the suspend failed, resume interfaces that did get suspended */
1198 if (status != 0) { 1207 if (status != 0) {
1199 msg.event ^= (PM_EVENT_SUSPEND | PM_EVENT_RESUME); 1208 msg.event ^= (PM_EVENT_SUSPEND | PM_EVENT_RESUME);
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 90ae1753dda1..a428aa080a36 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1634,6 +1634,7 @@ void usb_disconnect(struct usb_device **pdev)
1634{ 1634{
1635 struct usb_device *udev = *pdev; 1635 struct usb_device *udev = *pdev;
1636 int i; 1636 int i;
1637 struct usb_hcd *hcd = bus_to_hcd(udev->bus);
1637 1638
1638 if (!udev) { 1639 if (!udev) {
1639 pr_debug ("%s nodev\n", __func__); 1640 pr_debug ("%s nodev\n", __func__);
@@ -1661,7 +1662,9 @@ void usb_disconnect(struct usb_device **pdev)
1661 * so that the hardware is now fully quiesced. 1662 * so that the hardware is now fully quiesced.
1662 */ 1663 */
1663 dev_dbg (&udev->dev, "unregistering device\n"); 1664 dev_dbg (&udev->dev, "unregistering device\n");
1665 mutex_lock(hcd->bandwidth_mutex);
1664 usb_disable_device(udev, 0); 1666 usb_disable_device(udev, 0);
1667 mutex_unlock(hcd->bandwidth_mutex);
1665 usb_hcd_synchronize_unlinks(udev); 1668 usb_hcd_synchronize_unlinks(udev);
1666 1669
1667 usb_remove_ep_devs(&udev->ep0); 1670 usb_remove_ep_devs(&udev->ep0);
@@ -2362,6 +2365,10 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
2362 USB_DEVICE_REMOTE_WAKEUP, 0, 2365 USB_DEVICE_REMOTE_WAKEUP, 0,
2363 NULL, 0, 2366 NULL, 0,
2364 USB_CTRL_SET_TIMEOUT); 2367 USB_CTRL_SET_TIMEOUT);
2368
2369 /* System sleep transitions should never fail */
2370 if (!(msg.event & PM_EVENT_AUTO))
2371 status = 0;
2365 } else { 2372 } else {
2366 /* device has up to 10 msec to fully suspend */ 2373 /* device has up to 10 msec to fully suspend */
2367 dev_dbg(&udev->dev, "usb %ssuspend\n", 2374 dev_dbg(&udev->dev, "usb %ssuspend\n",
@@ -2611,16 +2618,15 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
2611 struct usb_device *hdev = hub->hdev; 2618 struct usb_device *hdev = hub->hdev;
2612 unsigned port1; 2619 unsigned port1;
2613 2620
2614 /* fail if children aren't already suspended */ 2621 /* Warn if children aren't already suspended */
2615 for (port1 = 1; port1 <= hdev->maxchild; port1++) { 2622 for (port1 = 1; port1 <= hdev->maxchild; port1++) {
2616 struct usb_device *udev; 2623 struct usb_device *udev;
2617 2624
2618 udev = hdev->children [port1-1]; 2625 udev = hdev->children [port1-1];
2619 if (udev && udev->can_submit) { 2626 if (udev && udev->can_submit) {
2620 if (!(msg.event & PM_EVENT_AUTO)) 2627 dev_warn(&intf->dev, "port %d nyet suspended\n", port1);
2621 dev_dbg(&intf->dev, "port %d nyet suspended\n", 2628 if (msg.event & PM_EVENT_AUTO)
2622 port1); 2629 return -EBUSY;
2623 return -EBUSY;
2624 } 2630 }
2625 } 2631 }
2626 2632
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 5701e857392b..64c7ab4702df 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1135,10 +1135,13 @@ void usb_disable_interface(struct usb_device *dev, struct usb_interface *intf,
1135 * Deallocates hcd/hardware state for the endpoints (nuking all or most 1135 * Deallocates hcd/hardware state for the endpoints (nuking all or most
1136 * pending urbs) and usbcore state for the interfaces, so that usbcore 1136 * pending urbs) and usbcore state for the interfaces, so that usbcore
1137 * must usb_set_configuration() before any interfaces could be used. 1137 * must usb_set_configuration() before any interfaces could be used.
1138 *
1139 * Must be called with hcd->bandwidth_mutex held.
1138 */ 1140 */
1139void usb_disable_device(struct usb_device *dev, int skip_ep0) 1141void usb_disable_device(struct usb_device *dev, int skip_ep0)
1140{ 1142{
1141 int i; 1143 int i;
1144 struct usb_hcd *hcd = bus_to_hcd(dev->bus);
1142 1145
1143 /* getting rid of interfaces will disconnect 1146 /* getting rid of interfaces will disconnect
1144 * any drivers bound to them (a key side effect) 1147 * any drivers bound to them (a key side effect)
@@ -1172,6 +1175,16 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
1172 1175
1173 dev_dbg(&dev->dev, "%s nuking %s URBs\n", __func__, 1176 dev_dbg(&dev->dev, "%s nuking %s URBs\n", __func__,
1174 skip_ep0 ? "non-ep0" : "all"); 1177 skip_ep0 ? "non-ep0" : "all");
1178 if (hcd->driver->check_bandwidth) {
1179 /* First pass: Cancel URBs, leave endpoint pointers intact. */
1180 for (i = skip_ep0; i < 16; ++i) {
1181 usb_disable_endpoint(dev, i, false);
1182 usb_disable_endpoint(dev, i + USB_DIR_IN, false);
1183 }
1184 /* Remove endpoints from the host controller internal state */
1185 usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL);
1186 /* Second pass: remove endpoint pointers */
1187 }
1175 for (i = skip_ep0; i < 16; ++i) { 1188 for (i = skip_ep0; i < 16; ++i) {
1176 usb_disable_endpoint(dev, i, true); 1189 usb_disable_endpoint(dev, i, true);
1177 usb_disable_endpoint(dev, i + USB_DIR_IN, true); 1190 usb_disable_endpoint(dev, i + USB_DIR_IN, true);
@@ -1727,6 +1740,7 @@ free_interfaces:
1727 /* if it's already configured, clear out old state first. 1740 /* if it's already configured, clear out old state first.
1728 * getting rid of old interfaces means unbinding their drivers. 1741 * getting rid of old interfaces means unbinding their drivers.
1729 */ 1742 */
1743 mutex_lock(hcd->bandwidth_mutex);
1730 if (dev->state != USB_STATE_ADDRESS) 1744 if (dev->state != USB_STATE_ADDRESS)
1731 usb_disable_device(dev, 1); /* Skip ep0 */ 1745 usb_disable_device(dev, 1); /* Skip ep0 */
1732 1746
@@ -1739,7 +1753,6 @@ free_interfaces:
1739 * host controller will not allow submissions to dropped endpoints. If 1753 * host controller will not allow submissions to dropped endpoints. If
1740 * this call fails, the device state is unchanged. 1754 * this call fails, the device state is unchanged.
1741 */ 1755 */
1742 mutex_lock(hcd->bandwidth_mutex);
1743 ret = usb_hcd_alloc_bandwidth(dev, cp, NULL, NULL); 1756 ret = usb_hcd_alloc_bandwidth(dev, cp, NULL, NULL);
1744 if (ret < 0) { 1757 if (ret < 0) {
1745 mutex_unlock(hcd->bandwidth_mutex); 1758 mutex_unlock(hcd->bandwidth_mutex);
diff --git a/drivers/usb/host/ehci-ath79.c b/drivers/usb/host/ehci-ath79.c
index 98cc8a13169c..aa248c2f2c60 100644
--- a/drivers/usb/host/ehci-ath79.c
+++ b/drivers/usb/host/ehci-ath79.c
@@ -44,7 +44,6 @@ static int ehci_ath79_init(struct usb_hcd *hcd)
44 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 44 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
45 struct platform_device *pdev = to_platform_device(hcd->self.controller); 45 struct platform_device *pdev = to_platform_device(hcd->self.controller);
46 const struct platform_device_id *id; 46 const struct platform_device_id *id;
47 int hclength;
48 int ret; 47 int ret;
49 48
50 id = platform_get_device_id(pdev); 49 id = platform_get_device_id(pdev);
@@ -53,20 +52,23 @@ static int ehci_ath79_init(struct usb_hcd *hcd)
53 return -EINVAL; 52 return -EINVAL;
54 } 53 }
55 54
56 hclength = HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase));
57 switch (id->driver_data) { 55 switch (id->driver_data) {
58 case EHCI_ATH79_IP_V1: 56 case EHCI_ATH79_IP_V1:
59 ehci->has_synopsys_hc_bug = 1; 57 ehci->has_synopsys_hc_bug = 1;
60 58
61 ehci->caps = hcd->regs; 59 ehci->caps = hcd->regs;
62 ehci->regs = hcd->regs + hclength; 60 ehci->regs = hcd->regs +
61 HC_LENGTH(ehci,
62 ehci_readl(ehci, &ehci->caps->hc_capbase));
63 break; 63 break;
64 64
65 case EHCI_ATH79_IP_V2: 65 case EHCI_ATH79_IP_V2:
66 hcd->has_tt = 1; 66 hcd->has_tt = 1;
67 67
68 ehci->caps = hcd->regs + 0x100; 68 ehci->caps = hcd->regs + 0x100;
69 ehci->regs = hcd->regs + 0x100 + hclength; 69 ehci->regs = hcd->regs + 0x100 +
70 HC_LENGTH(ehci,
71 ehci_readl(ehci, &ehci->caps->hc_capbase));
70 break; 72 break;
71 73
72 default: 74 default:
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index b435ed67dd5c..f8030ee928e8 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1,4 +1,8 @@
1/* 1/*
2 * Enhanced Host Controller Interface (EHCI) driver for USB.
3 *
4 * Maintainer: Alan Stern <stern@rowland.harvard.edu>
5 *
2 * Copyright (c) 2000-2004 by David Brownell 6 * Copyright (c) 2000-2004 by David Brownell
3 * 7 *
4 * This program is free software; you can redistribute it and/or modify it 8 * This program is free software; you can redistribute it and/or modify it
diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c
index c9e6e454c625..55d3d5859ac5 100644
--- a/drivers/usb/host/isp1760-hcd.c
+++ b/drivers/usb/host/isp1760-hcd.c
@@ -1555,7 +1555,7 @@ static void kill_transfer(struct usb_hcd *hcd, struct urb *urb,
1555 1555
1556 /* We need to forcefully reclaim the slot since some transfers never 1556 /* We need to forcefully reclaim the slot since some transfers never
1557 return, e.g. interrupt transfers and NAKed bulk transfers. */ 1557 return, e.g. interrupt transfers and NAKed bulk transfers. */
1558 if (usb_pipebulk(urb->pipe)) { 1558 if (usb_pipecontrol(urb->pipe) || usb_pipebulk(urb->pipe)) {
1559 skip_map = reg_read32(hcd->regs, HC_ATL_PTD_SKIPMAP_REG); 1559 skip_map = reg_read32(hcd->regs, HC_ATL_PTD_SKIPMAP_REG);
1560 skip_map |= (1 << qh->slot); 1560 skip_map |= (1 << qh->slot);
1561 reg_write32(hcd->regs, HC_ATL_PTD_SKIPMAP_REG, skip_map); 1561 reg_write32(hcd->regs, HC_ATL_PTD_SKIPMAP_REG, skip_map);
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 9aa10bdf3918..f9cf3f04b742 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -1,5 +1,7 @@
1/* 1/*
2 * OHCI HCD (Host Controller Driver) for USB. 2 * Open Host Controller Interface (OHCI) driver for USB.
3 *
4 * Maintainer: Alan Stern <stern@rowland.harvard.edu>
3 * 5 *
4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at> 6 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
5 * (C) Copyright 2000-2004 David Brownell <dbrownell@users.sourceforge.net> 7 * (C) Copyright 2000-2004 David Brownell <dbrownell@users.sourceforge.net>
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index db6f8b9c19b6..4586369dda00 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -2517,6 +2517,7 @@ static int __devinit r8a66597_probe(struct platform_device *pdev)
2517 INIT_LIST_HEAD(&r8a66597->child_device); 2517 INIT_LIST_HEAD(&r8a66597->child_device);
2518 2518
2519 hcd->rsrc_start = res->start; 2519 hcd->rsrc_start = res->start;
2520 hcd->has_tt = 1;
2520 2521
2521 ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | irq_trigger); 2522 ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | irq_trigger);
2522 if (ret != 0) { 2523 if (ret != 0) {
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 0f8e1d29a858..fcb7f7efc86d 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1215,8 +1215,6 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
1215 ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet)); 1215 ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet));
1216 /* dig out max burst from ep companion desc */ 1216 /* dig out max burst from ep companion desc */
1217 max_packet = ep->ss_ep_comp.bMaxBurst; 1217 max_packet = ep->ss_ep_comp.bMaxBurst;
1218 if (!max_packet)
1219 xhci_warn(xhci, "WARN no SS endpoint bMaxBurst\n");
1220 ep_ctx->ep_info2 |= cpu_to_le32(MAX_BURST(max_packet)); 1218 ep_ctx->ep_info2 |= cpu_to_le32(MAX_BURST(max_packet));
1221 break; 1219 break;
1222 case USB_SPEED_HIGH: 1220 case USB_SPEED_HIGH:
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 17541d09eabb..cb16de213f64 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -29,6 +29,9 @@
29#define PCI_VENDOR_ID_FRESCO_LOGIC 0x1b73 29#define PCI_VENDOR_ID_FRESCO_LOGIC 0x1b73
30#define PCI_DEVICE_ID_FRESCO_LOGIC_PDK 0x1000 30#define PCI_DEVICE_ID_FRESCO_LOGIC_PDK 0x1000
31 31
32#define PCI_VENDOR_ID_ETRON 0x1b6f
33#define PCI_DEVICE_ID_ASROCK_P67 0x7023
34
32static const char hcd_name[] = "xhci_hcd"; 35static const char hcd_name[] = "xhci_hcd";
33 36
34/* called after powerup, by probe or system-pm "wakeup" */ 37/* called after powerup, by probe or system-pm "wakeup" */
@@ -134,6 +137,11 @@ static int xhci_pci_setup(struct usb_hcd *hcd)
134 xhci->quirks |= XHCI_EP_LIMIT_QUIRK; 137 xhci->quirks |= XHCI_EP_LIMIT_QUIRK;
135 xhci->limit_active_eps = 64; 138 xhci->limit_active_eps = 64;
136 } 139 }
140 if (pdev->vendor == PCI_VENDOR_ID_ETRON &&
141 pdev->device == PCI_DEVICE_ID_ASROCK_P67) {
142 xhci->quirks |= XHCI_RESET_ON_RESUME;
143 xhci_dbg(xhci, "QUIRK: Resetting on resume\n");
144 }
137 145
138 /* Make sure the HC is halted. */ 146 /* Make sure the HC is halted. */
139 retval = xhci_halt(xhci); 147 retval = xhci_halt(xhci);
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 800f417c7309..70cacbbe7fb9 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1733,6 +1733,7 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td,
1733 frame->status = -EOVERFLOW; 1733 frame->status = -EOVERFLOW;
1734 skip_td = true; 1734 skip_td = true;
1735 break; 1735 break;
1736 case COMP_DEV_ERR:
1736 case COMP_STALL: 1737 case COMP_STALL:
1737 frame->status = -EPROTO; 1738 frame->status = -EPROTO;
1738 skip_td = true; 1739 skip_td = true;
@@ -1767,9 +1768,6 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td,
1767 } 1768 }
1768 } 1769 }
1769 1770
1770 if ((idx == urb_priv->length - 1) && *status == -EINPROGRESS)
1771 *status = 0;
1772
1773 return finish_td(xhci, td, event_trb, event, ep, status, false); 1771 return finish_td(xhci, td, event_trb, event, ep, status, false);
1774} 1772}
1775 1773
@@ -1787,8 +1785,7 @@ static int skip_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td,
1787 idx = urb_priv->td_cnt; 1785 idx = urb_priv->td_cnt;
1788 frame = &td->urb->iso_frame_desc[idx]; 1786 frame = &td->urb->iso_frame_desc[idx];
1789 1787
1790 /* The transfer is partly done */ 1788 /* The transfer is partly done. */
1791 *status = -EXDEV;
1792 frame->status = -EXDEV; 1789 frame->status = -EXDEV;
1793 1790
1794 /* calc actual length */ 1791 /* calc actual length */
@@ -2016,6 +2013,10 @@ static int handle_tx_event(struct xhci_hcd *xhci,
2016 TRB_TO_SLOT_ID(le32_to_cpu(event->flags)), 2013 TRB_TO_SLOT_ID(le32_to_cpu(event->flags)),
2017 ep_index); 2014 ep_index);
2018 goto cleanup; 2015 goto cleanup;
2016 case COMP_DEV_ERR:
2017 xhci_warn(xhci, "WARN: detect an incompatible device");
2018 status = -EPROTO;
2019 break;
2019 case COMP_MISSED_INT: 2020 case COMP_MISSED_INT:
2020 /* 2021 /*
2021 * When encounter missed service error, one or more isoc tds 2022 * When encounter missed service error, one or more isoc tds
@@ -2063,6 +2064,20 @@ static int handle_tx_event(struct xhci_hcd *xhci,
2063 /* Is this a TRB in the currently executing TD? */ 2064 /* Is this a TRB in the currently executing TD? */
2064 event_seg = trb_in_td(ep_ring->deq_seg, ep_ring->dequeue, 2065 event_seg = trb_in_td(ep_ring->deq_seg, ep_ring->dequeue,
2065 td->last_trb, event_dma); 2066 td->last_trb, event_dma);
2067
2068 /*
2069 * Skip the Force Stopped Event. The event_trb(event_dma) of FSE
2070 * is not in the current TD pointed by ep_ring->dequeue because
2071 * that the hardware dequeue pointer still at the previous TRB
2072 * of the current TD. The previous TRB maybe a Link TD or the
2073 * last TRB of the previous TD. The command completion handle
2074 * will take care the rest.
2075 */
2076 if (!event_seg && trb_comp_code == COMP_STOP_INVAL) {
2077 ret = 0;
2078 goto cleanup;
2079 }
2080
2066 if (!event_seg) { 2081 if (!event_seg) {
2067 if (!ep->skip || 2082 if (!ep->skip ||
2068 !usb_endpoint_xfer_isoc(&td->urb->ep->desc)) { 2083 !usb_endpoint_xfer_isoc(&td->urb->ep->desc)) {
@@ -2158,6 +2173,11 @@ cleanup:
2158 urb->transfer_buffer_length, 2173 urb->transfer_buffer_length,
2159 status); 2174 status);
2160 spin_unlock(&xhci->lock); 2175 spin_unlock(&xhci->lock);
2176 /* EHCI, UHCI, and OHCI always unconditionally set the
2177 * urb->status of an isochronous endpoint to 0.
2178 */
2179 if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS)
2180 status = 0;
2161 usb_hcd_giveback_urb(bus_to_hcd(urb->dev->bus), urb, status); 2181 usb_hcd_giveback_urb(bus_to_hcd(urb->dev->bus), urb, status);
2162 spin_lock(&xhci->lock); 2182 spin_lock(&xhci->lock);
2163 } 2183 }
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 06e7023258d0..f5fe1ac301ab 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -759,6 +759,8 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
759 msleep(100); 759 msleep(100);
760 760
761 spin_lock_irq(&xhci->lock); 761 spin_lock_irq(&xhci->lock);
762 if (xhci->quirks & XHCI_RESET_ON_RESUME)
763 hibernated = true;
762 764
763 if (!hibernated) { 765 if (!hibernated) {
764 /* step 1: restore register */ 766 /* step 1: restore register */
@@ -1401,6 +1403,7 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1401 u32 added_ctxs; 1403 u32 added_ctxs;
1402 unsigned int last_ctx; 1404 unsigned int last_ctx;
1403 u32 new_add_flags, new_drop_flags, new_slot_info; 1405 u32 new_add_flags, new_drop_flags, new_slot_info;
1406 struct xhci_virt_device *virt_dev;
1404 int ret = 0; 1407 int ret = 0;
1405 1408
1406 ret = xhci_check_args(hcd, udev, ep, 1, true, __func__); 1409 ret = xhci_check_args(hcd, udev, ep, 1, true, __func__);
@@ -1425,11 +1428,25 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1425 return 0; 1428 return 0;
1426 } 1429 }
1427 1430
1428 in_ctx = xhci->devs[udev->slot_id]->in_ctx; 1431 virt_dev = xhci->devs[udev->slot_id];
1429 out_ctx = xhci->devs[udev->slot_id]->out_ctx; 1432 in_ctx = virt_dev->in_ctx;
1433 out_ctx = virt_dev->out_ctx;
1430 ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx); 1434 ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx);
1431 ep_index = xhci_get_endpoint_index(&ep->desc); 1435 ep_index = xhci_get_endpoint_index(&ep->desc);
1432 ep_ctx = xhci_get_ep_ctx(xhci, out_ctx, ep_index); 1436 ep_ctx = xhci_get_ep_ctx(xhci, out_ctx, ep_index);
1437
1438 /* If this endpoint is already in use, and the upper layers are trying
1439 * to add it again without dropping it, reject the addition.
1440 */
1441 if (virt_dev->eps[ep_index].ring &&
1442 !(le32_to_cpu(ctrl_ctx->drop_flags) &
1443 xhci_get_endpoint_flag(&ep->desc))) {
1444 xhci_warn(xhci, "Trying to add endpoint 0x%x "
1445 "without dropping it.\n",
1446 (unsigned int) ep->desc.bEndpointAddress);
1447 return -EINVAL;
1448 }
1449
1433 /* If the HCD has already noted the endpoint is enabled, 1450 /* If the HCD has already noted the endpoint is enabled,
1434 * ignore this request. 1451 * ignore this request.
1435 */ 1452 */
@@ -1445,8 +1462,7 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1445 * process context, not interrupt context (or so documenation 1462 * process context, not interrupt context (or so documenation
1446 * for usb_set_interface() and usb_set_configuration() claim). 1463 * for usb_set_interface() and usb_set_configuration() claim).
1447 */ 1464 */
1448 if (xhci_endpoint_init(xhci, xhci->devs[udev->slot_id], 1465 if (xhci_endpoint_init(xhci, virt_dev, udev, ep, GFP_NOIO) < 0) {
1449 udev, ep, GFP_NOIO) < 0) {
1450 dev_dbg(&udev->dev, "%s - could not initialize ep %#x\n", 1466 dev_dbg(&udev->dev, "%s - could not initialize ep %#x\n",
1451 __func__, ep->desc.bEndpointAddress); 1467 __func__, ep->desc.bEndpointAddress);
1452 return -ENOMEM; 1468 return -ENOMEM;
@@ -1537,6 +1553,11 @@ static int xhci_configure_endpoint_result(struct xhci_hcd *xhci,
1537 "and endpoint is not disabled.\n"); 1553 "and endpoint is not disabled.\n");
1538 ret = -EINVAL; 1554 ret = -EINVAL;
1539 break; 1555 break;
1556 case COMP_DEV_ERR:
1557 dev_warn(&udev->dev, "ERROR: Incompatible device for endpoint "
1558 "configure command.\n");
1559 ret = -ENODEV;
1560 break;
1540 case COMP_SUCCESS: 1561 case COMP_SUCCESS:
1541 dev_dbg(&udev->dev, "Successful Endpoint Configure command\n"); 1562 dev_dbg(&udev->dev, "Successful Endpoint Configure command\n");
1542 ret = 0; 1563 ret = 0;
@@ -1571,6 +1592,11 @@ static int xhci_evaluate_context_result(struct xhci_hcd *xhci,
1571 xhci_dbg_ctx(xhci, virt_dev->out_ctx, 1); 1592 xhci_dbg_ctx(xhci, virt_dev->out_ctx, 1);
1572 ret = -EINVAL; 1593 ret = -EINVAL;
1573 break; 1594 break;
1595 case COMP_DEV_ERR:
1596 dev_warn(&udev->dev, "ERROR: Incompatible device for evaluate "
1597 "context command.\n");
1598 ret = -ENODEV;
1599 break;
1574 case COMP_MEL_ERR: 1600 case COMP_MEL_ERR:
1575 /* Max Exit Latency too large error */ 1601 /* Max Exit Latency too large error */
1576 dev_warn(&udev->dev, "WARN: Max Exit Latency too large\n"); 1602 dev_warn(&udev->dev, "WARN: Max Exit Latency too large\n");
@@ -2853,6 +2879,11 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
2853 dev_warn(&udev->dev, "Device not responding to set address.\n"); 2879 dev_warn(&udev->dev, "Device not responding to set address.\n");
2854 ret = -EPROTO; 2880 ret = -EPROTO;
2855 break; 2881 break;
2882 case COMP_DEV_ERR:
2883 dev_warn(&udev->dev, "ERROR: Incompatible device for address "
2884 "device command.\n");
2885 ret = -ENODEV;
2886 break;
2856 case COMP_SUCCESS: 2887 case COMP_SUCCESS:
2857 xhci_dbg(xhci, "Successful Address Device command\n"); 2888 xhci_dbg(xhci, "Successful Address Device command\n");
2858 break; 2889 break;
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 7d1ea3bf5e1f..d8bbf5ccb10d 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -874,6 +874,8 @@ struct xhci_transfer_event {
874#define COMP_PING_ERR 20 874#define COMP_PING_ERR 20
875/* Event Ring is full */ 875/* Event Ring is full */
876#define COMP_ER_FULL 21 876#define COMP_ER_FULL 21
877/* Incompatible Device Error */
878#define COMP_DEV_ERR 22
877/* Missed Service Error - HC couldn't service an isoc ep within interval */ 879/* Missed Service Error - HC couldn't service an isoc ep within interval */
878#define COMP_MISSED_INT 23 880#define COMP_MISSED_INT 23
879/* Successfully stopped command ring */ 881/* Successfully stopped command ring */
@@ -1308,6 +1310,7 @@ struct xhci_hcd {
1308 */ 1310 */
1309#define XHCI_EP_LIMIT_QUIRK (1 << 5) 1311#define XHCI_EP_LIMIT_QUIRK (1 << 5)
1310#define XHCI_BROKEN_MSI (1 << 6) 1312#define XHCI_BROKEN_MSI (1 << 6)
1313#define XHCI_RESET_ON_RESUME (1 << 7)
1311 unsigned int num_active_eps; 1314 unsigned int num_active_eps;
1312 unsigned int limit_active_eps; 1315 unsigned int limit_active_eps;
1313 /* There are two roothubs to keep track of bus suspend info for */ 1316 /* There are two roothubs to keep track of bus suspend info for */
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 0a50a35e1853..6aeb363e63e7 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1524,6 +1524,12 @@ static void musb_gadget_fifo_flush(struct usb_ep *ep)
1524 csr = musb_readw(epio, MUSB_TXCSR); 1524 csr = musb_readw(epio, MUSB_TXCSR);
1525 if (csr & MUSB_TXCSR_FIFONOTEMPTY) { 1525 if (csr & MUSB_TXCSR_FIFONOTEMPTY) {
1526 csr |= MUSB_TXCSR_FLUSHFIFO | MUSB_TXCSR_P_WZC_BITS; 1526 csr |= MUSB_TXCSR_FLUSHFIFO | MUSB_TXCSR_P_WZC_BITS;
1527 /*
1528 * Setting both TXPKTRDY and FLUSHFIFO makes controller
1529 * to interrupt current FIFO loading, but not flushing
1530 * the already loaded ones.
1531 */
1532 csr &= ~MUSB_TXCSR_TXPKTRDY;
1527 musb_writew(epio, MUSB_TXCSR, csr); 1533 musb_writew(epio, MUSB_TXCSR, csr);
1528 /* REVISIT may be inappropriate w/o FIFONOTEMPTY ... */ 1534 /* REVISIT may be inappropriate w/o FIFONOTEMPTY ... */
1529 musb_writew(epio, MUSB_TXCSR, csr); 1535 musb_writew(epio, MUSB_TXCSR, csr);
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 7295e316bdfc..8b2473fa0f47 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -1575,7 +1575,7 @@ void musb_host_rx(struct musb *musb, u8 epnum)
1575 /* even if there was an error, we did the dma 1575 /* even if there was an error, we did the dma
1576 * for iso_frame_desc->length 1576 * for iso_frame_desc->length
1577 */ 1577 */
1578 if (d->status != EILSEQ && d->status != -EOVERFLOW) 1578 if (d->status != -EILSEQ && d->status != -EOVERFLOW)
1579 d->status = 0; 1579 d->status = 0;
1580 1580
1581 if (++qh->iso_idx >= urb->number_of_packets) 1581 if (++qh->iso_idx >= urb->number_of_packets)
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 162728977553..2e06b90aa1f8 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -179,6 +179,7 @@ static struct usb_device_id id_table_combined [] = {
179 { USB_DEVICE(FTDI_VID, FTDI_232RL_PID) }, 179 { USB_DEVICE(FTDI_VID, FTDI_232RL_PID) },
180 { USB_DEVICE(FTDI_VID, FTDI_8U2232C_PID) }, 180 { USB_DEVICE(FTDI_VID, FTDI_8U2232C_PID) },
181 { USB_DEVICE(FTDI_VID, FTDI_4232H_PID) }, 181 { USB_DEVICE(FTDI_VID, FTDI_4232H_PID) },
182 { USB_DEVICE(FTDI_VID, FTDI_232H_PID) },
182 { USB_DEVICE(FTDI_VID, FTDI_MICRO_CHAMELEON_PID) }, 183 { USB_DEVICE(FTDI_VID, FTDI_MICRO_CHAMELEON_PID) },
183 { USB_DEVICE(FTDI_VID, FTDI_RELAIS_PID) }, 184 { USB_DEVICE(FTDI_VID, FTDI_RELAIS_PID) },
184 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_PID) }, 185 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_PID) },
@@ -848,7 +849,8 @@ static const char *ftdi_chip_name[] = {
848 [FT2232C] = "FT2232C", 849 [FT2232C] = "FT2232C",
849 [FT232RL] = "FT232RL", 850 [FT232RL] = "FT232RL",
850 [FT2232H] = "FT2232H", 851 [FT2232H] = "FT2232H",
851 [FT4232H] = "FT4232H" 852 [FT4232H] = "FT4232H",
853 [FT232H] = "FT232H"
852}; 854};
853 855
854 856
@@ -1168,6 +1170,7 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty,
1168 break; 1170 break;
1169 case FT2232H: /* FT2232H chip */ 1171 case FT2232H: /* FT2232H chip */
1170 case FT4232H: /* FT4232H chip */ 1172 case FT4232H: /* FT4232H chip */
1173 case FT232H: /* FT232H chip */
1171 if ((baud <= 12000000) & (baud >= 1200)) { 1174 if ((baud <= 12000000) & (baud >= 1200)) {
1172 div_value = ftdi_2232h_baud_to_divisor(baud); 1175 div_value = ftdi_2232h_baud_to_divisor(baud);
1173 } else if (baud < 1200) { 1176 } else if (baud < 1200) {
@@ -1429,9 +1432,12 @@ static void ftdi_determine_type(struct usb_serial_port *port)
1429 } else if (version < 0x600) { 1432 } else if (version < 0x600) {
1430 /* Assume it's an FT232BM (or FT245BM) */ 1433 /* Assume it's an FT232BM (or FT245BM) */
1431 priv->chip_type = FT232BM; 1434 priv->chip_type = FT232BM;
1432 } else { 1435 } else if (version < 0x900) {
1433 /* Assume it's an FT232R */ 1436 /* Assume it's an FT232RL */
1434 priv->chip_type = FT232RL; 1437 priv->chip_type = FT232RL;
1438 } else {
1439 /* Assume it's an FT232H */
1440 priv->chip_type = FT232H;
1435 } 1441 }
1436 dev_info(&udev->dev, "Detected %s\n", ftdi_chip_name[priv->chip_type]); 1442 dev_info(&udev->dev, "Detected %s\n", ftdi_chip_name[priv->chip_type]);
1437} 1443}
@@ -1559,7 +1565,8 @@ static int create_sysfs_attrs(struct usb_serial_port *port)
1559 priv->chip_type == FT2232C || 1565 priv->chip_type == FT2232C ||
1560 priv->chip_type == FT232RL || 1566 priv->chip_type == FT232RL ||
1561 priv->chip_type == FT2232H || 1567 priv->chip_type == FT2232H ||
1562 priv->chip_type == FT4232H)) { 1568 priv->chip_type == FT4232H ||
1569 priv->chip_type == FT232H)) {
1563 retval = device_create_file(&port->dev, 1570 retval = device_create_file(&port->dev,
1564 &dev_attr_latency_timer); 1571 &dev_attr_latency_timer);
1565 } 1572 }
@@ -1580,7 +1587,8 @@ static void remove_sysfs_attrs(struct usb_serial_port *port)
1580 priv->chip_type == FT2232C || 1587 priv->chip_type == FT2232C ||
1581 priv->chip_type == FT232RL || 1588 priv->chip_type == FT232RL ||
1582 priv->chip_type == FT2232H || 1589 priv->chip_type == FT2232H ||
1583 priv->chip_type == FT4232H) { 1590 priv->chip_type == FT4232H ||
1591 priv->chip_type == FT232H) {
1584 device_remove_file(&port->dev, &dev_attr_latency_timer); 1592 device_remove_file(&port->dev, &dev_attr_latency_timer);
1585 } 1593 }
1586 } 1594 }
@@ -2212,6 +2220,7 @@ static int ftdi_tiocmget(struct tty_struct *tty)
2212 case FT232RL: 2220 case FT232RL:
2213 case FT2232H: 2221 case FT2232H:
2214 case FT4232H: 2222 case FT4232H:
2223 case FT232H:
2215 len = 2; 2224 len = 2;
2216 break; 2225 break;
2217 default: 2226 default:
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index 213fe3d61282..19584faa86f9 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -156,7 +156,8 @@ enum ftdi_chip_type {
156 FT2232C = 4, 156 FT2232C = 4,
157 FT232RL = 5, 157 FT232RL = 5,
158 FT2232H = 6, 158 FT2232H = 6,
159 FT4232H = 7 159 FT4232H = 7,
160 FT232H = 8
160}; 161};
161 162
162enum ftdi_sio_baudrate { 163enum ftdi_sio_baudrate {
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index ab1fcdf3c378..19156d1049fe 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -22,6 +22,7 @@
22#define FTDI_8U232AM_ALT_PID 0x6006 /* FTDI's alternate PID for above */ 22#define FTDI_8U232AM_ALT_PID 0x6006 /* FTDI's alternate PID for above */
23#define FTDI_8U2232C_PID 0x6010 /* Dual channel device */ 23#define FTDI_8U2232C_PID 0x6010 /* Dual channel device */
24#define FTDI_4232H_PID 0x6011 /* Quad channel hi-speed device */ 24#define FTDI_4232H_PID 0x6011 /* Quad channel hi-speed device */
25#define FTDI_232H_PID 0x6014 /* Single channel hi-speed device */
25#define FTDI_SIO_PID 0x8372 /* Product Id SIO application of 8U100AX */ 26#define FTDI_SIO_PID 0x8372 /* Product Id SIO application of 8U100AX */
26#define FTDI_232RL_PID 0xFBFA /* Product ID for FT232RL */ 27#define FTDI_232RL_PID 0xFBFA /* Product ID for FT232RL */
27 28
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index c6d92a530086..ea8445689c85 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -1745,6 +1745,7 @@ static int ti_download_firmware(struct ti_device *tdev)
1745 } 1745 }
1746 if (fw_p->size > TI_FIRMWARE_BUF_SIZE) { 1746 if (fw_p->size > TI_FIRMWARE_BUF_SIZE) {
1747 dev_err(&dev->dev, "%s - firmware too large %zu\n", __func__, fw_p->size); 1747 dev_err(&dev->dev, "%s - firmware too large %zu\n", __func__, fw_p->size);
1748 release_firmware(fw_p);
1748 return -ENOENT; 1749 return -ENOENT;
1749 } 1750 }
1750 1751
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 1a2421f908f0..610e8e0b04b8 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -762,7 +762,19 @@ static struct block_device *bd_start_claiming(struct block_device *bdev,
762 if (!disk) 762 if (!disk)
763 return ERR_PTR(-ENXIO); 763 return ERR_PTR(-ENXIO);
764 764
765 whole = bdget_disk(disk, 0); 765 /*
766 * Normally, @bdev should equal what's returned from bdget_disk()
767 * if partno is 0; however, some drivers (floppy) use multiple
768 * bdev's for the same physical device and @bdev may be one of the
769 * aliases. Keep @bdev if partno is 0. This means claimer
770 * tracking is broken for those devices but it has always been that
771 * way.
772 */
773 if (partno)
774 whole = bdget_disk(disk, 0);
775 else
776 whole = bdgrab(bdev);
777
766 module_put(disk->fops->owner); 778 module_put(disk->fops->owner);
767 put_disk(disk); 779 put_disk(disk);
768 if (!whole) 780 if (!whole)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 300628795fdb..f30ac05dbda7 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -19,7 +19,6 @@
19#ifndef __BTRFS_CTREE__ 19#ifndef __BTRFS_CTREE__
20#define __BTRFS_CTREE__ 20#define __BTRFS_CTREE__
21 21
22#include <linux/version.h>
23#include <linux/mm.h> 22#include <linux/mm.h>
24#include <linux/highmem.h> 23#include <linux/highmem.h>
25#include <linux/fs.h> 24#include <linux/fs.h>
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index f1cbd028f7b3..98c68e658a9b 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -82,19 +82,16 @@ static inline struct btrfs_delayed_root *btrfs_get_delayed_root(
82 return root->fs_info->delayed_root; 82 return root->fs_info->delayed_root;
83} 83}
84 84
85static struct btrfs_delayed_node *btrfs_get_or_create_delayed_node( 85static struct btrfs_delayed_node *btrfs_get_delayed_node(struct inode *inode)
86 struct inode *inode)
87{ 86{
88 struct btrfs_delayed_node *node;
89 struct btrfs_inode *btrfs_inode = BTRFS_I(inode); 87 struct btrfs_inode *btrfs_inode = BTRFS_I(inode);
90 struct btrfs_root *root = btrfs_inode->root; 88 struct btrfs_root *root = btrfs_inode->root;
91 u64 ino = btrfs_ino(inode); 89 u64 ino = btrfs_ino(inode);
92 int ret; 90 struct btrfs_delayed_node *node;
93 91
94again:
95 node = ACCESS_ONCE(btrfs_inode->delayed_node); 92 node = ACCESS_ONCE(btrfs_inode->delayed_node);
96 if (node) { 93 if (node) {
97 atomic_inc(&node->refs); /* can be accessed */ 94 atomic_inc(&node->refs);
98 return node; 95 return node;
99 } 96 }
100 97
@@ -102,8 +99,10 @@ again:
102 node = radix_tree_lookup(&root->delayed_nodes_tree, ino); 99 node = radix_tree_lookup(&root->delayed_nodes_tree, ino);
103 if (node) { 100 if (node) {
104 if (btrfs_inode->delayed_node) { 101 if (btrfs_inode->delayed_node) {
102 atomic_inc(&node->refs); /* can be accessed */
103 BUG_ON(btrfs_inode->delayed_node != node);
105 spin_unlock(&root->inode_lock); 104 spin_unlock(&root->inode_lock);
106 goto again; 105 return node;
107 } 106 }
108 btrfs_inode->delayed_node = node; 107 btrfs_inode->delayed_node = node;
109 atomic_inc(&node->refs); /* can be accessed */ 108 atomic_inc(&node->refs); /* can be accessed */
@@ -113,6 +112,23 @@ again:
113 } 112 }
114 spin_unlock(&root->inode_lock); 113 spin_unlock(&root->inode_lock);
115 114
115 return NULL;
116}
117
118static struct btrfs_delayed_node *btrfs_get_or_create_delayed_node(
119 struct inode *inode)
120{
121 struct btrfs_delayed_node *node;
122 struct btrfs_inode *btrfs_inode = BTRFS_I(inode);
123 struct btrfs_root *root = btrfs_inode->root;
124 u64 ino = btrfs_ino(inode);
125 int ret;
126
127again:
128 node = btrfs_get_delayed_node(inode);
129 if (node)
130 return node;
131
116 node = kmem_cache_alloc(delayed_node_cache, GFP_NOFS); 132 node = kmem_cache_alloc(delayed_node_cache, GFP_NOFS);
117 if (!node) 133 if (!node)
118 return ERR_PTR(-ENOMEM); 134 return ERR_PTR(-ENOMEM);
@@ -548,19 +564,6 @@ struct btrfs_delayed_item *__btrfs_next_delayed_item(
548 return next; 564 return next;
549} 565}
550 566
551static inline struct btrfs_delayed_node *btrfs_get_delayed_node(
552 struct inode *inode)
553{
554 struct btrfs_inode *btrfs_inode = BTRFS_I(inode);
555 struct btrfs_delayed_node *delayed_node;
556
557 delayed_node = btrfs_inode->delayed_node;
558 if (delayed_node)
559 atomic_inc(&delayed_node->refs);
560
561 return delayed_node;
562}
563
564static inline struct btrfs_root *btrfs_get_fs_root(struct btrfs_root *root, 567static inline struct btrfs_root *btrfs_get_fs_root(struct btrfs_root *root,
565 u64 root_id) 568 u64 root_id)
566{ 569{
@@ -1404,8 +1407,7 @@ end:
1404 1407
1405int btrfs_inode_delayed_dir_index_count(struct inode *inode) 1408int btrfs_inode_delayed_dir_index_count(struct inode *inode)
1406{ 1409{
1407 struct btrfs_delayed_node *delayed_node = BTRFS_I(inode)->delayed_node; 1410 struct btrfs_delayed_node *delayed_node = btrfs_get_delayed_node(inode);
1408 int ret = 0;
1409 1411
1410 if (!delayed_node) 1412 if (!delayed_node)
1411 return -ENOENT; 1413 return -ENOENT;
@@ -1415,11 +1417,14 @@ int btrfs_inode_delayed_dir_index_count(struct inode *inode)
1415 * a new directory index is added into the delayed node and index_cnt 1417 * a new directory index is added into the delayed node and index_cnt
1416 * is updated now. So we needn't lock the delayed node. 1418 * is updated now. So we needn't lock the delayed node.
1417 */ 1419 */
1418 if (!delayed_node->index_cnt) 1420 if (!delayed_node->index_cnt) {
1421 btrfs_release_delayed_node(delayed_node);
1419 return -EINVAL; 1422 return -EINVAL;
1423 }
1420 1424
1421 BTRFS_I(inode)->index_cnt = delayed_node->index_cnt; 1425 BTRFS_I(inode)->index_cnt = delayed_node->index_cnt;
1422 return ret; 1426 btrfs_release_delayed_node(delayed_node);
1427 return 0;
1423} 1428}
1424 1429
1425void btrfs_get_delayed_items(struct inode *inode, struct list_head *ins_list, 1430void btrfs_get_delayed_items(struct inode *inode, struct list_head *ins_list,
@@ -1613,6 +1618,57 @@ static void fill_stack_inode_item(struct btrfs_trans_handle *trans,
1613 inode->i_ctime.tv_nsec); 1618 inode->i_ctime.tv_nsec);
1614} 1619}
1615 1620
1621int btrfs_fill_inode(struct inode *inode, u32 *rdev)
1622{
1623 struct btrfs_delayed_node *delayed_node;
1624 struct btrfs_inode_item *inode_item;
1625 struct btrfs_timespec *tspec;
1626
1627 delayed_node = btrfs_get_delayed_node(inode);
1628 if (!delayed_node)
1629 return -ENOENT;
1630
1631 mutex_lock(&delayed_node->mutex);
1632 if (!delayed_node->inode_dirty) {
1633 mutex_unlock(&delayed_node->mutex);
1634 btrfs_release_delayed_node(delayed_node);
1635 return -ENOENT;
1636 }
1637
1638 inode_item = &delayed_node->inode_item;
1639
1640 inode->i_uid = btrfs_stack_inode_uid(inode_item);
1641 inode->i_gid = btrfs_stack_inode_gid(inode_item);
1642 btrfs_i_size_write(inode, btrfs_stack_inode_size(inode_item));
1643 inode->i_mode = btrfs_stack_inode_mode(inode_item);
1644 inode->i_nlink = btrfs_stack_inode_nlink(inode_item);
1645 inode_set_bytes(inode, btrfs_stack_inode_nbytes(inode_item));
1646 BTRFS_I(inode)->generation = btrfs_stack_inode_generation(inode_item);
1647 BTRFS_I(inode)->sequence = btrfs_stack_inode_sequence(inode_item);
1648 inode->i_rdev = 0;
1649 *rdev = btrfs_stack_inode_rdev(inode_item);
1650 BTRFS_I(inode)->flags = btrfs_stack_inode_flags(inode_item);
1651
1652 tspec = btrfs_inode_atime(inode_item);
1653 inode->i_atime.tv_sec = btrfs_stack_timespec_sec(tspec);
1654 inode->i_atime.tv_nsec = btrfs_stack_timespec_nsec(tspec);
1655
1656 tspec = btrfs_inode_mtime(inode_item);
1657 inode->i_mtime.tv_sec = btrfs_stack_timespec_sec(tspec);
1658 inode->i_mtime.tv_nsec = btrfs_stack_timespec_nsec(tspec);
1659
1660 tspec = btrfs_inode_ctime(inode_item);
1661 inode->i_ctime.tv_sec = btrfs_stack_timespec_sec(tspec);
1662 inode->i_ctime.tv_nsec = btrfs_stack_timespec_nsec(tspec);
1663
1664 inode->i_generation = BTRFS_I(inode)->generation;
1665 BTRFS_I(inode)->index_cnt = (u64)-1;
1666
1667 mutex_unlock(&delayed_node->mutex);
1668 btrfs_release_delayed_node(delayed_node);
1669 return 0;
1670}
1671
1616int btrfs_delayed_update_inode(struct btrfs_trans_handle *trans, 1672int btrfs_delayed_update_inode(struct btrfs_trans_handle *trans,
1617 struct btrfs_root *root, struct inode *inode) 1673 struct btrfs_root *root, struct inode *inode)
1618{ 1674{
diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
index d1a6a2915c66..8d27af4bd8b9 100644
--- a/fs/btrfs/delayed-inode.h
+++ b/fs/btrfs/delayed-inode.h
@@ -119,6 +119,7 @@ void btrfs_kill_delayed_inode_items(struct inode *inode);
119 119
120int btrfs_delayed_update_inode(struct btrfs_trans_handle *trans, 120int btrfs_delayed_update_inode(struct btrfs_trans_handle *trans,
121 struct btrfs_root *root, struct inode *inode); 121 struct btrfs_root *root, struct inode *inode);
122int btrfs_fill_inode(struct inode *inode, u32 *rdev);
122 123
123/* Used for drop dead root */ 124/* Used for drop dead root */
124void btrfs_kill_all_delayed_nodes(struct btrfs_root *root); 125void btrfs_kill_all_delayed_nodes(struct btrfs_root *root);
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 1f61bf5b4960..71cd456fdb60 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4842,7 +4842,7 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans,
4842 u64 num_bytes, u64 empty_size, 4842 u64 num_bytes, u64 empty_size,
4843 u64 search_start, u64 search_end, 4843 u64 search_start, u64 search_end,
4844 u64 hint_byte, struct btrfs_key *ins, 4844 u64 hint_byte, struct btrfs_key *ins,
4845 int data) 4845 u64 data)
4846{ 4846{
4847 int ret = 0; 4847 int ret = 0;
4848 struct btrfs_root *root = orig_root->fs_info->extent_root; 4848 struct btrfs_root *root = orig_root->fs_info->extent_root;
@@ -4869,7 +4869,7 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans,
4869 4869
4870 space_info = __find_space_info(root->fs_info, data); 4870 space_info = __find_space_info(root->fs_info, data);
4871 if (!space_info) { 4871 if (!space_info) {
4872 printk(KERN_ERR "No space info for %d\n", data); 4872 printk(KERN_ERR "No space info for %llu\n", data);
4873 return -ENOSPC; 4873 return -ENOSPC;
4874 } 4874 }
4875 4875
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 9f985a429877..bf0d61567f3d 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -1893,9 +1893,12 @@ void __btrfs_remove_free_space_cache_locked(struct btrfs_free_space_ctl *ctl)
1893 1893
1894 while ((node = rb_last(&ctl->free_space_offset)) != NULL) { 1894 while ((node = rb_last(&ctl->free_space_offset)) != NULL) {
1895 info = rb_entry(node, struct btrfs_free_space, offset_index); 1895 info = rb_entry(node, struct btrfs_free_space, offset_index);
1896 unlink_free_space(ctl, info); 1896 if (!info->bitmap) {
1897 kfree(info->bitmap); 1897 unlink_free_space(ctl, info);
1898 kmem_cache_free(btrfs_free_space_cachep, info); 1898 kmem_cache_free(btrfs_free_space_cachep, info);
1899 } else {
1900 free_bitmap(ctl, info);
1901 }
1899 if (need_resched()) { 1902 if (need_resched()) {
1900 spin_unlock(&ctl->tree_lock); 1903 spin_unlock(&ctl->tree_lock);
1901 cond_resched(); 1904 cond_resched();
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 0a9b10c5b0a7..d340f63d8f07 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2509,6 +2509,11 @@ static void btrfs_read_locked_inode(struct inode *inode)
2509 int maybe_acls; 2509 int maybe_acls;
2510 u32 rdev; 2510 u32 rdev;
2511 int ret; 2511 int ret;
2512 bool filled = false;
2513
2514 ret = btrfs_fill_inode(inode, &rdev);
2515 if (!ret)
2516 filled = true;
2512 2517
2513 path = btrfs_alloc_path(); 2518 path = btrfs_alloc_path();
2514 BUG_ON(!path); 2519 BUG_ON(!path);
@@ -2520,6 +2525,10 @@ static void btrfs_read_locked_inode(struct inode *inode)
2520 goto make_bad; 2525 goto make_bad;
2521 2526
2522 leaf = path->nodes[0]; 2527 leaf = path->nodes[0];
2528
2529 if (filled)
2530 goto cache_acl;
2531
2523 inode_item = btrfs_item_ptr(leaf, path->slots[0], 2532 inode_item = btrfs_item_ptr(leaf, path->slots[0],
2524 struct btrfs_inode_item); 2533 struct btrfs_inode_item);
2525 if (!leaf->map_token) 2534 if (!leaf->map_token)
@@ -2556,7 +2565,7 @@ static void btrfs_read_locked_inode(struct inode *inode)
2556 2565
2557 BTRFS_I(inode)->index_cnt = (u64)-1; 2566 BTRFS_I(inode)->index_cnt = (u64)-1;
2558 BTRFS_I(inode)->flags = btrfs_inode_flags(leaf, inode_item); 2567 BTRFS_I(inode)->flags = btrfs_inode_flags(leaf, inode_item);
2559 2568cache_acl:
2560 /* 2569 /*
2561 * try to precache a NULL acl entry for files that don't have 2570 * try to precache a NULL acl entry for files that don't have
2562 * any xattrs or acls 2571 * any xattrs or acls
@@ -2572,7 +2581,6 @@ static void btrfs_read_locked_inode(struct inode *inode)
2572 } 2581 }
2573 2582
2574 btrfs_free_path(path); 2583 btrfs_free_path(path);
2575 inode_item = NULL;
2576 2584
2577 switch (inode->i_mode & S_IFMT) { 2585 switch (inode->i_mode & S_IFMT) {
2578 case S_IFREG: 2586 case S_IFREG:
@@ -4520,6 +4528,7 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
4520 inode_tree_add(inode); 4528 inode_tree_add(inode);
4521 4529
4522 trace_btrfs_inode_new(inode); 4530 trace_btrfs_inode_new(inode);
4531 btrfs_set_inode_last_trans(trans, inode);
4523 4532
4524 return inode; 4533 return inode;
4525fail: 4534fail:
diff --git a/fs/cifs/Kconfig b/fs/cifs/Kconfig
index 53ed1ad2c112..f66cc1625150 100644
--- a/fs/cifs/Kconfig
+++ b/fs/cifs/Kconfig
@@ -156,6 +156,6 @@ config CIFS_ACL
156 156
157config CIFS_NFSD_EXPORT 157config CIFS_NFSD_EXPORT
158 bool "Allow nfsd to export CIFS file system (EXPERIMENTAL)" 158 bool "Allow nfsd to export CIFS file system (EXPERIMENTAL)"
159 depends on CIFS && EXPERIMENTAL 159 depends on CIFS && EXPERIMENTAL && BROKEN
160 help 160 help
161 Allows NFS server to export a CIFS mounted share (nfsd over cifs) 161 Allows NFS server to export a CIFS mounted share (nfsd over cifs)
diff --git a/fs/cifs/cifs_fs_sb.h b/fs/cifs/cifs_fs_sb.h
index ffb1459dc6ec..7260e11e21f8 100644
--- a/fs/cifs/cifs_fs_sb.h
+++ b/fs/cifs/cifs_fs_sb.h
@@ -42,6 +42,7 @@
42#define CIFS_MOUNT_MULTIUSER 0x20000 /* multiuser mount */ 42#define CIFS_MOUNT_MULTIUSER 0x20000 /* multiuser mount */
43#define CIFS_MOUNT_STRICT_IO 0x40000 /* strict cache mode */ 43#define CIFS_MOUNT_STRICT_IO 0x40000 /* strict cache mode */
44#define CIFS_MOUNT_RWPIDFORWARD 0x80000 /* use pid forwarding for rw */ 44#define CIFS_MOUNT_RWPIDFORWARD 0x80000 /* use pid forwarding for rw */
45#define CIFS_MOUNT_POSIXACL 0x100000 /* mirror of MS_POSIXACL in mnt_cifs_flags */
45 46
46struct cifs_sb_info { 47struct cifs_sb_info {
47 struct rb_root tlink_tree; 48 struct rb_root tlink_tree;
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 2f0c58646c10..35f9154615fa 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -104,8 +104,7 @@ cifs_sb_deactive(struct super_block *sb)
104} 104}
105 105
106static int 106static int
107cifs_read_super(struct super_block *sb, struct smb_vol *volume_info, 107cifs_read_super(struct super_block *sb)
108 const char *devname, int silent)
109{ 108{
110 struct inode *inode; 109 struct inode *inode;
111 struct cifs_sb_info *cifs_sb; 110 struct cifs_sb_info *cifs_sb;
@@ -113,22 +112,16 @@ cifs_read_super(struct super_block *sb, struct smb_vol *volume_info,
113 112
114 cifs_sb = CIFS_SB(sb); 113 cifs_sb = CIFS_SB(sb);
115 114
116 spin_lock_init(&cifs_sb->tlink_tree_lock); 115 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIXACL)
117 cifs_sb->tlink_tree = RB_ROOT; 116 sb->s_flags |= MS_POSIXACL;
118 117
119 rc = bdi_setup_and_register(&cifs_sb->bdi, "cifs", BDI_CAP_MAP_COPY); 118 if (cifs_sb_master_tcon(cifs_sb)->ses->capabilities & CAP_LARGE_FILES)
120 if (rc) 119 sb->s_maxbytes = MAX_LFS_FILESIZE;
121 return rc; 120 else
122 121 sb->s_maxbytes = MAX_NON_LFS;
123 cifs_sb->bdi.ra_pages = default_backing_dev_info.ra_pages;
124 122
125 rc = cifs_mount(sb, cifs_sb, volume_info, devname); 123 /* BB FIXME fix time_gran to be larger for LANMAN sessions */
126 124 sb->s_time_gran = 100;
127 if (rc) {
128 if (!silent)
129 cERROR(1, "cifs_mount failed w/return code = %d", rc);
130 goto out_mount_failed;
131 }
132 125
133 sb->s_magic = CIFS_MAGIC_NUMBER; 126 sb->s_magic = CIFS_MAGIC_NUMBER;
134 sb->s_op = &cifs_super_ops; 127 sb->s_op = &cifs_super_ops;
@@ -170,37 +163,14 @@ out_no_root:
170 if (inode) 163 if (inode)
171 iput(inode); 164 iput(inode);
172 165
173 cifs_umount(sb, cifs_sb);
174
175out_mount_failed:
176 bdi_destroy(&cifs_sb->bdi);
177 return rc; 166 return rc;
178} 167}
179 168
180static void 169static void cifs_kill_sb(struct super_block *sb)
181cifs_put_super(struct super_block *sb)
182{ 170{
183 int rc = 0; 171 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
184 struct cifs_sb_info *cifs_sb; 172 kill_anon_super(sb);
185 173 cifs_umount(cifs_sb);
186 cFYI(1, "In cifs_put_super");
187 cifs_sb = CIFS_SB(sb);
188 if (cifs_sb == NULL) {
189 cFYI(1, "Empty cifs superblock info passed to unmount");
190 return;
191 }
192
193 rc = cifs_umount(sb, cifs_sb);
194 if (rc)
195 cERROR(1, "cifs_umount failed with return code %d", rc);
196 if (cifs_sb->mountdata) {
197 kfree(cifs_sb->mountdata);
198 cifs_sb->mountdata = NULL;
199 }
200
201 unload_nls(cifs_sb->local_nls);
202 bdi_destroy(&cifs_sb->bdi);
203 kfree(cifs_sb);
204} 174}
205 175
206static int 176static int
@@ -548,7 +518,6 @@ static int cifs_drop_inode(struct inode *inode)
548} 518}
549 519
550static const struct super_operations cifs_super_ops = { 520static const struct super_operations cifs_super_ops = {
551 .put_super = cifs_put_super,
552 .statfs = cifs_statfs, 521 .statfs = cifs_statfs,
553 .alloc_inode = cifs_alloc_inode, 522 .alloc_inode = cifs_alloc_inode,
554 .destroy_inode = cifs_destroy_inode, 523 .destroy_inode = cifs_destroy_inode,
@@ -585,7 +554,7 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb)
585 full_path = cifs_build_path_to_root(vol, cifs_sb, 554 full_path = cifs_build_path_to_root(vol, cifs_sb,
586 cifs_sb_master_tcon(cifs_sb)); 555 cifs_sb_master_tcon(cifs_sb));
587 if (full_path == NULL) 556 if (full_path == NULL)
588 return NULL; 557 return ERR_PTR(-ENOMEM);
589 558
590 cFYI(1, "Get root dentry for %s", full_path); 559 cFYI(1, "Get root dentry for %s", full_path);
591 560
@@ -614,7 +583,7 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb)
614 dchild = d_alloc(dparent, &name); 583 dchild = d_alloc(dparent, &name);
615 if (dchild == NULL) { 584 if (dchild == NULL) {
616 dput(dparent); 585 dput(dparent);
617 dparent = NULL; 586 dparent = ERR_PTR(-ENOMEM);
618 goto out; 587 goto out;
619 } 588 }
620 } 589 }
@@ -632,7 +601,7 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb)
632 if (rc) { 601 if (rc) {
633 dput(dchild); 602 dput(dchild);
634 dput(dparent); 603 dput(dparent);
635 dparent = NULL; 604 dparent = ERR_PTR(rc);
636 goto out; 605 goto out;
637 } 606 }
638 alias = d_materialise_unique(dchild, inode); 607 alias = d_materialise_unique(dchild, inode);
@@ -640,7 +609,7 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb)
640 dput(dchild); 609 dput(dchild);
641 if (IS_ERR(alias)) { 610 if (IS_ERR(alias)) {
642 dput(dparent); 611 dput(dparent);
643 dparent = NULL; 612 dparent = ERR_PTR(-EINVAL); /* XXX */
644 goto out; 613 goto out;
645 } 614 }
646 dchild = alias; 615 dchild = alias;
@@ -660,6 +629,13 @@ out:
660 return dparent; 629 return dparent;
661} 630}
662 631
632static int cifs_set_super(struct super_block *sb, void *data)
633{
634 struct cifs_mnt_data *mnt_data = data;
635 sb->s_fs_info = mnt_data->cifs_sb;
636 return set_anon_super(sb, NULL);
637}
638
663static struct dentry * 639static struct dentry *
664cifs_do_mount(struct file_system_type *fs_type, 640cifs_do_mount(struct file_system_type *fs_type,
665 int flags, const char *dev_name, void *data) 641 int flags, const char *dev_name, void *data)
@@ -680,75 +656,73 @@ cifs_do_mount(struct file_system_type *fs_type,
680 cifs_sb = kzalloc(sizeof(struct cifs_sb_info), GFP_KERNEL); 656 cifs_sb = kzalloc(sizeof(struct cifs_sb_info), GFP_KERNEL);
681 if (cifs_sb == NULL) { 657 if (cifs_sb == NULL) {
682 root = ERR_PTR(-ENOMEM); 658 root = ERR_PTR(-ENOMEM);
683 goto out; 659 goto out_nls;
660 }
661
662 cifs_sb->mountdata = kstrndup(data, PAGE_SIZE, GFP_KERNEL);
663 if (cifs_sb->mountdata == NULL) {
664 root = ERR_PTR(-ENOMEM);
665 goto out_cifs_sb;
684 } 666 }
685 667
686 cifs_setup_cifs_sb(volume_info, cifs_sb); 668 cifs_setup_cifs_sb(volume_info, cifs_sb);
687 669
670 rc = cifs_mount(cifs_sb, volume_info);
671 if (rc) {
672 if (!(flags & MS_SILENT))
673 cERROR(1, "cifs_mount failed w/return code = %d", rc);
674 root = ERR_PTR(rc);
675 goto out_mountdata;
676 }
677
688 mnt_data.vol = volume_info; 678 mnt_data.vol = volume_info;
689 mnt_data.cifs_sb = cifs_sb; 679 mnt_data.cifs_sb = cifs_sb;
690 mnt_data.flags = flags; 680 mnt_data.flags = flags;
691 681
692 sb = sget(fs_type, cifs_match_super, set_anon_super, &mnt_data); 682 sb = sget(fs_type, cifs_match_super, cifs_set_super, &mnt_data);
693 if (IS_ERR(sb)) { 683 if (IS_ERR(sb)) {
694 root = ERR_CAST(sb); 684 root = ERR_CAST(sb);
695 goto out_cifs_sb; 685 cifs_umount(cifs_sb);
686 goto out;
696 } 687 }
697 688
698 if (sb->s_fs_info) { 689 if (sb->s_root) {
699 cFYI(1, "Use existing superblock"); 690 cFYI(1, "Use existing superblock");
700 goto out_shared; 691 cifs_umount(cifs_sb);
701 } 692 } else {
702 693 sb->s_flags = flags;
703 /* 694 /* BB should we make this contingent on mount parm? */
704 * Copy mount params for use in submounts. Better to do 695 sb->s_flags |= MS_NODIRATIME | MS_NOATIME;
705 * the copy here and deal with the error before cleanup gets 696
706 * complicated post-mount. 697 rc = cifs_read_super(sb);
707 */ 698 if (rc) {
708 cifs_sb->mountdata = kstrndup(data, PAGE_SIZE, GFP_KERNEL); 699 root = ERR_PTR(rc);
709 if (cifs_sb->mountdata == NULL) { 700 goto out_super;
710 root = ERR_PTR(-ENOMEM); 701 }
711 goto out_super;
712 }
713
714 sb->s_flags = flags;
715 /* BB should we make this contingent on mount parm? */
716 sb->s_flags |= MS_NODIRATIME | MS_NOATIME;
717 sb->s_fs_info = cifs_sb;
718 702
719 rc = cifs_read_super(sb, volume_info, dev_name, 703 sb->s_flags |= MS_ACTIVE;
720 flags & MS_SILENT ? 1 : 0);
721 if (rc) {
722 root = ERR_PTR(rc);
723 goto out_super;
724 } 704 }
725 705
726 sb->s_flags |= MS_ACTIVE;
727
728 root = cifs_get_root(volume_info, sb); 706 root = cifs_get_root(volume_info, sb);
729 if (root == NULL) 707 if (IS_ERR(root))
730 goto out_super; 708 goto out_super;
731 709
732 cFYI(1, "dentry root is: %p", root); 710 cFYI(1, "dentry root is: %p", root);
733 goto out; 711 goto out;
734 712
735out_shared:
736 root = cifs_get_root(volume_info, sb);
737 if (root)
738 cFYI(1, "dentry root is: %p", root);
739 goto out;
740
741out_super: 713out_super:
742 kfree(cifs_sb->mountdata);
743 deactivate_locked_super(sb); 714 deactivate_locked_super(sb);
744
745out_cifs_sb:
746 unload_nls(cifs_sb->local_nls);
747 kfree(cifs_sb);
748
749out: 715out:
750 cifs_cleanup_volume_info(&volume_info); 716 cifs_cleanup_volume_info(&volume_info);
751 return root; 717 return root;
718
719out_mountdata:
720 kfree(cifs_sb->mountdata);
721out_cifs_sb:
722 kfree(cifs_sb);
723out_nls:
724 unload_nls(volume_info->local_nls);
725 goto out;
752} 726}
753 727
754static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov, 728static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
@@ -837,7 +811,7 @@ struct file_system_type cifs_fs_type = {
837 .owner = THIS_MODULE, 811 .owner = THIS_MODULE,
838 .name = "cifs", 812 .name = "cifs",
839 .mount = cifs_do_mount, 813 .mount = cifs_do_mount,
840 .kill_sb = kill_anon_super, 814 .kill_sb = cifs_kill_sb,
841 /* .fs_flags */ 815 /* .fs_flags */
842}; 816};
843const struct inode_operations cifs_dir_inode_ops = { 817const struct inode_operations cifs_dir_inode_ops = {
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 953f84413c77..257f312ede42 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -157,9 +157,8 @@ extern int cifs_match_super(struct super_block *, void *);
157extern void cifs_cleanup_volume_info(struct smb_vol **pvolume_info); 157extern void cifs_cleanup_volume_info(struct smb_vol **pvolume_info);
158extern int cifs_setup_volume_info(struct smb_vol **pvolume_info, 158extern int cifs_setup_volume_info(struct smb_vol **pvolume_info,
159 char *mount_data, const char *devname); 159 char *mount_data, const char *devname);
160extern int cifs_mount(struct super_block *, struct cifs_sb_info *, 160extern int cifs_mount(struct cifs_sb_info *, struct smb_vol *);
161 struct smb_vol *, const char *); 161extern void cifs_umount(struct cifs_sb_info *);
162extern int cifs_umount(struct super_block *, struct cifs_sb_info *);
163extern void cifs_dfs_release_automount_timer(void); 162extern void cifs_dfs_release_automount_timer(void);
164void cifs_proc_init(void); 163void cifs_proc_init(void);
165void cifs_proc_clean(void); 164void cifs_proc_clean(void);
@@ -218,7 +217,8 @@ extern int get_dfs_path(int xid, struct cifs_ses *pSesInfo,
218 struct dfs_info3_param **preferrals, 217 struct dfs_info3_param **preferrals,
219 int remap); 218 int remap);
220extern void reset_cifs_unix_caps(int xid, struct cifs_tcon *tcon, 219extern void reset_cifs_unix_caps(int xid, struct cifs_tcon *tcon,
221 struct super_block *sb, struct smb_vol *vol); 220 struct cifs_sb_info *cifs_sb,
221 struct smb_vol *vol);
222extern int CIFSSMBQFSInfo(const int xid, struct cifs_tcon *tcon, 222extern int CIFSSMBQFSInfo(const int xid, struct cifs_tcon *tcon,
223 struct kstatfs *FSData); 223 struct kstatfs *FSData);
224extern int SMBOldQFSInfo(const int xid, struct cifs_tcon *tcon, 224extern int SMBOldQFSInfo(const int xid, struct cifs_tcon *tcon,
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 12cf72dd0c42..7f540df52527 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -2546,7 +2546,7 @@ ip_connect(struct TCP_Server_Info *server)
2546} 2546}
2547 2547
2548void reset_cifs_unix_caps(int xid, struct cifs_tcon *tcon, 2548void reset_cifs_unix_caps(int xid, struct cifs_tcon *tcon,
2549 struct super_block *sb, struct smb_vol *vol_info) 2549 struct cifs_sb_info *cifs_sb, struct smb_vol *vol_info)
2550{ 2550{
2551 /* if we are reconnecting then should we check to see if 2551 /* if we are reconnecting then should we check to see if
2552 * any requested capabilities changed locally e.g. via 2552 * any requested capabilities changed locally e.g. via
@@ -2600,22 +2600,23 @@ void reset_cifs_unix_caps(int xid, struct cifs_tcon *tcon,
2600 cap &= ~CIFS_UNIX_POSIX_ACL_CAP; 2600 cap &= ~CIFS_UNIX_POSIX_ACL_CAP;
2601 else if (CIFS_UNIX_POSIX_ACL_CAP & cap) { 2601 else if (CIFS_UNIX_POSIX_ACL_CAP & cap) {
2602 cFYI(1, "negotiated posix acl support"); 2602 cFYI(1, "negotiated posix acl support");
2603 if (sb) 2603 if (cifs_sb)
2604 sb->s_flags |= MS_POSIXACL; 2604 cifs_sb->mnt_cifs_flags |=
2605 CIFS_MOUNT_POSIXACL;
2605 } 2606 }
2606 2607
2607 if (vol_info && vol_info->posix_paths == 0) 2608 if (vol_info && vol_info->posix_paths == 0)
2608 cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP; 2609 cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP;
2609 else if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) { 2610 else if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) {
2610 cFYI(1, "negotiate posix pathnames"); 2611 cFYI(1, "negotiate posix pathnames");
2611 if (sb) 2612 if (cifs_sb)
2612 CIFS_SB(sb)->mnt_cifs_flags |= 2613 cifs_sb->mnt_cifs_flags |=
2613 CIFS_MOUNT_POSIX_PATHS; 2614 CIFS_MOUNT_POSIX_PATHS;
2614 } 2615 }
2615 2616
2616 if (sb && (CIFS_SB(sb)->rsize > 127 * 1024)) { 2617 if (cifs_sb && (cifs_sb->rsize > 127 * 1024)) {
2617 if ((cap & CIFS_UNIX_LARGE_READ_CAP) == 0) { 2618 if ((cap & CIFS_UNIX_LARGE_READ_CAP) == 0) {
2618 CIFS_SB(sb)->rsize = 127 * 1024; 2619 cifs_sb->rsize = 127 * 1024;
2619 cFYI(DBG2, "larger reads not supported by srv"); 2620 cFYI(DBG2, "larger reads not supported by srv");
2620 } 2621 }
2621 } 2622 }
@@ -2662,6 +2663,9 @@ void cifs_setup_cifs_sb(struct smb_vol *pvolume_info,
2662{ 2663{
2663 INIT_DELAYED_WORK(&cifs_sb->prune_tlinks, cifs_prune_tlinks); 2664 INIT_DELAYED_WORK(&cifs_sb->prune_tlinks, cifs_prune_tlinks);
2664 2665
2666 spin_lock_init(&cifs_sb->tlink_tree_lock);
2667 cifs_sb->tlink_tree = RB_ROOT;
2668
2665 if (pvolume_info->rsize > CIFSMaxBufSize) { 2669 if (pvolume_info->rsize > CIFSMaxBufSize) {
2666 cERROR(1, "rsize %d too large, using MaxBufSize", 2670 cERROR(1, "rsize %d too large, using MaxBufSize",
2667 pvolume_info->rsize); 2671 pvolume_info->rsize);
@@ -2750,21 +2754,21 @@ void cifs_setup_cifs_sb(struct smb_vol *pvolume_info,
2750 2754
2751/* 2755/*
2752 * When the server supports very large writes via POSIX extensions, we can 2756 * When the server supports very large writes via POSIX extensions, we can
2753 * allow up to 2^24 - PAGE_CACHE_SIZE. 2757 * allow up to 2^24-1, minus the size of a WRITE_AND_X header, not including
2758 * the RFC1001 length.
2754 * 2759 *
2755 * Note that this might make for "interesting" allocation problems during 2760 * Note that this might make for "interesting" allocation problems during
2756 * writeback however (as we have to allocate an array of pointers for the 2761 * writeback however as we have to allocate an array of pointers for the
2757 * pages). A 16M write means ~32kb page array with PAGE_CACHE_SIZE == 4096. 2762 * pages. A 16M write means ~32kb page array with PAGE_CACHE_SIZE == 4096.
2758 */ 2763 */
2759#define CIFS_MAX_WSIZE ((1<<24) - PAGE_CACHE_SIZE) 2764#define CIFS_MAX_WSIZE ((1<<24) - 1 - sizeof(WRITE_REQ) + 4)
2760 2765
2761/* 2766/*
2762 * When the server doesn't allow large posix writes, default to a wsize of 2767 * When the server doesn't allow large posix writes, only allow a wsize of
2763 * 128k - PAGE_CACHE_SIZE -- one page less than the largest frame size 2768 * 128k minus the size of the WRITE_AND_X header. That allows for a write up
2764 * described in RFC1001. This allows space for the header without going over 2769 * to the maximum size described by RFC1002.
2765 * that by default.
2766 */ 2770 */
2767#define CIFS_MAX_RFC1001_WSIZE (128 * 1024 - PAGE_CACHE_SIZE) 2771#define CIFS_MAX_RFC1002_WSIZE (128 * 1024 - sizeof(WRITE_REQ) + 4)
2768 2772
2769/* 2773/*
2770 * The default wsize is 1M. find_get_pages seems to return a maximum of 256 2774 * The default wsize is 1M. find_get_pages seems to return a maximum of 256
@@ -2783,11 +2787,18 @@ cifs_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *pvolume_info)
2783 2787
2784 /* can server support 24-bit write sizes? (via UNIX extensions) */ 2788 /* can server support 24-bit write sizes? (via UNIX extensions) */
2785 if (!tcon->unix_ext || !(unix_cap & CIFS_UNIX_LARGE_WRITE_CAP)) 2789 if (!tcon->unix_ext || !(unix_cap & CIFS_UNIX_LARGE_WRITE_CAP))
2786 wsize = min_t(unsigned int, wsize, CIFS_MAX_RFC1001_WSIZE); 2790 wsize = min_t(unsigned int, wsize, CIFS_MAX_RFC1002_WSIZE);
2787 2791
2788 /* no CAP_LARGE_WRITE_X? Limit it to 16 bits */ 2792 /*
2789 if (!(server->capabilities & CAP_LARGE_WRITE_X)) 2793 * no CAP_LARGE_WRITE_X or is signing enabled without CAP_UNIX set?
2790 wsize = min_t(unsigned int, wsize, USHRT_MAX); 2794 * Limit it to max buffer offered by the server, minus the size of the
2795 * WRITEX header, not including the 4 byte RFC1001 length.
2796 */
2797 if (!(server->capabilities & CAP_LARGE_WRITE_X) ||
2798 (!(server->capabilities & CAP_UNIX) &&
2799 (server->sec_mode & (SECMODE_SIGN_ENABLED|SECMODE_SIGN_REQUIRED))))
2800 wsize = min_t(unsigned int, wsize,
2801 server->maxBuf - sizeof(WRITE_REQ) + 4);
2791 2802
2792 /* hard limit of CIFS_MAX_WSIZE */ 2803 /* hard limit of CIFS_MAX_WSIZE */
2793 wsize = min_t(unsigned int, wsize, CIFS_MAX_WSIZE); 2804 wsize = min_t(unsigned int, wsize, CIFS_MAX_WSIZE);
@@ -2937,7 +2948,11 @@ int cifs_setup_volume_info(struct smb_vol **pvolume_info, char *mount_data,
2937 2948
2938 if (volume_info->nullauth) { 2949 if (volume_info->nullauth) {
2939 cFYI(1, "null user"); 2950 cFYI(1, "null user");
2940 volume_info->username = ""; 2951 volume_info->username = kzalloc(1, GFP_KERNEL);
2952 if (volume_info->username == NULL) {
2953 rc = -ENOMEM;
2954 goto out;
2955 }
2941 } else if (volume_info->username) { 2956 } else if (volume_info->username) {
2942 /* BB fixme parse for domain name here */ 2957 /* BB fixme parse for domain name here */
2943 cFYI(1, "Username: %s", volume_info->username); 2958 cFYI(1, "Username: %s", volume_info->username);
@@ -2971,8 +2986,7 @@ out:
2971} 2986}
2972 2987
2973int 2988int
2974cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, 2989cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *volume_info)
2975 struct smb_vol *volume_info, const char *devname)
2976{ 2990{
2977 int rc = 0; 2991 int rc = 0;
2978 int xid; 2992 int xid;
@@ -2983,6 +2997,13 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2983 struct tcon_link *tlink; 2997 struct tcon_link *tlink;
2984#ifdef CONFIG_CIFS_DFS_UPCALL 2998#ifdef CONFIG_CIFS_DFS_UPCALL
2985 int referral_walks_count = 0; 2999 int referral_walks_count = 0;
3000
3001 rc = bdi_setup_and_register(&cifs_sb->bdi, "cifs", BDI_CAP_MAP_COPY);
3002 if (rc)
3003 return rc;
3004
3005 cifs_sb->bdi.ra_pages = default_backing_dev_info.ra_pages;
3006
2986try_mount_again: 3007try_mount_again:
2987 /* cleanup activities if we're chasing a referral */ 3008 /* cleanup activities if we're chasing a referral */
2988 if (referral_walks_count) { 3009 if (referral_walks_count) {
@@ -3007,6 +3028,7 @@ try_mount_again:
3007 srvTcp = cifs_get_tcp_session(volume_info); 3028 srvTcp = cifs_get_tcp_session(volume_info);
3008 if (IS_ERR(srvTcp)) { 3029 if (IS_ERR(srvTcp)) {
3009 rc = PTR_ERR(srvTcp); 3030 rc = PTR_ERR(srvTcp);
3031 bdi_destroy(&cifs_sb->bdi);
3010 goto out; 3032 goto out;
3011 } 3033 }
3012 3034
@@ -3018,14 +3040,6 @@ try_mount_again:
3018 goto mount_fail_check; 3040 goto mount_fail_check;
3019 } 3041 }
3020 3042
3021 if (pSesInfo->capabilities & CAP_LARGE_FILES)
3022 sb->s_maxbytes = MAX_LFS_FILESIZE;
3023 else
3024 sb->s_maxbytes = MAX_NON_LFS;
3025
3026 /* BB FIXME fix time_gran to be larger for LANMAN sessions */
3027 sb->s_time_gran = 100;
3028
3029 /* search for existing tcon to this server share */ 3043 /* search for existing tcon to this server share */
3030 tcon = cifs_get_tcon(pSesInfo, volume_info); 3044 tcon = cifs_get_tcon(pSesInfo, volume_info);
3031 if (IS_ERR(tcon)) { 3045 if (IS_ERR(tcon)) {
@@ -3038,7 +3052,7 @@ try_mount_again:
3038 if (tcon->ses->capabilities & CAP_UNIX) { 3052 if (tcon->ses->capabilities & CAP_UNIX) {
3039 /* reset of caps checks mount to see if unix extensions 3053 /* reset of caps checks mount to see if unix extensions
3040 disabled for just this mount */ 3054 disabled for just this mount */
3041 reset_cifs_unix_caps(xid, tcon, sb, volume_info); 3055 reset_cifs_unix_caps(xid, tcon, cifs_sb, volume_info);
3042 if ((tcon->ses->server->tcpStatus == CifsNeedReconnect) && 3056 if ((tcon->ses->server->tcpStatus == CifsNeedReconnect) &&
3043 (le64_to_cpu(tcon->fsUnixInfo.Capability) & 3057 (le64_to_cpu(tcon->fsUnixInfo.Capability) &
3044 CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP)) { 3058 CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP)) {
@@ -3161,6 +3175,7 @@ mount_fail_check:
3161 cifs_put_smb_ses(pSesInfo); 3175 cifs_put_smb_ses(pSesInfo);
3162 else 3176 else
3163 cifs_put_tcp_session(srvTcp); 3177 cifs_put_tcp_session(srvTcp);
3178 bdi_destroy(&cifs_sb->bdi);
3164 goto out; 3179 goto out;
3165 } 3180 }
3166 3181
@@ -3335,8 +3350,8 @@ CIFSTCon(unsigned int xid, struct cifs_ses *ses,
3335 return rc; 3350 return rc;
3336} 3351}
3337 3352
3338int 3353void
3339cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb) 3354cifs_umount(struct cifs_sb_info *cifs_sb)
3340{ 3355{
3341 struct rb_root *root = &cifs_sb->tlink_tree; 3356 struct rb_root *root = &cifs_sb->tlink_tree;
3342 struct rb_node *node; 3357 struct rb_node *node;
@@ -3357,7 +3372,10 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb)
3357 } 3372 }
3358 spin_unlock(&cifs_sb->tlink_tree_lock); 3373 spin_unlock(&cifs_sb->tlink_tree_lock);
3359 3374
3360 return 0; 3375 bdi_destroy(&cifs_sb->bdi);
3376 kfree(cifs_sb->mountdata);
3377 unload_nls(cifs_sb->local_nls);
3378 kfree(cifs_sb);
3361} 3379}
3362 3380
3363int cifs_negotiate_protocol(unsigned int xid, struct cifs_ses *ses) 3381int cifs_negotiate_protocol(unsigned int xid, struct cifs_ses *ses)
diff --git a/fs/cifs/smbencrypt.c b/fs/cifs/smbencrypt.c
index 1525d5e662b6..1c5b770c3141 100644
--- a/fs/cifs/smbencrypt.c
+++ b/fs/cifs/smbencrypt.c
@@ -90,12 +90,10 @@ smbhash(unsigned char *out, const unsigned char *in, unsigned char *key)
90 sg_init_one(&sgout, out, 8); 90 sg_init_one(&sgout, out, 8);
91 91
92 rc = crypto_blkcipher_encrypt(&desc, &sgout, &sgin, 8); 92 rc = crypto_blkcipher_encrypt(&desc, &sgout, &sgin, 8);
93 if (rc) { 93 if (rc)
94 cERROR(1, "could not encrypt crypt key rc: %d\n", rc); 94 cERROR(1, "could not encrypt crypt key rc: %d\n", rc);
95 crypto_free_blkcipher(tfm_des);
96 goto smbhash_err;
97 }
98 95
96 crypto_free_blkcipher(tfm_des);
99smbhash_err: 97smbhash_err:
100 return rc; 98 return rc;
101} 99}
diff --git a/fs/ext4/ext4_extents.h b/fs/ext4/ext4_extents.h
index 2e29abb30f76..095c36f3b612 100644
--- a/fs/ext4/ext4_extents.h
+++ b/fs/ext4/ext4_extents.h
@@ -125,7 +125,7 @@ struct ext4_ext_path {
125 * positive retcode - signal for ext4_ext_walk_space(), see below 125 * positive retcode - signal for ext4_ext_walk_space(), see below
126 * callback must return valid extent (passed or newly created) 126 * callback must return valid extent (passed or newly created)
127 */ 127 */
128typedef int (*ext_prepare_callback)(struct inode *, struct ext4_ext_path *, 128typedef int (*ext_prepare_callback)(struct inode *, ext4_lblk_t,
129 struct ext4_ext_cache *, 129 struct ext4_ext_cache *,
130 struct ext4_extent *, void *); 130 struct ext4_extent *, void *);
131 131
@@ -133,8 +133,11 @@ typedef int (*ext_prepare_callback)(struct inode *, struct ext4_ext_path *,
133#define EXT_BREAK 1 133#define EXT_BREAK 1
134#define EXT_REPEAT 2 134#define EXT_REPEAT 2
135 135
136/* Maximum logical block in a file; ext4_extent's ee_block is __le32 */ 136/*
137#define EXT_MAX_BLOCK 0xffffffff 137 * Maximum number of logical blocks in a file; ext4_extent's ee_block is
138 * __le32.
139 */
140#define EXT_MAX_BLOCKS 0xffffffff
138 141
139/* 142/*
140 * EXT_INIT_MAX_LEN is the maximum number of blocks we can have in an 143 * EXT_INIT_MAX_LEN is the maximum number of blocks we can have in an
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 5199bac7fc62..f815cc81e7a2 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -1408,7 +1408,7 @@ got_index:
1408 1408
1409/* 1409/*
1410 * ext4_ext_next_allocated_block: 1410 * ext4_ext_next_allocated_block:
1411 * returns allocated block in subsequent extent or EXT_MAX_BLOCK. 1411 * returns allocated block in subsequent extent or EXT_MAX_BLOCKS.
1412 * NOTE: it considers block number from index entry as 1412 * NOTE: it considers block number from index entry as
1413 * allocated block. Thus, index entries have to be consistent 1413 * allocated block. Thus, index entries have to be consistent
1414 * with leaves. 1414 * with leaves.
@@ -1422,7 +1422,7 @@ ext4_ext_next_allocated_block(struct ext4_ext_path *path)
1422 depth = path->p_depth; 1422 depth = path->p_depth;
1423 1423
1424 if (depth == 0 && path->p_ext == NULL) 1424 if (depth == 0 && path->p_ext == NULL)
1425 return EXT_MAX_BLOCK; 1425 return EXT_MAX_BLOCKS;
1426 1426
1427 while (depth >= 0) { 1427 while (depth >= 0) {
1428 if (depth == path->p_depth) { 1428 if (depth == path->p_depth) {
@@ -1439,12 +1439,12 @@ ext4_ext_next_allocated_block(struct ext4_ext_path *path)
1439 depth--; 1439 depth--;
1440 } 1440 }
1441 1441
1442 return EXT_MAX_BLOCK; 1442 return EXT_MAX_BLOCKS;
1443} 1443}
1444 1444
1445/* 1445/*
1446 * ext4_ext_next_leaf_block: 1446 * ext4_ext_next_leaf_block:
1447 * returns first allocated block from next leaf or EXT_MAX_BLOCK 1447 * returns first allocated block from next leaf or EXT_MAX_BLOCKS
1448 */ 1448 */
1449static ext4_lblk_t ext4_ext_next_leaf_block(struct inode *inode, 1449static ext4_lblk_t ext4_ext_next_leaf_block(struct inode *inode,
1450 struct ext4_ext_path *path) 1450 struct ext4_ext_path *path)
@@ -1456,7 +1456,7 @@ static ext4_lblk_t ext4_ext_next_leaf_block(struct inode *inode,
1456 1456
1457 /* zero-tree has no leaf blocks at all */ 1457 /* zero-tree has no leaf blocks at all */
1458 if (depth == 0) 1458 if (depth == 0)
1459 return EXT_MAX_BLOCK; 1459 return EXT_MAX_BLOCKS;
1460 1460
1461 /* go to index block */ 1461 /* go to index block */
1462 depth--; 1462 depth--;
@@ -1469,7 +1469,7 @@ static ext4_lblk_t ext4_ext_next_leaf_block(struct inode *inode,
1469 depth--; 1469 depth--;
1470 } 1470 }
1471 1471
1472 return EXT_MAX_BLOCK; 1472 return EXT_MAX_BLOCKS;
1473} 1473}
1474 1474
1475/* 1475/*
@@ -1677,13 +1677,13 @@ static unsigned int ext4_ext_check_overlap(struct inode *inode,
1677 */ 1677 */
1678 if (b2 < b1) { 1678 if (b2 < b1) {
1679 b2 = ext4_ext_next_allocated_block(path); 1679 b2 = ext4_ext_next_allocated_block(path);
1680 if (b2 == EXT_MAX_BLOCK) 1680 if (b2 == EXT_MAX_BLOCKS)
1681 goto out; 1681 goto out;
1682 } 1682 }
1683 1683
1684 /* check for wrap through zero on extent logical start block*/ 1684 /* check for wrap through zero on extent logical start block*/
1685 if (b1 + len1 < b1) { 1685 if (b1 + len1 < b1) {
1686 len1 = EXT_MAX_BLOCK - b1; 1686 len1 = EXT_MAX_BLOCKS - b1;
1687 newext->ee_len = cpu_to_le16(len1); 1687 newext->ee_len = cpu_to_le16(len1);
1688 ret = 1; 1688 ret = 1;
1689 } 1689 }
@@ -1767,7 +1767,7 @@ repeat:
1767 fex = EXT_LAST_EXTENT(eh); 1767 fex = EXT_LAST_EXTENT(eh);
1768 next = ext4_ext_next_leaf_block(inode, path); 1768 next = ext4_ext_next_leaf_block(inode, path);
1769 if (le32_to_cpu(newext->ee_block) > le32_to_cpu(fex->ee_block) 1769 if (le32_to_cpu(newext->ee_block) > le32_to_cpu(fex->ee_block)
1770 && next != EXT_MAX_BLOCK) { 1770 && next != EXT_MAX_BLOCKS) {
1771 ext_debug("next leaf block - %d\n", next); 1771 ext_debug("next leaf block - %d\n", next);
1772 BUG_ON(npath != NULL); 1772 BUG_ON(npath != NULL);
1773 npath = ext4_ext_find_extent(inode, next, NULL); 1773 npath = ext4_ext_find_extent(inode, next, NULL);
@@ -1887,7 +1887,7 @@ static int ext4_ext_walk_space(struct inode *inode, ext4_lblk_t block,
1887 BUG_ON(func == NULL); 1887 BUG_ON(func == NULL);
1888 BUG_ON(inode == NULL); 1888 BUG_ON(inode == NULL);
1889 1889
1890 while (block < last && block != EXT_MAX_BLOCK) { 1890 while (block < last && block != EXT_MAX_BLOCKS) {
1891 num = last - block; 1891 num = last - block;
1892 /* find extent for this block */ 1892 /* find extent for this block */
1893 down_read(&EXT4_I(inode)->i_data_sem); 1893 down_read(&EXT4_I(inode)->i_data_sem);
@@ -1958,7 +1958,7 @@ static int ext4_ext_walk_space(struct inode *inode, ext4_lblk_t block,
1958 err = -EIO; 1958 err = -EIO;
1959 break; 1959 break;
1960 } 1960 }
1961 err = func(inode, path, &cbex, ex, cbdata); 1961 err = func(inode, next, &cbex, ex, cbdata);
1962 ext4_ext_drop_refs(path); 1962 ext4_ext_drop_refs(path);
1963 1963
1964 if (err < 0) 1964 if (err < 0)
@@ -2020,7 +2020,7 @@ ext4_ext_put_gap_in_cache(struct inode *inode, struct ext4_ext_path *path,
2020 if (ex == NULL) { 2020 if (ex == NULL) {
2021 /* there is no extent yet, so gap is [0;-] */ 2021 /* there is no extent yet, so gap is [0;-] */
2022 lblock = 0; 2022 lblock = 0;
2023 len = EXT_MAX_BLOCK; 2023 len = EXT_MAX_BLOCKS;
2024 ext_debug("cache gap(whole file):"); 2024 ext_debug("cache gap(whole file):");
2025 } else if (block < le32_to_cpu(ex->ee_block)) { 2025 } else if (block < le32_to_cpu(ex->ee_block)) {
2026 lblock = block; 2026 lblock = block;
@@ -2350,7 +2350,7 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,
2350 * never happen because at least one of the end points 2350 * never happen because at least one of the end points
2351 * needs to be on the edge of the extent. 2351 * needs to be on the edge of the extent.
2352 */ 2352 */
2353 if (end == EXT_MAX_BLOCK) { 2353 if (end == EXT_MAX_BLOCKS - 1) {
2354 ext_debug(" bad truncate %u:%u\n", 2354 ext_debug(" bad truncate %u:%u\n",
2355 start, end); 2355 start, end);
2356 block = 0; 2356 block = 0;
@@ -2398,7 +2398,7 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,
2398 * If this is a truncate, this condition 2398 * If this is a truncate, this condition
2399 * should never happen 2399 * should never happen
2400 */ 2400 */
2401 if (end == EXT_MAX_BLOCK) { 2401 if (end == EXT_MAX_BLOCKS - 1) {
2402 ext_debug(" bad truncate %u:%u\n", 2402 ext_debug(" bad truncate %u:%u\n",
2403 start, end); 2403 start, end);
2404 err = -EIO; 2404 err = -EIO;
@@ -2478,7 +2478,7 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,
2478 * we need to remove it from the leaf 2478 * we need to remove it from the leaf
2479 */ 2479 */
2480 if (num == 0) { 2480 if (num == 0) {
2481 if (end != EXT_MAX_BLOCK) { 2481 if (end != EXT_MAX_BLOCKS - 1) {
2482 /* 2482 /*
2483 * For hole punching, we need to scoot all the 2483 * For hole punching, we need to scoot all the
2484 * extents up when an extent is removed so that 2484 * extents up when an extent is removed so that
@@ -3699,7 +3699,7 @@ void ext4_ext_truncate(struct inode *inode)
3699 3699
3700 last_block = (inode->i_size + sb->s_blocksize - 1) 3700 last_block = (inode->i_size + sb->s_blocksize - 1)
3701 >> EXT4_BLOCK_SIZE_BITS(sb); 3701 >> EXT4_BLOCK_SIZE_BITS(sb);
3702 err = ext4_ext_remove_space(inode, last_block, EXT_MAX_BLOCK); 3702 err = ext4_ext_remove_space(inode, last_block, EXT_MAX_BLOCKS - 1);
3703 3703
3704 /* In a multi-transaction truncate, we only make the final 3704 /* In a multi-transaction truncate, we only make the final
3705 * transaction synchronous. 3705 * transaction synchronous.
@@ -3914,14 +3914,13 @@ int ext4_convert_unwritten_extents(struct inode *inode, loff_t offset,
3914/* 3914/*
3915 * Callback function called for each extent to gather FIEMAP information. 3915 * Callback function called for each extent to gather FIEMAP information.
3916 */ 3916 */
3917static int ext4_ext_fiemap_cb(struct inode *inode, struct ext4_ext_path *path, 3917static int ext4_ext_fiemap_cb(struct inode *inode, ext4_lblk_t next,
3918 struct ext4_ext_cache *newex, struct ext4_extent *ex, 3918 struct ext4_ext_cache *newex, struct ext4_extent *ex,
3919 void *data) 3919 void *data)
3920{ 3920{
3921 __u64 logical; 3921 __u64 logical;
3922 __u64 physical; 3922 __u64 physical;
3923 __u64 length; 3923 __u64 length;
3924 loff_t size;
3925 __u32 flags = 0; 3924 __u32 flags = 0;
3926 int ret = 0; 3925 int ret = 0;
3927 struct fiemap_extent_info *fieinfo = data; 3926 struct fiemap_extent_info *fieinfo = data;
@@ -4103,8 +4102,7 @@ found_delayed_extent:
4103 if (ex && ext4_ext_is_uninitialized(ex)) 4102 if (ex && ext4_ext_is_uninitialized(ex))
4104 flags |= FIEMAP_EXTENT_UNWRITTEN; 4103 flags |= FIEMAP_EXTENT_UNWRITTEN;
4105 4104
4106 size = i_size_read(inode); 4105 if (next == EXT_MAX_BLOCKS)
4107 if (logical + length >= size)
4108 flags |= FIEMAP_EXTENT_LAST; 4106 flags |= FIEMAP_EXTENT_LAST;
4109 4107
4110 ret = fiemap_fill_next_extent(fieinfo, logical, physical, 4108 ret = fiemap_fill_next_extent(fieinfo, logical, physical,
@@ -4347,8 +4345,8 @@ int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
4347 4345
4348 start_blk = start >> inode->i_sb->s_blocksize_bits; 4346 start_blk = start >> inode->i_sb->s_blocksize_bits;
4349 last_blk = (start + len - 1) >> inode->i_sb->s_blocksize_bits; 4347 last_blk = (start + len - 1) >> inode->i_sb->s_blocksize_bits;
4350 if (last_blk >= EXT_MAX_BLOCK) 4348 if (last_blk >= EXT_MAX_BLOCKS)
4351 last_blk = EXT_MAX_BLOCK-1; 4349 last_blk = EXT_MAX_BLOCKS-1;
4352 len_blks = ((ext4_lblk_t) last_blk) - start_blk + 1; 4350 len_blks = ((ext4_lblk_t) last_blk) - start_blk + 1;
4353 4351
4354 /* 4352 /*
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index a5763e3505ba..e3126c051006 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2634,7 +2634,7 @@ static int ext4_writepage(struct page *page,
2634 struct buffer_head *page_bufs = NULL; 2634 struct buffer_head *page_bufs = NULL;
2635 struct inode *inode = page->mapping->host; 2635 struct inode *inode = page->mapping->host;
2636 2636
2637 trace_ext4_writepage(inode, page); 2637 trace_ext4_writepage(page);
2638 size = i_size_read(inode); 2638 size = i_size_read(inode);
2639 if (page->index == size >> PAGE_CACHE_SHIFT) 2639 if (page->index == size >> PAGE_CACHE_SHIFT)
2640 len = size & ~PAGE_CACHE_MASK; 2640 len = size & ~PAGE_CACHE_MASK;
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 859f2ae8864e..6ed859d56850 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -3578,8 +3578,8 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
3578 free += next - bit; 3578 free += next - bit;
3579 3579
3580 trace_ext4_mballoc_discard(sb, NULL, group, bit, next - bit); 3580 trace_ext4_mballoc_discard(sb, NULL, group, bit, next - bit);
3581 trace_ext4_mb_release_inode_pa(sb, pa->pa_inode, pa, 3581 trace_ext4_mb_release_inode_pa(pa, grp_blk_start + bit,
3582 grp_blk_start + bit, next - bit); 3582 next - bit);
3583 mb_free_blocks(pa->pa_inode, e4b, bit, next - bit); 3583 mb_free_blocks(pa->pa_inode, e4b, bit, next - bit);
3584 bit = next + 1; 3584 bit = next + 1;
3585 } 3585 }
@@ -3608,7 +3608,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
3608 ext4_group_t group; 3608 ext4_group_t group;
3609 ext4_grpblk_t bit; 3609 ext4_grpblk_t bit;
3610 3610
3611 trace_ext4_mb_release_group_pa(sb, pa); 3611 trace_ext4_mb_release_group_pa(pa);
3612 BUG_ON(pa->pa_deleted == 0); 3612 BUG_ON(pa->pa_deleted == 0);
3613 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit); 3613 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
3614 BUG_ON(group != e4b->bd_group && pa->pa_len != 0); 3614 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
@@ -4448,7 +4448,7 @@ ext4_mb_free_metadata(handle_t *handle, struct ext4_buddy *e4b,
4448 * @inode: inode 4448 * @inode: inode
4449 * @block: start physical block to free 4449 * @block: start physical block to free
4450 * @count: number of blocks to count 4450 * @count: number of blocks to count
4451 * @metadata: Are these metadata blocks 4451 * @flags: flags used by ext4_free_blocks
4452 */ 4452 */
4453void ext4_free_blocks(handle_t *handle, struct inode *inode, 4453void ext4_free_blocks(handle_t *handle, struct inode *inode,
4454 struct buffer_head *bh, ext4_fsblk_t block, 4454 struct buffer_head *bh, ext4_fsblk_t block,
diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
index 2b8304bf3c50..f57455a1b1b2 100644
--- a/fs/ext4/move_extent.c
+++ b/fs/ext4/move_extent.c
@@ -1002,12 +1002,12 @@ mext_check_arguments(struct inode *orig_inode,
1002 return -EINVAL; 1002 return -EINVAL;
1003 } 1003 }
1004 1004
1005 if ((orig_start > EXT_MAX_BLOCK) || 1005 if ((orig_start >= EXT_MAX_BLOCKS) ||
1006 (donor_start > EXT_MAX_BLOCK) || 1006 (donor_start >= EXT_MAX_BLOCKS) ||
1007 (*len > EXT_MAX_BLOCK) || 1007 (*len > EXT_MAX_BLOCKS) ||
1008 (orig_start + *len > EXT_MAX_BLOCK)) { 1008 (orig_start + *len >= EXT_MAX_BLOCKS)) {
1009 ext4_debug("ext4 move extent: Can't handle over [%u] blocks " 1009 ext4_debug("ext4 move extent: Can't handle over [%u] blocks "
1010 "[ino:orig %lu, donor %lu]\n", EXT_MAX_BLOCK, 1010 "[ino:orig %lu, donor %lu]\n", EXT_MAX_BLOCKS,
1011 orig_inode->i_ino, donor_inode->i_ino); 1011 orig_inode->i_ino, donor_inode->i_ino);
1012 return -EINVAL; 1012 return -EINVAL;
1013 } 1013 }
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index cc5c157aa11d..9ea71aa864b3 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -2243,6 +2243,12 @@ static void ext4_orphan_cleanup(struct super_block *sb,
2243 * in the vfs. ext4 inode has 48 bits of i_block in fsblock units, 2243 * in the vfs. ext4 inode has 48 bits of i_block in fsblock units,
2244 * so that won't be a limiting factor. 2244 * so that won't be a limiting factor.
2245 * 2245 *
2246 * However there is other limiting factor. We do store extents in the form
2247 * of starting block and length, hence the resulting length of the extent
2248 * covering maximum file size must fit into on-disk format containers as
2249 * well. Given that length is always by 1 unit bigger than max unit (because
2250 * we count 0 as well) we have to lower the s_maxbytes by one fs block.
2251 *
2246 * Note, this does *not* consider any metadata overhead for vfs i_blocks. 2252 * Note, this does *not* consider any metadata overhead for vfs i_blocks.
2247 */ 2253 */
2248static loff_t ext4_max_size(int blkbits, int has_huge_files) 2254static loff_t ext4_max_size(int blkbits, int has_huge_files)
@@ -2264,10 +2270,13 @@ static loff_t ext4_max_size(int blkbits, int has_huge_files)
2264 upper_limit <<= blkbits; 2270 upper_limit <<= blkbits;
2265 } 2271 }
2266 2272
2267 /* 32-bit extent-start container, ee_block */ 2273 /*
2268 res = 1LL << 32; 2274 * 32-bit extent-start container, ee_block. We lower the maxbytes
2275 * by one fs block, so ee_len can cover the extent of maximum file
2276 * size
2277 */
2278 res = (1LL << 32) - 1;
2269 res <<= blkbits; 2279 res <<= blkbits;
2270 res -= 1;
2271 2280
2272 /* Sanity check against vm- & vfs- imposed limits */ 2281 /* Sanity check against vm- & vfs- imposed limits */
2273 if (res > upper_limit) 2282 if (res > upper_limit)
diff --git a/fs/inode.c b/fs/inode.c
index 0f7e88a7803f..43566d17d1b8 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -423,7 +423,14 @@ EXPORT_SYMBOL(remove_inode_hash);
423void end_writeback(struct inode *inode) 423void end_writeback(struct inode *inode)
424{ 424{
425 might_sleep(); 425 might_sleep();
426 /*
427 * We have to cycle tree_lock here because reclaim can be still in the
428 * process of removing the last page (in __delete_from_page_cache())
429 * and we must not free mapping under it.
430 */
431 spin_lock_irq(&inode->i_data.tree_lock);
426 BUG_ON(inode->i_data.nrpages); 432 BUG_ON(inode->i_data.nrpages);
433 spin_unlock_irq(&inode->i_data.tree_lock);
427 BUG_ON(!list_empty(&inode->i_data.private_list)); 434 BUG_ON(!list_empty(&inode->i_data.private_list));
428 BUG_ON(!(inode->i_state & I_FREEING)); 435 BUG_ON(!(inode->i_state & I_FREEING));
429 BUG_ON(inode->i_state & I_CLEAR); 436 BUG_ON(inode->i_state & I_CLEAR);
diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c
index 6a79fd0a1a32..2c62c5aae82f 100644
--- a/fs/jbd2/checkpoint.c
+++ b/fs/jbd2/checkpoint.c
@@ -97,10 +97,14 @@ static int __try_to_free_cp_buf(struct journal_head *jh)
97 97
98 if (jh->b_jlist == BJ_None && !buffer_locked(bh) && 98 if (jh->b_jlist == BJ_None && !buffer_locked(bh) &&
99 !buffer_dirty(bh) && !buffer_write_io_error(bh)) { 99 !buffer_dirty(bh) && !buffer_write_io_error(bh)) {
100 /*
101 * Get our reference so that bh cannot be freed before
102 * we unlock it
103 */
104 get_bh(bh);
100 JBUFFER_TRACE(jh, "remove from checkpoint list"); 105 JBUFFER_TRACE(jh, "remove from checkpoint list");
101 ret = __jbd2_journal_remove_checkpoint(jh) + 1; 106 ret = __jbd2_journal_remove_checkpoint(jh) + 1;
102 jbd_unlock_bh_state(bh); 107 jbd_unlock_bh_state(bh);
103 jbd2_journal_remove_journal_head(bh);
104 BUFFER_TRACE(bh, "release"); 108 BUFFER_TRACE(bh, "release");
105 __brelse(bh); 109 __brelse(bh);
106 } else { 110 } else {
@@ -223,8 +227,8 @@ restart:
223 spin_lock(&journal->j_list_lock); 227 spin_lock(&journal->j_list_lock);
224 goto restart; 228 goto restart;
225 } 229 }
230 get_bh(bh);
226 if (buffer_locked(bh)) { 231 if (buffer_locked(bh)) {
227 atomic_inc(&bh->b_count);
228 spin_unlock(&journal->j_list_lock); 232 spin_unlock(&journal->j_list_lock);
229 jbd_unlock_bh_state(bh); 233 jbd_unlock_bh_state(bh);
230 wait_on_buffer(bh); 234 wait_on_buffer(bh);
@@ -243,7 +247,6 @@ restart:
243 */ 247 */
244 released = __jbd2_journal_remove_checkpoint(jh); 248 released = __jbd2_journal_remove_checkpoint(jh);
245 jbd_unlock_bh_state(bh); 249 jbd_unlock_bh_state(bh);
246 jbd2_journal_remove_journal_head(bh);
247 __brelse(bh); 250 __brelse(bh);
248 } 251 }
249 252
@@ -284,7 +287,7 @@ static int __process_buffer(journal_t *journal, struct journal_head *jh,
284 int ret = 0; 287 int ret = 0;
285 288
286 if (buffer_locked(bh)) { 289 if (buffer_locked(bh)) {
287 atomic_inc(&bh->b_count); 290 get_bh(bh);
288 spin_unlock(&journal->j_list_lock); 291 spin_unlock(&journal->j_list_lock);
289 jbd_unlock_bh_state(bh); 292 jbd_unlock_bh_state(bh);
290 wait_on_buffer(bh); 293 wait_on_buffer(bh);
@@ -316,12 +319,12 @@ static int __process_buffer(journal_t *journal, struct journal_head *jh,
316 ret = 1; 319 ret = 1;
317 if (unlikely(buffer_write_io_error(bh))) 320 if (unlikely(buffer_write_io_error(bh)))
318 ret = -EIO; 321 ret = -EIO;
322 get_bh(bh);
319 J_ASSERT_JH(jh, !buffer_jbddirty(bh)); 323 J_ASSERT_JH(jh, !buffer_jbddirty(bh));
320 BUFFER_TRACE(bh, "remove from checkpoint"); 324 BUFFER_TRACE(bh, "remove from checkpoint");
321 __jbd2_journal_remove_checkpoint(jh); 325 __jbd2_journal_remove_checkpoint(jh);
322 spin_unlock(&journal->j_list_lock); 326 spin_unlock(&journal->j_list_lock);
323 jbd_unlock_bh_state(bh); 327 jbd_unlock_bh_state(bh);
324 jbd2_journal_remove_journal_head(bh);
325 __brelse(bh); 328 __brelse(bh);
326 } else { 329 } else {
327 /* 330 /*
@@ -554,7 +557,8 @@ int jbd2_cleanup_journal_tail(journal_t *journal)
554/* 557/*
555 * journal_clean_one_cp_list 558 * journal_clean_one_cp_list
556 * 559 *
557 * Find all the written-back checkpoint buffers in the given list and release them. 560 * Find all the written-back checkpoint buffers in the given list and
561 * release them.
558 * 562 *
559 * Called with the journal locked. 563 * Called with the journal locked.
560 * Called with j_list_lock held. 564 * Called with j_list_lock held.
@@ -663,8 +667,8 @@ out:
663 * checkpoint lists. 667 * checkpoint lists.
664 * 668 *
665 * The function returns 1 if it frees the transaction, 0 otherwise. 669 * The function returns 1 if it frees the transaction, 0 otherwise.
670 * The function can free jh and bh.
666 * 671 *
667 * This function is called with the journal locked.
668 * This function is called with j_list_lock held. 672 * This function is called with j_list_lock held.
669 * This function is called with jbd_lock_bh_state(jh2bh(jh)) 673 * This function is called with jbd_lock_bh_state(jh2bh(jh))
670 */ 674 */
@@ -684,13 +688,14 @@ int __jbd2_journal_remove_checkpoint(struct journal_head *jh)
684 } 688 }
685 journal = transaction->t_journal; 689 journal = transaction->t_journal;
686 690
691 JBUFFER_TRACE(jh, "removing from transaction");
687 __buffer_unlink(jh); 692 __buffer_unlink(jh);
688 jh->b_cp_transaction = NULL; 693 jh->b_cp_transaction = NULL;
694 jbd2_journal_put_journal_head(jh);
689 695
690 if (transaction->t_checkpoint_list != NULL || 696 if (transaction->t_checkpoint_list != NULL ||
691 transaction->t_checkpoint_io_list != NULL) 697 transaction->t_checkpoint_io_list != NULL)
692 goto out; 698 goto out;
693 JBUFFER_TRACE(jh, "transaction has no more buffers");
694 699
695 /* 700 /*
696 * There is one special case to worry about: if we have just pulled the 701 * There is one special case to worry about: if we have just pulled the
@@ -701,10 +706,8 @@ int __jbd2_journal_remove_checkpoint(struct journal_head *jh)
701 * The locking here around t_state is a bit sleazy. 706 * The locking here around t_state is a bit sleazy.
702 * See the comment at the end of jbd2_journal_commit_transaction(). 707 * See the comment at the end of jbd2_journal_commit_transaction().
703 */ 708 */
704 if (transaction->t_state != T_FINISHED) { 709 if (transaction->t_state != T_FINISHED)
705 JBUFFER_TRACE(jh, "belongs to running/committing transaction");
706 goto out; 710 goto out;
707 }
708 711
709 /* OK, that was the last buffer for the transaction: we can now 712 /* OK, that was the last buffer for the transaction: we can now
710 safely remove this transaction from the log */ 713 safely remove this transaction from the log */
@@ -723,7 +726,6 @@ int __jbd2_journal_remove_checkpoint(struct journal_head *jh)
723 wake_up(&journal->j_wait_logspace); 726 wake_up(&journal->j_wait_logspace);
724 ret = 1; 727 ret = 1;
725out: 728out:
726 JBUFFER_TRACE(jh, "exit");
727 return ret; 729 return ret;
728} 730}
729 731
@@ -742,6 +744,8 @@ void __jbd2_journal_insert_checkpoint(struct journal_head *jh,
742 J_ASSERT_JH(jh, buffer_dirty(jh2bh(jh)) || buffer_jbddirty(jh2bh(jh))); 744 J_ASSERT_JH(jh, buffer_dirty(jh2bh(jh)) || buffer_jbddirty(jh2bh(jh)));
743 J_ASSERT_JH(jh, jh->b_cp_transaction == NULL); 745 J_ASSERT_JH(jh, jh->b_cp_transaction == NULL);
744 746
747 /* Get reference for checkpointing transaction */
748 jbd2_journal_grab_journal_head(jh2bh(jh));
745 jh->b_cp_transaction = transaction; 749 jh->b_cp_transaction = transaction;
746 750
747 if (!transaction->t_checkpoint_list) { 751 if (!transaction->t_checkpoint_list) {
diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
index 7f21cf3aaf92..eef6979821a4 100644
--- a/fs/jbd2/commit.c
+++ b/fs/jbd2/commit.c
@@ -848,10 +848,16 @@ restart_loop:
848 while (commit_transaction->t_forget) { 848 while (commit_transaction->t_forget) {
849 transaction_t *cp_transaction; 849 transaction_t *cp_transaction;
850 struct buffer_head *bh; 850 struct buffer_head *bh;
851 int try_to_free = 0;
851 852
852 jh = commit_transaction->t_forget; 853 jh = commit_transaction->t_forget;
853 spin_unlock(&journal->j_list_lock); 854 spin_unlock(&journal->j_list_lock);
854 bh = jh2bh(jh); 855 bh = jh2bh(jh);
856 /*
857 * Get a reference so that bh cannot be freed before we are
858 * done with it.
859 */
860 get_bh(bh);
855 jbd_lock_bh_state(bh); 861 jbd_lock_bh_state(bh);
856 J_ASSERT_JH(jh, jh->b_transaction == commit_transaction); 862 J_ASSERT_JH(jh, jh->b_transaction == commit_transaction);
857 863
@@ -914,28 +920,27 @@ restart_loop:
914 __jbd2_journal_insert_checkpoint(jh, commit_transaction); 920 __jbd2_journal_insert_checkpoint(jh, commit_transaction);
915 if (is_journal_aborted(journal)) 921 if (is_journal_aborted(journal))
916 clear_buffer_jbddirty(bh); 922 clear_buffer_jbddirty(bh);
917 JBUFFER_TRACE(jh, "refile for checkpoint writeback");
918 __jbd2_journal_refile_buffer(jh);
919 jbd_unlock_bh_state(bh);
920 } else { 923 } else {
921 J_ASSERT_BH(bh, !buffer_dirty(bh)); 924 J_ASSERT_BH(bh, !buffer_dirty(bh));
922 /* The buffer on BJ_Forget list and not jbddirty means 925 /*
926 * The buffer on BJ_Forget list and not jbddirty means
923 * it has been freed by this transaction and hence it 927 * it has been freed by this transaction and hence it
924 * could not have been reallocated until this 928 * could not have been reallocated until this
925 * transaction has committed. *BUT* it could be 929 * transaction has committed. *BUT* it could be
926 * reallocated once we have written all the data to 930 * reallocated once we have written all the data to
927 * disk and before we process the buffer on BJ_Forget 931 * disk and before we process the buffer on BJ_Forget
928 * list. */ 932 * list.
929 JBUFFER_TRACE(jh, "refile or unfile freed buffer"); 933 */
930 __jbd2_journal_refile_buffer(jh); 934 if (!jh->b_next_transaction)
931 if (!jh->b_transaction) { 935 try_to_free = 1;
932 jbd_unlock_bh_state(bh);
933 /* needs a brelse */
934 jbd2_journal_remove_journal_head(bh);
935 release_buffer_page(bh);
936 } else
937 jbd_unlock_bh_state(bh);
938 } 936 }
937 JBUFFER_TRACE(jh, "refile or unfile buffer");
938 __jbd2_journal_refile_buffer(jh);
939 jbd_unlock_bh_state(bh);
940 if (try_to_free)
941 release_buffer_page(bh); /* Drops bh reference */
942 else
943 __brelse(bh);
939 cond_resched_lock(&journal->j_list_lock); 944 cond_resched_lock(&journal->j_list_lock);
940 } 945 }
941 spin_unlock(&journal->j_list_lock); 946 spin_unlock(&journal->j_list_lock);
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 9a7826990304..0dfa5b598e68 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -2078,10 +2078,9 @@ static void journal_free_journal_head(struct journal_head *jh)
2078 * When a buffer has its BH_JBD bit set it is immune from being released by 2078 * When a buffer has its BH_JBD bit set it is immune from being released by
2079 * core kernel code, mainly via ->b_count. 2079 * core kernel code, mainly via ->b_count.
2080 * 2080 *
2081 * A journal_head may be detached from its buffer_head when the journal_head's 2081 * A journal_head is detached from its buffer_head when the journal_head's
2082 * b_transaction, b_cp_transaction and b_next_transaction pointers are NULL. 2082 * b_jcount reaches zero. Running transaction (b_transaction) and checkpoint
2083 * Various places in JBD call jbd2_journal_remove_journal_head() to indicate that the 2083 * transaction (b_cp_transaction) hold their references to b_jcount.
2084 * journal_head can be dropped if needed.
2085 * 2084 *
2086 * Various places in the kernel want to attach a journal_head to a buffer_head 2085 * Various places in the kernel want to attach a journal_head to a buffer_head
2087 * _before_ attaching the journal_head to a transaction. To protect the 2086 * _before_ attaching the journal_head to a transaction. To protect the
@@ -2094,17 +2093,16 @@ static void journal_free_journal_head(struct journal_head *jh)
2094 * (Attach a journal_head if needed. Increments b_jcount) 2093 * (Attach a journal_head if needed. Increments b_jcount)
2095 * struct journal_head *jh = jbd2_journal_add_journal_head(bh); 2094 * struct journal_head *jh = jbd2_journal_add_journal_head(bh);
2096 * ... 2095 * ...
2096 * (Get another reference for transaction)
2097 * jbd2_journal_grab_journal_head(bh);
2097 * jh->b_transaction = xxx; 2098 * jh->b_transaction = xxx;
2099 * (Put original reference)
2098 * jbd2_journal_put_journal_head(jh); 2100 * jbd2_journal_put_journal_head(jh);
2099 *
2100 * Now, the journal_head's b_jcount is zero, but it is safe from being released
2101 * because it has a non-zero b_transaction.
2102 */ 2101 */
2103 2102
2104/* 2103/*
2105 * Give a buffer_head a journal_head. 2104 * Give a buffer_head a journal_head.
2106 * 2105 *
2107 * Doesn't need the journal lock.
2108 * May sleep. 2106 * May sleep.
2109 */ 2107 */
2110struct journal_head *jbd2_journal_add_journal_head(struct buffer_head *bh) 2108struct journal_head *jbd2_journal_add_journal_head(struct buffer_head *bh)
@@ -2168,61 +2166,29 @@ static void __journal_remove_journal_head(struct buffer_head *bh)
2168 struct journal_head *jh = bh2jh(bh); 2166 struct journal_head *jh = bh2jh(bh);
2169 2167
2170 J_ASSERT_JH(jh, jh->b_jcount >= 0); 2168 J_ASSERT_JH(jh, jh->b_jcount >= 0);
2171 2169 J_ASSERT_JH(jh, jh->b_transaction == NULL);
2172 get_bh(bh); 2170 J_ASSERT_JH(jh, jh->b_next_transaction == NULL);
2173 if (jh->b_jcount == 0) { 2171 J_ASSERT_JH(jh, jh->b_cp_transaction == NULL);
2174 if (jh->b_transaction == NULL && 2172 J_ASSERT_JH(jh, jh->b_jlist == BJ_None);
2175 jh->b_next_transaction == NULL && 2173 J_ASSERT_BH(bh, buffer_jbd(bh));
2176 jh->b_cp_transaction == NULL) { 2174 J_ASSERT_BH(bh, jh2bh(jh) == bh);
2177 J_ASSERT_JH(jh, jh->b_jlist == BJ_None); 2175 BUFFER_TRACE(bh, "remove journal_head");
2178 J_ASSERT_BH(bh, buffer_jbd(bh)); 2176 if (jh->b_frozen_data) {
2179 J_ASSERT_BH(bh, jh2bh(jh) == bh); 2177 printk(KERN_WARNING "%s: freeing b_frozen_data\n", __func__);
2180 BUFFER_TRACE(bh, "remove journal_head"); 2178 jbd2_free(jh->b_frozen_data, bh->b_size);
2181 if (jh->b_frozen_data) {
2182 printk(KERN_WARNING "%s: freeing "
2183 "b_frozen_data\n",
2184 __func__);
2185 jbd2_free(jh->b_frozen_data, bh->b_size);
2186 }
2187 if (jh->b_committed_data) {
2188 printk(KERN_WARNING "%s: freeing "
2189 "b_committed_data\n",
2190 __func__);
2191 jbd2_free(jh->b_committed_data, bh->b_size);
2192 }
2193 bh->b_private = NULL;
2194 jh->b_bh = NULL; /* debug, really */
2195 clear_buffer_jbd(bh);
2196 __brelse(bh);
2197 journal_free_journal_head(jh);
2198 } else {
2199 BUFFER_TRACE(bh, "journal_head was locked");
2200 }
2201 } 2179 }
2180 if (jh->b_committed_data) {
2181 printk(KERN_WARNING "%s: freeing b_committed_data\n", __func__);
2182 jbd2_free(jh->b_committed_data, bh->b_size);
2183 }
2184 bh->b_private = NULL;
2185 jh->b_bh = NULL; /* debug, really */
2186 clear_buffer_jbd(bh);
2187 journal_free_journal_head(jh);
2202} 2188}
2203 2189
2204/* 2190/*
2205 * jbd2_journal_remove_journal_head(): if the buffer isn't attached to a transaction 2191 * Drop a reference on the passed journal_head. If it fell to zero then
2206 * and has a zero b_jcount then remove and release its journal_head. If we did
2207 * see that the buffer is not used by any transaction we also "logically"
2208 * decrement ->b_count.
2209 *
2210 * We in fact take an additional increment on ->b_count as a convenience,
2211 * because the caller usually wants to do additional things with the bh
2212 * after calling here.
2213 * The caller of jbd2_journal_remove_journal_head() *must* run __brelse(bh) at some
2214 * time. Once the caller has run __brelse(), the buffer is eligible for
2215 * reaping by try_to_free_buffers().
2216 */
2217void jbd2_journal_remove_journal_head(struct buffer_head *bh)
2218{
2219 jbd_lock_bh_journal_head(bh);
2220 __journal_remove_journal_head(bh);
2221 jbd_unlock_bh_journal_head(bh);
2222}
2223
2224/*
2225 * Drop a reference on the passed journal_head. If it fell to zero then try to
2226 * release the journal_head from the buffer_head. 2192 * release the journal_head from the buffer_head.
2227 */ 2193 */
2228void jbd2_journal_put_journal_head(struct journal_head *jh) 2194void jbd2_journal_put_journal_head(struct journal_head *jh)
@@ -2232,11 +2198,12 @@ void jbd2_journal_put_journal_head(struct journal_head *jh)
2232 jbd_lock_bh_journal_head(bh); 2198 jbd_lock_bh_journal_head(bh);
2233 J_ASSERT_JH(jh, jh->b_jcount > 0); 2199 J_ASSERT_JH(jh, jh->b_jcount > 0);
2234 --jh->b_jcount; 2200 --jh->b_jcount;
2235 if (!jh->b_jcount && !jh->b_transaction) { 2201 if (!jh->b_jcount) {
2236 __journal_remove_journal_head(bh); 2202 __journal_remove_journal_head(bh);
2203 jbd_unlock_bh_journal_head(bh);
2237 __brelse(bh); 2204 __brelse(bh);
2238 } 2205 } else
2239 jbd_unlock_bh_journal_head(bh); 2206 jbd_unlock_bh_journal_head(bh);
2240} 2207}
2241 2208
2242/* 2209/*
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index 3eec82d32fd4..2d7109414cdd 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -30,6 +30,7 @@
30#include <linux/module.h> 30#include <linux/module.h>
31 31
32static void __jbd2_journal_temp_unlink_buffer(struct journal_head *jh); 32static void __jbd2_journal_temp_unlink_buffer(struct journal_head *jh);
33static void __jbd2_journal_unfile_buffer(struct journal_head *jh);
33 34
34/* 35/*
35 * jbd2_get_transaction: obtain a new transaction_t object. 36 * jbd2_get_transaction: obtain a new transaction_t object.
@@ -764,7 +765,6 @@ repeat:
764 if (!jh->b_transaction) { 765 if (!jh->b_transaction) {
765 JBUFFER_TRACE(jh, "no transaction"); 766 JBUFFER_TRACE(jh, "no transaction");
766 J_ASSERT_JH(jh, !jh->b_next_transaction); 767 J_ASSERT_JH(jh, !jh->b_next_transaction);
767 jh->b_transaction = transaction;
768 JBUFFER_TRACE(jh, "file as BJ_Reserved"); 768 JBUFFER_TRACE(jh, "file as BJ_Reserved");
769 spin_lock(&journal->j_list_lock); 769 spin_lock(&journal->j_list_lock);
770 __jbd2_journal_file_buffer(jh, transaction, BJ_Reserved); 770 __jbd2_journal_file_buffer(jh, transaction, BJ_Reserved);
@@ -814,7 +814,6 @@ out:
814 * int jbd2_journal_get_write_access() - notify intent to modify a buffer for metadata (not data) update. 814 * int jbd2_journal_get_write_access() - notify intent to modify a buffer for metadata (not data) update.
815 * @handle: transaction to add buffer modifications to 815 * @handle: transaction to add buffer modifications to
816 * @bh: bh to be used for metadata writes 816 * @bh: bh to be used for metadata writes
817 * @credits: variable that will receive credits for the buffer
818 * 817 *
819 * Returns an error code or 0 on success. 818 * Returns an error code or 0 on success.
820 * 819 *
@@ -896,8 +895,6 @@ int jbd2_journal_get_create_access(handle_t *handle, struct buffer_head *bh)
896 * committed and so it's safe to clear the dirty bit. 895 * committed and so it's safe to clear the dirty bit.
897 */ 896 */
898 clear_buffer_dirty(jh2bh(jh)); 897 clear_buffer_dirty(jh2bh(jh));
899 jh->b_transaction = transaction;
900
901 /* first access by this transaction */ 898 /* first access by this transaction */
902 jh->b_modified = 0; 899 jh->b_modified = 0;
903 900
@@ -932,7 +929,6 @@ out:
932 * non-rewindable consequences 929 * non-rewindable consequences
933 * @handle: transaction 930 * @handle: transaction
934 * @bh: buffer to undo 931 * @bh: buffer to undo
935 * @credits: store the number of taken credits here (if not NULL)
936 * 932 *
937 * Sometimes there is a need to distinguish between metadata which has 933 * Sometimes there is a need to distinguish between metadata which has
938 * been committed to disk and that which has not. The ext3fs code uses 934 * been committed to disk and that which has not. The ext3fs code uses
@@ -1232,8 +1228,6 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
1232 __jbd2_journal_file_buffer(jh, transaction, BJ_Forget); 1228 __jbd2_journal_file_buffer(jh, transaction, BJ_Forget);
1233 } else { 1229 } else {
1234 __jbd2_journal_unfile_buffer(jh); 1230 __jbd2_journal_unfile_buffer(jh);
1235 jbd2_journal_remove_journal_head(bh);
1236 __brelse(bh);
1237 if (!buffer_jbd(bh)) { 1231 if (!buffer_jbd(bh)) {
1238 spin_unlock(&journal->j_list_lock); 1232 spin_unlock(&journal->j_list_lock);
1239 jbd_unlock_bh_state(bh); 1233 jbd_unlock_bh_state(bh);
@@ -1556,19 +1550,32 @@ void __jbd2_journal_temp_unlink_buffer(struct journal_head *jh)
1556 mark_buffer_dirty(bh); /* Expose it to the VM */ 1550 mark_buffer_dirty(bh); /* Expose it to the VM */
1557} 1551}
1558 1552
1559void __jbd2_journal_unfile_buffer(struct journal_head *jh) 1553/*
1554 * Remove buffer from all transactions.
1555 *
1556 * Called with bh_state lock and j_list_lock
1557 *
1558 * jh and bh may be already freed when this function returns.
1559 */
1560static void __jbd2_journal_unfile_buffer(struct journal_head *jh)
1560{ 1561{
1561 __jbd2_journal_temp_unlink_buffer(jh); 1562 __jbd2_journal_temp_unlink_buffer(jh);
1562 jh->b_transaction = NULL; 1563 jh->b_transaction = NULL;
1564 jbd2_journal_put_journal_head(jh);
1563} 1565}
1564 1566
1565void jbd2_journal_unfile_buffer(journal_t *journal, struct journal_head *jh) 1567void jbd2_journal_unfile_buffer(journal_t *journal, struct journal_head *jh)
1566{ 1568{
1567 jbd_lock_bh_state(jh2bh(jh)); 1569 struct buffer_head *bh = jh2bh(jh);
1570
1571 /* Get reference so that buffer cannot be freed before we unlock it */
1572 get_bh(bh);
1573 jbd_lock_bh_state(bh);
1568 spin_lock(&journal->j_list_lock); 1574 spin_lock(&journal->j_list_lock);
1569 __jbd2_journal_unfile_buffer(jh); 1575 __jbd2_journal_unfile_buffer(jh);
1570 spin_unlock(&journal->j_list_lock); 1576 spin_unlock(&journal->j_list_lock);
1571 jbd_unlock_bh_state(jh2bh(jh)); 1577 jbd_unlock_bh_state(bh);
1578 __brelse(bh);
1572} 1579}
1573 1580
1574/* 1581/*
@@ -1595,8 +1602,6 @@ __journal_try_to_free_buffer(journal_t *journal, struct buffer_head *bh)
1595 if (jh->b_jlist == BJ_None) { 1602 if (jh->b_jlist == BJ_None) {
1596 JBUFFER_TRACE(jh, "remove from checkpoint list"); 1603 JBUFFER_TRACE(jh, "remove from checkpoint list");
1597 __jbd2_journal_remove_checkpoint(jh); 1604 __jbd2_journal_remove_checkpoint(jh);
1598 jbd2_journal_remove_journal_head(bh);
1599 __brelse(bh);
1600 } 1605 }
1601 } 1606 }
1602 spin_unlock(&journal->j_list_lock); 1607 spin_unlock(&journal->j_list_lock);
@@ -1659,7 +1664,6 @@ int jbd2_journal_try_to_free_buffers(journal_t *journal,
1659 /* 1664 /*
1660 * We take our own ref against the journal_head here to avoid 1665 * We take our own ref against the journal_head here to avoid
1661 * having to add tons of locking around each instance of 1666 * having to add tons of locking around each instance of
1662 * jbd2_journal_remove_journal_head() and
1663 * jbd2_journal_put_journal_head(). 1667 * jbd2_journal_put_journal_head().
1664 */ 1668 */
1665 jh = jbd2_journal_grab_journal_head(bh); 1669 jh = jbd2_journal_grab_journal_head(bh);
@@ -1697,10 +1701,9 @@ static int __dispose_buffer(struct journal_head *jh, transaction_t *transaction)
1697 int may_free = 1; 1701 int may_free = 1;
1698 struct buffer_head *bh = jh2bh(jh); 1702 struct buffer_head *bh = jh2bh(jh);
1699 1703
1700 __jbd2_journal_unfile_buffer(jh);
1701
1702 if (jh->b_cp_transaction) { 1704 if (jh->b_cp_transaction) {
1703 JBUFFER_TRACE(jh, "on running+cp transaction"); 1705 JBUFFER_TRACE(jh, "on running+cp transaction");
1706 __jbd2_journal_temp_unlink_buffer(jh);
1704 /* 1707 /*
1705 * We don't want to write the buffer anymore, clear the 1708 * We don't want to write the buffer anymore, clear the
1706 * bit so that we don't confuse checks in 1709 * bit so that we don't confuse checks in
@@ -1711,8 +1714,7 @@ static int __dispose_buffer(struct journal_head *jh, transaction_t *transaction)
1711 may_free = 0; 1714 may_free = 0;
1712 } else { 1715 } else {
1713 JBUFFER_TRACE(jh, "on running transaction"); 1716 JBUFFER_TRACE(jh, "on running transaction");
1714 jbd2_journal_remove_journal_head(bh); 1717 __jbd2_journal_unfile_buffer(jh);
1715 __brelse(bh);
1716 } 1718 }
1717 return may_free; 1719 return may_free;
1718} 1720}
@@ -1990,6 +1992,8 @@ void __jbd2_journal_file_buffer(struct journal_head *jh,
1990 1992
1991 if (jh->b_transaction) 1993 if (jh->b_transaction)
1992 __jbd2_journal_temp_unlink_buffer(jh); 1994 __jbd2_journal_temp_unlink_buffer(jh);
1995 else
1996 jbd2_journal_grab_journal_head(bh);
1993 jh->b_transaction = transaction; 1997 jh->b_transaction = transaction;
1994 1998
1995 switch (jlist) { 1999 switch (jlist) {
@@ -2041,9 +2045,10 @@ void jbd2_journal_file_buffer(struct journal_head *jh,
2041 * already started to be used by a subsequent transaction, refile the 2045 * already started to be used by a subsequent transaction, refile the
2042 * buffer on that transaction's metadata list. 2046 * buffer on that transaction's metadata list.
2043 * 2047 *
2044 * Called under journal->j_list_lock 2048 * Called under j_list_lock
2045 *
2046 * Called under jbd_lock_bh_state(jh2bh(jh)) 2049 * Called under jbd_lock_bh_state(jh2bh(jh))
2050 *
2051 * jh and bh may be already free when this function returns
2047 */ 2052 */
2048void __jbd2_journal_refile_buffer(struct journal_head *jh) 2053void __jbd2_journal_refile_buffer(struct journal_head *jh)
2049{ 2054{
@@ -2067,6 +2072,11 @@ void __jbd2_journal_refile_buffer(struct journal_head *jh)
2067 2072
2068 was_dirty = test_clear_buffer_jbddirty(bh); 2073 was_dirty = test_clear_buffer_jbddirty(bh);
2069 __jbd2_journal_temp_unlink_buffer(jh); 2074 __jbd2_journal_temp_unlink_buffer(jh);
2075 /*
2076 * We set b_transaction here because b_next_transaction will inherit
2077 * our jh reference and thus __jbd2_journal_file_buffer() must not
2078 * take a new one.
2079 */
2070 jh->b_transaction = jh->b_next_transaction; 2080 jh->b_transaction = jh->b_next_transaction;
2071 jh->b_next_transaction = NULL; 2081 jh->b_next_transaction = NULL;
2072 if (buffer_freed(bh)) 2082 if (buffer_freed(bh))
@@ -2083,30 +2093,21 @@ void __jbd2_journal_refile_buffer(struct journal_head *jh)
2083} 2093}
2084 2094
2085/* 2095/*
2086 * For the unlocked version of this call, also make sure that any 2096 * __jbd2_journal_refile_buffer() with necessary locking added. We take our
2087 * hanging journal_head is cleaned up if necessary. 2097 * bh reference so that we can safely unlock bh.
2088 * 2098 *
2089 * __jbd2_journal_refile_buffer is usually called as part of a single locked 2099 * The jh and bh may be freed by this call.
2090 * operation on a buffer_head, in which the caller is probably going to
2091 * be hooking the journal_head onto other lists. In that case it is up
2092 * to the caller to remove the journal_head if necessary. For the
2093 * unlocked jbd2_journal_refile_buffer call, the caller isn't going to be
2094 * doing anything else to the buffer so we need to do the cleanup
2095 * ourselves to avoid a jh leak.
2096 *
2097 * *** The journal_head may be freed by this call! ***
2098 */ 2100 */
2099void jbd2_journal_refile_buffer(journal_t *journal, struct journal_head *jh) 2101void jbd2_journal_refile_buffer(journal_t *journal, struct journal_head *jh)
2100{ 2102{
2101 struct buffer_head *bh = jh2bh(jh); 2103 struct buffer_head *bh = jh2bh(jh);
2102 2104
2105 /* Get reference so that buffer cannot be freed before we unlock it */
2106 get_bh(bh);
2103 jbd_lock_bh_state(bh); 2107 jbd_lock_bh_state(bh);
2104 spin_lock(&journal->j_list_lock); 2108 spin_lock(&journal->j_list_lock);
2105
2106 __jbd2_journal_refile_buffer(jh); 2109 __jbd2_journal_refile_buffer(jh);
2107 jbd_unlock_bh_state(bh); 2110 jbd_unlock_bh_state(bh);
2108 jbd2_journal_remove_journal_head(bh);
2109
2110 spin_unlock(&journal->j_list_lock); 2111 spin_unlock(&journal->j_list_lock);
2111 __brelse(bh); 2112 __brelse(bh);
2112} 2113}
diff --git a/fs/jfs/file.c b/fs/jfs/file.c
index c5ce6c1d1ff4..2f3f531f3606 100644
--- a/fs/jfs/file.c
+++ b/fs/jfs/file.c
@@ -66,9 +66,9 @@ static int jfs_open(struct inode *inode, struct file *file)
66 struct jfs_inode_info *ji = JFS_IP(inode); 66 struct jfs_inode_info *ji = JFS_IP(inode);
67 spin_lock_irq(&ji->ag_lock); 67 spin_lock_irq(&ji->ag_lock);
68 if (ji->active_ag == -1) { 68 if (ji->active_ag == -1) {
69 ji->active_ag = ji->agno; 69 struct jfs_sb_info *jfs_sb = JFS_SBI(inode->i_sb);
70 atomic_inc( 70 ji->active_ag = BLKTOAG(addressPXD(&ji->ixpxd), jfs_sb);
71 &JFS_SBI(inode->i_sb)->bmap->db_active[ji->agno]); 71 atomic_inc( &jfs_sb->bmap->db_active[ji->active_ag]);
72 } 72 }
73 spin_unlock_irq(&ji->ag_lock); 73 spin_unlock_irq(&ji->ag_lock);
74 } 74 }
diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
index ed53a4740168..b78b2f978f04 100644
--- a/fs/jfs/jfs_imap.c
+++ b/fs/jfs/jfs_imap.c
@@ -397,7 +397,7 @@ int diRead(struct inode *ip)
397 release_metapage(mp); 397 release_metapage(mp);
398 398
399 /* set the ag for the inode */ 399 /* set the ag for the inode */
400 JFS_IP(ip)->agno = BLKTOAG(agstart, sbi); 400 JFS_IP(ip)->agstart = agstart;
401 JFS_IP(ip)->active_ag = -1; 401 JFS_IP(ip)->active_ag = -1;
402 402
403 return (rc); 403 return (rc);
@@ -901,7 +901,7 @@ int diFree(struct inode *ip)
901 901
902 /* get the allocation group for this ino. 902 /* get the allocation group for this ino.
903 */ 903 */
904 agno = JFS_IP(ip)->agno; 904 agno = BLKTOAG(JFS_IP(ip)->agstart, JFS_SBI(ip->i_sb));
905 905
906 /* Lock the AG specific inode map information 906 /* Lock the AG specific inode map information
907 */ 907 */
@@ -1315,12 +1315,11 @@ int diFree(struct inode *ip)
1315static inline void 1315static inline void
1316diInitInode(struct inode *ip, int iagno, int ino, int extno, struct iag * iagp) 1316diInitInode(struct inode *ip, int iagno, int ino, int extno, struct iag * iagp)
1317{ 1317{
1318 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
1319 struct jfs_inode_info *jfs_ip = JFS_IP(ip); 1318 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
1320 1319
1321 ip->i_ino = (iagno << L2INOSPERIAG) + ino; 1320 ip->i_ino = (iagno << L2INOSPERIAG) + ino;
1322 jfs_ip->ixpxd = iagp->inoext[extno]; 1321 jfs_ip->ixpxd = iagp->inoext[extno];
1323 jfs_ip->agno = BLKTOAG(le64_to_cpu(iagp->agstart), sbi); 1322 jfs_ip->agstart = le64_to_cpu(iagp->agstart);
1324 jfs_ip->active_ag = -1; 1323 jfs_ip->active_ag = -1;
1325} 1324}
1326 1325
@@ -1379,7 +1378,7 @@ int diAlloc(struct inode *pip, bool dir, struct inode *ip)
1379 */ 1378 */
1380 1379
1381 /* get the ag number of this iag */ 1380 /* get the ag number of this iag */
1382 agno = JFS_IP(pip)->agno; 1381 agno = BLKTOAG(JFS_IP(pip)->agstart, JFS_SBI(pip->i_sb));
1383 1382
1384 if (atomic_read(&JFS_SBI(pip->i_sb)->bmap->db_active[agno])) { 1383 if (atomic_read(&JFS_SBI(pip->i_sb)->bmap->db_active[agno])) {
1385 /* 1384 /*
@@ -2921,10 +2920,9 @@ int diExtendFS(struct inode *ipimap, struct inode *ipbmap)
2921 continue; 2920 continue;
2922 } 2921 }
2923 2922
2924 /* agstart that computes to the same ag is treated as same; */
2925 agstart = le64_to_cpu(iagp->agstart); 2923 agstart = le64_to_cpu(iagp->agstart);
2926 /* iagp->agstart = agstart & ~(mp->db_agsize - 1); */
2927 n = agstart >> mp->db_agl2size; 2924 n = agstart >> mp->db_agl2size;
2925 iagp->agstart = cpu_to_le64((s64)n << mp->db_agl2size);
2928 2926
2929 /* compute backed inodes */ 2927 /* compute backed inodes */
2930 numinos = (EXTSPERIAG - le32_to_cpu(iagp->nfreeexts)) 2928 numinos = (EXTSPERIAG - le32_to_cpu(iagp->nfreeexts))
diff --git a/fs/jfs/jfs_incore.h b/fs/jfs/jfs_incore.h
index 1439f119ec83..584a4a1a6e81 100644
--- a/fs/jfs/jfs_incore.h
+++ b/fs/jfs/jfs_incore.h
@@ -50,8 +50,9 @@ struct jfs_inode_info {
50 short btindex; /* btpage entry index*/ 50 short btindex; /* btpage entry index*/
51 struct inode *ipimap; /* inode map */ 51 struct inode *ipimap; /* inode map */
52 unsigned long cflag; /* commit flags */ 52 unsigned long cflag; /* commit flags */
53 u64 agstart; /* agstart of the containing IAG */
53 u16 bxflag; /* xflag of pseudo buffer? */ 54 u16 bxflag; /* xflag of pseudo buffer? */
54 unchar agno; /* ag number */ 55 unchar pad;
55 signed char active_ag; /* ag currently allocating from */ 56 signed char active_ag; /* ag currently allocating from */
56 lid_t blid; /* lid of pseudo buffer? */ 57 lid_t blid; /* lid of pseudo buffer? */
57 lid_t atlhead; /* anonymous tlock list head */ 58 lid_t atlhead; /* anonymous tlock list head */
diff --git a/fs/jfs/resize.c b/fs/jfs/resize.c
index 8ea5efb5a34e..8d0c1c7c0820 100644
--- a/fs/jfs/resize.c
+++ b/fs/jfs/resize.c
@@ -80,7 +80,7 @@ int jfs_extendfs(struct super_block *sb, s64 newLVSize, int newLogSize)
80 int log_formatted = 0; 80 int log_formatted = 0;
81 struct inode *iplist[1]; 81 struct inode *iplist[1];
82 struct jfs_superblock *j_sb, *j_sb2; 82 struct jfs_superblock *j_sb, *j_sb2;
83 uint old_agsize; 83 s64 old_agsize;
84 int agsizechanged = 0; 84 int agsizechanged = 0;
85 struct buffer_head *bh, *bh2; 85 struct buffer_head *bh, *bh2;
86 86
diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
index adb45ec9038c..e374050a911c 100644
--- a/fs/lockd/clntproc.c
+++ b/fs/lockd/clntproc.c
@@ -708,7 +708,13 @@ static void nlmclnt_unlock_callback(struct rpc_task *task, void *data)
708 708
709 if (task->tk_status < 0) { 709 if (task->tk_status < 0) {
710 dprintk("lockd: unlock failed (err = %d)\n", -task->tk_status); 710 dprintk("lockd: unlock failed (err = %d)\n", -task->tk_status);
711 goto retry_rebind; 711 switch (task->tk_status) {
712 case -EACCES:
713 case -EIO:
714 goto die;
715 default:
716 goto retry_rebind;
717 }
712 } 718 }
713 if (status == NLM_LCK_DENIED_GRACE_PERIOD) { 719 if (status == NLM_LCK_DENIED_GRACE_PERIOD) {
714 rpc_delay(task, NLMCLNT_GRACE_WAIT); 720 rpc_delay(task, NLMCLNT_GRACE_WAIT);
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 144f2a3c7185..6f4850deb272 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -256,7 +256,8 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
256 256
257 nfs_attr_check_mountpoint(sb, fattr); 257 nfs_attr_check_mountpoint(sb, fattr);
258 258
259 if ((fattr->valid & NFS_ATTR_FATTR_FILEID) == 0 && (fattr->valid & NFS_ATTR_FATTR_MOUNTPOINT) == 0) 259 if (((fattr->valid & NFS_ATTR_FATTR_FILEID) == 0) &&
260 !nfs_attr_use_mounted_on_fileid(fattr))
260 goto out_no_inode; 261 goto out_no_inode;
261 if ((fattr->valid & NFS_ATTR_FATTR_TYPE) == 0) 262 if ((fattr->valid & NFS_ATTR_FATTR_TYPE) == 0)
262 goto out_no_inode; 263 goto out_no_inode;
@@ -1294,7 +1295,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
1294 if (new_isize != cur_isize) { 1295 if (new_isize != cur_isize) {
1295 /* Do we perhaps have any outstanding writes, or has 1296 /* Do we perhaps have any outstanding writes, or has
1296 * the file grown beyond our last write? */ 1297 * the file grown beyond our last write? */
1297 if (nfsi->npages == 0 || new_isize > cur_isize) { 1298 if ((nfsi->npages == 0 && !test_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags)) ||
1299 new_isize > cur_isize) {
1298 i_size_write(inode, new_isize); 1300 i_size_write(inode, new_isize);
1299 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA; 1301 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA;
1300 } 1302 }
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index b9056cbe68d6..2a55347a2daa 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -45,6 +45,17 @@ static inline void nfs_attr_check_mountpoint(struct super_block *parent, struct
45 fattr->valid |= NFS_ATTR_FATTR_MOUNTPOINT; 45 fattr->valid |= NFS_ATTR_FATTR_MOUNTPOINT;
46} 46}
47 47
48static inline int nfs_attr_use_mounted_on_fileid(struct nfs_fattr *fattr)
49{
50 if (((fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) == 0) ||
51 (((fattr->valid & NFS_ATTR_FATTR_MOUNTPOINT) == 0) &&
52 ((fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL) == 0)))
53 return 0;
54
55 fattr->fileid = fattr->mounted_on_fileid;
56 return 1;
57}
58
48struct nfs_clone_mount { 59struct nfs_clone_mount {
49 const struct super_block *sb; 60 const struct super_block *sb;
50 const struct dentry *dentry; 61 const struct dentry *dentry;
diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c
index 426908809c97..0bafcc91c27f 100644
--- a/fs/nfs/nfs4filelayout.c
+++ b/fs/nfs/nfs4filelayout.c
@@ -30,6 +30,7 @@
30 */ 30 */
31 31
32#include <linux/nfs_fs.h> 32#include <linux/nfs_fs.h>
33#include <linux/nfs_page.h>
33 34
34#include "internal.h" 35#include "internal.h"
35#include "nfs4filelayout.h" 36#include "nfs4filelayout.h"
@@ -552,13 +553,18 @@ filelayout_decode_layout(struct pnfs_layout_hdr *flo,
552 __func__, nfl_util, fl->num_fh, fl->first_stripe_index, 553 __func__, nfl_util, fl->num_fh, fl->first_stripe_index,
553 fl->pattern_offset); 554 fl->pattern_offset);
554 555
555 if (!fl->num_fh) 556 /* Note that a zero value for num_fh is legal for STRIPE_SPARSE.
557 * Futher checking is done in filelayout_check_layout */
558 if (fl->num_fh < 0 || fl->num_fh >
559 max(NFS4_PNFS_MAX_STRIPE_CNT, NFS4_PNFS_MAX_MULTI_CNT))
556 goto out_err; 560 goto out_err;
557 561
558 fl->fh_array = kzalloc(fl->num_fh * sizeof(struct nfs_fh *), 562 if (fl->num_fh > 0) {
559 gfp_flags); 563 fl->fh_array = kzalloc(fl->num_fh * sizeof(struct nfs_fh *),
560 if (!fl->fh_array) 564 gfp_flags);
561 goto out_err; 565 if (!fl->fh_array)
566 goto out_err;
567 }
562 568
563 for (i = 0; i < fl->num_fh; i++) { 569 for (i = 0; i < fl->num_fh; i++) {
564 /* Do we want to use a mempool here? */ 570 /* Do we want to use a mempool here? */
@@ -661,8 +667,9 @@ filelayout_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev,
661 u64 p_stripe, r_stripe; 667 u64 p_stripe, r_stripe;
662 u32 stripe_unit; 668 u32 stripe_unit;
663 669
664 if (!pnfs_generic_pg_test(pgio, prev, req)) 670 if (!pnfs_generic_pg_test(pgio, prev, req) ||
665 return 0; 671 !nfs_generic_pg_test(pgio, prev, req))
672 return false;
666 673
667 if (!pgio->pg_lseg) 674 if (!pgio->pg_lseg)
668 return 1; 675 return 1;
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index d2c4b59c896d..5879b23e0c99 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -2265,12 +2265,14 @@ static int nfs4_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
2265 return nfs4_map_errors(status); 2265 return nfs4_map_errors(status);
2266} 2266}
2267 2267
2268static void nfs_fixup_referral_attributes(struct nfs_fattr *fattr);
2268/* 2269/*
2269 * Get locations and (maybe) other attributes of a referral. 2270 * Get locations and (maybe) other attributes of a referral.
2270 * Note that we'll actually follow the referral later when 2271 * Note that we'll actually follow the referral later when
2271 * we detect fsid mismatch in inode revalidation 2272 * we detect fsid mismatch in inode revalidation
2272 */ 2273 */
2273static int nfs4_get_referral(struct inode *dir, const struct qstr *name, struct nfs_fattr *fattr, struct nfs_fh *fhandle) 2274static int nfs4_get_referral(struct inode *dir, const struct qstr *name,
2275 struct nfs_fattr *fattr, struct nfs_fh *fhandle)
2274{ 2276{
2275 int status = -ENOMEM; 2277 int status = -ENOMEM;
2276 struct page *page = NULL; 2278 struct page *page = NULL;
@@ -2288,15 +2290,16 @@ static int nfs4_get_referral(struct inode *dir, const struct qstr *name, struct
2288 goto out; 2290 goto out;
2289 /* Make sure server returned a different fsid for the referral */ 2291 /* Make sure server returned a different fsid for the referral */
2290 if (nfs_fsid_equal(&NFS_SERVER(dir)->fsid, &locations->fattr.fsid)) { 2292 if (nfs_fsid_equal(&NFS_SERVER(dir)->fsid, &locations->fattr.fsid)) {
2291 dprintk("%s: server did not return a different fsid for a referral at %s\n", __func__, name->name); 2293 dprintk("%s: server did not return a different fsid for"
2294 " a referral at %s\n", __func__, name->name);
2292 status = -EIO; 2295 status = -EIO;
2293 goto out; 2296 goto out;
2294 } 2297 }
2298 /* Fixup attributes for the nfs_lookup() call to nfs_fhget() */
2299 nfs_fixup_referral_attributes(&locations->fattr);
2295 2300
2301 /* replace the lookup nfs_fattr with the locations nfs_fattr */
2296 memcpy(fattr, &locations->fattr, sizeof(struct nfs_fattr)); 2302 memcpy(fattr, &locations->fattr, sizeof(struct nfs_fattr));
2297 fattr->valid |= NFS_ATTR_FATTR_V4_REFERRAL;
2298 if (!fattr->mode)
2299 fattr->mode = S_IFDIR;
2300 memset(fhandle, 0, sizeof(struct nfs_fh)); 2303 memset(fhandle, 0, sizeof(struct nfs_fh));
2301out: 2304out:
2302 if (page) 2305 if (page)
@@ -4667,11 +4670,15 @@ static size_t nfs4_xattr_list_nfs4_acl(struct dentry *dentry, char *list,
4667 return len; 4670 return len;
4668} 4671}
4669 4672
4673/*
4674 * nfs_fhget will use either the mounted_on_fileid or the fileid
4675 */
4670static void nfs_fixup_referral_attributes(struct nfs_fattr *fattr) 4676static void nfs_fixup_referral_attributes(struct nfs_fattr *fattr)
4671{ 4677{
4672 if (!((fattr->valid & NFS_ATTR_FATTR_FILEID) && 4678 if (!(((fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) ||
4673 (fattr->valid & NFS_ATTR_FATTR_FSID) && 4679 (fattr->valid & NFS_ATTR_FATTR_FILEID)) &&
4674 (fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL))) 4680 (fattr->valid & NFS_ATTR_FATTR_FSID) &&
4681 (fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL)))
4675 return; 4682 return;
4676 4683
4677 fattr->valid |= NFS_ATTR_FATTR_TYPE | NFS_ATTR_FATTR_MODE | 4684 fattr->valid |= NFS_ATTR_FATTR_TYPE | NFS_ATTR_FATTR_MODE |
@@ -4686,7 +4693,6 @@ int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name,
4686 struct nfs_server *server = NFS_SERVER(dir); 4693 struct nfs_server *server = NFS_SERVER(dir);
4687 u32 bitmask[2] = { 4694 u32 bitmask[2] = {
4688 [0] = FATTR4_WORD0_FSID | FATTR4_WORD0_FS_LOCATIONS, 4695 [0] = FATTR4_WORD0_FSID | FATTR4_WORD0_FS_LOCATIONS,
4689 [1] = FATTR4_WORD1_MOUNTED_ON_FILEID,
4690 }; 4696 };
4691 struct nfs4_fs_locations_arg args = { 4697 struct nfs4_fs_locations_arg args = {
4692 .dir_fh = NFS_FH(dir), 4698 .dir_fh = NFS_FH(dir),
@@ -4705,11 +4711,18 @@ int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name,
4705 int status; 4711 int status;
4706 4712
4707 dprintk("%s: start\n", __func__); 4713 dprintk("%s: start\n", __func__);
4714
4715 /* Ask for the fileid of the absent filesystem if mounted_on_fileid
4716 * is not supported */
4717 if (NFS_SERVER(dir)->attr_bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)
4718 bitmask[1] |= FATTR4_WORD1_MOUNTED_ON_FILEID;
4719 else
4720 bitmask[0] |= FATTR4_WORD0_FILEID;
4721
4708 nfs_fattr_init(&fs_locations->fattr); 4722 nfs_fattr_init(&fs_locations->fattr);
4709 fs_locations->server = server; 4723 fs_locations->server = server;
4710 fs_locations->nlocations = 0; 4724 fs_locations->nlocations = 0;
4711 status = nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 0); 4725 status = nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 0);
4712 nfs_fixup_referral_attributes(&fs_locations->fattr);
4713 dprintk("%s: returned status = %d\n", __func__, status); 4726 dprintk("%s: returned status = %d\n", __func__, status);
4714 return status; 4727 return status;
4715} 4728}
@@ -5098,7 +5111,6 @@ static void nfs4_init_channel_attrs(struct nfs41_create_session_args *args)
5098 if (mxresp_sz == 0) 5111 if (mxresp_sz == 0)
5099 mxresp_sz = NFS_MAX_FILE_IO_SIZE; 5112 mxresp_sz = NFS_MAX_FILE_IO_SIZE;
5100 /* Fore channel attributes */ 5113 /* Fore channel attributes */
5101 args->fc_attrs.headerpadsz = 0;
5102 args->fc_attrs.max_rqst_sz = mxrqst_sz; 5114 args->fc_attrs.max_rqst_sz = mxrqst_sz;
5103 args->fc_attrs.max_resp_sz = mxresp_sz; 5115 args->fc_attrs.max_resp_sz = mxresp_sz;
5104 args->fc_attrs.max_ops = NFS4_MAX_OPS; 5116 args->fc_attrs.max_ops = NFS4_MAX_OPS;
@@ -5111,7 +5123,6 @@ static void nfs4_init_channel_attrs(struct nfs41_create_session_args *args)
5111 args->fc_attrs.max_ops, args->fc_attrs.max_reqs); 5123 args->fc_attrs.max_ops, args->fc_attrs.max_reqs);
5112 5124
5113 /* Back channel attributes */ 5125 /* Back channel attributes */
5114 args->bc_attrs.headerpadsz = 0;
5115 args->bc_attrs.max_rqst_sz = PAGE_SIZE; 5126 args->bc_attrs.max_rqst_sz = PAGE_SIZE;
5116 args->bc_attrs.max_resp_sz = PAGE_SIZE; 5127 args->bc_attrs.max_resp_sz = PAGE_SIZE;
5117 args->bc_attrs.max_resp_sz_cached = 0; 5128 args->bc_attrs.max_resp_sz_cached = 0;
@@ -5131,8 +5142,6 @@ static int nfs4_verify_fore_channel_attrs(struct nfs41_create_session_args *args
5131 struct nfs4_channel_attrs *sent = &args->fc_attrs; 5142 struct nfs4_channel_attrs *sent = &args->fc_attrs;
5132 struct nfs4_channel_attrs *rcvd = &session->fc_attrs; 5143 struct nfs4_channel_attrs *rcvd = &session->fc_attrs;
5133 5144
5134 if (rcvd->headerpadsz > sent->headerpadsz)
5135 return -EINVAL;
5136 if (rcvd->max_resp_sz > sent->max_resp_sz) 5145 if (rcvd->max_resp_sz > sent->max_resp_sz)
5137 return -EINVAL; 5146 return -EINVAL;
5138 /* 5147 /*
@@ -5697,6 +5706,7 @@ static void nfs4_layoutreturn_done(struct rpc_task *task, void *calldata)
5697{ 5706{
5698 struct nfs4_layoutreturn *lrp = calldata; 5707 struct nfs4_layoutreturn *lrp = calldata;
5699 struct nfs_server *server; 5708 struct nfs_server *server;
5709 struct pnfs_layout_hdr *lo = NFS_I(lrp->args.inode)->layout;
5700 5710
5701 dprintk("--> %s\n", __func__); 5711 dprintk("--> %s\n", __func__);
5702 5712
@@ -5708,16 +5718,15 @@ static void nfs4_layoutreturn_done(struct rpc_task *task, void *calldata)
5708 nfs_restart_rpc(task, lrp->clp); 5718 nfs_restart_rpc(task, lrp->clp);
5709 return; 5719 return;
5710 } 5720 }
5721 spin_lock(&lo->plh_inode->i_lock);
5711 if (task->tk_status == 0) { 5722 if (task->tk_status == 0) {
5712 struct pnfs_layout_hdr *lo = NFS_I(lrp->args.inode)->layout;
5713
5714 if (lrp->res.lrs_present) { 5723 if (lrp->res.lrs_present) {
5715 spin_lock(&lo->plh_inode->i_lock);
5716 pnfs_set_layout_stateid(lo, &lrp->res.stateid, true); 5724 pnfs_set_layout_stateid(lo, &lrp->res.stateid, true);
5717 spin_unlock(&lo->plh_inode->i_lock);
5718 } else 5725 } else
5719 BUG_ON(!list_empty(&lo->plh_segs)); 5726 BUG_ON(!list_empty(&lo->plh_segs));
5720 } 5727 }
5728 lo->plh_block_lgets--;
5729 spin_unlock(&lo->plh_inode->i_lock);
5721 dprintk("<-- %s\n", __func__); 5730 dprintk("<-- %s\n", __func__);
5722} 5731}
5723 5732
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index d869a5e5464b..6870bc61ceec 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -255,7 +255,7 @@ static int nfs4_stat_to_errno(int);
255#define decode_fs_locations_maxsz \ 255#define decode_fs_locations_maxsz \
256 (0) 256 (0)
257#define encode_secinfo_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz) 257#define encode_secinfo_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz)
258#define decode_secinfo_maxsz (op_decode_hdr_maxsz + 4 + (NFS_MAX_SECFLAVORS * (16 + GSS_OID_MAX_LEN))) 258#define decode_secinfo_maxsz (op_decode_hdr_maxsz + 1 + ((NFS_MAX_SECFLAVORS * (16 + GSS_OID_MAX_LEN)) / 4))
259 259
260#if defined(CONFIG_NFS_V4_1) 260#if defined(CONFIG_NFS_V4_1)
261#define NFS4_MAX_MACHINE_NAME_LEN (64) 261#define NFS4_MAX_MACHINE_NAME_LEN (64)
@@ -1725,7 +1725,7 @@ static void encode_create_session(struct xdr_stream *xdr,
1725 *p++ = cpu_to_be32(args->flags); /*flags */ 1725 *p++ = cpu_to_be32(args->flags); /*flags */
1726 1726
1727 /* Fore Channel */ 1727 /* Fore Channel */
1728 *p++ = cpu_to_be32(args->fc_attrs.headerpadsz); /* header padding size */ 1728 *p++ = cpu_to_be32(0); /* header padding size */
1729 *p++ = cpu_to_be32(args->fc_attrs.max_rqst_sz); /* max req size */ 1729 *p++ = cpu_to_be32(args->fc_attrs.max_rqst_sz); /* max req size */
1730 *p++ = cpu_to_be32(args->fc_attrs.max_resp_sz); /* max resp size */ 1730 *p++ = cpu_to_be32(args->fc_attrs.max_resp_sz); /* max resp size */
1731 *p++ = cpu_to_be32(max_resp_sz_cached); /* Max resp sz cached */ 1731 *p++ = cpu_to_be32(max_resp_sz_cached); /* Max resp sz cached */
@@ -1734,7 +1734,7 @@ static void encode_create_session(struct xdr_stream *xdr,
1734 *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ 1734 *p++ = cpu_to_be32(0); /* rdmachannel_attrs */
1735 1735
1736 /* Back Channel */ 1736 /* Back Channel */
1737 *p++ = cpu_to_be32(args->fc_attrs.headerpadsz); /* header padding size */ 1737 *p++ = cpu_to_be32(0); /* header padding size */
1738 *p++ = cpu_to_be32(args->bc_attrs.max_rqst_sz); /* max req size */ 1738 *p++ = cpu_to_be32(args->bc_attrs.max_rqst_sz); /* max req size */
1739 *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz); /* max resp size */ 1739 *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz); /* max resp size */
1740 *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz_cached); /* Max resp sz cached */ 1740 *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz_cached); /* Max resp sz cached */
@@ -3098,7 +3098,7 @@ out_overflow:
3098 return -EIO; 3098 return -EIO;
3099} 3099}
3100 3100
3101static int decode_attr_error(struct xdr_stream *xdr, uint32_t *bitmap) 3101static int decode_attr_error(struct xdr_stream *xdr, uint32_t *bitmap, int32_t *res)
3102{ 3102{
3103 __be32 *p; 3103 __be32 *p;
3104 3104
@@ -3109,7 +3109,7 @@ static int decode_attr_error(struct xdr_stream *xdr, uint32_t *bitmap)
3109 if (unlikely(!p)) 3109 if (unlikely(!p))
3110 goto out_overflow; 3110 goto out_overflow;
3111 bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR; 3111 bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR;
3112 return -be32_to_cpup(p); 3112 *res = -be32_to_cpup(p);
3113 } 3113 }
3114 return 0; 3114 return 0;
3115out_overflow: 3115out_overflow:
@@ -4070,6 +4070,7 @@ static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap,
4070 int status; 4070 int status;
4071 umode_t fmode = 0; 4071 umode_t fmode = 0;
4072 uint32_t type; 4072 uint32_t type;
4073 int32_t err;
4073 4074
4074 status = decode_attr_type(xdr, bitmap, &type); 4075 status = decode_attr_type(xdr, bitmap, &type);
4075 if (status < 0) 4076 if (status < 0)
@@ -4095,13 +4096,12 @@ static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap,
4095 goto xdr_error; 4096 goto xdr_error;
4096 fattr->valid |= status; 4097 fattr->valid |= status;
4097 4098
4098 status = decode_attr_error(xdr, bitmap); 4099 err = 0;
4099 if (status == -NFS4ERR_WRONGSEC) { 4100 status = decode_attr_error(xdr, bitmap, &err);
4100 nfs_fixup_secinfo_attributes(fattr, fh);
4101 status = 0;
4102 }
4103 if (status < 0) 4101 if (status < 0)
4104 goto xdr_error; 4102 goto xdr_error;
4103 if (err == -NFS4ERR_WRONGSEC)
4104 nfs_fixup_secinfo_attributes(fattr, fh);
4105 4105
4106 status = decode_attr_filehandle(xdr, bitmap, fh); 4106 status = decode_attr_filehandle(xdr, bitmap, fh);
4107 if (status < 0) 4107 if (status < 0)
@@ -4997,12 +4997,14 @@ static int decode_chan_attrs(struct xdr_stream *xdr,
4997 struct nfs4_channel_attrs *attrs) 4997 struct nfs4_channel_attrs *attrs)
4998{ 4998{
4999 __be32 *p; 4999 __be32 *p;
5000 u32 nr_attrs; 5000 u32 nr_attrs, val;
5001 5001
5002 p = xdr_inline_decode(xdr, 28); 5002 p = xdr_inline_decode(xdr, 28);
5003 if (unlikely(!p)) 5003 if (unlikely(!p))
5004 goto out_overflow; 5004 goto out_overflow;
5005 attrs->headerpadsz = be32_to_cpup(p++); 5005 val = be32_to_cpup(p++); /* headerpadsz */
5006 if (val)
5007 return -EINVAL; /* no support for header padding yet */
5006 attrs->max_rqst_sz = be32_to_cpup(p++); 5008 attrs->max_rqst_sz = be32_to_cpup(p++);
5007 attrs->max_resp_sz = be32_to_cpup(p++); 5009 attrs->max_resp_sz = be32_to_cpup(p++);
5008 attrs->max_resp_sz_cached = be32_to_cpup(p++); 5010 attrs->max_resp_sz_cached = be32_to_cpup(p++);
diff --git a/fs/nfs/objlayout/objio_osd.c b/fs/nfs/objlayout/objio_osd.c
index 9cf208df1f25..8ff2ea3f10ef 100644
--- a/fs/nfs/objlayout/objio_osd.c
+++ b/fs/nfs/objlayout/objio_osd.c
@@ -108,7 +108,6 @@ _dev_list_add(const struct nfs_server *nfss,
108 de = n; 108 de = n;
109 } 109 }
110 110
111 atomic_inc(&de->id_node.ref);
112 return de; 111 return de;
113} 112}
114 113
@@ -1001,6 +1000,9 @@ static bool objio_pg_test(struct nfs_pageio_descriptor *pgio,
1001 if (!pnfs_generic_pg_test(pgio, prev, req)) 1000 if (!pnfs_generic_pg_test(pgio, prev, req))
1002 return false; 1001 return false;
1003 1002
1003 if (pgio->pg_lseg == NULL)
1004 return true;
1005
1004 return pgio->pg_count + req->wb_bytes <= 1006 return pgio->pg_count + req->wb_bytes <=
1005 OBJIO_LSEG(pgio->pg_lseg)->max_io_size; 1007 OBJIO_LSEG(pgio->pg_lseg)->max_io_size;
1006} 1008}
diff --git a/fs/nfs/objlayout/objlayout.c b/fs/nfs/objlayout/objlayout.c
index dc3956c0de80..1d06f8e2adea 100644
--- a/fs/nfs/objlayout/objlayout.c
+++ b/fs/nfs/objlayout/objlayout.c
@@ -291,7 +291,7 @@ objlayout_read_done(struct objlayout_io_state *state, ssize_t status, bool sync)
291 struct nfs_read_data *rdata; 291 struct nfs_read_data *rdata;
292 292
293 state->status = status; 293 state->status = status;
294 dprintk("%s: Begin status=%ld eof=%d\n", __func__, status, eof); 294 dprintk("%s: Begin status=%zd eof=%d\n", __func__, status, eof);
295 rdata = state->rpcdata; 295 rdata = state->rpcdata;
296 rdata->task.tk_status = status; 296 rdata->task.tk_status = status;
297 if (status >= 0) { 297 if (status >= 0) {
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index 7913961aff22..009855716286 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -204,7 +204,7 @@ nfs_wait_on_request(struct nfs_page *req)
204 TASK_UNINTERRUPTIBLE); 204 TASK_UNINTERRUPTIBLE);
205} 205}
206 206
207static bool nfs_generic_pg_test(struct nfs_pageio_descriptor *desc, struct nfs_page *prev, struct nfs_page *req) 207bool nfs_generic_pg_test(struct nfs_pageio_descriptor *desc, struct nfs_page *prev, struct nfs_page *req)
208{ 208{
209 /* 209 /*
210 * FIXME: ideally we should be able to coalesce all requests 210 * FIXME: ideally we should be able to coalesce all requests
@@ -218,6 +218,7 @@ static bool nfs_generic_pg_test(struct nfs_pageio_descriptor *desc, struct nfs_p
218 218
219 return desc->pg_count + req->wb_bytes <= desc->pg_bsize; 219 return desc->pg_count + req->wb_bytes <= desc->pg_bsize;
220} 220}
221EXPORT_SYMBOL_GPL(nfs_generic_pg_test);
221 222
222/** 223/**
223 * nfs_pageio_init - initialise a page io descriptor 224 * nfs_pageio_init - initialise a page io descriptor
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 8c1309d852a6..29c0ca7fc347 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -634,14 +634,16 @@ _pnfs_return_layout(struct inode *ino)
634 634
635 spin_lock(&ino->i_lock); 635 spin_lock(&ino->i_lock);
636 lo = nfsi->layout; 636 lo = nfsi->layout;
637 if (!lo || !mark_matching_lsegs_invalid(lo, &tmp_list, NULL)) { 637 if (!lo) {
638 spin_unlock(&ino->i_lock); 638 spin_unlock(&ino->i_lock);
639 dprintk("%s: no layout segments to return\n", __func__); 639 dprintk("%s: no layout to return\n", __func__);
640 goto out; 640 return status;
641 } 641 }
642 stateid = nfsi->layout->plh_stateid; 642 stateid = nfsi->layout->plh_stateid;
643 /* Reference matched in nfs4_layoutreturn_release */ 643 /* Reference matched in nfs4_layoutreturn_release */
644 get_layout_hdr(lo); 644 get_layout_hdr(lo);
645 mark_matching_lsegs_invalid(lo, &tmp_list, NULL);
646 lo->plh_block_lgets++;
645 spin_unlock(&ino->i_lock); 647 spin_unlock(&ino->i_lock);
646 pnfs_free_lseg_list(&tmp_list); 648 pnfs_free_lseg_list(&tmp_list);
647 649
@@ -650,6 +652,9 @@ _pnfs_return_layout(struct inode *ino)
650 lrp = kzalloc(sizeof(*lrp), GFP_KERNEL); 652 lrp = kzalloc(sizeof(*lrp), GFP_KERNEL);
651 if (unlikely(lrp == NULL)) { 653 if (unlikely(lrp == NULL)) {
652 status = -ENOMEM; 654 status = -ENOMEM;
655 set_bit(NFS_LAYOUT_RW_FAILED, &lo->plh_flags);
656 set_bit(NFS_LAYOUT_RO_FAILED, &lo->plh_flags);
657 put_layout_hdr(lo);
653 goto out; 658 goto out;
654 } 659 }
655 660
@@ -887,7 +892,7 @@ pnfs_find_lseg(struct pnfs_layout_hdr *lo,
887 ret = get_lseg(lseg); 892 ret = get_lseg(lseg);
888 break; 893 break;
889 } 894 }
890 if (cmp_layout(range, &lseg->pls_range) > 0) 895 if (lseg->pls_range.offset > range->offset)
891 break; 896 break;
892 } 897 }
893 898
@@ -1059,23 +1064,36 @@ pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev,
1059 gfp_flags = GFP_NOFS; 1064 gfp_flags = GFP_NOFS;
1060 } 1065 }
1061 1066
1062 if (pgio->pg_count == prev->wb_bytes) { 1067 if (pgio->pg_lseg == NULL) {
1068 if (pgio->pg_count != prev->wb_bytes)
1069 return true;
1063 /* This is first coelesce call for a series of nfs_pages */ 1070 /* This is first coelesce call for a series of nfs_pages */
1064 pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, 1071 pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode,
1065 prev->wb_context, 1072 prev->wb_context,
1066 req_offset(req), 1073 req_offset(prev),
1067 pgio->pg_count, 1074 pgio->pg_count,
1068 access_type, 1075 access_type,
1069 gfp_flags); 1076 gfp_flags);
1070 return true; 1077 if (pgio->pg_lseg == NULL)
1078 return true;
1071 } 1079 }
1072 1080
1073 if (pgio->pg_lseg && 1081 /*
1074 req_offset(req) > end_offset(pgio->pg_lseg->pls_range.offset, 1082 * Test if a nfs_page is fully contained in the pnfs_layout_range.
1075 pgio->pg_lseg->pls_range.length)) 1083 * Note that this test makes several assumptions:
1076 return false; 1084 * - that the previous nfs_page in the struct nfs_pageio_descriptor
1077 1085 * is known to lie within the range.
1078 return true; 1086 * - that the nfs_page being tested is known to be contiguous with the
1087 * previous nfs_page.
1088 * - Layout ranges are page aligned, so we only have to test the
1089 * start offset of the request.
1090 *
1091 * Please also note that 'end_offset' is actually the offset of the
1092 * first byte that lies outside the pnfs_layout_range. FIXME?
1093 *
1094 */
1095 return req_offset(req) < end_offset(pgio->pg_lseg->pls_range.offset,
1096 pgio->pg_lseg->pls_range.length);
1079} 1097}
1080EXPORT_SYMBOL_GPL(pnfs_generic_pg_test); 1098EXPORT_SYMBOL_GPL(pnfs_generic_pg_test);
1081 1099
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index 48d0a8e4d062..96bf4e6f45be 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -186,6 +186,7 @@ int pnfs_ld_read_done(struct nfs_read_data *);
186/* pnfs_dev.c */ 186/* pnfs_dev.c */
187struct nfs4_deviceid_node { 187struct nfs4_deviceid_node {
188 struct hlist_node node; 188 struct hlist_node node;
189 struct hlist_node tmpnode;
189 const struct pnfs_layoutdriver_type *ld; 190 const struct pnfs_layoutdriver_type *ld;
190 const struct nfs_client *nfs_client; 191 const struct nfs_client *nfs_client;
191 struct nfs4_deviceid deviceid; 192 struct nfs4_deviceid deviceid;
diff --git a/fs/nfs/pnfs_dev.c b/fs/nfs/pnfs_dev.c
index c65e133ce9c0..f0f8e1e22f6c 100644
--- a/fs/nfs/pnfs_dev.c
+++ b/fs/nfs/pnfs_dev.c
@@ -174,6 +174,7 @@ nfs4_init_deviceid_node(struct nfs4_deviceid_node *d,
174 const struct nfs4_deviceid *id) 174 const struct nfs4_deviceid *id)
175{ 175{
176 INIT_HLIST_NODE(&d->node); 176 INIT_HLIST_NODE(&d->node);
177 INIT_HLIST_NODE(&d->tmpnode);
177 d->ld = ld; 178 d->ld = ld;
178 d->nfs_client = nfs_client; 179 d->nfs_client = nfs_client;
179 d->deviceid = *id; 180 d->deviceid = *id;
@@ -208,6 +209,7 @@ nfs4_insert_deviceid_node(struct nfs4_deviceid_node *new)
208 209
209 hlist_add_head_rcu(&new->node, &nfs4_deviceid_cache[hash]); 210 hlist_add_head_rcu(&new->node, &nfs4_deviceid_cache[hash]);
210 spin_unlock(&nfs4_deviceid_lock); 211 spin_unlock(&nfs4_deviceid_lock);
212 atomic_inc(&new->ref);
211 213
212 return new; 214 return new;
213} 215}
@@ -238,24 +240,29 @@ static void
238_deviceid_purge_client(const struct nfs_client *clp, long hash) 240_deviceid_purge_client(const struct nfs_client *clp, long hash)
239{ 241{
240 struct nfs4_deviceid_node *d; 242 struct nfs4_deviceid_node *d;
241 struct hlist_node *n, *next; 243 struct hlist_node *n;
242 HLIST_HEAD(tmp); 244 HLIST_HEAD(tmp);
243 245
246 spin_lock(&nfs4_deviceid_lock);
244 rcu_read_lock(); 247 rcu_read_lock();
245 hlist_for_each_entry_rcu(d, n, &nfs4_deviceid_cache[hash], node) 248 hlist_for_each_entry_rcu(d, n, &nfs4_deviceid_cache[hash], node)
246 if (d->nfs_client == clp && atomic_read(&d->ref)) { 249 if (d->nfs_client == clp && atomic_read(&d->ref)) {
247 hlist_del_init_rcu(&d->node); 250 hlist_del_init_rcu(&d->node);
248 hlist_add_head(&d->node, &tmp); 251 hlist_add_head(&d->tmpnode, &tmp);
249 } 252 }
250 rcu_read_unlock(); 253 rcu_read_unlock();
254 spin_unlock(&nfs4_deviceid_lock);
251 255
252 if (hlist_empty(&tmp)) 256 if (hlist_empty(&tmp))
253 return; 257 return;
254 258
255 synchronize_rcu(); 259 synchronize_rcu();
256 hlist_for_each_entry_safe(d, n, next, &tmp, node) 260 while (!hlist_empty(&tmp)) {
261 d = hlist_entry(tmp.first, struct nfs4_deviceid_node, tmpnode);
262 hlist_del(&d->tmpnode);
257 if (atomic_dec_and_test(&d->ref)) 263 if (atomic_dec_and_test(&d->ref))
258 d->ld->free_deviceid_node(d); 264 d->ld->free_deviceid_node(d);
265 }
259} 266}
260 267
261void 268void
@@ -263,8 +270,8 @@ nfs4_deviceid_purge_client(const struct nfs_client *clp)
263{ 270{
264 long h; 271 long h;
265 272
266 spin_lock(&nfs4_deviceid_lock); 273 if (!(clp->cl_exchange_flags & EXCHGID4_FLAG_USE_PNFS_MDS))
274 return;
267 for (h = 0; h < NFS4_DEVICE_ID_HASH_SIZE; h++) 275 for (h = 0; h < NFS4_DEVICE_ID_HASH_SIZE; h++)
268 _deviceid_purge_client(clp, h); 276 _deviceid_purge_client(clp, h);
269 spin_unlock(&nfs4_deviceid_lock);
270} 277}
diff --git a/fs/omfs/file.c b/fs/omfs/file.c
index d738a7e493dd..2c6d95257a4d 100644
--- a/fs/omfs/file.c
+++ b/fs/omfs/file.c
@@ -4,7 +4,6 @@
4 * Released under GPL v2. 4 * Released under GPL v2.
5 */ 5 */
6 6
7#include <linux/version.h>
8#include <linux/module.h> 7#include <linux/module.h>
9#include <linux/fs.h> 8#include <linux/fs.h>
10#include <linux/buffer_head.h> 9#include <linux/buffer_head.h>
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 8a84210ca080..fc5bc2767692 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -2708,6 +2708,9 @@ static int do_io_accounting(struct task_struct *task, char *buffer, int whole)
2708 struct task_io_accounting acct = task->ioac; 2708 struct task_io_accounting acct = task->ioac;
2709 unsigned long flags; 2709 unsigned long flags;
2710 2710
2711 if (!ptrace_may_access(task, PTRACE_MODE_READ))
2712 return -EACCES;
2713
2711 if (whole && lock_task_sighand(task, &flags)) { 2714 if (whole && lock_task_sighand(task, &flags)) {
2712 struct task_struct *t = task; 2715 struct task_struct *t = task;
2713 2716
@@ -2839,7 +2842,7 @@ static const struct pid_entry tgid_base_stuff[] = {
2839 REG("coredump_filter", S_IRUGO|S_IWUSR, proc_coredump_filter_operations), 2842 REG("coredump_filter", S_IRUGO|S_IWUSR, proc_coredump_filter_operations),
2840#endif 2843#endif
2841#ifdef CONFIG_TASK_IO_ACCOUNTING 2844#ifdef CONFIG_TASK_IO_ACCOUNTING
2842 INF("io", S_IRUGO, proc_tgid_io_accounting), 2845 INF("io", S_IRUSR, proc_tgid_io_accounting),
2843#endif 2846#endif
2844#ifdef CONFIG_HARDWALL 2847#ifdef CONFIG_HARDWALL
2845 INF("hardwall", S_IRUGO, proc_pid_hardwall), 2848 INF("hardwall", S_IRUGO, proc_pid_hardwall),
@@ -3181,7 +3184,7 @@ static const struct pid_entry tid_base_stuff[] = {
3181 REG("make-it-fail", S_IRUGO|S_IWUSR, proc_fault_inject_operations), 3184 REG("make-it-fail", S_IRUGO|S_IWUSR, proc_fault_inject_operations),
3182#endif 3185#endif
3183#ifdef CONFIG_TASK_IO_ACCOUNTING 3186#ifdef CONFIG_TASK_IO_ACCOUNTING
3184 INF("io", S_IRUGO, proc_tid_io_accounting), 3187 INF("io", S_IRUSR, proc_tid_io_accounting),
3185#endif 3188#endif
3186#ifdef CONFIG_HARDWALL 3189#ifdef CONFIG_HARDWALL
3187 INF("hardwall", S_IRUGO, proc_pid_hardwall), 3190 INF("hardwall", S_IRUGO, proc_pid_hardwall),
diff --git a/fs/romfs/mmap-nommu.c b/fs/romfs/mmap-nommu.c
index f0511e816967..eed99428f104 100644
--- a/fs/romfs/mmap-nommu.c
+++ b/fs/romfs/mmap-nommu.c
@@ -27,14 +27,18 @@ static unsigned long romfs_get_unmapped_area(struct file *file,
27{ 27{
28 struct inode *inode = file->f_mapping->host; 28 struct inode *inode = file->f_mapping->host;
29 struct mtd_info *mtd = inode->i_sb->s_mtd; 29 struct mtd_info *mtd = inode->i_sb->s_mtd;
30 unsigned long isize, offset; 30 unsigned long isize, offset, maxpages, lpages;
31 31
32 if (!mtd) 32 if (!mtd)
33 goto cant_map_directly; 33 goto cant_map_directly;
34 34
35 /* the mapping mustn't extend beyond the EOF */
36 lpages = (len + PAGE_SIZE - 1) >> PAGE_SHIFT;
35 isize = i_size_read(inode); 37 isize = i_size_read(inode);
36 offset = pgoff << PAGE_SHIFT; 38 offset = pgoff << PAGE_SHIFT;
37 if (offset > isize || len > isize || offset > isize - len) 39
40 maxpages = (isize + PAGE_SIZE - 1) >> PAGE_SHIFT;
41 if ((pgoff >= maxpages) || (maxpages - pgoff < lpages))
38 return (unsigned long) -EINVAL; 42 return (unsigned long) -EINVAL;
39 43
40 /* we need to call down to the MTD layer to do the actual mapping */ 44 /* we need to call down to the MTD layer to do the actual mapping */
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index c86375378810..01d2072fb6d4 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -490,6 +490,13 @@ xfs_attr_remove_int(xfs_inode_t *dp, struct xfs_name *name, int flags)
490 args.whichfork = XFS_ATTR_FORK; 490 args.whichfork = XFS_ATTR_FORK;
491 491
492 /* 492 /*
493 * we have no control over the attribute names that userspace passes us
494 * to remove, so we have to allow the name lookup prior to attribute
495 * removal to fail.
496 */
497 args.op_flags = XFS_DA_OP_OKNOENT;
498
499 /*
493 * Attach the dquots to the inode. 500 * Attach the dquots to the inode.
494 */ 501 */
495 error = xfs_qm_dqattach(dp, 0); 502 error = xfs_qm_dqattach(dp, 0);
diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c
index cb9b6d1469f7..3631783b2b53 100644
--- a/fs/xfs/xfs_iget.c
+++ b/fs/xfs/xfs_iget.c
@@ -253,16 +253,21 @@ xfs_iget_cache_hit(
253 rcu_read_lock(); 253 rcu_read_lock();
254 spin_lock(&ip->i_flags_lock); 254 spin_lock(&ip->i_flags_lock);
255 255
256 ip->i_flags &= ~XFS_INEW; 256 ip->i_flags &= ~(XFS_INEW | XFS_IRECLAIM);
257 ip->i_flags |= XFS_IRECLAIMABLE; 257 ASSERT(ip->i_flags & XFS_IRECLAIMABLE);
258 __xfs_inode_set_reclaim_tag(pag, ip);
259 trace_xfs_iget_reclaim_fail(ip); 258 trace_xfs_iget_reclaim_fail(ip);
260 goto out_error; 259 goto out_error;
261 } 260 }
262 261
263 spin_lock(&pag->pag_ici_lock); 262 spin_lock(&pag->pag_ici_lock);
264 spin_lock(&ip->i_flags_lock); 263 spin_lock(&ip->i_flags_lock);
265 ip->i_flags &= ~(XFS_IRECLAIMABLE | XFS_IRECLAIM); 264
265 /*
266 * Clear the per-lifetime state in the inode as we are now
267 * effectively a new inode and need to return to the initial
268 * state before reuse occurs.
269 */
270 ip->i_flags &= ~XFS_IRECLAIM_RESET_FLAGS;
266 ip->i_flags |= XFS_INEW; 271 ip->i_flags |= XFS_INEW;
267 __xfs_inode_clear_reclaim_tag(mp, pag, ip); 272 __xfs_inode_clear_reclaim_tag(mp, pag, ip);
268 inode->i_state = I_NEW; 273 inode->i_state = I_NEW;
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 3ae6d58e5473..964cfea77686 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -384,6 +384,16 @@ static inline void xfs_ifunlock(xfs_inode_t *ip)
384#define XFS_IDIRTY_RELEASE 0x0040 /* dirty release already seen */ 384#define XFS_IDIRTY_RELEASE 0x0040 /* dirty release already seen */
385 385
386/* 386/*
387 * Per-lifetime flags need to be reset when re-using a reclaimable inode during
388 * inode lookup. Thi prevents unintended behaviour on the new inode from
389 * ocurring.
390 */
391#define XFS_IRECLAIM_RESET_FLAGS \
392 (XFS_IRECLAIMABLE | XFS_IRECLAIM | \
393 XFS_IDIRTY_RELEASE | XFS_ITRUNCATED | \
394 XFS_IFILESTREAM);
395
396/*
387 * Flags for inode locking. 397 * Flags for inode locking.
388 * Bit ranges: 1<<1 - 1<<16-1 -- iolock/ilock modes (bitfield) 398 * Bit ranges: 1<<1 - 1<<16-1 -- iolock/ilock modes (bitfield)
389 * 1<<16 - 1<<32-1 -- lockdep annotation (integers) 399 * 1<<16 - 1<<32-1 -- lockdep annotation (integers)
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index b7a5fe7c52c8..619720705bc6 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -960,8 +960,11 @@ xfs_release(
960 * be exposed to that problem. 960 * be exposed to that problem.
961 */ 961 */
962 truncated = xfs_iflags_test_and_clear(ip, XFS_ITRUNCATED); 962 truncated = xfs_iflags_test_and_clear(ip, XFS_ITRUNCATED);
963 if (truncated && VN_DIRTY(VFS_I(ip)) && ip->i_delayed_blks > 0) 963 if (truncated) {
964 xfs_flush_pages(ip, 0, -1, XBF_ASYNC, FI_NONE); 964 xfs_iflags_clear(ip, XFS_IDIRTY_RELEASE);
965 if (VN_DIRTY(VFS_I(ip)) && ip->i_delayed_blks > 0)
966 xfs_flush_pages(ip, 0, -1, XBF_ASYNC, FI_NONE);
967 }
965 } 968 }
966 969
967 if (ip->i_d.di_nlink == 0) 970 if (ip->i_d.di_nlink == 0)
diff --git a/include/linux/amba/serial.h b/include/linux/amba/serial.h
index 5479fdc849e9..514ed45c462e 100644
--- a/include/linux/amba/serial.h
+++ b/include/linux/amba/serial.h
@@ -201,6 +201,9 @@ struct amba_pl011_data {
201 bool (*dma_filter)(struct dma_chan *chan, void *filter_param); 201 bool (*dma_filter)(struct dma_chan *chan, void *filter_param);
202 void *dma_rx_param; 202 void *dma_rx_param;
203 void *dma_tx_param; 203 void *dma_tx_param;
204 void (*init) (void);
205 void (*exit) (void);
206 void (*reset) (void);
204}; 207};
205#endif 208#endif
206 209
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index 2a7cea53ca0d..6395692b2e7a 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -167,7 +167,7 @@ enum rq_flag_bits {
167 (REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER) 167 (REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER)
168#define REQ_COMMON_MASK \ 168#define REQ_COMMON_MASK \
169 (REQ_WRITE | REQ_FAILFAST_MASK | REQ_SYNC | REQ_META | REQ_DISCARD | \ 169 (REQ_WRITE | REQ_FAILFAST_MASK | REQ_SYNC | REQ_META | REQ_DISCARD | \
170 REQ_NOIDLE | REQ_FLUSH | REQ_FUA) 170 REQ_NOIDLE | REQ_FLUSH | REQ_FUA | REQ_SECURE)
171#define REQ_CLONE_MASK REQ_COMMON_MASK 171#define REQ_CLONE_MASK REQ_COMMON_MASK
172 172
173#define REQ_RAHEAD (1 << __REQ_RAHEAD) 173#define REQ_RAHEAD (1 << __REQ_RAHEAD)
diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
index b22fb0d3db0f..8c7c2de7631a 100644
--- a/include/linux/blktrace_api.h
+++ b/include/linux/blktrace_api.h
@@ -169,7 +169,8 @@ extern void blk_trace_shutdown(struct request_queue *);
169extern int do_blk_trace_setup(struct request_queue *q, char *name, 169extern int do_blk_trace_setup(struct request_queue *q, char *name,
170 dev_t dev, struct block_device *bdev, 170 dev_t dev, struct block_device *bdev,
171 struct blk_user_trace_setup *buts); 171 struct blk_user_trace_setup *buts);
172extern void __trace_note_message(struct blk_trace *, const char *fmt, ...); 172extern __attribute__((format(printf, 2, 3)))
173void __trace_note_message(struct blk_trace *, const char *fmt, ...);
173 174
174/** 175/**
175 * blk_add_trace_msg - Add a (simple) message to the blktrace stream 176 * blk_add_trace_msg - Add a (simple) message to the blktrace stream
diff --git a/include/linux/compat.h b/include/linux/compat.h
index ddcb7db38e67..846bb1792572 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -467,6 +467,8 @@ asmlinkage long compat_sys_setsockopt(int fd, int level, int optname,
467 char __user *optval, unsigned int optlen); 467 char __user *optval, unsigned int optlen);
468asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg, 468asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg,
469 unsigned flags); 469 unsigned flags);
470asmlinkage long compat_sys_sendmmsg(int fd, struct compat_mmsghdr __user *mmsg,
471 unsigned vlen, unsigned int flags);
470asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg, 472asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg,
471 unsigned int flags); 473 unsigned int flags);
472asmlinkage long compat_sys_recv(int fd, void __user *buf, size_t len, 474asmlinkage long compat_sys_recv(int fd, void __user *buf, size_t len,
diff --git a/include/linux/connector.h b/include/linux/connector.h
index 7c60d0942adb..f696bccd48cb 100644
--- a/include/linux/connector.h
+++ b/include/linux/connector.h
@@ -44,7 +44,7 @@
44#define CN_VAL_DRBD 0x1 44#define CN_VAL_DRBD 0x1
45#define CN_KVP_IDX 0x9 /* HyperV KVP */ 45#define CN_KVP_IDX 0x9 /* HyperV KVP */
46 46
47#define CN_NETLINK_USERS 9 47#define CN_NETLINK_USERS 10 /* Highest index + 1 */
48 48
49/* 49/*
50 * Maximum connector's message size. 50 * Maximum connector's message size.
diff --git a/include/linux/device.h b/include/linux/device.h
index c66111affca9..e4f62d8896b7 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -530,7 +530,6 @@ struct device_dma_parameters {
530 * @dma_mem: Internal for coherent mem override. 530 * @dma_mem: Internal for coherent mem override.
531 * @archdata: For arch-specific additions. 531 * @archdata: For arch-specific additions.
532 * @of_node: Associated device tree node. 532 * @of_node: Associated device tree node.
533 * @of_match: Matching of_device_id from driver.
534 * @devt: For creating the sysfs "dev". 533 * @devt: For creating the sysfs "dev".
535 * @devres_lock: Spinlock to protect the resource of the device. 534 * @devres_lock: Spinlock to protect the resource of the device.
536 * @devres_head: The resources list of the device. 535 * @devres_head: The resources list of the device.
@@ -654,13 +653,13 @@ static inline int device_is_registered(struct device *dev)
654 653
655static inline void device_enable_async_suspend(struct device *dev) 654static inline void device_enable_async_suspend(struct device *dev)
656{ 655{
657 if (!dev->power.in_suspend) 656 if (!dev->power.is_prepared)
658 dev->power.async_suspend = true; 657 dev->power.async_suspend = true;
659} 658}
660 659
661static inline void device_disable_async_suspend(struct device *dev) 660static inline void device_disable_async_suspend(struct device *dev)
662{ 661{
663 if (!dev->power.in_suspend) 662 if (!dev->power.is_prepared)
664 dev->power.async_suspend = false; 663 dev->power.async_suspend = false;
665} 664}
666 665
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 6e73e2e9ae33..b5b979247863 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -639,6 +639,7 @@ struct address_space {
639 struct prio_tree_root i_mmap; /* tree of private and shared mappings */ 639 struct prio_tree_root i_mmap; /* tree of private and shared mappings */
640 struct list_head i_mmap_nonlinear;/*list VM_NONLINEAR mappings */ 640 struct list_head i_mmap_nonlinear;/*list VM_NONLINEAR mappings */
641 struct mutex i_mmap_mutex; /* protect tree, count, list */ 641 struct mutex i_mmap_mutex; /* protect tree, count, list */
642 /* Protected by tree_lock together with the radix tree */
642 unsigned long nrpages; /* number of total pages */ 643 unsigned long nrpages; /* number of total pages */
643 pgoff_t writeback_index;/* writeback starts here */ 644 pgoff_t writeback_index;/* writeback starts here */
644 const struct address_space_operations *a_ops; /* methods */ 645 const struct address_space_operations *a_ops; /* methods */
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 51932e5acf7c..fd0dc30c9f15 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -135,6 +135,7 @@ struct hrtimer_sleeper {
135 * @cpu_base: per cpu clock base 135 * @cpu_base: per cpu clock base
136 * @index: clock type index for per_cpu support when moving a 136 * @index: clock type index for per_cpu support when moving a
137 * timer to a base on another cpu. 137 * timer to a base on another cpu.
138 * @clockid: clock id for per_cpu support
138 * @active: red black tree root node for the active timers 139 * @active: red black tree root node for the active timers
139 * @resolution: the resolution of the clock, in nanoseconds 140 * @resolution: the resolution of the clock, in nanoseconds
140 * @get_time: function to retrieve the current time of the clock 141 * @get_time: function to retrieve the current time of the clock
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index 4ecb7b16b278..d087c2e7b2aa 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -1024,7 +1024,6 @@ struct journal_s
1024 1024
1025/* Filing buffers */ 1025/* Filing buffers */
1026extern void jbd2_journal_unfile_buffer(journal_t *, struct journal_head *); 1026extern void jbd2_journal_unfile_buffer(journal_t *, struct journal_head *);
1027extern void __jbd2_journal_unfile_buffer(struct journal_head *);
1028extern void __jbd2_journal_refile_buffer(struct journal_head *); 1027extern void __jbd2_journal_refile_buffer(struct journal_head *);
1029extern void jbd2_journal_refile_buffer(journal_t *, struct journal_head *); 1028extern void jbd2_journal_refile_buffer(journal_t *, struct journal_head *);
1030extern void __jbd2_journal_file_buffer(struct journal_head *, transaction_t *, int); 1029extern void __jbd2_journal_file_buffer(struct journal_head *, transaction_t *, int);
@@ -1165,7 +1164,6 @@ extern void jbd2_journal_release_jbd_inode(journal_t *journal, struct jbd2_in
1165 */ 1164 */
1166struct journal_head *jbd2_journal_add_journal_head(struct buffer_head *bh); 1165struct journal_head *jbd2_journal_add_journal_head(struct buffer_head *bh);
1167struct journal_head *jbd2_journal_grab_journal_head(struct buffer_head *bh); 1166struct journal_head *jbd2_journal_grab_journal_head(struct buffer_head *bh);
1168void jbd2_journal_remove_journal_head(struct buffer_head *bh);
1169void jbd2_journal_put_journal_head(struct journal_head *jh); 1167void jbd2_journal_put_journal_head(struct journal_head *jh);
1170 1168
1171/* 1169/*
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index c928dac6cad0..9f7c3ebcbbad 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -647,6 +647,13 @@ typedef struct pglist_data {
647#endif 647#endif
648#define nid_page_nr(nid, pagenr) pgdat_page_nr(NODE_DATA(nid),(pagenr)) 648#define nid_page_nr(nid, pagenr) pgdat_page_nr(NODE_DATA(nid),(pagenr))
649 649
650#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
651
652#define node_end_pfn(nid) ({\
653 pg_data_t *__pgdat = NODE_DATA(nid);\
654 __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
655})
656
650#include <linux/memory_hotplug.h> 657#include <linux/memory_hotplug.h>
651 658
652extern struct mutex zonelists_mutex; 659extern struct mutex zonelists_mutex;
diff --git a/include/linux/nfs_page.h b/include/linux/nfs_page.h
index 3a34e80ae92f..25311b3bedf8 100644
--- a/include/linux/nfs_page.h
+++ b/include/linux/nfs_page.h
@@ -92,6 +92,9 @@ extern int nfs_pageio_add_request(struct nfs_pageio_descriptor *,
92 struct nfs_page *); 92 struct nfs_page *);
93extern void nfs_pageio_complete(struct nfs_pageio_descriptor *desc); 93extern void nfs_pageio_complete(struct nfs_pageio_descriptor *desc);
94extern void nfs_pageio_cond_complete(struct nfs_pageio_descriptor *, pgoff_t); 94extern void nfs_pageio_cond_complete(struct nfs_pageio_descriptor *, pgoff_t);
95extern bool nfs_generic_pg_test(struct nfs_pageio_descriptor *desc,
96 struct nfs_page *prev,
97 struct nfs_page *req);
95extern int nfs_wait_on_request(struct nfs_page *); 98extern int nfs_wait_on_request(struct nfs_page *);
96extern void nfs_unlock_request(struct nfs_page *req); 99extern void nfs_unlock_request(struct nfs_page *req);
97extern int nfs_set_page_tag_locked(struct nfs_page *req); 100extern int nfs_set_page_tag_locked(struct nfs_page *req);
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index 5e8444a11adf..00848d86ffb2 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -158,7 +158,6 @@ struct nfs_seqid;
158 158
159/* nfs41 sessions channel attributes */ 159/* nfs41 sessions channel attributes */
160struct nfs4_channel_attrs { 160struct nfs4_channel_attrs {
161 u32 headerpadsz;
162 u32 max_rqst_sz; 161 u32 max_rqst_sz;
163 u32 max_resp_sz; 162 u32 max_resp_sz;
164 u32 max_resp_sz_cached; 163 u32 max_resp_sz_cached;
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index a311008af5e1..f8910e155566 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -1537,6 +1537,7 @@
1537#define PCI_DEVICE_ID_RICOH_RL5C476 0x0476 1537#define PCI_DEVICE_ID_RICOH_RL5C476 0x0476
1538#define PCI_DEVICE_ID_RICOH_RL5C478 0x0478 1538#define PCI_DEVICE_ID_RICOH_RL5C478 0x0478
1539#define PCI_DEVICE_ID_RICOH_R5C822 0x0822 1539#define PCI_DEVICE_ID_RICOH_R5C822 0x0822
1540#define PCI_DEVICE_ID_RICOH_R5CE823 0xe823
1540#define PCI_DEVICE_ID_RICOH_R5C832 0x0832 1541#define PCI_DEVICE_ID_RICOH_R5C832 0x0832
1541#define PCI_DEVICE_ID_RICOH_R5C843 0x0843 1542#define PCI_DEVICE_ID_RICOH_R5C843 0x0843
1542 1543
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 3160648ccdda..411e4f4be52b 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -425,7 +425,8 @@ struct dev_pm_info {
425 pm_message_t power_state; 425 pm_message_t power_state;
426 unsigned int can_wakeup:1; 426 unsigned int can_wakeup:1;
427 unsigned int async_suspend:1; 427 unsigned int async_suspend:1;
428 unsigned int in_suspend:1; /* Owned by the PM core */ 428 bool is_prepared:1; /* Owned by the PM core */
429 bool is_suspended:1; /* Ditto */
429 spinlock_t lock; 430 spinlock_t lock;
430#ifdef CONFIG_PM_SLEEP 431#ifdef CONFIG_PM_SLEEP
431 struct list_head entry; 432 struct list_head entry;
diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
index 2b7fec840517..aa08fa8fd79b 100644
--- a/include/linux/shmem_fs.h
+++ b/include/linux/shmem_fs.h
@@ -3,6 +3,7 @@
3 3
4#include <linux/swap.h> 4#include <linux/swap.h>
5#include <linux/mempolicy.h> 5#include <linux/mempolicy.h>
6#include <linux/pagemap.h>
6#include <linux/percpu_counter.h> 7#include <linux/percpu_counter.h>
7 8
8/* inode in-kernel data */ 9/* inode in-kernel data */
@@ -45,7 +46,27 @@ static inline struct shmem_inode_info *SHMEM_I(struct inode *inode)
45 return container_of(inode, struct shmem_inode_info, vfs_inode); 46 return container_of(inode, struct shmem_inode_info, vfs_inode);
46} 47}
47 48
49/*
50 * Functions in mm/shmem.c called directly from elsewhere:
51 */
48extern int init_tmpfs(void); 52extern int init_tmpfs(void);
49extern int shmem_fill_super(struct super_block *sb, void *data, int silent); 53extern int shmem_fill_super(struct super_block *sb, void *data, int silent);
54extern struct file *shmem_file_setup(const char *name,
55 loff_t size, unsigned long flags);
56extern int shmem_zero_setup(struct vm_area_struct *);
57extern int shmem_lock(struct file *file, int lock, struct user_struct *user);
58extern struct page *shmem_read_mapping_page_gfp(struct address_space *mapping,
59 pgoff_t index, gfp_t gfp_mask);
60extern void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end);
61extern int shmem_unuse(swp_entry_t entry, struct page *page);
62extern void mem_cgroup_get_shmem_target(struct inode *inode, pgoff_t pgoff,
63 struct page **pagep, swp_entry_t *ent);
64
65static inline struct page *shmem_read_mapping_page(
66 struct address_space *mapping, pgoff_t index)
67{
68 return shmem_read_mapping_page_gfp(mapping, index,
69 mapping_gfp_mask(mapping));
70}
50 71
51#endif 72#endif
diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h
index f73c482ec9c6..fe2d8e6b923b 100644
--- a/include/linux/sunrpc/sched.h
+++ b/include/linux/sunrpc/sched.h
@@ -84,7 +84,8 @@ struct rpc_task {
84#endif 84#endif
85 unsigned char tk_priority : 2,/* Task priority */ 85 unsigned char tk_priority : 2,/* Task priority */
86 tk_garb_retry : 2, 86 tk_garb_retry : 2,
87 tk_cred_retry : 2; 87 tk_cred_retry : 2,
88 tk_rebind_retry : 2;
88}; 89};
89#define tk_xprt tk_client->cl_xprt 90#define tk_xprt tk_client->cl_xprt
90 91
diff --git a/include/linux/swap.h b/include/linux/swap.h
index e70564647039..a273468f8285 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -300,16 +300,6 @@ static inline void scan_unevictable_unregister_node(struct node *node)
300extern int kswapd_run(int nid); 300extern int kswapd_run(int nid);
301extern void kswapd_stop(int nid); 301extern void kswapd_stop(int nid);
302 302
303#ifdef CONFIG_MMU
304/* linux/mm/shmem.c */
305extern int shmem_unuse(swp_entry_t entry, struct page *page);
306#endif /* CONFIG_MMU */
307
308#ifdef CONFIG_CGROUP_MEM_RES_CTLR
309extern void mem_cgroup_get_shmem_target(struct inode *inode, pgoff_t pgoff,
310 struct page **pagep, swp_entry_t *ent);
311#endif
312
313#ifdef CONFIG_SWAP 303#ifdef CONFIG_SWAP
314/* linux/mm/page_io.c */ 304/* linux/mm/page_io.c */
315extern int swap_readpage(struct page *); 305extern int swap_readpage(struct page *);
diff --git a/include/net/sock.h b/include/net/sock.h
index f2046e404a61..c0b938cb4b1a 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -178,7 +178,6 @@ struct sock_common {
178 * @sk_dst_cache: destination cache 178 * @sk_dst_cache: destination cache
179 * @sk_dst_lock: destination cache lock 179 * @sk_dst_lock: destination cache lock
180 * @sk_policy: flow policy 180 * @sk_policy: flow policy
181 * @sk_rmem_alloc: receive queue bytes committed
182 * @sk_receive_queue: incoming packets 181 * @sk_receive_queue: incoming packets
183 * @sk_wmem_alloc: transmit queue bytes committed 182 * @sk_wmem_alloc: transmit queue bytes committed
184 * @sk_write_queue: Packet sending queue 183 * @sk_write_queue: Packet sending queue
diff --git a/include/sound/soc.h b/include/sound/soc.h
index f1de3e0c75bc..3a4bd3a3c68d 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -248,8 +248,7 @@ typedef int (*hw_write_t)(void *,const char* ,int);
248extern struct snd_ac97_bus_ops soc_ac97_ops; 248extern struct snd_ac97_bus_ops soc_ac97_ops;
249 249
250enum snd_soc_control_type { 250enum snd_soc_control_type {
251 SND_SOC_CUSTOM = 1, 251 SND_SOC_I2C = 1,
252 SND_SOC_I2C,
253 SND_SOC_SPI, 252 SND_SOC_SPI,
254}; 253};
255 254
diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h
index e09592d2f916..5ce2b2f5f524 100644
--- a/include/trace/events/ext4.h
+++ b/include/trace/events/ext4.h
@@ -26,7 +26,7 @@ TRACE_EVENT(ext4_free_inode,
26 __field( umode_t, mode ) 26 __field( umode_t, mode )
27 __field( uid_t, uid ) 27 __field( uid_t, uid )
28 __field( gid_t, gid ) 28 __field( gid_t, gid )
29 __field( blkcnt_t, blocks ) 29 __field( __u64, blocks )
30 ), 30 ),
31 31
32 TP_fast_assign( 32 TP_fast_assign(
@@ -40,9 +40,8 @@ TRACE_EVENT(ext4_free_inode,
40 40
41 TP_printk("dev %d,%d ino %lu mode 0%o uid %u gid %u blocks %llu", 41 TP_printk("dev %d,%d ino %lu mode 0%o uid %u gid %u blocks %llu",
42 MAJOR(__entry->dev), MINOR(__entry->dev), 42 MAJOR(__entry->dev), MINOR(__entry->dev),
43 (unsigned long) __entry->ino, 43 (unsigned long) __entry->ino, __entry->mode,
44 __entry->mode, __entry->uid, __entry->gid, 44 __entry->uid, __entry->gid, __entry->blocks)
45 (unsigned long long) __entry->blocks)
46); 45);
47 46
48TRACE_EVENT(ext4_request_inode, 47TRACE_EVENT(ext4_request_inode,
@@ -178,7 +177,7 @@ TRACE_EVENT(ext4_begin_ordered_truncate,
178 TP_printk("dev %d,%d ino %lu new_size %lld", 177 TP_printk("dev %d,%d ino %lu new_size %lld",
179 MAJOR(__entry->dev), MINOR(__entry->dev), 178 MAJOR(__entry->dev), MINOR(__entry->dev),
180 (unsigned long) __entry->ino, 179 (unsigned long) __entry->ino,
181 (long long) __entry->new_size) 180 __entry->new_size)
182); 181);
183 182
184DECLARE_EVENT_CLASS(ext4__write_begin, 183DECLARE_EVENT_CLASS(ext4__write_begin,
@@ -204,7 +203,7 @@ DECLARE_EVENT_CLASS(ext4__write_begin,
204 __entry->flags = flags; 203 __entry->flags = flags;
205 ), 204 ),
206 205
207 TP_printk("dev %d,%d ino %lu pos %llu len %u flags %u", 206 TP_printk("dev %d,%d ino %lu pos %lld len %u flags %u",
208 MAJOR(__entry->dev), MINOR(__entry->dev), 207 MAJOR(__entry->dev), MINOR(__entry->dev),
209 (unsigned long) __entry->ino, 208 (unsigned long) __entry->ino,
210 __entry->pos, __entry->len, __entry->flags) 209 __entry->pos, __entry->len, __entry->flags)
@@ -248,7 +247,7 @@ DECLARE_EVENT_CLASS(ext4__write_end,
248 __entry->copied = copied; 247 __entry->copied = copied;
249 ), 248 ),
250 249
251 TP_printk("dev %d,%d ino %lu pos %llu len %u copied %u", 250 TP_printk("dev %d,%d ino %lu pos %lld len %u copied %u",
252 MAJOR(__entry->dev), MINOR(__entry->dev), 251 MAJOR(__entry->dev), MINOR(__entry->dev),
253 (unsigned long) __entry->ino, 252 (unsigned long) __entry->ino,
254 __entry->pos, __entry->len, __entry->copied) 253 __entry->pos, __entry->len, __entry->copied)
@@ -286,29 +285,6 @@ DEFINE_EVENT(ext4__write_end, ext4_da_write_end,
286 TP_ARGS(inode, pos, len, copied) 285 TP_ARGS(inode, pos, len, copied)
287); 286);
288 287
289TRACE_EVENT(ext4_writepage,
290 TP_PROTO(struct inode *inode, struct page *page),
291
292 TP_ARGS(inode, page),
293
294 TP_STRUCT__entry(
295 __field( dev_t, dev )
296 __field( ino_t, ino )
297 __field( pgoff_t, index )
298
299 ),
300
301 TP_fast_assign(
302 __entry->dev = inode->i_sb->s_dev;
303 __entry->ino = inode->i_ino;
304 __entry->index = page->index;
305 ),
306
307 TP_printk("dev %d,%d ino %lu page_index %lu",
308 MAJOR(__entry->dev), MINOR(__entry->dev),
309 (unsigned long) __entry->ino, __entry->index)
310);
311
312TRACE_EVENT(ext4_da_writepages, 288TRACE_EVENT(ext4_da_writepages,
313 TP_PROTO(struct inode *inode, struct writeback_control *wbc), 289 TP_PROTO(struct inode *inode, struct writeback_control *wbc),
314 290
@@ -341,7 +317,7 @@ TRACE_EVENT(ext4_da_writepages,
341 ), 317 ),
342 318
343 TP_printk("dev %d,%d ino %lu nr_to_write %ld pages_skipped %ld " 319 TP_printk("dev %d,%d ino %lu nr_to_write %ld pages_skipped %ld "
344 "range_start %llu range_end %llu sync_mode %d" 320 "range_start %lld range_end %lld sync_mode %d"
345 "for_kupdate %d range_cyclic %d writeback_index %lu", 321 "for_kupdate %d range_cyclic %d writeback_index %lu",
346 MAJOR(__entry->dev), MINOR(__entry->dev), 322 MAJOR(__entry->dev), MINOR(__entry->dev),
347 (unsigned long) __entry->ino, __entry->nr_to_write, 323 (unsigned long) __entry->ino, __entry->nr_to_write,
@@ -449,7 +425,14 @@ DECLARE_EVENT_CLASS(ext4__page_op,
449 TP_printk("dev %d,%d ino %lu page_index %lu", 425 TP_printk("dev %d,%d ino %lu page_index %lu",
450 MAJOR(__entry->dev), MINOR(__entry->dev), 426 MAJOR(__entry->dev), MINOR(__entry->dev),
451 (unsigned long) __entry->ino, 427 (unsigned long) __entry->ino,
452 __entry->index) 428 (unsigned long) __entry->index)
429);
430
431DEFINE_EVENT(ext4__page_op, ext4_writepage,
432
433 TP_PROTO(struct page *page),
434
435 TP_ARGS(page)
453); 436);
454 437
455DEFINE_EVENT(ext4__page_op, ext4_readpage, 438DEFINE_EVENT(ext4__page_op, ext4_readpage,
@@ -489,7 +472,7 @@ TRACE_EVENT(ext4_invalidatepage,
489 TP_printk("dev %d,%d ino %lu page_index %lu offset %lu", 472 TP_printk("dev %d,%d ino %lu page_index %lu offset %lu",
490 MAJOR(__entry->dev), MINOR(__entry->dev), 473 MAJOR(__entry->dev), MINOR(__entry->dev),
491 (unsigned long) __entry->ino, 474 (unsigned long) __entry->ino,
492 __entry->index, __entry->offset) 475 (unsigned long) __entry->index, __entry->offset)
493); 476);
494 477
495TRACE_EVENT(ext4_discard_blocks, 478TRACE_EVENT(ext4_discard_blocks,
@@ -562,12 +545,10 @@ DEFINE_EVENT(ext4__mb_new_pa, ext4_mb_new_group_pa,
562); 545);
563 546
564TRACE_EVENT(ext4_mb_release_inode_pa, 547TRACE_EVENT(ext4_mb_release_inode_pa,
565 TP_PROTO(struct super_block *sb, 548 TP_PROTO(struct ext4_prealloc_space *pa,
566 struct inode *inode,
567 struct ext4_prealloc_space *pa,
568 unsigned long long block, unsigned int count), 549 unsigned long long block, unsigned int count),
569 550
570 TP_ARGS(sb, inode, pa, block, count), 551 TP_ARGS(pa, block, count),
571 552
572 TP_STRUCT__entry( 553 TP_STRUCT__entry(
573 __field( dev_t, dev ) 554 __field( dev_t, dev )
@@ -578,8 +559,8 @@ TRACE_EVENT(ext4_mb_release_inode_pa,
578 ), 559 ),
579 560
580 TP_fast_assign( 561 TP_fast_assign(
581 __entry->dev = sb->s_dev; 562 __entry->dev = pa->pa_inode->i_sb->s_dev;
582 __entry->ino = inode->i_ino; 563 __entry->ino = pa->pa_inode->i_ino;
583 __entry->block = block; 564 __entry->block = block;
584 __entry->count = count; 565 __entry->count = count;
585 ), 566 ),
@@ -591,10 +572,9 @@ TRACE_EVENT(ext4_mb_release_inode_pa,
591); 572);
592 573
593TRACE_EVENT(ext4_mb_release_group_pa, 574TRACE_EVENT(ext4_mb_release_group_pa,
594 TP_PROTO(struct super_block *sb, 575 TP_PROTO(struct ext4_prealloc_space *pa),
595 struct ext4_prealloc_space *pa),
596 576
597 TP_ARGS(sb, pa), 577 TP_ARGS(pa),
598 578
599 TP_STRUCT__entry( 579 TP_STRUCT__entry(
600 __field( dev_t, dev ) 580 __field( dev_t, dev )
@@ -604,7 +584,7 @@ TRACE_EVENT(ext4_mb_release_group_pa,
604 ), 584 ),
605 585
606 TP_fast_assign( 586 TP_fast_assign(
607 __entry->dev = sb->s_dev; 587 __entry->dev = pa->pa_inode->i_sb->s_dev;
608 __entry->pa_pstart = pa->pa_pstart; 588 __entry->pa_pstart = pa->pa_pstart;
609 __entry->pa_len = pa->pa_len; 589 __entry->pa_len = pa->pa_len;
610 ), 590 ),
@@ -666,10 +646,10 @@ TRACE_EVENT(ext4_request_blocks,
666 __field( ino_t, ino ) 646 __field( ino_t, ino )
667 __field( unsigned int, flags ) 647 __field( unsigned int, flags )
668 __field( unsigned int, len ) 648 __field( unsigned int, len )
669 __field( __u64, logical ) 649 __field( __u32, logical )
650 __field( __u32, lleft )
651 __field( __u32, lright )
670 __field( __u64, goal ) 652 __field( __u64, goal )
671 __field( __u64, lleft )
672 __field( __u64, lright )
673 __field( __u64, pleft ) 653 __field( __u64, pleft )
674 __field( __u64, pright ) 654 __field( __u64, pright )
675 ), 655 ),
@@ -687,17 +667,13 @@ TRACE_EVENT(ext4_request_blocks,
687 __entry->pright = ar->pright; 667 __entry->pright = ar->pright;
688 ), 668 ),
689 669
690 TP_printk("dev %d,%d ino %lu flags %u len %u lblk %llu goal %llu " 670 TP_printk("dev %d,%d ino %lu flags %u len %u lblk %u goal %llu "
691 "lleft %llu lright %llu pleft %llu pright %llu ", 671 "lleft %u lright %u pleft %llu pright %llu ",
692 MAJOR(__entry->dev), MINOR(__entry->dev), 672 MAJOR(__entry->dev), MINOR(__entry->dev),
693 (unsigned long) __entry->ino, 673 (unsigned long) __entry->ino, __entry->flags,
694 __entry->flags, __entry->len, 674 __entry->len, __entry->logical, __entry->goal,
695 (unsigned long long) __entry->logical, 675 __entry->lleft, __entry->lright, __entry->pleft,
696 (unsigned long long) __entry->goal, 676 __entry->pright)
697 (unsigned long long) __entry->lleft,
698 (unsigned long long) __entry->lright,
699 (unsigned long long) __entry->pleft,
700 (unsigned long long) __entry->pright)
701); 677);
702 678
703TRACE_EVENT(ext4_allocate_blocks, 679TRACE_EVENT(ext4_allocate_blocks,
@@ -711,10 +687,10 @@ TRACE_EVENT(ext4_allocate_blocks,
711 __field( __u64, block ) 687 __field( __u64, block )
712 __field( unsigned int, flags ) 688 __field( unsigned int, flags )
713 __field( unsigned int, len ) 689 __field( unsigned int, len )
714 __field( __u64, logical ) 690 __field( __u32, logical )
691 __field( __u32, lleft )
692 __field( __u32, lright )
715 __field( __u64, goal ) 693 __field( __u64, goal )
716 __field( __u64, lleft )
717 __field( __u64, lright )
718 __field( __u64, pleft ) 694 __field( __u64, pleft )
719 __field( __u64, pright ) 695 __field( __u64, pright )
720 ), 696 ),
@@ -733,17 +709,13 @@ TRACE_EVENT(ext4_allocate_blocks,
733 __entry->pright = ar->pright; 709 __entry->pright = ar->pright;
734 ), 710 ),
735 711
736 TP_printk("dev %d,%d ino %lu flags %u len %u block %llu lblk %llu " 712 TP_printk("dev %d,%d ino %lu flags %u len %u block %llu lblk %u "
737 "goal %llu lleft %llu lright %llu pleft %llu pright %llu", 713 "goal %llu lleft %u lright %u pleft %llu pright %llu",
738 MAJOR(__entry->dev), MINOR(__entry->dev), 714 MAJOR(__entry->dev), MINOR(__entry->dev),
739 (unsigned long) __entry->ino, 715 (unsigned long) __entry->ino, __entry->flags,
740 __entry->flags, __entry->len, __entry->block, 716 __entry->len, __entry->block, __entry->logical,
741 (unsigned long long) __entry->logical, 717 __entry->goal, __entry->lleft, __entry->lright,
742 (unsigned long long) __entry->goal, 718 __entry->pleft, __entry->pright)
743 (unsigned long long) __entry->lleft,
744 (unsigned long long) __entry->lright,
745 (unsigned long long) __entry->pleft,
746 (unsigned long long) __entry->pright)
747); 719);
748 720
749TRACE_EVENT(ext4_free_blocks, 721TRACE_EVENT(ext4_free_blocks,
@@ -755,10 +727,10 @@ TRACE_EVENT(ext4_free_blocks,
755 TP_STRUCT__entry( 727 TP_STRUCT__entry(
756 __field( dev_t, dev ) 728 __field( dev_t, dev )
757 __field( ino_t, ino ) 729 __field( ino_t, ino )
758 __field( umode_t, mode ) 730 __field( umode_t, mode )
759 __field( __u64, block ) 731 __field( __u64, block )
760 __field( unsigned long, count ) 732 __field( unsigned long, count )
761 __field( int, flags ) 733 __field( int, flags )
762 ), 734 ),
763 735
764 TP_fast_assign( 736 TP_fast_assign(
@@ -798,7 +770,7 @@ TRACE_EVENT(ext4_sync_file_enter,
798 __entry->parent = dentry->d_parent->d_inode->i_ino; 770 __entry->parent = dentry->d_parent->d_inode->i_ino;
799 ), 771 ),
800 772
801 TP_printk("dev %d,%d ino %ld parent %ld datasync %d ", 773 TP_printk("dev %d,%d ino %lu parent %lu datasync %d ",
802 MAJOR(__entry->dev), MINOR(__entry->dev), 774 MAJOR(__entry->dev), MINOR(__entry->dev),
803 (unsigned long) __entry->ino, 775 (unsigned long) __entry->ino,
804 (unsigned long) __entry->parent, __entry->datasync) 776 (unsigned long) __entry->parent, __entry->datasync)
@@ -821,7 +793,7 @@ TRACE_EVENT(ext4_sync_file_exit,
821 __entry->dev = inode->i_sb->s_dev; 793 __entry->dev = inode->i_sb->s_dev;
822 ), 794 ),
823 795
824 TP_printk("dev %d,%d ino %ld ret %d", 796 TP_printk("dev %d,%d ino %lu ret %d",
825 MAJOR(__entry->dev), MINOR(__entry->dev), 797 MAJOR(__entry->dev), MINOR(__entry->dev),
826 (unsigned long) __entry->ino, 798 (unsigned long) __entry->ino,
827 __entry->ret) 799 __entry->ret)
@@ -1005,7 +977,7 @@ DECLARE_EVENT_CLASS(ext4__mballoc,
1005 __entry->result_len = len; 977 __entry->result_len = len;
1006 ), 978 ),
1007 979
1008 TP_printk("dev %d,%d inode %lu extent %u/%d/%u ", 980 TP_printk("dev %d,%d inode %lu extent %u/%d/%d ",
1009 MAJOR(__entry->dev), MINOR(__entry->dev), 981 MAJOR(__entry->dev), MINOR(__entry->dev),
1010 (unsigned long) __entry->ino, 982 (unsigned long) __entry->ino,
1011 __entry->result_group, __entry->result_start, 983 __entry->result_group, __entry->result_start,
@@ -1093,7 +1065,7 @@ TRACE_EVENT(ext4_da_update_reserve_space,
1093 "allocated_meta_blocks %d", 1065 "allocated_meta_blocks %d",
1094 MAJOR(__entry->dev), MINOR(__entry->dev), 1066 MAJOR(__entry->dev), MINOR(__entry->dev),
1095 (unsigned long) __entry->ino, 1067 (unsigned long) __entry->ino,
1096 __entry->mode, (unsigned long long) __entry->i_blocks, 1068 __entry->mode, __entry->i_blocks,
1097 __entry->used_blocks, __entry->reserved_data_blocks, 1069 __entry->used_blocks, __entry->reserved_data_blocks,
1098 __entry->reserved_meta_blocks, __entry->allocated_meta_blocks) 1070 __entry->reserved_meta_blocks, __entry->allocated_meta_blocks)
1099); 1071);
@@ -1127,7 +1099,7 @@ TRACE_EVENT(ext4_da_reserve_space,
1127 "reserved_data_blocks %d reserved_meta_blocks %d", 1099 "reserved_data_blocks %d reserved_meta_blocks %d",
1128 MAJOR(__entry->dev), MINOR(__entry->dev), 1100 MAJOR(__entry->dev), MINOR(__entry->dev),
1129 (unsigned long) __entry->ino, 1101 (unsigned long) __entry->ino,
1130 __entry->mode, (unsigned long long) __entry->i_blocks, 1102 __entry->mode, __entry->i_blocks,
1131 __entry->md_needed, __entry->reserved_data_blocks, 1103 __entry->md_needed, __entry->reserved_data_blocks,
1132 __entry->reserved_meta_blocks) 1104 __entry->reserved_meta_blocks)
1133); 1105);
@@ -1164,7 +1136,7 @@ TRACE_EVENT(ext4_da_release_space,
1164 "allocated_meta_blocks %d", 1136 "allocated_meta_blocks %d",
1165 MAJOR(__entry->dev), MINOR(__entry->dev), 1137 MAJOR(__entry->dev), MINOR(__entry->dev),
1166 (unsigned long) __entry->ino, 1138 (unsigned long) __entry->ino,
1167 __entry->mode, (unsigned long long) __entry->i_blocks, 1139 __entry->mode, __entry->i_blocks,
1168 __entry->freed_blocks, __entry->reserved_data_blocks, 1140 __entry->freed_blocks, __entry->reserved_data_blocks,
1169 __entry->reserved_meta_blocks, __entry->allocated_meta_blocks) 1141 __entry->reserved_meta_blocks, __entry->allocated_meta_blocks)
1170); 1142);
@@ -1239,14 +1211,15 @@ TRACE_EVENT(ext4_direct_IO_enter,
1239 __entry->rw = rw; 1211 __entry->rw = rw;
1240 ), 1212 ),
1241 1213
1242 TP_printk("dev %d,%d ino %lu pos %llu len %lu rw %d", 1214 TP_printk("dev %d,%d ino %lu pos %lld len %lu rw %d",
1243 MAJOR(__entry->dev), MINOR(__entry->dev), 1215 MAJOR(__entry->dev), MINOR(__entry->dev),
1244 (unsigned long) __entry->ino, 1216 (unsigned long) __entry->ino,
1245 (unsigned long long) __entry->pos, __entry->len, __entry->rw) 1217 __entry->pos, __entry->len, __entry->rw)
1246); 1218);
1247 1219
1248TRACE_EVENT(ext4_direct_IO_exit, 1220TRACE_EVENT(ext4_direct_IO_exit,
1249 TP_PROTO(struct inode *inode, loff_t offset, unsigned long len, int rw, int ret), 1221 TP_PROTO(struct inode *inode, loff_t offset, unsigned long len,
1222 int rw, int ret),
1250 1223
1251 TP_ARGS(inode, offset, len, rw, ret), 1224 TP_ARGS(inode, offset, len, rw, ret),
1252 1225
@@ -1268,10 +1241,10 @@ TRACE_EVENT(ext4_direct_IO_exit,
1268 __entry->ret = ret; 1241 __entry->ret = ret;
1269 ), 1242 ),
1270 1243
1271 TP_printk("dev %d,%d ino %lu pos %llu len %lu rw %d ret %d", 1244 TP_printk("dev %d,%d ino %lu pos %lld len %lu rw %d ret %d",
1272 MAJOR(__entry->dev), MINOR(__entry->dev), 1245 MAJOR(__entry->dev), MINOR(__entry->dev),
1273 (unsigned long) __entry->ino, 1246 (unsigned long) __entry->ino,
1274 (unsigned long long) __entry->pos, __entry->len, 1247 __entry->pos, __entry->len,
1275 __entry->rw, __entry->ret) 1248 __entry->rw, __entry->ret)
1276); 1249);
1277 1250
@@ -1296,15 +1269,15 @@ TRACE_EVENT(ext4_fallocate_enter,
1296 __entry->mode = mode; 1269 __entry->mode = mode;
1297 ), 1270 ),
1298 1271
1299 TP_printk("dev %d,%d ino %ld pos %llu len %llu mode %d", 1272 TP_printk("dev %d,%d ino %lu pos %lld len %lld mode %d",
1300 MAJOR(__entry->dev), MINOR(__entry->dev), 1273 MAJOR(__entry->dev), MINOR(__entry->dev),
1301 (unsigned long) __entry->ino, 1274 (unsigned long) __entry->ino, __entry->pos,
1302 (unsigned long long) __entry->pos, 1275 __entry->len, __entry->mode)
1303 (unsigned long long) __entry->len, __entry->mode)
1304); 1276);
1305 1277
1306TRACE_EVENT(ext4_fallocate_exit, 1278TRACE_EVENT(ext4_fallocate_exit,
1307 TP_PROTO(struct inode *inode, loff_t offset, unsigned int max_blocks, int ret), 1279 TP_PROTO(struct inode *inode, loff_t offset,
1280 unsigned int max_blocks, int ret),
1308 1281
1309 TP_ARGS(inode, offset, max_blocks, ret), 1282 TP_ARGS(inode, offset, max_blocks, ret),
1310 1283
@@ -1312,7 +1285,7 @@ TRACE_EVENT(ext4_fallocate_exit,
1312 __field( ino_t, ino ) 1285 __field( ino_t, ino )
1313 __field( dev_t, dev ) 1286 __field( dev_t, dev )
1314 __field( loff_t, pos ) 1287 __field( loff_t, pos )
1315 __field( unsigned, blocks ) 1288 __field( unsigned int, blocks )
1316 __field( int, ret ) 1289 __field( int, ret )
1317 ), 1290 ),
1318 1291
@@ -1324,10 +1297,10 @@ TRACE_EVENT(ext4_fallocate_exit,
1324 __entry->ret = ret; 1297 __entry->ret = ret;
1325 ), 1298 ),
1326 1299
1327 TP_printk("dev %d,%d ino %ld pos %llu blocks %d ret %d", 1300 TP_printk("dev %d,%d ino %lu pos %lld blocks %u ret %d",
1328 MAJOR(__entry->dev), MINOR(__entry->dev), 1301 MAJOR(__entry->dev), MINOR(__entry->dev),
1329 (unsigned long) __entry->ino, 1302 (unsigned long) __entry->ino,
1330 (unsigned long long) __entry->pos, __entry->blocks, 1303 __entry->pos, __entry->blocks,
1331 __entry->ret) 1304 __entry->ret)
1332); 1305);
1333 1306
@@ -1350,7 +1323,7 @@ TRACE_EVENT(ext4_unlink_enter,
1350 __entry->dev = dentry->d_inode->i_sb->s_dev; 1323 __entry->dev = dentry->d_inode->i_sb->s_dev;
1351 ), 1324 ),
1352 1325
1353 TP_printk("dev %d,%d ino %ld size %lld parent %ld", 1326 TP_printk("dev %d,%d ino %lu size %lld parent %lu",
1354 MAJOR(__entry->dev), MINOR(__entry->dev), 1327 MAJOR(__entry->dev), MINOR(__entry->dev),
1355 (unsigned long) __entry->ino, __entry->size, 1328 (unsigned long) __entry->ino, __entry->size,
1356 (unsigned long) __entry->parent) 1329 (unsigned long) __entry->parent)
@@ -1373,7 +1346,7 @@ TRACE_EVENT(ext4_unlink_exit,
1373 __entry->ret = ret; 1346 __entry->ret = ret;
1374 ), 1347 ),
1375 1348
1376 TP_printk("dev %d,%d ino %ld ret %d", 1349 TP_printk("dev %d,%d ino %lu ret %d",
1377 MAJOR(__entry->dev), MINOR(__entry->dev), 1350 MAJOR(__entry->dev), MINOR(__entry->dev),
1378 (unsigned long) __entry->ino, 1351 (unsigned long) __entry->ino,
1379 __entry->ret) 1352 __entry->ret)
@@ -1387,7 +1360,7 @@ DECLARE_EVENT_CLASS(ext4__truncate,
1387 TP_STRUCT__entry( 1360 TP_STRUCT__entry(
1388 __field( ino_t, ino ) 1361 __field( ino_t, ino )
1389 __field( dev_t, dev ) 1362 __field( dev_t, dev )
1390 __field( blkcnt_t, blocks ) 1363 __field( __u64, blocks )
1391 ), 1364 ),
1392 1365
1393 TP_fast_assign( 1366 TP_fast_assign(
@@ -1396,9 +1369,9 @@ DECLARE_EVENT_CLASS(ext4__truncate,
1396 __entry->blocks = inode->i_blocks; 1369 __entry->blocks = inode->i_blocks;
1397 ), 1370 ),
1398 1371
1399 TP_printk("dev %d,%d ino %lu blocks %lu", 1372 TP_printk("dev %d,%d ino %lu blocks %llu",
1400 MAJOR(__entry->dev), MINOR(__entry->dev), 1373 MAJOR(__entry->dev), MINOR(__entry->dev),
1401 (unsigned long) __entry->ino, (unsigned long) __entry->blocks) 1374 (unsigned long) __entry->ino, __entry->blocks)
1402); 1375);
1403 1376
1404DEFINE_EVENT(ext4__truncate, ext4_truncate_enter, 1377DEFINE_EVENT(ext4__truncate, ext4_truncate_enter,
@@ -1417,7 +1390,7 @@ DEFINE_EVENT(ext4__truncate, ext4_truncate_exit,
1417 1390
1418DECLARE_EVENT_CLASS(ext4__map_blocks_enter, 1391DECLARE_EVENT_CLASS(ext4__map_blocks_enter,
1419 TP_PROTO(struct inode *inode, ext4_lblk_t lblk, 1392 TP_PROTO(struct inode *inode, ext4_lblk_t lblk,
1420 unsigned len, unsigned flags), 1393 unsigned int len, unsigned int flags),
1421 1394
1422 TP_ARGS(inode, lblk, len, flags), 1395 TP_ARGS(inode, lblk, len, flags),
1423 1396
@@ -1425,8 +1398,8 @@ DECLARE_EVENT_CLASS(ext4__map_blocks_enter,
1425 __field( ino_t, ino ) 1398 __field( ino_t, ino )
1426 __field( dev_t, dev ) 1399 __field( dev_t, dev )
1427 __field( ext4_lblk_t, lblk ) 1400 __field( ext4_lblk_t, lblk )
1428 __field( unsigned, len ) 1401 __field( unsigned int, len )
1429 __field( unsigned, flags ) 1402 __field( unsigned int, flags )
1430 ), 1403 ),
1431 1404
1432 TP_fast_assign( 1405 TP_fast_assign(
@@ -1440,7 +1413,7 @@ DECLARE_EVENT_CLASS(ext4__map_blocks_enter,
1440 TP_printk("dev %d,%d ino %lu lblk %u len %u flags %u", 1413 TP_printk("dev %d,%d ino %lu lblk %u len %u flags %u",
1441 MAJOR(__entry->dev), MINOR(__entry->dev), 1414 MAJOR(__entry->dev), MINOR(__entry->dev),
1442 (unsigned long) __entry->ino, 1415 (unsigned long) __entry->ino,
1443 (unsigned) __entry->lblk, __entry->len, __entry->flags) 1416 __entry->lblk, __entry->len, __entry->flags)
1444); 1417);
1445 1418
1446DEFINE_EVENT(ext4__map_blocks_enter, ext4_ext_map_blocks_enter, 1419DEFINE_EVENT(ext4__map_blocks_enter, ext4_ext_map_blocks_enter,
@@ -1459,7 +1432,7 @@ DEFINE_EVENT(ext4__map_blocks_enter, ext4_ind_map_blocks_enter,
1459 1432
1460DECLARE_EVENT_CLASS(ext4__map_blocks_exit, 1433DECLARE_EVENT_CLASS(ext4__map_blocks_exit,
1461 TP_PROTO(struct inode *inode, ext4_lblk_t lblk, 1434 TP_PROTO(struct inode *inode, ext4_lblk_t lblk,
1462 ext4_fsblk_t pblk, unsigned len, int ret), 1435 ext4_fsblk_t pblk, unsigned int len, int ret),
1463 1436
1464 TP_ARGS(inode, lblk, pblk, len, ret), 1437 TP_ARGS(inode, lblk, pblk, len, ret),
1465 1438
@@ -1468,7 +1441,7 @@ DECLARE_EVENT_CLASS(ext4__map_blocks_exit,
1468 __field( dev_t, dev ) 1441 __field( dev_t, dev )
1469 __field( ext4_lblk_t, lblk ) 1442 __field( ext4_lblk_t, lblk )
1470 __field( ext4_fsblk_t, pblk ) 1443 __field( ext4_fsblk_t, pblk )
1471 __field( unsigned, len ) 1444 __field( unsigned int, len )
1472 __field( int, ret ) 1445 __field( int, ret )
1473 ), 1446 ),
1474 1447
@@ -1484,7 +1457,7 @@ DECLARE_EVENT_CLASS(ext4__map_blocks_exit,
1484 TP_printk("dev %d,%d ino %lu lblk %u pblk %llu len %u ret %d", 1457 TP_printk("dev %d,%d ino %lu lblk %u pblk %llu len %u ret %d",
1485 MAJOR(__entry->dev), MINOR(__entry->dev), 1458 MAJOR(__entry->dev), MINOR(__entry->dev),
1486 (unsigned long) __entry->ino, 1459 (unsigned long) __entry->ino,
1487 (unsigned) __entry->lblk, (unsigned long long) __entry->pblk, 1460 __entry->lblk, __entry->pblk,
1488 __entry->len, __entry->ret) 1461 __entry->len, __entry->ret)
1489); 1462);
1490 1463
@@ -1524,7 +1497,7 @@ TRACE_EVENT(ext4_ext_load_extent,
1524 TP_printk("dev %d,%d ino %lu lblk %u pblk %llu", 1497 TP_printk("dev %d,%d ino %lu lblk %u pblk %llu",
1525 MAJOR(__entry->dev), MINOR(__entry->dev), 1498 MAJOR(__entry->dev), MINOR(__entry->dev),
1526 (unsigned long) __entry->ino, 1499 (unsigned long) __entry->ino,
1527 (unsigned) __entry->lblk, (unsigned long long) __entry->pblk) 1500 __entry->lblk, __entry->pblk)
1528); 1501);
1529 1502
1530TRACE_EVENT(ext4_load_inode, 1503TRACE_EVENT(ext4_load_inode,
diff --git a/init/calibrate.c b/init/calibrate.c
index 2568d22a304e..aae2f40fea4c 100644
--- a/init/calibrate.c
+++ b/init/calibrate.c
@@ -245,30 +245,32 @@ recalibrate:
245 245
246void __cpuinit calibrate_delay(void) 246void __cpuinit calibrate_delay(void)
247{ 247{
248 unsigned long lpj;
248 static bool printed; 249 static bool printed;
249 250
250 if (preset_lpj) { 251 if (preset_lpj) {
251 loops_per_jiffy = preset_lpj; 252 lpj = preset_lpj;
252 if (!printed) 253 if (!printed)
253 pr_info("Calibrating delay loop (skipped) " 254 pr_info("Calibrating delay loop (skipped) "
254 "preset value.. "); 255 "preset value.. ");
255 } else if ((!printed) && lpj_fine) { 256 } else if ((!printed) && lpj_fine) {
256 loops_per_jiffy = lpj_fine; 257 lpj = lpj_fine;
257 pr_info("Calibrating delay loop (skipped), " 258 pr_info("Calibrating delay loop (skipped), "
258 "value calculated using timer frequency.. "); 259 "value calculated using timer frequency.. ");
259 } else if ((loops_per_jiffy = calibrate_delay_direct()) != 0) { 260 } else if ((lpj = calibrate_delay_direct()) != 0) {
260 if (!printed) 261 if (!printed)
261 pr_info("Calibrating delay using timer " 262 pr_info("Calibrating delay using timer "
262 "specific routine.. "); 263 "specific routine.. ");
263 } else { 264 } else {
264 if (!printed) 265 if (!printed)
265 pr_info("Calibrating delay loop... "); 266 pr_info("Calibrating delay loop... ");
266 loops_per_jiffy = calibrate_delay_converge(); 267 lpj = calibrate_delay_converge();
267 } 268 }
268 if (!printed) 269 if (!printed)
269 pr_cont("%lu.%02lu BogoMIPS (lpj=%lu)\n", 270 pr_cont("%lu.%02lu BogoMIPS (lpj=%lu)\n",
270 loops_per_jiffy/(500000/HZ), 271 lpj/(500000/HZ),
271 (loops_per_jiffy/(5000/HZ)) % 100, loops_per_jiffy); 272 (lpj/(5000/HZ)) % 100, lpj);
272 273
274 loops_per_jiffy = lpj;
273 printed = true; 275 printed = true;
274} 276}
diff --git a/kernel/power/user.c b/kernel/power/user.c
index 7d02d33be699..42ddbc6f0de6 100644
--- a/kernel/power/user.c
+++ b/kernel/power/user.c
@@ -113,8 +113,10 @@ static int snapshot_open(struct inode *inode, struct file *filp)
113 if (error) 113 if (error)
114 pm_notifier_call_chain(PM_POST_RESTORE); 114 pm_notifier_call_chain(PM_POST_RESTORE);
115 } 115 }
116 if (error) 116 if (error) {
117 free_basic_memory_bitmaps();
117 atomic_inc(&snapshot_device_available); 118 atomic_inc(&snapshot_device_available);
119 }
118 data->frozen = 0; 120 data->frozen = 0;
119 data->ready = 0; 121 data->ready = 0;
120 data->platform_support = 0; 122 data->platform_support = 0;
diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index 9ffea360a778..fc0f22005417 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -285,16 +285,18 @@ ret:
285static int add_del_listener(pid_t pid, const struct cpumask *mask, int isadd) 285static int add_del_listener(pid_t pid, const struct cpumask *mask, int isadd)
286{ 286{
287 struct listener_list *listeners; 287 struct listener_list *listeners;
288 struct listener *s, *tmp; 288 struct listener *s, *tmp, *s2;
289 unsigned int cpu; 289 unsigned int cpu;
290 290
291 if (!cpumask_subset(mask, cpu_possible_mask)) 291 if (!cpumask_subset(mask, cpu_possible_mask))
292 return -EINVAL; 292 return -EINVAL;
293 293
294 s = NULL;
294 if (isadd == REGISTER) { 295 if (isadd == REGISTER) {
295 for_each_cpu(cpu, mask) { 296 for_each_cpu(cpu, mask) {
296 s = kmalloc_node(sizeof(struct listener), GFP_KERNEL, 297 if (!s)
297 cpu_to_node(cpu)); 298 s = kmalloc_node(sizeof(struct listener),
299 GFP_KERNEL, cpu_to_node(cpu));
298 if (!s) 300 if (!s)
299 goto cleanup; 301 goto cleanup;
300 s->pid = pid; 302 s->pid = pid;
@@ -303,9 +305,16 @@ static int add_del_listener(pid_t pid, const struct cpumask *mask, int isadd)
303 305
304 listeners = &per_cpu(listener_array, cpu); 306 listeners = &per_cpu(listener_array, cpu);
305 down_write(&listeners->sem); 307 down_write(&listeners->sem);
308 list_for_each_entry_safe(s2, tmp, &listeners->list, list) {
309 if (s2->pid == pid)
310 goto next_cpu;
311 }
306 list_add(&s->list, &listeners->list); 312 list_add(&s->list, &listeners->list);
313 s = NULL;
314next_cpu:
307 up_write(&listeners->sem); 315 up_write(&listeners->sem);
308 } 316 }
317 kfree(s);
309 return 0; 318 return 0;
310 } 319 }
311 320
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 2d966244ea60..59f369f98a04 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -42,15 +42,75 @@ static struct alarm_base {
42 clockid_t base_clockid; 42 clockid_t base_clockid;
43} alarm_bases[ALARM_NUMTYPE]; 43} alarm_bases[ALARM_NUMTYPE];
44 44
45/* freezer delta & lock used to handle clock_nanosleep triggered wakeups */
46static ktime_t freezer_delta;
47static DEFINE_SPINLOCK(freezer_delta_lock);
48
45#ifdef CONFIG_RTC_CLASS 49#ifdef CONFIG_RTC_CLASS
46/* rtc timer and device for setting alarm wakeups at suspend */ 50/* rtc timer and device for setting alarm wakeups at suspend */
47static struct rtc_timer rtctimer; 51static struct rtc_timer rtctimer;
48static struct rtc_device *rtcdev; 52static struct rtc_device *rtcdev;
49#endif 53static DEFINE_SPINLOCK(rtcdev_lock);
50 54
51/* freezer delta & lock used to handle clock_nanosleep triggered wakeups */ 55/**
52static ktime_t freezer_delta; 56 * has_wakealarm - check rtc device has wakealarm ability
53static DEFINE_SPINLOCK(freezer_delta_lock); 57 * @dev: current device
58 * @name_ptr: name to be returned
59 *
60 * This helper function checks to see if the rtc device can wake
61 * from suspend.
62 */
63static int has_wakealarm(struct device *dev, void *name_ptr)
64{
65 struct rtc_device *candidate = to_rtc_device(dev);
66
67 if (!candidate->ops->set_alarm)
68 return 0;
69 if (!device_may_wakeup(candidate->dev.parent))
70 return 0;
71
72 *(const char **)name_ptr = dev_name(dev);
73 return 1;
74}
75
76/**
77 * alarmtimer_get_rtcdev - Return selected rtcdevice
78 *
79 * This function returns the rtc device to use for wakealarms.
80 * If one has not already been chosen, it checks to see if a
81 * functional rtc device is available.
82 */
83static struct rtc_device *alarmtimer_get_rtcdev(void)
84{
85 struct device *dev;
86 char *str;
87 unsigned long flags;
88 struct rtc_device *ret;
89
90 spin_lock_irqsave(&rtcdev_lock, flags);
91 if (!rtcdev) {
92 /* Find an rtc device and init the rtc_timer */
93 dev = class_find_device(rtc_class, NULL, &str, has_wakealarm);
94 /* If we have a device then str is valid. See has_wakealarm() */
95 if (dev) {
96 rtcdev = rtc_class_open(str);
97 /*
98 * Drop the reference we got in class_find_device,
99 * rtc_open takes its own.
100 */
101 put_device(dev);
102 rtc_timer_init(&rtctimer, NULL, NULL);
103 }
104 }
105 ret = rtcdev;
106 spin_unlock_irqrestore(&rtcdev_lock, flags);
107
108 return ret;
109}
110#else
111#define alarmtimer_get_rtcdev() (0)
112#define rtcdev (0)
113#endif
54 114
55 115
56/** 116/**
@@ -166,6 +226,7 @@ static int alarmtimer_suspend(struct device *dev)
166 struct rtc_time tm; 226 struct rtc_time tm;
167 ktime_t min, now; 227 ktime_t min, now;
168 unsigned long flags; 228 unsigned long flags;
229 struct rtc_device *rtc;
169 int i; 230 int i;
170 231
171 spin_lock_irqsave(&freezer_delta_lock, flags); 232 spin_lock_irqsave(&freezer_delta_lock, flags);
@@ -173,8 +234,9 @@ static int alarmtimer_suspend(struct device *dev)
173 freezer_delta = ktime_set(0, 0); 234 freezer_delta = ktime_set(0, 0);
174 spin_unlock_irqrestore(&freezer_delta_lock, flags); 235 spin_unlock_irqrestore(&freezer_delta_lock, flags);
175 236
237 rtc = rtcdev;
176 /* If we have no rtcdev, just return */ 238 /* If we have no rtcdev, just return */
177 if (!rtcdev) 239 if (!rtc)
178 return 0; 240 return 0;
179 241
180 /* Find the soonest timer to expire*/ 242 /* Find the soonest timer to expire*/
@@ -199,12 +261,12 @@ static int alarmtimer_suspend(struct device *dev)
199 WARN_ON(min.tv64 < NSEC_PER_SEC); 261 WARN_ON(min.tv64 < NSEC_PER_SEC);
200 262
201 /* Setup an rtc timer to fire that far in the future */ 263 /* Setup an rtc timer to fire that far in the future */
202 rtc_timer_cancel(rtcdev, &rtctimer); 264 rtc_timer_cancel(rtc, &rtctimer);
203 rtc_read_time(rtcdev, &tm); 265 rtc_read_time(rtc, &tm);
204 now = rtc_tm_to_ktime(tm); 266 now = rtc_tm_to_ktime(tm);
205 now = ktime_add(now, min); 267 now = ktime_add(now, min);
206 268
207 rtc_timer_start(rtcdev, &rtctimer, now, ktime_set(0, 0)); 269 rtc_timer_start(rtc, &rtctimer, now, ktime_set(0, 0));
208 270
209 return 0; 271 return 0;
210} 272}
@@ -322,6 +384,9 @@ static int alarm_clock_getres(const clockid_t which_clock, struct timespec *tp)
322{ 384{
323 clockid_t baseid = alarm_bases[clock2alarm(which_clock)].base_clockid; 385 clockid_t baseid = alarm_bases[clock2alarm(which_clock)].base_clockid;
324 386
387 if (!alarmtimer_get_rtcdev())
388 return -ENOTSUPP;
389
325 return hrtimer_get_res(baseid, tp); 390 return hrtimer_get_res(baseid, tp);
326} 391}
327 392
@@ -336,6 +401,9 @@ static int alarm_clock_get(clockid_t which_clock, struct timespec *tp)
336{ 401{
337 struct alarm_base *base = &alarm_bases[clock2alarm(which_clock)]; 402 struct alarm_base *base = &alarm_bases[clock2alarm(which_clock)];
338 403
404 if (!alarmtimer_get_rtcdev())
405 return -ENOTSUPP;
406
339 *tp = ktime_to_timespec(base->gettime()); 407 *tp = ktime_to_timespec(base->gettime());
340 return 0; 408 return 0;
341} 409}
@@ -351,6 +419,9 @@ static int alarm_timer_create(struct k_itimer *new_timer)
351 enum alarmtimer_type type; 419 enum alarmtimer_type type;
352 struct alarm_base *base; 420 struct alarm_base *base;
353 421
422 if (!alarmtimer_get_rtcdev())
423 return -ENOTSUPP;
424
354 if (!capable(CAP_WAKE_ALARM)) 425 if (!capable(CAP_WAKE_ALARM))
355 return -EPERM; 426 return -EPERM;
356 427
@@ -385,6 +456,9 @@ static void alarm_timer_get(struct k_itimer *timr,
385 */ 456 */
386static int alarm_timer_del(struct k_itimer *timr) 457static int alarm_timer_del(struct k_itimer *timr)
387{ 458{
459 if (!rtcdev)
460 return -ENOTSUPP;
461
388 alarm_cancel(&timr->it.alarmtimer); 462 alarm_cancel(&timr->it.alarmtimer);
389 return 0; 463 return 0;
390} 464}
@@ -402,6 +476,9 @@ static int alarm_timer_set(struct k_itimer *timr, int flags,
402 struct itimerspec *new_setting, 476 struct itimerspec *new_setting,
403 struct itimerspec *old_setting) 477 struct itimerspec *old_setting)
404{ 478{
479 if (!rtcdev)
480 return -ENOTSUPP;
481
405 /* Save old values */ 482 /* Save old values */
406 old_setting->it_interval = 483 old_setting->it_interval =
407 ktime_to_timespec(timr->it.alarmtimer.period); 484 ktime_to_timespec(timr->it.alarmtimer.period);
@@ -541,6 +618,9 @@ static int alarm_timer_nsleep(const clockid_t which_clock, int flags,
541 int ret = 0; 618 int ret = 0;
542 struct restart_block *restart; 619 struct restart_block *restart;
543 620
621 if (!alarmtimer_get_rtcdev())
622 return -ENOTSUPP;
623
544 if (!capable(CAP_WAKE_ALARM)) 624 if (!capable(CAP_WAKE_ALARM))
545 return -EPERM; 625 return -EPERM;
546 626
@@ -638,65 +718,3 @@ static int __init alarmtimer_init(void)
638} 718}
639device_initcall(alarmtimer_init); 719device_initcall(alarmtimer_init);
640 720
641#ifdef CONFIG_RTC_CLASS
642/**
643 * has_wakealarm - check rtc device has wakealarm ability
644 * @dev: current device
645 * @name_ptr: name to be returned
646 *
647 * This helper function checks to see if the rtc device can wake
648 * from suspend.
649 */
650static int __init has_wakealarm(struct device *dev, void *name_ptr)
651{
652 struct rtc_device *candidate = to_rtc_device(dev);
653
654 if (!candidate->ops->set_alarm)
655 return 0;
656 if (!device_may_wakeup(candidate->dev.parent))
657 return 0;
658
659 *(const char **)name_ptr = dev_name(dev);
660 return 1;
661}
662
663/**
664 * alarmtimer_init_late - Late initializing of alarmtimer code
665 *
666 * This function locates a rtc device to use for wakealarms.
667 * Run as late_initcall to make sure rtc devices have been
668 * registered.
669 */
670static int __init alarmtimer_init_late(void)
671{
672 struct device *dev;
673 char *str;
674
675 /* Find an rtc device and init the rtc_timer */
676 dev = class_find_device(rtc_class, NULL, &str, has_wakealarm);
677 /* If we have a device then str is valid. See has_wakealarm() */
678 if (dev) {
679 rtcdev = rtc_class_open(str);
680 /*
681 * Drop the reference we got in class_find_device,
682 * rtc_open takes its own.
683 */
684 put_device(dev);
685 }
686 if (!rtcdev) {
687 printk(KERN_WARNING "No RTC device found, ALARM timers will"
688 " not wake from suspend");
689 }
690 rtc_timer_init(&rtctimer, NULL, NULL);
691
692 return 0;
693}
694#else
695static int __init alarmtimer_init_late(void)
696{
697 printk(KERN_WARNING "Kernel not built with RTC support, ALARM timers"
698 " will not wake from suspend");
699 return 0;
700}
701#endif
702late_initcall(alarmtimer_init_late);
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index cf7d027a8844..ddffc74cdebe 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -35,6 +35,7 @@
35#include <linux/limits.h> 35#include <linux/limits.h>
36#include <linux/mutex.h> 36#include <linux/mutex.h>
37#include <linux/rbtree.h> 37#include <linux/rbtree.h>
38#include <linux/shmem_fs.h>
38#include <linux/slab.h> 39#include <linux/slab.h>
39#include <linux/swap.h> 40#include <linux/swap.h>
40#include <linux/swapops.h> 41#include <linux/swapops.h>
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index eac0ba561491..740c4f52059c 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -391,10 +391,11 @@ static void collect_procs_anon(struct page *page, struct list_head *to_kill,
391 struct task_struct *tsk; 391 struct task_struct *tsk;
392 struct anon_vma *av; 392 struct anon_vma *av;
393 393
394 read_lock(&tasklist_lock);
395 av = page_lock_anon_vma(page); 394 av = page_lock_anon_vma(page);
396 if (av == NULL) /* Not actually mapped anymore */ 395 if (av == NULL) /* Not actually mapped anymore */
397 goto out; 396 return;
397
398 read_lock(&tasklist_lock);
398 for_each_process (tsk) { 399 for_each_process (tsk) {
399 struct anon_vma_chain *vmac; 400 struct anon_vma_chain *vmac;
400 401
@@ -408,9 +409,8 @@ static void collect_procs_anon(struct page *page, struct list_head *to_kill,
408 add_to_kill(tsk, page, vma, to_kill, tkc); 409 add_to_kill(tsk, page, vma, to_kill, tkc);
409 } 410 }
410 } 411 }
411 page_unlock_anon_vma(av);
412out:
413 read_unlock(&tasklist_lock); 412 read_unlock(&tasklist_lock);
413 page_unlock_anon_vma(av);
414} 414}
415 415
416/* 416/*
@@ -424,17 +424,8 @@ static void collect_procs_file(struct page *page, struct list_head *to_kill,
424 struct prio_tree_iter iter; 424 struct prio_tree_iter iter;
425 struct address_space *mapping = page->mapping; 425 struct address_space *mapping = page->mapping;
426 426
427 /*
428 * A note on the locking order between the two locks.
429 * We don't rely on this particular order.
430 * If you have some other code that needs a different order
431 * feel free to switch them around. Or add a reverse link
432 * from mm_struct to task_struct, then this could be all
433 * done without taking tasklist_lock and looping over all tasks.
434 */
435
436 read_lock(&tasklist_lock);
437 mutex_lock(&mapping->i_mmap_mutex); 427 mutex_lock(&mapping->i_mmap_mutex);
428 read_lock(&tasklist_lock);
438 for_each_process(tsk) { 429 for_each_process(tsk) {
439 pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); 430 pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
440 431
@@ -454,8 +445,8 @@ static void collect_procs_file(struct page *page, struct list_head *to_kill,
454 add_to_kill(tsk, page, vma, to_kill, tkc); 445 add_to_kill(tsk, page, vma, to_kill, tkc);
455 } 446 }
456 } 447 }
457 mutex_unlock(&mapping->i_mmap_mutex);
458 read_unlock(&tasklist_lock); 448 read_unlock(&tasklist_lock);
449 mutex_unlock(&mapping->i_mmap_mutex);
459} 450}
460 451
461/* 452/*
diff --git a/mm/memory.c b/mm/memory.c
index 87d935333f0d..40b7531ee8ba 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2798,30 +2798,6 @@ void unmap_mapping_range(struct address_space *mapping,
2798} 2798}
2799EXPORT_SYMBOL(unmap_mapping_range); 2799EXPORT_SYMBOL(unmap_mapping_range);
2800 2800
2801int vmtruncate_range(struct inode *inode, loff_t offset, loff_t end)
2802{
2803 struct address_space *mapping = inode->i_mapping;
2804
2805 /*
2806 * If the underlying filesystem is not going to provide
2807 * a way to truncate a range of blocks (punch a hole) -
2808 * we should return failure right now.
2809 */
2810 if (!inode->i_op->truncate_range)
2811 return -ENOSYS;
2812
2813 mutex_lock(&inode->i_mutex);
2814 down_write(&inode->i_alloc_sem);
2815 unmap_mapping_range(mapping, offset, (end - offset), 1);
2816 truncate_inode_pages_range(mapping, offset, end);
2817 unmap_mapping_range(mapping, offset, (end - offset), 1);
2818 inode->i_op->truncate_range(inode, offset, end);
2819 up_write(&inode->i_alloc_sem);
2820 mutex_unlock(&inode->i_mutex);
2821
2822 return 0;
2823}
2824
2825/* 2801/*
2826 * We enter with non-exclusive mmap_sem (to exclude vma changes, 2802 * We enter with non-exclusive mmap_sem (to exclude vma changes,
2827 * but allow concurrent faults), and pte mapped but not yet locked. 2803 * but allow concurrent faults), and pte mapped but not yet locked.
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 02159c755136..c46887b5a11e 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -498,7 +498,9 @@ static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start)
498 * The node we allocated has no zone fallback lists. For avoiding 498 * The node we allocated has no zone fallback lists. For avoiding
499 * to access not-initialized zonelist, build here. 499 * to access not-initialized zonelist, build here.
500 */ 500 */
501 mutex_lock(&zonelists_mutex);
501 build_all_zonelists(NULL); 502 build_all_zonelists(NULL);
503 mutex_unlock(&zonelists_mutex);
502 504
503 return pgdat; 505 return pgdat;
504} 506}
@@ -521,7 +523,7 @@ int mem_online_node(int nid)
521 523
522 lock_memory_hotplug(); 524 lock_memory_hotplug();
523 pgdat = hotadd_new_pgdat(nid, 0); 525 pgdat = hotadd_new_pgdat(nid, 0);
524 if (pgdat) { 526 if (!pgdat) {
525 ret = -ENOMEM; 527 ret = -ENOMEM;
526 goto out; 528 goto out;
527 } 529 }
diff --git a/mm/rmap.c b/mm/rmap.c
index 27dfd3b82b0f..23295f65ae43 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -38,9 +38,8 @@
38 * in arch-dependent flush_dcache_mmap_lock, 38 * in arch-dependent flush_dcache_mmap_lock,
39 * within inode_wb_list_lock in __sync_single_inode) 39 * within inode_wb_list_lock in __sync_single_inode)
40 * 40 *
41 * (code doesn't rely on that order so it could be switched around) 41 * anon_vma->mutex,mapping->i_mutex (memory_failure, collect_procs_anon)
42 * ->tasklist_lock 42 * ->tasklist_lock
43 * anon_vma->mutex (memory_failure, collect_procs_anon)
44 * pte map lock 43 * pte map lock
45 */ 44 */
46 45
diff --git a/mm/shmem.c b/mm/shmem.c
index d221a1cfd7b1..fcedf5464eb7 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -539,7 +539,7 @@ static void shmem_free_pages(struct list_head *next)
539 } while (next); 539 } while (next);
540} 540}
541 541
542static void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end) 542void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end)
543{ 543{
544 struct shmem_inode_info *info = SHMEM_I(inode); 544 struct shmem_inode_info *info = SHMEM_I(inode);
545 unsigned long idx; 545 unsigned long idx;
@@ -562,6 +562,8 @@ static void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end)
562 spinlock_t *punch_lock; 562 spinlock_t *punch_lock;
563 unsigned long upper_limit; 563 unsigned long upper_limit;
564 564
565 truncate_inode_pages_range(inode->i_mapping, start, end);
566
565 inode->i_ctime = inode->i_mtime = CURRENT_TIME; 567 inode->i_ctime = inode->i_mtime = CURRENT_TIME;
566 idx = (start + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; 568 idx = (start + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
567 if (idx >= info->next_index) 569 if (idx >= info->next_index)
@@ -738,16 +740,8 @@ done2:
738 * lowered next_index. Also, though shmem_getpage checks 740 * lowered next_index. Also, though shmem_getpage checks
739 * i_size before adding to cache, no recheck after: so fix the 741 * i_size before adding to cache, no recheck after: so fix the
740 * narrow window there too. 742 * narrow window there too.
741 *
742 * Recalling truncate_inode_pages_range and unmap_mapping_range
743 * every time for punch_hole (which never got a chance to clear
744 * SHMEM_PAGEIN at the start of vmtruncate_range) is expensive,
745 * yet hardly ever necessary: try to optimize them out later.
746 */ 743 */
747 truncate_inode_pages_range(inode->i_mapping, start, end); 744 truncate_inode_pages_range(inode->i_mapping, start, end);
748 if (punch_hole)
749 unmap_mapping_range(inode->i_mapping, start,
750 end - start, 1);
751 } 745 }
752 746
753 spin_lock(&info->lock); 747 spin_lock(&info->lock);
@@ -766,22 +760,23 @@ done2:
766 shmem_free_pages(pages_to_free.next); 760 shmem_free_pages(pages_to_free.next);
767 } 761 }
768} 762}
763EXPORT_SYMBOL_GPL(shmem_truncate_range);
769 764
770static int shmem_notify_change(struct dentry *dentry, struct iattr *attr) 765static int shmem_setattr(struct dentry *dentry, struct iattr *attr)
771{ 766{
772 struct inode *inode = dentry->d_inode; 767 struct inode *inode = dentry->d_inode;
773 loff_t newsize = attr->ia_size;
774 int error; 768 int error;
775 769
776 error = inode_change_ok(inode, attr); 770 error = inode_change_ok(inode, attr);
777 if (error) 771 if (error)
778 return error; 772 return error;
779 773
780 if (S_ISREG(inode->i_mode) && (attr->ia_valid & ATTR_SIZE) 774 if (S_ISREG(inode->i_mode) && (attr->ia_valid & ATTR_SIZE)) {
781 && newsize != inode->i_size) { 775 loff_t oldsize = inode->i_size;
776 loff_t newsize = attr->ia_size;
782 struct page *page = NULL; 777 struct page *page = NULL;
783 778
784 if (newsize < inode->i_size) { 779 if (newsize < oldsize) {
785 /* 780 /*
786 * If truncating down to a partial page, then 781 * If truncating down to a partial page, then
787 * if that page is already allocated, hold it 782 * if that page is already allocated, hold it
@@ -810,12 +805,19 @@ static int shmem_notify_change(struct dentry *dentry, struct iattr *attr)
810 spin_unlock(&info->lock); 805 spin_unlock(&info->lock);
811 } 806 }
812 } 807 }
813 808 if (newsize != oldsize) {
814 /* XXX(truncate): truncate_setsize should be called last */ 809 i_size_write(inode, newsize);
815 truncate_setsize(inode, newsize); 810 inode->i_ctime = inode->i_mtime = CURRENT_TIME;
811 }
812 if (newsize < oldsize) {
813 loff_t holebegin = round_up(newsize, PAGE_SIZE);
814 unmap_mapping_range(inode->i_mapping, holebegin, 0, 1);
815 shmem_truncate_range(inode, newsize, (loff_t)-1);
816 /* unmap again to remove racily COWed private pages */
817 unmap_mapping_range(inode->i_mapping, holebegin, 0, 1);
818 }
816 if (page) 819 if (page)
817 page_cache_release(page); 820 page_cache_release(page);
818 shmem_truncate_range(inode, newsize, (loff_t)-1);
819 } 821 }
820 822
821 setattr_copy(inode, attr); 823 setattr_copy(inode, attr);
@@ -832,7 +834,6 @@ static void shmem_evict_inode(struct inode *inode)
832 struct shmem_xattr *xattr, *nxattr; 834 struct shmem_xattr *xattr, *nxattr;
833 835
834 if (inode->i_mapping->a_ops == &shmem_aops) { 836 if (inode->i_mapping->a_ops == &shmem_aops) {
835 truncate_inode_pages(inode->i_mapping, 0);
836 shmem_unacct_size(info->flags, inode->i_size); 837 shmem_unacct_size(info->flags, inode->i_size);
837 inode->i_size = 0; 838 inode->i_size = 0;
838 shmem_truncate_range(inode, 0, (loff_t)-1); 839 shmem_truncate_range(inode, 0, (loff_t)-1);
@@ -2706,7 +2707,7 @@ static const struct file_operations shmem_file_operations = {
2706}; 2707};
2707 2708
2708static const struct inode_operations shmem_inode_operations = { 2709static const struct inode_operations shmem_inode_operations = {
2709 .setattr = shmem_notify_change, 2710 .setattr = shmem_setattr,
2710 .truncate_range = shmem_truncate_range, 2711 .truncate_range = shmem_truncate_range,
2711#ifdef CONFIG_TMPFS_XATTR 2712#ifdef CONFIG_TMPFS_XATTR
2712 .setxattr = shmem_setxattr, 2713 .setxattr = shmem_setxattr,
@@ -2739,7 +2740,7 @@ static const struct inode_operations shmem_dir_inode_operations = {
2739 .removexattr = shmem_removexattr, 2740 .removexattr = shmem_removexattr,
2740#endif 2741#endif
2741#ifdef CONFIG_TMPFS_POSIX_ACL 2742#ifdef CONFIG_TMPFS_POSIX_ACL
2742 .setattr = shmem_notify_change, 2743 .setattr = shmem_setattr,
2743 .check_acl = generic_check_acl, 2744 .check_acl = generic_check_acl,
2744#endif 2745#endif
2745}; 2746};
@@ -2752,7 +2753,7 @@ static const struct inode_operations shmem_special_inode_operations = {
2752 .removexattr = shmem_removexattr, 2753 .removexattr = shmem_removexattr,
2753#endif 2754#endif
2754#ifdef CONFIG_TMPFS_POSIX_ACL 2755#ifdef CONFIG_TMPFS_POSIX_ACL
2755 .setattr = shmem_notify_change, 2756 .setattr = shmem_setattr,
2756 .check_acl = generic_check_acl, 2757 .check_acl = generic_check_acl,
2757#endif 2758#endif
2758}; 2759};
@@ -2908,6 +2909,12 @@ int shmem_lock(struct file *file, int lock, struct user_struct *user)
2908 return 0; 2909 return 0;
2909} 2910}
2910 2911
2912void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end)
2913{
2914 truncate_inode_pages_range(inode->i_mapping, start, end);
2915}
2916EXPORT_SYMBOL_GPL(shmem_truncate_range);
2917
2911#ifdef CONFIG_CGROUP_MEM_RES_CTLR 2918#ifdef CONFIG_CGROUP_MEM_RES_CTLR
2912/** 2919/**
2913 * mem_cgroup_get_shmem_target - find a page or entry assigned to the shmem file 2920 * mem_cgroup_get_shmem_target - find a page or entry assigned to the shmem file
@@ -3028,3 +3035,26 @@ int shmem_zero_setup(struct vm_area_struct *vma)
3028 vma->vm_flags |= VM_CAN_NONLINEAR; 3035 vma->vm_flags |= VM_CAN_NONLINEAR;
3029 return 0; 3036 return 0;
3030} 3037}
3038
3039/**
3040 * shmem_read_mapping_page_gfp - read into page cache, using specified page allocation flags.
3041 * @mapping: the page's address_space
3042 * @index: the page index
3043 * @gfp: the page allocator flags to use if allocating
3044 *
3045 * This behaves as a tmpfs "read_cache_page_gfp(mapping, index, gfp)",
3046 * with any new page allocations done using the specified allocation flags.
3047 * But read_cache_page_gfp() uses the ->readpage() method: which does not
3048 * suit tmpfs, since it may have pages in swapcache, and needs to find those
3049 * for itself; although drivers/gpu/drm i915 and ttm rely upon this support.
3050 *
3051 * Provide a stub for those callers to start using now, then later
3052 * flesh it out to call shmem_getpage() with additional gfp mask, when
3053 * shmem_file_splice_read() is added and shmem_readpage() is removed.
3054 */
3055struct page *shmem_read_mapping_page_gfp(struct address_space *mapping,
3056 pgoff_t index, gfp_t gfp)
3057{
3058 return read_cache_page_gfp(mapping, index, gfp);
3059}
3060EXPORT_SYMBOL_GPL(shmem_read_mapping_page_gfp);
diff --git a/mm/swapfile.c b/mm/swapfile.c
index d537d29e9b7b..ff8dc1a18cb4 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -14,7 +14,7 @@
14#include <linux/vmalloc.h> 14#include <linux/vmalloc.h>
15#include <linux/pagemap.h> 15#include <linux/pagemap.h>
16#include <linux/namei.h> 16#include <linux/namei.h>
17#include <linux/shm.h> 17#include <linux/shmem_fs.h>
18#include <linux/blkdev.h> 18#include <linux/blkdev.h>
19#include <linux/random.h> 19#include <linux/random.h>
20#include <linux/writeback.h> 20#include <linux/writeback.h>
diff --git a/mm/truncate.c b/mm/truncate.c
index 3a29a6180212..e13f22efaad7 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -304,6 +304,11 @@ EXPORT_SYMBOL(truncate_inode_pages_range);
304 * @lstart: offset from which to truncate 304 * @lstart: offset from which to truncate
305 * 305 *
306 * Called under (and serialised by) inode->i_mutex. 306 * Called under (and serialised by) inode->i_mutex.
307 *
308 * Note: When this function returns, there can be a page in the process of
309 * deletion (inside __delete_from_page_cache()) in the specified range. Thus
310 * mapping->nrpages can be non-zero when this function returns even after
311 * truncation of the whole mapping.
307 */ 312 */
308void truncate_inode_pages(struct address_space *mapping, loff_t lstart) 313void truncate_inode_pages(struct address_space *mapping, loff_t lstart)
309{ 314{
@@ -603,3 +608,27 @@ int vmtruncate(struct inode *inode, loff_t offset)
603 return 0; 608 return 0;
604} 609}
605EXPORT_SYMBOL(vmtruncate); 610EXPORT_SYMBOL(vmtruncate);
611
612int vmtruncate_range(struct inode *inode, loff_t offset, loff_t end)
613{
614 struct address_space *mapping = inode->i_mapping;
615
616 /*
617 * If the underlying filesystem is not going to provide
618 * a way to truncate a range of blocks (punch a hole) -
619 * we should return failure right now.
620 */
621 if (!inode->i_op->truncate_range)
622 return -ENOSYS;
623
624 mutex_lock(&inode->i_mutex);
625 down_write(&inode->i_alloc_sem);
626 unmap_mapping_range(mapping, offset, (end - offset), 1);
627 inode->i_op->truncate_range(inode, offset, end);
628 /* unmap again to remove racily COWed private pages */
629 unmap_mapping_range(mapping, offset, (end - offset), 1);
630 up_write(&inode->i_alloc_sem);
631 mutex_unlock(&inode->i_mutex);
632
633 return 0;
634}
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 8ff834e19c24..4f49535d4cd3 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1995,14 +1995,13 @@ restart:
1995 * If a zone is deemed to be full of pinned pages then just give it a light 1995 * If a zone is deemed to be full of pinned pages then just give it a light
1996 * scan then give up on it. 1996 * scan then give up on it.
1997 */ 1997 */
1998static unsigned long shrink_zones(int priority, struct zonelist *zonelist, 1998static void shrink_zones(int priority, struct zonelist *zonelist,
1999 struct scan_control *sc) 1999 struct scan_control *sc)
2000{ 2000{
2001 struct zoneref *z; 2001 struct zoneref *z;
2002 struct zone *zone; 2002 struct zone *zone;
2003 unsigned long nr_soft_reclaimed; 2003 unsigned long nr_soft_reclaimed;
2004 unsigned long nr_soft_scanned; 2004 unsigned long nr_soft_scanned;
2005 unsigned long total_scanned = 0;
2006 2005
2007 for_each_zone_zonelist_nodemask(zone, z, zonelist, 2006 for_each_zone_zonelist_nodemask(zone, z, zonelist,
2008 gfp_zone(sc->gfp_mask), sc->nodemask) { 2007 gfp_zone(sc->gfp_mask), sc->nodemask) {
@@ -2017,19 +2016,23 @@ static unsigned long shrink_zones(int priority, struct zonelist *zonelist,
2017 continue; 2016 continue;
2018 if (zone->all_unreclaimable && priority != DEF_PRIORITY) 2017 if (zone->all_unreclaimable && priority != DEF_PRIORITY)
2019 continue; /* Let kswapd poll it */ 2018 continue; /* Let kswapd poll it */
2019 /*
2020 * This steals pages from memory cgroups over softlimit
2021 * and returns the number of reclaimed pages and
2022 * scanned pages. This works for global memory pressure
2023 * and balancing, not for a memcg's limit.
2024 */
2025 nr_soft_scanned = 0;
2026 nr_soft_reclaimed = mem_cgroup_soft_limit_reclaim(zone,
2027 sc->order, sc->gfp_mask,
2028 &nr_soft_scanned);
2029 sc->nr_reclaimed += nr_soft_reclaimed;
2030 sc->nr_scanned += nr_soft_scanned;
2031 /* need some check for avoid more shrink_zone() */
2020 } 2032 }
2021 2033
2022 nr_soft_scanned = 0;
2023 nr_soft_reclaimed = mem_cgroup_soft_limit_reclaim(zone,
2024 sc->order, sc->gfp_mask,
2025 &nr_soft_scanned);
2026 sc->nr_reclaimed += nr_soft_reclaimed;
2027 total_scanned += nr_soft_scanned;
2028
2029 shrink_zone(priority, zone, sc); 2034 shrink_zone(priority, zone, sc);
2030 } 2035 }
2031
2032 return total_scanned;
2033} 2036}
2034 2037
2035static bool zone_reclaimable(struct zone *zone) 2038static bool zone_reclaimable(struct zone *zone)
@@ -2094,7 +2097,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
2094 sc->nr_scanned = 0; 2097 sc->nr_scanned = 0;
2095 if (!priority) 2098 if (!priority)
2096 disable_swap_token(sc->mem_cgroup); 2099 disable_swap_token(sc->mem_cgroup);
2097 total_scanned += shrink_zones(priority, zonelist, sc); 2100 shrink_zones(priority, zonelist, sc);
2098 /* 2101 /*
2099 * Don't shrink slabs when reclaiming memory from 2102 * Don't shrink slabs when reclaiming memory from
2100 * over limit cgroups 2103 * over limit cgroups
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index 339ba64cce1e..5daf6cc4faea 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -577,13 +577,13 @@ retry:
577 } 577 }
578 inode = &gss_msg->inode->vfs_inode; 578 inode = &gss_msg->inode->vfs_inode;
579 for (;;) { 579 for (;;) {
580 prepare_to_wait(&gss_msg->waitqueue, &wait, TASK_INTERRUPTIBLE); 580 prepare_to_wait(&gss_msg->waitqueue, &wait, TASK_KILLABLE);
581 spin_lock(&inode->i_lock); 581 spin_lock(&inode->i_lock);
582 if (gss_msg->ctx != NULL || gss_msg->msg.errno < 0) { 582 if (gss_msg->ctx != NULL || gss_msg->msg.errno < 0) {
583 break; 583 break;
584 } 584 }
585 spin_unlock(&inode->i_lock); 585 spin_unlock(&inode->i_lock);
586 if (signalled()) { 586 if (fatal_signal_pending(current)) {
587 err = -ERESTARTSYS; 587 err = -ERESTARTSYS;
588 goto out_intr; 588 goto out_intr;
589 } 589 }
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index b84d7395535e..8c9141583d6f 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -1061,7 +1061,7 @@ call_allocate(struct rpc_task *task)
1061 1061
1062 dprintk("RPC: %5u rpc_buffer allocation failed\n", task->tk_pid); 1062 dprintk("RPC: %5u rpc_buffer allocation failed\n", task->tk_pid);
1063 1063
1064 if (RPC_IS_ASYNC(task) || !signalled()) { 1064 if (RPC_IS_ASYNC(task) || !fatal_signal_pending(current)) {
1065 task->tk_action = call_allocate; 1065 task->tk_action = call_allocate;
1066 rpc_delay(task, HZ>>4); 1066 rpc_delay(task, HZ>>4);
1067 return; 1067 return;
@@ -1175,6 +1175,9 @@ call_bind_status(struct rpc_task *task)
1175 status = -EOPNOTSUPP; 1175 status = -EOPNOTSUPP;
1176 break; 1176 break;
1177 } 1177 }
1178 if (task->tk_rebind_retry == 0)
1179 break;
1180 task->tk_rebind_retry--;
1178 rpc_delay(task, 3*HZ); 1181 rpc_delay(task, 3*HZ);
1179 goto retry_timeout; 1182 goto retry_timeout;
1180 case -ETIMEDOUT: 1183 case -ETIMEDOUT:
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index 6b43ee7221d5..a27406b1654f 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -792,6 +792,7 @@ static void rpc_init_task(struct rpc_task *task, const struct rpc_task_setup *ta
792 /* Initialize retry counters */ 792 /* Initialize retry counters */
793 task->tk_garb_retry = 2; 793 task->tk_garb_retry = 2;
794 task->tk_cred_retry = 2; 794 task->tk_cred_retry = 2;
795 task->tk_rebind_retry = 2;
795 796
796 task->tk_priority = task_setup_data->priority - RPC_PRIORITY_LOW; 797 task->tk_priority = task_setup_data->priority - RPC_PRIORITY_LOW;
797 task->tk_owner = current->tgid; 798 task->tk_owner = current->tgid;
diff --git a/security/keys/request_key.c b/security/keys/request_key.c
index 8e319a416eec..82465328c39b 100644
--- a/security/keys/request_key.c
+++ b/security/keys/request_key.c
@@ -469,7 +469,7 @@ static struct key *construct_key_and_link(struct key_type *type,
469 } else if (ret == -EINPROGRESS) { 469 } else if (ret == -EINPROGRESS) {
470 ret = 0; 470 ret = 0;
471 } else { 471 } else {
472 key = ERR_PTR(ret); 472 goto couldnt_alloc_key;
473 } 473 }
474 474
475 key_put(dest_keyring); 475 key_put(dest_keyring);
@@ -479,6 +479,7 @@ static struct key *construct_key_and_link(struct key_type *type,
479construction_failed: 479construction_failed:
480 key_negate_and_link(key, key_negative_timeout, NULL, NULL); 480 key_negate_and_link(key, key_negative_timeout, NULL, NULL);
481 key_put(key); 481 key_put(key);
482couldnt_alloc_key:
482 key_put(dest_keyring); 483 key_put(dest_keyring);
483 kleave(" = %d", ret); 484 kleave(" = %d", ret);
484 return ERR_PTR(ret); 485 return ERR_PTR(ret);
diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c
index 2ca6f4f85b41..e3569bdd3b64 100644
--- a/sound/pci/asihpi/asihpi.c
+++ b/sound/pci/asihpi/asihpi.c
@@ -27,7 +27,6 @@
27#include "hpioctl.h" 27#include "hpioctl.h"
28 28
29#include <linux/pci.h> 29#include <linux/pci.h>
30#include <linux/version.h>
31#include <linux/init.h> 30#include <linux/init.h>
32#include <linux/jiffies.h> 31#include <linux/jiffies.h>
33#include <linux/slab.h> 32#include <linux/slab.h>
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 61a774b3d3cb..d21191dcfe88 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -4883,7 +4883,6 @@ static const struct snd_pci_quirk alc880_cfg_tbl[] = {
4883 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG), 4883 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4884 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST), 4884 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
4885 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG), 4885 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4886 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
4887 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V), 4886 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4888 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG), 4887 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4889 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG), 4888 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
@@ -12600,6 +12599,7 @@ static const struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12600 */ 12599 */
12601enum { 12600enum {
12602 PINFIX_FSC_H270, 12601 PINFIX_FSC_H270,
12602 PINFIX_HP_Z200,
12603}; 12603};
12604 12604
12605static const struct alc_fixup alc262_fixups[] = { 12605static const struct alc_fixup alc262_fixups[] = {
@@ -12612,9 +12612,17 @@ static const struct alc_fixup alc262_fixups[] = {
12612 { } 12612 { }
12613 } 12613 }
12614 }, 12614 },
12615 [PINFIX_HP_Z200] = {
12616 .type = ALC_FIXUP_PINS,
12617 .v.pins = (const struct alc_pincfg[]) {
12618 { 0x16, 0x99130120 }, /* internal speaker */
12619 { }
12620 }
12621 },
12615}; 12622};
12616 12623
12617static const struct snd_pci_quirk alc262_fixup_tbl[] = { 12624static const struct snd_pci_quirk alc262_fixup_tbl[] = {
12625 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", PINFIX_HP_Z200),
12618 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270), 12626 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12619 {} 12627 {}
12620}; 12628};
@@ -12731,6 +12739,8 @@ static const struct snd_pci_quirk alc262_cfg_tbl[] = {
12731 ALC262_HP_BPC), 12739 ALC262_HP_BPC),
12732 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1500, "HP z series", 12740 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1500, "HP z series",
12733 ALC262_HP_BPC), 12741 ALC262_HP_BPC),
12742 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200",
12743 ALC262_AUTO),
12734 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series", 12744 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12735 ALC262_HP_BPC), 12745 ALC262_HP_BPC),
12736 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL), 12746 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
@@ -13872,7 +13882,6 @@ static const struct snd_pci_quirk alc268_cfg_tbl[] = {
13872 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST), 13882 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
13873 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO), 13883 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
13874 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA), 13884 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
13875 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
13876 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1), 13885 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
13877 {} 13886 {}
13878}; 13887};
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index c952582fb218..f43bb0eaed8b 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -745,12 +745,23 @@ static int via_independent_hp_put(struct snd_kcontrol *kcontrol,
745 struct via_spec *spec = codec->spec; 745 struct via_spec *spec = codec->spec;
746 hda_nid_t nid = kcontrol->private_value; 746 hda_nid_t nid = kcontrol->private_value;
747 unsigned int pinsel = ucontrol->value.enumerated.item[0]; 747 unsigned int pinsel = ucontrol->value.enumerated.item[0];
748 unsigned int parm0, parm1;
748 /* Get Independent Mode index of headphone pin widget */ 749 /* Get Independent Mode index of headphone pin widget */
749 spec->hp_independent_mode = spec->hp_independent_mode_index == pinsel 750 spec->hp_independent_mode = spec->hp_independent_mode_index == pinsel
750 ? 1 : 0; 751 ? 1 : 0;
751 if (spec->codec_type == VT1718S) 752 if (spec->codec_type == VT1718S) {
752 snd_hda_codec_write(codec, nid, 0, 753 snd_hda_codec_write(codec, nid, 0,
753 AC_VERB_SET_CONNECT_SEL, pinsel ? 2 : 0); 754 AC_VERB_SET_CONNECT_SEL, pinsel ? 2 : 0);
755 /* Set correct mute switch for MW3 */
756 parm0 = spec->hp_independent_mode ?
757 AMP_IN_UNMUTE(0) : AMP_IN_MUTE(0);
758 parm1 = spec->hp_independent_mode ?
759 AMP_IN_MUTE(1) : AMP_IN_UNMUTE(1);
760 snd_hda_codec_write(codec, 0x1b, 0,
761 AC_VERB_SET_AMP_GAIN_MUTE, parm0);
762 snd_hda_codec_write(codec, 0x1b, 0,
763 AC_VERB_SET_AMP_GAIN_MUTE, parm1);
764 }
754 else 765 else
755 snd_hda_codec_write(codec, nid, 0, 766 snd_hda_codec_write(codec, nid, 0,
756 AC_VERB_SET_CONNECT_SEL, pinsel); 767 AC_VERB_SET_CONNECT_SEL, pinsel);
@@ -4283,9 +4294,6 @@ static const struct hda_verb vt1718S_volume_init_verbs[] = {
4283 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 4294 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4284 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 4295 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4285 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, 4296 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
4286
4287 /* Setup default input of Front HP to MW9 */
4288 {0x28, AC_VERB_SET_CONNECT_SEL, 0x1},
4289 /* PW9 PW10 Output enable */ 4297 /* PW9 PW10 Output enable */
4290 {0x2d, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_OUT_EN}, 4298 {0x2d, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_OUT_EN},
4291 {0x2e, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_OUT_EN}, 4299 {0x2e, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_OUT_EN},
@@ -4294,10 +4302,10 @@ static const struct hda_verb vt1718S_volume_init_verbs[] = {
4294 /* Enable Boost Volume backdoor */ 4302 /* Enable Boost Volume backdoor */
4295 {0x1, 0xf88, 0x8}, 4303 {0x1, 0xf88, 0x8},
4296 /* MW0/1/2/3/4: un-mute index 0 (AOWx), mute index 1 (MW9) */ 4304 /* MW0/1/2/3/4: un-mute index 0 (AOWx), mute index 1 (MW9) */
4297 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4305 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4298 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4306 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4299 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4307 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4300 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4308 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4301 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4309 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4302 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 4310 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4303 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4311 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
@@ -4307,8 +4315,6 @@ static const struct hda_verb vt1718S_volume_init_verbs[] = {
4307 /* set MUX1 = 2 (AOW4), MUX2 = 1 (AOW3) */ 4315 /* set MUX1 = 2 (AOW4), MUX2 = 1 (AOW3) */
4308 {0x34, AC_VERB_SET_CONNECT_SEL, 0x2}, 4316 {0x34, AC_VERB_SET_CONNECT_SEL, 0x2},
4309 {0x35, AC_VERB_SET_CONNECT_SEL, 0x1}, 4317 {0x35, AC_VERB_SET_CONNECT_SEL, 0x1},
4310 /* Unmute MW4's index 0 */
4311 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4312 { } 4318 { }
4313}; 4319};
4314 4320
@@ -4456,6 +4462,19 @@ static int vt1718S_auto_create_multi_out_ctls(struct via_spec *spec,
4456 if (err < 0) 4462 if (err < 0)
4457 return err; 4463 return err;
4458 } else if (i == AUTO_SEQ_FRONT) { 4464 } else if (i == AUTO_SEQ_FRONT) {
4465 /* add control to mixer index 0 */
4466 err = via_add_control(spec, VIA_CTL_WIDGET_VOL,
4467 "Master Front Playback Volume",
4468 HDA_COMPOSE_AMP_VAL(0x21, 3, 5,
4469 HDA_INPUT));
4470 if (err < 0)
4471 return err;
4472 err = via_add_control(spec, VIA_CTL_WIDGET_MUTE,
4473 "Master Front Playback Switch",
4474 HDA_COMPOSE_AMP_VAL(0x21, 3, 5,
4475 HDA_INPUT));
4476 if (err < 0)
4477 return err;
4459 /* Front */ 4478 /* Front */
4460 sprintf(name, "%s Playback Volume", chname[i]); 4479 sprintf(name, "%s Playback Volume", chname[i]);
4461 err = via_add_control( 4480 err = via_add_control(
diff --git a/sound/soc/codecs/wm8991.c b/sound/soc/codecs/wm8991.c
index 3c2ee1bb73cd..6af23d06870f 100644
--- a/sound/soc/codecs/wm8991.c
+++ b/sound/soc/codecs/wm8991.c
@@ -13,7 +13,6 @@
13 13
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/moduleparam.h> 15#include <linux/moduleparam.h>
16#include <linux/version.h>
17#include <linux/kernel.h> 16#include <linux/kernel.h>
18#include <linux/init.h> 17#include <linux/init.h>
19#include <linux/delay.h> 18#include <linux/delay.h>
diff --git a/sound/soc/imx/Kconfig b/sound/soc/imx/Kconfig
index d8f130d39dd9..bb699bb55a50 100644
--- a/sound/soc/imx/Kconfig
+++ b/sound/soc/imx/Kconfig
@@ -11,9 +11,6 @@ menuconfig SND_IMX_SOC
11 11
12if SND_IMX_SOC 12if SND_IMX_SOC
13 13
14config SND_MXC_SOC_SSI
15 tristate
16
17config SND_MXC_SOC_FIQ 14config SND_MXC_SOC_FIQ
18 tristate 15 tristate
19 16
@@ -24,7 +21,6 @@ config SND_MXC_SOC_WM1133_EV1
24 tristate "Audio on the the i.MX31ADS with WM1133-EV1 fitted" 21 tristate "Audio on the the i.MX31ADS with WM1133-EV1 fitted"
25 depends on MACH_MX31ADS_WM1133_EV1 && EXPERIMENTAL 22 depends on MACH_MX31ADS_WM1133_EV1 && EXPERIMENTAL
26 select SND_SOC_WM8350 23 select SND_SOC_WM8350
27 select SND_MXC_SOC_SSI
28 select SND_MXC_SOC_FIQ 24 select SND_MXC_SOC_FIQ
29 help 25 help
30 Enable support for audio on the i.MX31ADS with the WM1133-EV1 26 Enable support for audio on the i.MX31ADS with the WM1133-EV1
@@ -34,7 +30,6 @@ config SND_SOC_MX27VIS_AIC32X4
34 tristate "SoC audio support for Visstrim M10 boards" 30 tristate "SoC audio support for Visstrim M10 boards"
35 depends on MACH_IMX27_VISSTRIM_M10 31 depends on MACH_IMX27_VISSTRIM_M10
36 select SND_SOC_TVL320AIC32X4 32 select SND_SOC_TVL320AIC32X4
37 select SND_MXC_SOC_SSI
38 select SND_MXC_SOC_MX2 33 select SND_MXC_SOC_MX2
39 help 34 help
40 Say Y if you want to add support for SoC audio on Visstrim SM10 35 Say Y if you want to add support for SoC audio on Visstrim SM10
@@ -44,7 +39,6 @@ config SND_SOC_PHYCORE_AC97
44 tristate "SoC Audio support for Phytec phyCORE (and phyCARD) boards" 39 tristate "SoC Audio support for Phytec phyCORE (and phyCARD) boards"
45 depends on MACH_PCM043 || MACH_PCA100 40 depends on MACH_PCM043 || MACH_PCA100
46 select SND_SOC_WM9712 41 select SND_SOC_WM9712
47 select SND_MXC_SOC_SSI
48 select SND_MXC_SOC_FIQ 42 select SND_MXC_SOC_FIQ
49 help 43 help
50 Say Y if you want to add support for SoC audio on Phytec phyCORE 44 Say Y if you want to add support for SoC audio on Phytec phyCORE
@@ -57,7 +51,6 @@ config SND_SOC_EUKREA_TLV320
57 || MACH_EUKREA_MBIMXSD35_BASEBOARD \ 51 || MACH_EUKREA_MBIMXSD35_BASEBOARD \
58 || MACH_EUKREA_MBIMXSD51_BASEBOARD 52 || MACH_EUKREA_MBIMXSD51_BASEBOARD
59 select SND_SOC_TLV320AIC23 53 select SND_SOC_TLV320AIC23
60 select SND_MXC_SOC_SSI
61 select SND_MXC_SOC_FIQ 54 select SND_MXC_SOC_FIQ
62 help 55 help
63 Enable I2S based access to the TLV320AIC23B codec attached 56 Enable I2S based access to the TLV320AIC23B codec attached
diff --git a/sound/soc/imx/imx-pcm-dma-mx2.c b/sound/soc/imx/imx-pcm-dma-mx2.c
index aab7765f401a..4173b3d87f97 100644
--- a/sound/soc/imx/imx-pcm-dma-mx2.c
+++ b/sound/soc/imx/imx-pcm-dma-mx2.c
@@ -337,3 +337,5 @@ static void __exit snd_imx_pcm_exit(void)
337 platform_driver_unregister(&imx_pcm_driver); 337 platform_driver_unregister(&imx_pcm_driver);
338} 338}
339module_exit(snd_imx_pcm_exit); 339module_exit(snd_imx_pcm_exit);
340MODULE_LICENSE("GPL");
341MODULE_ALIAS("platform:imx-pcm-audio");
diff --git a/sound/soc/imx/imx-ssi.c b/sound/soc/imx/imx-ssi.c
index 5b13feca7537..61fceb09cdb5 100644
--- a/sound/soc/imx/imx-ssi.c
+++ b/sound/soc/imx/imx-ssi.c
@@ -774,4 +774,4 @@ module_exit(imx_ssi_exit);
774MODULE_AUTHOR("Sascha Hauer, <s.hauer@pengutronix.de>"); 774MODULE_AUTHOR("Sascha Hauer, <s.hauer@pengutronix.de>");
775MODULE_DESCRIPTION("i.MX I2S/ac97 SoC Interface"); 775MODULE_DESCRIPTION("i.MX I2S/ac97 SoC Interface");
776MODULE_LICENSE("GPL"); 776MODULE_LICENSE("GPL");
777 777MODULE_ALIAS("platform:imx-ssi");
diff --git a/sound/soc/pxa/pxa2xx-pcm.c b/sound/soc/pxa/pxa2xx-pcm.c
index 2ce0b2d891d5..fab20a54e863 100644
--- a/sound/soc/pxa/pxa2xx-pcm.c
+++ b/sound/soc/pxa/pxa2xx-pcm.c
@@ -95,14 +95,14 @@ static int pxa2xx_soc_pcm_new(struct snd_card *card, struct snd_soc_dai *dai,
95 if (!card->dev->coherent_dma_mask) 95 if (!card->dev->coherent_dma_mask)
96 card->dev->coherent_dma_mask = DMA_BIT_MASK(32); 96 card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
97 97
98 if (dai->driver->playback.channels_min) { 98 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
99 ret = pxa2xx_pcm_preallocate_dma_buffer(pcm, 99 ret = pxa2xx_pcm_preallocate_dma_buffer(pcm,
100 SNDRV_PCM_STREAM_PLAYBACK); 100 SNDRV_PCM_STREAM_PLAYBACK);
101 if (ret) 101 if (ret)
102 goto out; 102 goto out;
103 } 103 }
104 104
105 if (dai->driver->capture.channels_min) { 105 if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
106 ret = pxa2xx_pcm_preallocate_dma_buffer(pcm, 106 ret = pxa2xx_pcm_preallocate_dma_buffer(pcm,
107 SNDRV_PCM_STREAM_CAPTURE); 107 SNDRV_PCM_STREAM_CAPTURE);
108 if (ret) 108 if (ret)
diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c
index c005ceb70c9d..039b9532b270 100644
--- a/sound/soc/soc-cache.c
+++ b/sound/soc/soc-cache.c
@@ -409,9 +409,6 @@ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
409 codec->bulk_write_raw = snd_soc_hw_bulk_write_raw; 409 codec->bulk_write_raw = snd_soc_hw_bulk_write_raw;
410 410
411 switch (control) { 411 switch (control) {
412 case SND_SOC_CUSTOM:
413 break;
414
415 case SND_SOC_I2C: 412 case SND_SOC_I2C:
416#if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE)) 413#if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE))
417 codec->hw_write = (hw_write_t)i2c_master_send; 414 codec->hw_write = (hw_write_t)i2c_master_send;