aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Hilman <khilman@linaro.org>2014-09-05 11:01:52 -0400
committerKevin Hilman <khilman@linaro.org>2014-09-05 11:05:56 -0400
commit95f6e8142d82789eca977ccdd6153a48b343fde9 (patch)
treeef39263a5bbc5c497d8603b77d2db1316a2845fc
parent28c2260f13c8ea3be6fcba1609502874f868284b (diff)
parentc7cc9ba11f8c09a4d12af0fc4aa9f9b026cdd354 (diff)
Merge tag 'omap-fixes-against-v3.17-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap into fixes
Merge "omap fixes against v3.17-rc3" from Tony Lindgren: Few fixes for omaps mostly for various devices to get them working properly on the new am437x and dra7 hardware for several devices such as I2C, NAND, DDR3 and USB. There's also a clock fix for omap3. And also included are two minor cosmetic fixes that are not stictly fixes for the new hardware support added recently to downgrade a GPMC warning into a debug statement, and fix the confusing comments for dra7-evm spi1 mux. Note that these are all .dts changes except for a GPMC change. * tag 'omap-fixes-against-v3.17-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap: (255 commits) ARM: dts: dra7-evm: Add vtt regulator support ARM: dts: dra7-evm: Fix spi1 mux documentation ARM: dts: am43x-epos-evm: Disable QSPI to prevent conflict with GPMC-NAND ARM: OMAP2+: gpmc: Don't complain if wait pin is used without r/w monitoring ARM: dts: am43xx-epos-evm: Don't use read/write wait monitoring ARM: dts: am437x-gp-evm: Don't use read/write wait monitoring ARM: dts: am437x-gp-evm: Use BCH16 ECC scheme instead of BCH8 ARM: dts: am43x-epos-evm: Use BCH16 ECC scheme instead of BCH8 ARM: dts: am4372: fix USB regs size ARM: dts: am437x-gp: switch i2c0 to 100KHz ARM: dts: dra7-evm: Fix 8th NAND partition's name ARM: dts: dra7-evm: Fix i2c3 pinmux and frequency Linux 3.17-rc3 ... Signed-off-by: Kevin Hilman <khilman@linaro.org>
-rw-r--r--Documentation/devicetree/bindings/mfd/tc3589x.txt107
-rw-r--r--Documentation/devicetree/bindings/pinctrl/qcom,apq8064-pinctrl.txt2
-rw-r--r--Documentation/dma-buf-sharing.txt14
-rw-r--r--Documentation/kdump/kdump.txt36
-rw-r--r--Documentation/this_cpu_ops.txt213
-rw-r--r--MAINTAINERS8
-rw-r--r--Makefile2
-rw-r--r--arch/alpha/include/asm/io.h12
-rw-r--r--arch/alpha/include/asm/unistd.h2
-rw-r--r--arch/alpha/include/uapi/asm/unistd.h3
-rw-r--r--arch/alpha/kernel/systbls.S3
-rw-r--r--arch/arc/mm/cache_arc700.c1
-rw-r--r--arch/arm/Kconfig2
-rw-r--r--arch/arm/boot/dts/am4372.dtsi4
-rw-r--r--arch/arm/boot/dts/am437x-gp-evm.dts6
-rw-r--r--arch/arm/boot/dts/am43x-epos-evm.dts9
-rw-r--r--arch/arm/boot/dts/dra7-evm.dts47
-rw-r--r--arch/arm/boot/dts/omap3-n900.dts2
-rw-r--r--arch/arm/boot/dts/omap3xxx-clocks.dtsi1
-rw-r--r--arch/arm/include/asm/cacheflush.h1
-rw-r--r--arch/arm/include/asm/cputype.h3
-rw-r--r--arch/arm/include/asm/elf.h1
-rw-r--r--arch/arm/include/asm/smp_plat.h15
-rw-r--r--arch/arm/kernel/entry-header.S29
-rw-r--r--arch/arm/kernel/module.c1
-rw-r--r--arch/arm/mach-exynos/mcpm-exynos.c1
-rw-r--r--arch/arm/mach-omap2/gpmc.c7
-rw-r--r--arch/arm/mm/abort-ev6.S6
-rw-r--r--arch/arm/mm/abort-ev7.S6
-rw-r--r--arch/hexagon/mm/cache.c1
-rw-r--r--arch/ia64/Kconfig2
-rw-r--r--arch/m68k/Kconfig2
-rw-r--r--arch/mips/Kconfig2
-rw-r--r--arch/powerpc/Kconfig2
-rw-r--r--arch/s390/Kconfig2
-rw-r--r--arch/s390/include/uapi/asm/unistd.h5
-rw-r--r--arch/s390/kernel/compat_wrapper.c3
-rw-r--r--arch/s390/kernel/ipl.c7
-rw-r--r--arch/s390/kernel/setup.c19
-rw-r--r--arch/s390/kernel/syscalls.S3
-rw-r--r--arch/sh/Kconfig2
-rw-r--r--arch/sh/mm/cache.c1
-rw-r--r--arch/tile/Kconfig2
-rw-r--r--arch/tile/kernel/smp.c1
-rw-r--r--arch/unicore32/kernel/signal.c9
-rw-r--r--arch/x86/Kbuild4
-rw-r--r--arch/x86/Kconfig18
-rw-r--r--arch/x86/Makefile6
-rw-r--r--arch/x86/include/asm/io_apic.h2
-rw-r--r--arch/x86/include/asm/pgtable.h9
-rw-r--r--arch/x86/kernel/Makefile2
-rw-r--r--arch/x86/kernel/apic/io_apic.c27
-rw-r--r--arch/x86/kernel/crash.c6
-rw-r--r--arch/x86/kernel/irqinit.c2
-rw-r--r--arch/x86/kernel/machine_kexec_64.c11
-rw-r--r--arch/x86/kernel/time.c2
-rw-r--r--arch/x86/pci/intel_mid_pci.c2
-rw-r--r--arch/x86/pci/irq.c2
-rw-r--r--arch/x86/purgatory/Makefile6
-rw-r--r--arch/xtensa/Kconfig92
-rw-r--r--arch/xtensa/Makefile7
-rw-r--r--arch/xtensa/boot/dts/kc705.dts5
-rw-r--r--arch/xtensa/configs/common_defconfig1
-rw-r--r--arch/xtensa/configs/iss_defconfig3
-rw-r--r--arch/xtensa/configs/s6105_defconfig1
-rw-r--r--arch/xtensa/include/asm/cacheflush.h2
-rw-r--r--arch/xtensa/include/asm/fixmap.h30
-rw-r--r--arch/xtensa/include/asm/highmem.h40
-rw-r--r--arch/xtensa/include/asm/page.h14
-rw-r--r--arch/xtensa/include/asm/pgtable.h7
-rw-r--r--arch/xtensa/include/asm/uaccess.h5
-rw-r--r--arch/xtensa/include/uapi/asm/ioctls.h19
-rw-r--r--arch/xtensa/include/uapi/asm/unistd.h5
-rw-r--r--arch/xtensa/kernel/align.S128
-rw-r--r--arch/xtensa/kernel/entry.S54
-rw-r--r--arch/xtensa/kernel/pci-dma.c12
-rw-r--r--arch/xtensa/kernel/smp.c1
-rw-r--r--arch/xtensa/kernel/traps.c5
-rw-r--r--arch/xtensa/kernel/vectors.S8
-rw-r--r--arch/xtensa/kernel/vmlinux.lds.S4
-rw-r--r--arch/xtensa/mm/cache.c77
-rw-r--r--arch/xtensa/mm/highmem.c41
-rw-r--r--arch/xtensa/mm/misc.S116
-rw-r--r--arch/xtensa/mm/mmu.c38
-rw-r--r--block/bio-integrity.c2
-rw-r--r--block/blk-core.c1
-rw-r--r--block/blk-mq.c36
-rw-r--r--block/cfq-iosched.c19
-rw-r--r--block/scsi_ioctl.c40
-rw-r--r--drivers/acpi/acpi_lpss.c17
-rw-r--r--drivers/acpi/ec.c21
-rw-r--r--drivers/acpi/pci_irq.c4
-rw-r--r--drivers/acpi/scan.c17
-rw-r--r--drivers/block/brd.c6
-rw-r--r--drivers/block/xsysace.c1
-rw-r--r--drivers/block/zram/zram_drv.c10
-rw-r--r--drivers/block/zram/zram_drv.h2
-rw-r--r--drivers/cpufreq/intel_pstate.c3
-rw-r--r--drivers/cpufreq/s5pv210-cpufreq.c2
-rw-r--r--drivers/cpuidle/cpuidle-big_little.c13
-rw-r--r--drivers/dma-buf/fence.c2
-rw-r--r--drivers/gpu/drm/ast/ast_tables.h1
-rw-r--r--drivers/gpu/drm/drm_crtc.c3
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c2
-rw-r--r--drivers/gpu/drm/msm/msm_drv.c3
-rw-r--r--drivers/gpu/drm/msm/msm_fbdev.c2
-rw-r--r--drivers/gpu/drm/msm/msm_iommu.c4
-rw-r--r--drivers/gpu/drm/radeon/cik.c26
-rw-r--r--drivers/gpu/drm/radeon/ni.c9
-rw-r--r--drivers/gpu/drm/radeon/r600.c26
-rw-r--r--drivers/gpu/drm/radeon/radeon.h2
-rw-r--r--drivers/gpu/drm/radeon/rv770.c23
-rw-r--r--drivers/gpu/drm/radeon/si.c21
-rw-r--r--drivers/gpu/drm/sti/Kconfig1
-rw-r--r--drivers/gpu/drm/sti/sti_drm_drv.c4
-rw-r--r--drivers/gpu/drm/sti/sti_hda.c10
-rw-r--r--drivers/gpu/drm/sti/sti_hdmi.c10
-rw-r--r--drivers/gpu/drm/sti/sti_tvout.c6
-rw-r--r--drivers/hid/hid-logitech-dj.c43
-rw-r--r--drivers/hid/hid-logitech-dj.h1
-rw-r--r--drivers/hid/hid-magicmouse.c10
-rw-r--r--drivers/hid/hid-picolcd_core.c6
-rw-r--r--drivers/md/dm-crypt.c25
-rw-r--r--drivers/mfd/ab8500-core.c2
-rw-r--r--drivers/mfd/htc-i2cpld.c2
-rw-r--r--drivers/mfd/omap-usb-host.c2
-rw-r--r--drivers/mfd/twl4030-power.c20
-rw-r--r--drivers/misc/mei/client.c1
-rw-r--r--drivers/misc/mei/nfc.c11
-rw-r--r--drivers/pinctrl/nomadik/pinctrl-abx500.c3
-rw-r--r--drivers/pinctrl/pinctrl-at91.c4
-rw-r--r--drivers/pinctrl/pinctrl-rockchip.c15
-rw-r--r--drivers/pinctrl/pinctrl-tegra-xusb.c5
-rw-r--r--drivers/pinctrl/samsung/pinctrl-exynos.c69
-rw-r--r--drivers/pinctrl/samsung/pinctrl-samsung.h1
-rw-r--r--drivers/pinctrl/sh-pfc/pfc-r8a7791.c8
-rw-r--r--drivers/rtc/rtc-s5m.c21
-rw-r--r--drivers/s390/char/con3215.c20
-rw-r--r--drivers/s390/char/sclp_tty.c2
-rw-r--r--drivers/scsi/scsi_lib.c1
-rw-r--r--drivers/spi/spi-au1550.c2
-rw-r--r--drivers/spi/spi-davinci.c16
-rw-r--r--drivers/spi/spi-dw-pci.c2
-rw-r--r--drivers/spi/spi-dw.c2
-rw-r--r--drivers/spi/spi-omap2-mcspi.c3
-rw-r--r--drivers/spi/spi-pxa2xx.c1
-rw-r--r--drivers/spi/spi-rockchip.c4
-rw-r--r--drivers/spi/spi-rspi.c94
-rw-r--r--drivers/spi/spi-sh-msiof.c71
-rw-r--r--drivers/spi/spi.c1
-rw-r--r--drivers/staging/Kconfig2
-rw-r--r--drivers/staging/Makefile1
-rw-r--r--drivers/staging/android/logger.c5
-rw-r--r--drivers/staging/et131x/et131x.c68
-rw-r--r--drivers/staging/lustre/lustre/libcfs/workitem.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/class_obd.c2
-rw-r--r--drivers/staging/rtl8188eu/os_dep/usb_intf.c2
-rw-r--r--drivers/thunderbolt/path.c21
-rw-r--r--drivers/usb/Kconfig2
-rw-r--r--drivers/usb/Makefile2
-rw-r--r--drivers/usb/core/hub.c16
-rw-r--r--drivers/usb/dwc2/gadget.c2
-rw-r--r--drivers/usb/dwc3/dwc3-omap.c2
-rw-r--r--drivers/usb/gadget/Makefile2
-rw-r--r--drivers/usb/gadget/function/Makefile4
-rw-r--r--drivers/usb/gadget/function/u_ether.c3
-rw-r--r--drivers/usb/gadget/function/uvc_video.c3
-rw-r--r--drivers/usb/gadget/legacy/Makefile6
-rw-r--r--drivers/usb/gadget/legacy/dbgp.c2
-rw-r--r--drivers/usb/gadget/legacy/inode.c2
-rw-r--r--drivers/usb/gadget/udc/Kconfig3
-rw-r--r--drivers/usb/gadget/udc/atmel_usba_udc.c2
-rw-r--r--drivers/usb/gadget/udc/fusb300_udc.c8
-rw-r--r--drivers/usb/gadget/udc/pch_udc.c22
-rw-r--r--drivers/usb/gadget/udc/r8a66597-udc.c4
-rw-r--r--drivers/usb/host/ehci-hub.c2
-rw-r--r--drivers/usb/host/xhci-pci.c9
-rw-r--r--drivers/usb/host/xhci-ring.c104
-rw-r--r--drivers/usb/host/xhci.c3
-rw-r--r--drivers/usb/misc/sisusbvga/sisusb.c1
-rw-r--r--drivers/usb/musb/ux500_dma.c2
-rw-r--r--drivers/usb/phy/phy-gpio-vbus-usb.c4
-rw-r--r--drivers/usb/phy/phy-msm-usb.c4
-rw-r--r--drivers/usb/phy/phy-samsung-usb.h2
-rw-r--r--drivers/usb/phy/phy.c3
-rw-r--r--drivers/usb/serial/ftdi_sio.c3
-rw-r--r--drivers/usb/serial/ftdi_sio_ids.h7
-rw-r--r--drivers/usb/serial/option.c31
-rw-r--r--drivers/usb/serial/pl2303.c1
-rw-r--r--drivers/usb/serial/pl2303.h1
-rw-r--r--drivers/usb/serial/usb-serial.c37
-rw-r--r--drivers/usb/serial/whiteheat.c7
-rw-r--r--drivers/usb/serial/zte_ev.c20
-rw-r--r--drivers/usb/storage/unusual_devs.h6
-rw-r--r--drivers/usb/usbip/Kconfig (renamed from drivers/staging/usbip/Kconfig)0
-rw-r--r--drivers/usb/usbip/Makefile (renamed from drivers/staging/usbip/Makefile)0
-rw-r--r--drivers/usb/usbip/README (renamed from drivers/staging/usbip/README)0
-rw-r--r--drivers/usb/usbip/stub.h (renamed from drivers/staging/usbip/stub.h)0
-rw-r--r--drivers/usb/usbip/stub_dev.c (renamed from drivers/staging/usbip/stub_dev.c)27
-rw-r--r--drivers/usb/usbip/stub_main.c (renamed from drivers/staging/usbip/stub_main.c)0
-rw-r--r--drivers/usb/usbip/stub_rx.c (renamed from drivers/staging/usbip/stub_rx.c)0
-rw-r--r--drivers/usb/usbip/stub_tx.c (renamed from drivers/staging/usbip/stub_tx.c)0
-rw-r--r--drivers/usb/usbip/usbip_common.c (renamed from drivers/staging/usbip/usbip_common.c)0
-rw-r--r--drivers/usb/usbip/usbip_common.h (renamed from drivers/staging/usbip/usbip_common.h)2
-rw-r--r--drivers/usb/usbip/usbip_event.c (renamed from drivers/staging/usbip/usbip_event.c)0
-rw-r--r--drivers/usb/usbip/usbip_protocol.txt (renamed from drivers/staging/usbip/usbip_protocol.txt)0
-rw-r--r--drivers/usb/usbip/vhci.h (renamed from drivers/staging/usbip/vhci.h)0
-rw-r--r--drivers/usb/usbip/vhci_hcd.c (renamed from drivers/staging/usbip/vhci_hcd.c)0
-rw-r--r--drivers/usb/usbip/vhci_rx.c (renamed from drivers/staging/usbip/vhci_rx.c)0
-rw-r--r--drivers/usb/usbip/vhci_sysfs.c (renamed from drivers/staging/usbip/vhci_sysfs.c)0
-rw-r--r--drivers/usb/usbip/vhci_tx.c (renamed from drivers/staging/usbip/vhci_tx.c)0
-rw-r--r--drivers/usb/wusbcore/wa-xfer.c3
-rw-r--r--drivers/video/backlight/pwm_bl.c1
-rw-r--r--drivers/video/fbdev/amba-clcd.c23
-rw-r--r--drivers/video/fbdev/atmel_lcdfb.c2
-rw-r--r--drivers/video/fbdev/chipsfb.c2
-rw-r--r--drivers/video/fbdev/da8xx-fb.c2
-rw-r--r--drivers/video/of_display_timing.c1
-rw-r--r--fs/btrfs/async-thread.c44
-rw-r--r--fs/btrfs/async-thread.h28
-rw-r--r--fs/btrfs/delayed-inode.c4
-rw-r--r--fs/btrfs/disk-io.c56
-rw-r--r--fs/btrfs/extent-tree.c23
-rw-r--r--fs/btrfs/extent_io.c5
-rw-r--r--fs/btrfs/file.c17
-rw-r--r--fs/btrfs/inode.c109
-rw-r--r--fs/btrfs/ioctl.c36
-rw-r--r--fs/btrfs/ordered-data.c1
-rw-r--r--fs/btrfs/qgroup.c3
-rw-r--r--fs/btrfs/raid56.c9
-rw-r--r--fs/btrfs/reada.c3
-rw-r--r--fs/btrfs/scrub.c25
-rw-r--r--fs/btrfs/sysfs.c2
-rw-r--r--fs/btrfs/tree-log.c17
-rw-r--r--fs/btrfs/volumes.c65
-rw-r--r--fs/ext4/ext4.h18
-rw-r--r--fs/ext4/extents.c88
-rw-r--r--fs/ext4/inode.c44
-rw-r--r--fs/ext4/mballoc.c5
-rw-r--r--fs/ext4/namei.c56
-rw-r--r--fs/ext4/super.c5
-rw-r--r--fs/jbd2/commit.c21
-rw-r--r--fs/jbd2/journal.c56
-rw-r--r--fs/jbd2/recovery.c33
-rw-r--r--fs/jbd2/revoke.c6
-rw-r--r--fs/locks.c2
-rw-r--r--fs/nfs/nfs3acl.c5
-rw-r--r--fs/nfs/nfs4proc.c26
-rw-r--r--fs/ocfs2/cluster/quorum.c13
-rw-r--r--fs/ocfs2/cluster/tcp.c45
-rw-r--r--fs/ocfs2/cluster/tcp.h1
-rw-r--r--fs/ocfs2/ioctl.c129
-rw-r--r--include/linux/blk-mq.h7
-rw-r--r--include/linux/jbd2.h30
-rw-r--r--include/linux/seqno-fence.h1
-rw-r--r--include/linux/spi/spi.h7
-rw-r--r--include/uapi/linux/usbip.h (renamed from drivers/staging/usbip/uapi/usbip.h)0
-rw-r--r--include/uapi/linux/xattr.h2
-rw-r--r--kernel/kexec.c11
-rw-r--r--kernel/resource.c11
-rw-r--r--kernel/trace/ring_buffer.c16
-rw-r--r--lib/Kconfig.debug11
-rw-r--r--mm/hugetlb_cgroup.c2
-rw-r--r--mm/memblock.c3
-rw-r--r--mm/memory.c7
-rw-r--r--mm/pgtable-generic.c2
-rw-r--r--mm/zbud.c1
-rw-r--r--mm/zpool.c2
-rw-r--r--mm/zsmalloc.c1
-rwxr-xr-xscripts/checkpatch.pl4
-rwxr-xr-xscripts/kernel-doc1
-rw-r--r--security/tomoyo/realpath.c5
-rw-r--r--sound/core/info.c4
-rw-r--r--sound/core/pcm_misc.c4
-rw-r--r--sound/pci/ctxfi/ct20k1reg.h4
-rw-r--r--sound/pci/hda/ca0132_regs.h2
-rw-r--r--sound/pci/hda/patch_realtek.c18
-rw-r--r--tools/testing/selftests/ipc/Makefile6
-rw-r--r--tools/testing/selftests/kcmp/Makefile6
-rw-r--r--tools/testing/selftests/memfd/Makefile10
-rw-r--r--tools/usb/usbip/.gitignore (renamed from drivers/staging/usbip/userspace/.gitignore)0
-rw-r--r--tools/usb/usbip/AUTHORS (renamed from drivers/staging/usbip/userspace/AUTHORS)0
-rw-r--r--tools/usb/usbip/COPYING (renamed from drivers/staging/usbip/userspace/COPYING)0
-rw-r--r--tools/usb/usbip/INSTALL (renamed from drivers/staging/usbip/userspace/INSTALL)0
-rw-r--r--tools/usb/usbip/Makefile.am (renamed from drivers/staging/usbip/userspace/Makefile.am)0
-rw-r--r--tools/usb/usbip/README (renamed from drivers/staging/usbip/userspace/README)0
-rwxr-xr-xtools/usb/usbip/autogen.sh (renamed from drivers/staging/usbip/userspace/autogen.sh)0
-rwxr-xr-xtools/usb/usbip/cleanup.sh (renamed from drivers/staging/usbip/userspace/cleanup.sh)0
-rw-r--r--tools/usb/usbip/configure.ac (renamed from drivers/staging/usbip/userspace/configure.ac)0
-rw-r--r--tools/usb/usbip/doc/usbip.8 (renamed from drivers/staging/usbip/userspace/doc/usbip.8)0
-rw-r--r--tools/usb/usbip/doc/usbipd.8 (renamed from drivers/staging/usbip/userspace/doc/usbipd.8)0
-rw-r--r--tools/usb/usbip/libsrc/Makefile.am (renamed from drivers/staging/usbip/userspace/libsrc/Makefile.am)0
-rw-r--r--tools/usb/usbip/libsrc/list.h (renamed from drivers/staging/usbip/userspace/libsrc/list.h)0
-rw-r--r--tools/usb/usbip/libsrc/names.c (renamed from drivers/staging/usbip/userspace/libsrc/names.c)0
-rw-r--r--tools/usb/usbip/libsrc/names.h (renamed from drivers/staging/usbip/userspace/libsrc/names.h)0
-rw-r--r--tools/usb/usbip/libsrc/sysfs_utils.c (renamed from drivers/staging/usbip/userspace/libsrc/sysfs_utils.c)0
-rw-r--r--tools/usb/usbip/libsrc/sysfs_utils.h (renamed from drivers/staging/usbip/userspace/libsrc/sysfs_utils.h)0
-rw-r--r--tools/usb/usbip/libsrc/usbip_common.c (renamed from drivers/staging/usbip/userspace/libsrc/usbip_common.c)0
-rw-r--r--tools/usb/usbip/libsrc/usbip_common.h (renamed from drivers/staging/usbip/userspace/libsrc/usbip_common.h)0
-rw-r--r--tools/usb/usbip/libsrc/usbip_host_driver.c (renamed from drivers/staging/usbip/userspace/libsrc/usbip_host_driver.c)0
-rw-r--r--tools/usb/usbip/libsrc/usbip_host_driver.h (renamed from drivers/staging/usbip/userspace/libsrc/usbip_host_driver.h)0
-rw-r--r--tools/usb/usbip/libsrc/vhci_driver.c (renamed from drivers/staging/usbip/userspace/libsrc/vhci_driver.c)0
-rw-r--r--tools/usb/usbip/libsrc/vhci_driver.h (renamed from drivers/staging/usbip/userspace/libsrc/vhci_driver.h)0
-rw-r--r--tools/usb/usbip/src/Makefile.am (renamed from drivers/staging/usbip/userspace/src/Makefile.am)0
-rw-r--r--tools/usb/usbip/src/usbip.c (renamed from drivers/staging/usbip/userspace/src/usbip.c)0
-rw-r--r--tools/usb/usbip/src/usbip.h (renamed from drivers/staging/usbip/userspace/src/usbip.h)0
-rw-r--r--tools/usb/usbip/src/usbip_attach.c (renamed from drivers/staging/usbip/userspace/src/usbip_attach.c)0
-rw-r--r--tools/usb/usbip/src/usbip_bind.c (renamed from drivers/staging/usbip/userspace/src/usbip_bind.c)0
-rw-r--r--tools/usb/usbip/src/usbip_detach.c (renamed from drivers/staging/usbip/userspace/src/usbip_detach.c)0
-rw-r--r--tools/usb/usbip/src/usbip_list.c (renamed from drivers/staging/usbip/userspace/src/usbip_list.c)0
-rw-r--r--tools/usb/usbip/src/usbip_network.c (renamed from drivers/staging/usbip/userspace/src/usbip_network.c)0
-rw-r--r--tools/usb/usbip/src/usbip_network.h (renamed from drivers/staging/usbip/userspace/src/usbip_network.h)0
-rw-r--r--tools/usb/usbip/src/usbip_port.c (renamed from drivers/staging/usbip/userspace/src/usbip_port.c)0
-rw-r--r--tools/usb/usbip/src/usbip_unbind.c (renamed from drivers/staging/usbip/userspace/src/usbip_unbind.c)0
-rw-r--r--tools/usb/usbip/src/usbipd.c (renamed from drivers/staging/usbip/userspace/src/usbipd.c)0
-rw-r--r--tools/usb/usbip/src/utils.c (renamed from drivers/staging/usbip/userspace/src/utils.c)0
-rw-r--r--tools/usb/usbip/src/utils.h (renamed from drivers/staging/usbip/userspace/src/utils.h)0
317 files changed, 2620 insertions, 1293 deletions
diff --git a/Documentation/devicetree/bindings/mfd/tc3589x.txt b/Documentation/devicetree/bindings/mfd/tc3589x.txt
new file mode 100644
index 000000000000..6fcedba46ae9
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/tc3589x.txt
@@ -0,0 +1,107 @@
1* Toshiba TC3589x multi-purpose expander
2
3The Toshiba TC3589x series are I2C-based MFD devices which may expose the
4following built-in devices: gpio, keypad, rotator (vibrator), PWM (for
5e.g. LEDs or vibrators) The included models are:
6
7- TC35890
8- TC35892
9- TC35893
10- TC35894
11- TC35895
12- TC35896
13
14Required properties:
15 - compatible : must be "toshiba,tc35890", "toshiba,tc35892", "toshiba,tc35893",
16 "toshiba,tc35894", "toshiba,tc35895" or "toshiba,tc35896"
17 - reg : I2C address of the device
18 - interrupt-parent : specifies which IRQ controller we're connected to
19 - interrupts : the interrupt on the parent the controller is connected to
20 - interrupt-controller : marks the device node as an interrupt controller
21 - #interrupt-cells : should be <1>, the first cell is the IRQ offset on this
22 TC3589x interrupt controller.
23
24Optional nodes:
25
26- GPIO
27 This GPIO module inside the TC3589x has 24 (TC35890, TC35892) or 20
28 (other models) GPIO lines.
29 - compatible : must be "toshiba,tc3589x-gpio"
30 - interrupts : interrupt on the parent, which must be the tc3589x MFD device
31 - interrupt-controller : marks the device node as an interrupt controller
32 - #interrupt-cells : should be <2>, the first cell is the IRQ offset on this
33 TC3589x GPIO interrupt controller, the second cell is the interrupt flags
34 in accordance with <dt-bindings/interrupt-controller/irq.h>. The following
35 flags are valid:
36 - IRQ_TYPE_LEVEL_LOW
37 - IRQ_TYPE_LEVEL_HIGH
38 - IRQ_TYPE_EDGE_RISING
39 - IRQ_TYPE_EDGE_FALLING
40 - IRQ_TYPE_EDGE_BOTH
41 - gpio-controller : marks the device node as a GPIO controller
42 - #gpio-cells : should be <2>, the first cell is the GPIO offset on this
43 GPIO controller, the second cell is the flags.
44
45- Keypad
46 This keypad is the same on all variants, supporting up to 96 different
47 keys. The linux-specific properties are modeled on those already existing
48 in other input drivers.
49 - compatible : must be "toshiba,tc3589x-keypad"
50 - debounce-delay-ms : debounce interval in milliseconds
51 - keypad,num-rows : number of rows in the matrix, see
52 bindings/input/matrix-keymap.txt
53 - keypad,num-columns : number of columns in the matrix, see
54 bindings/input/matrix-keymap.txt
55 - linux,keymap: the definition can be found in
56 bindings/input/matrix-keymap.txt
57 - linux,no-autorepeat: do no enable autorepeat feature.
58 - linux,wakeup: use any event on keypad as wakeup event.
59
60Example:
61
62tc35893@44 {
63 compatible = "toshiba,tc35893";
64 reg = <0x44>;
65 interrupt-parent = <&gpio6>;
66 interrupts = <26 IRQ_TYPE_EDGE_RISING>;
67
68 interrupt-controller;
69 #interrupt-cells = <1>;
70
71 tc3589x_gpio {
72 compatible = "toshiba,tc3589x-gpio";
73 interrupts = <0>;
74
75 interrupt-controller;
76 #interrupt-cells = <2>;
77 gpio-controller;
78 #gpio-cells = <2>;
79 };
80 tc3589x_keypad {
81 compatible = "toshiba,tc3589x-keypad";
82 interrupts = <6>;
83 debounce-delay-ms = <4>;
84 keypad,num-columns = <8>;
85 keypad,num-rows = <8>;
86 linux,no-autorepeat;
87 linux,wakeup;
88 linux,keymap = <0x0301006b
89 0x04010066
90 0x06040072
91 0x040200d7
92 0x0303006a
93 0x0205000e
94 0x0607008b
95 0x0500001c
96 0x0403000b
97 0x03040034
98 0x05020067
99 0x0305006c
100 0x040500e7
101 0x0005009e
102 0x06020073
103 0x01030039
104 0x07060069
105 0x050500d9>;
106 };
107};
diff --git a/Documentation/devicetree/bindings/pinctrl/qcom,apq8064-pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/qcom,apq8064-pinctrl.txt
index 0211c6d8a522..92fae82f35f2 100644
--- a/Documentation/devicetree/bindings/pinctrl/qcom,apq8064-pinctrl.txt
+++ b/Documentation/devicetree/bindings/pinctrl/qcom,apq8064-pinctrl.txt
@@ -62,7 +62,7 @@ Example:
62 #gpio-cells = <2>; 62 #gpio-cells = <2>;
63 interrupt-controller; 63 interrupt-controller;
64 #interrupt-cells = <2>; 64 #interrupt-cells = <2>;
65 interrupts = <0 32 0x4>; 65 interrupts = <0 16 0x4>;
66 66
67 pinctrl-names = "default"; 67 pinctrl-names = "default";
68 pinctrl-0 = <&gsbi5_uart_default>; 68 pinctrl-0 = <&gsbi5_uart_default>;
diff --git a/Documentation/dma-buf-sharing.txt b/Documentation/dma-buf-sharing.txt
index 67a4087d53f9..bb9753b635a3 100644
--- a/Documentation/dma-buf-sharing.txt
+++ b/Documentation/dma-buf-sharing.txt
@@ -56,10 +56,10 @@ The dma_buf buffer sharing API usage contains the following steps:
56 size_t size, int flags, 56 size_t size, int flags,
57 const char *exp_name) 57 const char *exp_name)
58 58
59 If this succeeds, dma_buf_export allocates a dma_buf structure, and returns a 59 If this succeeds, dma_buf_export_named allocates a dma_buf structure, and
60 pointer to the same. It also associates an anonymous file with this buffer, 60 returns a pointer to the same. It also associates an anonymous file with this
61 so it can be exported. On failure to allocate the dma_buf object, it returns 61 buffer, so it can be exported. On failure to allocate the dma_buf object,
62 NULL. 62 it returns NULL.
63 63
64 'exp_name' is the name of exporter - to facilitate information while 64 'exp_name' is the name of exporter - to facilitate information while
65 debugging. 65 debugging.
@@ -76,7 +76,7 @@ The dma_buf buffer sharing API usage contains the following steps:
76 drivers and/or processes. 76 drivers and/or processes.
77 77
78 Interface: 78 Interface:
79 int dma_buf_fd(struct dma_buf *dmabuf) 79 int dma_buf_fd(struct dma_buf *dmabuf, int flags)
80 80
81 This API installs an fd for the anonymous file associated with this buffer; 81 This API installs an fd for the anonymous file associated with this buffer;
82 returns either 'fd', or error. 82 returns either 'fd', or error.
@@ -157,7 +157,9 @@ to request use of buffer for allocation.
157 "dma_buf->ops->" indirection from the users of this interface. 157 "dma_buf->ops->" indirection from the users of this interface.
158 158
159 In struct dma_buf_ops, unmap_dma_buf is defined as 159 In struct dma_buf_ops, unmap_dma_buf is defined as
160 void (*unmap_dma_buf)(struct dma_buf_attachment *, struct sg_table *); 160 void (*unmap_dma_buf)(struct dma_buf_attachment *,
161 struct sg_table *,
162 enum dma_data_direction);
161 163
162 unmap_dma_buf signifies the end-of-DMA for the attachment provided. Like 164 unmap_dma_buf signifies the end-of-DMA for the attachment provided. Like
163 map_dma_buf, this API also must be implemented by the exporter. 165 map_dma_buf, this API also must be implemented by the exporter.
diff --git a/Documentation/kdump/kdump.txt b/Documentation/kdump/kdump.txt
index 88d5a863712a..6c0b9f27e465 100644
--- a/Documentation/kdump/kdump.txt
+++ b/Documentation/kdump/kdump.txt
@@ -18,7 +18,7 @@ memory image to a dump file on the local disk, or across the network to
18a remote system. 18a remote system.
19 19
20Kdump and kexec are currently supported on the x86, x86_64, ppc64, ia64, 20Kdump and kexec are currently supported on the x86, x86_64, ppc64, ia64,
21and s390x architectures. 21s390x and arm architectures.
22 22
23When the system kernel boots, it reserves a small section of memory for 23When the system kernel boots, it reserves a small section of memory for
24the dump-capture kernel. This ensures that ongoing Direct Memory Access 24the dump-capture kernel. This ensures that ongoing Direct Memory Access
@@ -112,7 +112,7 @@ There are two possible methods of using Kdump.
1122) Or use the system kernel binary itself as dump-capture kernel and there is 1122) Or use the system kernel binary itself as dump-capture kernel and there is
113 no need to build a separate dump-capture kernel. This is possible 113 no need to build a separate dump-capture kernel. This is possible
114 only with the architectures which support a relocatable kernel. As 114 only with the architectures which support a relocatable kernel. As
115 of today, i386, x86_64, ppc64 and ia64 architectures support relocatable 115 of today, i386, x86_64, ppc64, ia64 and arm architectures support relocatable
116 kernel. 116 kernel.
117 117
118Building a relocatable kernel is advantageous from the point of view that 118Building a relocatable kernel is advantageous from the point of view that
@@ -241,6 +241,13 @@ Dump-capture kernel config options (Arch Dependent, ia64)
241 kernel will be aligned to 64Mb, so if the start address is not then 241 kernel will be aligned to 64Mb, so if the start address is not then
242 any space below the alignment point will be wasted. 242 any space below the alignment point will be wasted.
243 243
244Dump-capture kernel config options (Arch Dependent, arm)
245----------------------------------------------------------
246
247- To use a relocatable kernel,
248 Enable "AUTO_ZRELADDR" support under "Boot" options:
249
250 AUTO_ZRELADDR=y
244 251
245Extended crashkernel syntax 252Extended crashkernel syntax
246=========================== 253===========================
@@ -256,6 +263,10 @@ The syntax is:
256 crashkernel=<range1>:<size1>[,<range2>:<size2>,...][@offset] 263 crashkernel=<range1>:<size1>[,<range2>:<size2>,...][@offset]
257 range=start-[end] 264 range=start-[end]
258 265
266Please note, on arm, the offset is required.
267 crashkernel=<range1>:<size1>[,<range2>:<size2>,...]@offset
268 range=start-[end]
269
259 'start' is inclusive and 'end' is exclusive. 270 'start' is inclusive and 'end' is exclusive.
260 271
261For example: 272For example:
@@ -296,6 +307,12 @@ Boot into System Kernel
296 on the memory consumption of the kdump system. In general this is not 307 on the memory consumption of the kdump system. In general this is not
297 dependent on the memory size of the production system. 308 dependent on the memory size of the production system.
298 309
310 On arm, use "crashkernel=Y@X". Note that the start address of the kernel
311 will be aligned to 128MiB (0x08000000), so if the start address is not then
312 any space below the alignment point may be overwritten by the dump-capture kernel,
313 which means it is possible that the vmcore is not that precise as expected.
314
315
299Load the Dump-capture Kernel 316Load the Dump-capture Kernel
300============================ 317============================
301 318
@@ -315,7 +332,8 @@ For ia64:
315 - Use vmlinux or vmlinuz.gz 332 - Use vmlinux or vmlinuz.gz
316For s390x: 333For s390x:
317 - Use image or bzImage 334 - Use image or bzImage
318 335For arm:
336 - Use zImage
319 337
320If you are using a uncompressed vmlinux image then use following command 338If you are using a uncompressed vmlinux image then use following command
321to load dump-capture kernel. 339to load dump-capture kernel.
@@ -331,6 +349,15 @@ to load dump-capture kernel.
331 --initrd=<initrd-for-dump-capture-kernel> \ 349 --initrd=<initrd-for-dump-capture-kernel> \
332 --append="root=<root-dev> <arch-specific-options>" 350 --append="root=<root-dev> <arch-specific-options>"
333 351
352If you are using a compressed zImage, then use following command
353to load dump-capture kernel.
354
355 kexec --type zImage -p <dump-capture-kernel-bzImage> \
356 --initrd=<initrd-for-dump-capture-kernel> \
357 --dtb=<dtb-for-dump-capture-kernel> \
358 --append="root=<root-dev> <arch-specific-options>"
359
360
334Please note, that --args-linux does not need to be specified for ia64. 361Please note, that --args-linux does not need to be specified for ia64.
335It is planned to make this a no-op on that architecture, but for now 362It is planned to make this a no-op on that architecture, but for now
336it should be omitted 363it should be omitted
@@ -347,6 +374,9 @@ For ppc64:
347For s390x: 374For s390x:
348 "1 maxcpus=1 cgroup_disable=memory" 375 "1 maxcpus=1 cgroup_disable=memory"
349 376
377For arm:
378 "1 maxcpus=1 reset_devices"
379
350Notes on loading the dump-capture kernel: 380Notes on loading the dump-capture kernel:
351 381
352* By default, the ELF headers are stored in ELF64 format to support 382* By default, the ELF headers are stored in ELF64 format to support
diff --git a/Documentation/this_cpu_ops.txt b/Documentation/this_cpu_ops.txt
index 1a4ce7e3e05f..0ec995712176 100644
--- a/Documentation/this_cpu_ops.txt
+++ b/Documentation/this_cpu_ops.txt
@@ -2,26 +2,26 @@ this_cpu operations
2------------------- 2-------------------
3 3
4this_cpu operations are a way of optimizing access to per cpu 4this_cpu operations are a way of optimizing access to per cpu
5variables associated with the *currently* executing processor through 5variables associated with the *currently* executing processor. This is
6the use of segment registers (or a dedicated register where the cpu 6done through the use of segment registers (or a dedicated register where
7permanently stored the beginning of the per cpu area for a specific 7the cpu permanently stored the beginning of the per cpu area for a
8processor). 8specific processor).
9 9
10The this_cpu operations add a per cpu variable offset to the processor 10this_cpu operations add a per cpu variable offset to the processor
11specific percpu base and encode that operation in the instruction 11specific per cpu base and encode that operation in the instruction
12operating on the per cpu variable. 12operating on the per cpu variable.
13 13
14This means there are no atomicity issues between the calculation of 14This means that there are no atomicity issues between the calculation of
15the offset and the operation on the data. Therefore it is not 15the offset and the operation on the data. Therefore it is not
16necessary to disable preempt or interrupts to ensure that the 16necessary to disable preemption or interrupts to ensure that the
17processor is not changed between the calculation of the address and 17processor is not changed between the calculation of the address and
18the operation on the data. 18the operation on the data.
19 19
20Read-modify-write operations are of particular interest. Frequently 20Read-modify-write operations are of particular interest. Frequently
21processors have special lower latency instructions that can operate 21processors have special lower latency instructions that can operate
22without the typical synchronization overhead but still provide some 22without the typical synchronization overhead, but still provide some
23sort of relaxed atomicity guarantee. The x86 for example can execute 23sort of relaxed atomicity guarantees. The x86, for example, can execute
24RMV (Read Modify Write) instructions like inc/dec/cmpxchg without the 24RMW (Read Modify Write) instructions like inc/dec/cmpxchg without the
25lock prefix and the associated latency penalty. 25lock prefix and the associated latency penalty.
26 26
27Access to the variable without the lock prefix is not synchronized but 27Access to the variable without the lock prefix is not synchronized but
@@ -30,6 +30,38 @@ data specific to the currently executing processor. Only the current
30processor should be accessing that variable and therefore there are no 30processor should be accessing that variable and therefore there are no
31concurrency issues with other processors in the system. 31concurrency issues with other processors in the system.
32 32
33Please note that accesses by remote processors to a per cpu area are
34exceptional situations and may impact performance and/or correctness
35(remote write operations) of local RMW operations via this_cpu_*.
36
37The main use of the this_cpu operations has been to optimize counter
38operations.
39
40The following this_cpu() operations with implied preemption protection
41are defined. These operations can be used without worrying about
42preemption and interrupts.
43
44 this_cpu_add()
45 this_cpu_read(pcp)
46 this_cpu_write(pcp, val)
47 this_cpu_add(pcp, val)
48 this_cpu_and(pcp, val)
49 this_cpu_or(pcp, val)
50 this_cpu_add_return(pcp, val)
51 this_cpu_xchg(pcp, nval)
52 this_cpu_cmpxchg(pcp, oval, nval)
53 this_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
54 this_cpu_sub(pcp, val)
55 this_cpu_inc(pcp)
56 this_cpu_dec(pcp)
57 this_cpu_sub_return(pcp, val)
58 this_cpu_inc_return(pcp)
59 this_cpu_dec_return(pcp)
60
61
62Inner working of this_cpu operations
63------------------------------------
64
33On x86 the fs: or the gs: segment registers contain the base of the 65On x86 the fs: or the gs: segment registers contain the base of the
34per cpu area. It is then possible to simply use the segment override 66per cpu area. It is then possible to simply use the segment override
35to relocate a per cpu relative address to the proper per cpu area for 67to relocate a per cpu relative address to the proper per cpu area for
@@ -48,22 +80,21 @@ results in a single instruction
48 mov ax, gs:[x] 80 mov ax, gs:[x]
49 81
50instead of a sequence of calculation of the address and then a fetch 82instead of a sequence of calculation of the address and then a fetch
51from that address which occurs with the percpu operations. Before 83from that address which occurs with the per cpu operations. Before
52this_cpu_ops such sequence also required preempt disable/enable to 84this_cpu_ops such sequence also required preempt disable/enable to
53prevent the kernel from moving the thread to a different processor 85prevent the kernel from moving the thread to a different processor
54while the calculation is performed. 86while the calculation is performed.
55 87
56The main use of the this_cpu operations has been to optimize counter 88Consider the following this_cpu operation:
57operations.
58 89
59 this_cpu_inc(x) 90 this_cpu_inc(x)
60 91
61results in the following single instruction (no lock prefix!) 92The above results in the following single instruction (no lock prefix!)
62 93
63 inc gs:[x] 94 inc gs:[x]
64 95
65instead of the following operations required if there is no segment 96instead of the following operations required if there is no segment
66register. 97register:
67 98
68 int *y; 99 int *y;
69 int cpu; 100 int cpu;
@@ -73,10 +104,10 @@ register.
73 (*y)++; 104 (*y)++;
74 put_cpu(); 105 put_cpu();
75 106
76Note that these operations can only be used on percpu data that is 107Note that these operations can only be used on per cpu data that is
77reserved for a specific processor. Without disabling preemption in the 108reserved for a specific processor. Without disabling preemption in the
78surrounding code this_cpu_inc() will only guarantee that one of the 109surrounding code this_cpu_inc() will only guarantee that one of the
79percpu counters is correctly incremented. However, there is no 110per cpu counters is correctly incremented. However, there is no
80guarantee that the OS will not move the process directly before or 111guarantee that the OS will not move the process directly before or
81after the this_cpu instruction is executed. In general this means that 112after the this_cpu instruction is executed. In general this means that
82the value of the individual counters for each processor are 113the value of the individual counters for each processor are
@@ -86,9 +117,9 @@ that is of interest.
86Per cpu variables are used for performance reasons. Bouncing cache 117Per cpu variables are used for performance reasons. Bouncing cache
87lines can be avoided if multiple processors concurrently go through 118lines can be avoided if multiple processors concurrently go through
88the same code paths. Since each processor has its own per cpu 119the same code paths. Since each processor has its own per cpu
89variables no concurrent cacheline updates take place. The price that 120variables no concurrent cache line updates take place. The price that
90has to be paid for this optimization is the need to add up the per cpu 121has to be paid for this optimization is the need to add up the per cpu
91counters when the value of the counter is needed. 122counters when the value of a counter is needed.
92 123
93 124
94Special operations: 125Special operations:
@@ -100,33 +131,39 @@ Takes the offset of a per cpu variable (&x !) and returns the address
100of the per cpu variable that belongs to the currently executing 131of the per cpu variable that belongs to the currently executing
101processor. this_cpu_ptr avoids multiple steps that the common 132processor. this_cpu_ptr avoids multiple steps that the common
102get_cpu/put_cpu sequence requires. No processor number is 133get_cpu/put_cpu sequence requires. No processor number is
103available. Instead the offset of the local per cpu area is simply 134available. Instead, the offset of the local per cpu area is simply
104added to the percpu offset. 135added to the per cpu offset.
105 136
137Note that this operation is usually used in a code segment when
138preemption has been disabled. The pointer is then used to
139access local per cpu data in a critical section. When preemption
140is re-enabled this pointer is usually no longer useful since it may
141no longer point to per cpu data of the current processor.
106 142
107 143
108Per cpu variables and offsets 144Per cpu variables and offsets
109----------------------------- 145-----------------------------
110 146
111Per cpu variables have *offsets* to the beginning of the percpu 147Per cpu variables have *offsets* to the beginning of the per cpu
112area. They do not have addresses although they look like that in the 148area. They do not have addresses although they look like that in the
113code. Offsets cannot be directly dereferenced. The offset must be 149code. Offsets cannot be directly dereferenced. The offset must be
114added to a base pointer of a percpu area of a processor in order to 150added to a base pointer of a per cpu area of a processor in order to
115form a valid address. 151form a valid address.
116 152
117Therefore the use of x or &x outside of the context of per cpu 153Therefore the use of x or &x outside of the context of per cpu
118operations is invalid and will generally be treated like a NULL 154operations is invalid and will generally be treated like a NULL
119pointer dereference. 155pointer dereference.
120 156
121In the context of per cpu operations 157 DEFINE_PER_CPU(int, x);
122 158
123 x is a per cpu variable. Most this_cpu operations take a cpu 159In the context of per cpu operations the above implies that x is a per
124 variable. 160cpu variable. Most this_cpu operations take a cpu variable.
125 161
126 &x is the *offset* a per cpu variable. this_cpu_ptr() takes 162 int __percpu *p = &x;
127 the offset of a per cpu variable which makes this look a bit
128 strange.
129 163
164&x and hence p is the *offset* of a per cpu variable. this_cpu_ptr()
165takes the offset of a per cpu variable which makes this look a bit
166strange.
130 167
131 168
132Operations on a field of a per cpu structure 169Operations on a field of a per cpu structure
@@ -152,7 +189,7 @@ If we have an offset to struct s:
152 189
153 struct s __percpu *ps = &p; 190 struct s __percpu *ps = &p;
154 191
155 z = this_cpu_dec(ps->m); 192 this_cpu_dec(ps->m);
156 193
157 z = this_cpu_inc_return(ps->n); 194 z = this_cpu_inc_return(ps->n);
158 195
@@ -172,29 +209,52 @@ if we do not make use of this_cpu ops later to manipulate fields:
172Variants of this_cpu ops 209Variants of this_cpu ops
173------------------------- 210-------------------------
174 211
175this_cpu ops are interrupt safe. Some architecture do not support 212this_cpu ops are interrupt safe. Some architectures do not support
176these per cpu local operations. In that case the operation must be 213these per cpu local operations. In that case the operation must be
177replaced by code that disables interrupts, then does the operations 214replaced by code that disables interrupts, then does the operations
178that are guaranteed to be atomic and then reenable interrupts. Doing 215that are guaranteed to be atomic and then re-enable interrupts. Doing
179so is expensive. If there are other reasons why the scheduler cannot 216so is expensive. If there are other reasons why the scheduler cannot
180change the processor we are executing on then there is no reason to 217change the processor we are executing on then there is no reason to
181disable interrupts. For that purpose the __this_cpu operations are 218disable interrupts. For that purpose the following __this_cpu operations
182provided. For example. 219are provided.
183 220
184 __this_cpu_inc(x); 221These operations have no guarantee against concurrent interrupts or
185 222preemption. If a per cpu variable is not used in an interrupt context
186Will increment x and will not fallback to code that disables 223and the scheduler cannot preempt, then they are safe. If any interrupts
224still occur while an operation is in progress and if the interrupt too
225modifies the variable, then RMW actions can not be guaranteed to be
226safe.
227
228 __this_cpu_add()
229 __this_cpu_read(pcp)
230 __this_cpu_write(pcp, val)
231 __this_cpu_add(pcp, val)
232 __this_cpu_and(pcp, val)
233 __this_cpu_or(pcp, val)
234 __this_cpu_add_return(pcp, val)
235 __this_cpu_xchg(pcp, nval)
236 __this_cpu_cmpxchg(pcp, oval, nval)
237 __this_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
238 __this_cpu_sub(pcp, val)
239 __this_cpu_inc(pcp)
240 __this_cpu_dec(pcp)
241 __this_cpu_sub_return(pcp, val)
242 __this_cpu_inc_return(pcp)
243 __this_cpu_dec_return(pcp)
244
245
246Will increment x and will not fall-back to code that disables
187interrupts on platforms that cannot accomplish atomicity through 247interrupts on platforms that cannot accomplish atomicity through
188address relocation and a Read-Modify-Write operation in the same 248address relocation and a Read-Modify-Write operation in the same
189instruction. 249instruction.
190 250
191 251
192
193&this_cpu_ptr(pp)->n vs this_cpu_ptr(&pp->n) 252&this_cpu_ptr(pp)->n vs this_cpu_ptr(&pp->n)
194-------------------------------------------- 253--------------------------------------------
195 254
196The first operation takes the offset and forms an address and then 255The first operation takes the offset and forms an address and then
197adds the offset of the n field. 256adds the offset of the n field. This may result in two add
257instructions emitted by the compiler.
198 258
199The second one first adds the two offsets and then does the 259The second one first adds the two offsets and then does the
200relocation. IMHO the second form looks cleaner and has an easier time 260relocation. IMHO the second form looks cleaner and has an easier time
@@ -202,4 +262,73 @@ with (). The second form also is consistent with the way
202this_cpu_read() and friends are used. 262this_cpu_read() and friends are used.
203 263
204 264
205Christoph Lameter, April 3rd, 2013 265Remote access to per cpu data
266------------------------------
267
268Per cpu data structures are designed to be used by one cpu exclusively.
269If you use the variables as intended, this_cpu_ops() are guaranteed to
270be "atomic" as no other CPU has access to these data structures.
271
272There are special cases where you might need to access per cpu data
273structures remotely. It is usually safe to do a remote read access
274and that is frequently done to summarize counters. Remote write access
275something which could be problematic because this_cpu ops do not
276have lock semantics. A remote write may interfere with a this_cpu
277RMW operation.
278
279Remote write accesses to percpu data structures are highly discouraged
280unless absolutely necessary. Please consider using an IPI to wake up
281the remote CPU and perform the update to its per cpu area.
282
283To access per-cpu data structure remotely, typically the per_cpu_ptr()
284function is used:
285
286
287 DEFINE_PER_CPU(struct data, datap);
288
289 struct data *p = per_cpu_ptr(&datap, cpu);
290
291This makes it explicit that we are getting ready to access a percpu
292area remotely.
293
294You can also do the following to convert the datap offset to an address
295
296 struct data *p = this_cpu_ptr(&datap);
297
298but, passing of pointers calculated via this_cpu_ptr to other cpus is
299unusual and should be avoided.
300
301Remote access are typically only for reading the status of another cpus
302per cpu data. Write accesses can cause unique problems due to the
303relaxed synchronization requirements for this_cpu operations.
304
305One example that illustrates some concerns with write operations is
306the following scenario that occurs because two per cpu variables
307share a cache-line but the relaxed synchronization is applied to
308only one process updating the cache-line.
309
310Consider the following example
311
312
313 struct test {
314 atomic_t a;
315 int b;
316 };
317
318 DEFINE_PER_CPU(struct test, onecacheline);
319
320There is some concern about what would happen if the field 'a' is updated
321remotely from one processor and the local processor would use this_cpu ops
322to update field b. Care should be taken that such simultaneous accesses to
323data within the same cache line are avoided. Also costly synchronization
324may be necessary. IPIs are generally recommended in such scenarios instead
325of a remote write to the per cpu area of another processor.
326
327Even in cases where the remote writes are rare, please bear in
328mind that a remote write will evict the cache line from the processor
329that most likely will access it. If the processor wakes up and finds a
330missing local cache line of a per cpu area, its performance and hence
331the wake up times will be affected.
332
333Christoph Lameter, August 4th, 2014
334Pranith Kumar, Aug 2nd, 2014
diff --git a/MAINTAINERS b/MAINTAINERS
index 93e9f730f406..cf24bb56bab9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9562,6 +9562,14 @@ S: Maintained
9562F: Documentation/usb/ohci.txt 9562F: Documentation/usb/ohci.txt
9563F: drivers/usb/host/ohci* 9563F: drivers/usb/host/ohci*
9564 9564
9565USB OVER IP DRIVER
9566M: Valentina Manea <valentina.manea.m@gmail.com>
9567M: Shuah Khan <shuah.kh@samsung.com>
9568L: linux-usb@vger.kernel.org
9569S: Maintained
9570F: drivers/usb/usbip/
9571F: tools/usb/usbip/
9572
9565USB PEGASUS DRIVER 9573USB PEGASUS DRIVER
9566M: Petko Manolov <petkan@nucleusys.com> 9574M: Petko Manolov <petkan@nucleusys.com>
9567L: linux-usb@vger.kernel.org 9575L: linux-usb@vger.kernel.org
diff --git a/Makefile b/Makefile
index f64fc7804a03..2893d7f0fecc 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 3 1VERSION = 3
2PATCHLEVEL = 17 2PATCHLEVEL = 17
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc2 4EXTRAVERSION = -rc3
5NAME = Shuffling Zombie Juror 5NAME = Shuffling Zombie Juror
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/alpha/include/asm/io.h b/arch/alpha/include/asm/io.h
index 5ebab5895edb..f05bdb4b1cb9 100644
--- a/arch/alpha/include/asm/io.h
+++ b/arch/alpha/include/asm/io.h
@@ -500,10 +500,14 @@ extern inline void writeq(u64 b, volatile void __iomem *addr)
500#define outb_p outb 500#define outb_p outb
501#define outw_p outw 501#define outw_p outw
502#define outl_p outl 502#define outl_p outl
503#define readb_relaxed(addr) __raw_readb(addr) 503#define readb_relaxed(addr) __raw_readb(addr)
504#define readw_relaxed(addr) __raw_readw(addr) 504#define readw_relaxed(addr) __raw_readw(addr)
505#define readl_relaxed(addr) __raw_readl(addr) 505#define readl_relaxed(addr) __raw_readl(addr)
506#define readq_relaxed(addr) __raw_readq(addr) 506#define readq_relaxed(addr) __raw_readq(addr)
507#define writeb_relaxed(b, addr) __raw_writeb(b, addr)
508#define writew_relaxed(b, addr) __raw_writew(b, addr)
509#define writel_relaxed(b, addr) __raw_writel(b, addr)
510#define writeq_relaxed(b, addr) __raw_writeq(b, addr)
507 511
508#define mmiowb() 512#define mmiowb()
509 513
diff --git a/arch/alpha/include/asm/unistd.h b/arch/alpha/include/asm/unistd.h
index f2c94402e2c8..c509d306db45 100644
--- a/arch/alpha/include/asm/unistd.h
+++ b/arch/alpha/include/asm/unistd.h
@@ -3,7 +3,7 @@
3 3
4#include <uapi/asm/unistd.h> 4#include <uapi/asm/unistd.h>
5 5
6#define NR_SYSCALLS 508 6#define NR_SYSCALLS 511
7 7
8#define __ARCH_WANT_OLD_READDIR 8#define __ARCH_WANT_OLD_READDIR
9#define __ARCH_WANT_STAT64 9#define __ARCH_WANT_STAT64
diff --git a/arch/alpha/include/uapi/asm/unistd.h b/arch/alpha/include/uapi/asm/unistd.h
index 53ae7bb1bfd1..d214a0358100 100644
--- a/arch/alpha/include/uapi/asm/unistd.h
+++ b/arch/alpha/include/uapi/asm/unistd.h
@@ -469,5 +469,8 @@
469#define __NR_process_vm_writev 505 469#define __NR_process_vm_writev 505
470#define __NR_kcmp 506 470#define __NR_kcmp 506
471#define __NR_finit_module 507 471#define __NR_finit_module 507
472#define __NR_sched_setattr 508
473#define __NR_sched_getattr 509
474#define __NR_renameat2 510
472 475
473#endif /* _UAPI_ALPHA_UNISTD_H */ 476#endif /* _UAPI_ALPHA_UNISTD_H */
diff --git a/arch/alpha/kernel/systbls.S b/arch/alpha/kernel/systbls.S
index dca9b3fb0071..24789713f1ea 100644
--- a/arch/alpha/kernel/systbls.S
+++ b/arch/alpha/kernel/systbls.S
@@ -526,6 +526,9 @@ sys_call_table:
526 .quad sys_process_vm_writev /* 505 */ 526 .quad sys_process_vm_writev /* 505 */
527 .quad sys_kcmp 527 .quad sys_kcmp
528 .quad sys_finit_module 528 .quad sys_finit_module
529 .quad sys_sched_setattr
530 .quad sys_sched_getattr
531 .quad sys_renameat2 /* 510 */
529 532
530 .size sys_call_table, . - sys_call_table 533 .size sys_call_table, . - sys_call_table
531 .type sys_call_table, @object 534 .type sys_call_table, @object
diff --git a/arch/arc/mm/cache_arc700.c b/arch/arc/mm/cache_arc700.c
index 4670afc3b971..e88ddbf990e3 100644
--- a/arch/arc/mm/cache_arc700.c
+++ b/arch/arc/mm/cache_arc700.c
@@ -581,6 +581,7 @@ void flush_icache_range(unsigned long kstart, unsigned long kend)
581 tot_sz -= sz; 581 tot_sz -= sz;
582 } 582 }
583} 583}
584EXPORT_SYMBOL(flush_icache_range);
584 585
585/* 586/*
586 * General purpose helper to make I and D cache lines consistent. 587 * General purpose helper to make I and D cache lines consistent.
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index c49a775937db..32cbbd565902 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1983,8 +1983,6 @@ config XIP_PHYS_ADDR
1983config KEXEC 1983config KEXEC
1984 bool "Kexec system call (EXPERIMENTAL)" 1984 bool "Kexec system call (EXPERIMENTAL)"
1985 depends on (!SMP || PM_SLEEP_SMP) 1985 depends on (!SMP || PM_SLEEP_SMP)
1986 select CRYPTO
1987 select CRYPTO_SHA256
1988 help 1986 help
1989 kexec is a system call that implements the ability to shutdown your 1987 kexec is a system call that implements the ability to shutdown your
1990 current kernel, and to start another kernel. It is like a reboot 1988 current kernel, and to start another kernel. It is like a reboot
diff --git a/arch/arm/boot/dts/am4372.dtsi b/arch/arm/boot/dts/am4372.dtsi
index 9b3d2ba82f13..8689949bdba3 100644
--- a/arch/arm/boot/dts/am4372.dtsi
+++ b/arch/arm/boot/dts/am4372.dtsi
@@ -804,7 +804,7 @@
804 804
805 usb1: usb@48390000 { 805 usb1: usb@48390000 {
806 compatible = "synopsys,dwc3"; 806 compatible = "synopsys,dwc3";
807 reg = <0x48390000 0x17000>; 807 reg = <0x48390000 0x10000>;
808 interrupts = <GIC_SPI 168 IRQ_TYPE_LEVEL_HIGH>; 808 interrupts = <GIC_SPI 168 IRQ_TYPE_LEVEL_HIGH>;
809 phys = <&usb2_phy1>; 809 phys = <&usb2_phy1>;
810 phy-names = "usb2-phy"; 810 phy-names = "usb2-phy";
@@ -826,7 +826,7 @@
826 826
827 usb2: usb@483d0000 { 827 usb2: usb@483d0000 {
828 compatible = "synopsys,dwc3"; 828 compatible = "synopsys,dwc3";
829 reg = <0x483d0000 0x17000>; 829 reg = <0x483d0000 0x10000>;
830 interrupts = <GIC_SPI 174 IRQ_TYPE_LEVEL_HIGH>; 830 interrupts = <GIC_SPI 174 IRQ_TYPE_LEVEL_HIGH>;
831 phys = <&usb2_phy2>; 831 phys = <&usb2_phy2>;
832 phy-names = "usb2-phy"; 832 phy-names = "usb2-phy";
diff --git a/arch/arm/boot/dts/am437x-gp-evm.dts b/arch/arm/boot/dts/am437x-gp-evm.dts
index 646a6eade788..e7ac47fa6615 100644
--- a/arch/arm/boot/dts/am437x-gp-evm.dts
+++ b/arch/arm/boot/dts/am437x-gp-evm.dts
@@ -260,7 +260,7 @@
260 status = "okay"; 260 status = "okay";
261 pinctrl-names = "default"; 261 pinctrl-names = "default";
262 pinctrl-0 = <&i2c0_pins>; 262 pinctrl-0 = <&i2c0_pins>;
263 clock-frequency = <400000>; 263 clock-frequency = <100000>;
264 264
265 tps65218: tps65218@24 { 265 tps65218: tps65218@24 {
266 reg = <0x24>; 266 reg = <0x24>;
@@ -424,7 +424,7 @@
424 ranges = <0 0 0 0x01000000>; /* minimum GPMC partition = 16MB */ 424 ranges = <0 0 0 0x01000000>; /* minimum GPMC partition = 16MB */
425 nand@0,0 { 425 nand@0,0 {
426 reg = <0 0 4>; /* device IO registers */ 426 reg = <0 0 4>; /* device IO registers */
427 ti,nand-ecc-opt = "bch8"; 427 ti,nand-ecc-opt = "bch16";
428 ti,elm-id = <&elm>; 428 ti,elm-id = <&elm>;
429 nand-bus-width = <8>; 429 nand-bus-width = <8>;
430 gpmc,device-width = <1>; 430 gpmc,device-width = <1>;
@@ -443,8 +443,6 @@
443 gpmc,rd-cycle-ns = <40>; 443 gpmc,rd-cycle-ns = <40>;
444 gpmc,wr-cycle-ns = <40>; 444 gpmc,wr-cycle-ns = <40>;
445 gpmc,wait-pin = <0>; 445 gpmc,wait-pin = <0>;
446 gpmc,wait-on-read;
447 gpmc,wait-on-write;
448 gpmc,bus-turnaround-ns = <0>; 446 gpmc,bus-turnaround-ns = <0>;
449 gpmc,cycle2cycle-delay-ns = <0>; 447 gpmc,cycle2cycle-delay-ns = <0>;
450 gpmc,clk-activation-ns = <0>; 448 gpmc,clk-activation-ns = <0>;
diff --git a/arch/arm/boot/dts/am43x-epos-evm.dts b/arch/arm/boot/dts/am43x-epos-evm.dts
index ed7dd2395915..ac3e4859935f 100644
--- a/arch/arm/boot/dts/am43x-epos-evm.dts
+++ b/arch/arm/boot/dts/am43x-epos-evm.dts
@@ -435,13 +435,13 @@
435}; 435};
436 436
437&gpmc { 437&gpmc {
438 status = "okay"; 438 status = "okay"; /* Disable QSPI when enabling GPMC (NAND) */
439 pinctrl-names = "default"; 439 pinctrl-names = "default";
440 pinctrl-0 = <&nand_flash_x8>; 440 pinctrl-0 = <&nand_flash_x8>;
441 ranges = <0 0 0x08000000 0x10000000>; /* CS0: NAND */ 441 ranges = <0 0 0x08000000 0x10000000>; /* CS0: NAND */
442 nand@0,0 { 442 nand@0,0 {
443 reg = <0 0 0>; /* CS0, offset 0 */ 443 reg = <0 0 0>; /* CS0, offset 0 */
444 ti,nand-ecc-opt = "bch8"; 444 ti,nand-ecc-opt = "bch16";
445 ti,elm-id = <&elm>; 445 ti,elm-id = <&elm>;
446 nand-bus-width = <8>; 446 nand-bus-width = <8>;
447 gpmc,device-width = <1>; 447 gpmc,device-width = <1>;
@@ -459,8 +459,7 @@
459 gpmc,access-ns = <30>; /* tCEA + 4*/ 459 gpmc,access-ns = <30>; /* tCEA + 4*/
460 gpmc,rd-cycle-ns = <40>; 460 gpmc,rd-cycle-ns = <40>;
461 gpmc,wr-cycle-ns = <40>; 461 gpmc,wr-cycle-ns = <40>;
462 gpmc,wait-on-read = "true"; 462 gpmc,wait-pin = <0>;
463 gpmc,wait-on-write = "true";
464 gpmc,bus-turnaround-ns = <0>; 463 gpmc,bus-turnaround-ns = <0>;
465 gpmc,cycle2cycle-delay-ns = <0>; 464 gpmc,cycle2cycle-delay-ns = <0>;
466 gpmc,clk-activation-ns = <0>; 465 gpmc,clk-activation-ns = <0>;
@@ -557,7 +556,7 @@
557}; 556};
558 557
559&qspi { 558&qspi {
560 status = "okay"; 559 status = "disabled"; /* Disable GPMC (NAND) when enabling QSPI */
561 pinctrl-names = "default"; 560 pinctrl-names = "default";
562 pinctrl-0 = <&qspi1_default>; 561 pinctrl-0 = <&qspi1_default>;
563 562
diff --git a/arch/arm/boot/dts/dra7-evm.dts b/arch/arm/boot/dts/dra7-evm.dts
index 50f8022905a1..e03fbf3c6889 100644
--- a/arch/arm/boot/dts/dra7-evm.dts
+++ b/arch/arm/boot/dts/dra7-evm.dts
@@ -8,6 +8,7 @@
8/dts-v1/; 8/dts-v1/;
9 9
10#include "dra74x.dtsi" 10#include "dra74x.dtsi"
11#include <dt-bindings/gpio/gpio.h>
11 12
12/ { 13/ {
13 model = "TI DRA742"; 14 model = "TI DRA742";
@@ -24,9 +25,29 @@
24 regulator-min-microvolt = <3300000>; 25 regulator-min-microvolt = <3300000>;
25 regulator-max-microvolt = <3300000>; 26 regulator-max-microvolt = <3300000>;
26 }; 27 };
28
29 vtt_fixed: fixedregulator-vtt {
30 compatible = "regulator-fixed";
31 regulator-name = "vtt_fixed";
32 regulator-min-microvolt = <1350000>;
33 regulator-max-microvolt = <1350000>;
34 regulator-always-on;
35 regulator-boot-on;
36 enable-active-high;
37 gpio = <&gpio7 11 GPIO_ACTIVE_HIGH>;
38 };
27}; 39};
28 40
29&dra7_pmx_core { 41&dra7_pmx_core {
42 pinctrl-names = "default";
43 pinctrl-0 = <&vtt_pin>;
44
45 vtt_pin: pinmux_vtt_pin {
46 pinctrl-single,pins = <
47 0x3b4 (PIN_OUTPUT | MUX_MODE14) /* spi1_cs1.gpio7_11 */
48 >;
49 };
50
30 i2c1_pins: pinmux_i2c1_pins { 51 i2c1_pins: pinmux_i2c1_pins {
31 pinctrl-single,pins = < 52 pinctrl-single,pins = <
32 0x400 (PIN_INPUT | MUX_MODE0) /* i2c1_sda */ 53 0x400 (PIN_INPUT | MUX_MODE0) /* i2c1_sda */
@@ -43,20 +64,19 @@
43 64
44 i2c3_pins: pinmux_i2c3_pins { 65 i2c3_pins: pinmux_i2c3_pins {
45 pinctrl-single,pins = < 66 pinctrl-single,pins = <
46 0x410 (PIN_INPUT | MUX_MODE0) /* i2c3_sda */ 67 0x288 (PIN_INPUT | MUX_MODE9) /* gpio6_14.i2c3_sda */
47 0x414 (PIN_INPUT | MUX_MODE0) /* i2c3_scl */ 68 0x28c (PIN_INPUT | MUX_MODE9) /* gpio6_15.i2c3_scl */
48 >; 69 >;
49 }; 70 };
50 71
51 mcspi1_pins: pinmux_mcspi1_pins { 72 mcspi1_pins: pinmux_mcspi1_pins {
52 pinctrl-single,pins = < 73 pinctrl-single,pins = <
53 0x3a4 (PIN_INPUT | MUX_MODE0) /* spi2_clk */ 74 0x3a4 (PIN_INPUT | MUX_MODE0) /* spi1_sclk */
54 0x3a8 (PIN_INPUT | MUX_MODE0) /* spi2_d1 */ 75 0x3a8 (PIN_INPUT | MUX_MODE0) /* spi1_d1 */
55 0x3ac (PIN_INPUT | MUX_MODE0) /* spi2_d0 */ 76 0x3ac (PIN_INPUT | MUX_MODE0) /* spi1_d0 */
56 0x3b0 (PIN_INPUT_SLEW | MUX_MODE0) /* spi2_cs0 */ 77 0x3b0 (PIN_INPUT_SLEW | MUX_MODE0) /* spi1_cs0 */
57 0x3b4 (PIN_INPUT_SLEW | MUX_MODE0) /* spi2_cs1 */ 78 0x3b8 (PIN_INPUT_SLEW | MUX_MODE6) /* spi1_cs2.hdmi1_hpd */
58 0x3b8 (PIN_INPUT_SLEW | MUX_MODE6) /* spi2_cs2 */ 79 0x3bc (PIN_INPUT_SLEW | MUX_MODE6) /* spi1_cs3.hdmi1_cec */
59 0x3bc (PIN_INPUT_SLEW | MUX_MODE6) /* spi2_cs3 */
60 >; 80 >;
61 }; 81 };
62 82
@@ -284,7 +304,7 @@
284 status = "okay"; 304 status = "okay";
285 pinctrl-names = "default"; 305 pinctrl-names = "default";
286 pinctrl-0 = <&i2c3_pins>; 306 pinctrl-0 = <&i2c3_pins>;
287 clock-frequency = <3400000>; 307 clock-frequency = <400000>;
288}; 308};
289 309
290&mcspi1 { 310&mcspi1 {
@@ -483,7 +503,7 @@
483 reg = <0x001c0000 0x00020000>; 503 reg = <0x001c0000 0x00020000>;
484 }; 504 };
485 partition@7 { 505 partition@7 {
486 label = "NAND.u-boot-env"; 506 label = "NAND.u-boot-env.backup1";
487 reg = <0x001e0000 0x00020000>; 507 reg = <0x001e0000 0x00020000>;
488 }; 508 };
489 partition@8 { 509 partition@8 {
@@ -504,3 +524,8 @@
504&usb2_phy2 { 524&usb2_phy2 {
505 phy-supply = <&ldousb_reg>; 525 phy-supply = <&ldousb_reg>;
506}; 526};
527
528&gpio7 {
529 ti,no-reset-on-init;
530 ti,no-idle-on-init;
531};
diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts
index b15f1a77d684..1fe45d1f75ec 100644
--- a/arch/arm/boot/dts/omap3-n900.dts
+++ b/arch/arm/boot/dts/omap3-n900.dts
@@ -353,7 +353,7 @@
353 }; 353 };
354 354
355 twl_power: power { 355 twl_power: power {
356 compatible = "ti,twl4030-power-n900"; 356 compatible = "ti,twl4030-power-n900", "ti,twl4030-power-idle-osc-off";
357 ti,use_poweroff; 357 ti,use_poweroff;
358 }; 358 };
359}; 359};
diff --git a/arch/arm/boot/dts/omap3xxx-clocks.dtsi b/arch/arm/boot/dts/omap3xxx-clocks.dtsi
index e47ff69dcf70..5c375003bad1 100644
--- a/arch/arm/boot/dts/omap3xxx-clocks.dtsi
+++ b/arch/arm/boot/dts/omap3xxx-clocks.dtsi
@@ -467,6 +467,7 @@
467 ti,bit-shift = <0x1e>; 467 ti,bit-shift = <0x1e>;
468 reg = <0x0d00>; 468 reg = <0x0d00>;
469 ti,set-bit-to-disable; 469 ti,set-bit-to-disable;
470 ti,set-rate-parent;
470 }; 471 };
471 472
472 dpll4_m6_ck: dpll4_m6_ck { 473 dpll4_m6_ck: dpll4_m6_ck {
diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
index fd43f7f55b70..79ecb4f34ffb 100644
--- a/arch/arm/include/asm/cacheflush.h
+++ b/arch/arm/include/asm/cacheflush.h
@@ -472,7 +472,6 @@ static inline void __sync_cache_range_r(volatile void *p, size_t size)
472 "mcr p15, 0, r0, c1, c0, 0 @ set SCTLR \n\t" \ 472 "mcr p15, 0, r0, c1, c0, 0 @ set SCTLR \n\t" \
473 "isb \n\t" \ 473 "isb \n\t" \
474 "bl v7_flush_dcache_"__stringify(level)" \n\t" \ 474 "bl v7_flush_dcache_"__stringify(level)" \n\t" \
475 "clrex \n\t" \
476 "mrc p15, 0, r0, c1, c0, 1 @ get ACTLR \n\t" \ 475 "mrc p15, 0, r0, c1, c0, 1 @ get ACTLR \n\t" \
477 "bic r0, r0, #(1 << 6) @ disable local coherency \n\t" \ 476 "bic r0, r0, #(1 << 6) @ disable local coherency \n\t" \
478 "mcr p15, 0, r0, c1, c0, 1 @ set ACTLR \n\t" \ 477 "mcr p15, 0, r0, c1, c0, 1 @ set ACTLR \n\t" \
diff --git a/arch/arm/include/asm/cputype.h b/arch/arm/include/asm/cputype.h
index 963a2515906d..819777d0e91f 100644
--- a/arch/arm/include/asm/cputype.h
+++ b/arch/arm/include/asm/cputype.h
@@ -74,6 +74,7 @@
74#define ARM_CPU_PART_CORTEX_A12 0x4100c0d0 74#define ARM_CPU_PART_CORTEX_A12 0x4100c0d0
75#define ARM_CPU_PART_CORTEX_A17 0x4100c0e0 75#define ARM_CPU_PART_CORTEX_A17 0x4100c0e0
76#define ARM_CPU_PART_CORTEX_A15 0x4100c0f0 76#define ARM_CPU_PART_CORTEX_A15 0x4100c0f0
77#define ARM_CPU_PART_MASK 0xff00fff0
77 78
78#define ARM_CPU_XSCALE_ARCH_MASK 0xe000 79#define ARM_CPU_XSCALE_ARCH_MASK 0xe000
79#define ARM_CPU_XSCALE_ARCH_V1 0x2000 80#define ARM_CPU_XSCALE_ARCH_V1 0x2000
@@ -179,7 +180,7 @@ static inline unsigned int __attribute_const__ read_cpuid_implementor(void)
179 */ 180 */
180static inline unsigned int __attribute_const__ read_cpuid_part(void) 181static inline unsigned int __attribute_const__ read_cpuid_part(void)
181{ 182{
182 return read_cpuid_id() & 0xff00fff0; 183 return read_cpuid_id() & ARM_CPU_PART_MASK;
183} 184}
184 185
185static inline unsigned int __attribute_const__ __deprecated read_cpuid_part_number(void) 186static inline unsigned int __attribute_const__ __deprecated read_cpuid_part_number(void)
diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
index f4b46d39b9cf..afb9cafd3786 100644
--- a/arch/arm/include/asm/elf.h
+++ b/arch/arm/include/asm/elf.h
@@ -50,6 +50,7 @@ typedef struct user_fp elf_fpregset_t;
50#define R_ARM_ABS32 2 50#define R_ARM_ABS32 2
51#define R_ARM_CALL 28 51#define R_ARM_CALL 28
52#define R_ARM_JUMP24 29 52#define R_ARM_JUMP24 29
53#define R_ARM_TARGET1 38
53#define R_ARM_V4BX 40 54#define R_ARM_V4BX 40
54#define R_ARM_PREL31 42 55#define R_ARM_PREL31 42
55#define R_ARM_MOVW_ABS_NC 43 56#define R_ARM_MOVW_ABS_NC 43
diff --git a/arch/arm/include/asm/smp_plat.h b/arch/arm/include/asm/smp_plat.h
index a252c0bfacf5..0ad7d490ee6f 100644
--- a/arch/arm/include/asm/smp_plat.h
+++ b/arch/arm/include/asm/smp_plat.h
@@ -8,6 +8,7 @@
8#include <linux/cpumask.h> 8#include <linux/cpumask.h>
9#include <linux/err.h> 9#include <linux/err.h>
10 10
11#include <asm/cpu.h>
11#include <asm/cputype.h> 12#include <asm/cputype.h>
12 13
13/* 14/*
@@ -25,6 +26,20 @@ static inline bool is_smp(void)
25#endif 26#endif
26} 27}
27 28
29/**
30 * smp_cpuid_part() - return part id for a given cpu
31 * @cpu: logical cpu id.
32 *
33 * Return: part id of logical cpu passed as argument.
34 */
35static inline unsigned int smp_cpuid_part(int cpu)
36{
37 struct cpuinfo_arm *cpu_info = &per_cpu(cpu_data, cpu);
38
39 return is_smp() ? cpu_info->cpuid & ARM_CPU_PART_MASK :
40 read_cpuid_part();
41}
42
28/* all SMP configurations have the extended CPUID registers */ 43/* all SMP configurations have the extended CPUID registers */
29#ifndef CONFIG_MMU 44#ifndef CONFIG_MMU
30#define tlb_ops_need_broadcast() 0 45#define tlb_ops_need_broadcast() 0
diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
index 8db307d0954b..2fdf8679b46e 100644
--- a/arch/arm/kernel/entry-header.S
+++ b/arch/arm/kernel/entry-header.S
@@ -208,26 +208,21 @@
208#endif 208#endif
209 .endif 209 .endif
210 msr spsr_cxsf, \rpsr 210 msr spsr_cxsf, \rpsr
211#if defined(CONFIG_CPU_V6) 211#if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_32v6K)
212 ldr r0, [sp] 212 @ We must avoid clrex due to Cortex-A15 erratum #830321
213 strex r1, r2, [sp] @ clear the exclusive monitor 213 sub r0, sp, #4 @ uninhabited address
214 ldmib sp, {r1 - pc}^ @ load r1 - pc, cpsr 214 strex r1, r2, [r0] @ clear the exclusive monitor
215#elif defined(CONFIG_CPU_32v6K)
216 clrex @ clear the exclusive monitor
217 ldmia sp, {r0 - pc}^ @ load r0 - pc, cpsr
218#else
219 ldmia sp, {r0 - pc}^ @ load r0 - pc, cpsr
220#endif 215#endif
216 ldmia sp, {r0 - pc}^ @ load r0 - pc, cpsr
221 .endm 217 .endm
222 218
223 .macro restore_user_regs, fast = 0, offset = 0 219 .macro restore_user_regs, fast = 0, offset = 0
224 ldr r1, [sp, #\offset + S_PSR] @ get calling cpsr 220 ldr r1, [sp, #\offset + S_PSR] @ get calling cpsr
225 ldr lr, [sp, #\offset + S_PC]! @ get pc 221 ldr lr, [sp, #\offset + S_PC]! @ get pc
226 msr spsr_cxsf, r1 @ save in spsr_svc 222 msr spsr_cxsf, r1 @ save in spsr_svc
227#if defined(CONFIG_CPU_V6) 223#if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_32v6K)
224 @ We must avoid clrex due to Cortex-A15 erratum #830321
228 strex r1, r2, [sp] @ clear the exclusive monitor 225 strex r1, r2, [sp] @ clear the exclusive monitor
229#elif defined(CONFIG_CPU_32v6K)
230 clrex @ clear the exclusive monitor
231#endif 226#endif
232 .if \fast 227 .if \fast
233 ldmdb sp, {r1 - lr}^ @ get calling r1 - lr 228 ldmdb sp, {r1 - lr}^ @ get calling r1 - lr
@@ -261,7 +256,10 @@
261 .endif 256 .endif
262 ldr lr, [sp, #S_SP] @ top of the stack 257 ldr lr, [sp, #S_SP] @ top of the stack
263 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc 258 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
264 clrex @ clear the exclusive monitor 259
260 @ We must avoid clrex due to Cortex-A15 erratum #830321
261 strex r2, r1, [sp, #S_LR] @ clear the exclusive monitor
262
265 stmdb lr!, {r0, r1, \rpsr} @ calling lr and rfe context 263 stmdb lr!, {r0, r1, \rpsr} @ calling lr and rfe context
266 ldmia sp, {r0 - r12} 264 ldmia sp, {r0 - r12}
267 mov sp, lr 265 mov sp, lr
@@ -282,13 +280,16 @@
282 .endm 280 .endm
283#else /* ifdef CONFIG_CPU_V7M */ 281#else /* ifdef CONFIG_CPU_V7M */
284 .macro restore_user_regs, fast = 0, offset = 0 282 .macro restore_user_regs, fast = 0, offset = 0
285 clrex @ clear the exclusive monitor
286 mov r2, sp 283 mov r2, sp
287 load_user_sp_lr r2, r3, \offset + S_SP @ calling sp, lr 284 load_user_sp_lr r2, r3, \offset + S_SP @ calling sp, lr
288 ldr r1, [sp, #\offset + S_PSR] @ get calling cpsr 285 ldr r1, [sp, #\offset + S_PSR] @ get calling cpsr
289 ldr lr, [sp, #\offset + S_PC] @ get pc 286 ldr lr, [sp, #\offset + S_PC] @ get pc
290 add sp, sp, #\offset + S_SP 287 add sp, sp, #\offset + S_SP
291 msr spsr_cxsf, r1 @ save in spsr_svc 288 msr spsr_cxsf, r1 @ save in spsr_svc
289
290 @ We must avoid clrex due to Cortex-A15 erratum #830321
291 strex r1, r2, [sp] @ clear the exclusive monitor
292
292 .if \fast 293 .if \fast
293 ldmdb sp, {r1 - r12} @ get calling r1 - r12 294 ldmdb sp, {r1 - r12} @ get calling r1 - r12
294 .else 295 .else
diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
index 45e478157278..6a4dffefd357 100644
--- a/arch/arm/kernel/module.c
+++ b/arch/arm/kernel/module.c
@@ -91,6 +91,7 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
91 break; 91 break;
92 92
93 case R_ARM_ABS32: 93 case R_ARM_ABS32:
94 case R_ARM_TARGET1:
94 *(u32 *)loc += sym->st_value; 95 *(u32 *)loc += sym->st_value;
95 break; 96 break;
96 97
diff --git a/arch/arm/mach-exynos/mcpm-exynos.c b/arch/arm/mach-exynos/mcpm-exynos.c
index b2f8b60cf0e9..dc9a764a7c37 100644
--- a/arch/arm/mach-exynos/mcpm-exynos.c
+++ b/arch/arm/mach-exynos/mcpm-exynos.c
@@ -43,7 +43,6 @@
43 "mcr p15, 0, r0, c1, c0, 0 @ set SCTLR\n\t" \ 43 "mcr p15, 0, r0, c1, c0, 0 @ set SCTLR\n\t" \
44 "isb\n\t"\ 44 "isb\n\t"\
45 "bl v7_flush_dcache_"__stringify(level)"\n\t" \ 45 "bl v7_flush_dcache_"__stringify(level)"\n\t" \
46 "clrex\n\t"\
47 "mrc p15, 0, r0, c1, c0, 1 @ get ACTLR\n\t" \ 46 "mrc p15, 0, r0, c1, c0, 1 @ get ACTLR\n\t" \
48 "bic r0, r0, #(1 << 6) @ disable local coherency\n\t" \ 47 "bic r0, r0, #(1 << 6) @ disable local coherency\n\t" \
49 /* Dummy Load of a device register to avoid Erratum 799270 */ \ 48 /* Dummy Load of a device register to avoid Erratum 799270 */ \
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 9f42d5437fcc..2f97228f188a 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -1207,8 +1207,7 @@ int gpmc_cs_program_settings(int cs, struct gpmc_settings *p)
1207 } 1207 }
1208 } 1208 }
1209 1209
1210 if ((p->wait_on_read || p->wait_on_write) && 1210 if (p->wait_pin > gpmc_nr_waitpins) {
1211 (p->wait_pin > gpmc_nr_waitpins)) {
1212 pr_err("%s: invalid wait-pin (%d)\n", __func__, p->wait_pin); 1211 pr_err("%s: invalid wait-pin (%d)\n", __func__, p->wait_pin);
1213 return -EINVAL; 1212 return -EINVAL;
1214 } 1213 }
@@ -1288,8 +1287,8 @@ void gpmc_read_settings_dt(struct device_node *np, struct gpmc_settings *p)
1288 p->wait_on_write = of_property_read_bool(np, 1287 p->wait_on_write = of_property_read_bool(np,
1289 "gpmc,wait-on-write"); 1288 "gpmc,wait-on-write");
1290 if (!p->wait_on_read && !p->wait_on_write) 1289 if (!p->wait_on_read && !p->wait_on_write)
1291 pr_warn("%s: read/write wait monitoring not enabled!\n", 1290 pr_debug("%s: rd/wr wait monitoring not enabled!\n",
1292 __func__); 1291 __func__);
1293 } 1292 }
1294} 1293}
1295 1294
diff --git a/arch/arm/mm/abort-ev6.S b/arch/arm/mm/abort-ev6.S
index 3815a8262af0..8c48c5c22a33 100644
--- a/arch/arm/mm/abort-ev6.S
+++ b/arch/arm/mm/abort-ev6.S
@@ -17,12 +17,6 @@
17 */ 17 */
18 .align 5 18 .align 5
19ENTRY(v6_early_abort) 19ENTRY(v6_early_abort)
20#ifdef CONFIG_CPU_V6
21 sub r1, sp, #4 @ Get unused stack location
22 strex r0, r1, [r1] @ Clear the exclusive monitor
23#elif defined(CONFIG_CPU_32v6K)
24 clrex
25#endif
26 mrc p15, 0, r1, c5, c0, 0 @ get FSR 20 mrc p15, 0, r1, c5, c0, 0 @ get FSR
27 mrc p15, 0, r0, c6, c0, 0 @ get FAR 21 mrc p15, 0, r0, c6, c0, 0 @ get FAR
28/* 22/*
diff --git a/arch/arm/mm/abort-ev7.S b/arch/arm/mm/abort-ev7.S
index 703375277ba6..4812ad054214 100644
--- a/arch/arm/mm/abort-ev7.S
+++ b/arch/arm/mm/abort-ev7.S
@@ -13,12 +13,6 @@
13 */ 13 */
14 .align 5 14 .align 5
15ENTRY(v7_early_abort) 15ENTRY(v7_early_abort)
16 /*
17 * The effect of data aborts on on the exclusive access monitor are
18 * UNPREDICTABLE. Do a CLREX to clear the state
19 */
20 clrex
21
22 mrc p15, 0, r1, c5, c0, 0 @ get FSR 16 mrc p15, 0, r1, c5, c0, 0 @ get FSR
23 mrc p15, 0, r0, c6, c0, 0 @ get FAR 17 mrc p15, 0, r0, c6, c0, 0 @ get FAR
24 18
diff --git a/arch/hexagon/mm/cache.c b/arch/hexagon/mm/cache.c
index fe14ccf28561..0c76c802e31c 100644
--- a/arch/hexagon/mm/cache.c
+++ b/arch/hexagon/mm/cache.c
@@ -68,6 +68,7 @@ void flush_icache_range(unsigned long start, unsigned long end)
68 ); 68 );
69 local_irq_restore(flags); 69 local_irq_restore(flags);
70} 70}
71EXPORT_SYMBOL(flush_icache_range);
71 72
72void hexagon_clean_dcache_range(unsigned long start, unsigned long end) 73void hexagon_clean_dcache_range(unsigned long start, unsigned long end)
73{ 74{
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 64aefb76bd69..c84c88bbbbd7 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -549,8 +549,6 @@ source "drivers/sn/Kconfig"
549config KEXEC 549config KEXEC
550 bool "kexec system call" 550 bool "kexec system call"
551 depends on !IA64_HP_SIM && (!SMP || HOTPLUG_CPU) 551 depends on !IA64_HP_SIM && (!SMP || HOTPLUG_CPU)
552 select CRYPTO
553 select CRYPTO_SHA256
554 help 552 help
555 kexec is a system call that implements the ability to shutdown your 553 kexec is a system call that implements the ability to shutdown your
556 current kernel, and to start another kernel. It is like a reboot 554 current kernel, and to start another kernel. It is like a reboot
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 3ff8c9a25335..87b7c7581b1d 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -91,8 +91,6 @@ config MMU_SUN3
91config KEXEC 91config KEXEC
92 bool "kexec system call" 92 bool "kexec system call"
93 depends on M68KCLASSIC 93 depends on M68KCLASSIC
94 select CRYPTO
95 select CRYPTO_SHA256
96 help 94 help
97 kexec is a system call that implements the ability to shutdown your 95 kexec is a system call that implements the ability to shutdown your
98 current kernel, and to start another kernel. It is like a reboot 96 current kernel, and to start another kernel. It is like a reboot
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index df51e78a72cc..900c7e5333b6 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -2396,8 +2396,6 @@ source "kernel/Kconfig.preempt"
2396 2396
2397config KEXEC 2397config KEXEC
2398 bool "Kexec system call" 2398 bool "Kexec system call"
2399 select CRYPTO
2400 select CRYPTO_SHA256
2401 help 2399 help
2402 kexec is a system call that implements the ability to shutdown your 2400 kexec is a system call that implements the ability to shutdown your
2403 current kernel, and to start another kernel. It is like a reboot 2401 current kernel, and to start another kernel. It is like a reboot
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index a577609f8ed6..4bc7b62fb4b6 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -399,8 +399,6 @@ config PPC64_SUPPORTS_MEMORY_FAILURE
399config KEXEC 399config KEXEC
400 bool "kexec system call" 400 bool "kexec system call"
401 depends on (PPC_BOOK3S || FSL_BOOKE || (44x && !SMP)) 401 depends on (PPC_BOOK3S || FSL_BOOKE || (44x && !SMP))
402 select CRYPTO
403 select CRYPTO_SHA256
404 help 402 help
405 kexec is a system call that implements the ability to shutdown your 403 kexec is a system call that implements the ability to shutdown your
406 current kernel, and to start another kernel. It is like a reboot 404 current kernel, and to start another kernel. It is like a reboot
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index ab39ceb89ecf..05c78bb5f570 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -48,8 +48,6 @@ config ARCH_SUPPORTS_DEBUG_PAGEALLOC
48 48
49config KEXEC 49config KEXEC
50 def_bool y 50 def_bool y
51 select CRYPTO
52 select CRYPTO_SHA256
53 51
54config AUDIT_ARCH 52config AUDIT_ARCH
55 def_bool y 53 def_bool y
diff --git a/arch/s390/include/uapi/asm/unistd.h b/arch/s390/include/uapi/asm/unistd.h
index 3802d2d3a18d..940ac49198db 100644
--- a/arch/s390/include/uapi/asm/unistd.h
+++ b/arch/s390/include/uapi/asm/unistd.h
@@ -283,7 +283,10 @@
283#define __NR_sched_setattr 345 283#define __NR_sched_setattr 345
284#define __NR_sched_getattr 346 284#define __NR_sched_getattr 346
285#define __NR_renameat2 347 285#define __NR_renameat2 347
286#define NR_syscalls 348 286#define __NR_seccomp 348
287#define __NR_getrandom 349
288#define __NR_memfd_create 350
289#define NR_syscalls 351
287 290
288/* 291/*
289 * There are some system calls that are not present on 64 bit, some 292 * There are some system calls that are not present on 64 bit, some
diff --git a/arch/s390/kernel/compat_wrapper.c b/arch/s390/kernel/compat_wrapper.c
index 45cdb37aa6f8..faf6caa510dc 100644
--- a/arch/s390/kernel/compat_wrapper.c
+++ b/arch/s390/kernel/compat_wrapper.c
@@ -214,3 +214,6 @@ COMPAT_SYSCALL_WRAP3(finit_module, int, fd, const char __user *, uargs, int, fla
214COMPAT_SYSCALL_WRAP3(sched_setattr, pid_t, pid, struct sched_attr __user *, attr, unsigned int, flags); 214COMPAT_SYSCALL_WRAP3(sched_setattr, pid_t, pid, struct sched_attr __user *, attr, unsigned int, flags);
215COMPAT_SYSCALL_WRAP4(sched_getattr, pid_t, pid, struct sched_attr __user *, attr, unsigned int, size, unsigned int, flags); 215COMPAT_SYSCALL_WRAP4(sched_getattr, pid_t, pid, struct sched_attr __user *, attr, unsigned int, size, unsigned int, flags);
216COMPAT_SYSCALL_WRAP5(renameat2, int, olddfd, const char __user *, oldname, int, newdfd, const char __user *, newname, unsigned int, flags); 216COMPAT_SYSCALL_WRAP5(renameat2, int, olddfd, const char __user *, oldname, int, newdfd, const char __user *, newname, unsigned int, flags);
217COMPAT_SYSCALL_WRAP3(seccomp, unsigned int, op, unsigned int, flags, const char __user *, uargs)
218COMPAT_SYSCALL_WRAP3(getrandom, char __user *, buf, size_t, count, unsigned int, flags)
219COMPAT_SYSCALL_WRAP2(memfd_create, const char __user *, uname, unsigned int, flags)
diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c
index 633ca7504536..22aac5885ba2 100644
--- a/arch/s390/kernel/ipl.c
+++ b/arch/s390/kernel/ipl.c
@@ -2060,6 +2060,13 @@ void s390_reset_system(void (*func)(void *), void *data)
2060 S390_lowcore.program_new_psw.addr = 2060 S390_lowcore.program_new_psw.addr =
2061 PSW_ADDR_AMODE | (unsigned long) s390_base_pgm_handler; 2061 PSW_ADDR_AMODE | (unsigned long) s390_base_pgm_handler;
2062 2062
2063 /*
2064 * Clear subchannel ID and number to signal new kernel that no CCW or
2065 * SCSI IPL has been done (for kexec and kdump)
2066 */
2067 S390_lowcore.subchannel_id = 0;
2068 S390_lowcore.subchannel_nr = 0;
2069
2063 /* Store status at absolute zero */ 2070 /* Store status at absolute zero */
2064 store_status(); 2071 store_status();
2065 2072
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index ae1d5be7dd88..82bc113e8c1d 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -24,6 +24,7 @@
24#include <linux/stddef.h> 24#include <linux/stddef.h>
25#include <linux/unistd.h> 25#include <linux/unistd.h>
26#include <linux/ptrace.h> 26#include <linux/ptrace.h>
27#include <linux/random.h>
27#include <linux/user.h> 28#include <linux/user.h>
28#include <linux/tty.h> 29#include <linux/tty.h>
29#include <linux/ioport.h> 30#include <linux/ioport.h>
@@ -61,6 +62,7 @@
61#include <asm/diag.h> 62#include <asm/diag.h>
62#include <asm/os_info.h> 63#include <asm/os_info.h>
63#include <asm/sclp.h> 64#include <asm/sclp.h>
65#include <asm/sysinfo.h>
64#include "entry.h" 66#include "entry.h"
65 67
66/* 68/*
@@ -766,6 +768,7 @@ static void __init setup_hwcaps(void)
766#endif 768#endif
767 769
768 get_cpu_id(&cpu_id); 770 get_cpu_id(&cpu_id);
771 add_device_randomness(&cpu_id, sizeof(cpu_id));
769 switch (cpu_id.machine) { 772 switch (cpu_id.machine) {
770 case 0x9672: 773 case 0x9672:
771#if !defined(CONFIG_64BIT) 774#if !defined(CONFIG_64BIT)
@@ -804,6 +807,19 @@ static void __init setup_hwcaps(void)
804} 807}
805 808
806/* 809/*
810 * Add system information as device randomness
811 */
812static void __init setup_randomness(void)
813{
814 struct sysinfo_3_2_2 *vmms;
815
816 vmms = (struct sysinfo_3_2_2 *) alloc_page(GFP_KERNEL);
817 if (vmms && stsi(vmms, 3, 2, 2) == 0 && vmms->count)
818 add_device_randomness(&vmms, vmms->count);
819 free_page((unsigned long) vmms);
820}
821
822/*
807 * Setup function called from init/main.c just after the banner 823 * Setup function called from init/main.c just after the banner
808 * was printed. 824 * was printed.
809 */ 825 */
@@ -901,6 +917,9 @@ void __init setup_arch(char **cmdline_p)
901 917
902 /* Setup zfcpdump support */ 918 /* Setup zfcpdump support */
903 setup_zfcpdump(); 919 setup_zfcpdump();
920
921 /* Add system specific data to the random pool */
922 setup_randomness();
904} 923}
905 924
906#ifdef CONFIG_32BIT 925#ifdef CONFIG_32BIT
diff --git a/arch/s390/kernel/syscalls.S b/arch/s390/kernel/syscalls.S
index fe5cdf29a001..6fe886ac2db5 100644
--- a/arch/s390/kernel/syscalls.S
+++ b/arch/s390/kernel/syscalls.S
@@ -356,3 +356,6 @@ SYSCALL(sys_finit_module,sys_finit_module,compat_sys_finit_module)
356SYSCALL(sys_sched_setattr,sys_sched_setattr,compat_sys_sched_setattr) /* 345 */ 356SYSCALL(sys_sched_setattr,sys_sched_setattr,compat_sys_sched_setattr) /* 345 */
357SYSCALL(sys_sched_getattr,sys_sched_getattr,compat_sys_sched_getattr) 357SYSCALL(sys_sched_getattr,sys_sched_getattr,compat_sys_sched_getattr)
358SYSCALL(sys_renameat2,sys_renameat2,compat_sys_renameat2) 358SYSCALL(sys_renameat2,sys_renameat2,compat_sys_renameat2)
359SYSCALL(sys_seccomp,sys_seccomp,compat_sys_seccomp)
360SYSCALL(sys_getrandom,sys_getrandom,compat_sys_getrandom)
361SYSCALL(sys_memfd_create,sys_memfd_create,compat_sys_memfd_create) /* 350 */
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index b319846ad97f..244fb4c81e25 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -598,8 +598,6 @@ source kernel/Kconfig.hz
598config KEXEC 598config KEXEC
599 bool "kexec system call (EXPERIMENTAL)" 599 bool "kexec system call (EXPERIMENTAL)"
600 depends on SUPERH32 && MMU 600 depends on SUPERH32 && MMU
601 select CRYPTO
602 select CRYPTO_SHA256
603 help 601 help
604 kexec is a system call that implements the ability to shutdown your 602 kexec is a system call that implements the ability to shutdown your
605 current kernel, and to start another kernel. It is like a reboot 603 current kernel, and to start another kernel. It is like a reboot
diff --git a/arch/sh/mm/cache.c b/arch/sh/mm/cache.c
index 097c2cdd117f..f770e3992620 100644
--- a/arch/sh/mm/cache.c
+++ b/arch/sh/mm/cache.c
@@ -229,6 +229,7 @@ void flush_icache_range(unsigned long start, unsigned long end)
229 229
230 cacheop_on_each_cpu(local_flush_icache_range, (void *)&data, 1); 230 cacheop_on_each_cpu(local_flush_icache_range, (void *)&data, 1);
231} 231}
232EXPORT_SYMBOL(flush_icache_range);
232 233
233void flush_icache_page(struct vm_area_struct *vma, struct page *page) 234void flush_icache_page(struct vm_area_struct *vma, struct page *page)
234{ 235{
diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
index a3ffe2dd4832..7fcd492adbfc 100644
--- a/arch/tile/Kconfig
+++ b/arch/tile/Kconfig
@@ -191,8 +191,6 @@ source "kernel/Kconfig.hz"
191 191
192config KEXEC 192config KEXEC
193 bool "kexec system call" 193 bool "kexec system call"
194 select CRYPTO
195 select CRYPTO_SHA256
196 ---help--- 194 ---help---
197 kexec is a system call that implements the ability to shutdown your 195 kexec is a system call that implements the ability to shutdown your
198 current kernel, and to start another kernel. It is like a reboot 196 current kernel, and to start another kernel. It is like a reboot
diff --git a/arch/tile/kernel/smp.c b/arch/tile/kernel/smp.c
index 01e8ab29f43a..19eaa62d456a 100644
--- a/arch/tile/kernel/smp.c
+++ b/arch/tile/kernel/smp.c
@@ -183,6 +183,7 @@ void flush_icache_range(unsigned long start, unsigned long end)
183 preempt_enable(); 183 preempt_enable();
184 } 184 }
185} 185}
186EXPORT_SYMBOL(flush_icache_range);
186 187
187 188
188/* Called when smp_send_reschedule() triggers IRQ_RESCHEDULE. */ 189/* Called when smp_send_reschedule() triggers IRQ_RESCHEDULE. */
diff --git a/arch/unicore32/kernel/signal.c b/arch/unicore32/kernel/signal.c
index 780d77388dec..7c8fb7018dc6 100644
--- a/arch/unicore32/kernel/signal.c
+++ b/arch/unicore32/kernel/signal.c
@@ -254,7 +254,8 @@ static int setup_frame(struct ksignal *ksig, sigset_t *set,
254 254
255 err |= setup_sigframe(frame, regs, set); 255 err |= setup_sigframe(frame, regs, set);
256 if (err == 0) 256 if (err == 0)
257 err |= setup_return(regs, &ksig->ka, frame->retcode, frame, usig); 257 err |= setup_return(regs, &ksig->ka, frame->retcode, frame,
258 ksig->sig);
258 259
259 return err; 260 return err;
260} 261}
@@ -276,7 +277,8 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set,
276 err |= __save_altstack(&frame->sig.uc.uc_stack, regs->UCreg_sp); 277 err |= __save_altstack(&frame->sig.uc.uc_stack, regs->UCreg_sp);
277 err |= setup_sigframe(&frame->sig, regs, set); 278 err |= setup_sigframe(&frame->sig, regs, set);
278 if (err == 0) 279 if (err == 0)
279 err |= setup_return(regs, &ksig->ka, frame->sig.retcode, frame, usig); 280 err |= setup_return(regs, &ksig->ka, frame->sig.retcode, frame,
281 ksig->sig);
280 282
281 if (err == 0) { 283 if (err == 0) {
282 /* 284 /*
@@ -303,7 +305,6 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs,
303 int syscall) 305 int syscall)
304{ 306{
305 struct thread_info *thread = current_thread_info(); 307 struct thread_info *thread = current_thread_info();
306 struct task_struct *tsk = current;
307 sigset_t *oldset = sigmask_to_save(); 308 sigset_t *oldset = sigmask_to_save();
308 int usig = ksig->sig; 309 int usig = ksig->sig;
309 int ret; 310 int ret;
@@ -373,7 +374,7 @@ static void do_signal(struct pt_regs *regs, int syscall)
373 if (!user_mode(regs)) 374 if (!user_mode(regs))
374 return; 375 return;
375 376
376 if (get_signsl(&ksig)) { 377 if (get_signal(&ksig)) {
377 handle_signal(&ksig, regs, syscall); 378 handle_signal(&ksig, regs, syscall);
378 return; 379 return;
379 } 380 }
diff --git a/arch/x86/Kbuild b/arch/x86/Kbuild
index 61b6d51866f8..3942f74c92d7 100644
--- a/arch/x86/Kbuild
+++ b/arch/x86/Kbuild
@@ -17,6 +17,4 @@ obj-$(CONFIG_IA32_EMULATION) += ia32/
17obj-y += platform/ 17obj-y += platform/
18obj-y += net/ 18obj-y += net/
19 19
20ifeq ($(CONFIG_X86_64),y) 20obj-$(CONFIG_KEXEC_FILE) += purgatory/
21obj-$(CONFIG_KEXEC) += purgatory/
22endif
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 5d0bf1aa9dcb..778178f4c7d1 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1585,9 +1585,6 @@ source kernel/Kconfig.hz
1585 1585
1586config KEXEC 1586config KEXEC
1587 bool "kexec system call" 1587 bool "kexec system call"
1588 select BUILD_BIN2C
1589 select CRYPTO
1590 select CRYPTO_SHA256
1591 ---help--- 1588 ---help---
1592 kexec is a system call that implements the ability to shutdown your 1589 kexec is a system call that implements the ability to shutdown your
1593 current kernel, and to start another kernel. It is like a reboot 1590 current kernel, and to start another kernel. It is like a reboot
@@ -1602,9 +1599,22 @@ config KEXEC
1602 interface is strongly in flux, so no good recommendation can be 1599 interface is strongly in flux, so no good recommendation can be
1603 made. 1600 made.
1604 1601
1602config KEXEC_FILE
1603 bool "kexec file based system call"
1604 select BUILD_BIN2C
1605 depends on KEXEC
1606 depends on X86_64
1607 depends on CRYPTO=y
1608 depends on CRYPTO_SHA256=y
1609 ---help---
1610 This is new version of kexec system call. This system call is
1611 file based and takes file descriptors as system call argument
1612 for kernel and initramfs as opposed to list of segments as
1613 accepted by previous system call.
1614
1605config KEXEC_VERIFY_SIG 1615config KEXEC_VERIFY_SIG
1606 bool "Verify kernel signature during kexec_file_load() syscall" 1616 bool "Verify kernel signature during kexec_file_load() syscall"
1607 depends on KEXEC 1617 depends on KEXEC_FILE
1608 ---help--- 1618 ---help---
1609 This option makes kernel signature verification mandatory for 1619 This option makes kernel signature verification mandatory for
1610 kexec_file_load() syscall. If kernel is signature can not be 1620 kexec_file_load() syscall. If kernel is signature can not be
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index c1aa36887843..60087ca37679 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -184,11 +184,8 @@ archheaders:
184 $(Q)$(MAKE) $(build)=arch/x86/syscalls all 184 $(Q)$(MAKE) $(build)=arch/x86/syscalls all
185 185
186archprepare: 186archprepare:
187ifeq ($(CONFIG_KEXEC),y) 187ifeq ($(CONFIG_KEXEC_FILE),y)
188# Build only for 64bit. No loaders for 32bit yet.
189 ifeq ($(CONFIG_X86_64),y)
190 $(Q)$(MAKE) $(build)=arch/x86/purgatory arch/x86/purgatory/kexec-purgatory.c 188 $(Q)$(MAKE) $(build)=arch/x86/purgatory arch/x86/purgatory/kexec-purgatory.c
191 endif
192endif 189endif
193 190
194### 191###
@@ -254,6 +251,7 @@ archclean:
254 $(Q)rm -rf $(objtree)/arch/x86_64 251 $(Q)rm -rf $(objtree)/arch/x86_64
255 $(Q)$(MAKE) $(clean)=$(boot) 252 $(Q)$(MAKE) $(clean)=$(boot)
256 $(Q)$(MAKE) $(clean)=arch/x86/tools 253 $(Q)$(MAKE) $(clean)=arch/x86/tools
254 $(Q)$(MAKE) $(clean)=arch/x86/purgatory
257 255
258PHONY += kvmconfig 256PHONY += kvmconfig
259kvmconfig: 257kvmconfig:
diff --git a/arch/x86/include/asm/io_apic.h b/arch/x86/include/asm/io_apic.h
index 0aeed5ca356e..478c490f3654 100644
--- a/arch/x86/include/asm/io_apic.h
+++ b/arch/x86/include/asm/io_apic.h
@@ -227,6 +227,8 @@ static inline void io_apic_modify(unsigned int apic, unsigned int reg, unsigned
227 227
228extern void io_apic_eoi(unsigned int apic, unsigned int vector); 228extern void io_apic_eoi(unsigned int apic, unsigned int vector);
229 229
230extern bool mp_should_keep_irq(struct device *dev);
231
230#else /* !CONFIG_X86_IO_APIC */ 232#else /* !CONFIG_X86_IO_APIC */
231 233
232#define io_apic_assign_pci_irqs 0 234#define io_apic_assign_pci_irqs 0
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 0ec056012618..aa97a070f09f 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -131,8 +131,13 @@ static inline int pte_exec(pte_t pte)
131 131
132static inline int pte_special(pte_t pte) 132static inline int pte_special(pte_t pte)
133{ 133{
134 return (pte_flags(pte) & (_PAGE_PRESENT|_PAGE_SPECIAL)) == 134 /*
135 (_PAGE_PRESENT|_PAGE_SPECIAL); 135 * See CONFIG_NUMA_BALANCING pte_numa in include/asm-generic/pgtable.h.
136 * On x86 we have _PAGE_BIT_NUMA == _PAGE_BIT_GLOBAL+1 ==
137 * __PAGE_BIT_SOFTW1 == _PAGE_BIT_SPECIAL.
138 */
139 return (pte_flags(pte) & _PAGE_SPECIAL) &&
140 (pte_flags(pte) & (_PAGE_PRESENT|_PAGE_PROTNONE));
136} 141}
137 142
138static inline unsigned long pte_pfn(pte_t pte) 143static inline unsigned long pte_pfn(pte_t pte)
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index b5ea75c4a4b4..ada2e2d6be3e 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -71,6 +71,7 @@ obj-$(CONFIG_FTRACE_SYSCALLS) += ftrace.o
71obj-$(CONFIG_X86_TSC) += trace_clock.o 71obj-$(CONFIG_X86_TSC) += trace_clock.o
72obj-$(CONFIG_KEXEC) += machine_kexec_$(BITS).o 72obj-$(CONFIG_KEXEC) += machine_kexec_$(BITS).o
73obj-$(CONFIG_KEXEC) += relocate_kernel_$(BITS).o crash.o 73obj-$(CONFIG_KEXEC) += relocate_kernel_$(BITS).o crash.o
74obj-$(CONFIG_KEXEC_FILE) += kexec-bzimage64.o
74obj-$(CONFIG_CRASH_DUMP) += crash_dump_$(BITS).o 75obj-$(CONFIG_CRASH_DUMP) += crash_dump_$(BITS).o
75obj-y += kprobes/ 76obj-y += kprobes/
76obj-$(CONFIG_MODULES) += module.o 77obj-$(CONFIG_MODULES) += module.o
@@ -118,5 +119,4 @@ ifeq ($(CONFIG_X86_64),y)
118 119
119 obj-$(CONFIG_PCI_MMCONFIG) += mmconf-fam10h_64.o 120 obj-$(CONFIG_PCI_MMCONFIG) += mmconf-fam10h_64.o
120 obj-y += vsmp_64.o 121 obj-y += vsmp_64.o
121 obj-$(CONFIG_KEXEC) += kexec-bzimage64.o
122endif 122endif
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 29290f554e79..337ce5a9b15c 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -1070,6 +1070,11 @@ static int mp_map_pin_to_irq(u32 gsi, int idx, int ioapic, int pin,
1070 } 1070 }
1071 1071
1072 if (flags & IOAPIC_MAP_ALLOC) { 1072 if (flags & IOAPIC_MAP_ALLOC) {
1073 /* special handling for legacy IRQs */
1074 if (irq < nr_legacy_irqs() && info->count == 1 &&
1075 mp_irqdomain_map(domain, irq, pin) != 0)
1076 irq = -1;
1077
1073 if (irq > 0) 1078 if (irq > 0)
1074 info->count++; 1079 info->count++;
1075 else if (info->count == 0) 1080 else if (info->count == 0)
@@ -3896,7 +3901,15 @@ int mp_irqdomain_map(struct irq_domain *domain, unsigned int virq,
3896 info->polarity = 1; 3901 info->polarity = 1;
3897 } 3902 }
3898 info->node = NUMA_NO_NODE; 3903 info->node = NUMA_NO_NODE;
3899 info->set = 1; 3904
3905 /*
3906 * setup_IO_APIC_irqs() programs all legacy IRQs with default
3907 * trigger and polarity attributes. Don't set the flag for that
3908 * case so the first legacy IRQ user could reprogram the pin
3909 * with real trigger and polarity attributes.
3910 */
3911 if (virq >= nr_legacy_irqs() || info->count)
3912 info->set = 1;
3900 } 3913 }
3901 set_io_apic_irq_attr(&attr, ioapic, hwirq, info->trigger, 3914 set_io_apic_irq_attr(&attr, ioapic, hwirq, info->trigger,
3902 info->polarity); 3915 info->polarity);
@@ -3946,6 +3959,18 @@ int mp_set_gsi_attr(u32 gsi, int trigger, int polarity, int node)
3946 return ret; 3959 return ret;
3947} 3960}
3948 3961
3962bool mp_should_keep_irq(struct device *dev)
3963{
3964 if (dev->power.is_prepared)
3965 return true;
3966#ifdef CONFIG_PM_RUNTIME
3967 if (dev->power.runtime_status == RPM_SUSPENDING)
3968 return true;
3969#endif
3970
3971 return false;
3972}
3973
3949/* Enable IOAPIC early just for system timer */ 3974/* Enable IOAPIC early just for system timer */
3950void __init pre_init_apic_IRQ0(void) 3975void __init pre_init_apic_IRQ0(void)
3951{ 3976{
diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
index 0553a34fa0df..a618fcd2c07d 100644
--- a/arch/x86/kernel/crash.c
+++ b/arch/x86/kernel/crash.c
@@ -182,8 +182,7 @@ void native_machine_crash_shutdown(struct pt_regs *regs)
182 crash_save_cpu(regs, safe_smp_processor_id()); 182 crash_save_cpu(regs, safe_smp_processor_id());
183} 183}
184 184
185#ifdef CONFIG_X86_64 185#ifdef CONFIG_KEXEC_FILE
186
187static int get_nr_ram_ranges_callback(unsigned long start_pfn, 186static int get_nr_ram_ranges_callback(unsigned long start_pfn,
188 unsigned long nr_pfn, void *arg) 187 unsigned long nr_pfn, void *arg)
189{ 188{
@@ -696,5 +695,4 @@ int crash_load_segments(struct kimage *image)
696 695
697 return ret; 696 return ret;
698} 697}
699 698#endif /* CONFIG_KEXEC_FILE */
700#endif /* CONFIG_X86_64 */
diff --git a/arch/x86/kernel/irqinit.c b/arch/x86/kernel/irqinit.c
index 1e6cff5814fa..44f1ed42fdf2 100644
--- a/arch/x86/kernel/irqinit.c
+++ b/arch/x86/kernel/irqinit.c
@@ -203,7 +203,7 @@ void __init native_init_IRQ(void)
203 set_intr_gate(i, interrupt[i - FIRST_EXTERNAL_VECTOR]); 203 set_intr_gate(i, interrupt[i - FIRST_EXTERNAL_VECTOR]);
204 } 204 }
205 205
206 if (!acpi_ioapic && !of_ioapic) 206 if (!acpi_ioapic && !of_ioapic && nr_legacy_irqs())
207 setup_irq(2, &irq2); 207 setup_irq(2, &irq2);
208 208
209#ifdef CONFIG_X86_32 209#ifdef CONFIG_X86_32
diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
index 8b04018e5d1f..485981059a40 100644
--- a/arch/x86/kernel/machine_kexec_64.c
+++ b/arch/x86/kernel/machine_kexec_64.c
@@ -25,9 +25,11 @@
25#include <asm/debugreg.h> 25#include <asm/debugreg.h>
26#include <asm/kexec-bzimage64.h> 26#include <asm/kexec-bzimage64.h>
27 27
28#ifdef CONFIG_KEXEC_FILE
28static struct kexec_file_ops *kexec_file_loaders[] = { 29static struct kexec_file_ops *kexec_file_loaders[] = {
29 &kexec_bzImage64_ops, 30 &kexec_bzImage64_ops,
30}; 31};
32#endif
31 33
32static void free_transition_pgtable(struct kimage *image) 34static void free_transition_pgtable(struct kimage *image)
33{ 35{
@@ -178,6 +180,7 @@ static void load_segments(void)
178 ); 180 );
179} 181}
180 182
183#ifdef CONFIG_KEXEC_FILE
181/* Update purgatory as needed after various image segments have been prepared */ 184/* Update purgatory as needed after various image segments have been prepared */
182static int arch_update_purgatory(struct kimage *image) 185static int arch_update_purgatory(struct kimage *image)
183{ 186{
@@ -209,6 +212,12 @@ static int arch_update_purgatory(struct kimage *image)
209 212
210 return ret; 213 return ret;
211} 214}
215#else /* !CONFIG_KEXEC_FILE */
216static inline int arch_update_purgatory(struct kimage *image)
217{
218 return 0;
219}
220#endif /* CONFIG_KEXEC_FILE */
212 221
213int machine_kexec_prepare(struct kimage *image) 222int machine_kexec_prepare(struct kimage *image)
214{ 223{
@@ -329,6 +338,7 @@ void arch_crash_save_vmcoreinfo(void)
329 338
330/* arch-dependent functionality related to kexec file-based syscall */ 339/* arch-dependent functionality related to kexec file-based syscall */
331 340
341#ifdef CONFIG_KEXEC_FILE
332int arch_kexec_kernel_image_probe(struct kimage *image, void *buf, 342int arch_kexec_kernel_image_probe(struct kimage *image, void *buf,
333 unsigned long buf_len) 343 unsigned long buf_len)
334{ 344{
@@ -522,3 +532,4 @@ overflow:
522 (int)ELF64_R_TYPE(rel[i].r_info), value); 532 (int)ELF64_R_TYPE(rel[i].r_info), value);
523 return -ENOEXEC; 533 return -ENOEXEC;
524} 534}
535#endif /* CONFIG_KEXEC_FILE */
diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
index bf7ef5ce29df..0fa29609b2c4 100644
--- a/arch/x86/kernel/time.c
+++ b/arch/x86/kernel/time.c
@@ -68,6 +68,8 @@ static struct irqaction irq0 = {
68 68
69void __init setup_default_timer_irq(void) 69void __init setup_default_timer_irq(void)
70{ 70{
71 if (!nr_legacy_irqs())
72 return;
71 setup_irq(0, &irq0); 73 setup_irq(0, &irq0);
72} 74}
73 75
diff --git a/arch/x86/pci/intel_mid_pci.c b/arch/x86/pci/intel_mid_pci.c
index 3865116c51fb..b9958c364075 100644
--- a/arch/x86/pci/intel_mid_pci.c
+++ b/arch/x86/pci/intel_mid_pci.c
@@ -229,7 +229,7 @@ static int intel_mid_pci_irq_enable(struct pci_dev *dev)
229 229
230static void intel_mid_pci_irq_disable(struct pci_dev *dev) 230static void intel_mid_pci_irq_disable(struct pci_dev *dev)
231{ 231{
232 if (!dev->dev.power.is_prepared && dev->irq > 0) 232 if (!mp_should_keep_irq(&dev->dev) && dev->irq > 0)
233 mp_unmap_irq(dev->irq); 233 mp_unmap_irq(dev->irq);
234} 234}
235 235
diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
index bc1a2c341891..eb500c2592ad 100644
--- a/arch/x86/pci/irq.c
+++ b/arch/x86/pci/irq.c
@@ -1256,7 +1256,7 @@ static int pirq_enable_irq(struct pci_dev *dev)
1256 1256
1257static void pirq_disable_irq(struct pci_dev *dev) 1257static void pirq_disable_irq(struct pci_dev *dev)
1258{ 1258{
1259 if (io_apic_assign_pci_irqs && !dev->dev.power.is_prepared && 1259 if (io_apic_assign_pci_irqs && !mp_should_keep_irq(&dev->dev) &&
1260 dev->irq) { 1260 dev->irq) {
1261 mp_unmap_irq(dev->irq); 1261 mp_unmap_irq(dev->irq);
1262 dev->irq = 0; 1262 dev->irq = 0;
diff --git a/arch/x86/purgatory/Makefile b/arch/x86/purgatory/Makefile
index 7fde9ee438a4..899dd2454256 100644
--- a/arch/x86/purgatory/Makefile
+++ b/arch/x86/purgatory/Makefile
@@ -11,6 +11,7 @@ targets += purgatory.ro
11# sure how to relocate those. Like kexec-tools, use custom flags. 11# sure how to relocate those. Like kexec-tools, use custom flags.
12 12
13KBUILD_CFLAGS := -fno-strict-aliasing -Wall -Wstrict-prototypes -fno-zero-initialized-in-bss -fno-builtin -ffreestanding -c -MD -Os -mcmodel=large 13KBUILD_CFLAGS := -fno-strict-aliasing -Wall -Wstrict-prototypes -fno-zero-initialized-in-bss -fno-builtin -ffreestanding -c -MD -Os -mcmodel=large
14KBUILD_CFLAGS += -m$(BITS)
14 15
15$(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE 16$(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE
16 $(call if_changed,ld) 17 $(call if_changed,ld)
@@ -24,7 +25,4 @@ $(obj)/kexec-purgatory.c: $(obj)/purgatory.ro FORCE
24 $(call if_changed,bin2c) 25 $(call if_changed,bin2c)
25 26
26 27
27# No loaders for 32bits yet. 28obj-$(CONFIG_KEXEC_FILE) += kexec-purgatory.o
28ifeq ($(CONFIG_X86_64),y)
29 obj-$(CONFIG_KEXEC) += kexec-purgatory.o
30endif
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 3a617af60d46..49c6c3d94449 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -4,24 +4,23 @@ config ZONE_DMA
4config XTENSA 4config XTENSA
5 def_bool y 5 def_bool y
6 select ARCH_WANT_FRAME_POINTERS 6 select ARCH_WANT_FRAME_POINTERS
7 select HAVE_IDE
8 select GENERIC_ATOMIC64
9 select GENERIC_CLOCKEVENTS
10 select VIRT_TO_BUS
11 select GENERIC_IRQ_SHOW
12 select GENERIC_SCHED_CLOCK
13 select MODULES_USE_ELF_RELA
14 select GENERIC_PCI_IOMAP
15 select ARCH_WANT_IPC_PARSE_VERSION 7 select ARCH_WANT_IPC_PARSE_VERSION
16 select ARCH_WANT_OPTIONAL_GPIOLIB 8 select ARCH_WANT_OPTIONAL_GPIOLIB
17 select BUILDTIME_EXTABLE_SORT 9 select BUILDTIME_EXTABLE_SORT
18 select CLONE_BACKWARDS 10 select CLONE_BACKWARDS
19 select IRQ_DOMAIN 11 select COMMON_CLK
20 select HAVE_OPROFILE 12 select GENERIC_ATOMIC64
13 select GENERIC_CLOCKEVENTS
14 select GENERIC_IRQ_SHOW
15 select GENERIC_PCI_IOMAP
16 select GENERIC_SCHED_CLOCK
21 select HAVE_FUNCTION_TRACER 17 select HAVE_FUNCTION_TRACER
22 select HAVE_IRQ_TIME_ACCOUNTING 18 select HAVE_IRQ_TIME_ACCOUNTING
19 select HAVE_OPROFILE
23 select HAVE_PERF_EVENTS 20 select HAVE_PERF_EVENTS
24 select COMMON_CLK 21 select IRQ_DOMAIN
22 select MODULES_USE_ELF_RELA
23 select VIRT_TO_BUS
25 help 24 help
26 Xtensa processors are 32-bit RISC machines designed by Tensilica 25 Xtensa processors are 32-bit RISC machines designed by Tensilica
27 primarily for embedded systems. These processors are both 26 primarily for embedded systems. These processors are both
@@ -62,7 +61,9 @@ config TRACE_IRQFLAGS_SUPPORT
62 def_bool y 61 def_bool y
63 62
64config MMU 63config MMU
65 def_bool n 64 bool
65 default n if !XTENSA_VARIANT_CUSTOM
66 default XTENSA_VARIANT_MMU if XTENSA_VARIANT_CUSTOM
66 67
67config VARIANT_IRQ_SWITCH 68config VARIANT_IRQ_SWITCH
68 def_bool n 69 def_bool n
@@ -102,8 +103,40 @@ config XTENSA_VARIANT_S6000
102 select VARIANT_IRQ_SWITCH 103 select VARIANT_IRQ_SWITCH
103 select ARCH_REQUIRE_GPIOLIB 104 select ARCH_REQUIRE_GPIOLIB
104 select XTENSA_CALIBRATE_CCOUNT 105 select XTENSA_CALIBRATE_CCOUNT
106
107config XTENSA_VARIANT_CUSTOM
108 bool "Custom Xtensa processor configuration"
109 select MAY_HAVE_SMP
110 select HAVE_XTENSA_GPIO32
111 help
112 Select this variant to use a custom Xtensa processor configuration.
113 You will be prompted for a processor variant CORENAME.
105endchoice 114endchoice
106 115
116config XTENSA_VARIANT_CUSTOM_NAME
117 string "Xtensa Processor Custom Core Variant Name"
118 depends on XTENSA_VARIANT_CUSTOM
119 help
120 Provide the name of a custom Xtensa processor variant.
121 This CORENAME selects arch/xtensa/variant/CORENAME.
122 Dont forget you have to select MMU if you have one.
123
124config XTENSA_VARIANT_NAME
125 string
126 default "dc232b" if XTENSA_VARIANT_DC232B
127 default "dc233c" if XTENSA_VARIANT_DC233C
128 default "fsf" if XTENSA_VARIANT_FSF
129 default "s6000" if XTENSA_VARIANT_S6000
130 default XTENSA_VARIANT_CUSTOM_NAME if XTENSA_VARIANT_CUSTOM
131
132config XTENSA_VARIANT_MMU
133 bool "Core variant has a Full MMU (TLB, Pages, Protection, etc)"
134 depends on XTENSA_VARIANT_CUSTOM
135 default y
136 help
137 Build a Conventional Kernel with full MMU support,
138 ie: it supports a TLB with auto-loading, page protection.
139
107config XTENSA_UNALIGNED_USER 140config XTENSA_UNALIGNED_USER
108 bool "Unaligned memory access in use space" 141 bool "Unaligned memory access in use space"
109 help 142 help
@@ -156,13 +189,9 @@ config HOTPLUG_CPU
156 189
157 Say N if you want to disable CPU hotplug. 190 Say N if you want to disable CPU hotplug.
158 191
159config MATH_EMULATION
160 bool "Math emulation"
161 help
162 Can we use information of configuration file?
163
164config INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX 192config INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX
165 bool "Initialize Xtensa MMU inside the Linux kernel code" 193 bool "Initialize Xtensa MMU inside the Linux kernel code"
194 depends on MMU
166 default y 195 default y
167 help 196 help
168 Earlier version initialized the MMU in the exception vector 197 Earlier version initialized the MMU in the exception vector
@@ -192,6 +221,7 @@ config INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX
192 221
193config HIGHMEM 222config HIGHMEM
194 bool "High Memory Support" 223 bool "High Memory Support"
224 depends on MMU
195 help 225 help
196 Linux can use the full amount of RAM in the system by 226 Linux can use the full amount of RAM in the system by
197 default. However, the default MMUv2 setup only maps the 227 default. However, the default MMUv2 setup only maps the
@@ -208,6 +238,32 @@ config HIGHMEM
208 238
209 If unsure, say Y. 239 If unsure, say Y.
210 240
241config FAST_SYSCALL_XTENSA
242 bool "Enable fast atomic syscalls"
243 default n
244 help
245 fast_syscall_xtensa is a syscall that can make atomic operations
246 on UP kernel when processor has no s32c1i support.
247
248 This syscall is deprecated. It may have issues when called with
249 invalid arguments. It is provided only for backwards compatibility.
250 Only enable it if your userspace software requires it.
251
252 If unsure, say N.
253
254config FAST_SYSCALL_SPILL_REGISTERS
255 bool "Enable spill registers syscall"
256 default n
257 help
258 fast_syscall_spill_registers is a syscall that spills all active
259 register windows of a calling userspace task onto its stack.
260
261 This syscall is deprecated. It may have issues when called with
262 invalid arguments. It is provided only for backwards compatibility.
263 Only enable it if your userspace software requires it.
264
265 If unsure, say N.
266
211endmenu 267endmenu
212 268
213config XTENSA_CALIBRATE_CCOUNT 269config XTENSA_CALIBRATE_CCOUNT
@@ -250,12 +306,14 @@ config XTENSA_PLATFORM_ISS
250 306
251config XTENSA_PLATFORM_XT2000 307config XTENSA_PLATFORM_XT2000
252 bool "XT2000" 308 bool "XT2000"
309 select HAVE_IDE
253 help 310 help
254 XT2000 is the name of Tensilica's feature-rich emulation platform. 311 XT2000 is the name of Tensilica's feature-rich emulation platform.
255 This hardware is capable of running a full Linux distribution. 312 This hardware is capable of running a full Linux distribution.
256 313
257config XTENSA_PLATFORM_S6105 314config XTENSA_PLATFORM_S6105
258 bool "S6105" 315 bool "S6105"
316 select HAVE_IDE
259 select SERIAL_CONSOLE 317 select SERIAL_CONSOLE
260 select NO_IOPORT_MAP 318 select NO_IOPORT_MAP
261 319
diff --git a/arch/xtensa/Makefile b/arch/xtensa/Makefile
index 81250ece3062..472533064b46 100644
--- a/arch/xtensa/Makefile
+++ b/arch/xtensa/Makefile
@@ -4,6 +4,7 @@
4# for more details. 4# for more details.
5# 5#
6# Copyright (C) 2001 - 2005 Tensilica Inc. 6# Copyright (C) 2001 - 2005 Tensilica Inc.
7# Copyright (C) 2014 Cadence Design Systems Inc.
7# 8#
8# This file is included by the global makefile so that you can add your own 9# This file is included by the global makefile so that you can add your own
9# architecture-specific flags and dependencies. Remember to do have actions 10# architecture-specific flags and dependencies. Remember to do have actions
@@ -13,11 +14,7 @@
13# Core configuration. 14# Core configuration.
14# (Use VAR=<xtensa_config> to use another default compiler.) 15# (Use VAR=<xtensa_config> to use another default compiler.)
15 16
16variant-$(CONFIG_XTENSA_VARIANT_FSF) := fsf 17variant-y := $(patsubst "%",%,$(CONFIG_XTENSA_VARIANT_NAME))
17variant-$(CONFIG_XTENSA_VARIANT_DC232B) := dc232b
18variant-$(CONFIG_XTENSA_VARIANT_DC233C) := dc233c
19variant-$(CONFIG_XTENSA_VARIANT_S6000) := s6000
20variant-$(CONFIG_XTENSA_VARIANT_LINUX_CUSTOM) := custom
21 18
22VARIANT = $(variant-y) 19VARIANT = $(variant-y)
23export VARIANT 20export VARIANT
diff --git a/arch/xtensa/boot/dts/kc705.dts b/arch/xtensa/boot/dts/kc705.dts
index 742a347be67a..c4d17a34ab86 100644
--- a/arch/xtensa/boot/dts/kc705.dts
+++ b/arch/xtensa/boot/dts/kc705.dts
@@ -4,8 +4,11 @@
4 4
5/ { 5/ {
6 compatible = "cdns,xtensa-kc705"; 6 compatible = "cdns,xtensa-kc705";
7 chosen {
8 bootargs = "earlycon=uart8250,mmio32,0xfd050020,115200n8 console=ttyS0,115200n8 ip=dhcp root=/dev/nfs rw debug memmap=0x38000000";
9 };
7 memory@0 { 10 memory@0 {
8 device_type = "memory"; 11 device_type = "memory";
9 reg = <0x00000000 0x08000000>; 12 reg = <0x00000000 0x38000000>;
10 }; 13 };
11}; 14};
diff --git a/arch/xtensa/configs/common_defconfig b/arch/xtensa/configs/common_defconfig
index f6000fe05119..721df1214bc3 100644
--- a/arch/xtensa/configs/common_defconfig
+++ b/arch/xtensa/configs/common_defconfig
@@ -66,7 +66,6 @@ CONFIG_XTENSA_ARCH_LINUX_BE=y
66CONFIG_MMU=y 66CONFIG_MMU=y
67# CONFIG_XTENSA_UNALIGNED_USER is not set 67# CONFIG_XTENSA_UNALIGNED_USER is not set
68# CONFIG_PREEMPT is not set 68# CONFIG_PREEMPT is not set
69# CONFIG_MATH_EMULATION is not set
70# CONFIG_HIGHMEM is not set 69# CONFIG_HIGHMEM is not set
71 70
72# 71#
diff --git a/arch/xtensa/configs/iss_defconfig b/arch/xtensa/configs/iss_defconfig
index 1493c68352d1..b966baf82cae 100644
--- a/arch/xtensa/configs/iss_defconfig
+++ b/arch/xtensa/configs/iss_defconfig
@@ -146,7 +146,6 @@ CONFIG_XTENSA_VARIANT_FSF=y
146# CONFIG_XTENSA_VARIANT_S6000 is not set 146# CONFIG_XTENSA_VARIANT_S6000 is not set
147# CONFIG_XTENSA_UNALIGNED_USER is not set 147# CONFIG_XTENSA_UNALIGNED_USER is not set
148# CONFIG_PREEMPT is not set 148# CONFIG_PREEMPT is not set
149# CONFIG_MATH_EMULATION is not set
150CONFIG_XTENSA_CALIBRATE_CCOUNT=y 149CONFIG_XTENSA_CALIBRATE_CCOUNT=y
151CONFIG_SERIAL_CONSOLE=y 150CONFIG_SERIAL_CONSOLE=y
152CONFIG_XTENSA_ISS_NETWORK=y 151CONFIG_XTENSA_ISS_NETWORK=y
@@ -308,7 +307,7 @@ CONFIG_MISC_DEVICES=y
308# EEPROM support 307# EEPROM support
309# 308#
310# CONFIG_EEPROM_93CX6 is not set 309# CONFIG_EEPROM_93CX6 is not set
311CONFIG_HAVE_IDE=y 310# CONFIG_HAVE_IDE is not set
312# CONFIG_IDE is not set 311# CONFIG_IDE is not set
313 312
314# 313#
diff --git a/arch/xtensa/configs/s6105_defconfig b/arch/xtensa/configs/s6105_defconfig
index 12a492ab6d17..9471265b8ca6 100644
--- a/arch/xtensa/configs/s6105_defconfig
+++ b/arch/xtensa/configs/s6105_defconfig
@@ -109,7 +109,6 @@ CONFIG_VARIANT_IRQ_SWITCH=y
109CONFIG_XTENSA_VARIANT_S6000=y 109CONFIG_XTENSA_VARIANT_S6000=y
110# CONFIG_XTENSA_UNALIGNED_USER is not set 110# CONFIG_XTENSA_UNALIGNED_USER is not set
111CONFIG_PREEMPT=y 111CONFIG_PREEMPT=y
112# CONFIG_MATH_EMULATION is not set
113# CONFIG_HIGHMEM is not set 112# CONFIG_HIGHMEM is not set
114CONFIG_XTENSA_CALIBRATE_CCOUNT=y 113CONFIG_XTENSA_CALIBRATE_CCOUNT=y
115CONFIG_SERIAL_CONSOLE=y 114CONFIG_SERIAL_CONSOLE=y
diff --git a/arch/xtensa/include/asm/cacheflush.h b/arch/xtensa/include/asm/cacheflush.h
index 555a98a18453..e72aaca7a77f 100644
--- a/arch/xtensa/include/asm/cacheflush.h
+++ b/arch/xtensa/include/asm/cacheflush.h
@@ -37,6 +37,7 @@
37 * specials for cache aliasing: 37 * specials for cache aliasing:
38 * 38 *
39 * __flush_invalidate_dcache_page_alias(vaddr,paddr) 39 * __flush_invalidate_dcache_page_alias(vaddr,paddr)
40 * __invalidate_dcache_page_alias(vaddr,paddr)
40 * __invalidate_icache_page_alias(vaddr,paddr) 41 * __invalidate_icache_page_alias(vaddr,paddr)
41 */ 42 */
42 43
@@ -62,6 +63,7 @@ extern void __flush_invalidate_dcache_range(unsigned long, unsigned long);
62 63
63#if defined(CONFIG_MMU) && (DCACHE_WAY_SIZE > PAGE_SIZE) 64#if defined(CONFIG_MMU) && (DCACHE_WAY_SIZE > PAGE_SIZE)
64extern void __flush_invalidate_dcache_page_alias(unsigned long, unsigned long); 65extern void __flush_invalidate_dcache_page_alias(unsigned long, unsigned long);
66extern void __invalidate_dcache_page_alias(unsigned long, unsigned long);
65#else 67#else
66static inline void __flush_invalidate_dcache_page_alias(unsigned long virt, 68static inline void __flush_invalidate_dcache_page_alias(unsigned long virt,
67 unsigned long phys) { } 69 unsigned long phys) { }
diff --git a/arch/xtensa/include/asm/fixmap.h b/arch/xtensa/include/asm/fixmap.h
index 9f6c33d0428a..62b507deea9d 100644
--- a/arch/xtensa/include/asm/fixmap.h
+++ b/arch/xtensa/include/asm/fixmap.h
@@ -23,8 +23,8 @@
23 * Here we define all the compile-time 'special' virtual 23 * Here we define all the compile-time 'special' virtual
24 * addresses. The point is to have a constant address at 24 * addresses. The point is to have a constant address at
25 * compile time, but to set the physical address only 25 * compile time, but to set the physical address only
26 * in the boot process. We allocate these special addresses 26 * in the boot process. We allocate these special addresses
27 * from the end of the consistent memory region backwards. 27 * from the start of the consistent memory region upwards.
28 * Also this lets us do fail-safe vmalloc(), we 28 * Also this lets us do fail-safe vmalloc(), we
29 * can guarantee that these special addresses and 29 * can guarantee that these special addresses and
30 * vmalloc()-ed addresses never overlap. 30 * vmalloc()-ed addresses never overlap.
@@ -38,7 +38,8 @@ enum fixed_addresses {
38#ifdef CONFIG_HIGHMEM 38#ifdef CONFIG_HIGHMEM
39 /* reserved pte's for temporary kernel mappings */ 39 /* reserved pte's for temporary kernel mappings */
40 FIX_KMAP_BEGIN, 40 FIX_KMAP_BEGIN,
41 FIX_KMAP_END = FIX_KMAP_BEGIN + (KM_TYPE_NR * NR_CPUS) - 1, 41 FIX_KMAP_END = FIX_KMAP_BEGIN +
42 (KM_TYPE_NR * NR_CPUS * DCACHE_N_COLORS) - 1,
42#endif 43#endif
43 __end_of_fixed_addresses 44 __end_of_fixed_addresses
44}; 45};
@@ -47,7 +48,28 @@ enum fixed_addresses {
47#define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT) 48#define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
48#define FIXADDR_START ((FIXADDR_TOP - FIXADDR_SIZE) & PMD_MASK) 49#define FIXADDR_START ((FIXADDR_TOP - FIXADDR_SIZE) & PMD_MASK)
49 50
50#include <asm-generic/fixmap.h> 51#define __fix_to_virt(x) (FIXADDR_START + ((x) << PAGE_SHIFT))
52#define __virt_to_fix(x) (((x) - FIXADDR_START) >> PAGE_SHIFT)
53
54#ifndef __ASSEMBLY__
55/*
56 * 'index to address' translation. If anyone tries to use the idx
57 * directly without translation, we catch the bug with a NULL-deference
58 * kernel oops. Illegal ranges of incoming indices are caught too.
59 */
60static __always_inline unsigned long fix_to_virt(const unsigned int idx)
61{
62 BUILD_BUG_ON(idx >= __end_of_fixed_addresses);
63 return __fix_to_virt(idx);
64}
65
66static inline unsigned long virt_to_fix(const unsigned long vaddr)
67{
68 BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
69 return __virt_to_fix(vaddr);
70}
71
72#endif
51 73
52#define kmap_get_fixmap_pte(vaddr) \ 74#define kmap_get_fixmap_pte(vaddr) \
53 pte_offset_kernel( \ 75 pte_offset_kernel( \
diff --git a/arch/xtensa/include/asm/highmem.h b/arch/xtensa/include/asm/highmem.h
index 2653ef5d55f1..2c7901edffaf 100644
--- a/arch/xtensa/include/asm/highmem.h
+++ b/arch/xtensa/include/asm/highmem.h
@@ -12,19 +12,55 @@
12#ifndef _XTENSA_HIGHMEM_H 12#ifndef _XTENSA_HIGHMEM_H
13#define _XTENSA_HIGHMEM_H 13#define _XTENSA_HIGHMEM_H
14 14
15#include <linux/wait.h>
15#include <asm/cacheflush.h> 16#include <asm/cacheflush.h>
16#include <asm/fixmap.h> 17#include <asm/fixmap.h>
17#include <asm/kmap_types.h> 18#include <asm/kmap_types.h>
18#include <asm/pgtable.h> 19#include <asm/pgtable.h>
19 20
20#define PKMAP_BASE (FIXADDR_START - PMD_SIZE) 21#define PKMAP_BASE ((FIXADDR_START - \
21#define LAST_PKMAP PTRS_PER_PTE 22 (LAST_PKMAP + 1) * PAGE_SIZE) & PMD_MASK)
23#define LAST_PKMAP (PTRS_PER_PTE * DCACHE_N_COLORS)
22#define LAST_PKMAP_MASK (LAST_PKMAP - 1) 24#define LAST_PKMAP_MASK (LAST_PKMAP - 1)
23#define PKMAP_NR(virt) (((virt) - PKMAP_BASE) >> PAGE_SHIFT) 25#define PKMAP_NR(virt) (((virt) - PKMAP_BASE) >> PAGE_SHIFT)
24#define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT)) 26#define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT))
25 27
26#define kmap_prot PAGE_KERNEL 28#define kmap_prot PAGE_KERNEL
27 29
30#if DCACHE_WAY_SIZE > PAGE_SIZE
31#define get_pkmap_color get_pkmap_color
32static inline int get_pkmap_color(struct page *page)
33{
34 return DCACHE_ALIAS(page_to_phys(page));
35}
36
37extern unsigned int last_pkmap_nr_arr[];
38
39static inline unsigned int get_next_pkmap_nr(unsigned int color)
40{
41 last_pkmap_nr_arr[color] =
42 (last_pkmap_nr_arr[color] + DCACHE_N_COLORS) & LAST_PKMAP_MASK;
43 return last_pkmap_nr_arr[color] + color;
44}
45
46static inline int no_more_pkmaps(unsigned int pkmap_nr, unsigned int color)
47{
48 return pkmap_nr < DCACHE_N_COLORS;
49}
50
51static inline int get_pkmap_entries_count(unsigned int color)
52{
53 return LAST_PKMAP / DCACHE_N_COLORS;
54}
55
56extern wait_queue_head_t pkmap_map_wait_arr[];
57
58static inline wait_queue_head_t *get_pkmap_wait_queue_head(unsigned int color)
59{
60 return pkmap_map_wait_arr + color;
61}
62#endif
63
28extern pte_t *pkmap_page_table; 64extern pte_t *pkmap_page_table;
29 65
30void *kmap_high(struct page *page); 66void *kmap_high(struct page *page);
diff --git a/arch/xtensa/include/asm/page.h b/arch/xtensa/include/asm/page.h
index 47f582333f6b..abe24c6f8b2f 100644
--- a/arch/xtensa/include/asm/page.h
+++ b/arch/xtensa/include/asm/page.h
@@ -78,7 +78,9 @@
78# define DCACHE_ALIAS_EQ(a,b) ((((a) ^ (b)) & DCACHE_ALIAS_MASK) == 0) 78# define DCACHE_ALIAS_EQ(a,b) ((((a) ^ (b)) & DCACHE_ALIAS_MASK) == 0)
79#else 79#else
80# define DCACHE_ALIAS_ORDER 0 80# define DCACHE_ALIAS_ORDER 0
81# define DCACHE_ALIAS(a) ((void)(a), 0)
81#endif 82#endif
83#define DCACHE_N_COLORS (1 << DCACHE_ALIAS_ORDER)
82 84
83#if ICACHE_WAY_SIZE > PAGE_SIZE 85#if ICACHE_WAY_SIZE > PAGE_SIZE
84# define ICACHE_ALIAS_ORDER (ICACHE_WAY_SHIFT - PAGE_SHIFT) 86# define ICACHE_ALIAS_ORDER (ICACHE_WAY_SHIFT - PAGE_SHIFT)
@@ -134,6 +136,7 @@ static inline __attribute_const__ int get_order(unsigned long size)
134#endif 136#endif
135 137
136struct page; 138struct page;
139struct vm_area_struct;
137extern void clear_page(void *page); 140extern void clear_page(void *page);
138extern void copy_page(void *to, void *from); 141extern void copy_page(void *to, void *from);
139 142
@@ -143,8 +146,15 @@ extern void copy_page(void *to, void *from);
143 */ 146 */
144 147
145#if DCACHE_WAY_SIZE > PAGE_SIZE 148#if DCACHE_WAY_SIZE > PAGE_SIZE
146extern void clear_user_page(void*, unsigned long, struct page*); 149extern void clear_page_alias(void *vaddr, unsigned long paddr);
147extern void copy_user_page(void*, void*, unsigned long, struct page*); 150extern void copy_page_alias(void *to, void *from,
151 unsigned long to_paddr, unsigned long from_paddr);
152
153#define clear_user_highpage clear_user_highpage
154void clear_user_highpage(struct page *page, unsigned long vaddr);
155#define __HAVE_ARCH_COPY_USER_HIGHPAGE
156void copy_user_highpage(struct page *to, struct page *from,
157 unsigned long vaddr, struct vm_area_struct *vma);
148#else 158#else
149# define clear_user_page(page, vaddr, pg) clear_page(page) 159# define clear_user_page(page, vaddr, pg) clear_page(page)
150# define copy_user_page(to, from, vaddr, pg) copy_page(to, from) 160# define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
diff --git a/arch/xtensa/include/asm/pgtable.h b/arch/xtensa/include/asm/pgtable.h
index 4b0ca35a93b1..b2173e5da601 100644
--- a/arch/xtensa/include/asm/pgtable.h
+++ b/arch/xtensa/include/asm/pgtable.h
@@ -67,7 +67,12 @@
67#define VMALLOC_START 0xC0000000 67#define VMALLOC_START 0xC0000000
68#define VMALLOC_END 0xC7FEFFFF 68#define VMALLOC_END 0xC7FEFFFF
69#define TLBTEMP_BASE_1 0xC7FF0000 69#define TLBTEMP_BASE_1 0xC7FF0000
70#define TLBTEMP_BASE_2 0xC7FF8000 70#define TLBTEMP_BASE_2 (TLBTEMP_BASE_1 + DCACHE_WAY_SIZE)
71#if 2 * DCACHE_WAY_SIZE > ICACHE_WAY_SIZE
72#define TLBTEMP_SIZE (2 * DCACHE_WAY_SIZE)
73#else
74#define TLBTEMP_SIZE ICACHE_WAY_SIZE
75#endif
71 76
72/* 77/*
73 * For the Xtensa architecture, the PTE layout is as follows: 78 * For the Xtensa architecture, the PTE layout is as follows:
diff --git a/arch/xtensa/include/asm/uaccess.h b/arch/xtensa/include/asm/uaccess.h
index fd686dc45d1a..c7211e7e182d 100644
--- a/arch/xtensa/include/asm/uaccess.h
+++ b/arch/xtensa/include/asm/uaccess.h
@@ -52,7 +52,12 @@
52 */ 52 */
53 .macro get_fs ad, sp 53 .macro get_fs ad, sp
54 GET_CURRENT(\ad,\sp) 54 GET_CURRENT(\ad,\sp)
55#if THREAD_CURRENT_DS > 1020
56 addi \ad, \ad, TASK_THREAD
57 l32i \ad, \ad, THREAD_CURRENT_DS - TASK_THREAD
58#else
55 l32i \ad, \ad, THREAD_CURRENT_DS 59 l32i \ad, \ad, THREAD_CURRENT_DS
60#endif
56 .endm 61 .endm
57 62
58/* 63/*
diff --git a/arch/xtensa/include/uapi/asm/ioctls.h b/arch/xtensa/include/uapi/asm/ioctls.h
index b4cb1100c0fb..a47909f0c34b 100644
--- a/arch/xtensa/include/uapi/asm/ioctls.h
+++ b/arch/xtensa/include/uapi/asm/ioctls.h
@@ -28,17 +28,17 @@
28#define TCSETSW 0x5403 28#define TCSETSW 0x5403
29#define TCSETSF 0x5404 29#define TCSETSF 0x5404
30 30
31#define TCGETA _IOR('t', 23, struct termio) 31#define TCGETA 0x80127417 /* _IOR('t', 23, struct termio) */
32#define TCSETA _IOW('t', 24, struct termio) 32#define TCSETA 0x40127418 /* _IOW('t', 24, struct termio) */
33#define TCSETAW _IOW('t', 25, struct termio) 33#define TCSETAW 0x40127419 /* _IOW('t', 25, struct termio) */
34#define TCSETAF _IOW('t', 28, struct termio) 34#define TCSETAF 0x4012741C /* _IOW('t', 28, struct termio) */
35 35
36#define TCSBRK _IO('t', 29) 36#define TCSBRK _IO('t', 29)
37#define TCXONC _IO('t', 30) 37#define TCXONC _IO('t', 30)
38#define TCFLSH _IO('t', 31) 38#define TCFLSH _IO('t', 31)
39 39
40#define TIOCSWINSZ _IOW('t', 103, struct winsize) 40#define TIOCSWINSZ 0x40087467 /* _IOW('t', 103, struct winsize) */
41#define TIOCGWINSZ _IOR('t', 104, struct winsize) 41#define TIOCGWINSZ 0x80087468 /* _IOR('t', 104, struct winsize) */
42#define TIOCSTART _IO('t', 110) /* start output, like ^Q */ 42#define TIOCSTART _IO('t', 110) /* start output, like ^Q */
43#define TIOCSTOP _IO('t', 111) /* stop output, like ^S */ 43#define TIOCSTOP _IO('t', 111) /* stop output, like ^S */
44#define TIOCOUTQ _IOR('t', 115, int) /* output queue size */ 44#define TIOCOUTQ _IOR('t', 115, int) /* output queue size */
@@ -88,7 +88,6 @@
88#define TIOCSETD _IOW('T', 35, int) 88#define TIOCSETD _IOW('T', 35, int)
89#define TIOCGETD _IOR('T', 36, int) 89#define TIOCGETD _IOR('T', 36, int)
90#define TCSBRKP _IOW('T', 37, int) /* Needed for POSIX tcsendbreak()*/ 90#define TCSBRKP _IOW('T', 37, int) /* Needed for POSIX tcsendbreak()*/
91#define TIOCTTYGSTRUCT _IOR('T', 38, struct tty_struct) /* For debugging only*/
92#define TIOCSBRK _IO('T', 39) /* BSD compatibility */ 91#define TIOCSBRK _IO('T', 39) /* BSD compatibility */
93#define TIOCCBRK _IO('T', 40) /* BSD compatibility */ 92#define TIOCCBRK _IO('T', 40) /* BSD compatibility */
94#define TIOCGSID _IOR('T', 41, pid_t) /* Return the session ID of FD*/ 93#define TIOCGSID _IOR('T', 41, pid_t) /* Return the session ID of FD*/
@@ -114,8 +113,10 @@
114#define TIOCSERGETLSR _IOR('T', 89, unsigned int) /* Get line status reg. */ 113#define TIOCSERGETLSR _IOR('T', 89, unsigned int) /* Get line status reg. */
115 /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ 114 /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
116# define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ 115# define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
117#define TIOCSERGETMULTI _IOR('T', 90, struct serial_multiport_struct) /* Get multiport config */ 116#define TIOCSERGETMULTI 0x80a8545a /* Get multiport config */
118#define TIOCSERSETMULTI _IOW('T', 91, struct serial_multiport_struct) /* Set multiport config */ 117 /* _IOR('T', 90, struct serial_multiport_struct) */
118#define TIOCSERSETMULTI 0x40a8545b /* Set multiport config */
119 /* _IOW('T', 91, struct serial_multiport_struct) */
119 120
120#define TIOCMIWAIT _IO('T', 92) /* wait for a change on serial input line(s) */ 121#define TIOCMIWAIT _IO('T', 92) /* wait for a change on serial input line(s) */
121#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ 122#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
diff --git a/arch/xtensa/include/uapi/asm/unistd.h b/arch/xtensa/include/uapi/asm/unistd.h
index b9395529f02d..8883fc877c5c 100644
--- a/arch/xtensa/include/uapi/asm/unistd.h
+++ b/arch/xtensa/include/uapi/asm/unistd.h
@@ -739,7 +739,10 @@ __SYSCALL(334, sys_sched_setattr, 2)
739#define __NR_sched_getattr 335 739#define __NR_sched_getattr 335
740__SYSCALL(335, sys_sched_getattr, 3) 740__SYSCALL(335, sys_sched_getattr, 3)
741 741
742#define __NR_syscall_count 336 742#define __NR_renameat2 336
743__SYSCALL(336, sys_renameat2, 5)
744
745#define __NR_syscall_count 337
743 746
744/* 747/*
745 * sysxtensa syscall handler 748 * sysxtensa syscall handler
diff --git a/arch/xtensa/kernel/align.S b/arch/xtensa/kernel/align.S
index d4cef6039a5c..890004af03a9 100644
--- a/arch/xtensa/kernel/align.S
+++ b/arch/xtensa/kernel/align.S
@@ -8,6 +8,7 @@
8 * this archive for more details. 8 * this archive for more details.
9 * 9 *
10 * Copyright (C) 2001 - 2005 Tensilica, Inc. 10 * Copyright (C) 2001 - 2005 Tensilica, Inc.
11 * Copyright (C) 2014 Cadence Design Systems Inc.
11 * 12 *
12 * Rewritten by Chris Zankel <chris@zankel.net> 13 * Rewritten by Chris Zankel <chris@zankel.net>
13 * 14 *
@@ -174,6 +175,10 @@ ENTRY(fast_unaligned)
174 s32i a0, a2, PT_AREG2 175 s32i a0, a2, PT_AREG2
175 s32i a3, a2, PT_AREG3 176 s32i a3, a2, PT_AREG3
176 177
178 rsr a3, excsave1
179 movi a4, fast_unaligned_fixup
180 s32i a4, a3, EXC_TABLE_FIXUP
181
177 /* Keep value of SAR in a0 */ 182 /* Keep value of SAR in a0 */
178 183
179 rsr a0, sar 184 rsr a0, sar
@@ -225,10 +230,6 @@ ENTRY(fast_unaligned)
225 addx8 a5, a6, a5 230 addx8 a5, a6, a5
226 jx a5 # jump into table 231 jx a5 # jump into table
227 232
228 /* Invalid instruction, CRITICAL! */
229.Linvalid_instruction_load:
230 j .Linvalid_instruction
231
232 /* Load: Load memory address. */ 233 /* Load: Load memory address. */
233 234
234.Lload: movi a3, ~3 235.Lload: movi a3, ~3
@@ -272,18 +273,6 @@ ENTRY(fast_unaligned)
272 /* Set target register. */ 273 /* Set target register. */
273 274
2741: 2751:
275
276#if XCHAL_HAVE_LOOPS
277 rsr a5, lend # check if we reached LEND
278 bne a7, a5, 1f
279 rsr a5, lcount # and LCOUNT != 0
280 beqz a5, 1f
281 addi a5, a5, -1 # decrement LCOUNT and set
282 rsr a7, lbeg # set PC to LBEGIN
283 wsr a5, lcount
284#endif
285
2861: wsr a7, epc1 # skip load instruction
287 extui a4, a4, INSN_T, 4 # extract target register 276 extui a4, a4, INSN_T, 4 # extract target register
288 movi a5, .Lload_table 277 movi a5, .Lload_table
289 addx8 a4, a4, a5 278 addx8 a4, a4, a5
@@ -326,6 +315,35 @@ ENTRY(fast_unaligned)
326 mov a3, a14 ; _j 1f; .align 8 315 mov a3, a14 ; _j 1f; .align 8
327 mov a3, a15 ; _j 1f; .align 8 316 mov a3, a15 ; _j 1f; .align 8
328 317
318 /* We cannot handle this exception. */
319
320 .extern _kernel_exception
321.Linvalid_instruction_load:
322.Linvalid_instruction_store:
323
324 movi a4, 0
325 rsr a3, excsave1
326 s32i a4, a3, EXC_TABLE_FIXUP
327
328 /* Restore a4...a8 and SAR, set SP, and jump to default exception. */
329
330 l32i a8, a2, PT_AREG8
331 l32i a7, a2, PT_AREG7
332 l32i a6, a2, PT_AREG6
333 l32i a5, a2, PT_AREG5
334 l32i a4, a2, PT_AREG4
335 wsr a0, sar
336 mov a1, a2
337
338 rsr a0, ps
339 bbsi.l a0, PS_UM_BIT, 2f # jump if user mode
340
341 movi a0, _kernel_exception
342 jx a0
343
3442: movi a0, _user_exception
345 jx a0
346
3291: # a7: instruction pointer, a4: instruction, a3: value 3471: # a7: instruction pointer, a4: instruction, a3: value
330 348
331 movi a6, 0 # mask: ffffffff:00000000 349 movi a6, 0 # mask: ffffffff:00000000
@@ -353,17 +371,6 @@ ENTRY(fast_unaligned)
353 /* Get memory address */ 371 /* Get memory address */
354 372
3551: 3731:
356#if XCHAL_HAVE_LOOPS
357 rsr a4, lend # check if we reached LEND
358 bne a7, a4, 1f
359 rsr a4, lcount # and LCOUNT != 0
360 beqz a4, 1f
361 addi a4, a4, -1 # decrement LCOUNT and set
362 rsr a7, lbeg # set PC to LBEGIN
363 wsr a4, lcount
364#endif
365
3661: wsr a7, epc1 # skip store instruction
367 movi a4, ~3 374 movi a4, ~3
368 and a4, a4, a8 # align memory address 375 and a4, a4, a8 # align memory address
369 376
@@ -375,25 +382,25 @@ ENTRY(fast_unaligned)
375#endif 382#endif
376 383
377 __ssa8r a8 384 __ssa8r a8
378 __src_b a7, a5, a6 # lo-mask F..F0..0 (BE) 0..0F..F (LE) 385 __src_b a8, a5, a6 # lo-mask F..F0..0 (BE) 0..0F..F (LE)
379 __src_b a6, a6, a5 # hi-mask 0..0F..F (BE) F..F0..0 (LE) 386 __src_b a6, a6, a5 # hi-mask 0..0F..F (BE) F..F0..0 (LE)
380#ifdef UNALIGNED_USER_EXCEPTION 387#ifdef UNALIGNED_USER_EXCEPTION
381 l32e a5, a4, -8 388 l32e a5, a4, -8
382#else 389#else
383 l32i a5, a4, 0 # load lower address word 390 l32i a5, a4, 0 # load lower address word
384#endif 391#endif
385 and a5, a5, a7 # mask 392 and a5, a5, a8 # mask
386 __sh a7, a3 # shift value 393 __sh a8, a3 # shift value
387 or a5, a5, a7 # or with original value 394 or a5, a5, a8 # or with original value
388#ifdef UNALIGNED_USER_EXCEPTION 395#ifdef UNALIGNED_USER_EXCEPTION
389 s32e a5, a4, -8 396 s32e a5, a4, -8
390 l32e a7, a4, -4 397 l32e a8, a4, -4
391#else 398#else
392 s32i a5, a4, 0 # store 399 s32i a5, a4, 0 # store
393 l32i a7, a4, 4 # same for upper address word 400 l32i a8, a4, 4 # same for upper address word
394#endif 401#endif
395 __sl a5, a3 402 __sl a5, a3
396 and a6, a7, a6 403 and a6, a8, a6
397 or a6, a6, a5 404 or a6, a6, a5
398#ifdef UNALIGNED_USER_EXCEPTION 405#ifdef UNALIGNED_USER_EXCEPTION
399 s32e a6, a4, -4 406 s32e a6, a4, -4
@@ -401,9 +408,27 @@ ENTRY(fast_unaligned)
401 s32i a6, a4, 4 408 s32i a6, a4, 4
402#endif 409#endif
403 410
404 /* Done. restore stack and return */
405
406.Lexit: 411.Lexit:
412#if XCHAL_HAVE_LOOPS
413 rsr a4, lend # check if we reached LEND
414 bne a7, a4, 1f
415 rsr a4, lcount # and LCOUNT != 0
416 beqz a4, 1f
417 addi a4, a4, -1 # decrement LCOUNT and set
418 rsr a7, lbeg # set PC to LBEGIN
419 wsr a4, lcount
420#endif
421
4221: wsr a7, epc1 # skip emulated instruction
423
424 /* Update icount if we're single-stepping in userspace. */
425 rsr a4, icountlevel
426 beqz a4, 1f
427 bgeui a4, LOCKLEVEL + 1, 1f
428 rsr a4, icount
429 addi a4, a4, 1
430 wsr a4, icount
4311:
407 movi a4, 0 432 movi a4, 0
408 rsr a3, excsave1 433 rsr a3, excsave1
409 s32i a4, a3, EXC_TABLE_FIXUP 434 s32i a4, a3, EXC_TABLE_FIXUP
@@ -424,31 +449,40 @@ ENTRY(fast_unaligned)
424 l32i a2, a2, PT_AREG2 449 l32i a2, a2, PT_AREG2
425 rfe 450 rfe
426 451
427 /* We cannot handle this exception. */ 452ENDPROC(fast_unaligned)
428 453
429 .extern _kernel_exception 454ENTRY(fast_unaligned_fixup)
430.Linvalid_instruction_store:
431.Linvalid_instruction:
432 455
433 /* Restore a4...a8 and SAR, set SP, and jump to default exception. */ 456 l32i a2, a3, EXC_TABLE_DOUBLE_SAVE
457 wsr a3, excsave1
434 458
435 l32i a8, a2, PT_AREG8 459 l32i a8, a2, PT_AREG8
436 l32i a7, a2, PT_AREG7 460 l32i a7, a2, PT_AREG7
437 l32i a6, a2, PT_AREG6 461 l32i a6, a2, PT_AREG6
438 l32i a5, a2, PT_AREG5 462 l32i a5, a2, PT_AREG5
439 l32i a4, a2, PT_AREG4 463 l32i a4, a2, PT_AREG4
464 l32i a0, a2, PT_AREG2
465 xsr a0, depc # restore depc and a0
440 wsr a0, sar 466 wsr a0, sar
441 mov a1, a2 467
468 rsr a0, exccause
469 s32i a0, a2, PT_DEPC # mark as a regular exception
442 470
443 rsr a0, ps 471 rsr a0, ps
444 bbsi.l a2, PS_UM_BIT, 1f # jump if user mode 472 bbsi.l a0, PS_UM_BIT, 1f # jump if user mode
445 473
446 movi a0, _kernel_exception 474 rsr a0, exccause
475 addx4 a0, a0, a3 # find entry in table
476 l32i a0, a0, EXC_TABLE_FAST_KERNEL # load handler
477 l32i a3, a2, PT_AREG3
447 jx a0 478 jx a0
448 4791:
4491: movi a0, _user_exception 480 rsr a0, exccause
481 addx4 a0, a0, a3 # find entry in table
482 l32i a0, a0, EXC_TABLE_FAST_USER # load handler
483 l32i a3, a2, PT_AREG3
450 jx a0 484 jx a0
451 485
452ENDPROC(fast_unaligned) 486ENDPROC(fast_unaligned_fixup)
453 487
454#endif /* XCHAL_UNALIGNED_LOAD_EXCEPTION || XCHAL_UNALIGNED_STORE_EXCEPTION */ 488#endif /* XCHAL_UNALIGNED_LOAD_EXCEPTION || XCHAL_UNALIGNED_STORE_EXCEPTION */
diff --git a/arch/xtensa/kernel/entry.S b/arch/xtensa/kernel/entry.S
index ef7f4990722b..82bbfa5a05b3 100644
--- a/arch/xtensa/kernel/entry.S
+++ b/arch/xtensa/kernel/entry.S
@@ -986,6 +986,8 @@ ENDPROC(fast_syscall_unrecoverable)
986 * j done 986 * j done
987 */ 987 */
988 988
989#ifdef CONFIG_FAST_SYSCALL_XTENSA
990
989#define TRY \ 991#define TRY \
990 .section __ex_table, "a"; \ 992 .section __ex_table, "a"; \
991 .word 66f, 67f; \ 993 .word 66f, 67f; \
@@ -1001,9 +1003,8 @@ ENTRY(fast_syscall_xtensa)
1001 movi a7, 4 # sizeof(unsigned int) 1003 movi a7, 4 # sizeof(unsigned int)
1002 access_ok a3, a7, a0, a2, .Leac # a0: scratch reg, a2: sp 1004 access_ok a3, a7, a0, a2, .Leac # a0: scratch reg, a2: sp
1003 1005
1004 addi a6, a6, -1 # assuming SYS_XTENSA_ATOMIC_SET = 1 1006 _bgeui a6, SYS_XTENSA_COUNT, .Lill
1005 _bgeui a6, SYS_XTENSA_COUNT - 1, .Lill 1007 _bnei a6, SYS_XTENSA_ATOMIC_CMP_SWP, .Lnswp
1006 _bnei a6, SYS_XTENSA_ATOMIC_CMP_SWP - 1, .Lnswp
1007 1008
1008 /* Fall through for ATOMIC_CMP_SWP. */ 1009 /* Fall through for ATOMIC_CMP_SWP. */
1009 1010
@@ -1015,27 +1016,26 @@ TRY s32i a5, a3, 0 # different, modify value
1015 l32i a7, a2, PT_AREG7 # restore a7 1016 l32i a7, a2, PT_AREG7 # restore a7
1016 l32i a0, a2, PT_AREG0 # restore a0 1017 l32i a0, a2, PT_AREG0 # restore a0
1017 movi a2, 1 # and return 1 1018 movi a2, 1 # and return 1
1018 addi a6, a6, 1 # restore a6 (really necessary?)
1019 rfe 1019 rfe
1020 1020
10211: l32i a7, a2, PT_AREG7 # restore a7 10211: l32i a7, a2, PT_AREG7 # restore a7
1022 l32i a0, a2, PT_AREG0 # restore a0 1022 l32i a0, a2, PT_AREG0 # restore a0
1023 movi a2, 0 # return 0 (note that we cannot set 1023 movi a2, 0 # return 0 (note that we cannot set
1024 addi a6, a6, 1 # restore a6 (really necessary?)
1025 rfe 1024 rfe
1026 1025
1027.Lnswp: /* Atomic set, add, and exg_add. */ 1026.Lnswp: /* Atomic set, add, and exg_add. */
1028 1027
1029TRY l32i a7, a3, 0 # orig 1028TRY l32i a7, a3, 0 # orig
1029 addi a6, a6, -SYS_XTENSA_ATOMIC_SET
1030 add a0, a4, a7 # + arg 1030 add a0, a4, a7 # + arg
1031 moveqz a0, a4, a6 # set 1031 moveqz a0, a4, a6 # set
1032 addi a6, a6, SYS_XTENSA_ATOMIC_SET
1032TRY s32i a0, a3, 0 # write new value 1033TRY s32i a0, a3, 0 # write new value
1033 1034
1034 mov a0, a2 1035 mov a0, a2
1035 mov a2, a7 1036 mov a2, a7
1036 l32i a7, a0, PT_AREG7 # restore a7 1037 l32i a7, a0, PT_AREG7 # restore a7
1037 l32i a0, a0, PT_AREG0 # restore a0 1038 l32i a0, a0, PT_AREG0 # restore a0
1038 addi a6, a6, 1 # restore a6 (really necessary?)
1039 rfe 1039 rfe
1040 1040
1041CATCH 1041CATCH
@@ -1044,13 +1044,25 @@ CATCH
1044 movi a2, -EFAULT 1044 movi a2, -EFAULT
1045 rfe 1045 rfe
1046 1046
1047.Lill: l32i a7, a2, PT_AREG0 # restore a7 1047.Lill: l32i a7, a2, PT_AREG7 # restore a7
1048 l32i a0, a2, PT_AREG0 # restore a0 1048 l32i a0, a2, PT_AREG0 # restore a0
1049 movi a2, -EINVAL 1049 movi a2, -EINVAL
1050 rfe 1050 rfe
1051 1051
1052ENDPROC(fast_syscall_xtensa) 1052ENDPROC(fast_syscall_xtensa)
1053 1053
1054#else /* CONFIG_FAST_SYSCALL_XTENSA */
1055
1056ENTRY(fast_syscall_xtensa)
1057
1058 l32i a0, a2, PT_AREG0 # restore a0
1059 movi a2, -ENOSYS
1060 rfe
1061
1062ENDPROC(fast_syscall_xtensa)
1063
1064#endif /* CONFIG_FAST_SYSCALL_XTENSA */
1065
1054 1066
1055/* fast_syscall_spill_registers. 1067/* fast_syscall_spill_registers.
1056 * 1068 *
@@ -1066,6 +1078,8 @@ ENDPROC(fast_syscall_xtensa)
1066 * Note: We assume the stack pointer is EXC_TABLE_KSTK in the fixup handler. 1078 * Note: We assume the stack pointer is EXC_TABLE_KSTK in the fixup handler.
1067 */ 1079 */
1068 1080
1081#ifdef CONFIG_FAST_SYSCALL_SPILL_REGISTERS
1082
1069ENTRY(fast_syscall_spill_registers) 1083ENTRY(fast_syscall_spill_registers)
1070 1084
1071 /* Register a FIXUP handler (pass current wb as a parameter) */ 1085 /* Register a FIXUP handler (pass current wb as a parameter) */
@@ -1400,6 +1414,18 @@ ENTRY(fast_syscall_spill_registers_fixup_return)
1400 1414
1401ENDPROC(fast_syscall_spill_registers_fixup_return) 1415ENDPROC(fast_syscall_spill_registers_fixup_return)
1402 1416
1417#else /* CONFIG_FAST_SYSCALL_SPILL_REGISTERS */
1418
1419ENTRY(fast_syscall_spill_registers)
1420
1421 l32i a0, a2, PT_AREG0 # restore a0
1422 movi a2, -ENOSYS
1423 rfe
1424
1425ENDPROC(fast_syscall_spill_registers)
1426
1427#endif /* CONFIG_FAST_SYSCALL_SPILL_REGISTERS */
1428
1403#ifdef CONFIG_MMU 1429#ifdef CONFIG_MMU
1404/* 1430/*
1405 * We should never get here. Bail out! 1431 * We should never get here. Bail out!
@@ -1565,7 +1591,7 @@ ENTRY(fast_second_level_miss)
1565 rsr a0, excvaddr 1591 rsr a0, excvaddr
1566 bltu a0, a3, 2f 1592 bltu a0, a3, 2f
1567 1593
1568 addi a1, a0, -(2 << (DCACHE_ALIAS_ORDER + PAGE_SHIFT)) 1594 addi a1, a0, -TLBTEMP_SIZE
1569 bgeu a1, a3, 2f 1595 bgeu a1, a3, 2f
1570 1596
1571 /* Check if we have to restore an ITLB mapping. */ 1597 /* Check if we have to restore an ITLB mapping. */
@@ -1820,7 +1846,6 @@ ENTRY(_switch_to)
1820 1846
1821 entry a1, 16 1847 entry a1, 16
1822 1848
1823 mov a10, a2 # preserve 'prev' (a2)
1824 mov a11, a3 # and 'next' (a3) 1849 mov a11, a3 # and 'next' (a3)
1825 1850
1826 l32i a4, a2, TASK_THREAD_INFO 1851 l32i a4, a2, TASK_THREAD_INFO
@@ -1828,8 +1853,14 @@ ENTRY(_switch_to)
1828 1853
1829 save_xtregs_user a4 a6 a8 a9 a12 a13 THREAD_XTREGS_USER 1854 save_xtregs_user a4 a6 a8 a9 a12 a13 THREAD_XTREGS_USER
1830 1855
1831 s32i a0, a10, THREAD_RA # save return address 1856#if THREAD_RA > 1020 || THREAD_SP > 1020
1832 s32i a1, a10, THREAD_SP # save stack pointer 1857 addi a10, a2, TASK_THREAD
1858 s32i a0, a10, THREAD_RA - TASK_THREAD # save return address
1859 s32i a1, a10, THREAD_SP - TASK_THREAD # save stack pointer
1860#else
1861 s32i a0, a2, THREAD_RA # save return address
1862 s32i a1, a2, THREAD_SP # save stack pointer
1863#endif
1833 1864
1834 /* Disable ints while we manipulate the stack pointer. */ 1865 /* Disable ints while we manipulate the stack pointer. */
1835 1866
@@ -1870,7 +1901,6 @@ ENTRY(_switch_to)
1870 load_xtregs_user a5 a6 a8 a9 a12 a13 THREAD_XTREGS_USER 1901 load_xtregs_user a5 a6 a8 a9 a12 a13 THREAD_XTREGS_USER
1871 1902
1872 wsr a14, ps 1903 wsr a14, ps
1873 mov a2, a10 # return 'prev'
1874 rsync 1904 rsync
1875 1905
1876 retw 1906 retw
diff --git a/arch/xtensa/kernel/pci-dma.c b/arch/xtensa/kernel/pci-dma.c
index 2d9cc6dbfd78..e8b76b8e4b29 100644
--- a/arch/xtensa/kernel/pci-dma.c
+++ b/arch/xtensa/kernel/pci-dma.c
@@ -49,9 +49,8 @@ dma_alloc_coherent(struct device *dev,size_t size,dma_addr_t *handle,gfp_t flag)
49 49
50 /* We currently don't support coherent memory outside KSEG */ 50 /* We currently don't support coherent memory outside KSEG */
51 51
52 if (ret < XCHAL_KSEG_CACHED_VADDR 52 BUG_ON(ret < XCHAL_KSEG_CACHED_VADDR ||
53 || ret >= XCHAL_KSEG_CACHED_VADDR + XCHAL_KSEG_SIZE) 53 ret > XCHAL_KSEG_CACHED_VADDR + XCHAL_KSEG_SIZE - 1);
54 BUG();
55 54
56 55
57 if (ret != 0) { 56 if (ret != 0) {
@@ -68,10 +67,11 @@ EXPORT_SYMBOL(dma_alloc_coherent);
68void dma_free_coherent(struct device *hwdev, size_t size, 67void dma_free_coherent(struct device *hwdev, size_t size,
69 void *vaddr, dma_addr_t dma_handle) 68 void *vaddr, dma_addr_t dma_handle)
70{ 69{
71 long addr=(long)vaddr+XCHAL_KSEG_CACHED_VADDR-XCHAL_KSEG_BYPASS_VADDR; 70 unsigned long addr = (unsigned long)vaddr +
71 XCHAL_KSEG_CACHED_VADDR - XCHAL_KSEG_BYPASS_VADDR;
72 72
73 if (addr < 0 || addr >= XCHAL_KSEG_SIZE) 73 BUG_ON(addr < XCHAL_KSEG_CACHED_VADDR ||
74 BUG(); 74 addr > XCHAL_KSEG_CACHED_VADDR + XCHAL_KSEG_SIZE - 1);
75 75
76 free_pages(addr, get_order(size)); 76 free_pages(addr, get_order(size));
77} 77}
diff --git a/arch/xtensa/kernel/smp.c b/arch/xtensa/kernel/smp.c
index 40b5a3771fb0..4d02e38514f5 100644
--- a/arch/xtensa/kernel/smp.c
+++ b/arch/xtensa/kernel/smp.c
@@ -571,6 +571,7 @@ void flush_icache_range(unsigned long start, unsigned long end)
571 }; 571 };
572 on_each_cpu(ipi_flush_icache_range, &fd, 1); 572 on_each_cpu(ipi_flush_icache_range, &fd, 1);
573} 573}
574EXPORT_SYMBOL(flush_icache_range);
574 575
575/* ------------------------------------------------------------------------- */ 576/* ------------------------------------------------------------------------- */
576 577
diff --git a/arch/xtensa/kernel/traps.c b/arch/xtensa/kernel/traps.c
index eebbfd8c26fc..9d2f45f010ef 100644
--- a/arch/xtensa/kernel/traps.c
+++ b/arch/xtensa/kernel/traps.c
@@ -101,9 +101,8 @@ static dispatch_init_table_t __initdata dispatch_init_table[] = {
101#if XCHAL_UNALIGNED_LOAD_EXCEPTION || XCHAL_UNALIGNED_STORE_EXCEPTION 101#if XCHAL_UNALIGNED_LOAD_EXCEPTION || XCHAL_UNALIGNED_STORE_EXCEPTION
102#ifdef CONFIG_XTENSA_UNALIGNED_USER 102#ifdef CONFIG_XTENSA_UNALIGNED_USER
103{ EXCCAUSE_UNALIGNED, USER, fast_unaligned }, 103{ EXCCAUSE_UNALIGNED, USER, fast_unaligned },
104#else
105{ EXCCAUSE_UNALIGNED, 0, do_unaligned_user },
106#endif 104#endif
105{ EXCCAUSE_UNALIGNED, 0, do_unaligned_user },
107{ EXCCAUSE_UNALIGNED, KRNL, fast_unaligned }, 106{ EXCCAUSE_UNALIGNED, KRNL, fast_unaligned },
108#endif 107#endif
109#ifdef CONFIG_MMU 108#ifdef CONFIG_MMU
@@ -264,7 +263,6 @@ do_illegal_instruction(struct pt_regs *regs)
264 */ 263 */
265 264
266#if XCHAL_UNALIGNED_LOAD_EXCEPTION || XCHAL_UNALIGNED_STORE_EXCEPTION 265#if XCHAL_UNALIGNED_LOAD_EXCEPTION || XCHAL_UNALIGNED_STORE_EXCEPTION
267#ifndef CONFIG_XTENSA_UNALIGNED_USER
268void 266void
269do_unaligned_user (struct pt_regs *regs) 267do_unaligned_user (struct pt_regs *regs)
270{ 268{
@@ -286,7 +284,6 @@ do_unaligned_user (struct pt_regs *regs)
286 284
287} 285}
288#endif 286#endif
289#endif
290 287
291void 288void
292do_debug(struct pt_regs *regs) 289do_debug(struct pt_regs *regs)
diff --git a/arch/xtensa/kernel/vectors.S b/arch/xtensa/kernel/vectors.S
index 8453e6e39895..1b397a902292 100644
--- a/arch/xtensa/kernel/vectors.S
+++ b/arch/xtensa/kernel/vectors.S
@@ -454,8 +454,14 @@ _DoubleExceptionVector_WindowOverflow:
454 s32i a0, a2, PT_DEPC 454 s32i a0, a2, PT_DEPC
455 455
456_DoubleExceptionVector_handle_exception: 456_DoubleExceptionVector_handle_exception:
457 addi a0, a0, -EXCCAUSE_UNALIGNED
458 beqz a0, 2f
457 addx4 a0, a0, a3 459 addx4 a0, a0, a3
458 l32i a0, a0, EXC_TABLE_FAST_USER 460 l32i a0, a0, EXC_TABLE_FAST_USER + 4 * EXCCAUSE_UNALIGNED
461 xsr a3, excsave1
462 jx a0
4632:
464 movi a0, user_exception
459 xsr a3, excsave1 465 xsr a3, excsave1
460 jx a0 466 jx a0
461 467
diff --git a/arch/xtensa/kernel/vmlinux.lds.S b/arch/xtensa/kernel/vmlinux.lds.S
index d16db6df86f8..fc1bc2ba8d5d 100644
--- a/arch/xtensa/kernel/vmlinux.lds.S
+++ b/arch/xtensa/kernel/vmlinux.lds.S
@@ -269,13 +269,13 @@ SECTIONS
269 .UserExceptionVector.literal) 269 .UserExceptionVector.literal)
270 SECTION_VECTOR (_DoubleExceptionVector_literal, 270 SECTION_VECTOR (_DoubleExceptionVector_literal,
271 .DoubleExceptionVector.literal, 271 .DoubleExceptionVector.literal,
272 DOUBLEEXC_VECTOR_VADDR - 40, 272 DOUBLEEXC_VECTOR_VADDR - 48,
273 SIZEOF(.UserExceptionVector.text), 273 SIZEOF(.UserExceptionVector.text),
274 .UserExceptionVector.text) 274 .UserExceptionVector.text)
275 SECTION_VECTOR (_DoubleExceptionVector_text, 275 SECTION_VECTOR (_DoubleExceptionVector_text,
276 .DoubleExceptionVector.text, 276 .DoubleExceptionVector.text,
277 DOUBLEEXC_VECTOR_VADDR, 277 DOUBLEEXC_VECTOR_VADDR,
278 40, 278 48,
279 .DoubleExceptionVector.literal) 279 .DoubleExceptionVector.literal)
280 280
281 . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3; 281 . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3;
diff --git a/arch/xtensa/mm/cache.c b/arch/xtensa/mm/cache.c
index 63cbb867dadd..d75aa1476da7 100644
--- a/arch/xtensa/mm/cache.c
+++ b/arch/xtensa/mm/cache.c
@@ -59,9 +59,68 @@
59 * 59 *
60 */ 60 */
61 61
62#if (DCACHE_WAY_SIZE > PAGE_SIZE) && defined(CONFIG_HIGHMEM) 62#if (DCACHE_WAY_SIZE > PAGE_SIZE)
63#error "HIGHMEM is not supported on cores with aliasing cache." 63static inline void kmap_invalidate_coherent(struct page *page,
64#endif 64 unsigned long vaddr)
65{
66 if (!DCACHE_ALIAS_EQ(page_to_phys(page), vaddr)) {
67 unsigned long kvaddr;
68
69 if (!PageHighMem(page)) {
70 kvaddr = (unsigned long)page_to_virt(page);
71
72 __invalidate_dcache_page(kvaddr);
73 } else {
74 kvaddr = TLBTEMP_BASE_1 +
75 (page_to_phys(page) & DCACHE_ALIAS_MASK);
76
77 __invalidate_dcache_page_alias(kvaddr,
78 page_to_phys(page));
79 }
80 }
81}
82
83static inline void *coherent_kvaddr(struct page *page, unsigned long base,
84 unsigned long vaddr, unsigned long *paddr)
85{
86 if (PageHighMem(page) || !DCACHE_ALIAS_EQ(page_to_phys(page), vaddr)) {
87 *paddr = page_to_phys(page);
88 return (void *)(base + (vaddr & DCACHE_ALIAS_MASK));
89 } else {
90 *paddr = 0;
91 return page_to_virt(page);
92 }
93}
94
95void clear_user_highpage(struct page *page, unsigned long vaddr)
96{
97 unsigned long paddr;
98 void *kvaddr = coherent_kvaddr(page, TLBTEMP_BASE_1, vaddr, &paddr);
99
100 pagefault_disable();
101 kmap_invalidate_coherent(page, vaddr);
102 set_bit(PG_arch_1, &page->flags);
103 clear_page_alias(kvaddr, paddr);
104 pagefault_enable();
105}
106
107void copy_user_highpage(struct page *dst, struct page *src,
108 unsigned long vaddr, struct vm_area_struct *vma)
109{
110 unsigned long dst_paddr, src_paddr;
111 void *dst_vaddr = coherent_kvaddr(dst, TLBTEMP_BASE_1, vaddr,
112 &dst_paddr);
113 void *src_vaddr = coherent_kvaddr(src, TLBTEMP_BASE_2, vaddr,
114 &src_paddr);
115
116 pagefault_disable();
117 kmap_invalidate_coherent(dst, vaddr);
118 set_bit(PG_arch_1, &dst->flags);
119 copy_page_alias(dst_vaddr, src_vaddr, dst_paddr, src_paddr);
120 pagefault_enable();
121}
122
123#endif /* DCACHE_WAY_SIZE > PAGE_SIZE */
65 124
66#if (DCACHE_WAY_SIZE > PAGE_SIZE) && XCHAL_DCACHE_IS_WRITEBACK 125#if (DCACHE_WAY_SIZE > PAGE_SIZE) && XCHAL_DCACHE_IS_WRITEBACK
67 126
@@ -103,7 +162,8 @@ void flush_dcache_page(struct page *page)
103 if (!alias && !mapping) 162 if (!alias && !mapping)
104 return; 163 return;
105 164
106 __flush_invalidate_dcache_page((long)page_address(page)); 165 virt = TLBTEMP_BASE_1 + (phys & DCACHE_ALIAS_MASK);
166 __flush_invalidate_dcache_page_alias(virt, phys);
107 167
108 virt = TLBTEMP_BASE_1 + (temp & DCACHE_ALIAS_MASK); 168 virt = TLBTEMP_BASE_1 + (temp & DCACHE_ALIAS_MASK);
109 169
@@ -168,13 +228,12 @@ update_mmu_cache(struct vm_area_struct * vma, unsigned long addr, pte_t *ptep)
168#if (DCACHE_WAY_SIZE > PAGE_SIZE) && XCHAL_DCACHE_IS_WRITEBACK 228#if (DCACHE_WAY_SIZE > PAGE_SIZE) && XCHAL_DCACHE_IS_WRITEBACK
169 229
170 if (!PageReserved(page) && test_bit(PG_arch_1, &page->flags)) { 230 if (!PageReserved(page) && test_bit(PG_arch_1, &page->flags)) {
171
172 unsigned long paddr = (unsigned long) page_address(page);
173 unsigned long phys = page_to_phys(page); 231 unsigned long phys = page_to_phys(page);
174 unsigned long tmp = TLBTEMP_BASE_1 + (addr & DCACHE_ALIAS_MASK); 232 unsigned long tmp;
175
176 __flush_invalidate_dcache_page(paddr);
177 233
234 tmp = TLBTEMP_BASE_1 + (phys & DCACHE_ALIAS_MASK);
235 __flush_invalidate_dcache_page_alias(tmp, phys);
236 tmp = TLBTEMP_BASE_1 + (addr & DCACHE_ALIAS_MASK);
178 __flush_invalidate_dcache_page_alias(tmp, phys); 237 __flush_invalidate_dcache_page_alias(tmp, phys);
179 __invalidate_icache_page_alias(tmp, phys); 238 __invalidate_icache_page_alias(tmp, phys);
180 239
diff --git a/arch/xtensa/mm/highmem.c b/arch/xtensa/mm/highmem.c
index 17a8c0d6fd17..8cfb71ec0937 100644
--- a/arch/xtensa/mm/highmem.c
+++ b/arch/xtensa/mm/highmem.c
@@ -14,23 +14,45 @@
14 14
15static pte_t *kmap_pte; 15static pte_t *kmap_pte;
16 16
17#if DCACHE_WAY_SIZE > PAGE_SIZE
18unsigned int last_pkmap_nr_arr[DCACHE_N_COLORS];
19wait_queue_head_t pkmap_map_wait_arr[DCACHE_N_COLORS];
20
21static void __init kmap_waitqueues_init(void)
22{
23 unsigned int i;
24
25 for (i = 0; i < ARRAY_SIZE(pkmap_map_wait_arr); ++i)
26 init_waitqueue_head(pkmap_map_wait_arr + i);
27}
28#else
29static inline void kmap_waitqueues_init(void)
30{
31}
32#endif
33
34static inline enum fixed_addresses kmap_idx(int type, unsigned long color)
35{
36 return (type + KM_TYPE_NR * smp_processor_id()) * DCACHE_N_COLORS +
37 color;
38}
39
17void *kmap_atomic(struct page *page) 40void *kmap_atomic(struct page *page)
18{ 41{
19 enum fixed_addresses idx; 42 enum fixed_addresses idx;
20 unsigned long vaddr; 43 unsigned long vaddr;
21 int type;
22 44
23 pagefault_disable(); 45 pagefault_disable();
24 if (!PageHighMem(page)) 46 if (!PageHighMem(page))
25 return page_address(page); 47 return page_address(page);
26 48
27 type = kmap_atomic_idx_push(); 49 idx = kmap_idx(kmap_atomic_idx_push(),
28 idx = type + KM_TYPE_NR * smp_processor_id(); 50 DCACHE_ALIAS(page_to_phys(page)));
29 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); 51 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
30#ifdef CONFIG_DEBUG_HIGHMEM 52#ifdef CONFIG_DEBUG_HIGHMEM
31 BUG_ON(!pte_none(*(kmap_pte - idx))); 53 BUG_ON(!pte_none(*(kmap_pte + idx)));
32#endif 54#endif
33 set_pte(kmap_pte - idx, mk_pte(page, PAGE_KERNEL_EXEC)); 55 set_pte(kmap_pte + idx, mk_pte(page, PAGE_KERNEL_EXEC));
34 56
35 return (void *)vaddr; 57 return (void *)vaddr;
36} 58}
@@ -38,12 +60,10 @@ EXPORT_SYMBOL(kmap_atomic);
38 60
39void __kunmap_atomic(void *kvaddr) 61void __kunmap_atomic(void *kvaddr)
40{ 62{
41 int idx, type;
42
43 if (kvaddr >= (void *)FIXADDR_START && 63 if (kvaddr >= (void *)FIXADDR_START &&
44 kvaddr < (void *)FIXADDR_TOP) { 64 kvaddr < (void *)FIXADDR_TOP) {
45 type = kmap_atomic_idx(); 65 int idx = kmap_idx(kmap_atomic_idx(),
46 idx = type + KM_TYPE_NR * smp_processor_id(); 66 DCACHE_ALIAS((unsigned long)kvaddr));
47 67
48 /* 68 /*
49 * Force other mappings to Oops if they'll try to access this 69 * Force other mappings to Oops if they'll try to access this
@@ -51,7 +71,7 @@ void __kunmap_atomic(void *kvaddr)
51 * is a bad idea also, in case the page changes cacheability 71 * is a bad idea also, in case the page changes cacheability
52 * attributes or becomes a protected page in a hypervisor. 72 * attributes or becomes a protected page in a hypervisor.
53 */ 73 */
54 pte_clear(&init_mm, kvaddr, kmap_pte - idx); 74 pte_clear(&init_mm, kvaddr, kmap_pte + idx);
55 local_flush_tlb_kernel_range((unsigned long)kvaddr, 75 local_flush_tlb_kernel_range((unsigned long)kvaddr,
56 (unsigned long)kvaddr + PAGE_SIZE); 76 (unsigned long)kvaddr + PAGE_SIZE);
57 77
@@ -69,4 +89,5 @@ void __init kmap_init(void)
69 /* cache the first kmap pte */ 89 /* cache the first kmap pte */
70 kmap_vstart = __fix_to_virt(FIX_KMAP_BEGIN); 90 kmap_vstart = __fix_to_virt(FIX_KMAP_BEGIN);
71 kmap_pte = kmap_get_fixmap_pte(kmap_vstart); 91 kmap_pte = kmap_get_fixmap_pte(kmap_vstart);
92 kmap_waitqueues_init();
72} 93}
diff --git a/arch/xtensa/mm/misc.S b/arch/xtensa/mm/misc.S
index 1f68558dbcc2..11a01c3e9cea 100644
--- a/arch/xtensa/mm/misc.S
+++ b/arch/xtensa/mm/misc.S
@@ -110,41 +110,24 @@ ENTRY(__tlbtemp_mapping_start)
110#if (DCACHE_WAY_SIZE > PAGE_SIZE) 110#if (DCACHE_WAY_SIZE > PAGE_SIZE)
111 111
112/* 112/*
113 * clear_user_page (void *addr, unsigned long vaddr, struct page *page) 113 * clear_page_alias(void *addr, unsigned long paddr)
114 * a2 a3 a4 114 * a2 a3
115 */ 115 */
116 116
117ENTRY(clear_user_page) 117ENTRY(clear_page_alias)
118 118
119 entry a1, 32 119 entry a1, 32
120 120
121 /* Mark page dirty and determine alias. */ 121 /* Skip setting up a temporary DTLB if not aliased low page. */
122 122
123 movi a7, (1 << PG_ARCH_1) 123 movi a5, PAGE_OFFSET
124 l32i a5, a4, PAGE_FLAGS 124 movi a6, 0
125 xor a6, a2, a3 125 beqz a3, 1f
126 extui a3, a3, PAGE_SHIFT, DCACHE_ALIAS_ORDER
127 extui a6, a6, PAGE_SHIFT, DCACHE_ALIAS_ORDER
128 or a5, a5, a7
129 slli a3, a3, PAGE_SHIFT
130 s32i a5, a4, PAGE_FLAGS
131 126
132 /* Skip setting up a temporary DTLB if not aliased. */ 127 /* Setup a temporary DTLB for the addr. */
133
134 beqz a6, 1f
135
136 /* Invalidate kernel page. */
137
138 mov a10, a2
139 call8 __invalidate_dcache_page
140
141 /* Setup a temporary DTLB with the color of the VPN */
142
143 movi a4, ((PAGE_KERNEL | _PAGE_HW_WRITE) - PAGE_OFFSET) & 0xffffffff
144 movi a5, TLBTEMP_BASE_1 # virt
145 add a6, a2, a4 # ppn
146 add a2, a5, a3 # add 'color'
147 128
129 addi a6, a3, (PAGE_KERNEL | _PAGE_HW_WRITE)
130 mov a4, a2
148 wdtlb a6, a2 131 wdtlb a6, a2
149 dsync 132 dsync
150 133
@@ -165,62 +148,43 @@ ENTRY(clear_user_page)
165 148
166 /* We need to invalidate the temporary idtlb entry, if any. */ 149 /* We need to invalidate the temporary idtlb entry, if any. */
167 150
1681: addi a2, a2, -PAGE_SIZE 1511: idtlb a4
169 idtlb a2
170 dsync 152 dsync
171 153
172 retw 154 retw
173 155
174ENDPROC(clear_user_page) 156ENDPROC(clear_page_alias)
175 157
176/* 158/*
177 * copy_page_user (void *to, void *from, unsigned long vaddr, struct page *page) 159 * copy_page_alias(void *to, void *from,
178 * a2 a3 a4 a5 160 * a2 a3
161 * unsigned long to_paddr, unsigned long from_paddr)
162 * a4 a5
179 */ 163 */
180 164
181ENTRY(copy_user_page) 165ENTRY(copy_page_alias)
182 166
183 entry a1, 32 167 entry a1, 32
184 168
185 /* Mark page dirty and determine alias for destination. */ 169 /* Skip setting up a temporary DTLB for destination if not aliased. */
186
187 movi a8, (1 << PG_ARCH_1)
188 l32i a9, a5, PAGE_FLAGS
189 xor a6, a2, a4
190 xor a7, a3, a4
191 extui a4, a4, PAGE_SHIFT, DCACHE_ALIAS_ORDER
192 extui a6, a6, PAGE_SHIFT, DCACHE_ALIAS_ORDER
193 extui a7, a7, PAGE_SHIFT, DCACHE_ALIAS_ORDER
194 or a9, a9, a8
195 slli a4, a4, PAGE_SHIFT
196 s32i a9, a5, PAGE_FLAGS
197 movi a5, ((PAGE_KERNEL | _PAGE_HW_WRITE) - PAGE_OFFSET) & 0xffffffff
198
199 beqz a6, 1f
200
201 /* Invalidate dcache */
202
203 mov a10, a2
204 call8 __invalidate_dcache_page
205 170
206 /* Setup a temporary DTLB with a matching color. */ 171 movi a6, 0
172 movi a7, 0
173 beqz a4, 1f
207 174
208 movi a8, TLBTEMP_BASE_1 # base 175 /* Setup a temporary DTLB for destination. */
209 add a6, a2, a5 # ppn
210 add a2, a8, a4 # add 'color'
211 176
177 addi a6, a4, (PAGE_KERNEL | _PAGE_HW_WRITE)
212 wdtlb a6, a2 178 wdtlb a6, a2
213 dsync 179 dsync
214 180
215 /* Skip setting up a temporary DTLB for destination if not aliased. */ 181 /* Skip setting up a temporary DTLB for source if not aliased. */
216 182
2171: beqz a7, 1f 1831: beqz a5, 1f
218 184
219 /* Setup a temporary DTLB with a matching color. */ 185 /* Setup a temporary DTLB for source. */
220 186
221 movi a8, TLBTEMP_BASE_2 # base 187 addi a7, a5, PAGE_KERNEL
222 add a7, a3, a5 # ppn
223 add a3, a8, a4
224 addi a8, a3, 1 # way1 188 addi a8, a3, 1 # way1
225 189
226 wdtlb a7, a8 190 wdtlb a7, a8
@@ -271,7 +235,7 @@ ENTRY(copy_user_page)
271 235
272 retw 236 retw
273 237
274ENDPROC(copy_user_page) 238ENDPROC(copy_page_alias)
275 239
276#endif 240#endif
277 241
@@ -300,6 +264,30 @@ ENTRY(__flush_invalidate_dcache_page_alias)
300 retw 264 retw
301 265
302ENDPROC(__flush_invalidate_dcache_page_alias) 266ENDPROC(__flush_invalidate_dcache_page_alias)
267
268/*
269 * void __invalidate_dcache_page_alias (addr, phys)
270 * a2 a3
271 */
272
273ENTRY(__invalidate_dcache_page_alias)
274
275 entry sp, 16
276
277 movi a7, 0 # required for exception handler
278 addi a6, a3, (PAGE_KERNEL | _PAGE_HW_WRITE)
279 mov a4, a2
280 wdtlb a6, a2
281 dsync
282
283 ___invalidate_dcache_page a2 a3
284
285 idtlb a4
286 dsync
287
288 retw
289
290ENDPROC(__invalidate_dcache_page_alias)
303#endif 291#endif
304 292
305ENTRY(__tlbtemp_mapping_itlb) 293ENTRY(__tlbtemp_mapping_itlb)
diff --git a/arch/xtensa/mm/mmu.c b/arch/xtensa/mm/mmu.c
index 3429b483d9f8..abe4513eb0dd 100644
--- a/arch/xtensa/mm/mmu.c
+++ b/arch/xtensa/mm/mmu.c
@@ -18,32 +18,38 @@
18#include <asm/io.h> 18#include <asm/io.h>
19 19
20#if defined(CONFIG_HIGHMEM) 20#if defined(CONFIG_HIGHMEM)
21static void * __init init_pmd(unsigned long vaddr) 21static void * __init init_pmd(unsigned long vaddr, unsigned long n_pages)
22{ 22{
23 pgd_t *pgd = pgd_offset_k(vaddr); 23 pgd_t *pgd = pgd_offset_k(vaddr);
24 pmd_t *pmd = pmd_offset(pgd, vaddr); 24 pmd_t *pmd = pmd_offset(pgd, vaddr);
25 pte_t *pte;
26 unsigned long i;
25 27
26 if (pmd_none(*pmd)) { 28 n_pages = ALIGN(n_pages, PTRS_PER_PTE);
27 unsigned i;
28 pte_t *pte = alloc_bootmem_low_pages(PAGE_SIZE);
29 29
30 for (i = 0; i < 1024; i++) 30 pr_debug("%s: vaddr: 0x%08lx, n_pages: %ld\n",
31 pte_clear(NULL, 0, pte + i); 31 __func__, vaddr, n_pages);
32 32
33 set_pmd(pmd, __pmd(((unsigned long)pte) & PAGE_MASK)); 33 pte = alloc_bootmem_low_pages(n_pages * sizeof(pte_t));
34 BUG_ON(pte != pte_offset_kernel(pmd, 0)); 34
35 pr_debug("%s: vaddr: 0x%08lx, pmd: 0x%p, pte: 0x%p\n", 35 for (i = 0; i < n_pages; ++i)
36 __func__, vaddr, pmd, pte); 36 pte_clear(NULL, 0, pte + i);
37 return pte; 37
38 } else { 38 for (i = 0; i < n_pages; i += PTRS_PER_PTE, ++pmd) {
39 return pte_offset_kernel(pmd, 0); 39 pte_t *cur_pte = pte + i;
40
41 BUG_ON(!pmd_none(*pmd));
42 set_pmd(pmd, __pmd(((unsigned long)cur_pte) & PAGE_MASK));
43 BUG_ON(cur_pte != pte_offset_kernel(pmd, 0));
44 pr_debug("%s: pmd: 0x%p, pte: 0x%p\n",
45 __func__, pmd, cur_pte);
40 } 46 }
47 return pte;
41} 48}
42 49
43static void __init fixedrange_init(void) 50static void __init fixedrange_init(void)
44{ 51{
45 BUILD_BUG_ON(FIXADDR_SIZE > PMD_SIZE); 52 init_pmd(__fix_to_virt(0), __end_of_fixed_addresses);
46 init_pmd(__fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK);
47} 53}
48#endif 54#endif
49 55
@@ -52,7 +58,7 @@ void __init paging_init(void)
52 memset(swapper_pg_dir, 0, PAGE_SIZE); 58 memset(swapper_pg_dir, 0, PAGE_SIZE);
53#ifdef CONFIG_HIGHMEM 59#ifdef CONFIG_HIGHMEM
54 fixedrange_init(); 60 fixedrange_init();
55 pkmap_page_table = init_pmd(PKMAP_BASE); 61 pkmap_page_table = init_pmd(PKMAP_BASE, LAST_PKMAP);
56 kmap_init(); 62 kmap_init();
57#endif 63#endif
58} 64}
diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index bc423f7b02da..f14b4abbebd8 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -520,7 +520,7 @@ void bio_integrity_endio(struct bio *bio, int error)
520 */ 520 */
521 if (error) { 521 if (error) {
522 bio->bi_end_io = bip->bip_end_io; 522 bio->bi_end_io = bip->bip_end_io;
523 bio_endio(bio, error); 523 bio_endio_nodec(bio, error);
524 524
525 return; 525 return;
526 } 526 }
diff --git a/block/blk-core.c b/block/blk-core.c
index c359d72e9d76..bf930f481d43 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1252,7 +1252,6 @@ void blk_rq_set_block_pc(struct request *rq)
1252 rq->__sector = (sector_t) -1; 1252 rq->__sector = (sector_t) -1;
1253 rq->bio = rq->biotail = NULL; 1253 rq->bio = rq->biotail = NULL;
1254 memset(rq->__cmd, 0, sizeof(rq->__cmd)); 1254 memset(rq->__cmd, 0, sizeof(rq->__cmd));
1255 rq->cmd = rq->__cmd;
1256} 1255}
1257EXPORT_SYMBOL(blk_rq_set_block_pc); 1256EXPORT_SYMBOL(blk_rq_set_block_pc);
1258 1257
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 5189cb1e478a..4aac82615a46 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -112,18 +112,22 @@ static void blk_mq_usage_counter_release(struct percpu_ref *ref)
112 */ 112 */
113void blk_mq_freeze_queue(struct request_queue *q) 113void blk_mq_freeze_queue(struct request_queue *q)
114{ 114{
115 bool freeze;
116
115 spin_lock_irq(q->queue_lock); 117 spin_lock_irq(q->queue_lock);
116 q->mq_freeze_depth++; 118 freeze = !q->mq_freeze_depth++;
117 spin_unlock_irq(q->queue_lock); 119 spin_unlock_irq(q->queue_lock);
118 120
119 percpu_ref_kill(&q->mq_usage_counter); 121 if (freeze) {
120 blk_mq_run_queues(q, false); 122 percpu_ref_kill(&q->mq_usage_counter);
123 blk_mq_run_queues(q, false);
124 }
121 wait_event(q->mq_freeze_wq, percpu_ref_is_zero(&q->mq_usage_counter)); 125 wait_event(q->mq_freeze_wq, percpu_ref_is_zero(&q->mq_usage_counter));
122} 126}
123 127
124static void blk_mq_unfreeze_queue(struct request_queue *q) 128static void blk_mq_unfreeze_queue(struct request_queue *q)
125{ 129{
126 bool wake = false; 130 bool wake;
127 131
128 spin_lock_irq(q->queue_lock); 132 spin_lock_irq(q->queue_lock);
129 wake = !--q->mq_freeze_depth; 133 wake = !--q->mq_freeze_depth;
@@ -172,6 +176,8 @@ static void blk_mq_rq_ctx_init(struct request_queue *q, struct blk_mq_ctx *ctx,
172 /* tag was already set */ 176 /* tag was already set */
173 rq->errors = 0; 177 rq->errors = 0;
174 178
179 rq->cmd = rq->__cmd;
180
175 rq->extra_len = 0; 181 rq->extra_len = 0;
176 rq->sense_len = 0; 182 rq->sense_len = 0;
177 rq->resid_len = 0; 183 rq->resid_len = 0;
@@ -1068,13 +1074,17 @@ static void blk_mq_bio_to_request(struct request *rq, struct bio *bio)
1068 blk_account_io_start(rq, 1); 1074 blk_account_io_start(rq, 1);
1069} 1075}
1070 1076
1077static inline bool hctx_allow_merges(struct blk_mq_hw_ctx *hctx)
1078{
1079 return (hctx->flags & BLK_MQ_F_SHOULD_MERGE) &&
1080 !blk_queue_nomerges(hctx->queue);
1081}
1082
1071static inline bool blk_mq_merge_queue_io(struct blk_mq_hw_ctx *hctx, 1083static inline bool blk_mq_merge_queue_io(struct blk_mq_hw_ctx *hctx,
1072 struct blk_mq_ctx *ctx, 1084 struct blk_mq_ctx *ctx,
1073 struct request *rq, struct bio *bio) 1085 struct request *rq, struct bio *bio)
1074{ 1086{
1075 struct request_queue *q = hctx->queue; 1087 if (!hctx_allow_merges(hctx)) {
1076
1077 if (!(hctx->flags & BLK_MQ_F_SHOULD_MERGE)) {
1078 blk_mq_bio_to_request(rq, bio); 1088 blk_mq_bio_to_request(rq, bio);
1079 spin_lock(&ctx->lock); 1089 spin_lock(&ctx->lock);
1080insert_rq: 1090insert_rq:
@@ -1082,6 +1092,8 @@ insert_rq:
1082 spin_unlock(&ctx->lock); 1092 spin_unlock(&ctx->lock);
1083 return false; 1093 return false;
1084 } else { 1094 } else {
1095 struct request_queue *q = hctx->queue;
1096
1085 spin_lock(&ctx->lock); 1097 spin_lock(&ctx->lock);
1086 if (!blk_mq_attempt_merge(q, ctx, bio)) { 1098 if (!blk_mq_attempt_merge(q, ctx, bio)) {
1087 blk_mq_bio_to_request(rq, bio); 1099 blk_mq_bio_to_request(rq, bio);
@@ -1574,7 +1586,7 @@ static int blk_mq_init_hw_queues(struct request_queue *q,
1574 hctx->tags = set->tags[i]; 1586 hctx->tags = set->tags[i];
1575 1587
1576 /* 1588 /*
1577 * Allocate space for all possible cpus to avoid allocation in 1589 * Allocate space for all possible cpus to avoid allocation at
1578 * runtime 1590 * runtime
1579 */ 1591 */
1580 hctx->ctxs = kmalloc_node(nr_cpu_ids * sizeof(void *), 1592 hctx->ctxs = kmalloc_node(nr_cpu_ids * sizeof(void *),
@@ -1662,8 +1674,8 @@ static void blk_mq_map_swqueue(struct request_queue *q)
1662 1674
1663 queue_for_each_hw_ctx(q, hctx, i) { 1675 queue_for_each_hw_ctx(q, hctx, i) {
1664 /* 1676 /*
1665 * If not software queues are mapped to this hardware queue, 1677 * If no software queues are mapped to this hardware queue,
1666 * disable it and free the request entries 1678 * disable it and free the request entries.
1667 */ 1679 */
1668 if (!hctx->nr_ctx) { 1680 if (!hctx->nr_ctx) {
1669 struct blk_mq_tag_set *set = q->tag_set; 1681 struct blk_mq_tag_set *set = q->tag_set;
@@ -1713,14 +1725,10 @@ static void blk_mq_del_queue_tag_set(struct request_queue *q)
1713{ 1725{
1714 struct blk_mq_tag_set *set = q->tag_set; 1726 struct blk_mq_tag_set *set = q->tag_set;
1715 1727
1716 blk_mq_freeze_queue(q);
1717
1718 mutex_lock(&set->tag_list_lock); 1728 mutex_lock(&set->tag_list_lock);
1719 list_del_init(&q->tag_set_list); 1729 list_del_init(&q->tag_set_list);
1720 blk_mq_update_tag_set_depth(set); 1730 blk_mq_update_tag_set_depth(set);
1721 mutex_unlock(&set->tag_list_lock); 1731 mutex_unlock(&set->tag_list_lock);
1722
1723 blk_mq_unfreeze_queue(q);
1724} 1732}
1725 1733
1726static void blk_mq_add_queue_tag_set(struct blk_mq_tag_set *set, 1734static void blk_mq_add_queue_tag_set(struct blk_mq_tag_set *set,
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index cadc37841744..3f31cf9508e6 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -1272,15 +1272,22 @@ __cfq_group_service_tree_add(struct cfq_rb_root *st, struct cfq_group *cfqg)
1272 rb_insert_color(&cfqg->rb_node, &st->rb); 1272 rb_insert_color(&cfqg->rb_node, &st->rb);
1273} 1273}
1274 1274
1275/*
1276 * This has to be called only on activation of cfqg
1277 */
1275static void 1278static void
1276cfq_update_group_weight(struct cfq_group *cfqg) 1279cfq_update_group_weight(struct cfq_group *cfqg)
1277{ 1280{
1278 BUG_ON(!RB_EMPTY_NODE(&cfqg->rb_node));
1279
1280 if (cfqg->new_weight) { 1281 if (cfqg->new_weight) {
1281 cfqg->weight = cfqg->new_weight; 1282 cfqg->weight = cfqg->new_weight;
1282 cfqg->new_weight = 0; 1283 cfqg->new_weight = 0;
1283 } 1284 }
1285}
1286
1287static void
1288cfq_update_group_leaf_weight(struct cfq_group *cfqg)
1289{
1290 BUG_ON(!RB_EMPTY_NODE(&cfqg->rb_node));
1284 1291
1285 if (cfqg->new_leaf_weight) { 1292 if (cfqg->new_leaf_weight) {
1286 cfqg->leaf_weight = cfqg->new_leaf_weight; 1293 cfqg->leaf_weight = cfqg->new_leaf_weight;
@@ -1299,7 +1306,12 @@ cfq_group_service_tree_add(struct cfq_rb_root *st, struct cfq_group *cfqg)
1299 /* add to the service tree */ 1306 /* add to the service tree */
1300 BUG_ON(!RB_EMPTY_NODE(&cfqg->rb_node)); 1307 BUG_ON(!RB_EMPTY_NODE(&cfqg->rb_node));
1301 1308
1302 cfq_update_group_weight(cfqg); 1309 /*
1310 * Update leaf_weight. We cannot update weight at this point
1311 * because cfqg might already have been activated and is
1312 * contributing its current weight to the parent's child_weight.
1313 */
1314 cfq_update_group_leaf_weight(cfqg);
1303 __cfq_group_service_tree_add(st, cfqg); 1315 __cfq_group_service_tree_add(st, cfqg);
1304 1316
1305 /* 1317 /*
@@ -1323,6 +1335,7 @@ cfq_group_service_tree_add(struct cfq_rb_root *st, struct cfq_group *cfqg)
1323 */ 1335 */
1324 while ((parent = cfqg_parent(pos))) { 1336 while ((parent = cfqg_parent(pos))) {
1325 if (propagate) { 1337 if (propagate) {
1338 cfq_update_group_weight(pos);
1326 propagate = !parent->nr_active++; 1339 propagate = !parent->nr_active++;
1327 parent->children_weight += pos->weight; 1340 parent->children_weight += pos->weight;
1328 } 1341 }
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index 51bf5155ee75..9b8eaeca6a79 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -279,7 +279,6 @@ static int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr,
279 r = blk_rq_unmap_user(bio); 279 r = blk_rq_unmap_user(bio);
280 if (!ret) 280 if (!ret)
281 ret = r; 281 ret = r;
282 blk_put_request(rq);
283 282
284 return ret; 283 return ret;
285} 284}
@@ -297,8 +296,6 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,
297 296
298 if (hdr->interface_id != 'S') 297 if (hdr->interface_id != 'S')
299 return -EINVAL; 298 return -EINVAL;
300 if (hdr->cmd_len > BLK_MAX_CDB)
301 return -EINVAL;
302 299
303 if (hdr->dxfer_len > (queue_max_hw_sectors(q) << 9)) 300 if (hdr->dxfer_len > (queue_max_hw_sectors(q) << 9))
304 return -EIO; 301 return -EIO;
@@ -317,16 +314,23 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,
317 if (hdr->flags & SG_FLAG_Q_AT_HEAD) 314 if (hdr->flags & SG_FLAG_Q_AT_HEAD)
318 at_head = 1; 315 at_head = 1;
319 316
317 ret = -ENOMEM;
320 rq = blk_get_request(q, writing ? WRITE : READ, GFP_KERNEL); 318 rq = blk_get_request(q, writing ? WRITE : READ, GFP_KERNEL);
321 if (!rq) 319 if (!rq)
322 return -ENOMEM; 320 goto out;
323 blk_rq_set_block_pc(rq); 321 blk_rq_set_block_pc(rq);
324 322
325 if (blk_fill_sghdr_rq(q, rq, hdr, mode)) { 323 if (hdr->cmd_len > BLK_MAX_CDB) {
326 blk_put_request(rq); 324 rq->cmd = kzalloc(hdr->cmd_len, GFP_KERNEL);
327 return -EFAULT; 325 if (!rq->cmd)
326 goto out_put_request;
328 } 327 }
329 328
329 ret = -EFAULT;
330 if (blk_fill_sghdr_rq(q, rq, hdr, mode))
331 goto out_free_cdb;
332
333 ret = 0;
330 if (hdr->iovec_count) { 334 if (hdr->iovec_count) {
331 size_t iov_data_len; 335 size_t iov_data_len;
332 struct iovec *iov = NULL; 336 struct iovec *iov = NULL;
@@ -335,7 +339,7 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,
335 0, NULL, &iov); 339 0, NULL, &iov);
336 if (ret < 0) { 340 if (ret < 0) {
337 kfree(iov); 341 kfree(iov);
338 goto out; 342 goto out_free_cdb;
339 } 343 }
340 344
341 iov_data_len = ret; 345 iov_data_len = ret;
@@ -358,7 +362,7 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,
358 GFP_KERNEL); 362 GFP_KERNEL);
359 363
360 if (ret) 364 if (ret)
361 goto out; 365 goto out_free_cdb;
362 366
363 bio = rq->bio; 367 bio = rq->bio;
364 memset(sense, 0, sizeof(sense)); 368 memset(sense, 0, sizeof(sense));
@@ -376,9 +380,14 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,
376 380
377 hdr->duration = jiffies_to_msecs(jiffies - start_time); 381 hdr->duration = jiffies_to_msecs(jiffies - start_time);
378 382
379 return blk_complete_sghdr_rq(rq, hdr, bio); 383 ret = blk_complete_sghdr_rq(rq, hdr, bio);
380out: 384
385out_free_cdb:
386 if (rq->cmd != rq->__cmd)
387 kfree(rq->cmd);
388out_put_request:
381 blk_put_request(rq); 389 blk_put_request(rq);
390out:
382 return ret; 391 return ret;
383} 392}
384 393
@@ -448,6 +457,11 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
448 } 457 }
449 458
450 rq = blk_get_request(q, in_len ? WRITE : READ, __GFP_WAIT); 459 rq = blk_get_request(q, in_len ? WRITE : READ, __GFP_WAIT);
460 if (!rq) {
461 err = -ENOMEM;
462 goto error;
463 }
464 blk_rq_set_block_pc(rq);
451 465
452 cmdlen = COMMAND_SIZE(opcode); 466 cmdlen = COMMAND_SIZE(opcode);
453 467
@@ -501,7 +515,6 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
501 memset(sense, 0, sizeof(sense)); 515 memset(sense, 0, sizeof(sense));
502 rq->sense = sense; 516 rq->sense = sense;
503 rq->sense_len = 0; 517 rq->sense_len = 0;
504 blk_rq_set_block_pc(rq);
505 518
506 blk_execute_rq(q, disk, rq, 0); 519 blk_execute_rq(q, disk, rq, 0);
507 520
@@ -521,7 +534,8 @@ out:
521 534
522error: 535error:
523 kfree(buffer); 536 kfree(buffer);
524 blk_put_request(rq); 537 if (rq)
538 blk_put_request(rq);
525 return err; 539 return err;
526} 540}
527EXPORT_SYMBOL_GPL(sg_scsi_ioctl); 541EXPORT_SYMBOL_GPL(sg_scsi_ioctl);
diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index ce06149088c5..9dfec48dd4e5 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -196,6 +196,17 @@ static struct lpss_device_desc byt_i2c_dev_desc = {
196 .setup = lpss_i2c_setup, 196 .setup = lpss_i2c_setup,
197}; 197};
198 198
199static struct lpss_shared_clock bsw_pwm_clock = {
200 .name = "pwm_clk",
201 .rate = 19200000,
202};
203
204static struct lpss_device_desc bsw_pwm_dev_desc = {
205 .clk_required = true,
206 .save_ctx = true,
207 .shared_clock = &bsw_pwm_clock,
208};
209
199#else 210#else
200 211
201#define LPSS_ADDR(desc) (0UL) 212#define LPSS_ADDR(desc) (0UL)
@@ -225,6 +236,12 @@ static const struct acpi_device_id acpi_lpss_device_ids[] = {
225 { "INT33B2", }, 236 { "INT33B2", },
226 { "INT33FC", }, 237 { "INT33FC", },
227 238
239 /* Braswell LPSS devices */
240 { "80862288", LPSS_ADDR(bsw_pwm_dev_desc) },
241 { "8086228A", LPSS_ADDR(byt_uart_dev_desc) },
242 { "8086228E", LPSS_ADDR(byt_spi_dev_desc) },
243 { "808622C1", LPSS_ADDR(byt_i2c_dev_desc) },
244
228 { "INT3430", LPSS_ADDR(lpt_dev_desc) }, 245 { "INT3430", LPSS_ADDR(lpt_dev_desc) },
229 { "INT3431", LPSS_ADDR(lpt_dev_desc) }, 246 { "INT3431", LPSS_ADDR(lpt_dev_desc) },
230 { "INT3432", LPSS_ADDR(lpt_i2c_dev_desc) }, 247 { "INT3432", LPSS_ADDR(lpt_i2c_dev_desc) },
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index a66ab658abbc..9922cc46b15c 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -197,6 +197,8 @@ static bool advance_transaction(struct acpi_ec *ec)
197 t->rdata[t->ri++] = acpi_ec_read_data(ec); 197 t->rdata[t->ri++] = acpi_ec_read_data(ec);
198 if (t->rlen == t->ri) { 198 if (t->rlen == t->ri) {
199 t->flags |= ACPI_EC_COMMAND_COMPLETE; 199 t->flags |= ACPI_EC_COMMAND_COMPLETE;
200 if (t->command == ACPI_EC_COMMAND_QUERY)
201 pr_debug("hardware QR_EC completion\n");
200 wakeup = true; 202 wakeup = true;
201 } 203 }
202 } else 204 } else
@@ -208,7 +210,20 @@ static bool advance_transaction(struct acpi_ec *ec)
208 } 210 }
209 return wakeup; 211 return wakeup;
210 } else { 212 } else {
211 if ((status & ACPI_EC_FLAG_IBF) == 0) { 213 /*
214 * There is firmware refusing to respond QR_EC when SCI_EVT
215 * is not set, for which case, we complete the QR_EC
216 * without issuing it to the firmware.
217 * https://bugzilla.kernel.org/show_bug.cgi?id=86211
218 */
219 if (!(status & ACPI_EC_FLAG_SCI) &&
220 (t->command == ACPI_EC_COMMAND_QUERY)) {
221 t->flags |= ACPI_EC_COMMAND_POLL;
222 t->rdata[t->ri++] = 0x00;
223 t->flags |= ACPI_EC_COMMAND_COMPLETE;
224 pr_debug("software QR_EC completion\n");
225 wakeup = true;
226 } else if ((status & ACPI_EC_FLAG_IBF) == 0) {
212 acpi_ec_write_cmd(ec, t->command); 227 acpi_ec_write_cmd(ec, t->command);
213 t->flags |= ACPI_EC_COMMAND_POLL; 228 t->flags |= ACPI_EC_COMMAND_POLL;
214 } else 229 } else
@@ -288,11 +303,11 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec,
288 /* following two actions should be kept atomic */ 303 /* following two actions should be kept atomic */
289 ec->curr = t; 304 ec->curr = t;
290 start_transaction(ec); 305 start_transaction(ec);
291 if (ec->curr->command == ACPI_EC_COMMAND_QUERY)
292 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
293 spin_unlock_irqrestore(&ec->lock, tmp); 306 spin_unlock_irqrestore(&ec->lock, tmp);
294 ret = ec_poll(ec); 307 ret = ec_poll(ec);
295 spin_lock_irqsave(&ec->lock, tmp); 308 spin_lock_irqsave(&ec->lock, tmp);
309 if (ec->curr->command == ACPI_EC_COMMAND_QUERY)
310 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
296 ec->curr = NULL; 311 ec->curr = NULL;
297 spin_unlock_irqrestore(&ec->lock, tmp); 312 spin_unlock_irqrestore(&ec->lock, tmp);
298 return ret; 313 return ret;
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index c96887d5289e..6e6b80eb0bba 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -484,6 +484,10 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
484 /* Keep IOAPIC pin configuration when suspending */ 484 /* Keep IOAPIC pin configuration when suspending */
485 if (dev->dev.power.is_prepared) 485 if (dev->dev.power.is_prepared)
486 return; 486 return;
487#ifdef CONFIG_PM_RUNTIME
488 if (dev->dev.power.runtime_status == RPM_SUSPENDING)
489 return;
490#endif
487 491
488 entry = acpi_pci_irq_lookup(dev, pin); 492 entry = acpi_pci_irq_lookup(dev, pin);
489 if (!entry) 493 if (!entry)
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 0a817ad24f16..9a9298994e26 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -922,12 +922,17 @@ static void acpi_device_notify(acpi_handle handle, u32 event, void *data)
922 device->driver->ops.notify(device, event); 922 device->driver->ops.notify(device, event);
923} 923}
924 924
925static acpi_status acpi_device_notify_fixed(void *data) 925static void acpi_device_notify_fixed(void *data)
926{ 926{
927 struct acpi_device *device = data; 927 struct acpi_device *device = data;
928 928
929 /* Fixed hardware devices have no handles */ 929 /* Fixed hardware devices have no handles */
930 acpi_device_notify(NULL, ACPI_FIXED_HARDWARE_EVENT, device); 930 acpi_device_notify(NULL, ACPI_FIXED_HARDWARE_EVENT, device);
931}
932
933static acpi_status acpi_device_fixed_event(void *data)
934{
935 acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_device_notify_fixed, data);
931 return AE_OK; 936 return AE_OK;
932} 937}
933 938
@@ -938,12 +943,12 @@ static int acpi_device_install_notify_handler(struct acpi_device *device)
938 if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) 943 if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON)
939 status = 944 status =
940 acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, 945 acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
941 acpi_device_notify_fixed, 946 acpi_device_fixed_event,
942 device); 947 device);
943 else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON) 948 else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON)
944 status = 949 status =
945 acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, 950 acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON,
946 acpi_device_notify_fixed, 951 acpi_device_fixed_event,
947 device); 952 device);
948 else 953 else
949 status = acpi_install_notify_handler(device->handle, 954 status = acpi_install_notify_handler(device->handle,
@@ -960,10 +965,10 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device)
960{ 965{
961 if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) 966 if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON)
962 acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, 967 acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
963 acpi_device_notify_fixed); 968 acpi_device_fixed_event);
964 else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON) 969 else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON)
965 acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, 970 acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON,
966 acpi_device_notify_fixed); 971 acpi_device_fixed_event);
967 else 972 else
968 acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, 973 acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
969 acpi_device_notify); 974 acpi_device_notify);
@@ -975,7 +980,7 @@ static int acpi_device_probe(struct device *dev)
975 struct acpi_driver *acpi_drv = to_acpi_driver(dev->driver); 980 struct acpi_driver *acpi_drv = to_acpi_driver(dev->driver);
976 int ret; 981 int ret;
977 982
978 if (acpi_dev->handler) 983 if (acpi_dev->handler && !acpi_is_pnp_device(acpi_dev))
979 return -EINVAL; 984 return -EINVAL;
980 985
981 if (!acpi_drv->ops.add) 986 if (!acpi_drv->ops.add)
diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index c7d138eca731..3598110d2cef 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -442,12 +442,15 @@ static int rd_nr;
442int rd_size = CONFIG_BLK_DEV_RAM_SIZE; 442int rd_size = CONFIG_BLK_DEV_RAM_SIZE;
443static int max_part; 443static int max_part;
444static int part_shift; 444static int part_shift;
445static int part_show = 0;
445module_param(rd_nr, int, S_IRUGO); 446module_param(rd_nr, int, S_IRUGO);
446MODULE_PARM_DESC(rd_nr, "Maximum number of brd devices"); 447MODULE_PARM_DESC(rd_nr, "Maximum number of brd devices");
447module_param(rd_size, int, S_IRUGO); 448module_param(rd_size, int, S_IRUGO);
448MODULE_PARM_DESC(rd_size, "Size of each RAM disk in kbytes."); 449MODULE_PARM_DESC(rd_size, "Size of each RAM disk in kbytes.");
449module_param(max_part, int, S_IRUGO); 450module_param(max_part, int, S_IRUGO);
450MODULE_PARM_DESC(max_part, "Maximum number of partitions per RAM disk"); 451MODULE_PARM_DESC(max_part, "Maximum number of partitions per RAM disk");
452module_param(part_show, int, S_IRUGO);
453MODULE_PARM_DESC(part_show, "Control RAM disk visibility in /proc/partitions");
451MODULE_LICENSE("GPL"); 454MODULE_LICENSE("GPL");
452MODULE_ALIAS_BLOCKDEV_MAJOR(RAMDISK_MAJOR); 455MODULE_ALIAS_BLOCKDEV_MAJOR(RAMDISK_MAJOR);
453MODULE_ALIAS("rd"); 456MODULE_ALIAS("rd");
@@ -501,7 +504,8 @@ static struct brd_device *brd_alloc(int i)
501 disk->fops = &brd_fops; 504 disk->fops = &brd_fops;
502 disk->private_data = brd; 505 disk->private_data = brd;
503 disk->queue = brd->brd_queue; 506 disk->queue = brd->brd_queue;
504 disk->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO; 507 if (!part_show)
508 disk->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO;
505 sprintf(disk->disk_name, "ram%d", i); 509 sprintf(disk->disk_name, "ram%d", i);
506 set_capacity(disk, rd_size * 2); 510 set_capacity(disk, rd_size * 2);
507 511
diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c
index ab3ea62e5dfc..c4328d9d9981 100644
--- a/drivers/block/xsysace.c
+++ b/drivers/block/xsysace.c
@@ -1203,7 +1203,6 @@ static struct platform_driver ace_platform_driver = {
1203 .probe = ace_probe, 1203 .probe = ace_probe,
1204 .remove = ace_remove, 1204 .remove = ace_remove,
1205 .driver = { 1205 .driver = {
1206 .owner = THIS_MODULE,
1207 .name = "xsysace", 1206 .name = "xsysace",
1208 .of_match_table = ace_of_match, 1207 .of_match_table = ace_of_match,
1209 }, 1208 },
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index dfa4024c448a..d00831c3d731 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -378,7 +378,6 @@ static int zram_decompress_page(struct zram *zram, char *mem, u32 index)
378 /* Should NEVER happen. Return bio error if it does. */ 378 /* Should NEVER happen. Return bio error if it does. */
379 if (unlikely(ret)) { 379 if (unlikely(ret)) {
380 pr_err("Decompression failed! err=%d, page=%u\n", ret, index); 380 pr_err("Decompression failed! err=%d, page=%u\n", ret, index);
381 atomic64_inc(&zram->stats.failed_reads);
382 return ret; 381 return ret;
383 } 382 }
384 383
@@ -547,8 +546,6 @@ out:
547 zcomp_strm_release(zram->comp, zstrm); 546 zcomp_strm_release(zram->comp, zstrm);
548 if (is_partial_io(bvec)) 547 if (is_partial_io(bvec))
549 kfree(uncmem); 548 kfree(uncmem);
550 if (ret)
551 atomic64_inc(&zram->stats.failed_writes);
552 return ret; 549 return ret;
553} 550}
554 551
@@ -566,6 +563,13 @@ static int zram_bvec_rw(struct zram *zram, struct bio_vec *bvec, u32 index,
566 ret = zram_bvec_write(zram, bvec, index, offset); 563 ret = zram_bvec_write(zram, bvec, index, offset);
567 } 564 }
568 565
566 if (unlikely(ret)) {
567 if (rw == READ)
568 atomic64_inc(&zram->stats.failed_reads);
569 else
570 atomic64_inc(&zram->stats.failed_writes);
571 }
572
569 return ret; 573 return ret;
570} 574}
571 575
diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h
index 5b0afde729cd..e0f725c87cc6 100644
--- a/drivers/block/zram/zram_drv.h
+++ b/drivers/block/zram/zram_drv.h
@@ -84,7 +84,7 @@ struct zram_stats {
84 atomic64_t compr_data_size; /* compressed size of pages stored */ 84 atomic64_t compr_data_size; /* compressed size of pages stored */
85 atomic64_t num_reads; /* failed + successful */ 85 atomic64_t num_reads; /* failed + successful */
86 atomic64_t num_writes; /* --do-- */ 86 atomic64_t num_writes; /* --do-- */
87 atomic64_t failed_reads; /* should NEVER! happen */ 87 atomic64_t failed_reads; /* can happen when memory is too low */
88 atomic64_t failed_writes; /* can happen when memory is too low */ 88 atomic64_t failed_writes; /* can happen when memory is too low */
89 atomic64_t invalid_io; /* non-page-aligned I/O requests */ 89 atomic64_t invalid_io; /* non-page-aligned I/O requests */
90 atomic64_t notify_free; /* no. of swap slot free notifications */ 90 atomic64_t notify_free; /* no. of swap slot free notifications */
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index c5eac949760d..e396ad3f8f3f 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -660,6 +660,7 @@ static const struct x86_cpu_id intel_pstate_cpu_ids[] = {
660 ICPU(0x3f, core_params), 660 ICPU(0x3f, core_params),
661 ICPU(0x45, core_params), 661 ICPU(0x45, core_params),
662 ICPU(0x46, core_params), 662 ICPU(0x46, core_params),
663 ICPU(0x4c, byt_params),
663 ICPU(0x4f, core_params), 664 ICPU(0x4f, core_params),
664 ICPU(0x56, core_params), 665 ICPU(0x56, core_params),
665 {} 666 {}
@@ -688,7 +689,7 @@ static int intel_pstate_init_cpu(unsigned int cpunum)
688 689
689 add_timer_on(&cpu->timer, cpunum); 690 add_timer_on(&cpu->timer, cpunum);
690 691
691 pr_info("Intel pstate controlling: cpu %d\n", cpunum); 692 pr_debug("Intel pstate controlling: cpu %d\n", cpunum);
692 693
693 return 0; 694 return 0;
694} 695}
diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
index 9a68225a757e..3f9791f07b8e 100644
--- a/drivers/cpufreq/s5pv210-cpufreq.c
+++ b/drivers/cpufreq/s5pv210-cpufreq.c
@@ -501,7 +501,7 @@ static int check_mem_type(void __iomem *dmc_reg)
501 return val >> 8; 501 return val >> 8;
502} 502}
503 503
504static int __init s5pv210_cpu_init(struct cpufreq_policy *policy) 504static int s5pv210_cpu_init(struct cpufreq_policy *policy)
505{ 505{
506 unsigned long mem_type; 506 unsigned long mem_type;
507 int ret; 507 int ret;
diff --git a/drivers/cpuidle/cpuidle-big_little.c b/drivers/cpuidle/cpuidle-big_little.c
index 344d79fa3407..ef94c3b81f18 100644
--- a/drivers/cpuidle/cpuidle-big_little.c
+++ b/drivers/cpuidle/cpuidle-big_little.c
@@ -138,25 +138,18 @@ static int bl_enter_powerdown(struct cpuidle_device *dev,
138 return idx; 138 return idx;
139} 139}
140 140
141static int __init bl_idle_driver_init(struct cpuidle_driver *drv, int cpu_id) 141static int __init bl_idle_driver_init(struct cpuidle_driver *drv, int part_id)
142{ 142{
143 struct cpuinfo_arm *cpu_info;
144 struct cpumask *cpumask; 143 struct cpumask *cpumask;
145 unsigned long cpuid;
146 int cpu; 144 int cpu;
147 145
148 cpumask = kzalloc(cpumask_size(), GFP_KERNEL); 146 cpumask = kzalloc(cpumask_size(), GFP_KERNEL);
149 if (!cpumask) 147 if (!cpumask)
150 return -ENOMEM; 148 return -ENOMEM;
151 149
152 for_each_possible_cpu(cpu) { 150 for_each_possible_cpu(cpu)
153 cpu_info = &per_cpu(cpu_data, cpu); 151 if (smp_cpuid_part(cpu) == part_id)
154 cpuid = is_smp() ? cpu_info->cpuid : read_cpuid_id();
155
156 /* read cpu id part number */
157 if ((cpuid & 0xFFF0) == cpu_id)
158 cpumask_set_cpu(cpu, cpumask); 152 cpumask_set_cpu(cpu, cpumask);
159 }
160 153
161 drv->cpumask = cpumask; 154 drv->cpumask = cpumask;
162 155
diff --git a/drivers/dma-buf/fence.c b/drivers/dma-buf/fence.c
index 4222cb2aa96a..7bb9d65d9a2c 100644
--- a/drivers/dma-buf/fence.c
+++ b/drivers/dma-buf/fence.c
@@ -29,7 +29,7 @@
29EXPORT_TRACEPOINT_SYMBOL(fence_annotate_wait_on); 29EXPORT_TRACEPOINT_SYMBOL(fence_annotate_wait_on);
30EXPORT_TRACEPOINT_SYMBOL(fence_emit); 30EXPORT_TRACEPOINT_SYMBOL(fence_emit);
31 31
32/** 32/*
33 * fence context counter: each execution context should have its own 33 * fence context counter: each execution context should have its own
34 * fence context, this allows checking if fences belong to the same 34 * fence context, this allows checking if fences belong to the same
35 * context or not. One device can have multiple separate contexts, 35 * context or not. One device can have multiple separate contexts,
diff --git a/drivers/gpu/drm/ast/ast_tables.h b/drivers/gpu/drm/ast/ast_tables.h
index 4c761dcea972..05c01ea85294 100644
--- a/drivers/gpu/drm/ast/ast_tables.h
+++ b/drivers/gpu/drm/ast/ast_tables.h
@@ -99,6 +99,7 @@ static struct ast_vbios_dclk_info dclk_table[] = {
99 {0x25, 0x65, 0x80}, /* 16: VCLK88.75 */ 99 {0x25, 0x65, 0x80}, /* 16: VCLK88.75 */
100 {0x77, 0x58, 0x80}, /* 17: VCLK119 */ 100 {0x77, 0x58, 0x80}, /* 17: VCLK119 */
101 {0x32, 0x67, 0x80}, /* 18: VCLK85_5 */ 101 {0x32, 0x67, 0x80}, /* 18: VCLK85_5 */
102 {0x6a, 0x6d, 0x80}, /* 19: VCLK97_75 */
102}; 103};
103 104
104static struct ast_vbios_stdtable vbios_stdtable[] = { 105static struct ast_vbios_stdtable vbios_stdtable[] = {
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index fa2be249999c..90e773019eac 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -4696,8 +4696,9 @@ int drm_mode_create_dumb_ioctl(struct drm_device *dev,
4696 return -EINVAL; 4696 return -EINVAL;
4697 4697
4698 /* overflow checks for 32bit size calculations */ 4698 /* overflow checks for 32bit size calculations */
4699 /* NOTE: DIV_ROUND_UP() can overflow */
4699 cpp = DIV_ROUND_UP(args->bpp, 8); 4700 cpp = DIV_ROUND_UP(args->bpp, 8);
4700 if (cpp > 0xffffffffU / args->width) 4701 if (!cpp || cpp > 0xffffffffU / args->width)
4701 return -EINVAL; 4702 return -EINVAL;
4702 stride = cpp * args->width; 4703 stride = cpp * args->width;
4703 if (args->height > 0xffffffffU / stride) 4704 if (args->height > 0xffffffffU / stride)
diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
index 74cebb51e8c2..c6c80ea28c35 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
@@ -397,6 +397,7 @@ static void mdp4_crtc_prepare(struct drm_crtc *crtc)
397 struct mdp4_crtc *mdp4_crtc = to_mdp4_crtc(crtc); 397 struct mdp4_crtc *mdp4_crtc = to_mdp4_crtc(crtc);
398 DBG("%s", mdp4_crtc->name); 398 DBG("%s", mdp4_crtc->name);
399 /* make sure we hold a ref to mdp clks while setting up mode: */ 399 /* make sure we hold a ref to mdp clks while setting up mode: */
400 drm_crtc_vblank_get(crtc);
400 mdp4_enable(get_kms(crtc)); 401 mdp4_enable(get_kms(crtc));
401 mdp4_crtc_dpms(crtc, DRM_MODE_DPMS_OFF); 402 mdp4_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
402} 403}
@@ -407,6 +408,7 @@ static void mdp4_crtc_commit(struct drm_crtc *crtc)
407 crtc_flush(crtc); 408 crtc_flush(crtc);
408 /* drop the ref to mdp clk's that we got in prepare: */ 409 /* drop the ref to mdp clk's that we got in prepare: */
409 mdp4_disable(get_kms(crtc)); 410 mdp4_disable(get_kms(crtc));
411 drm_crtc_vblank_put(crtc);
410} 412}
411 413
412static int mdp4_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y, 414static int mdp4_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index b447c01ad89c..26ee80db17af 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -974,12 +974,11 @@ static int msm_pdev_probe(struct platform_device *pdev)
974 974
975 for (i = 0; i < ARRAY_SIZE(devnames); i++) { 975 for (i = 0; i < ARRAY_SIZE(devnames); i++) {
976 struct device *dev; 976 struct device *dev;
977 int ret;
978 977
979 dev = bus_find_device_by_name(&platform_bus_type, 978 dev = bus_find_device_by_name(&platform_bus_type,
980 NULL, devnames[i]); 979 NULL, devnames[i]);
981 if (!dev) { 980 if (!dev) {
982 dev_info(master, "still waiting for %s\n", devnames[i]); 981 dev_info(&pdev->dev, "still waiting for %s\n", devnames[i]);
983 return -EPROBE_DEFER; 982 return -EPROBE_DEFER;
984 } 983 }
985 984
diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c
index 9c5221ce391a..ab5bfd2d0ebf 100644
--- a/drivers/gpu/drm/msm/msm_fbdev.c
+++ b/drivers/gpu/drm/msm/msm_fbdev.c
@@ -143,7 +143,7 @@ static int msm_fbdev_create(struct drm_fb_helper *helper,
143 ret = msm_gem_get_iova_locked(fbdev->bo, 0, &paddr); 143 ret = msm_gem_get_iova_locked(fbdev->bo, 0, &paddr);
144 if (ret) { 144 if (ret) {
145 dev_err(dev->dev, "failed to get buffer obj iova: %d\n", ret); 145 dev_err(dev->dev, "failed to get buffer obj iova: %d\n", ret);
146 goto fail; 146 goto fail_unlock;
147 } 147 }
148 148
149 fbi = framebuffer_alloc(0, dev->dev); 149 fbi = framebuffer_alloc(0, dev->dev);
diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iommu.c
index 099af483fdf0..7acdaa5688b7 100644
--- a/drivers/gpu/drm/msm/msm_iommu.c
+++ b/drivers/gpu/drm/msm/msm_iommu.c
@@ -27,8 +27,8 @@ struct msm_iommu {
27static int msm_fault_handler(struct iommu_domain *iommu, struct device *dev, 27static int msm_fault_handler(struct iommu_domain *iommu, struct device *dev,
28 unsigned long iova, int flags, void *arg) 28 unsigned long iova, int flags, void *arg)
29{ 29{
30 DBG("*** fault: iova=%08lx, flags=%d", iova, flags); 30 pr_warn_ratelimited("*** fault: iova=%08lx, flags=%d\n", iova, flags);
31 return -ENOSYS; 31 return 0;
32} 32}
33 33
34static int msm_iommu_attach(struct msm_mmu *mmu, const char **names, int cnt) 34static int msm_iommu_attach(struct msm_mmu *mmu, const char **names, int cnt)
diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
index 79a5a5519bd6..fa9565957f9d 100644
--- a/drivers/gpu/drm/radeon/cik.c
+++ b/drivers/gpu/drm/radeon/cik.c
@@ -5749,20 +5749,17 @@ static int cik_pcie_gart_enable(struct radeon_device *rdev)
5749 WREG32(0x15D8, 0); 5749 WREG32(0x15D8, 0);
5750 WREG32(0x15DC, 0); 5750 WREG32(0x15DC, 0);
5751 5751
5752 /* empty context1-15 */ 5752 /* restore context1-15 */
5753 /* FIXME start with 4G, once using 2 level pt switch to full
5754 * vm size space
5755 */
5756 /* set vm size, must be a multiple of 4 */ 5753 /* set vm size, must be a multiple of 4 */
5757 WREG32(VM_CONTEXT1_PAGE_TABLE_START_ADDR, 0); 5754 WREG32(VM_CONTEXT1_PAGE_TABLE_START_ADDR, 0);
5758 WREG32(VM_CONTEXT1_PAGE_TABLE_END_ADDR, rdev->vm_manager.max_pfn); 5755 WREG32(VM_CONTEXT1_PAGE_TABLE_END_ADDR, rdev->vm_manager.max_pfn);
5759 for (i = 1; i < 16; i++) { 5756 for (i = 1; i < 16; i++) {
5760 if (i < 8) 5757 if (i < 8)
5761 WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (i << 2), 5758 WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (i << 2),
5762 rdev->gart.table_addr >> 12); 5759 rdev->vm_manager.saved_table_addr[i]);
5763 else 5760 else
5764 WREG32(VM_CONTEXT8_PAGE_TABLE_BASE_ADDR + ((i - 8) << 2), 5761 WREG32(VM_CONTEXT8_PAGE_TABLE_BASE_ADDR + ((i - 8) << 2),
5765 rdev->gart.table_addr >> 12); 5762 rdev->vm_manager.saved_table_addr[i]);
5766 } 5763 }
5767 5764
5768 /* enable context1-15 */ 5765 /* enable context1-15 */
@@ -5827,6 +5824,17 @@ static int cik_pcie_gart_enable(struct radeon_device *rdev)
5827 */ 5824 */
5828static void cik_pcie_gart_disable(struct radeon_device *rdev) 5825static void cik_pcie_gart_disable(struct radeon_device *rdev)
5829{ 5826{
5827 unsigned i;
5828
5829 for (i = 1; i < 16; ++i) {
5830 uint32_t reg;
5831 if (i < 8)
5832 reg = VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (i << 2);
5833 else
5834 reg = VM_CONTEXT8_PAGE_TABLE_BASE_ADDR + ((i - 8) << 2);
5835 rdev->vm_manager.saved_table_addr[i] = RREG32(reg);
5836 }
5837
5830 /* Disable all tables */ 5838 /* Disable all tables */
5831 WREG32(VM_CONTEXT0_CNTL, 0); 5839 WREG32(VM_CONTEXT0_CNTL, 0);
5832 WREG32(VM_CONTEXT1_CNTL, 0); 5840 WREG32(VM_CONTEXT1_CNTL, 0);
@@ -9555,6 +9563,9 @@ static void cik_pcie_gen3_enable(struct radeon_device *rdev)
9555 int ret, i; 9563 int ret, i;
9556 u16 tmp16; 9564 u16 tmp16;
9557 9565
9566 if (pci_is_root_bus(rdev->pdev->bus))
9567 return;
9568
9558 if (radeon_pcie_gen2 == 0) 9569 if (radeon_pcie_gen2 == 0)
9559 return; 9570 return;
9560 9571
@@ -9781,7 +9792,8 @@ static void cik_program_aspm(struct radeon_device *rdev)
9781 if (orig != data) 9792 if (orig != data)
9782 WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, data); 9793 WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, data);
9783 9794
9784 if (!disable_clkreq) { 9795 if (!disable_clkreq &&
9796 !pci_is_root_bus(rdev->pdev->bus)) {
9785 struct pci_dev *root = rdev->pdev->bus->self; 9797 struct pci_dev *root = rdev->pdev->bus->self;
9786 u32 lnkcap; 9798 u32 lnkcap;
9787 9799
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index ba89375f197f..3faee58946dd 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -1271,7 +1271,7 @@ static int cayman_pcie_gart_enable(struct radeon_device *rdev)
1271 WREG32(VM_CONTEXT0_PAGE_TABLE_START_ADDR + (i << 2), 0); 1271 WREG32(VM_CONTEXT0_PAGE_TABLE_START_ADDR + (i << 2), 0);
1272 WREG32(VM_CONTEXT0_PAGE_TABLE_END_ADDR + (i << 2), rdev->vm_manager.max_pfn); 1272 WREG32(VM_CONTEXT0_PAGE_TABLE_END_ADDR + (i << 2), rdev->vm_manager.max_pfn);
1273 WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (i << 2), 1273 WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (i << 2),
1274 rdev->gart.table_addr >> 12); 1274 rdev->vm_manager.saved_table_addr[i]);
1275 } 1275 }
1276 1276
1277 /* enable context1-7 */ 1277 /* enable context1-7 */
@@ -1303,6 +1303,13 @@ static int cayman_pcie_gart_enable(struct radeon_device *rdev)
1303 1303
1304static void cayman_pcie_gart_disable(struct radeon_device *rdev) 1304static void cayman_pcie_gart_disable(struct radeon_device *rdev)
1305{ 1305{
1306 unsigned i;
1307
1308 for (i = 1; i < 8; ++i) {
1309 rdev->vm_manager.saved_table_addr[i] = RREG32(
1310 VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (i << 2));
1311 }
1312
1306 /* Disable all tables */ 1313 /* Disable all tables */
1307 WREG32(VM_CONTEXT0_CNTL, 0); 1314 WREG32(VM_CONTEXT0_CNTL, 0);
1308 WREG32(VM_CONTEXT1_CNTL, 0); 1315 WREG32(VM_CONTEXT1_CNTL, 0);
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index e8bf0ea2dade..e616eb5f6e7a 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -1812,7 +1812,6 @@ static void r600_gpu_init(struct radeon_device *rdev)
1812{ 1812{
1813 u32 tiling_config; 1813 u32 tiling_config;
1814 u32 ramcfg; 1814 u32 ramcfg;
1815 u32 cc_rb_backend_disable;
1816 u32 cc_gc_shader_pipe_config; 1815 u32 cc_gc_shader_pipe_config;
1817 u32 tmp; 1816 u32 tmp;
1818 int i, j; 1817 int i, j;
@@ -1939,29 +1938,20 @@ static void r600_gpu_init(struct radeon_device *rdev)
1939 } 1938 }
1940 tiling_config |= BANK_SWAPS(1); 1939 tiling_config |= BANK_SWAPS(1);
1941 1940
1942 cc_rb_backend_disable = RREG32(CC_RB_BACKEND_DISABLE) & 0x00ff0000;
1943 tmp = R6XX_MAX_BACKENDS -
1944 r600_count_pipe_bits((cc_rb_backend_disable >> 16) & R6XX_MAX_BACKENDS_MASK);
1945 if (tmp < rdev->config.r600.max_backends) {
1946 rdev->config.r600.max_backends = tmp;
1947 }
1948
1949 cc_gc_shader_pipe_config = RREG32(CC_GC_SHADER_PIPE_CONFIG) & 0x00ffff00; 1941 cc_gc_shader_pipe_config = RREG32(CC_GC_SHADER_PIPE_CONFIG) & 0x00ffff00;
1950 tmp = R6XX_MAX_PIPES -
1951 r600_count_pipe_bits((cc_gc_shader_pipe_config >> 8) & R6XX_MAX_PIPES_MASK);
1952 if (tmp < rdev->config.r600.max_pipes) {
1953 rdev->config.r600.max_pipes = tmp;
1954 }
1955 tmp = R6XX_MAX_SIMDS -
1956 r600_count_pipe_bits((cc_gc_shader_pipe_config >> 16) & R6XX_MAX_SIMDS_MASK);
1957 if (tmp < rdev->config.r600.max_simds) {
1958 rdev->config.r600.max_simds = tmp;
1959 }
1960 tmp = rdev->config.r600.max_simds - 1942 tmp = rdev->config.r600.max_simds -
1961 r600_count_pipe_bits((cc_gc_shader_pipe_config >> 16) & R6XX_MAX_SIMDS_MASK); 1943 r600_count_pipe_bits((cc_gc_shader_pipe_config >> 16) & R6XX_MAX_SIMDS_MASK);
1962 rdev->config.r600.active_simds = tmp; 1944 rdev->config.r600.active_simds = tmp;
1963 1945
1964 disabled_rb_mask = (RREG32(CC_RB_BACKEND_DISABLE) >> 16) & R6XX_MAX_BACKENDS_MASK; 1946 disabled_rb_mask = (RREG32(CC_RB_BACKEND_DISABLE) >> 16) & R6XX_MAX_BACKENDS_MASK;
1947 tmp = 0;
1948 for (i = 0; i < rdev->config.r600.max_backends; i++)
1949 tmp |= (1 << i);
1950 /* if all the backends are disabled, fix it up here */
1951 if ((disabled_rb_mask & tmp) == tmp) {
1952 for (i = 0; i < rdev->config.r600.max_backends; i++)
1953 disabled_rb_mask &= ~(1 << i);
1954 }
1965 tmp = (tiling_config & PIPE_TILING__MASK) >> PIPE_TILING__SHIFT; 1955 tmp = (tiling_config & PIPE_TILING__MASK) >> PIPE_TILING__SHIFT;
1966 tmp = r6xx_remap_render_backend(rdev, tmp, rdev->config.r600.max_backends, 1956 tmp = r6xx_remap_render_backend(rdev, tmp, rdev->config.r600.max_backends,
1967 R6XX_MAX_BACKENDS, disabled_rb_mask); 1957 R6XX_MAX_BACKENDS, disabled_rb_mask);
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index b281886f6f51..5f05b4c84338 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -915,6 +915,8 @@ struct radeon_vm_manager {
915 u64 vram_base_offset; 915 u64 vram_base_offset;
916 /* is vm enabled? */ 916 /* is vm enabled? */
917 bool enabled; 917 bool enabled;
918 /* for hw to save the PD addr on suspend/resume */
919 uint32_t saved_table_addr[RADEON_NUM_VM];
918}; 920};
919 921
920/* 922/*
diff --git a/drivers/gpu/drm/radeon/rv770.c b/drivers/gpu/drm/radeon/rv770.c
index 2983f17ea1b3..d9f5ce715c9b 100644
--- a/drivers/gpu/drm/radeon/rv770.c
+++ b/drivers/gpu/drm/radeon/rv770.c
@@ -1177,7 +1177,6 @@ static void rv770_gpu_init(struct radeon_device *rdev)
1177 u32 hdp_host_path_cntl; 1177 u32 hdp_host_path_cntl;
1178 u32 sq_dyn_gpr_size_simd_ab_0; 1178 u32 sq_dyn_gpr_size_simd_ab_0;
1179 u32 gb_tiling_config = 0; 1179 u32 gb_tiling_config = 0;
1180 u32 cc_rb_backend_disable = 0;
1181 u32 cc_gc_shader_pipe_config = 0; 1180 u32 cc_gc_shader_pipe_config = 0;
1182 u32 mc_arb_ramcfg; 1181 u32 mc_arb_ramcfg;
1183 u32 db_debug4, tmp; 1182 u32 db_debug4, tmp;
@@ -1311,21 +1310,7 @@ static void rv770_gpu_init(struct radeon_device *rdev)
1311 WREG32(SPI_CONFIG_CNTL, 0); 1310 WREG32(SPI_CONFIG_CNTL, 0);
1312 } 1311 }
1313 1312
1314 cc_rb_backend_disable = RREG32(CC_RB_BACKEND_DISABLE) & 0x00ff0000;
1315 tmp = R7XX_MAX_BACKENDS - r600_count_pipe_bits(cc_rb_backend_disable >> 16);
1316 if (tmp < rdev->config.rv770.max_backends) {
1317 rdev->config.rv770.max_backends = tmp;
1318 }
1319
1320 cc_gc_shader_pipe_config = RREG32(CC_GC_SHADER_PIPE_CONFIG) & 0xffffff00; 1313 cc_gc_shader_pipe_config = RREG32(CC_GC_SHADER_PIPE_CONFIG) & 0xffffff00;
1321 tmp = R7XX_MAX_PIPES - r600_count_pipe_bits((cc_gc_shader_pipe_config >> 8) & R7XX_MAX_PIPES_MASK);
1322 if (tmp < rdev->config.rv770.max_pipes) {
1323 rdev->config.rv770.max_pipes = tmp;
1324 }
1325 tmp = R7XX_MAX_SIMDS - r600_count_pipe_bits((cc_gc_shader_pipe_config >> 16) & R7XX_MAX_SIMDS_MASK);
1326 if (tmp < rdev->config.rv770.max_simds) {
1327 rdev->config.rv770.max_simds = tmp;
1328 }
1329 tmp = rdev->config.rv770.max_simds - 1314 tmp = rdev->config.rv770.max_simds -
1330 r600_count_pipe_bits((cc_gc_shader_pipe_config >> 16) & R7XX_MAX_SIMDS_MASK); 1315 r600_count_pipe_bits((cc_gc_shader_pipe_config >> 16) & R7XX_MAX_SIMDS_MASK);
1331 rdev->config.rv770.active_simds = tmp; 1316 rdev->config.rv770.active_simds = tmp;
@@ -1348,6 +1333,14 @@ static void rv770_gpu_init(struct radeon_device *rdev)
1348 rdev->config.rv770.tiling_npipes = rdev->config.rv770.max_tile_pipes; 1333 rdev->config.rv770.tiling_npipes = rdev->config.rv770.max_tile_pipes;
1349 1334
1350 disabled_rb_mask = (RREG32(CC_RB_BACKEND_DISABLE) >> 16) & R7XX_MAX_BACKENDS_MASK; 1335 disabled_rb_mask = (RREG32(CC_RB_BACKEND_DISABLE) >> 16) & R7XX_MAX_BACKENDS_MASK;
1336 tmp = 0;
1337 for (i = 0; i < rdev->config.rv770.max_backends; i++)
1338 tmp |= (1 << i);
1339 /* if all the backends are disabled, fix it up here */
1340 if ((disabled_rb_mask & tmp) == tmp) {
1341 for (i = 0; i < rdev->config.rv770.max_backends; i++)
1342 disabled_rb_mask &= ~(1 << i);
1343 }
1351 tmp = (gb_tiling_config & PIPE_TILING__MASK) >> PIPE_TILING__SHIFT; 1344 tmp = (gb_tiling_config & PIPE_TILING__MASK) >> PIPE_TILING__SHIFT;
1352 tmp = r6xx_remap_render_backend(rdev, tmp, rdev->config.rv770.max_backends, 1345 tmp = r6xx_remap_render_backend(rdev, tmp, rdev->config.rv770.max_backends,
1353 R7XX_MAX_BACKENDS, disabled_rb_mask); 1346 R7XX_MAX_BACKENDS, disabled_rb_mask);
diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
index a1274a31405c..6bce40847753 100644
--- a/drivers/gpu/drm/radeon/si.c
+++ b/drivers/gpu/drm/radeon/si.c
@@ -4290,10 +4290,10 @@ static int si_pcie_gart_enable(struct radeon_device *rdev)
4290 for (i = 1; i < 16; i++) { 4290 for (i = 1; i < 16; i++) {
4291 if (i < 8) 4291 if (i < 8)
4292 WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (i << 2), 4292 WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (i << 2),
4293 rdev->gart.table_addr >> 12); 4293 rdev->vm_manager.saved_table_addr[i]);
4294 else 4294 else
4295 WREG32(VM_CONTEXT8_PAGE_TABLE_BASE_ADDR + ((i - 8) << 2), 4295 WREG32(VM_CONTEXT8_PAGE_TABLE_BASE_ADDR + ((i - 8) << 2),
4296 rdev->gart.table_addr >> 12); 4296 rdev->vm_manager.saved_table_addr[i]);
4297 } 4297 }
4298 4298
4299 /* enable context1-15 */ 4299 /* enable context1-15 */
@@ -4325,6 +4325,17 @@ static int si_pcie_gart_enable(struct radeon_device *rdev)
4325 4325
4326static void si_pcie_gart_disable(struct radeon_device *rdev) 4326static void si_pcie_gart_disable(struct radeon_device *rdev)
4327{ 4327{
4328 unsigned i;
4329
4330 for (i = 1; i < 16; ++i) {
4331 uint32_t reg;
4332 if (i < 8)
4333 reg = VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (i << 2);
4334 else
4335 reg = VM_CONTEXT8_PAGE_TABLE_BASE_ADDR + ((i - 8) << 2);
4336 rdev->vm_manager.saved_table_addr[i] = RREG32(reg);
4337 }
4338
4328 /* Disable all tables */ 4339 /* Disable all tables */
4329 WREG32(VM_CONTEXT0_CNTL, 0); 4340 WREG32(VM_CONTEXT0_CNTL, 0);
4330 WREG32(VM_CONTEXT1_CNTL, 0); 4341 WREG32(VM_CONTEXT1_CNTL, 0);
@@ -7177,6 +7188,9 @@ static void si_pcie_gen3_enable(struct radeon_device *rdev)
7177 int ret, i; 7188 int ret, i;
7178 u16 tmp16; 7189 u16 tmp16;
7179 7190
7191 if (pci_is_root_bus(rdev->pdev->bus))
7192 return;
7193
7180 if (radeon_pcie_gen2 == 0) 7194 if (radeon_pcie_gen2 == 0)
7181 return; 7195 return;
7182 7196
@@ -7454,7 +7468,8 @@ static void si_program_aspm(struct radeon_device *rdev)
7454 if (orig != data) 7468 if (orig != data)
7455 WREG32_PIF_PHY1(PB1_PIF_CNTL, data); 7469 WREG32_PIF_PHY1(PB1_PIF_CNTL, data);
7456 7470
7457 if (!disable_clkreq) { 7471 if (!disable_clkreq &&
7472 !pci_is_root_bus(rdev->pdev->bus)) {
7458 struct pci_dev *root = rdev->pdev->bus->self; 7473 struct pci_dev *root = rdev->pdev->bus->self;
7459 u32 lnkcap; 7474 u32 lnkcap;
7460 7475
diff --git a/drivers/gpu/drm/sti/Kconfig b/drivers/gpu/drm/sti/Kconfig
index 2d9d4252d598..ae8850f3e63b 100644
--- a/drivers/gpu/drm/sti/Kconfig
+++ b/drivers/gpu/drm/sti/Kconfig
@@ -1,6 +1,7 @@
1config DRM_STI 1config DRM_STI
2 tristate "DRM Support for STMicroelectronics SoC stiH41x Series" 2 tristate "DRM Support for STMicroelectronics SoC stiH41x Series"
3 depends on DRM && (SOC_STIH415 || SOC_STIH416 || ARCH_MULTIPLATFORM) 3 depends on DRM && (SOC_STIH415 || SOC_STIH416 || ARCH_MULTIPLATFORM)
4 select RESET_CONTROLLER
4 select DRM_KMS_HELPER 5 select DRM_KMS_HELPER
5 select DRM_GEM_CMA_HELPER 6 select DRM_GEM_CMA_HELPER
6 select DRM_KMS_CMA_HELPER 7 select DRM_KMS_CMA_HELPER
diff --git a/drivers/gpu/drm/sti/sti_drm_drv.c b/drivers/gpu/drm/sti/sti_drm_drv.c
index a7cc24917a96..223d93c3a05d 100644
--- a/drivers/gpu/drm/sti/sti_drm_drv.c
+++ b/drivers/gpu/drm/sti/sti_drm_drv.c
@@ -201,8 +201,8 @@ static int sti_drm_platform_probe(struct platform_device *pdev)
201 master = platform_device_register_resndata(dev, 201 master = platform_device_register_resndata(dev,
202 DRIVER_NAME "__master", -1, 202 DRIVER_NAME "__master", -1,
203 NULL, 0, NULL, 0); 203 NULL, 0, NULL, 0);
204 if (!master) 204 if (IS_ERR(master))
205 return -EINVAL; 205 return PTR_ERR(master);
206 206
207 platform_set_drvdata(pdev, master); 207 platform_set_drvdata(pdev, master);
208 return 0; 208 return 0;
diff --git a/drivers/gpu/drm/sti/sti_hda.c b/drivers/gpu/drm/sti/sti_hda.c
index 72d957f81c05..2ae9a9b73666 100644
--- a/drivers/gpu/drm/sti/sti_hda.c
+++ b/drivers/gpu/drm/sti/sti_hda.c
@@ -730,16 +730,16 @@ static int sti_hda_probe(struct platform_device *pdev)
730 return -ENOMEM; 730 return -ENOMEM;
731 } 731 }
732 hda->regs = devm_ioremap_nocache(dev, res->start, resource_size(res)); 732 hda->regs = devm_ioremap_nocache(dev, res->start, resource_size(res));
733 if (IS_ERR(hda->regs)) 733 if (!hda->regs)
734 return PTR_ERR(hda->regs); 734 return -ENOMEM;
735 735
736 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, 736 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
737 "video-dacs-ctrl"); 737 "video-dacs-ctrl");
738 if (res) { 738 if (res) {
739 hda->video_dacs_ctrl = devm_ioremap_nocache(dev, res->start, 739 hda->video_dacs_ctrl = devm_ioremap_nocache(dev, res->start,
740 resource_size(res)); 740 resource_size(res));
741 if (IS_ERR(hda->video_dacs_ctrl)) 741 if (!hda->video_dacs_ctrl)
742 return PTR_ERR(hda->video_dacs_ctrl); 742 return -ENOMEM;
743 } else { 743 } else {
744 /* If no existing video-dacs-ctrl resource continue the probe */ 744 /* If no existing video-dacs-ctrl resource continue the probe */
745 DRM_DEBUG_DRIVER("No video-dacs-ctrl resource\n"); 745 DRM_DEBUG_DRIVER("No video-dacs-ctrl resource\n");
@@ -770,7 +770,7 @@ static int sti_hda_remove(struct platform_device *pdev)
770 return 0; 770 return 0;
771} 771}
772 772
773static struct of_device_id hda_of_match[] = { 773static const struct of_device_id hda_of_match[] = {
774 { .compatible = "st,stih416-hda", }, 774 { .compatible = "st,stih416-hda", },
775 { .compatible = "st,stih407-hda", }, 775 { .compatible = "st,stih407-hda", },
776 { /* end node */ } 776 { /* end node */ }
diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c
index 284e541d970d..ef93156a69c6 100644
--- a/drivers/gpu/drm/sti/sti_hdmi.c
+++ b/drivers/gpu/drm/sti/sti_hdmi.c
@@ -677,7 +677,7 @@ static const struct component_ops sti_hdmi_ops = {
677 .unbind = sti_hdmi_unbind, 677 .unbind = sti_hdmi_unbind,
678}; 678};
679 679
680static struct of_device_id hdmi_of_match[] = { 680static const struct of_device_id hdmi_of_match[] = {
681 { 681 {
682 .compatible = "st,stih416-hdmi", 682 .compatible = "st,stih416-hdmi",
683 .data = &tx3g0c55phy_ops, 683 .data = &tx3g0c55phy_ops,
@@ -713,8 +713,8 @@ static int sti_hdmi_probe(struct platform_device *pdev)
713 return -ENOMEM; 713 return -ENOMEM;
714 } 714 }
715 hdmi->regs = devm_ioremap_nocache(dev, res->start, resource_size(res)); 715 hdmi->regs = devm_ioremap_nocache(dev, res->start, resource_size(res));
716 if (IS_ERR(hdmi->regs)) 716 if (!hdmi->regs)
717 return PTR_ERR(hdmi->regs); 717 return -ENOMEM;
718 718
719 if (of_device_is_compatible(np, "st,stih416-hdmi")) { 719 if (of_device_is_compatible(np, "st,stih416-hdmi")) {
720 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, 720 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
@@ -725,8 +725,8 @@ static int sti_hdmi_probe(struct platform_device *pdev)
725 } 725 }
726 hdmi->syscfg = devm_ioremap_nocache(dev, res->start, 726 hdmi->syscfg = devm_ioremap_nocache(dev, res->start,
727 resource_size(res)); 727 resource_size(res));
728 if (IS_ERR(hdmi->syscfg)) 728 if (!hdmi->syscfg)
729 return PTR_ERR(hdmi->syscfg); 729 return -ENOMEM;
730 730
731 } 731 }
732 732
diff --git a/drivers/gpu/drm/sti/sti_tvout.c b/drivers/gpu/drm/sti/sti_tvout.c
index b69e26fee76e..b8afe490356a 100644
--- a/drivers/gpu/drm/sti/sti_tvout.c
+++ b/drivers/gpu/drm/sti/sti_tvout.c
@@ -591,8 +591,8 @@ static int sti_tvout_probe(struct platform_device *pdev)
591 return -ENOMEM; 591 return -ENOMEM;
592 } 592 }
593 tvout->regs = devm_ioremap_nocache(dev, res->start, resource_size(res)); 593 tvout->regs = devm_ioremap_nocache(dev, res->start, resource_size(res));
594 if (IS_ERR(tvout->regs)) 594 if (!tvout->regs)
595 return PTR_ERR(tvout->regs); 595 return -ENOMEM;
596 596
597 /* get reset resources */ 597 /* get reset resources */
598 tvout->reset = devm_reset_control_get(dev, "tvout"); 598 tvout->reset = devm_reset_control_get(dev, "tvout");
@@ -624,7 +624,7 @@ static int sti_tvout_remove(struct platform_device *pdev)
624 return 0; 624 return 0;
625} 625}
626 626
627static struct of_device_id tvout_of_match[] = { 627static const struct of_device_id tvout_of_match[] = {
628 { .compatible = "st,stih416-tvout", }, 628 { .compatible = "st,stih416-tvout", },
629 { .compatible = "st,stih407-tvout", }, 629 { .compatible = "st,stih407-tvout", },
630 { /* end node */ } 630 { /* end node */ }
diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
index b7ba82960c79..9bf8637747a5 100644
--- a/drivers/hid/hid-logitech-dj.c
+++ b/drivers/hid/hid-logitech-dj.c
@@ -656,7 +656,6 @@ static int logi_dj_raw_event(struct hid_device *hdev,
656 struct dj_receiver_dev *djrcv_dev = hid_get_drvdata(hdev); 656 struct dj_receiver_dev *djrcv_dev = hid_get_drvdata(hdev);
657 struct dj_report *dj_report = (struct dj_report *) data; 657 struct dj_report *dj_report = (struct dj_report *) data;
658 unsigned long flags; 658 unsigned long flags;
659 bool report_processed = false;
660 659
661 dbg_hid("%s, size:%d\n", __func__, size); 660 dbg_hid("%s, size:%d\n", __func__, size);
662 661
@@ -683,34 +682,42 @@ static int logi_dj_raw_event(struct hid_device *hdev,
683 * device (via hid_input_report() ) and return 1 so hid-core does not do 682 * device (via hid_input_report() ) and return 1 so hid-core does not do
684 * anything else with it. 683 * anything else with it.
685 */ 684 */
685
686 /* case 1) */
687 if (data[0] != REPORT_ID_DJ_SHORT)
688 return false;
689
686 if ((dj_report->device_index < DJ_DEVICE_INDEX_MIN) || 690 if ((dj_report->device_index < DJ_DEVICE_INDEX_MIN) ||
687 (dj_report->device_index > DJ_DEVICE_INDEX_MAX)) { 691 (dj_report->device_index > DJ_DEVICE_INDEX_MAX)) {
688 dev_err(&hdev->dev, "%s: invalid device index:%d\n", 692 /*
693 * Device index is wrong, bail out.
694 * This driver can ignore safely the receiver notifications,
695 * so ignore those reports too.
696 */
697 if (dj_report->device_index != DJ_RECEIVER_INDEX)
698 dev_err(&hdev->dev, "%s: invalid device index:%d\n",
689 __func__, dj_report->device_index); 699 __func__, dj_report->device_index);
690 return false; 700 return false;
691 } 701 }
692 702
693 spin_lock_irqsave(&djrcv_dev->lock, flags); 703 spin_lock_irqsave(&djrcv_dev->lock, flags);
694 if (dj_report->report_id == REPORT_ID_DJ_SHORT) { 704 switch (dj_report->report_type) {
695 switch (dj_report->report_type) { 705 case REPORT_TYPE_NOTIF_DEVICE_PAIRED:
696 case REPORT_TYPE_NOTIF_DEVICE_PAIRED: 706 case REPORT_TYPE_NOTIF_DEVICE_UNPAIRED:
697 case REPORT_TYPE_NOTIF_DEVICE_UNPAIRED: 707 logi_dj_recv_queue_notification(djrcv_dev, dj_report);
698 logi_dj_recv_queue_notification(djrcv_dev, dj_report); 708 break;
699 break; 709 case REPORT_TYPE_NOTIF_CONNECTION_STATUS:
700 case REPORT_TYPE_NOTIF_CONNECTION_STATUS: 710 if (dj_report->report_params[CONNECTION_STATUS_PARAM_STATUS] ==
701 if (dj_report->report_params[CONNECTION_STATUS_PARAM_STATUS] == 711 STATUS_LINKLOSS) {
702 STATUS_LINKLOSS) { 712 logi_dj_recv_forward_null_report(djrcv_dev, dj_report);
703 logi_dj_recv_forward_null_report(djrcv_dev, dj_report);
704 }
705 break;
706 default:
707 logi_dj_recv_forward_report(djrcv_dev, dj_report);
708 } 713 }
709 report_processed = true; 714 break;
715 default:
716 logi_dj_recv_forward_report(djrcv_dev, dj_report);
710 } 717 }
711 spin_unlock_irqrestore(&djrcv_dev->lock, flags); 718 spin_unlock_irqrestore(&djrcv_dev->lock, flags);
712 719
713 return report_processed; 720 return true;
714} 721}
715 722
716static int logi_dj_probe(struct hid_device *hdev, 723static int logi_dj_probe(struct hid_device *hdev,
diff --git a/drivers/hid/hid-logitech-dj.h b/drivers/hid/hid-logitech-dj.h
index 4a4000340ce1..daeb0aa4bee9 100644
--- a/drivers/hid/hid-logitech-dj.h
+++ b/drivers/hid/hid-logitech-dj.h
@@ -27,6 +27,7 @@
27 27
28#define DJ_MAX_PAIRED_DEVICES 6 28#define DJ_MAX_PAIRED_DEVICES 6
29#define DJ_MAX_NUMBER_NOTIFICATIONS 8 29#define DJ_MAX_NUMBER_NOTIFICATIONS 8
30#define DJ_RECEIVER_INDEX 0
30#define DJ_DEVICE_INDEX_MIN 1 31#define DJ_DEVICE_INDEX_MIN 1
31#define DJ_DEVICE_INDEX_MAX 6 32#define DJ_DEVICE_INDEX_MAX 6
32 33
diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index ecc2cbf300cc..29a74c1efcb8 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -290,6 +290,11 @@ static int magicmouse_raw_event(struct hid_device *hdev,
290 if (size < 4 || ((size - 4) % 9) != 0) 290 if (size < 4 || ((size - 4) % 9) != 0)
291 return 0; 291 return 0;
292 npoints = (size - 4) / 9; 292 npoints = (size - 4) / 9;
293 if (npoints > 15) {
294 hid_warn(hdev, "invalid size value (%d) for TRACKPAD_REPORT_ID\n",
295 size);
296 return 0;
297 }
293 msc->ntouches = 0; 298 msc->ntouches = 0;
294 for (ii = 0; ii < npoints; ii++) 299 for (ii = 0; ii < npoints; ii++)
295 magicmouse_emit_touch(msc, ii, data + ii * 9 + 4); 300 magicmouse_emit_touch(msc, ii, data + ii * 9 + 4);
@@ -307,6 +312,11 @@ static int magicmouse_raw_event(struct hid_device *hdev,
307 if (size < 6 || ((size - 6) % 8) != 0) 312 if (size < 6 || ((size - 6) % 8) != 0)
308 return 0; 313 return 0;
309 npoints = (size - 6) / 8; 314 npoints = (size - 6) / 8;
315 if (npoints > 15) {
316 hid_warn(hdev, "invalid size value (%d) for MOUSE_REPORT_ID\n",
317 size);
318 return 0;
319 }
310 msc->ntouches = 0; 320 msc->ntouches = 0;
311 for (ii = 0; ii < npoints; ii++) 321 for (ii = 0; ii < npoints; ii++)
312 magicmouse_emit_touch(msc, ii, data + ii * 8 + 6); 322 magicmouse_emit_touch(msc, ii, data + ii * 8 + 6);
diff --git a/drivers/hid/hid-picolcd_core.c b/drivers/hid/hid-picolcd_core.c
index acbb021065ec..020df3c2e8b4 100644
--- a/drivers/hid/hid-picolcd_core.c
+++ b/drivers/hid/hid-picolcd_core.c
@@ -350,6 +350,12 @@ static int picolcd_raw_event(struct hid_device *hdev,
350 if (!data) 350 if (!data)
351 return 1; 351 return 1;
352 352
353 if (size > 64) {
354 hid_warn(hdev, "invalid size value (%d) for picolcd raw event\n",
355 size);
356 return 0;
357 }
358
353 if (report->id == REPORT_KEY_STATE) { 359 if (report->id == REPORT_KEY_STATE) {
354 if (data->input_keys) 360 if (data->input_keys)
355 ret = picolcd_raw_keypad(data, report, raw_data+1, size-1); 361 ret = picolcd_raw_keypad(data, report, raw_data+1, size-1);
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 2785007e0e46..cd15e0801228 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -1688,6 +1688,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
1688 unsigned int key_size, opt_params; 1688 unsigned int key_size, opt_params;
1689 unsigned long long tmpll; 1689 unsigned long long tmpll;
1690 int ret; 1690 int ret;
1691 size_t iv_size_padding;
1691 struct dm_arg_set as; 1692 struct dm_arg_set as;
1692 const char *opt_string; 1693 const char *opt_string;
1693 char dummy; 1694 char dummy;
@@ -1724,20 +1725,32 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
1724 1725
1725 cc->dmreq_start = sizeof(struct ablkcipher_request); 1726 cc->dmreq_start = sizeof(struct ablkcipher_request);
1726 cc->dmreq_start += crypto_ablkcipher_reqsize(any_tfm(cc)); 1727 cc->dmreq_start += crypto_ablkcipher_reqsize(any_tfm(cc));
1727 cc->dmreq_start = ALIGN(cc->dmreq_start, crypto_tfm_ctx_alignment()); 1728 cc->dmreq_start = ALIGN(cc->dmreq_start, __alignof__(struct dm_crypt_request));
1728 cc->dmreq_start += crypto_ablkcipher_alignmask(any_tfm(cc)) & 1729
1729 ~(crypto_tfm_ctx_alignment() - 1); 1730 if (crypto_ablkcipher_alignmask(any_tfm(cc)) < CRYPTO_MINALIGN) {
1731 /* Allocate the padding exactly */
1732 iv_size_padding = -(cc->dmreq_start + sizeof(struct dm_crypt_request))
1733 & crypto_ablkcipher_alignmask(any_tfm(cc));
1734 } else {
1735 /*
1736 * If the cipher requires greater alignment than kmalloc
1737 * alignment, we don't know the exact position of the
1738 * initialization vector. We must assume worst case.
1739 */
1740 iv_size_padding = crypto_ablkcipher_alignmask(any_tfm(cc));
1741 }
1730 1742
1731 cc->req_pool = mempool_create_kmalloc_pool(MIN_IOS, cc->dmreq_start + 1743 cc->req_pool = mempool_create_kmalloc_pool(MIN_IOS, cc->dmreq_start +
1732 sizeof(struct dm_crypt_request) + cc->iv_size); 1744 sizeof(struct dm_crypt_request) + iv_size_padding + cc->iv_size);
1733 if (!cc->req_pool) { 1745 if (!cc->req_pool) {
1734 ti->error = "Cannot allocate crypt request mempool"; 1746 ti->error = "Cannot allocate crypt request mempool";
1735 goto bad; 1747 goto bad;
1736 } 1748 }
1737 1749
1738 cc->per_bio_data_size = ti->per_bio_data_size = 1750 cc->per_bio_data_size = ti->per_bio_data_size =
1739 sizeof(struct dm_crypt_io) + cc->dmreq_start + 1751 ALIGN(sizeof(struct dm_crypt_io) + cc->dmreq_start +
1740 sizeof(struct dm_crypt_request) + cc->iv_size; 1752 sizeof(struct dm_crypt_request) + iv_size_padding + cc->iv_size,
1753 ARCH_KMALLOC_MINALIGN);
1741 1754
1742 cc->page_pool = mempool_create_page_pool(MIN_POOL_PAGES, 0); 1755 cc->page_pool = mempool_create_page_pool(MIN_POOL_PAGES, 0);
1743 if (!cc->page_pool) { 1756 if (!cc->page_pool) {
diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c
index ce48aa72bb42..bde2fc072410 100644
--- a/drivers/mfd/ab8500-core.c
+++ b/drivers/mfd/ab8500-core.c
@@ -1754,7 +1754,7 @@ static int ab8500_probe(struct platform_device *pdev)
1754 if (ret) 1754 if (ret)
1755 return ret; 1755 return ret;
1756 1756
1757#if CONFIG_DEBUG_FS 1757#ifdef CONFIG_DEBUG_FS
1758 /* Pass to debugfs */ 1758 /* Pass to debugfs */
1759 ab8500_debug_resources[0].start = ab8500->irq; 1759 ab8500_debug_resources[0].start = ab8500->irq;
1760 ab8500_debug_resources[0].end = ab8500->irq; 1760 ab8500_debug_resources[0].end = ab8500->irq;
diff --git a/drivers/mfd/htc-i2cpld.c b/drivers/mfd/htc-i2cpld.c
index b44f0203983b..6bdb78c2ac77 100644
--- a/drivers/mfd/htc-i2cpld.c
+++ b/drivers/mfd/htc-i2cpld.c
@@ -404,7 +404,7 @@ static int htcpld_register_chip_i2c(
404 } 404 }
405 405
406 i2c_set_clientdata(client, chip); 406 i2c_set_clientdata(client, chip);
407 snprintf(client->name, I2C_NAME_SIZE, "Chip_0x%d", client->addr); 407 snprintf(client->name, I2C_NAME_SIZE, "Chip_0x%x", client->addr);
408 chip->client = client; 408 chip->client = client;
409 409
410 /* Reset the chip */ 410 /* Reset the chip */
diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 33a9234b701c..83dab2f0a50e 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -647,7 +647,7 @@ static int usbhs_omap_probe(struct platform_device *pdev)
647 default: 647 default:
648 omap->nports = OMAP3_HS_USB_PORTS; 648 omap->nports = OMAP3_HS_USB_PORTS;
649 dev_dbg(dev, 649 dev_dbg(dev,
650 "USB HOST Rev:0x%d not recognized, assuming %d ports\n", 650 "USB HOST Rev:0x%x not recognized, assuming %d ports\n",
651 omap->usbhs_rev, omap->nports); 651 omap->usbhs_rev, omap->nports);
652 break; 652 break;
653 } 653 }
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index 3bc969a5916b..4d3ff3771491 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -724,24 +724,24 @@ static struct twl4030_script *omap3_idle_scripts[] = {
724 * above. 724 * above.
725 */ 725 */
726static struct twl4030_resconfig omap3_idle_rconfig[] = { 726static struct twl4030_resconfig omap3_idle_rconfig[] = {
727 TWL_REMAP_SLEEP(RES_VAUX1, DEV_GRP_NULL, 0, 0), 727 TWL_REMAP_SLEEP(RES_VAUX1, TWL4030_RESCONFIG_UNDEF, 0, 0),
728 TWL_REMAP_SLEEP(RES_VAUX2, DEV_GRP_NULL, 0, 0), 728 TWL_REMAP_SLEEP(RES_VAUX2, TWL4030_RESCONFIG_UNDEF, 0, 0),
729 TWL_REMAP_SLEEP(RES_VAUX3, DEV_GRP_NULL, 0, 0), 729 TWL_REMAP_SLEEP(RES_VAUX3, TWL4030_RESCONFIG_UNDEF, 0, 0),
730 TWL_REMAP_SLEEP(RES_VAUX4, DEV_GRP_NULL, 0, 0), 730 TWL_REMAP_SLEEP(RES_VAUX4, TWL4030_RESCONFIG_UNDEF, 0, 0),
731 TWL_REMAP_SLEEP(RES_VMMC1, DEV_GRP_NULL, 0, 0), 731 TWL_REMAP_SLEEP(RES_VMMC1, TWL4030_RESCONFIG_UNDEF, 0, 0),
732 TWL_REMAP_SLEEP(RES_VMMC2, DEV_GRP_NULL, 0, 0), 732 TWL_REMAP_SLEEP(RES_VMMC2, TWL4030_RESCONFIG_UNDEF, 0, 0),
733 TWL_REMAP_OFF(RES_VPLL1, DEV_GRP_P1, 3, 1), 733 TWL_REMAP_OFF(RES_VPLL1, DEV_GRP_P1, 3, 1),
734 TWL_REMAP_SLEEP(RES_VPLL2, DEV_GRP_P1, 0, 0), 734 TWL_REMAP_SLEEP(RES_VPLL2, DEV_GRP_P1, 0, 0),
735 TWL_REMAP_SLEEP(RES_VSIM, DEV_GRP_NULL, 0, 0), 735 TWL_REMAP_SLEEP(RES_VSIM, TWL4030_RESCONFIG_UNDEF, 0, 0),
736 TWL_REMAP_SLEEP(RES_VDAC, DEV_GRP_NULL, 0, 0), 736 TWL_REMAP_SLEEP(RES_VDAC, TWL4030_RESCONFIG_UNDEF, 0, 0),
737 TWL_REMAP_SLEEP(RES_VINTANA1, TWL_DEV_GRP_P123, 1, 2), 737 TWL_REMAP_SLEEP(RES_VINTANA1, TWL_DEV_GRP_P123, 1, 2),
738 TWL_REMAP_SLEEP(RES_VINTANA2, TWL_DEV_GRP_P123, 0, 2), 738 TWL_REMAP_SLEEP(RES_VINTANA2, TWL_DEV_GRP_P123, 0, 2),
739 TWL_REMAP_SLEEP(RES_VINTDIG, TWL_DEV_GRP_P123, 1, 2), 739 TWL_REMAP_SLEEP(RES_VINTDIG, TWL_DEV_GRP_P123, 1, 2),
740 TWL_REMAP_SLEEP(RES_VIO, TWL_DEV_GRP_P123, 2, 2), 740 TWL_REMAP_SLEEP(RES_VIO, TWL_DEV_GRP_P123, 2, 2),
741 TWL_REMAP_OFF(RES_VDD1, DEV_GRP_P1, 4, 1), 741 TWL_REMAP_OFF(RES_VDD1, DEV_GRP_P1, 4, 1),
742 TWL_REMAP_OFF(RES_VDD2, DEV_GRP_P1, 3, 1), 742 TWL_REMAP_OFF(RES_VDD2, DEV_GRP_P1, 3, 1),
743 TWL_REMAP_SLEEP(RES_VUSB_1V5, DEV_GRP_NULL, 0, 0), 743 TWL_REMAP_SLEEP(RES_VUSB_1V5, TWL4030_RESCONFIG_UNDEF, 0, 0),
744 TWL_REMAP_SLEEP(RES_VUSB_1V8, DEV_GRP_NULL, 0, 0), 744 TWL_REMAP_SLEEP(RES_VUSB_1V8, TWL4030_RESCONFIG_UNDEF, 0, 0),
745 TWL_REMAP_SLEEP(RES_VUSB_3V1, TWL_DEV_GRP_P123, 0, 0), 745 TWL_REMAP_SLEEP(RES_VUSB_3V1, TWL_DEV_GRP_P123, 0, 0),
746 /* Resource #20 USB charge pump skipped */ 746 /* Resource #20 USB charge pump skipped */
747 TWL_REMAP_SLEEP(RES_REGEN, TWL_DEV_GRP_P123, 2, 1), 747 TWL_REMAP_SLEEP(RES_REGEN, TWL_DEV_GRP_P123, 2, 1),
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index 324e1de93687..2da05c0e113d 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -601,6 +601,7 @@ int mei_cl_connect(struct mei_cl *cl, struct file *file)
601 cl->timer_count = MEI_CONNECT_TIMEOUT; 601 cl->timer_count = MEI_CONNECT_TIMEOUT;
602 list_add_tail(&cb->list, &dev->ctrl_rd_list.list); 602 list_add_tail(&cb->list, &dev->ctrl_rd_list.list);
603 } else { 603 } else {
604 cl->state = MEI_FILE_INITIALIZING;
604 list_add_tail(&cb->list, &dev->ctrl_wr_list.list); 605 list_add_tail(&cb->list, &dev->ctrl_wr_list.list);
605 } 606 }
606 607
diff --git a/drivers/misc/mei/nfc.c b/drivers/misc/mei/nfc.c
index 3095fc514a65..5ccc23bc7690 100644
--- a/drivers/misc/mei/nfc.c
+++ b/drivers/misc/mei/nfc.c
@@ -342,9 +342,10 @@ static int mei_nfc_send(struct mei_cl_device *cldev, u8 *buf, size_t length)
342 ndev = (struct mei_nfc_dev *) cldev->priv_data; 342 ndev = (struct mei_nfc_dev *) cldev->priv_data;
343 dev = ndev->cl->dev; 343 dev = ndev->cl->dev;
344 344
345 err = -ENOMEM;
345 mei_buf = kzalloc(length + MEI_NFC_HEADER_SIZE, GFP_KERNEL); 346 mei_buf = kzalloc(length + MEI_NFC_HEADER_SIZE, GFP_KERNEL);
346 if (!mei_buf) 347 if (!mei_buf)
347 return -ENOMEM; 348 goto out;
348 349
349 hdr = (struct mei_nfc_hci_hdr *) mei_buf; 350 hdr = (struct mei_nfc_hci_hdr *) mei_buf;
350 hdr->cmd = MEI_NFC_CMD_HCI_SEND; 351 hdr->cmd = MEI_NFC_CMD_HCI_SEND;
@@ -354,12 +355,9 @@ static int mei_nfc_send(struct mei_cl_device *cldev, u8 *buf, size_t length)
354 hdr->data_size = length; 355 hdr->data_size = length;
355 356
356 memcpy(mei_buf + MEI_NFC_HEADER_SIZE, buf, length); 357 memcpy(mei_buf + MEI_NFC_HEADER_SIZE, buf, length);
357
358 err = __mei_cl_send(ndev->cl, mei_buf, length + MEI_NFC_HEADER_SIZE); 358 err = __mei_cl_send(ndev->cl, mei_buf, length + MEI_NFC_HEADER_SIZE);
359 if (err < 0) 359 if (err < 0)
360 return err; 360 goto out;
361
362 kfree(mei_buf);
363 361
364 if (!wait_event_interruptible_timeout(ndev->send_wq, 362 if (!wait_event_interruptible_timeout(ndev->send_wq,
365 ndev->recv_req_id == ndev->req_id, HZ)) { 363 ndev->recv_req_id == ndev->req_id, HZ)) {
@@ -368,7 +366,8 @@ static int mei_nfc_send(struct mei_cl_device *cldev, u8 *buf, size_t length)
368 } else { 366 } else {
369 ndev->req_id++; 367 ndev->req_id++;
370 } 368 }
371 369out:
370 kfree(mei_buf);
372 return err; 371 return err;
373} 372}
374 373
diff --git a/drivers/pinctrl/nomadik/pinctrl-abx500.c b/drivers/pinctrl/nomadik/pinctrl-abx500.c
index a53a689a2bfa..8c6fd8d4dd3c 100644
--- a/drivers/pinctrl/nomadik/pinctrl-abx500.c
+++ b/drivers/pinctrl/nomadik/pinctrl-abx500.c
@@ -620,8 +620,7 @@ static void abx500_gpio_dbg_show_one(struct seq_file *s,
620 } else 620 } else
621 seq_printf(s, " %-9s", chip->get(chip, offset) ? "hi" : "lo"); 621 seq_printf(s, " %-9s", chip->get(chip, offset) ? "hi" : "lo");
622 622
623 if (pctldev) 623 mode = abx500_get_mode(pctldev, chip, offset);
624 mode = abx500_get_mode(pctldev, chip, offset);
625 624
626 seq_printf(s, " %s", (mode < 0) ? "unknown" : modes[mode]); 625 seq_printf(s, " %s", (mode < 0) ? "unknown" : modes[mode]);
627 626
diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index af1ba4fc150d..60464a2648aa 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -497,10 +497,10 @@ static struct at91_pinctrl_mux_ops at91sam9x5_ops = {
497static void at91_pin_dbg(const struct device *dev, const struct at91_pmx_pin *pin) 497static void at91_pin_dbg(const struct device *dev, const struct at91_pmx_pin *pin)
498{ 498{
499 if (pin->mux) { 499 if (pin->mux) {
500 dev_dbg(dev, "pio%c%d configured as periph%c with conf = 0x%lu\n", 500 dev_dbg(dev, "pio%c%d configured as periph%c with conf = 0x%lx\n",
501 pin->bank + 'A', pin->pin, pin->mux - 1 + 'A', pin->conf); 501 pin->bank + 'A', pin->pin, pin->mux - 1 + 'A', pin->conf);
502 } else { 502 } else {
503 dev_dbg(dev, "pio%c%d configured as gpio with conf = 0x%lu\n", 503 dev_dbg(dev, "pio%c%d configured as gpio with conf = 0x%lx\n",
504 pin->bank + 'A', pin->pin, pin->conf); 504 pin->bank + 'A', pin->pin, pin->conf);
505 } 505 }
506} 506}
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index 5e8b2e04cd7a..0c372a300cb8 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -438,7 +438,7 @@ static int rockchip_set_mux(struct rockchip_pin_bank *bank, int pin, int mux)
438 int reg, ret, mask; 438 int reg, ret, mask;
439 unsigned long flags; 439 unsigned long flags;
440 u8 bit; 440 u8 bit;
441 u32 data; 441 u32 data, rmask;
442 442
443 if (iomux_num > 3) 443 if (iomux_num > 3)
444 return -EINVAL; 444 return -EINVAL;
@@ -478,8 +478,9 @@ static int rockchip_set_mux(struct rockchip_pin_bank *bank, int pin, int mux)
478 spin_lock_irqsave(&bank->slock, flags); 478 spin_lock_irqsave(&bank->slock, flags);
479 479
480 data = (mask << (bit + 16)); 480 data = (mask << (bit + 16));
481 rmask = data | (data >> 16);
481 data |= (mux & mask) << bit; 482 data |= (mux & mask) << bit;
482 ret = regmap_write(regmap, reg, data); 483 ret = regmap_update_bits(regmap, reg, rmask, data);
483 484
484 spin_unlock_irqrestore(&bank->slock, flags); 485 spin_unlock_irqrestore(&bank->slock, flags);
485 486
@@ -634,7 +635,7 @@ static int rk3288_set_drive(struct rockchip_pin_bank *bank, int pin_num,
634 struct regmap *regmap; 635 struct regmap *regmap;
635 unsigned long flags; 636 unsigned long flags;
636 int reg, ret, i; 637 int reg, ret, i;
637 u32 data; 638 u32 data, rmask;
638 u8 bit; 639 u8 bit;
639 640
640 rk3288_calc_drv_reg_and_bit(bank, pin_num, &regmap, &reg, &bit); 641 rk3288_calc_drv_reg_and_bit(bank, pin_num, &regmap, &reg, &bit);
@@ -657,9 +658,10 @@ static int rk3288_set_drive(struct rockchip_pin_bank *bank, int pin_num,
657 658
658 /* enable the write to the equivalent lower bits */ 659 /* enable the write to the equivalent lower bits */
659 data = ((1 << RK3288_DRV_BITS_PER_PIN) - 1) << (bit + 16); 660 data = ((1 << RK3288_DRV_BITS_PER_PIN) - 1) << (bit + 16);
661 rmask = data | (data >> 16);
660 data |= (ret << bit); 662 data |= (ret << bit);
661 663
662 ret = regmap_write(regmap, reg, data); 664 ret = regmap_update_bits(regmap, reg, rmask, data);
663 spin_unlock_irqrestore(&bank->slock, flags); 665 spin_unlock_irqrestore(&bank->slock, flags);
664 666
665 return ret; 667 return ret;
@@ -722,7 +724,7 @@ static int rockchip_set_pull(struct rockchip_pin_bank *bank,
722 int reg, ret; 724 int reg, ret;
723 unsigned long flags; 725 unsigned long flags;
724 u8 bit; 726 u8 bit;
725 u32 data; 727 u32 data, rmask;
726 728
727 dev_dbg(info->dev, "setting pull of GPIO%d-%d to %d\n", 729 dev_dbg(info->dev, "setting pull of GPIO%d-%d to %d\n",
728 bank->bank_num, pin_num, pull); 730 bank->bank_num, pin_num, pull);
@@ -750,6 +752,7 @@ static int rockchip_set_pull(struct rockchip_pin_bank *bank,
750 752
751 /* enable the write to the equivalent lower bits */ 753 /* enable the write to the equivalent lower bits */
752 data = ((1 << RK3188_PULL_BITS_PER_PIN) - 1) << (bit + 16); 754 data = ((1 << RK3188_PULL_BITS_PER_PIN) - 1) << (bit + 16);
755 rmask = data | (data >> 16);
753 756
754 switch (pull) { 757 switch (pull) {
755 case PIN_CONFIG_BIAS_DISABLE: 758 case PIN_CONFIG_BIAS_DISABLE:
@@ -770,7 +773,7 @@ static int rockchip_set_pull(struct rockchip_pin_bank *bank,
770 return -EINVAL; 773 return -EINVAL;
771 } 774 }
772 775
773 ret = regmap_write(regmap, reg, data); 776 ret = regmap_update_bits(regmap, reg, rmask, data);
774 777
775 spin_unlock_irqrestore(&bank->slock, flags); 778 spin_unlock_irqrestore(&bank->slock, flags);
776 break; 779 break;
diff --git a/drivers/pinctrl/pinctrl-tegra-xusb.c b/drivers/pinctrl/pinctrl-tegra-xusb.c
index a06620474845..e641b4226c42 100644
--- a/drivers/pinctrl/pinctrl-tegra-xusb.c
+++ b/drivers/pinctrl/pinctrl-tegra-xusb.c
@@ -680,7 +680,7 @@ static struct phy *tegra_xusb_padctl_xlate(struct device *dev,
680 if (args->args_count <= 0) 680 if (args->args_count <= 0)
681 return ERR_PTR(-EINVAL); 681 return ERR_PTR(-EINVAL);
682 682
683 if (index > ARRAY_SIZE(padctl->phys)) 683 if (index >= ARRAY_SIZE(padctl->phys))
684 return ERR_PTR(-EINVAL); 684 return ERR_PTR(-EINVAL);
685 685
686 return padctl->phys[index]; 686 return padctl->phys[index];
@@ -930,7 +930,8 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev)
930 930
931 padctl->provider = devm_of_phy_provider_register(&pdev->dev, 931 padctl->provider = devm_of_phy_provider_register(&pdev->dev,
932 tegra_xusb_padctl_xlate); 932 tegra_xusb_padctl_xlate);
933 if (err < 0) { 933 if (IS_ERR(padctl->provider)) {
934 err = PTR_ERR(padctl->provider);
934 dev_err(&pdev->dev, "failed to register PHYs: %d\n", err); 935 dev_err(&pdev->dev, "failed to register PHYs: %d\n", err);
935 goto unregister; 936 goto unregister;
936 } 937 }
diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c b/drivers/pinctrl/samsung/pinctrl-exynos.c
index 003bfd874a61..d7154ed0b0eb 100644
--- a/drivers/pinctrl/samsung/pinctrl-exynos.c
+++ b/drivers/pinctrl/samsung/pinctrl-exynos.c
@@ -127,14 +127,10 @@ static int exynos_irq_set_type(struct irq_data *irqd, unsigned int type)
127 struct irq_chip *chip = irq_data_get_irq_chip(irqd); 127 struct irq_chip *chip = irq_data_get_irq_chip(irqd);
128 struct exynos_irq_chip *our_chip = to_exynos_irq_chip(chip); 128 struct exynos_irq_chip *our_chip = to_exynos_irq_chip(chip);
129 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd); 129 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd);
130 struct samsung_pin_bank_type *bank_type = bank->type;
131 struct samsung_pinctrl_drv_data *d = bank->drvdata; 130 struct samsung_pinctrl_drv_data *d = bank->drvdata;
132 unsigned int pin = irqd->hwirq; 131 unsigned int shift = EXYNOS_EINT_CON_LEN * irqd->hwirq;
133 unsigned int shift = EXYNOS_EINT_CON_LEN * pin;
134 unsigned int con, trig_type; 132 unsigned int con, trig_type;
135 unsigned long reg_con = our_chip->eint_con + bank->eint_offset; 133 unsigned long reg_con = our_chip->eint_con + bank->eint_offset;
136 unsigned long flags;
137 unsigned int mask;
138 134
139 switch (type) { 135 switch (type) {
140 case IRQ_TYPE_EDGE_RISING: 136 case IRQ_TYPE_EDGE_RISING:
@@ -167,8 +163,32 @@ static int exynos_irq_set_type(struct irq_data *irqd, unsigned int type)
167 con |= trig_type << shift; 163 con |= trig_type << shift;
168 writel(con, d->virt_base + reg_con); 164 writel(con, d->virt_base + reg_con);
169 165
166 return 0;
167}
168
169static int exynos_irq_request_resources(struct irq_data *irqd)
170{
171 struct irq_chip *chip = irq_data_get_irq_chip(irqd);
172 struct exynos_irq_chip *our_chip = to_exynos_irq_chip(chip);
173 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd);
174 struct samsung_pin_bank_type *bank_type = bank->type;
175 struct samsung_pinctrl_drv_data *d = bank->drvdata;
176 unsigned int shift = EXYNOS_EINT_CON_LEN * irqd->hwirq;
177 unsigned long reg_con = our_chip->eint_con + bank->eint_offset;
178 unsigned long flags;
179 unsigned int mask;
180 unsigned int con;
181 int ret;
182
183 ret = gpio_lock_as_irq(&bank->gpio_chip, irqd->hwirq);
184 if (ret) {
185 dev_err(bank->gpio_chip.dev, "unable to lock pin %s-%lu IRQ\n",
186 bank->name, irqd->hwirq);
187 return ret;
188 }
189
170 reg_con = bank->pctl_offset + bank_type->reg_offset[PINCFG_TYPE_FUNC]; 190 reg_con = bank->pctl_offset + bank_type->reg_offset[PINCFG_TYPE_FUNC];
171 shift = pin * bank_type->fld_width[PINCFG_TYPE_FUNC]; 191 shift = irqd->hwirq * bank_type->fld_width[PINCFG_TYPE_FUNC];
172 mask = (1 << bank_type->fld_width[PINCFG_TYPE_FUNC]) - 1; 192 mask = (1 << bank_type->fld_width[PINCFG_TYPE_FUNC]) - 1;
173 193
174 spin_lock_irqsave(&bank->slock, flags); 194 spin_lock_irqsave(&bank->slock, flags);
@@ -180,9 +200,42 @@ static int exynos_irq_set_type(struct irq_data *irqd, unsigned int type)
180 200
181 spin_unlock_irqrestore(&bank->slock, flags); 201 spin_unlock_irqrestore(&bank->slock, flags);
182 202
203 exynos_irq_unmask(irqd);
204
183 return 0; 205 return 0;
184} 206}
185 207
208static void exynos_irq_release_resources(struct irq_data *irqd)
209{
210 struct irq_chip *chip = irq_data_get_irq_chip(irqd);
211 struct exynos_irq_chip *our_chip = to_exynos_irq_chip(chip);
212 struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd);
213 struct samsung_pin_bank_type *bank_type = bank->type;
214 struct samsung_pinctrl_drv_data *d = bank->drvdata;
215 unsigned int shift = EXYNOS_EINT_CON_LEN * irqd->hwirq;
216 unsigned long reg_con = our_chip->eint_con + bank->eint_offset;
217 unsigned long flags;
218 unsigned int mask;
219 unsigned int con;
220
221 reg_con = bank->pctl_offset + bank_type->reg_offset[PINCFG_TYPE_FUNC];
222 shift = irqd->hwirq * bank_type->fld_width[PINCFG_TYPE_FUNC];
223 mask = (1 << bank_type->fld_width[PINCFG_TYPE_FUNC]) - 1;
224
225 exynos_irq_mask(irqd);
226
227 spin_lock_irqsave(&bank->slock, flags);
228
229 con = readl(d->virt_base + reg_con);
230 con &= ~(mask << shift);
231 con |= FUNC_INPUT << shift;
232 writel(con, d->virt_base + reg_con);
233
234 spin_unlock_irqrestore(&bank->slock, flags);
235
236 gpio_unlock_as_irq(&bank->gpio_chip, irqd->hwirq);
237}
238
186/* 239/*
187 * irq_chip for gpio interrupts. 240 * irq_chip for gpio interrupts.
188 */ 241 */
@@ -193,6 +246,8 @@ static struct exynos_irq_chip exynos_gpio_irq_chip = {
193 .irq_mask = exynos_irq_mask, 246 .irq_mask = exynos_irq_mask,
194 .irq_ack = exynos_irq_ack, 247 .irq_ack = exynos_irq_ack,
195 .irq_set_type = exynos_irq_set_type, 248 .irq_set_type = exynos_irq_set_type,
249 .irq_request_resources = exynos_irq_request_resources,
250 .irq_release_resources = exynos_irq_release_resources,
196 }, 251 },
197 .eint_con = EXYNOS_GPIO_ECON_OFFSET, 252 .eint_con = EXYNOS_GPIO_ECON_OFFSET,
198 .eint_mask = EXYNOS_GPIO_EMASK_OFFSET, 253 .eint_mask = EXYNOS_GPIO_EMASK_OFFSET,
@@ -336,6 +391,8 @@ static struct exynos_irq_chip exynos_wkup_irq_chip = {
336 .irq_ack = exynos_irq_ack, 391 .irq_ack = exynos_irq_ack,
337 .irq_set_type = exynos_irq_set_type, 392 .irq_set_type = exynos_irq_set_type,
338 .irq_set_wake = exynos_wkup_irq_set_wake, 393 .irq_set_wake = exynos_wkup_irq_set_wake,
394 .irq_request_resources = exynos_irq_request_resources,
395 .irq_release_resources = exynos_irq_release_resources,
339 }, 396 },
340 .eint_con = EXYNOS_WKUP_ECON_OFFSET, 397 .eint_con = EXYNOS_WKUP_ECON_OFFSET,
341 .eint_mask = EXYNOS_WKUP_EMASK_OFFSET, 398 .eint_mask = EXYNOS_WKUP_EMASK_OFFSET,
diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.h b/drivers/pinctrl/samsung/pinctrl-samsung.h
index 2b882320e8e9..5cedc9d26390 100644
--- a/drivers/pinctrl/samsung/pinctrl-samsung.h
+++ b/drivers/pinctrl/samsung/pinctrl-samsung.h
@@ -26,6 +26,7 @@
26#include <linux/gpio.h> 26#include <linux/gpio.h>
27 27
28/* pinmux function number for pin as gpio output line */ 28/* pinmux function number for pin as gpio output line */
29#define FUNC_INPUT 0x0
29#define FUNC_OUTPUT 0x1 30#define FUNC_OUTPUT 0x1
30 31
31/** 32/**
diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7791.c b/drivers/pinctrl/sh-pfc/pfc-r8a7791.c
index 576d41b459e9..c6e5deba238e 100644
--- a/drivers/pinctrl/sh-pfc/pfc-r8a7791.c
+++ b/drivers/pinctrl/sh-pfc/pfc-r8a7791.c
@@ -4509,24 +4509,24 @@ static const char * const audio_clk_groups[] = {
4509}; 4509};
4510 4510
4511static const char * const can0_groups[] = { 4511static const char * const can0_groups[] = {
4512 "can0_data_a", 4512 "can0_data",
4513 "can0_data_b", 4513 "can0_data_b",
4514 "can0_data_c", 4514 "can0_data_c",
4515 "can0_data_d", 4515 "can0_data_d",
4516 "can0_data_e", 4516 "can0_data_e",
4517 "can0_data_f", 4517 "can0_data_f",
4518 "can_clk_a", 4518 "can_clk",
4519 "can_clk_b", 4519 "can_clk_b",
4520 "can_clk_c", 4520 "can_clk_c",
4521 "can_clk_d", 4521 "can_clk_d",
4522}; 4522};
4523 4523
4524static const char * const can1_groups[] = { 4524static const char * const can1_groups[] = {
4525 "can1_data_a", 4525 "can1_data",
4526 "can1_data_b", 4526 "can1_data_b",
4527 "can1_data_c", 4527 "can1_data_c",
4528 "can1_data_d", 4528 "can1_data_d",
4529 "can_clk_a", 4529 "can_clk",
4530 "can_clk_b", 4530 "can_clk_b",
4531 "can_clk_c", 4531 "can_clk_c",
4532 "can_clk_d", 4532 "can_clk_d",
diff --git a/drivers/rtc/rtc-s5m.c b/drivers/rtc/rtc-s5m.c
index 8f06250a0389..8754c33361e8 100644
--- a/drivers/rtc/rtc-s5m.c
+++ b/drivers/rtc/rtc-s5m.c
@@ -717,12 +717,14 @@ static int s5m_rtc_probe(struct platform_device *pdev)
717 info->device_type = s5m87xx->device_type; 717 info->device_type = s5m87xx->device_type;
718 info->wtsr_smpl = s5m87xx->wtsr_smpl; 718 info->wtsr_smpl = s5m87xx->wtsr_smpl;
719 719
720 info->irq = regmap_irq_get_virq(s5m87xx->irq_data, alarm_irq); 720 if (s5m87xx->irq_data) {
721 if (info->irq <= 0) { 721 info->irq = regmap_irq_get_virq(s5m87xx->irq_data, alarm_irq);
722 ret = -EINVAL; 722 if (info->irq <= 0) {
723 dev_err(&pdev->dev, "Failed to get virtual IRQ %d\n", 723 ret = -EINVAL;
724 dev_err(&pdev->dev, "Failed to get virtual IRQ %d\n",
724 alarm_irq); 725 alarm_irq);
725 goto err; 726 goto err;
727 }
726 } 728 }
727 729
728 platform_set_drvdata(pdev, info); 730 platform_set_drvdata(pdev, info);
@@ -744,6 +746,11 @@ static int s5m_rtc_probe(struct platform_device *pdev)
744 goto err; 746 goto err;
745 } 747 }
746 748
749 if (!info->irq) {
750 dev_info(&pdev->dev, "Alarm IRQ not available\n");
751 return 0;
752 }
753
747 ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL, 754 ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL,
748 s5m_rtc_alarm_irq, 0, "rtc-alarm0", 755 s5m_rtc_alarm_irq, 0, "rtc-alarm0",
749 info); 756 info);
@@ -802,7 +809,7 @@ static int s5m_rtc_resume(struct device *dev)
802 struct s5m_rtc_info *info = dev_get_drvdata(dev); 809 struct s5m_rtc_info *info = dev_get_drvdata(dev);
803 int ret = 0; 810 int ret = 0;
804 811
805 if (device_may_wakeup(dev)) 812 if (info->irq && device_may_wakeup(dev))
806 ret = disable_irq_wake(info->irq); 813 ret = disable_irq_wake(info->irq);
807 814
808 return ret; 815 return ret;
@@ -813,7 +820,7 @@ static int s5m_rtc_suspend(struct device *dev)
813 struct s5m_rtc_info *info = dev_get_drvdata(dev); 820 struct s5m_rtc_info *info = dev_get_drvdata(dev);
814 int ret = 0; 821 int ret = 0;
815 822
816 if (device_may_wakeup(dev)) 823 if (info->irq && device_may_wakeup(dev))
817 ret = enable_irq_wake(info->irq); 824 ret = enable_irq_wake(info->irq);
818 825
819 return ret; 826 return ret;
diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
index a6d47e5eee9e..c43aca69fb30 100644
--- a/drivers/s390/char/con3215.c
+++ b/drivers/s390/char/con3215.c
@@ -1035,12 +1035,26 @@ static int tty3215_write(struct tty_struct * tty,
1035 const unsigned char *buf, int count) 1035 const unsigned char *buf, int count)
1036{ 1036{
1037 struct raw3215_info *raw; 1037 struct raw3215_info *raw;
1038 int i, written;
1038 1039
1039 if (!tty) 1040 if (!tty)
1040 return 0; 1041 return 0;
1041 raw = (struct raw3215_info *) tty->driver_data; 1042 raw = (struct raw3215_info *) tty->driver_data;
1042 raw3215_write(raw, buf, count); 1043 written = count;
1043 return count; 1044 while (count > 0) {
1045 for (i = 0; i < count; i++)
1046 if (buf[i] == '\t' || buf[i] == '\n')
1047 break;
1048 raw3215_write(raw, buf, i);
1049 count -= i;
1050 buf += i;
1051 if (count > 0) {
1052 raw3215_putchar(raw, *buf);
1053 count--;
1054 buf++;
1055 }
1056 }
1057 return written;
1044} 1058}
1045 1059
1046/* 1060/*
@@ -1188,7 +1202,7 @@ static int __init tty3215_init(void)
1188 driver->subtype = SYSTEM_TYPE_TTY; 1202 driver->subtype = SYSTEM_TYPE_TTY;
1189 driver->init_termios = tty_std_termios; 1203 driver->init_termios = tty_std_termios;
1190 driver->init_termios.c_iflag = IGNBRK | IGNPAR; 1204 driver->init_termios.c_iflag = IGNBRK | IGNPAR;
1191 driver->init_termios.c_oflag = ONLCR | XTABS; 1205 driver->init_termios.c_oflag = ONLCR;
1192 driver->init_termios.c_lflag = ISIG; 1206 driver->init_termios.c_lflag = ISIG;
1193 driver->flags = TTY_DRIVER_REAL_RAW; 1207 driver->flags = TTY_DRIVER_REAL_RAW;
1194 tty_set_operations(driver, &tty3215_ops); 1208 tty_set_operations(driver, &tty3215_ops);
diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c
index 7ed7a5987816..003663288e29 100644
--- a/drivers/s390/char/sclp_tty.c
+++ b/drivers/s390/char/sclp_tty.c
@@ -559,7 +559,7 @@ sclp_tty_init(void)
559 driver->subtype = SYSTEM_TYPE_TTY; 559 driver->subtype = SYSTEM_TYPE_TTY;
560 driver->init_termios = tty_std_termios; 560 driver->init_termios = tty_std_termios;
561 driver->init_termios.c_iflag = IGNBRK | IGNPAR; 561 driver->init_termios.c_iflag = IGNBRK | IGNPAR;
562 driver->init_termios.c_oflag = ONLCR | XTABS; 562 driver->init_termios.c_oflag = ONLCR;
563 driver->init_termios.c_lflag = ISIG | ECHO; 563 driver->init_termios.c_lflag = ISIG | ECHO;
564 driver->flags = TTY_DRIVER_REAL_RAW; 564 driver->flags = TTY_DRIVER_REAL_RAW;
565 tty_set_operations(driver, &sclp_ops); 565 tty_set_operations(driver, &sclp_ops);
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index ce62e8798cc8..d837dc180522 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1808,7 +1808,6 @@ static int scsi_mq_prep_fn(struct request *req)
1808 1808
1809 cmd->tag = req->tag; 1809 cmd->tag = req->tag;
1810 1810
1811 req->cmd = req->__cmd;
1812 cmd->cmnd = req->cmd; 1811 cmd->cmnd = req->cmd;
1813 cmd->prot_op = SCSI_PROT_NORMAL; 1812 cmd->prot_op = SCSI_PROT_NORMAL;
1814 1813
diff --git a/drivers/spi/spi-au1550.c b/drivers/spi/spi-au1550.c
index 40c3d43c9292..f40b34cdf2fc 100644
--- a/drivers/spi/spi-au1550.c
+++ b/drivers/spi/spi-au1550.c
@@ -945,7 +945,7 @@ static int au1550_spi_remove(struct platform_device *pdev)
945 spi_bitbang_stop(&hw->bitbang); 945 spi_bitbang_stop(&hw->bitbang);
946 free_irq(hw->irq, hw); 946 free_irq(hw->irq, hw);
947 iounmap((void __iomem *)hw->regs); 947 iounmap((void __iomem *)hw->regs);
948 release_mem_region(r->start, sizeof(psc_spi_t)); 948 release_mem_region(hw->ioarea->start, sizeof(psc_spi_t));
949 949
950 if (hw->usedma) { 950 if (hw->usedma) {
951 au1550_spi_dma_rxtmp_free(hw); 951 au1550_spi_dma_rxtmp_free(hw);
diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c
index 276a3884fb3c..48f1d26e6ad9 100644
--- a/drivers/spi/spi-davinci.c
+++ b/drivers/spi/spi-davinci.c
@@ -417,16 +417,16 @@ static int davinci_spi_setup(struct spi_device *spi)
417 flags, dev_name(&spi->dev)); 417 flags, dev_name(&spi->dev));
418 internal_cs = false; 418 internal_cs = false;
419 } 419 }
420 }
421 420
422 if (retval) { 421 if (retval) {
423 dev_err(&spi->dev, "GPIO %d setup failed (%d)\n", 422 dev_err(&spi->dev, "GPIO %d setup failed (%d)\n",
424 spi->cs_gpio, retval); 423 spi->cs_gpio, retval);
425 return retval; 424 return retval;
426 } 425 }
427 426
428 if (internal_cs) 427 if (internal_cs)
429 set_io_bits(dspi->base + SPIPC0, 1 << spi->chip_select); 428 set_io_bits(dspi->base + SPIPC0, 1 << spi->chip_select);
429 }
430 430
431 if (spi->mode & SPI_READY) 431 if (spi->mode & SPI_READY)
432 set_io_bits(dspi->base + SPIPC0, SPIPC0_SPIENA_MASK); 432 set_io_bits(dspi->base + SPIPC0, SPIPC0_SPIENA_MASK);
diff --git a/drivers/spi/spi-dw-pci.c b/drivers/spi/spi-dw-pci.c
index 3f3dc1226edf..e14960470d8d 100644
--- a/drivers/spi/spi-dw-pci.c
+++ b/drivers/spi/spi-dw-pci.c
@@ -62,6 +62,8 @@ static int spi_pci_probe(struct pci_dev *pdev,
62 if (ret) 62 if (ret)
63 return ret; 63 return ret;
64 64
65 dws->regs = pcim_iomap_table(pdev)[pci_bar];
66
65 dws->bus_num = 0; 67 dws->bus_num = 0;
66 dws->num_cs = 4; 68 dws->num_cs = 4;
67 dws->irq = pdev->irq; 69 dws->irq = pdev->irq;
diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index 29f33143b795..670f0627f3bf 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -271,7 +271,7 @@ static void giveback(struct dw_spi *dws)
271 transfer_list); 271 transfer_list);
272 272
273 if (!last_transfer->cs_change) 273 if (!last_transfer->cs_change)
274 spi_chip_sel(dws, dws->cur_msg->spi, 0); 274 spi_chip_sel(dws, msg->spi, 0);
275 275
276 spi_finalize_current_message(dws->master); 276 spi_finalize_current_message(dws->master);
277} 277}
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 68441fa448de..352eed7463ac 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -329,7 +329,8 @@ static void omap2_mcspi_set_fifo(const struct spi_device *spi,
329disable_fifo: 329disable_fifo:
330 if (t->rx_buf != NULL) 330 if (t->rx_buf != NULL)
331 chconf &= ~OMAP2_MCSPI_CHCONF_FFER; 331 chconf &= ~OMAP2_MCSPI_CHCONF_FFER;
332 else 332
333 if (t->tx_buf != NULL)
333 chconf &= ~OMAP2_MCSPI_CHCONF_FFET; 334 chconf &= ~OMAP2_MCSPI_CHCONF_FFET;
334 335
335 mcspi_write_chconf0(spi, chconf); 336 mcspi_write_chconf0(spi, chconf);
diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
index fe792106bdc5..46f45ca2c694 100644
--- a/drivers/spi/spi-pxa2xx.c
+++ b/drivers/spi/spi-pxa2xx.c
@@ -1074,6 +1074,7 @@ static struct acpi_device_id pxa2xx_spi_acpi_match[] = {
1074 { "INT3430", 0 }, 1074 { "INT3430", 0 },
1075 { "INT3431", 0 }, 1075 { "INT3431", 0 },
1076 { "80860F0E", 0 }, 1076 { "80860F0E", 0 },
1077 { "8086228E", 0 },
1077 { }, 1078 { },
1078}; 1079};
1079MODULE_DEVICE_TABLE(acpi, pxa2xx_spi_acpi_match); 1080MODULE_DEVICE_TABLE(acpi, pxa2xx_spi_acpi_match);
diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
index c0743604b906..cd0e08b0c9f6 100644
--- a/drivers/spi/spi-rockchip.c
+++ b/drivers/spi/spi-rockchip.c
@@ -499,7 +499,7 @@ static void rockchip_spi_config(struct rockchip_spi *rs)
499 } 499 }
500 500
501 /* div doesn't support odd number */ 501 /* div doesn't support odd number */
502 div = rs->max_freq / rs->speed; 502 div = max_t(u32, rs->max_freq / rs->speed, 1);
503 div = (div + 1) & 0xfffe; 503 div = (div + 1) & 0xfffe;
504 504
505 spi_enable_chip(rs, 0); 505 spi_enable_chip(rs, 0);
@@ -678,7 +678,7 @@ static int rockchip_spi_probe(struct platform_device *pdev)
678 rs->dma_tx.addr = (dma_addr_t)(mem->start + ROCKCHIP_SPI_TXDR); 678 rs->dma_tx.addr = (dma_addr_t)(mem->start + ROCKCHIP_SPI_TXDR);
679 rs->dma_rx.addr = (dma_addr_t)(mem->start + ROCKCHIP_SPI_RXDR); 679 rs->dma_rx.addr = (dma_addr_t)(mem->start + ROCKCHIP_SPI_RXDR);
680 rs->dma_tx.direction = DMA_MEM_TO_DEV; 680 rs->dma_tx.direction = DMA_MEM_TO_DEV;
681 rs->dma_tx.direction = DMA_DEV_TO_MEM; 681 rs->dma_rx.direction = DMA_DEV_TO_MEM;
682 682
683 master->can_dma = rockchip_spi_can_dma; 683 master->can_dma = rockchip_spi_can_dma;
684 master->dma_tx = rs->dma_tx.ch; 684 master->dma_tx = rs->dma_tx.ch;
diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index c850dfdfa9e3..ad87a98f8f68 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -472,25 +472,52 @@ static int rspi_dma_transfer(struct rspi_data *rspi, struct sg_table *tx,
472 dma_cookie_t cookie; 472 dma_cookie_t cookie;
473 int ret; 473 int ret;
474 474
475 if (tx) { 475 /* First prepare and submit the DMA request(s), as this may fail */
476 desc_tx = dmaengine_prep_slave_sg(rspi->master->dma_tx,
477 tx->sgl, tx->nents, DMA_TO_DEVICE,
478 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
479 if (!desc_tx)
480 goto no_dma;
481
482 irq_mask |= SPCR_SPTIE;
483 }
484 if (rx) { 476 if (rx) {
485 desc_rx = dmaengine_prep_slave_sg(rspi->master->dma_rx, 477 desc_rx = dmaengine_prep_slave_sg(rspi->master->dma_rx,
486 rx->sgl, rx->nents, DMA_FROM_DEVICE, 478 rx->sgl, rx->nents, DMA_FROM_DEVICE,
487 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 479 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
488 if (!desc_rx) 480 if (!desc_rx) {
489 goto no_dma; 481 ret = -EAGAIN;
482 goto no_dma_rx;
483 }
484
485 desc_rx->callback = rspi_dma_complete;
486 desc_rx->callback_param = rspi;
487 cookie = dmaengine_submit(desc_rx);
488 if (dma_submit_error(cookie)) {
489 ret = cookie;
490 goto no_dma_rx;
491 }
490 492
491 irq_mask |= SPCR_SPRIE; 493 irq_mask |= SPCR_SPRIE;
492 } 494 }
493 495
496 if (tx) {
497 desc_tx = dmaengine_prep_slave_sg(rspi->master->dma_tx,
498 tx->sgl, tx->nents, DMA_TO_DEVICE,
499 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
500 if (!desc_tx) {
501 ret = -EAGAIN;
502 goto no_dma_tx;
503 }
504
505 if (rx) {
506 /* No callback */
507 desc_tx->callback = NULL;
508 } else {
509 desc_tx->callback = rspi_dma_complete;
510 desc_tx->callback_param = rspi;
511 }
512 cookie = dmaengine_submit(desc_tx);
513 if (dma_submit_error(cookie)) {
514 ret = cookie;
515 goto no_dma_tx;
516 }
517
518 irq_mask |= SPCR_SPTIE;
519 }
520
494 /* 521 /*
495 * DMAC needs SPxIE, but if SPxIE is set, the IRQ routine will be 522 * DMAC needs SPxIE, but if SPxIE is set, the IRQ routine will be
496 * called. So, this driver disables the IRQ while DMA transfer. 523 * called. So, this driver disables the IRQ while DMA transfer.
@@ -503,34 +530,24 @@ static int rspi_dma_transfer(struct rspi_data *rspi, struct sg_table *tx,
503 rspi_enable_irq(rspi, irq_mask); 530 rspi_enable_irq(rspi, irq_mask);
504 rspi->dma_callbacked = 0; 531 rspi->dma_callbacked = 0;
505 532
506 if (rx) { 533 /* Now start DMA */
507 desc_rx->callback = rspi_dma_complete; 534 if (rx)
508 desc_rx->callback_param = rspi;
509 cookie = dmaengine_submit(desc_rx);
510 if (dma_submit_error(cookie))
511 return cookie;
512 dma_async_issue_pending(rspi->master->dma_rx); 535 dma_async_issue_pending(rspi->master->dma_rx);
513 } 536 if (tx)
514 if (tx) {
515 if (rx) {
516 /* No callback */
517 desc_tx->callback = NULL;
518 } else {
519 desc_tx->callback = rspi_dma_complete;
520 desc_tx->callback_param = rspi;
521 }
522 cookie = dmaengine_submit(desc_tx);
523 if (dma_submit_error(cookie))
524 return cookie;
525 dma_async_issue_pending(rspi->master->dma_tx); 537 dma_async_issue_pending(rspi->master->dma_tx);
526 }
527 538
528 ret = wait_event_interruptible_timeout(rspi->wait, 539 ret = wait_event_interruptible_timeout(rspi->wait,
529 rspi->dma_callbacked, HZ); 540 rspi->dma_callbacked, HZ);
530 if (ret > 0 && rspi->dma_callbacked) 541 if (ret > 0 && rspi->dma_callbacked)
531 ret = 0; 542 ret = 0;
532 else if (!ret) 543 else if (!ret) {
544 dev_err(&rspi->master->dev, "DMA timeout\n");
533 ret = -ETIMEDOUT; 545 ret = -ETIMEDOUT;
546 if (tx)
547 dmaengine_terminate_all(rspi->master->dma_tx);
548 if (rx)
549 dmaengine_terminate_all(rspi->master->dma_rx);
550 }
534 551
535 rspi_disable_irq(rspi, irq_mask); 552 rspi_disable_irq(rspi, irq_mask);
536 553
@@ -541,11 +558,16 @@ static int rspi_dma_transfer(struct rspi_data *rspi, struct sg_table *tx,
541 558
542 return ret; 559 return ret;
543 560
544no_dma: 561no_dma_tx:
545 pr_warn_once("%s %s: DMA not available, falling back to PIO\n", 562 if (rx)
546 dev_driver_string(&rspi->master->dev), 563 dmaengine_terminate_all(rspi->master->dma_rx);
547 dev_name(&rspi->master->dev)); 564no_dma_rx:
548 return -EAGAIN; 565 if (ret == -EAGAIN) {
566 pr_warn_once("%s %s: DMA not available, falling back to PIO\n",
567 dev_driver_string(&rspi->master->dev),
568 dev_name(&rspi->master->dev));
569 }
570 return ret;
549} 571}
550 572
551static void rspi_receive_init(const struct rspi_data *rspi) 573static void rspi_receive_init(const struct rspi_data *rspi)
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 2a4354dcd661..543075b80f16 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -636,48 +636,38 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv *p, const void *tx,
636 dma_cookie_t cookie; 636 dma_cookie_t cookie;
637 int ret; 637 int ret;
638 638
639 if (tx) { 639 /* First prepare and submit the DMA request(s), as this may fail */
640 ier_bits |= IER_TDREQE | IER_TDMAE;
641 dma_sync_single_for_device(p->master->dma_tx->device->dev,
642 p->tx_dma_addr, len, DMA_TO_DEVICE);
643 desc_tx = dmaengine_prep_slave_single(p->master->dma_tx,
644 p->tx_dma_addr, len, DMA_TO_DEVICE,
645 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
646 if (!desc_tx)
647 return -EAGAIN;
648 }
649
650 if (rx) { 640 if (rx) {
651 ier_bits |= IER_RDREQE | IER_RDMAE; 641 ier_bits |= IER_RDREQE | IER_RDMAE;
652 desc_rx = dmaengine_prep_slave_single(p->master->dma_rx, 642 desc_rx = dmaengine_prep_slave_single(p->master->dma_rx,
653 p->rx_dma_addr, len, DMA_FROM_DEVICE, 643 p->rx_dma_addr, len, DMA_FROM_DEVICE,
654 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 644 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
655 if (!desc_rx) 645 if (!desc_rx) {
656 return -EAGAIN; 646 ret = -EAGAIN;
657 } 647 goto no_dma_rx;
658 648 }
659 /* 1 stage FIFO watermarks for DMA */
660 sh_msiof_write(p, FCTR, FCTR_TFWM_1 | FCTR_RFWM_1);
661
662 /* setup msiof transfer mode registers (32-bit words) */
663 sh_msiof_spi_set_mode_regs(p, tx, rx, 32, len / 4);
664
665 sh_msiof_write(p, IER, ier_bits);
666
667 reinit_completion(&p->done);
668 649
669 if (rx) {
670 desc_rx->callback = sh_msiof_dma_complete; 650 desc_rx->callback = sh_msiof_dma_complete;
671 desc_rx->callback_param = p; 651 desc_rx->callback_param = p;
672 cookie = dmaengine_submit(desc_rx); 652 cookie = dmaengine_submit(desc_rx);
673 if (dma_submit_error(cookie)) { 653 if (dma_submit_error(cookie)) {
674 ret = cookie; 654 ret = cookie;
675 goto stop_ier; 655 goto no_dma_rx;
676 } 656 }
677 dma_async_issue_pending(p->master->dma_rx);
678 } 657 }
679 658
680 if (tx) { 659 if (tx) {
660 ier_bits |= IER_TDREQE | IER_TDMAE;
661 dma_sync_single_for_device(p->master->dma_tx->device->dev,
662 p->tx_dma_addr, len, DMA_TO_DEVICE);
663 desc_tx = dmaengine_prep_slave_single(p->master->dma_tx,
664 p->tx_dma_addr, len, DMA_TO_DEVICE,
665 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
666 if (!desc_tx) {
667 ret = -EAGAIN;
668 goto no_dma_tx;
669 }
670
681 if (rx) { 671 if (rx) {
682 /* No callback */ 672 /* No callback */
683 desc_tx->callback = NULL; 673 desc_tx->callback = NULL;
@@ -688,15 +678,30 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv *p, const void *tx,
688 cookie = dmaengine_submit(desc_tx); 678 cookie = dmaengine_submit(desc_tx);
689 if (dma_submit_error(cookie)) { 679 if (dma_submit_error(cookie)) {
690 ret = cookie; 680 ret = cookie;
691 goto stop_rx; 681 goto no_dma_tx;
692 } 682 }
693 dma_async_issue_pending(p->master->dma_tx);
694 } 683 }
695 684
685 /* 1 stage FIFO watermarks for DMA */
686 sh_msiof_write(p, FCTR, FCTR_TFWM_1 | FCTR_RFWM_1);
687
688 /* setup msiof transfer mode registers (32-bit words) */
689 sh_msiof_spi_set_mode_regs(p, tx, rx, 32, len / 4);
690
691 sh_msiof_write(p, IER, ier_bits);
692
693 reinit_completion(&p->done);
694
695 /* Now start DMA */
696 if (rx)
697 dma_async_issue_pending(p->master->dma_rx);
698 if (tx)
699 dma_async_issue_pending(p->master->dma_tx);
700
696 ret = sh_msiof_spi_start(p, rx); 701 ret = sh_msiof_spi_start(p, rx);
697 if (ret) { 702 if (ret) {
698 dev_err(&p->pdev->dev, "failed to start hardware\n"); 703 dev_err(&p->pdev->dev, "failed to start hardware\n");
699 goto stop_tx; 704 goto stop_dma;
700 } 705 }
701 706
702 /* wait for tx fifo to be emptied / rx fifo to be filled */ 707 /* wait for tx fifo to be emptied / rx fifo to be filled */
@@ -726,14 +731,14 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv *p, const void *tx,
726stop_reset: 731stop_reset:
727 sh_msiof_reset_str(p); 732 sh_msiof_reset_str(p);
728 sh_msiof_spi_stop(p, rx); 733 sh_msiof_spi_stop(p, rx);
729stop_tx: 734stop_dma:
730 if (tx) 735 if (tx)
731 dmaengine_terminate_all(p->master->dma_tx); 736 dmaengine_terminate_all(p->master->dma_tx);
732stop_rx: 737no_dma_tx:
733 if (rx) 738 if (rx)
734 dmaengine_terminate_all(p->master->dma_rx); 739 dmaengine_terminate_all(p->master->dma_rx);
735stop_ier:
736 sh_msiof_write(p, IER, 0); 740 sh_msiof_write(p, IER, 0);
741no_dma_rx:
737 return ret; 742 return ret;
738} 743}
739 744
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index e0531baf2782..ca935df80c88 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -848,6 +848,7 @@ out:
848 848
849/** 849/**
850 * spi_finalize_current_transfer - report completion of a transfer 850 * spi_finalize_current_transfer - report completion of a transfer
851 * @master: the master reporting completion
851 * 852 *
852 * Called by SPI drivers using the core transfer_one_message() 853 * Called by SPI drivers using the core transfer_one_message()
853 * implementation to notify it that the current interrupt driven 854 * implementation to notify it that the current interrupt driven
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index 2c486ea6236b..35b494f5667f 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -28,8 +28,6 @@ source "drivers/staging/et131x/Kconfig"
28 28
29source "drivers/staging/slicoss/Kconfig" 29source "drivers/staging/slicoss/Kconfig"
30 30
31source "drivers/staging/usbip/Kconfig"
32
33source "drivers/staging/wlan-ng/Kconfig" 31source "drivers/staging/wlan-ng/Kconfig"
34 32
35source "drivers/staging/comedi/Kconfig" 33source "drivers/staging/comedi/Kconfig"
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index 1e1a3a10faf7..e66a5dbd9b02 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -6,7 +6,6 @@ obj-$(CONFIG_STAGING) += staging.o
6obj-y += media/ 6obj-y += media/
7obj-$(CONFIG_ET131X) += et131x/ 7obj-$(CONFIG_ET131X) += et131x/
8obj-$(CONFIG_SLICOSS) += slicoss/ 8obj-$(CONFIG_SLICOSS) += slicoss/
9obj-$(CONFIG_USBIP_CORE) += usbip/
10obj-$(CONFIG_PRISM2_USB) += wlan-ng/ 9obj-$(CONFIG_PRISM2_USB) += wlan-ng/
11obj-$(CONFIG_COMEDI) += comedi/ 10obj-$(CONFIG_COMEDI) += comedi/
12obj-$(CONFIG_FB_OLPC_DCON) += olpc_dcon/ 11obj-$(CONFIG_FB_OLPC_DCON) += olpc_dcon/
diff --git a/drivers/staging/android/logger.c b/drivers/staging/android/logger.c
index 9b47e66599a3..0bf0d24d12d5 100644
--- a/drivers/staging/android/logger.c
+++ b/drivers/staging/android/logger.c
@@ -790,7 +790,7 @@ static int __init create_log(char *log_name, int size)
790 if (unlikely(ret)) { 790 if (unlikely(ret)) {
791 pr_err("failed to register misc device for log '%s'!\n", 791 pr_err("failed to register misc device for log '%s'!\n",
792 log->misc.name); 792 log->misc.name);
793 goto out_free_log; 793 goto out_free_misc_name;
794 } 794 }
795 795
796 pr_info("created %luK log '%s'\n", 796 pr_info("created %luK log '%s'\n",
@@ -798,6 +798,9 @@ static int __init create_log(char *log_name, int size)
798 798
799 return 0; 799 return 0;
800 800
801out_free_misc_name:
802 kfree(log->misc.name);
803
801out_free_log: 804out_free_log:
802 kfree(log); 805 kfree(log);
803 806
diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c
index 8bf1eb485163..831b7c6fe494 100644
--- a/drivers/staging/et131x/et131x.c
+++ b/drivers/staging/et131x/et131x.c
@@ -1421,22 +1421,16 @@ static int et131x_mii_read(struct et131x_adapter *adapter, u8 reg, u16 *value)
1421 * @reg: the register to read 1421 * @reg: the register to read
1422 * @value: 16-bit value to write 1422 * @value: 16-bit value to write
1423 */ 1423 */
1424static int et131x_mii_write(struct et131x_adapter *adapter, u8 reg, u16 value) 1424static int et131x_mii_write(struct et131x_adapter *adapter, u8 addr, u8 reg,
1425 u16 value)
1425{ 1426{
1426 struct mac_regs __iomem *mac = &adapter->regs->mac; 1427 struct mac_regs __iomem *mac = &adapter->regs->mac;
1427 struct phy_device *phydev = adapter->phydev;
1428 int status = 0; 1428 int status = 0;
1429 u8 addr;
1430 u32 delay = 0; 1429 u32 delay = 0;
1431 u32 mii_addr; 1430 u32 mii_addr;
1432 u32 mii_cmd; 1431 u32 mii_cmd;
1433 u32 mii_indicator; 1432 u32 mii_indicator;
1434 1433
1435 if (!phydev)
1436 return -EIO;
1437
1438 addr = phydev->addr;
1439
1440 /* Save a local copy of the registers we are dealing with so we can 1434 /* Save a local copy of the registers we are dealing with so we can
1441 * set them back 1435 * set them back
1442 */ 1436 */
@@ -1631,17 +1625,7 @@ static int et131x_mdio_write(struct mii_bus *bus, int phy_addr,
1631 struct net_device *netdev = bus->priv; 1625 struct net_device *netdev = bus->priv;
1632 struct et131x_adapter *adapter = netdev_priv(netdev); 1626 struct et131x_adapter *adapter = netdev_priv(netdev);
1633 1627
1634 return et131x_mii_write(adapter, reg, value); 1628 return et131x_mii_write(adapter, phy_addr, reg, value);
1635}
1636
1637static int et131x_mdio_reset(struct mii_bus *bus)
1638{
1639 struct net_device *netdev = bus->priv;
1640 struct et131x_adapter *adapter = netdev_priv(netdev);
1641
1642 et131x_mii_write(adapter, MII_BMCR, BMCR_RESET);
1643
1644 return 0;
1645} 1629}
1646 1630
1647/* et1310_phy_power_switch - PHY power control 1631/* et1310_phy_power_switch - PHY power control
@@ -1656,18 +1640,20 @@ static int et131x_mdio_reset(struct mii_bus *bus)
1656static void et1310_phy_power_switch(struct et131x_adapter *adapter, bool down) 1640static void et1310_phy_power_switch(struct et131x_adapter *adapter, bool down)
1657{ 1641{
1658 u16 data; 1642 u16 data;
1643 struct phy_device *phydev = adapter->phydev;
1659 1644
1660 et131x_mii_read(adapter, MII_BMCR, &data); 1645 et131x_mii_read(adapter, MII_BMCR, &data);
1661 data &= ~BMCR_PDOWN; 1646 data &= ~BMCR_PDOWN;
1662 if (down) 1647 if (down)
1663 data |= BMCR_PDOWN; 1648 data |= BMCR_PDOWN;
1664 et131x_mii_write(adapter, MII_BMCR, data); 1649 et131x_mii_write(adapter, phydev->addr, MII_BMCR, data);
1665} 1650}
1666 1651
1667/* et131x_xcvr_init - Init the phy if we are setting it into force mode */ 1652/* et131x_xcvr_init - Init the phy if we are setting it into force mode */
1668static void et131x_xcvr_init(struct et131x_adapter *adapter) 1653static void et131x_xcvr_init(struct et131x_adapter *adapter)
1669{ 1654{
1670 u16 lcr2; 1655 u16 lcr2;
1656 struct phy_device *phydev = adapter->phydev;
1671 1657
1672 /* Set the LED behavior such that LED 1 indicates speed (off = 1658 /* Set the LED behavior such that LED 1 indicates speed (off =
1673 * 10Mbits, blink = 100Mbits, on = 1000Mbits) and LED 2 indicates 1659 * 10Mbits, blink = 100Mbits, on = 1000Mbits) and LED 2 indicates
@@ -1688,7 +1674,7 @@ static void et131x_xcvr_init(struct et131x_adapter *adapter)
1688 else 1674 else
1689 lcr2 |= (LED_VAL_LINKON << LED_TXRX_SHIFT); 1675 lcr2 |= (LED_VAL_LINKON << LED_TXRX_SHIFT);
1690 1676
1691 et131x_mii_write(adapter, PHY_LED_2, lcr2); 1677 et131x_mii_write(adapter, phydev->addr, PHY_LED_2, lcr2);
1692 } 1678 }
1693} 1679}
1694 1680
@@ -3643,14 +3629,14 @@ static void et131x_adjust_link(struct net_device *netdev)
3643 3629
3644 et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, 3630 et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG,
3645 &register18); 3631 &register18);
3646 et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, 3632 et131x_mii_write(adapter, phydev->addr,
3647 register18 | 0x4); 3633 PHY_MPHY_CONTROL_REG, register18 | 0x4);
3648 et131x_mii_write(adapter, PHY_INDEX_REG, 3634 et131x_mii_write(adapter, phydev->addr, PHY_INDEX_REG,
3649 register18 | 0x8402); 3635 register18 | 0x8402);
3650 et131x_mii_write(adapter, PHY_DATA_REG, 3636 et131x_mii_write(adapter, phydev->addr, PHY_DATA_REG,
3651 register18 | 511); 3637 register18 | 511);
3652 et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, 3638 et131x_mii_write(adapter, phydev->addr,
3653 register18); 3639 PHY_MPHY_CONTROL_REG, register18);
3654 } 3640 }
3655 3641
3656 et1310_config_flow_control(adapter); 3642 et1310_config_flow_control(adapter);
@@ -3662,7 +3648,8 @@ static void et131x_adjust_link(struct net_device *netdev)
3662 et131x_mii_read(adapter, PHY_CONFIG, &reg); 3648 et131x_mii_read(adapter, PHY_CONFIG, &reg);
3663 reg &= ~ET_PHY_CONFIG_TX_FIFO_DEPTH; 3649 reg &= ~ET_PHY_CONFIG_TX_FIFO_DEPTH;
3664 reg |= ET_PHY_CONFIG_FIFO_DEPTH_32; 3650 reg |= ET_PHY_CONFIG_FIFO_DEPTH_32;
3665 et131x_mii_write(adapter, PHY_CONFIG, reg); 3651 et131x_mii_write(adapter, phydev->addr, PHY_CONFIG,
3652 reg);
3666 } 3653 }
3667 3654
3668 et131x_set_rx_dma_timer(adapter); 3655 et131x_set_rx_dma_timer(adapter);
@@ -3675,14 +3662,14 @@ static void et131x_adjust_link(struct net_device *netdev)
3675 3662
3676 et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, 3663 et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG,
3677 &register18); 3664 &register18);
3678 et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, 3665 et131x_mii_write(adapter, phydev->addr,
3679 register18 | 0x4); 3666 PHY_MPHY_CONTROL_REG, register18 | 0x4);
3680 et131x_mii_write(adapter, PHY_INDEX_REG, 3667 et131x_mii_write(adapter, phydev->addr,
3681 register18 | 0x8402); 3668 PHY_INDEX_REG, register18 | 0x8402);
3682 et131x_mii_write(adapter, PHY_DATA_REG, 3669 et131x_mii_write(adapter, phydev->addr,
3683 register18 | 511); 3670 PHY_DATA_REG, register18 | 511);
3684 et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, 3671 et131x_mii_write(adapter, phydev->addr,
3685 register18); 3672 PHY_MPHY_CONTROL_REG, register18);
3686 } 3673 }
3687 3674
3688 /* Free the packets being actively sent & stopped */ 3675 /* Free the packets being actively sent & stopped */
@@ -4644,10 +4631,6 @@ static int et131x_pci_setup(struct pci_dev *pdev,
4644 /* Copy address into the net_device struct */ 4631 /* Copy address into the net_device struct */
4645 memcpy(netdev->dev_addr, adapter->addr, ETH_ALEN); 4632 memcpy(netdev->dev_addr, adapter->addr, ETH_ALEN);
4646 4633
4647 /* Init variable for counting how long we do not have link status */
4648 adapter->boot_coma = 0;
4649 et1310_disable_phy_coma(adapter);
4650
4651 rc = -ENOMEM; 4634 rc = -ENOMEM;
4652 4635
4653 /* Setup the mii_bus struct */ 4636 /* Setup the mii_bus struct */
@@ -4663,7 +4646,6 @@ static int et131x_pci_setup(struct pci_dev *pdev,
4663 adapter->mii_bus->priv = netdev; 4646 adapter->mii_bus->priv = netdev;
4664 adapter->mii_bus->read = et131x_mdio_read; 4647 adapter->mii_bus->read = et131x_mdio_read;
4665 adapter->mii_bus->write = et131x_mdio_write; 4648 adapter->mii_bus->write = et131x_mdio_write;
4666 adapter->mii_bus->reset = et131x_mdio_reset;
4667 adapter->mii_bus->irq = kmalloc_array(PHY_MAX_ADDR, sizeof(int), 4649 adapter->mii_bus->irq = kmalloc_array(PHY_MAX_ADDR, sizeof(int),
4668 GFP_KERNEL); 4650 GFP_KERNEL);
4669 if (!adapter->mii_bus->irq) 4651 if (!adapter->mii_bus->irq)
@@ -4687,6 +4669,10 @@ static int et131x_pci_setup(struct pci_dev *pdev,
4687 /* Setup et1310 as per the documentation */ 4669 /* Setup et1310 as per the documentation */
4688 et131x_adapter_setup(adapter); 4670 et131x_adapter_setup(adapter);
4689 4671
4672 /* Init variable for counting how long we do not have link status */
4673 adapter->boot_coma = 0;
4674 et1310_disable_phy_coma(adapter);
4675
4690 /* We can enable interrupts now 4676 /* We can enable interrupts now
4691 * 4677 *
4692 * NOTE - Because registration of interrupt handler is done in the 4678 * NOTE - Because registration of interrupt handler is done in the
diff --git a/drivers/staging/lustre/lustre/libcfs/workitem.c b/drivers/staging/lustre/lustre/libcfs/workitem.c
index 65629579bd7d..03ab9e046784 100644
--- a/drivers/staging/lustre/lustre/libcfs/workitem.c
+++ b/drivers/staging/lustre/lustre/libcfs/workitem.c
@@ -365,6 +365,7 @@ cfs_wi_sched_create(char *name, struct cfs_cpt_table *cptab,
365 return -ENOMEM; 365 return -ENOMEM;
366 366
367 strncpy(sched->ws_name, name, CFS_WS_NAME_LEN); 367 strncpy(sched->ws_name, name, CFS_WS_NAME_LEN);
368 sched->ws_name[CFS_WS_NAME_LEN - 1] = '\0';
368 sched->ws_cptab = cptab; 369 sched->ws_cptab = cptab;
369 sched->ws_cpt = cpt; 370 sched->ws_cpt = cpt;
370 371
diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c
index 8b19f3caa68f..701c6a776524 100644
--- a/drivers/staging/lustre/lustre/obdclass/class_obd.c
+++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c
@@ -35,7 +35,7 @@
35 */ 35 */
36 36
37#define DEBUG_SUBSYSTEM S_CLASS 37#define DEBUG_SUBSYSTEM S_CLASS
38# include <asm/atomic.h> 38# include <linux/atomic.h>
39 39
40#include "../include/obd_support.h" 40#include "../include/obd_support.h"
41#include "../include/obd_class.h" 41#include "../include/obd_class.h"
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
index b8676ac77b0c..407a318b09db 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
@@ -43,9 +43,11 @@ static struct usb_device_id rtw_usb_id_tbl[] = {
43 {USB_DEVICE(USB_VENDER_ID_REALTEK, 0x0179)}, /* 8188ETV */ 43 {USB_DEVICE(USB_VENDER_ID_REALTEK, 0x0179)}, /* 8188ETV */
44 /*=== Customer ID ===*/ 44 /*=== Customer ID ===*/
45 /****** 8188EUS ********/ 45 /****** 8188EUS ********/
46 {USB_DEVICE(0x056e, 0x4008)}, /* Elecom WDC-150SU2M */
46 {USB_DEVICE(0x07b8, 0x8179)}, /* Abocom - Abocom */ 47 {USB_DEVICE(0x07b8, 0x8179)}, /* Abocom - Abocom */
47 {USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */ 48 {USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */
48 {USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */ 49 {USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */
50 {USB_DEVICE(0x0df6, 0x0076)}, /* Sitecom N150 v2 */
49 {} /* Terminating entry */ 51 {} /* Terminating entry */
50}; 52};
51 53
diff --git a/drivers/thunderbolt/path.c b/drivers/thunderbolt/path.c
index 8fcf8a7b6c22..9562cd026dc0 100644
--- a/drivers/thunderbolt/path.c
+++ b/drivers/thunderbolt/path.c
@@ -150,7 +150,26 @@ int tb_path_activate(struct tb_path *path)
150 150
151 /* Activate hops. */ 151 /* Activate hops. */
152 for (i = path->path_length - 1; i >= 0; i--) { 152 for (i = path->path_length - 1; i >= 0; i--) {
153 struct tb_regs_hop hop; 153 struct tb_regs_hop hop = { 0 };
154
155 /*
156 * We do (currently) not tear down paths setup by the firmeware.
157 * If a firmware device is unplugged and plugged in again then
158 * it can happen that we reuse some of the hops from the (now
159 * defunct) firmeware path. This causes the hotplug operation to
160 * fail (the pci device does not show up). Clearing the hop
161 * before overwriting it fixes the problem.
162 *
163 * Should be removed once we discover and tear down firmeware
164 * paths.
165 */
166 res = tb_port_write(path->hops[i].in_port, &hop, TB_CFG_HOPS,
167 2 * path->hops[i].in_hop_index, 2);
168 if (res) {
169 __tb_path_deactivate_hops(path, i);
170 __tb_path_deallocate_nfc(path, 0);
171 goto err;
172 }
154 173
155 /* dword 0 */ 174 /* dword 0 */
156 hop.next_hop = path->hops[i].next_hop_index; 175 hop.next_hop = path->hops[i].next_hop_index;
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index e0cad4418085..cf1b19bca306 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -92,6 +92,8 @@ source "drivers/usb/storage/Kconfig"
92 92
93source "drivers/usb/image/Kconfig" 93source "drivers/usb/image/Kconfig"
94 94
95source "drivers/usb/usbip/Kconfig"
96
95endif 97endif
96 98
97source "drivers/usb/musb/Kconfig" 99source "drivers/usb/musb/Kconfig"
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index 3cba892b83a2..d7be71778059 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -60,3 +60,5 @@ obj-$(CONFIG_USB_RENESAS_USBHS) += renesas_usbhs/
60obj-$(CONFIG_USB_GADGET) += gadget/ 60obj-$(CONFIG_USB_GADGET) += gadget/
61 61
62obj-$(CONFIG_USB_COMMON) += common/ 62obj-$(CONFIG_USB_COMMON) += common/
63
64obj-$(CONFIG_USBIP_CORE) += usbip/
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 8a4dcbc7a75f..46f5161c7891 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1728,8 +1728,14 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
1728 * - Change autosuspend delay of hub can avoid unnecessary auto 1728 * - Change autosuspend delay of hub can avoid unnecessary auto
1729 * suspend timer for hub, also may decrease power consumption 1729 * suspend timer for hub, also may decrease power consumption
1730 * of USB bus. 1730 * of USB bus.
1731 *
1732 * - If user has indicated to prevent autosuspend by passing
1733 * usbcore.autosuspend = -1 then keep autosuspend disabled.
1731 */ 1734 */
1732 pm_runtime_set_autosuspend_delay(&hdev->dev, 0); 1735#ifdef CONFIG_PM_RUNTIME
1736 if (hdev->dev.power.autosuspend_delay >= 0)
1737 pm_runtime_set_autosuspend_delay(&hdev->dev, 0);
1738#endif
1733 1739
1734 /* 1740 /*
1735 * Hubs have proper suspend/resume support, except for root hubs 1741 * Hubs have proper suspend/resume support, except for root hubs
@@ -2107,8 +2113,8 @@ void usb_disconnect(struct usb_device **pdev)
2107{ 2113{
2108 struct usb_port *port_dev = NULL; 2114 struct usb_port *port_dev = NULL;
2109 struct usb_device *udev = *pdev; 2115 struct usb_device *udev = *pdev;
2110 struct usb_hub *hub; 2116 struct usb_hub *hub = NULL;
2111 int port1; 2117 int port1 = 1;
2112 2118
2113 /* mark the device as inactive, so any further urb submissions for 2119 /* mark the device as inactive, so any further urb submissions for
2114 * this device (and any of its children) will fail immediately. 2120 * this device (and any of its children) will fail immediately.
@@ -4631,9 +4637,7 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
4631 if (status != -ENODEV && 4637 if (status != -ENODEV &&
4632 port1 != unreliable_port && 4638 port1 != unreliable_port &&
4633 printk_ratelimit()) 4639 printk_ratelimit())
4634 dev_err(&udev->dev, "connect-debounce failed, port %d disabled\n", 4640 dev_err(&port_dev->dev, "connect-debounce failed\n");
4635 port1);
4636
4637 portstatus &= ~USB_PORT_STAT_CONNECTION; 4641 portstatus &= ~USB_PORT_STAT_CONNECTION;
4638 unreliable_port = port1; 4642 unreliable_port = port1;
4639 } else { 4643 } else {
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 0ba9c335b584..7c9618e916e2 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -1901,7 +1901,7 @@ static void s3c_hsotg_epint(struct s3c_hsotg *hsotg, unsigned int idx,
1901static void s3c_hsotg_irq_enumdone(struct s3c_hsotg *hsotg) 1901static void s3c_hsotg_irq_enumdone(struct s3c_hsotg *hsotg)
1902{ 1902{
1903 u32 dsts = readl(hsotg->regs + DSTS); 1903 u32 dsts = readl(hsotg->regs + DSTS);
1904 int ep0_mps = 0, ep_mps; 1904 int ep0_mps = 0, ep_mps = 8;
1905 1905
1906 /* 1906 /*
1907 * This should signal the finish of the enumeration phase 1907 * This should signal the finish of the enumeration phase
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index ef4936ff626c..9dcfbe7cd5f5 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -425,7 +425,7 @@ static void dwc3_omap_set_utmi_mode(struct dwc3_omap *omap)
425 425
426static int dwc3_omap_extcon_register(struct dwc3_omap *omap) 426static int dwc3_omap_extcon_register(struct dwc3_omap *omap)
427{ 427{
428 u32 ret; 428 int ret;
429 struct device_node *node = omap->dev->of_node; 429 struct device_node *node = omap->dev->of_node;
430 struct extcon_dev *edev; 430 struct extcon_dev *edev;
431 431
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index a186afeaa700..9add915d41f7 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -3,7 +3,7 @@
3# 3#
4subdir-ccflags-$(CONFIG_USB_GADGET_DEBUG) := -DDEBUG 4subdir-ccflags-$(CONFIG_USB_GADGET_DEBUG) := -DDEBUG
5subdir-ccflags-$(CONFIG_USB_GADGET_VERBOSE) += -DVERBOSE_DEBUG 5subdir-ccflags-$(CONFIG_USB_GADGET_VERBOSE) += -DVERBOSE_DEBUG
6ccflags-y += -I$(PWD)/drivers/usb/gadget/udc 6ccflags-y += -Idrivers/usb/gadget/udc
7 7
8obj-$(CONFIG_USB_LIBCOMPOSITE) += libcomposite.o 8obj-$(CONFIG_USB_LIBCOMPOSITE) += libcomposite.o
9libcomposite-y := usbstring.o config.o epautoconf.o 9libcomposite-y := usbstring.o config.o epautoconf.o
diff --git a/drivers/usb/gadget/function/Makefile b/drivers/usb/gadget/function/Makefile
index 6d91f21b52a6..83ae1065149d 100644
--- a/drivers/usb/gadget/function/Makefile
+++ b/drivers/usb/gadget/function/Makefile
@@ -2,8 +2,8 @@
2# USB peripheral controller drivers 2# USB peripheral controller drivers
3# 3#
4 4
5ccflags-y := -I$(PWD)/drivers/usb/gadget/ 5ccflags-y := -Idrivers/usb/gadget/
6ccflags-y += -I$(PWD)/drivers/usb/gadget/udc/ 6ccflags-y += -Idrivers/usb/gadget/udc/
7 7
8# USB Functions 8# USB Functions
9usb_f_acm-y := f_acm.o 9usb_f_acm-y := f_acm.o
diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
index d50adda913cf..6e6f87656e7b 100644
--- a/drivers/usb/gadget/function/u_ether.c
+++ b/drivers/usb/gadget/function/u_ether.c
@@ -1127,10 +1127,7 @@ void gether_disconnect(struct gether *link)
1127 1127
1128 DBG(dev, "%s\n", __func__); 1128 DBG(dev, "%s\n", __func__);
1129 1129
1130 netif_tx_lock(dev->net);
1131 netif_stop_queue(dev->net); 1130 netif_stop_queue(dev->net);
1132 netif_tx_unlock(dev->net);
1133
1134 netif_carrier_off(dev->net); 1131 netif_carrier_off(dev->net);
1135 1132
1136 /* disable endpoints, forcing (synchronous) completion 1133 /* disable endpoints, forcing (synchronous) completion
diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c
index 71e896d4c5ae..a5eb9a3fbb7a 100644
--- a/drivers/usb/gadget/function/uvc_video.c
+++ b/drivers/usb/gadget/function/uvc_video.c
@@ -195,6 +195,7 @@ uvc_video_complete(struct usb_ep *ep, struct usb_request *req)
195 printk(KERN_INFO "Failed to queue request (%d).\n", ret); 195 printk(KERN_INFO "Failed to queue request (%d).\n", ret);
196 usb_ep_set_halt(ep); 196 usb_ep_set_halt(ep);
197 spin_unlock_irqrestore(&video->queue.irqlock, flags); 197 spin_unlock_irqrestore(&video->queue.irqlock, flags);
198 uvc_queue_cancel(queue, 0);
198 goto requeue; 199 goto requeue;
199 } 200 }
200 spin_unlock_irqrestore(&video->queue.irqlock, flags); 201 spin_unlock_irqrestore(&video->queue.irqlock, flags);
@@ -281,6 +282,7 @@ error:
281static int 282static int
282uvc_video_pump(struct uvc_video *video) 283uvc_video_pump(struct uvc_video *video)
283{ 284{
285 struct uvc_video_queue *queue = &video->queue;
284 struct usb_request *req; 286 struct usb_request *req;
285 struct uvc_buffer *buf; 287 struct uvc_buffer *buf;
286 unsigned long flags; 288 unsigned long flags;
@@ -322,6 +324,7 @@ uvc_video_pump(struct uvc_video *video)
322 printk(KERN_INFO "Failed to queue request (%d)\n", ret); 324 printk(KERN_INFO "Failed to queue request (%d)\n", ret);
323 usb_ep_set_halt(video->ep); 325 usb_ep_set_halt(video->ep);
324 spin_unlock_irqrestore(&video->queue.irqlock, flags); 326 spin_unlock_irqrestore(&video->queue.irqlock, flags);
327 uvc_queue_cancel(queue, 0);
325 break; 328 break;
326 } 329 }
327 spin_unlock_irqrestore(&video->queue.irqlock, flags); 330 spin_unlock_irqrestore(&video->queue.irqlock, flags);
diff --git a/drivers/usb/gadget/legacy/Makefile b/drivers/usb/gadget/legacy/Makefile
index a11aad5635df..edba2d1ee0f3 100644
--- a/drivers/usb/gadget/legacy/Makefile
+++ b/drivers/usb/gadget/legacy/Makefile
@@ -2,9 +2,9 @@
2# USB gadget drivers 2# USB gadget drivers
3# 3#
4 4
5ccflags-y := -I$(PWD)/drivers/usb/gadget/ 5ccflags-y := -Idrivers/usb/gadget/
6ccflags-y += -I$(PWD)/drivers/usb/gadget/udc/ 6ccflags-y += -Idrivers/usb/gadget/udc/
7ccflags-y += -I$(PWD)/drivers/usb/gadget/function/ 7ccflags-y += -Idrivers/usb/gadget/function/
8 8
9g_zero-y := zero.o 9g_zero-y := zero.o
10g_audio-y := audio.o 10g_audio-y := audio.o
diff --git a/drivers/usb/gadget/legacy/dbgp.c b/drivers/usb/gadget/legacy/dbgp.c
index 986fc511a2ed..225e385a6160 100644
--- a/drivers/usb/gadget/legacy/dbgp.c
+++ b/drivers/usb/gadget/legacy/dbgp.c
@@ -222,10 +222,12 @@ static void dbgp_unbind(struct usb_gadget *gadget)
222{ 222{
223#ifdef CONFIG_USB_G_DBGP_SERIAL 223#ifdef CONFIG_USB_G_DBGP_SERIAL
224 kfree(dbgp.serial); 224 kfree(dbgp.serial);
225 dbgp.serial = NULL;
225#endif 226#endif
226 if (dbgp.req) { 227 if (dbgp.req) {
227 kfree(dbgp.req->buf); 228 kfree(dbgp.req->buf);
228 usb_ep_free_request(gadget->ep0, dbgp.req); 229 usb_ep_free_request(gadget->ep0, dbgp.req);
230 dbgp.req = NULL;
229 } 231 }
230 232
231 gadget->ep0->driver_data = NULL; 233 gadget->ep0->driver_data = NULL;
diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
index 2e4ce7704908..e96077b8bf79 100644
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -440,7 +440,7 @@ ep_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
440 440
441 value = -ENOMEM; 441 value = -ENOMEM;
442 kbuf = memdup_user(buf, len); 442 kbuf = memdup_user(buf, len);
443 if (!kbuf) { 443 if (IS_ERR(kbuf)) {
444 value = PTR_ERR(kbuf); 444 value = PTR_ERR(kbuf);
445 goto free1; 445 goto free1;
446 } 446 }
diff --git a/drivers/usb/gadget/udc/Kconfig b/drivers/usb/gadget/udc/Kconfig
index 5151f947a4f5..34ebaa68504c 100644
--- a/drivers/usb/gadget/udc/Kconfig
+++ b/drivers/usb/gadget/udc/Kconfig
@@ -332,7 +332,7 @@ config USB_GOKU
332 gadget drivers to also be dynamically linked. 332 gadget drivers to also be dynamically linked.
333 333
334config USB_EG20T 334config USB_EG20T
335 tristate "Intel EG20T PCH/LAPIS Semiconductor IOH(ML7213/ML7831) UDC" 335 tristate "Intel QUARK X1000/EG20T PCH/LAPIS Semiconductor IOH(ML7213/ML7831) UDC"
336 depends on PCI 336 depends on PCI
337 help 337 help
338 This is a USB device driver for EG20T PCH. 338 This is a USB device driver for EG20T PCH.
@@ -353,6 +353,7 @@ config USB_EG20T
353 ML7213/ML7831 is companion chip for Intel Atom E6xx series. 353 ML7213/ML7831 is companion chip for Intel Atom E6xx series.
354 ML7213/ML7831 is completely compatible for Intel EG20T PCH. 354 ML7213/ML7831 is completely compatible for Intel EG20T PCH.
355 355
356 This driver can be used with Intel's Quark X1000 SOC platform
356# 357#
357# LAST -- dummy/emulated controller 358# LAST -- dummy/emulated controller
358# 359#
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
index 906e65f0e4fa..c9fe67e29d35 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -1661,7 +1661,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
1661 if (dma_status) { 1661 if (dma_status) {
1662 int i; 1662 int i;
1663 1663
1664 for (i = 1; i < USBA_NR_DMAS; i++) 1664 for (i = 1; i <= USBA_NR_DMAS; i++)
1665 if (dma_status & (1 << i)) 1665 if (dma_status & (1 << i))
1666 usba_dma_irq(udc, &udc->usba_ep[i]); 1666 usba_dma_irq(udc, &udc->usba_ep[i]);
1667 } 1667 }
diff --git a/drivers/usb/gadget/udc/fusb300_udc.c b/drivers/usb/gadget/udc/fusb300_udc.c
index d40255f784df..5c5d1adda7eb 100644
--- a/drivers/usb/gadget/udc/fusb300_udc.c
+++ b/drivers/usb/gadget/udc/fusb300_udc.c
@@ -1398,13 +1398,17 @@ static int fusb300_probe(struct platform_device *pdev)
1398 1398
1399 /* initialize udc */ 1399 /* initialize udc */
1400 fusb300 = kzalloc(sizeof(struct fusb300), GFP_KERNEL); 1400 fusb300 = kzalloc(sizeof(struct fusb300), GFP_KERNEL);
1401 if (fusb300 == NULL) 1401 if (fusb300 == NULL) {
1402 ret = -ENOMEM;
1402 goto clean_up; 1403 goto clean_up;
1404 }
1403 1405
1404 for (i = 0; i < FUSB300_MAX_NUM_EP; i++) { 1406 for (i = 0; i < FUSB300_MAX_NUM_EP; i++) {
1405 _ep[i] = kzalloc(sizeof(struct fusb300_ep), GFP_KERNEL); 1407 _ep[i] = kzalloc(sizeof(struct fusb300_ep), GFP_KERNEL);
1406 if (_ep[i] == NULL) 1408 if (_ep[i] == NULL) {
1409 ret = -ENOMEM;
1407 goto clean_up; 1410 goto clean_up;
1411 }
1408 fusb300->ep[i] = _ep[i]; 1412 fusb300->ep[i] = _ep[i];
1409 } 1413 }
1410 1414
diff --git a/drivers/usb/gadget/udc/pch_udc.c b/drivers/usb/gadget/udc/pch_udc.c
index eb8c3bedb57a..460d953c91b6 100644
--- a/drivers/usb/gadget/udc/pch_udc.c
+++ b/drivers/usb/gadget/udc/pch_udc.c
@@ -343,6 +343,7 @@ struct pch_vbus_gpio_data {
343 * @setup_data: Received setup data 343 * @setup_data: Received setup data
344 * @phys_addr: of device memory 344 * @phys_addr: of device memory
345 * @base_addr: for mapped device memory 345 * @base_addr: for mapped device memory
346 * @bar: Indicates which PCI BAR for USB regs
346 * @irq: IRQ line for the device 347 * @irq: IRQ line for the device
347 * @cfg_data: current cfg, intf, and alt in use 348 * @cfg_data: current cfg, intf, and alt in use
348 * @vbus_gpio: GPIO informaton for detecting VBUS 349 * @vbus_gpio: GPIO informaton for detecting VBUS
@@ -370,14 +371,17 @@ struct pch_udc_dev {
370 struct usb_ctrlrequest setup_data; 371 struct usb_ctrlrequest setup_data;
371 unsigned long phys_addr; 372 unsigned long phys_addr;
372 void __iomem *base_addr; 373 void __iomem *base_addr;
374 unsigned bar;
373 unsigned irq; 375 unsigned irq;
374 struct pch_udc_cfg_data cfg_data; 376 struct pch_udc_cfg_data cfg_data;
375 struct pch_vbus_gpio_data vbus_gpio; 377 struct pch_vbus_gpio_data vbus_gpio;
376}; 378};
377#define to_pch_udc(g) (container_of((g), struct pch_udc_dev, gadget)) 379#define to_pch_udc(g) (container_of((g), struct pch_udc_dev, gadget))
378 380
381#define PCH_UDC_PCI_BAR_QUARK_X1000 0
379#define PCH_UDC_PCI_BAR 1 382#define PCH_UDC_PCI_BAR 1
380#define PCI_DEVICE_ID_INTEL_EG20T_UDC 0x8808 383#define PCI_DEVICE_ID_INTEL_EG20T_UDC 0x8808
384#define PCI_DEVICE_ID_INTEL_QUARK_X1000_UDC 0x0939
381#define PCI_VENDOR_ID_ROHM 0x10DB 385#define PCI_VENDOR_ID_ROHM 0x10DB
382#define PCI_DEVICE_ID_ML7213_IOH_UDC 0x801D 386#define PCI_DEVICE_ID_ML7213_IOH_UDC 0x801D
383#define PCI_DEVICE_ID_ML7831_IOH_UDC 0x8808 387#define PCI_DEVICE_ID_ML7831_IOH_UDC 0x8808
@@ -3076,7 +3080,7 @@ static void pch_udc_remove(struct pci_dev *pdev)
3076 iounmap(dev->base_addr); 3080 iounmap(dev->base_addr);
3077 if (dev->mem_region) 3081 if (dev->mem_region)
3078 release_mem_region(dev->phys_addr, 3082 release_mem_region(dev->phys_addr,
3079 pci_resource_len(pdev, PCH_UDC_PCI_BAR)); 3083 pci_resource_len(pdev, dev->bar));
3080 if (dev->active) 3084 if (dev->active)
3081 pci_disable_device(pdev); 3085 pci_disable_device(pdev);
3082 kfree(dev); 3086 kfree(dev);
@@ -3144,9 +3148,15 @@ static int pch_udc_probe(struct pci_dev *pdev,
3144 dev->active = 1; 3148 dev->active = 1;
3145 pci_set_drvdata(pdev, dev); 3149 pci_set_drvdata(pdev, dev);
3146 3150
3151 /* Determine BAR based on PCI ID */
3152 if (id->device == PCI_DEVICE_ID_INTEL_QUARK_X1000_UDC)
3153 dev->bar = PCH_UDC_PCI_BAR_QUARK_X1000;
3154 else
3155 dev->bar = PCH_UDC_PCI_BAR;
3156
3147 /* PCI resource allocation */ 3157 /* PCI resource allocation */
3148 resource = pci_resource_start(pdev, 1); 3158 resource = pci_resource_start(pdev, dev->bar);
3149 len = pci_resource_len(pdev, 1); 3159 len = pci_resource_len(pdev, dev->bar);
3150 3160
3151 if (!request_mem_region(resource, len, KBUILD_MODNAME)) { 3161 if (!request_mem_region(resource, len, KBUILD_MODNAME)) {
3152 dev_err(&pdev->dev, "%s: pci device used already\n", __func__); 3162 dev_err(&pdev->dev, "%s: pci device used already\n", __func__);
@@ -3212,6 +3222,12 @@ finished:
3212 3222
3213static const struct pci_device_id pch_udc_pcidev_id[] = { 3223static const struct pci_device_id pch_udc_pcidev_id[] = {
3214 { 3224 {
3225 PCI_DEVICE(PCI_VENDOR_ID_INTEL,
3226 PCI_DEVICE_ID_INTEL_QUARK_X1000_UDC),
3227 .class = (PCI_CLASS_SERIAL_USB << 8) | 0xfe,
3228 .class_mask = 0xffffffff,
3229 },
3230 {
3215 PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_EG20T_UDC), 3231 PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_EG20T_UDC),
3216 .class = (PCI_CLASS_SERIAL_USB << 8) | 0xfe, 3232 .class = (PCI_CLASS_SERIAL_USB << 8) | 0xfe,
3217 .class_mask = 0xffffffff, 3233 .class_mask = 0xffffffff,
diff --git a/drivers/usb/gadget/udc/r8a66597-udc.c b/drivers/usb/gadget/udc/r8a66597-udc.c
index 46008421c1ec..de2a8713b428 100644
--- a/drivers/usb/gadget/udc/r8a66597-udc.c
+++ b/drivers/usb/gadget/udc/r8a66597-udc.c
@@ -1868,8 +1868,8 @@ static int r8a66597_probe(struct platform_device *pdev)
1868 1868
1869 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1869 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1870 reg = devm_ioremap_resource(&pdev->dev, res); 1870 reg = devm_ioremap_resource(&pdev->dev, res);
1871 if (!reg) 1871 if (IS_ERR(reg))
1872 return -ENODEV; 1872 return PTR_ERR(reg);
1873 1873
1874 ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 1874 ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
1875 irq = ires->start; 1875 irq = ires->start;
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index cc305c71ac3d..6130b7574908 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -1230,7 +1230,7 @@ int ehci_hub_control(
1230 if (selector == EHSET_TEST_SINGLE_STEP_SET_FEATURE) { 1230 if (selector == EHSET_TEST_SINGLE_STEP_SET_FEATURE) {
1231 spin_unlock_irqrestore(&ehci->lock, flags); 1231 spin_unlock_irqrestore(&ehci->lock, flags);
1232 retval = ehset_single_step_set_feature(hcd, 1232 retval = ehset_single_step_set_feature(hcd,
1233 wIndex); 1233 wIndex + 1);
1234 spin_lock_irqsave(&ehci->lock, flags); 1234 spin_lock_irqsave(&ehci->lock, flags);
1235 break; 1235 break;
1236 } 1236 }
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 687d36608155..c22a3e15a16e 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -101,6 +101,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
101 /* AMD PLL quirk */ 101 /* AMD PLL quirk */
102 if (pdev->vendor == PCI_VENDOR_ID_AMD && usb_amd_find_chipset_info()) 102 if (pdev->vendor == PCI_VENDOR_ID_AMD && usb_amd_find_chipset_info())
103 xhci->quirks |= XHCI_AMD_PLL_FIX; 103 xhci->quirks |= XHCI_AMD_PLL_FIX;
104
105 if (pdev->vendor == PCI_VENDOR_ID_AMD)
106 xhci->quirks |= XHCI_TRUST_TX_LENGTH;
107
104 if (pdev->vendor == PCI_VENDOR_ID_INTEL) { 108 if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
105 xhci->quirks |= XHCI_LPM_SUPPORT; 109 xhci->quirks |= XHCI_LPM_SUPPORT;
106 xhci->quirks |= XHCI_INTEL_HOST; 110 xhci->quirks |= XHCI_INTEL_HOST;
@@ -151,6 +155,11 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
151 if (pdev->vendor == PCI_VENDOR_ID_VIA) 155 if (pdev->vendor == PCI_VENDOR_ID_VIA)
152 xhci->quirks |= XHCI_RESET_ON_RESUME; 156 xhci->quirks |= XHCI_RESET_ON_RESUME;
153 157
158 /* See https://bugzilla.kernel.org/show_bug.cgi?id=79511 */
159 if (pdev->vendor == PCI_VENDOR_ID_VIA &&
160 pdev->device == 0x3432)
161 xhci->quirks |= XHCI_BROKEN_STREAMS;
162
154 if (xhci->quirks & XHCI_RESET_ON_RESUME) 163 if (xhci->quirks & XHCI_RESET_ON_RESUME)
155 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, 164 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
156 "QUIRK: Resetting on resume"); 165 "QUIRK: Resetting on resume");
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 60fb52ae864b..abed30b82905 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -364,32 +364,6 @@ static void ring_doorbell_for_active_rings(struct xhci_hcd *xhci,
364 } 364 }
365} 365}
366 366
367/*
368 * Find the segment that trb is in. Start searching in start_seg.
369 * If we must move past a segment that has a link TRB with a toggle cycle state
370 * bit set, then we will toggle the value pointed at by cycle_state.
371 */
372static struct xhci_segment *find_trb_seg(
373 struct xhci_segment *start_seg,
374 union xhci_trb *trb, int *cycle_state)
375{
376 struct xhci_segment *cur_seg = start_seg;
377 struct xhci_generic_trb *generic_trb;
378
379 while (cur_seg->trbs > trb ||
380 &cur_seg->trbs[TRBS_PER_SEGMENT - 1] < trb) {
381 generic_trb = &cur_seg->trbs[TRBS_PER_SEGMENT - 1].generic;
382 if (generic_trb->field[3] & cpu_to_le32(LINK_TOGGLE))
383 *cycle_state ^= 0x1;
384 cur_seg = cur_seg->next;
385 if (cur_seg == start_seg)
386 /* Looped over the entire list. Oops! */
387 return NULL;
388 }
389 return cur_seg;
390}
391
392
393static struct xhci_ring *xhci_triad_to_transfer_ring(struct xhci_hcd *xhci, 367static struct xhci_ring *xhci_triad_to_transfer_ring(struct xhci_hcd *xhci,
394 unsigned int slot_id, unsigned int ep_index, 368 unsigned int slot_id, unsigned int ep_index,
395 unsigned int stream_id) 369 unsigned int stream_id)
@@ -459,9 +433,12 @@ void xhci_find_new_dequeue_state(struct xhci_hcd *xhci,
459 struct xhci_virt_device *dev = xhci->devs[slot_id]; 433 struct xhci_virt_device *dev = xhci->devs[slot_id];
460 struct xhci_virt_ep *ep = &dev->eps[ep_index]; 434 struct xhci_virt_ep *ep = &dev->eps[ep_index];
461 struct xhci_ring *ep_ring; 435 struct xhci_ring *ep_ring;
462 struct xhci_generic_trb *trb; 436 struct xhci_segment *new_seg;
437 union xhci_trb *new_deq;
463 dma_addr_t addr; 438 dma_addr_t addr;
464 u64 hw_dequeue; 439 u64 hw_dequeue;
440 bool cycle_found = false;
441 bool td_last_trb_found = false;
465 442
466 ep_ring = xhci_triad_to_transfer_ring(xhci, slot_id, 443 ep_ring = xhci_triad_to_transfer_ring(xhci, slot_id,
467 ep_index, stream_id); 444 ep_index, stream_id);
@@ -486,45 +463,45 @@ void xhci_find_new_dequeue_state(struct xhci_hcd *xhci,
486 hw_dequeue = le64_to_cpu(ep_ctx->deq); 463 hw_dequeue = le64_to_cpu(ep_ctx->deq);
487 } 464 }
488 465
489 /* Find virtual address and segment of hardware dequeue pointer */ 466 new_seg = ep_ring->deq_seg;
490 state->new_deq_seg = ep_ring->deq_seg; 467 new_deq = ep_ring->dequeue;
491 state->new_deq_ptr = ep_ring->dequeue; 468 state->new_cycle_state = hw_dequeue & 0x1;
492 while (xhci_trb_virt_to_dma(state->new_deq_seg, state->new_deq_ptr) 469
493 != (dma_addr_t)(hw_dequeue & ~0xf)) {
494 next_trb(xhci, ep_ring, &state->new_deq_seg,
495 &state->new_deq_ptr);
496 if (state->new_deq_ptr == ep_ring->dequeue) {
497 WARN_ON(1);
498 return;
499 }
500 }
501 /* 470 /*
502 * Find cycle state for last_trb, starting at old cycle state of 471 * We want to find the pointer, segment and cycle state of the new trb
503 * hw_dequeue. If there is only one segment ring, find_trb_seg() will 472 * (the one after current TD's last_trb). We know the cycle state at
504 * return immediately and cannot toggle the cycle state if this search 473 * hw_dequeue, so walk the ring until both hw_dequeue and last_trb are
505 * wraps around, so add one more toggle manually in that case. 474 * found.
506 */ 475 */
507 state->new_cycle_state = hw_dequeue & 0x1; 476 do {
508 if (ep_ring->first_seg == ep_ring->first_seg->next && 477 if (!cycle_found && xhci_trb_virt_to_dma(new_seg, new_deq)
509 cur_td->last_trb < state->new_deq_ptr) 478 == (dma_addr_t)(hw_dequeue & ~0xf)) {
510 state->new_cycle_state ^= 0x1; 479 cycle_found = true;
480 if (td_last_trb_found)
481 break;
482 }
483 if (new_deq == cur_td->last_trb)
484 td_last_trb_found = true;
511 485
512 state->new_deq_ptr = cur_td->last_trb; 486 if (cycle_found &&
513 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, 487 TRB_TYPE_LINK_LE32(new_deq->generic.field[3]) &&
514 "Finding segment containing last TRB in TD."); 488 new_deq->generic.field[3] & cpu_to_le32(LINK_TOGGLE))
515 state->new_deq_seg = find_trb_seg(state->new_deq_seg, 489 state->new_cycle_state ^= 0x1;
516 state->new_deq_ptr, &state->new_cycle_state); 490
517 if (!state->new_deq_seg) { 491 next_trb(xhci, ep_ring, &new_seg, &new_deq);
518 WARN_ON(1); 492
519 return; 493 /* Search wrapped around, bail out */
520 } 494 if (new_deq == ep->ring->dequeue) {
495 xhci_err(xhci, "Error: Failed finding new dequeue state\n");
496 state->new_deq_seg = NULL;
497 state->new_deq_ptr = NULL;
498 return;
499 }
500
501 } while (!cycle_found || !td_last_trb_found);
521 502
522 /* Increment to find next TRB after last_trb. Cycle if appropriate. */ 503 state->new_deq_seg = new_seg;
523 trb = &state->new_deq_ptr->generic; 504 state->new_deq_ptr = new_deq;
524 if (TRB_TYPE_LINK_LE32(trb->field[3]) &&
525 (trb->field[3] & cpu_to_le32(LINK_TOGGLE)))
526 state->new_cycle_state ^= 0x1;
527 next_trb(xhci, ep_ring, &state->new_deq_seg, &state->new_deq_ptr);
528 505
529 /* Don't update the ring cycle state for the producer (us). */ 506 /* Don't update the ring cycle state for the producer (us). */
530 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, 507 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
@@ -2487,7 +2464,8 @@ static int handle_tx_event(struct xhci_hcd *xhci,
2487 * last TRB of the previous TD. The command completion handle 2464 * last TRB of the previous TD. The command completion handle
2488 * will take care the rest. 2465 * will take care the rest.
2489 */ 2466 */
2490 if (!event_seg && trb_comp_code == COMP_STOP_INVAL) { 2467 if (!event_seg && (trb_comp_code == COMP_STOP ||
2468 trb_comp_code == COMP_STOP_INVAL)) {
2491 ret = 0; 2469 ret = 0;
2492 goto cleanup; 2470 goto cleanup;
2493 } 2471 }
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index b6f21175b872..c020b094fe7d 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -2880,6 +2880,9 @@ void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci,
2880 ep_index, ep->stopped_stream, ep->stopped_td, 2880 ep_index, ep->stopped_stream, ep->stopped_td,
2881 &deq_state); 2881 &deq_state);
2882 2882
2883 if (!deq_state.new_deq_ptr || !deq_state.new_deq_seg)
2884 return;
2885
2883 /* HW with the reset endpoint quirk will use the saved dequeue state to 2886 /* HW with the reset endpoint quirk will use the saved dequeue state to
2884 * issue a configure endpoint command later. 2887 * issue a configure endpoint command later.
2885 */ 2888 */
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c
index 06b5d77cd9ad..633caf643122 100644
--- a/drivers/usb/misc/sisusbvga/sisusb.c
+++ b/drivers/usb/misc/sisusbvga/sisusb.c
@@ -3250,6 +3250,7 @@ static const struct usb_device_id sisusb_table[] = {
3250 { USB_DEVICE(0x0711, 0x0918) }, 3250 { USB_DEVICE(0x0711, 0x0918) },
3251 { USB_DEVICE(0x0711, 0x0920) }, 3251 { USB_DEVICE(0x0711, 0x0920) },
3252 { USB_DEVICE(0x0711, 0x0950) }, 3252 { USB_DEVICE(0x0711, 0x0950) },
3253 { USB_DEVICE(0x0711, 0x5200) },
3253 { USB_DEVICE(0x182d, 0x021c) }, 3254 { USB_DEVICE(0x182d, 0x021c) },
3254 { USB_DEVICE(0x182d, 0x0269) }, 3255 { USB_DEVICE(0x182d, 0x0269) },
3255 { } 3256 { }
diff --git a/drivers/usb/musb/ux500_dma.c b/drivers/usb/musb/ux500_dma.c
index 9aad00f11bd5..221faed9f074 100644
--- a/drivers/usb/musb/ux500_dma.c
+++ b/drivers/usb/musb/ux500_dma.c
@@ -96,7 +96,7 @@ static bool ux500_configure_channel(struct dma_channel *channel,
96 struct musb *musb = ux500_channel->controller->private_data; 96 struct musb *musb = ux500_channel->controller->private_data;
97 97
98 dev_dbg(musb->controller, 98 dev_dbg(musb->controller,
99 "packet_sz=%d, mode=%d, dma_addr=0x%llu, len=%d is_tx=%d\n", 99 "packet_sz=%d, mode=%d, dma_addr=0x%llx, len=%d is_tx=%d\n",
100 packet_sz, mode, (unsigned long long) dma_addr, 100 packet_sz, mode, (unsigned long long) dma_addr,
101 len, ux500_channel->is_tx); 101 len, ux500_channel->is_tx);
102 102
diff --git a/drivers/usb/phy/phy-gpio-vbus-usb.c b/drivers/usb/phy/phy-gpio-vbus-usb.c
index ea9e705555df..f4b14bd97e14 100644
--- a/drivers/usb/phy/phy-gpio-vbus-usb.c
+++ b/drivers/usb/phy/phy-gpio-vbus-usb.c
@@ -260,10 +260,8 @@ static int gpio_vbus_probe(struct platform_device *pdev)
260 260
261 gpio_vbus->phy.otg = devm_kzalloc(&pdev->dev, sizeof(struct usb_otg), 261 gpio_vbus->phy.otg = devm_kzalloc(&pdev->dev, sizeof(struct usb_otg),
262 GFP_KERNEL); 262 GFP_KERNEL);
263 if (!gpio_vbus->phy.otg) { 263 if (!gpio_vbus->phy.otg)
264 kfree(gpio_vbus);
265 return -ENOMEM; 264 return -ENOMEM;
266 }
267 265
268 platform_set_drvdata(pdev, gpio_vbus); 266 platform_set_drvdata(pdev, gpio_vbus);
269 gpio_vbus->dev = &pdev->dev; 267 gpio_vbus->dev = &pdev->dev;
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index e4108eec5ef4..afc09087ec36 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1601,8 +1601,8 @@ static int msm_otg_probe(struct platform_device *pdev)
1601 */ 1601 */
1602 if (motg->phy_number) { 1602 if (motg->phy_number) {
1603 phy_select = devm_ioremap_nocache(&pdev->dev, USB2_PHY_SEL, 4); 1603 phy_select = devm_ioremap_nocache(&pdev->dev, USB2_PHY_SEL, 4);
1604 if (IS_ERR(phy_select)) 1604 if (!phy_select)
1605 return PTR_ERR(phy_select); 1605 return -ENOMEM;
1606 /* Enable second PHY with the OTG port */ 1606 /* Enable second PHY with the OTG port */
1607 writel(0x1, phy_select); 1607 writel(0x1, phy_select);
1608 } 1608 }
diff --git a/drivers/usb/phy/phy-samsung-usb.h b/drivers/usb/phy/phy-samsung-usb.h
index 68771bfd1825..80eedd45a20a 100644
--- a/drivers/usb/phy/phy-samsung-usb.h
+++ b/drivers/usb/phy/phy-samsung-usb.h
@@ -216,7 +216,7 @@
216 216
217#define EXYNOS5_DRD_PHYPARAM1 (0x20) 217#define EXYNOS5_DRD_PHYPARAM1 (0x20)
218 218
219#define PHYPARAM1_PCS_TXDEEMPH_MASK (0x1f << 0) 219#define PHYPARAM1_PCS_TXDEEMPH_MASK (0x3f << 0)
220#define PHYPARAM1_PCS_TXDEEMPH (0x1c) 220#define PHYPARAM1_PCS_TXDEEMPH (0x1c)
221 221
222#define EXYNOS5_DRD_PHYTERM (0x24) 222#define EXYNOS5_DRD_PHYTERM (0x24)
diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c
index 6d0f6080eceb..045cd309367a 100644
--- a/drivers/usb/phy/phy.c
+++ b/drivers/usb/phy/phy.c
@@ -232,6 +232,9 @@ struct usb_phy *usb_get_phy_dev(struct device *dev, u8 index)
232 phy = __usb_find_phy_dev(dev, &phy_bind_list, index); 232 phy = __usb_find_phy_dev(dev, &phy_bind_list, index);
233 if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) { 233 if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) {
234 dev_dbg(dev, "unable to find transceiver\n"); 234 dev_dbg(dev, "unable to find transceiver\n");
235 if (!IS_ERR(phy))
236 phy = ERR_PTR(-ENODEV);
237
235 goto err0; 238 goto err0;
236 } 239 }
237 240
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 216ce3078270..824ea5e7ec8b 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -146,6 +146,7 @@ static const struct usb_device_id id_table_combined[] = {
146 { USB_DEVICE(FTDI_VID, FTDI_AMC232_PID) }, 146 { USB_DEVICE(FTDI_VID, FTDI_AMC232_PID) },
147 { USB_DEVICE(FTDI_VID, FTDI_CANUSB_PID) }, 147 { USB_DEVICE(FTDI_VID, FTDI_CANUSB_PID) },
148 { USB_DEVICE(FTDI_VID, FTDI_CANDAPTER_PID) }, 148 { USB_DEVICE(FTDI_VID, FTDI_CANDAPTER_PID) },
149 { USB_DEVICE(FTDI_VID, FTDI_BM_ATOM_NANO_PID) },
149 { USB_DEVICE(FTDI_VID, FTDI_NXTCAM_PID) }, 150 { USB_DEVICE(FTDI_VID, FTDI_NXTCAM_PID) },
150 { USB_DEVICE(FTDI_VID, FTDI_EV3CON_PID) }, 151 { USB_DEVICE(FTDI_VID, FTDI_EV3CON_PID) },
151 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_0_PID) }, 152 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_0_PID) },
@@ -934,6 +935,8 @@ static const struct usb_device_id id_table_combined[] = {
934 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_2_PID) }, 935 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_2_PID) },
935 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_3_PID) }, 936 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_3_PID) },
936 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_4_PID) }, 937 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_4_PID) },
938 /* ekey Devices */
939 { USB_DEVICE(FTDI_VID, FTDI_EKEY_CONV_USB_PID) },
937 /* Infineon Devices */ 940 /* Infineon Devices */
938 { USB_DEVICE_INTERFACE_NUMBER(INFINEON_VID, INFINEON_TRIBOARD_PID, 1) }, 941 { USB_DEVICE_INTERFACE_NUMBER(INFINEON_VID, INFINEON_TRIBOARD_PID, 1) },
939 { } /* Terminating entry */ 942 { } /* Terminating entry */
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index 1e58d90a0b6c..70b0b1d88ae9 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -42,6 +42,8 @@
42/* www.candapter.com Ewert Energy Systems CANdapter device */ 42/* www.candapter.com Ewert Energy Systems CANdapter device */
43#define FTDI_CANDAPTER_PID 0x9F80 /* Product Id */ 43#define FTDI_CANDAPTER_PID 0x9F80 /* Product Id */
44 44
45#define FTDI_BM_ATOM_NANO_PID 0xa559 /* Basic Micro ATOM Nano USB2Serial */
46
45/* 47/*
46 * Texas Instruments XDS100v2 JTAG / BeagleBone A3 48 * Texas Instruments XDS100v2 JTAG / BeagleBone A3
47 * http://processors.wiki.ti.com/index.php/XDS100 49 * http://processors.wiki.ti.com/index.php/XDS100
@@ -1378,3 +1380,8 @@
1378#define BRAINBOXES_US_160_6_PID 0x9006 /* US-160 16xRS232 1Mbaud Port 11 and 12 */ 1380#define BRAINBOXES_US_160_6_PID 0x9006 /* US-160 16xRS232 1Mbaud Port 11 and 12 */
1379#define BRAINBOXES_US_160_7_PID 0x9007 /* US-160 16xRS232 1Mbaud Port 13 and 14 */ 1381#define BRAINBOXES_US_160_7_PID 0x9007 /* US-160 16xRS232 1Mbaud Port 13 and 14 */
1380#define BRAINBOXES_US_160_8_PID 0x9008 /* US-160 16xRS232 1Mbaud Port 15 and 16 */ 1382#define BRAINBOXES_US_160_8_PID 0x9008 /* US-160 16xRS232 1Mbaud Port 15 and 16 */
1383
1384/*
1385 * ekey biometric systems GmbH (http://ekey.net/)
1386 */
1387#define FTDI_EKEY_CONV_USB_PID 0xCB08 /* Converter USB */
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index a9688940543d..54a8120897a6 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -275,8 +275,12 @@ static void option_instat_callback(struct urb *urb);
275#define ZTE_PRODUCT_MF622 0x0001 275#define ZTE_PRODUCT_MF622 0x0001
276#define ZTE_PRODUCT_MF628 0x0015 276#define ZTE_PRODUCT_MF628 0x0015
277#define ZTE_PRODUCT_MF626 0x0031 277#define ZTE_PRODUCT_MF626 0x0031
278#define ZTE_PRODUCT_MC2718 0xffe8
279#define ZTE_PRODUCT_AC2726 0xfff1 278#define ZTE_PRODUCT_AC2726 0xfff1
279#define ZTE_PRODUCT_CDMA_TECH 0xfffe
280#define ZTE_PRODUCT_AC8710T 0xffff
281#define ZTE_PRODUCT_MC2718 0xffe8
282#define ZTE_PRODUCT_AD3812 0xffeb
283#define ZTE_PRODUCT_MC2716 0xffed
280 284
281#define BENQ_VENDOR_ID 0x04a5 285#define BENQ_VENDOR_ID 0x04a5
282#define BENQ_PRODUCT_H10 0x4068 286#define BENQ_PRODUCT_H10 0x4068
@@ -494,6 +498,10 @@ static void option_instat_callback(struct urb *urb);
494#define INOVIA_VENDOR_ID 0x20a6 498#define INOVIA_VENDOR_ID 0x20a6
495#define INOVIA_SEW858 0x1105 499#define INOVIA_SEW858 0x1105
496 500
501/* VIA Telecom */
502#define VIATELECOM_VENDOR_ID 0x15eb
503#define VIATELECOM_PRODUCT_CDS7 0x0001
504
497/* some devices interfaces need special handling due to a number of reasons */ 505/* some devices interfaces need special handling due to a number of reasons */
498enum option_blacklist_reason { 506enum option_blacklist_reason {
499 OPTION_BLACKLIST_NONE = 0, 507 OPTION_BLACKLIST_NONE = 0,
@@ -527,10 +535,18 @@ static const struct option_blacklist_info zte_k3765_z_blacklist = {
527 .reserved = BIT(4), 535 .reserved = BIT(4),
528}; 536};
529 537
538static const struct option_blacklist_info zte_ad3812_z_blacklist = {
539 .sendsetup = BIT(0) | BIT(1) | BIT(2),
540};
541
530static const struct option_blacklist_info zte_mc2718_z_blacklist = { 542static const struct option_blacklist_info zte_mc2718_z_blacklist = {
531 .sendsetup = BIT(1) | BIT(2) | BIT(3) | BIT(4), 543 .sendsetup = BIT(1) | BIT(2) | BIT(3) | BIT(4),
532}; 544};
533 545
546static const struct option_blacklist_info zte_mc2716_z_blacklist = {
547 .sendsetup = BIT(1) | BIT(2) | BIT(3),
548};
549
534static const struct option_blacklist_info huawei_cdc12_blacklist = { 550static const struct option_blacklist_info huawei_cdc12_blacklist = {
535 .reserved = BIT(1) | BIT(2), 551 .reserved = BIT(1) | BIT(2),
536}; 552};
@@ -1070,6 +1086,7 @@ static const struct usb_device_id option_ids[] = {
1070 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1012, 0xff) }, 1086 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1012, 0xff) },
1071 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC650) }, 1087 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC650) },
1072 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, 1088 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) },
1089 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6000)}, /* ZTE AC8700 */
1073 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ 1090 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */
1074 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x0023)}, /* ONYX 3G device */ 1091 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x0023)}, /* ONYX 3G device */
1075 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */ 1092 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */
@@ -1544,13 +1561,18 @@ static const struct usb_device_id option_ids[] = {
1544 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff93, 0xff, 0xff, 0xff) }, 1561 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff93, 0xff, 0xff, 0xff) },
1545 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff94, 0xff, 0xff, 0xff) }, 1562 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff94, 0xff, 0xff, 0xff) },
1546 1563
1547 /* NOTE: most ZTE CDMA devices should be driven by zte_ev, not option */ 1564 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH, 0xff, 0xff, 0xff) },
1565 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 0xff, 0xff, 0xff) },
1566 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710T, 0xff, 0xff, 0xff) },
1548 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MC2718, 0xff, 0xff, 0xff), 1567 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MC2718, 0xff, 0xff, 0xff),
1549 .driver_info = (kernel_ulong_t)&zte_mc2718_z_blacklist }, 1568 .driver_info = (kernel_ulong_t)&zte_mc2718_z_blacklist },
1569 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AD3812, 0xff, 0xff, 0xff),
1570 .driver_info = (kernel_ulong_t)&zte_ad3812_z_blacklist },
1571 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MC2716, 0xff, 0xff, 0xff),
1572 .driver_info = (kernel_ulong_t)&zte_mc2716_z_blacklist },
1550 { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x01) }, 1573 { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x01) },
1551 { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x05) }, 1574 { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x05) },
1552 { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x86, 0x10) }, 1575 { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x86, 0x10) },
1553 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 0xff, 0xff, 0xff) },
1554 1576
1555 { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) }, 1577 { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) },
1556 { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) }, 1578 { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) },
@@ -1724,6 +1746,7 @@ static const struct usb_device_id option_ids[] = {
1724 { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */ 1746 { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */
1725 { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */ 1747 { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */
1726 { USB_DEVICE(INOVIA_VENDOR_ID, INOVIA_SEW858) }, 1748 { USB_DEVICE(INOVIA_VENDOR_ID, INOVIA_SEW858) },
1749 { USB_DEVICE(VIATELECOM_VENDOR_ID, VIATELECOM_PRODUCT_CDS7) },
1727 { } /* Terminating entry */ 1750 { } /* Terminating entry */
1728}; 1751};
1729MODULE_DEVICE_TABLE(usb, option_ids); 1752MODULE_DEVICE_TABLE(usb, option_ids);
@@ -1916,6 +1939,8 @@ static void option_instat_callback(struct urb *urb)
1916 dev_dbg(dev, "%s: type %x req %x\n", __func__, 1939 dev_dbg(dev, "%s: type %x req %x\n", __func__,
1917 req_pkt->bRequestType, req_pkt->bRequest); 1940 req_pkt->bRequestType, req_pkt->bRequest);
1918 } 1941 }
1942 } else if (status == -ENOENT || status == -ESHUTDOWN) {
1943 dev_dbg(dev, "%s: urb stopped: %d\n", __func__, status);
1919 } else 1944 } else
1920 dev_err(dev, "%s: error %d\n", __func__, status); 1945 dev_err(dev, "%s: error %d\n", __func__, status);
1921 1946
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index b3d5a35c0d4b..e9bad928039f 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -45,6 +45,7 @@ static const struct usb_device_id id_table[] = {
45 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_GPRS) }, 45 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_GPRS) },
46 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_HCR331) }, 46 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_HCR331) },
47 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_MOTOROLA) }, 47 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_MOTOROLA) },
48 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_ZTEK) },
48 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) }, 49 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) },
49 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) }, 50 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) },
50 { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) }, 51 { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) },
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
index 42bc082896ac..71fd9da1d6e7 100644
--- a/drivers/usb/serial/pl2303.h
+++ b/drivers/usb/serial/pl2303.h
@@ -22,6 +22,7 @@
22#define PL2303_PRODUCT_ID_GPRS 0x0609 22#define PL2303_PRODUCT_ID_GPRS 0x0609
23#define PL2303_PRODUCT_ID_HCR331 0x331a 23#define PL2303_PRODUCT_ID_HCR331 0x331a
24#define PL2303_PRODUCT_ID_MOTOROLA 0x0307 24#define PL2303_PRODUCT_ID_MOTOROLA 0x0307
25#define PL2303_PRODUCT_ID_ZTEK 0xe1f1
25 26
26#define ATEN_VENDOR_ID 0x0557 27#define ATEN_VENDOR_ID 0x0557
27#define ATEN_VENDOR_ID2 0x0547 28#define ATEN_VENDOR_ID2 0x0547
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 02de3110fe94..475723c006f9 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -764,29 +764,39 @@ static int usb_serial_probe(struct usb_interface *interface,
764 if (usb_endpoint_is_bulk_in(endpoint)) { 764 if (usb_endpoint_is_bulk_in(endpoint)) {
765 /* we found a bulk in endpoint */ 765 /* we found a bulk in endpoint */
766 dev_dbg(ddev, "found bulk in on endpoint %d\n", i); 766 dev_dbg(ddev, "found bulk in on endpoint %d\n", i);
767 bulk_in_endpoint[num_bulk_in] = endpoint; 767 if (num_bulk_in < MAX_NUM_PORTS) {
768 ++num_bulk_in; 768 bulk_in_endpoint[num_bulk_in] = endpoint;
769 ++num_bulk_in;
770 }
769 } 771 }
770 772
771 if (usb_endpoint_is_bulk_out(endpoint)) { 773 if (usb_endpoint_is_bulk_out(endpoint)) {
772 /* we found a bulk out endpoint */ 774 /* we found a bulk out endpoint */
773 dev_dbg(ddev, "found bulk out on endpoint %d\n", i); 775 dev_dbg(ddev, "found bulk out on endpoint %d\n", i);
774 bulk_out_endpoint[num_bulk_out] = endpoint; 776 if (num_bulk_out < MAX_NUM_PORTS) {
775 ++num_bulk_out; 777 bulk_out_endpoint[num_bulk_out] = endpoint;
778 ++num_bulk_out;
779 }
776 } 780 }
777 781
778 if (usb_endpoint_is_int_in(endpoint)) { 782 if (usb_endpoint_is_int_in(endpoint)) {
779 /* we found a interrupt in endpoint */ 783 /* we found a interrupt in endpoint */
780 dev_dbg(ddev, "found interrupt in on endpoint %d\n", i); 784 dev_dbg(ddev, "found interrupt in on endpoint %d\n", i);
781 interrupt_in_endpoint[num_interrupt_in] = endpoint; 785 if (num_interrupt_in < MAX_NUM_PORTS) {
782 ++num_interrupt_in; 786 interrupt_in_endpoint[num_interrupt_in] =
787 endpoint;
788 ++num_interrupt_in;
789 }
783 } 790 }
784 791
785 if (usb_endpoint_is_int_out(endpoint)) { 792 if (usb_endpoint_is_int_out(endpoint)) {
786 /* we found an interrupt out endpoint */ 793 /* we found an interrupt out endpoint */
787 dev_dbg(ddev, "found interrupt out on endpoint %d\n", i); 794 dev_dbg(ddev, "found interrupt out on endpoint %d\n", i);
788 interrupt_out_endpoint[num_interrupt_out] = endpoint; 795 if (num_interrupt_out < MAX_NUM_PORTS) {
789 ++num_interrupt_out; 796 interrupt_out_endpoint[num_interrupt_out] =
797 endpoint;
798 ++num_interrupt_out;
799 }
790 } 800 }
791 } 801 }
792 802
@@ -809,8 +819,10 @@ static int usb_serial_probe(struct usb_interface *interface,
809 if (usb_endpoint_is_int_in(endpoint)) { 819 if (usb_endpoint_is_int_in(endpoint)) {
810 /* we found a interrupt in endpoint */ 820 /* we found a interrupt in endpoint */
811 dev_dbg(ddev, "found interrupt in for Prolific device on separate interface\n"); 821 dev_dbg(ddev, "found interrupt in for Prolific device on separate interface\n");
812 interrupt_in_endpoint[num_interrupt_in] = endpoint; 822 if (num_interrupt_in < MAX_NUM_PORTS) {
813 ++num_interrupt_in; 823 interrupt_in_endpoint[num_interrupt_in] = endpoint;
824 ++num_interrupt_in;
825 }
814 } 826 }
815 } 827 }
816 } 828 }
@@ -850,6 +862,11 @@ static int usb_serial_probe(struct usb_interface *interface,
850 num_ports = type->num_ports; 862 num_ports = type->num_ports;
851 } 863 }
852 864
865 if (num_ports > MAX_NUM_PORTS) {
866 dev_warn(ddev, "too many ports requested: %d\n", num_ports);
867 num_ports = MAX_NUM_PORTS;
868 }
869
853 serial->num_ports = num_ports; 870 serial->num_ports = num_ports;
854 serial->num_bulk_in = num_bulk_in; 871 serial->num_bulk_in = num_bulk_in;
855 serial->num_bulk_out = num_bulk_out; 872 serial->num_bulk_out = num_bulk_out;
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index e62f2dff8b7d..6c3734d2b45a 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -514,6 +514,10 @@ static void command_port_read_callback(struct urb *urb)
514 dev_dbg(&urb->dev->dev, "%s - command_info is NULL, exiting.\n", __func__); 514 dev_dbg(&urb->dev->dev, "%s - command_info is NULL, exiting.\n", __func__);
515 return; 515 return;
516 } 516 }
517 if (!urb->actual_length) {
518 dev_dbg(&urb->dev->dev, "%s - empty response, exiting.\n", __func__);
519 return;
520 }
517 if (status) { 521 if (status) {
518 dev_dbg(&urb->dev->dev, "%s - nonzero urb status: %d\n", __func__, status); 522 dev_dbg(&urb->dev->dev, "%s - nonzero urb status: %d\n", __func__, status);
519 if (status != -ENOENT) 523 if (status != -ENOENT)
@@ -534,7 +538,8 @@ static void command_port_read_callback(struct urb *urb)
534 /* These are unsolicited reports from the firmware, hence no 538 /* These are unsolicited reports from the firmware, hence no
535 waiting command to wakeup */ 539 waiting command to wakeup */
536 dev_dbg(&urb->dev->dev, "%s - event received\n", __func__); 540 dev_dbg(&urb->dev->dev, "%s - event received\n", __func__);
537 } else if (data[0] == WHITEHEAT_GET_DTR_RTS) { 541 } else if ((data[0] == WHITEHEAT_GET_DTR_RTS) &&
542 (urb->actual_length - 1 <= sizeof(command_info->result_buffer))) {
538 memcpy(command_info->result_buffer, &data[1], 543 memcpy(command_info->result_buffer, &data[1],
539 urb->actual_length - 1); 544 urb->actual_length - 1);
540 command_info->command_finished = WHITEHEAT_CMD_COMPLETE; 545 command_info->command_finished = WHITEHEAT_CMD_COMPLETE;
diff --git a/drivers/usb/serial/zte_ev.c b/drivers/usb/serial/zte_ev.c
index e40ab739c4a6..1a132e9e947a 100644
--- a/drivers/usb/serial/zte_ev.c
+++ b/drivers/usb/serial/zte_ev.c
@@ -272,28 +272,8 @@ static void zte_ev_usb_serial_close(struct usb_serial_port *port)
272} 272}
273 273
274static const struct usb_device_id id_table[] = { 274static const struct usb_device_id id_table[] = {
275 /* AC8710, AC8710T */
276 { USB_DEVICE_AND_INTERFACE_INFO(0x19d2, 0xffff, 0xff, 0xff, 0xff) },
277 /* AC8700 */
278 { USB_DEVICE_AND_INTERFACE_INFO(0x19d2, 0xfffe, 0xff, 0xff, 0xff) },
279 /* MG880 */ 275 /* MG880 */
280 { USB_DEVICE(0x19d2, 0xfffd) }, 276 { USB_DEVICE(0x19d2, 0xfffd) },
281 { USB_DEVICE(0x19d2, 0xfffc) },
282 { USB_DEVICE(0x19d2, 0xfffb) },
283 /* AC8710_V3 */
284 { USB_DEVICE(0x19d2, 0xfff6) },
285 { USB_DEVICE(0x19d2, 0xfff7) },
286 { USB_DEVICE(0x19d2, 0xfff8) },
287 { USB_DEVICE(0x19d2, 0xfff9) },
288 { USB_DEVICE(0x19d2, 0xffee) },
289 /* AC2716, MC2716 */
290 { USB_DEVICE_AND_INTERFACE_INFO(0x19d2, 0xffed, 0xff, 0xff, 0xff) },
291 /* AD3812 */
292 { USB_DEVICE_AND_INTERFACE_INFO(0x19d2, 0xffeb, 0xff, 0xff, 0xff) },
293 { USB_DEVICE(0x19d2, 0xffec) },
294 { USB_DEVICE(0x05C6, 0x3197) },
295 { USB_DEVICE(0x05C6, 0x6000) },
296 { USB_DEVICE(0x05C6, 0x9008) },
297 { }, 277 { },
298}; 278};
299MODULE_DEVICE_TABLE(usb, id_table); 279MODULE_DEVICE_TABLE(usb, id_table);
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 80a5b366255f..7ef99b2f3aaf 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -922,6 +922,12 @@ UNUSUAL_DEV( 0x069b, 0x3004, 0x0001, 0x0001,
922 USB_SC_DEVICE, USB_PR_DEVICE, NULL, 922 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
923 US_FL_FIX_CAPACITY ), 923 US_FL_FIX_CAPACITY ),
924 924
925UNUSUAL_DEV( 0x06ca, 0x2003, 0x0100, 0x0100,
926 "Newer Technology",
927 "uSCSI",
928 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init,
929 US_FL_SCM_MULT_TARG ),
930
925/* Reported by Adrian Pilchowiec <adi1981@epf.pl> */ 931/* Reported by Adrian Pilchowiec <adi1981@epf.pl> */
926UNUSUAL_DEV( 0x071b, 0x3203, 0x0000, 0x0000, 932UNUSUAL_DEV( 0x071b, 0x3203, 0x0000, 0x0000,
927 "RockChip", 933 "RockChip",
diff --git a/drivers/staging/usbip/Kconfig b/drivers/usb/usbip/Kconfig
index bd99e9e47e50..bd99e9e47e50 100644
--- a/drivers/staging/usbip/Kconfig
+++ b/drivers/usb/usbip/Kconfig
diff --git a/drivers/staging/usbip/Makefile b/drivers/usb/usbip/Makefile
index 9ecd61545be1..9ecd61545be1 100644
--- a/drivers/staging/usbip/Makefile
+++ b/drivers/usb/usbip/Makefile
diff --git a/drivers/staging/usbip/README b/drivers/usb/usbip/README
index 41a2cf2e77a6..41a2cf2e77a6 100644
--- a/drivers/staging/usbip/README
+++ b/drivers/usb/usbip/README
diff --git a/drivers/staging/usbip/stub.h b/drivers/usb/usbip/stub.h
index 266e2b0ce9a8..266e2b0ce9a8 100644
--- a/drivers/staging/usbip/stub.h
+++ b/drivers/usb/usbip/stub.h
diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c
index 51d0c7188738..fac20e0434c0 100644
--- a/drivers/staging/usbip/stub_dev.c
+++ b/drivers/usb/usbip/stub_dev.c
@@ -26,33 +26,6 @@
26#include "stub.h" 26#include "stub.h"
27 27
28/* 28/*
29 * Define device IDs here if you want to explicitly limit exportable devices.
30 * In most cases, wildcard matching will be okay because driver binding can be
31 * changed dynamically by a userland program.
32 */
33static struct usb_device_id stub_table[] = {
34#if 0
35 /* just an example */
36 { USB_DEVICE(0x05ac, 0x0301) }, /* Mac 1 button mouse */
37 { USB_DEVICE(0x0430, 0x0009) }, /* Plat Home Keyboard */
38 { USB_DEVICE(0x059b, 0x0001) }, /* Iomega USB Zip 100 */
39 { USB_DEVICE(0x04b3, 0x4427) }, /* IBM USB CD-ROM */
40 { USB_DEVICE(0x05a9, 0xa511) }, /* LifeView USB cam */
41 { USB_DEVICE(0x55aa, 0x0201) }, /* Imation card reader */
42 { USB_DEVICE(0x046d, 0x0870) }, /* Qcam Express(QV-30) */
43 { USB_DEVICE(0x04bb, 0x0101) }, /* IO-DATA HD 120GB */
44 { USB_DEVICE(0x04bb, 0x0904) }, /* IO-DATA USB-ET/TX */
45 { USB_DEVICE(0x04bb, 0x0201) }, /* IO-DATA USB-ET/TX */
46 { USB_DEVICE(0x08bb, 0x2702) }, /* ONKYO USB Speaker */
47 { USB_DEVICE(0x046d, 0x08b2) }, /* Logicool Qcam 4000 Pro */
48#endif
49 /* magic for wild card */
50 { .driver_info = 1 },
51 { 0, } /* Terminating entry */
52};
53MODULE_DEVICE_TABLE(usb, stub_table);
54
55/*
56 * usbip_status shows the status of usbip-host as long as this driver is bound 29 * usbip_status shows the status of usbip-host as long as this driver is bound
57 * to the target device. 30 * to the target device.
58 */ 31 */
diff --git a/drivers/staging/usbip/stub_main.c b/drivers/usb/usbip/stub_main.c
index 44ab43fc4fcc..44ab43fc4fcc 100644
--- a/drivers/staging/usbip/stub_main.c
+++ b/drivers/usb/usbip/stub_main.c
diff --git a/drivers/staging/usbip/stub_rx.c b/drivers/usb/usbip/stub_rx.c
index 00e475c51a12..00e475c51a12 100644
--- a/drivers/staging/usbip/stub_rx.c
+++ b/drivers/usb/usbip/stub_rx.c
diff --git a/drivers/staging/usbip/stub_tx.c b/drivers/usb/usbip/stub_tx.c
index dbcabc9dbe0d..dbcabc9dbe0d 100644
--- a/drivers/staging/usbip/stub_tx.c
+++ b/drivers/usb/usbip/stub_tx.c
diff --git a/drivers/staging/usbip/usbip_common.c b/drivers/usb/usbip/usbip_common.c
index facaaf003f19..facaaf003f19 100644
--- a/drivers/staging/usbip/usbip_common.c
+++ b/drivers/usb/usbip/usbip_common.c
diff --git a/drivers/staging/usbip/usbip_common.h b/drivers/usb/usbip/usbip_common.h
index 4da3866a037d..86b08475c254 100644
--- a/drivers/staging/usbip/usbip_common.h
+++ b/drivers/usb/usbip/usbip_common.h
@@ -29,7 +29,7 @@
29#include <linux/types.h> 29#include <linux/types.h>
30#include <linux/usb.h> 30#include <linux/usb.h>
31#include <linux/wait.h> 31#include <linux/wait.h>
32#include "uapi/usbip.h" 32#include <uapi/linux/usbip.h>
33 33
34#define USBIP_VERSION "1.0.0" 34#define USBIP_VERSION "1.0.0"
35 35
diff --git a/drivers/staging/usbip/usbip_event.c b/drivers/usb/usbip/usbip_event.c
index 64933b993d7a..64933b993d7a 100644
--- a/drivers/staging/usbip/usbip_event.c
+++ b/drivers/usb/usbip/usbip_event.c
diff --git a/drivers/staging/usbip/usbip_protocol.txt b/drivers/usb/usbip/usbip_protocol.txt
index 16b6fe27284c..16b6fe27284c 100644
--- a/drivers/staging/usbip/usbip_protocol.txt
+++ b/drivers/usb/usbip/usbip_protocol.txt
diff --git a/drivers/staging/usbip/vhci.h b/drivers/usb/usbip/vhci.h
index a863a98a91ce..a863a98a91ce 100644
--- a/drivers/staging/usbip/vhci.h
+++ b/drivers/usb/usbip/vhci.h
diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index c02374b6049c..c02374b6049c 100644
--- a/drivers/staging/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/usb/usbip/vhci_rx.c
index 00e4a54308e4..00e4a54308e4 100644
--- a/drivers/staging/usbip/vhci_rx.c
+++ b/drivers/usb/usbip/vhci_rx.c
diff --git a/drivers/staging/usbip/vhci_sysfs.c b/drivers/usb/usbip/vhci_sysfs.c
index 211f43f67ea2..211f43f67ea2 100644
--- a/drivers/staging/usbip/vhci_sysfs.c
+++ b/drivers/usb/usbip/vhci_sysfs.c
diff --git a/drivers/staging/usbip/vhci_tx.c b/drivers/usb/usbip/vhci_tx.c
index 409fd99f3257..409fd99f3257 100644
--- a/drivers/staging/usbip/vhci_tx.c
+++ b/drivers/usb/usbip/vhci_tx.c
diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
index 3e2e4ed20157..e279015be466 100644
--- a/drivers/usb/wusbcore/wa-xfer.c
+++ b/drivers/usb/wusbcore/wa-xfer.c
@@ -2602,6 +2602,7 @@ static void wa_buf_in_cb(struct urb *urb)
2602 dev = &wa->usb_iface->dev; 2602 dev = &wa->usb_iface->dev;
2603 --(wa->active_buf_in_urbs); 2603 --(wa->active_buf_in_urbs);
2604 active_buf_in_urbs = wa->active_buf_in_urbs; 2604 active_buf_in_urbs = wa->active_buf_in_urbs;
2605 rpipe = xfer->ep->hcpriv;
2605 2606
2606 if (usb_pipeisoc(xfer->urb->pipe)) { 2607 if (usb_pipeisoc(xfer->urb->pipe)) {
2607 struct usb_iso_packet_descriptor *iso_frame_desc = 2608 struct usb_iso_packet_descriptor *iso_frame_desc =
@@ -2659,7 +2660,6 @@ static void wa_buf_in_cb(struct urb *urb)
2659 resubmit_dti = (isoc_data_frame_count == 2660 resubmit_dti = (isoc_data_frame_count ==
2660 urb_frame_count); 2661 urb_frame_count);
2661 } else if (active_buf_in_urbs == 0) { 2662 } else if (active_buf_in_urbs == 0) {
2662 rpipe = xfer->ep->hcpriv;
2663 dev_dbg(dev, 2663 dev_dbg(dev,
2664 "xfer %p 0x%08X#%u: data in done (%zu bytes)\n", 2664 "xfer %p 0x%08X#%u: data in done (%zu bytes)\n",
2665 xfer, wa_xfer_id(xfer), seg->index, 2665 xfer, wa_xfer_id(xfer), seg->index,
@@ -2685,7 +2685,6 @@ static void wa_buf_in_cb(struct urb *urb)
2685 */ 2685 */
2686 resubmit_dti = wa->dti_state != WA_DTI_TRANSFER_RESULT_PENDING; 2686 resubmit_dti = wa->dti_state != WA_DTI_TRANSFER_RESULT_PENDING;
2687 spin_lock_irqsave(&xfer->lock, flags); 2687 spin_lock_irqsave(&xfer->lock, flags);
2688 rpipe = xfer->ep->hcpriv;
2689 if (printk_ratelimit()) 2688 if (printk_ratelimit())
2690 dev_err(dev, "xfer %p 0x%08X#%u: data in error %d\n", 2689 dev_err(dev, "xfer %p 0x%08X#%u: data in error %d\n",
2691 xfer, wa_xfer_id(xfer), seg->index, 2690 xfer, wa_xfer_id(xfer), seg->index,
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index d7a3d13e72ec..b85983e97f0a 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -173,6 +173,7 @@ static int pwm_backlight_parse_dt(struct device *dev,
173 data->max_brightness--; 173 data->max_brightness--;
174 } 174 }
175 175
176 data->enable_gpio = -EINVAL;
176 return 0; 177 return 0;
177} 178}
178 179
diff --git a/drivers/video/fbdev/amba-clcd.c b/drivers/video/fbdev/amba-clcd.c
index beadd3edaa17..a7b6217ac87b 100644
--- a/drivers/video/fbdev/amba-clcd.c
+++ b/drivers/video/fbdev/amba-clcd.c
@@ -24,6 +24,7 @@
24#include <linux/list.h> 24#include <linux/list.h>
25#include <linux/amba/bus.h> 25#include <linux/amba/bus.h>
26#include <linux/amba/clcd.h> 26#include <linux/amba/clcd.h>
27#include <linux/bitops.h>
27#include <linux/clk.h> 28#include <linux/clk.h>
28#include <linux/hardirq.h> 29#include <linux/hardirq.h>
29#include <linux/dma-mapping.h> 30#include <linux/dma-mapping.h>
@@ -650,6 +651,7 @@ static int clcdfb_of_init_display(struct clcd_fb *fb)
650{ 651{
651 struct device_node *endpoint; 652 struct device_node *endpoint;
652 int err; 653 int err;
654 unsigned int bpp;
653 u32 max_bandwidth; 655 u32 max_bandwidth;
654 u32 tft_r0b0g0[3]; 656 u32 tft_r0b0g0[3];
655 657
@@ -667,11 +669,22 @@ static int clcdfb_of_init_display(struct clcd_fb *fb)
667 669
668 err = of_property_read_u32(fb->dev->dev.of_node, "max-memory-bandwidth", 670 err = of_property_read_u32(fb->dev->dev.of_node, "max-memory-bandwidth",
669 &max_bandwidth); 671 &max_bandwidth);
670 if (!err) 672 if (!err) {
671 fb->panel->bpp = 8 * max_bandwidth / (fb->panel->mode.xres * 673 /*
672 fb->panel->mode.yres * fb->panel->mode.refresh); 674 * max_bandwidth is in bytes per second and pixclock in
673 else 675 * pico-seconds, so the maximum allowed bits per pixel is
674 fb->panel->bpp = 32; 676 * 8 * max_bandwidth / (PICOS2KHZ(pixclock) * 1000)
677 * Rearrange this calculation to avoid overflow and then ensure
678 * result is a valid format.
679 */
680 bpp = max_bandwidth / (1000 / 8)
681 / PICOS2KHZ(fb->panel->mode.pixclock);
682 bpp = rounddown_pow_of_two(bpp);
683 if (bpp > 32)
684 bpp = 32;
685 } else
686 bpp = 32;
687 fb->panel->bpp = bpp;
675 688
676#ifdef CONFIG_CPU_BIG_ENDIAN 689#ifdef CONFIG_CPU_BIG_ENDIAN
677 fb->panel->cntl |= CNTL_BEBO; 690 fb->panel->cntl |= CNTL_BEBO;
diff --git a/drivers/video/fbdev/atmel_lcdfb.c b/drivers/video/fbdev/atmel_lcdfb.c
index 92640d46770a..1d8bdb92939b 100644
--- a/drivers/video/fbdev/atmel_lcdfb.c
+++ b/drivers/video/fbdev/atmel_lcdfb.c
@@ -1102,12 +1102,14 @@ static int atmel_lcdfb_of_init(struct atmel_lcdfb_info *sinfo)
1102 timings = of_get_display_timings(display_np); 1102 timings = of_get_display_timings(display_np);
1103 if (!timings) { 1103 if (!timings) {
1104 dev_err(dev, "failed to get display timings\n"); 1104 dev_err(dev, "failed to get display timings\n");
1105 ret = -EINVAL;
1105 goto put_display_node; 1106 goto put_display_node;
1106 } 1107 }
1107 1108
1108 timings_np = of_find_node_by_name(display_np, "display-timings"); 1109 timings_np = of_find_node_by_name(display_np, "display-timings");
1109 if (!timings_np) { 1110 if (!timings_np) {
1110 dev_err(dev, "failed to find display-timings node\n"); 1111 dev_err(dev, "failed to find display-timings node\n");
1112 ret = -ENODEV;
1111 goto put_display_node; 1113 goto put_display_node;
1112 } 1114 }
1113 1115
diff --git a/drivers/video/fbdev/chipsfb.c b/drivers/video/fbdev/chipsfb.c
index 206a66b61072..59abdc6a97f6 100644
--- a/drivers/video/fbdev/chipsfb.c
+++ b/drivers/video/fbdev/chipsfb.c
@@ -273,7 +273,7 @@ static struct chips_init_reg chips_init_xr[] = {
273 { 0xa8, 0x00 } 273 { 0xa8, 0x00 }
274}; 274};
275 275
276static void __init chips_hw_init(void) 276static void chips_hw_init(void)
277{ 277{
278 int i; 278 int i;
279 279
diff --git a/drivers/video/fbdev/da8xx-fb.c b/drivers/video/fbdev/da8xx-fb.c
index 788f6b37fce7..10c876c95772 100644
--- a/drivers/video/fbdev/da8xx-fb.c
+++ b/drivers/video/fbdev/da8xx-fb.c
@@ -419,7 +419,7 @@ static void lcd_cfg_horizontal_sync(int back_porch, int pulse_width,
419{ 419{
420 u32 reg; 420 u32 reg;
421 421
422 reg = lcdc_read(LCD_RASTER_TIMING_0_REG) & 0xf; 422 reg = lcdc_read(LCD_RASTER_TIMING_0_REG) & 0x3ff;
423 reg |= (((back_porch-1) & 0xff) << 24) 423 reg |= (((back_porch-1) & 0xff) << 24)
424 | (((front_porch-1) & 0xff) << 16) 424 | (((front_porch-1) & 0xff) << 16)
425 | (((pulse_width-1) & 0x3f) << 10); 425 | (((pulse_width-1) & 0x3f) << 10);
diff --git a/drivers/video/of_display_timing.c b/drivers/video/of_display_timing.c
index 987edf110038..5c098d5b4043 100644
--- a/drivers/video/of_display_timing.c
+++ b/drivers/video/of_display_timing.c
@@ -236,6 +236,7 @@ timingfail:
236 if (native_mode) 236 if (native_mode)
237 of_node_put(native_mode); 237 of_node_put(native_mode);
238 display_timings_release(disp); 238 display_timings_release(disp);
239 disp = NULL;
239entryfail: 240entryfail:
240 kfree(disp); 241 kfree(disp);
241dispfail: 242dispfail:
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index 5a201d81049c..fbd76ded9a34 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -22,7 +22,6 @@
22#include <linux/list.h> 22#include <linux/list.h>
23#include <linux/spinlock.h> 23#include <linux/spinlock.h>
24#include <linux/freezer.h> 24#include <linux/freezer.h>
25#include <linux/workqueue.h>
26#include "async-thread.h" 25#include "async-thread.h"
27#include "ctree.h" 26#include "ctree.h"
28 27
@@ -55,8 +54,39 @@ struct btrfs_workqueue {
55 struct __btrfs_workqueue *high; 54 struct __btrfs_workqueue *high;
56}; 55};
57 56
58static inline struct __btrfs_workqueue 57static void normal_work_helper(struct btrfs_work *work);
59*__btrfs_alloc_workqueue(const char *name, int flags, int max_active, 58
59#define BTRFS_WORK_HELPER(name) \
60void btrfs_##name(struct work_struct *arg) \
61{ \
62 struct btrfs_work *work = container_of(arg, struct btrfs_work, \
63 normal_work); \
64 normal_work_helper(work); \
65}
66
67BTRFS_WORK_HELPER(worker_helper);
68BTRFS_WORK_HELPER(delalloc_helper);
69BTRFS_WORK_HELPER(flush_delalloc_helper);
70BTRFS_WORK_HELPER(cache_helper);
71BTRFS_WORK_HELPER(submit_helper);
72BTRFS_WORK_HELPER(fixup_helper);
73BTRFS_WORK_HELPER(endio_helper);
74BTRFS_WORK_HELPER(endio_meta_helper);
75BTRFS_WORK_HELPER(endio_meta_write_helper);
76BTRFS_WORK_HELPER(endio_raid56_helper);
77BTRFS_WORK_HELPER(rmw_helper);
78BTRFS_WORK_HELPER(endio_write_helper);
79BTRFS_WORK_HELPER(freespace_write_helper);
80BTRFS_WORK_HELPER(delayed_meta_helper);
81BTRFS_WORK_HELPER(readahead_helper);
82BTRFS_WORK_HELPER(qgroup_rescan_helper);
83BTRFS_WORK_HELPER(extent_refs_helper);
84BTRFS_WORK_HELPER(scrub_helper);
85BTRFS_WORK_HELPER(scrubwrc_helper);
86BTRFS_WORK_HELPER(scrubnc_helper);
87
88static struct __btrfs_workqueue *
89__btrfs_alloc_workqueue(const char *name, int flags, int max_active,
60 int thresh) 90 int thresh)
61{ 91{
62 struct __btrfs_workqueue *ret = kzalloc(sizeof(*ret), GFP_NOFS); 92 struct __btrfs_workqueue *ret = kzalloc(sizeof(*ret), GFP_NOFS);
@@ -232,13 +262,11 @@ static void run_ordered_work(struct __btrfs_workqueue *wq)
232 spin_unlock_irqrestore(lock, flags); 262 spin_unlock_irqrestore(lock, flags);
233} 263}
234 264
235static void normal_work_helper(struct work_struct *arg) 265static void normal_work_helper(struct btrfs_work *work)
236{ 266{
237 struct btrfs_work *work;
238 struct __btrfs_workqueue *wq; 267 struct __btrfs_workqueue *wq;
239 int need_order = 0; 268 int need_order = 0;
240 269
241 work = container_of(arg, struct btrfs_work, normal_work);
242 /* 270 /*
243 * We should not touch things inside work in the following cases: 271 * We should not touch things inside work in the following cases:
244 * 1) after work->func() if it has no ordered_free 272 * 1) after work->func() if it has no ordered_free
@@ -262,7 +290,7 @@ static void normal_work_helper(struct work_struct *arg)
262 trace_btrfs_all_work_done(work); 290 trace_btrfs_all_work_done(work);
263} 291}
264 292
265void btrfs_init_work(struct btrfs_work *work, 293void btrfs_init_work(struct btrfs_work *work, btrfs_work_func_t uniq_func,
266 btrfs_func_t func, 294 btrfs_func_t func,
267 btrfs_func_t ordered_func, 295 btrfs_func_t ordered_func,
268 btrfs_func_t ordered_free) 296 btrfs_func_t ordered_free)
@@ -270,7 +298,7 @@ void btrfs_init_work(struct btrfs_work *work,
270 work->func = func; 298 work->func = func;
271 work->ordered_func = ordered_func; 299 work->ordered_func = ordered_func;
272 work->ordered_free = ordered_free; 300 work->ordered_free = ordered_free;
273 INIT_WORK(&work->normal_work, normal_work_helper); 301 INIT_WORK(&work->normal_work, uniq_func);
274 INIT_LIST_HEAD(&work->ordered_list); 302 INIT_LIST_HEAD(&work->ordered_list);
275 work->flags = 0; 303 work->flags = 0;
276} 304}
diff --git a/fs/btrfs/async-thread.h b/fs/btrfs/async-thread.h
index 9c6b66d15fb0..e9e31c94758f 100644
--- a/fs/btrfs/async-thread.h
+++ b/fs/btrfs/async-thread.h
@@ -19,12 +19,14 @@
19 19
20#ifndef __BTRFS_ASYNC_THREAD_ 20#ifndef __BTRFS_ASYNC_THREAD_
21#define __BTRFS_ASYNC_THREAD_ 21#define __BTRFS_ASYNC_THREAD_
22#include <linux/workqueue.h>
22 23
23struct btrfs_workqueue; 24struct btrfs_workqueue;
24/* Internal use only */ 25/* Internal use only */
25struct __btrfs_workqueue; 26struct __btrfs_workqueue;
26struct btrfs_work; 27struct btrfs_work;
27typedef void (*btrfs_func_t)(struct btrfs_work *arg); 28typedef void (*btrfs_func_t)(struct btrfs_work *arg);
29typedef void (*btrfs_work_func_t)(struct work_struct *arg);
28 30
29struct btrfs_work { 31struct btrfs_work {
30 btrfs_func_t func; 32 btrfs_func_t func;
@@ -38,11 +40,35 @@ struct btrfs_work {
38 unsigned long flags; 40 unsigned long flags;
39}; 41};
40 42
43#define BTRFS_WORK_HELPER_PROTO(name) \
44void btrfs_##name(struct work_struct *arg)
45
46BTRFS_WORK_HELPER_PROTO(worker_helper);
47BTRFS_WORK_HELPER_PROTO(delalloc_helper);
48BTRFS_WORK_HELPER_PROTO(flush_delalloc_helper);
49BTRFS_WORK_HELPER_PROTO(cache_helper);
50BTRFS_WORK_HELPER_PROTO(submit_helper);
51BTRFS_WORK_HELPER_PROTO(fixup_helper);
52BTRFS_WORK_HELPER_PROTO(endio_helper);
53BTRFS_WORK_HELPER_PROTO(endio_meta_helper);
54BTRFS_WORK_HELPER_PROTO(endio_meta_write_helper);
55BTRFS_WORK_HELPER_PROTO(endio_raid56_helper);
56BTRFS_WORK_HELPER_PROTO(rmw_helper);
57BTRFS_WORK_HELPER_PROTO(endio_write_helper);
58BTRFS_WORK_HELPER_PROTO(freespace_write_helper);
59BTRFS_WORK_HELPER_PROTO(delayed_meta_helper);
60BTRFS_WORK_HELPER_PROTO(readahead_helper);
61BTRFS_WORK_HELPER_PROTO(qgroup_rescan_helper);
62BTRFS_WORK_HELPER_PROTO(extent_refs_helper);
63BTRFS_WORK_HELPER_PROTO(scrub_helper);
64BTRFS_WORK_HELPER_PROTO(scrubwrc_helper);
65BTRFS_WORK_HELPER_PROTO(scrubnc_helper);
66
41struct btrfs_workqueue *btrfs_alloc_workqueue(const char *name, 67struct btrfs_workqueue *btrfs_alloc_workqueue(const char *name,
42 int flags, 68 int flags,
43 int max_active, 69 int max_active,
44 int thresh); 70 int thresh);
45void btrfs_init_work(struct btrfs_work *work, 71void btrfs_init_work(struct btrfs_work *work, btrfs_work_func_t helper,
46 btrfs_func_t func, 72 btrfs_func_t func,
47 btrfs_func_t ordered_func, 73 btrfs_func_t ordered_func,
48 btrfs_func_t ordered_free); 74 btrfs_func_t ordered_free);
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index da775bfdebc9..a2e90f855d7d 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -1395,8 +1395,8 @@ static int btrfs_wq_run_delayed_node(struct btrfs_delayed_root *delayed_root,
1395 return -ENOMEM; 1395 return -ENOMEM;
1396 1396
1397 async_work->delayed_root = delayed_root; 1397 async_work->delayed_root = delayed_root;
1398 btrfs_init_work(&async_work->work, btrfs_async_run_delayed_root, 1398 btrfs_init_work(&async_work->work, btrfs_delayed_meta_helper,
1399 NULL, NULL); 1399 btrfs_async_run_delayed_root, NULL, NULL);
1400 async_work->nr = nr; 1400 async_work->nr = nr;
1401 1401
1402 btrfs_queue_work(root->fs_info->delayed_workers, &async_work->work); 1402 btrfs_queue_work(root->fs_info->delayed_workers, &async_work->work);
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index d0ed9e664f7d..a1d36e62179c 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -39,7 +39,6 @@
39#include "btrfs_inode.h" 39#include "btrfs_inode.h"
40#include "volumes.h" 40#include "volumes.h"
41#include "print-tree.h" 41#include "print-tree.h"
42#include "async-thread.h"
43#include "locking.h" 42#include "locking.h"
44#include "tree-log.h" 43#include "tree-log.h"
45#include "free-space-cache.h" 44#include "free-space-cache.h"
@@ -693,35 +692,41 @@ static void end_workqueue_bio(struct bio *bio, int err)
693{ 692{
694 struct end_io_wq *end_io_wq = bio->bi_private; 693 struct end_io_wq *end_io_wq = bio->bi_private;
695 struct btrfs_fs_info *fs_info; 694 struct btrfs_fs_info *fs_info;
695 struct btrfs_workqueue *wq;
696 btrfs_work_func_t func;
696 697
697 fs_info = end_io_wq->info; 698 fs_info = end_io_wq->info;
698 end_io_wq->error = err; 699 end_io_wq->error = err;
699 btrfs_init_work(&end_io_wq->work, end_workqueue_fn, NULL, NULL);
700 700
701 if (bio->bi_rw & REQ_WRITE) { 701 if (bio->bi_rw & REQ_WRITE) {
702 if (end_io_wq->metadata == BTRFS_WQ_ENDIO_METADATA) 702 if (end_io_wq->metadata == BTRFS_WQ_ENDIO_METADATA) {
703 btrfs_queue_work(fs_info->endio_meta_write_workers, 703 wq = fs_info->endio_meta_write_workers;
704 &end_io_wq->work); 704 func = btrfs_endio_meta_write_helper;
705 else if (end_io_wq->metadata == BTRFS_WQ_ENDIO_FREE_SPACE) 705 } else if (end_io_wq->metadata == BTRFS_WQ_ENDIO_FREE_SPACE) {
706 btrfs_queue_work(fs_info->endio_freespace_worker, 706 wq = fs_info->endio_freespace_worker;
707 &end_io_wq->work); 707 func = btrfs_freespace_write_helper;
708 else if (end_io_wq->metadata == BTRFS_WQ_ENDIO_RAID56) 708 } else if (end_io_wq->metadata == BTRFS_WQ_ENDIO_RAID56) {
709 btrfs_queue_work(fs_info->endio_raid56_workers, 709 wq = fs_info->endio_raid56_workers;
710 &end_io_wq->work); 710 func = btrfs_endio_raid56_helper;
711 else 711 } else {
712 btrfs_queue_work(fs_info->endio_write_workers, 712 wq = fs_info->endio_write_workers;
713 &end_io_wq->work); 713 func = btrfs_endio_write_helper;
714 }
714 } else { 715 } else {
715 if (end_io_wq->metadata == BTRFS_WQ_ENDIO_RAID56) 716 if (end_io_wq->metadata == BTRFS_WQ_ENDIO_RAID56) {
716 btrfs_queue_work(fs_info->endio_raid56_workers, 717 wq = fs_info->endio_raid56_workers;
717 &end_io_wq->work); 718 func = btrfs_endio_raid56_helper;
718 else if (end_io_wq->metadata) 719 } else if (end_io_wq->metadata) {
719 btrfs_queue_work(fs_info->endio_meta_workers, 720 wq = fs_info->endio_meta_workers;
720 &end_io_wq->work); 721 func = btrfs_endio_meta_helper;
721 else 722 } else {
722 btrfs_queue_work(fs_info->endio_workers, 723 wq = fs_info->endio_workers;
723 &end_io_wq->work); 724 func = btrfs_endio_helper;
725 }
724 } 726 }
727
728 btrfs_init_work(&end_io_wq->work, func, end_workqueue_fn, NULL, NULL);
729 btrfs_queue_work(wq, &end_io_wq->work);
725} 730}
726 731
727/* 732/*
@@ -828,7 +833,7 @@ int btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct inode *inode,
828 async->submit_bio_start = submit_bio_start; 833 async->submit_bio_start = submit_bio_start;
829 async->submit_bio_done = submit_bio_done; 834 async->submit_bio_done = submit_bio_done;
830 835
831 btrfs_init_work(&async->work, run_one_async_start, 836 btrfs_init_work(&async->work, btrfs_worker_helper, run_one_async_start,
832 run_one_async_done, run_one_async_free); 837 run_one_async_done, run_one_async_free);
833 838
834 async->bio_flags = bio_flags; 839 async->bio_flags = bio_flags;
@@ -3450,7 +3455,8 @@ static int write_all_supers(struct btrfs_root *root, int max_mirrors)
3450 btrfs_set_stack_device_generation(dev_item, 0); 3455 btrfs_set_stack_device_generation(dev_item, 0);
3451 btrfs_set_stack_device_type(dev_item, dev->type); 3456 btrfs_set_stack_device_type(dev_item, dev->type);
3452 btrfs_set_stack_device_id(dev_item, dev->devid); 3457 btrfs_set_stack_device_id(dev_item, dev->devid);
3453 btrfs_set_stack_device_total_bytes(dev_item, dev->total_bytes); 3458 btrfs_set_stack_device_total_bytes(dev_item,
3459 dev->disk_total_bytes);
3454 btrfs_set_stack_device_bytes_used(dev_item, dev->bytes_used); 3460 btrfs_set_stack_device_bytes_used(dev_item, dev->bytes_used);
3455 btrfs_set_stack_device_io_align(dev_item, dev->io_align); 3461 btrfs_set_stack_device_io_align(dev_item, dev->io_align);
3456 btrfs_set_stack_device_io_width(dev_item, dev->io_width); 3462 btrfs_set_stack_device_io_width(dev_item, dev->io_width);
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 102ed3143976..3efe1c3877bf 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -552,7 +552,8 @@ static int cache_block_group(struct btrfs_block_group_cache *cache,
552 caching_ctl->block_group = cache; 552 caching_ctl->block_group = cache;
553 caching_ctl->progress = cache->key.objectid; 553 caching_ctl->progress = cache->key.objectid;
554 atomic_set(&caching_ctl->count, 1); 554 atomic_set(&caching_ctl->count, 1);
555 btrfs_init_work(&caching_ctl->work, caching_thread, NULL, NULL); 555 btrfs_init_work(&caching_ctl->work, btrfs_cache_helper,
556 caching_thread, NULL, NULL);
556 557
557 spin_lock(&cache->lock); 558 spin_lock(&cache->lock);
558 /* 559 /*
@@ -2749,8 +2750,8 @@ int btrfs_async_run_delayed_refs(struct btrfs_root *root,
2749 async->sync = 0; 2750 async->sync = 0;
2750 init_completion(&async->wait); 2751 init_completion(&async->wait);
2751 2752
2752 btrfs_init_work(&async->work, delayed_ref_async_start, 2753 btrfs_init_work(&async->work, btrfs_extent_refs_helper,
2753 NULL, NULL); 2754 delayed_ref_async_start, NULL, NULL);
2754 2755
2755 btrfs_queue_work(root->fs_info->extent_workers, &async->work); 2756 btrfs_queue_work(root->fs_info->extent_workers, &async->work);
2756 2757
@@ -3586,13 +3587,7 @@ static u64 get_restripe_target(struct btrfs_fs_info *fs_info, u64 flags)
3586 */ 3587 */
3587static u64 btrfs_reduce_alloc_profile(struct btrfs_root *root, u64 flags) 3588static u64 btrfs_reduce_alloc_profile(struct btrfs_root *root, u64 flags)
3588{ 3589{
3589 /* 3590 u64 num_devices = root->fs_info->fs_devices->rw_devices;
3590 * we add in the count of missing devices because we want
3591 * to make sure that any RAID levels on a degraded FS
3592 * continue to be honored.
3593 */
3594 u64 num_devices = root->fs_info->fs_devices->rw_devices +
3595 root->fs_info->fs_devices->missing_devices;
3596 u64 target; 3591 u64 target;
3597 u64 tmp; 3592 u64 tmp;
3598 3593
@@ -8440,13 +8435,7 @@ static u64 update_block_group_flags(struct btrfs_root *root, u64 flags)
8440 if (stripped) 8435 if (stripped)
8441 return extended_to_chunk(stripped); 8436 return extended_to_chunk(stripped);
8442 8437
8443 /* 8438 num_devices = root->fs_info->fs_devices->rw_devices;
8444 * we add in the count of missing devices because we want
8445 * to make sure that any RAID levels on a degraded FS
8446 * continue to be honored.
8447 */
8448 num_devices = root->fs_info->fs_devices->rw_devices +
8449 root->fs_info->fs_devices->missing_devices;
8450 8439
8451 stripped = BTRFS_BLOCK_GROUP_RAID0 | 8440 stripped = BTRFS_BLOCK_GROUP_RAID0 |
8452 BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6 | 8441 BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6 |
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 3e11aab9f391..af0359dcf337 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2532,6 +2532,7 @@ static void end_bio_extent_readpage(struct bio *bio, int err)
2532 test_bit(BIO_UPTODATE, &bio->bi_flags); 2532 test_bit(BIO_UPTODATE, &bio->bi_flags);
2533 if (err) 2533 if (err)
2534 uptodate = 0; 2534 uptodate = 0;
2535 offset += len;
2535 continue; 2536 continue;
2536 } 2537 }
2537 } 2538 }
@@ -4207,8 +4208,8 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
4207 return -ENOMEM; 4208 return -ENOMEM;
4208 path->leave_spinning = 1; 4209 path->leave_spinning = 1;
4209 4210
4210 start = ALIGN(start, BTRFS_I(inode)->root->sectorsize); 4211 start = round_down(start, BTRFS_I(inode)->root->sectorsize);
4211 len = ALIGN(len, BTRFS_I(inode)->root->sectorsize); 4212 len = round_up(max, BTRFS_I(inode)->root->sectorsize) - start;
4212 4213
4213 /* 4214 /*
4214 * lookup the last file extent. We're not using i_size here 4215 * lookup the last file extent. We're not using i_size here
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index d3afac292d67..36861b7a6757 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1840,7 +1840,15 @@ int btrfs_release_file(struct inode *inode, struct file *filp)
1840{ 1840{
1841 if (filp->private_data) 1841 if (filp->private_data)
1842 btrfs_ioctl_trans_end(filp); 1842 btrfs_ioctl_trans_end(filp);
1843 filemap_flush(inode->i_mapping); 1843 /*
1844 * ordered_data_close is set by settattr when we are about to truncate
1845 * a file from a non-zero size to a zero size. This tries to
1846 * flush down new bytes that may have been written if the
1847 * application were using truncate to replace a file in place.
1848 */
1849 if (test_and_clear_bit(BTRFS_INODE_ORDERED_DATA_CLOSE,
1850 &BTRFS_I(inode)->runtime_flags))
1851 filemap_flush(inode->i_mapping);
1844 return 0; 1852 return 0;
1845} 1853}
1846 1854
@@ -2088,10 +2096,9 @@ static int fill_holes(struct btrfs_trans_handle *trans, struct inode *inode,
2088 goto out; 2096 goto out;
2089 } 2097 }
2090 2098
2091 if (hole_mergeable(inode, leaf, path->slots[0]+1, offset, end)) { 2099 if (hole_mergeable(inode, leaf, path->slots[0], offset, end)) {
2092 u64 num_bytes; 2100 u64 num_bytes;
2093 2101
2094 path->slots[0]++;
2095 key.offset = offset; 2102 key.offset = offset;
2096 btrfs_set_item_key_safe(root, path, &key); 2103 btrfs_set_item_key_safe(root, path, &key);
2097 fi = btrfs_item_ptr(leaf, path->slots[0], 2104 fi = btrfs_item_ptr(leaf, path->slots[0],
@@ -2216,7 +2223,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
2216 goto out_only_mutex; 2223 goto out_only_mutex;
2217 } 2224 }
2218 2225
2219 lockstart = round_up(offset , BTRFS_I(inode)->root->sectorsize); 2226 lockstart = round_up(offset, BTRFS_I(inode)->root->sectorsize);
2220 lockend = round_down(offset + len, 2227 lockend = round_down(offset + len,
2221 BTRFS_I(inode)->root->sectorsize) - 1; 2228 BTRFS_I(inode)->root->sectorsize) - 1;
2222 same_page = ((offset >> PAGE_CACHE_SHIFT) == 2229 same_page = ((offset >> PAGE_CACHE_SHIFT) ==
@@ -2277,7 +2284,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
2277 tail_start + tail_len, 0, 1); 2284 tail_start + tail_len, 0, 1);
2278 if (ret) 2285 if (ret)
2279 goto out_only_mutex; 2286 goto out_only_mutex;
2280 } 2287 }
2281 } 2288 }
2282 } 2289 }
2283 2290
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 03708ef3deef..9c194bd74d6e 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1096,8 +1096,10 @@ static int cow_file_range_async(struct inode *inode, struct page *locked_page,
1096 async_cow->end = cur_end; 1096 async_cow->end = cur_end;
1097 INIT_LIST_HEAD(&async_cow->extents); 1097 INIT_LIST_HEAD(&async_cow->extents);
1098 1098
1099 btrfs_init_work(&async_cow->work, async_cow_start, 1099 btrfs_init_work(&async_cow->work,
1100 async_cow_submit, async_cow_free); 1100 btrfs_delalloc_helper,
1101 async_cow_start, async_cow_submit,
1102 async_cow_free);
1101 1103
1102 nr_pages = (cur_end - start + PAGE_CACHE_SIZE) >> 1104 nr_pages = (cur_end - start + PAGE_CACHE_SIZE) >>
1103 PAGE_CACHE_SHIFT; 1105 PAGE_CACHE_SHIFT;
@@ -1881,7 +1883,8 @@ static int btrfs_writepage_start_hook(struct page *page, u64 start, u64 end)
1881 1883
1882 SetPageChecked(page); 1884 SetPageChecked(page);
1883 page_cache_get(page); 1885 page_cache_get(page);
1884 btrfs_init_work(&fixup->work, btrfs_writepage_fixup_worker, NULL, NULL); 1886 btrfs_init_work(&fixup->work, btrfs_fixup_helper,
1887 btrfs_writepage_fixup_worker, NULL, NULL);
1885 fixup->page = page; 1888 fixup->page = page;
1886 btrfs_queue_work(root->fs_info->fixup_workers, &fixup->work); 1889 btrfs_queue_work(root->fs_info->fixup_workers, &fixup->work);
1887 return -EBUSY; 1890 return -EBUSY;
@@ -2822,7 +2825,8 @@ static int btrfs_writepage_end_io_hook(struct page *page, u64 start, u64 end,
2822 struct inode *inode = page->mapping->host; 2825 struct inode *inode = page->mapping->host;
2823 struct btrfs_root *root = BTRFS_I(inode)->root; 2826 struct btrfs_root *root = BTRFS_I(inode)->root;
2824 struct btrfs_ordered_extent *ordered_extent = NULL; 2827 struct btrfs_ordered_extent *ordered_extent = NULL;
2825 struct btrfs_workqueue *workers; 2828 struct btrfs_workqueue *wq;
2829 btrfs_work_func_t func;
2826 2830
2827 trace_btrfs_writepage_end_io_hook(page, start, end, uptodate); 2831 trace_btrfs_writepage_end_io_hook(page, start, end, uptodate);
2828 2832
@@ -2831,13 +2835,17 @@ static int btrfs_writepage_end_io_hook(struct page *page, u64 start, u64 end,
2831 end - start + 1, uptodate)) 2835 end - start + 1, uptodate))
2832 return 0; 2836 return 0;
2833 2837
2834 btrfs_init_work(&ordered_extent->work, finish_ordered_fn, NULL, NULL); 2838 if (btrfs_is_free_space_inode(inode)) {
2839 wq = root->fs_info->endio_freespace_worker;
2840 func = btrfs_freespace_write_helper;
2841 } else {
2842 wq = root->fs_info->endio_write_workers;
2843 func = btrfs_endio_write_helper;
2844 }
2835 2845
2836 if (btrfs_is_free_space_inode(inode)) 2846 btrfs_init_work(&ordered_extent->work, func, finish_ordered_fn, NULL,
2837 workers = root->fs_info->endio_freespace_worker; 2847 NULL);
2838 else 2848 btrfs_queue_work(wq, &ordered_extent->work);
2839 workers = root->fs_info->endio_write_workers;
2840 btrfs_queue_work(workers, &ordered_extent->work);
2841 2849
2842 return 0; 2850 return 0;
2843} 2851}
@@ -4674,6 +4682,11 @@ static void evict_inode_truncate_pages(struct inode *inode)
4674 clear_bit(EXTENT_FLAG_LOGGING, &em->flags); 4682 clear_bit(EXTENT_FLAG_LOGGING, &em->flags);
4675 remove_extent_mapping(map_tree, em); 4683 remove_extent_mapping(map_tree, em);
4676 free_extent_map(em); 4684 free_extent_map(em);
4685 if (need_resched()) {
4686 write_unlock(&map_tree->lock);
4687 cond_resched();
4688 write_lock(&map_tree->lock);
4689 }
4677 } 4690 }
4678 write_unlock(&map_tree->lock); 4691 write_unlock(&map_tree->lock);
4679 4692
@@ -4696,6 +4709,7 @@ static void evict_inode_truncate_pages(struct inode *inode)
4696 &cached_state, GFP_NOFS); 4709 &cached_state, GFP_NOFS);
4697 free_extent_state(state); 4710 free_extent_state(state);
4698 4711
4712 cond_resched();
4699 spin_lock(&io_tree->lock); 4713 spin_lock(&io_tree->lock);
4700 } 4714 }
4701 spin_unlock(&io_tree->lock); 4715 spin_unlock(&io_tree->lock);
@@ -5181,6 +5195,42 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
5181 iput(inode); 5195 iput(inode);
5182 inode = ERR_PTR(ret); 5196 inode = ERR_PTR(ret);
5183 } 5197 }
5198 /*
5199 * If orphan cleanup did remove any orphans, it means the tree
5200 * was modified and therefore the commit root is not the same as
5201 * the current root anymore. This is a problem, because send
5202 * uses the commit root and therefore can see inode items that
5203 * don't exist in the current root anymore, and for example make
5204 * calls to btrfs_iget, which will do tree lookups based on the
5205 * current root and not on the commit root. Those lookups will
5206 * fail, returning a -ESTALE error, and making send fail with
5207 * that error. So make sure a send does not see any orphans we
5208 * have just removed, and that it will see the same inodes
5209 * regardless of whether a transaction commit happened before
5210 * it started (meaning that the commit root will be the same as
5211 * the current root) or not.
5212 */
5213 if (sub_root->node != sub_root->commit_root) {
5214 u64 sub_flags = btrfs_root_flags(&sub_root->root_item);
5215
5216 if (sub_flags & BTRFS_ROOT_SUBVOL_RDONLY) {
5217 struct extent_buffer *eb;
5218
5219 /*
5220 * Assert we can't have races between dentry
5221 * lookup called through the snapshot creation
5222 * ioctl and the VFS.
5223 */
5224 ASSERT(mutex_is_locked(&dir->i_mutex));
5225
5226 down_write(&root->fs_info->commit_root_sem);
5227 eb = sub_root->commit_root;
5228 sub_root->commit_root =
5229 btrfs_root_node(sub_root);
5230 up_write(&root->fs_info->commit_root_sem);
5231 free_extent_buffer(eb);
5232 }
5233 }
5184 } 5234 }
5185 5235
5186 return inode; 5236 return inode;
@@ -5606,6 +5656,13 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
5606 } 5656 }
5607 5657
5608 /* 5658 /*
5659 * O_TMPFILE, set link count to 0, so that after this point,
5660 * we fill in an inode item with the correct link count.
5661 */
5662 if (!name)
5663 set_nlink(inode, 0);
5664
5665 /*
5609 * we have to initialize this early, so we can reclaim the inode 5666 * we have to initialize this early, so we can reclaim the inode
5610 * number if we fail afterwards in this function. 5667 * number if we fail afterwards in this function.
5611 */ 5668 */
@@ -6097,14 +6154,14 @@ out_fail:
6097static int merge_extent_mapping(struct extent_map_tree *em_tree, 6154static int merge_extent_mapping(struct extent_map_tree *em_tree,
6098 struct extent_map *existing, 6155 struct extent_map *existing,
6099 struct extent_map *em, 6156 struct extent_map *em,
6100 u64 map_start, u64 map_len) 6157 u64 map_start)
6101{ 6158{
6102 u64 start_diff; 6159 u64 start_diff;
6103 6160
6104 BUG_ON(map_start < em->start || map_start >= extent_map_end(em)); 6161 BUG_ON(map_start < em->start || map_start >= extent_map_end(em));
6105 start_diff = map_start - em->start; 6162 start_diff = map_start - em->start;
6106 em->start = map_start; 6163 em->start = map_start;
6107 em->len = map_len; 6164 em->len = existing->start - em->start;
6108 if (em->block_start < EXTENT_MAP_LAST_BYTE && 6165 if (em->block_start < EXTENT_MAP_LAST_BYTE &&
6109 !test_bit(EXTENT_FLAG_COMPRESSED, &em->flags)) { 6166 !test_bit(EXTENT_FLAG_COMPRESSED, &em->flags)) {
6110 em->block_start += start_diff; 6167 em->block_start += start_diff;
@@ -6275,6 +6332,8 @@ next:
6275 goto not_found; 6332 goto not_found;
6276 if (start + len <= found_key.offset) 6333 if (start + len <= found_key.offset)
6277 goto not_found; 6334 goto not_found;
6335 if (start > found_key.offset)
6336 goto next;
6278 em->start = start; 6337 em->start = start;
6279 em->orig_start = start; 6338 em->orig_start = start;
6280 em->len = found_key.offset - start; 6339 em->len = found_key.offset - start;
@@ -6390,8 +6449,7 @@ insert:
6390 em->len); 6449 em->len);
6391 if (existing) { 6450 if (existing) {
6392 err = merge_extent_mapping(em_tree, existing, 6451 err = merge_extent_mapping(em_tree, existing,
6393 em, start, 6452 em, start);
6394 root->sectorsize);
6395 free_extent_map(existing); 6453 free_extent_map(existing);
6396 if (err) { 6454 if (err) {
6397 free_extent_map(em); 6455 free_extent_map(em);
@@ -7158,7 +7216,8 @@ again:
7158 if (!ret) 7216 if (!ret)
7159 goto out_test; 7217 goto out_test;
7160 7218
7161 btrfs_init_work(&ordered->work, finish_ordered_fn, NULL, NULL); 7219 btrfs_init_work(&ordered->work, btrfs_endio_write_helper,
7220 finish_ordered_fn, NULL, NULL);
7162 btrfs_queue_work(root->fs_info->endio_write_workers, 7221 btrfs_queue_work(root->fs_info->endio_write_workers,
7163 &ordered->work); 7222 &ordered->work);
7164out_test: 7223out_test:
@@ -7306,10 +7365,8 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip,
7306 map_length = orig_bio->bi_iter.bi_size; 7365 map_length = orig_bio->bi_iter.bi_size;
7307 ret = btrfs_map_block(root->fs_info, rw, start_sector << 9, 7366 ret = btrfs_map_block(root->fs_info, rw, start_sector << 9,
7308 &map_length, NULL, 0); 7367 &map_length, NULL, 0);
7309 if (ret) { 7368 if (ret)
7310 bio_put(orig_bio);
7311 return -EIO; 7369 return -EIO;
7312 }
7313 7370
7314 if (map_length >= orig_bio->bi_iter.bi_size) { 7371 if (map_length >= orig_bio->bi_iter.bi_size) {
7315 bio = orig_bio; 7372 bio = orig_bio;
@@ -7326,6 +7383,7 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip,
7326 bio = btrfs_dio_bio_alloc(orig_bio->bi_bdev, start_sector, GFP_NOFS); 7383 bio = btrfs_dio_bio_alloc(orig_bio->bi_bdev, start_sector, GFP_NOFS);
7327 if (!bio) 7384 if (!bio)
7328 return -ENOMEM; 7385 return -ENOMEM;
7386
7329 bio->bi_private = dip; 7387 bio->bi_private = dip;
7330 bio->bi_end_io = btrfs_end_dio_bio; 7388 bio->bi_end_io = btrfs_end_dio_bio;
7331 atomic_inc(&dip->pending_bios); 7389 atomic_inc(&dip->pending_bios);
@@ -7534,7 +7592,8 @@ static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb,
7534 count = iov_iter_count(iter); 7592 count = iov_iter_count(iter);
7535 if (test_bit(BTRFS_INODE_HAS_ASYNC_EXTENT, 7593 if (test_bit(BTRFS_INODE_HAS_ASYNC_EXTENT,
7536 &BTRFS_I(inode)->runtime_flags)) 7594 &BTRFS_I(inode)->runtime_flags))
7537 filemap_fdatawrite_range(inode->i_mapping, offset, count); 7595 filemap_fdatawrite_range(inode->i_mapping, offset,
7596 offset + count - 1);
7538 7597
7539 if (rw & WRITE) { 7598 if (rw & WRITE) {
7540 /* 7599 /*
@@ -8495,7 +8554,9 @@ struct btrfs_delalloc_work *btrfs_alloc_delalloc_work(struct inode *inode,
8495 work->inode = inode; 8554 work->inode = inode;
8496 work->wait = wait; 8555 work->wait = wait;
8497 work->delay_iput = delay_iput; 8556 work->delay_iput = delay_iput;
8498 btrfs_init_work(&work->work, btrfs_run_delalloc_work, NULL, NULL); 8557 WARN_ON_ONCE(!inode);
8558 btrfs_init_work(&work->work, btrfs_flush_delalloc_helper,
8559 btrfs_run_delalloc_work, NULL, NULL);
8499 8560
8500 return work; 8561 return work;
8501} 8562}
@@ -8979,6 +9040,14 @@ static int btrfs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
8979 if (ret) 9040 if (ret)
8980 goto out; 9041 goto out;
8981 9042
9043 /*
9044 * We set number of links to 0 in btrfs_new_inode(), and here we set
9045 * it to 1 because d_tmpfile() will issue a warning if the count is 0,
9046 * through:
9047 *
9048 * d_tmpfile() -> inode_dec_link_count() -> drop_nlink()
9049 */
9050 set_nlink(inode, 1);
8982 d_tmpfile(dentry, inode); 9051 d_tmpfile(dentry, inode);
8983 mark_inode_dirty(inode); 9052 mark_inode_dirty(inode);
8984 9053
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 47aceb494d1d..fce6fd0e3f50 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -711,39 +711,6 @@ static int create_snapshot(struct btrfs_root *root, struct inode *dir,
711 if (ret) 711 if (ret)
712 goto fail; 712 goto fail;
713 713
714 ret = btrfs_orphan_cleanup(pending_snapshot->snap);
715 if (ret)
716 goto fail;
717
718 /*
719 * If orphan cleanup did remove any orphans, it means the tree was
720 * modified and therefore the commit root is not the same as the
721 * current root anymore. This is a problem, because send uses the
722 * commit root and therefore can see inode items that don't exist
723 * in the current root anymore, and for example make calls to
724 * btrfs_iget, which will do tree lookups based on the current root
725 * and not on the commit root. Those lookups will fail, returning a
726 * -ESTALE error, and making send fail with that error. So make sure
727 * a send does not see any orphans we have just removed, and that it
728 * will see the same inodes regardless of whether a transaction
729 * commit happened before it started (meaning that the commit root
730 * will be the same as the current root) or not.
731 */
732 if (readonly && pending_snapshot->snap->node !=
733 pending_snapshot->snap->commit_root) {
734 trans = btrfs_join_transaction(pending_snapshot->snap);
735 if (IS_ERR(trans) && PTR_ERR(trans) != -ENOENT) {
736 ret = PTR_ERR(trans);
737 goto fail;
738 }
739 if (!IS_ERR(trans)) {
740 ret = btrfs_commit_transaction(trans,
741 pending_snapshot->snap);
742 if (ret)
743 goto fail;
744 }
745 }
746
747 inode = btrfs_lookup_dentry(dentry->d_parent->d_inode, dentry); 714 inode = btrfs_lookup_dentry(dentry->d_parent->d_inode, dentry);
748 if (IS_ERR(inode)) { 715 if (IS_ERR(inode)) {
749 ret = PTR_ERR(inode); 716 ret = PTR_ERR(inode);
@@ -3527,7 +3494,8 @@ process_slot:
3527 btrfs_mark_buffer_dirty(leaf); 3494 btrfs_mark_buffer_dirty(leaf);
3528 btrfs_release_path(path); 3495 btrfs_release_path(path);
3529 3496
3530 last_dest_end = new_key.offset + datal; 3497 last_dest_end = ALIGN(new_key.offset + datal,
3498 root->sectorsize);
3531 ret = clone_finish_inode_update(trans, inode, 3499 ret = clone_finish_inode_update(trans, inode,
3532 last_dest_end, 3500 last_dest_end,
3533 destoff, olen); 3501 destoff, olen);
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index 963895c1f801..ac734ec4cc20 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -615,6 +615,7 @@ int btrfs_wait_ordered_extents(struct btrfs_root *root, int nr)
615 spin_unlock(&root->ordered_extent_lock); 615 spin_unlock(&root->ordered_extent_lock);
616 616
617 btrfs_init_work(&ordered->flush_work, 617 btrfs_init_work(&ordered->flush_work,
618 btrfs_flush_delalloc_helper,
618 btrfs_run_ordered_extent_work, NULL, NULL); 619 btrfs_run_ordered_extent_work, NULL, NULL);
619 list_add_tail(&ordered->work_list, &works); 620 list_add_tail(&ordered->work_list, &works);
620 btrfs_queue_work(root->fs_info->flush_workers, 621 btrfs_queue_work(root->fs_info->flush_workers,
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index b497498484be..ded5c601d916 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -1973,7 +1973,7 @@ static int qgroup_subtree_accounting(struct btrfs_trans_handle *trans,
1973 elem.seq, &roots); 1973 elem.seq, &roots);
1974 btrfs_put_tree_mod_seq(fs_info, &elem); 1974 btrfs_put_tree_mod_seq(fs_info, &elem);
1975 if (ret < 0) 1975 if (ret < 0)
1976 return ret; 1976 goto out;
1977 1977
1978 if (roots->nnodes != 1) 1978 if (roots->nnodes != 1)
1979 goto out; 1979 goto out;
@@ -2720,6 +2720,7 @@ qgroup_rescan_init(struct btrfs_fs_info *fs_info, u64 progress_objectid,
2720 memset(&fs_info->qgroup_rescan_work, 0, 2720 memset(&fs_info->qgroup_rescan_work, 0,
2721 sizeof(fs_info->qgroup_rescan_work)); 2721 sizeof(fs_info->qgroup_rescan_work));
2722 btrfs_init_work(&fs_info->qgroup_rescan_work, 2722 btrfs_init_work(&fs_info->qgroup_rescan_work,
2723 btrfs_qgroup_rescan_helper,
2723 btrfs_qgroup_rescan_worker, NULL, NULL); 2724 btrfs_qgroup_rescan_worker, NULL, NULL);
2724 2725
2725 if (ret) { 2726 if (ret) {
diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index 4a88f073fdd7..0a6b6e4bcbb9 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -1416,7 +1416,8 @@ cleanup:
1416 1416
1417static void async_rmw_stripe(struct btrfs_raid_bio *rbio) 1417static void async_rmw_stripe(struct btrfs_raid_bio *rbio)
1418{ 1418{
1419 btrfs_init_work(&rbio->work, rmw_work, NULL, NULL); 1419 btrfs_init_work(&rbio->work, btrfs_rmw_helper,
1420 rmw_work, NULL, NULL);
1420 1421
1421 btrfs_queue_work(rbio->fs_info->rmw_workers, 1422 btrfs_queue_work(rbio->fs_info->rmw_workers,
1422 &rbio->work); 1423 &rbio->work);
@@ -1424,7 +1425,8 @@ static void async_rmw_stripe(struct btrfs_raid_bio *rbio)
1424 1425
1425static void async_read_rebuild(struct btrfs_raid_bio *rbio) 1426static void async_read_rebuild(struct btrfs_raid_bio *rbio)
1426{ 1427{
1427 btrfs_init_work(&rbio->work, read_rebuild_work, NULL, NULL); 1428 btrfs_init_work(&rbio->work, btrfs_rmw_helper,
1429 read_rebuild_work, NULL, NULL);
1428 1430
1429 btrfs_queue_work(rbio->fs_info->rmw_workers, 1431 btrfs_queue_work(rbio->fs_info->rmw_workers,
1430 &rbio->work); 1432 &rbio->work);
@@ -1665,7 +1667,8 @@ static void btrfs_raid_unplug(struct blk_plug_cb *cb, bool from_schedule)
1665 plug = container_of(cb, struct btrfs_plug_cb, cb); 1667 plug = container_of(cb, struct btrfs_plug_cb, cb);
1666 1668
1667 if (from_schedule) { 1669 if (from_schedule) {
1668 btrfs_init_work(&plug->work, unplug_work, NULL, NULL); 1670 btrfs_init_work(&plug->work, btrfs_rmw_helper,
1671 unplug_work, NULL, NULL);
1669 btrfs_queue_work(plug->info->rmw_workers, 1672 btrfs_queue_work(plug->info->rmw_workers,
1670 &plug->work); 1673 &plug->work);
1671 return; 1674 return;
diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c
index 09230cf3a244..20408c6b665a 100644
--- a/fs/btrfs/reada.c
+++ b/fs/btrfs/reada.c
@@ -798,7 +798,8 @@ static void reada_start_machine(struct btrfs_fs_info *fs_info)
798 /* FIXME we cannot handle this properly right now */ 798 /* FIXME we cannot handle this properly right now */
799 BUG(); 799 BUG();
800 } 800 }
801 btrfs_init_work(&rmw->work, reada_start_machine_worker, NULL, NULL); 801 btrfs_init_work(&rmw->work, btrfs_readahead_helper,
802 reada_start_machine_worker, NULL, NULL);
802 rmw->fs_info = fs_info; 803 rmw->fs_info = fs_info;
803 804
804 btrfs_queue_work(fs_info->readahead_workers, &rmw->work); 805 btrfs_queue_work(fs_info->readahead_workers, &rmw->work);
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index b6d198f5181e..f4a41f37be22 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -428,8 +428,8 @@ struct scrub_ctx *scrub_setup_ctx(struct btrfs_device *dev, int is_dev_replace)
428 sbio->index = i; 428 sbio->index = i;
429 sbio->sctx = sctx; 429 sbio->sctx = sctx;
430 sbio->page_count = 0; 430 sbio->page_count = 0;
431 btrfs_init_work(&sbio->work, scrub_bio_end_io_worker, 431 btrfs_init_work(&sbio->work, btrfs_scrub_helper,
432 NULL, NULL); 432 scrub_bio_end_io_worker, NULL, NULL);
433 433
434 if (i != SCRUB_BIOS_PER_SCTX - 1) 434 if (i != SCRUB_BIOS_PER_SCTX - 1)
435 sctx->bios[i]->next_free = i + 1; 435 sctx->bios[i]->next_free = i + 1;
@@ -999,8 +999,8 @@ nodatasum_case:
999 fixup_nodatasum->root = fs_info->extent_root; 999 fixup_nodatasum->root = fs_info->extent_root;
1000 fixup_nodatasum->mirror_num = failed_mirror_index + 1; 1000 fixup_nodatasum->mirror_num = failed_mirror_index + 1;
1001 scrub_pending_trans_workers_inc(sctx); 1001 scrub_pending_trans_workers_inc(sctx);
1002 btrfs_init_work(&fixup_nodatasum->work, scrub_fixup_nodatasum, 1002 btrfs_init_work(&fixup_nodatasum->work, btrfs_scrub_helper,
1003 NULL, NULL); 1003 scrub_fixup_nodatasum, NULL, NULL);
1004 btrfs_queue_work(fs_info->scrub_workers, 1004 btrfs_queue_work(fs_info->scrub_workers,
1005 &fixup_nodatasum->work); 1005 &fixup_nodatasum->work);
1006 goto out; 1006 goto out;
@@ -1616,7 +1616,8 @@ static void scrub_wr_bio_end_io(struct bio *bio, int err)
1616 sbio->err = err; 1616 sbio->err = err;
1617 sbio->bio = bio; 1617 sbio->bio = bio;
1618 1618
1619 btrfs_init_work(&sbio->work, scrub_wr_bio_end_io_worker, NULL, NULL); 1619 btrfs_init_work(&sbio->work, btrfs_scrubwrc_helper,
1620 scrub_wr_bio_end_io_worker, NULL, NULL);
1620 btrfs_queue_work(fs_info->scrub_wr_completion_workers, &sbio->work); 1621 btrfs_queue_work(fs_info->scrub_wr_completion_workers, &sbio->work);
1621} 1622}
1622 1623
@@ -2904,6 +2905,7 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
2904 struct scrub_ctx *sctx; 2905 struct scrub_ctx *sctx;
2905 int ret; 2906 int ret;
2906 struct btrfs_device *dev; 2907 struct btrfs_device *dev;
2908 struct rcu_string *name;
2907 2909
2908 if (btrfs_fs_closing(fs_info)) 2910 if (btrfs_fs_closing(fs_info))
2909 return -EINVAL; 2911 return -EINVAL;
@@ -2965,6 +2967,16 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
2965 return -ENODEV; 2967 return -ENODEV;
2966 } 2968 }
2967 2969
2970 if (!is_dev_replace && !readonly && !dev->writeable) {
2971 mutex_unlock(&fs_info->fs_devices->device_list_mutex);
2972 rcu_read_lock();
2973 name = rcu_dereference(dev->name);
2974 btrfs_err(fs_info, "scrub: device %s is not writable",
2975 name->str);
2976 rcu_read_unlock();
2977 return -EROFS;
2978 }
2979
2968 mutex_lock(&fs_info->scrub_lock); 2980 mutex_lock(&fs_info->scrub_lock);
2969 if (!dev->in_fs_metadata || dev->is_tgtdev_for_dev_replace) { 2981 if (!dev->in_fs_metadata || dev->is_tgtdev_for_dev_replace) {
2970 mutex_unlock(&fs_info->scrub_lock); 2982 mutex_unlock(&fs_info->scrub_lock);
@@ -3203,7 +3215,8 @@ static int copy_nocow_pages(struct scrub_ctx *sctx, u64 logical, u64 len,
3203 nocow_ctx->len = len; 3215 nocow_ctx->len = len;
3204 nocow_ctx->mirror_num = mirror_num; 3216 nocow_ctx->mirror_num = mirror_num;
3205 nocow_ctx->physical_for_dev_replace = physical_for_dev_replace; 3217 nocow_ctx->physical_for_dev_replace = physical_for_dev_replace;
3206 btrfs_init_work(&nocow_ctx->work, copy_nocow_pages_worker, NULL, NULL); 3218 btrfs_init_work(&nocow_ctx->work, btrfs_scrubnc_helper,
3219 copy_nocow_pages_worker, NULL, NULL);
3207 INIT_LIST_HEAD(&nocow_ctx->inodes); 3220 INIT_LIST_HEAD(&nocow_ctx->inodes);
3208 btrfs_queue_work(fs_info->scrub_nocow_workers, 3221 btrfs_queue_work(fs_info->scrub_nocow_workers,
3209 &nocow_ctx->work); 3222 &nocow_ctx->work);
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 78699364f537..12e53556e214 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -614,7 +614,7 @@ int btrfs_kobj_rm_device(struct btrfs_fs_info *fs_info,
614 if (!fs_info->device_dir_kobj) 614 if (!fs_info->device_dir_kobj)
615 return -EINVAL; 615 return -EINVAL;
616 616
617 if (one_device) { 617 if (one_device && one_device->bdev) {
618 disk = one_device->bdev->bd_part; 618 disk = one_device->bdev->bd_part;
619 disk_kobj = &part_to_dev(disk)->kobj; 619 disk_kobj = &part_to_dev(disk)->kobj;
620 620
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 9e1f2cd5e67a..7e0e6e3029dd 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -3298,7 +3298,7 @@ static noinline int copy_items(struct btrfs_trans_handle *trans,
3298 struct list_head ordered_sums; 3298 struct list_head ordered_sums;
3299 int skip_csum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM; 3299 int skip_csum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM;
3300 bool has_extents = false; 3300 bool has_extents = false;
3301 bool need_find_last_extent = (*last_extent == 0); 3301 bool need_find_last_extent = true;
3302 bool done = false; 3302 bool done = false;
3303 3303
3304 INIT_LIST_HEAD(&ordered_sums); 3304 INIT_LIST_HEAD(&ordered_sums);
@@ -3352,8 +3352,7 @@ static noinline int copy_items(struct btrfs_trans_handle *trans,
3352 */ 3352 */
3353 if (ins_keys[i].type == BTRFS_EXTENT_DATA_KEY) { 3353 if (ins_keys[i].type == BTRFS_EXTENT_DATA_KEY) {
3354 has_extents = true; 3354 has_extents = true;
3355 if (need_find_last_extent && 3355 if (first_key.objectid == (u64)-1)
3356 first_key.objectid == (u64)-1)
3357 first_key = ins_keys[i]; 3356 first_key = ins_keys[i];
3358 } else { 3357 } else {
3359 need_find_last_extent = false; 3358 need_find_last_extent = false;
@@ -3427,6 +3426,16 @@ static noinline int copy_items(struct btrfs_trans_handle *trans,
3427 if (!has_extents) 3426 if (!has_extents)
3428 return ret; 3427 return ret;
3429 3428
3429 if (need_find_last_extent && *last_extent == first_key.offset) {
3430 /*
3431 * We don't have any leafs between our current one and the one
3432 * we processed before that can have file extent items for our
3433 * inode (and have a generation number smaller than our current
3434 * transaction id).
3435 */
3436 need_find_last_extent = false;
3437 }
3438
3430 /* 3439 /*
3431 * Because we use btrfs_search_forward we could skip leaves that were 3440 * Because we use btrfs_search_forward we could skip leaves that were
3432 * not modified and then assume *last_extent is valid when it really 3441 * not modified and then assume *last_extent is valid when it really
@@ -3537,7 +3546,7 @@ fill_holes:
3537 0, 0); 3546 0, 0);
3538 if (ret) 3547 if (ret)
3539 break; 3548 break;
3540 *last_extent = offset + len; 3549 *last_extent = extent_end;
3541 } 3550 }
3542 /* 3551 /*
3543 * Need to let the callers know we dropped the path so they should 3552 * Need to let the callers know we dropped the path so they should
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 6cb82f62cb7c..340a92d08e84 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -508,6 +508,44 @@ static noinline int device_list_add(const char *path,
508 ret = 1; 508 ret = 1;
509 device->fs_devices = fs_devices; 509 device->fs_devices = fs_devices;
510 } else if (!device->name || strcmp(device->name->str, path)) { 510 } else if (!device->name || strcmp(device->name->str, path)) {
511 /*
512 * When FS is already mounted.
513 * 1. If you are here and if the device->name is NULL that
514 * means this device was missing at time of FS mount.
515 * 2. If you are here and if the device->name is different
516 * from 'path' that means either
517 * a. The same device disappeared and reappeared with
518 * different name. or
519 * b. The missing-disk-which-was-replaced, has
520 * reappeared now.
521 *
522 * We must allow 1 and 2a above. But 2b would be a spurious
523 * and unintentional.
524 *
525 * Further in case of 1 and 2a above, the disk at 'path'
526 * would have missed some transaction when it was away and
527 * in case of 2a the stale bdev has to be updated as well.
528 * 2b must not be allowed at all time.
529 */
530
531 /*
532 * As of now don't allow update to btrfs_fs_device through
533 * the btrfs dev scan cli, after FS has been mounted.
534 */
535 if (fs_devices->opened) {
536 return -EBUSY;
537 } else {
538 /*
539 * That is if the FS is _not_ mounted and if you
540 * are here, that means there is more than one
541 * disk with same uuid and devid.We keep the one
542 * with larger generation number or the last-in if
543 * generation are equal.
544 */
545 if (found_transid < device->generation)
546 return -EEXIST;
547 }
548
511 name = rcu_string_strdup(path, GFP_NOFS); 549 name = rcu_string_strdup(path, GFP_NOFS);
512 if (!name) 550 if (!name)
513 return -ENOMEM; 551 return -ENOMEM;
@@ -519,6 +557,15 @@ static noinline int device_list_add(const char *path,
519 } 557 }
520 } 558 }
521 559
560 /*
561 * Unmount does not free the btrfs_device struct but would zero
562 * generation along with most of the other members. So just update
563 * it back. We need it to pick the disk with largest generation
564 * (as above).
565 */
566 if (!fs_devices->opened)
567 device->generation = found_transid;
568
522 if (found_transid > fs_devices->latest_trans) { 569 if (found_transid > fs_devices->latest_trans) {
523 fs_devices->latest_devid = devid; 570 fs_devices->latest_devid = devid;
524 fs_devices->latest_trans = found_transid; 571 fs_devices->latest_trans = found_transid;
@@ -1436,7 +1483,7 @@ static int btrfs_add_device(struct btrfs_trans_handle *trans,
1436 btrfs_set_device_io_align(leaf, dev_item, device->io_align); 1483 btrfs_set_device_io_align(leaf, dev_item, device->io_align);
1437 btrfs_set_device_io_width(leaf, dev_item, device->io_width); 1484 btrfs_set_device_io_width(leaf, dev_item, device->io_width);
1438 btrfs_set_device_sector_size(leaf, dev_item, device->sector_size); 1485 btrfs_set_device_sector_size(leaf, dev_item, device->sector_size);
1439 btrfs_set_device_total_bytes(leaf, dev_item, device->total_bytes); 1486 btrfs_set_device_total_bytes(leaf, dev_item, device->disk_total_bytes);
1440 btrfs_set_device_bytes_used(leaf, dev_item, device->bytes_used); 1487 btrfs_set_device_bytes_used(leaf, dev_item, device->bytes_used);
1441 btrfs_set_device_group(leaf, dev_item, 0); 1488 btrfs_set_device_group(leaf, dev_item, 0);
1442 btrfs_set_device_seek_speed(leaf, dev_item, 0); 1489 btrfs_set_device_seek_speed(leaf, dev_item, 0);
@@ -1671,7 +1718,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
1671 device->fs_devices->total_devices--; 1718 device->fs_devices->total_devices--;
1672 1719
1673 if (device->missing) 1720 if (device->missing)
1674 root->fs_info->fs_devices->missing_devices--; 1721 device->fs_devices->missing_devices--;
1675 1722
1676 next_device = list_entry(root->fs_info->fs_devices->devices.next, 1723 next_device = list_entry(root->fs_info->fs_devices->devices.next,
1677 struct btrfs_device, dev_list); 1724 struct btrfs_device, dev_list);
@@ -1801,8 +1848,12 @@ void btrfs_rm_dev_replace_srcdev(struct btrfs_fs_info *fs_info,
1801 if (srcdev->bdev) { 1848 if (srcdev->bdev) {
1802 fs_info->fs_devices->open_devices--; 1849 fs_info->fs_devices->open_devices--;
1803 1850
1804 /* zero out the old super */ 1851 /*
1805 btrfs_scratch_superblock(srcdev); 1852 * zero out the old super if it is not writable
1853 * (e.g. seed device)
1854 */
1855 if (srcdev->writeable)
1856 btrfs_scratch_superblock(srcdev);
1806 } 1857 }
1807 1858
1808 call_rcu(&srcdev->rcu, free_device); 1859 call_rcu(&srcdev->rcu, free_device);
@@ -1941,6 +1992,9 @@ static int btrfs_prepare_sprout(struct btrfs_root *root)
1941 fs_devices->seeding = 0; 1992 fs_devices->seeding = 0;
1942 fs_devices->num_devices = 0; 1993 fs_devices->num_devices = 0;
1943 fs_devices->open_devices = 0; 1994 fs_devices->open_devices = 0;
1995 fs_devices->missing_devices = 0;
1996 fs_devices->num_can_discard = 0;
1997 fs_devices->rotating = 0;
1944 fs_devices->seed = seed_devices; 1998 fs_devices->seed = seed_devices;
1945 1999
1946 generate_random_uuid(fs_devices->fsid); 2000 generate_random_uuid(fs_devices->fsid);
@@ -5800,7 +5854,8 @@ struct btrfs_device *btrfs_alloc_device(struct btrfs_fs_info *fs_info,
5800 else 5854 else
5801 generate_random_uuid(dev->uuid); 5855 generate_random_uuid(dev->uuid);
5802 5856
5803 btrfs_init_work(&dev->work, pending_bios_fn, NULL, NULL); 5857 btrfs_init_work(&dev->work, btrfs_submit_helper,
5858 pending_bios_fn, NULL, NULL);
5804 5859
5805 return dev; 5860 return dev;
5806} 5861}
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 5b19760b1de5..b0c225cdb52c 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1825,7 +1825,7 @@ ext4_group_first_block_no(struct super_block *sb, ext4_group_t group_no)
1825/* 1825/*
1826 * Special error return code only used by dx_probe() and its callers. 1826 * Special error return code only used by dx_probe() and its callers.
1827 */ 1827 */
1828#define ERR_BAD_DX_DIR -75000 1828#define ERR_BAD_DX_DIR (-(MAX_ERRNO - 1))
1829 1829
1830/* 1830/*
1831 * Timeout and state flag for lazy initialization inode thread. 1831 * Timeout and state flag for lazy initialization inode thread.
@@ -2454,6 +2454,22 @@ static inline void ext4_update_i_disksize(struct inode *inode, loff_t newsize)
2454 up_write(&EXT4_I(inode)->i_data_sem); 2454 up_write(&EXT4_I(inode)->i_data_sem);
2455} 2455}
2456 2456
2457/* Update i_size, i_disksize. Requires i_mutex to avoid races with truncate */
2458static inline int ext4_update_inode_size(struct inode *inode, loff_t newsize)
2459{
2460 int changed = 0;
2461
2462 if (newsize > inode->i_size) {
2463 i_size_write(inode, newsize);
2464 changed = 1;
2465 }
2466 if (newsize > EXT4_I(inode)->i_disksize) {
2467 ext4_update_i_disksize(inode, newsize);
2468 changed |= 2;
2469 }
2470 return changed;
2471}
2472
2457struct ext4_group_info { 2473struct ext4_group_info {
2458 unsigned long bb_state; 2474 unsigned long bb_state;
2459 struct rb_root bb_free_root; 2475 struct rb_root bb_free_root;
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 76c2df382b7d..74292a71b384 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4665,7 +4665,8 @@ retry:
4665} 4665}
4666 4666
4667static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset, 4667static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset,
4668 ext4_lblk_t len, int flags, int mode) 4668 ext4_lblk_t len, loff_t new_size,
4669 int flags, int mode)
4669{ 4670{
4670 struct inode *inode = file_inode(file); 4671 struct inode *inode = file_inode(file);
4671 handle_t *handle; 4672 handle_t *handle;
@@ -4674,8 +4675,10 @@ static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset,
4674 int retries = 0; 4675 int retries = 0;
4675 struct ext4_map_blocks map; 4676 struct ext4_map_blocks map;
4676 unsigned int credits; 4677 unsigned int credits;
4678 loff_t epos;
4677 4679
4678 map.m_lblk = offset; 4680 map.m_lblk = offset;
4681 map.m_len = len;
4679 /* 4682 /*
4680 * Don't normalize the request if it can fit in one extent so 4683 * Don't normalize the request if it can fit in one extent so
4681 * that it doesn't get unnecessarily split into multiple 4684 * that it doesn't get unnecessarily split into multiple
@@ -4690,9 +4693,7 @@ static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset,
4690 credits = ext4_chunk_trans_blocks(inode, len); 4693 credits = ext4_chunk_trans_blocks(inode, len);
4691 4694
4692retry: 4695retry:
4693 while (ret >= 0 && ret < len) { 4696 while (ret >= 0 && len) {
4694 map.m_lblk = map.m_lblk + ret;
4695 map.m_len = len = len - ret;
4696 handle = ext4_journal_start(inode, EXT4_HT_MAP_BLOCKS, 4697 handle = ext4_journal_start(inode, EXT4_HT_MAP_BLOCKS,
4697 credits); 4698 credits);
4698 if (IS_ERR(handle)) { 4699 if (IS_ERR(handle)) {
@@ -4709,6 +4710,21 @@ retry:
4709 ret2 = ext4_journal_stop(handle); 4710 ret2 = ext4_journal_stop(handle);
4710 break; 4711 break;
4711 } 4712 }
4713 map.m_lblk += ret;
4714 map.m_len = len = len - ret;
4715 epos = (loff_t)map.m_lblk << inode->i_blkbits;
4716 inode->i_ctime = ext4_current_time(inode);
4717 if (new_size) {
4718 if (epos > new_size)
4719 epos = new_size;
4720 if (ext4_update_inode_size(inode, epos) & 0x1)
4721 inode->i_mtime = inode->i_ctime;
4722 } else {
4723 if (epos > inode->i_size)
4724 ext4_set_inode_flag(inode,
4725 EXT4_INODE_EOFBLOCKS);
4726 }
4727 ext4_mark_inode_dirty(handle, inode);
4712 ret2 = ext4_journal_stop(handle); 4728 ret2 = ext4_journal_stop(handle);
4713 if (ret2) 4729 if (ret2)
4714 break; 4730 break;
@@ -4731,7 +4747,8 @@ static long ext4_zero_range(struct file *file, loff_t offset,
4731 loff_t new_size = 0; 4747 loff_t new_size = 0;
4732 int ret = 0; 4748 int ret = 0;
4733 int flags; 4749 int flags;
4734 int partial; 4750 int credits;
4751 int partial_begin, partial_end;
4735 loff_t start, end; 4752 loff_t start, end;
4736 ext4_lblk_t lblk; 4753 ext4_lblk_t lblk;
4737 struct address_space *mapping = inode->i_mapping; 4754 struct address_space *mapping = inode->i_mapping;
@@ -4771,7 +4788,8 @@ static long ext4_zero_range(struct file *file, loff_t offset,
4771 4788
4772 if (start < offset || end > offset + len) 4789 if (start < offset || end > offset + len)
4773 return -EINVAL; 4790 return -EINVAL;
4774 partial = (offset + len) & ((1 << blkbits) - 1); 4791 partial_begin = offset & ((1 << blkbits) - 1);
4792 partial_end = (offset + len) & ((1 << blkbits) - 1);
4775 4793
4776 lblk = start >> blkbits; 4794 lblk = start >> blkbits;
4777 max_blocks = (end >> blkbits); 4795 max_blocks = (end >> blkbits);
@@ -4805,7 +4823,7 @@ static long ext4_zero_range(struct file *file, loff_t offset,
4805 * If we have a partial block after EOF we have to allocate 4823 * If we have a partial block after EOF we have to allocate
4806 * the entire block. 4824 * the entire block.
4807 */ 4825 */
4808 if (partial) 4826 if (partial_end)
4809 max_blocks += 1; 4827 max_blocks += 1;
4810 } 4828 }
4811 4829
@@ -4813,6 +4831,7 @@ static long ext4_zero_range(struct file *file, loff_t offset,
4813 4831
4814 /* Now release the pages and zero block aligned part of pages*/ 4832 /* Now release the pages and zero block aligned part of pages*/
4815 truncate_pagecache_range(inode, start, end - 1); 4833 truncate_pagecache_range(inode, start, end - 1);
4834 inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
4816 4835
4817 /* Wait all existing dio workers, newcomers will block on i_mutex */ 4836 /* Wait all existing dio workers, newcomers will block on i_mutex */
4818 ext4_inode_block_unlocked_dio(inode); 4837 ext4_inode_block_unlocked_dio(inode);
@@ -4825,13 +4844,22 @@ static long ext4_zero_range(struct file *file, loff_t offset,
4825 if (ret) 4844 if (ret)
4826 goto out_dio; 4845 goto out_dio;
4827 4846
4828 ret = ext4_alloc_file_blocks(file, lblk, max_blocks, flags, 4847 ret = ext4_alloc_file_blocks(file, lblk, max_blocks, new_size,
4829 mode); 4848 flags, mode);
4830 if (ret) 4849 if (ret)
4831 goto out_dio; 4850 goto out_dio;
4832 } 4851 }
4852 if (!partial_begin && !partial_end)
4853 goto out_dio;
4833 4854
4834 handle = ext4_journal_start(inode, EXT4_HT_MISC, 4); 4855 /*
4856 * In worst case we have to writeout two nonadjacent unwritten
4857 * blocks and update the inode
4858 */
4859 credits = (2 * ext4_ext_index_trans_blocks(inode, 2)) + 1;
4860 if (ext4_should_journal_data(inode))
4861 credits += 2;
4862 handle = ext4_journal_start(inode, EXT4_HT_MISC, credits);
4835 if (IS_ERR(handle)) { 4863 if (IS_ERR(handle)) {
4836 ret = PTR_ERR(handle); 4864 ret = PTR_ERR(handle);
4837 ext4_std_error(inode->i_sb, ret); 4865 ext4_std_error(inode->i_sb, ret);
@@ -4839,12 +4867,8 @@ static long ext4_zero_range(struct file *file, loff_t offset,
4839 } 4867 }
4840 4868
4841 inode->i_mtime = inode->i_ctime = ext4_current_time(inode); 4869 inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
4842
4843 if (new_size) { 4870 if (new_size) {
4844 if (new_size > i_size_read(inode)) 4871 ext4_update_inode_size(inode, new_size);
4845 i_size_write(inode, new_size);
4846 if (new_size > EXT4_I(inode)->i_disksize)
4847 ext4_update_i_disksize(inode, new_size);
4848 } else { 4872 } else {
4849 /* 4873 /*
4850 * Mark that we allocate beyond EOF so the subsequent truncate 4874 * Mark that we allocate beyond EOF so the subsequent truncate
@@ -4853,7 +4877,6 @@ static long ext4_zero_range(struct file *file, loff_t offset,
4853 if ((offset + len) > i_size_read(inode)) 4877 if ((offset + len) > i_size_read(inode))
4854 ext4_set_inode_flag(inode, EXT4_INODE_EOFBLOCKS); 4878 ext4_set_inode_flag(inode, EXT4_INODE_EOFBLOCKS);
4855 } 4879 }
4856
4857 ext4_mark_inode_dirty(handle, inode); 4880 ext4_mark_inode_dirty(handle, inode);
4858 4881
4859 /* Zero out partial block at the edges of the range */ 4882 /* Zero out partial block at the edges of the range */
@@ -4880,13 +4903,11 @@ out_mutex:
4880long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len) 4903long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
4881{ 4904{
4882 struct inode *inode = file_inode(file); 4905 struct inode *inode = file_inode(file);
4883 handle_t *handle;
4884 loff_t new_size = 0; 4906 loff_t new_size = 0;
4885 unsigned int max_blocks; 4907 unsigned int max_blocks;
4886 int ret = 0; 4908 int ret = 0;
4887 int flags; 4909 int flags;
4888 ext4_lblk_t lblk; 4910 ext4_lblk_t lblk;
4889 struct timespec tv;
4890 unsigned int blkbits = inode->i_blkbits; 4911 unsigned int blkbits = inode->i_blkbits;
4891 4912
4892 /* Return error if mode is not supported */ 4913 /* Return error if mode is not supported */
@@ -4937,36 +4958,15 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
4937 goto out; 4958 goto out;
4938 } 4959 }
4939 4960
4940 ret = ext4_alloc_file_blocks(file, lblk, max_blocks, flags, mode); 4961 ret = ext4_alloc_file_blocks(file, lblk, max_blocks, new_size,
4962 flags, mode);
4941 if (ret) 4963 if (ret)
4942 goto out; 4964 goto out;
4943 4965
4944 handle = ext4_journal_start(inode, EXT4_HT_INODE, 2); 4966 if (file->f_flags & O_SYNC && EXT4_SB(inode->i_sb)->s_journal) {
4945 if (IS_ERR(handle)) 4967 ret = jbd2_complete_transaction(EXT4_SB(inode->i_sb)->s_journal,
4946 goto out; 4968 EXT4_I(inode)->i_sync_tid);
4947
4948 tv = inode->i_ctime = ext4_current_time(inode);
4949
4950 if (new_size) {
4951 if (new_size > i_size_read(inode)) {
4952 i_size_write(inode, new_size);
4953 inode->i_mtime = tv;
4954 }
4955 if (new_size > EXT4_I(inode)->i_disksize)
4956 ext4_update_i_disksize(inode, new_size);
4957 } else {
4958 /*
4959 * Mark that we allocate beyond EOF so the subsequent truncate
4960 * can proceed even if the new size is the same as i_size.
4961 */
4962 if ((offset + len) > i_size_read(inode))
4963 ext4_set_inode_flag(inode, EXT4_INODE_EOFBLOCKS);
4964 } 4969 }
4965 ext4_mark_inode_dirty(handle, inode);
4966 if (file->f_flags & O_SYNC)
4967 ext4_handle_sync(handle);
4968
4969 ext4_journal_stop(handle);
4970out: 4970out:
4971 mutex_unlock(&inode->i_mutex); 4971 mutex_unlock(&inode->i_mutex);
4972 trace_ext4_fallocate_exit(inode, offset, max_blocks, ret); 4972 trace_ext4_fallocate_exit(inode, offset, max_blocks, ret);
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 367a60c07cf0..3aa26e9117c4 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1055,27 +1055,11 @@ static int ext4_write_end(struct file *file,
1055 } else 1055 } else
1056 copied = block_write_end(file, mapping, pos, 1056 copied = block_write_end(file, mapping, pos,
1057 len, copied, page, fsdata); 1057 len, copied, page, fsdata);
1058
1059 /* 1058 /*
1060 * No need to use i_size_read() here, the i_size 1059 * it's important to update i_size while still holding page lock:
1061 * cannot change under us because we hole i_mutex.
1062 *
1063 * But it's important to update i_size while still holding page lock:
1064 * page writeout could otherwise come in and zero beyond i_size. 1060 * page writeout could otherwise come in and zero beyond i_size.
1065 */ 1061 */
1066 if (pos + copied > inode->i_size) { 1062 i_size_changed = ext4_update_inode_size(inode, pos + copied);
1067 i_size_write(inode, pos + copied);
1068 i_size_changed = 1;
1069 }
1070
1071 if (pos + copied > EXT4_I(inode)->i_disksize) {
1072 /* We need to mark inode dirty even if
1073 * new_i_size is less that inode->i_size
1074 * but greater than i_disksize. (hint delalloc)
1075 */
1076 ext4_update_i_disksize(inode, (pos + copied));
1077 i_size_changed = 1;
1078 }
1079 unlock_page(page); 1063 unlock_page(page);
1080 page_cache_release(page); 1064 page_cache_release(page);
1081 1065
@@ -1123,7 +1107,7 @@ static int ext4_journalled_write_end(struct file *file,
1123 int ret = 0, ret2; 1107 int ret = 0, ret2;
1124 int partial = 0; 1108 int partial = 0;
1125 unsigned from, to; 1109 unsigned from, to;
1126 loff_t new_i_size; 1110 int size_changed = 0;
1127 1111
1128 trace_ext4_journalled_write_end(inode, pos, len, copied); 1112 trace_ext4_journalled_write_end(inode, pos, len, copied);
1129 from = pos & (PAGE_CACHE_SIZE - 1); 1113 from = pos & (PAGE_CACHE_SIZE - 1);
@@ -1146,20 +1130,18 @@ static int ext4_journalled_write_end(struct file *file,
1146 if (!partial) 1130 if (!partial)
1147 SetPageUptodate(page); 1131 SetPageUptodate(page);
1148 } 1132 }
1149 new_i_size = pos + copied; 1133 size_changed = ext4_update_inode_size(inode, pos + copied);
1150 if (new_i_size > inode->i_size)
1151 i_size_write(inode, pos+copied);
1152 ext4_set_inode_state(inode, EXT4_STATE_JDATA); 1134 ext4_set_inode_state(inode, EXT4_STATE_JDATA);
1153 EXT4_I(inode)->i_datasync_tid = handle->h_transaction->t_tid; 1135 EXT4_I(inode)->i_datasync_tid = handle->h_transaction->t_tid;
1154 if (new_i_size > EXT4_I(inode)->i_disksize) { 1136 unlock_page(page);
1155 ext4_update_i_disksize(inode, new_i_size); 1137 page_cache_release(page);
1138
1139 if (size_changed) {
1156 ret2 = ext4_mark_inode_dirty(handle, inode); 1140 ret2 = ext4_mark_inode_dirty(handle, inode);
1157 if (!ret) 1141 if (!ret)
1158 ret = ret2; 1142 ret = ret2;
1159 } 1143 }
1160 1144
1161 unlock_page(page);
1162 page_cache_release(page);
1163 if (pos + len > inode->i_size && ext4_can_truncate(inode)) 1145 if (pos + len > inode->i_size && ext4_can_truncate(inode))
1164 /* if we have allocated more blocks and copied 1146 /* if we have allocated more blocks and copied
1165 * less. We will have blocks allocated outside 1147 * less. We will have blocks allocated outside
@@ -2095,6 +2077,7 @@ static int mpage_map_and_submit_extent(handle_t *handle,
2095 struct ext4_map_blocks *map = &mpd->map; 2077 struct ext4_map_blocks *map = &mpd->map;
2096 int err; 2078 int err;
2097 loff_t disksize; 2079 loff_t disksize;
2080 int progress = 0;
2098 2081
2099 mpd->io_submit.io_end->offset = 2082 mpd->io_submit.io_end->offset =
2100 ((loff_t)map->m_lblk) << inode->i_blkbits; 2083 ((loff_t)map->m_lblk) << inode->i_blkbits;
@@ -2111,8 +2094,11 @@ static int mpage_map_and_submit_extent(handle_t *handle,
2111 * is non-zero, a commit should free up blocks. 2094 * is non-zero, a commit should free up blocks.
2112 */ 2095 */
2113 if ((err == -ENOMEM) || 2096 if ((err == -ENOMEM) ||
2114 (err == -ENOSPC && ext4_count_free_clusters(sb))) 2097 (err == -ENOSPC && ext4_count_free_clusters(sb))) {
2098 if (progress)
2099 goto update_disksize;
2115 return err; 2100 return err;
2101 }
2116 ext4_msg(sb, KERN_CRIT, 2102 ext4_msg(sb, KERN_CRIT,
2117 "Delayed block allocation failed for " 2103 "Delayed block allocation failed for "
2118 "inode %lu at logical offset %llu with" 2104 "inode %lu at logical offset %llu with"
@@ -2129,15 +2115,17 @@ static int mpage_map_and_submit_extent(handle_t *handle,
2129 *give_up_on_write = true; 2115 *give_up_on_write = true;
2130 return err; 2116 return err;
2131 } 2117 }
2118 progress = 1;
2132 /* 2119 /*
2133 * Update buffer state, submit mapped pages, and get us new 2120 * Update buffer state, submit mapped pages, and get us new
2134 * extent to map 2121 * extent to map
2135 */ 2122 */
2136 err = mpage_map_and_submit_buffers(mpd); 2123 err = mpage_map_and_submit_buffers(mpd);
2137 if (err < 0) 2124 if (err < 0)
2138 return err; 2125 goto update_disksize;
2139 } while (map->m_len); 2126 } while (map->m_len);
2140 2127
2128update_disksize:
2141 /* 2129 /*
2142 * Update on-disk size after IO is submitted. Races with 2130 * Update on-disk size after IO is submitted. Races with
2143 * truncate are avoided by checking i_size under i_data_sem. 2131 * truncate are avoided by checking i_size under i_data_sem.
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 956027711faf..8b0f9ef517d6 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -1412,6 +1412,8 @@ static void mb_free_blocks(struct inode *inode, struct ext4_buddy *e4b,
1412 int last = first + count - 1; 1412 int last = first + count - 1;
1413 struct super_block *sb = e4b->bd_sb; 1413 struct super_block *sb = e4b->bd_sb;
1414 1414
1415 if (WARN_ON(count == 0))
1416 return;
1415 BUG_ON(last >= (sb->s_blocksize << 3)); 1417 BUG_ON(last >= (sb->s_blocksize << 3));
1416 assert_spin_locked(ext4_group_lock_ptr(sb, e4b->bd_group)); 1418 assert_spin_locked(ext4_group_lock_ptr(sb, e4b->bd_group));
1417 /* Don't bother if the block group is corrupt. */ 1419 /* Don't bother if the block group is corrupt. */
@@ -3221,6 +3223,8 @@ static void ext4_discard_allocated_blocks(struct ext4_allocation_context *ac)
3221 int err; 3223 int err;
3222 3224
3223 if (pa == NULL) { 3225 if (pa == NULL) {
3226 if (ac->ac_f_ex.fe_len == 0)
3227 return;
3224 err = ext4_mb_load_buddy(ac->ac_sb, ac->ac_f_ex.fe_group, &e4b); 3228 err = ext4_mb_load_buddy(ac->ac_sb, ac->ac_f_ex.fe_group, &e4b);
3225 if (err) { 3229 if (err) {
3226 /* 3230 /*
@@ -3235,6 +3239,7 @@ static void ext4_discard_allocated_blocks(struct ext4_allocation_context *ac)
3235 mb_free_blocks(ac->ac_inode, &e4b, ac->ac_f_ex.fe_start, 3239 mb_free_blocks(ac->ac_inode, &e4b, ac->ac_f_ex.fe_start,
3236 ac->ac_f_ex.fe_len); 3240 ac->ac_f_ex.fe_len);
3237 ext4_unlock_group(ac->ac_sb, ac->ac_f_ex.fe_group); 3241 ext4_unlock_group(ac->ac_sb, ac->ac_f_ex.fe_group);
3242 ext4_mb_unload_buddy(&e4b);
3238 return; 3243 return;
3239 } 3244 }
3240 if (pa->pa_type == MB_INODE_PA) 3245 if (pa->pa_type == MB_INODE_PA)
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index b147a67baa0d..90a3cdca3f88 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -1227,7 +1227,7 @@ static struct buffer_head * ext4_find_entry (struct inode *dir,
1227 buffer */ 1227 buffer */
1228 int num = 0; 1228 int num = 0;
1229 ext4_lblk_t nblocks; 1229 ext4_lblk_t nblocks;
1230 int i, err; 1230 int i, err = 0;
1231 int namelen; 1231 int namelen;
1232 1232
1233 *res_dir = NULL; 1233 *res_dir = NULL;
@@ -1264,7 +1264,11 @@ static struct buffer_head * ext4_find_entry (struct inode *dir,
1264 * return. Otherwise, fall back to doing a search the 1264 * return. Otherwise, fall back to doing a search the
1265 * old fashioned way. 1265 * old fashioned way.
1266 */ 1266 */
1267 if (bh || (err != ERR_BAD_DX_DIR)) 1267 if (err == -ENOENT)
1268 return NULL;
1269 if (err && err != ERR_BAD_DX_DIR)
1270 return ERR_PTR(err);
1271 if (bh)
1268 return bh; 1272 return bh;
1269 dxtrace(printk(KERN_DEBUG "ext4_find_entry: dx failed, " 1273 dxtrace(printk(KERN_DEBUG "ext4_find_entry: dx failed, "
1270 "falling back\n")); 1274 "falling back\n"));
@@ -1295,6 +1299,11 @@ restart:
1295 } 1299 }
1296 num++; 1300 num++;
1297 bh = ext4_getblk(NULL, dir, b++, 0, &err); 1301 bh = ext4_getblk(NULL, dir, b++, 0, &err);
1302 if (unlikely(err)) {
1303 if (ra_max == 0)
1304 return ERR_PTR(err);
1305 break;
1306 }
1298 bh_use[ra_max] = bh; 1307 bh_use[ra_max] = bh;
1299 if (bh) 1308 if (bh)
1300 ll_rw_block(READ | REQ_META | REQ_PRIO, 1309 ll_rw_block(READ | REQ_META | REQ_PRIO,
@@ -1417,6 +1426,8 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi
1417 return ERR_PTR(-ENAMETOOLONG); 1426 return ERR_PTR(-ENAMETOOLONG);
1418 1427
1419 bh = ext4_find_entry(dir, &dentry->d_name, &de, NULL); 1428 bh = ext4_find_entry(dir, &dentry->d_name, &de, NULL);
1429 if (IS_ERR(bh))
1430 return (struct dentry *) bh;
1420 inode = NULL; 1431 inode = NULL;
1421 if (bh) { 1432 if (bh) {
1422 __u32 ino = le32_to_cpu(de->inode); 1433 __u32 ino = le32_to_cpu(de->inode);
@@ -1450,6 +1461,8 @@ struct dentry *ext4_get_parent(struct dentry *child)
1450 struct buffer_head *bh; 1461 struct buffer_head *bh;
1451 1462
1452 bh = ext4_find_entry(child->d_inode, &dotdot, &de, NULL); 1463 bh = ext4_find_entry(child->d_inode, &dotdot, &de, NULL);
1464 if (IS_ERR(bh))
1465 return (struct dentry *) bh;
1453 if (!bh) 1466 if (!bh)
1454 return ERR_PTR(-ENOENT); 1467 return ERR_PTR(-ENOENT);
1455 ino = le32_to_cpu(de->inode); 1468 ino = le32_to_cpu(de->inode);
@@ -2727,6 +2740,8 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)
2727 2740
2728 retval = -ENOENT; 2741 retval = -ENOENT;
2729 bh = ext4_find_entry(dir, &dentry->d_name, &de, NULL); 2742 bh = ext4_find_entry(dir, &dentry->d_name, &de, NULL);
2743 if (IS_ERR(bh))
2744 return PTR_ERR(bh);
2730 if (!bh) 2745 if (!bh)
2731 goto end_rmdir; 2746 goto end_rmdir;
2732 2747
@@ -2794,6 +2809,8 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry)
2794 2809
2795 retval = -ENOENT; 2810 retval = -ENOENT;
2796 bh = ext4_find_entry(dir, &dentry->d_name, &de, NULL); 2811 bh = ext4_find_entry(dir, &dentry->d_name, &de, NULL);
2812 if (IS_ERR(bh))
2813 return PTR_ERR(bh);
2797 if (!bh) 2814 if (!bh)
2798 goto end_unlink; 2815 goto end_unlink;
2799 2816
@@ -3121,6 +3138,8 @@ static int ext4_find_delete_entry(handle_t *handle, struct inode *dir,
3121 struct ext4_dir_entry_2 *de; 3138 struct ext4_dir_entry_2 *de;
3122 3139
3123 bh = ext4_find_entry(dir, d_name, &de, NULL); 3140 bh = ext4_find_entry(dir, d_name, &de, NULL);
3141 if (IS_ERR(bh))
3142 return PTR_ERR(bh);
3124 if (bh) { 3143 if (bh) {
3125 retval = ext4_delete_entry(handle, dir, de, bh); 3144 retval = ext4_delete_entry(handle, dir, de, bh);
3126 brelse(bh); 3145 brelse(bh);
@@ -3128,7 +3147,8 @@ static int ext4_find_delete_entry(handle_t *handle, struct inode *dir,
3128 return retval; 3147 return retval;
3129} 3148}
3130 3149
3131static void ext4_rename_delete(handle_t *handle, struct ext4_renament *ent) 3150static void ext4_rename_delete(handle_t *handle, struct ext4_renament *ent,
3151 int force_reread)
3132{ 3152{
3133 int retval; 3153 int retval;
3134 /* 3154 /*
@@ -3140,7 +3160,8 @@ static void ext4_rename_delete(handle_t *handle, struct ext4_renament *ent)
3140 if (le32_to_cpu(ent->de->inode) != ent->inode->i_ino || 3160 if (le32_to_cpu(ent->de->inode) != ent->inode->i_ino ||
3141 ent->de->name_len != ent->dentry->d_name.len || 3161 ent->de->name_len != ent->dentry->d_name.len ||
3142 strncmp(ent->de->name, ent->dentry->d_name.name, 3162 strncmp(ent->de->name, ent->dentry->d_name.name,
3143 ent->de->name_len)) { 3163 ent->de->name_len) ||
3164 force_reread) {
3144 retval = ext4_find_delete_entry(handle, ent->dir, 3165 retval = ext4_find_delete_entry(handle, ent->dir,
3145 &ent->dentry->d_name); 3166 &ent->dentry->d_name);
3146 } else { 3167 } else {
@@ -3191,6 +3212,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
3191 .dentry = new_dentry, 3212 .dentry = new_dentry,
3192 .inode = new_dentry->d_inode, 3213 .inode = new_dentry->d_inode,
3193 }; 3214 };
3215 int force_reread;
3194 int retval; 3216 int retval;
3195 3217
3196 dquot_initialize(old.dir); 3218 dquot_initialize(old.dir);
@@ -3202,6 +3224,8 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
3202 dquot_initialize(new.inode); 3224 dquot_initialize(new.inode);
3203 3225
3204 old.bh = ext4_find_entry(old.dir, &old.dentry->d_name, &old.de, NULL); 3226 old.bh = ext4_find_entry(old.dir, &old.dentry->d_name, &old.de, NULL);
3227 if (IS_ERR(old.bh))
3228 return PTR_ERR(old.bh);
3205 /* 3229 /*
3206 * Check for inode number is _not_ due to possible IO errors. 3230 * Check for inode number is _not_ due to possible IO errors.
3207 * We might rmdir the source, keep it as pwd of some process 3231 * We might rmdir the source, keep it as pwd of some process
@@ -3214,6 +3238,10 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
3214 3238
3215 new.bh = ext4_find_entry(new.dir, &new.dentry->d_name, 3239 new.bh = ext4_find_entry(new.dir, &new.dentry->d_name,
3216 &new.de, &new.inlined); 3240 &new.de, &new.inlined);
3241 if (IS_ERR(new.bh)) {
3242 retval = PTR_ERR(new.bh);
3243 goto end_rename;
3244 }
3217 if (new.bh) { 3245 if (new.bh) {
3218 if (!new.inode) { 3246 if (!new.inode) {
3219 brelse(new.bh); 3247 brelse(new.bh);
@@ -3246,6 +3274,15 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
3246 if (retval) 3274 if (retval)
3247 goto end_rename; 3275 goto end_rename;
3248 } 3276 }
3277 /*
3278 * If we're renaming a file within an inline_data dir and adding or
3279 * setting the new dirent causes a conversion from inline_data to
3280 * extents/blockmap, we need to force the dirent delete code to
3281 * re-read the directory, or else we end up trying to delete a dirent
3282 * from what is now the extent tree root (or a block map).
3283 */
3284 force_reread = (new.dir->i_ino == old.dir->i_ino &&
3285 ext4_test_inode_flag(new.dir, EXT4_INODE_INLINE_DATA));
3249 if (!new.bh) { 3286 if (!new.bh) {
3250 retval = ext4_add_entry(handle, new.dentry, old.inode); 3287 retval = ext4_add_entry(handle, new.dentry, old.inode);
3251 if (retval) 3288 if (retval)
@@ -3256,6 +3293,9 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
3256 if (retval) 3293 if (retval)
3257 goto end_rename; 3294 goto end_rename;
3258 } 3295 }
3296 if (force_reread)
3297 force_reread = !ext4_test_inode_flag(new.dir,
3298 EXT4_INODE_INLINE_DATA);
3259 3299
3260 /* 3300 /*
3261 * Like most other Unix systems, set the ctime for inodes on a 3301 * Like most other Unix systems, set the ctime for inodes on a
@@ -3267,7 +3307,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
3267 /* 3307 /*
3268 * ok, that's it 3308 * ok, that's it
3269 */ 3309 */
3270 ext4_rename_delete(handle, &old); 3310 ext4_rename_delete(handle, &old, force_reread);
3271 3311
3272 if (new.inode) { 3312 if (new.inode) {
3273 ext4_dec_count(handle, new.inode); 3313 ext4_dec_count(handle, new.inode);
@@ -3330,6 +3370,8 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
3330 3370
3331 old.bh = ext4_find_entry(old.dir, &old.dentry->d_name, 3371 old.bh = ext4_find_entry(old.dir, &old.dentry->d_name,
3332 &old.de, &old.inlined); 3372 &old.de, &old.inlined);
3373 if (IS_ERR(old.bh))
3374 return PTR_ERR(old.bh);
3333 /* 3375 /*
3334 * Check for inode number is _not_ due to possible IO errors. 3376 * Check for inode number is _not_ due to possible IO errors.
3335 * We might rmdir the source, keep it as pwd of some process 3377 * We might rmdir the source, keep it as pwd of some process
@@ -3342,6 +3384,10 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
3342 3384
3343 new.bh = ext4_find_entry(new.dir, &new.dentry->d_name, 3385 new.bh = ext4_find_entry(new.dir, &new.dentry->d_name,
3344 &new.de, &new.inlined); 3386 &new.de, &new.inlined);
3387 if (IS_ERR(new.bh)) {
3388 retval = PTR_ERR(new.bh);
3389 goto end_rename;
3390 }
3345 3391
3346 /* RENAME_EXCHANGE case: old *and* new must both exist */ 3392 /* RENAME_EXCHANGE case: old *and* new must both exist */
3347 if (!new.bh || le32_to_cpu(new.de->inode) != new.inode->i_ino) 3393 if (!new.bh || le32_to_cpu(new.de->inode) != new.inode->i_ino)
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 32b43ad154b9..0b28b36e7915 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3181,9 +3181,9 @@ static int set_journal_csum_feature_set(struct super_block *sb)
3181 3181
3182 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, 3182 if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
3183 EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) { 3183 EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
3184 /* journal checksum v2 */ 3184 /* journal checksum v3 */
3185 compat = 0; 3185 compat = 0;
3186 incompat = JBD2_FEATURE_INCOMPAT_CSUM_V2; 3186 incompat = JBD2_FEATURE_INCOMPAT_CSUM_V3;
3187 } else { 3187 } else {
3188 /* journal checksum v1 */ 3188 /* journal checksum v1 */
3189 compat = JBD2_FEATURE_COMPAT_CHECKSUM; 3189 compat = JBD2_FEATURE_COMPAT_CHECKSUM;
@@ -3205,6 +3205,7 @@ static int set_journal_csum_feature_set(struct super_block *sb)
3205 jbd2_journal_clear_features(sbi->s_journal, 3205 jbd2_journal_clear_features(sbi->s_journal,
3206 JBD2_FEATURE_COMPAT_CHECKSUM, 0, 3206 JBD2_FEATURE_COMPAT_CHECKSUM, 0,
3207 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT | 3207 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT |
3208 JBD2_FEATURE_INCOMPAT_CSUM_V3 |
3208 JBD2_FEATURE_INCOMPAT_CSUM_V2); 3209 JBD2_FEATURE_INCOMPAT_CSUM_V2);
3209 } 3210 }
3210 3211
diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
index 6fac74349856..b73e0215baa7 100644
--- a/fs/jbd2/commit.c
+++ b/fs/jbd2/commit.c
@@ -97,7 +97,7 @@ static void jbd2_commit_block_csum_set(journal_t *j, struct buffer_head *bh)
97 struct commit_header *h; 97 struct commit_header *h;
98 __u32 csum; 98 __u32 csum;
99 99
100 if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 100 if (!jbd2_journal_has_csum_v2or3(j))
101 return; 101 return;
102 102
103 h = (struct commit_header *)(bh->b_data); 103 h = (struct commit_header *)(bh->b_data);
@@ -313,11 +313,11 @@ static __u32 jbd2_checksum_data(__u32 crc32_sum, struct buffer_head *bh)
313 return checksum; 313 return checksum;
314} 314}
315 315
316static void write_tag_block(int tag_bytes, journal_block_tag_t *tag, 316static void write_tag_block(journal_t *j, journal_block_tag_t *tag,
317 unsigned long long block) 317 unsigned long long block)
318{ 318{
319 tag->t_blocknr = cpu_to_be32(block & (u32)~0); 319 tag->t_blocknr = cpu_to_be32(block & (u32)~0);
320 if (tag_bytes > JBD2_TAG_SIZE32) 320 if (JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_64BIT))
321 tag->t_blocknr_high = cpu_to_be32((block >> 31) >> 1); 321 tag->t_blocknr_high = cpu_to_be32((block >> 31) >> 1);
322} 322}
323 323
@@ -327,7 +327,7 @@ static void jbd2_descr_block_csum_set(journal_t *j,
327 struct jbd2_journal_block_tail *tail; 327 struct jbd2_journal_block_tail *tail;
328 __u32 csum; 328 __u32 csum;
329 329
330 if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 330 if (!jbd2_journal_has_csum_v2or3(j))
331 return; 331 return;
332 332
333 tail = (struct jbd2_journal_block_tail *)(bh->b_data + j->j_blocksize - 333 tail = (struct jbd2_journal_block_tail *)(bh->b_data + j->j_blocksize -
@@ -340,12 +340,13 @@ static void jbd2_descr_block_csum_set(journal_t *j,
340static void jbd2_block_tag_csum_set(journal_t *j, journal_block_tag_t *tag, 340static void jbd2_block_tag_csum_set(journal_t *j, journal_block_tag_t *tag,
341 struct buffer_head *bh, __u32 sequence) 341 struct buffer_head *bh, __u32 sequence)
342{ 342{
343 journal_block_tag3_t *tag3 = (journal_block_tag3_t *)tag;
343 struct page *page = bh->b_page; 344 struct page *page = bh->b_page;
344 __u8 *addr; 345 __u8 *addr;
345 __u32 csum32; 346 __u32 csum32;
346 __be32 seq; 347 __be32 seq;
347 348
348 if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 349 if (!jbd2_journal_has_csum_v2or3(j))
349 return; 350 return;
350 351
351 seq = cpu_to_be32(sequence); 352 seq = cpu_to_be32(sequence);
@@ -355,8 +356,10 @@ static void jbd2_block_tag_csum_set(journal_t *j, journal_block_tag_t *tag,
355 bh->b_size); 356 bh->b_size);
356 kunmap_atomic(addr); 357 kunmap_atomic(addr);
357 358
358 /* We only have space to store the lower 16 bits of the crc32c. */ 359 if (JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V3))
359 tag->t_checksum = cpu_to_be16(csum32); 360 tag3->t_checksum = cpu_to_be32(csum32);
361 else
362 tag->t_checksum = cpu_to_be16(csum32);
360} 363}
361/* 364/*
362 * jbd2_journal_commit_transaction 365 * jbd2_journal_commit_transaction
@@ -396,7 +399,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
396 LIST_HEAD(io_bufs); 399 LIST_HEAD(io_bufs);
397 LIST_HEAD(log_bufs); 400 LIST_HEAD(log_bufs);
398 401
399 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 402 if (jbd2_journal_has_csum_v2or3(journal))
400 csum_size = sizeof(struct jbd2_journal_block_tail); 403 csum_size = sizeof(struct jbd2_journal_block_tail);
401 404
402 /* 405 /*
@@ -690,7 +693,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
690 tag_flag |= JBD2_FLAG_SAME_UUID; 693 tag_flag |= JBD2_FLAG_SAME_UUID;
691 694
692 tag = (journal_block_tag_t *) tagp; 695 tag = (journal_block_tag_t *) tagp;
693 write_tag_block(tag_bytes, tag, jh2bh(jh)->b_blocknr); 696 write_tag_block(journal, tag, jh2bh(jh)->b_blocknr);
694 tag->t_flags = cpu_to_be16(tag_flag); 697 tag->t_flags = cpu_to_be16(tag_flag);
695 jbd2_block_tag_csum_set(journal, tag, wbuf[bufs], 698 jbd2_block_tag_csum_set(journal, tag, wbuf[bufs],
696 commit_transaction->t_tid); 699 commit_transaction->t_tid);
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 67b8e303946c..19d74d86d99c 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -124,7 +124,7 @@ EXPORT_SYMBOL(__jbd2_debug);
124/* Checksumming functions */ 124/* Checksumming functions */
125static int jbd2_verify_csum_type(journal_t *j, journal_superblock_t *sb) 125static int jbd2_verify_csum_type(journal_t *j, journal_superblock_t *sb)
126{ 126{
127 if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 127 if (!jbd2_journal_has_csum_v2or3(j))
128 return 1; 128 return 1;
129 129
130 return sb->s_checksum_type == JBD2_CRC32C_CHKSUM; 130 return sb->s_checksum_type == JBD2_CRC32C_CHKSUM;
@@ -145,7 +145,7 @@ static __be32 jbd2_superblock_csum(journal_t *j, journal_superblock_t *sb)
145 145
146static int jbd2_superblock_csum_verify(journal_t *j, journal_superblock_t *sb) 146static int jbd2_superblock_csum_verify(journal_t *j, journal_superblock_t *sb)
147{ 147{
148 if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 148 if (!jbd2_journal_has_csum_v2or3(j))
149 return 1; 149 return 1;
150 150
151 return sb->s_checksum == jbd2_superblock_csum(j, sb); 151 return sb->s_checksum == jbd2_superblock_csum(j, sb);
@@ -153,7 +153,7 @@ static int jbd2_superblock_csum_verify(journal_t *j, journal_superblock_t *sb)
153 153
154static void jbd2_superblock_csum_set(journal_t *j, journal_superblock_t *sb) 154static void jbd2_superblock_csum_set(journal_t *j, journal_superblock_t *sb)
155{ 155{
156 if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 156 if (!jbd2_journal_has_csum_v2or3(j))
157 return; 157 return;
158 158
159 sb->s_checksum = jbd2_superblock_csum(j, sb); 159 sb->s_checksum = jbd2_superblock_csum(j, sb);
@@ -1522,21 +1522,29 @@ static int journal_get_superblock(journal_t *journal)
1522 goto out; 1522 goto out;
1523 } 1523 }
1524 1524
1525 if (JBD2_HAS_COMPAT_FEATURE(journal, JBD2_FEATURE_COMPAT_CHECKSUM) && 1525 if (jbd2_journal_has_csum_v2or3(journal) &&
1526 JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) { 1526 JBD2_HAS_COMPAT_FEATURE(journal, JBD2_FEATURE_COMPAT_CHECKSUM)) {
1527 /* Can't have checksum v1 and v2 on at the same time! */ 1527 /* Can't have checksum v1 and v2 on at the same time! */
1528 printk(KERN_ERR "JBD2: Can't enable checksumming v1 and v2 " 1528 printk(KERN_ERR "JBD2: Can't enable checksumming v1 and v2 "
1529 "at the same time!\n"); 1529 "at the same time!\n");
1530 goto out; 1530 goto out;
1531 } 1531 }
1532 1532
1533 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2) &&
1534 JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V3)) {
1535 /* Can't have checksum v2 and v3 at the same time! */
1536 printk(KERN_ERR "JBD2: Can't enable checksumming v2 and v3 "
1537 "at the same time!\n");
1538 goto out;
1539 }
1540
1533 if (!jbd2_verify_csum_type(journal, sb)) { 1541 if (!jbd2_verify_csum_type(journal, sb)) {
1534 printk(KERN_ERR "JBD2: Unknown checksum type\n"); 1542 printk(KERN_ERR "JBD2: Unknown checksum type\n");
1535 goto out; 1543 goto out;
1536 } 1544 }
1537 1545
1538 /* Load the checksum driver */ 1546 /* Load the checksum driver */
1539 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) { 1547 if (jbd2_journal_has_csum_v2or3(journal)) {
1540 journal->j_chksum_driver = crypto_alloc_shash("crc32c", 0, 0); 1548 journal->j_chksum_driver = crypto_alloc_shash("crc32c", 0, 0);
1541 if (IS_ERR(journal->j_chksum_driver)) { 1549 if (IS_ERR(journal->j_chksum_driver)) {
1542 printk(KERN_ERR "JBD2: Cannot load crc32c driver.\n"); 1550 printk(KERN_ERR "JBD2: Cannot load crc32c driver.\n");
@@ -1553,7 +1561,7 @@ static int journal_get_superblock(journal_t *journal)
1553 } 1561 }
1554 1562
1555 /* Precompute checksum seed for all metadata */ 1563 /* Precompute checksum seed for all metadata */
1556 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 1564 if (jbd2_journal_has_csum_v2or3(journal))
1557 journal->j_csum_seed = jbd2_chksum(journal, ~0, sb->s_uuid, 1565 journal->j_csum_seed = jbd2_chksum(journal, ~0, sb->s_uuid,
1558 sizeof(sb->s_uuid)); 1566 sizeof(sb->s_uuid));
1559 1567
@@ -1813,8 +1821,14 @@ int jbd2_journal_set_features (journal_t *journal, unsigned long compat,
1813 if (!jbd2_journal_check_available_features(journal, compat, ro, incompat)) 1821 if (!jbd2_journal_check_available_features(journal, compat, ro, incompat))
1814 return 0; 1822 return 0;
1815 1823
1816 /* Asking for checksumming v2 and v1? Only give them v2. */ 1824 /* If enabling v2 checksums, turn on v3 instead */
1817 if (incompat & JBD2_FEATURE_INCOMPAT_CSUM_V2 && 1825 if (incompat & JBD2_FEATURE_INCOMPAT_CSUM_V2) {
1826 incompat &= ~JBD2_FEATURE_INCOMPAT_CSUM_V2;
1827 incompat |= JBD2_FEATURE_INCOMPAT_CSUM_V3;
1828 }
1829
1830 /* Asking for checksumming v3 and v1? Only give them v3. */
1831 if (incompat & JBD2_FEATURE_INCOMPAT_CSUM_V3 &&
1818 compat & JBD2_FEATURE_COMPAT_CHECKSUM) 1832 compat & JBD2_FEATURE_COMPAT_CHECKSUM)
1819 compat &= ~JBD2_FEATURE_COMPAT_CHECKSUM; 1833 compat &= ~JBD2_FEATURE_COMPAT_CHECKSUM;
1820 1834
@@ -1823,8 +1837,8 @@ int jbd2_journal_set_features (journal_t *journal, unsigned long compat,
1823 1837
1824 sb = journal->j_superblock; 1838 sb = journal->j_superblock;
1825 1839
1826 /* If enabling v2 checksums, update superblock */ 1840 /* If enabling v3 checksums, update superblock */
1827 if (INCOMPAT_FEATURE_ON(JBD2_FEATURE_INCOMPAT_CSUM_V2)) { 1841 if (INCOMPAT_FEATURE_ON(JBD2_FEATURE_INCOMPAT_CSUM_V3)) {
1828 sb->s_checksum_type = JBD2_CRC32C_CHKSUM; 1842 sb->s_checksum_type = JBD2_CRC32C_CHKSUM;
1829 sb->s_feature_compat &= 1843 sb->s_feature_compat &=
1830 ~cpu_to_be32(JBD2_FEATURE_COMPAT_CHECKSUM); 1844 ~cpu_to_be32(JBD2_FEATURE_COMPAT_CHECKSUM);
@@ -1842,8 +1856,7 @@ int jbd2_journal_set_features (journal_t *journal, unsigned long compat,
1842 } 1856 }
1843 1857
1844 /* Precompute checksum seed for all metadata */ 1858 /* Precompute checksum seed for all metadata */
1845 if (JBD2_HAS_INCOMPAT_FEATURE(journal, 1859 if (jbd2_journal_has_csum_v2or3(journal))
1846 JBD2_FEATURE_INCOMPAT_CSUM_V2))
1847 journal->j_csum_seed = jbd2_chksum(journal, ~0, 1860 journal->j_csum_seed = jbd2_chksum(journal, ~0,
1848 sb->s_uuid, 1861 sb->s_uuid,
1849 sizeof(sb->s_uuid)); 1862 sizeof(sb->s_uuid));
@@ -1852,7 +1865,8 @@ int jbd2_journal_set_features (journal_t *journal, unsigned long compat,
1852 /* If enabling v1 checksums, downgrade superblock */ 1865 /* If enabling v1 checksums, downgrade superblock */
1853 if (COMPAT_FEATURE_ON(JBD2_FEATURE_COMPAT_CHECKSUM)) 1866 if (COMPAT_FEATURE_ON(JBD2_FEATURE_COMPAT_CHECKSUM))
1854 sb->s_feature_incompat &= 1867 sb->s_feature_incompat &=
1855 ~cpu_to_be32(JBD2_FEATURE_INCOMPAT_CSUM_V2); 1868 ~cpu_to_be32(JBD2_FEATURE_INCOMPAT_CSUM_V2 |
1869 JBD2_FEATURE_INCOMPAT_CSUM_V3);
1856 1870
1857 sb->s_feature_compat |= cpu_to_be32(compat); 1871 sb->s_feature_compat |= cpu_to_be32(compat);
1858 sb->s_feature_ro_compat |= cpu_to_be32(ro); 1872 sb->s_feature_ro_compat |= cpu_to_be32(ro);
@@ -2165,16 +2179,20 @@ int jbd2_journal_blocks_per_page(struct inode *inode)
2165 */ 2179 */
2166size_t journal_tag_bytes(journal_t *journal) 2180size_t journal_tag_bytes(journal_t *journal)
2167{ 2181{
2168 journal_block_tag_t tag; 2182 size_t sz;
2169 size_t x = 0; 2183
2184 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V3))
2185 return sizeof(journal_block_tag3_t);
2186
2187 sz = sizeof(journal_block_tag_t);
2170 2188
2171 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 2189 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2))
2172 x += sizeof(tag.t_checksum); 2190 sz += sizeof(__u16);
2173 2191
2174 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_64BIT)) 2192 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_64BIT))
2175 return x + JBD2_TAG_SIZE64; 2193 return sz;
2176 else 2194 else
2177 return x + JBD2_TAG_SIZE32; 2195 return sz - sizeof(__u32);
2178} 2196}
2179 2197
2180/* 2198/*
diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c
index 3b6bb19d60b1..9b329b55ffe3 100644
--- a/fs/jbd2/recovery.c
+++ b/fs/jbd2/recovery.c
@@ -181,7 +181,7 @@ static int jbd2_descr_block_csum_verify(journal_t *j,
181 __be32 provided; 181 __be32 provided;
182 __u32 calculated; 182 __u32 calculated;
183 183
184 if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 184 if (!jbd2_journal_has_csum_v2or3(j))
185 return 1; 185 return 1;
186 186
187 tail = (struct jbd2_journal_block_tail *)(buf + j->j_blocksize - 187 tail = (struct jbd2_journal_block_tail *)(buf + j->j_blocksize -
@@ -205,7 +205,7 @@ static int count_tags(journal_t *journal, struct buffer_head *bh)
205 int nr = 0, size = journal->j_blocksize; 205 int nr = 0, size = journal->j_blocksize;
206 int tag_bytes = journal_tag_bytes(journal); 206 int tag_bytes = journal_tag_bytes(journal);
207 207
208 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 208 if (jbd2_journal_has_csum_v2or3(journal))
209 size -= sizeof(struct jbd2_journal_block_tail); 209 size -= sizeof(struct jbd2_journal_block_tail);
210 210
211 tagp = &bh->b_data[sizeof(journal_header_t)]; 211 tagp = &bh->b_data[sizeof(journal_header_t)];
@@ -338,10 +338,11 @@ int jbd2_journal_skip_recovery(journal_t *journal)
338 return err; 338 return err;
339} 339}
340 340
341static inline unsigned long long read_tag_block(int tag_bytes, journal_block_tag_t *tag) 341static inline unsigned long long read_tag_block(journal_t *journal,
342 journal_block_tag_t *tag)
342{ 343{
343 unsigned long long block = be32_to_cpu(tag->t_blocknr); 344 unsigned long long block = be32_to_cpu(tag->t_blocknr);
344 if (tag_bytes > JBD2_TAG_SIZE32) 345 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_64BIT))
345 block |= (u64)be32_to_cpu(tag->t_blocknr_high) << 32; 346 block |= (u64)be32_to_cpu(tag->t_blocknr_high) << 32;
346 return block; 347 return block;
347} 348}
@@ -384,7 +385,7 @@ static int jbd2_commit_block_csum_verify(journal_t *j, void *buf)
384 __be32 provided; 385 __be32 provided;
385 __u32 calculated; 386 __u32 calculated;
386 387
387 if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 388 if (!jbd2_journal_has_csum_v2or3(j))
388 return 1; 389 return 1;
389 390
390 h = buf; 391 h = buf;
@@ -399,17 +400,21 @@ static int jbd2_commit_block_csum_verify(journal_t *j, void *buf)
399static int jbd2_block_tag_csum_verify(journal_t *j, journal_block_tag_t *tag, 400static int jbd2_block_tag_csum_verify(journal_t *j, journal_block_tag_t *tag,
400 void *buf, __u32 sequence) 401 void *buf, __u32 sequence)
401{ 402{
403 journal_block_tag3_t *tag3 = (journal_block_tag3_t *)tag;
402 __u32 csum32; 404 __u32 csum32;
403 __be32 seq; 405 __be32 seq;
404 406
405 if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 407 if (!jbd2_journal_has_csum_v2or3(j))
406 return 1; 408 return 1;
407 409
408 seq = cpu_to_be32(sequence); 410 seq = cpu_to_be32(sequence);
409 csum32 = jbd2_chksum(j, j->j_csum_seed, (__u8 *)&seq, sizeof(seq)); 411 csum32 = jbd2_chksum(j, j->j_csum_seed, (__u8 *)&seq, sizeof(seq));
410 csum32 = jbd2_chksum(j, csum32, buf, j->j_blocksize); 412 csum32 = jbd2_chksum(j, csum32, buf, j->j_blocksize);
411 413
412 return tag->t_checksum == cpu_to_be16(csum32); 414 if (JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V3))
415 return tag3->t_checksum == cpu_to_be32(csum32);
416 else
417 return tag->t_checksum == cpu_to_be16(csum32);
413} 418}
414 419
415static int do_one_pass(journal_t *journal, 420static int do_one_pass(journal_t *journal,
@@ -426,6 +431,7 @@ static int do_one_pass(journal_t *journal,
426 int tag_bytes = journal_tag_bytes(journal); 431 int tag_bytes = journal_tag_bytes(journal);
427 __u32 crc32_sum = ~0; /* Transactional Checksums */ 432 __u32 crc32_sum = ~0; /* Transactional Checksums */
428 int descr_csum_size = 0; 433 int descr_csum_size = 0;
434 int block_error = 0;
429 435
430 /* 436 /*
431 * First thing is to establish what we expect to find in the log 437 * First thing is to establish what we expect to find in the log
@@ -512,8 +518,7 @@ static int do_one_pass(journal_t *journal,
512 switch(blocktype) { 518 switch(blocktype) {
513 case JBD2_DESCRIPTOR_BLOCK: 519 case JBD2_DESCRIPTOR_BLOCK:
514 /* Verify checksum first */ 520 /* Verify checksum first */
515 if (JBD2_HAS_INCOMPAT_FEATURE(journal, 521 if (jbd2_journal_has_csum_v2or3(journal))
516 JBD2_FEATURE_INCOMPAT_CSUM_V2))
517 descr_csum_size = 522 descr_csum_size =
518 sizeof(struct jbd2_journal_block_tail); 523 sizeof(struct jbd2_journal_block_tail);
519 if (descr_csum_size > 0 && 524 if (descr_csum_size > 0 &&
@@ -574,7 +579,7 @@ static int do_one_pass(journal_t *journal,
574 unsigned long long blocknr; 579 unsigned long long blocknr;
575 580
576 J_ASSERT(obh != NULL); 581 J_ASSERT(obh != NULL);
577 blocknr = read_tag_block(tag_bytes, 582 blocknr = read_tag_block(journal,
578 tag); 583 tag);
579 584
580 /* If the block has been 585 /* If the block has been
@@ -598,7 +603,8 @@ static int do_one_pass(journal_t *journal,
598 "checksum recovering " 603 "checksum recovering "
599 "block %llu in log\n", 604 "block %llu in log\n",
600 blocknr); 605 blocknr);
601 continue; 606 block_error = 1;
607 goto skip_write;
602 } 608 }
603 609
604 /* Find a buffer for the new 610 /* Find a buffer for the new
@@ -797,7 +803,8 @@ static int do_one_pass(journal_t *journal,
797 success = -EIO; 803 success = -EIO;
798 } 804 }
799 } 805 }
800 806 if (block_error && success == 0)
807 success = -EIO;
801 return success; 808 return success;
802 809
803 failed: 810 failed:
@@ -811,7 +818,7 @@ static int jbd2_revoke_block_csum_verify(journal_t *j,
811 __be32 provided; 818 __be32 provided;
812 __u32 calculated; 819 __u32 calculated;
813 820
814 if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 821 if (!jbd2_journal_has_csum_v2or3(j))
815 return 1; 822 return 1;
816 823
817 tail = (struct jbd2_journal_revoke_tail *)(buf + j->j_blocksize - 824 tail = (struct jbd2_journal_revoke_tail *)(buf + j->j_blocksize -
diff --git a/fs/jbd2/revoke.c b/fs/jbd2/revoke.c
index 198c9c10276d..d5e95a175c92 100644
--- a/fs/jbd2/revoke.c
+++ b/fs/jbd2/revoke.c
@@ -91,8 +91,8 @@
91#include <linux/list.h> 91#include <linux/list.h>
92#include <linux/init.h> 92#include <linux/init.h>
93#include <linux/bio.h> 93#include <linux/bio.h>
94#endif
95#include <linux/log2.h> 94#include <linux/log2.h>
95#endif
96 96
97static struct kmem_cache *jbd2_revoke_record_cache; 97static struct kmem_cache *jbd2_revoke_record_cache;
98static struct kmem_cache *jbd2_revoke_table_cache; 98static struct kmem_cache *jbd2_revoke_table_cache;
@@ -597,7 +597,7 @@ static void write_one_revoke_record(journal_t *journal,
597 offset = *offsetp; 597 offset = *offsetp;
598 598
599 /* Do we need to leave space at the end for a checksum? */ 599 /* Do we need to leave space at the end for a checksum? */
600 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 600 if (jbd2_journal_has_csum_v2or3(journal))
601 csum_size = sizeof(struct jbd2_journal_revoke_tail); 601 csum_size = sizeof(struct jbd2_journal_revoke_tail);
602 602
603 /* Make sure we have a descriptor with space left for the record */ 603 /* Make sure we have a descriptor with space left for the record */
@@ -644,7 +644,7 @@ static void jbd2_revoke_csum_set(journal_t *j, struct buffer_head *bh)
644 struct jbd2_journal_revoke_tail *tail; 644 struct jbd2_journal_revoke_tail *tail;
645 __u32 csum; 645 __u32 csum;
646 646
647 if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 647 if (!jbd2_journal_has_csum_v2or3(j))
648 return; 648 return;
649 649
650 tail = (struct jbd2_journal_revoke_tail *)(bh->b_data + j->j_blocksize - 650 tail = (struct jbd2_journal_revoke_tail *)(bh->b_data + j->j_blocksize -
diff --git a/fs/locks.c b/fs/locks.c
index cb66fb05ad4a..bb08857f90b5 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1619,7 +1619,7 @@ static int generic_add_lease(struct file *filp, long arg, struct file_lock **flp
1619 smp_mb(); 1619 smp_mb();
1620 error = check_conflicting_open(dentry, arg); 1620 error = check_conflicting_open(dentry, arg);
1621 if (error) 1621 if (error)
1622 locks_unlink_lock(flp); 1622 locks_unlink_lock(before);
1623out: 1623out:
1624 if (is_deleg) 1624 if (is_deleg)
1625 mutex_unlock(&inode->i_mutex); 1625 mutex_unlock(&inode->i_mutex);
diff --git a/fs/nfs/nfs3acl.c b/fs/nfs/nfs3acl.c
index d0fec260132a..24c6898159cc 100644
--- a/fs/nfs/nfs3acl.c
+++ b/fs/nfs/nfs3acl.c
@@ -129,7 +129,10 @@ static int __nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl,
129 .rpc_argp = &args, 129 .rpc_argp = &args,
130 .rpc_resp = &fattr, 130 .rpc_resp = &fattr,
131 }; 131 };
132 int status; 132 int status = 0;
133
134 if (acl == NULL && (!S_ISDIR(inode->i_mode) || dfacl == NULL))
135 goto out;
133 136
134 status = -EOPNOTSUPP; 137 status = -EOPNOTSUPP;
135 if (!nfs_server_capable(inode, NFS_CAP_ACLS)) 138 if (!nfs_server_capable(inode, NFS_CAP_ACLS))
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 75ae8d22f067..7dd8aca31c29 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -2560,6 +2560,7 @@ static void nfs4_close_done(struct rpc_task *task, void *data)
2560 struct nfs4_closedata *calldata = data; 2560 struct nfs4_closedata *calldata = data;
2561 struct nfs4_state *state = calldata->state; 2561 struct nfs4_state *state = calldata->state;
2562 struct nfs_server *server = NFS_SERVER(calldata->inode); 2562 struct nfs_server *server = NFS_SERVER(calldata->inode);
2563 nfs4_stateid *res_stateid = NULL;
2563 2564
2564 dprintk("%s: begin!\n", __func__); 2565 dprintk("%s: begin!\n", __func__);
2565 if (!nfs4_sequence_done(task, &calldata->res.seq_res)) 2566 if (!nfs4_sequence_done(task, &calldata->res.seq_res))
@@ -2570,12 +2571,12 @@ static void nfs4_close_done(struct rpc_task *task, void *data)
2570 */ 2571 */
2571 switch (task->tk_status) { 2572 switch (task->tk_status) {
2572 case 0: 2573 case 0:
2573 if (calldata->roc) 2574 res_stateid = &calldata->res.stateid;
2575 if (calldata->arg.fmode == 0 && calldata->roc)
2574 pnfs_roc_set_barrier(state->inode, 2576 pnfs_roc_set_barrier(state->inode,
2575 calldata->roc_barrier); 2577 calldata->roc_barrier);
2576 nfs_clear_open_stateid(state, &calldata->res.stateid, 0);
2577 renew_lease(server, calldata->timestamp); 2578 renew_lease(server, calldata->timestamp);
2578 goto out_release; 2579 break;
2579 case -NFS4ERR_ADMIN_REVOKED: 2580 case -NFS4ERR_ADMIN_REVOKED:
2580 case -NFS4ERR_STALE_STATEID: 2581 case -NFS4ERR_STALE_STATEID:
2581 case -NFS4ERR_OLD_STATEID: 2582 case -NFS4ERR_OLD_STATEID:
@@ -2589,7 +2590,7 @@ static void nfs4_close_done(struct rpc_task *task, void *data)
2589 goto out_release; 2590 goto out_release;
2590 } 2591 }
2591 } 2592 }
2592 nfs_clear_open_stateid(state, NULL, calldata->arg.fmode); 2593 nfs_clear_open_stateid(state, res_stateid, calldata->arg.fmode);
2593out_release: 2594out_release:
2594 nfs_release_seqid(calldata->arg.seqid); 2595 nfs_release_seqid(calldata->arg.seqid);
2595 nfs_refresh_inode(calldata->inode, calldata->res.fattr); 2596 nfs_refresh_inode(calldata->inode, calldata->res.fattr);
@@ -2601,6 +2602,7 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
2601 struct nfs4_closedata *calldata = data; 2602 struct nfs4_closedata *calldata = data;
2602 struct nfs4_state *state = calldata->state; 2603 struct nfs4_state *state = calldata->state;
2603 struct inode *inode = calldata->inode; 2604 struct inode *inode = calldata->inode;
2605 bool is_rdonly, is_wronly, is_rdwr;
2604 int call_close = 0; 2606 int call_close = 0;
2605 2607
2606 dprintk("%s: begin!\n", __func__); 2608 dprintk("%s: begin!\n", __func__);
@@ -2608,18 +2610,24 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
2608 goto out_wait; 2610 goto out_wait;
2609 2611
2610 task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE]; 2612 task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE];
2611 calldata->arg.fmode = FMODE_READ|FMODE_WRITE;
2612 spin_lock(&state->owner->so_lock); 2613 spin_lock(&state->owner->so_lock);
2614 is_rdwr = test_bit(NFS_O_RDWR_STATE, &state->flags);
2615 is_rdonly = test_bit(NFS_O_RDONLY_STATE, &state->flags);
2616 is_wronly = test_bit(NFS_O_WRONLY_STATE, &state->flags);
2617 /* Calculate the current open share mode */
2618 calldata->arg.fmode = 0;
2619 if (is_rdonly || is_rdwr)
2620 calldata->arg.fmode |= FMODE_READ;
2621 if (is_wronly || is_rdwr)
2622 calldata->arg.fmode |= FMODE_WRITE;
2613 /* Calculate the change in open mode */ 2623 /* Calculate the change in open mode */
2614 if (state->n_rdwr == 0) { 2624 if (state->n_rdwr == 0) {
2615 if (state->n_rdonly == 0) { 2625 if (state->n_rdonly == 0) {
2616 call_close |= test_bit(NFS_O_RDONLY_STATE, &state->flags); 2626 call_close |= is_rdonly || is_rdwr;
2617 call_close |= test_bit(NFS_O_RDWR_STATE, &state->flags);
2618 calldata->arg.fmode &= ~FMODE_READ; 2627 calldata->arg.fmode &= ~FMODE_READ;
2619 } 2628 }
2620 if (state->n_wronly == 0) { 2629 if (state->n_wronly == 0) {
2621 call_close |= test_bit(NFS_O_WRONLY_STATE, &state->flags); 2630 call_close |= is_wronly || is_rdwr;
2622 call_close |= test_bit(NFS_O_RDWR_STATE, &state->flags);
2623 calldata->arg.fmode &= ~FMODE_WRITE; 2631 calldata->arg.fmode &= ~FMODE_WRITE;
2624 } 2632 }
2625 } 2633 }
diff --git a/fs/ocfs2/cluster/quorum.c b/fs/ocfs2/cluster/quorum.c
index 1ec141e758d7..62e8ec619b4c 100644
--- a/fs/ocfs2/cluster/quorum.c
+++ b/fs/ocfs2/cluster/quorum.c
@@ -160,9 +160,18 @@ static void o2quo_make_decision(struct work_struct *work)
160 } 160 }
161 161
162out: 162out:
163 spin_unlock(&qs->qs_lock); 163 if (fence) {
164 if (fence) 164 spin_unlock(&qs->qs_lock);
165 o2quo_fence_self(); 165 o2quo_fence_self();
166 } else {
167 mlog(ML_NOTICE, "not fencing this node, heartbeating: %d, "
168 "connected: %d, lowest: %d (%sreachable)\n",
169 qs->qs_heartbeating, qs->qs_connected, lowest_hb,
170 lowest_reachable ? "" : "un");
171 spin_unlock(&qs->qs_lock);
172
173 }
174
166} 175}
167 176
168static void o2quo_set_hold(struct o2quo_state *qs, u8 node) 177static void o2quo_set_hold(struct o2quo_state *qs, u8 node)
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c
index 681691bc233a..ea34952f9496 100644
--- a/fs/ocfs2/cluster/tcp.c
+++ b/fs/ocfs2/cluster/tcp.c
@@ -1480,6 +1480,14 @@ static int o2net_set_nodelay(struct socket *sock)
1480 return ret; 1480 return ret;
1481} 1481}
1482 1482
1483static int o2net_set_usertimeout(struct socket *sock)
1484{
1485 int user_timeout = O2NET_TCP_USER_TIMEOUT;
1486
1487 return kernel_setsockopt(sock, SOL_TCP, TCP_USER_TIMEOUT,
1488 (char *)&user_timeout, sizeof(user_timeout));
1489}
1490
1483static void o2net_initialize_handshake(void) 1491static void o2net_initialize_handshake(void)
1484{ 1492{
1485 o2net_hand->o2hb_heartbeat_timeout_ms = cpu_to_be32( 1493 o2net_hand->o2hb_heartbeat_timeout_ms = cpu_to_be32(
@@ -1536,16 +1544,20 @@ static void o2net_idle_timer(unsigned long data)
1536#endif 1544#endif
1537 1545
1538 printk(KERN_NOTICE "o2net: Connection to " SC_NODEF_FMT " has been " 1546 printk(KERN_NOTICE "o2net: Connection to " SC_NODEF_FMT " has been "
1539 "idle for %lu.%lu secs, shutting it down.\n", SC_NODEF_ARGS(sc), 1547 "idle for %lu.%lu secs.\n",
1540 msecs / 1000, msecs % 1000); 1548 SC_NODEF_ARGS(sc), msecs / 1000, msecs % 1000);
1541 1549
1542 /* 1550 /* idle timerout happen, don't shutdown the connection, but
1543 * Initialize the nn_timeout so that the next connection attempt 1551 * make fence decision. Maybe the connection can recover before
1544 * will continue in o2net_start_connect. 1552 * the decision is made.
1545 */ 1553 */
1546 atomic_set(&nn->nn_timeout, 1); 1554 atomic_set(&nn->nn_timeout, 1);
1555 o2quo_conn_err(o2net_num_from_nn(nn));
1556 queue_delayed_work(o2net_wq, &nn->nn_still_up,
1557 msecs_to_jiffies(O2NET_QUORUM_DELAY_MS));
1558
1559 o2net_sc_reset_idle_timer(sc);
1547 1560
1548 o2net_sc_queue_work(sc, &sc->sc_shutdown_work);
1549} 1561}
1550 1562
1551static void o2net_sc_reset_idle_timer(struct o2net_sock_container *sc) 1563static void o2net_sc_reset_idle_timer(struct o2net_sock_container *sc)
@@ -1560,6 +1572,15 @@ static void o2net_sc_reset_idle_timer(struct o2net_sock_container *sc)
1560 1572
1561static void o2net_sc_postpone_idle(struct o2net_sock_container *sc) 1573static void o2net_sc_postpone_idle(struct o2net_sock_container *sc)
1562{ 1574{
1575 struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num);
1576
1577 /* clear fence decision since the connection recover from timeout*/
1578 if (atomic_read(&nn->nn_timeout)) {
1579 o2quo_conn_up(o2net_num_from_nn(nn));
1580 cancel_delayed_work(&nn->nn_still_up);
1581 atomic_set(&nn->nn_timeout, 0);
1582 }
1583
1563 /* Only push out an existing timer */ 1584 /* Only push out an existing timer */
1564 if (timer_pending(&sc->sc_idle_timeout)) 1585 if (timer_pending(&sc->sc_idle_timeout))
1565 o2net_sc_reset_idle_timer(sc); 1586 o2net_sc_reset_idle_timer(sc);
@@ -1650,6 +1671,12 @@ static void o2net_start_connect(struct work_struct *work)
1650 goto out; 1671 goto out;
1651 } 1672 }
1652 1673
1674 ret = o2net_set_usertimeout(sock);
1675 if (ret) {
1676 mlog(ML_ERROR, "set TCP_USER_TIMEOUT failed with %d\n", ret);
1677 goto out;
1678 }
1679
1653 o2net_register_callbacks(sc->sc_sock->sk, sc); 1680 o2net_register_callbacks(sc->sc_sock->sk, sc);
1654 1681
1655 spin_lock(&nn->nn_lock); 1682 spin_lock(&nn->nn_lock);
@@ -1831,6 +1858,12 @@ static int o2net_accept_one(struct socket *sock, int *more)
1831 goto out; 1858 goto out;
1832 } 1859 }
1833 1860
1861 ret = o2net_set_usertimeout(new_sock);
1862 if (ret) {
1863 mlog(ML_ERROR, "set TCP_USER_TIMEOUT failed with %d\n", ret);
1864 goto out;
1865 }
1866
1834 slen = sizeof(sin); 1867 slen = sizeof(sin);
1835 ret = new_sock->ops->getname(new_sock, (struct sockaddr *) &sin, 1868 ret = new_sock->ops->getname(new_sock, (struct sockaddr *) &sin,
1836 &slen, 1); 1869 &slen, 1);
diff --git a/fs/ocfs2/cluster/tcp.h b/fs/ocfs2/cluster/tcp.h
index 5bada2a69b50..c571e849fda4 100644
--- a/fs/ocfs2/cluster/tcp.h
+++ b/fs/ocfs2/cluster/tcp.h
@@ -63,6 +63,7 @@ typedef void (o2net_post_msg_handler_func)(int status, void *data,
63#define O2NET_KEEPALIVE_DELAY_MS_DEFAULT 2000 63#define O2NET_KEEPALIVE_DELAY_MS_DEFAULT 2000
64#define O2NET_IDLE_TIMEOUT_MS_DEFAULT 30000 64#define O2NET_IDLE_TIMEOUT_MS_DEFAULT 30000
65 65
66#define O2NET_TCP_USER_TIMEOUT 0x7fffffff
66 67
67/* TODO: figure this out.... */ 68/* TODO: figure this out.... */
68static inline int o2net_link_down(int err, struct socket *sock) 69static inline int o2net_link_down(int err, struct socket *sock)
diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c
index 6f66b3751ace..53e6c40ed4c6 100644
--- a/fs/ocfs2/ioctl.c
+++ b/fs/ocfs2/ioctl.c
@@ -35,9 +35,8 @@
35 copy_to_user((typeof(a) __user *)b, &(a), sizeof(a)) 35 copy_to_user((typeof(a) __user *)b, &(a), sizeof(a))
36 36
37/* 37/*
38 * This call is void because we are already reporting an error that may 38 * This is just a best-effort to tell userspace that this request
39 * be -EFAULT. The error will be returned from the ioctl(2) call. It's 39 * caused the error.
40 * just a best-effort to tell userspace that this request caused the error.
41 */ 40 */
42static inline void o2info_set_request_error(struct ocfs2_info_request *kreq, 41static inline void o2info_set_request_error(struct ocfs2_info_request *kreq,
43 struct ocfs2_info_request __user *req) 42 struct ocfs2_info_request __user *req)
@@ -146,136 +145,105 @@ bail:
146static int ocfs2_info_handle_blocksize(struct inode *inode, 145static int ocfs2_info_handle_blocksize(struct inode *inode,
147 struct ocfs2_info_request __user *req) 146 struct ocfs2_info_request __user *req)
148{ 147{
149 int status = -EFAULT;
150 struct ocfs2_info_blocksize oib; 148 struct ocfs2_info_blocksize oib;
151 149
152 if (o2info_from_user(oib, req)) 150 if (o2info_from_user(oib, req))
153 goto bail; 151 return -EFAULT;
154 152
155 oib.ib_blocksize = inode->i_sb->s_blocksize; 153 oib.ib_blocksize = inode->i_sb->s_blocksize;
156 154
157 o2info_set_request_filled(&oib.ib_req); 155 o2info_set_request_filled(&oib.ib_req);
158 156
159 if (o2info_to_user(oib, req)) 157 if (o2info_to_user(oib, req))
160 goto bail; 158 return -EFAULT;
161
162 status = 0;
163bail:
164 if (status)
165 o2info_set_request_error(&oib.ib_req, req);
166 159
167 return status; 160 return 0;
168} 161}
169 162
170static int ocfs2_info_handle_clustersize(struct inode *inode, 163static int ocfs2_info_handle_clustersize(struct inode *inode,
171 struct ocfs2_info_request __user *req) 164 struct ocfs2_info_request __user *req)
172{ 165{
173 int status = -EFAULT;
174 struct ocfs2_info_clustersize oic; 166 struct ocfs2_info_clustersize oic;
175 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 167 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
176 168
177 if (o2info_from_user(oic, req)) 169 if (o2info_from_user(oic, req))
178 goto bail; 170 return -EFAULT;
179 171
180 oic.ic_clustersize = osb->s_clustersize; 172 oic.ic_clustersize = osb->s_clustersize;
181 173
182 o2info_set_request_filled(&oic.ic_req); 174 o2info_set_request_filled(&oic.ic_req);
183 175
184 if (o2info_to_user(oic, req)) 176 if (o2info_to_user(oic, req))
185 goto bail; 177 return -EFAULT;
186
187 status = 0;
188bail:
189 if (status)
190 o2info_set_request_error(&oic.ic_req, req);
191 178
192 return status; 179 return 0;
193} 180}
194 181
195static int ocfs2_info_handle_maxslots(struct inode *inode, 182static int ocfs2_info_handle_maxslots(struct inode *inode,
196 struct ocfs2_info_request __user *req) 183 struct ocfs2_info_request __user *req)
197{ 184{
198 int status = -EFAULT;
199 struct ocfs2_info_maxslots oim; 185 struct ocfs2_info_maxslots oim;
200 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 186 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
201 187
202 if (o2info_from_user(oim, req)) 188 if (o2info_from_user(oim, req))
203 goto bail; 189 return -EFAULT;
204 190
205 oim.im_max_slots = osb->max_slots; 191 oim.im_max_slots = osb->max_slots;
206 192
207 o2info_set_request_filled(&oim.im_req); 193 o2info_set_request_filled(&oim.im_req);
208 194
209 if (o2info_to_user(oim, req)) 195 if (o2info_to_user(oim, req))
210 goto bail; 196 return -EFAULT;
211 197
212 status = 0; 198 return 0;
213bail:
214 if (status)
215 o2info_set_request_error(&oim.im_req, req);
216
217 return status;
218} 199}
219 200
220static int ocfs2_info_handle_label(struct inode *inode, 201static int ocfs2_info_handle_label(struct inode *inode,
221 struct ocfs2_info_request __user *req) 202 struct ocfs2_info_request __user *req)
222{ 203{
223 int status = -EFAULT;
224 struct ocfs2_info_label oil; 204 struct ocfs2_info_label oil;
225 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 205 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
226 206
227 if (o2info_from_user(oil, req)) 207 if (o2info_from_user(oil, req))
228 goto bail; 208 return -EFAULT;
229 209
230 memcpy(oil.il_label, osb->vol_label, OCFS2_MAX_VOL_LABEL_LEN); 210 memcpy(oil.il_label, osb->vol_label, OCFS2_MAX_VOL_LABEL_LEN);
231 211
232 o2info_set_request_filled(&oil.il_req); 212 o2info_set_request_filled(&oil.il_req);
233 213
234 if (o2info_to_user(oil, req)) 214 if (o2info_to_user(oil, req))
235 goto bail; 215 return -EFAULT;
236 216
237 status = 0; 217 return 0;
238bail:
239 if (status)
240 o2info_set_request_error(&oil.il_req, req);
241
242 return status;
243} 218}
244 219
245static int ocfs2_info_handle_uuid(struct inode *inode, 220static int ocfs2_info_handle_uuid(struct inode *inode,
246 struct ocfs2_info_request __user *req) 221 struct ocfs2_info_request __user *req)
247{ 222{
248 int status = -EFAULT;
249 struct ocfs2_info_uuid oiu; 223 struct ocfs2_info_uuid oiu;
250 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 224 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
251 225
252 if (o2info_from_user(oiu, req)) 226 if (o2info_from_user(oiu, req))
253 goto bail; 227 return -EFAULT;
254 228
255 memcpy(oiu.iu_uuid_str, osb->uuid_str, OCFS2_TEXT_UUID_LEN + 1); 229 memcpy(oiu.iu_uuid_str, osb->uuid_str, OCFS2_TEXT_UUID_LEN + 1);
256 230
257 o2info_set_request_filled(&oiu.iu_req); 231 o2info_set_request_filled(&oiu.iu_req);
258 232
259 if (o2info_to_user(oiu, req)) 233 if (o2info_to_user(oiu, req))
260 goto bail; 234 return -EFAULT;
261
262 status = 0;
263bail:
264 if (status)
265 o2info_set_request_error(&oiu.iu_req, req);
266 235
267 return status; 236 return 0;
268} 237}
269 238
270static int ocfs2_info_handle_fs_features(struct inode *inode, 239static int ocfs2_info_handle_fs_features(struct inode *inode,
271 struct ocfs2_info_request __user *req) 240 struct ocfs2_info_request __user *req)
272{ 241{
273 int status = -EFAULT;
274 struct ocfs2_info_fs_features oif; 242 struct ocfs2_info_fs_features oif;
275 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 243 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
276 244
277 if (o2info_from_user(oif, req)) 245 if (o2info_from_user(oif, req))
278 goto bail; 246 return -EFAULT;
279 247
280 oif.if_compat_features = osb->s_feature_compat; 248 oif.if_compat_features = osb->s_feature_compat;
281 oif.if_incompat_features = osb->s_feature_incompat; 249 oif.if_incompat_features = osb->s_feature_incompat;
@@ -284,39 +252,28 @@ static int ocfs2_info_handle_fs_features(struct inode *inode,
284 o2info_set_request_filled(&oif.if_req); 252 o2info_set_request_filled(&oif.if_req);
285 253
286 if (o2info_to_user(oif, req)) 254 if (o2info_to_user(oif, req))
287 goto bail; 255 return -EFAULT;
288 256
289 status = 0; 257 return 0;
290bail:
291 if (status)
292 o2info_set_request_error(&oif.if_req, req);
293
294 return status;
295} 258}
296 259
297static int ocfs2_info_handle_journal_size(struct inode *inode, 260static int ocfs2_info_handle_journal_size(struct inode *inode,
298 struct ocfs2_info_request __user *req) 261 struct ocfs2_info_request __user *req)
299{ 262{
300 int status = -EFAULT;
301 struct ocfs2_info_journal_size oij; 263 struct ocfs2_info_journal_size oij;
302 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 264 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
303 265
304 if (o2info_from_user(oij, req)) 266 if (o2info_from_user(oij, req))
305 goto bail; 267 return -EFAULT;
306 268
307 oij.ij_journal_size = i_size_read(osb->journal->j_inode); 269 oij.ij_journal_size = i_size_read(osb->journal->j_inode);
308 270
309 o2info_set_request_filled(&oij.ij_req); 271 o2info_set_request_filled(&oij.ij_req);
310 272
311 if (o2info_to_user(oij, req)) 273 if (o2info_to_user(oij, req))
312 goto bail; 274 return -EFAULT;
313 275
314 status = 0; 276 return 0;
315bail:
316 if (status)
317 o2info_set_request_error(&oij.ij_req, req);
318
319 return status;
320} 277}
321 278
322static int ocfs2_info_scan_inode_alloc(struct ocfs2_super *osb, 279static int ocfs2_info_scan_inode_alloc(struct ocfs2_super *osb,
@@ -373,7 +330,7 @@ static int ocfs2_info_handle_freeinode(struct inode *inode,
373 u32 i; 330 u32 i;
374 u64 blkno = -1; 331 u64 blkno = -1;
375 char namebuf[40]; 332 char namebuf[40];
376 int status = -EFAULT, type = INODE_ALLOC_SYSTEM_INODE; 333 int status, type = INODE_ALLOC_SYSTEM_INODE;
377 struct ocfs2_info_freeinode *oifi = NULL; 334 struct ocfs2_info_freeinode *oifi = NULL;
378 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 335 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
379 struct inode *inode_alloc = NULL; 336 struct inode *inode_alloc = NULL;
@@ -385,8 +342,10 @@ static int ocfs2_info_handle_freeinode(struct inode *inode,
385 goto out_err; 342 goto out_err;
386 } 343 }
387 344
388 if (o2info_from_user(*oifi, req)) 345 if (o2info_from_user(*oifi, req)) {
389 goto bail; 346 status = -EFAULT;
347 goto out_free;
348 }
390 349
391 oifi->ifi_slotnum = osb->max_slots; 350 oifi->ifi_slotnum = osb->max_slots;
392 351
@@ -424,14 +383,16 @@ static int ocfs2_info_handle_freeinode(struct inode *inode,
424 383
425 o2info_set_request_filled(&oifi->ifi_req); 384 o2info_set_request_filled(&oifi->ifi_req);
426 385
427 if (o2info_to_user(*oifi, req)) 386 if (o2info_to_user(*oifi, req)) {
428 goto bail; 387 status = -EFAULT;
388 goto out_free;
389 }
429 390
430 status = 0; 391 status = 0;
431bail: 392bail:
432 if (status) 393 if (status)
433 o2info_set_request_error(&oifi->ifi_req, req); 394 o2info_set_request_error(&oifi->ifi_req, req);
434 395out_free:
435 kfree(oifi); 396 kfree(oifi);
436out_err: 397out_err:
437 return status; 398 return status;
@@ -658,7 +619,7 @@ static int ocfs2_info_handle_freefrag(struct inode *inode,
658{ 619{
659 u64 blkno = -1; 620 u64 blkno = -1;
660 char namebuf[40]; 621 char namebuf[40];
661 int status = -EFAULT, type = GLOBAL_BITMAP_SYSTEM_INODE; 622 int status, type = GLOBAL_BITMAP_SYSTEM_INODE;
662 623
663 struct ocfs2_info_freefrag *oiff; 624 struct ocfs2_info_freefrag *oiff;
664 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 625 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
@@ -671,8 +632,10 @@ static int ocfs2_info_handle_freefrag(struct inode *inode,
671 goto out_err; 632 goto out_err;
672 } 633 }
673 634
674 if (o2info_from_user(*oiff, req)) 635 if (o2info_from_user(*oiff, req)) {
675 goto bail; 636 status = -EFAULT;
637 goto out_free;
638 }
676 /* 639 /*
677 * chunksize from userspace should be power of 2. 640 * chunksize from userspace should be power of 2.
678 */ 641 */
@@ -711,14 +674,14 @@ static int ocfs2_info_handle_freefrag(struct inode *inode,
711 674
712 if (o2info_to_user(*oiff, req)) { 675 if (o2info_to_user(*oiff, req)) {
713 status = -EFAULT; 676 status = -EFAULT;
714 goto bail; 677 goto out_free;
715 } 678 }
716 679
717 status = 0; 680 status = 0;
718bail: 681bail:
719 if (status) 682 if (status)
720 o2info_set_request_error(&oiff->iff_req, req); 683 o2info_set_request_error(&oiff->iff_req, req);
721 684out_free:
722 kfree(oiff); 685 kfree(oiff);
723out_err: 686out_err:
724 return status; 687 return status;
@@ -727,23 +690,17 @@ out_err:
727static int ocfs2_info_handle_unknown(struct inode *inode, 690static int ocfs2_info_handle_unknown(struct inode *inode,
728 struct ocfs2_info_request __user *req) 691 struct ocfs2_info_request __user *req)
729{ 692{
730 int status = -EFAULT;
731 struct ocfs2_info_request oir; 693 struct ocfs2_info_request oir;
732 694
733 if (o2info_from_user(oir, req)) 695 if (o2info_from_user(oir, req))
734 goto bail; 696 return -EFAULT;
735 697
736 o2info_clear_request_filled(&oir); 698 o2info_clear_request_filled(&oir);
737 699
738 if (o2info_to_user(oir, req)) 700 if (o2info_to_user(oir, req))
739 goto bail; 701 return -EFAULT;
740 702
741 status = 0; 703 return 0;
742bail:
743 if (status)
744 o2info_set_request_error(&oir, req);
745
746 return status;
747} 704}
748 705
749/* 706/*
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index eb726b9c5762..a1e31f274fcd 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -127,10 +127,9 @@ enum {
127 BLK_MQ_RQ_QUEUE_ERROR = 2, /* end IO with error */ 127 BLK_MQ_RQ_QUEUE_ERROR = 2, /* end IO with error */
128 128
129 BLK_MQ_F_SHOULD_MERGE = 1 << 0, 129 BLK_MQ_F_SHOULD_MERGE = 1 << 0,
130 BLK_MQ_F_SHOULD_SORT = 1 << 1, 130 BLK_MQ_F_TAG_SHARED = 1 << 1,
131 BLK_MQ_F_TAG_SHARED = 1 << 2, 131 BLK_MQ_F_SG_MERGE = 1 << 2,
132 BLK_MQ_F_SG_MERGE = 1 << 3, 132 BLK_MQ_F_SYSFS_UP = 1 << 3,
133 BLK_MQ_F_SYSFS_UP = 1 << 4,
134 133
135 BLK_MQ_S_STOPPED = 0, 134 BLK_MQ_S_STOPPED = 0,
136 BLK_MQ_S_TAG_ACTIVE = 1, 135 BLK_MQ_S_TAG_ACTIVE = 1,
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index d5b50a19463c..0dae71e9971c 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -159,7 +159,11 @@ typedef struct journal_header_s
159 * journal_block_tag (in the descriptor). The other h_chksum* fields are 159 * journal_block_tag (in the descriptor). The other h_chksum* fields are
160 * not used. 160 * not used.
161 * 161 *
162 * Checksum v1 and v2 are mutually exclusive features. 162 * If FEATURE_INCOMPAT_CSUM_V3 is set, the descriptor block uses
163 * journal_block_tag3_t to store a full 32-bit checksum. Everything else
164 * is the same as v2.
165 *
166 * Checksum v1, v2, and v3 are mutually exclusive features.
163 */ 167 */
164struct commit_header { 168struct commit_header {
165 __be32 h_magic; 169 __be32 h_magic;
@@ -179,6 +183,14 @@ struct commit_header {
179 * raw struct shouldn't be used for pointer math or sizeof() - use 183 * raw struct shouldn't be used for pointer math or sizeof() - use
180 * journal_tag_bytes(journal) instead to compute this. 184 * journal_tag_bytes(journal) instead to compute this.
181 */ 185 */
186typedef struct journal_block_tag3_s
187{
188 __be32 t_blocknr; /* The on-disk block number */
189 __be32 t_flags; /* See below */
190 __be32 t_blocknr_high; /* most-significant high 32bits. */
191 __be32 t_checksum; /* crc32c(uuid+seq+block) */
192} journal_block_tag3_t;
193
182typedef struct journal_block_tag_s 194typedef struct journal_block_tag_s
183{ 195{
184 __be32 t_blocknr; /* The on-disk block number */ 196 __be32 t_blocknr; /* The on-disk block number */
@@ -187,9 +199,6 @@ typedef struct journal_block_tag_s
187 __be32 t_blocknr_high; /* most-significant high 32bits. */ 199 __be32 t_blocknr_high; /* most-significant high 32bits. */
188} journal_block_tag_t; 200} journal_block_tag_t;
189 201
190#define JBD2_TAG_SIZE32 (offsetof(journal_block_tag_t, t_blocknr_high))
191#define JBD2_TAG_SIZE64 (sizeof(journal_block_tag_t))
192
193/* Tail of descriptor block, for checksumming */ 202/* Tail of descriptor block, for checksumming */
194struct jbd2_journal_block_tail { 203struct jbd2_journal_block_tail {
195 __be32 t_checksum; /* crc32c(uuid+descr_block) */ 204 __be32 t_checksum; /* crc32c(uuid+descr_block) */
@@ -284,6 +293,7 @@ typedef struct journal_superblock_s
284#define JBD2_FEATURE_INCOMPAT_64BIT 0x00000002 293#define JBD2_FEATURE_INCOMPAT_64BIT 0x00000002
285#define JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT 0x00000004 294#define JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT 0x00000004
286#define JBD2_FEATURE_INCOMPAT_CSUM_V2 0x00000008 295#define JBD2_FEATURE_INCOMPAT_CSUM_V2 0x00000008
296#define JBD2_FEATURE_INCOMPAT_CSUM_V3 0x00000010
287 297
288/* Features known to this kernel version: */ 298/* Features known to this kernel version: */
289#define JBD2_KNOWN_COMPAT_FEATURES JBD2_FEATURE_COMPAT_CHECKSUM 299#define JBD2_KNOWN_COMPAT_FEATURES JBD2_FEATURE_COMPAT_CHECKSUM
@@ -291,7 +301,8 @@ typedef struct journal_superblock_s
291#define JBD2_KNOWN_INCOMPAT_FEATURES (JBD2_FEATURE_INCOMPAT_REVOKE | \ 301#define JBD2_KNOWN_INCOMPAT_FEATURES (JBD2_FEATURE_INCOMPAT_REVOKE | \
292 JBD2_FEATURE_INCOMPAT_64BIT | \ 302 JBD2_FEATURE_INCOMPAT_64BIT | \
293 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT | \ 303 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT | \
294 JBD2_FEATURE_INCOMPAT_CSUM_V2) 304 JBD2_FEATURE_INCOMPAT_CSUM_V2 | \
305 JBD2_FEATURE_INCOMPAT_CSUM_V3)
295 306
296#ifdef __KERNEL__ 307#ifdef __KERNEL__
297 308
@@ -1296,6 +1307,15 @@ static inline int tid_geq(tid_t x, tid_t y)
1296extern int jbd2_journal_blocks_per_page(struct inode *inode); 1307extern int jbd2_journal_blocks_per_page(struct inode *inode);
1297extern size_t journal_tag_bytes(journal_t *journal); 1308extern size_t journal_tag_bytes(journal_t *journal);
1298 1309
1310static inline int jbd2_journal_has_csum_v2or3(journal_t *journal)
1311{
1312 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2) ||
1313 JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V3))
1314 return 1;
1315
1316 return 0;
1317}
1318
1299/* 1319/*
1300 * We reserve t_outstanding_credits >> JBD2_CONTROL_BLOCKS_SHIFT for 1320 * We reserve t_outstanding_credits >> JBD2_CONTROL_BLOCKS_SHIFT for
1301 * transaction control blocks. 1321 * transaction control blocks.
diff --git a/include/linux/seqno-fence.h b/include/linux/seqno-fence.h
index 3d6003de4b0d..a1ba6a5ccdd6 100644
--- a/include/linux/seqno-fence.h
+++ b/include/linux/seqno-fence.h
@@ -62,6 +62,7 @@ to_seqno_fence(struct fence *fence)
62 * @context: the execution context this fence is a part of 62 * @context: the execution context this fence is a part of
63 * @seqno_ofs: the offset within @sync_buf 63 * @seqno_ofs: the offset within @sync_buf
64 * @seqno: the sequence # to signal on 64 * @seqno: the sequence # to signal on
65 * @cond: fence wait condition
65 * @ops: the fence_ops for operations on this seqno fence 66 * @ops: the fence_ops for operations on this seqno fence
66 * 67 *
67 * This function initializes a struct seqno_fence with passed parameters, 68 * This function initializes a struct seqno_fence with passed parameters,
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index e713543336f1..46d188a9947c 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -253,6 +253,7 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
253 * the device whose settings are being modified. 253 * the device whose settings are being modified.
254 * @transfer: adds a message to the controller's transfer queue. 254 * @transfer: adds a message to the controller's transfer queue.
255 * @cleanup: frees controller-specific state 255 * @cleanup: frees controller-specific state
256 * @can_dma: determine whether this master supports DMA
256 * @queued: whether this master is providing an internal message queue 257 * @queued: whether this master is providing an internal message queue
257 * @kworker: thread struct for message pump 258 * @kworker: thread struct for message pump
258 * @kworker_task: pointer to task for message pump kworker thread 259 * @kworker_task: pointer to task for message pump kworker thread
@@ -262,6 +263,7 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
262 * @cur_msg: the currently in-flight message 263 * @cur_msg: the currently in-flight message
263 * @cur_msg_prepared: spi_prepare_message was called for the currently 264 * @cur_msg_prepared: spi_prepare_message was called for the currently
264 * in-flight message 265 * in-flight message
266 * @cur_msg_mapped: message has been mapped for DMA
265 * @xfer_completion: used by core transfer_one_message() 267 * @xfer_completion: used by core transfer_one_message()
266 * @busy: message pump is busy 268 * @busy: message pump is busy
267 * @running: message pump is running 269 * @running: message pump is running
@@ -299,6 +301,10 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
299 * @cs_gpios: Array of GPIOs to use as chip select lines; one per CS 301 * @cs_gpios: Array of GPIOs to use as chip select lines; one per CS
300 * number. Any individual value may be -ENOENT for CS lines that 302 * number. Any individual value may be -ENOENT for CS lines that
301 * are not GPIOs (driven by the SPI controller itself). 303 * are not GPIOs (driven by the SPI controller itself).
304 * @dma_tx: DMA transmit channel
305 * @dma_rx: DMA receive channel
306 * @dummy_rx: dummy receive buffer for full-duplex devices
307 * @dummy_tx: dummy transmit buffer for full-duplex devices
302 * 308 *
303 * Each SPI master controller can communicate with one or more @spi_device 309 * Each SPI master controller can communicate with one or more @spi_device
304 * children. These make a small bus, sharing MOSI, MISO and SCK signals 310 * children. These make a small bus, sharing MOSI, MISO and SCK signals
@@ -632,6 +638,7 @@ struct spi_transfer {
632 * addresses for each transfer buffer 638 * addresses for each transfer buffer
633 * @complete: called to report transaction completions 639 * @complete: called to report transaction completions
634 * @context: the argument to complete() when it's called 640 * @context: the argument to complete() when it's called
641 * @frame_length: the total number of bytes in the message
635 * @actual_length: the total number of bytes that were transferred in all 642 * @actual_length: the total number of bytes that were transferred in all
636 * successful segments 643 * successful segments
637 * @status: zero for success, else negative errno 644 * @status: zero for success, else negative errno
diff --git a/drivers/staging/usbip/uapi/usbip.h b/include/uapi/linux/usbip.h
index fa5db30ede36..fa5db30ede36 100644
--- a/drivers/staging/usbip/uapi/usbip.h
+++ b/include/uapi/linux/usbip.h
diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
index c38355c1f3c9..1590c49cae57 100644
--- a/include/uapi/linux/xattr.h
+++ b/include/uapi/linux/xattr.h
@@ -13,7 +13,7 @@
13#ifndef _UAPI_LINUX_XATTR_H 13#ifndef _UAPI_LINUX_XATTR_H
14#define _UAPI_LINUX_XATTR_H 14#define _UAPI_LINUX_XATTR_H
15 15
16#ifdef __UAPI_DEF_XATTR 16#if __UAPI_DEF_XATTR
17#define __USE_KERNEL_XATTR_DEFS 17#define __USE_KERNEL_XATTR_DEFS
18 18
19#define XATTR_CREATE 0x1 /* set value, fail if attr already exists */ 19#define XATTR_CREATE 0x1 /* set value, fail if attr already exists */
diff --git a/kernel/kexec.c b/kernel/kexec.c
index 0b49a0a58102..2bee072268d9 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -64,7 +64,9 @@ bool kexec_in_progress = false;
64char __weak kexec_purgatory[0]; 64char __weak kexec_purgatory[0];
65size_t __weak kexec_purgatory_size = 0; 65size_t __weak kexec_purgatory_size = 0;
66 66
67#ifdef CONFIG_KEXEC_FILE
67static int kexec_calculate_store_digests(struct kimage *image); 68static int kexec_calculate_store_digests(struct kimage *image);
69#endif
68 70
69/* Location of the reserved area for the crash kernel */ 71/* Location of the reserved area for the crash kernel */
70struct resource crashk_res = { 72struct resource crashk_res = {
@@ -341,6 +343,7 @@ out_free_image:
341 return ret; 343 return ret;
342} 344}
343 345
346#ifdef CONFIG_KEXEC_FILE
344static int copy_file_from_fd(int fd, void **buf, unsigned long *buf_len) 347static int copy_file_from_fd(int fd, void **buf, unsigned long *buf_len)
345{ 348{
346 struct fd f = fdget(fd); 349 struct fd f = fdget(fd);
@@ -612,6 +615,9 @@ out_free_image:
612 kfree(image); 615 kfree(image);
613 return ret; 616 return ret;
614} 617}
618#else /* CONFIG_KEXEC_FILE */
619static inline void kimage_file_post_load_cleanup(struct kimage *image) { }
620#endif /* CONFIG_KEXEC_FILE */
615 621
616static int kimage_is_destination_range(struct kimage *image, 622static int kimage_is_destination_range(struct kimage *image,
617 unsigned long start, 623 unsigned long start,
@@ -1375,6 +1381,7 @@ COMPAT_SYSCALL_DEFINE4(kexec_load, compat_ulong_t, entry,
1375} 1381}
1376#endif 1382#endif
1377 1383
1384#ifdef CONFIG_KEXEC_FILE
1378SYSCALL_DEFINE5(kexec_file_load, int, kernel_fd, int, initrd_fd, 1385SYSCALL_DEFINE5(kexec_file_load, int, kernel_fd, int, initrd_fd,
1379 unsigned long, cmdline_len, const char __user *, cmdline_ptr, 1386 unsigned long, cmdline_len, const char __user *, cmdline_ptr,
1380 unsigned long, flags) 1387 unsigned long, flags)
@@ -1451,6 +1458,8 @@ out:
1451 return ret; 1458 return ret;
1452} 1459}
1453 1460
1461#endif /* CONFIG_KEXEC_FILE */
1462
1454void crash_kexec(struct pt_regs *regs) 1463void crash_kexec(struct pt_regs *regs)
1455{ 1464{
1456 /* Take the kexec_mutex here to prevent sys_kexec_load 1465 /* Take the kexec_mutex here to prevent sys_kexec_load
@@ -2006,6 +2015,7 @@ static int __init crash_save_vmcoreinfo_init(void)
2006 2015
2007subsys_initcall(crash_save_vmcoreinfo_init); 2016subsys_initcall(crash_save_vmcoreinfo_init);
2008 2017
2018#ifdef CONFIG_KEXEC_FILE
2009static int __kexec_add_segment(struct kimage *image, char *buf, 2019static int __kexec_add_segment(struct kimage *image, char *buf,
2010 unsigned long bufsz, unsigned long mem, 2020 unsigned long bufsz, unsigned long mem,
2011 unsigned long memsz) 2021 unsigned long memsz)
@@ -2682,6 +2692,7 @@ int kexec_purgatory_get_set_symbol(struct kimage *image, const char *name,
2682 2692
2683 return 0; 2693 return 0;
2684} 2694}
2695#endif /* CONFIG_KEXEC_FILE */
2685 2696
2686/* 2697/*
2687 * Move into place and start executing a preloaded standalone 2698 * Move into place and start executing a preloaded standalone
diff --git a/kernel/resource.c b/kernel/resource.c
index da14b8d09296..60c5a3856ab7 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -351,15 +351,12 @@ static int find_next_iomem_res(struct resource *res, char *name,
351 end = res->end; 351 end = res->end;
352 BUG_ON(start >= end); 352 BUG_ON(start >= end);
353 353
354 read_lock(&resource_lock); 354 if (first_level_children_only)
355
356 if (first_level_children_only) {
357 p = iomem_resource.child;
358 sibling_only = true; 355 sibling_only = true;
359 } else
360 p = &iomem_resource;
361 356
362 while ((p = next_resource(p, sibling_only))) { 357 read_lock(&resource_lock);
358
359 for (p = iomem_resource.child; p; p = next_resource(p, sibling_only)) {
363 if (p->flags != res->flags) 360 if (p->flags != res->flags)
364 continue; 361 continue;
365 if (name && strcmp(p->name, name)) 362 if (name && strcmp(p->name, name))
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index afb04b9b818a..b38fb2b9e237 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -626,8 +626,22 @@ int ring_buffer_poll_wait(struct ring_buffer *buffer, int cpu,
626 work = &cpu_buffer->irq_work; 626 work = &cpu_buffer->irq_work;
627 } 627 }
628 628
629 work->waiters_pending = true;
630 poll_wait(filp, &work->waiters, poll_table); 629 poll_wait(filp, &work->waiters, poll_table);
630 work->waiters_pending = true;
631 /*
632 * There's a tight race between setting the waiters_pending and
633 * checking if the ring buffer is empty. Once the waiters_pending bit
634 * is set, the next event will wake the task up, but we can get stuck
635 * if there's only a single event in.
636 *
637 * FIXME: Ideally, we need a memory barrier on the writer side as well,
638 * but adding a memory barrier to all events will cause too much of a
639 * performance hit in the fast path. We only need a memory barrier when
640 * the buffer goes from empty to having content. But as this race is
641 * extremely small, and it's not a problem if another event comes in, we
642 * will fix it later.
643 */
644 smp_mb();
631 645
632 if ((cpu == RING_BUFFER_ALL_CPUS && !ring_buffer_empty(buffer)) || 646 if ((cpu == RING_BUFFER_ALL_CPUS && !ring_buffer_empty(buffer)) ||
633 (cpu != RING_BUFFER_ALL_CPUS && !ring_buffer_empty_cpu(buffer, cpu))) 647 (cpu != RING_BUFFER_ALL_CPUS && !ring_buffer_empty_cpu(buffer, cpu)))
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 07c28323f88f..a28590083622 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -892,6 +892,10 @@ config DEBUG_WW_MUTEX_SLOWPATH
892 the full mutex checks enabled with (CONFIG_PROVE_LOCKING) this 892 the full mutex checks enabled with (CONFIG_PROVE_LOCKING) this
893 will test all possible w/w mutex interface abuse with the 893 will test all possible w/w mutex interface abuse with the
894 exception of simply not acquiring all the required locks. 894 exception of simply not acquiring all the required locks.
895 Note that this feature can introduce significant overhead, so
896 it really should not be enabled in a production or distro kernel,
897 even a debug kernel. If you are a driver writer, enable it. If
898 you are a distro, do not.
895 899
896config DEBUG_LOCK_ALLOC 900config DEBUG_LOCK_ALLOC
897 bool "Lock debugging: detect incorrect freeing of live locks" 901 bool "Lock debugging: detect incorrect freeing of live locks"
@@ -1032,8 +1036,13 @@ config TRACE_IRQFLAGS
1032 either tracing or lock debugging. 1036 either tracing or lock debugging.
1033 1037
1034config STACKTRACE 1038config STACKTRACE
1035 bool 1039 bool "Stack backtrace support"
1036 depends on STACKTRACE_SUPPORT 1040 depends on STACKTRACE_SUPPORT
1041 help
1042 This option causes the kernel to create a /proc/pid/stack for
1043 every process, showing its current stack trace.
1044 It is also used by various kernel debugging features that require
1045 stack trace generation.
1037 1046
1038config DEBUG_KOBJECT 1047config DEBUG_KOBJECT
1039 bool "kobject debugging" 1048 bool "kobject debugging"
diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c
index 9eebfadeeee1..a67c26e0f360 100644
--- a/mm/hugetlb_cgroup.c
+++ b/mm/hugetlb_cgroup.c
@@ -217,7 +217,7 @@ void hugetlb_cgroup_uncharge_page(int idx, unsigned long nr_pages,
217 217
218 if (hugetlb_cgroup_disabled()) 218 if (hugetlb_cgroup_disabled())
219 return; 219 return;
220 VM_BUG_ON(!spin_is_locked(&hugetlb_lock)); 220 lockdep_assert_held(&hugetlb_lock);
221 h_cg = hugetlb_cgroup_from_page(page); 221 h_cg = hugetlb_cgroup_from_page(page);
222 if (unlikely(!h_cg)) 222 if (unlikely(!h_cg))
223 return; 223 return;
diff --git a/mm/memblock.c b/mm/memblock.c
index 6d2f219a48b0..70fad0c0dafb 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -192,8 +192,7 @@ phys_addr_t __init_memblock memblock_find_in_range_node(phys_addr_t size,
192 phys_addr_t align, phys_addr_t start, 192 phys_addr_t align, phys_addr_t start,
193 phys_addr_t end, int nid) 193 phys_addr_t end, int nid)
194{ 194{
195 int ret; 195 phys_addr_t kernel_end, ret;
196 phys_addr_t kernel_end;
197 196
198 /* pump up @end */ 197 /* pump up @end */
199 if (end == MEMBLOCK_ALLOC_ACCESSIBLE) 198 if (end == MEMBLOCK_ALLOC_ACCESSIBLE)
diff --git a/mm/memory.c b/mm/memory.c
index ab3537bcfed2..adeac306610f 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -751,7 +751,7 @@ struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
751 unsigned long pfn = pte_pfn(pte); 751 unsigned long pfn = pte_pfn(pte);
752 752
753 if (HAVE_PTE_SPECIAL) { 753 if (HAVE_PTE_SPECIAL) {
754 if (likely(!pte_special(pte) || pte_numa(pte))) 754 if (likely(!pte_special(pte)))
755 goto check_pfn; 755 goto check_pfn;
756 if (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP)) 756 if (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP))
757 return NULL; 757 return NULL;
@@ -777,15 +777,14 @@ struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
777 } 777 }
778 } 778 }
779 779
780 if (is_zero_pfn(pfn))
781 return NULL;
780check_pfn: 782check_pfn:
781 if (unlikely(pfn > highest_memmap_pfn)) { 783 if (unlikely(pfn > highest_memmap_pfn)) {
782 print_bad_pte(vma, addr, pte, NULL); 784 print_bad_pte(vma, addr, pte, NULL);
783 return NULL; 785 return NULL;
784 } 786 }
785 787
786 if (is_zero_pfn(pfn))
787 return NULL;
788
789 /* 788 /*
790 * NOTE! We still have PageReserved() pages in the page tables. 789 * NOTE! We still have PageReserved() pages in the page tables.
791 * eg. VDSO mappings can cause them to exist. 790 * eg. VDSO mappings can cause them to exist.
diff --git a/mm/pgtable-generic.c b/mm/pgtable-generic.c
index a8b919925934..dfb79e028ecb 100644
--- a/mm/pgtable-generic.c
+++ b/mm/pgtable-generic.c
@@ -195,7 +195,7 @@ void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address,
195 pmd_t entry = *pmdp; 195 pmd_t entry = *pmdp;
196 if (pmd_numa(entry)) 196 if (pmd_numa(entry))
197 entry = pmd_mknonnuma(entry); 197 entry = pmd_mknonnuma(entry);
198 set_pmd_at(vma->vm_mm, address, pmdp, pmd_mknotpresent(*pmdp)); 198 set_pmd_at(vma->vm_mm, address, pmdp, pmd_mknotpresent(entry));
199 flush_tlb_range(vma, address, address + HPAGE_PMD_SIZE); 199 flush_tlb_range(vma, address, address + HPAGE_PMD_SIZE);
200} 200}
201#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ 201#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
diff --git a/mm/zbud.c b/mm/zbud.c
index a05790b1915e..f26e7fcc7fa2 100644
--- a/mm/zbud.c
+++ b/mm/zbud.c
@@ -195,6 +195,7 @@ static struct zpool_driver zbud_zpool_driver = {
195 .total_size = zbud_zpool_total_size, 195 .total_size = zbud_zpool_total_size,
196}; 196};
197 197
198MODULE_ALIAS("zpool-zbud");
198#endif /* CONFIG_ZPOOL */ 199#endif /* CONFIG_ZPOOL */
199 200
200/***************** 201/*****************
diff --git a/mm/zpool.c b/mm/zpool.c
index e40612a1df00..739cdf0d183a 100644
--- a/mm/zpool.c
+++ b/mm/zpool.c
@@ -150,7 +150,7 @@ struct zpool *zpool_create_pool(char *type, gfp_t gfp, struct zpool_ops *ops)
150 driver = zpool_get_driver(type); 150 driver = zpool_get_driver(type);
151 151
152 if (!driver) { 152 if (!driver) {
153 request_module(type); 153 request_module("zpool-%s", type);
154 driver = zpool_get_driver(type); 154 driver = zpool_get_driver(type);
155 } 155 }
156 156
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 4e2fc83cb394..94f38fac5e81 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -315,6 +315,7 @@ static struct zpool_driver zs_zpool_driver = {
315 .total_size = zs_zpool_total_size, 315 .total_size = zs_zpool_total_size,
316}; 316};
317 317
318MODULE_ALIAS("zpool-zsmalloc");
318#endif /* CONFIG_ZPOOL */ 319#endif /* CONFIG_ZPOOL */
319 320
320/* per-cpu VM mapping areas for zspage accesses that cross page boundaries */ 321/* per-cpu VM mapping areas for zspage accesses that cross page boundaries */
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 31a731e06f50..b385bcbbf2f5 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2133,7 +2133,7 @@ sub process {
2133# Check for improperly formed commit descriptions 2133# Check for improperly formed commit descriptions
2134 if ($in_commit_log && 2134 if ($in_commit_log &&
2135 $line =~ /\bcommit\s+[0-9a-f]{5,}/i && 2135 $line =~ /\bcommit\s+[0-9a-f]{5,}/i &&
2136 $line !~ /\b[Cc]ommit [0-9a-f]{12,16} \("/) { 2136 $line !~ /\b[Cc]ommit [0-9a-f]{12,40} \("/) {
2137 $line =~ /\b(c)ommit\s+([0-9a-f]{5,})/i; 2137 $line =~ /\b(c)ommit\s+([0-9a-f]{5,})/i;
2138 my $init_char = $1; 2138 my $init_char = $1;
2139 my $orig_commit = lc($2); 2139 my $orig_commit = lc($2);
@@ -2141,7 +2141,7 @@ sub process {
2141 my $desc = 'commit description'; 2141 my $desc = 'commit description';
2142 ($id, $desc) = git_commit_info($orig_commit, $id, $desc); 2142 ($id, $desc) = git_commit_info($orig_commit, $id, $desc);
2143 ERROR("GIT_COMMIT_ID", 2143 ERROR("GIT_COMMIT_ID",
2144 "Please use 12 to 16 chars for the git commit ID like: '${init_char}ommit $id (\"$desc\")'\n" . $herecurr); 2144 "Please use 12 or more chars for the git commit ID like: '${init_char}ommit $id (\"$desc\")'\n" . $herecurr);
2145 } 2145 }
2146 2146
2147# Check for added, moved or deleted files 2147# Check for added, moved or deleted files
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 16a07cfa4d34..70bea942b413 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -2085,6 +2085,7 @@ sub dump_function($$) {
2085 $prototype =~ s/^noinline +//; 2085 $prototype =~ s/^noinline +//;
2086 $prototype =~ s/__init +//; 2086 $prototype =~ s/__init +//;
2087 $prototype =~ s/__init_or_module +//; 2087 $prototype =~ s/__init_or_module +//;
2088 $prototype =~ s/__meminit +//;
2088 $prototype =~ s/__must_check +//; 2089 $prototype =~ s/__must_check +//;
2089 $prototype =~ s/__weak +//; 2090 $prototype =~ s/__weak +//;
2090 my $define = $prototype =~ s/^#\s*define\s+//; #ak added 2091 my $define = $prototype =~ s/^#\s*define\s+//; #ak added
diff --git a/security/tomoyo/realpath.c b/security/tomoyo/realpath.c
index a3386d119425..bed745c8b1a3 100644
--- a/security/tomoyo/realpath.c
+++ b/security/tomoyo/realpath.c
@@ -173,7 +173,7 @@ static char *tomoyo_get_local_path(struct dentry *dentry, char * const buffer,
173 * Use filesystem name if filesystem does not support rename() 173 * Use filesystem name if filesystem does not support rename()
174 * operation. 174 * operation.
175 */ 175 */
176 if (!inode->i_op->rename) 176 if (!inode->i_op->rename && !inode->i_op->rename2)
177 goto prepend_filesystem_name; 177 goto prepend_filesystem_name;
178 } 178 }
179 /* Prepend device name. */ 179 /* Prepend device name. */
@@ -282,7 +282,8 @@ char *tomoyo_realpath_from_path(struct path *path)
282 * Get local name for filesystems without rename() operation 282 * Get local name for filesystems without rename() operation
283 * or dentry without vfsmount. 283 * or dentry without vfsmount.
284 */ 284 */
285 if (!path->mnt || !inode->i_op->rename) 285 if (!path->mnt ||
286 (!inode->i_op->rename && !inode->i_op->rename2))
286 pos = tomoyo_get_local_path(path->dentry, buf, 287 pos = tomoyo_get_local_path(path->dentry, buf,
287 buf_len - 1); 288 buf_len - 1);
288 /* Get absolute name for the rest. */ 289 /* Get absolute name for the rest. */
diff --git a/sound/core/info.c b/sound/core/info.c
index 051d55b05521..9f404e965ea2 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -684,7 +684,7 @@ int snd_info_card_free(struct snd_card *card)
684 * snd_info_get_line - read one line from the procfs buffer 684 * snd_info_get_line - read one line from the procfs buffer
685 * @buffer: the procfs buffer 685 * @buffer: the procfs buffer
686 * @line: the buffer to store 686 * @line: the buffer to store
687 * @len: the max. buffer size - 1 687 * @len: the max. buffer size
688 * 688 *
689 * Reads one line from the buffer and stores the string. 689 * Reads one line from the buffer and stores the string.
690 * 690 *
@@ -704,7 +704,7 @@ int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len)
704 buffer->stop = 1; 704 buffer->stop = 1;
705 if (c == '\n') 705 if (c == '\n')
706 break; 706 break;
707 if (len) { 707 if (len > 1) {
708 len--; 708 len--;
709 *line++ = c; 709 *line++ = c;
710 } 710 }
diff --git a/sound/core/pcm_misc.c b/sound/core/pcm_misc.c
index 4560ca0e5651..2c6fd80e0bd1 100644
--- a/sound/core/pcm_misc.c
+++ b/sound/core/pcm_misc.c
@@ -142,11 +142,11 @@ static struct pcm_format_data pcm_formats[(INT)SNDRV_PCM_FORMAT_LAST+1] = {
142 }, 142 },
143 [SNDRV_PCM_FORMAT_DSD_U8] = { 143 [SNDRV_PCM_FORMAT_DSD_U8] = {
144 .width = 8, .phys = 8, .le = 1, .signd = 0, 144 .width = 8, .phys = 8, .le = 1, .signd = 0,
145 .silence = {}, 145 .silence = { 0x69 },
146 }, 146 },
147 [SNDRV_PCM_FORMAT_DSD_U16_LE] = { 147 [SNDRV_PCM_FORMAT_DSD_U16_LE] = {
148 .width = 16, .phys = 16, .le = 1, .signd = 0, 148 .width = 16, .phys = 16, .le = 1, .signd = 0,
149 .silence = {}, 149 .silence = { 0x69, 0x69 },
150 }, 150 },
151 /* FIXME: the following three formats are not defined properly yet */ 151 /* FIXME: the following three formats are not defined properly yet */
152 [SNDRV_PCM_FORMAT_MPEG] = { 152 [SNDRV_PCM_FORMAT_MPEG] = {
diff --git a/sound/pci/ctxfi/ct20k1reg.h b/sound/pci/ctxfi/ct20k1reg.h
index f2e34e3f27ee..5851249f11d9 100644
--- a/sound/pci/ctxfi/ct20k1reg.h
+++ b/sound/pci/ctxfi/ct20k1reg.h
@@ -7,7 +7,7 @@
7 */ 7 */
8 8
9#ifndef CT20K1REG_H 9#ifndef CT20K1REG_H
10#define CT20k1REG_H 10#define CT20K1REG_H
11 11
12/* 20k1 registers */ 12/* 20k1 registers */
13#define DSPXRAM_START 0x000000 13#define DSPXRAM_START 0x000000
@@ -632,5 +632,3 @@
632#define I2SD_R 0x19L 632#define I2SD_R 0x19L
633 633
634#endif /* CT20K1REG_H */ 634#endif /* CT20K1REG_H */
635
636
diff --git a/sound/pci/hda/ca0132_regs.h b/sound/pci/hda/ca0132_regs.h
index 07e760937d3c..8371274aa811 100644
--- a/sound/pci/hda/ca0132_regs.h
+++ b/sound/pci/hda/ca0132_regs.h
@@ -20,7 +20,7 @@
20 */ 20 */
21 21
22#ifndef __CA0132_REGS_H 22#ifndef __CA0132_REGS_H
23#define __CA0312_REGS_H 23#define __CA0132_REGS_H
24 24
25#define DSP_CHIP_OFFSET 0x100000 25#define DSP_CHIP_OFFSET 0x100000
26#define DSP_DBGCNTL_MODULE_OFFSET 0xE30 26#define DSP_DBGCNTL_MODULE_OFFSET 0xE30
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index d71270a3f73f..d446ac3137b3 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -4408,6 +4408,7 @@ enum {
4408 ALC292_FIXUP_TPT440_DOCK, 4408 ALC292_FIXUP_TPT440_DOCK,
4409 ALC283_FIXUP_BXBT2807_MIC, 4409 ALC283_FIXUP_BXBT2807_MIC,
4410 ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED, 4410 ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED,
4411 ALC282_FIXUP_ASPIRE_V5_PINS,
4411}; 4412};
4412 4413
4413static const struct hda_fixup alc269_fixups[] = { 4414static const struct hda_fixup alc269_fixups[] = {
@@ -4855,6 +4856,22 @@ static const struct hda_fixup alc269_fixups[] = {
4855 .chained_before = true, 4856 .chained_before = true,
4856 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE 4857 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
4857 }, 4858 },
4859 [ALC282_FIXUP_ASPIRE_V5_PINS] = {
4860 .type = HDA_FIXUP_PINS,
4861 .v.pins = (const struct hda_pintbl[]) {
4862 { 0x12, 0x90a60130 },
4863 { 0x14, 0x90170110 },
4864 { 0x17, 0x40000008 },
4865 { 0x18, 0x411111f0 },
4866 { 0x19, 0x411111f0 },
4867 { 0x1a, 0x411111f0 },
4868 { 0x1b, 0x411111f0 },
4869 { 0x1d, 0x40f89b2d },
4870 { 0x1e, 0x411111f0 },
4871 { 0x21, 0x0321101f },
4872 { },
4873 },
4874 },
4858 4875
4859}; 4876};
4860 4877
@@ -4866,6 +4883,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4866 SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK), 4883 SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK),
4867 SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK), 4884 SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK),
4868 SND_PCI_QUIRK(0x1025, 0x0775, "Acer Aspire E1-572", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572), 4885 SND_PCI_QUIRK(0x1025, 0x0775, "Acer Aspire E1-572", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
4886 SND_PCI_QUIRK(0x1025, 0x079b, "Acer Aspire V5-573G", ALC282_FIXUP_ASPIRE_V5_PINS),
4869 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), 4887 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
4870 SND_PCI_QUIRK(0x1028, 0x05bd, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 4888 SND_PCI_QUIRK(0x1028, 0x05bd, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
4871 SND_PCI_QUIRK(0x1028, 0x05be, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 4889 SND_PCI_QUIRK(0x1028, 0x05be, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
diff --git a/tools/testing/selftests/ipc/Makefile b/tools/testing/selftests/ipc/Makefile
index 5386fd7c43ae..74bbefdeaf4c 100644
--- a/tools/testing/selftests/ipc/Makefile
+++ b/tools/testing/selftests/ipc/Makefile
@@ -1,18 +1,18 @@
1uname_M := $(shell uname -m 2>/dev/null || echo not) 1uname_M := $(shell uname -m 2>/dev/null || echo not)
2ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/) 2ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/)
3ifeq ($(ARCH),i386) 3ifeq ($(ARCH),i386)
4 ARCH := X86 4 ARCH := x86
5 CFLAGS := -DCONFIG_X86_32 -D__i386__ 5 CFLAGS := -DCONFIG_X86_32 -D__i386__
6endif 6endif
7ifeq ($(ARCH),x86_64) 7ifeq ($(ARCH),x86_64)
8 ARCH := X86 8 ARCH := x86
9 CFLAGS := -DCONFIG_X86_64 -D__x86_64__ 9 CFLAGS := -DCONFIG_X86_64 -D__x86_64__
10endif 10endif
11 11
12CFLAGS += -I../../../../usr/include/ 12CFLAGS += -I../../../../usr/include/
13 13
14all: 14all:
15ifeq ($(ARCH),X86) 15ifeq ($(ARCH),x86)
16 gcc $(CFLAGS) msgque.c -o msgque_test 16 gcc $(CFLAGS) msgque.c -o msgque_test
17else 17else
18 echo "Not an x86 target, can't build msgque selftest" 18 echo "Not an x86 target, can't build msgque selftest"
diff --git a/tools/testing/selftests/kcmp/Makefile b/tools/testing/selftests/kcmp/Makefile
index d7d6bbeeff2f..8aabd82db9e4 100644
--- a/tools/testing/selftests/kcmp/Makefile
+++ b/tools/testing/selftests/kcmp/Makefile
@@ -1,11 +1,11 @@
1uname_M := $(shell uname -m 2>/dev/null || echo not) 1uname_M := $(shell uname -m 2>/dev/null || echo not)
2ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/) 2ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/)
3ifeq ($(ARCH),i386) 3ifeq ($(ARCH),i386)
4 ARCH := X86 4 ARCH := x86
5 CFLAGS := -DCONFIG_X86_32 -D__i386__ 5 CFLAGS := -DCONFIG_X86_32 -D__i386__
6endif 6endif
7ifeq ($(ARCH),x86_64) 7ifeq ($(ARCH),x86_64)
8 ARCH := X86 8 ARCH := x86
9 CFLAGS := -DCONFIG_X86_64 -D__x86_64__ 9 CFLAGS := -DCONFIG_X86_64 -D__x86_64__
10endif 10endif
11 11
@@ -15,7 +15,7 @@ CFLAGS += -I../../../../usr/include/
15CFLAGS += -I../../../../arch/x86/include/ 15CFLAGS += -I../../../../arch/x86/include/
16 16
17all: 17all:
18ifeq ($(ARCH),X86) 18ifeq ($(ARCH),x86)
19 gcc $(CFLAGS) kcmp_test.c -o kcmp_test 19 gcc $(CFLAGS) kcmp_test.c -o kcmp_test
20else 20else
21 echo "Not an x86 target, can't build kcmp selftest" 21 echo "Not an x86 target, can't build kcmp selftest"
diff --git a/tools/testing/selftests/memfd/Makefile b/tools/testing/selftests/memfd/Makefile
index 6816c491c5ff..ad4ab01cd28f 100644
--- a/tools/testing/selftests/memfd/Makefile
+++ b/tools/testing/selftests/memfd/Makefile
@@ -1,10 +1,10 @@
1uname_M := $(shell uname -m 2>/dev/null || echo not) 1uname_M := $(shell uname -m 2>/dev/null || echo not)
2ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/) 2ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/)
3ifeq ($(ARCH),i386) 3ifeq ($(ARCH),i386)
4 ARCH := X86 4 ARCH := x86
5endif 5endif
6ifeq ($(ARCH),x86_64) 6ifeq ($(ARCH),x86_64)
7 ARCH := X86 7 ARCH := x86
8endif 8endif
9 9
10CFLAGS += -D_FILE_OFFSET_BITS=64 10CFLAGS += -D_FILE_OFFSET_BITS=64
@@ -14,20 +14,20 @@ CFLAGS += -I../../../../include/uapi/
14CFLAGS += -I../../../../include/ 14CFLAGS += -I../../../../include/
15 15
16all: 16all:
17ifeq ($(ARCH),X86) 17ifeq ($(ARCH),x86)
18 gcc $(CFLAGS) memfd_test.c -o memfd_test 18 gcc $(CFLAGS) memfd_test.c -o memfd_test
19else 19else
20 echo "Not an x86 target, can't build memfd selftest" 20 echo "Not an x86 target, can't build memfd selftest"
21endif 21endif
22 22
23run_tests: all 23run_tests: all
24ifeq ($(ARCH),X86) 24ifeq ($(ARCH),x86)
25 gcc $(CFLAGS) memfd_test.c -o memfd_test 25 gcc $(CFLAGS) memfd_test.c -o memfd_test
26endif 26endif
27 @./memfd_test || echo "memfd_test: [FAIL]" 27 @./memfd_test || echo "memfd_test: [FAIL]"
28 28
29build_fuse: 29build_fuse:
30ifeq ($(ARCH),X86) 30ifeq ($(ARCH),x86)
31 gcc $(CFLAGS) fuse_mnt.c `pkg-config fuse --cflags --libs` -o fuse_mnt 31 gcc $(CFLAGS) fuse_mnt.c `pkg-config fuse --cflags --libs` -o fuse_mnt
32 gcc $(CFLAGS) fuse_test.c -o fuse_test 32 gcc $(CFLAGS) fuse_test.c -o fuse_test
33else 33else
diff --git a/drivers/staging/usbip/userspace/.gitignore b/tools/usb/usbip/.gitignore
index 9aad9e30a8ba..9aad9e30a8ba 100644
--- a/drivers/staging/usbip/userspace/.gitignore
+++ b/tools/usb/usbip/.gitignore
diff --git a/drivers/staging/usbip/userspace/AUTHORS b/tools/usb/usbip/AUTHORS
index a27ea8d03aec..a27ea8d03aec 100644
--- a/drivers/staging/usbip/userspace/AUTHORS
+++ b/tools/usb/usbip/AUTHORS
diff --git a/drivers/staging/usbip/userspace/COPYING b/tools/usb/usbip/COPYING
index c5611e48a8e1..c5611e48a8e1 100644
--- a/drivers/staging/usbip/userspace/COPYING
+++ b/tools/usb/usbip/COPYING
diff --git a/drivers/staging/usbip/userspace/INSTALL b/tools/usb/usbip/INSTALL
index d3c5b40a9409..d3c5b40a9409 100644
--- a/drivers/staging/usbip/userspace/INSTALL
+++ b/tools/usb/usbip/INSTALL
diff --git a/drivers/staging/usbip/userspace/Makefile.am b/tools/usb/usbip/Makefile.am
index 66f8bf038c9f..66f8bf038c9f 100644
--- a/drivers/staging/usbip/userspace/Makefile.am
+++ b/tools/usb/usbip/Makefile.am
diff --git a/drivers/staging/usbip/userspace/README b/tools/usb/usbip/README
index 831f49fea3ce..831f49fea3ce 100644
--- a/drivers/staging/usbip/userspace/README
+++ b/tools/usb/usbip/README
diff --git a/drivers/staging/usbip/userspace/autogen.sh b/tools/usb/usbip/autogen.sh
index e1112d3fcbf6..e1112d3fcbf6 100755
--- a/drivers/staging/usbip/userspace/autogen.sh
+++ b/tools/usb/usbip/autogen.sh
diff --git a/drivers/staging/usbip/userspace/cleanup.sh b/tools/usb/usbip/cleanup.sh
index 955c3ccb729a..955c3ccb729a 100755
--- a/drivers/staging/usbip/userspace/cleanup.sh
+++ b/tools/usb/usbip/cleanup.sh
diff --git a/drivers/staging/usbip/userspace/configure.ac b/tools/usb/usbip/configure.ac
index 607d05c5ccfd..607d05c5ccfd 100644
--- a/drivers/staging/usbip/userspace/configure.ac
+++ b/tools/usb/usbip/configure.ac
diff --git a/drivers/staging/usbip/userspace/doc/usbip.8 b/tools/usb/usbip/doc/usbip.8
index a6097be25d28..a6097be25d28 100644
--- a/drivers/staging/usbip/userspace/doc/usbip.8
+++ b/tools/usb/usbip/doc/usbip.8
diff --git a/drivers/staging/usbip/userspace/doc/usbipd.8 b/tools/usb/usbip/doc/usbipd.8
index ac4635db3f03..ac4635db3f03 100644
--- a/drivers/staging/usbip/userspace/doc/usbipd.8
+++ b/tools/usb/usbip/doc/usbipd.8
diff --git a/drivers/staging/usbip/userspace/libsrc/Makefile.am b/tools/usb/usbip/libsrc/Makefile.am
index 7c8f8a4d54e4..7c8f8a4d54e4 100644
--- a/drivers/staging/usbip/userspace/libsrc/Makefile.am
+++ b/tools/usb/usbip/libsrc/Makefile.am
diff --git a/drivers/staging/usbip/userspace/libsrc/list.h b/tools/usb/usbip/libsrc/list.h
index 8d0c936e184f..8d0c936e184f 100644
--- a/drivers/staging/usbip/userspace/libsrc/list.h
+++ b/tools/usb/usbip/libsrc/list.h
diff --git a/drivers/staging/usbip/userspace/libsrc/names.c b/tools/usb/usbip/libsrc/names.c
index 81ff8522405c..81ff8522405c 100644
--- a/drivers/staging/usbip/userspace/libsrc/names.c
+++ b/tools/usb/usbip/libsrc/names.c
diff --git a/drivers/staging/usbip/userspace/libsrc/names.h b/tools/usb/usbip/libsrc/names.h
index 680926512de2..680926512de2 100644
--- a/drivers/staging/usbip/userspace/libsrc/names.h
+++ b/tools/usb/usbip/libsrc/names.h
diff --git a/drivers/staging/usbip/userspace/libsrc/sysfs_utils.c b/tools/usb/usbip/libsrc/sysfs_utils.c
index 36ac88ece0b8..36ac88ece0b8 100644
--- a/drivers/staging/usbip/userspace/libsrc/sysfs_utils.c
+++ b/tools/usb/usbip/libsrc/sysfs_utils.c
diff --git a/drivers/staging/usbip/userspace/libsrc/sysfs_utils.h b/tools/usb/usbip/libsrc/sysfs_utils.h
index 32ac1d105d18..32ac1d105d18 100644
--- a/drivers/staging/usbip/userspace/libsrc/sysfs_utils.h
+++ b/tools/usb/usbip/libsrc/sysfs_utils.h
diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.c b/tools/usb/usbip/libsrc/usbip_common.c
index ac73710473de..ac73710473de 100644
--- a/drivers/staging/usbip/userspace/libsrc/usbip_common.c
+++ b/tools/usb/usbip/libsrc/usbip_common.c
diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.h b/tools/usb/usbip/libsrc/usbip_common.h
index 5a0e95edf4df..5a0e95edf4df 100644
--- a/drivers/staging/usbip/userspace/libsrc/usbip_common.h
+++ b/tools/usb/usbip/libsrc/usbip_common.h
diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_host_driver.c b/tools/usb/usbip/libsrc/usbip_host_driver.c
index bef08d5c44e8..bef08d5c44e8 100644
--- a/drivers/staging/usbip/userspace/libsrc/usbip_host_driver.c
+++ b/tools/usb/usbip/libsrc/usbip_host_driver.c
diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_host_driver.h b/tools/usb/usbip/libsrc/usbip_host_driver.h
index 2a31f855c616..2a31f855c616 100644
--- a/drivers/staging/usbip/userspace/libsrc/usbip_host_driver.h
+++ b/tools/usb/usbip/libsrc/usbip_host_driver.h
diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c b/tools/usb/usbip/libsrc/vhci_driver.c
index ad9204773533..ad9204773533 100644
--- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
+++ b/tools/usb/usbip/libsrc/vhci_driver.c
diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.h b/tools/usb/usbip/libsrc/vhci_driver.h
index fa2316cf2cac..fa2316cf2cac 100644
--- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
+++ b/tools/usb/usbip/libsrc/vhci_driver.h
diff --git a/drivers/staging/usbip/userspace/src/Makefile.am b/tools/usb/usbip/src/Makefile.am
index e81a4ebadeff..e81a4ebadeff 100644
--- a/drivers/staging/usbip/userspace/src/Makefile.am
+++ b/tools/usb/usbip/src/Makefile.am
diff --git a/drivers/staging/usbip/userspace/src/usbip.c b/tools/usb/usbip/src/usbip.c
index d7599d943529..d7599d943529 100644
--- a/drivers/staging/usbip/userspace/src/usbip.c
+++ b/tools/usb/usbip/src/usbip.c
diff --git a/drivers/staging/usbip/userspace/src/usbip.h b/tools/usb/usbip/src/usbip.h
index 84fe66a9d8ad..84fe66a9d8ad 100644
--- a/drivers/staging/usbip/userspace/src/usbip.h
+++ b/tools/usb/usbip/src/usbip.h
diff --git a/drivers/staging/usbip/userspace/src/usbip_attach.c b/tools/usb/usbip/src/usbip_attach.c
index d58a14dfc094..d58a14dfc094 100644
--- a/drivers/staging/usbip/userspace/src/usbip_attach.c
+++ b/tools/usb/usbip/src/usbip_attach.c
diff --git a/drivers/staging/usbip/userspace/src/usbip_bind.c b/tools/usb/usbip/src/usbip_bind.c
index fa46141ae68b..fa46141ae68b 100644
--- a/drivers/staging/usbip/userspace/src/usbip_bind.c
+++ b/tools/usb/usbip/src/usbip_bind.c
diff --git a/drivers/staging/usbip/userspace/src/usbip_detach.c b/tools/usb/usbip/src/usbip_detach.c
index 05c6d15856eb..05c6d15856eb 100644
--- a/drivers/staging/usbip/userspace/src/usbip_detach.c
+++ b/tools/usb/usbip/src/usbip_detach.c
diff --git a/drivers/staging/usbip/userspace/src/usbip_list.c b/tools/usb/usbip/src/usbip_list.c
index d5ce34a410e7..d5ce34a410e7 100644
--- a/drivers/staging/usbip/userspace/src/usbip_list.c
+++ b/tools/usb/usbip/src/usbip_list.c
diff --git a/drivers/staging/usbip/userspace/src/usbip_network.c b/tools/usb/usbip/src/usbip_network.c
index b4c37e76a6e0..b4c37e76a6e0 100644
--- a/drivers/staging/usbip/userspace/src/usbip_network.c
+++ b/tools/usb/usbip/src/usbip_network.c
diff --git a/drivers/staging/usbip/userspace/src/usbip_network.h b/tools/usb/usbip/src/usbip_network.h
index c1e875cf1078..c1e875cf1078 100644
--- a/drivers/staging/usbip/userspace/src/usbip_network.h
+++ b/tools/usb/usbip/src/usbip_network.h
diff --git a/drivers/staging/usbip/userspace/src/usbip_port.c b/tools/usb/usbip/src/usbip_port.c
index a2e884fd9226..a2e884fd9226 100644
--- a/drivers/staging/usbip/userspace/src/usbip_port.c
+++ b/tools/usb/usbip/src/usbip_port.c
diff --git a/drivers/staging/usbip/userspace/src/usbip_unbind.c b/tools/usb/usbip/src/usbip_unbind.c
index a4a496c9cbaf..a4a496c9cbaf 100644
--- a/drivers/staging/usbip/userspace/src/usbip_unbind.c
+++ b/tools/usb/usbip/src/usbip_unbind.c
diff --git a/drivers/staging/usbip/userspace/src/usbipd.c b/tools/usb/usbip/src/usbipd.c
index 2f87f2d348ba..2f87f2d348ba 100644
--- a/drivers/staging/usbip/userspace/src/usbipd.c
+++ b/tools/usb/usbip/src/usbipd.c
diff --git a/drivers/staging/usbip/userspace/src/utils.c b/tools/usb/usbip/src/utils.c
index 2b3d6d235015..2b3d6d235015 100644
--- a/drivers/staging/usbip/userspace/src/utils.c
+++ b/tools/usb/usbip/src/utils.c
diff --git a/drivers/staging/usbip/userspace/src/utils.h b/tools/usb/usbip/src/utils.h
index 5916fd3e02a6..5916fd3e02a6 100644
--- a/drivers/staging/usbip/userspace/src/utils.h
+++ b/tools/usb/usbip/src/utils.h